Commit 3a448205 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: abm: map per-band symbols

In preparation for multi-band RED offload if FW is capable map
the extended symbols which will allow us to set per-band parameters
and read stats.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarJohn Hurley <john.hurley@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e432abfb
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* Copyright (C) 2018 Netronome Systems, Inc. */ /* Copyright (C) 2018 Netronome Systems, Inc. */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/log2.h>
#include "../nfpcore/nfp_cpp.h" #include "../nfpcore/nfp_cpp.h"
#include "../nfpcore/nfp_nffw.h" #include "../nfpcore/nfp_nffw.h"
...@@ -11,13 +12,16 @@ ...@@ -11,13 +12,16 @@
#include "../nfp_net.h" #include "../nfp_net.h"
#include "main.h" #include "main.h"
#define NFP_QLVL_SYM_NAME "_abi_nfd_out_q_lvls_%u" #define NFP_NUM_PRIOS_SYM_NAME "_abi_pci_dscp_num_prio_%u"
#define NFP_NUM_BANDS_SYM_NAME "_abi_pci_dscp_num_band_%u"
#define NFP_QLVL_SYM_NAME "_abi_nfd_out_q_lvls_%u%s"
#define NFP_QLVL_STRIDE 16 #define NFP_QLVL_STRIDE 16
#define NFP_QLVL_BLOG_BYTES 0 #define NFP_QLVL_BLOG_BYTES 0
#define NFP_QLVL_BLOG_PKTS 4 #define NFP_QLVL_BLOG_PKTS 4
#define NFP_QLVL_THRS 8 #define NFP_QLVL_THRS 8
#define NFP_QMSTAT_SYM_NAME "_abi_nfdqm%u_stats" #define NFP_QMSTAT_SYM_NAME "_abi_nfdqm%u_stats%s"
#define NFP_QMSTAT_STRIDE 32 #define NFP_QMSTAT_STRIDE 32
#define NFP_QMSTAT_NON_STO 0 #define NFP_QMSTAT_NON_STO 0
#define NFP_QMSTAT_STO 8 #define NFP_QMSTAT_STO 8
...@@ -189,30 +193,56 @@ nfp_abm_ctrl_find_rtsym(struct nfp_pf *pf, const char *name, unsigned int size) ...@@ -189,30 +193,56 @@ nfp_abm_ctrl_find_rtsym(struct nfp_pf *pf, const char *name, unsigned int size)
} }
static const struct nfp_rtsym * static const struct nfp_rtsym *
nfp_abm_ctrl_find_q_rtsym(struct nfp_pf *pf, const char *name, nfp_abm_ctrl_find_q_rtsym(struct nfp_abm *abm, const char *name_fmt,
unsigned int size) size_t size)
{ {
return nfp_abm_ctrl_find_rtsym(pf, name, size * NFP_NET_MAX_RX_RINGS); char pf_symbol[64];
size = array3_size(size, abm->num_bands, NFP_NET_MAX_RX_RINGS);
snprintf(pf_symbol, sizeof(pf_symbol), name_fmt,
abm->pf_id, nfp_abm_has_prio(abm) ? "_per_band" : "");
return nfp_abm_ctrl_find_rtsym(abm->app->pf, pf_symbol, size);
} }
int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm) int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm)
{ {
struct nfp_pf *pf = abm->app->pf; struct nfp_pf *pf = abm->app->pf;
const struct nfp_rtsym *sym; const struct nfp_rtsym *sym;
unsigned int pf_id; int res;
char pf_symbol[64];
pf_id = nfp_cppcore_pcie_unit(pf->cpp); abm->pf_id = nfp_cppcore_pcie_unit(pf->cpp);
abm->pf_id = pf_id;
/* Read count of prios and prio bands */
res = nfp_pf_rtsym_read_optional(pf, NFP_NUM_BANDS_SYM_NAME, 1);
if (res < 0)
return res;
abm->num_bands = res;
res = nfp_pf_rtsym_read_optional(pf, NFP_NUM_PRIOS_SYM_NAME, 1);
if (res < 0)
return res;
abm->num_prios = res;
/* Check values are sane, U16_MAX is arbitrarily chosen as max */
if (!is_power_of_2(abm->num_bands) || !is_power_of_2(abm->num_prios) ||
abm->num_bands > U16_MAX || abm->num_prios > U16_MAX ||
(abm->num_bands == 1) != (abm->num_prios == 1)) {
nfp_err(pf->cpp,
"invalid priomap description num bands: %u and num prios: %u\n",
abm->num_bands, abm->num_prios);
return -EINVAL;
}
snprintf(pf_symbol, sizeof(pf_symbol), NFP_QLVL_SYM_NAME, pf_id); /* Find level and stat symbols */
sym = nfp_abm_ctrl_find_q_rtsym(pf, pf_symbol, NFP_QLVL_STRIDE); sym = nfp_abm_ctrl_find_q_rtsym(abm, NFP_QLVL_SYM_NAME,
NFP_QLVL_STRIDE);
if (IS_ERR(sym)) if (IS_ERR(sym))
return PTR_ERR(sym); return PTR_ERR(sym);
abm->q_lvls = sym; abm->q_lvls = sym;
snprintf(pf_symbol, sizeof(pf_symbol), NFP_QMSTAT_SYM_NAME, pf_id); sym = nfp_abm_ctrl_find_q_rtsym(abm, NFP_QMSTAT_SYM_NAME,
sym = nfp_abm_ctrl_find_q_rtsym(pf, pf_symbol, NFP_QMSTAT_STRIDE); NFP_QMSTAT_STRIDE);
if (IS_ERR(sym)) if (IS_ERR(sym))
return PTR_ERR(sym); return PTR_ERR(sym);
abm->qm_stats = sym; abm->qm_stats = sym;
......
...@@ -27,6 +27,9 @@ struct nfp_net; ...@@ -27,6 +27,9 @@ struct nfp_net;
* @app: back pointer to nfp_app * @app: back pointer to nfp_app
* @pf_id: ID of our PF link * @pf_id: ID of our PF link
* *
* @num_prios: number of supported DSCP priorities
* @num_bands: number of supported DSCP priority bands
*
* @thresholds: current threshold configuration * @thresholds: current threshold configuration
* @threshold_undef: bitmap of thresholds which have not been set * @threshold_undef: bitmap of thresholds which have not been set
* @num_thresholds: number of @thresholds and bits in @threshold_undef * @num_thresholds: number of @thresholds and bits in @threshold_undef
...@@ -40,6 +43,9 @@ struct nfp_abm { ...@@ -40,6 +43,9 @@ struct nfp_abm {
struct nfp_app *app; struct nfp_app *app;
unsigned int pf_id; unsigned int pf_id;
unsigned int num_prios;
unsigned int num_bands;
u32 *thresholds; u32 *thresholds;
unsigned long *threshold_undef; unsigned long *threshold_undef;
size_t num_thresholds; size_t num_thresholds;
...@@ -166,6 +172,11 @@ struct nfp_abm_link { ...@@ -166,6 +172,11 @@ struct nfp_abm_link {
struct radix_tree_root qdiscs; struct radix_tree_root qdiscs;
}; };
static inline bool nfp_abm_has_prio(struct nfp_abm *abm)
{
return abm->num_bands > 1;
}
void nfp_abm_qdisc_offload_update(struct nfp_abm_link *alink); void nfp_abm_qdisc_offload_update(struct nfp_abm_link *alink);
int nfp_abm_setup_root(struct net_device *netdev, struct nfp_abm_link *alink, int nfp_abm_setup_root(struct net_device *netdev, struct nfp_abm_link *alink,
struct tc_root_qopt_offload *opt); struct tc_root_qopt_offload *opt);
......
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