1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
3 * net/dsa/tag_hellcreek.c - Hirschmann Hellcreek switch tag format handling
5 * Copyright (C) 2019,2020 Linutronix GmbH
11 #include <linux/skbuff.h>
16 #define HELLCREEK_TAG_LEN 1
18 static struct sk_buff *hellcreek_xmit(struct sk_buff *skb,
19 struct net_device *dev)
21 struct dsa_port *dp = dsa_slave_to_port(dev);
25 tag = skb_put(skb, HELLCREEK_TAG_LEN);
26 *tag = BIT(dp->index);
31 static struct sk_buff *hellcreek_rcv(struct sk_buff *skb,
32 struct net_device *dev,
33 struct packet_type *pt)
36 u8 *tag = skb_tail_pointer(skb) - HELLCREEK_TAG_LEN;
37 unsigned int port = tag[0] & 0x03;
39 skb->dev = dsa_master_find_slave(dev, 0, port);
41 netdev_warn(dev, "Failed to get source port: %d\n", port);
45 pskb_trim_rcsum(skb, skb->len - HELLCREEK_TAG_LEN);
47 skb->offload_fwd_mark = true;
52 static const struct dsa_device_ops hellcreek_netdev_ops = {
54 .proto = DSA_TAG_PROTO_HELLCREEK,
55 .xmit = hellcreek_xmit,
57 .overhead = HELLCREEK_TAG_LEN,
61 MODULE_LICENSE("Dual MIT/GPL");
62 MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_HELLCREEK);
64 module_dsa_tag_driver(hellcreek_netdev_ops);