Commit 036b9e7c authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

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: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarDirk van der Merwe <dirk.vandermerwe@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9c46ae0e
......@@ -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
......@@ -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)
......@@ -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))
......
......@@ -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;
......@@ -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) {
......@@ -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;
......
......@@ -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
......@@ -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;
......
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