On Wed, 22 Apr 2020 18:09:43 +0200 Jesper Dangaard Brouer <brouer@xxxxxxxxxx> wrote: > 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 first_frame_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(). > > Cc: Tariq Toukan <tariqt@xxxxxxxxxxxx> > Cc: Saeed Mahameed <saeedm@xxxxxxxxxxxx> > Signed-off-by: Jesper Dangaard Brouer <brouer@xxxxxxxxxx> > --- > drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + > drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 1 + > drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 ++++++ > 3 files changed, 8 insertions(+) I found a bug in this patch, that can lead to BUG in skb_panic() in XDP_PASS case when growing the tail. (Hint why I fixed output in [1]). I already have a fix, but this implies I will send a V2 tomorrow. I'll pickup all the ACKs manually tomorrow, before I resubmit. [1] https://lore.kernel.org/netdev/158800546361.1962096.4535216438507756179.stgit@firesoul/ -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer