History

mlx5: Rx queue setup time determine frame_sz for XDP

The mlx5 driver have multiple memory models, which are also changed according to whether a XDP bpf_prog is attached. The 'rx_striding_rq' setting is adjusted via ethtool priv-flags e.g.: # ethtool --set-priv-flags mlx5p2 rx_striding_rq off On the general case with 4K page_size and regular MTU packet, then the frame_sz is 2048 and 4096 when XDP is enabled, in both modes. The info on the given frame size is stored differently depending on the RQ-mode and encoded in a union in struct mlx5e_rq union wqe/mpwqe. In rx striding mode rq->mpwqe.log_stride_sz is either 11 or 12, which corresponds to 2048 or 4096 (MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ). In non-striding mode (MLX5_WQ_TYPE_CYCLIC) the frag_stride is stored in rq->wqe.info.arr[0].frag_stride, for the first fragment, which is what the XDP case cares about. To reduce effect on fast-path, this patch determine the frame_sz at setup time, to avoid determining the memory model runtime. Variable is named frame0_sz to make it clear that this is only the frame size of the first fragment. This mlx5 driver does a DMA-sync on XDP_TX action, but grow is safe as it have done a DMA-map on the entire PAGE_SIZE. The driver also already does a XDP length check against sq->hw_mtu on the possible XDP xmit paths mlx5e_xmit_xdp_frame() + mlx5e_xmit_xdp_frame_mpwqe(). V3+4: Change variable name first_frame_sz to frame0_sz V2: Fix that frag_size need to be recalc before creating SKB.

Jesper Dangaard Brouer committed 6 years ago

Commit d628ee41 parent 2a637c54 files · +10 −0Browse files

Unified · Split

4 files
  1. drivers/net/ethernet/mellanox/mlx5/core/en.h +1 −0
  2. drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +1 −0
  3. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +6 −0
  4. drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +2 −0
drivers/net/ethernet/mellanox/mlx5/core/en.h+1−0
@@ -625,6 +625,7 @@ struct mlx5e_rq { · 624 unmodified lines
625 struct {625 struct {
626 u16 umem_headroom;626 u16 umem_headroom;
627 u16 headroom;627 u16 headroom;
628 u32 frame0_sz;
628 u8 map_dir; /* dma map direction */629 u8 map_dir; /* dma map direction */
629 } buff;630 } buff;
630 631
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c+1−0
@@ -137,6 +137,7 @@ bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di, · 136 unmodified lines
137 if (xsk)137 if (xsk)
138 xdp.handle = di->xsk.handle;138 xdp.handle = di->xsk.handle;
139 xdp.rxq = &rq->xdp_rxq;139 xdp.rxq = &rq->xdp_rxq;
140 xdp.frame_sz = rq->buff.frame0_sz;
140 141
141 act = bpf_prog_run_xdp(prog, &xdp);142 act = bpf_prog_run_xdp(prog, &xdp);
142 if (xsk) {143 if (xsk) {
drivers/net/ethernet/mellanox/mlx5/core/en_main.c+6−0
@@ -462,6 +462,8 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, · 461 unmodified lines
462 rq->mpwqe.num_strides =462 rq->mpwqe.num_strides =
463 BIT(mlx5e_mpwqe_get_log_num_strides(mdev, params, xsk));463 BIT(mlx5e_mpwqe_get_log_num_strides(mdev, params, xsk));
464 464
465 rq->buff.frame0_sz = (1 << rq->mpwqe.log_stride_sz);
466
465 err = mlx5e_create_rq_umr_mkey(mdev, rq);467 err = mlx5e_create_rq_umr_mkey(mdev, rq);
466 if (err)468 if (err)
467 goto err_rq_wq_destroy;469 goto err_rq_wq_destroy;
@@ -485,6 +487,8 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, · 17 unmodified lines
485 num_xsk_frames = wq_sz << rq->wqe.info.log_num_frags;487 num_xsk_frames = wq_sz << rq->wqe.info.log_num_frags;
486 488
487 rq->wqe.info = rqp->frags_info;489 rq->wqe.info = rqp->frags_info;
490 rq->buff.frame0_sz = rq->wqe.info.arr[0].frag_stride;
491
488 rq->wqe.frags =492 rq->wqe.frags =
489 kvzalloc_node(array_size(sizeof(*rq->wqe.frags),493 kvzalloc_node(array_size(sizeof(*rq->wqe.frags),
490 (wq_sz << rq->wqe.info.log_num_frags)),494 (wq_sz << rq->wqe.info.log_num_frags)),
@@ -522,6 +526,8 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, · 31 unmodified lines
522 }526 }
523 527
524 if (xsk) {528 if (xsk) {
529 rq->buff.frame0_sz = xsk_umem_xdp_frame_sz(umem);
530
525 err = mlx5e_xsk_resize_reuseq(umem, num_xsk_frames);531 err = mlx5e_xsk_resize_reuseq(umem, num_xsk_frames);
526 if (unlikely(err)) {532 if (unlikely(err)) {
527 mlx5_core_err(mdev, "Unable to allocate the Reuse Ring for %u frames\n",533 mlx5_core_err(mdev, "Unable to allocate the Reuse Ring for %u frames\n",
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c+2−0
@@ -1070,6 +1070,7 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe, · 1069 unmodified lines
1070 if (consumed)1070 if (consumed)
1071 return NULL; /* page/packet was consumed by XDP */1071 return NULL; /* page/packet was consumed by XDP */
1072 1072
1073 frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt);
1073 skb = mlx5e_build_linear_skb(rq, va, frag_size, rx_headroom, cqe_bcnt);1074 skb = mlx5e_build_linear_skb(rq, va, frag_size, rx_headroom, cqe_bcnt);
1074 if (unlikely(!skb))1075 if (unlikely(!skb))
1075 return NULL;1076 return NULL;
@@ -1371,6 +1372,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi, · 295 unmodified lines
1371 return NULL; /* page/packet was consumed by XDP */1372 return NULL; /* page/packet was consumed by XDP */
1372 }1373 }
1373 1374
1375 frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt32);
1374 skb = mlx5e_build_linear_skb(rq, va, frag_size, rx_headroom, cqe_bcnt32);1376 skb = mlx5e_build_linear_skb(rq, va, frag_size, rx_headroom, cqe_bcnt32);
1375 if (unlikely(!skb))1377 if (unlikely(!skb))
1376 return NULL;1378 return NULL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t