net: dsa: mv88e6xxx: factorize GLOBAL_MONITOR_CONTROL setup
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Mon, 9 May 2016 17:22:53 +0000 (13:22 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 9 May 2016 18:26:12 +0000 (14:26 -0400)
All switch drivers configure the GLOBAL_MONITOR_CONTROL register with
slightly changes.

Assume the setup of the upstream port, and configure it as the port to
which ingress and egress and ARP monitor frames are to be sent.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6123.c
drivers/net/dsa/mv88e6131.c
drivers/net/dsa/mv88e6171.c
drivers/net/dsa/mv88e6352.c
drivers/net/dsa/mv88e6xxx.c

index 1cd30ac19c1a8f63435b4ba547d2a9027e31adbb..5df06d8c3ed22af5e34d0cec4a48f6663023b354 100644 (file)
@@ -54,20 +54,6 @@ static const char *mv88e6123_drv_probe(struct device *dsa_dev,
 static int mv88e6123_setup_global(struct dsa_switch *ds)
 {
        struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-       u32 upstream_port = dsa_upstream_port(ds);
-       int ret;
-       u32 reg;
-
-       /* Configure the upstream port, and configure the upstream
-        * port as the port to which ingress and egress monitor frames
-        * are to be sent.
-        */
-       reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
-               upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
-               upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT;
-       ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
-       if (ret)
-               return ret;
 
        /* Disable remote management for now, and set the switch's
         * DSA device number.
index 1c3b245cd110b75b8d6baeb87afcab389bfe3761..c8e3974163dc7aa09f1441ef843e2999b48fa811 100644 (file)
@@ -61,20 +61,7 @@ static const char *mv88e6131_drv_probe(struct device *dsa_dev,
 static int mv88e6131_setup_global(struct dsa_switch *ds)
 {
        struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-       u32 upstream_port = dsa_upstream_port(ds);
        int ret;
-       u32 reg;
-
-       /* Disable ARP mirroring, and configure the upstream port as
-        * the port to which ingress and egress monitor frames are to
-        * be sent.
-        */
-       reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
-               upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
-               GLOBAL_MONITOR_CONTROL_ARP_DISABLED;
-       ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
-       if (ret)
-               return ret;
 
        /* Disable cascade port functionality unless this device
         * is used in a cascade configuration, and set the switch's
index 6c8554ce24e66d3ad56e84ce1320c74ad8db653f..a848aefb4c74837ecdc4f5394045d1ba44837e2b 100644 (file)
@@ -61,21 +61,6 @@ static const char *mv88e6171_drv_probe(struct device *dsa_dev,
 static int mv88e6171_setup_global(struct dsa_switch *ds)
 {
        struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-       u32 upstream_port = dsa_upstream_port(ds);
-       int ret;
-       u32 reg;
-
-       /* Configure the upstream port, and configure the upstream
-        * port as the port to which ingress and egress monitor frames
-        * are to be sent.
-        */
-       reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
-               upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
-               upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT |
-               upstream_port << GLOBAL_MONITOR_CONTROL_MIRROR_SHIFT;
-       ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
-       if (ret)
-               return ret;
 
        /* Disable remote management for now, and set the switch's
         * DSA device number.
index a27616c00ad6cea669993904d517ad28b0ee989a..e0988706c88216c1ac992e5c2a494ab7ebc7b424 100644 (file)
@@ -80,20 +80,6 @@ static const char *mv88e6352_drv_probe(struct device *dsa_dev,
 static int mv88e6352_setup_global(struct dsa_switch *ds)
 {
        struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-       u32 upstream_port = dsa_upstream_port(ds);
-       int ret;
-       u32 reg;
-
-       /* Configure the upstream port, and configure the upstream
-        * port as the port to which ingress and egress monitor frames
-        * are to be sent.
-        */
-       reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
-               upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
-               upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT;
-       ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
-       if (ret)
-               return ret;
 
        /* Disable remote management for now, and set the switch's
         * DSA device number.
index f1cd66073bf7ac453a9290a113ba252ce6237d9c..27551c1f1cd01ef997ed56354aa2e3ef4f4cadbe 100644 (file)
@@ -2922,6 +2922,8 @@ int mv88e6xxx_setup_ports(struct dsa_switch *ds)
 
 static int mv88e6xxx_setup_global(struct mv88e6xxx_priv_state *ps)
 {
+       struct dsa_switch *ds = ps->ds;
+       u32 upstream_port = dsa_upstream_port(ds);
        u16 reg;
        int err;
        int i;
@@ -2938,6 +2940,16 @@ static int mv88e6xxx_setup_global(struct mv88e6xxx_priv_state *ps)
        if (err)
                return err;
 
+       /* Configure the upstream port, and configure it as the port to which
+        * ingress and egress and ARP monitor frames are to be sent.
+        */
+       reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
+               upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
+               upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT;
+       err = _mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
+       if (err)
+               return err;
+
        /* Set the default address aging time to 5 minutes, and
         * enable address learn messages to be sent to all message
         * ports.
This page took 0.030135 seconds and 5 git commands to generate.