Commit 46e457a4 authored by Jakub Kicinski's avatar Jakub Kicinski

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: default avatarPavan Chebbi <pavan.chebbi@broadcom.com>
Link: https://patch.msgid.link/20240711220713.283778-12-kuba@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 73afb518
...@@ -6222,10 +6222,9 @@ static u16 bnxt_cp_ring_for_tx(struct bnxt *bp, struct bnxt_tx_ring_info *txr) ...@@ -6222,10 +6222,9 @@ static u16 bnxt_cp_ring_for_tx(struct bnxt *bp, struct bnxt_tx_ring_info *txr)
return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct); return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct);
} }
int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) static int bnxt_alloc_rss_indir_tbl(struct bnxt *bp)
{ {
int entries; int entries;
u32 *tbl;
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
entries = BNXT_MAX_RSS_TABLE_ENTRIES_P5; entries = BNXT_MAX_RSS_TABLE_ENTRIES_P5;
...@@ -6233,19 +6232,16 @@ int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) ...@@ -6233,19 +6232,16 @@ int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx)
entries = HW_HASH_INDEX_SIZE; entries = HW_HASH_INDEX_SIZE;
bp->rss_indir_tbl_entries = entries; bp->rss_indir_tbl_entries = entries;
tbl = kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), GFP_KERNEL); bp->rss_indir_tbl =
if (!tbl) kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), GFP_KERNEL);
if (!bp->rss_indir_tbl)
return -ENOMEM; return -ENOMEM;
if (rss_ctx)
rss_ctx->rss_indir_tbl = tbl;
else
bp->rss_indir_tbl = tbl;
return 0; return 0;
} }
void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp,
struct ethtool_rxfh_context *rss_ctx)
{ {
u16 max_rings, max_entries, pad, i; u16 max_rings, max_entries, pad, i;
u32 *rss_indir_tbl; u32 *rss_indir_tbl;
...@@ -6260,7 +6256,7 @@ void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) ...@@ -6260,7 +6256,7 @@ void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx)
max_entries = bnxt_get_rxfh_indir_size(bp->dev); max_entries = bnxt_get_rxfh_indir_size(bp->dev);
if (rss_ctx) if (rss_ctx)
rss_indir_tbl = &rss_ctx->rss_indir_tbl[0]; rss_indir_tbl = ethtool_rxfh_context_indir(rss_ctx);
else else
rss_indir_tbl = &bp->rss_indir_tbl[0]; rss_indir_tbl = &bp->rss_indir_tbl[0];
...@@ -6326,7 +6322,7 @@ static void bnxt_fill_hw_rss_tbl_p5(struct bnxt *bp, ...@@ -6326,7 +6322,7 @@ static void bnxt_fill_hw_rss_tbl_p5(struct bnxt *bp,
if (vnic->flags & BNXT_VNIC_NTUPLE_FLAG) if (vnic->flags & BNXT_VNIC_NTUPLE_FLAG)
j = ethtool_rxfh_indir_default(i, bp->rx_nr_rings); j = ethtool_rxfh_indir_default(i, bp->rx_nr_rings);
else if (vnic->flags & BNXT_VNIC_RSSCTX_FLAG) else if (vnic->flags & BNXT_VNIC_RSSCTX_FLAG)
j = vnic->rss_ctx->rss_indir_tbl[i]; j = ethtool_rxfh_context_indir(vnic->rss_ctx)[i];
else else
j = bp->rss_indir_tbl[i]; j = bp->rss_indir_tbl[i];
rxr = &bp->rx_ring[j]; rxr = &bp->rx_ring[j];
...@@ -10224,7 +10220,6 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, ...@@ -10224,7 +10220,6 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
dma_free_coherent(&bp->pdev->dev, vnic->rss_table_size, dma_free_coherent(&bp->pdev->dev, vnic->rss_table_size,
vnic->rss_table, vnic->rss_table,
vnic->rss_table_dma_addr); vnic->rss_table_dma_addr);
kfree(rss_ctx->rss_indir_tbl);
bp->num_rss_ctx--; bp->num_rss_ctx--;
} }
...@@ -15689,7 +15684,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -15689,7 +15684,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
bp->flags |= BNXT_FLAG_CHIP_P7; bp->flags |= BNXT_FLAG_CHIP_P7;
} }
rc = bnxt_alloc_rss_indir_tbl(bp, NULL); rc = bnxt_alloc_rss_indir_tbl(bp);
if (rc) if (rc)
goto init_err_pci_clean; goto init_err_pci_clean;
......
...@@ -1286,13 +1286,12 @@ struct bnxt_vnic_info { ...@@ -1286,13 +1286,12 @@ struct bnxt_vnic_info {
#define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10 #define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10
#define BNXT_VNIC_NTUPLE_FLAG 0x20 #define BNXT_VNIC_NTUPLE_FLAG 0x20
#define BNXT_VNIC_RSSCTX_FLAG 0x40 #define BNXT_VNIC_RSSCTX_FLAG 0x40
struct bnxt_rss_ctx *rss_ctx; struct ethtool_rxfh_context *rss_ctx;
u32 vnic_id; u32 vnic_id;
}; };
struct bnxt_rss_ctx { struct bnxt_rss_ctx {
struct bnxt_vnic_info vnic; struct bnxt_vnic_info vnic;
u32 *rss_indir_tbl;
u8 index; u8 index;
}; };
...@@ -2808,8 +2807,8 @@ int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, ...@@ -2808,8 +2807,8 @@ int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp,
int bnxt_hwrm_vnic_set_tpa(struct bnxt *bp, struct bnxt_vnic_info *vnic, int bnxt_hwrm_vnic_set_tpa(struct bnxt *bp, struct bnxt_vnic_info *vnic,
u32 tpa_flags); u32 tpa_flags);
void bnxt_fill_ipv6_mask(__be32 mask[4]); void bnxt_fill_ipv6_mask(__be32 mask[4]);
int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx); void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp,
void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx); struct ethtool_rxfh_context *rss_ctx);
int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings); int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings);
int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic);
int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic, int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic,
......
...@@ -1218,11 +1218,10 @@ static struct bnxt_rss_ctx *bnxt_get_rss_ctx_from_index(struct bnxt *bp, ...@@ -1218,11 +1218,10 @@ static struct bnxt_rss_ctx *bnxt_get_rss_ctx_from_index(struct bnxt *bp,
return ethtool_rxfh_context_priv(ctx); return ethtool_rxfh_context_priv(ctx);
} }
static int bnxt_alloc_rss_ctx_rss_table(struct bnxt *bp, static int bnxt_alloc_vnic_rss_table(struct bnxt *bp,
struct bnxt_rss_ctx *rss_ctx) struct bnxt_vnic_info *vnic)
{ {
int size = L1_CACHE_ALIGN(BNXT_MAX_RSS_TABLE_SIZE_P5); int size = L1_CACHE_ALIGN(BNXT_MAX_RSS_TABLE_SIZE_P5);
struct bnxt_vnic_info *vnic = &rss_ctx->vnic;
vnic->rss_table_size = size + HW_HASH_KEY_SIZE; vnic->rss_table_size = size + HW_HASH_KEY_SIZE;
vnic->rss_table = dma_alloc_coherent(&bp->pdev->dev, vnic->rss_table = dma_alloc_coherent(&bp->pdev->dev,
...@@ -1801,7 +1800,6 @@ static u32 bnxt_get_rxfh_key_size(struct net_device *dev) ...@@ -1801,7 +1800,6 @@ static u32 bnxt_get_rxfh_key_size(struct net_device *dev)
static int bnxt_get_rxfh(struct net_device *dev, static int bnxt_get_rxfh(struct net_device *dev,
struct ethtool_rxfh_param *rxfh) struct ethtool_rxfh_param *rxfh)
{ {
u32 rss_context = rxfh->rss_context;
struct bnxt_rss_ctx *rss_ctx = NULL; struct bnxt_rss_ctx *rss_ctx = NULL;
struct bnxt *bp = netdev_priv(dev); struct bnxt *bp = netdev_priv(dev);
u32 *indir_tbl = bp->rss_indir_tbl; u32 *indir_tbl = bp->rss_indir_tbl;
...@@ -1815,10 +1813,13 @@ static int bnxt_get_rxfh(struct net_device *dev, ...@@ -1815,10 +1813,13 @@ static int bnxt_get_rxfh(struct net_device *dev,
vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT];
if (rxfh->rss_context) { if (rxfh->rss_context) {
rss_ctx = bnxt_get_rss_ctx_from_index(bp, rss_context); struct ethtool_rxfh_context *ctx;
if (!rss_ctx)
ctx = xa_load(&bp->dev->ethtool->rss_ctx, rxfh->rss_context);
if (!ctx)
return -EINVAL; return -EINVAL;
indir_tbl = rss_ctx->rss_indir_tbl; indir_tbl = ethtool_rxfh_context_indir(ctx);
rss_ctx = ethtool_rxfh_context_priv(ctx);
vnic = &rss_ctx->vnic; vnic = &rss_ctx->vnic;
} }
...@@ -1834,7 +1835,8 @@ static int bnxt_get_rxfh(struct net_device *dev, ...@@ -1834,7 +1835,8 @@ static int bnxt_get_rxfh(struct net_device *dev,
return 0; return 0;
} }
static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, static void bnxt_modify_rss(struct bnxt *bp, struct ethtool_rxfh_context *ctx,
struct bnxt_rss_ctx *rss_ctx,
const struct ethtool_rxfh_param *rxfh) const struct ethtool_rxfh_param *rxfh)
{ {
if (rxfh->key) { if (rxfh->key) {
...@@ -1851,7 +1853,7 @@ static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, ...@@ -1851,7 +1853,7 @@ static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
u32 *indir_tbl = bp->rss_indir_tbl; u32 *indir_tbl = bp->rss_indir_tbl;
if (rss_ctx) if (rss_ctx)
indir_tbl = rss_ctx->rss_indir_tbl; indir_tbl = ethtool_rxfh_context_indir(ctx);
for (i = 0; i < tbl_size; i++) for (i = 0; i < tbl_size; i++)
indir_tbl[i] = rxfh->indir[i]; indir_tbl[i] = rxfh->indir[i];
pad = bp->rss_indir_tbl_entries - tbl_size; pad = bp->rss_indir_tbl_entries - tbl_size;
...@@ -1906,18 +1908,14 @@ static int bnxt_create_rxfh_context(struct net_device *dev, ...@@ -1906,18 +1908,14 @@ static int bnxt_create_rxfh_context(struct net_device *dev,
bp->num_rss_ctx++; bp->num_rss_ctx++;
vnic = &rss_ctx->vnic; vnic = &rss_ctx->vnic;
vnic->rss_ctx = rss_ctx; vnic->rss_ctx = ctx;
vnic->flags |= BNXT_VNIC_RSSCTX_FLAG; vnic->flags |= BNXT_VNIC_RSSCTX_FLAG;
vnic->vnic_id = BNXT_VNIC_ID_INVALID; vnic->vnic_id = BNXT_VNIC_ID_INVALID;
rc = bnxt_alloc_rss_ctx_rss_table(bp, rss_ctx); rc = bnxt_alloc_vnic_rss_table(bp, vnic);
if (rc)
goto out;
rc = bnxt_alloc_rss_indir_tbl(bp, rss_ctx);
if (rc) if (rc)
goto out; goto out;
bnxt_set_dflt_rss_indir_tbl(bp, rss_ctx); bnxt_set_dflt_rss_indir_tbl(bp, ctx);
memcpy(vnic->rss_hash_key, bp->rss_hash_key, HW_HASH_KEY_SIZE); memcpy(vnic->rss_hash_key, bp->rss_hash_key, HW_HASH_KEY_SIZE);
rc = bnxt_hwrm_vnic_alloc(bp, vnic, 0, bp->rx_nr_rings); 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, ...@@ -1931,7 +1929,7 @@ static int bnxt_create_rxfh_context(struct net_device *dev,
NL_SET_ERR_MSG_MOD(extack, "Unable to setup TPA"); NL_SET_ERR_MSG_MOD(extack, "Unable to setup TPA");
goto out; goto out;
} }
bnxt_modify_rss(bp, rss_ctx, rxfh); bnxt_modify_rss(bp, ctx, rss_ctx, rxfh);
rc = __bnxt_setup_vnic_p5(bp, vnic); rc = __bnxt_setup_vnic_p5(bp, vnic);
if (rc) { if (rc) {
...@@ -1961,7 +1959,7 @@ static int bnxt_modify_rxfh_context(struct net_device *dev, ...@@ -1961,7 +1959,7 @@ static int bnxt_modify_rxfh_context(struct net_device *dev,
rss_ctx = ethtool_rxfh_context_priv(ctx); rss_ctx = ethtool_rxfh_context_priv(ctx);
bnxt_modify_rss(bp, rss_ctx, rxfh); bnxt_modify_rss(bp, ctx, rss_ctx, rxfh);
return bnxt_hwrm_vnic_rss_cfg_p5(bp, &rss_ctx->vnic); return bnxt_hwrm_vnic_rss_cfg_p5(bp, &rss_ctx->vnic);
} }
...@@ -1990,7 +1988,7 @@ static int bnxt_set_rxfh(struct net_device *dev, ...@@ -1990,7 +1988,7 @@ static int bnxt_set_rxfh(struct net_device *dev,
if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP)
return -EOPNOTSUPP; return -EOPNOTSUPP;
bnxt_modify_rss(bp, NULL, rxfh); bnxt_modify_rss(bp, NULL, NULL, rxfh);
bnxt_clear_usr_fltrs(bp, false); bnxt_clear_usr_fltrs(bp, false);
if (netif_running(bp->dev)) { if (netif_running(bp->dev)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment