Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4332652rwb; Sun, 13 Nov 2022 04:09:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf45wD05ITnFbwOdltSVMnp13k2OHePEXX5fKBOpcu9larly573JslKv8kkUugEoCXnBJofR X-Received: by 2002:aa7:d4d0:0:b0:462:273b:6b5c with SMTP id t16-20020aa7d4d0000000b00462273b6b5cmr7678016edr.57.1668341381524; Sun, 13 Nov 2022 04:09:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668341381; cv=none; d=google.com; s=arc-20160816; b=cxklvBPgslQo+MlPb6nTvFgE0/b9z65NjN71ZzXEWXpJzj65+KB/6Jt8wDYTYyFxjM EnnweL5T8U4OLnKl1WCHTGwpsCKPwyVYkbz2yFLrQk0+JTW2WtPwcjsdqjV8uF40JsXN kGj26epaiMFE7Urwt489vpPy8+KS4MBCr/AAe7r4nXJHbs79xwx3hdqpScTm/ZaAw7p0 MPqxFnlb1xa7sT/os0XZNCdDSEkQPKsOTs51LGRXcwgom2wmuIIZ+9j7MK6+rK401Hj6 BDtbffL3LSgjvoL+LtF9BFza4Xf7pfV8ZO22OCvnETM1+Ha0tzyi7iUHoIypX6VfhpBb CfbA== 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=Y3XaJe7HU29G6mhB6yKGc/jcj6No8cfwY4vdpEL1zsg=; b=U2qqhIsVO5OE5PdkTd73gSkRjb59vxFKCN5TPsVbCvnb14CqdeWtmtwknpsCzODahn WJ5+WNlfOAbeFTbgpJEs4iwTEjHyoQq2yCa07GaFHq1mxYqBCipey/C8Lp8QZf7vv5Kv dYoFVyEGVRyD5cVH7ldNHbvfghL4bMwNS6VYnitrxMyJTyse6orfkap3mim3AunNuoqa JeU+t2xG2Odmp01w5X4pOZv8y3HIXW9VTeeFa45vvL9zQBnUpYRwfv9BKPAqfFi5Mo42 Kv5uYNbDD2AV0T0Ln+UyEIF44crOHydF2eWj53UKHprhIkYlgJSxF6lvbTa6KgpQHBKS wMHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=SPqeb664; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x12-20020a05640226cc00b004631f24f2d1si6784712edd.610.2022.11.13.04.09.18; Sun, 13 Nov 2022 04:09:41 -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=SPqeb664; 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 S235240AbiKMLMZ (ORCPT + 89 others); Sun, 13 Nov 2022 06:12:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235207AbiKMLMW (ORCPT ); Sun, 13 Nov 2022 06:12:22 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CFCB12AF3; Sun, 13 Nov 2022 03:12:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1668337941; x=1699873941; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HZHZO0WhtkDNe6O+t1GNqVTy3ldQ1ijx80yqsva3JXA=; b=SPqeb664/AWGva7ef4h1O3NaDADaZ+NH//h1QYs9ssd4mIsmSbh01nRV BCpaROspflOLpzRhvLpCdDSaCRoEDiImBccSsG+L9hz1KtpCHaw8Yl7lk ihqxXbTLVYAmJwITSHYphgWsTDcdQi8CvRYYtRlx80fg4gHNh9YB4WkbA Dv4uxgqgYbFPKvtzUJQTmr0iM/utvsQZxITqmeXyLquJNiqvs0f+4E04J t1NCLexDaqGXD+Z9IhHt6qTKfZFbup31T3Z1aAb9xhMUvTQg1KjPwXilg tVhouNT2j6kEitwOk4LmvJ+Vi0M32fHQKrwAQyFrcHrv8kBwYTDd0KaB/ g==; X-IronPort-AV: E=Sophos;i="5.96,161,1665471600"; d="scan'208";a="183271854" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 13 Nov 2022 04:12:20 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Sun, 13 Nov 2022 04:12:19 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Sun, 13 Nov 2022 04:12:17 -0700 From: Horatiu Vultur To: , , CC: , , , , , , , , , , Horatiu Vultur Subject: [PATCH net-next 1/5] net: lan966x: Add XDP_PACKET_HEADROOM Date: Sun, 13 Nov 2022 12:15:55 +0100 Message-ID: <20221113111559.1028030-2-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221113111559.1028030-1-horatiu.vultur@microchip.com> References: <20221113111559.1028030-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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,SPF_PASS 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 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 | 22 +++++++++++++------ .../ethernet/microchip/lan966x/lan966x_xdp.c | 5 +++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c index 5fbbd479cfb06..dc1ac340e1fb3 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; @@ -444,7 +448,9 @@ static int lan966x_fdma_rx_check_frame(struct lan966x_rx *rx, u64 *src_port) if (!lan966x_xdp_port_present(port)) return FDMA_PASS; - return lan966x_xdp_run(port, page, FDMA_DCB_STATUS_BLOCKL(db->status)); + return lan966x_xdp_run(port, page, + FDMA_DCB_STATUS_BLOCKL(db->status) + + XDP_PACKET_HEADROOM); } static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx, @@ -466,7 +472,8 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx, skb_mark_for_recycle(skb); - skb_put(skb, FDMA_DCB_STATUS_BLOCKL(db->status)); + skb_put(skb, FDMA_DCB_STATUS_BLOCKL(db->status) + XDP_PACKET_HEADROOM); + skb_pull(skb, XDP_PACKET_HEADROOM); lan966x_ifh_get_timestamp(skb->data, ×tamp); @@ -786,7 +793,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..bab447e79273f 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c @@ -44,8 +44,9 @@ 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, - data_len - IFH_LEN_BYTES, false); + xdp_prepare_buff(&xdp, page_address(page), + IFH_LEN_BYTES + XDP_PACKET_HEADROOM, + data_len - IFH_LEN_BYTES - XDP_PACKET_HEADROOM, false); act = bpf_prog_run_xdp(xdp_prog, &xdp); switch (act) { case XDP_PASS: -- 2.38.0