mlxsw: SPAN cleanups
Subsystems (3)
cover mlxsw: SPAN cleanups
From: Jiri Pirko <[email protected]>
In patch one of this short series, a misplaced pointer star is moved to the correct place.
In the second patch, we observe that if SPAN entries carry their reference count anyway, it's redundant to also carry a "used" flag.
In the third patch, SPAN support code is moved to a separate module.
Petr Machata (3):
mlxsw: spectrum: Fix a coding style nit
mlxsw: spectrum: Drop struct span_entry.used
mlxsw: spectrum: Move SPAN code to separate module
drivers/net/ethernet/mellanox/mlxsw/Makefile | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 322 +------------------ drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 30 +- .../mellanox/mlxsw/spectrum_acl_flex_actions.c | 1 + .../net/ethernet/mellanox/mlxsw/spectrum_span.c | 356 +++++++++++++++++++++ .../net/ethernet/mellanox/mlxsw/spectrum_span.h | 73 +++++ 6 files changed, 433 insertions(+), 351 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c create mode 100644 drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h
Signature · 1 line
2.14.3
PATCH 1/3 mlxsw: spectrum: Fix a coding style nit
From: Petr Machata <[email protected]>
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +2 -2
@@ -582,8 +582,8 @@ mlxsw_sp_span_entry_find(struct mlxsw_sp *mlxsw_sp, u8 local_port)return NULL ; } -static struct mlxsw_sp_span_entry -*mlxsw_sp_span_entry_get (struct mlxsw_sp_port *port) +static struct mlxsw_sp_span_entry * +mlxsw_sp_span_entry_get (struct mlxsw_sp_port *port) {struct mlxsw_sp_span_entry *span_entry;
Signature · 1 line
2.14.3
PATCH 2/3 mlxsw: spectrum: Drop struct span_entry.used
In reply to Jiri PirkoFrom: Petr Machata <[email protected]>
The member ref_count already determines whether a given SPAN entry is used, and is as easy to use as a dedicated boolean.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 6 ++---- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 1 - 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +2 -4
@@ -534,7 +534,7 @@ mlxsw_sp_span_entry_create(struct mlxsw_sp_port *port)/* find a free entry to use */ index =-1 ;for (i =0 ; i < mlxsw_sp->span.entries_count; i++) { -if (!mlxsw_sp->span.entries[i].used) { +if (!mlxsw_sp->span.entries[i].ref_count) { index = i; span_entry = &mlxsw_sp->span.entries[i];break ;
@@ -549,7 +549,6 @@ mlxsw_sp_span_entry_create(struct mlxsw_sp_port *port)if (err)return NULL ; - span_entry->used = true; span_entry->id = index; span_entry->ref_count =1 ; span_entry->local_port = local_port;
@@ -565,7 +564,6 @@ static void mlxsw_sp_span_entry_destroy(struct mlxsw_sp *mlxsw_sp,mlxsw_reg_mpat_pack (mpat_pl, pa_id, local_port, false);mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (mpat), mpat_pl); - span_entry->used = false; } struct mlxsw_sp_span_entry *
@@ -576,7 +574,7 @@ mlxsw_sp_span_entry_find(struct mlxsw_sp *mlxsw_sp, u8 local_port)for (i =0 ; i < mlxsw_sp->span.entries_count; i++) {struct mlxsw_sp_span_entry *curr = &mlxsw_sp->span.entries[i]; -if (curr->used && curr->local_port == local_port) +if (curr->ref_count && curr->local_port == local_port)return curr; }return NULL ;
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +0 -1
@@ -124,7 +124,6 @@ struct mlxsw_sp_span_inspected_port {struct mlxsw_sp_span_entry {u8 local_port; -bool used;struct list_head bound_ports_list;int ref_count;int id;
Signature · 1 line
2.14.3
PATCH 3/3 mlxsw: spectrum: Move SPAN code to separate module
In reply to Jiri PirkoFrom: Petr Machata <[email protected]>
For the upcoming work on SPAN, it makes sense to move the current code to a module of its own. It already has a well-defined API boundary to the mirror management (which is used from matchall and ACL code). A couple more functions need to be exported for the functions that spectrum.c needs to use for MTU handling and subsystem init/fini.
--- drivers/net/ethernet/mellanox/mlxsw/Makefile | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 320 +----------------- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 29 +- .../mellanox/mlxsw/spectrum_acl_flex_actions.c | 1 + .../net/ethernet/mellanox/mlxsw/spectrum_span.c | 356 +++++++++++++++++++++ .../net/ethernet/mellanox/mlxsw/spectrum_span.h | 73 +++++ 6 files changed, 433 insertions(+), 348 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c create mode 100644 drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h
drivers/net/ethernet/mellanox/mlxsw/Makefile +1 -1
@@ -20,7 +20,7 @@ mlxsw_spectrum-objs := spectrum.o spectrum_buffers.o \ spectrum_cnt.o spectrum_fid.o \ spectrum_ipip.o spectrum_acl_flex_actions.o \ spectrum_mr.o spectrum_mr_tcam.o \ - spectrum_qdisc.o + spectrum_qdisc.o spectrum_span.o mlxsw_spectrum-$(CONFIG_MLXSW_SPECTRUM_DCB) += spectrum_dcb.o mlxsw_spectrum-$(CONFIG_NET_DEVLINK) += spectrum_dpipe.o obj-$(CONFIG_MLXSW_MINIMAL) += mlxsw_minimal.o
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +1 -319
332 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +1 -28
@@ -80,6 +80,7 @@ enum mlxsw_sp_resource_id {struct mlxsw_sp_port ;struct mlxsw_sp_rif ; +struct mlxsw_sp_span_entry ;struct mlxsw_sp_upper {struct net_device *dev;
@@ -111,24 +112,6 @@ struct mlxsw_sp_mid {unsigned long *ports_in_mid;/* bits array */ }; -enum mlxsw_sp_span_type { -MLXSW_SP_SPAN_EGRESS , -MLXSW_SP_SPAN_INGRESS -}; - -struct mlxsw_sp_span_inspected_port { -struct list_head list; -enum mlxsw_sp_span_type type; -u8 local_port; -}; - -struct mlxsw_sp_span_entry { -u8 local_port; -struct list_head bound_ports_list; -int ref_count; -int id; -}; -enum mlxsw_sp_port_mall_action_type {MLXSW_SP_PORT_MALL_MIRROR ,MLXSW_SP_PORT_MALL_SAMPLE ,
@@ -395,16 +378,6 @@ struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold (struct net_device *dev);void mlxsw_sp_port_dev_put (struct mlxsw_sp_port *mlxsw_sp_port);struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu (struct net_device *dev); -int mlxsw_sp_span_mirror_add (struct mlxsw_sp_port *from, -struct mlxsw_sp_port *to, -enum mlxsw_sp_span_type type, -bool bind); -void mlxsw_sp_span_mirror_del (struct mlxsw_sp_port *from, -u8 destination_port, -enum mlxsw_sp_span_type type, -bool bind); -struct mlxsw_sp_span_entry * -mlxsw_sp_span_entry_find (struct mlxsw_sp *mlxsw_sp,u8 local_port);/* spectrum_dcb.c */ #ifdef CONFIG_MLXSW_SPECTRUM_DCB
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_actions.c +1 -0
@@ -35,6 +35,7 @@#include "spectrum_acl_flex_actions.h" #include "core_acl_flex_actions.h" +#include "spectrum_span.h" #define MLXSW_SP_KVDL_ACT_EXT_SIZE 1
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c new file +356 -0
356 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h new file +73 -0
73 lines not on this page · raw message
Signature · 1 line
2.14.3
David Miller
maintainerFrom: Jiri Pirko <[email protected]>
Date: Tue, 13 Feb 2018 11:27:45 +0100
Quoted 7 lines
In patch one of this short series, a misplaced pointer star is moved to the correct place.
In the second patch, we observe that if SPAN entries carry their reference count anyway, it's redundant to also carry a "used" flag.
In the third patch, SPAN support code is moved to a separate module.
Series applied.
Thanks.