Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp684578pxb; Tue, 5 Apr 2022 18:42:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwI6xUriXyIsGiQfavPI1DYrLmfjR6ZOP4xOQPpB4g0h80FOWAtDp7VBHK04JIW8acCGNoj X-Received: by 2002:a17:907:2d8d:b0:6df:a06c:7c55 with SMTP id gt13-20020a1709072d8d00b006dfa06c7c55mr6154570ejc.325.1649209323824; Tue, 05 Apr 2022 18:42:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649209323; cv=none; d=google.com; s=arc-20160816; b=eDsWrXq8UlnwhtFDhDMPFWJZzoSdcP/Goj7Xn25//1hPfJa03IX2B3gb/NXCug0xia tmkuV4k4uxdH/0ZLJjn5vJ9rksMG/F6Az1OE2CanuuKXzjbfWt5kfLpc8CmW4a0uHJG6 v/IeUZ8Oo7xvT71q+TNLlCWLBynnzd0+quJoPccN7Eyl/WIoU0RV6lq5/mGoKr2JghZD ScYN5QOd/Fxn/5kC1SGWE4aUDdyLQRDP0W2jFAdAt6GKCvuUyqFvwfgfh3uRcVn3uT/J Hq5v7mw5sEbs+gzfR9xCCiKOGktiirafIsqU2UzLVfjvuxF3T/tbIkrKJqH9jJQUzEl8 Kepg== 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=0eu/A74E9CcGV6m9sYzf/9Mj5pfgz/X1uISCLdABn1c=; b=MgPC0C8Q0UuPuEuJHA84t4tkab/xWXftB7bck8TFxFLIhHM4npn2VpMF4wqZjo6Q64 Es8GM7h27ghyHv4RVdfiKviS7e8s6DzqxIIwJ1Qp4sr6yXqrj2pqaB5MZ/EHIDIM6mQj 9ocwt4Xv04bm5ALpuVeMpkMOC5LGnJbcYOZZwUwkVpeRXGC/OOmIwTztxOXkf/gBsQvS xx+WusUz8uDvSjTRqea15GmIKjngZzuyOh4t9FmwVOM4AGLKpjF/9tdpUvDD2FU7Be4h 0jD9rslVkNyHFBWwON2pdfDQr2q/QGRieBzm8pWoxsb1doO6xF8tVOYorCKwec2mf1tl ++QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s2Dd6Ulr; 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 dz22-20020a0564021d5600b004191b307738si12222758edb.61.2022.04.05.18.41.39; Tue, 05 Apr 2022 18:42:03 -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=s2Dd6Ulr; 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 S238552AbiDEIoP (ORCPT + 99 others); Tue, 5 Apr 2022 04:44:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232147AbiDEIDt (ORCPT ); Tue, 5 Apr 2022 04:03:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9F425DA0B; Tue, 5 Apr 2022 01:00:54 -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 447CF61668; Tue, 5 Apr 2022 08:00:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59468C340EE; Tue, 5 Apr 2022 08:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145653; bh=FCzUSqyFkrXkHcD2H6cFA6cmPBvi2HRH2NQg9q9wzpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s2Dd6Ulr4URy512IEv9ChXRaYCvVe7gnjRcgcofOPCREXuR6wk7cQZAq0VlTXHsDK HSKCVhfyeQHPgjSWqCXNQ3MtQgVt32mkq8Qu9I+3skUQlJqJ6+Pz7D6x2ixa2q0f6q PL1K5vZS0TShuaNwu5SFGgTSPWLi7qkO+Jg0ZMns= 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.17 0482/1126] ice: respect metadata on XSK Rx to skb Date: Tue, 5 Apr 2022 09:20:29 +0200 Message-Id: <20220405070421.775189056@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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 45a34ca68070e34e09d5bf4309f7f1f286a27fc7 ] 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 ice_construct_skb(). Fixes: 2d4238f55697 ("ice: Add support for AF_XDP") 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/ice/ice_xsk.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c index 8fd8052edf09..feb874bde171 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -428,18 +428,24 @@ static void ice_bump_ntc(struct ice_rx_ring *rx_ring) static struct sk_buff * ice_construct_skb_zc(struct ice_rx_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; - skb = __napi_alloc_skb(&rx_ring->q_vector->napi, datasize, + net_prefetch(xdp->data_meta); + + skb = __napi_alloc_skb(&rx_ring->q_vector->napi, totalsize, GFP_ATOMIC | __GFP_NOWARN); if (unlikely(!skb)) return NULL; - 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); + } xsk_buff_free(xdp); return skb; -- 2.34.1