OSDN Git Service

net/mlx5e: E-Switch, Add support for tx_port_ts in switchdev mode
authorAya Levin <ayal@nvidia.com>
Thu, 20 Jan 2022 15:53:06 +0000 (17:53 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Thu, 17 Feb 2022 07:55:15 +0000 (23:55 -0800)
When turning on tx_port_ts (private flag) a PTP-SQ is created. Consider
this queue when adding rules matching SQs to VPORTs. Otherwise the
traffic on this queue won't reach the wire.

Signed-off-by: Aya Levin <ayal@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

index 4459e55..6070b8a 100644 (file)
@@ -55,6 +55,7 @@
 #include "diag/en_rep_tracepoint.h"
 #include "en_accel/ipsec.h"
 #include "en/tc/int_port.h"
+#include "en/ptp.h"
 
 #define MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE \
        max(0x7, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)
@@ -401,13 +402,18 @@ int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
        struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
        struct mlx5e_rep_priv *rpriv = priv->ppriv;
        struct mlx5_eswitch_rep *rep = rpriv->rep;
+       int n, tc, nch, num_sqs = 0;
        struct mlx5e_channel *c;
-       int n, tc, num_sqs = 0;
        int err = -ENOMEM;
+       bool ptp_sq;
        u32 *sqs;
 
-       sqs = kcalloc(priv->channels.num * mlx5e_get_dcb_num_tc(&priv->channels.params),
-                     sizeof(*sqs), GFP_KERNEL);
+       ptp_sq = !!(priv->channels.ptp &&
+                   MLX5E_GET_PFLAG(&priv->channels.params, MLX5E_PFLAG_TX_PORT_TS));
+       nch = priv->channels.num + ptp_sq;
+
+       sqs = kcalloc(nch * mlx5e_get_dcb_num_tc(&priv->channels.params), sizeof(*sqs),
+                     GFP_KERNEL);
        if (!sqs)
                goto out;
 
@@ -416,6 +422,12 @@ int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
                for (tc = 0; tc < c->num_tc; tc++)
                        sqs[num_sqs++] = c->sq[tc].sqn;
        }
+       if (ptp_sq) {
+               struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
+
+               for (tc = 0; tc < ptp_ch->num_tc; tc++)
+                       sqs[num_sqs++] = ptp_ch->ptpsq[tc].txqsq.sqn;
+       }
 
        err = mlx5e_sqs2vport_start(esw, rep, sqs, num_sqs);
        kfree(sqs);