All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] mlxsw: ACL and mirroring fixes
@ 2018-03-09 13:33 Ido Schimmel
  2018-03-09 13:33 ` [PATCH net 1/2] mlxsw: spectrum: Fix gact_ok offloading Ido Schimmel
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ido Schimmel @ 2018-03-09 13:33 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, petrm, mlxsw, Ido Schimmel

Hi,

The first patch fixes offload of rules using the 'pass' action. Instead
of continuing to evaluate lower priority rules, the binding is
terminated and the packet proceeds to the bridge and router blocks on
ingress, or goes out of the port on egress.

Second patch prevents the user from mirroring more than once from a
given {Port, Direction} as this is not supported by the device.

Jiri Pirko (1):
  mlxsw: spectrum: Fix gact_ok offloading

Petr Machata (1):
  mlxsw: spectrum: Prevent duplicate mirrors

 .../mellanox/mlxsw/core_acl_flex_actions.c         | 11 +++++++++
 .../mellanox/mlxsw/core_acl_flex_actions.h         |  1 +
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c     | 28 ++++++++++++++++++----
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h     |  4 ++++
 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c |  5 ++++
 .../net/ethernet/mellanox/mlxsw/spectrum_flower.c  |  2 +-
 6 files changed, 46 insertions(+), 5 deletions(-)

-- 
2.14.3

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

* [PATCH net 1/2] mlxsw: spectrum: Fix gact_ok offloading
  2018-03-09 13:33 [PATCH net 0/2] mlxsw: ACL and mirroring fixes Ido Schimmel
@ 2018-03-09 13:33 ` Ido Schimmel
  2018-03-09 13:33 ` [PATCH net 2/2] mlxsw: spectrum: Prevent duplicate mirrors Ido Schimmel
  2018-03-09 18:02 ` [PATCH net 0/2] mlxsw: ACL and mirroring fixes David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2018-03-09 13:33 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, petrm, mlxsw, Ido Schimmel

From: Jiri Pirko <jiri@mellanox.com>

For ok GACT action, TERMINATE binding_cmd should be used in action set
passed down to HW.

Fixes: b2925957ec1a9 ("mlxsw: spectrum_flower: Offload "ok" termination action")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reported-by: Alexander Petrovskiy <alexpe@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c | 11 +++++++++++
 drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h |  1 +
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h              |  1 +
 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c          |  5 +++++
 drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c       |  2 +-
 5 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
index b698fb481b2e..996dc099cd58 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
@@ -443,6 +443,17 @@ int mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id)
 }
 EXPORT_SYMBOL(mlxsw_afa_block_jump);
 
+int mlxsw_afa_block_terminate(struct mlxsw_afa_block *block)
+{
+	if (block->finished)
+		return -EINVAL;
+	mlxsw_afa_set_goto_set(block->cur_set,
+			       MLXSW_AFA_SET_GOTO_BINDING_CMD_TERM, 0);
+	block->finished = true;
+	return 0;
+}
+EXPORT_SYMBOL(mlxsw_afa_block_terminate);
+
 static struct mlxsw_afa_fwd_entry *
 mlxsw_afa_fwd_entry_create(struct mlxsw_afa *mlxsw_afa, u8 local_port)
 {
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h
index 43132293475c..b91f2b0829b0 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h
@@ -65,6 +65,7 @@ char *mlxsw_afa_block_first_set(struct mlxsw_afa_block *block);
 u32 mlxsw_afa_block_first_set_kvdl_index(struct mlxsw_afa_block *block);
 int mlxsw_afa_block_continue(struct mlxsw_afa_block *block);
 int mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id);
+int mlxsw_afa_block_terminate(struct mlxsw_afa_block *block);
 int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block);
 int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block, u16 trap_id);
 int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index 4ec1ca3c96c8..386861773476 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -553,6 +553,7 @@ void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei,
 int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei);
 int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
 				u16 group_id);
+int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei);
 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei);
 int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
 int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
index 0897a5435cc2..92d90ed7207e 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
@@ -528,6 +528,11 @@ int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
 	return mlxsw_afa_block_jump(rulei->act_block, group_id);
 }
 
+int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei)
+{
+	return mlxsw_afa_block_terminate(rulei->act_block);
+}
+
 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei)
 {
 	return mlxsw_afa_block_append_drop(rulei->act_block);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
index 6ce00e28d4ea..89dbf569dff5 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
@@ -65,7 +65,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
 	tcf_exts_to_list(exts, &actions);
 	list_for_each_entry(a, &actions, list) {
 		if (is_tcf_gact_ok(a)) {
-			err = mlxsw_sp_acl_rulei_act_continue(rulei);
+			err = mlxsw_sp_acl_rulei_act_terminate(rulei);
 			if (err)
 				return err;
 		} else if (is_tcf_gact_shot(a)) {
-- 
2.14.3

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

* [PATCH net 2/2] mlxsw: spectrum: Prevent duplicate mirrors
  2018-03-09 13:33 [PATCH net 0/2] mlxsw: ACL and mirroring fixes Ido Schimmel
  2018-03-09 13:33 ` [PATCH net 1/2] mlxsw: spectrum: Fix gact_ok offloading Ido Schimmel
@ 2018-03-09 13:33 ` Ido Schimmel
  2018-03-09 13:39   ` Ido Schimmel
  2018-03-09 18:02 ` [PATCH net 0/2] mlxsw: ACL and mirroring fixes David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Ido Schimmel @ 2018-03-09 13:33 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, petrm, mlxsw, Ido Schimmel

From: Petr Machata <petrm@mellanox.com>

The Spectrum ASIC doesn't support mirroring more than once from a single
binding point (which is a port-direction pair). Therefore detect that a
second binding of a given binding point is attempted.

To that end, extend struct mlxsw_sp_span_inspected_port to track whether
a given binding point is bound or not. Extend
mlxsw_sp_span_entry_port_find() to look for ports based on the full
unique key: port number, direction, and boundness.

Besides fixing the overt bug where configured mirrors are not offloaded,
this also fixes a more subtle bug: mlxsw_sp_span_inspected_port_del()
just defers to mlxsw_sp_span_entry_bound_port_find(), and that used to
find the first port with the right number (disregarding the type). Thus
by adding and removing egress and ingress mirrors in the right order,
one could trick the system into believing it has no egress mirrors when
in fact it did have some. That then caused that
mlxsw_sp_span_port_mtu_update() didn't update mirroring buffer when MTU
was changed.

Fixes: 763b4b70afcd ("mlxsw: spectrum: Add support in matchall mirror TC offloading")
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 28 ++++++++++++++++++++++----
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h |  3 +++
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index c7e941aecc2a..bf400c75fcc8 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -655,13 +655,17 @@ static int mlxsw_sp_span_port_mtu_update(struct mlxsw_sp_port *port, u16 mtu)
 }
 
 static struct mlxsw_sp_span_inspected_port *
-mlxsw_sp_span_entry_bound_port_find(struct mlxsw_sp_port *port,
-				    struct mlxsw_sp_span_entry *span_entry)
+mlxsw_sp_span_entry_bound_port_find(struct mlxsw_sp_span_entry *span_entry,
+				    enum mlxsw_sp_span_type type,
+				    struct mlxsw_sp_port *port,
+				    bool bind)
 {
 	struct mlxsw_sp_span_inspected_port *p;
 
 	list_for_each_entry(p, &span_entry->bound_ports_list, list)
-		if (port->local_port == p->local_port)
+		if (type == p->type &&
+		    port->local_port == p->local_port &&
+		    bind == p->bound)
 			return p;
 	return NULL;
 }
@@ -691,8 +695,22 @@ mlxsw_sp_span_inspected_port_add(struct mlxsw_sp_port *port,
 	struct mlxsw_sp_span_inspected_port *inspected_port;
 	struct mlxsw_sp *mlxsw_sp = port->mlxsw_sp;
 	char sbib_pl[MLXSW_REG_SBIB_LEN];
+	int i;
 	int err;
 
+	/* A given (source port, direction) can only be bound to one analyzer,
+	 * so if a binding is requested, check for conflicts.
+	 */
+	if (bind)
+		for (i = 0; i < mlxsw_sp->span.entries_count; i++) {
+			struct mlxsw_sp_span_entry *curr =
+				&mlxsw_sp->span.entries[i];
+
+			if (mlxsw_sp_span_entry_bound_port_find(curr, type,
+								port, bind))
+				return -EEXIST;
+		}
+
 	/* if it is an egress SPAN, bind a shared buffer to it */
 	if (type == MLXSW_SP_SPAN_EGRESS) {
 		u32 buffsize = mlxsw_sp_span_mtu_to_buffsize(mlxsw_sp,
@@ -720,6 +738,7 @@ mlxsw_sp_span_inspected_port_add(struct mlxsw_sp_port *port,
 	}
 	inspected_port->local_port = port->local_port;
 	inspected_port->type = type;
+	inspected_port->bound = bind;
 	list_add_tail(&inspected_port->list, &span_entry->bound_ports_list);
 
 	return 0;
@@ -746,7 +765,8 @@ mlxsw_sp_span_inspected_port_del(struct mlxsw_sp_port *port,
 	struct mlxsw_sp *mlxsw_sp = port->mlxsw_sp;
 	char sbib_pl[MLXSW_REG_SBIB_LEN];
 
-	inspected_port = mlxsw_sp_span_entry_bound_port_find(port, span_entry);
+	inspected_port = mlxsw_sp_span_entry_bound_port_find(span_entry, type,
+							     port, bind);
 	if (!inspected_port)
 		return;
 
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index 386861773476..92064db2ae44 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -120,6 +120,9 @@ struct mlxsw_sp_span_inspected_port {
 	struct list_head list;
 	enum mlxsw_sp_span_type type;
 	u8 local_port;
+
+	/* Whether this is a directly bound mirror (port-to-port) or an ACL. */
+	bool bound;
 };
 
 struct mlxsw_sp_span_entry {
-- 
2.14.3

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

* Re: [PATCH net 2/2] mlxsw: spectrum: Prevent duplicate mirrors
  2018-03-09 13:33 ` [PATCH net 2/2] mlxsw: spectrum: Prevent duplicate mirrors Ido Schimmel
@ 2018-03-09 13:39   ` Ido Schimmel
  0 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2018-03-09 13:39 UTC (permalink / raw)
  To: netdev, davem, sfr; +Cc: jiri, petrm, mlxsw

+Stephen

On Fri, Mar 09, 2018 at 03:33:53PM +0200, Ido Schimmel wrote:
> From: Petr Machata <petrm@mellanox.com>
> 
> The Spectrum ASIC doesn't support mirroring more than once from a single
> binding point (which is a port-direction pair). Therefore detect that a
> second binding of a given binding point is attempted.
> 
> To that end, extend struct mlxsw_sp_span_inspected_port to track whether
> a given binding point is bound or not. Extend
> mlxsw_sp_span_entry_port_find() to look for ports based on the full
> unique key: port number, direction, and boundness.
> 
> Besides fixing the overt bug where configured mirrors are not offloaded,
> this also fixes a more subtle bug: mlxsw_sp_span_inspected_port_del()
> just defers to mlxsw_sp_span_entry_bound_port_find(), and that used to
> find the first port with the right number (disregarding the type). Thus
> by adding and removing egress and ingress mirrors in the right order,
> one could trick the system into believing it has no egress mirrors when
> in fact it did have some. That then caused that
> mlxsw_sp_span_port_mtu_update() didn't update mirroring buffer when MTU
> was changed.
> 
> Fixes: 763b4b70afcd ("mlxsw: spectrum: Add support in matchall mirror TC offloading")
> Signed-off-by: Petr Machata <petrm@mellanox.com>
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>

Hi Dave, Stephen,

Please note that this is going to conflict with recent mirroring to GRE
tap work when you merge net into net-next. The resolution is available
here:
git@github.com:jpirko/linux_mlxsw.git (branch: linux-next-fix)

Or simply here:
https://github.com/jpirko/linux_mlxsw/commit/8175f7c4736fe9f6a4dac330ee79b45593502a6c

Thanks and sorry about the added work.

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

* Re: [PATCH net 0/2] mlxsw: ACL and mirroring fixes
  2018-03-09 13:33 [PATCH net 0/2] mlxsw: ACL and mirroring fixes Ido Schimmel
  2018-03-09 13:33 ` [PATCH net 1/2] mlxsw: spectrum: Fix gact_ok offloading Ido Schimmel
  2018-03-09 13:33 ` [PATCH net 2/2] mlxsw: spectrum: Prevent duplicate mirrors Ido Schimmel
@ 2018-03-09 18:02 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-03-09 18:02 UTC (permalink / raw)
  To: idosch; +Cc: netdev, jiri, petrm, mlxsw

From: Ido Schimmel <idosch@mellanox.com>
Date: Fri,  9 Mar 2018 15:33:51 +0200

> The first patch fixes offload of rules using the 'pass' action. Instead
> of continuing to evaluate lower priority rules, the binding is
> terminated and the packet proceeds to the bridge and router blocks on
> ingress, or goes out of the port on egress.
> 
> Second patch prevents the user from mirroring more than once from a
> given {Port, Direction} as this is not supported by the device.

Series applied, and thanks for the heads up about conflicts.

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

end of thread, other threads:[~2018-03-09 18:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09 13:33 [PATCH net 0/2] mlxsw: ACL and mirroring fixes Ido Schimmel
2018-03-09 13:33 ` [PATCH net 1/2] mlxsw: spectrum: Fix gact_ok offloading Ido Schimmel
2018-03-09 13:33 ` [PATCH net 2/2] mlxsw: spectrum: Prevent duplicate mirrors Ido Schimmel
2018-03-09 13:39   ` Ido Schimmel
2018-03-09 18:02 ` [PATCH net 0/2] mlxsw: ACL and mirroring fixes David Miller

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.