tc-gate offload for SJA1105 DSA switch
Subsystems (5)
Vladimir Oltean
maintainercover tc-gate offload for SJA1105 DSA switch
From: Vladimir Oltean <[email protected]>
Expose the TTEthernet hardware features of the switch using standard tc-flower actions: trap, drop, redirect and gate.
Vladimir Oltean (6):
net: dsa: export dsa_slave_dev_check and dsa_slave_to_port
net: dsa: sja1105: add static tables for virtual links
net: dsa: sja1105: make room for virtual link parsing in flower
offload
net: dsa: sja1105: support flow-based redirection via virtual links
net: dsa: sja1105: implement tc-gate using time-triggered virtual
links
docs: net: dsa: sja1105: document intended usage of virtual links
Documentation/networking/dsa/sja1105.rst | 116 +++ drivers/net/dsa/sja1105/Kconfig | 9 + drivers/net/dsa/sja1105/Makefile | 4 + drivers/net/dsa/sja1105/sja1105.h | 59 +- .../net/dsa/sja1105/sja1105_dynamic_config.c | 51 ++ drivers/net/dsa/sja1105/sja1105_flower.c | 215 ++++- drivers/net/dsa/sja1105/sja1105_main.c | 13 +- drivers/net/dsa/sja1105/sja1105_ptp.h | 13 + drivers/net/dsa/sja1105/sja1105_spi.c | 2 + .../net/dsa/sja1105/sja1105_static_config.c | 202 +++++ .../net/dsa/sja1105/sja1105_static_config.h | 65 ++ drivers/net/dsa/sja1105/sja1105_tas.c | 127 ++- drivers/net/dsa/sja1105/sja1105_tas.h | 31 + drivers/net/dsa/sja1105/sja1105_vl.c | 796 ++++++++++++++++++ drivers/net/dsa/sja1105/sja1105_vl.h | 72 ++ include/net/dsa.h | 2 + net/dsa/dsa_priv.h | 8 - net/dsa/slave.c | 9 + 18 files changed, 1742 insertions(+), 52 deletions(-) create mode 100644 drivers/net/dsa/sja1105/sja1105_vl.c create mode 100644 drivers/net/dsa/sja1105/sja1105_vl.h
Signature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH 1/6 net: dsa: export dsa_slave_dev_check and dsa_slave_to_port
From: Vladimir Oltean <[email protected]>
To be able to perform mirroring and redirection through tc-flower offloads (the implementation of which is given raw access to the flow_cls_offload structure), switch drivers need to be able to call these functions on act->dev.
---
Changes from RFC:
None.
include/net/dsa.h | 2 ++ net/dsa/dsa_priv.h | 8 -------- net/dsa/slave.c | 9 +++++++++ 3 files changed, 11 insertions(+), 8 deletions(-)
include/net/dsa.h +2 -0
@@ -739,6 +739,8 @@ int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data);int dsa_port_get_ethtool_phy_stats (struct dsa_port *dp,uint64_t *data);int dsa_port_get_phy_sset_count (struct dsa_port *dp);void dsa_port_phylink_mac_change (struct dsa_switch *ds,int port,bool up); +bool dsa_slave_dev_check (const struct net_device *dev); +struct dsa_port *dsa_slave_to_port (const struct net_device *dev);struct dsa_tag_driver {const struct dsa_device_ops *ops;
net/dsa/dsa_priv.h +0 -8
@@ -173,19 +173,11 @@ extern const struct dsa_device_ops notag_netdev_ops;void dsa_slave_mii_bus_init (struct dsa_switch *ds);int dsa_slave_create (struct dsa_port *dp);void dsa_slave_destroy (struct net_device *slave_dev); -bool dsa_slave_dev_check (const struct net_device *dev);int dsa_slave_suspend (struct net_device *slave_dev);int dsa_slave_resume (struct net_device *slave_dev);int dsa_slave_register_notifier (void );void dsa_slave_unregister_notifier (void ); -static inline struct dsa_port *dsa_slave_to_port (const struct net_device *dev) -{ -struct dsa_slave_priv *p =netdev_priv (dev); - -return p->dp; -} -static inline struct net_device *dsa_slave_to_master (const struct net_device *dev) {
net/dsa/slave.c +9 -0
@@ -62,6 +62,14 @@ static int dsa_slave_get_iflink(const struct net_device *dev)return dsa_slave_to_master (dev)->ifindex; } +struct dsa_port *dsa_slave_to_port (const struct net_device *dev) +{ +struct dsa_slave_priv *p =netdev_priv (dev); + +return p->dp; +} +EXPORT_SYMBOL_GPL (dsa_slave_to_port); +static int dsa_slave_open (struct net_device *dev) {struct net_device *master =dsa_slave_to_master (dev);
@@ -1836,6 +1844,7 @@ bool dsa_slave_dev_check(const struct net_device *dev) {return dev->netdev_ops == &dsa_slave_netdev_ops; } +EXPORT_SYMBOL_GPL (dsa_slave_dev_check);static int dsa_slave_changeupper (struct net_device *dev,struct netdev_notifier_changeupper_info *info)
Signature · 1 line
2.17.1
Re: [PATCH net-next 1/6] net: dsa: export dsa_slave_dev_check and dsa_slave_to_port
Quoted 59 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
To be able to perform mirroring and redirection through tc-flower offloads (the implementation of which is given raw access to the
flow_cls_offloadstructure), switch drivers need to be able to call these functions onact->dev.Signed-off-by Vladimir Oltean <[email protected]>---
Changes from RFC:
None.include/net/dsa.h | 2 ++ net/dsa/dsa_priv.h | 8 -------- net/dsa/slave.c | 9 +++++++++ 3 files changed, 11 insertions(+), 8 deletions(-)include/net/dsa.h +2
-0@@ -739,6 +739,8 @@ int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data);int dsa_port_get_ethtool_phy_stats (struct dsa_port *dp,uint64_t *data);int dsa_port_get_phy_sset_count (struct dsa_port *dp);void dsa_port_phylink_mac_change (struct dsa_switch *ds,int port,bool up); +bool dsa_slave_dev_check (const struct net_device *dev); +struct dsa_port *dsa_slave_to_port (const struct net_device *dev);struct dsa_tag_driver {const struct dsa_device_ops *ops;net/dsa/dsa_priv.h +0
-8@@ -173,19 +173,11 @@ extern const struct dsa_device_ops notag_netdev_ops;void dsa_slave_mii_bus_init (struct dsa_switch *ds);int dsa_slave_create (struct dsa_port *dp);void dsa_slave_destroy (struct net_device *slave_dev); -bool dsa_slave_dev_check (const struct net_device *dev);int dsa_slave_suspend (struct net_device *slave_dev);int dsa_slave_resume (struct net_device *slave_dev);int dsa_slave_register_notifier (void );void dsa_slave_unregister_notifier (void ); -static inline struct dsa_port *dsa_slave_to_port (const struct net_device *dev) -{ -struct dsa_slave_priv *p =netdev_priv (dev); - -return p->dp; -} -static inline struct net_device *dsa_slave_to_master (const struct net_device *dev) {net/dsa/slave.c +0
-0
net/dsa/slave.c static int dsa_slave_get_iflink(const struct net_device *dev) · line 71
Quoted 10 lines
net/dsa/slave.c +7
-0@@ -62,6 +62,14 @@ static int dsa_slave_get_iflink(const struct net_device *dev)return dsa_slave_to_master (dev)->ifindex; } +struct dsa_port *dsa_slave_to_port (const struct net_device *dev) +{ +struct dsa_slave_priv *p =netdev_priv (dev); + +return p->dp; +} +EXPORT_SYMBOL_GPL (dsa_slave_to_port);
You could probably make this a static inline in net/dsa.h, too. With or without doing that:
Signature · 1 line
Florian
Vladimir Oltean
maintainerRe: [PATCH net-next 1/6] net: dsa: export dsa_slave_dev_check and dsa_slave_to_port
Hi Florian,
Quoted 66 lines · Florian Fainelli
Quoted 62 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
To be able to perform mirroring and redirection through tc-flower offloads (the implementation of which is given raw access to the
flow_cls_offloadstructure), switch drivers need to be able to call these functions onact->dev.Signed-off-by Vladimir Oltean <[email protected]>---
Changes from RFC:
None.include/net/dsa.h | 2 ++ net/dsa/dsa_priv.h | 8 -------- net/dsa/slave.c | 9 +++++++++ 3 files changed, 11 insertions(+), 8 deletions(-)include/net/dsa.h +2
-0@@ -739,6 +739,8 @@ int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data);int dsa_port_get_ethtool_phy_stats (struct dsa_port *dp,uint64_t *data);int dsa_port_get_phy_sset_count (struct dsa_port *dp);void dsa_port_phylink_mac_change (struct dsa_switch *ds,int port,bool up); +bool dsa_slave_dev_check (const struct net_device *dev); +struct dsa_port *dsa_slave_to_port (const struct net_device *dev);struct dsa_tag_driver {const struct dsa_device_ops *ops;net/dsa/dsa_priv.h +0
-8@@ -173,19 +173,11 @@ extern const struct dsa_device_ops notag_netdev_ops;void dsa_slave_mii_bus_init (struct dsa_switch *ds);int dsa_slave_create (struct dsa_port *dp);void dsa_slave_destroy (struct net_device *slave_dev); -bool dsa_slave_dev_check (const struct net_device *dev);int dsa_slave_suspend (struct net_device *slave_dev);int dsa_slave_resume (struct net_device *slave_dev);int dsa_slave_register_notifier (void );void dsa_slave_unregister_notifier (void ); -static inline struct dsa_port *dsa_slave_to_port (const struct net_device *dev) -{ -struct dsa_slave_priv *p =netdev_priv (dev); - -return p->dp; -} -static inline struct net_device *dsa_slave_to_master (const struct net_device *dev) {net/dsa/slave.c +0
-0@@ -62,6 +62,14 @@ static int dsa_slave_get_iflink(const struct net_device *dev)return dsa_slave_to_master (dev)->ifindex; }
Quoted 10 lines
net/dsa/slave.c static int dsa_slave_get_iflink(const struct net_device *dev) · line 71
Quoted 7 lines
net/dsa/slave.c +7
-0+struct dsa_port *dsa_slave_to_port (const struct net_device *dev) +{ +struct dsa_slave_priv *p =netdev_priv (dev); + +return p->dp; +} +EXPORT_SYMBOL_GPL (dsa_slave_to_port);You could probably make this a static inline in
net/dsa.h, too. With or without doing that:
With dereferencing dsa_slave_priv, I don't think so.
Quoted 4 lines
Reviewed-by Florian Fainelli <[email protected]>--
Florian
Thanks,
-Vladimir
Re: [PATCH net-next 1/6] net: dsa: export dsa_slave_dev_check and dsa_slave_to_port
Quoted 80 lines · Vladimir Oltean
Hi Florian,
Quoted 66 lines · Florian Fainelli
Quoted 62 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
To be able to perform mirroring and redirection through tc-flower offloads (the implementation of which is given raw access to the
flow_cls_offloadstructure), switch drivers need to be able to call these functions onact->dev.Signed-off-by Vladimir Oltean <[email protected]>---
Changes from RFC:
None.include/net/dsa.h | 2 ++ net/dsa/dsa_priv.h | 8 -------- net/dsa/slave.c | 9 +++++++++ 3 files changed, 11 insertions(+), 8 deletions(-)include/net/dsa.h +2
-0@@ -739,6 +739,8 @@ int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data);int dsa_port_get_ethtool_phy_stats (struct dsa_port *dp,uint64_t *data);int dsa_port_get_phy_sset_count (struct dsa_port *dp);void dsa_port_phylink_mac_change (struct dsa_switch *ds,int port,bool up); +bool dsa_slave_dev_check (const struct net_device *dev); +struct dsa_port *dsa_slave_to_port (const struct net_device *dev);struct dsa_tag_driver {const struct dsa_device_ops *ops;net/dsa/dsa_priv.h +0
-8@@ -173,19 +173,11 @@ extern const struct dsa_device_ops notag_netdev_ops;void dsa_slave_mii_bus_init (struct dsa_switch *ds);int dsa_slave_create (struct dsa_port *dp);void dsa_slave_destroy (struct net_device *slave_dev); -bool dsa_slave_dev_check (const struct net_device *dev);int dsa_slave_suspend (struct net_device *slave_dev);int dsa_slave_resume (struct net_device *slave_dev);int dsa_slave_register_notifier (void );void dsa_slave_unregister_notifier (void ); -static inline struct dsa_port *dsa_slave_to_port (const struct net_device *dev) -{ -struct dsa_slave_priv *p =netdev_priv (dev); - -return p->dp; -} -static inline struct net_device *dsa_slave_to_master (const struct net_device *dev) {net/dsa/slave.c +0
-0@@ -62,6 +62,14 @@ static int dsa_slave_get_iflink(const struct net_device *dev)return dsa_slave_to_master (dev)->ifindex; }Quoted 10 lines
net/dsa/slave.c static int dsa_slave_get_iflink(const struct net_device *dev) · line 71
Quoted 7 lines
net/dsa/slave.c +7
-0+struct dsa_port *dsa_slave_to_port (const struct net_device *dev) +{ +struct dsa_slave_priv *p =netdev_priv (dev); + +return p->dp; +} +EXPORT_SYMBOL_GPL (dsa_slave_to_port);You could probably make this a static inline in
net/dsa.h, too. With or without doing that:
Quoted 1 line
With dereferencing
dsa_slave_priv, I don't think so.
Yes, I missed that dsa_slave_priv is not visible outside of dsa_priv.h (on purpose). Thanks!
Signature · 1 line
Florian
Vladimir Oltean
maintainerPATCH 2/6 net: dsa: sja1105: add static tables for virtual links
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
This patch adds the register definitions for the:
- VL Lookup Table
- VL Policing Table
- VL Forwarding Table
- VL Forwarding Parameters Table
These are needed in order to perform TTEthernet operations: QoS classification, flow-based policing and/or frame redirecting with the switch.
---
Changes from RFC:
None.
drivers/net/dsa/sja1105/sja1105.h | 2 + .../net/dsa/sja1105/sja1105_dynamic_config.c | 51 +++++ .../net/dsa/sja1105/sja1105_static_config.c | 202 ++++++++++++++++++ .../net/dsa/sja1105/sja1105_static_config.h | 63 ++++++ 4 files changed, 318 insertions(+)
drivers/net/dsa/sja1105/sja1105.h +2 -0
@@ -254,6 +254,8 @@ size_t sja1105pqrs_mac_config_entry_packing(void *buf, void *entry_ptr, enum packing_op op);size_t sja1105pqrs_avb_params_entry_packing (void *buf,void *entry_ptr,enum packing_op op); +size_t sja1105_vl_lookup_entry_packing (void *buf,void *entry_ptr, +enum packing_op op);/* From sja1105_flower.c */ int sja1105_cls_flower_del(struct dsa_switch *ds, int port,
drivers/net/dsa/sja1105/sja1105_dynamic_config.c +51 -0
87 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_static_config.c +202 -0
316 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_static_config.h +63 -0
123 lines not on this page · raw message
Signature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH 3/6 net: dsa: sja1105: make room for virtual link parsing in flower offload
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Virtual links are a sja1105 hardware concept of executing various flow actions based on a key extracted from the frame's DMAC, VID and PCP.
Currently the tc-flower offload code supports only parsing the DMAC if that is the broadcast MAC address, and the VLAN PCP. Extract the key parsing logic from the L2 policers functionality and move it into its own function, after adding extra logic for matching on any DMAC and VID.
---
Changes from RFC:
None.
drivers/net/dsa/sja1105/sja1105.h | 28 +++++- drivers/net/dsa/sja1105/sja1105_flower.c | 111 +++++++++++++++++------ 2 files changed, 112 insertions(+), 27 deletions(-)
drivers/net/dsa/sja1105/sja1105.h +27 -1
@@ -97,6 +97,32 @@ struct sja1105_info {const char *name; }; +enum sja1105_key_type { +SJA1105_KEY_BCAST , +SJA1105_KEY_TC , +SJA1105_KEY_VLAN_UNAWARE_VL , +SJA1105_KEY_VLAN_AWARE_VL , +}; + +struct sja1105_key { +enum sja1105_key_type type; + +union { +/* SJA1105_KEY_TC */ +struct { +int pcp; + } tc; + +/* SJA1105_KEY_VLAN_UNAWARE_VL */ +/* SJA1105_KEY_VLAN_AWARE_VL */ +struct { +u64 dmac; +u16 vid; +u16 pcp; + } vl; + }; +}; +enum sja1105_rule_type {SJA1105_RULE_BCAST_POLICER ,SJA1105_RULE_TC_POLICER ,
@@ -106,6 +132,7 @@ struct sja1105_rule {struct list_head list;unsigned long cookie;unsigned long port_mask; +struct sja1105_key key;enum sja1105_rule_type type;union {
@@ -117,7 +144,6 @@ struct sja1105_rule {/* SJA1105_RULE_TC_POLICER */ struct {int sharindx; -int tc; } tc_pol; }; };
drivers/net/dsa/sja1105/sja1105_flower.c +85 -26
179 lines not on this page · raw message
Signature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH 4/6 net: dsa: sja1105: support flow-based redirection via virtual links
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Implement tc-flower offloads for redirect, trap and drop using non-critical virtual links.
Commands which were tested to work are:
# Send frames received on swp2 with a DA of 42:be:24:9b:76:20 to the
# CPU and to swp3. This type of key (DA only) when the port's VLAN
# awareness state is off.
tc qdisc add dev swp2 clsact
tc filter add dev swp2 ingress flower skip_sw dst_mac 42:be:24:9b:76:20 \
action mirred egress redirect dev swp3 \
action trap
# Drop frames received on swp2 with a DA of 42:be:24:9b:76:20, a VID
# of 100 and a PCP of 0.
tc filter add dev swp2 ingress protocol 802.1Q flower skip_sw \
dst_mac 42:be:24:9b:76:20 vlan_id 100 vlan_prio 0 action dropUnder the hood, all rules match on DMAC, VID and PCP, but when VLAN filtering is disabled, those are set internally by the driver to the port-based defaults. Because we would be put in an awkward situation if the user were to change the VLAN filtering state while there are active rules (packets would no longer match on the specified keys), we simply deny changing vlan_filtering unless the list of flows offloaded via virtual links is empty. Then the user can re-add new rules.
---
Changes from RFC:
None.
drivers/net/dsa/sja1105/Kconfig | 9 + drivers/net/dsa/sja1105/Makefile | 4 + drivers/net/dsa/sja1105/sja1105.h | 18 ++ drivers/net/dsa/sja1105/sja1105_flower.c | 57 ++++- drivers/net/dsa/sja1105/sja1105_main.c | 12 +- drivers/net/dsa/sja1105/sja1105_vl.c | 302 +++++++++++++++++++++++ drivers/net/dsa/sja1105/sja1105_vl.h | 41 +++ 7 files changed, 437 insertions(+), 6 deletions(-) create mode 100644 drivers/net/dsa/sja1105/sja1105_vl.c create mode 100644 drivers/net/dsa/sja1105/sja1105_vl.h
drivers/net/dsa/sja1105/Kconfig +9 -0
@@ -33,3 +33,12 @@ config NET_DSA_SJA1105_TAS This enables support for the TTEthernet-based egress scheduling engine in the SJA1105 DSA driver, which is controlled using a hardware offload of the tc-tqprio qdisc. + +config NET_DSA_SJA1105_VL + bool "Support for Virtual Links on NXP SJA1105" + depends on NET_DSA_SJA1105_TAS + help + This enables support for flow classification using capable devices + (SJA1105T, SJA1105Q, SJA1105S). The following actions are supported: + - redirect, trap, drop + - time-based ingress policing, via the tc-gate action
drivers/net/dsa/sja1105/Makefile +4 -0
@@ -17,3 +17,7 @@ endif ifdef CONFIG_NET_DSA_SJA1105_TAS sja1105-objs += sja1105_tas.o endif + +ifdef CONFIG_NET_DSA_SJA1105_VL +sja1105-objs += sja1105_vl.o +endif
drivers/net/dsa/sja1105/sja1105.h +18 -0
@@ -126,6 +126,13 @@ struct sja1105_key {enum sja1105_rule_type {SJA1105_RULE_BCAST_POLICER ,SJA1105_RULE_TC_POLICER , +SJA1105_RULE_VL , +}; + +enum sja1105_vl_type { +SJA1105_VL_NONCRITICAL , +SJA1105_VL_RATE_CONSTRAINED , +SJA1105_VL_TIME_TRIGGERED , };struct sja1105_rule {
@@ -135,6 +142,7 @@ struct sja1105_rule {struct sja1105_key key;enum sja1105_rule_type type; +/* Action */ union { /* SJA1105_RULE_BCAST_POLICER */ struct {
@@ -145,12 +153,19 @@ struct sja1105_rule {struct {int sharindx; } tc_pol; + +/* SJA1105_RULE_VL */ +struct { +unsigned long destports; +enum sja1105_vl_type type; + } vl; }; };struct sja1105_flow_block {struct list_head rules;bool l2_policer_used[SJA1105_NUM_L2_POLICERS ]; +int num_virtual_links; };struct sja1105_private {
@@ -187,6 +202,7 @@ enum sja1105_reset_reason {SJA1105_AGEING_TIME ,SJA1105_SCHEDULING ,SJA1105_BEST_EFFORT_POLICING , + SJA1105_VIRTUAL_LINKS, }; int sja1105_static_config_reload(struct sja1105_private *priv,
@@ -290,5 +306,7 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port, struct flow_cls_offload *cls, bool ingress);void sja1105_flower_setup (struct dsa_switch *ds);void sja1105_flower_teardown (struct dsa_switch *ds); +struct sja1105_rule *sja1105_rule_find (struct sja1105_private *priv, +unsigned long cookie);#endif
drivers/net/dsa/sja1105/sja1105_flower.c +52 -5
99 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_main.c +11 -1
@@ -445,7 +445,7 @@ static int sja1105_init_general_params(struct sja1105_private *priv)*/ .casc_port = SJA1105_NUM_PORTS,/* No TTEthernet */ - .vllupformat = 0, + .vllupformat = SJA1105_VL_FORMAT_PSFP, .vlmarker = 0, .vlmask = 0,/* Only update correctionField for 1-step PTP (L2 transport) */
@@ -1589,6 +1589,7 @@ static const char * const sja1105_reset_reasons[] = { [SJA1105_AGEING_TIME] = "Ageing time", [SJA1105_SCHEDULING] = "Time-aware scheduling", [SJA1105_BEST_EFFORT_POLICING] = "Best-effort policing", + [SJA1105_VIRTUAL_LINKS] = "Virtual links", };/* For situations where we need to change a setting at runtime that is only
@@ -1831,9 +1832,18 @@ static int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled)struct sja1105_general_params_entry *general_params;struct sja1105_private *priv = ds->priv;struct sja1105_table *table; +struct sja1105_rule *rule;u16 tpid, tpid2;int rc; +list_for_each_entry (rule, &priv->flow_block.rules, list) { +if (rule->type ==SJA1105_RULE_VL ) { +dev_err (ds->dev, +"Cannot change VLAN filtering state while VL rules are active\n" ); +return -EBUSY ; + } + } +if (enabled) {/* Enable VLAN filtering. */ tpid =ETH_P_8021Q ;
drivers/net/dsa/sja1105/sja1105_vl.c new file +302 -0
302 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_vl.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH net-next 4/6] net: dsa: sja1105: support flow-based redirection via virtual links
Hi Vladimir,
drivers/net/dsa/sja1105/sja1105_flower.c int sja1105_cls_flower_add(struct dsa_switch *ds, int port, · line 352
Quoted 10 lines · Vladimir Oltean
drivers/net/dsa/sja1105/sja1105_flower.c +10
-0+case FLOW_ACTION_REDIRECT : { +struct dsa_port *to_dp; + +if (!dsa_slave_dev_check (act->dev)) { +NL_SET_ERR_MSG_MOD (extack, +"Destination not a switch port" ); +return -EOPNOTSUPP ; + } + + to_dp =dsa_slave_to_port (act->dev);
Instead of exporting two DSA core internal functions, I would rather expose a new helper for drivers, such as this one:
struct dsa_port *dsa_dev_to_port(struct net_device *dev)
{
if (!dsa_slave_dev_check(dev))
return -EOPNOTSUPP;
return dsa_slave_to_port(dev);
}The naming might not be the best, this helper could even be mirroring-specific, I didn't really check the requirements for this functionality yet.
Thank you,
Vivien
Re: [PATCH net-next 4/6] net: dsa: sja1105: support flow-based redirection via virtual links
Quoted 17 lines · Vivien Didelot
Hi Vladimir,
drivers/net/dsa/sja1105/sja1105_flower.c int sja1105_cls_flower_add(struct dsa_switch *ds, int port, · line 352
Quoted 10 lines · Vladimir Oltean
drivers/net/dsa/sja1105/sja1105_flower.c +10
-0+case FLOW_ACTION_REDIRECT : { +struct dsa_port *to_dp; + +if (!dsa_slave_dev_check (act->dev)) { +NL_SET_ERR_MSG_MOD (extack, +"Destination not a switch port" ); +return -EOPNOTSUPP ; + } + + to_dp =dsa_slave_to_port (act->dev);Instead of exporting two DSA core internal functions, I would rather expose a new helper for drivers, such as this one:
Quoted 4 lines
struct dsa_port *dsa_dev_to_port(struct net_device *dev)
{
if (!dsa_slave_dev_check(dev))
return -EOPNOTSUPP;Oops, NULL, not an integer error code, but you get the idea of public helpers.
Quoted 11 lines
return dsa_slave_to_port(dev); }The naming might not be the best, this helper could even be mirroring-specific, I didn't really check the requirements for this functionality yet.
Thank you,
Vivien
Vladimir Oltean
maintainerRe: [PATCH net-next 4/6] net: dsa: sja1105: support flow-based redirection via virtual links
Hi Vivien,
Quoted 19 lines · Vivien Didelot
Quoted 17 lines · Vivien Didelot
Hi Vladimir,
drivers/net/dsa/sja1105/sja1105_flower.c int sja1105_cls_flower_add(struct dsa_switch *ds, int port, · line 352
Quoted 10 lines · Vladimir Oltean
drivers/net/dsa/sja1105/sja1105_flower.c +10
-0+case FLOW_ACTION_REDIRECT : { +struct dsa_port *to_dp; + +if (!dsa_slave_dev_check (act->dev)) { +NL_SET_ERR_MSG_MOD (extack, +"Destination not a switch port" ); +return -EOPNOTSUPP ; + } + + to_dp =dsa_slave_to_port (act->dev);Instead of exporting two DSA core internal functions, I would rather expose a new helper for drivers, such as this one:
Quoted 18 lines
Quoted 4 lines
struct dsa_port *dsa_dev_to_port(struct net_device *dev) { if (!dsa_slave_dev_check(dev)) return -EOPNOTSUPP;Oops, NULL, not an integer error code, but you get the idea of public helpers.
Quoted 11 lines
return dsa_slave_to_port(dev); }The naming might not be the best, this helper could even be mirroring-specific, I didn't really check the requirements for this functionality yet.
Thank you,
Vivien
How about
int dsa_slave_get_port_index(struct net_device *dev)
{
if (!dsa_slave_dev_check(dev))
return -EINVAL;
return dsa_slave_to_port(dev)->index;
}EXPORT_SYMBOL_GPL(dsa_slave_get_port_index);
also, where to put it? slave.c I suppose?
Thanks,
-Vladimir
Re: [PATCH net-next 4/6] net: dsa: sja1105: support flow-based redirection via virtual links
Hi Vladimir,
Quoted 50 lines · Vladimir Oltean
Hi Vivien,
Quoted 19 lines · Vivien Didelot
Quoted 17 lines · Vivien Didelot
Hi Vladimir,
drivers/net/dsa/sja1105/sja1105_flower.c int sja1105_cls_flower_add(struct dsa_switch *ds, int port, · line 352
Quoted 10 lines · Vladimir Oltean
drivers/net/dsa/sja1105/sja1105_flower.c +10
-0+case FLOW_ACTION_REDIRECT : { +struct dsa_port *to_dp; + +if (!dsa_slave_dev_check (act->dev)) { +NL_SET_ERR_MSG_MOD (extack, +"Destination not a switch port" ); +return -EOPNOTSUPP ; + } + + to_dp =dsa_slave_to_port (act->dev);Instead of exporting two DSA core internal functions, I would rather expose a new helper for drivers, such as this one:
Quoted 18 lines
Quoted 4 lines
struct dsa_port *dsa_dev_to_port(struct net_device *dev) { if (!dsa_slave_dev_check(dev)) return -EOPNOTSUPP;Oops, NULL, not an integer error code, but you get the idea of public helpers.
Quoted 11 lines
return dsa_slave_to_port(dev); }The naming might not be the best, this helper could even be mirroring-specific, I didn't really check the requirements for this functionality yet.
Thank you,
Vivien
How about
int
dsa_slave_get_port_index(struct net_device *dev){ if (!dsa_slave_dev_check(dev)) return -EINVAL; return dsa_slave_to_port(dev)->index; }
Quoted 3 lines
EXPORT_SYMBOL_GPL(dsa_slave_get_port_index);also, where to put it?
slave.cI suppose?
dsa.c is the place for private implementation of public functions. "slave" is a core term, no need to expose it. Public helpers exposed in dsa.h usually scope the dsa_switch structure and an optional port index. mv88e6xxx allows mirroring an external device port, so dsa_port would be preferred, but this can wait. So I'm thinking about implementing the following:
net/dsa/dsa.c:
int dsa_to_port_index(struct dsa_switch *ds, struct net_device *dev)
{
struct dsa_port *dp;
if (!dsa_slave_dev_check(dev))
return -ENODEV;
dp = dsa_slave_to_port(dev);
if (dp->ds != ds)
return -EINVAL;
return dp->index;
}include/net/dsa.h:
int dsa_to_port_index(struct dsa_switch *ds, struct net_device *dev);
What do you think?
Vivien
Vladimir Oltean
maintainerRe: [PATCH net-next 4/6] net: dsa: sja1105: support flow-based redirection via virtual links
Quoted 56 lines · Vivien Didelot
Hi Vladimir,
Quoted 52 lines · Vladimir Oltean
Hi Vivien,
Quoted 19 lines · Vivien Didelot
Quoted 17 lines · Vivien Didelot
Hi Vladimir,
drivers/net/dsa/sja1105/sja1105_flower.c int sja1105_cls_flower_add(struct dsa_switch *ds, int port, · line 352
Quoted 10 lines · Vladimir Oltean
drivers/net/dsa/sja1105/sja1105_flower.c +10
-0+case FLOW_ACTION_REDIRECT : { +struct dsa_port *to_dp; + +if (!dsa_slave_dev_check (act->dev)) { +NL_SET_ERR_MSG_MOD (extack, +"Destination not a switch port" ); +return -EOPNOTSUPP ; + } + + to_dp =dsa_slave_to_port (act->dev);Instead of exporting two DSA core internal functions, I would rather expose a new helper for drivers, such as this one:
Quoted 18 lines
Quoted 4 lines
struct dsa_port *dsa_dev_to_port(struct net_device *dev) { if (!dsa_slave_dev_check(dev)) return -EOPNOTSUPP;Oops, NULL, not an integer error code, but you get the idea of public helpers.
Quoted 11 lines
return dsa_slave_to_port(dev); }The naming might not be the best, this helper could even be mirroring-specific, I didn't really check the requirements for this functionality yet.
Thank you,
Vivien
How about
int
dsa_slave_get_port_index(struct net_device *dev){ if (!dsa_slave_dev_check(dev)) return -EINVAL; return dsa_slave_to_port(dev)->index; }
EXPORT_SYMBOL_GPL(dsa_slave_get_port_index);
Quoted 6 lines
Quoted 1 line
also, where to put it?
slave.cI suppose?
dsa.cis the place for private implementation of public functions. "slave" is a core term, no need to expose it. Public helpers exposed indsa.husually scope thedsa_switchstructure and an optional port index. mv88e6xxx allows mirroring an external device port,
For mirroring an entire port (via tc-matchall), the tc structures are already parsed by DSA core and a simple API is given to drivers. The discussion we're having is for flow-based mirroring (via tc-flower) where that is not the case.
Quoted 6 lines
so
dsa_portwould be preferred, but this
can wait. So I'm thinking about implementing the following:
net/dsa/dsa.c:int
dsa_to_port_index(struct dsa_switch *ds, struct net_device *dev)
But let's assume for a second that mv88e6xxx supports flow-based mirroring/redirection too.
Aren't we limiting ourselves uselessly here, by requiring the caller to pass a ds pointer just to perform validation on it? I think it's a valid use case to want to support cross-chip mirroring/redirection sometime in the future. Both sja1105 and mv88e6xxx support that kind of setup, you just need to set the destination port to dsa_towards_port() in case the dp->ds found by dsa_slave_to_port does not coincide with ours. But surprise, using the syntactic sugar API we're introducing here, we'd get -EINVAL and we would have to somehow try again and guess with a ds pointer we don't have.
Quoted 14 lines
{
struct dsa_port *dp;
if (!dsa_slave_dev_check(dev))
return -ENODEV;
dp = dsa_slave_to_port(dev);
if (dp->ds != ds)
return -EINVAL;
return dp->index;
}Quoted 6 lines
include/net/dsa.h:int
dsa_to_port_index(struct dsa_switch *ds, struct net_device *dev);What do you think?
I'm actually not convinced about this idea. I think the function that should be called should be named dsa_slave_to_port, and it should return a struct dsa_port. Quite conveniently, that function already exists. I'm not actually sure what are the issues of exposing the existing functions.
Quoted 2 lines
Vivien
Thanks,
-Vladimir
Vladimir Oltean
maintainerPATCH 5/6 net: dsa: sja1105: implement tc-gate using time-triggered virtual links
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Restrict the TTEthernet hardware support on this switch to operate as closely as possible to IEEE 802.1Qci as possible. This means that it can perform PTP-time-based ingress admission control on streams identified by {DMAC, VID, PCP}, which is useful when trying to ensure the determinism of traffic scheduled via IEEE 802.1Qbv.
The oddity comes from the fact that in hardware (and in TTEthernet at large), virtual links always need a full-blown action, including not only the type of policing, but also the list of destination ports. So in practice, a single tc-gate action will result in all packets getting dropped. Additional actions (either "trap" or "redirect") need to be specified in the same filter rule such that the conforming packets are actually forwarded somewhere.
Apart from the VL Lookup, Policing and Forwarding tables which need to be programmed for each flow (virtual link), the Schedule engine also needs to be told to open/close the admission gates for each individual virtual link. A fairly accurate (and detailed) description of how that works is already present in sja1105_tas.c, since it is already used to trigger the egress gates for the tc-taprio offload (IEEE 802.1Qbv). Key point here, we remember that the schedule engine supports 8 "subschedules" (execution threads that iterate through the global schedule in parallel, and that no 2 hardware threads must execute a schedule entry at the same time). For tc-taprio, each egress port used one of these 8 subschedules, leaving a total of 4 subschedules unused. In principle we could have allocated 1 subschedule for the tc-gate offload of each ingress port, but actually the schedules of all virtual links installed on each ingress port would have needed to be merged together, before they could have been programmed to hardware. So simplify our life and just merge the entire tc-gate configuration, for all virtual links on all ingress ports, into a single subschedule. Be sure to check that against the usual hardware scheduling conflicts, and program it to hardware alongside any tc-taprio subschedule that may be present.
The following scenarios were tested:
1. Quantitative testing:
tc qdisc add dev swp2 clsact
tc filter add dev swp2 ingress flower skip_sw \
dst_mac 42:be:24:9b:76:20 \
action gate index 1 base-time 0 \
sched-entry OPEN 1200 -1 -1 \
sched-entry CLOSE 1200 -1 -1 \
action trap ping 192.168.1.2 -f
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
.............................
--- 192.168.1.2 ping statistics ---
948 packets transmitted, 467 received, 50.7384% packet loss, time 9671ms
2. Qualitative testing (with a phase-aligned schedule - the clocks are synchronized by ptp4l, not shown here):
Receiver (sja1105):
tc qdisc add dev swp2 clsact
now=$(phc_ctl /dev/ptp1 get | awk '/clock time is/ {print $5}') && \
sec=$(echo $now | awk -F. '{print $1}') && \
base_time="$(((sec + 2) * 1000000000))" && \
echo "base time ${base_time}"
tc filter add dev swp2 ingress flower skip_sw \
dst_mac 42:be:24:9b:76:20 \
action gate base-time ${base_time} \
sched-entry OPEN 60000 -1 -1 \
sched-entry CLOSE 40000 -1 -1 \
action trap
Sender (enetc):
now=$(phc_ctl /dev/ptp0 get | awk '/clock time is/ {print $5}') && \
sec=$(echo $now | awk -F. '{print $1}') && \
base_time="$(((sec + 2) * 1000000000))" && \
echo "base time ${base_time}"
tc qdisc add dev eno0 parent root taprio \
num_tc 8 \
map 0 1 2 3 4 5 6 7 \
queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \
base-time ${base_time} \
sched-entry S 01 50000 \
sched-entry S 00 50000 \
flags 2 ping -A 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
...
^C
--- 192.168.1.1 ping statistics ---
1425 packets transmitted, 1424 packets received, 0% packet loss round-trip min/avg/max = 0.322/0.361/0.990 ms
And just for comparison, with the tc-taprio schedule deleted:
ping -A 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
...
^C
--- 192.168.1.1 ping statistics ---
33 packets transmitted, 19 packets received, 42% packet loss round-trip min/avg/max = 0.336/0.464/0.597 ms
---
Changes from RFC:
* Deny gating actions in absence of any routing action. Without this check, the default behavior would be to drop everything, which is probably not what the user expects.
* Deny offloading IntervalOctetMax, which I initially mistook for meaning per-flow MTU. It actually means a sort of flow metering within each time slot. Not supported.
drivers/net/dsa/sja1105/sja1105.h | 13 +- drivers/net/dsa/sja1105/sja1105_flower.c | 57 +- drivers/net/dsa/sja1105/sja1105_main.c | 1 + drivers/net/dsa/sja1105/sja1105_ptp.h | 13 + drivers/net/dsa/sja1105/sja1105_spi.c | 2 + .../net/dsa/sja1105/sja1105_static_config.h | 2 + drivers/net/dsa/sja1105/sja1105_tas.c | 127 ++++- drivers/net/dsa/sja1105/sja1105_tas.h | 31 ++ drivers/net/dsa/sja1105/sja1105_vl.c | 494 ++++++++++++++++++ drivers/net/dsa/sja1105/sja1105_vl.h | 31 ++ 10 files changed, 754 insertions(+), 17 deletions(-)
drivers/net/dsa/sja1105/sja1105.h +12 -1
@@ -36,6 +36,7 @@ struct sja1105_regs {u64 status;u64 port_control;u64 rgu; +u64 vl_status;u64 config;u64 sgmii;u64 rmii_pll1;
@@ -156,8 +157,16 @@ struct sja1105_rule {/* SJA1105_RULE_VL */ struct { -unsigned long destports;enum sja1105_vl_type type; +unsigned long destports; +int sharindx; +int maxlen; +int ipv; +u64 base_time; +u64 cycle_time; +int num_entries; +struct action_gate_entry *entries; +struct flow_stats stats; } vl; }; };
@@ -304,6 +313,8 @@ int sja1105_cls_flower_del(struct dsa_switch *ds, int port, struct flow_cls_offload *cls, bool ingress);int sja1105_cls_flower_add (struct dsa_switch *ds,int port,struct flow_cls_offload *cls,bool ingress); +int sja1105_cls_flower_stats (struct dsa_switch *ds,int port, +struct flow_cls_offload *cls,bool ingress);void sja1105_flower_setup (struct dsa_switch *ds);void sja1105_flower_teardown (struct dsa_switch *ds); struct sja1105_rule *sja1105_rule_find(struct sja1105_private *priv,
drivers/net/dsa/sja1105/sja1105_flower.c +56 -1
95 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_main.c +1 -0
@@ -2369,6 +2369,7 @@ static const struct dsa_switch_ops sja1105_switch_ops = { .port_policer_del = sja1105_port_policer_del, .cls_flower_add = sja1105_cls_flower_add, .cls_flower_del = sja1105_cls_flower_del, + .cls_flower_stats = sja1105_cls_flower_stats, };static int sja1105_check_device_id (struct sja1105_private *priv)
drivers/net/dsa/sja1105/sja1105_ptp.h +13 -0
@@ -48,6 +48,19 @@ static inline s64 future_base_time(s64 base_time, s64 cycle_time, s64 now)return base_time + n * cycle_time; } +/* This is not a preprocessor macro because the "ns" argument may or may not be +* s64 at caller side. This ensures it is properly type-cast before div_s64. +*/ +static inline s64 ns_to_sja1105_delta (s64 ns) +{ +return div_s64 (ns,200 ); +} + +static inline s64 sja1105_delta_to_ns (s64 delta) +{ +return delta *200 ; +} +struct sja1105_ptp_cmd {u64 startptpcp;/* start toggling PTP_CLK pin */ u64 stopptpcp;/* stop toggling PTP_CLK pin */
drivers/net/dsa/sja1105/sja1105_spi.c +2 -0
@@ -439,6 +439,7 @@ static struct sja1105_regs sja1105et_regs = { .prod_id = 0x100BC3, .status = 0x1, .port_control = 0x11, + .vl_status = 0x10000, .config = 0x020000, .rgu = 0x100440,/* UM10944.pdf, Table 86, ACU Register overview */
@@ -472,6 +473,7 @@ static struct sja1105_regs sja1105pqrs_regs = { .prod_id = 0x100BC3, .status = 0x1, .port_control = 0x12, + .vl_status = 0x10000, .config = 0x020000, .rgu = 0x100440,/* UM10944.pdf, Table 86, ACU Register overview */
drivers/net/dsa/sja1105/sja1105_static_config.h +2 -0
@@ -302,6 +302,8 @@ struct sja1105_vl_lookup_entry {u64 vlid; }; }; +/* Not part of hardware structure */ +unsigned long flow_cookie; };struct sja1105_vl_policing_entry {
drivers/net/dsa/sja1105/sja1105_tas.c +112 -15
190 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_tas.h +31 -0
@@ -6,6 +6,8 @@#include <net/pkt_sched.h> +#define SJA1105_TAS_MAX_DELTA BIT(18) +#if IS_ENABLED (CONFIG_NET_DSA_SJA1105_TAS ) enum sja1105_tas_state {
@@ -20,8 +22,23 @@ enum sja1105_ptp_op { SJA1105_PTP_ADJUSTFREQ, }; +struct sja1105_gate_entry { +struct list_head list; +struct sja1105_rule *rule; +s64 interval; +u8 gate_state; +}; + +struct sja1105_gating_config { +u64 cycle_time; +s64 base_time; +int num_entries; +struct list_head entries; +}; +struct sja1105_tas_data {struct tc_taprio_qopt_offload *offload[SJA1105_NUM_PORTS ]; +struct sja1105_gating_config gating_cfg;enum sja1105_tas_state state;enum sja1105_ptp_op last_op;struct work_struct tas_work;
@@ -31,6 +48,8 @@ struct sja1105_tas_data {bool enabled; }; +struct sja1105_private ; +int sja1105_setup_tc_taprio (struct dsa_switch *ds,int port,struct tc_taprio_qopt_offload *admin);
@@ -42,6 +61,11 @@ void sja1105_tas_clockstep(struct dsa_switch *ds);void sja1105_tas_adjfreq (struct dsa_switch *ds); +bool sja1105_gating_check_conflicts (struct sja1105_private *priv,int port, +struct netlink_ext_ack *extack); + +int sja1105_init_scheduling (struct sja1105_private *priv); +#else /* C doesn't allow empty structures, bah! */
@@ -63,6 +87,13 @@ static inline void sja1105_tas_clockstep(struct dsa_switch *ds) { }static inline void sja1105_tas_adjfreq (struct dsa_switch *ds) { } +static inline bool +sja1105_gating_check_conflicts (struct dsa_switch *ds,int port, +struct netlink_ext_ack *extack) +{ +return true; +} +#endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS) */ #endif /* _SJA1105_TAS_H */
drivers/net/dsa/sja1105/sja1105_vl.c +494 -0
548 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_vl.h +31 -0
@@ -15,6 +15,16 @@ int sja1105_vl_delete(struct sja1105_private *priv, int port,struct sja1105_rule *rule, struct netlink_ext_ack *extack); +int sja1105_vl_gate (struct sja1105_private *priv,int port, +struct netlink_ext_ack *extack,unsigned long cookie, +struct sja1105_key *key,u32 index,s32 prio, +u64 base_time,u64 cycle_time,u64 cycle_time_ext, +u32 num_entries,struct action_gate_entry *entries); + +int sja1105_vl_stats (struct sja1105_private *priv,int port, +struct sja1105_rule *rule,struct flow_stats *stats, +struct netlink_ext_ack *extack); +#else static inline int sja1105_vl_redirect(struct sja1105_private *priv, int port,
@@ -36,6 +46,27 @@ static inline int sja1105_vl_delete(struct sja1105_private *priv,return -EOPNOTSUPP ; } +static inline int sja1105_vl_gate (struct sja1105_private *priv,int port, +struct netlink_ext_ack *extack, +unsigned long cookie, +struct sja1105_key *key,u32 index,s32 prio, +u64 base_time,u64 cycle_time, +u64 cycle_time_ext,u32 num_entries, +struct action_gate_entry *entries) +{ +NL_SET_ERR_MSG_MOD (extack,"Virtual Links not compiled in" ); +return -EOPNOTSUPP ; +} + +static inline int sja1105_vl_stats (struct sja1105_private *priv,int port, +struct sja1105_rule *rule, +struct flow_stats *stats, +struct netlink_ext_ack *extack) +{ +NL_SET_ERR_MSG_MOD (extack,"Virtual Links not compiled in" ); +return -EOPNOTSUPP ; +} +#endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_VL) */ #endif /* _SJA1105_VL_H */
Signature · 1 line
2.17.1
kbuild test robot
build botRe: [PATCH net-next 5/6] net: dsa: sja1105: implement tc-gate using time-triggered virtual links
I love your patch! Yet something to improve:
Hi Vladimir,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
[also build test ERROR on net/master linus/master v5.7-rc4 next-20200505] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Vladimir-Oltean/tc-gate-offload-for-SJA1105-DSA-switch/20200505-040345 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 627642f07b3093f501495d226c7a0b9d56a0c870 config: i386-randconfig-h001-20200503 (attached as .config) compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0 reproduce: # save the attached .config to linux build tree make ARCH=i386
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/net/dsa/sja1105/sja1105_flower.c: In function 'sja1105_cls_flower_add':
>> drivers/net/dsa/sja1105/sja1105_flower.c:406:9: error: implicit declaration of function 'sja1105_init_scheduling'; did you mean 'sja1105_get_strings'? [-Werror=implicit-function-declaration]
rc = sja1105_init_scheduling(priv);
^~~~~~~~~~~~~~~~~~~~~~~
sja1105_get_stringscc1: some warnings being treated as errors
vim +406 drivers/net/dsa/sja1105/sja1105_flower.c
303
304 int sja1105_cls_flower_add(struct dsa_switch *ds, int port,
305 struct flow_cls_offload *cls, bool ingress)
306 {
307 struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
308 struct netlink_ext_ack *extack = cls->common.extack;
309 struct sja1105_private *priv = ds->priv;
310 const struct flow_action_entry *act;
311 unsigned long cookie = cls->cookie;
312 bool routing_rule = false;
313 struct sja1105_key key;
314 bool gate_rule = false;
315 bool vl_rule = false;
316 int rc, i;
317
318 rc = sja1105_flower_parse_key(priv, extack, cls, &key);
319 if (rc)
320 return rc;
321
322 rc = -EOPNOTSUPP;
323
324 flow_action_for_each(i, act, &rule->action) {
325 switch (act->id) {
326 case FLOW_ACTION_POLICE:
327 rc = sja1105_flower_policer(priv, port, extack, cookie,
328 &key,
329 act->police.rate_bytes_ps,
330 act->police.burst);
331 if (rc)
332 goto out;
333 break;
334 case FLOW_ACTION_TRAP: {
335 int cpu = dsa_upstream_port(ds, port);
336
337 routing_rule = true;
338 vl_rule = true;
339
340 rc = sja1105_vl_redirect(priv, port, extack, cookie,
341 &key, BIT(cpu), true);
342 if (rc)
343 goto out;
344 break;
345 }
346 case FLOW_ACTION_REDIRECT: {
347 struct dsa_port *to_dp;
348
349 if (!dsa_slave_dev_check(act->dev)) {
350 NL_SET_ERR_MSG_MOD(extack,
351 "Destination not a switch port");
352 return -EOPNOTSUPP;
353 }
354
355 to_dp = dsa_slave_to_port(act->dev);
356 routing_rule = true;
357 vl_rule = true;
358
359 rc = sja1105_vl_redirect(priv, port, extack, cookie,
360 &key, BIT(to_dp->index), true);
361 if (rc)
362 goto out;
363 break;
364 }
365 case FLOW_ACTION_DROP:
366 vl_rule = true;
367
368 rc = sja1105_vl_redirect(priv, port, extack, cookie,
369 &key, 0, false);
370 if (rc)
371 goto out;
372 break;
373 case FLOW_ACTION_GATE:
374 gate_rule = true;
375 vl_rule = true;
376
377 rc = sja1105_vl_gate(priv, port, extack, cookie,
378 &key, act->gate.index,
379 act->gate.prio,
380 act->gate.basetime,
381 act->gate.cycletime,
382 act->gate.cycletimeext,
383 act->gate.num_entries,
384 act->gate.entries);
385 if (rc)
386 goto out;
387 break;
388 default:
389 NL_SET_ERR_MSG_MOD(extack,
390 "Action not supported");
391 rc = -EOPNOTSUPP;
392 goto out;
393 }
394 }
395
396 if (vl_rule && !rc) {
397 /* Delay scheduling configuration until DESTPORTS has been
398 * populated by all other actions.
399 */
400 if (gate_rule) {
401 if (!routing_rule) {
402 NL_SET_ERR_MSG_MOD(extack,
403 "Can only offload gate action together with redirect or trap");
404 return -EOPNOTSUPP;
405 }
> 406 rc = sja1105_init_scheduling(priv); 407 if (rc)
408 goto out;
409 }
410
411 rc = sja1105_static_config_reload(priv, SJA1105_VIRTUAL_LINKS);
412 }
413
414 out:
415 return rc;
416 }
417
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Vladimir Oltean
maintainerRe: [PATCH net-next 5/6] net: dsa: sja1105: implement tc-gate using time-triggered virtual links
Quoted 149 lines · kbuild test robot
Hi Vladimir,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
[also build test ERROR on net/master linus/master v5.7-rc4 next-20200505] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]url: https://github.com/0day-ci/linux/commits/Vladimir-Oltean/tc-gate-offload-for-SJA1105-DSA-switch/20200505-040345 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 627642f07b3093f501495d226c7a0b9d56a0c870 config: i386-randconfig-h001-20200503 (attached as .config) compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0 reproduce: # save the attached .config to linux build tree make ARCH=i386If you fix the issue, kindly add following tag as appropriate
Reported-by kbuild test robot <[email protected]>All errors (new ones prefixed by >>):
drivers/net/dsa/sja1105/sja1105_flower.c: In function 'sja1105_cls_flower_add':Quoted 1 line
Quoted 1 line
drivers/net/dsa/sja1105/sja1105_flower.c:406:9: error: implicit declaration of function 'sja1105_init_scheduling'; did you mean 'sja1105_get_strings'? [-Werror=implicit-function-declaration]rc = sja1105_init_scheduling(priv); ^~~~~~~~~~~~~~~~~~~~~~~ sja1105_get_stringscc1: some warnings being treated as errors
vim +406
drivers/net/dsa/sja1105/sja1105_flower.c303 304 int sja1105_cls_flower_add(struct dsa_switch *ds, int port, 305 struct flow_cls_offload *cls, bool ingress) 306 { 307 struct flow_rule *rule = flow_cls_offload_flow_rule(cls); 308 struct netlink_ext_ack *extack = cls->common.extack; 309 struct sja1105_private *priv = ds->priv; 310 const struct flow_action_entry *act; 311 unsigned long cookie = cls->cookie; 312 bool routing_rule = false; 313 struct sja1105_key key; 314 bool gate_rule = false; 315 bool vl_rule = false; 316 int rc, i; 317 318 rc = sja1105_flower_parse_key(priv, extack, cls, &key); 319 if (rc) 320 return rc; 321 322 rc = -EOPNOTSUPP; 323 324 flow_action_for_each(i, act, &rule->action) { 325 switch (act->id) { 326 case FLOW_ACTION_POLICE: 327 rc = sja1105_flower_policer(priv, port, extack, cookie, 328 &key, 329 act->police.rate_bytes_ps, 330 act->police.burst); 331 if (rc) 332 goto out; 333 break; 334 case FLOW_ACTION_TRAP: { 335 int cpu = dsa_upstream_port(ds, port); 336 337 routing_rule = true; 338 vl_rule = true; 339 340 rc = sja1105_vl_redirect(priv, port, extack, cookie, 341 &key, BIT(cpu), true); 342 if (rc) 343 goto out; 344 break; 345 } 346 case FLOW_ACTION_REDIRECT: { 347 struct dsa_port *to_dp; 348 349 if (!dsa_slave_dev_check(act->dev)) { 350 NL_SET_ERR_MSG_MOD(extack, 351 "Destination not a switch port"); 352 return -EOPNOTSUPP; 353 } 354 355 to_dp = dsa_slave_to_port(act->dev); 356 routing_rule = true; 357 vl_rule = true; 358 359 rc = sja1105_vl_redirect(priv, port, extack, cookie, 360 &key, BIT(to_dp->index), true); 361 if (rc) 362 goto out; 363 break; 364 } 365 case FLOW_ACTION_DROP: 366 vl_rule = true; 367 368 rc = sja1105_vl_redirect(priv, port, extack, cookie, 369 &key, 0, false); 370 if (rc) 371 goto out; 372 break; 373 case FLOW_ACTION_GATE: 374 gate_rule = true; 375 vl_rule = true; 376 377 rc = sja1105_vl_gate(priv, port, extack, cookie, 378 &key, act->gate.index, 379 act->gate.prio, 380 act->gate.basetime, 381 act->gate.cycletime, 382 act->gate.cycletimeext, 383 act->gate.num_entries, 384 act->gate.entries); 385 if (rc) 386 goto out; 387 break; 388 default: 389 NL_SET_ERR_MSG_MOD(extack, 390 "Action not supported"); 391 rc = -EOPNOTSUPP; 392 goto out; 393 } 394 } 395 396 if (vl_rule && !rc) { 397 /* Delay scheduling configuration until DESTPORTS has been 398 * populated by all other actions. 399 */ 400 if (gate_rule) { 401 if (!routing_rule) { 402 NL_SET_ERR_MSG_MOD(extack, 403 "Can only offload gate action together with redirect or trap"); 404 return -EOPNOTSUPP; 405 }Quoted 1 line
406 rc =
sja1105_init_scheduling(priv);407 if (rc)
408 goto out; 409 } 410 411 rc = sja1105_static_config_reload(priv, SJA1105_VIRTUAL_LINKS); 412 } 413 414 out: 415 return rc; 416 } 417
Quoted 3 lines
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
Whoops, I forgot to provide a shim implementation sja1105_init_scheduling for the case where NET_DSA_SJA1105_TAS is not enabled.
If there are no other comments I'll send a v3 soon with just this change.
-Vladimir
Vladimir Oltean
maintainerPATCH 6/6 docs: net: dsa: sja1105: document intended usage of virtual links
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Add some verbiage describing how the hardware features of the switch are exposed to users through tc-flower.
---
Changes from RFC:
Patch is new.
Documentation/networking/dsa/sja1105.rst | 116 +++++++++++++++++++++++ 1 file changed, 116 insertions(+)
Documentation/networking/dsa/sja1105.rst +116 -0
@@ -230,6 +230,122 @@ simultaneously on two ports. The driver checks the consistency of the schedules against this restriction and errors out when appropriate. Schedule analysis is needed to avoid this, which is outside the scope of the document. +Routing actions (redirect, trap, drop) +-------------------------------------- + +The switch is able to offload flow-based redirection of packets to a set of +destination ports specified by the user. Internally, this is implemented by +making use of Virtual Links, a TTEthernet concept. + +The driver supports 2 types of keys for Virtual Links: + +- VLAN-aware virtual links: these match on destination MAC address, VLAN ID and + VLAN PCP. +- VLAN-unaware virtual links: these match on destination MAC address only. + +The VLAN awareness state of the bridge (vlan_filtering) cannot be changed while +there are virtual link rules installed. + +Composing multiple actions inside the same rule is supported. When only routing +actions are requested, the driver creates a "non-critical" virtual link. When +the action list also contains tc-gate (more details below), the virtual link +becomes "time-critical" (draws frame buffers from a reserved memory partition, +etc). + +The 3 routing actions that are supported are "trap", "drop" and "redirect". + +Example 1: send frames received on swp2 with a DA of 42:be:24:9b:76:20 to the +CPU and to swp3. This type of key (DA only) when the port's VLAN awareness +state is off:: + + tc qdisc add dev swp2 clsact + tc filter add dev swp2 ingress flower skip_sw dst_mac 42:be:24:9b:76:20 \ + action mirred egress redirect dev swp3 \ + action trap + +Example 2: drop frames received on swp2 with a DA of 42:be:24:9b:76:20, a VID +of 100 and a PCP of 0:: + + tc filter add dev swp2 ingress protocol 802.1Q flower skip_sw \ + dst_mac 42:be:24:9b:76:20 vlan_id 100 vlan_prio 0 action drop + +Time-based ingress policing +--------------------------- + +The TTEthernet hardware abilities of the switch can be constrained to act +similarly to the Per-Stream Filtering and Policing (PSFP) clause specified in +IEEE 802.1Q-2018 (formerly 802.1Qci). This means it can be used to perform +tight timing-based admission control for up to 1024 flows (identified by a +tuple composed of destination MAC address, VLAN ID and VLAN PCP). Packets which +are received outside their expected reception window are dropped. + +This capability can be managed through the offload of the tc-gate action. As +routing actions are intrinsic to virtual links in TTEthernet (which performs +explicit routing of time-critical traffic and does not leave that in the hands +of the FDB, flooding etc), the tc-gate action may never appear alone when +asking sja1105 to offload it. One (or more) redirect or trap actions must also +follow along. + +Example: create a tc-taprio schedule that is phase-aligned with a tc-gate +schedule (the clocks must be synchronized by a 1588 application stack, which is +outside the scope of this document). No packet delivered by the sender will be +dropped. Note that the reception window is larger than the transmission window +(and much more so, in this example) to compensate for the packet propagation +delay of the link (which can be determined by the 1588 application stack). + +Receiver (sja1105):: + + tc qdisc add dev swp2 clsact + now=$(phc_ctl /dev/ptp1 get | awk '/clock time is/ {print $5}') && \ + sec=$(echo $now | awk -F. '{print $1}') && \ + base_time="$(((sec + 2) * 1000000000))" && \ + echo "base time ${base_time}" + tc filter add dev swp2 ingress flower skip_sw \ + dst_mac 42:be:24:9b:76:20 \ + action gate base-time ${base_time} \ + sched-entry OPEN 60000 -1 -1 \ + sched-entry CLOSE 40000 -1 -1 \ + action trap + +Sender:: + + now=$(phc_ctl /dev/ptp0 get | awk '/clock time is/ {print $5}') && \ + sec=$(echo $now | awk -F. '{print $1}') && \ + base_time="$(((sec + 2) * 1000000000))" && \ + echo "base time ${base_time}" + tc qdisc add dev eno0 parent root taprio \ + num_tc 8 \ + map 0 1 2 3 4 5 6 7 \ + queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \ + base-time ${base_time} \ + sched-entry S 01 50000 \ + sched-entry S 00 50000 \ + flags 2 + +The engine used to schedule the ingress gate operations is the same that the +one used for the tc-taprio offload. Therefore, the restrictions regarding the +fact that no two gate actions (either tc-gate or tc-taprio gates) may fire at +the same time (during the same 200 ns slot) still apply. + +To come in handy, it is possible to share time-triggered virtual links across +more than 1 ingress port, via flow blocks. In this case, the restriction of +firing at the same time does not apply because there is a single schedule in +the system, that of the shared virtual link:: + + tc qdisc add dev swp2 ingress_block 1 clsact + tc qdisc add dev swp3 ingress_block 1 clsact + tc filter add block 1 flower skip_sw dst_mac 42:be:24:9b:76:20 \ + action gate index 2 \ + base-time 0 \ + sched-entry OPEN 50000000 -1 -1 \ + sched-entry CLOSE 50000000 -1 -1 \ + action trap + +Hardware statistics for each flow are also available ("pkts" counts the number +of dropped frames, which is a sum of frames dropped due to timing violations, +lack of destination ports and MTU enforcement checks). Byte-level counters are +not available. + Device Tree bindings and board design =====================================
Signature · 1 line
2.17.1