diff options
author | Petr Machata <petrm@mellanox.com> | 2018-02-27 08:53:43 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-02-27 14:46:27 -0500 |
commit | 7b2ef81fd2bd4d01fc4890fb22c4dcfe76dd8c77 (patch) | |
tree | c333776569223a4fa2bcd53adf2eca1c0bc872dd | |
parent | 3546b03ffcdb0a70b0d7302d7e139f096a613e9f (diff) |
mlxsw: spectrum_span: Extract mlxsw_sp_span_entry_{de, }configure()
Configuring the hardware for encapsulated SPAN involves more code than
the simple mirroring case. Extract the related code to a separate
function to separate it from the rest of SPAN entry creation. Extract
deconfigure as well for symmetry, even though disablement is the same
regardless of SPAN type.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c index 5c87e6dfc5a1..442771908600 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c | |||
@@ -73,15 +73,40 @@ void mlxsw_sp_span_fini(struct mlxsw_sp *mlxsw_sp) | |||
73 | kfree(mlxsw_sp->span.entries); | 73 | kfree(mlxsw_sp->span.entries); |
74 | } | 74 | } |
75 | 75 | ||
76 | static int | ||
77 | mlxsw_sp_span_entry_configure(struct mlxsw_sp *mlxsw_sp, | ||
78 | struct mlxsw_sp_span_entry *span_entry, | ||
79 | u8 local_port) | ||
80 | { | ||
81 | char mpat_pl[MLXSW_REG_MPAT_LEN]; | ||
82 | int pa_id = span_entry->id; | ||
83 | |||
84 | /* Create a new port analayzer entry for local_port. */ | ||
85 | mlxsw_reg_mpat_pack(mpat_pl, pa_id, local_port, true, | ||
86 | MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH); | ||
87 | return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); | ||
88 | } | ||
89 | |||
90 | static void | ||
91 | mlxsw_sp_span_entry_deconfigure(struct mlxsw_sp *mlxsw_sp, | ||
92 | struct mlxsw_sp_span_entry *span_entry) | ||
93 | { | ||
94 | u8 local_port = span_entry->local_port; | ||
95 | char mpat_pl[MLXSW_REG_MPAT_LEN]; | ||
96 | int pa_id = span_entry->id; | ||
97 | |||
98 | mlxsw_reg_mpat_pack(mpat_pl, pa_id, local_port, false, | ||
99 | MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH); | ||
100 | mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); | ||
101 | } | ||
102 | |||
76 | static struct mlxsw_sp_span_entry * | 103 | static struct mlxsw_sp_span_entry * |
77 | mlxsw_sp_span_entry_create(struct mlxsw_sp_port *port) | 104 | mlxsw_sp_span_entry_create(struct mlxsw_sp_port *port) |
78 | { | 105 | { |
79 | struct mlxsw_sp_span_entry *span_entry = NULL; | 106 | struct mlxsw_sp_span_entry *span_entry = NULL; |
80 | struct mlxsw_sp *mlxsw_sp = port->mlxsw_sp; | 107 | struct mlxsw_sp *mlxsw_sp = port->mlxsw_sp; |
81 | char mpat_pl[MLXSW_REG_MPAT_LEN]; | ||
82 | u8 local_port = port->local_port; | 108 | u8 local_port = port->local_port; |
83 | int i; | 109 | int i; |
84 | int err; | ||
85 | 110 | ||
86 | /* find a free entry to use */ | 111 | /* find a free entry to use */ |
87 | for (i = 0; i < mlxsw_sp->span.entries_count; i++) { | 112 | for (i = 0; i < mlxsw_sp->span.entries_count; i++) { |
@@ -93,11 +118,7 @@ mlxsw_sp_span_entry_create(struct mlxsw_sp_port *port) | |||
93 | if (!span_entry) | 118 | if (!span_entry) |
94 | return NULL; | 119 | return NULL; |
95 | 120 | ||
96 | /* create a new port analayzer entry for local_port */ | 121 | if (mlxsw_sp_span_entry_configure(mlxsw_sp, span_entry, local_port)) |
97 | mlxsw_reg_mpat_pack(mpat_pl, span_entry->id, local_port, true, | ||
98 | MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH); | ||
99 | err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); | ||
100 | if (err) | ||
101 | return NULL; | 122 | return NULL; |
102 | 123 | ||
103 | span_entry->ref_count = 1; | 124 | span_entry->ref_count = 1; |
@@ -108,13 +129,7 @@ mlxsw_sp_span_entry_create(struct mlxsw_sp_port *port) | |||
108 | static void mlxsw_sp_span_entry_destroy(struct mlxsw_sp *mlxsw_sp, | 129 | static void mlxsw_sp_span_entry_destroy(struct mlxsw_sp *mlxsw_sp, |
109 | struct mlxsw_sp_span_entry *span_entry) | 130 | struct mlxsw_sp_span_entry *span_entry) |
110 | { | 131 | { |
111 | u8 local_port = span_entry->local_port; | 132 | mlxsw_sp_span_entry_deconfigure(mlxsw_sp, span_entry); |
112 | char mpat_pl[MLXSW_REG_MPAT_LEN]; | ||
113 | int pa_id = span_entry->id; | ||
114 | |||
115 | mlxsw_reg_mpat_pack(mpat_pl, pa_id, local_port, false, | ||
116 | MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH); | ||
117 | mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); | ||
118 | } | 133 | } |
119 | 134 | ||
120 | struct mlxsw_sp_span_entry * | 135 | struct mlxsw_sp_span_entry * |