All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: allow port mirroring towards foreign interfaces
@ 2021-02-05 22:33 Vladimir Oltean
  2021-02-05 22:42 ` Florian Fainelli
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir Oltean @ 2021-02-05 22:33 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, netdev
  Cc: Andrew Lunn, Florian Fainelli, Vivien Didelot

From: Vladimir Oltean <vladimir.oltean@nxp.com>

To a DSA switch, port mirroring towards a foreign interface is the same
as mirroring towards the CPU port, since all non-DSA interfaces are
reachable through that. Tell the hardware to send the packets to the CPU
port and let the mirred action deal with them in software.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/dsa/slave.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index b0571ab4e5a7..913a4a5e32a9 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -936,19 +936,19 @@ dsa_slave_add_cls_matchall_mirred(struct net_device *dev,
 	if (!act->dev)
 		return -EINVAL;
 
-	if (!dsa_slave_dev_check(act->dev))
-		return -EOPNOTSUPP;
-
 	mall_tc_entry = kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL);
 	if (!mall_tc_entry)
 		return -ENOMEM;
 
+	if (dsa_slave_dev_check(act->dev))
+		to_dp = dsa_slave_to_port(act->dev);
+	else
+		to_dp = dp->cpu_dp;
+
 	mall_tc_entry->cookie = cls->cookie;
 	mall_tc_entry->type = DSA_PORT_MALL_MIRROR;
 	mirror = &mall_tc_entry->mirror;
 
-	to_dp = dsa_slave_to_port(act->dev);
-
 	mirror->to_local_port = to_dp->index;
 	mirror->ingress = ingress;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-07  0:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05 22:33 [PATCH net-next] net: dsa: allow port mirroring towards foreign interfaces Vladimir Oltean
2021-02-05 22:42 ` Florian Fainelli
2021-02-05 23:05   ` Vladimir Oltean
2021-02-06 23:58     ` Jakub Kicinski
2021-02-07  0:16       ` Vladimir Oltean
2021-02-07  0:43         ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.