Skip to content

Commit 46e457a

Browse files
committed
eth: bnxt: use the indir table from ethtool context
Instead of allocating a separate indir table in the vnic use the one already present in the RSS context allocated by the core. This saves some LoC and also we won't have to worry about syncing the local version back to the core, once core learns how to dump contexts. Reviewed-by: Pavan Chebbi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 73afb51 commit 46e457a

File tree

3 files changed

+29
-37
lines changed

3 files changed

+29
-37
lines changed

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6222,30 +6222,26 @@ static u16 bnxt_cp_ring_for_tx(struct bnxt *bp, struct bnxt_tx_ring_info *txr)
62226222
return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct);
62236223
}
62246224

6225-
int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx)
6225+
static int bnxt_alloc_rss_indir_tbl(struct bnxt *bp)
62266226
{
62276227
int entries;
6228-
u32 *tbl;
62296228

62306229
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
62316230
entries = BNXT_MAX_RSS_TABLE_ENTRIES_P5;
62326231
else
62336232
entries = HW_HASH_INDEX_SIZE;
62346233

62356234
bp->rss_indir_tbl_entries = entries;
6236-
tbl = kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), GFP_KERNEL);
6237-
if (!tbl)
6235+
bp->rss_indir_tbl =
6236+
kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), GFP_KERNEL);
6237+
if (!bp->rss_indir_tbl)
62386238
return -ENOMEM;
62396239

6240-
if (rss_ctx)
6241-
rss_ctx->rss_indir_tbl = tbl;
6242-
else
6243-
bp->rss_indir_tbl = tbl;
6244-
62456240
return 0;
62466241
}
62476242

6248-
void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx)
6243+
void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp,
6244+
struct ethtool_rxfh_context *rss_ctx)
62496245
{
62506246
u16 max_rings, max_entries, pad, i;
62516247
u32 *rss_indir_tbl;
@@ -6260,7 +6256,7 @@ void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx)
62606256

62616257
max_entries = bnxt_get_rxfh_indir_size(bp->dev);
62626258
if (rss_ctx)
6263-
rss_indir_tbl = &rss_ctx->rss_indir_tbl[0];
6259+
rss_indir_tbl = ethtool_rxfh_context_indir(rss_ctx);
62646260
else
62656261
rss_indir_tbl = &bp->rss_indir_tbl[0];
62666262

@@ -6326,7 +6322,7 @@ static void bnxt_fill_hw_rss_tbl_p5(struct bnxt *bp,
63266322
if (vnic->flags & BNXT_VNIC_NTUPLE_FLAG)
63276323
j = ethtool_rxfh_indir_default(i, bp->rx_nr_rings);
63286324
else if (vnic->flags & BNXT_VNIC_RSSCTX_FLAG)
6329-
j = vnic->rss_ctx->rss_indir_tbl[i];
6325+
j = ethtool_rxfh_context_indir(vnic->rss_ctx)[i];
63306326
else
63316327
j = bp->rss_indir_tbl[i];
63326328
rxr = &bp->rx_ring[j];
@@ -10224,7 +10220,6 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
1022410220
dma_free_coherent(&bp->pdev->dev, vnic->rss_table_size,
1022510221
vnic->rss_table,
1022610222
vnic->rss_table_dma_addr);
10227-
kfree(rss_ctx->rss_indir_tbl);
1022810223
bp->num_rss_ctx--;
1022910224
}
1023010225

@@ -15689,7 +15684,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1568915684
bp->flags |= BNXT_FLAG_CHIP_P7;
1569015685
}
1569115686

15692-
rc = bnxt_alloc_rss_indir_tbl(bp, NULL);
15687+
rc = bnxt_alloc_rss_indir_tbl(bp);
1569315688
if (rc)
1569415689
goto init_err_pci_clean;
1569515690

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,13 +1286,12 @@ struct bnxt_vnic_info {
12861286
#define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10
12871287
#define BNXT_VNIC_NTUPLE_FLAG 0x20
12881288
#define BNXT_VNIC_RSSCTX_FLAG 0x40
1289-
struct bnxt_rss_ctx *rss_ctx;
1289+
struct ethtool_rxfh_context *rss_ctx;
12901290
u32 vnic_id;
12911291
};
12921292

12931293
struct bnxt_rss_ctx {
12941294
struct bnxt_vnic_info vnic;
1295-
u32 *rss_indir_tbl;
12961295
u8 index;
12971296
};
12981297

@@ -2808,8 +2807,8 @@ int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp,
28082807
int bnxt_hwrm_vnic_set_tpa(struct bnxt *bp, struct bnxt_vnic_info *vnic,
28092808
u32 tpa_flags);
28102809
void bnxt_fill_ipv6_mask(__be32 mask[4]);
2811-
int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx);
2812-
void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx);
2810+
void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp,
2811+
struct ethtool_rxfh_context *rss_ctx);
28132812
int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings);
28142813
int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic);
28152814
int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic,

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

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,11 +1218,10 @@ static struct bnxt_rss_ctx *bnxt_get_rss_ctx_from_index(struct bnxt *bp,
12181218
return ethtool_rxfh_context_priv(ctx);
12191219
}
12201220

1221-
static int bnxt_alloc_rss_ctx_rss_table(struct bnxt *bp,
1222-
struct bnxt_rss_ctx *rss_ctx)
1221+
static int bnxt_alloc_vnic_rss_table(struct bnxt *bp,
1222+
struct bnxt_vnic_info *vnic)
12231223
{
12241224
int size = L1_CACHE_ALIGN(BNXT_MAX_RSS_TABLE_SIZE_P5);
1225-
struct bnxt_vnic_info *vnic = &rss_ctx->vnic;
12261225

12271226
vnic->rss_table_size = size + HW_HASH_KEY_SIZE;
12281227
vnic->rss_table = dma_alloc_coherent(&bp->pdev->dev,
@@ -1801,7 +1800,6 @@ static u32 bnxt_get_rxfh_key_size(struct net_device *dev)
18011800
static int bnxt_get_rxfh(struct net_device *dev,
18021801
struct ethtool_rxfh_param *rxfh)
18031802
{
1804-
u32 rss_context = rxfh->rss_context;
18051803
struct bnxt_rss_ctx *rss_ctx = NULL;
18061804
struct bnxt *bp = netdev_priv(dev);
18071805
u32 *indir_tbl = bp->rss_indir_tbl;
@@ -1815,10 +1813,13 @@ static int bnxt_get_rxfh(struct net_device *dev,
18151813

18161814
vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT];
18171815
if (rxfh->rss_context) {
1818-
rss_ctx = bnxt_get_rss_ctx_from_index(bp, rss_context);
1819-
if (!rss_ctx)
1816+
struct ethtool_rxfh_context *ctx;
1817+
1818+
ctx = xa_load(&bp->dev->ethtool->rss_ctx, rxfh->rss_context);
1819+
if (!ctx)
18201820
return -EINVAL;
1821-
indir_tbl = rss_ctx->rss_indir_tbl;
1821+
indir_tbl = ethtool_rxfh_context_indir(ctx);
1822+
rss_ctx = ethtool_rxfh_context_priv(ctx);
18221823
vnic = &rss_ctx->vnic;
18231824
}
18241825

@@ -1834,7 +1835,8 @@ static int bnxt_get_rxfh(struct net_device *dev,
18341835
return 0;
18351836
}
18361837

1837-
static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
1838+
static void bnxt_modify_rss(struct bnxt *bp, struct ethtool_rxfh_context *ctx,
1839+
struct bnxt_rss_ctx *rss_ctx,
18381840
const struct ethtool_rxfh_param *rxfh)
18391841
{
18401842
if (rxfh->key) {
@@ -1851,7 +1853,7 @@ static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
18511853
u32 *indir_tbl = bp->rss_indir_tbl;
18521854

18531855
if (rss_ctx)
1854-
indir_tbl = rss_ctx->rss_indir_tbl;
1856+
indir_tbl = ethtool_rxfh_context_indir(ctx);
18551857
for (i = 0; i < tbl_size; i++)
18561858
indir_tbl[i] = rxfh->indir[i];
18571859
pad = bp->rss_indir_tbl_entries - tbl_size;
@@ -1906,18 +1908,14 @@ static int bnxt_create_rxfh_context(struct net_device *dev,
19061908
bp->num_rss_ctx++;
19071909

19081910
vnic = &rss_ctx->vnic;
1909-
vnic->rss_ctx = rss_ctx;
1911+
vnic->rss_ctx = ctx;
19101912
vnic->flags |= BNXT_VNIC_RSSCTX_FLAG;
19111913
vnic->vnic_id = BNXT_VNIC_ID_INVALID;
1912-
rc = bnxt_alloc_rss_ctx_rss_table(bp, rss_ctx);
1913-
if (rc)
1914-
goto out;
1915-
1916-
rc = bnxt_alloc_rss_indir_tbl(bp, rss_ctx);
1914+
rc = bnxt_alloc_vnic_rss_table(bp, vnic);
19171915
if (rc)
19181916
goto out;
19191917

1920-
bnxt_set_dflt_rss_indir_tbl(bp, rss_ctx);
1918+
bnxt_set_dflt_rss_indir_tbl(bp, ctx);
19211919
memcpy(vnic->rss_hash_key, bp->rss_hash_key, HW_HASH_KEY_SIZE);
19221920

19231921
rc = bnxt_hwrm_vnic_alloc(bp, vnic, 0, bp->rx_nr_rings);
@@ -1931,7 +1929,7 @@ static int bnxt_create_rxfh_context(struct net_device *dev,
19311929
NL_SET_ERR_MSG_MOD(extack, "Unable to setup TPA");
19321930
goto out;
19331931
}
1934-
bnxt_modify_rss(bp, rss_ctx, rxfh);
1932+
bnxt_modify_rss(bp, ctx, rss_ctx, rxfh);
19351933

19361934
rc = __bnxt_setup_vnic_p5(bp, vnic);
19371935
if (rc) {
@@ -1961,7 +1959,7 @@ static int bnxt_modify_rxfh_context(struct net_device *dev,
19611959

19621960
rss_ctx = ethtool_rxfh_context_priv(ctx);
19631961

1964-
bnxt_modify_rss(bp, rss_ctx, rxfh);
1962+
bnxt_modify_rss(bp, ctx, rss_ctx, rxfh);
19651963

19661964
return bnxt_hwrm_vnic_rss_cfg_p5(bp, &rss_ctx->vnic);
19671965
}
@@ -1990,7 +1988,7 @@ static int bnxt_set_rxfh(struct net_device *dev,
19901988
if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP)
19911989
return -EOPNOTSUPP;
19921990

1993-
bnxt_modify_rss(bp, NULL, rxfh);
1991+
bnxt_modify_rss(bp, NULL, NULL, rxfh);
19941992

19951993
bnxt_clear_usr_fltrs(bp, false);
19961994
if (netif_running(bp->dev)) {

0 commit comments

Comments
 (0)