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

nfp: abm: pass band parameter to functions

In preparation for per-band RED offload pass band parameter to
functions.  For now it will always be 0.
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 3a448205
...@@ -30,23 +30,25 @@ ...@@ -30,23 +30,25 @@
static int static int
nfp_abm_ctrl_stat(struct nfp_abm_link *alink, const struct nfp_rtsym *sym, nfp_abm_ctrl_stat(struct nfp_abm_link *alink, const struct nfp_rtsym *sym,
unsigned int stride, unsigned int offset, unsigned int i, unsigned int stride, unsigned int offset, unsigned int band,
bool is_u64, u64 *res) unsigned int queue, bool is_u64, u64 *res)
{ {
struct nfp_cpp *cpp = alink->abm->app->cpp; struct nfp_cpp *cpp = alink->abm->app->cpp;
u64 val, sym_offset; u64 val, sym_offset;
unsigned int qid;
u32 val32; u32 val32;
int err; int err;
sym_offset = (alink->queue_base + i) * stride + offset; qid = band * NFP_NET_MAX_RX_RINGS + alink->queue_base + queue;
sym_offset = qid * stride + offset;
if (is_u64) if (is_u64)
err = __nfp_rtsym_readq(cpp, sym, 3, 0, sym_offset, &val); err = __nfp_rtsym_readq(cpp, sym, 3, 0, sym_offset, &val);
else else
err = __nfp_rtsym_readl(cpp, sym, 3, 0, sym_offset, &val32); err = __nfp_rtsym_readl(cpp, sym, 3, 0, sym_offset, &val32);
if (err) { if (err) {
nfp_err(cpp, nfp_err(cpp, "RED offload reading stat failed on vNIC %d band %d queue %d (+ %d)\n",
"RED offload reading stat failed on vNIC %d queue %d\n", alink->id, band, queue, alink->queue_base);
alink->id, i);
return err; return err;
} }
...@@ -77,12 +79,12 @@ int __nfp_abm_ctrl_set_q_lvl(struct nfp_abm *abm, unsigned int id, u32 val) ...@@ -77,12 +79,12 @@ int __nfp_abm_ctrl_set_q_lvl(struct nfp_abm *abm, unsigned int id, u32 val)
return 0; return 0;
} }
int nfp_abm_ctrl_set_q_lvl(struct nfp_abm_link *alink, unsigned int queue, int nfp_abm_ctrl_set_q_lvl(struct nfp_abm_link *alink, unsigned int band,
u32 val) unsigned int queue, u32 val)
{ {
unsigned int threshold; unsigned int threshold;
threshold = alink->queue_base + queue; threshold = band * NFP_NET_MAX_RX_RINGS + alink->queue_base + queue;
return __nfp_abm_ctrl_set_q_lvl(alink->abm, threshold, val); return __nfp_abm_ctrl_set_q_lvl(alink->abm, threshold, val);
} }
...@@ -92,7 +94,7 @@ u64 nfp_abm_ctrl_stat_non_sto(struct nfp_abm_link *alink, unsigned int i) ...@@ -92,7 +94,7 @@ u64 nfp_abm_ctrl_stat_non_sto(struct nfp_abm_link *alink, unsigned int i)
u64 val; u64 val;
if (nfp_abm_ctrl_stat(alink, alink->abm->qm_stats, NFP_QMSTAT_STRIDE, if (nfp_abm_ctrl_stat(alink, alink->abm->qm_stats, NFP_QMSTAT_STRIDE,
NFP_QMSTAT_NON_STO, i, true, &val)) NFP_QMSTAT_NON_STO, 0, i, true, &val))
return 0; return 0;
return val; return val;
} }
...@@ -102,56 +104,58 @@ u64 nfp_abm_ctrl_stat_sto(struct nfp_abm_link *alink, unsigned int i) ...@@ -102,56 +104,58 @@ u64 nfp_abm_ctrl_stat_sto(struct nfp_abm_link *alink, unsigned int i)
u64 val; u64 val;
if (nfp_abm_ctrl_stat(alink, alink->abm->qm_stats, NFP_QMSTAT_STRIDE, if (nfp_abm_ctrl_stat(alink, alink->abm->qm_stats, NFP_QMSTAT_STRIDE,
NFP_QMSTAT_STO, i, true, &val)) NFP_QMSTAT_STO, 0, i, true, &val))
return 0; return 0;
return val; return val;
} }
int nfp_abm_ctrl_read_q_stats(struct nfp_abm_link *alink, unsigned int i, int nfp_abm_ctrl_read_q_stats(struct nfp_abm_link *alink, unsigned int band,
struct nfp_alink_stats *stats) unsigned int queue, struct nfp_alink_stats *stats)
{ {
int err; int err;
stats->tx_pkts = nn_readq(alink->vnic, NFP_NET_CFG_RXR_STATS(i)); stats->tx_pkts += nn_readq(alink->vnic, NFP_NET_CFG_RXR_STATS(queue));
stats->tx_bytes = nn_readq(alink->vnic, NFP_NET_CFG_RXR_STATS(i) + 8); stats->tx_bytes += nn_readq(alink->vnic,
NFP_NET_CFG_RXR_STATS(queue) + 8);
err = nfp_abm_ctrl_stat(alink, alink->abm->q_lvls, err = nfp_abm_ctrl_stat(alink, alink->abm->q_lvls, NFP_QLVL_STRIDE,
NFP_QLVL_STRIDE, NFP_QLVL_BLOG_BYTES, NFP_QLVL_BLOG_BYTES, band, queue, false,
i, false, &stats->backlog_bytes); &stats->backlog_bytes);
if (err) if (err)
return err; return err;
err = nfp_abm_ctrl_stat(alink, alink->abm->q_lvls, err = nfp_abm_ctrl_stat(alink, alink->abm->q_lvls,
NFP_QLVL_STRIDE, NFP_QLVL_BLOG_PKTS, NFP_QLVL_STRIDE, NFP_QLVL_BLOG_PKTS,
i, false, &stats->backlog_pkts); band, queue, false, &stats->backlog_pkts);
if (err) if (err)
return err; return err;
err = nfp_abm_ctrl_stat(alink, alink->abm->qm_stats, err = nfp_abm_ctrl_stat(alink, alink->abm->qm_stats,
NFP_QMSTAT_STRIDE, NFP_QMSTAT_DROP, NFP_QMSTAT_STRIDE, NFP_QMSTAT_DROP,
i, true, &stats->drops); band, queue, true, &stats->drops);
if (err) if (err)
return err; return err;
return nfp_abm_ctrl_stat(alink, alink->abm->qm_stats, return nfp_abm_ctrl_stat(alink, alink->abm->qm_stats,
NFP_QMSTAT_STRIDE, NFP_QMSTAT_ECN, NFP_QMSTAT_STRIDE, NFP_QMSTAT_ECN,
i, true, &stats->overlimits); band, queue, true, &stats->overlimits);
} }
int nfp_abm_ctrl_read_q_xstats(struct nfp_abm_link *alink, unsigned int i, int nfp_abm_ctrl_read_q_xstats(struct nfp_abm_link *alink,
unsigned int band, unsigned int queue,
struct nfp_alink_xstats *xstats) struct nfp_alink_xstats *xstats)
{ {
int err; int err;
err = nfp_abm_ctrl_stat(alink, alink->abm->qm_stats, err = nfp_abm_ctrl_stat(alink, alink->abm->qm_stats,
NFP_QMSTAT_STRIDE, NFP_QMSTAT_DROP, NFP_QMSTAT_STRIDE, NFP_QMSTAT_DROP,
i, true, &xstats->pdrop); band, queue, true, &xstats->pdrop);
if (err) if (err)
return err; return err;
return nfp_abm_ctrl_stat(alink, alink->abm->qm_stats, return nfp_abm_ctrl_stat(alink, alink->abm->qm_stats,
NFP_QMSTAT_STRIDE, NFP_QMSTAT_ECN, NFP_QMSTAT_STRIDE, NFP_QMSTAT_ECN,
i, true, &xstats->ecn_marked); band, queue, true, &xstats->ecn_marked);
} }
int nfp_abm_ctrl_qm_enable(struct nfp_abm *abm) int nfp_abm_ctrl_qm_enable(struct nfp_abm *abm)
......
...@@ -188,11 +188,13 @@ int nfp_abm_setup_tc_mq(struct net_device *netdev, struct nfp_abm_link *alink, ...@@ -188,11 +188,13 @@ int nfp_abm_setup_tc_mq(struct net_device *netdev, struct nfp_abm_link *alink,
void nfp_abm_ctrl_read_params(struct nfp_abm_link *alink); void nfp_abm_ctrl_read_params(struct nfp_abm_link *alink);
int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm); int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm);
int __nfp_abm_ctrl_set_q_lvl(struct nfp_abm *abm, unsigned int id, u32 val); int __nfp_abm_ctrl_set_q_lvl(struct nfp_abm *abm, unsigned int id, u32 val);
int nfp_abm_ctrl_set_q_lvl(struct nfp_abm_link *alink, unsigned int queue, int nfp_abm_ctrl_set_q_lvl(struct nfp_abm_link *alink, unsigned int band,
u32 val); unsigned int queue, u32 val);
int nfp_abm_ctrl_read_q_stats(struct nfp_abm_link *alink, unsigned int i, int nfp_abm_ctrl_read_q_stats(struct nfp_abm_link *alink,
unsigned int band, unsigned int queue,
struct nfp_alink_stats *stats); struct nfp_alink_stats *stats);
int nfp_abm_ctrl_read_q_xstats(struct nfp_abm_link *alink, unsigned int i, int nfp_abm_ctrl_read_q_xstats(struct nfp_abm_link *alink,
unsigned int band, unsigned int queue,
struct nfp_alink_xstats *xstats); struct nfp_alink_xstats *xstats);
u64 nfp_abm_ctrl_stat_non_sto(struct nfp_abm_link *alink, unsigned int i); u64 nfp_abm_ctrl_stat_non_sto(struct nfp_abm_link *alink, unsigned int i);
u64 nfp_abm_ctrl_stat_sto(struct nfp_abm_link *alink, unsigned int i); u64 nfp_abm_ctrl_stat_sto(struct nfp_abm_link *alink, unsigned int i);
......
...@@ -51,15 +51,15 @@ nfp_abm_stats_update_red(struct nfp_abm_link *alink, struct nfp_qdisc *qdisc, ...@@ -51,15 +51,15 @@ nfp_abm_stats_update_red(struct nfp_abm_link *alink, struct nfp_qdisc *qdisc,
if (!qdisc->offloaded) if (!qdisc->offloaded)
return; return;
err = nfp_abm_ctrl_read_q_stats(alink, queue, &qdisc->red.stats); err = nfp_abm_ctrl_read_q_stats(alink, 0, queue, &qdisc->red.stats);
if (err) if (err)
nfp_err(cpp, "RED stats (%d) read failed with error %d\n", nfp_err(cpp, "RED stats (%d, %d) read failed with error %d\n",
queue, err); 0, queue, err);
err = nfp_abm_ctrl_read_q_xstats(alink, queue, &qdisc->red.xstats); err = nfp_abm_ctrl_read_q_xstats(alink, 0, queue, &qdisc->red.xstats);
if (err) if (err)
nfp_err(cpp, "RED xstats (%d) read failed with error %d\n", nfp_err(cpp, "RED xstats (%d, %d) read failed with error %d\n",
queue, err); 0, queue, err);
} }
static void static void
...@@ -126,7 +126,7 @@ nfp_abm_qdisc_offload_stop(struct nfp_abm_link *alink, struct nfp_qdisc *qdisc) ...@@ -126,7 +126,7 @@ nfp_abm_qdisc_offload_stop(struct nfp_abm_link *alink, struct nfp_qdisc *qdisc)
} }
static int static int
__nfp_abm_stats_init(struct nfp_abm_link *alink, __nfp_abm_stats_init(struct nfp_abm_link *alink, unsigned int band,
unsigned int queue, struct nfp_alink_stats *prev_stats, unsigned int queue, struct nfp_alink_stats *prev_stats,
struct nfp_alink_xstats *prev_xstats) struct nfp_alink_xstats *prev_xstats)
{ {
...@@ -139,19 +139,19 @@ __nfp_abm_stats_init(struct nfp_abm_link *alink, ...@@ -139,19 +139,19 @@ __nfp_abm_stats_init(struct nfp_abm_link *alink,
backlog_pkts = prev_stats->backlog_pkts; backlog_pkts = prev_stats->backlog_pkts;
backlog_bytes = prev_stats->backlog_bytes; backlog_bytes = prev_stats->backlog_bytes;
err = nfp_abm_ctrl_read_q_stats(alink, queue, prev_stats); err = nfp_abm_ctrl_read_q_stats(alink, band, queue, prev_stats);
if (err) { if (err) {
nfp_err(alink->abm->app->cpp, nfp_err(alink->abm->app->cpp,
"RED stats init (%d) failed with error %d\n", "RED stats init (%d, %d) failed with error %d\n",
queue, err); band, queue, err);
return err; return err;
} }
err = nfp_abm_ctrl_read_q_xstats(alink, queue, prev_xstats); err = nfp_abm_ctrl_read_q_xstats(alink, band, queue, prev_xstats);
if (err) { if (err) {
nfp_err(alink->abm->app->cpp, nfp_err(alink->abm->app->cpp,
"RED xstats init (%d) failed with error %d\n", "RED xstats init (%d, %d) failed with error %d\n",
queue, err); band, queue, err);
return err; return err;
} }
...@@ -164,7 +164,7 @@ static int ...@@ -164,7 +164,7 @@ static int
nfp_abm_stats_init(struct nfp_abm_link *alink, struct nfp_qdisc *qdisc, nfp_abm_stats_init(struct nfp_abm_link *alink, struct nfp_qdisc *qdisc,
unsigned int queue) unsigned int queue)
{ {
return __nfp_abm_stats_init(alink, queue, return __nfp_abm_stats_init(alink, 0, queue,
&qdisc->red.prev_stats, &qdisc->red.prev_stats,
&qdisc->red.prev_xstats); &qdisc->red.prev_xstats);
} }
...@@ -186,7 +186,7 @@ nfp_abm_offload_compile_red(struct nfp_abm_link *alink, struct nfp_qdisc *qdisc, ...@@ -186,7 +186,7 @@ nfp_abm_offload_compile_red(struct nfp_abm_link *alink, struct nfp_qdisc *qdisc,
if (!qdisc->offload_mark) if (!qdisc->offload_mark)
return; return;
nfp_abm_ctrl_set_q_lvl(alink, queue, qdisc->red.threshold); nfp_abm_ctrl_set_q_lvl(alink, 0, queue, qdisc->red.threshold);
} }
static void static void
......
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