Skip to content

Commit c027c6b

Browse files
Vasundhara Volamdavem330
authored andcommitted
bnxt_en: get rid of num_stat_ctxs variable
For bnxt_en driver, stat_ctxs created will always be same as cp_nr_rings. Remove extra variable that duplicates the value. Also introduce bnxt_get_avail_stat_ctxs_for_en() helper to get available stat_ctxs and bnxt_get_ulp_stat_ctxs() helper to return number of stat_ctxs used by RDMA. Signed-off-by: Vasundhara Volam <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e916b08 commit c027c6b

File tree

7 files changed

+25
-16
lines changed

7 files changed

+25
-16
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7081,6 +7081,15 @@ unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp)
70817081
return cp - bp->cp_nr_rings;
70827082
}
70837083

7084+
unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp)
7085+
{
7086+
unsigned int stat;
7087+
7088+
stat = bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_ulp_stat_ctxs(bp);
7089+
stat -= bp->cp_nr_rings;
7090+
return stat;
7091+
}
7092+
70847093
int bnxt_get_avail_msix(struct bnxt *bp, int num)
70857094
{
70867095
int max_cp = bnxt_get_max_func_cp_rings(bp);
@@ -7242,7 +7251,6 @@ int bnxt_reserve_rings(struct bnxt *bp)
72427251
bp->tx_nr_rings_per_tc = bp->tx_nr_rings;
72437252
return -ENOMEM;
72447253
}
7245-
bp->num_stat_ctxs = bp->cp_nr_rings;
72467254
return 0;
72477255
}
72487256

@@ -9309,7 +9317,6 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
93099317
bp->tx_nr_rings += bp->tx_nr_rings_xdp;
93109318
bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) :
93119319
bp->tx_nr_rings + bp->rx_nr_rings;
9312-
bp->num_stat_ctxs = bp->cp_nr_rings;
93139320

93149321
if (netif_running(bp->dev))
93159322
return bnxt_open_nic(bp, true, false);
@@ -9849,7 +9856,7 @@ static void _bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx,
98499856
*max_cp = bnxt_get_max_func_cp_rings_for_en(bp);
98509857
max_irq = min_t(int, bnxt_get_max_func_irqs(bp) -
98519858
bnxt_get_ulp_msix_num(bp),
9852-
bnxt_get_max_func_stat_ctxs(bp));
9859+
hw_resc->max_stat_ctxs - bnxt_get_ulp_stat_ctxs(bp));
98539860
if (!(bp->flags & BNXT_FLAG_CHIP_P5))
98549861
*max_cp = min_t(int, *max_cp, max_irq);
98559862
max_ring_grps = hw_resc->max_hw_ring_grps;
@@ -9980,7 +9987,6 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
99809987
netdev_warn(bp->dev, "2nd rings reservation failed.\n");
99819988
bp->tx_nr_rings_per_tc = bp->tx_nr_rings;
99829989
}
9983-
bp->num_stat_ctxs = bp->cp_nr_rings;
99849990
if (BNXT_CHIP_TYPE_NITRO_A0(bp)) {
99859991
bp->rx_nr_rings++;
99869992
bp->cp_nr_rings++;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,8 +1417,6 @@ struct bnxt {
14171417
int cp_nr_pages;
14181418
int cp_nr_rings;
14191419

1420-
int num_stat_ctxs;
1421-
14221420
/* grp_info indexed by completion ring index */
14231421
struct bnxt_ring_grp_info *grp_info;
14241422
struct bnxt_vnic_info *vnic_info;
@@ -1690,6 +1688,7 @@ int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings);
16901688
int bnxt_hwrm_set_coal(struct bnxt *);
16911689
unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
16921690
void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max);
1691+
unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp);
16931692
unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
16941693
unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp);
16951694
int bnxt_get_avail_msix(struct bnxt *bp, int num);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,6 @@ static int bnxt_set_channels(struct net_device *dev,
663663
bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) :
664664
bp->tx_nr_rings + bp->rx_nr_rings;
665665

666-
bp->num_stat_ctxs = bp->cp_nr_rings;
667-
668666
/* After changing number of rx channels, update NTUPLE feature. */
669667
netdev_update_features(dev);
670668
if (netif_running(dev)) {

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs)
452452
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_RESOURCE_CFG, -1, -1);
453453

454454
vf_cp_rings = bnxt_get_avail_cp_rings_for_en(bp);
455-
vf_stat_ctx = hw_resc->max_stat_ctxs - bp->num_stat_ctxs;
455+
vf_stat_ctx = bnxt_get_avail_stat_ctxs_for_en(bp);
456456
if (bp->flags & BNXT_FLAG_AGG_RINGS)
457457
vf_rx_rings = hw_resc->max_rx_rings - bp->rx_nr_rings * 2;
458458
else
@@ -539,18 +539,16 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
539539
u32 rc = 0, mtu, i;
540540
u16 vf_tx_rings, vf_rx_rings, vf_cp_rings, vf_stat_ctx, vf_vnics;
541541
struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
542-
u16 vf_ring_grps, max_stat_ctxs;
543542
struct hwrm_func_cfg_input req = {0};
544543
struct bnxt_pf_info *pf = &bp->pf;
545544
int total_vf_tx_rings = 0;
545+
u16 vf_ring_grps;
546546

547547
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1);
548548

549-
max_stat_ctxs = hw_resc->max_stat_ctxs;
550-
551549
/* Remaining rings are distributed equally amongs VF's for now */
552550
vf_cp_rings = bnxt_get_avail_cp_rings_for_en(bp) / num_vfs;
553-
vf_stat_ctx = (max_stat_ctxs - bp->num_stat_ctxs) / num_vfs;
551+
vf_stat_ctx = bnxt_get_avail_stat_ctxs_for_en(bp) / num_vfs;
554552
if (bp->flags & BNXT_FLAG_AGG_RINGS)
555553
vf_rx_rings = (hw_resc->max_rx_rings - bp->rx_nr_rings * 2) /
556554
num_vfs;
@@ -644,7 +642,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
644642
vfs_supported = *num_vfs;
645643

646644
avail_cp = bnxt_get_avail_cp_rings_for_en(bp);
647-
avail_stat = hw_resc->max_stat_ctxs - bp->num_stat_ctxs;
645+
avail_stat = bnxt_get_avail_stat_ctxs_for_en(bp);
648646
avail_cp = min_t(int, avail_cp, avail_stat);
649647

650648
while (vfs_supported) {

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static int bnxt_register_dev(struct bnxt_en_dev *edev, int ulp_id,
4848

4949
max_stat_ctxs = bnxt_get_max_func_stat_ctxs(bp);
5050
if (max_stat_ctxs <= BNXT_MIN_ROCE_STAT_CTXS ||
51-
bp->num_stat_ctxs == max_stat_ctxs)
51+
bp->cp_nr_rings == max_stat_ctxs)
5252
return -ENOMEM;
5353
bnxt_set_max_func_stat_ctxs(bp, max_stat_ctxs -
5454
BNXT_MIN_ROCE_STAT_CTXS);
@@ -218,6 +218,14 @@ int bnxt_get_ulp_msix_base(struct bnxt *bp)
218218
return 0;
219219
}
220220

221+
int bnxt_get_ulp_stat_ctxs(struct bnxt *bp)
222+
{
223+
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP))
224+
return BNXT_MIN_ROCE_STAT_CTXS;
225+
226+
return 0;
227+
}
228+
221229
static int bnxt_send_msg(struct bnxt_en_dev *edev, int ulp_id,
222230
struct bnxt_fw_msg *fw_msg)
223231
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id)
9090

9191
int bnxt_get_ulp_msix_num(struct bnxt *bp);
9292
int bnxt_get_ulp_msix_base(struct bnxt *bp);
93+
int bnxt_get_ulp_stat_ctxs(struct bnxt *bp);
9394
void bnxt_ulp_stop(struct bnxt *bp);
9495
void bnxt_ulp_start(struct bnxt *bp);
9596
void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)
199199
bp->tx_nr_rings_xdp = tx_xdp;
200200
bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc + tx_xdp;
201201
bp->cp_nr_rings = max_t(int, bp->tx_nr_rings, bp->rx_nr_rings);
202-
bp->num_stat_ctxs = bp->cp_nr_rings;
203202
bnxt_set_tpa_flags(bp);
204203
bnxt_set_ring_params(bp);
205204

0 commit comments

Comments
 (0)