diff mbox series

[RFC,net-next,2/2] net: dsa: felix: offload port priority

Message ID 20210113154139.1803705-3-olteanv@gmail.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series Port-based priority on DSA switches using tc-matchall | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 4 maintainers not CCed: claudiu.manoil@nxp.com vladimir.oltean@nxp.com UNGLinuxDriver@microchip.com alexandre.belloni@bootlin.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 27 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Vladimir Oltean Jan. 13, 2021, 3:41 p.m. UTC
From: Vladimir Oltean <vladimir.oltean@nxp.com>

Even though we should really share the implementation with the ocelot
switchdev driver, that one needs a little bit of rework first, since its
struct ocelot_port_tc only supports one tc matchall action at a time,
which at the moment is used for port policers. Whereas DSA keeps a list
of port-based actions in struct dsa_slave_priv::mall_tc_list, so it is
much more easily extensible. It is too tempting to add the implementation
for the port priority directly in Felix at the moment, which is what we
do.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/dsa/ocelot/felix.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Andrew Lunn Jan. 13, 2021, 11:36 p.m. UTC | #1
On Wed, Jan 13, 2021 at 05:41:39PM +0200, Vladimir Oltean wrote:
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> Even though we should really share the implementation with the ocelot
> switchdev driver, that one needs a little bit of rework first, since its
> struct ocelot_port_tc only supports one tc matchall action at a time,
> which at the moment is used for port policers. Whereas DSA keeps a list
> of port-based actions in struct dsa_slave_priv::mall_tc_list, so it is
> much more easily extensible. It is too tempting to add the implementation
> for the port priority directly in Felix at the moment, which is what we
> do.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  drivers/net/dsa/ocelot/felix.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
> index 768a74dc462a..5cc42c3aaf0d 100644
> --- a/drivers/net/dsa/ocelot/felix.c
> +++ b/drivers/net/dsa/ocelot/felix.c
> @@ -739,6 +739,20 @@ static void felix_port_policer_del(struct dsa_switch *ds, int port)
>  	ocelot_port_policer_del(ocelot, port);
>  }
>  
> +static int felix_port_priority_set(struct dsa_switch *ds, int port,
> +				   struct dsa_mall_skbedit_tc_entry *skbedit)
> +{
> +	struct ocelot *ocelot = ds->priv;
> +
> +	ocelot_rmw_gix(ocelot,
> +		       ANA_PORT_QOS_CFG_QOS_DEFAULT_VAL(skbedit->priority),

No range check? Seems like -ERANGE or similar would help avoid
surprises when somebody asks for an unsupported priority and it gets
masked to something much lower.

       Andrew
Florian Fainelli Jan. 13, 2021, 11:37 p.m. UTC | #2
On 1/13/21 3:36 PM, Andrew Lunn wrote:
> On Wed, Jan 13, 2021 at 05:41:39PM +0200, Vladimir Oltean wrote:
>> From: Vladimir Oltean <vladimir.oltean@nxp.com>
>>
>> Even though we should really share the implementation with the ocelot
>> switchdev driver, that one needs a little bit of rework first, since its
>> struct ocelot_port_tc only supports one tc matchall action at a time,
>> which at the moment is used for port policers. Whereas DSA keeps a list
>> of port-based actions in struct dsa_slave_priv::mall_tc_list, so it is
>> much more easily extensible. It is too tempting to add the implementation
>> for the port priority directly in Felix at the moment, which is what we
>> do.
>>
>> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
>> ---
>>  drivers/net/dsa/ocelot/felix.c | 15 +++++++++++++++
>>  1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
>> index 768a74dc462a..5cc42c3aaf0d 100644
>> --- a/drivers/net/dsa/ocelot/felix.c
>> +++ b/drivers/net/dsa/ocelot/felix.c
>> @@ -739,6 +739,20 @@ static void felix_port_policer_del(struct dsa_switch *ds, int port)
>>  	ocelot_port_policer_del(ocelot, port);
>>  }
>>  
>> +static int felix_port_priority_set(struct dsa_switch *ds, int port,
>> +				   struct dsa_mall_skbedit_tc_entry *skbedit)
>> +{
>> +	struct ocelot *ocelot = ds->priv;
>> +
>> +	ocelot_rmw_gix(ocelot,
>> +		       ANA_PORT_QOS_CFG_QOS_DEFAULT_VAL(skbedit->priority),
> 
> No range check? Seems like -ERANGE or similar would help avoid
> surprises when somebody asks for an unsupported priority and it gets
> masked to something much lower.

You are passing the whole dsa_mall_skbedit_tc_entry  structure here,
only to look up priority, would it make sense for now to pass
skbedit->priority as a parameter which would be matching the function
name and what it is dealing with?
Vladimir Oltean Jan. 14, 2021, 12:57 a.m. UTC | #3
On Wed, Jan 13, 2021 at 03:37:49PM -0800, Florian Fainelli wrote:
> You are passing the whole dsa_mall_skbedit_tc_entry  structure here,
> only to look up priority, would it make sense for now to pass
> skbedit->priority as a parameter which would be matching the function
> name and what it is dealing with?

Actually I am passing a pointer to it, which should be more or less
equal in size to an integer. But I can pass just the priority, sure.
diff mbox series

Patch

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 768a74dc462a..5cc42c3aaf0d 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -739,6 +739,20 @@  static void felix_port_policer_del(struct dsa_switch *ds, int port)
 	ocelot_port_policer_del(ocelot, port);
 }
 
+static int felix_port_priority_set(struct dsa_switch *ds, int port,
+				   struct dsa_mall_skbedit_tc_entry *skbedit)
+{
+	struct ocelot *ocelot = ds->priv;
+
+	ocelot_rmw_gix(ocelot,
+		       ANA_PORT_QOS_CFG_QOS_DEFAULT_VAL(skbedit->priority),
+		       ANA_PORT_QOS_CFG_QOS_DEFAULT_VAL_M,
+		       ANA_PORT_QOS_CFG,
+		       port);
+
+	return 0;
+}
+
 static int felix_port_setup_tc(struct dsa_switch *ds, int port,
 			       enum tc_setup_type type,
 			       void *type_data)
@@ -786,6 +800,7 @@  const struct dsa_switch_ops felix_switch_ops = {
 	.port_max_mtu		= felix_get_max_mtu,
 	.port_policer_add	= felix_port_policer_add,
 	.port_policer_del	= felix_port_policer_del,
+	.port_priority_set	= felix_port_priority_set,
 	.cls_flower_add		= felix_cls_flower_add,
 	.cls_flower_del		= felix_cls_flower_del,
 	.cls_flower_stats	= felix_cls_flower_stats,