Skip to content

Commit 092d992

Browse files
committed
Merge tag 'mlx5-updates-2022-03-18' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-updates-2022-03-18 1) XDP multi buffer support This series enables XDP on non-linear legacy RQ in multi buffer mode. When XDP is enabled, fragmentation scheme on non-linear legacy RQ is adjusted to comply to limitations of XDP multi buffer (fragments of the same size). DMA addresses of fragments are stored in struct page for the completion handler to be able to unmap them. XDP_TX is supported. XDP_REDIRECT is not yet supported, the XDP core blocks it for multi buffer packets at the moment. 2) Trivial cleanups ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 62f6555 + 5dc2b58 commit 092d992

File tree

13 files changed

+329
-113
lines changed

13 files changed

+329
-113
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force
17201720
}
17211721
}
17221722

1723-
void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev)
1723+
static void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev)
17241724
{
17251725
struct mlx5_cmd *cmd = &dev->cmd;
17261726
unsigned long bitmask;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ enum {
405405
MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE,
406406
MLX5E_SQ_STATE_PENDING_XSK_TX,
407407
MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC,
408+
MLX5E_SQ_STATE_XDP_MULTIBUF,
408409
};
409410

410411
struct mlx5e_tx_mpwqe {
@@ -515,7 +516,7 @@ struct mlx5e_xdp_info {
515516
} frame;
516517
struct {
517518
struct mlx5e_rq *rq;
518-
struct mlx5e_dma_info di;
519+
struct page *page;
519520
} page;
520521
};
521522
};
@@ -537,7 +538,7 @@ struct mlx5e_xdpsq;
537538
typedef int (*mlx5e_fp_xmit_xdp_frame_check)(struct mlx5e_xdpsq *);
538539
typedef bool (*mlx5e_fp_xmit_xdp_frame)(struct mlx5e_xdpsq *,
539540
struct mlx5e_xmit_data *,
540-
struct mlx5e_xdp_info *,
541+
struct skb_shared_info *,
541542
int);
542543

543544
struct mlx5e_xdpsq {

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

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,12 @@ void mlx5e_build_create_cq_param(struct mlx5e_create_cq_param *ccp, struct mlx5e
398398
};
399399
}
400400

401-
static int mlx5e_max_nonlinear_mtu(int first_frag_size, int frag_size)
401+
static int mlx5e_max_nonlinear_mtu(int first_frag_size, int frag_size, bool xdp)
402402
{
403+
if (xdp)
404+
/* XDP requires all fragments to be of the same size. */
405+
return first_frag_size + (MLX5E_MAX_RX_FRAGS - 1) * frag_size;
406+
403407
/* Optimization for small packets: the last fragment is bigger than the others. */
404408
return first_frag_size + (MLX5E_MAX_RX_FRAGS - 2) * frag_size + PAGE_SIZE;
405409
}
@@ -438,12 +442,14 @@ static int mlx5e_build_rq_frags_info(struct mlx5_core_dev *mdev,
438442
headroom = mlx5e_get_linear_rq_headroom(params, xsk);
439443
first_frag_size_max = SKB_WITH_OVERHEAD(frag_size_max - headroom);
440444

441-
max_mtu = mlx5e_max_nonlinear_mtu(first_frag_size_max, frag_size_max);
442-
if (byte_count > max_mtu) {
445+
max_mtu = mlx5e_max_nonlinear_mtu(first_frag_size_max, frag_size_max,
446+
params->xdp_prog);
447+
if (byte_count > max_mtu || params->xdp_prog) {
443448
frag_size_max = PAGE_SIZE;
444449
first_frag_size_max = SKB_WITH_OVERHEAD(frag_size_max - headroom);
445450

446-
max_mtu = mlx5e_max_nonlinear_mtu(first_frag_size_max, frag_size_max);
451+
max_mtu = mlx5e_max_nonlinear_mtu(first_frag_size_max, frag_size_max,
452+
params->xdp_prog);
447453
if (byte_count > max_mtu) {
448454
mlx5_core_err(mdev, "MTU %u is too big for non-linear legacy RQ (max %d)\n",
449455
params->sw_mtu, max_mtu);
@@ -463,14 +469,18 @@ static int mlx5e_build_rq_frags_info(struct mlx5_core_dev *mdev,
463469
info->arr[i].frag_size = frag_size;
464470
buf_size += frag_size;
465471

466-
if (i == 0) {
467-
/* Ensure that headroom and tailroom are included. */
468-
frag_size += headroom;
469-
frag_size += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
472+
if (params->xdp_prog) {
473+
/* XDP multi buffer expects fragments of the same size. */
474+
info->arr[i].frag_stride = frag_size_max;
475+
} else {
476+
if (i == 0) {
477+
/* Ensure that headroom and tailroom are included. */
478+
frag_size += headroom;
479+
frag_size += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
480+
}
481+
info->arr[i].frag_stride = roundup_pow_of_two(frag_size);
470482
}
471483

472-
info->arr[i].frag_stride = roundup_pow_of_two(frag_size);
473-
474484
i++;
475485
}
476486
info->num_frags = i;
@@ -833,6 +843,7 @@ static void mlx5e_build_async_icosq_param(struct mlx5_core_dev *mdev,
833843

834844
void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev,
835845
struct mlx5e_params *params,
846+
struct mlx5e_xsk_param *xsk,
836847
struct mlx5e_sq_param *param)
837848
{
838849
void *sqc = param->sqc;
@@ -841,6 +852,7 @@ void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev,
841852
mlx5e_build_sq_param_common(mdev, param);
842853
MLX5_SET(wq, wq, log_wq_sz, params->log_sq_size);
843854
param->is_mpw = MLX5E_GET_PFLAG(params, MLX5E_PFLAG_XDP_TX_MPWQE);
855+
param->is_xdp_mb = !mlx5e_rx_is_linear_skb(params, xsk);
844856
mlx5e_build_tx_cq_param(mdev, params, &param->cqp);
845857
}
846858

@@ -860,7 +872,7 @@ int mlx5e_build_channel_param(struct mlx5_core_dev *mdev,
860872
async_icosq_log_wq_sz = mlx5e_build_async_icosq_log_wq_sz(mdev);
861873

862874
mlx5e_build_sq_param(mdev, params, &cparam->txq_sq);
863-
mlx5e_build_xdpsq_param(mdev, params, &cparam->xdp_sq);
875+
mlx5e_build_xdpsq_param(mdev, params, NULL, &cparam->xdp_sq);
864876
mlx5e_build_icosq_param(mdev, icosq_log_wq_sz, &cparam->icosq);
865877
mlx5e_build_async_icosq_param(mdev, async_icosq_log_wq_sz, &cparam->async_icosq);
866878

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct mlx5e_sq_param {
3131
struct mlx5_wq_param wq;
3232
bool is_mpw;
3333
bool is_tls;
34+
bool is_xdp_mb;
3435
u16 stop_room;
3536
};
3637

@@ -155,6 +156,7 @@ void mlx5e_build_tx_cq_param(struct mlx5_core_dev *mdev,
155156
struct mlx5e_cq_param *param);
156157
void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev,
157158
struct mlx5e_params *params,
159+
struct mlx5e_xsk_param *xsk,
158160
struct mlx5e_sq_param *param);
159161
int mlx5e_build_channel_param(struct mlx5_core_dev *mdev,
160162
struct mlx5e_params *params,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ int mlx5e_qos_cur_leaf_nodes(struct mlx5e_priv *priv);
1818

1919
/* TX datapath API */
2020
int mlx5e_get_txq_by_classid(struct mlx5e_priv *priv, u16 classid);
21-
struct mlx5e_txqsq *mlx5e_get_sq(struct mlx5e_priv *priv, int qid);
2221

2322
/* SQ lifecycle */
2423
int mlx5e_qos_open_queues(struct mlx5e_priv *priv, struct mlx5e_channels *chs);

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget);
4444
int mlx5e_poll_ico_cq(struct mlx5e_cq *cq);
4545

4646
/* RX */
47-
void mlx5e_page_dma_unmap(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info);
48-
void mlx5e_page_release_dynamic(struct mlx5e_rq *rq,
49-
struct mlx5e_dma_info *dma_info,
50-
bool recycle);
47+
void mlx5e_page_dma_unmap(struct mlx5e_rq *rq, struct page *page);
48+
void mlx5e_page_release_dynamic(struct mlx5e_rq *rq, struct page *page, bool recycle);
5149
INDIRECT_CALLABLE_DECLARE(bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq));
5250
INDIRECT_CALLABLE_DECLARE(bool mlx5e_post_rx_mpwqes(struct mlx5e_rq *rq));
5351
int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget);

0 commit comments

Comments
 (0)