1 // SPDX-License-Identifier: GPL-2.0+
3 * XRS700x tag format handling
4 * Copyright (c) 2008-2009 Marvell Semiconductor
5 * Copyright (c) 2020 NovaTech LLC
8 #include <linux/bitops.h>
12 static struct sk_buff *xrs700x_xmit(struct sk_buff *skb, struct net_device *dev)
14 struct dsa_port *partner, *dp = dsa_slave_to_port(dev);
17 trailer = skb_put(skb, 1);
18 trailer[0] = BIT(dp->index);
21 dsa_hsr_foreach_port(partner, dp->ds, dp->hsr_dev)
23 trailer[0] |= BIT(partner->index);
28 static struct sk_buff *xrs700x_rcv(struct sk_buff *skb, struct net_device *dev,
29 struct packet_type *pt)
34 trailer = skb_tail_pointer(skb) - 1;
36 source_port = ffs((int)trailer[0]) - 1;
41 skb->dev = dsa_master_find_slave(dev, 0, source_port);
45 if (pskb_trim_rcsum(skb, skb->len - 1))
48 /* Frame is forwarded by hardware, don't forward in software. */
49 skb->offload_fwd_mark = 1;
54 static const struct dsa_device_ops xrs700x_netdev_ops = {
56 .proto = DSA_TAG_PROTO_XRS700X,
62 MODULE_LICENSE("GPL");
63 MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_XRS700X);
65 module_dsa_tag_driver(xrs700x_netdev_ops);