Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1008069pxb; Wed, 6 Apr 2022 06:35:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOIbBIrynvsr9UDaet1NMCzx12NGHyoahl1DJ64XUq1b0cHQPxv3N1svgJMGLn1e9yyy1V X-Received: by 2002:a05:6a00:1593:b0:4fb:344:2c40 with SMTP id u19-20020a056a00159300b004fb03442c40mr8902983pfk.44.1649252135414; Wed, 06 Apr 2022 06:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649252135; cv=none; d=google.com; s=arc-20160816; b=lMExpv2mAdZZ5VfZQVPDEK6kqRSA7NundAFt9HLrYDwxzbTIWBqPwrCKaXCoWf7D8L E6JJAVybdNo9TJADf0oUaH81ssODLzu0RzscfRztGUBkKM9mvy/Bb8/xbh4UgZVs0KR0 QOTOrpQsH/YwvmdRcRvNLPyKl3kxibzoMo8RHJF7mbmSZXsMZ0QSeGZ7rIHKuTvYIufO sVcP2vtMY8CudmBgZlfzEes3fSPNGI15+8rKxyRzgBXp9h485+4Q1SIJDbcQXHnzRFF3 c8SELgi7oTMl9kIp83Eq1mB9Zq4kdS4r4ljITMHPS9/+j1CMxgmlS1YHy3kPI1sDkI2C vz6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TeXKQG3Ahakcp2vdGASx5xpJtlg8LjkdecwThLJFFbk=; b=KMdbuak5ieqIx7IUIETKElhFt09YMLmKgN4SAPJxAYVYxC6U1qspNgjViH8rzDV4/o g8Uv0Ianwje8YZJWpek9lL+x/uPLv5Vhuly1idMm/RNVNtkM3G6q6XLaVSnaC2DIspt6 7w5BQ46BUqP8m0cuzZ9fuSon5MePL7KCdwgcoQ4RYQvXPeJ2bDLCHiLh4o3fHJzi8BpN uk4atBI9jZ17CUrFtVLmujFNpsESC9yT67Lcoj97CgLTZrkZHpoUzQnhoFGSbJCFw+vM QR7tygx3OFMWX/+0i2UGJRl5wss+EHU5vp/0ZSC7D5SFv783cTb4CEusoqRZPtRc+f2X HJWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Oi4OYppb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q13-20020a17090311cd00b00153b2d1641fsi17907400plh.39.2022.04.06.06.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:35:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Oi4OYppb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F3C6B5D815F; Wed, 6 Apr 2022 04:16:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1583792AbiDEX4l (ORCPT + 99 others); Tue, 5 Apr 2022 19:56:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348919AbiDEJsq (ORCPT ); Tue, 5 Apr 2022 05:48:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B3A7EE4EB; Tue, 5 Apr 2022 02:37:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3BAA6B81C82; Tue, 5 Apr 2022 09:37:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91F5FC385A4; Tue, 5 Apr 2022 09:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151446; bh=jMa5vKX+IK/TdveRuGnDnVQhQTMh4DJUkiqPggtNSi8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oi4OYppbXDxcbTtDUSD4c37ZrrAk+ZIWX5a2BLmBevitYnv4mhaZSqv4FxtE6ZL6M RaMjaKLi3UR9enPEpXlzOlZrivAkv7Py8fv/o9E7x9rdB2kFfCMf4HMjZLWa+WmrQH u1+o/rHhMrGseuAX0xmwNIC9brukb0qYwAGV2a+c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jesper Dangaard Brouer , Maciej Fijalkowski , Alexander Lobakin , Michal Swiatkowski , Kiran Bhandare , Tony Nguyen , Sasha Levin Subject: [PATCH 5.15 411/913] i40e: respect metadata on XSK Rx to skb Date: Tue, 5 Apr 2022 09:24:33 +0200 Message-Id: <20220405070352.165820389@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Lobakin [ Upstream commit 6dba29537c0f639b482bd8f8bbd50ab4ae74b48d ] For now, if the XDP prog returns XDP_PASS on XSK, the metadata will be lost as it doesn't get copied to the skb. Copy it along with the frame headers. Account its size on skb allocation, and when copying just treat it as a part of the frame and do a pull after to "move" it to the "reserved" zone. net_prefetch() xdp->data_meta and align the copy size to speed-up memcpy() a little and better match i40e_construct_skb(). Fixes: 0a714186d3c0 ("i40e: add AF_XDP zero-copy Rx support") Suggested-by: Jesper Dangaard Brouer Suggested-by: Maciej Fijalkowski Signed-off-by: Alexander Lobakin Reviewed-by: Michal Swiatkowski Tested-by: Kiran Bhandare Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/i40e/i40e_xsk.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c index 48f5319a3d41..3f27a8ebe2ec 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c @@ -243,19 +243,25 @@ bool i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 count) static struct sk_buff *i40e_construct_skb_zc(struct i40e_ring *rx_ring, struct xdp_buff *xdp) { + unsigned int totalsize = xdp->data_end - xdp->data_meta; unsigned int metasize = xdp->data - xdp->data_meta; - unsigned int datasize = xdp->data_end - xdp->data; struct sk_buff *skb; + net_prefetch(xdp->data_meta); + /* allocate a skb to store the frags */ - skb = __napi_alloc_skb(&rx_ring->q_vector->napi, datasize, + skb = __napi_alloc_skb(&rx_ring->q_vector->napi, totalsize, GFP_ATOMIC | __GFP_NOWARN); if (unlikely(!skb)) goto out; - memcpy(__skb_put(skb, datasize), xdp->data, datasize); - if (metasize) + memcpy(__skb_put(skb, totalsize), xdp->data_meta, + ALIGN(totalsize, sizeof(long))); + + if (metasize) { skb_metadata_set(skb, metasize); + __skb_pull(skb, metasize); + } out: xsk_buff_free(xdp); -- 2.34.1