Skip to content

Commit 7f525ac

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5e: Support per-mdev queue counter
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 <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 40e6ad9 commit 7f525ac

File tree

10 files changed

+111
-69
lines changed

10 files changed

+111
-69
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ struct mlx5e_channel {
793793
DECLARE_BITMAP(state, MLX5E_CHANNEL_NUM_STATES);
794794
int ix;
795795
int vec_ix;
796+
int sd_ix;
796797
int cpu;
797798
/* Sync between icosq recovery and XSK enable/disable. */
798799
struct mutex icosq_recovery_lock;
@@ -916,7 +917,7 @@ struct mlx5e_priv {
916917
bool tx_ptp_opened;
917918
bool rx_ptp_opened;
918919
struct hwtstamp_config tstamp;
919-
u16 q_counter;
920+
u16 q_counter[MLX5_SD_MAX_GROUP_SZ];
920921
u16 drop_rq_q_counter;
921922
struct notifier_block events_nb;
922923
struct notifier_block blocking_events_nb;
@@ -1031,12 +1032,12 @@ struct mlx5e_xsk_param;
10311032

10321033
struct mlx5e_rq_param;
10331034
int mlx5e_open_rq(struct mlx5e_params *params, struct mlx5e_rq_param *param,
1034-
struct mlx5e_xsk_param *xsk, int node,
1035+
struct mlx5e_xsk_param *xsk, int node, u16 q_counter,
10351036
struct mlx5e_rq *rq);
10361037
#define MLX5E_RQ_WQES_TIMEOUT 20000 /* msecs */
10371038
int mlx5e_wait_for_min_rx_wqes(struct mlx5e_rq *rq, int wait_time);
10381039
void mlx5e_close_rq(struct mlx5e_rq *rq);
1039-
int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param);
1040+
int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param, u16 q_counter);
10401041
void mlx5e_destroy_rq(struct mlx5e_rq *rq);
10411042

10421043
struct mlx5e_sq_param;

drivers/net/ethernet/mellanox/mlx5/core/en/monitor_stats.c

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020
#define NUM_REQ_PPCNT_COUNTER_S1 MLX5_CMD_SET_MONITOR_NUM_PPCNT_COUNTER_SET1
2121
#define NUM_REQ_Q_COUNTERS_S1 MLX5_CMD_SET_MONITOR_NUM_Q_COUNTERS_SET1
2222

23-
int mlx5e_monitor_counter_supported(struct mlx5e_priv *priv)
23+
static int mlx5e_monitor_counter_cap(struct mlx5_core_dev *mdev)
2424
{
25-
struct mlx5_core_dev *mdev = priv->mdev;
26-
2725
if (!MLX5_CAP_GEN(mdev, max_num_of_monitor_counters))
2826
return false;
2927
if (MLX5_CAP_PCAM_REG(mdev, ppcnt) &&
@@ -36,24 +34,38 @@ int mlx5e_monitor_counter_supported(struct mlx5e_priv *priv)
3634
return true;
3735
}
3836

39-
static void mlx5e_monitor_counter_arm(struct mlx5e_priv *priv)
37+
int mlx5e_monitor_counter_supported(struct mlx5e_priv *priv)
38+
{
39+
struct mlx5_core_dev *pos;
40+
int i;
41+
42+
mlx5_sd_for_each_dev(i, priv->mdev, pos)
43+
if (!mlx5e_monitor_counter_cap(pos))
44+
return false;
45+
return true;
46+
}
47+
48+
static void mlx5e_monitor_counter_arm(struct mlx5_core_dev *mdev)
4049
{
4150
u32 in[MLX5_ST_SZ_DW(arm_monitor_counter_in)] = {};
4251

4352
MLX5_SET(arm_monitor_counter_in, in, opcode,
4453
MLX5_CMD_OP_ARM_MONITOR_COUNTER);
45-
mlx5_cmd_exec_in(priv->mdev, arm_monitor_counter, in);
54+
mlx5_cmd_exec_in(mdev, arm_monitor_counter, in);
4655
}
4756

4857
static void mlx5e_monitor_counters_work(struct work_struct *work)
4958
{
5059
struct mlx5e_priv *priv = container_of(work, struct mlx5e_priv,
5160
monitor_counters_work);
61+
struct mlx5_core_dev *pos;
62+
int i;
5263

5364
mutex_lock(&priv->state_lock);
5465
mlx5e_stats_update_ndo_stats(priv);
5566
mutex_unlock(&priv->state_lock);
56-
mlx5e_monitor_counter_arm(priv);
67+
mlx5_sd_for_each_dev(i, priv->mdev, pos)
68+
mlx5e_monitor_counter_arm(pos);
5769
}
5870

5971
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)
97109
}
98110

99111
/* check if mlx5e_monitor_counter_supported before calling this function*/
100-
static void mlx5e_set_monitor_counter(struct mlx5e_priv *priv)
112+
static void mlx5e_set_monitor_counter(struct mlx5_core_dev *mdev, int q_counter)
101113
{
102-
struct mlx5_core_dev *mdev = priv->mdev;
103114
int max_num_of_counters = MLX5_CAP_GEN(mdev, max_num_of_monitor_counters);
104115
int num_q_counters = MLX5_CAP_GEN(mdev, num_q_monitor_counters);
105116
int num_ppcnt_counters = !MLX5_CAP_PCAM_REG(mdev, ppcnt) ? 0 :
106117
MLX5_CAP_GEN(mdev, num_ppcnt_monitor_counters);
107118
u32 in[MLX5_ST_SZ_DW(set_monitor_counter_in)] = {};
108-
int q_counter = priv->q_counter;
109119
int cnt = 0;
110120

111121
if (num_ppcnt_counters >= NUM_REQ_PPCNT_COUNTER_S1 &&
@@ -127,25 +137,33 @@ static void mlx5e_set_monitor_counter(struct mlx5e_priv *priv)
127137
/* check if mlx5e_monitor_counter_supported before calling this function*/
128138
void mlx5e_monitor_counter_init(struct mlx5e_priv *priv)
129139
{
140+
struct mlx5_core_dev *pos;
141+
int i;
142+
130143
INIT_WORK(&priv->monitor_counters_work, mlx5e_monitor_counters_work);
131144
MLX5_NB_INIT(&priv->monitor_counters_nb, mlx5e_monitor_event_handler,
132145
MONITOR_COUNTER);
133-
mlx5_eq_notifier_register(priv->mdev, &priv->monitor_counters_nb);
134-
135-
mlx5e_set_monitor_counter(priv);
136-
mlx5e_monitor_counter_arm(priv);
146+
mlx5_sd_for_each_dev(i, priv->mdev, pos) {
147+
mlx5_eq_notifier_register(pos, &priv->monitor_counters_nb);
148+
mlx5e_set_monitor_counter(pos, priv->q_counter[i]);
149+
mlx5e_monitor_counter_arm(pos);
150+
}
137151
queue_work(priv->wq, &priv->update_stats_work);
138152
}
139153

140154
/* check if mlx5e_monitor_counter_supported before calling this function*/
141155
void mlx5e_monitor_counter_cleanup(struct mlx5e_priv *priv)
142156
{
143157
u32 in[MLX5_ST_SZ_DW(set_monitor_counter_in)] = {};
158+
struct mlx5_core_dev *pos;
159+
int i;
144160

145161
MLX5_SET(set_monitor_counter_in, in, opcode,
146162
MLX5_CMD_OP_SET_MONITOR_COUNTER);
147163

148-
mlx5_cmd_exec_in(priv->mdev, set_monitor_counter, in);
149-
mlx5_eq_notifier_unregister(priv->mdev, &priv->monitor_counters_nb);
164+
mlx5_sd_for_each_dev(i, priv->mdev, pos) {
165+
mlx5_cmd_exec_in(pos, set_monitor_counter, in);
166+
mlx5_eq_notifier_unregister(pos, &priv->monitor_counters_nb);
167+
}
150168
cancel_work_sync(&priv->monitor_counters_work);
151169
}

drivers/net/ethernet/mellanox/mlx5/core/en/params.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,6 @@ static u8 rq_end_pad_mode(struct mlx5_core_dev *mdev, struct mlx5e_params *param
959959
int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
960960
struct mlx5e_params *params,
961961
struct mlx5e_xsk_param *xsk,
962-
u16 q_counter,
963962
struct mlx5e_rq_param *param)
964963
{
965964
void *rqc = param->rqc;
@@ -1021,7 +1020,6 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
10211020
MLX5_SET(wq, wq, log_wq_stride,
10221021
mlx5e_get_rqwq_log_stride(params->rq_wq_type, ndsegs));
10231022
MLX5_SET(wq, wq, pd, mdev->mlx5e_res.hw_objs.pdn);
1024-
MLX5_SET(rqc, rqc, counter_set_id, q_counter);
10251023
MLX5_SET(rqc, rqc, vsd, params->vlan_strip_disable);
10261024
MLX5_SET(rqc, rqc, scatter_fcs, params->scatter_fcs_en);
10271025

@@ -1032,7 +1030,6 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
10321030
}
10331031

10341032
void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev,
1035-
u16 q_counter,
10361033
struct mlx5e_rq_param *param)
10371034
{
10381035
void *rqc = param->rqc;
@@ -1041,7 +1038,6 @@ void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev,
10411038
MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_CYCLIC);
10421039
MLX5_SET(wq, wq, log_wq_stride,
10431040
mlx5e_get_rqwq_log_stride(MLX5_WQ_TYPE_CYCLIC, 1));
1044-
MLX5_SET(rqc, rqc, counter_set_id, q_counter);
10451041

10461042
param->wq.buf_numa_node = dev_to_node(mlx5_core_dma_dev(mdev));
10471043
}
@@ -1306,13 +1302,12 @@ void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev,
13061302

13071303
int mlx5e_build_channel_param(struct mlx5_core_dev *mdev,
13081304
struct mlx5e_params *params,
1309-
u16 q_counter,
13101305
struct mlx5e_channel_param *cparam)
13111306
{
13121307
u8 icosq_log_wq_sz, async_icosq_log_wq_sz;
13131308
int err;
13141309

1315-
err = mlx5e_build_rq_param(mdev, params, NULL, q_counter, &cparam->rq);
1310+
err = mlx5e_build_rq_param(mdev, params, NULL, &cparam->rq);
13161311
if (err)
13171312
return err;
13181313

drivers/net/ethernet/mellanox/mlx5/core/en/params.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ void mlx5e_build_create_cq_param(struct mlx5e_create_cq_param *ccp, struct mlx5e
130130
int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
131131
struct mlx5e_params *params,
132132
struct mlx5e_xsk_param *xsk,
133-
u16 q_counter,
134133
struct mlx5e_rq_param *param);
135134
void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev,
136-
u16 q_counter,
137135
struct mlx5e_rq_param *param);
138136
void mlx5e_build_sq_param_common(struct mlx5_core_dev *mdev,
139137
struct mlx5e_sq_param *param);
@@ -149,7 +147,6 @@ void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev,
149147
struct mlx5e_sq_param *param);
150148
int mlx5e_build_channel_param(struct mlx5_core_dev *mdev,
151149
struct mlx5e_params *params,
152-
u16 q_counter,
153150
struct mlx5e_channel_param *cparam);
154151

155152
u16 mlx5e_calc_sq_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params);

drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,6 @@ static void mlx5e_ptp_build_sq_param(struct mlx5_core_dev *mdev,
646646

647647
static void mlx5e_ptp_build_rq_param(struct mlx5_core_dev *mdev,
648648
struct net_device *netdev,
649-
u16 q_counter,
650649
struct mlx5e_ptp_params *ptp_params)
651650
{
652651
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,
655654
params->rq_wq_type = MLX5_WQ_TYPE_CYCLIC;
656655
mlx5e_init_rq_type_params(mdev, params);
657656
params->sw_mtu = netdev->max_mtu;
658-
mlx5e_build_rq_param(mdev, params, NULL, q_counter, rq_params);
657+
mlx5e_build_rq_param(mdev, params, NULL, rq_params);
659658
}
660659

661660
static void mlx5e_ptp_build_params(struct mlx5e_ptp *c,
@@ -681,7 +680,7 @@ static void mlx5e_ptp_build_params(struct mlx5e_ptp *c,
681680
/* RQ */
682681
if (test_bit(MLX5E_PTP_STATE_RX, c->state)) {
683682
params->vlan_strip_disable = orig->vlan_strip_disable;
684-
mlx5e_ptp_build_rq_param(c->mdev, c->netdev, c->priv->q_counter, cparams);
683+
mlx5e_ptp_build_rq_param(c->mdev, c->netdev, cparams);
685684
}
686685
}
687686

@@ -714,13 +713,16 @@ static int mlx5e_ptp_open_rq(struct mlx5e_ptp *c, struct mlx5e_params *params,
714713
struct mlx5e_rq_param *rq_param)
715714
{
716715
int node = dev_to_node(c->mdev->device);
717-
int err;
716+
int err, sd_ix;
717+
u16 q_counter;
718718

719719
err = mlx5e_init_ptp_rq(c, params, &c->rq);
720720
if (err)
721721
return err;
722722

723-
return mlx5e_open_rq(params, rq_param, NULL, node, &c->rq);
723+
sd_ix = mlx5_sd_ch_ix_get_dev_ix(c->mdev, MLX5E_PTP_CHANNEL_IX);
724+
q_counter = c->priv->q_counter[sd_ix];
725+
return mlx5e_open_rq(params, rq_param, NULL, node, q_counter, &c->rq);
724726
}
725727

726728
static int mlx5e_ptp_open_queues(struct mlx5e_ptp *c,

drivers/net/ethernet/mellanox/mlx5/core/en/trap.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ static int mlx5e_open_trap_rq(struct mlx5e_priv *priv, struct mlx5e_trap *t)
6363
struct mlx5e_create_cq_param ccp = {};
6464
struct dim_cq_moder trap_moder = {};
6565
struct mlx5e_rq *rq = &t->rq;
66+
u16 q_counter;
6667
int node;
6768
int err;
6869

6970
node = dev_to_node(mdev->device);
71+
q_counter = priv->q_counter[0];
7072

7173
ccp.netdev = priv->netdev;
7274
ccp.wq = priv->wq;
@@ -79,7 +81,7 @@ static int mlx5e_open_trap_rq(struct mlx5e_priv *priv, struct mlx5e_trap *t)
7981
return err;
8082

8183
mlx5e_init_trap_rq(t, &t->params, rq);
82-
err = mlx5e_open_rq(&t->params, rq_param, NULL, node, rq);
84+
err = mlx5e_open_rq(&t->params, rq_param, NULL, node, q_counter, rq);
8385
if (err)
8486
goto err_destroy_cq;
8587

@@ -116,15 +118,14 @@ static int mlx5e_create_trap_direct_rq_tir(struct mlx5_core_dev *mdev, struct ml
116118
}
117119

118120
static void mlx5e_build_trap_params(struct mlx5_core_dev *mdev,
119-
int max_mtu, u16 q_counter,
120-
struct mlx5e_trap *t)
121+
int max_mtu, struct mlx5e_trap *t)
121122
{
122123
struct mlx5e_params *params = &t->params;
123124

124125
params->rq_wq_type = MLX5_WQ_TYPE_CYCLIC;
125126
mlx5e_init_rq_type_params(mdev, params);
126127
params->sw_mtu = max_mtu;
127-
mlx5e_build_rq_param(mdev, params, NULL, q_counter, &t->rq_param);
128+
mlx5e_build_rq_param(mdev, params, NULL, &t->rq_param);
128129
}
129130

130131
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)
138139
if (!t)
139140
return ERR_PTR(-ENOMEM);
140141

141-
mlx5e_build_trap_params(priv->mdev, netdev->max_mtu, priv->q_counter, t);
142+
mlx5e_build_trap_params(priv->mdev, netdev->max_mtu, t);
142143

143144
t->priv = priv;
144145
t->mdev = priv->mdev;

drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params,
4949
static void mlx5e_build_xsk_cparam(struct mlx5_core_dev *mdev,
5050
struct mlx5e_params *params,
5151
struct mlx5e_xsk_param *xsk,
52-
u16 q_counter,
5352
struct mlx5e_channel_param *cparam)
5453
{
55-
mlx5e_build_rq_param(mdev, params, xsk, q_counter, &cparam->rq);
54+
mlx5e_build_rq_param(mdev, params, xsk, &cparam->rq);
5655
mlx5e_build_xdpsq_param(mdev, params, xsk, &cparam->xdp_sq);
5756
}
5857

@@ -93,14 +92,15 @@ static int mlx5e_open_xsk_rq(struct mlx5e_channel *c, struct mlx5e_params *param
9392
struct mlx5e_rq_param *rq_params, struct xsk_buff_pool *pool,
9493
struct mlx5e_xsk_param *xsk)
9594
{
95+
u16 q_counter = c->priv->q_counter[c->sd_ix];
9696
struct mlx5e_rq *xskrq = &c->xskrq;
9797
int err;
9898

9999
err = mlx5e_init_xsk_rq(c, params, pool, xsk, xskrq);
100100
if (err)
101101
return err;
102102

103-
err = mlx5e_open_rq(params, rq_params, xsk, cpu_to_node(c->cpu), xskrq);
103+
err = mlx5e_open_rq(params, rq_params, xsk, cpu_to_node(c->cpu), q_counter, xskrq);
104104
if (err)
105105
return err;
106106

@@ -125,7 +125,7 @@ int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,
125125
if (!cparam)
126126
return -ENOMEM;
127127

128-
mlx5e_build_xsk_cparam(priv->mdev, params, xsk, priv->q_counter, cparam);
128+
mlx5e_build_xsk_cparam(priv->mdev, params, xsk, cparam);
129129

130130
err = mlx5e_open_cq(c->mdev, params->rx_cq_moderation, &cparam->rq.cqp, &ccp,
131131
&c->xskrq.cq);

0 commit comments

Comments
 (0)