]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: dsa: microchip: move tag_protocol to ksz_common
authorArun Ramadoss <arun.ramadoss@microchip.com>
Fri, 17 Jun 2022 08:42:47 +0000 (14:12 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Aug 2022 15:18:04 +0000 (17:18 +0200)
[ Upstream commit 534a0431e9e68959e2c0d71c141d5b911d66ad7c ]

This patch move the dsa hook get_tag_protocol to ksz_common file. And
the tag_protocol is returned based on the dev->chip_id.

Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/dsa/microchip/ksz8795.c
drivers/net/dsa/microchip/ksz9477.c
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/microchip/ksz_common.h

index 3cc51ee5fb6cc1b65f2b41c8954a3f2c01f3cd76..041956e3c7b1ac61b68be205c2d81ac8a3ff1289 100644 (file)
@@ -898,17 +898,6 @@ static void ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val)
        }
 }
 
-static enum dsa_tag_protocol ksz8_get_tag_protocol(struct dsa_switch *ds,
-                                                  int port,
-                                                  enum dsa_tag_protocol mp)
-{
-       struct ksz_device *dev = ds->priv;
-
-       /* ksz88x3 uses the same tag schema as KSZ9893 */
-       return ksz_is_ksz88x3(dev) ?
-               DSA_TAG_PROTO_KSZ9893 : DSA_TAG_PROTO_KSZ8795;
-}
-
 static u32 ksz8_sw_get_phy_flags(struct dsa_switch *ds, int port)
 {
        /* Silicon Errata Sheet (DS80000830A):
@@ -1394,7 +1383,7 @@ static void ksz8_get_caps(struct dsa_switch *ds, int port,
 }
 
 static const struct dsa_switch_ops ksz8_switch_ops = {
-       .get_tag_protocol       = ksz8_get_tag_protocol,
+       .get_tag_protocol       = ksz_get_tag_protocol,
        .get_phy_flags          = ksz8_sw_get_phy_flags,
        .setup                  = ksz8_setup,
        .phy_read               = ksz_phy_read16,
index bcfdd505ca79ad39e79029c1a9df3afe97d04982..31be767027feb33294890f0fdf98f340eb80e4c1 100644 (file)
@@ -276,18 +276,6 @@ static void ksz9477_port_init_cnt(struct ksz_device *dev, int port)
        mutex_unlock(&mib->cnt_mutex);
 }
 
-static enum dsa_tag_protocol ksz9477_get_tag_protocol(struct dsa_switch *ds,
-                                                     int port,
-                                                     enum dsa_tag_protocol mp)
-{
-       enum dsa_tag_protocol proto = DSA_TAG_PROTO_KSZ9477;
-       struct ksz_device *dev = ds->priv;
-
-       if (dev->features & IS_9893)
-               proto = DSA_TAG_PROTO_KSZ9893;
-       return proto;
-}
-
 static int ksz9477_phy_read16(struct dsa_switch *ds, int addr, int reg)
 {
        struct ksz_device *dev = ds->priv;
@@ -1329,7 +1317,7 @@ static int ksz9477_setup(struct dsa_switch *ds)
 }
 
 static const struct dsa_switch_ops ksz9477_switch_ops = {
-       .get_tag_protocol       = ksz9477_get_tag_protocol,
+       .get_tag_protocol       = ksz_get_tag_protocol,
        .setup                  = ksz9477_setup,
        .phy_read               = ksz9477_phy_read16,
        .phy_write              = ksz9477_phy_write16,
index 4511e99823f5704d4832acb9efa1ef783cf80df0..0713a40685fa995cef3c0669c1d1c90c85476ceb 100644 (file)
@@ -930,6 +930,30 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, int port,
 }
 EXPORT_SYMBOL_GPL(ksz_port_stp_state_set);
 
+enum dsa_tag_protocol ksz_get_tag_protocol(struct dsa_switch *ds,
+                                          int port, enum dsa_tag_protocol mp)
+{
+       struct ksz_device *dev = ds->priv;
+       enum dsa_tag_protocol proto = DSA_TAG_PROTO_NONE;
+
+       if (dev->chip_id == KSZ8795_CHIP_ID ||
+           dev->chip_id == KSZ8794_CHIP_ID ||
+           dev->chip_id == KSZ8765_CHIP_ID)
+               proto = DSA_TAG_PROTO_KSZ8795;
+
+       if (dev->chip_id == KSZ8830_CHIP_ID ||
+           dev->chip_id == KSZ9893_CHIP_ID)
+               proto = DSA_TAG_PROTO_KSZ9893;
+
+       if (dev->chip_id == KSZ9477_CHIP_ID ||
+           dev->chip_id == KSZ9897_CHIP_ID ||
+           dev->chip_id == KSZ9567_CHIP_ID)
+               proto = DSA_TAG_PROTO_KSZ9477;
+
+       return proto;
+}
+EXPORT_SYMBOL_GPL(ksz_get_tag_protocol);
+
 static int ksz_switch_detect(struct ksz_device *dev)
 {
        u8 id1, id2;
index e6bc5fb2b13037c5fb939466fa86f34693cdfb0d..21db6f79035faceeaf9e0bc98ef6482e8d6577c6 100644 (file)
@@ -231,6 +231,8 @@ int ksz_port_mdb_del(struct dsa_switch *ds, int port,
 int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy);
 void ksz_get_strings(struct dsa_switch *ds, int port,
                     u32 stringset, uint8_t *buf);
+enum dsa_tag_protocol ksz_get_tag_protocol(struct dsa_switch *ds,
+                                          int port, enum dsa_tag_protocol mp);
 
 /* Common register access functions */