]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: mv88e6xxx: factorize ATU access
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Mon, 9 May 2016 17:22:48 +0000 (13:22 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 9 May 2016 18:26:10 +0000 (14:26 -0400)
Add a MV88E6XXX_FLAG_ATU flag to identify switch models with an Address
Translation Unit.

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/mv88e6xxx.c
drivers/net/dsa/mv88e6xxx.h

index da5aa9c0a4716b08d1c04ced03351a02e59df265..45cce4fa5f37f21c9de10a72663fe8c3c55320ba 100644 (file)
@@ -141,6 +141,10 @@ struct dsa_switch_driver mv88e6123_switch_driver = {
        .port_vlan_add          = mv88e6xxx_port_vlan_add,
        .port_vlan_del          = mv88e6xxx_port_vlan_del,
        .port_vlan_dump         = mv88e6xxx_port_vlan_dump,
+       .port_fdb_prepare       = mv88e6xxx_port_fdb_prepare,
+       .port_fdb_add           = mv88e6xxx_port_fdb_add,
+       .port_fdb_del           = mv88e6xxx_port_fdb_del,
+       .port_fdb_dump          = mv88e6xxx_port_fdb_dump,
 };
 
 MODULE_ALIAS("platform:mv88e6123");
index 6c472cfa1df9903c4f21a9f39ae29eecb4732f73..037244b95e795ec284b2b4515d3f812d0c7144b1 100644 (file)
@@ -2275,6 +2275,11 @@ int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
                               const struct switchdev_obj_port_fdb *fdb,
                               struct switchdev_trans *trans)
 {
+       struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+
+       if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU))
+               return -EOPNOTSUPP;
+
        /* We don't need any dynamic resource from the kernel (yet),
         * so skip the prepare phase.
         */
@@ -2290,6 +2295,9 @@ void mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
                GLOBAL_ATU_DATA_STATE_UC_STATIC;
        struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
+       if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU))
+               return;
+
        mutex_lock(&ps->smi_mutex);
        if (_mv88e6xxx_port_fdb_load(ps, port, fdb->addr, fdb->vid, state))
                netdev_err(ds->ports[port], "failed to load MAC address\n");
@@ -2302,6 +2310,9 @@ int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
        struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
        int ret;
 
+       if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU))
+               return -EOPNOTSUPP;
+
        mutex_lock(&ps->smi_mutex);
        ret = _mv88e6xxx_port_fdb_load(ps, port, fdb->addr, fdb->vid,
                                       GLOBAL_ATU_DATA_STATE_UNUSED);
@@ -2407,6 +2418,9 @@ int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
        u16 fid;
        int err;
 
+       if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU))
+               return -EOPNOTSUPP;
+
        mutex_lock(&ps->smi_mutex);
 
        /* Dump port's default Filtering Information Database (VLAN ID 0) */
index 4f21206ac4de2d79b429b11d8a25e2cf1c1f2154..192292f21c8a5d3c657c8d746c5b8bad4d9f7488 100644 (file)
@@ -351,6 +351,11 @@ enum mv88e6xxx_family {
 };
 
 enum mv88e6xxx_cap {
+       /* Address Translation Unit.
+        * The ATU is used to lookup and learn MAC addresses. See GLOBAL_ATU_OP.
+        */
+       MV88E6XXX_CAP_ATU,
+
        /* Energy Efficient Ethernet.
         */
        MV88E6XXX_CAP_EEE,
@@ -402,6 +407,7 @@ enum mv88e6xxx_cap {
 };
 
 /* Bitmask of capabilities */
+#define MV88E6XXX_FLAG_ATU             BIT(MV88E6XXX_CAP_ATU)
 #define MV88E6XXX_FLAG_EEE             BIT(MV88E6XXX_CAP_EEE)
 #define MV88E6XXX_FLAG_EEPROM          BIT(MV88E6XXX_CAP_EEPROM)
 #define MV88E6XXX_FLAG_PORTSTATE       BIT(MV88E6XXX_CAP_PORTSTATE)
@@ -414,12 +420,14 @@ enum mv88e6xxx_cap {
 #define MV88E6XXX_FLAG_VTU             BIT(MV88E6XXX_CAP_VTU)
 
 #define MV88E6XXX_FLAGS_FAMILY_6095    \
-       (MV88E6XXX_FLAG_PPU |           \
+       (MV88E6XXX_FLAG_ATU |           \
+        MV88E6XXX_FLAG_PPU |           \
         MV88E6XXX_FLAG_VLANTABLE |     \
         MV88E6XXX_FLAG_VTU)
 
 #define MV88E6XXX_FLAGS_FAMILY_6097    \
-       (MV88E6XXX_FLAG_PPU |           \
+       (MV88E6XXX_FLAG_ATU |           \
+        MV88E6XXX_FLAG_PPU |           \
         MV88E6XXX_FLAG_VLANTABLE |     \
         MV88E6XXX_FLAG_VTU)
 
@@ -428,12 +436,14 @@ enum mv88e6xxx_cap {
         MV88E6XXX_FLAG_TEMP)
 
 #define MV88E6XXX_FLAGS_FAMILY_6185    \
-       (MV88E6XXX_FLAG_PPU |           \
+       (MV88E6XXX_FLAG_ATU |           \
+        MV88E6XXX_FLAG_PPU |           \
         MV88E6XXX_FLAG_VLANTABLE |     \
         MV88E6XXX_FLAG_VTU)
 
 #define MV88E6XXX_FLAGS_FAMILY_6320    \
-       (MV88E6XXX_FLAG_EEE |           \
+       (MV88E6XXX_FLAG_ATU |           \
+        MV88E6XXX_FLAG_EEE |           \
         MV88E6XXX_FLAG_EEPROM |        \
         MV88E6XXX_FLAG_PORTSTATE |     \
         MV88E6XXX_FLAG_SMI_PHY |       \
@@ -444,7 +454,8 @@ enum mv88e6xxx_cap {
         MV88E6XXX_FLAG_VTU)
 
 #define MV88E6XXX_FLAGS_FAMILY_6351    \
-       (MV88E6XXX_FLAG_PORTSTATE |     \
+       (MV88E6XXX_FLAG_ATU |           \
+        MV88E6XXX_FLAG_PORTSTATE |     \
         MV88E6XXX_FLAG_SMI_PHY |       \
         MV88E6XXX_FLAG_SWITCH_MAC |    \
         MV88E6XXX_FLAG_TEMP |          \
@@ -452,7 +463,8 @@ enum mv88e6xxx_cap {
         MV88E6XXX_FLAG_VTU)
 
 #define MV88E6XXX_FLAGS_FAMILY_6352    \
-       (MV88E6XXX_FLAG_EEE |           \
+       (MV88E6XXX_FLAG_ATU |           \
+        MV88E6XXX_FLAG_EEE |           \
         MV88E6XXX_FLAG_EEPROM |        \
         MV88E6XXX_FLAG_PORTSTATE |     \
         MV88E6XXX_FLAG_SMI_PHY |       \