Skip to content

Commit 432599d

Browse files
committed
Merge branch 'bnxt_en-fixes'
Michael Chan says: ==================== bnxt_en: Bug fixes. Miscellaneous small bug fixes. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 49a496c + 4bb6cdc commit 432599d

File tree

3 files changed

+64
-30
lines changed

3 files changed

+64
-30
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,8 +1292,6 @@ static inline int bnxt_has_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
12921292
return TX_CMP_VALID(txcmp, raw_cons);
12931293
}
12941294

1295-
#define CAG_LEGACY_INT_STATUS 0x2014
1296-
12971295
static irqreturn_t bnxt_inta(int irq, void *dev_instance)
12981296
{
12991297
struct bnxt_napi *bnapi = dev_instance;
@@ -1305,7 +1303,7 @@ static irqreturn_t bnxt_inta(int irq, void *dev_instance)
13051303
prefetch(&cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]);
13061304

13071305
if (!bnxt_has_work(bp, cpr)) {
1308-
int_status = readl(bp->bar0 + CAG_LEGACY_INT_STATUS);
1306+
int_status = readl(bp->bar0 + BNXT_CAG_REG_LEGACY_INT_STATUS);
13091307
/* return if erroneous interrupt */
13101308
if (!(int_status & (0x10000 << cpr->cp_ring_struct.fw_ring_id)))
13111309
return IRQ_NONE;
@@ -4527,10 +4525,25 @@ static int bnxt_update_phy_setting(struct bnxt *bp)
45274525
return rc;
45284526
}
45294527

4528+
/* Common routine to pre-map certain register block to different GRC window.
4529+
* A PF has 16 4K windows and a VF has 4 4K windows. However, only 15 windows
4530+
* in PF and 3 windows in VF that can be customized to map in different
4531+
* register blocks.
4532+
*/
4533+
static void bnxt_preset_reg_win(struct bnxt *bp)
4534+
{
4535+
if (BNXT_PF(bp)) {
4536+
/* CAG registers map to GRC window #4 */
4537+
writel(BNXT_CAG_REG_BASE,
4538+
bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 12);
4539+
}
4540+
}
4541+
45304542
static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
45314543
{
45324544
int rc = 0;
45334545

4546+
bnxt_preset_reg_win(bp);
45344547
netif_carrier_off(bp->dev);
45354548
if (irq_re_init) {
45364549
rc = bnxt_setup_int_mode(bp);
@@ -5294,7 +5307,7 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
52945307
struct bnxt_ntuple_filter *fltr, *new_fltr;
52955308
struct flow_keys *fkeys;
52965309
struct ethhdr *eth = (struct ethhdr *)skb_mac_header(skb);
5297-
int rc = 0, idx;
5310+
int rc = 0, idx, bit_id;
52985311
struct hlist_head *head;
52995312

53005313
if (skb->encapsulation)
@@ -5332,14 +5345,15 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
53325345
rcu_read_unlock();
53335346

53345347
spin_lock_bh(&bp->ntp_fltr_lock);
5335-
new_fltr->sw_id = bitmap_find_free_region(bp->ntp_fltr_bmap,
5336-
BNXT_NTP_FLTR_MAX_FLTR, 0);
5337-
if (new_fltr->sw_id < 0) {
5348+
bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap,
5349+
BNXT_NTP_FLTR_MAX_FLTR, 0);
5350+
if (bit_id < 0) {
53385351
spin_unlock_bh(&bp->ntp_fltr_lock);
53395352
rc = -ENOMEM;
53405353
goto err_free;
53415354
}
53425355

5356+
new_fltr->sw_id = (u16)bit_id;
53435357
new_fltr->flow_id = flow_id;
53445358
new_fltr->rxq = rxq_index;
53455359
hlist_add_head_rcu(&new_fltr->hash, head);

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,11 @@ struct rx_cmp {
166166
#define RX_CMP_HASH_VALID(rxcmp) \
167167
((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID))
168168

169+
#define RSS_PROFILE_ID_MASK 0x1f
170+
169171
#define RX_CMP_HASH_TYPE(rxcmp) \
170-
((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_RSS_HASH_TYPE) >>\
171-
RX_CMP_RSS_HASH_TYPE_SHIFT)
172+
(((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_RSS_HASH_TYPE) >>\
173+
RX_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
172174

173175
struct rx_cmp_ext {
174176
__le32 rx_cmp_flags2;
@@ -282,9 +284,9 @@ struct rx_tpa_start_cmp {
282284
cpu_to_le32(RX_TPA_START_CMP_FLAGS_RSS_VALID))
283285

284286
#define TPA_START_HASH_TYPE(rx_tpa_start) \
285-
((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
286-
RX_TPA_START_CMP_RSS_HASH_TYPE) >> \
287-
RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT)
287+
(((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
288+
RX_TPA_START_CMP_RSS_HASH_TYPE) >> \
289+
RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
288290

289291
#define TPA_START_AGG_ID(rx_tpa_start) \
290292
((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
@@ -839,6 +841,10 @@ struct bnxt_queue_info {
839841
u8 queue_profile;
840842
};
841843

844+
#define BNXT_GRCPF_REG_WINDOW_BASE_OUT 0x400
845+
#define BNXT_CAG_REG_LEGACY_INT_STATUS 0x4014
846+
#define BNXT_CAG_REG_BASE 0x300000
847+
842848
struct bnxt {
843849
void __iomem *bar0;
844850
void __iomem *bar1;
@@ -959,11 +965,11 @@ struct bnxt {
959965
#define BNXT_RX_MASK_SP_EVENT 0
960966
#define BNXT_RX_NTP_FLTR_SP_EVENT 1
961967
#define BNXT_LINK_CHNG_SP_EVENT 2
962-
#define BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT 4
963-
#define BNXT_VXLAN_ADD_PORT_SP_EVENT 8
964-
#define BNXT_VXLAN_DEL_PORT_SP_EVENT 16
965-
#define BNXT_RESET_TASK_SP_EVENT 32
966-
#define BNXT_RST_RING_SP_EVENT 64
968+
#define BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT 3
969+
#define BNXT_VXLAN_ADD_PORT_SP_EVENT 4
970+
#define BNXT_VXLAN_DEL_PORT_SP_EVENT 5
971+
#define BNXT_RESET_TASK_SP_EVENT 6
972+
#define BNXT_RST_RING_SP_EVENT 7
967973

968974
struct bnxt_pf_info pf;
969975
#ifdef CONFIG_BNXT_SRIOV

drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static int bnxt_set_vf_attr(struct bnxt *bp, int num_vfs)
258258
return 0;
259259
}
260260

261-
static int bnxt_hwrm_func_vf_resource_free(struct bnxt *bp)
261+
static int bnxt_hwrm_func_vf_resource_free(struct bnxt *bp, int num_vfs)
262262
{
263263
int i, rc = 0;
264264
struct bnxt_pf_info *pf = &bp->pf;
@@ -267,7 +267,7 @@ static int bnxt_hwrm_func_vf_resource_free(struct bnxt *bp)
267267
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_RESC_FREE, -1, -1);
268268

269269
mutex_lock(&bp->hwrm_cmd_lock);
270-
for (i = pf->first_vf_id; i < pf->first_vf_id + pf->active_vfs; i++) {
270+
for (i = pf->first_vf_id; i < pf->first_vf_id + num_vfs; i++) {
271271
req.vf_id = cpu_to_le16(i);
272272
rc = _hwrm_send_message(bp, &req, sizeof(req),
273273
HWRM_CMD_TIMEOUT);
@@ -509,7 +509,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
509509

510510
err_out2:
511511
/* Free the resources reserved for various VF's */
512-
bnxt_hwrm_func_vf_resource_free(bp);
512+
bnxt_hwrm_func_vf_resource_free(bp, *num_vfs);
513513

514514
err_out1:
515515
bnxt_free_vf_resources(bp);
@@ -519,13 +519,19 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
519519

520520
void bnxt_sriov_disable(struct bnxt *bp)
521521
{
522-
if (!bp->pf.active_vfs)
523-
return;
522+
u16 num_vfs = pci_num_vf(bp->pdev);
524523

525-
pci_disable_sriov(bp->pdev);
524+
if (!num_vfs)
525+
return;
526526

527-
/* Free the resources reserved for various VF's */
528-
bnxt_hwrm_func_vf_resource_free(bp);
527+
if (pci_vfs_assigned(bp->pdev)) {
528+
netdev_warn(bp->dev, "Unable to free %d VFs because some are assigned to VMs.\n",
529+
num_vfs);
530+
} else {
531+
pci_disable_sriov(bp->pdev);
532+
/* Free the HW resources reserved for various VF's */
533+
bnxt_hwrm_func_vf_resource_free(bp, num_vfs);
534+
}
529535

530536
bnxt_free_vf_resources(bp);
531537

@@ -552,17 +558,25 @@ int bnxt_sriov_configure(struct pci_dev *pdev, int num_vfs)
552558
}
553559
bp->sriov_cfg = true;
554560
rtnl_unlock();
555-
if (!num_vfs) {
556-
bnxt_sriov_disable(bp);
557-
return 0;
561+
562+
if (pci_vfs_assigned(bp->pdev)) {
563+
netdev_warn(dev, "Unable to configure SRIOV since some VFs are assigned to VMs.\n");
564+
num_vfs = 0;
565+
goto sriov_cfg_exit;
558566
}
559567

560568
/* Check if enabled VFs is same as requested */
561-
if (num_vfs == bp->pf.active_vfs)
562-
return 0;
569+
if (num_vfs && num_vfs == bp->pf.active_vfs)
570+
goto sriov_cfg_exit;
571+
572+
/* if there are previous existing VFs, clean them up */
573+
bnxt_sriov_disable(bp);
574+
if (!num_vfs)
575+
goto sriov_cfg_exit;
563576

564577
bnxt_sriov_enable(bp, &num_vfs);
565578

579+
sriov_cfg_exit:
566580
bp->sriov_cfg = false;
567581
wake_up(&bp->sriov_cfg_wait);
568582

0 commit comments

Comments
 (0)