]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net/mlx5e: Support per-mdev queue counter
authorTariq Toukan <tariqt@nvidia.com>
Tue, 8 Aug 2023 16:50:34 +0000 (19:50 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Thu, 21 Dec 2023 00:54:26 +0000 (16:54 -0800)
Each queue counter object counts some events (in hardware) for the RQs
that are attached to it, like events of packet drops due to no receive
WQE (rx_out_of_buffer).

Each RQ can be attached to a queue counter only within the same vhca. To
still cover all RQs with these counters, we create multiple instances,
one per vhca.

The result that's shown to the user is now the sum of all instances.

Signed-off-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/monitor_stats.c
drivers/net/ethernet/mellanox/mlx5/core/en/params.c
drivers/net/ethernet/mellanox/mlx5/core/en/params.h
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
drivers/net/ethernet/mellanox/mlx5/core/en/trap.c
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

index f6e78c465c7ab91fdc1562da0558c7ed4970103f..84db05fb938958cad2a12d49d913e131d07b934f 100644 (file)
@@ -793,6 +793,7 @@ struct mlx5e_channel {
        DECLARE_BITMAP(state, MLX5E_CHANNEL_NUM_STATES);
        int                        ix;
        int                        vec_ix;
+       int                        sd_ix;
        int                        cpu;
        /* Sync between icosq recovery and XSK enable/disable. */
        struct mutex               icosq_recovery_lock;
@@ -916,7 +917,7 @@ struct mlx5e_priv {
        bool                       tx_ptp_opened;
        bool                       rx_ptp_opened;
        struct hwtstamp_config     tstamp;
-       u16                        q_counter;
+       u16                        q_counter[MLX5_SD_MAX_GROUP_SZ];
        u16                        drop_rq_q_counter;
        struct notifier_block      events_nb;
        struct notifier_block      blocking_events_nb;
@@ -1031,12 +1032,12 @@ struct mlx5e_xsk_param;
 
 struct mlx5e_rq_param;
 int mlx5e_open_rq(struct mlx5e_params *params, struct mlx5e_rq_param *param,
-                 struct mlx5e_xsk_param *xsk, int node,
+                 struct mlx5e_xsk_param *xsk, int node, u16 q_counter,
                  struct mlx5e_rq *rq);
 #define MLX5E_RQ_WQES_TIMEOUT 20000 /* msecs */
 int mlx5e_wait_for_min_rx_wqes(struct mlx5e_rq *rq, int wait_time);
 void mlx5e_close_rq(struct mlx5e_rq *rq);
-int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param);
+int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param, u16 q_counter);
 void mlx5e_destroy_rq(struct mlx5e_rq *rq);
 
 struct mlx5e_sq_param;
index 40c8df111754fdf487a6bce1d5cce26f898d015b..e2d8d2754be0576b5b10e069773d3eed9569484b 100644 (file)
 #define NUM_REQ_PPCNT_COUNTER_S1 MLX5_CMD_SET_MONITOR_NUM_PPCNT_COUNTER_SET1
 #define NUM_REQ_Q_COUNTERS_S1    MLX5_CMD_SET_MONITOR_NUM_Q_COUNTERS_SET1
 
-int mlx5e_monitor_counter_supported(struct mlx5e_priv *priv)
+static int mlx5e_monitor_counter_cap(struct mlx5_core_dev *mdev)
 {
-       struct mlx5_core_dev *mdev = priv->mdev;
-
        if (!MLX5_CAP_GEN(mdev, max_num_of_monitor_counters))
                return false;
        if (MLX5_CAP_PCAM_REG(mdev, ppcnt) &&
@@ -36,24 +34,38 @@ int mlx5e_monitor_counter_supported(struct mlx5e_priv *priv)
        return true;
 }
 
-static void mlx5e_monitor_counter_arm(struct mlx5e_priv *priv)
+int mlx5e_monitor_counter_supported(struct mlx5e_priv *priv)
+{
+       struct mlx5_core_dev *pos;
+       int i;
+
+       mlx5_sd_for_each_dev(i, priv->mdev, pos)
+               if (!mlx5e_monitor_counter_cap(pos))
+                       return false;
+       return true;
+}
+
+static void mlx5e_monitor_counter_arm(struct mlx5_core_dev *mdev)
 {
        u32 in[MLX5_ST_SZ_DW(arm_monitor_counter_in)] = {};
 
        MLX5_SET(arm_monitor_counter_in, in, opcode,
                 MLX5_CMD_OP_ARM_MONITOR_COUNTER);
-       mlx5_cmd_exec_in(priv->mdev, arm_monitor_counter, in);
+       mlx5_cmd_exec_in(mdev, arm_monitor_counter, in);
 }
 
 static void mlx5e_monitor_counters_work(struct work_struct *work)
 {
        struct mlx5e_priv *priv = container_of(work, struct mlx5e_priv,
                                               monitor_counters_work);
+       struct mlx5_core_dev *pos;
+       int i;
 
        mutex_lock(&priv->state_lock);
        mlx5e_stats_update_ndo_stats(priv);
        mutex_unlock(&priv->state_lock);
-       mlx5e_monitor_counter_arm(priv);
+       mlx5_sd_for_each_dev(i, priv->mdev, pos)
+               mlx5e_monitor_counter_arm(pos);
 }
 
 static int mlx5e_monitor_event_handler(struct notifier_block *nb,
@@ -97,15 +109,13 @@ static int fill_monitor_counter_q_counter_set1(int cnt, int q_counter, u32 *in)
 }
 
 /* check if mlx5e_monitor_counter_supported before calling this function*/
-static void mlx5e_set_monitor_counter(struct mlx5e_priv *priv)
+static void mlx5e_set_monitor_counter(struct mlx5_core_dev *mdev, int q_counter)
 {
-       struct mlx5_core_dev *mdev = priv->mdev;
        int max_num_of_counters = MLX5_CAP_GEN(mdev, max_num_of_monitor_counters);
        int num_q_counters      = MLX5_CAP_GEN(mdev, num_q_monitor_counters);
        int num_ppcnt_counters  = !MLX5_CAP_PCAM_REG(mdev, ppcnt) ? 0 :
                                  MLX5_CAP_GEN(mdev, num_ppcnt_monitor_counters);
        u32 in[MLX5_ST_SZ_DW(set_monitor_counter_in)] = {};
-       int q_counter = priv->q_counter;
        int cnt = 0;
 
        if (num_ppcnt_counters  >=  NUM_REQ_PPCNT_COUNTER_S1 &&
@@ -127,13 +137,17 @@ static void mlx5e_set_monitor_counter(struct mlx5e_priv *priv)
 /* check if mlx5e_monitor_counter_supported before calling this function*/
 void mlx5e_monitor_counter_init(struct mlx5e_priv *priv)
 {
+       struct mlx5_core_dev *pos;
+       int i;
+
        INIT_WORK(&priv->monitor_counters_work, mlx5e_monitor_counters_work);
        MLX5_NB_INIT(&priv->monitor_counters_nb, mlx5e_monitor_event_handler,
                     MONITOR_COUNTER);
-       mlx5_eq_notifier_register(priv->mdev, &priv->monitor_counters_nb);
-
-       mlx5e_set_monitor_counter(priv);
-       mlx5e_monitor_counter_arm(priv);
+       mlx5_sd_for_each_dev(i, priv->mdev, pos) {
+               mlx5_eq_notifier_register(pos, &priv->monitor_counters_nb);
+               mlx5e_set_monitor_counter(pos, priv->q_counter[i]);
+               mlx5e_monitor_counter_arm(pos);
+       }
        queue_work(priv->wq, &priv->update_stats_work);
 }
 
@@ -141,11 +155,15 @@ void mlx5e_monitor_counter_init(struct mlx5e_priv *priv)
 void mlx5e_monitor_counter_cleanup(struct mlx5e_priv *priv)
 {
        u32 in[MLX5_ST_SZ_DW(set_monitor_counter_in)] = {};
+       struct mlx5_core_dev *pos;
+       int i;
 
        MLX5_SET(set_monitor_counter_in, in, opcode,
                 MLX5_CMD_OP_SET_MONITOR_COUNTER);
 
-       mlx5_cmd_exec_in(priv->mdev, set_monitor_counter, in);
-       mlx5_eq_notifier_unregister(priv->mdev, &priv->monitor_counters_nb);
+       mlx5_sd_for_each_dev(i, priv->mdev, pos) {
+               mlx5_cmd_exec_in(pos, set_monitor_counter, in);
+               mlx5_eq_notifier_unregister(pos, &priv->monitor_counters_nb);
+       }
        cancel_work_sync(&priv->monitor_counters_work);
 }
index 18f0cedc8610cb79e6fb933165e13441922edb5d..fb10bb166fbbdffbdd1a4536205d2c918c0983df 100644 (file)
@@ -945,7 +945,6 @@ static u8 rq_end_pad_mode(struct mlx5_core_dev *mdev, struct mlx5e_params *param
 int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
                         struct mlx5e_params *params,
                         struct mlx5e_xsk_param *xsk,
-                        u16 q_counter,
                         struct mlx5e_rq_param *param)
 {
        void *rqc = param->rqc;
@@ -1007,7 +1006,6 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
        MLX5_SET(wq, wq, log_wq_stride,
                 mlx5e_get_rqwq_log_stride(params->rq_wq_type, ndsegs));
        MLX5_SET(wq, wq, pd,               mdev->mlx5e_res.hw_objs.pdn);
-       MLX5_SET(rqc, rqc, counter_set_id, q_counter);
        MLX5_SET(rqc, rqc, vsd,            params->vlan_strip_disable);
        MLX5_SET(rqc, rqc, scatter_fcs,    params->scatter_fcs_en);
 
@@ -1018,7 +1016,6 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
 }
 
 void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev,
-                              u16 q_counter,
                               struct mlx5e_rq_param *param)
 {
        void *rqc = param->rqc;
@@ -1027,7 +1024,6 @@ void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev,
        MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_CYCLIC);
        MLX5_SET(wq, wq, log_wq_stride,
                 mlx5e_get_rqwq_log_stride(MLX5_WQ_TYPE_CYCLIC, 1));
-       MLX5_SET(rqc, rqc, counter_set_id, q_counter);
 
        param->wq.buf_numa_node = dev_to_node(mlx5_core_dma_dev(mdev));
 }
@@ -1292,13 +1288,12 @@ void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev,
 
 int mlx5e_build_channel_param(struct mlx5_core_dev *mdev,
                              struct mlx5e_params *params,
-                             u16 q_counter,
                              struct mlx5e_channel_param *cparam)
 {
        u8 icosq_log_wq_sz, async_icosq_log_wq_sz;
        int err;
 
-       err = mlx5e_build_rq_param(mdev, params, NULL, q_counter, &cparam->rq);
+       err = mlx5e_build_rq_param(mdev, params, NULL, &cparam->rq);
        if (err)
                return err;
 
index 6800949dafbc99b0b530ec9d8dcda89179dd1e1e..9a781f18b57fc8f0014eeeeeaf2d26d7633657e1 100644 (file)
@@ -130,10 +130,8 @@ void mlx5e_build_create_cq_param(struct mlx5e_create_cq_param *ccp, struct mlx5e
 int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
                         struct mlx5e_params *params,
                         struct mlx5e_xsk_param *xsk,
-                        u16 q_counter,
                         struct mlx5e_rq_param *param);
 void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev,
-                              u16 q_counter,
                               struct mlx5e_rq_param *param);
 void mlx5e_build_sq_param_common(struct mlx5_core_dev *mdev,
                                 struct mlx5e_sq_param *param);
@@ -149,7 +147,6 @@ void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev,
                             struct mlx5e_sq_param *param);
 int mlx5e_build_channel_param(struct mlx5_core_dev *mdev,
                              struct mlx5e_params *params,
-                             u16 q_counter,
                              struct mlx5e_channel_param *cparam);
 
 u16 mlx5e_calc_sq_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
index c206cc0a84832e6ebf104cc92990c43a81e94d60..cafb41895f9437a9d25b7f0132b749392721061f 100644 (file)
@@ -646,7 +646,6 @@ static void mlx5e_ptp_build_sq_param(struct mlx5_core_dev *mdev,
 
 static void mlx5e_ptp_build_rq_param(struct mlx5_core_dev *mdev,
                                     struct net_device *netdev,
-                                    u16 q_counter,
                                     struct mlx5e_ptp_params *ptp_params)
 {
        struct mlx5e_rq_param *rq_params = &ptp_params->rq_param;
@@ -655,7 +654,7 @@ static void mlx5e_ptp_build_rq_param(struct mlx5_core_dev *mdev,
        params->rq_wq_type = MLX5_WQ_TYPE_CYCLIC;
        mlx5e_init_rq_type_params(mdev, params);
        params->sw_mtu = netdev->max_mtu;
-       mlx5e_build_rq_param(mdev, params, NULL, q_counter, rq_params);
+       mlx5e_build_rq_param(mdev, params, NULL, rq_params);
 }
 
 static void mlx5e_ptp_build_params(struct mlx5e_ptp *c,
@@ -681,7 +680,7 @@ static void mlx5e_ptp_build_params(struct mlx5e_ptp *c,
        /* RQ */
        if (test_bit(MLX5E_PTP_STATE_RX, c->state)) {
                params->vlan_strip_disable = orig->vlan_strip_disable;
-               mlx5e_ptp_build_rq_param(c->mdev, c->netdev, c->priv->q_counter, cparams);
+               mlx5e_ptp_build_rq_param(c->mdev, c->netdev, cparams);
        }
 }
 
@@ -714,13 +713,16 @@ static int mlx5e_ptp_open_rq(struct mlx5e_ptp *c, struct mlx5e_params *params,
                             struct mlx5e_rq_param *rq_param)
 {
        int node = dev_to_node(c->mdev->device);
-       int err;
+       int err, sd_ix;
+       u16 q_counter;
 
        err = mlx5e_init_ptp_rq(c, params, &c->rq);
        if (err)
                return err;
 
-       return mlx5e_open_rq(params, rq_param, NULL, node, &c->rq);
+       sd_ix = mlx5_sd_ch_ix_get_dev_ix(c->mdev, MLX5E_PTP_CHANNEL_IX);
+       q_counter = c->priv->q_counter[sd_ix];
+       return mlx5e_open_rq(params, rq_param, NULL, node, q_counter, &c->rq);
 }
 
 static int mlx5e_ptp_open_queues(struct mlx5e_ptp *c,
index ac458a8d10e0f127e52cfdfac600912985c4a485..53ca16cb9c41a82cba927143794ddb70809d5f24 100644 (file)
@@ -63,10 +63,12 @@ static int mlx5e_open_trap_rq(struct mlx5e_priv *priv, struct mlx5e_trap *t)
        struct mlx5e_create_cq_param ccp = {};
        struct dim_cq_moder trap_moder = {};
        struct mlx5e_rq *rq = &t->rq;
+       u16 q_counter;
        int node;
        int err;
 
        node = dev_to_node(mdev->device);
+       q_counter = priv->q_counter[0];
 
        ccp.netdev   = priv->netdev;
        ccp.wq       = priv->wq;
@@ -79,7 +81,7 @@ static int mlx5e_open_trap_rq(struct mlx5e_priv *priv, struct mlx5e_trap *t)
                return err;
 
        mlx5e_init_trap_rq(t, &t->params, rq);
-       err = mlx5e_open_rq(&t->params, rq_param, NULL, node, rq);
+       err = mlx5e_open_rq(&t->params, rq_param, NULL, node, q_counter, rq);
        if (err)
                goto err_destroy_cq;
 
@@ -116,15 +118,14 @@ static int mlx5e_create_trap_direct_rq_tir(struct mlx5_core_dev *mdev, struct ml
 }
 
 static void mlx5e_build_trap_params(struct mlx5_core_dev *mdev,
-                                   int max_mtu, u16 q_counter,
-                                   struct mlx5e_trap *t)
+                                   int max_mtu, struct mlx5e_trap *t)
 {
        struct mlx5e_params *params = &t->params;
 
        params->rq_wq_type = MLX5_WQ_TYPE_CYCLIC;
        mlx5e_init_rq_type_params(mdev, params);
        params->sw_mtu = max_mtu;
-       mlx5e_build_rq_param(mdev, params, NULL, q_counter, &t->rq_param);
+       mlx5e_build_rq_param(mdev, params, NULL, &t->rq_param);
 }
 
 static struct mlx5e_trap *mlx5e_open_trap(struct mlx5e_priv *priv)
@@ -138,7 +139,7 @@ static struct mlx5e_trap *mlx5e_open_trap(struct mlx5e_priv *priv)
        if (!t)
                return ERR_PTR(-ENOMEM);
 
-       mlx5e_build_trap_params(priv->mdev, netdev->max_mtu, priv->q_counter, t);
+       mlx5e_build_trap_params(priv->mdev, netdev->max_mtu, t);
 
        t->priv     = priv;
        t->mdev     = priv->mdev;
index 82e6abbc173423d436b268bebe168400f14eaeba..06592b9f04242c9b940c9b8c29eb3363d74bb57b 100644 (file)
@@ -49,10 +49,9 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params,
 static void mlx5e_build_xsk_cparam(struct mlx5_core_dev *mdev,
                                   struct mlx5e_params *params,
                                   struct mlx5e_xsk_param *xsk,
-                                  u16 q_counter,
                                   struct mlx5e_channel_param *cparam)
 {
-       mlx5e_build_rq_param(mdev, params, xsk, q_counter, &cparam->rq);
+       mlx5e_build_rq_param(mdev, params, xsk, &cparam->rq);
        mlx5e_build_xdpsq_param(mdev, params, xsk, &cparam->xdp_sq);
 }
 
@@ -93,6 +92,7 @@ static int mlx5e_open_xsk_rq(struct mlx5e_channel *c, struct mlx5e_params *param
                             struct mlx5e_rq_param *rq_params, struct xsk_buff_pool *pool,
                             struct mlx5e_xsk_param *xsk)
 {
+       u16 q_counter = c->priv->q_counter[c->sd_ix];
        struct mlx5e_rq *xskrq = &c->xskrq;
        int err;
 
@@ -100,7 +100,7 @@ static int mlx5e_open_xsk_rq(struct mlx5e_channel *c, struct mlx5e_params *param
        if (err)
                return err;
 
-       err = mlx5e_open_rq(params, rq_params, xsk, cpu_to_node(c->cpu), xskrq);
+       err = mlx5e_open_rq(params, rq_params, xsk, cpu_to_node(c->cpu), q_counter, xskrq);
        if (err)
                return err;
 
@@ -125,7 +125,7 @@ int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,
        if (!cparam)
                return -ENOMEM;
 
-       mlx5e_build_xsk_cparam(priv->mdev, params, xsk, priv->q_counter, cparam);
+       mlx5e_build_xsk_cparam(priv->mdev, params, xsk, cparam);
 
        err = mlx5e_open_cq(c->mdev, params->rx_cq_moderation, &cparam->rq.cqp, &ccp,
                            &c->xskrq.cq);
index d707d45ca074b65dc4853991f2224a9e2b375194..b8f08d64f66b0f1738b2dea90c2aa69171304c4f 100644 (file)
@@ -1025,7 +1025,7 @@ static void mlx5e_free_rq(struct mlx5e_rq *rq)
        mlx5_wq_destroy(&rq->wq_ctrl);
 }
 
-int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param)
+int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param, u16 q_counter)
 {
        struct mlx5_core_dev *mdev = rq->mdev;
        u8 ts_format;
@@ -1052,6 +1052,7 @@ int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param)
        MLX5_SET(rqc,  rqc, cqn,                rq->cq.mcq.cqn);
        MLX5_SET(rqc,  rqc, state,              MLX5_RQC_STATE_RST);
        MLX5_SET(rqc,  rqc, ts_format,          ts_format);
+       MLX5_SET(rqc,  rqc, counter_set_id,     q_counter);
        MLX5_SET(wq,   wq,  log_wq_pg_sz,       rq->wq_ctrl.buf.page_shift -
                                                MLX5_ADAPTER_PAGE_SHIFT);
        MLX5_SET64(wq, wq,  dbr_addr,           rq->wq_ctrl.db.dma);
@@ -1275,7 +1276,7 @@ void mlx5e_free_rx_descs(struct mlx5e_rq *rq)
 }
 
 int mlx5e_open_rq(struct mlx5e_params *params, struct mlx5e_rq_param *param,
-                 struct mlx5e_xsk_param *xsk, int node,
+                 struct mlx5e_xsk_param *xsk, int node, u16 q_counter,
                  struct mlx5e_rq *rq)
 {
        struct mlx5_core_dev *mdev = rq->mdev;
@@ -1288,7 +1289,7 @@ int mlx5e_open_rq(struct mlx5e_params *params, struct mlx5e_rq_param *param,
        if (err)
                return err;
 
-       err = mlx5e_create_rq(rq, param);
+       err = mlx5e_create_rq(rq, param, q_counter);
        if (err)
                goto err_free_rq;
 
@@ -2334,13 +2335,14 @@ static int mlx5e_set_tx_maxrate(struct net_device *dev, int index, u32 rate)
 static int mlx5e_open_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *params,
                             struct mlx5e_rq_param *rq_params)
 {
+       u16 q_counter = c->priv->q_counter[c->sd_ix];
        int err;
 
        err = mlx5e_init_rxq_rq(c, params, rq_params->xdp_frag_size, &c->rq);
        if (err)
                return err;
 
-       return mlx5e_open_rq(params, rq_params, NULL, cpu_to_node(c->cpu), &c->rq);
+       return mlx5e_open_rq(params, rq_params, NULL, cpu_to_node(c->cpu), q_counter, &c->rq);
 }
 
 static int mlx5e_open_queues(struct mlx5e_channel *c,
@@ -2557,6 +2559,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
        c->tstamp   = &priv->tstamp;
        c->ix       = ix;
        c->vec_ix   = vec_ix;
+       c->sd_ix    = mlx5_sd_ch_ix_get_dev_ix(mdev, ix);
        c->cpu      = cpu;
        c->pdev     = mlx5_core_dma_dev(mdev);
        c->netdev   = priv->netdev;
@@ -2655,7 +2658,7 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
        if (!chs->c || !cparam)
                goto err_free;
 
-       err = mlx5e_build_channel_param(priv->mdev, &chs->params, priv->q_counter, cparam);
+       err = mlx5e_build_channel_param(priv->mdev, &chs->params, cparam);
        if (err)
                goto err_free;
 
@@ -3346,7 +3349,7 @@ int mlx5e_open_drop_rq(struct mlx5e_priv *priv,
        struct mlx5e_cq *cq = &drop_rq->cq;
        int err;
 
-       mlx5e_build_drop_rq_param(mdev, priv->drop_rq_q_counter, &rq_param);
+       mlx5e_build_drop_rq_param(mdev, &rq_param);
 
        err = mlx5e_alloc_drop_cq(priv, cq, &cq_param);
        if (err)
@@ -3360,7 +3363,7 @@ int mlx5e_open_drop_rq(struct mlx5e_priv *priv,
        if (err)
                goto err_destroy_cq;
 
-       err = mlx5e_create_rq(drop_rq, &rq_param);
+       err = mlx5e_create_rq(drop_rq, &rq_param, priv->drop_rq_q_counter);
        if (err)
                goto err_free_rq;
 
@@ -5275,13 +5278,17 @@ void mlx5e_create_q_counters(struct mlx5e_priv *priv)
        u32 out[MLX5_ST_SZ_DW(alloc_q_counter_out)] = {};
        u32 in[MLX5_ST_SZ_DW(alloc_q_counter_in)] = {};
        struct mlx5_core_dev *mdev = priv->mdev;
-       int err;
+       struct mlx5_core_dev *pos;
+       int err, i;
 
        MLX5_SET(alloc_q_counter_in, in, opcode, MLX5_CMD_OP_ALLOC_Q_COUNTER);
-       err = mlx5_cmd_exec_inout(mdev, alloc_q_counter, in, out);
-       if (!err)
-               priv->q_counter =
-                       MLX5_GET(alloc_q_counter_out, out, counter_set_id);
+
+       mlx5_sd_for_each_dev(i, mdev, pos) {
+               err = mlx5_cmd_exec_inout(pos, alloc_q_counter, in, out);
+               if (!err)
+                       priv->q_counter[i] =
+                               MLX5_GET(alloc_q_counter_out, out, counter_set_id);
+       }
 
        err = mlx5_cmd_exec_inout(mdev, alloc_q_counter, in, out);
        if (!err)
@@ -5292,13 +5299,17 @@ void mlx5e_create_q_counters(struct mlx5e_priv *priv)
 void mlx5e_destroy_q_counters(struct mlx5e_priv *priv)
 {
        u32 in[MLX5_ST_SZ_DW(dealloc_q_counter_in)] = {};
+       struct mlx5_core_dev *pos;
+       int i;
 
        MLX5_SET(dealloc_q_counter_in, in, opcode,
                 MLX5_CMD_OP_DEALLOC_Q_COUNTER);
-       if (priv->q_counter) {
-               MLX5_SET(dealloc_q_counter_in, in, counter_set_id,
-                        priv->q_counter);
-               mlx5_cmd_exec_in(priv->mdev, dealloc_q_counter, in);
+       mlx5_sd_for_each_dev(i, priv->mdev, pos) {
+               if (priv->q_counter[i]) {
+                       MLX5_SET(dealloc_q_counter_in, in, counter_set_id,
+                                priv->q_counter[i]);
+                       mlx5_cmd_exec_in(pos, dealloc_q_counter, in);
+               }
        }
 
        if (priv->drop_rq_q_counter) {
index 4b96ad657145b8dac0492d9c2a76241ae9b11bbb..f3d0898bdbc6e28b67db27e860354e0f1b7ba404 100644 (file)
@@ -561,11 +561,23 @@ static const struct counter_desc drop_rq_stats_desc[] = {
 #define NUM_Q_COUNTERS                 ARRAY_SIZE(q_stats_desc)
 #define NUM_DROP_RQ_COUNTERS           ARRAY_SIZE(drop_rq_stats_desc)
 
+static bool q_counter_any(struct mlx5e_priv *priv)
+{
+       struct mlx5_core_dev *pos;
+       int i;
+
+       mlx5_sd_for_each_dev(i, priv->mdev, pos)
+               if (priv->q_counter[i++])
+                       return true;
+
+       return false;
+}
+
 static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(qcnt)
 {
        int num_stats = 0;
 
-       if (priv->q_counter)
+       if (q_counter_any(priv))
                num_stats += NUM_Q_COUNTERS;
 
        if (priv->drop_rq_q_counter)
@@ -578,7 +590,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(qcnt)
 {
        int i;
 
-       for (i = 0; i < NUM_Q_COUNTERS && priv->q_counter; i++)
+       for (i = 0; i < NUM_Q_COUNTERS && q_counter_any(priv); i++)
                strcpy(data + (idx++) * ETH_GSTRING_LEN,
                       q_stats_desc[i].format);
 
@@ -593,7 +605,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(qcnt)
 {
        int i;
 
-       for (i = 0; i < NUM_Q_COUNTERS && priv->q_counter; i++)
+       for (i = 0; i < NUM_Q_COUNTERS && q_counter_any(priv); i++)
                data[idx++] = MLX5E_READ_CTR32_CPU(&priv->stats.qcnt,
                                                   q_stats_desc, i);
        for (i = 0; i < NUM_DROP_RQ_COUNTERS && priv->drop_rq_q_counter; i++)
@@ -607,18 +619,23 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(qcnt)
        struct mlx5e_qcounter_stats *qcnt = &priv->stats.qcnt;
        u32 out[MLX5_ST_SZ_DW(query_q_counter_out)] = {};
        u32 in[MLX5_ST_SZ_DW(query_q_counter_in)] = {};
-       int ret;
+       struct mlx5_core_dev *pos;
+       u32 rx_out_of_buffer = 0;
+       int ret, i;
 
        MLX5_SET(query_q_counter_in, in, opcode, MLX5_CMD_OP_QUERY_Q_COUNTER);
 
-       if (priv->q_counter) {
-               MLX5_SET(query_q_counter_in, in, counter_set_id,
-                        priv->q_counter);
-               ret = mlx5_cmd_exec_inout(priv->mdev, query_q_counter, in, out);
-               if (!ret)
-                       qcnt->rx_out_of_buffer = MLX5_GET(query_q_counter_out,
-                                                         out, out_of_buffer);
+       mlx5_sd_for_each_dev(i, priv->mdev, pos) {
+               if (priv->q_counter[i]) {
+                       MLX5_SET(query_q_counter_in, in, counter_set_id,
+                                priv->q_counter[i]);
+                       ret = mlx5_cmd_exec_inout(pos, query_q_counter, in, out);
+                       if (!ret)
+                               rx_out_of_buffer += MLX5_GET(query_q_counter_out,
+                                                            out, out_of_buffer);
+               }
        }
+       qcnt->rx_out_of_buffer = rx_out_of_buffer;
 
        if (priv->drop_rq_q_counter) {
                MLX5_SET(query_q_counter_in, in, counter_set_id,
index 6590443d6f2eb5c80f8e7a1076e4da97af986d90..ebcf40fb671d06178fe5d06f1db1cf57bec67d53 100644 (file)
@@ -1169,7 +1169,7 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv,
                        MLX5_CAP_GEN(priv->mdev, log_min_hairpin_wq_data_sz),
                        MLX5_CAP_GEN(priv->mdev, log_max_hairpin_wq_data_sz));
 
-       params.q_counter = priv->q_counter;
+       params.q_counter = priv->q_counter[0];
        err = devl_param_driverinit_value_get(
                devlink, MLX5_DEVLINK_PARAM_ID_HAIRPIN_NUM_QUEUES, &val);
        if (err) {