Skip to content

Commit 88b573a

Browse files
triha2workdavem330
authored andcommitted
net: dsa: add KSZ9893 switch tagging support
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 <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a1c0ed2 commit 88b573a

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

include/net/dsa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ enum dsa_tag_protocol {
3838
DSA_TAG_PROTO_EDSA,
3939
DSA_TAG_PROTO_GSWIP,
4040
DSA_TAG_PROTO_KSZ9477,
41+
DSA_TAG_PROTO_KSZ9893,
4142
DSA_TAG_PROTO_LAN9303,
4243
DSA_TAG_PROTO_MTK,
4344
DSA_TAG_PROTO_QCA,

net/dsa/dsa.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = {
5757
#endif
5858
#ifdef CONFIG_NET_DSA_TAG_KSZ9477
5959
[DSA_TAG_PROTO_KSZ9477] = &ksz9477_netdev_ops,
60+
[DSA_TAG_PROTO_KSZ9893] = &ksz9893_netdev_ops,
6061
#endif
6162
#ifdef CONFIG_NET_DSA_TAG_LAN9303
6263
[DSA_TAG_PROTO_LAN9303] = &lan9303_netdev_ops,
@@ -93,6 +94,7 @@ const char *dsa_tag_protocol_to_str(const struct dsa_device_ops *ops)
9394
#endif
9495
#ifdef CONFIG_NET_DSA_TAG_KSZ9477
9596
[DSA_TAG_PROTO_KSZ9477] = "ksz9477",
97+
[DSA_TAG_PROTO_KSZ9893] = "ksz9893",
9698
#endif
9799
#ifdef CONFIG_NET_DSA_TAG_LAN9303
98100
[DSA_TAG_PROTO_LAN9303] = "lan9303",

net/dsa/dsa_priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ extern const struct dsa_device_ops gswip_netdev_ops;
216216

217217
/* tag_ksz.c */
218218
extern const struct dsa_device_ops ksz9477_netdev_ops;
219+
extern const struct dsa_device_ops ksz9893_netdev_ops;
219220

220221
/* tag_lan9303.c */
221222
extern const struct dsa_device_ops lan9303_netdev_ops;

net/dsa/tag_ksz.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/* Typically only one byte is used for tail tag. */
1818
#define KSZ_EGRESS_TAG_LEN 1
19+
#define KSZ_INGRESS_TAG_LEN 1
1920

2021
static struct sk_buff *ksz_common_xmit(struct sk_buff *skb,
2122
struct net_device *dev, int len)
@@ -141,3 +142,36 @@ const struct dsa_device_ops ksz9477_netdev_ops = {
141142
.rcv = ksz9477_rcv,
142143
.overhead = KSZ9477_INGRESS_TAG_LEN,
143144
};
145+
146+
#define KSZ9893_TAIL_TAG_OVERRIDE BIT(5)
147+
#define KSZ9893_TAIL_TAG_LOOKUP BIT(6)
148+
149+
static struct sk_buff *ksz9893_xmit(struct sk_buff *skb,
150+
struct net_device *dev)
151+
{
152+
struct dsa_port *dp = dsa_slave_to_port(dev);
153+
struct sk_buff *nskb;
154+
u8 *addr;
155+
u8 *tag;
156+
157+
nskb = ksz_common_xmit(skb, dev, KSZ_INGRESS_TAG_LEN);
158+
if (!nskb)
159+
return NULL;
160+
161+
/* Tag encoding */
162+
tag = skb_put(nskb, KSZ_INGRESS_TAG_LEN);
163+
addr = skb_mac_header(nskb);
164+
165+
*tag = BIT(dp->index);
166+
167+
if (is_link_local_ether_addr(addr))
168+
*tag |= KSZ9893_TAIL_TAG_OVERRIDE;
169+
170+
return nskb;
171+
}
172+
173+
const struct dsa_device_ops ksz9893_netdev_ops = {
174+
.xmit = ksz9893_xmit,
175+
.rcv = ksz9477_rcv,
176+
.overhead = KSZ_INGRESS_TAG_LEN,
177+
};

0 commit comments

Comments
 (0)