]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: dsa: add KSZ9893 switch tagging support
authorTristram Ha <Tristram.Ha@microchip.com>
Fri, 1 Mar 2019 03:57:23 +0000 (19:57 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 3 Mar 2019 21:48:49 +0000 (13:48 -0800)
KSZ9893 switch is similar to KSZ9477 switch except the ingress tail tag
has 1 byte instead of 2 bytes.  The size of the portmap is smaller and
so the override and lookup bits are also moved.

Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/dsa.h
net/dsa/dsa.c
net/dsa/dsa_priv.h
net/dsa/tag_ksz.c

index e8ac5b35ac4aaaf506d86c74364c817494e2baf8..ae480bba11f58e28435bd45c18632d2d5614a661 100644 (file)
@@ -38,6 +38,7 @@ enum dsa_tag_protocol {
        DSA_TAG_PROTO_EDSA,
        DSA_TAG_PROTO_GSWIP,
        DSA_TAG_PROTO_KSZ9477,
+       DSA_TAG_PROTO_KSZ9893,
        DSA_TAG_PROTO_LAN9303,
        DSA_TAG_PROTO_MTK,
        DSA_TAG_PROTO_QCA,
index aee909bcddc4fe8a7beb0e86198d521905cbafbe..36de4f2a3366b4a56d50d3c3ac26a61c0c89548b 100644 (file)
@@ -57,6 +57,7 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = {
 #endif
 #ifdef CONFIG_NET_DSA_TAG_KSZ9477
        [DSA_TAG_PROTO_KSZ9477] = &ksz9477_netdev_ops,
+       [DSA_TAG_PROTO_KSZ9893] = &ksz9893_netdev_ops,
 #endif
 #ifdef CONFIG_NET_DSA_TAG_LAN9303
        [DSA_TAG_PROTO_LAN9303] = &lan9303_netdev_ops,
@@ -93,6 +94,7 @@ const char *dsa_tag_protocol_to_str(const struct dsa_device_ops *ops)
 #endif
 #ifdef CONFIG_NET_DSA_TAG_KSZ9477
                [DSA_TAG_PROTO_KSZ9477] = "ksz9477",
+               [DSA_TAG_PROTO_KSZ9893] = "ksz9893",
 #endif
 #ifdef CONFIG_NET_DSA_TAG_LAN9303
                [DSA_TAG_PROTO_LAN9303] = "lan9303",
index c6caa58c5c7176559228af58a35f93ec589c9b10..093b7d145eb14d7c8b581c1f1438fa270d9800e4 100644 (file)
@@ -216,6 +216,7 @@ extern const struct dsa_device_ops gswip_netdev_ops;
 
 /* tag_ksz.c */
 extern const struct dsa_device_ops ksz9477_netdev_ops;
+extern const struct dsa_device_ops ksz9893_netdev_ops;
 
 /* tag_lan9303.c */
 extern const struct dsa_device_ops lan9303_netdev_ops;
index 927e9c86f745184d6c0fcb773289896cd60a5728..de246c93d3bbd752a8ca432edfc0b179a7893be7 100644 (file)
@@ -16,6 +16,7 @@
 
 /* Typically only one byte is used for tail tag. */
 #define KSZ_EGRESS_TAG_LEN             1
+#define KSZ_INGRESS_TAG_LEN            1
 
 static struct sk_buff *ksz_common_xmit(struct sk_buff *skb,
                                       struct net_device *dev, int len)
@@ -141,3 +142,36 @@ const struct dsa_device_ops ksz9477_netdev_ops = {
        .rcv    = ksz9477_rcv,
        .overhead = KSZ9477_INGRESS_TAG_LEN,
 };
+
+#define KSZ9893_TAIL_TAG_OVERRIDE      BIT(5)
+#define KSZ9893_TAIL_TAG_LOOKUP                BIT(6)
+
+static struct sk_buff *ksz9893_xmit(struct sk_buff *skb,
+                                   struct net_device *dev)
+{
+       struct dsa_port *dp = dsa_slave_to_port(dev);
+       struct sk_buff *nskb;
+       u8 *addr;
+       u8 *tag;
+
+       nskb = ksz_common_xmit(skb, dev, KSZ_INGRESS_TAG_LEN);
+       if (!nskb)
+               return NULL;
+
+       /* Tag encoding */
+       tag = skb_put(nskb, KSZ_INGRESS_TAG_LEN);
+       addr = skb_mac_header(nskb);
+
+       *tag = BIT(dp->index);
+
+       if (is_link_local_ether_addr(addr))
+               *tag |= KSZ9893_TAIL_TAG_OVERRIDE;
+
+       return nskb;
+}
+
+const struct dsa_device_ops ksz9893_netdev_ops = {
+       .xmit   = ksz9893_xmit,
+       .rcv    = ksz9477_rcv,
+       .overhead = KSZ_INGRESS_TAG_LEN,
+};