From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mail.toke.dk (Postfix) with ESMTPS id 1EC5E982DA3 for ; Tue, 28 Jun 2022 21:49:40 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=C3B0BxgV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656445781; x=1687981781; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=djZbQklvKIuE0rRB8nAV8RBPw505lomk91c2ko+Lmfs=; b=C3B0BxgVtZqEO/XJD/mXtMgLD7tFduh/hbR54/zx8eHzHLLrJIj64MTU mMexSDSD9c5esCfrN0J6UgC3+fmFsSuypuZrH9cvqu0xpfuVtBxNHel8R 5f/V/0ORq0Z2pM371JflLG53dhqlpLj1WP2pt/7FKZKbpMaIS5q6+I0Jb p8n+PJGrSBDacEXRkfHqB6TzHF24e4/iHujzeJZ2p/BVUWkXmUFKtkPUF sQ25o0xG0Kh7Umy7ViEC94szTtMiKzNwQ3dC6CpDLEfac2OepST3MU9P2 6HZx9CnRS2c6hAiCkePtKFRtJqiewaxtYw0rXfn3UGmFm6j721PNQ6nYU Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10392"; a="280595932" X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="280595932" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 12:49:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="693251043" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga002.fm.intel.com with ESMTP; 28 Jun 2022 12:49:34 -0700 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 25SJmr9T022013; Tue, 28 Jun 2022 20:49:32 +0100 From: Alexander Lobakin To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Date: Tue, 28 Jun 2022 21:47:49 +0200 Message-Id: <20220628194812.1453059-30-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628194812.1453059-1-alexandr.lobakin@intel.com> References: <20220628194812.1453059-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: O3VQRTHIICN2V7PWL334BHFVKK6HSDVX X-Message-ID-Hash: O3VQRTHIICN2V7PWL334BHFVKK6HSDVX X-MailFrom: alexandr.lobakin@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Alexander Lobakin , Larysa Zaremba , Michal Swiatkowski , Jesper Dangaard Brouer , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Toke Hoiland-Jorgensen , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesse Brandeburg , John Fastabend , Yajun Deng , Willem de Bruijn , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.5 Precedence: list Subject: [xdp-hints] [PATCH RFC bpf-next 29/52] net, xdp: try to fill skb fields when converting from an &xdp_frame List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In __xdp_build_skb_from_frame(), if there's a metadata in front of the data, check if it's a generic-compatible metadata and try to populate the HW-originated skb fields: checksum status, hash etc. As xdp_populate_skb_meta_generic() requires the skb->mac_header to be set and valid, call the skb_reset_mac_header() first, as skb->data at this point is pointing (sic!) to the MAC header. The two most obvious users are cpumap and veth. Signed-off-by: Alexander Lobakin --- net/bpf/core.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/net/bpf/core.c b/net/bpf/core.c index 775f9648e8cf..d2d01b8e6441 100644 --- a/net/bpf/core.c +++ b/net/bpf/core.c @@ -659,8 +659,11 @@ struct sk_buff *__xdp_build_skb_from_frame(struct xdp_frame *xdpf, skb_reserve(skb, headroom); __skb_put(skb, xdpf->len); - if (metasize) + if (metasize) { + skb_reset_mac_header(skb); skb_metadata_set(skb, metasize); + xdp_populate_skb_meta_generic(skb); + } if (unlikely(xdp_frame_has_frags(xdpf))) xdp_update_skb_shared_info(skb, nr_frags, @@ -671,12 +674,6 @@ struct sk_buff *__xdp_build_skb_from_frame(struct xdp_frame *xdpf, /* Essential SKB info: protocol and skb->dev */ skb->protocol = eth_type_trans(skb, dev); - /* Optional SKB info, currently missing: - * - HW checksum info (skb->ip_summed) - * - HW RX hash (skb_set_hash) - * - RX ring dev queue index (skb_record_rx_queue) - */ - /* Until page_pool get SKB return path, release DMA here */ xdp_release_frame(xdpf); -- 2.36.1