Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp689056pxb; Tue, 5 Apr 2022 18:53:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+HGD17Q027A5WGZNKNpqVzfIuEQeUtA47ts+PrhlpYCW5XjLTr7u4cVxbAsSMbkTHBQjB X-Received: by 2002:a05:6a00:a26:b0:4fd:f9dd:549c with SMTP id p38-20020a056a000a2600b004fdf9dd549cmr6480440pfh.42.1649210001635; Tue, 05 Apr 2022 18:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210001; cv=none; d=google.com; s=arc-20160816; b=m1X+oYa7jOaVCYcILJJB6jTlAduNnKB3zG5MdGbuqXbOQWh+DrHABaG3iHwApOdQ3j 64G0VsjBJpbkVe30vYPBCMeQXFin+qbxxZTYTp5xN27ypTnIexxET35U4OoBiir5y9hB cJ+Dd/HIPu603WEKIuyG1sHNcRU5G+EybiVRcbTattFM6eXgKxG2Ff2WbuwhxeQgPGWI t/TO587zwZQWet0OIMgAn8rYafk8XkKyuxs/mC9F1tOUbhZPgJYCM4VM1sPW3jMHV7nv hhbe1D/60EF1CzKI5YKdk/H26SU/blRmBXo2W/4r4lRt6Fu+nWIqdfmSFrlkbhnZQRHN 4oJQ== 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=0NO48LHdzHa87eKpXnbARiH6RkfRGBPqJZP1X/Bdy/Q=; b=i75RPI9uP7tZbdVCWHob8Ao8JBJ7Vkz3maaBvl8nj5/QoLCSMT14U6kojiH/PKayP9 3LeJAcbNLiVHZEEXdXpxstMehKqtU4S1oloaidHvyR1+tZZzhSRqFGDwot+jl9ouHTqH R0VPm2SF3BhrYYPWSsGBkdD50AM/JK+jLAYqDGO3834egev+eOQnhQwAsgTR0utvYEOf 5nGOvp1a/NCs5vecITW8NEPwY9fQRX6QND+O7+PGBfbiLqe+0bZ74C99+hyj+jwTIGW3 PvIVIUgqzkeMW+RJk+VQ9h0bROqUcPpVNCgOHGBBeaKb3fUbIBACWJZwfKDfQfSHktLH O9UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L3dlVKB1; 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 a37-20020a631a25000000b003985223c137si14436200pga.354.2022.04.05.18.53.06; Tue, 05 Apr 2022 18:53:21 -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=L3dlVKB1; 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 S239173AbiDEIoq (ORCPT + 99 others); Tue, 5 Apr 2022 04:44:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232990AbiDEIEx (ORCPT ); Tue, 5 Apr 2022 04:04:53 -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 56C2762C94; Tue, 5 Apr 2022 01:01: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 E729061668; Tue, 5 Apr 2022 08:01:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEF6CC3410F; Tue, 5 Apr 2022 08:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145667; bh=bVEPAGwn5Sk1aFoFushqrnLjvlDtDg7rK9rf5Q4UiIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L3dlVKB1h/yQZEoWn7su3Ozth5ZuaPUV0dI8dCAYGdWy0iboJwvGr42nd7uet3O31 DZ15btWgJ8PSrkZufgNfCOwol6iSQreRLFDhhnBjhfrd1zXXnWfOoDUsGn+hYdRaFu cZeA6WncWhiRFmT3O1JlvFutuR99KU7teyuonj64= 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 , Sandeep Penigalapati , Tony Nguyen , Sasha Levin Subject: [PATCH 5.17 0486/1126] ixgbe: respect metadata on XSK Rx to skb Date: Tue, 5 Apr 2022 09:20:33 +0200 Message-Id: <20220405070421.892272259@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 f322a620be69e95594eda89502b478aa7dbf6ec2 ] 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 ixgbe_construct_skb(). Fixes: d0bcacd0a130 ("ixgbe: 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: Sandeep Penigalapati Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c index eec42c907d57..dd7ff66d422f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c @@ -209,19 +209,25 @@ bool ixgbe_alloc_rx_buffers_zc(struct ixgbe_ring *rx_ring, u16 count) static struct sk_buff *ixgbe_construct_skb_zc(struct ixgbe_ring *rx_ring, const 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)) 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); + } return skb; } -- 2.34.1