[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190521193004.10767-3-vivien.didelot@gmail.com>
Date: Tue, 21 May 2019 15:29:57 -0400
From: Vivien Didelot <vivien.didelot@...il.com>
To: netdev@...r.kernel.org
Cc: cphealy@...il.com, Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
Andrew Lunn <andrew@...n.ch>,
"David S. Miller" <davem@...emloft.net>
Subject: [RFC net-next 2/9] net: dsa: allow switches to receive frames
Add a rcv DSA switch operation to allow taggers to let the driver of
the source switch to process the received frame on its own.
At the moment, only DSA and EDSA taggers make use of this hook.
Signed-off-by: Vivien Didelot <vivien.didelot@...il.com>
---
include/net/dsa.h | 5 +++++
net/dsa/tag_dsa.c | 6 ++++++
net/dsa/tag_edsa.c | 6 ++++++
3 files changed, 17 insertions(+)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 685294817712..027bb67ebaf7 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -543,6 +543,11 @@ struct dsa_switch_ops {
*/
netdev_tx_t (*port_deferred_xmit)(struct dsa_switch *ds, int port,
struct sk_buff *skb);
+
+ /*
+ * SKB Rx hooks
+ */
+ bool (*rcv)(struct dsa_switch *ds, struct sk_buff *skb);
};
struct dsa_switch_driver {
diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c
index 7ddec9794477..20688674e00f 100644
--- a/net/dsa/tag_dsa.c
+++ b/net/dsa/tag_dsa.c
@@ -63,6 +63,7 @@ static struct sk_buff *dsa_xmit(struct sk_buff *skb, struct net_device *dev)
static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt)
{
+ struct dsa_switch *ds;
u8 *dsa_header;
int source_device;
int source_port;
@@ -87,6 +88,11 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev,
source_device = dsa_header[0] & 0x1f;
source_port = (dsa_header[1] >> 3) & 0x1f;
+ /* Allow the source switch device to process the frame on its own */
+ ds = dsa_master_find_switch(dev, source_device);
+ if (ds && ds->ops->rcv && ds->ops->rcv(ds, skb))
+ return NULL;
+
skb->dev = dsa_master_find_slave(dev, source_device, source_port);
if (!skb->dev)
return NULL;
diff --git a/net/dsa/tag_edsa.c b/net/dsa/tag_edsa.c
index e8eaa804ccb9..2ba3d48a23e2 100644
--- a/net/dsa/tag_edsa.c
+++ b/net/dsa/tag_edsa.c
@@ -76,6 +76,7 @@ static struct sk_buff *edsa_xmit(struct sk_buff *skb, struct net_device *dev)
static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt)
{
+ struct dsa_switch *ds;
u8 *edsa_header;
int source_device;
int source_port;
@@ -100,6 +101,11 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
source_device = edsa_header[0] & 0x1f;
source_port = (edsa_header[1] >> 3) & 0x1f;
+ /* Allow the target switch device to process the frame on its own */
+ ds = dsa_master_find_switch(dev, source_device);
+ if (ds && ds->ops->rcv && ds->ops->rcv(ds, skb))
+ return NULL;
+
skb->dev = dsa_master_find_slave(dev, source_device, source_port);
if (!skb->dev)
return NULL;
--
2.21.0
Powered by blists - more mailing lists