From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: nogahf@mellanox.com, davem@davemloft.net, idosch@mellanox.com,
mlxsw@mellanox.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com
Subject: [patch net-next 06/11] mlxsw: spectrum: qdiscs: Add tclass number to the mlxsw_sp_qdisc
Date: Wed, 10 Jan 2018 15:00:02 +0100 [thread overview]
Message-ID: <20180110140007.28924-7-jiri@resnulli.us> (raw)
In-Reply-To: <20180110140007.28924-1-jiri@resnulli.us>
From: Nogah Frankel <nogahf@mellanox.com>
Tclass number is needed for most of the operations related to the qdisc in
the driver. Create a field for it in the mlxsw_sp_qdisc instead of passing
it to every function as parameter.
Signed-off-by: Nogah Frankel <nogahf@mellanox.com>
Reviewed-by: Yuval Mintz <yuvalm@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
.../net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 36 +++++++++++-----------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
index 6f7687bfa1e2..dcf6d7c932f9 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
@@ -49,6 +49,7 @@ enum mlxsw_sp_qdisc_type {
struct mlxsw_sp_qdisc {
u32 handle;
enum mlxsw_sp_qdisc_type type;
+ u8 tclass_num;
union {
struct red_stats red;
} xstats_base;
@@ -99,9 +100,9 @@ mlxsw_sp_tclass_congestion_disable(struct mlxsw_sp_port *mlxsw_sp_port,
static void
mlxsw_sp_setup_tc_qdisc_red_clean_stats(struct mlxsw_sp_port *mlxsw_sp_port,
- struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
- int tclass_num)
+ struct mlxsw_sp_qdisc *mlxsw_sp_qdisc)
{
+ u8 tclass_num = mlxsw_sp_qdisc->tclass_num;
struct mlxsw_sp_qdisc_stats *stats_base;
struct mlxsw_sp_port_xstats *xstats;
struct rtnl_link_stats64 *stats;
@@ -125,15 +126,15 @@ mlxsw_sp_setup_tc_qdisc_red_clean_stats(struct mlxsw_sp_port *mlxsw_sp_port,
static int
mlxsw_sp_qdisc_red_destroy(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
- struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
- int tclass_num)
+ struct mlxsw_sp_qdisc *mlxsw_sp_qdisc)
{
int err;
if (mlxsw_sp_qdisc->handle != handle)
return 0;
- err = mlxsw_sp_tclass_congestion_disable(mlxsw_sp_port, tclass_num);
+ err = mlxsw_sp_tclass_congestion_disable(mlxsw_sp_port,
+ mlxsw_sp_qdisc->tclass_num);
mlxsw_sp_qdisc->handle = TC_H_UNSPEC;
mlxsw_sp_qdisc->type = MLXSW_SP_QDISC_NO_QDISC;
@@ -143,10 +144,10 @@ mlxsw_sp_qdisc_red_destroy(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
static int
mlxsw_sp_qdisc_red_replace(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
- int tclass_num,
struct tc_red_qopt_offload_params *p)
{
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+ u8 tclass_num = mlxsw_sp_qdisc->tclass_num;
u32 min, max;
u64 prob;
int err = 0;
@@ -183,8 +184,7 @@ mlxsw_sp_qdisc_red_replace(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
mlxsw_sp_qdisc->type = MLXSW_SP_QDISC_RED;
if (mlxsw_sp_qdisc->handle != handle)
mlxsw_sp_setup_tc_qdisc_red_clean_stats(mlxsw_sp_port,
- mlxsw_sp_qdisc,
- tclass_num);
+ mlxsw_sp_qdisc);
mlxsw_sp_qdisc->handle = handle;
return 0;
@@ -193,16 +193,17 @@ mlxsw_sp_qdisc_red_replace(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
err = -EINVAL;
err_config:
mlxsw_sp_qdisc_red_destroy(mlxsw_sp_port, mlxsw_sp_qdisc->handle,
- mlxsw_sp_qdisc, tclass_num);
+ mlxsw_sp_qdisc);
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 *res)
{
struct red_stats *xstats_base = &mlxsw_sp_qdisc->xstats_base.red;
+ u8 tclass_num = mlxsw_sp_qdisc->tclass_num;
struct mlxsw_sp_port_xstats *xstats;
int early_drops, marks, pdrops;
@@ -229,10 +230,10 @@ mlxsw_sp_qdisc_get_red_xstats(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
static int
mlxsw_sp_qdisc_get_red_stats(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
- int tclass_num,
struct tc_qopt_offload_stats *res)
{
u64 tx_bytes, tx_packets, overlimits, drops;
+ u8 tclass_num = mlxsw_sp_qdisc->tclass_num;
struct mlxsw_sp_qdisc_stats *stats_base;
struct mlxsw_sp_port_xstats *xstats;
struct rtnl_link_stats64 *stats;
@@ -271,29 +272,26 @@ int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
struct tc_red_qopt_offload *p)
{
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc;
- int tclass_num;
if (p->parent != TC_H_ROOT)
return -EOPNOTSUPP;
mlxsw_sp_qdisc = mlxsw_sp_port->root_qdisc;
- tclass_num = MLXSW_SP_PORT_DEFAULT_TCLASS;
switch (p->command) {
case TC_RED_REPLACE:
return mlxsw_sp_qdisc_red_replace(mlxsw_sp_port, p->handle,
- mlxsw_sp_qdisc, tclass_num,
- &p->set);
+ mlxsw_sp_qdisc, &p->set);
case TC_RED_DESTROY:
return mlxsw_sp_qdisc_red_destroy(mlxsw_sp_port, p->handle,
- mlxsw_sp_qdisc, tclass_num);
+ mlxsw_sp_qdisc);
case TC_RED_XSTATS:
return mlxsw_sp_qdisc_get_red_xstats(mlxsw_sp_port, p->handle,
- mlxsw_sp_qdisc, tclass_num,
+ mlxsw_sp_qdisc,
p->xstats);
case TC_RED_STATS:
return mlxsw_sp_qdisc_get_red_stats(mlxsw_sp_port, p->handle,
- mlxsw_sp_qdisc, tclass_num,
+ mlxsw_sp_qdisc,
&p->stats);
default:
return -EOPNOTSUPP;
@@ -307,6 +305,8 @@ int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port)
if (!mlxsw_sp_port->root_qdisc)
return -ENOMEM;
+ mlxsw_sp_port->root_qdisc->tclass_num = MLXSW_SP_PORT_DEFAULT_TCLASS;
+
return 0;
}
--
2.14.3
next prev parent reply other threads:[~2018-01-10 14:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 13:59 [patch net-next 00/11] mlxsw qdisc refactoring Jiri Pirko
2018-01-10 13:59 ` [patch net-next 01/11] mlxsw: spectrum: qdiscs: Move qdisc's declarations to its designated file Jiri Pirko
2018-01-10 13:59 ` [patch net-next 02/11] net: sch: red: Change the name of the stats struct to be generic Jiri Pirko
2018-01-10 13:59 ` [patch net-next 03/11] net: sch: red: Change offloaded xstats to be incremental Jiri Pirko
2018-01-10 14:00 ` [patch net-next 04/11] mlxsw: spectrum: qdiscs: Clean qdisc statistics structs Jiri Pirko
2018-01-10 14:00 ` [patch net-next 05/11] mlxsw: spectrum: qdiscs: Make the clean stats function to be for RED only Jiri Pirko
2018-01-10 14:00 ` Jiri Pirko [this message]
2018-01-10 14:00 ` [patch net-next 07/11] mlxsw: spectrum: qdiscs: Unite all handle checks Jiri Pirko
2018-01-10 14:00 ` [patch net-next 08/11] mlxsw: spectrum: qdiscs: Add an ops struct Jiri Pirko
2018-01-10 14:00 ` [patch net-next 09/11] mlxsw: spectrum: qdiscs: Create a generic destroy function Jiri Pirko
2018-01-10 14:00 ` [patch net-next 10/11] mlxsw: spectrum: qdiscs: Create a generic replace function Jiri Pirko
2018-01-10 14:00 ` [patch net-next 11/11] mlxsw: spectrum: qdiscs: Remove qdisc before setting a new one Jiri Pirko
2018-01-10 21:08 ` [patch net-next 00/11] mlxsw qdisc refactoring David Miller
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=20180110140007.28924-7-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=jhs@mojatatu.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=nogahf@mellanox.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).