Skip to content

Commit 39a8f2a

Browse files
committed
Merge branch 'bnxt_en-Bug-fixes'
Michael Chan says: ==================== bnxt_en: Bug fixes. 5 bug fix patches covering an indexing bug for priority counters, memory leak when retrieving DCB ETS settings, error path return code, proper disabling of PCI before freeing context memory, and proper ring accounting in error path. Please also apply these to -stable. Thanks. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents b06d072 + 5d765a5 commit 39a8f2a

File tree

4 files changed

+35
-18
lines changed

4 files changed

+35
-18
lines changed

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6880,12 +6880,12 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
68806880
}
68816881
ena |= FUNC_BACKING_STORE_CFG_REQ_DFLT_ENABLES;
68826882
rc = bnxt_hwrm_func_backing_store_cfg(bp, ena);
6883-
if (rc)
6883+
if (rc) {
68846884
netdev_err(bp->dev, "Failed configuring context mem, rc = %d.\n",
68856885
rc);
6886-
else
6887-
ctx->flags |= BNXT_CTX_FLAG_INITED;
6888-
6886+
return rc;
6887+
}
6888+
ctx->flags |= BNXT_CTX_FLAG_INITED;
68896889
return 0;
68906890
}
68916891

@@ -7406,14 +7406,22 @@ static int bnxt_hwrm_port_qstats_ext(struct bnxt *bp)
74067406
pri2cos = &resp2->pri0_cos_queue_id;
74077407
for (i = 0; i < 8; i++) {
74087408
u8 queue_id = pri2cos[i];
7409+
u8 queue_idx;
74097410

7411+
/* Per port queue IDs start from 0, 10, 20, etc */
7412+
queue_idx = queue_id % 10;
7413+
if (queue_idx > BNXT_MAX_QUEUE) {
7414+
bp->pri2cos_valid = false;
7415+
goto qstats_done;
7416+
}
74107417
for (j = 0; j < bp->max_q; j++) {
74117418
if (bp->q_ids[j] == queue_id)
7412-
bp->pri2cos[i] = j;
7419+
bp->pri2cos_idx[i] = queue_idx;
74137420
}
74147421
}
74157422
bp->pri2cos_valid = 1;
74167423
}
7424+
qstats_done:
74177425
mutex_unlock(&bp->hwrm_cmd_lock);
74187426
return rc;
74197427
}
@@ -11669,6 +11677,10 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
1166911677
bp->rx_nr_rings++;
1167011678
bp->cp_nr_rings++;
1167111679
}
11680+
if (rc) {
11681+
bp->tx_nr_rings = 0;
11682+
bp->rx_nr_rings = 0;
11683+
}
1167211684
return rc;
1167311685
}
1167411686

@@ -11962,12 +11974,12 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1196211974
bnxt_hwrm_func_drv_unrgtr(bp);
1196311975
bnxt_free_hwrm_short_cmd_req(bp);
1196411976
bnxt_free_hwrm_resources(bp);
11965-
bnxt_free_ctx_mem(bp);
11966-
kfree(bp->ctx);
11967-
bp->ctx = NULL;
1196811977
kfree(bp->fw_health);
1196911978
bp->fw_health = NULL;
1197011979
bnxt_cleanup_pci(bp);
11980+
bnxt_free_ctx_mem(bp);
11981+
kfree(bp->ctx);
11982+
bp->ctx = NULL;
1197111983

1197211984
init_err_free:
1197311985
free_netdev(dev);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ struct bnxt {
17161716
u16 fw_rx_stats_ext_size;
17171717
u16 fw_tx_stats_ext_size;
17181718
u16 hw_ring_stats_size;
1719-
u8 pri2cos[8];
1719+
u8 pri2cos_idx[8];
17201720
u8 pri2cos_valid;
17211721

17221722
u16 hwrm_max_req_len;

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,24 +479,26 @@ static int bnxt_dcbnl_ieee_getets(struct net_device *dev, struct ieee_ets *ets)
479479
{
480480
struct bnxt *bp = netdev_priv(dev);
481481
struct ieee_ets *my_ets = bp->ieee_ets;
482+
int rc;
482483

483484
ets->ets_cap = bp->max_tc;
484485

485486
if (!my_ets) {
486-
int rc;
487-
488487
if (bp->dcbx_cap & DCB_CAP_DCBX_HOST)
489488
return 0;
490489

491490
my_ets = kzalloc(sizeof(*my_ets), GFP_KERNEL);
492491
if (!my_ets)
493-
return 0;
492+
return -ENOMEM;
494493
rc = bnxt_hwrm_queue_cos2bw_qcfg(bp, my_ets);
495494
if (rc)
496-
return 0;
495+
goto error;
497496
rc = bnxt_hwrm_queue_pri2cos_qcfg(bp, my_ets);
498497
if (rc)
499-
return 0;
498+
goto error;
499+
500+
/* cache result */
501+
bp->ieee_ets = my_ets;
500502
}
501503

502504
ets->cbs = my_ets->cbs;
@@ -505,6 +507,9 @@ static int bnxt_dcbnl_ieee_getets(struct net_device *dev, struct ieee_ets *ets)
505507
memcpy(ets->tc_tsa, my_ets->tc_tsa, sizeof(ets->tc_tsa));
506508
memcpy(ets->prio_tc, my_ets->prio_tc, sizeof(ets->prio_tc));
507509
return 0;
510+
error:
511+
kfree(my_ets);
512+
return rc;
508513
}
509514

510515
static int bnxt_dcbnl_ieee_setets(struct net_device *dev, struct ieee_ets *ets)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,25 +589,25 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
589589
if (bp->pri2cos_valid) {
590590
for (i = 0; i < 8; i++, j++) {
591591
long n = bnxt_rx_bytes_pri_arr[i].base_off +
592-
bp->pri2cos[i];
592+
bp->pri2cos_idx[i];
593593

594594
buf[j] = le64_to_cpu(*(rx_port_stats_ext + n));
595595
}
596596
for (i = 0; i < 8; i++, j++) {
597597
long n = bnxt_rx_pkts_pri_arr[i].base_off +
598-
bp->pri2cos[i];
598+
bp->pri2cos_idx[i];
599599

600600
buf[j] = le64_to_cpu(*(rx_port_stats_ext + n));
601601
}
602602
for (i = 0; i < 8; i++, j++) {
603603
long n = bnxt_tx_bytes_pri_arr[i].base_off +
604-
bp->pri2cos[i];
604+
bp->pri2cos_idx[i];
605605

606606
buf[j] = le64_to_cpu(*(tx_port_stats_ext + n));
607607
}
608608
for (i = 0; i < 8; i++, j++) {
609609
long n = bnxt_tx_pkts_pri_arr[i].base_off +
610-
bp->pri2cos[i];
610+
bp->pri2cos_idx[i];
611611

612612
buf[j] = le64_to_cpu(*(tx_port_stats_ext + n));
613613
}

0 commit comments

Comments
 (0)