]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mlxsw: spectrum_span: Add SPAN session identifier support
authorIdo Schimmel <idosch@nvidia.com>
Thu, 11 Mar 2021 12:24:11 +0000 (14:24 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 12 Mar 2021 00:22:39 +0000 (16:22 -0800)
When packets are mirrored to the CPU, the trap identifier with which the
packets are trapped is determined according to the session identifier of
the SPAN agent performing the mirroring. Packets that are trapped for
the same logical reason (e.g., buffer drops) should use the same session
identifier.

Currently, a single session is implicitly supported (identifier 0) and
is used for packets that are mirrored to the CPU due to buffer drops
(e.g., early drop).

Subsequent patches are going to mirror packets to the CPU due to
sampling, which will require a different session identifier.

Prepare for that by making the session identifier an attribute of the
SPAN agent.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h

index fd672c6c9133652454de8e392cb76efa21acb4a7..9d16823320ae8026f9f8de60706ae74d536938b9 100644 (file)
@@ -1404,7 +1404,9 @@ static int mlxsw_sp_qevent_trap_configure(struct mlxsw_sp *mlxsw_sp,
                                          struct mlxsw_sp_mall_entry *mall_entry,
                                          struct mlxsw_sp_qevent_binding *qevent_binding)
 {
-       struct mlxsw_sp_span_agent_parms agent_parms = {};
+       struct mlxsw_sp_span_agent_parms agent_parms = {
+               .session_id = MLXSW_SP_SPAN_SESSION_ID_BUFFER,
+       };
        int err;
 
        err = mlxsw_sp_trap_group_policer_hw_id_get(mlxsw_sp,
index 1892cea05ee7cc94d5597206bed0ca8643cb2984..3287211819df06f78d0ca8e2a9e5813364912df5 100644 (file)
@@ -186,6 +186,7 @@ mlxsw_sp_span_entry_phys_configure(struct mlxsw_sp_span_entry *span_entry,
        /* Create a new port analayzer entry for local_port. */
        mlxsw_reg_mpat_pack(mpat_pl, pa_id, local_port, true,
                            MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH);
+       mlxsw_reg_mpat_session_id_set(mpat_pl, sparms.session_id);
        mlxsw_reg_mpat_pide_set(mpat_pl, sparms.policer_enable);
        mlxsw_reg_mpat_pid_set(mpat_pl, sparms.policer_id);
 
@@ -203,6 +204,7 @@ mlxsw_sp_span_entry_deconfigure_common(struct mlxsw_sp_span_entry *span_entry,
        int pa_id = span_entry->id;
 
        mlxsw_reg_mpat_pack(mpat_pl, pa_id, local_port, false, span_type);
+       mlxsw_reg_mpat_session_id_set(mpat_pl, span_entry->parms.session_id);
        mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl);
 }
 
@@ -938,7 +940,8 @@ mlxsw_sp_span_entry_find_by_parms(struct mlxsw_sp *mlxsw_sp,
 
                if (refcount_read(&curr->ref_count) && curr->to_dev == to_dev &&
                    curr->parms.policer_enable == sparms->policer_enable &&
-                   curr->parms.policer_id == sparms->policer_id)
+                   curr->parms.policer_id == sparms->policer_id &&
+                   curr->parms.session_id == sparms->session_id)
                        return curr;
        }
        return NULL;
@@ -1085,6 +1088,7 @@ int mlxsw_sp_span_agent_get(struct mlxsw_sp *mlxsw_sp, int *p_span_id,
 
        sparms.policer_id = parms->policer_id;
        sparms.policer_enable = parms->policer_enable;
+       sparms.session_id = parms->session_id;
        span_entry = mlxsw_sp_span_entry_get(mlxsw_sp, to_dev, ops, sparms);
        if (!span_entry)
                return -ENOBUFS;
index aa1cd409c0e2ea15d585cb10d6cc344bc3dce879..6e84cc049428883fb1ecac59bdaedddac94a94fa 100644 (file)
 struct mlxsw_sp;
 struct mlxsw_sp_port;
 
+/* SPAN session identifiers that correspond to MLXSW_TRAP_ID_MIRROR_SESSION<i>
+ * trap identifiers. The session identifier is an attribute of the SPAN agent,
+ * which determines the trap identifier of packets that are mirrored to the
+ * CPU. Packets that are trapped to the CPU for the same logical reason (e.g.,
+ * buffer drops) should use the same session identifier.
+ */
+enum mlxsw_sp_span_session_id {
+       MLXSW_SP_SPAN_SESSION_ID_BUFFER,
+
+       __MLXSW_SP_SPAN_SESSION_ID_MAX = 8,
+};
+
 struct mlxsw_sp_span_parms {
        struct mlxsw_sp_port *dest_port; /* NULL for unoffloaded SPAN. */
        unsigned int ttl;
@@ -23,6 +35,7 @@ struct mlxsw_sp_span_parms {
        u16 vid;
        u16 policer_id;
        bool policer_enable;
+       enum mlxsw_sp_span_session_id session_id;
 };
 
 enum mlxsw_sp_span_trigger {
@@ -41,6 +54,7 @@ struct mlxsw_sp_span_agent_parms {
        const struct net_device *to_dev;
        u16 policer_id;
        bool policer_enable;
+       enum mlxsw_sp_span_session_id session_id;
 };
 
 struct mlxsw_sp_span_entry_ops;