net: dsa: tag_qca: return early if dev is not found
Christian Marangi
maintainerPATCH 1/3 net: dsa: tag_qca: return early if dev is not found
Currently checksum is recalculated and dsa tag stripped even if we later don't find the dev.
To improve code, exit early if we don't find the dev and skip additional operation on the skb since it will be freed anyway.
--- net/dsa/tag_qca.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/dsa/tag_qca.c +4 -4
@@ -75,10 +75,6 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev)return NULL ; } -/* Remove QCA tag and recalculate checksum */ -skb_pull_rcsum (skb,QCA_HDR_LEN ); -dsa_strip_etype_header (skb,QCA_HDR_LEN ); -/* Get source port information */ port =FIELD_GET (QCA_HDR_RECV_SOURCE_PORT , hdr);
@@ -86,6 +82,10 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev)if (!skb->dev)return NULL ; +/* Remove QCA tag and recalculate checksum */ +skb_pull_rcsum (skb,QCA_HDR_LEN ); +dsa_strip_etype_header (skb,QCA_HDR_LEN ); +return skb; }
Signature · 1 line
2.40.1
Christian Marangi
maintainerPATCH 2/3 net: dsa: qca8k: make learning configurable and keep off if standalone
Address learning should initially be turned off by the driver for port operation in standalone mode, then the DSA core handles changes to it via ds->ops->port_bridge_flags().
Currently this is not the case for qca8k where learning is enabled unconditionally in qca8k_setup for every user port.
Handle ports configured in standalone mode by making the learning configurable and not enabling it by default.
Implement .port_pre_bridge_flags and .port_bridge_flags dsa ops to enable learning for bridge that request it and tweak .port_stp_state_set to correctly disable learning when port is configured in standalone mode.
--- drivers/net/dsa/qca/qca8k-8xxx.c | 7 +++-- drivers/net/dsa/qca/qca8k-common.c | 44 ++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 6 ++++ 3 files changed, 54 insertions(+), 3 deletions(-)
drivers/net/dsa/qca/qca8k-8xxx.c +4 -3
@@ -1870,9 +1870,8 @@ qca8k_setup(struct dsa_switch *ds)if (ret)return ret; -/* Enable ARP Auto-learning by default */ - ret =regmap_set_bits (priv->regmap,QCA8K_PORT_LOOKUP_CTRL (i), -QCA8K_PORT_LOOKUP_LEARN ); + ret =regmap_clear_bits (priv->regmap,QCA8K_PORT_LOOKUP_CTRL (i), +QCA8K_PORT_LOOKUP_LEARN );if (ret)return ret;
@@ -1978,6 +1977,8 @@ static const struct dsa_switch_ops qca8k_switch_ops = { .port_change_mtu = qca8k_port_change_mtu, .port_max_mtu = qca8k_port_max_mtu, .port_stp_state_set = qca8k_port_stp_state_set, + .port_pre_bridge_flags = qca8k_port_pre_bridge_flags, + .port_bridge_flags = qca8k_port_bridge_flags, .port_bridge_join = qca8k_port_bridge_join, .port_bridge_leave = qca8k_port_bridge_leave, .port_fast_age = qca8k_port_fast_age,
drivers/net/dsa/qca/qca8k-common.c +44 -0
67 lines not on this page · raw message
drivers/net/dsa/qca/qca8k.h +6 -0
@@ -522,6 +522,12 @@ int qca8k_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e);/* Common bridge function */ void qca8k_port_stp_state_set (struct dsa_switch *ds,int port,u8 state); +int qca8k_port_pre_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack); +int qca8k_port_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack); int qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge, bool *tx_fwd_offload,
Signature · 1 line
2.40.1
Christian Marangi
maintainerPATCH 3/3 net: dsa: qca8k: limit user ports access to the first CPU port on setup
In reply to Christian MarangiIn preparation for multi-CPU support, set CPU port LOOKUP MEMBER outside the port loop and setup the LOOKUP MEMBER mask for user ports only to the first CPU port.
This is to handle flooding condition where every CPU port is set as target and prevent packet duplication for unknown frames from user ports.
Secondary CPU port LOOKUP MEMBER mask will be setup later when port_change_master will be implemented.
--- drivers/net/dsa/qca/qca8k-8xxx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/dsa/qca/qca8k-8xxx.c +6 -8
@@ -1850,18 +1850,16 @@ qca8k_setup(struct dsa_switch *ds)if (ret)return ret; +/* CPU port gets connected to all user ports of the switch */ + ret =qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (cpu_port), +QCA8K_PORT_LOOKUP_MEMBER ,dsa_user_ports (ds)); +if (ret) +return ret; +/* Setup connection between CPU port & user ports * Configure specific switch configuration for ports */ for (i =0 ; i <QCA8K_NUM_PORTS ; i++) { -/* CPU port gets connected to all user ports of the switch */ -if (dsa_is_cpu_port (ds, i)) { - ret =qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (i), -QCA8K_PORT_LOOKUP_MEMBER ,dsa_user_ports (ds)); -if (ret) -return ret; - } -/* Individual user ports get connected to CPU port only */ if (dsa_is_user_port (ds, i)) { ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(i),
Signature · 1 line
2.40.1
Quoted 7 lines · Christian Marangi
Currently checksum is recalculated and dsa tag stripped even if we later don't find the dev.
To improve code, exit early if we don't find the dev and skip additional operation on the skb since it will be freed anyway.
Signed-off-by Christian Marangi <[email protected]>
Re: [net-next PATCH 2/3] net: dsa: qca8k: make learning configurable and keep off if standalone
In reply to Christian MarangiQuoted 17 lines · Christian Marangi
Address learning should initially be turned off by the driver for port operation in standalone mode, then the DSA core handles changes to it via
ds->ops->port_bridge_flags().Currently this is not the case for qca8k where learning is enabled unconditionally in
qca8k_setupfor every user port.Handle ports configured in standalone mode by making the learning configurable and not enabling it by default.
Implement .port_pre_bridge_flags and .port_bridge_flags dsa ops to enable learning for bridge that request it and tweak .port_stp_state_set to correctly disable learning when port is configured in standalone mode.
Signed-off-by Christian Marangi <[email protected]>drivers/net/dsa/qca/qca8k-8xxx.c +0
-0
...
Quoted 10 lines
drivers/net/dsa/qca/qca8k-8xxx.c +2
-0@@ -1978,6 +1977,8 @@ static const struct dsa_switch_ops qca8k_switch_ops = { .port_change_mtu = qca8k_port_change_mtu, .port_max_mtu = qca8k_port_max_mtu, .port_stp_state_set = qca8k_port_stp_state_set, + .port_pre_bridge_flags = qca8k_port_pre_bridge_flags, + .port_bridge_flags = qca8k_port_bridge_flags, .port_bridge_join = qca8k_port_bridge_join, .port_bridge_leave = qca8k_port_bridge_leave, .port_fast_age = qca8k_port_fast_age,drivers/net/dsa/qca/qca8k-common.c +0
-0
...
Quoted 4 lines
drivers/net/dsa/qca/qca8k-common.c +0
-0@@ -591,6 +611,30 @@ void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (port),QCA8K_PORT_LOOKUP_STATE_MASK , stp_state);
drivers/net/dsa/qca/qca8k-common.c void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) · line 623
Quoted 10 lines
drivers/net/dsa/qca/qca8k-common.c +10
-0+ +qca8k_port_configure_learning (ds, port, learning); +} + +int qca8k_port_pre_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack) +{ +if (flags.mask & ~BR_LEARNING ) +return -EINVAL ;
If I am reading things right then some implementation of this callback return -EINVAL when they see unexpected flags. And some seem not to
- possibly because all flags are expected.
So I'm slightly unsure if this is correct or not.
Quoted 3 lines
drivers/net/dsa/qca/qca8k-common.c +3
-0+ +return 0 ; +}
...
Re: [net-next PATCH 3/3] net: dsa: qca8k: limit user ports access to the first CPU port on setup
In reply to Christian MarangiQuoted 11 lines · Christian Marangi
In preparation for multi-CPU support, set CPU port LOOKUP MEMBER outside the port loop and setup the LOOKUP MEMBER mask for user ports only to the first CPU port.
This is to handle flooding condition where every CPU port is set as target and prevent packet duplication for unknown frames from user ports.
Secondary CPU port LOOKUP MEMBER mask will be setup later when
port_change_masterwill be implemented.Signed-off-by Christian Marangi <[email protected]>
Quoted 8 lines · Christian Marangi
Currently checksum is recalculated and dsa tag stripped even if we later don't find the dev.
To improve code, exit early if we don't find the dev and skip additional operation on the skb since it will be freed anyway.
Signed-off-by Christian Marangi <[email protected]>---
Re: [net-next PATCH 2/3] net: dsa: qca8k: make learning configurable and keep off if standalone
In reply to Christian MarangiQuoted 10 lines · Christian Marangi
Address learning should initially be turned off by the driver for port operation in standalone mode, then the DSA core handles changes to it via
ds->ops->port_bridge_flags().Currently this is not the case for qca8k where learning is enabled unconditionally in
qca8k_setupfor every user port.Handle ports configured in standalone mode by making the learning configurable and not enabling it by default.
Quoted 7 lines
Implement .port_pre_bridge_flags and .port_bridge_flags dsa ops to enable learning for bridge that request it and tweak .port_stp_state_set to correctly disable learning when port is configured in standalone mode.
Signed-off-by Christian Marangi <[email protected]>---
Small nitpick below.
Quoted 91 lines
drivers/net/dsa/qca/qca8k-8xxx.c | 7 +++-- drivers/net/dsa/qca/qca8k-common.c | 44 ++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 6 ++++ 3 files changed, 54 insertions(+), 3 deletions(-)drivers/net/dsa/qca/qca8k-8xxx.c +4
-3@@ -1870,9 +1870,8 @@ qca8k_setup(struct dsa_switch *ds)if (ret)return ret; -/* Enable ARP Auto-learning by default */ - ret =regmap_set_bits (priv->regmap,QCA8K_PORT_LOOKUP_CTRL (i), -QCA8K_PORT_LOOKUP_LEARN ); + ret =regmap_clear_bits (priv->regmap,QCA8K_PORT_LOOKUP_CTRL (i), +QCA8K_PORT_LOOKUP_LEARN );if (ret)return ret;@@ -1978,6 +1977,8 @@ static const struct dsa_switch_ops qca8k_switch_ops = { .port_change_mtu = qca8k_port_change_mtu, .port_max_mtu = qca8k_port_max_mtu, .port_stp_state_set = qca8k_port_stp_state_set, + .port_pre_bridge_flags = qca8k_port_pre_bridge_flags, + .port_bridge_flags = qca8k_port_bridge_flags, .port_bridge_join = qca8k_port_bridge_join, .port_bridge_leave = qca8k_port_bridge_leave, .port_fast_age = qca8k_port_fast_age,drivers/net/dsa/qca/qca8k-common.c +34
-0@@ -565,9 +565,26 @@ int qca8k_get_mac_eee(struct dsa_switch *ds, int port,return 0 ; } +static int qca8k_port_configure_learning (struct dsa_switch *ds,int port, +bool learning) +{ +struct qca8k_priv *priv = ds->priv; + +if (learning) +return regmap_set_bits (priv->regmap, +QCA8K_PORT_LOOKUP_CTRL (port), +QCA8K_PORT_LOOKUP_LEARN ); +else +return regmap_clear_bits (priv->regmap, +QCA8K_PORT_LOOKUP_CTRL (port), +QCA8K_PORT_LOOKUP_LEARN ); +} +void qca8k_port_stp_state_set (struct dsa_switch *ds,int port,u8 state) { +struct dsa_port *dp =dsa_to_port (ds, port);struct qca8k_priv *priv = ds->priv; +bool learning = false;u32 stp_state;switch (state) {@@ -582,8 +599,11 @@ void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)break ;case BR_STATE_LEARNING : stp_state =QCA8K_PORT_LOOKUP_STATE_LEARNING ; + learning = dp->learning;break ;case BR_STATE_FORWARDING : + learning = dp->learning; + fallthrough;default : stp_state =QCA8K_PORT_LOOKUP_STATE_FORWARD ;break ;@@ -591,6 +611,30 @@ void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (port),QCA8K_PORT_LOOKUP_STATE_MASK , stp_state); + +qca8k_port_configure_learning (ds, port, learning); +} + +int qca8k_port_pre_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack) +{ +if (flags.mask & ~BR_LEARNING ) +return -EINVAL ; + +return 0 ; +} +
drivers/net/dsa/qca/qca8k-common.c void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) · line 637
Quoted 10 lines
drivers/net/dsa/qca/qca8k-common.c +10
-0+int qca8k_port_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack) +{ +int ret; + + ret =qca8k_port_configure_learning (ds, port, + flags.val &BR_LEARNING ); + +return ret;
I worry that the way in this is formulated will attract patches from kernel janitors to simplify it to:
return qca8k_port_configure_learning(...)
I agree that it's not strictly necessary to check flags.mask when port_pre_bridge_flags supports a single flag, but if you did that and structured the code for more future flags, you could avoid that.
int ret;
if (flags.mask & BR_LEARNING) {
ret = qca8k_port_configure_learning(...,
flags.val & BR_LEARNING);
if (ret)
return ret;
}
return 0;Anyway, probably not a big deal.
Quoted 23 lines
drivers/net/dsa/qca/qca8k-common.c +0
-0} int qca8k_port_bridge_join(struct dsa_switch *ds, int port,drivers/net/dsa/qca/qca8k.h +6
-0@@ -522,6 +522,12 @@ int qca8k_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e);/* Common bridge function */ void qca8k_port_stp_state_set (struct dsa_switch *ds,int port,u8 state); +int qca8k_port_pre_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack); +int qca8k_port_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack); int qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge, bool *tx_fwd_offload,Signature · 1 line
2.40.1
Vladimir Oltean
maintainerRe: [net-next PATCH 2/3] net: dsa: qca8k: make learning configurable and keep off if standalone
In reply to Simon HormanQuoted 11 lines · Simon Horman
drivers/net/dsa/qca/qca8k-common.c void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) · line 623
Quoted 6 lines
drivers/net/dsa/qca/qca8k-common.c +6
-0+int qca8k_port_pre_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack) +{ +if (flags.mask & ~BR_LEARNING ) +return -EINVAL ;If I am reading things right then some implementation of this callback return
-EINVALwhen they see unexpected flags. And some seem not to
- possibly because all flags are expected.
Quoted 1 line
So I'm slightly unsure if this is correct or not.
Which ones don't? All handlers of SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS should return -EINVAL for changes made to bridge port flags that aren't supported.
Re: [net-next PATCH 2/3] net: dsa: qca8k: make learning configurable and keep off if standalone
Quoted 12 lines · Vladimir Oltean
Quoted 11 lines · Simon Horman
drivers/net/dsa/qca/qca8k-common.c void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) · line 623
Quoted 6 lines
drivers/net/dsa/qca/qca8k-common.c +6
-0+int qca8k_port_pre_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack) +{ +if (flags.mask & ~BR_LEARNING ) +return -EINVAL ;If I am reading things right then some implementation of this callback return
-EINVALwhen they see unexpected flags. And some seem not to
- possibly because all flags are expected.
Quoted 5 lines
Quoted 1 line
So I'm slightly unsure if this is correct or not.
Which ones don't? All handlers of
SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGSshould return-EINVALfor changes made to bridge port flags that aren't supported.
Sorry, on a second look I see that my statement above is incorrect. I do wonder what it was I saw this morning. But this afternoon I see that all users check flags and return -EINVAL as appropriate.
Vladimir Oltean
maintainerRe: [net-next PATCH 3/3] net: dsa: qca8k: limit user ports access to the first CPU port on setup
In reply to Christian MarangiQuoted 4 lines · Christian Marangi
In preparation for multi-CPU support, set CPU port LOOKUP MEMBER outside the port loop and setup the LOOKUP MEMBER mask for user ports only to the first CPU port.
Quoted 8 lines
This is to handle flooding condition where every CPU port is set as target and prevent packet duplication for unknown frames from user ports.
Secondary CPU port LOOKUP MEMBER mask will be setup later when
port_change_masterwill be implemented.Signed-off-by Christian Marangi <[email protected]>---
This is kinda "net.git" material, in the sense that it fixes the current driver behavior with device trees from the future, right?
Quoted 7 lines · Christian Marangi
Currently checksum is recalculated and dsa tag stripped even if we later don't find the dev.
To improve code, exit early if we don't find the dev and skip additional operation on the skb since it will be freed anyway.
Signed-off-by Christian Marangi <[email protected]>
Signature · 1 line
Florian
Re: [net-next PATCH 3/3] net: dsa: qca8k: limit user ports access to the first CPU port on setup
In reply to Christian MarangiQuoted 11 lines · Christian Marangi
In preparation for multi-CPU support, set CPU port LOOKUP MEMBER outside the port loop and setup the LOOKUP MEMBER mask for user ports only to the first CPU port.
This is to handle flooding condition where every CPU port is set as target and prevent packet duplication for unknown frames from user ports.
Secondary CPU port LOOKUP MEMBER mask will be setup later when
port_change_masterwill be implemented.Signed-off-by Christian Marangi <[email protected]>
Signature · 1 line
Florian
Re: [net-next PATCH 2/3] net: dsa: qca8k: make learning configurable and keep off if standalone
In reply to Christian MarangiQuoted 10 lines · Christian Marangi
Address learning should initially be turned off by the driver for port operation in standalone mode, then the DSA core handles changes to it via
ds->ops->port_bridge_flags().Currently this is not the case for qca8k where learning is enabled unconditionally in
qca8k_setupfor every user port.Handle ports configured in standalone mode by making the learning configurable and not enabling it by default.
Quoted 6 lines
Implement .port_pre_bridge_flags and .port_bridge_flags dsa ops to enable learning for bridge that request it and tweak .port_stp_state_set to correctly disable learning when port is configured in standalone mode.
Signed-off-by Christian Marangi <[email protected]>
With the feedback from Vladimir being addressed:
Signature · 1 line
Florian
Christian Marangi
maintainerRe: [net-next PATCH 2/3] net: dsa: qca8k: make learning configurable and keep off if standalone
In reply to Vladimir OlteanQuoted 145 lines · Vladimir Oltean
Quoted 10 lines · Christian Marangi
Address learning should initially be turned off by the driver for port operation in standalone mode, then the DSA core handles changes to it via
ds->ops->port_bridge_flags().Currently this is not the case for qca8k where learning is enabled unconditionally in
qca8k_setupfor every user port.Handle ports configured in standalone mode by making the learning configurable and not enabling it by default.
Quoted 7 lines
Implement .port_pre_bridge_flags and .port_bridge_flags dsa ops to enable learning for bridge that request it and tweak .port_stp_state_set to correctly disable learning when port is configured in standalone mode.
Signed-off-by Christian Marangi <[email protected]>---
Reviewed-by Vladimir Oltean <[email protected]>Small nitpick below.
Quoted 91 lines
drivers/net/dsa/qca/qca8k-8xxx.c | 7 +++-- drivers/net/dsa/qca/qca8k-common.c | 44 ++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 6 ++++ 3 files changed, 54 insertions(+), 3 deletions(-)drivers/net/dsa/qca/qca8k-8xxx.c +4
-3@@ -1870,9 +1870,8 @@ qca8k_setup(struct dsa_switch *ds)if (ret)return ret; -/* Enable ARP Auto-learning by default */ - ret =regmap_set_bits (priv->regmap,QCA8K_PORT_LOOKUP_CTRL (i), -QCA8K_PORT_LOOKUP_LEARN ); + ret =regmap_clear_bits (priv->regmap,QCA8K_PORT_LOOKUP_CTRL (i), +QCA8K_PORT_LOOKUP_LEARN );if (ret)return ret;@@ -1978,6 +1977,8 @@ static const struct dsa_switch_ops qca8k_switch_ops = { .port_change_mtu = qca8k_port_change_mtu, .port_max_mtu = qca8k_port_max_mtu, .port_stp_state_set = qca8k_port_stp_state_set, + .port_pre_bridge_flags = qca8k_port_pre_bridge_flags, + .port_bridge_flags = qca8k_port_bridge_flags, .port_bridge_join = qca8k_port_bridge_join, .port_bridge_leave = qca8k_port_bridge_leave, .port_fast_age = qca8k_port_fast_age,drivers/net/dsa/qca/qca8k-common.c +34
-0@@ -565,9 +565,26 @@ int qca8k_get_mac_eee(struct dsa_switch *ds, int port,return 0 ; } +static int qca8k_port_configure_learning (struct dsa_switch *ds,int port, +bool learning) +{ +struct qca8k_priv *priv = ds->priv; + +if (learning) +return regmap_set_bits (priv->regmap, +QCA8K_PORT_LOOKUP_CTRL (port), +QCA8K_PORT_LOOKUP_LEARN ); +else +return regmap_clear_bits (priv->regmap, +QCA8K_PORT_LOOKUP_CTRL (port), +QCA8K_PORT_LOOKUP_LEARN ); +} +void qca8k_port_stp_state_set (struct dsa_switch *ds,int port,u8 state) { +struct dsa_port *dp =dsa_to_port (ds, port);struct qca8k_priv *priv = ds->priv; +bool learning = false;u32 stp_state;switch (state) {@@ -582,8 +599,11 @@ void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)break ;case BR_STATE_LEARNING : stp_state =QCA8K_PORT_LOOKUP_STATE_LEARNING ; + learning = dp->learning;break ;case BR_STATE_FORWARDING : + learning = dp->learning; + fallthrough;default : stp_state =QCA8K_PORT_LOOKUP_STATE_FORWARD ;break ;@@ -591,6 +611,30 @@ void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (port),QCA8K_PORT_LOOKUP_STATE_MASK , stp_state); + +qca8k_port_configure_learning (ds, port, learning); +} + +int qca8k_port_pre_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack) +{ +if (flags.mask & ~BR_LEARNING ) +return -EINVAL ; + +return 0 ; +} +drivers/net/dsa/qca/qca8k-common.c void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) · line 637
Quoted 10 lines
drivers/net/dsa/qca/qca8k-common.c +10
-0+int qca8k_port_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack) +{ +int ret; + + ret =qca8k_port_configure_learning (ds, port, + flags.val &BR_LEARNING ); + +return ret;I worry that the way in this is formulated will attract patches from kernel janitors to simplify it to:
return
qca8k_port_configure_learning(...)I agree that it's not strictly necessary to check flags.mask when
port_pre_bridge_flagssupports a single flag, but if you did that and structured the code for more future flags, you could avoid that.int ret; if (flags.mask & BR_LEARNING) { ret = qca8k_port_configure_learning(..., flags.val & BR_LEARNING); if (ret) return ret; } return 0;
Quoted 3 lines
Anyway, probably not a big deal.
Quoted 1 line
drivers/net/dsa/qca/qca8k-common.c +0
-0}
I hope and expect to send fbd isolation later with FLOOD flags so I will send v2 of this with the suggested format.
Quoted 23 lines
Quoted 22 lines
drivers/net/dsa/qca/qca8k-common.c +0
-0int qca8k_port_bridge_join(struct dsa_switch *ds, int port,drivers/net/dsa/qca/qca8k.h +6
-0@@ -522,6 +522,12 @@ int qca8k_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e);/* Common bridge function */ void qca8k_port_stp_state_set (struct dsa_switch *ds,int port,u8 state); +int qca8k_port_pre_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack); +int qca8k_port_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack); int qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge, bool *tx_fwd_offload,Signature · 1 line
2.40.1
Signature · 1 line
Ansuel
Christian Marangi
maintainerRe: [net-next PATCH 3/3] net: dsa: qca8k: limit user ports access to the first CPU port on setup
In reply to Vladimir OlteanQuoted 8 lines · Vladimir Oltean
Quoted 7 lines · Christian Marangi
In preparation for multi-CPU support, set CPU port LOOKUP MEMBER outside the port loop and setup the LOOKUP MEMBER mask for user ports only to the first CPU port.
This is to handle flooding condition where every CPU port is set as target and prevent packet duplication for unknown frames from user ports.
Quoted 8 lines
Quoted 5 lines
Secondary CPU port LOOKUP MEMBER mask will be setup later when
port_change_masterwill be implemented.Signed-off-by Christian Marangi <[email protected]>---
This is kinda "net.git" material, in the sense that it fixes the current driver behavior with device trees from the future, right?
This is not strictly a fix. The secondary CPU (if defined) doesn't have flood enabled so the switch won't forward packet. It's more of a cleanup/preparation from my point of view. What do you think?
Signature · 1 line
Ansuel
Vladimir Oltean
maintainerRe: [net-next PATCH 3/3] net: dsa: qca8k: limit user ports access to the first CPU port on setup
Quoted 15 lines · Christian Marangi
Quoted 14 lines · Vladimir Oltean
Quoted 12 lines · Christian Marangi
In preparation for multi-CPU support, set CPU port LOOKUP MEMBER outside the port loop and setup the LOOKUP MEMBER mask for user ports only to the first CPU port.
This is to handle flooding condition where every CPU port is set as target and prevent packet duplication for unknown frames from user ports.
Secondary CPU port LOOKUP MEMBER mask will be setup later when
port_change_masterwill be implemented.Signed-off-by Christian Marangi <[email protected]>---
Quoted 9 lines
Quoted 2 lines
This is kinda "net.git" material, in the sense that it fixes the current driver behavior with device trees from the future, right?
This is not strictly a fix. The secondary CPU (if defined) doesn't have flood enabled so the switch won't forward packet. It's more of a cleanup/preparation from my point of view. What do you think?
Signature · 1 line
Ansuel
Ah, ok, if packets don't reach the second CPU port anyway then it's fine.
Re: [net-next PATCH 3/3] net: dsa: qca8k: limit user ports access to the first CPU port on setup
In reply to Christian MarangiQuoted 4 lines · Christian Marangi
In preparation for multi-CPU support, set CPU port LOOKUP MEMBER outside the port loop and setup the LOOKUP MEMBER mask for user ports only to the first CPU port.
Quoted 8 lines
This is to handle flooding condition where every CPU port is set as target and prevent packet duplication for unknown frames from user ports.
Secondary CPU port LOOKUP MEMBER mask will be setup later when
port_change_masterwill be implemented.Signed-off-by Christian Marangi <[email protected]>---
Quoted 22 lines
drivers/net/dsa/qca/qca8k-8xxx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)drivers/net/dsa/qca/qca8k-8xxx.c +6
-1@@ -1850,18 +1850,16 @@ qca8k_setup(struct dsa_switch *ds)if (ret)return ret; +/* CPU port gets connected to all user ports of the switch */ + ret =qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (cpu_port), +QCA8K_PORT_LOOKUP_MEMBER ,dsa_user_ports (ds)); +if (ret) +return ret; +/* Setup connection between CPU port & user ports * Configure specific switch configuration for ports */ for (i =0 ; i <QCA8K_NUM_PORTS ; i++) { -/* CPU port gets connected to all user ports of the switch */
drivers/net/dsa/qca/qca8k-8xxx.c qca8k_setup(struct dsa_switch *ds) · line 1865
Quoted 10 lines
drivers/net/dsa/qca/qca8k-8xxx.c +0
-7-if (dsa_is_cpu_port (ds, i)) { - ret =qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (i), -QCA8K_PORT_LOOKUP_MEMBER ,dsa_user_ports (ds)); -if (ret) -return ret; - } -/* Individual user ports get connected to CPU port only */ if (dsa_is_user_port (ds, i)) { ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(i),
FWIW, the remaining loop can be rewritten (in a separate patch) using dsa_switch_for_each_user_port(), which is actually an operation of lower complexity compared to "for" + "dsa_is_user_port".
Quoted 3 lines
Signature · 1 line
2.40.1