Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp672164pxb; Tue, 5 Apr 2022 18:10:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6uHv09l5KE8KyhosUj5CopJ3aoSE9v85NEvrarDtDvWFkK7SgVP3mjv5SVwZau6Tr7YJD X-Received: by 2002:a17:906:58cb:b0:6df:f696:9b32 with SMTP id e11-20020a17090658cb00b006dff6969b32mr6243830ejs.384.1649207428214; Tue, 05 Apr 2022 18:10:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649207428; cv=none; d=google.com; s=arc-20160816; b=IrobogNpejVw7YB3dvwVrCoK4uF6wE0hY5uz/+XnoOk/gWnAX/ZyYU3euH/2nXuj07 kBtO4r/a2CQtFsZCzU03JV+5Dqiqu4j4y8yoGf3KEYJAm+vFLJdheD69OeSljnJst+HK tDcW+VvVesJkvu20RQhs8ZzMbvZRqkmOeDchMsQRYdF+8nYUJK7NC1Kv6gyXcNreV6kP fc8DbgUcr3/OZgqK8t+ziGoYjyP/chN0fTGEHA/RUba15cO9zXWFBwDL9fBfHPCxJI4X yNYWEbZA+lJW+2t0TZVhheDzo02NsffHJK37rrNPgnd+C52XwKsc6pAFpxHsGN64uZ07 Zr4Q== 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=rkYqf6xSBBj/nIHkshTSve5T3DNLQ+hQHbYAZQx1RPg=; b=zozbPkMbAkfDXrVN5taqJvuRUjRc9gIHcvcA8ciOMkJiCYBxnR/9aZ0gWtRXx/YoJM mIytvS0kiV04TpSt8xt3AgZ9W3vw9yiSs6Q2i0822f1vXwzpC/CWHYOSyTE4zXoGD+/G qGYnV2DVyXCQ+nwwIe966j7o47IpI15DyU1kl9C9/plUNL5Qc1Mfq6turdj8Rtslm/8N 7F4N/eJ7sFZDspNHrdQ+wTwFD2jBpQ3EQnZfCtZWlhbyR1YtxpO5vu0dJeHHd7Kk5BFL ZrrazVWNHsFZylOrBhGfqITjcPWtSKdDECAVol6iw4n2eX/yXRdHKSnekn2iYQOrFdJt P41g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zfrKNTQC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a1709064f0800b006df76385beesi7018381eju.142.2022.04.05.18.10.02; Tue, 05 Apr 2022 18:10:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zfrKNTQC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381294AbiDEL7C (ORCPT + 99 others); Tue, 5 Apr 2022 07:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245075AbiDEIxH (ORCPT ); Tue, 5 Apr 2022 04:53:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93B7C1097; Tue, 5 Apr 2022 01:51:08 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 2F9E861509; Tue, 5 Apr 2022 08:51:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40B8DC385A0; Tue, 5 Apr 2022 08:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148667; bh=vo2l9ZPlJPVhjO2uQ2ACZYHyIJ7GtH8lJKq6iOGV7Tk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zfrKNTQCb/bAAAJXD5TSAjMUY5Gj3AS+fGsb4DwHPcM+RyNAG7IUQNQUflpPXXiXX oeNiq/i7w1S0qI63gzJRUc49Z6Nk60qBOw2897YUUaI8erIDyjN8LYLd58NZIWCJvY j+TzJ9AMg7N950musNMrmECiMH1a3sqH8HSBjPh8= 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.16 0439/1017] i40e: respect metadata on XSK Rx to skb Date: Tue, 5 Apr 2022 09:22:32 +0200 Message-Id: <20220405070407.325572312@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 dff7c7fcc329..2553b130108d 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c @@ -241,19 +241,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