Skip to content

Commit 67936e1

Browse files
Tariq ToukanSaeed Mahameed
Tariq Toukan
authored and
Saeed Mahameed
committed
net/mlx5e: Let channels be SD-aware
Distribute the channels between the different SD-devices to acheive local numa node performance on multiple numas. Each channel works against one specific mdev, creating all datapath queues against it. We distribute channels to mdevs in a round-robin policy. Example for 2 mdevs and 6 channels: +-------+---------+ | ch ix | mdev ix | +-------+---------+ | 0 | 0 | | 1 | 1 | | 2 | 0 | | 3 | 1 | | 4 | 0 | | 5 | 1 | +-------+---------+ This round-robin distribution policy is preferred over another suggested intuitive distribution, in which we first distribute one half of the channels to mdev #0 and then the second half to mdev #1. We prefer round-robin for a reason: it is less influenced by changes in the number of channels. The mapping between channel index and mdev is fixed, no matter how many channels the user configures. As the channel stats are persistent to channels closure, changing the mapping every single time would turn the accumulative stats less representing of the channel's history. Per-channel objects should stop using the primary mdev (priv->mdev) directly, and instead move to using their own channel's mdev. Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Gal Pressman <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 846122b commit 67936e1

File tree

8 files changed

+35
-27
lines changed

8 files changed

+35
-27
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ struct mlx5e_channel {
792792
struct hwtstamp_config *tstamp;
793793
DECLARE_BITMAP(state, MLX5E_CHANNEL_NUM_STATES);
794794
int ix;
795+
int vec_ix;
795796
int cpu;
796797
/* Sync between icosq recovery and XSK enable/disable. */
797798
struct mutex icosq_recovery_lock;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ void mlx5e_build_create_cq_param(struct mlx5e_create_cq_param *ccp, struct mlx5e
688688
.napi = &c->napi,
689689
.ch_stats = c->stats,
690690
.node = cpu_to_node(c->cpu),
691-
.ix = c->ix,
691+
.ix = c->vec_ix,
692692
};
693693
}
694694

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ int mlx5e_open_qos_sq(struct mlx5e_priv *priv, struct mlx5e_channels *chs,
122122

123123
memset(&param_sq, 0, sizeof(param_sq));
124124
memset(&param_cq, 0, sizeof(param_cq));
125-
mlx5e_build_sq_param(priv->mdev, params, &param_sq);
126-
mlx5e_build_tx_cq_param(priv->mdev, params, &param_cq);
125+
mlx5e_build_sq_param(c->mdev, params, &param_sq);
126+
mlx5e_build_tx_cq_param(c->mdev, params, &param_cq);
127127
err = mlx5e_open_cq(c->mdev, params->tx_cq_moderation, &param_cq, &ccp, &sq->cq);
128128
if (err)
129129
goto err_free_sq;
@@ -176,7 +176,7 @@ int mlx5e_activate_qos_sq(void *data, u16 node_qid, u32 hw_id)
176176
*/
177177
smp_wmb();
178178

179-
qos_dbg(priv->mdev, "Activate QoS SQ qid %u\n", node_qid);
179+
qos_dbg(sq->mdev, "Activate QoS SQ qid %u\n", node_qid);
180180
mlx5e_activate_txqsq(sq);
181181

182182
return 0;
@@ -190,7 +190,7 @@ void mlx5e_deactivate_qos_sq(struct mlx5e_priv *priv, u16 qid)
190190
if (!sq) /* Handle the case when the SQ failed to open. */
191191
return;
192192

193-
qos_dbg(priv->mdev, "Deactivate QoS SQ qid %u\n", qid);
193+
qos_dbg(sq->mdev, "Deactivate QoS SQ qid %u\n", qid);
194194
mlx5e_deactivate_txqsq(sq);
195195

196196
priv->txq2sq[mlx5e_qid_from_qos(&priv->channels, qid)] = NULL;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ static void mlx5e_rx_reporter_diagnose_generic_rq(struct mlx5e_rq *rq,
294294

295295
params = &priv->channels.params;
296296
rq_sz = mlx5e_rqwq_get_size(rq);
297-
real_time = mlx5_is_real_time_rq(priv->mdev);
298-
rq_stride = BIT(mlx5e_mpwqe_get_log_stride_size(priv->mdev, params, NULL));
297+
real_time = mlx5_is_real_time_rq(rq->mdev);
298+
rq_stride = BIT(mlx5e_mpwqe_get_log_stride_size(rq->mdev, params, NULL));
299299

300300
mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RQ");
301301
devlink_fmsg_u8_pair_put(fmsg, "type", params->rq_wq_type);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,14 @@ mlx5e_tx_reporter_build_diagnose_output_sq_common(struct devlink_fmsg *fmsg,
219219
struct mlx5e_txqsq *sq, int tc)
220220
{
221221
bool stopped = netif_xmit_stopped(sq->txq);
222-
struct mlx5e_priv *priv = sq->priv;
223222
u8 state;
224223
int err;
225224

226225
devlink_fmsg_u32_pair_put(fmsg, "tc", tc);
227226
devlink_fmsg_u32_pair_put(fmsg, "txq ix", sq->txq_ix);
228227
devlink_fmsg_u32_pair_put(fmsg, "sqn", sq->sqn);
229228

230-
err = mlx5_core_query_sq_state(priv->mdev, sq->sqn, &state);
229+
err = mlx5_core_query_sq_state(sq->mdev, sq->sqn, &state);
231230
if (!err)
232231
devlink_fmsg_u8_pair_put(fmsg, "HW state", state);
233232

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
#include "setup.h"
77
#include "en/params.h"
88

9-
static int mlx5e_xsk_map_pool(struct mlx5e_priv *priv,
9+
static int mlx5e_xsk_map_pool(struct mlx5_core_dev *mdev,
1010
struct xsk_buff_pool *pool)
1111
{
12-
struct device *dev = mlx5_core_dma_dev(priv->mdev);
12+
struct device *dev = mlx5_core_dma_dev(mdev);
1313

1414
return xsk_pool_dma_map(pool, dev, DMA_ATTR_SKIP_CPU_SYNC);
1515
}
@@ -89,7 +89,7 @@ static int mlx5e_xsk_enable_locked(struct mlx5e_priv *priv,
8989
if (unlikely(!mlx5e_xsk_is_pool_sane(pool)))
9090
return -EINVAL;
9191

92-
err = mlx5e_xsk_map_pool(priv, pool);
92+
err = mlx5e_xsk_map_pool(mlx5_sd_ch_ix_get_dev(priv->mdev, ix), pool);
9393
if (unlikely(err))
9494
return err;
9595

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,
267267
goto err_out;
268268
}
269269

270-
pdev = mlx5_core_dma_dev(sq->channel->priv->mdev);
270+
pdev = mlx5_core_dma_dev(sq->channel->mdev);
271271
buf->dma_addr = dma_map_single(pdev, &buf->progress,
272272
PROGRESS_PARAMS_PADDED_SIZE, DMA_FROM_DEVICE);
273273
if (unlikely(dma_mapping_error(pdev, buf->dma_addr))) {
@@ -425,14 +425,12 @@ void mlx5e_ktls_handle_get_psv_completion(struct mlx5e_icosq_wqe_info *wi,
425425
{
426426
struct mlx5e_ktls_rx_resync_buf *buf = wi->tls_get_params.buf;
427427
struct mlx5e_ktls_offload_context_rx *priv_rx;
428-
struct mlx5e_ktls_rx_resync_ctx *resync;
429428
u8 tracker_state, auth_state, *ctx;
430429
struct device *dev;
431430
u32 hw_seq;
432431

433432
priv_rx = buf->priv_rx;
434-
resync = &priv_rx->resync;
435-
dev = mlx5_core_dma_dev(resync->priv->mdev);
433+
dev = mlx5_core_dma_dev(sq->channel->mdev);
436434
if (unlikely(test_bit(MLX5E_PRIV_RX_FLAG_DELETING, priv_rx->flags)))
437435
goto out;
438436

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,14 +2529,20 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
25292529
struct xsk_buff_pool *xsk_pool,
25302530
struct mlx5e_channel **cp)
25312531
{
2532-
int cpu = mlx5_comp_vector_get_cpu(priv->mdev, ix);
25332532
struct net_device *netdev = priv->netdev;
2533+
struct mlx5_core_dev *mdev;
25342534
struct mlx5e_xsk_param xsk;
25352535
struct mlx5e_channel *c;
25362536
unsigned int irq;
2537+
int vec_ix;
2538+
int cpu;
25372539
int err;
25382540

2539-
err = mlx5_comp_irqn_get(priv->mdev, ix, &irq);
2541+
mdev = mlx5_sd_ch_ix_get_dev(priv->mdev, ix);
2542+
vec_ix = mlx5_sd_ch_ix_get_vec_ix(mdev, ix);
2543+
cpu = mlx5_comp_vector_get_cpu(mdev, vec_ix);
2544+
2545+
err = mlx5_comp_irqn_get(mdev, vec_ix, &irq);
25402546
if (err)
25412547
return err;
25422548

@@ -2549,18 +2555,19 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
25492555
return -ENOMEM;
25502556

25512557
c->priv = priv;
2552-
c->mdev = priv->mdev;
2558+
c->mdev = mdev;
25532559
c->tstamp = &priv->tstamp;
25542560
c->ix = ix;
2561+
c->vec_ix = vec_ix;
25552562
c->cpu = cpu;
2556-
c->pdev = mlx5_core_dma_dev(priv->mdev);
2563+
c->pdev = mlx5_core_dma_dev(mdev);
25572564
c->netdev = priv->netdev;
2558-
c->mkey_be = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey);
2565+
c->mkey_be = cpu_to_be32(mdev->mlx5e_res.hw_objs.mkey);
25592566
c->num_tc = mlx5e_get_dcb_num_tc(params);
25602567
c->xdp = !!params->xdp_prog;
25612568
c->stats = &priv->channel_stats[ix]->ch;
25622569
c->aff_mask = irq_get_effective_affinity_mask(irq);
2563-
c->lag_port = mlx5e_enumerate_lag_port(priv->mdev, ix);
2570+
c->lag_port = mlx5e_enumerate_lag_port(mdev, ix);
25642571

25652572
netif_napi_add(netdev, &c->napi, mlx5e_napi_poll);
25662573
netif_napi_set_irq(&c->napi, irq);
@@ -2943,15 +2950,18 @@ static MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX(mlx5e_update_netdev_queues);
29432950
static void mlx5e_set_default_xps_cpumasks(struct mlx5e_priv *priv,
29442951
struct mlx5e_params *params)
29452952
{
2946-
struct mlx5_core_dev *mdev = priv->mdev;
2947-
int num_comp_vectors, ix, irq;
2948-
2949-
num_comp_vectors = mlx5_comp_vectors_max(mdev);
2953+
int ix;
29502954

29512955
for (ix = 0; ix < params->num_channels; ix++) {
2956+
int num_comp_vectors, irq, vec_ix;
2957+
struct mlx5_core_dev *mdev;
2958+
2959+
mdev = mlx5_sd_ch_ix_get_dev(priv->mdev, ix);
2960+
num_comp_vectors = mlx5_comp_vectors_max(mdev);
29522961
cpumask_clear(priv->scratchpad.cpumask);
2962+
vec_ix = mlx5_sd_ch_ix_get_vec_ix(mdev, ix);
29532963

2954-
for (irq = ix; irq < num_comp_vectors; irq += params->num_channels) {
2964+
for (irq = vec_ix; irq < num_comp_vectors; irq += params->num_channels) {
29552965
int cpu = mlx5_comp_vector_get_cpu(mdev, irq);
29562966

29572967
cpumask_set_cpu(cpu, priv->scratchpad.cpumask);

0 commit comments

Comments
 (0)