Skip to content

Commit 75fd607

Browse files
committed
Merge branch 'eth-bnxt-use-the-new-rss-api'
Jakub Kicinski says: ==================== eth: bnxt: use the new RSS API Convert bnxt from using the set_rxfh API to separate create/modify/remove callbacks. Two small extensions to the core APIs are necessary: - the ability to discard contexts if for some catastrophic reasons device can no longer provide them; - the ability to reserve space in the context for RSS table growth. The driver is adjusted to store indirection tables on u32 to make it easier to use core structs directly. With that out of the way the conversion is fairly straightforward. Since the opposition to discarding contexts was relatively mild and its what bnxt does already, I'm sticking to that. We may very well need to revisit that at a later time. v1: https://lore.kernel.org/all/[email protected]/ ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 338a93c + 46e457a commit 75fd607

File tree

6 files changed

+194
-194
lines changed

6 files changed

+194
-194
lines changed

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

Lines changed: 42 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -5970,17 +5970,20 @@ bnxt_cfg_rfs_ring_tbl_idx(struct bnxt *bp,
59705970
struct hwrm_cfa_ntuple_filter_alloc_input *req,
59715971
struct bnxt_ntuple_filter *fltr)
59725972
{
5973-
struct bnxt_rss_ctx *rss_ctx, *tmp;
59745973
u16 rxq = fltr->base.rxq;
59755974

59765975
if (fltr->base.flags & BNXT_ACT_RSS_CTX) {
5977-
list_for_each_entry_safe(rss_ctx, tmp, &bp->rss_ctx_list, list) {
5978-
if (rss_ctx->index == fltr->base.fw_vnic_id) {
5979-
struct bnxt_vnic_info *vnic = &rss_ctx->vnic;
5976+
struct ethtool_rxfh_context *ctx;
5977+
struct bnxt_rss_ctx *rss_ctx;
5978+
struct bnxt_vnic_info *vnic;
59805979

5981-
req->dst_id = cpu_to_le16(vnic->fw_vnic_id);
5982-
break;
5983-
}
5980+
ctx = xa_load(&bp->dev->ethtool->rss_ctx,
5981+
fltr->base.fw_vnic_id);
5982+
if (ctx) {
5983+
rss_ctx = ethtool_rxfh_context_priv(ctx);
5984+
vnic = &rss_ctx->vnic;
5985+
5986+
req->dst_id = cpu_to_le16(vnic->fw_vnic_id);
59845987
}
59855988
return;
59865989
}
@@ -6219,33 +6222,29 @@ static u16 bnxt_cp_ring_for_tx(struct bnxt *bp, struct bnxt_tx_ring_info *txr)
62196222
return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct);
62206223
}
62216224

6222-
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)
62236226
{
62246227
int entries;
6225-
u16 *tbl;
62266228

62276229
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
62286230
entries = BNXT_MAX_RSS_TABLE_ENTRIES_P5;
62296231
else
62306232
entries = HW_HASH_INDEX_SIZE;
62316233

62326234
bp->rss_indir_tbl_entries = entries;
6233-
tbl = kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), GFP_KERNEL);
6234-
if (!tbl)
6235+
bp->rss_indir_tbl =
6236+
kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), GFP_KERNEL);
6237+
if (!bp->rss_indir_tbl)
62356238
return -ENOMEM;
62366239

6237-
if (rss_ctx)
6238-
rss_ctx->rss_indir_tbl = tbl;
6239-
else
6240-
bp->rss_indir_tbl = tbl;
6241-
62426240
return 0;
62436241
}
62446242

6245-
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)
62466245
{
62476246
u16 max_rings, max_entries, pad, i;
6248-
u16 *rss_indir_tbl;
6247+
u32 *rss_indir_tbl;
62496248

62506249
if (!bp->rx_nr_rings)
62516250
return;
@@ -6257,7 +6256,7 @@ void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx)
62576256

62586257
max_entries = bnxt_get_rxfh_indir_size(bp->dev);
62596258
if (rss_ctx)
6260-
rss_indir_tbl = &rss_ctx->rss_indir_tbl[0];
6259+
rss_indir_tbl = ethtool_rxfh_context_indir(rss_ctx);
62616260
else
62626261
rss_indir_tbl = &bp->rss_indir_tbl[0];
62636262

@@ -6266,12 +6265,12 @@ void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx)
62666265

62676266
pad = bp->rss_indir_tbl_entries - max_entries;
62686267
if (pad)
6269-
memset(&rss_indir_tbl[i], 0, pad * sizeof(u16));
6268+
memset(&rss_indir_tbl[i], 0, pad * sizeof(*rss_indir_tbl));
62706269
}
62716270

62726271
static u16 bnxt_get_max_rss_ring(struct bnxt *bp)
62736272
{
6274-
u16 i, tbl_size, max_ring = 0;
6273+
u32 i, tbl_size, max_ring = 0;
62756274

62766275
if (!bp->rss_indir_tbl)
62776276
return 0;
@@ -6282,21 +6281,6 @@ static u16 bnxt_get_max_rss_ring(struct bnxt *bp)
62826281
return max_ring;
62836282
}
62846283

6285-
u16 bnxt_get_max_rss_ctx_ring(struct bnxt *bp)
6286-
{
6287-
u16 i, tbl_size, max_ring = 0;
6288-
struct bnxt_rss_ctx *rss_ctx;
6289-
6290-
tbl_size = bnxt_get_rxfh_indir_size(bp->dev);
6291-
6292-
list_for_each_entry(rss_ctx, &bp->rss_ctx_list, list) {
6293-
for (i = 0; i < tbl_size; i++)
6294-
max_ring = max(max_ring, rss_ctx->rss_indir_tbl[i]);
6295-
}
6296-
6297-
return max_ring;
6298-
}
6299-
63006284
int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings)
63016285
{
63026286
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
@@ -6338,7 +6322,7 @@ static void bnxt_fill_hw_rss_tbl_p5(struct bnxt *bp,
63386322
if (vnic->flags & BNXT_VNIC_NTUPLE_FLAG)
63396323
j = ethtool_rxfh_indir_default(i, bp->rx_nr_rings);
63406324
else if (vnic->flags & BNXT_VNIC_RSSCTX_FLAG)
6341-
j = vnic->rss_ctx->rss_indir_tbl[i];
6325+
j = ethtool_rxfh_context_indir(vnic->rss_ctx)[i];
63426326
else
63436327
j = bp->rss_indir_tbl[i];
63446328
rxr = &bp->rx_ring[j];
@@ -10210,10 +10194,12 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
1021010194
struct bnxt_ntuple_filter *ntp_fltr;
1021110195
int i;
1021210196

10213-
bnxt_hwrm_vnic_free_one(bp, &rss_ctx->vnic);
10214-
for (i = 0; i < BNXT_MAX_CTX_PER_VNIC; i++) {
10215-
if (vnic->fw_rss_cos_lb_ctx[i] != INVALID_HW_RING_ID)
10216-
bnxt_hwrm_vnic_ctx_free_one(bp, vnic, i);
10197+
if (netif_running(bp->dev)) {
10198+
bnxt_hwrm_vnic_free_one(bp, &rss_ctx->vnic);
10199+
for (i = 0; i < BNXT_MAX_CTX_PER_VNIC; i++) {
10200+
if (vnic->fw_rss_cos_lb_ctx[i] != INVALID_HW_RING_ID)
10201+
bnxt_hwrm_vnic_ctx_free_one(bp, vnic, i);
10202+
}
1021710203
}
1021810204
if (!all)
1021910205
return;
@@ -10234,19 +10220,17 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
1023410220
dma_free_coherent(&bp->pdev->dev, vnic->rss_table_size,
1023510221
vnic->rss_table,
1023610222
vnic->rss_table_dma_addr);
10237-
kfree(rss_ctx->rss_indir_tbl);
10238-
list_del(&rss_ctx->list);
1023910223
bp->num_rss_ctx--;
10240-
clear_bit(rss_ctx->index, bp->rss_ctx_bmap);
10241-
kfree(rss_ctx);
1024210224
}
1024310225

1024410226
static void bnxt_hwrm_realloc_rss_ctx_vnic(struct bnxt *bp)
1024510227
{
1024610228
bool set_tpa = !!(bp->flags & BNXT_FLAG_TPA);
10247-
struct bnxt_rss_ctx *rss_ctx, *tmp;
10229+
struct ethtool_rxfh_context *ctx;
10230+
unsigned long context;
1024810231

10249-
list_for_each_entry_safe(rss_ctx, tmp, &bp->rss_ctx_list, list) {
10232+
xa_for_each(&bp->dev->ethtool->rss_ctx, context, ctx) {
10233+
struct bnxt_rss_ctx *rss_ctx = ethtool_rxfh_context_priv(ctx);
1025010234
struct bnxt_vnic_info *vnic = &rss_ctx->vnic;
1025110235

1025210236
if (bnxt_hwrm_vnic_alloc(bp, vnic, 0, bp->rx_nr_rings) ||
@@ -10255,42 +10239,20 @@ static void bnxt_hwrm_realloc_rss_ctx_vnic(struct bnxt *bp)
1025510239
netdev_err(bp->dev, "Failed to restore RSS ctx %d\n",
1025610240
rss_ctx->index);
1025710241
bnxt_del_one_rss_ctx(bp, rss_ctx, true);
10242+
ethtool_rxfh_context_lost(bp->dev, rss_ctx->index);
1025810243
}
1025910244
}
1026010245
}
1026110246

10262-
struct bnxt_rss_ctx *bnxt_alloc_rss_ctx(struct bnxt *bp)
10263-
{
10264-
struct bnxt_rss_ctx *rss_ctx = NULL;
10265-
10266-
rss_ctx = kzalloc(sizeof(*rss_ctx), GFP_KERNEL);
10267-
if (rss_ctx) {
10268-
rss_ctx->vnic.rss_ctx = rss_ctx;
10269-
list_add_tail(&rss_ctx->list, &bp->rss_ctx_list);
10270-
bp->num_rss_ctx++;
10271-
}
10272-
return rss_ctx;
10273-
}
10274-
10275-
void bnxt_clear_rss_ctxs(struct bnxt *bp, bool all)
10247+
void bnxt_clear_rss_ctxs(struct bnxt *bp)
1027610248
{
10277-
struct bnxt_rss_ctx *rss_ctx, *tmp;
10249+
struct ethtool_rxfh_context *ctx;
10250+
unsigned long context;
1027810251

10279-
list_for_each_entry_safe(rss_ctx, tmp, &bp->rss_ctx_list, list)
10280-
bnxt_del_one_rss_ctx(bp, rss_ctx, all);
10252+
xa_for_each(&bp->dev->ethtool->rss_ctx, context, ctx) {
10253+
struct bnxt_rss_ctx *rss_ctx = ethtool_rxfh_context_priv(ctx);
1028110254

10282-
if (all)
10283-
bitmap_free(bp->rss_ctx_bmap);
10284-
}
10285-
10286-
static void bnxt_init_multi_rss_ctx(struct bnxt *bp)
10287-
{
10288-
bp->rss_ctx_bmap = bitmap_zalloc(BNXT_RSS_CTX_BMAP_LEN, GFP_KERNEL);
10289-
if (bp->rss_ctx_bmap) {
10290-
/* burn index 0 since we cannot have context 0 */
10291-
__set_bit(0, bp->rss_ctx_bmap);
10292-
INIT_LIST_HEAD(&bp->rss_ctx_list);
10293-
bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX;
10255+
bnxt_del_one_rss_ctx(bp, rss_ctx, false);
1029410256
}
1029510257
}
1029610258

@@ -12337,7 +12299,7 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init,
1233712299
msleep(20);
1233812300

1233912301
if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp))
12340-
bnxt_clear_rss_ctxs(bp, false);
12302+
bnxt_clear_rss_ctxs(bp);
1234112303
/* Flush rings and disable interrupts */
1234212304
bnxt_shutdown_nic(bp, irq_re_init);
1234312305

@@ -15252,8 +15214,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
1525215214

1525315215
bnxt_free_l2_filters(bp, true);
1525415216
bnxt_free_ntp_fltrs(bp, true);
15255-
if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp))
15256-
bnxt_clear_rss_ctxs(bp, true);
15217+
WARN_ON(bp->num_rss_ctx);
1525715218
clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state);
1525815219
/* Flush any pending tasks */
1525915220
cancel_work_sync(&bp->sp_task);
@@ -15723,7 +15684,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1572315684
bp->flags |= BNXT_FLAG_CHIP_P7;
1572415685
}
1572515686

15726-
rc = bnxt_alloc_rss_indir_tbl(bp, NULL);
15687+
rc = bnxt_alloc_rss_indir_tbl(bp);
1572715688
if (rc)
1572815689
goto init_err_pci_clean;
1572915690

@@ -15880,8 +15841,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1588015841
INIT_LIST_HEAD(&bp->usr_fltr_list);
1588115842

1588215843
if (BNXT_SUPPORTS_NTUPLE_VNIC(bp))
15883-
bnxt_init_multi_rss_ctx(bp);
15884-
15844+
bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX;
1588515845

1588615846
rc = register_netdev(dev);
1588715847
if (rc)
@@ -15904,8 +15864,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1590415864
bnxt_clear_int_mode(bp);
1590515865

1590615866
init_err_pci_clean:
15907-
if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp))
15908-
bnxt_clear_rss_ctxs(bp, true);
1590915867
bnxt_hwrm_func_drv_unrgtr(bp);
1591015868
bnxt_free_hwrm_resources(bp);
1591115869
bnxt_hwmon_uninit(bp);

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,19 +1286,16 @@ 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 {
1294-
struct list_head list;
12951294
struct bnxt_vnic_info vnic;
1296-
u16 *rss_indir_tbl;
12971295
u8 index;
12981296
};
12991297

13001298
#define BNXT_MAX_ETH_RSS_CTX 32
1301-
#define BNXT_RSS_CTX_BMAP_LEN (BNXT_MAX_ETH_RSS_CTX + 1)
13021299
#define BNXT_VNIC_ID_INVALID 0xffffffff
13031300

13041301
struct bnxt_hw_rings {
@@ -2331,11 +2328,9 @@ struct bnxt {
23312328
/* grp_info indexed by completion ring index */
23322329
struct bnxt_ring_grp_info *grp_info;
23332330
struct bnxt_vnic_info *vnic_info;
2334-
struct list_head rss_ctx_list;
2335-
unsigned long *rss_ctx_bmap;
23362331
u32 num_rss_ctx;
23372332
int nr_vnics;
2338-
u16 *rss_indir_tbl;
2333+
u32 *rss_indir_tbl;
23392334
u16 rss_indir_tbl_entries;
23402335
u32 rss_hash_cfg;
23412336
u32 rss_hash_delta;
@@ -2812,9 +2807,8 @@ int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp,
28122807
int bnxt_hwrm_vnic_set_tpa(struct bnxt *bp, struct bnxt_vnic_info *vnic,
28132808
u32 tpa_flags);
28142809
void bnxt_fill_ipv6_mask(__be32 mask[4]);
2815-
int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx);
2816-
void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx);
2817-
u16 bnxt_get_max_rss_ctx_ring(struct bnxt *bp);
2810+
void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp,
2811+
struct ethtool_rxfh_context *rss_ctx);
28182812
int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings);
28192813
int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic);
28202814
int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic,
@@ -2848,8 +2842,7 @@ int bnxt_hwrm_vnic_rss_cfg_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic);
28482842
int __bnxt_setup_vnic_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic);
28492843
void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
28502844
bool all);
2851-
struct bnxt_rss_ctx *bnxt_alloc_rss_ctx(struct bnxt *bp);
2852-
void bnxt_clear_rss_ctxs(struct bnxt *bp, bool all);
2845+
void bnxt_clear_rss_ctxs(struct bnxt *bp);
28532846
int bnxt_open_nic(struct bnxt *, bool, bool);
28542847
int bnxt_half_open_nic(struct bnxt *bp);
28552848
void bnxt_half_close_nic(struct bnxt *bp);

0 commit comments

Comments
 (0)