Skip to content

Commit

Permalink
nfp: abm: allow to opt-out of RED offload
Browse files Browse the repository at this point in the history
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 <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed Dec 16, 2018
1 parent 9c46ae0 commit 036b9e7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
11 changes: 11 additions & 0 deletions drivers/net/ethernet/netronome/nfp/abm/ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#define NFP_NUM_BANDS_SYM_NAME "_abi_pci_dscp_num_band_%u"
#define NFP_ACT_MASK_SYM_NAME "_abi_nfd_out_q_actions_%u"

#define NFP_RED_SUPPORT_SYM_NAME "_abi_nfd_out_red_offload_%u"

#define NFP_QLVL_SYM_NAME "_abi_nfd_out_q_lvls_%u%s"
#define NFP_QLVL_STRIDE 16
#define NFP_QLVL_BLOG_BYTES 0
Expand Down Expand Up @@ -358,6 +360,12 @@ int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm)

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

/* Check if Qdisc offloads are supported */
res = nfp_pf_rtsym_read_optional(pf, NFP_RED_SUPPORT_SYM_NAME, 1);
if (res < 0)
return res;
abm->red_support = res;

/* Read count of prios and prio bands */
res = nfp_pf_rtsym_read_optional(pf, NFP_NUM_BANDS_SYM_NAME, 1);
if (res < 0)
Expand Down Expand Up @@ -390,6 +398,9 @@ int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm)
}

/* Find level and stat symbols */
if (!abm->red_support)
return 0;

sym = nfp_abm_ctrl_find_q_rtsym(abm, NFP_QLVL_SYM_NAME,
NFP_QLVL_STRIDE);
if (IS_ERR(sym))
Expand Down
25 changes: 19 additions & 6 deletions drivers/net/ethernet/netronome/nfp/abm/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ static int nfp_abm_eswitch_set_switchdev(struct nfp_abm *abm)
struct nfp_net *nn;
int err;

if (!abm->red_support)
return -EOPNOTSUPP;

err = nfp_abm_ctrl_qm_enable(abm);
if (err)
return err;
Expand Down Expand Up @@ -418,12 +421,26 @@ nfp_abm_port_get_stats_strings(struct nfp_app *app, struct nfp_port *port,
return data;
}

static int nfp_abm_fw_init_reset(struct nfp_abm *abm)
{
unsigned int i;

if (!abm->red_support)
return 0;

for (i = 0; i < abm->num_bands * NFP_NET_MAX_RX_RINGS; i++) {
__nfp_abm_ctrl_set_q_lvl(abm, i, NFP_ABM_LVL_INFINITY);
__nfp_abm_ctrl_set_q_act(abm, i, NFP_ABM_ACT_DROP);
}

return nfp_abm_ctrl_qm_disable(abm);
}

static int nfp_abm_init(struct nfp_app *app)
{
struct nfp_pf *pf = app->pf;
struct nfp_reprs *reprs;
struct nfp_abm *abm;
unsigned int i;
int err;

if (!pf->eth_tbl) {
Expand Down Expand Up @@ -460,18 +477,14 @@ static int nfp_abm_init(struct nfp_app *app)
sizeof(*abm->thresholds), GFP_KERNEL);
if (!abm->thresholds)
goto err_free_thresh_umap;
for (i = 0; i < abm->num_bands * NFP_NET_MAX_RX_RINGS; i++)
__nfp_abm_ctrl_set_q_lvl(abm, i, NFP_ABM_LVL_INFINITY);

abm->actions = kvcalloc(abm->num_thresholds, sizeof(*abm->actions),
GFP_KERNEL);
if (!abm->actions)
goto err_free_thresh;
for (i = 0; i < abm->num_bands * NFP_NET_MAX_RX_RINGS; i++)
__nfp_abm_ctrl_set_q_act(abm, i, NFP_ABM_ACT_DROP);

/* We start in legacy mode, make sure advanced queuing is disabled */
err = nfp_abm_ctrl_qm_disable(abm);
err = nfp_abm_fw_init_reset(abm);
if (err)
goto err_free_act;

Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/netronome/nfp/abm/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum nfp_abm_q_action {
* @app: back pointer to nfp_app
* @pf_id: ID of our PF link
*
* @red_support: is RED offload supported
* @num_prios: number of supported DSCP priorities
* @num_bands: number of supported DSCP priority bands
* @action_mask: bitmask of supported actions
Expand All @@ -63,6 +64,7 @@ struct nfp_abm {
struct nfp_app *app;
unsigned int pf_id;

unsigned int red_support;
unsigned int num_prios;
unsigned int num_bands;
unsigned int action_mask;
Expand Down

0 comments on commit 036b9e7

Please sign in to comment.