All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Machon <daniel.machon@microchip.com>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Lars Povlsen <lars.povlsen@microchip.com>,
	"Steen Hegelund" <Steen.Hegelund@microchip.com>,
	<UNGLinuxDriver@microchip.com>,
	Russell King <linux@armlinux.org.uk>
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Horatiu Vultur" <horatiu.vultur@microchip.com>,
	"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Vladimir Oltean" <vladimir.oltean@nxp.com>,
	"Yue Haibing" <yuehaibing@huawei.com>,
	"Daniel Machon" <daniel.machon@microchip.com>
Subject: [PATCH net-next v3 4/5] net: sparx5: add the tc glue to support port mirroring
Date: Sat, 20 Apr 2024 21:29:13 +0200	[thread overview]
Message-ID: <20240420-port-mirroring-v3-4-0fe3ac52006d@microchip.com> (raw)
In-Reply-To: <20240420-port-mirroring-v3-0-0fe3ac52006d@microchip.com>

Add the necessary tc glue to add and delete mirror rules through tc
matchall.

Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
---
 .../ethernet/microchip/sparx5/sparx5_tc_matchall.c | 38 ++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
index 2a33b347098f..4f9ae026fa47 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
@@ -36,6 +36,13 @@ static void sparx5_tc_matchall_parse_action(struct sparx5_port *port,
 	entry->cookie = cookie;
 }
 
+static void
+sparx5_tc_matchall_parse_mirror_action(struct sparx5_mall_entry *entry,
+				       struct flow_action_entry *action)
+{
+	entry->mirror.port = netdev_priv(action->dev);
+}
+
 static int sparx5_tc_matchall_replace(struct net_device *ndev,
 				      struct tc_cls_matchall_offload *tmo,
 				      bool ingress)
@@ -65,6 +72,31 @@ static int sparx5_tc_matchall_replace(struct net_device *ndev,
 
 	sparx5 = port->sparx5;
 	switch (action->id) {
+	case FLOW_ACTION_MIRRED:
+		sparx5_tc_matchall_parse_mirror_action(mall_entry, action);
+		err = sparx5_mirror_add(mall_entry);
+		if (err) {
+			switch (err) {
+			case -EEXIST:
+				NL_SET_ERR_MSG_MOD(tmo->common.extack,
+						   "Mirroring already exists");
+				break;
+			case -EINVAL:
+				NL_SET_ERR_MSG_MOD(tmo->common.extack,
+						   "Cannot mirror a monitor port");
+				break;
+			case -ENOENT:
+				NL_SET_ERR_MSG_MOD(tmo->common.extack,
+						   "No more mirror probes available");
+				break;
+			default:
+				NL_SET_ERR_MSG_MOD(tmo->common.extack,
+						   "Unknown error");
+				break;
+			}
+			return err;
+		}
+		break;
 	case FLOW_ACTION_GOTO:
 		err = vcap_enable_lookups(sparx5->vcap_ctrl, ndev,
 					  tmo->common.chain_index,
@@ -108,14 +140,16 @@ static int sparx5_tc_matchall_destroy(struct net_device *ndev,
 	struct sparx5_port *port = netdev_priv(ndev);
 	struct sparx5 *sparx5 = port->sparx5;
 	struct sparx5_mall_entry *entry;
-	int err;
+	int err = 0;
 
 	entry = sparx5_tc_matchall_entry_find(&sparx5->mall_entries,
 					      tmo->cookie);
 	if (!entry)
 		return -ENOENT;
 
-	if (entry->type == FLOW_ACTION_GOTO) {
+	if (entry->type == FLOW_ACTION_MIRRED) {
+		sparx5_mirror_del(entry);
+	} else if (entry->type == FLOW_ACTION_GOTO) {
 		err = vcap_enable_lookups(sparx5->vcap_ctrl, ndev,
 					  0, 0, tmo->cookie, false);
 	} else {

-- 
2.34.1


WARNING: multiple messages have this Message-ID (diff)
From: Daniel Machon <daniel.machon@microchip.com>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Lars Povlsen <lars.povlsen@microchip.com>,
	"Steen Hegelund" <Steen.Hegelund@microchip.com>,
	<UNGLinuxDriver@microchip.com>,
	Russell King <linux@armlinux.org.uk>
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Horatiu Vultur" <horatiu.vultur@microchip.com>,
	"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Vladimir Oltean" <vladimir.oltean@nxp.com>,
	"Yue Haibing" <yuehaibing@huawei.com>,
	"Daniel Machon" <daniel.machon@microchip.com>
Subject: [PATCH net-next v3 4/5] net: sparx5: add the tc glue to support port mirroring
Date: Sat, 20 Apr 2024 21:29:13 +0200	[thread overview]
Message-ID: <20240420-port-mirroring-v3-4-0fe3ac52006d@microchip.com> (raw)
In-Reply-To: <20240420-port-mirroring-v3-0-0fe3ac52006d@microchip.com>

Add the necessary tc glue to add and delete mirror rules through tc
matchall.

Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
---
 .../ethernet/microchip/sparx5/sparx5_tc_matchall.c | 38 ++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
index 2a33b347098f..4f9ae026fa47 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
@@ -36,6 +36,13 @@ static void sparx5_tc_matchall_parse_action(struct sparx5_port *port,
 	entry->cookie = cookie;
 }
 
+static void
+sparx5_tc_matchall_parse_mirror_action(struct sparx5_mall_entry *entry,
+				       struct flow_action_entry *action)
+{
+	entry->mirror.port = netdev_priv(action->dev);
+}
+
 static int sparx5_tc_matchall_replace(struct net_device *ndev,
 				      struct tc_cls_matchall_offload *tmo,
 				      bool ingress)
@@ -65,6 +72,31 @@ static int sparx5_tc_matchall_replace(struct net_device *ndev,
 
 	sparx5 = port->sparx5;
 	switch (action->id) {
+	case FLOW_ACTION_MIRRED:
+		sparx5_tc_matchall_parse_mirror_action(mall_entry, action);
+		err = sparx5_mirror_add(mall_entry);
+		if (err) {
+			switch (err) {
+			case -EEXIST:
+				NL_SET_ERR_MSG_MOD(tmo->common.extack,
+						   "Mirroring already exists");
+				break;
+			case -EINVAL:
+				NL_SET_ERR_MSG_MOD(tmo->common.extack,
+						   "Cannot mirror a monitor port");
+				break;
+			case -ENOENT:
+				NL_SET_ERR_MSG_MOD(tmo->common.extack,
+						   "No more mirror probes available");
+				break;
+			default:
+				NL_SET_ERR_MSG_MOD(tmo->common.extack,
+						   "Unknown error");
+				break;
+			}
+			return err;
+		}
+		break;
 	case FLOW_ACTION_GOTO:
 		err = vcap_enable_lookups(sparx5->vcap_ctrl, ndev,
 					  tmo->common.chain_index,
@@ -108,14 +140,16 @@ static int sparx5_tc_matchall_destroy(struct net_device *ndev,
 	struct sparx5_port *port = netdev_priv(ndev);
 	struct sparx5 *sparx5 = port->sparx5;
 	struct sparx5_mall_entry *entry;
-	int err;
+	int err = 0;
 
 	entry = sparx5_tc_matchall_entry_find(&sparx5->mall_entries,
 					      tmo->cookie);
 	if (!entry)
 		return -ENOENT;
 
-	if (entry->type == FLOW_ACTION_GOTO) {
+	if (entry->type == FLOW_ACTION_MIRRED) {
+		sparx5_mirror_del(entry);
+	} else if (entry->type == FLOW_ACTION_GOTO) {
 		err = vcap_enable_lookups(sparx5->vcap_ctrl, ndev,
 					  0, 0, tmo->cookie, false);
 	} else {

-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2024-04-20 19:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-20 19:29 [PATCH net-next v3 0/5] net: sparx5: add support for port mirroring Daniel Machon
2024-04-20 19:29 ` Daniel Machon
2024-04-20 19:29 ` [PATCH net-next v3 1/5] net: sparx5: add new register definitions Daniel Machon
2024-04-20 19:29   ` Daniel Machon
2024-04-20 19:29 ` [PATCH net-next v3 2/5] net: sparx5: add bookkeeping code for matchall rules Daniel Machon
2024-04-20 19:29   ` Daniel Machon
2024-04-20 19:29 ` [PATCH net-next v3 3/5] net: sparx5: add port mirroring implementation Daniel Machon
2024-04-20 19:29   ` Daniel Machon
2024-04-20 19:29 ` Daniel Machon [this message]
2024-04-20 19:29   ` [PATCH net-next v3 4/5] net: sparx5: add the tc glue to support port mirroring Daniel Machon
2024-04-20 19:29 ` [PATCH net-next v3 5/5] net: sparx5: add support for matchall mirror stats Daniel Machon
2024-04-20 19:29   ` Daniel Machon
2024-04-24 12:10 ` [PATCH net-next v3 0/5] net: sparx5: add support for port mirroring patchwork-bot+netdevbpf
2024-04-24 12:10   ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240420-port-mirroring-v3-4-0fe3ac52006d@microchip.com \
    --to=daniel.machon@microchip.com \
    --cc=Steen.Hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kuba@kernel.org \
    --cc=lars.povlsen@microchip.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=vladimir.oltean@nxp.com \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.