Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp736780pxb; Tue, 5 Apr 2022 21:03:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwDxNKYzmQ8no9M1e/5qLvwLAGsIpQ0jip9PRmn055dXrD9LEOeg4YBaqBwYbPLUgKQPko X-Received: by 2002:a17:902:a501:b0:153:f956:29f0 with SMTP id s1-20020a170902a50100b00153f95629f0mr6752100plq.120.1649217808769; Tue, 05 Apr 2022 21:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649217808; cv=none; d=google.com; s=arc-20160816; b=dgbW7BHQcNL9SVwHV9yyWsbGA8A2qWgL3RkA0N1FOnqGi99zb5o34ArheE4rmPtL3U sDNxgGc8Qj973joi6TkB/+9S+sFV57c4wHPSHAGTl/nfY4ncPaRb2VOPSrRWTUYSeMCK gVkvMgEjjQzqI4504RUtLl5amSCMOCq7gRtUeHkFNDIHRUzlKxMv4RItMepmh4jBBSgt UJJkTApLUx4iJN1DHRfXwiOCUcdnBs5tkyi/hlIu/EQnHZnCeqDqHwxlEscdNJtxwMMK S+znfbLaN1Ewene+cw8uqwn5tJKQZV1QcaRfr60KjhQr4TokrJqeEPq/2S7SFHVPGbG0 6UyQ== 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=JJU9HOeU2VEpyU+cxv1UP+ViXslF32xbOGviPJLZJ4w=; b=Ldm9XAynTASlRBAAGsz2B9qC2KiDsg/7un9ON62v4s4QKyfEF27BbP58eDZ5qTkjue qj7E+sMcNW2AFR7+ogYJbzZ2ka5iUlu9wZfgQizDTzIBudMlnTT4MmgpMuW/G2thJJAk UvHV7wEYJk4Lm87hjseIialPueMdUxNie9sJijFg5njGVCEaO01ODbNI9Duo/a4ZJjMM 7NQGbMjuSDzFAQXT1H/Q4yYZvqaYvAu7sziCdpk2eiumF2/dtZmUg6qjhFfEtYVYl9O+ GvGoh4rz1bRfRxILFCiEh4fJXQJDv/am/nsQoaGNFyjSCpoIm9rPW0X/CAap9624EYE5 Tujw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Og2x+pC6; 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 x2-20020a170902b40200b0015663d4ac43si13557732plr.346.2022.04.05.21.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 21:03:28 -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=Og2x+pC6; 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 70EE516BF92; Tue, 5 Apr 2022 20:43:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1392501AbiDFB24 (ORCPT + 99 others); Tue, 5 Apr 2022 21:28:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349008AbiDEJsz (ORCPT ); Tue, 5 Apr 2022 05:48:55 -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 D2D3DDF5A; Tue, 5 Apr 2022 02:39:03 -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 6DF87615E5; Tue, 5 Apr 2022 09:39:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 807C4C385A1; Tue, 5 Apr 2022 09:39:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151542; bh=Ti/hMQRoUjDzZyl/JprxiwoA8pb7BvXKCaYpu3E0oKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Og2x+pC6YH5NmOBgFzZpQMdWa3I6EH8U2KZzkZ33pBLq/nTcmZHiGoRWgyDHG1Fkd xl8msuiLtRZ6DPMyM+owxRwqBp6snndBRKPjE1Z3SQJGXo+mZk/MP8kUs7HIqnqnB2 pgPr5sad/kzm3+DkuMw93AIDF0sWqgKp+1FBfrWA= 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.15 415/913] ixgbe: respect metadata on XSK Rx to skb Date: Tue, 5 Apr 2022 09:24:37 +0200 Message-Id: <20220405070352.287506962@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 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 36f43dc3a55e..b399b9c14717 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c @@ -203,19 +203,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