From: Jiri Pirko <jiri@resnulli•us>
To: netdev@vger•kernel.org
Cc: davem@davemloft•net, nogahf@mellanox•com, jhs@mojatatu•com,
xiyou.wangcong@gmail•com, mlxsw@mellanox•com, andrew@lunn•ch,
vivien.didelot@savoirfairelinux•com, f.fainelli@gmail•com,
michael.chan@broadcom•com, ganeshgr@chelsio•com,
saeedm@mellanox•com, matanb@mellanox•com, leonro@mellanox•com,
idosch@mellanox•com, jakub.kicinski@netronome•com,
simon.horman@netronome•com, pieter.jansenvanvuuren@netronome•com,
john.hurley@netronome•com, alexander.h.duyck@intel•com,
ogerlitz@mellanox•com, john.fastabend@gmail•com
Subject: [patch net-next RFC 8/9] mlxsw: spectrum: Support RED xstats
Date: Mon, 30 Oct 2017 09:56:12 +0100 [thread overview]
Message-ID: <20171030085613.8697-9-jiri@resnulli.us> (raw)
In-Reply-To: <20171030085613.8697-1-jiri@resnulli.us>
From: Nogah Frankel <nogahf@mellanox•com>
Add support for ndo_setup_tc with enum tc_setup_type value of
TC_SETUP_RED_XSTATS. This call returns the RED qdisc xstats from the cache
if the handle ID that is asked for matching the root qdisc ID and fails
otherwise.
Signed-off-by: Nogah Frankel <nogahf@mellanox•com>
Signed-off-by: Jiri Pirko <jiri@mellanox•com>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 9 ++++
.../net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 51 ++++++++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index de81e9c..f3cf1d1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -48,6 +48,7 @@
#include <linux/notifier.h>
#include <net/psample.h>
#include <net/pkt_cls.h>
+#include <net/red.h>
#include "port.h"
#include "core.h"
@@ -211,6 +212,14 @@ enum mlxsw_sp_qdisc_type {
struct mlxsw_sp_qdisc {
u32 handle;
enum mlxsw_sp_qdisc_type type;
+ struct red_stats xstats_base;
+ union {
+ struct {
+ u64 tail_drop_base;
+ u64 ecn_base;
+ u64 wred_drop_base;
+ } red;
+ } xstats;
};
/* No need an internal lock; At worse - miss a single periodic iteration */
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
index e9d289e..4c941f7 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
@@ -36,6 +36,7 @@
#include <linux/errno.h>
#include <linux/netdevice.h>
#include <net/pkt_cls.h>
+#include <net/red.h>
#include "spectrum.h"
#include "reg.h"
@@ -77,6 +78,27 @@ mlxsw_sp_tclass_congestion_disable(struct mlxsw_sp_port *mlxsw_sp_port,
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(cwtpm), cwtpm_cmd);
}
+static void
+mlxsw_sp_setup_tc_qdisc_clean_stats(struct mlxsw_sp_port *mlxsw_sp_port,
+ struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
+ int tclass_num)
+{
+ struct red_stats *xstats_base = &mlxsw_sp_qdisc->xstats_base;
+ struct mlxsw_sp_port_xstats *xstats;
+
+ xstats = &mlxsw_sp_port->periodic_hw_stats.xstats;
+
+ switch (mlxsw_sp_qdisc->type) {
+ case MLXSW_SP_QDISC_RED:
+ xstats_base->prob_mark = xstats->ecn;
+ xstats_base->prob_drop = xstats->wred_drop[tclass_num];
+ xstats_base->pdrop = xstats->tail_drop[tclass_num];
+ break;
+ default:
+ break;
+ }
+}
+
static int
mlxsw_sp_qdisc_red_replace(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
@@ -101,6 +123,11 @@ mlxsw_sp_qdisc_red_replace(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
goto out;
mlxsw_sp_qdisc->type = MLXSW_SP_QDISC_RED;
+ if (mlxsw_sp_qdisc->handle != handle)
+ mlxsw_sp_setup_tc_qdisc_clean_stats(mlxsw_sp_port,
+ mlxsw_sp_qdisc,
+ tclass_num);
+
mlxsw_sp_qdisc->handle = handle;
out:
@@ -124,6 +151,26 @@ mlxsw_sp_qdisc_red_destroy(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
return err;
}
+static int
+mlxsw_sp_qdisc_get_red_xstats(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
+ struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
+ int tclass_num, struct red_stats *res)
+{
+ struct red_stats *xstats_base = &mlxsw_sp_qdisc->xstats_base;
+ struct mlxsw_sp_port_xstats *xstats;
+
+ if (mlxsw_sp_qdisc->handle != handle ||
+ mlxsw_sp_qdisc->type != MLXSW_SP_QDISC_RED)
+ return -EOPNOTSUPP;
+
+ xstats = &mlxsw_sp_port->periodic_hw_stats.xstats;
+
+ res->prob_drop = xstats->wred_drop[tclass_num] - xstats_base->prob_drop;
+ res->prob_mark = xstats->ecn - xstats_base->prob_mark;
+ res->pdrop = xstats->tail_drop[tclass_num] - xstats_base->pdrop;
+ return 0;
+}
+
#define MLXSW_SP_PORT_DEFAULT_TCLASS 0
int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
@@ -146,6 +193,10 @@ int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
case TC_RED_DESTROY:
return mlxsw_sp_qdisc_red_destroy(mlxsw_sp_port, p->handle,
mlxsw_sp_qdisc, tclass_num);
+ case TC_RED_XSTATS:
+ return mlxsw_sp_qdisc_get_red_xstats(mlxsw_sp_port, p->handle,
+ mlxsw_sp_qdisc, tclass_num,
+ p->xstats);
default:
return -EOPNOTSUPP;
}
--
2.9.5
next prev parent reply other threads:[~2017-10-30 8:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-30 8:56 [patch net-next RFC 0/9] qdisc RED offload Jiri Pirko
2017-10-30 8:56 ` [patch net-next RFC 1/9] net_sch: red: Add offload ability to RED qdisc Jiri Pirko
2017-10-30 12:20 ` David Miller
2017-10-30 13:54 ` Nogah Frankel
2017-10-30 19:24 ` David Ahern
2017-10-31 7:41 ` Jiri Pirko
2017-10-31 14:59 ` David Ahern
2017-10-31 15:03 ` Jiri Pirko
2017-10-30 12:47 ` Roman Mashak
2017-10-30 14:10 ` Nogah Frankel
2017-10-30 8:56 ` [patch net-next RFC 2/9] net_sch: mqprio: Change TC_SETUP_MQPRIO to TC_SETUP_QDISC_MQPRIO Jiri Pirko
2017-11-01 15:31 ` Simon Horman
2017-11-02 6:48 ` Jiri Pirko
2017-10-30 8:56 ` [patch net-next RFC 3/9] net_sch: cbs: Change TC_SETUP_CBS to TC_SETUP_QDISC_CBS Jiri Pirko
2017-10-30 8:56 ` [patch net-next RFC 4/9] mlxsw: reg: Add cwtp & cwtpm registers Jiri Pirko
2017-10-30 8:56 ` [patch net-next RFC 5/9] mlxsw: spectrum: Support RED qdisc offload Jiri Pirko
2017-10-30 8:56 ` [patch net-next RFC 6/9] mlxsw: reg: Add ext and tc-cong counter groups Jiri Pirko
2017-10-30 8:56 ` [patch net-next RFC 7/9] mlxsw: spectrum: Collect tclass related stats periodically Jiri Pirko
2017-10-30 8:56 ` Jiri Pirko [this message]
2017-10-30 8:56 ` [patch net-next RFC 9/9] mlxsw: spectrum: Support general qdisc stats Jiri Pirko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171030085613.8697-9-jiri@resnulli.us \
--to=jiri@resnulli$(echo .)us \
--cc=alexander.h.duyck@intel$(echo .)com \
--cc=andrew@lunn$(echo .)ch \
--cc=davem@davemloft$(echo .)net \
--cc=f.fainelli@gmail$(echo .)com \
--cc=ganeshgr@chelsio$(echo .)com \
--cc=idosch@mellanox$(echo .)com \
--cc=jakub.kicinski@netronome$(echo .)com \
--cc=jhs@mojatatu$(echo .)com \
--cc=john.fastabend@gmail$(echo .)com \
--cc=john.hurley@netronome$(echo .)com \
--cc=leonro@mellanox$(echo .)com \
--cc=matanb@mellanox$(echo .)com \
--cc=michael.chan@broadcom$(echo .)com \
--cc=mlxsw@mellanox$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nogahf@mellanox$(echo .)com \
--cc=ogerlitz@mellanox$(echo .)com \
--cc=pieter.jansenvanvuuren@netronome$(echo .)com \
--cc=saeedm@mellanox$(echo .)com \
--cc=simon.horman@netronome$(echo .)com \
--cc=vivien.didelot@savoirfairelinux$(echo .)com \
--cc=xiyou.wangcong@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox