net/mlx5e: Move Q counters allocation and drop RQ to init_rx
authorRoi Dayan <roid@mellanox.com>
Sun, 5 Aug 2018 03:58:05 +0000 (06:58 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Thu, 6 Sep 2018 04:14:57 +0000 (21:14 -0700)
Not all profiles query the HW Q counters in update_stats() callback.
HW Q couners are limited per device and in case of representors all
their Q counters are allocated on the parent PF device.
Avoid reundant allocation of HW Q counters by moving the allocation
to init_rx profile callback.

Signed-off-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en.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

index de0f7702c86ad883755860590a9bf0dd4d7adc60..01a967e717e7d90b2ad54f6178f23c376488f875 100644 (file)
@@ -898,6 +898,12 @@ void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev);
 int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb);
 
 /* common netdev helpers */
 int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb);
 
 /* common netdev helpers */
+void mlx5e_create_q_counters(struct mlx5e_priv *priv);
+void mlx5e_destroy_q_counters(struct mlx5e_priv *priv);
+int mlx5e_open_drop_rq(struct mlx5e_priv *priv,
+                      struct mlx5e_rq *drop_rq);
+void mlx5e_close_drop_rq(struct mlx5e_rq *drop_rq);
+
 int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv);
 
 int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv);
 int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv);
 
 int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv);
index 5a7939e7019026aa9c08d4fba759f95cb0a813c5..d14c4051edd811bab5080e5debf3196d13340f77 100644 (file)
@@ -3049,8 +3049,8 @@ static int mlx5e_alloc_drop_cq(struct mlx5_core_dev *mdev,
        return mlx5e_alloc_cq_common(mdev, param, cq);
 }
 
        return mlx5e_alloc_cq_common(mdev, param, cq);
 }
 
-static int mlx5e_open_drop_rq(struct mlx5e_priv *priv,
-                             struct mlx5e_rq *drop_rq)
+int mlx5e_open_drop_rq(struct mlx5e_priv *priv,
+                      struct mlx5e_rq *drop_rq)
 {
        struct mlx5_core_dev *mdev = priv->mdev;
        struct mlx5e_cq_param cq_param = {};
 {
        struct mlx5_core_dev *mdev = priv->mdev;
        struct mlx5e_cq_param cq_param = {};
@@ -3094,7 +3094,7 @@ err_free_cq:
        return err;
 }
 
        return err;
 }
 
-static void mlx5e_close_drop_rq(struct mlx5e_rq *drop_rq)
+void mlx5e_close_drop_rq(struct mlx5e_rq *drop_rq)
 {
        mlx5e_destroy_rq(drop_rq);
        mlx5e_free_rq(drop_rq);
 {
        mlx5e_destroy_rq(drop_rq);
        mlx5e_free_rq(drop_rq);
@@ -4726,7 +4726,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
        mlx5e_tls_build_netdev(priv);
 }
 
        mlx5e_tls_build_netdev(priv);
 }
 
-static void mlx5e_create_q_counters(struct mlx5e_priv *priv)
+void mlx5e_create_q_counters(struct mlx5e_priv *priv)
 {
        struct mlx5_core_dev *mdev = priv->mdev;
        int err;
 {
        struct mlx5_core_dev *mdev = priv->mdev;
        int err;
@@ -4744,7 +4744,7 @@ static void mlx5e_create_q_counters(struct mlx5e_priv *priv)
        }
 }
 
        }
 }
 
-static void mlx5e_destroy_q_counters(struct mlx5e_priv *priv)
+void mlx5e_destroy_q_counters(struct mlx5e_priv *priv)
 {
        if (priv->q_counter)
                mlx5_core_dealloc_q_counter(priv->mdev, priv->q_counter);
 {
        if (priv->q_counter)
                mlx5_core_dealloc_q_counter(priv->mdev, priv->q_counter);
@@ -4783,9 +4783,17 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
        struct mlx5_core_dev *mdev = priv->mdev;
        int err;
 
        struct mlx5_core_dev *mdev = priv->mdev;
        int err;
 
+       mlx5e_create_q_counters(priv);
+
+       err = mlx5e_open_drop_rq(priv, &priv->drop_rq);
+       if (err) {
+               mlx5_core_err(mdev, "open drop rq failed, %d\n", err);
+               goto err_destroy_q_counters;
+       }
+
        err = mlx5e_create_indirect_rqt(priv);
        if (err)
        err = mlx5e_create_indirect_rqt(priv);
        if (err)
-               return err;
+               goto err_close_drop_rq;
 
        err = mlx5e_create_direct_rqts(priv);
        if (err)
 
        err = mlx5e_create_direct_rqts(priv);
        if (err)
@@ -4821,6 +4829,10 @@ err_destroy_direct_rqts:
        mlx5e_destroy_direct_rqts(priv);
 err_destroy_indirect_rqts:
        mlx5e_destroy_rqt(priv, &priv->indir_rqt);
        mlx5e_destroy_direct_rqts(priv);
 err_destroy_indirect_rqts:
        mlx5e_destroy_rqt(priv, &priv->indir_rqt);
+err_close_drop_rq:
+       mlx5e_close_drop_rq(&priv->drop_rq);
+err_destroy_q_counters:
+       mlx5e_destroy_q_counters(priv);
        return err;
 }
 
        return err;
 }
 
@@ -4832,6 +4844,8 @@ static void mlx5e_cleanup_nic_rx(struct mlx5e_priv *priv)
        mlx5e_destroy_indirect_tirs(priv);
        mlx5e_destroy_direct_rqts(priv);
        mlx5e_destroy_rqt(priv, &priv->indir_rqt);
        mlx5e_destroy_indirect_tirs(priv);
        mlx5e_destroy_direct_rqts(priv);
        mlx5e_destroy_rqt(priv, &priv->indir_rqt);
+       mlx5e_close_drop_rq(&priv->drop_rq);
+       mlx5e_destroy_q_counters(priv);
 }
 
 static int mlx5e_init_nic_tx(struct mlx5e_priv *priv)
 }
 
 static int mlx5e_init_nic_tx(struct mlx5e_priv *priv)
@@ -4975,7 +4989,6 @@ err_cleanup_nic:
 
 int mlx5e_attach_netdev(struct mlx5e_priv *priv)
 {
 
 int mlx5e_attach_netdev(struct mlx5e_priv *priv)
 {
-       struct mlx5_core_dev *mdev = priv->mdev;
        const struct mlx5e_profile *profile;
        int err;
 
        const struct mlx5e_profile *profile;
        int err;
 
@@ -4986,28 +4999,16 @@ int mlx5e_attach_netdev(struct mlx5e_priv *priv)
        if (err)
                goto out;
 
        if (err)
                goto out;
 
-       mlx5e_create_q_counters(priv);
-
-       err = mlx5e_open_drop_rq(priv, &priv->drop_rq);
-       if (err) {
-               mlx5_core_err(mdev, "open drop rq failed, %d\n", err);
-               goto err_destroy_q_counters;
-       }
-
        err = profile->init_rx(priv);
        if (err)
        err = profile->init_rx(priv);
        if (err)
-               goto err_close_drop_rq;
+               goto err_cleanup_tx;
 
        if (profile->enable)
                profile->enable(priv);
 
        return 0;
 
 
        if (profile->enable)
                profile->enable(priv);
 
        return 0;
 
-err_close_drop_rq:
-       mlx5e_close_drop_rq(&priv->drop_rq);
-
-err_destroy_q_counters:
-       mlx5e_destroy_q_counters(priv);
+err_cleanup_tx:
        profile->cleanup_tx(priv);
 
 out:
        profile->cleanup_tx(priv);
 
 out:
@@ -5025,8 +5026,6 @@ void mlx5e_detach_netdev(struct mlx5e_priv *priv)
        flush_workqueue(priv->wq);
 
        profile->cleanup_rx(priv);
        flush_workqueue(priv->wq);
 
        profile->cleanup_rx(priv);
-       mlx5e_close_drop_rq(&priv->drop_rq);
-       mlx5e_destroy_q_counters(priv);
        profile->cleanup_tx(priv);
        cancel_delayed_work_sync(&priv->update_stats_work);
 }
        profile->cleanup_tx(priv);
        cancel_delayed_work_sync(&priv->update_stats_work);
 }
index c9cc9747d21d187810c9f93efaf0937bb9c1ebe2..f6eead24931fb17ab17159d21559dc296a1817b7 100644 (file)
@@ -999,14 +999,21 @@ static int mlx5e_init_rep_rx(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;
        struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
        struct mlx5e_rep_priv *rpriv = priv->ppriv;
        struct mlx5_eswitch_rep *rep = rpriv->rep;
+       struct mlx5_core_dev *mdev = priv->mdev;
        struct mlx5_flow_handle *flow_rule;
        int err;
 
        mlx5e_init_l2_addr(priv);
 
        struct mlx5_flow_handle *flow_rule;
        int err;
 
        mlx5e_init_l2_addr(priv);
 
+       err = mlx5e_open_drop_rq(priv, &priv->drop_rq);
+       if (err) {
+               mlx5_core_err(mdev, "open drop rq failed, %d\n", err);
+               return err;
+       }
+
        err = mlx5e_create_direct_rqts(priv);
        if (err)
        err = mlx5e_create_direct_rqts(priv);
        if (err)
-               return err;
+               goto err_close_drop_rq;
 
        err = mlx5e_create_direct_tirs(priv);
        if (err)
 
        err = mlx5e_create_direct_tirs(priv);
        if (err)
@@ -1027,6 +1034,8 @@ err_destroy_direct_tirs:
        mlx5e_destroy_direct_tirs(priv);
 err_destroy_direct_rqts:
        mlx5e_destroy_direct_rqts(priv);
        mlx5e_destroy_direct_tirs(priv);
 err_destroy_direct_rqts:
        mlx5e_destroy_direct_rqts(priv);
+err_close_drop_rq:
+       mlx5e_close_drop_rq(&priv->drop_rq);
        return err;
 }
 
        return err;
 }
 
@@ -1037,6 +1046,7 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)
        mlx5_del_flow_rules(rpriv->vport_rx_rule);
        mlx5e_destroy_direct_tirs(priv);
        mlx5e_destroy_direct_rqts(priv);
        mlx5_del_flow_rules(rpriv->vport_rx_rule);
        mlx5e_destroy_direct_tirs(priv);
        mlx5e_destroy_direct_rqts(priv);
+       mlx5e_close_drop_rq(&priv->drop_rq);
 }
 
 static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
 }
 
 static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
index 3dd9f885ed8b7b12f50691845132b51b068558ac..a825ed093efd979c95b7fb9bfc99395a7efd856b 100644 (file)
@@ -349,11 +349,20 @@ static void mlx5i_destroy_flow_steering(struct mlx5e_priv *priv)
 
 static int mlx5i_init_rx(struct mlx5e_priv *priv)
 {
 
 static int mlx5i_init_rx(struct mlx5e_priv *priv)
 {
+       struct mlx5_core_dev *mdev = priv->mdev;
        int err;
 
        int err;
 
+       mlx5e_create_q_counters(priv);
+
+       err = mlx5e_open_drop_rq(priv, &priv->drop_rq);
+       if (err) {
+               mlx5_core_err(mdev, "open drop rq failed, %d\n", err);
+               goto err_destroy_q_counters;
+       }
+
        err = mlx5e_create_indirect_rqt(priv);
        if (err)
        err = mlx5e_create_indirect_rqt(priv);
        if (err)
-               return err;
+               goto err_close_drop_rq;
 
        err = mlx5e_create_direct_rqts(priv);
        if (err)
 
        err = mlx5e_create_direct_rqts(priv);
        if (err)
@@ -381,6 +390,10 @@ err_destroy_direct_rqts:
        mlx5e_destroy_direct_rqts(priv);
 err_destroy_indirect_rqts:
        mlx5e_destroy_rqt(priv, &priv->indir_rqt);
        mlx5e_destroy_direct_rqts(priv);
 err_destroy_indirect_rqts:
        mlx5e_destroy_rqt(priv, &priv->indir_rqt);
+err_close_drop_rq:
+       mlx5e_close_drop_rq(&priv->drop_rq);
+err_destroy_q_counters:
+       mlx5e_destroy_q_counters(priv);
        return err;
 }
 
        return err;
 }
 
@@ -391,6 +404,8 @@ static void mlx5i_cleanup_rx(struct mlx5e_priv *priv)
        mlx5e_destroy_indirect_tirs(priv);
        mlx5e_destroy_direct_rqts(priv);
        mlx5e_destroy_rqt(priv, &priv->indir_rqt);
        mlx5e_destroy_indirect_tirs(priv);
        mlx5e_destroy_direct_rqts(priv);
        mlx5e_destroy_rqt(priv, &priv->indir_rqt);
+       mlx5e_close_drop_rq(&priv->drop_rq);
+       mlx5e_destroy_q_counters(priv);
 }
 
 static const struct mlx5e_profile mlx5i_nic_profile = {
 }
 
 static const struct mlx5e_profile mlx5i_nic_profile = {