Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1344545

[PATCH net-next 6/9] net: dsa: mv88e6xxx: assign dynamic FDB to bridges

From Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Newsgroups linux.kernel
Subject [PATCH net-next 6/9] net: dsa: mv88e6xxx: assign dynamic FDB to bridges
Date 2016-02-26 19:30 +0100
Message-ID <r6vjl-7ja-31@gated-at.bofh.it> (permalink)
References <r6v9E-7fn-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Give a new bridge a fresh FDB, assign it to its members, and restore a
fresh FDB to a port leaving a bridge.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6xxx.c | 41 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 0f06488..0f16911 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -2093,19 +2093,56 @@ int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
 			       struct net_device *bridge)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+	u16 fid;
+	int i, err;
+
+	mutex_lock(&ps->smi_mutex);
+
+	/* Get or create the bridge FID and assign it to the port */
+	for (i = 0; i < ps->num_ports; ++i)
+		if (ps->ports[i].bridge_dev == bridge)
+			break;
+
+	if (i < ps->num_ports)
+		err = _mv88e6xxx_port_fid_get(ds, i, &fid);
+	else
+		err = _mv88e6xxx_fid_new(ds, &fid);
+	if (err)
+		goto unlock;
+
+	err = _mv88e6xxx_port_fid_set(ds, port, fid);
+	if (err)
+		goto unlock;
 
 	ps->ports[port].bridge_dev = bridge;
+unlock:
+	mutex_unlock(&ps->smi_mutex);
 
-	return 0;
+	return err;
 }
 
 int mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+	u16 fid;
+	int err;
+
+	mutex_lock(&ps->smi_mutex);
+
+	/* Give the port a fresh Filtering Information Database */
+	err = _mv88e6xxx_fid_new(ds, &fid);
+	if (err)
+		goto unlock;
+
+	err = _mv88e6xxx_port_fid_set(ds, port, fid);
+	if (err)
+		goto unlock;
 
 	ps->ports[port].bridge_dev = NULL;
+unlock:
+	mutex_unlock(&ps->smi_mutex);
 
-	return 0;
+	return err;
 }
 
 static int mv88e6xxx_setup_port_default_vlan(struct dsa_switch *ds, int port)
-- 
2.7.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH net-next 0/9] net: dsa: mv88e6xxx: implement VLAN filtering Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-02-26 19:30 +0100
  [PATCH net-next 2/9] net: dsa: mv88e6xxx: extract single VLAN retrieval Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-02-26 19:30 +0100
  [PATCH net-next 4/9] net: dsa: mv88e6xxx: assign dynamic FDB to VLANs Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-02-26 19:30 +0100
  [PATCH net-next 6/9] net: dsa: mv88e6xxx: assign dynamic FDB to bridges Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-02-26 19:30 +0100
  [PATCH net-next 7/9] net: dsa: mv88e6xxx: restore VLANTable map control Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-02-26 19:30 +0100
    Re: [PATCH net-next 7/9] net: dsa: mv88e6xxx: restore VLANTable map  control Kevin Smith <kevin.smith@elecsyscorp.com> - 2016-02-26 21:50 +0100
      Re: [PATCH net-next 7/9] net: dsa: mv88e6xxx: restore VLANTable map  control Andrew Lunn <andrew@lunn.ch> - 2016-02-26 22:10 +0100
        Re: [PATCH net-next 7/9] net: dsa: mv88e6xxx: restore VLANTable map control Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-02-26 22:40 +0100
          Re: [PATCH net-next 7/9] net: dsa: mv88e6xxx: restore VLANTable map  control Andrew Lunn <andrew@lunn.ch> - 2016-02-26 23:10 +0100
          Re: [PATCH net-next 7/9] net: dsa: mv88e6xxx: restore VLANTable map  control Kevin Smith <kevin.smith@elecsyscorp.com> - 2016-02-26 23:30 +0100
            Re: [PATCH net-next 7/9] net: dsa: mv88e6xxx: restore VLANTable map  control Andrew Lunn <andrew@lunn.ch> - 2016-02-26 23:40 +0100
              Re: [PATCH net-next 7/9] net: dsa: mv88e6xxx: restore VLANTable map  control Kevin Smith <kevin.smith@elecsyscorp.com> - 2016-02-26 23:50 +0100
                Re: [PATCH net-next 7/9] net: dsa: mv88e6xxx: restore VLANTable map  control Andrew Lunn <andrew@lunn.ch> - 2016-02-27 04:20 +0100
  [PATCH net-next 3/9] net: dsa: mv88e6xxx: extract single FDB dump Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-02-26 19:30 +0100
  Re: [PATCH net-next 0/9] net: dsa: mv88e6xxx: implement VLAN  filtering David Miller <davem@davemloft.net> - 2016-03-01 22:30 +0100

csiph-web