{"id":818023,"url":"http://patchwork.ozlabs.org/api/patches/818023/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/111d95035f7cee64abab545c98e56c3013cb4979.1506297988.git.daniel@iogearbox.net/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<111d95035f7cee64abab545c98e56c3013cb4979.1506297988.git.daniel@iogearbox.net>","list_archive_url":null,"date":"2017-09-25T00:25:55","name":"[net-next,6/6] bpf, ixgbe: add meta data support","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"d91fd27d670d4380c6972f2d85802a35e01868a3","submitter":{"id":65705,"url":"http://patchwork.ozlabs.org/api/people/65705/?format=json","name":"Daniel Borkmann","email":"daniel@iogearbox.net"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/111d95035f7cee64abab545c98e56c3013cb4979.1506297988.git.daniel@iogearbox.net/mbox/","series":[{"id":4860,"url":"http://patchwork.ozlabs.org/api/series/4860/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=4860","date":"2017-09-25T00:25:49","name":"BPF metadata for direct access","version":1,"mbox":"http://patchwork.ozlabs.org/series/4860/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/818023/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/818023/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y0lKH37Nmz9s82\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 25 Sep 2017 10:27:31 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S933279AbdIYA1S (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSun, 24 Sep 2017 20:27:18 -0400","from www62.your-server.de ([213.133.104.62]:37246 \"EHLO\n\twww62.your-server.de\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S933078AbdIYA1I (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Sun, 24 Sep 2017 20:27:08 -0400","from [85.7.161.218] (helo=localhost)\n\tby www62.your-server.de with esmtpsa\n\t(TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.85_2)\n\t(envelope-from <daniel@iogearbox.net>)\n\tid 1dwHEp-0000IX-60; Mon, 25 Sep 2017 02:27:07 +0200"],"From":"Daniel Borkmann <daniel@iogearbox.net>","To":"davem@davemloft.net","Cc":"alexei.starovoitov@gmail.com, john.fastabend@gmail.com,\n\tpeter.waskiewicz.jr@intel.com, jakub.kicinski@netronome.com,\n\tnetdev@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>","Subject":"[PATCH net-next 6/6] bpf, ixgbe: add meta data support","Date":"Mon, 25 Sep 2017 02:25:55 +0200","Message-Id":"<111d95035f7cee64abab545c98e56c3013cb4979.1506297988.git.daniel@iogearbox.net>","X-Mailer":"git-send-email 1.9.3","In-Reply-To":["<cover.1506297988.git.daniel@iogearbox.net>","<cover.1506297988.git.daniel@iogearbox.net>"],"References":["<cover.1506297988.git.daniel@iogearbox.net>","<cover.1506297988.git.daniel@iogearbox.net>"],"X-Authenticated-Sender":"daniel@iogearbox.net","X-Virus-Scanned":"Clear (ClamAV 0.99.2/23869/Sun Sep 24 18:45:57 2017)","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Implement support for transferring XDP meta data into skb for\nixgbe driver; before calling into the program, xdp.data_meta points\nto xdp.data, where on program return with pass verdict, we call\ninto skb_metadata_set().\n\nWe implement this for the default ixgbe_build_skb() variant. For the\nixgbe_construct_skb() that is used when legacy-rx buffer mananagement\nmode is turned on via ethtool, I found that XDP gets 0 headroom, so\nneither xdp_adjust_head() nor xdp_adjust_meta() can be used with this.\nJust add a comment with explanation for this operating mode.\n\nSigned-off-by: Daniel Borkmann <daniel@iogearbox.net>\nAcked-by: Alexei Starovoitov <ast@kernel.org>\nAcked-by: John Fastabend <john.fastabend@gmail.com>\n---\n drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 30 +++++++++++++++++++++++----\n 1 file changed, 26 insertions(+), 4 deletions(-)","diff":"diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c\nindex 04bb03b..3942c62 100644\n--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c\n+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c\n@@ -2133,6 +2133,21 @@ static struct sk_buff *ixgbe_construct_skb(struct ixgbe_ring *rx_ring,\n #if L1_CACHE_BYTES < 128\n \tprefetch(xdp->data + L1_CACHE_BYTES);\n #endif\n+\t/* Note, we get here by enabling legacy-rx via:\n+\t *\n+\t *    ethtool --set-priv-flags <dev> legacy-rx on\n+\t *\n+\t * In this mode, we currently get 0 extra XDP headroom as\n+\t * opposed to having legacy-rx off, where we process XDP\n+\t * packets going to stack via ixgbe_build_skb(). The latter\n+\t * provides us currently with 192 bytes of headroom.\n+\t *\n+\t * For ixgbe_construct_skb() mode it means that the\n+\t * xdp->data_meta will always point to xdp->data, since\n+\t * the helper cannot expand the head. Should this ever\n+\t * change in future for legacy-rx mode on, then lets also\n+\t * add xdp->data_meta handling here.\n+\t */\n \n \t/* allocate a skb to store the frags */\n \tskb = napi_alloc_skb(&rx_ring->q_vector->napi, IXGBE_RX_HDR_SIZE);\n@@ -2165,6 +2180,7 @@ static struct sk_buff *ixgbe_build_skb(struct ixgbe_ring *rx_ring,\n \t\t\t\t       struct xdp_buff *xdp,\n \t\t\t\t       union ixgbe_adv_rx_desc *rx_desc)\n {\n+\tunsigned int metasize = xdp->data - xdp->data_meta;\n #if (PAGE_SIZE < 8192)\n \tunsigned int truesize = ixgbe_rx_pg_size(rx_ring) / 2;\n #else\n@@ -2174,10 +2190,14 @@ static struct sk_buff *ixgbe_build_skb(struct ixgbe_ring *rx_ring,\n #endif\n \tstruct sk_buff *skb;\n \n-\t/* prefetch first cache line of first page */\n-\tprefetch(xdp->data);\n+\t/* Prefetch first cache line of first page. If xdp->data_meta\n+\t * is unused, this points extactly as xdp->data, otherwise we\n+\t * likely have a consumer accessing first few bytes of meta\n+\t * data, and then actual data.\n+\t */\n+\tprefetch(xdp->data_meta);\n #if L1_CACHE_BYTES < 128\n-\tprefetch(xdp->data + L1_CACHE_BYTES);\n+\tprefetch(xdp->data_meta + L1_CACHE_BYTES);\n #endif\n \n \t/* build an skb to around the page buffer */\n@@ -2188,6 +2208,8 @@ static struct sk_buff *ixgbe_build_skb(struct ixgbe_ring *rx_ring,\n \t/* update pointers within the skb to store the data */\n \tskb_reserve(skb, xdp->data - xdp->data_hard_start);\n \t__skb_put(skb, xdp->data_end - xdp->data);\n+\tif (metasize)\n+\t\tskb_metadata_set(skb, metasize);\n \n \t/* record DMA address if this is the start of a chain of buffers */\n \tif (!ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_EOP))\n@@ -2326,7 +2348,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,\n \t\tif (!skb) {\n \t\t\txdp.data = page_address(rx_buffer->page) +\n \t\t\t\t   rx_buffer->page_offset;\n-\t\t\txdp_set_data_meta_invalid(&xdp);\n+\t\t\txdp.data_meta = xdp.data;\n \t\t\txdp.data_hard_start = xdp.data -\n \t\t\t\t\t      ixgbe_rx_offset(rx_ring);\n \t\t\txdp.data_end = xdp.data + size;\n","prefixes":["net-next","6/6"]}