Skip to content

Commit ecb342b

Browse files
Pavan Chebbikuba-moo
authored andcommitted
bnxt_en: Refactor RSS indir alloc/set functions
We will need to dynamically allocate and change indirection tables for additional RSS contexts. Add the rss_ctx pointer parameter to bnxt_alloc_rss_indir_tbl() and bnxt_set_dflt_rss_indir_tbl(). Existing usage will always pass rss_ctx as NULL which means the default RSS context. When supporting additional RSS contexts in subsequent patches, we'll pass the valid rss_ctx to these 2 functions. Reviewed-by: Andy Gospodarek <[email protected]> Signed-off-by: Pavan Chebbi <[email protected]> Signed-off-by: Michael Chan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fea41bd commit ecb342b

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6026,26 +6026,33 @@ static u16 bnxt_cp_ring_for_tx(struct bnxt *bp, struct bnxt_tx_ring_info *txr)
60266026
return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct);
60276027
}
60286028

6029-
static int bnxt_alloc_rss_indir_tbl(struct bnxt *bp)
6029+
int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx)
60306030
{
60316031
int entries;
6032+
u16 *tbl;
60326033

60336034
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
60346035
entries = BNXT_MAX_RSS_TABLE_ENTRIES_P5;
60356036
else
60366037
entries = HW_HASH_INDEX_SIZE;
60376038

60386039
bp->rss_indir_tbl_entries = entries;
6039-
bp->rss_indir_tbl = kmalloc_array(entries, sizeof(*bp->rss_indir_tbl),
6040-
GFP_KERNEL);
6041-
if (!bp->rss_indir_tbl)
6040+
tbl = kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), GFP_KERNEL);
6041+
if (!tbl)
60426042
return -ENOMEM;
6043+
6044+
if (rss_ctx)
6045+
rss_ctx->rss_indir_tbl = tbl;
6046+
else
6047+
bp->rss_indir_tbl = tbl;
6048+
60436049
return 0;
60446050
}
60456051

6046-
static void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp)
6052+
void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx)
60476053
{
60486054
u16 max_rings, max_entries, pad, i;
6055+
u16 *rss_indir_tbl;
60496056

60506057
if (!bp->rx_nr_rings)
60516058
return;
@@ -6056,13 +6063,17 @@ static void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp)
60566063
max_rings = bp->rx_nr_rings;
60576064

60586065
max_entries = bnxt_get_rxfh_indir_size(bp->dev);
6066+
if (rss_ctx)
6067+
rss_indir_tbl = &rss_ctx->rss_indir_tbl[0];
6068+
else
6069+
rss_indir_tbl = &bp->rss_indir_tbl[0];
60596070

60606071
for (i = 0; i < max_entries; i++)
6061-
bp->rss_indir_tbl[i] = ethtool_rxfh_indir_default(i, max_rings);
6072+
rss_indir_tbl[i] = ethtool_rxfh_indir_default(i, max_rings);
60626073

60636074
pad = bp->rss_indir_tbl_entries - max_entries;
60646075
if (pad)
6065-
memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16));
6076+
memset(&rss_indir_tbl[i], 0, pad * sizeof(u16));
60666077
}
60676078

60686079
static u16 bnxt_get_max_rss_ring(struct bnxt *bp)
@@ -7341,7 +7352,7 @@ static void bnxt_check_rss_tbl_no_rmgr(struct bnxt *bp)
73417352
if (hw_resc->resv_rx_rings != bp->rx_nr_rings) {
73427353
hw_resc->resv_rx_rings = bp->rx_nr_rings;
73437354
if (!netif_is_rxfh_configured(bp->dev))
7344-
bnxt_set_dflt_rss_indir_tbl(bp);
7355+
bnxt_set_dflt_rss_indir_tbl(bp, NULL);
73457356
}
73467357
}
73477358

@@ -7497,7 +7508,7 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
74977508
return -ENOMEM;
74987509

74997510
if (!netif_is_rxfh_configured(bp->dev))
7500-
bnxt_set_dflt_rss_indir_tbl(bp);
7511+
bnxt_set_dflt_rss_indir_tbl(bp, NULL);
75017512

75027513
return rc;
75037514
}
@@ -15119,7 +15130,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1511915130
bp->flags |= BNXT_FLAG_CHIP_P7;
1512015131
}
1512115132

15122-
rc = bnxt_alloc_rss_indir_tbl(bp);
15133+
rc = bnxt_alloc_rss_indir_tbl(bp, NULL);
1512315134
if (rc)
1512415135
goto init_err_pci_clean;
1512515136

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,8 @@ int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp,
27152715
int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp,
27162716
struct bnxt_ntuple_filter *fltr);
27172717
void bnxt_fill_ipv6_mask(__be32 mask[4]);
2718+
int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx);
2719+
void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx);
27182720
int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings);
27192721
int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic);
27202722
int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings);

0 commit comments

Comments
 (0)