Skip to content

Commit 036b9e7

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: abm: allow to opt-out of RED offload
FW team asks to be able to not support RED even if NIC is capable of buffering for testing and experimentation. Add an opt-out flag. Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Dirk van der Merwe <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9c46ae0 commit 036b9e7

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

drivers/net/ethernet/netronome/nfp/abm/ctrl.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#define NFP_NUM_BANDS_SYM_NAME "_abi_pci_dscp_num_band_%u"
1818
#define NFP_ACT_MASK_SYM_NAME "_abi_nfd_out_q_actions_%u"
1919

20+
#define NFP_RED_SUPPORT_SYM_NAME "_abi_nfd_out_red_offload_%u"
21+
2022
#define NFP_QLVL_SYM_NAME "_abi_nfd_out_q_lvls_%u%s"
2123
#define NFP_QLVL_STRIDE 16
2224
#define NFP_QLVL_BLOG_BYTES 0
@@ -358,6 +360,12 @@ int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm)
358360

359361
abm->pf_id = nfp_cppcore_pcie_unit(pf->cpp);
360362

363+
/* Check if Qdisc offloads are supported */
364+
res = nfp_pf_rtsym_read_optional(pf, NFP_RED_SUPPORT_SYM_NAME, 1);
365+
if (res < 0)
366+
return res;
367+
abm->red_support = res;
368+
361369
/* Read count of prios and prio bands */
362370
res = nfp_pf_rtsym_read_optional(pf, NFP_NUM_BANDS_SYM_NAME, 1);
363371
if (res < 0)
@@ -390,6 +398,9 @@ int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm)
390398
}
391399

392400
/* Find level and stat symbols */
401+
if (!abm->red_support)
402+
return 0;
403+
393404
sym = nfp_abm_ctrl_find_q_rtsym(abm, NFP_QLVL_SYM_NAME,
394405
NFP_QLVL_STRIDE);
395406
if (IS_ERR(sym))

drivers/net/ethernet/netronome/nfp/abm/main.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ static int nfp_abm_eswitch_set_switchdev(struct nfp_abm *abm)
207207
struct nfp_net *nn;
208208
int err;
209209

210+
if (!abm->red_support)
211+
return -EOPNOTSUPP;
212+
210213
err = nfp_abm_ctrl_qm_enable(abm);
211214
if (err)
212215
return err;
@@ -418,12 +421,26 @@ nfp_abm_port_get_stats_strings(struct nfp_app *app, struct nfp_port *port,
418421
return data;
419422
}
420423

424+
static int nfp_abm_fw_init_reset(struct nfp_abm *abm)
425+
{
426+
unsigned int i;
427+
428+
if (!abm->red_support)
429+
return 0;
430+
431+
for (i = 0; i < abm->num_bands * NFP_NET_MAX_RX_RINGS; i++) {
432+
__nfp_abm_ctrl_set_q_lvl(abm, i, NFP_ABM_LVL_INFINITY);
433+
__nfp_abm_ctrl_set_q_act(abm, i, NFP_ABM_ACT_DROP);
434+
}
435+
436+
return nfp_abm_ctrl_qm_disable(abm);
437+
}
438+
421439
static int nfp_abm_init(struct nfp_app *app)
422440
{
423441
struct nfp_pf *pf = app->pf;
424442
struct nfp_reprs *reprs;
425443
struct nfp_abm *abm;
426-
unsigned int i;
427444
int err;
428445

429446
if (!pf->eth_tbl) {
@@ -460,18 +477,14 @@ static int nfp_abm_init(struct nfp_app *app)
460477
sizeof(*abm->thresholds), GFP_KERNEL);
461478
if (!abm->thresholds)
462479
goto err_free_thresh_umap;
463-
for (i = 0; i < abm->num_bands * NFP_NET_MAX_RX_RINGS; i++)
464-
__nfp_abm_ctrl_set_q_lvl(abm, i, NFP_ABM_LVL_INFINITY);
465480

466481
abm->actions = kvcalloc(abm->num_thresholds, sizeof(*abm->actions),
467482
GFP_KERNEL);
468483
if (!abm->actions)
469484
goto err_free_thresh;
470-
for (i = 0; i < abm->num_bands * NFP_NET_MAX_RX_RINGS; i++)
471-
__nfp_abm_ctrl_set_q_act(abm, i, NFP_ABM_ACT_DROP);
472485

473486
/* We start in legacy mode, make sure advanced queuing is disabled */
474-
err = nfp_abm_ctrl_qm_disable(abm);
487+
err = nfp_abm_fw_init_reset(abm);
475488
if (err)
476489
goto err_free_act;
477490

drivers/net/ethernet/netronome/nfp/abm/main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ enum nfp_abm_q_action {
4040
* @app: back pointer to nfp_app
4141
* @pf_id: ID of our PF link
4242
*
43+
* @red_support: is RED offload supported
4344
* @num_prios: number of supported DSCP priorities
4445
* @num_bands: number of supported DSCP priority bands
4546
* @action_mask: bitmask of supported actions
@@ -63,6 +64,7 @@ struct nfp_abm {
6364
struct nfp_app *app;
6465
unsigned int pf_id;
6566

67+
unsigned int red_support;
6668
unsigned int num_prios;
6769
unsigned int num_bands;
6870
unsigned int action_mask;

0 commit comments

Comments
 (0)