net:mlx5e: Add PTP-TIR and PTP-RQT
authorAya Levin <ayal@nvidia.com>
Thu, 25 Feb 2021 17:55:20 +0000 (19:55 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Tue, 30 Mar 2021 04:21:51 +0000 (21:21 -0700)
Add PTP-TIR and initiate its RQT to allow PTP-RQ to integrate into the
safe-reopen flow on configuration change. Add rx_ptp_support flag on a
profile and turn it on for ETH driver. With this flag set, create a
redirect-RQT for PTP-RQ.

Signed-off-by: Aya Levin <ayal@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c

index 8f6ccd54057a303ad889b9c525c94229f84384a4..f31b5ccc27d02d9136b6515e21ca5b11bd98dcc9 100644 (file)
@@ -837,6 +837,7 @@ struct mlx5e_priv {
        struct mlx5e_tir           inner_indir_tir[MLX5E_NUM_INDIR_TIRS];
        struct mlx5e_tir           direct_tir[MLX5E_MAX_NUM_CHANNELS];
        struct mlx5e_tir           xsk_tir[MLX5E_MAX_NUM_CHANNELS];
+       struct mlx5e_tir           ptp_tir;
        struct mlx5e_rss_params    rss_params;
        u32                        tx_rates[MLX5E_MAX_NUM_SQS];
 
@@ -916,6 +917,7 @@ struct mlx5e_profile {
        const struct mlx5e_rx_handlers *rx_handlers;
        int     max_tc;
        u8      rq_groups;
+       bool    rx_ptp_support;
 };
 
 void mlx5e_build_ptys2ethtool_map(void);
index 4595d2388d83b77ba4d831b3a49a40a4f8984e86..c1c41c8656dcb7ce9a1e3a70712dcf0d477e3112 100644 (file)
@@ -663,3 +663,12 @@ void mlx5e_ptp_deactivate_channel(struct mlx5e_ptp *c)
 
        napi_disable(&c->napi);
 }
+
+int mlx5e_ptp_get_rqn(struct mlx5e_ptp *c, u32 *rqn)
+{
+       if (!c || !test_bit(MLX5E_PTP_STATE_RX, c->state))
+               return -EINVAL;
+
+       *rqn = c->rq.rqn;
+       return 0;
+}
index cc6a48a432335615df2d6cedbc0a4043e2453125..460b167887bc18f0221546a0e5e5ca67810d3b87 100644 (file)
@@ -48,6 +48,7 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
 void mlx5e_ptp_close(struct mlx5e_ptp *c);
 void mlx5e_ptp_activate_channel(struct mlx5e_ptp *c);
 void mlx5e_ptp_deactivate_channel(struct mlx5e_ptp *c);
+int mlx5e_ptp_get_rqn(struct mlx5e_ptp *c, u32 *rqn);
 
 enum {
        MLX5E_SKB_CB_CQE_HWTSTAMP  = BIT(0),
index 7ecde284c57c9bebf0e6dc2712826c422f9a2846..7cf12342afe654ff193ce2ea7554c4dc93178d90 100644 (file)
@@ -2329,7 +2329,8 @@ static u32 mlx5e_get_direct_rqn(struct mlx5e_priv *priv, int ix,
 }
 
 static void mlx5e_redirect_rqts(struct mlx5e_priv *priv,
-                               struct mlx5e_redirect_rqt_param rrp)
+                               struct mlx5e_redirect_rqt_param rrp,
+                               struct mlx5e_redirect_rqt_param *ptp_rrp)
 {
        u32 rqtn;
        int ix;
@@ -2355,11 +2356,17 @@ static void mlx5e_redirect_rqts(struct mlx5e_priv *priv,
                rqtn = priv->direct_tir[ix].rqt.rqtn;
                mlx5e_redirect_rqt(priv, rqtn, 1, direct_rrp);
        }
+       if (ptp_rrp) {
+               rqtn = priv->ptp_tir.rqt.rqtn;
+               mlx5e_redirect_rqt(priv, rqtn, 1, *ptp_rrp);
+       }
 }
 
 static void mlx5e_redirect_rqts_to_channels(struct mlx5e_priv *priv,
                                            struct mlx5e_channels *chs)
 {
+       bool rx_ptp_support = priv->profile->rx_ptp_support;
+       struct mlx5e_redirect_rqt_param *ptp_rrp_p = NULL;
        struct mlx5e_redirect_rqt_param rrp = {
                .is_rss        = true,
                {
@@ -2369,12 +2376,22 @@ static void mlx5e_redirect_rqts_to_channels(struct mlx5e_priv *priv,
                        }
                },
        };
+       struct mlx5e_redirect_rqt_param ptp_rrp;
+
+       if (rx_ptp_support) {
+               u32 ptp_rqn;
 
-       mlx5e_redirect_rqts(priv, rrp);
+               ptp_rrp.is_rss = false;
+               ptp_rrp.rqn = mlx5e_ptp_get_rqn(priv->channels.ptp, &ptp_rqn) ?
+                             priv->drop_rq.rqn : ptp_rqn;
+               ptp_rrp_p = &ptp_rrp;
+       }
+       mlx5e_redirect_rqts(priv, rrp, ptp_rrp_p);
 }
 
 static void mlx5e_redirect_rqts_to_drop(struct mlx5e_priv *priv)
 {
+       bool rx_ptp_support = priv->profile->rx_ptp_support;
        struct mlx5e_redirect_rqt_param drop_rrp = {
                .is_rss = false,
                {
@@ -2382,7 +2399,7 @@ static void mlx5e_redirect_rqts_to_drop(struct mlx5e_priv *priv)
                },
        };
 
-       mlx5e_redirect_rqts(priv, drop_rrp);
+       mlx5e_redirect_rqts(priv, drop_rrp, rx_ptp_support ? &drop_rrp : NULL);
 }
 
 static const struct mlx5e_tirc_config tirc_default_config[MLX5E_NUM_INDIR_TIRS] = {
@@ -4944,10 +4961,18 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
        if (unlikely(err))
                goto err_destroy_xsk_rqts;
 
+       err = mlx5e_create_direct_rqts(priv, &priv->ptp_tir, 1);
+       if (err)
+               goto err_destroy_xsk_tirs;
+
+       err = mlx5e_create_direct_tirs(priv, &priv->ptp_tir, 1);
+       if (err)
+               goto err_destroy_ptp_rqt;
+
        err = mlx5e_create_flow_steering(priv);
        if (err) {
                mlx5_core_warn(mdev, "create flow steering failed, %d\n", err);
-               goto err_destroy_xsk_tirs;
+               goto err_destroy_ptp_direct_tir;
        }
 
        err = mlx5e_tc_nic_init(priv);
@@ -4968,6 +4993,10 @@ err_tc_nic_cleanup:
        mlx5e_tc_nic_cleanup(priv);
 err_destroy_flow_steering:
        mlx5e_destroy_flow_steering(priv);
+err_destroy_ptp_direct_tir:
+       mlx5e_destroy_direct_tirs(priv, &priv->ptp_tir, 1);
+err_destroy_ptp_rqt:
+       mlx5e_destroy_direct_rqts(priv, &priv->ptp_tir, 1);
 err_destroy_xsk_tirs:
        mlx5e_destroy_direct_tirs(priv, priv->xsk_tir, max_nch);
 err_destroy_xsk_rqts:
@@ -4994,6 +5023,8 @@ static void mlx5e_cleanup_nic_rx(struct mlx5e_priv *priv)
        mlx5e_accel_cleanup_rx(priv);
        mlx5e_tc_nic_cleanup(priv);
        mlx5e_destroy_flow_steering(priv);
+       mlx5e_destroy_direct_tirs(priv, &priv->ptp_tir, 1);
+       mlx5e_destroy_direct_rqts(priv, &priv->ptp_tir, 1);
        mlx5e_destroy_direct_tirs(priv, priv->xsk_tir, max_nch);
        mlx5e_destroy_direct_rqts(priv, priv->xsk_tir, max_nch);
        mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch);
@@ -5106,6 +5137,7 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
        .rq_groups         = MLX5E_NUM_RQ_GROUPS(XSK),
        .stats_grps        = mlx5e_nic_stats_grps,
        .stats_grps_num    = mlx5e_nic_stats_grps_num,
+       .rx_ptp_support    = true,
 };
 
 /* mlx5e generic netdev management API (move to en_common.c) */
index b597fc3b192b93835ccc7c582b48e895eca21673..9ef8e4a671a7f0f240f00305c170bcff38d6bf3a 100644 (file)
@@ -1062,6 +1062,7 @@ static const struct mlx5e_profile mlx5e_rep_profile = {
        .rq_groups              = MLX5E_NUM_RQ_GROUPS(REGULAR),
        .stats_grps             = mlx5e_rep_stats_grps,
        .stats_grps_num         = mlx5e_rep_stats_grps_num,
+       .rx_ptp_support         = false,
 };
 
 static const struct mlx5e_profile mlx5e_uplink_rep_profile = {
@@ -1082,6 +1083,7 @@ static const struct mlx5e_profile mlx5e_uplink_rep_profile = {
        .rq_groups              = MLX5E_NUM_RQ_GROUPS(XSK),
        .stats_grps             = mlx5e_ul_rep_stats_grps,
        .stats_grps_num         = mlx5e_ul_rep_stats_grps_num,
+       .rx_ptp_support         = false,
 };
 
 /* e-Switch vport representors */
index 63ca731051495cd5ab9f893f287b2052d96f2fd0..b65b0cefc5b3bf5b9ba3f17918e702ae4d53d26e 100644 (file)
@@ -473,6 +473,7 @@ static const struct mlx5e_profile mlx5i_nic_profile = {
        .rq_groups         = MLX5E_NUM_RQ_GROUPS(REGULAR),
        .stats_grps        = mlx5i_stats_grps,
        .stats_grps_num    = mlx5i_stats_grps_num,
+       .rx_ptp_support    = false,
 };
 
 /* mlx5i netdev NDos */
index 3d0a18a0bed4ae3a64c80c45153c653474bb9d19..18ee21b06a0015c40cd35cb1dfc07db78a373bed 100644 (file)
@@ -350,6 +350,7 @@ static const struct mlx5e_profile mlx5i_pkey_nic_profile = {
        .rx_handlers       = &mlx5i_rx_handlers,
        .max_tc            = MLX5I_MAX_NUM_TC,
        .rq_groups         = MLX5E_NUM_RQ_GROUPS(REGULAR),
+       .rx_ptp_support    = false,
 };
 
 const struct mlx5e_profile *mlx5i_pkey_get_profile(void)