From patchwork Thu May 14 10:48:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Dangaard Brouer X-Patchwork-Id: 219263 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA02BC433DF for ; Thu, 14 May 2020 10:49:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72F2C206A5 for ; Thu, 14 May 2020 10:49:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dcFhgO28" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726073AbgENKtO (ORCPT ); Thu, 14 May 2020 06:49:14 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:33548 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726010AbgENKtO (ORCPT ); Thu, 14 May 2020 06:49:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589453351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xl3PtZhUoXNCz9X55oC8eYBVnIgmufJyn0mQs9IfJGI=; b=dcFhgO28vuJSpveGYf2KhdfkRHy90mwzH4Jwp9vkYgYyfXQrK0+CrmOgYWxJwIxYcmXiHX cS+kWGDRv6QzcwhQgSSdgg75IP/bE1NgSbwql0nkw2rX0e/jeqfxiDotVKwQT+oSuGDShU WRrEeVgsXRHOGUQN5+2tlbKBFcpNzzE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-202-poiv3oWqN-KETWHC9gMMiw-1; Thu, 14 May 2020 06:49:04 -0400 X-MC-Unique: poiv3oWqN-KETWHC9gMMiw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C06FE100CCC5; Thu, 14 May 2020 10:49:02 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.40.208.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC56276C38; Thu, 14 May 2020 10:48:58 +0000 (UTC) Received: from [192.168.42.3] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 88EEB300020FC; Thu, 14 May 2020 12:48:57 +0200 (CEST) Subject: [PATCH net-next v4 00/33] XDP extend with knowledge of frame size From: Jesper Dangaard Brouer To: sameehj@amazon.com Cc: Jesper Dangaard Brouer , netdev@vger.kernel.org, bpf@vger.kernel.org, =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , Daniel Borkmann , Alexei Starovoitov , "David S. Miller" , John Fastabend , Alexander Duyck , Jeff Kirsher , David Ahern , Ilias Apalodimas , Lorenzo Bianconi , Saeed Mahameed , Tariq Toukan Date: Thu, 14 May 2020 12:48:57 +0200 Message-ID: <158945314698.97035.5286827951225578467.stgit@firesoul> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org (Patchset based on net-next due to all the driver updates) V4: - Fixup checkpatch.pl issues - Collected more ACKs V3: - Fix issue on virtio_net patch spotted by Jason Wang - Adjust name for variable in mlx5 patch - Collected more ACKs V2: - Fix bug in mlx5 for XDP_PASS case - Collected nitpicks and ACKs from mailing list V1: - Fix bug in dpaa2 XDP have evolved to support several frame sizes, but xdp_buff was not updated with this information. This have caused the side-effect that XDP frame data hard end is unknown. This have limited the BPF-helper bpf_xdp_adjust_tail to only shrink the packet. This patchset address this and add packet tail extend/grow. The purpose of the patchset is ALSO to reserve a memory area that can be used for storing extra information, specifically for extending XDP with multi-buffer support. One proposal is to use same layout as skb_shared_info, which is why this area is currently 320 bytes. When converting xdp_frame to SKB (veth and cpumap), the full tailroom area can now be used and SKB truesize is now correct. For most drivers this result in a much larger tailroom in SKB "head" data area. The network stack can now take advantage of this when doing SKB coalescing. Thus, a good driver test is to use xdp_redirect_cpu from samples/bpf/ and do some TCP stream testing. Use-cases for tail grow/extend: (1) IPsec / XFRM needs a tail extend[1][2]. (2) DNS-cache responses in XDP. (3) HAProxy ALOHA would need it to convert to XDP. (4) Add tail info e.g. timestamp and collect via tcpdump [1] http://vger.kernel.org/netconf2019_files/xfrm_xdp.pdf [2] http://vger.kernel.org/netconf2019.html Examples on howto access the tail area of an XDP packet is shown in the XDP-tutorial example[3]. [3] https://github.com/xdp-project/xdp-tutorial/blob/master/experiment01-tailgrow/ --- Ilias Apalodimas (1): net: netsec: Add support for XDP frame size Jesper Dangaard Brouer (32): xdp: add frame size to xdp_buff bnxt: add XDP frame size to driver sfc: add XDP frame size mvneta: add XDP frame size to driver net: XDP-generic determining XDP frame size xdp: xdp_frame add member frame_sz and handle in convert_to_xdp_frame xdp: cpumap redirect use frame_sz and increase skb_tailroom veth: adjust hard_start offset on redirect XDP frames veth: xdp using frame_sz in veth driver dpaa2-eth: add XDP frame size hv_netvsc: add XDP frame size to driver qlogic/qede: add XDP frame size to driver net: ethernet: ti: add XDP frame size to driver cpsw ena: add XDP frame size to amazon NIC driver mlx4: add XDP frame size and adjust max XDP MTU net: thunderx: add XDP frame size nfp: add XDP frame size to netronome driver tun: add XDP frame size vhost_net: also populate XDP frame size virtio_net: add XDP frame size in two code paths ixgbe: fix XDP redirect on archs with PAGE_SIZE above 4K ixgbe: add XDP frame size to driver ixgbevf: add XDP frame size to VF driver i40e: add XDP frame size to driver ice: add XDP frame size to driver xdp: for Intel AF_XDP drivers add XDP frame_sz mlx5: rx queue setup time determine frame_sz for XDP xdp: allow bpf_xdp_adjust_tail() to grow packet size xdp: clear grow memory in bpf_xdp_adjust_tail() bpf: add xdp.frame_sz in bpf_prog_test_run_xdp(). selftests/bpf: adjust BPF selftest for xdp_adjust_tail selftests/bpf: xdp_adjust_tail add grow tail tests drivers/net/ethernet/amazon/ena/ena_netdev.c | 1 drivers/net/ethernet/amazon/ena/ena_netdev.h | 5 - drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 1 drivers/net/ethernet/cavium/thunder/nicvf_main.c | 1 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 7 + drivers/net/ethernet/intel/i40e/i40e_txrx.c | 30 ++++- drivers/net/ethernet/intel/i40e/i40e_xsk.c | 2 drivers/net/ethernet/intel/ice/ice_txrx.c | 34 ++++-- drivers/net/ethernet/intel/ice/ice_xsk.c | 2 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 33 ++++- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 2 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 34 ++++-- drivers/net/ethernet/marvell/mvneta.c | 25 ++-- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 3 drivers/net/ethernet/mellanox/mlx4/en_rx.c | 1 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 + drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 .../net/ethernet/netronome/nfp/nfp_net_common.c | 6 + drivers/net/ethernet/qlogic/qede/qede_fp.c | 1 drivers/net/ethernet/qlogic/qede/qede_main.c | 2 drivers/net/ethernet/sfc/rx.c | 1 drivers/net/ethernet/socionext/netsec.c | 30 +++-- drivers/net/ethernet/ti/cpsw.c | 1 drivers/net/ethernet/ti/cpsw_new.c | 1 drivers/net/hyperv/netvsc_bpf.c | 1 drivers/net/hyperv/netvsc_drv.c | 2 drivers/net/tun.c | 2 drivers/net/veth.c | 28 +++-- drivers/net/virtio_net.c | 15 ++ drivers/vhost/net.c | 1 include/net/xdp.h | 27 ++++ include/net/xdp_sock.h | 11 ++ include/uapi/linux/bpf.h | 4 - kernel/bpf/cpumap.c | 21 --- net/bpf/test_run.c | 16 ++- net/core/dev.c | 14 +- net/core/filter.c | 15 ++ net/core/xdp.c | 8 + .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 123 +++++++++++++++++++- .../testing/selftests/bpf/progs/test_adjust_tail.c | 30 ----- .../bpf/progs/test_xdp_adjust_tail_grow.c | 33 +++++ .../bpf/progs/test_xdp_adjust_tail_shrink.c | 30 +++++ 44 files changed, 475 insertions(+), 139 deletions(-) delete mode 100644 tools/testing/selftests/bpf/progs/test_adjust_tail.c create mode 100644 tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_grow.c create mode 100644 tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_shrink.c --