File Index
Files and directories
Sign in
FILE

tag_xrs700x.c

File preview with syntax highlighting.

linux-6.19.14/net/dsa/tag_xrs700x.c C
 1// SPDX-License-Identifier: GPL-2.0+
 2/*
 3 * XRS700x tag format handling
 4 * Copyright (c) 2008-2009 Marvell Semiconductor
 5 * Copyright (c) 2020 NovaTech LLC
 6 */
 7
 8#include <linux/bitops.h>
 9
10#include "tag.h"
11
12#define XRS700X_NAME "xrs700x"
13
14static struct sk_buff *xrs700x_xmit(struct sk_buff *skb, struct net_device *dev)
15{
16	u8 *trailer;
17
18	trailer = skb_put(skb, 1);
19	trailer[0] = dsa_xmit_port_mask(skb, dev);
20
21	return skb;
22}
23
24static struct sk_buff *xrs700x_rcv(struct sk_buff *skb, struct net_device *dev)
25{
26	int source_port;
27	u8 *trailer;
28
29	trailer = skb_tail_pointer(skb) - 1;
30
31	source_port = ffs((int)trailer[0]) - 1;
32
33	if (source_port < 0)
34		return NULL;
35
36	skb->dev = dsa_conduit_find_user(dev, 0, source_port);
37	if (!skb->dev)
38		return NULL;
39
40	if (pskb_trim_rcsum(skb, skb->len - 1))
41		return NULL;
42
43	/* Frame is forwarded by hardware, don't forward in software. */
44	dsa_default_offload_fwd_mark(skb);
45
46	return skb;
47}
48
49static const struct dsa_device_ops xrs700x_netdev_ops = {
50	.name	= XRS700X_NAME,
51	.proto	= DSA_TAG_PROTO_XRS700X,
52	.xmit	= xrs700x_xmit,
53	.rcv	= xrs700x_rcv,
54	.needed_tailroom = 1,
55};
56
57MODULE_DESCRIPTION("DSA tag driver for XRS700x switches");
58MODULE_LICENSE("GPL");
59MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_XRS700X, XRS700X_NAME);
60
61module_dsa_tag_driver(xrs700x_netdev_ops);
~/ Read-only file preview.