From patchwork Mon Nov 21 21:28:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 24015 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1843475wrr; Mon, 21 Nov 2022 13:28:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf5pdllBDfzd4Ncidan5cD+JJ/yKNd1zvsgMLy4X+7+tpS026LRo9YF3tdLHmQjeJjeDXlt1 X-Received: by 2002:a50:fc10:0:b0:464:2afe:ae18 with SMTP id i16-20020a50fc10000000b004642afeae18mr18765809edr.183.1669066109015; Mon, 21 Nov 2022 13:28:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669066109; cv=none; d=google.com; s=arc-20160816; b=U9wBrzieYg3otoBMVNxoIdC/m1qYYDjwwo9DeGdrUeBhQ1tqG+ig162PEnvTJ7UkLN 5av+wmtYm5alZAKaUvfMIyyftAxoE3Kxua1Lqws50Vkp9807EBz0olhlNuWDC5ibNmUI 4e5BB7f6nKADaIYv9lIYaQFFb14Qujk2gJYISh3bUXNgmKnNdsOfeTjJx1b0AnN1xhwQ m04cBU9OcKotWEUOx5sNqmIvuE/PiUcg+UiEao8eBSULppqYfv2uvws47UgJzLlSDju5 hQZYeZK1jCL9FhJeAiYTxZNX3s3jmjkb7m0R9L6dihujs7SyJdTDqzsUM5VYX/5kCvkM +CMg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sbC7PiRZPINxL6kTcqUkLmMBkJDE3KtV3T6vvAK6zKQ=; b=Dho/hiisWqdj9hxbSF0f0yaKnThkSE/CPxAuZe3Sv4mqDEkLCzITAOCwDN3G2niqe0 QE/hfPCfV/ieEl4o0wAdC0a9Kf97VtBlUHzWdmC91fo43X3wqKQnxa8M9iFSeHfQvpuV VPoo0uyXoC8BWBVOF1yc1dLdWlV5t1HY9fuQMpWfcxZ/e0x1eT91tj8P06b7BolD4pvH SAgQLMPpKDWtQS7euSpFxflXtoO19z7S3kX5NCl/M9s6EdE1zWYEglRvvNBFx9fxPJKI pGkDiKF7Es1+Om6L1J7mjQW17rPECaEIki1Ps96JFWbCiqo9DSUhISfI3Z33aFk8Le0/ zqMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=XVf0aCtL; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c13-20020a170906340d00b007adbc807ca8si8302747ejb.137.2022.11.21.13.28.01; Mon, 21 Nov 2022 13:28:28 -0800 (PST) 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=@microchip.com header.s=mchp header.b=XVf0aCtL; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230228AbiKUVYr (ORCPT + 99 others); Mon, 21 Nov 2022 16:24:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiKUVYp (ORCPT ); Mon, 21 Nov 2022 16:24:45 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C4DB14D3A; Mon, 21 Nov 2022 13:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669065881; x=1700601881; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WQHtk5rD0UFDH3ezGkF35r6wv2LNLOm3eEkyD65lDDA=; b=XVf0aCtL/681SfdVnHJYCcRLGwk2h6KS2DhLTGV35rVRl61SnuRKQxcD 1miEamsZQ0BdFSwinx677UyR6A/SmfitHH+ubDB5jtKK5vSvUiV98Vvg0 sKSK1QKmiA1TLAhdFBsIdj2VwlrQYhzVzl9URQPfF9WwGAs0MnLYno+Ml aDiIHYUPgVybIxKF17d91junP6h4Ic+TaHFaGTPYBY/ovCt3/dBs9CbDx SsVdmyCkbZi+42nkmxebCQB4lxhmpLBm8YiTN7EI93MxgINKGhE+cAWxQ Qh1kCpUy/rGNNeewpLA/knQdWgjc9ltP76pze88R4FPJXd35G/vnscYe6 w==; X-IronPort-AV: E=Sophos;i="5.96,182,1665471600"; d="scan'208";a="124468619" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 21 Nov 2022 14:24:40 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Mon, 21 Nov 2022 14:24:35 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Mon, 21 Nov 2022 14:24:33 -0700 From: Horatiu Vultur To: , , CC: , , , , , , , , , Horatiu Vultur Subject: [PATCH net-next v3 1/7] net: lan966x: Add XDP_PACKET_HEADROOM Date: Mon, 21 Nov 2022 22:28:44 +0100 Message-ID: <20221121212850.3212649-2-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221121212850.3212649-1-horatiu.vultur@microchip.com> References: <20221121212850.3212649-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,T_SPF_TEMPERROR 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750142664713039626?= X-GMAIL-MSGID: =?utf-8?q?1750142664713039626?= Update the page_pool params to allocate XDP_PACKET_HEADROOM space as headroom for all received frames. This is needed for when the XDP_TX and XDP_REDIRECT are implemented. Signed-off-by: Horatiu Vultur --- .../ethernet/microchip/lan966x/lan966x_fdma.c | 16 +++++++++++----- .../net/ethernet/microchip/lan966x/lan966x_xdp.c | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c index 5fbbd479cfb06..3055124b4dd79 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ +#include + #include "lan966x_main.h" static int lan966x_fdma_channel_active(struct lan966x *lan966x) @@ -16,7 +18,7 @@ static struct page *lan966x_fdma_rx_alloc_page(struct lan966x_rx *rx, if (unlikely(!page)) return NULL; - db->dataptr = page_pool_get_dma_addr(page); + db->dataptr = page_pool_get_dma_addr(page) + XDP_PACKET_HEADROOM; return page; } @@ -72,7 +74,7 @@ static int lan966x_fdma_rx_alloc_page_pool(struct lan966x_rx *rx) .nid = NUMA_NO_NODE, .dev = lan966x->dev, .dma_dir = DMA_FROM_DEVICE, - .offset = 0, + .offset = XDP_PACKET_HEADROOM, .max_len = rx->max_mtu - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)), }; @@ -432,11 +434,13 @@ static int lan966x_fdma_rx_check_frame(struct lan966x_rx *rx, u64 *src_port) if (unlikely(!page)) return FDMA_ERROR; - dma_sync_single_for_cpu(lan966x->dev, (dma_addr_t)db->dataptr, + dma_sync_single_for_cpu(lan966x->dev, + (dma_addr_t)db->dataptr + XDP_PACKET_HEADROOM, FDMA_DCB_STATUS_BLOCKL(db->status), DMA_FROM_DEVICE); - lan966x_ifh_get_src_port(page_address(page), src_port); + lan966x_ifh_get_src_port(page_address(page) + XDP_PACKET_HEADROOM, + src_port); if (WARN_ON(*src_port >= lan966x->num_phys_ports)) return FDMA_ERROR; @@ -466,6 +470,7 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx, skb_mark_for_recycle(skb); + skb_reserve(skb, XDP_PACKET_HEADROOM); skb_put(skb, FDMA_DCB_STATUS_BLOCKL(db->status)); lan966x_ifh_get_timestamp(skb->data, ×tamp); @@ -786,7 +791,8 @@ static int lan966x_fdma_get_max_frame(struct lan966x *lan966x) return lan966x_fdma_get_max_mtu(lan966x) + IFH_LEN_BYTES + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + - VLAN_HLEN * 2; + VLAN_HLEN * 2 + + XDP_PACKET_HEADROOM; } int lan966x_fdma_change_mtu(struct lan966x *lan966x) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c b/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c index e77d9f2aad2b4..8ebde1eb6a09c 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c @@ -44,7 +44,8 @@ int lan966x_xdp_run(struct lan966x_port *port, struct page *page, u32 data_len) xdp_init_buff(&xdp, PAGE_SIZE << lan966x->rx.page_order, &port->xdp_rxq); - xdp_prepare_buff(&xdp, page_address(page), IFH_LEN_BYTES, + xdp_prepare_buff(&xdp, page_address(page), + IFH_LEN_BYTES + XDP_PACKET_HEADROOM, data_len - IFH_LEN_BYTES, false); act = bpf_prog_run_xdp(xdp_prog, &xdp); switch (act) {