From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, vivien.didelot@savoirfairelinux.com,
jerome.oufella@savoirfairelinux.com, linux@roeck-us.net,
andrew@lunn.ch, cphealy@gmail.com
Subject: Re: [PATCH RFC 2/2] net: dsa: bcm_sf2: implement HW bridging operations
Date: Wed, 18 Feb 2015 18:48:19 -0800 [thread overview]
Message-ID: <54E54EF3.9020802@gmail.com> (raw)
In-Reply-To: <1424201196-4901-3-git-send-email-f.fainelli@gmail.com>
On 17/02/15 11:26, Florian Fainelli wrote:
> Update the Broadcom Starfighter 2 switch driver to implement the
> join/leave/stp_update callbacks required for basic hardware bridging
> support.
>
> There is not much to be done at the driver level but translating the
> STP state from Linux to their HW values.
>
> Joining a bridge means that the joining port and the other port members
> need to be in the same VLAN membership as the CPU, while leaving the
> bridge puts the port back into a separate VLAN membership with only the
> CPU.
I found a couple additional issues while testing:
- manipulating UP/DOWN state of interfaces that are part of a bridge
would not restore their bridge membership
- removing an interface from a bridge and bringing it back up would
leave it in blocked state
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> drivers/net/dsa/bcm_sf2.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 93 insertions(+)
>
> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> index 4daffb284931..006c86a4df54 100644
> --- a/drivers/net/dsa/bcm_sf2.c
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -23,6 +23,7 @@
> #include <linux/of_address.h>
> #include <net/dsa.h>
> #include <linux/ethtool.h>
> +#include <linux/if_bridge.h>
>
> #include "bcm_sf2.h"
> #include "bcm_sf2_regs.h"
> @@ -400,6 +401,95 @@ static int bcm_sf2_sw_set_eee(struct dsa_switch *ds, int port,
> return 0;
> }
>
> +static int bcm_sf2_sw_br_join(struct dsa_switch *ds, int port,
> + u32 br_port_mask)
> +{
> + struct bcm_sf2_priv *priv = ds_to_priv(ds);
> + unsigned int i;
> + u32 reg, p_ctl;
> +
> + p_ctl = core_readl(priv, CORE_PORT_VLAN_CTL_PORT(port));
> +
> + for (i = 0; i < priv->hw_params.num_ports; i++) {
> + if (!((1 << i) & br_port_mask))
> + continue;
> +
> + reg = core_readl(priv, CORE_PORT_VLAN_CTL_PORT(i));
> + reg |= 1 << port;
> + core_writel(priv, reg, CORE_PORT_VLAN_CTL_PORT(i));
> +
> + p_ctl |= 1 << i;
> + }
> +
> + core_writel(priv, p_ctl, CORE_PORT_VLAN_CTL_PORT(port));
> +
> + return 0;
> +}
> +
> +static int bcm_sf2_sw_br_leave(struct dsa_switch *ds, int port,
> + u32 br_port_mask)
> +{
> + struct bcm_sf2_priv *priv = ds_to_priv(ds);
> + unsigned int i;
> + u32 reg, p_ctl;
> +
> + p_ctl = core_readl(priv, CORE_PORT_VLAN_CTL_PORT(port));
> +
> + for (i = 0; i < priv->hw_params.num_ports; i++) {
> + /* Don't touch the remaining ports */
> + if (!((1 << i) & br_port_mask))
> + continue;
> +
> + reg = core_readl(priv, CORE_PORT_VLAN_CTL_PORT(i));
> + reg &= ~(1 << port);
> + core_writel(priv, reg, CORE_PORT_VLAN_CTL_PORT(i));
> +
> + /* Prevent self removal to preserve isolation */
> + if (port != i)
> + p_ctl &= ~(1 << i);
> + }
> +
> + core_writel(priv, p_ctl, CORE_PORT_VLAN_CTL_PORT(port));
> +
> + return 0;
> +}
> +
> +static int bcm_sf2_sw_br_stp_update(struct dsa_switch *ds, int port,
> + u8 state)
> +{
> + struct bcm_sf2_priv *priv = ds_to_priv(ds);
> + u32 reg;
> + u8 hw_state;
> +
> + switch (state) {
> + case BR_STATE_DISABLED:
> + hw_state = G_MISTP_DIS_STATE;
> + break;
> + case BR_STATE_LISTENING:
> + hw_state = G_MISTP_LISTEN_STATE;
> + break;
> + case BR_STATE_LEARNING:
> + hw_state = G_MISTP_LEARN_STATE;
> + break;
> + case BR_STATE_FORWARDING:
> + hw_state = G_MISTP_FWD_STATE;
> + break;
> + case BR_STATE_BLOCKING:
> + hw_state = G_MISTP_BLOCK_STATE;
> + break;
> + default:
> + pr_err("%s: invalid STP state: %d\n", __func__, state);
> + return -EINVAL;
> + }
> +
> + reg = core_readl(priv, CORE_G_PCTL_PORT(port));
> + reg &= ~(G_MISTP_STATE_MASK << G_MISTP_STATE_SHIFT);
> + reg |= hw_state;
> + core_writel(priv, reg, CORE_G_PCTL_PORT(port));
> +
> + return 0;
> +}
> +
> static irqreturn_t bcm_sf2_switch_0_isr(int irq, void *dev_id)
> {
> struct bcm_sf2_priv *priv = dev_id;
> @@ -916,6 +1006,9 @@ static struct dsa_switch_driver bcm_sf2_switch_driver = {
> .port_disable = bcm_sf2_port_disable,
> .get_eee = bcm_sf2_sw_get_eee,
> .set_eee = bcm_sf2_sw_set_eee,
> + .port_join_bridge = bcm_sf2_sw_br_join,
> + .port_leave_bridge = bcm_sf2_sw_br_leave,
> + .port_stp_update = bcm_sf2_sw_br_stp_update,
> };
>
> static int __init bcm_sf2_init(void)
>
--
Florian
next prev parent reply other threads:[~2015-02-19 2:48 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-17 19:26 [PATCH RFC 0/2] net: dsa: integration with SWITCHDEV for HW bridging Florian Fainelli
2015-02-17 19:26 ` [PATCH RFC 1/2] net: dsa: integrate " Florian Fainelli
2015-02-17 20:13 ` Guenter Roeck
2015-02-17 20:24 ` Florian Fainelli
2015-02-17 20:28 ` Guenter Roeck
2015-02-18 1:19 ` Andrew Lunn
2015-02-18 1:43 ` Florian Fainelli
2015-02-18 3:53 ` Guenter Roeck
2015-02-18 4:53 ` Florian Fainelli
2015-02-18 6:14 ` Guenter Roeck
2015-02-18 13:49 ` Andrew Lunn
2015-02-18 14:05 ` Guenter Roeck
2015-02-23 2:20 ` Guenter Roeck
2015-02-23 3:14 ` Andrew Lunn
2015-02-23 4:07 ` Guenter Roeck
2015-02-23 4:22 ` Andrew Lunn
2015-02-23 4:33 ` Florian Fainelli
2015-02-23 4:38 ` Guenter Roeck
2015-02-23 4:43 ` Florian Fainelli
2015-02-23 6:19 ` Guenter Roeck
2015-02-23 13:34 ` Andrew Lunn
2015-02-23 14:23 ` Guenter Roeck
2015-02-23 16:01 ` Andrew Lunn
2015-02-23 18:05 ` Florian Fainelli
2015-02-23 18:35 ` Guenter Roeck
2015-02-25 13:43 ` Andrey Volkov
2015-02-25 14:25 ` Guenter Roeck
2015-02-25 16:05 ` Andrey Volkov
2015-02-25 17:41 ` Guenter Roeck
2015-02-26 1:18 ` Andrey Volkov
2015-02-27 17:09 ` Andrey Volkov
2015-02-28 7:53 ` Guenter Roeck
2015-03-02 14:38 ` Andrey Volkov
2015-03-02 14:49 ` Guenter Roeck
2015-03-02 15:27 ` Andrey Volkov
2015-03-02 17:16 ` Guenter Roeck
2015-03-04 10:07 ` Andrey Volkov
2015-02-17 19:26 ` [PATCH RFC 2/2] net: dsa: bcm_sf2: implement HW bridging operations Florian Fainelli
2015-02-19 2:48 ` Florian Fainelli [this message]
2015-02-19 5:59 ` Guenter Roeck
2015-02-19 17:27 ` Florian Fainelli
2015-02-19 17:46 ` Guenter Roeck
2015-02-19 23:50 ` Florian Fainelli
2015-02-20 0:09 ` Guenter Roeck
2015-02-20 0:51 ` roopa
2015-02-20 1:03 ` Guenter Roeck
2015-02-20 1:46 ` roopa
2015-02-20 2:00 ` Florian Fainelli
2015-02-20 2:41 ` roopa
2015-02-20 4:05 ` Guenter Roeck
2015-02-20 4:58 ` Scott Feldman
2015-02-20 4:59 ` roopa
2015-02-20 3:20 ` Andy Gospodarek
2015-02-20 3:53 ` Viswanath Bandaru
2015-02-20 3:56 ` Andy Gospodarek
2015-02-20 2:18 ` Andrew Lunn
2015-02-20 2:51 ` roopa
2015-02-20 3:52 ` Andrew Lunn
2015-02-20 4:07 ` Guenter Roeck
2015-02-20 2:02 ` Andrew Lunn
2015-02-20 3:55 ` Guenter Roeck
2015-02-20 2:03 ` Florian Fainelli
2015-02-20 2:46 ` roopa
2015-02-18 0:48 ` [PATCH RFC 0/2] net: dsa: integration with SWITCHDEV for HW bridging Scott Feldman
2015-02-18 1:09 ` Florian Fainelli
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=54E54EF3.9020802@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=cphealy@gmail.com \
--cc=davem@davemloft.net \
--cc=jerome.oufella@savoirfairelinux.com \
--cc=linux@roeck-us.net \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@savoirfairelinux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.