netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, jiri@mellanox.com,
	petrm@mellanox.com, amitc@mellanox.com, mlxsw@mellanox.com,
	Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH net-next 13/13] mlxsw: core: Use mirror reason during Rx listener lookup
Date: Tue, 14 Jul 2020 17:21:06 +0300	[thread overview]
Message-ID: <20200714142106.386354-14-idosch@idosch.org> (raw)
In-Reply-To: <20200714142106.386354-1-idosch@idosch.org>

From: Ido Schimmel <idosch@mellanox.com>

The Rx listener abstraction allows the switch driver (e.g.,
mlxsw_spectrum) to register a function that is called when a packet is
received (trapped) for a specific reason.

Up until now, the Rx listener lookup was solely based on the trap
identifier. However, when a packet is mirrored to the CPU the trap
identifier merely indicates that the packet was mirrored, but not why it
was mirrored. This makes it impossible for the switch driver to register
different Rx listeners for different mirror reasons.

Solve this by allowing the switch driver to register a Rx listener with
a mirror reason and by extending the Rx listener lookup to take the
mirror reason into account.

Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core.c | 6 ++++--
 drivers/net/ethernet/mellanox/mlxsw/core.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 8b3791d73c99..1363168b3c82 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -1524,7 +1524,8 @@ static bool __is_rx_listener_equal(const struct mlxsw_rx_listener *rxl_a,
 {
 	return (rxl_a->func == rxl_b->func &&
 		rxl_a->local_port == rxl_b->local_port &&
-		rxl_a->trap_id == rxl_b->trap_id);
+		rxl_a->trap_id == rxl_b->trap_id &&
+		rxl_a->mirror_reason == rxl_b->mirror_reason);
 }
 
 static struct mlxsw_rx_listener_item *
@@ -2044,7 +2045,8 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
 		rxl = &rxl_item->rxl;
 		if ((rxl->local_port == MLXSW_PORT_DONT_CARE ||
 		     rxl->local_port == local_port) &&
-		    rxl->trap_id == rx_info->trap_id) {
+		    rxl->trap_id == rx_info->trap_id &&
+		    rxl->mirror_reason == rx_info->mirror_reason) {
 			if (rxl_item->enabled)
 				found = true;
 			break;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
index c736b8673791..c1c1e039323a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
@@ -61,6 +61,7 @@ void mlxsw_core_ptp_transmitted(struct mlxsw_core *mlxsw_core,
 struct mlxsw_rx_listener {
 	void (*func)(struct sk_buff *skb, u8 local_port, void *priv);
 	u8 local_port;
+	u8 mirror_reason;
 	u16 trap_id;
 };
 
-- 
2.26.2


  parent reply	other threads:[~2020-07-14 14:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 14:20 [PATCH net-next 00/13] mlxsw: Mirror to CPU preparations Ido Schimmel
2020-07-14 14:20 ` [PATCH net-next 01/13] mlxsw: reg: Add session_id and pid to MPAT register Ido Schimmel
2020-07-14 14:20 ` [PATCH net-next 02/13] mlxsw: reg: add mirroring_pid_base to MOGCR register Ido Schimmel
2020-07-14 14:20 ` [PATCH net-next 03/13] mlxsw: spectrum_span: Add per-ASIC SPAN agent operations Ido Schimmel
2020-07-14 14:20 ` [PATCH net-next 04/13] mlxsw: spectrum_span: Add driver private info to parms_set() callback Ido Schimmel
2020-07-14 14:20 ` [PATCH net-next 05/13] mlxsw: spectrum_span: Do not dereference destination netdev Ido Schimmel
2020-07-14 14:20 ` [PATCH net-next 06/13] mlxsw: spectrum_span: Add support for mirroring towards CPU port Ido Schimmel
2020-07-14 14:21 ` [PATCH net-next 07/13] mlxsw: spectrum_span: Allow passing parameters to SPAN agents Ido Schimmel
2020-07-14 14:21 ` [PATCH net-next 08/13] mlxsw: spectrum_span: Allow setting policer on a SPAN agent Ido Schimmel
2020-07-14 14:21 ` [PATCH net-next 09/13] mlxsw: reg: Increase trap identifier to 10 bits Ido Schimmel
2020-07-14 14:21 ` [PATCH net-next 10/13] mlxsw: trap: Add trap identifiers for mirrored packets Ido Schimmel
2020-07-14 14:21 ` [PATCH net-next 11/13] mlxsw: pci: Add mirror reason field to CQEv2 Ido Schimmel
2020-07-14 14:21 ` [PATCH net-next 12/13] mlxsw: pci: Retrieve mirror reason from CQE during receive Ido Schimmel
2020-07-14 14:21 ` Ido Schimmel [this message]
2020-07-14 21:51 ` [PATCH net-next 00/13] mlxsw: Mirror to CPU preparations David Miller

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=20200714142106.386354-14-idosch@idosch.org \
    --to=idosch@idosch.org \
    --cc=amitc@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=idosch@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=kuba@kernel.org \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=petrm@mellanox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).