forked from torvalds/linux
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: dsa: add out-of-band tagging protocol
This tagging protocol is designed for the situation where the link between the MAC and the Switch is designed such that the Destination Port, which is usually embedded in some part of the Ethernet Header, is sent out-of-band, and isn't present at all in the Ethernet frame. This can happen when the MAC and Switch are tightly integrated on an SoC, as is the case with the Qualcomm IPQ4019 for example, where the DSA tag is inserted directly into the DMA descriptors. In that case, the MAC driver is responsible for sending the tag to the switch using the out-of-band medium. To do so, the MAC driver needs to have the information of the destination port for that skb. Add a new tagging protocol based on SKB extensions to convey the information about the destination port to the MAC driver Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
- Loading branch information
1 parent
b6c80e6
commit 884e368
Showing
9 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only | ||
* Copyright (C) 2022 Maxime Chevallier <maxime.chevallier@bootlin.com> | ||
*/ | ||
|
||
#ifndef _NET_DSA_OOB_H | ||
#define _NET_DSA_OOB_H | ||
|
||
#include <linux/skbuff.h> | ||
|
||
struct dsa_oob_tag_info { | ||
u16 port; | ||
}; | ||
|
||
int dsa_oob_tag_push(struct sk_buff *skb, struct dsa_oob_tag_info *ti); | ||
int dsa_oob_tag_pop(struct sk_buff *skb, struct dsa_oob_tag_info *ti); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
|
||
/* Copyright (c) 2022, Maxime Chevallier <maxime.chevallier@bootlin.com> */ | ||
|
||
#include <linux/bitfield.h> | ||
#include <linux/dsa/oob.h> | ||
#include <linux/skbuff.h> | ||
|
||
#include "dsa_priv.h" | ||
|
||
static struct sk_buff *oob_tag_xmit(struct sk_buff *skb, | ||
struct net_device *dev) | ||
{ | ||
struct dsa_oob_tag_info *tag_info = skb_ext_add(skb, SKB_EXT_DSA_OOB); | ||
struct dsa_port *dp = dsa_slave_to_port(dev); | ||
|
||
tag_info->port = dp->index; | ||
|
||
return skb; | ||
} | ||
|
||
static struct sk_buff *oob_tag_rcv(struct sk_buff *skb, | ||
struct net_device *dev) | ||
{ | ||
struct dsa_oob_tag_info *tag_info = skb_ext_find(skb, SKB_EXT_DSA_OOB); | ||
if (!tag_info) | ||
return NULL; | ||
|
||
skb->dev = dsa_master_find_slave(dev, 0, tag_info->port); | ||
if (!skb->dev) | ||
return NULL; | ||
|
||
return skb; | ||
} | ||
|
||
const struct dsa_device_ops oob_tag_dsa_ops = { | ||
.name = "oob", | ||
.proto = DSA_TAG_PROTO_OOB, | ||
.xmit = oob_tag_xmit, | ||
.rcv = oob_tag_rcv, | ||
}; | ||
|
||
MODULE_LICENSE("GPL"); | ||
MODULE_DESCRIPTION("DSA tag driver for out-of-band tagging"); | ||
MODULE_AUTHOR("Maxime Chevallier <maxime.chevallier@bootlin.com>"); | ||
MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_OOB); | ||
|
||
module_dsa_tag_driver(oob_tag_dsa_ops); |