Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp126948rwb; Tue, 8 Nov 2022 23:32:33 -0800 (PST) X-Google-Smtp-Source: AMsMyM6UAdyHlnJh54qmZf+8fZi82+fyFwkRkMcL5Ghd/oTow9PkvqUCfDKPmmGdy3jRc1fSAiSZ X-Received: by 2002:a17:902:70c4:b0:178:54cf:d397 with SMTP id l4-20020a17090270c400b0017854cfd397mr57869680plt.24.1667979153272; Tue, 08 Nov 2022 23:32:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667979153; cv=none; d=google.com; s=arc-20160816; b=M7mH1Fwml1e1Uc0CZnPROsCC+lwUYcL9AoBpDdc5xZ+kmHxaS76o20El1G5c7B80zQ oHfWkTpijRid4lQM9nVKLzj8bDZcEyx6MgVwHaHCQYqhtaaJL7r4Bv7pbuBT4PYAoAjz yqwAZ6sT37hm4TiuacmdtdiLHMARXViX6CtkMhHiZD32ULzBHzuDlr6XUNXQ3r/1HTuc 8iFG26cZU233I14WTcoIXej4MS/8r0ptmEhURq1F0jvmhRx1aFUnhxybaVJQQw4eLkrE yryYzY3XI/YxCOBlz7guQK45r+NkJN8QfJ6OesuUsjH0wECra56L+FFUOH6QuwgOfTN5 KbOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=U8B2IlCM1KQOFRFcvP461adTO1C/MIQI2V9m67rpUrA=; b=HIz7H77wwwZdSx/YJ7gJ2VTkbPnXVqRfpECP+baVWebnH4lnuoPaiebw4NSmv/byDL UA3gh5khJc5hQUgJJkAeh7UPc1WFe6R7h5gBqOrwTL/1GAStJlfaANVKOXHIqKcj6sBU N7GTLQC6mp+7OcGbAnB8b+lOhrpbuRXjhmSB9dfvgHznnzs3NMbuwpHsAVuAdmt5Y/lc RzbqISjQbChQNU15/7Hri7TWRPk2D+yfg3NEEsjWEp7u1S/acDPygxrHnkEbMyUb7/8y VQAJGMHjrJHgpNHBtvt4xC75qY2MDB4+IooLiF7yBJ+8XvhrE5JRNwzOIjDJ+2f1o7ii VT+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=nFvg0vlk; 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 134-20020a63048c000000b0046439853c62si17410770pge.127.2022.11.08.23.32.20; Tue, 08 Nov 2022 23:32:33 -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=nFvg0vlk; 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 S229802AbiKIHVZ (ORCPT + 93 others); Wed, 9 Nov 2022 02:21:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbiKIHVX (ORCPT ); Wed, 9 Nov 2022 02:21:23 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5524AC75B; Tue, 8 Nov 2022 23:21:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1667978480; x=1699514480; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=QT25db/AVyAAIQ4IdtuvBUVY1YCaY8UdcHnQyPzsTu4=; b=nFvg0vlkwL2vCMiz7GEI8mcqyKURLKia86qKRbBo7XphYcyvdeORLni5 KKYQoJd9AWza4T1JCBD+zqfmSToOPe/upnWkpFWVFd5Rbs8G8duUY3XxR /hJUY7daxXqBxZwJafZAxeANJDNvVejO5TsGjF/oULofL+Yqox+jtzoWA mfgtUVn8OV5uRTI8IjA5OXea2jwUU7O0ycml1Z3Jo8DfDJY4fmSUr+sKM 11E0YGanK0A6Ujo/Xt8LkZlpQldKzuGeFohZCke6Un/au9nImTqemJp1E AdDHImCbzDASxtsVWtKgUamRIF3pYFuwqGOo+izHnya7bhhk+mwvjJZG1 w==; X-IronPort-AV: E=Sophos;i="5.96,149,1665471600"; d="scan'208";a="186067139" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 09 Nov 2022 00:21:18 -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; Wed, 9 Nov 2022 00:21:17 -0700 Received: from localhost (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; Wed, 9 Nov 2022 00:21:17 -0700 Date: Wed, 9 Nov 2022 08:26:02 +0100 From: Horatiu Vultur To: Alexander Lobakin CC: , , , , , , , , , , , Subject: Re: [PATCH net-next v2 4/4] net: lan96x: Use page_pool API Message-ID: <20221109072602.ntx6myyx7hiffewk@soft-dev3-1> References: <20221106211154.3225784-1-horatiu.vultur@microchip.com> <20221106211154.3225784-5-horatiu.vultur@microchip.com> <20221107164056.557894-1-alexandr.lobakin@intel.com> <20221107213521.i6qmjut5hdxrrmcs@soft-dev3-1> <20221108113331.605821-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: <20221108113331.605821-1-alexandr.lobakin@intel.com> 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 The 11/08/2022 12:33, Alexander Lobakin wrote: > > From: Horatiu Vultur > Date: Mon, 7 Nov 2022 22:35:21 +0100 > > > The 11/07/2022 17:40, Alexander Lobakin wrote: > > > > Hi Olek, > > > > > > > > From: Horatiu Vultur > > > Date: Sun, 6 Nov 2022 22:11:54 +0100 > > > > > > > Use the page_pool API for allocation, freeing and DMA handling instead > > > > of dev_alloc_pages, __free_pages and dma_map_page. > > > > > > > > Signed-off-by: Horatiu Vultur > > > > --- > > > > .../net/ethernet/microchip/lan966x/Kconfig | 1 + > > > > .../ethernet/microchip/lan966x/lan966x_fdma.c | 72 ++++++++++--------- > > > > .../ethernet/microchip/lan966x/lan966x_main.h | 3 + > > > > 3 files changed, 43 insertions(+), 33 deletions(-) > > > > > > [...] > > > > > > > @@ -84,6 +62,27 @@ static void lan966x_fdma_rx_add_dcb(struct lan966x_rx *rx, > > > > rx->last_entry = dcb; > > > > } > > > > > > > > +static int lan966x_fdma_rx_alloc_page_pool(struct lan966x_rx *rx) > > > > +{ > > > > + struct lan966x *lan966x = rx->lan966x; > > > > + struct page_pool_params pp_params = { > > > > + .order = rx->page_order, > > > > + .flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV, > > > > + .pool_size = FDMA_DCB_MAX, > > > > + .nid = NUMA_NO_NODE, > > > > + .dev = lan966x->dev, > > > > + .dma_dir = DMA_FROM_DEVICE, > > > > + .offset = 0, > > > > + .max_len = PAGE_SIZE << rx->page_order, > > > > > > ::max_len's primary purpose is to save time on DMA syncs. > > > First of all, you can substract > > > `SKB_DATA_ALIGN(sizeof(struct skb_shared_info))`, your HW never > > > writes to those last couple hundred bytes. > > > But I suggest calculating ::max_len basing on your current MTU > > > value. Let's say you have 16k pages and MTU of 1500, that is a huge > > > difference (except your DMA is always coherent, but I assume that's > > > not the case). > > > > > > In lan966x_fdma_change_mtu() you do: > > > > > > max_mtu = lan966x_fdma_get_max_mtu(lan966x); > > > max_mtu += IFH_LEN_BYTES; > > > max_mtu += SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); > > > max_mtu += VLAN_HLEN * 2; > > > > > > `lan966x_fdma_get_max_mtu(lan966x) + IFH_LEN_BYTES + VLAN_HLEN * 2` > > > (ie 1536 for the MTU of 1500) is your max_len value actually, given > > > that you don't reserve any headroom (which is unfortunate, but I > > > guess you're working on this already, since XDP requires > > > %XDP_PACKET_HEADROOM). > > > > Thanks for the suggestion. I will try it. > > Regarding XDP_PACKET_HEADROOM, for the XDP_DROP, I didn't see it to be > > needed. Once the support for XDP_TX or XDP_REDIRECT is added, then yes I > > need to reserve also the headroom. > > Correct, since you're disabling metadata support in > xdp_prepare_buff(), headroom is not needed for pass and drop > actions. > > It's always good to have at least %NET_SKB_PAD headroom inside an > skb, so that networking stack won't perform excessive reallocations, > and your code currently misses that -- if I understand currently, > after converting hardware-specific header to an Ethernet header you > have 28 - 14 = 14 bytes of headroom, which sometimes can be not > enough for example for forwarding cases. It's not related to XDP, > but I would do that as a prerequisite patch for Tx/redirect, since > you'll be adding headroom support anyway :) Just a small comment here. There is no need to convert hardware-specific header, because after that header there is the ethernet header. So I would have 28 bytes left for headroom, but that is still less then NET_SKB_PAD. But I got the idea. When I will add the Tx/redirect, one of those patches will be to make sure we have enough headroom. > > > > > > > > > > + }; > > > > + > > > > + rx->page_pool = page_pool_create(&pp_params); > > > > + if (IS_ERR(rx->page_pool)) > > > > + return PTR_ERR(rx->page_pool); > > [...] > > > > > -- > > > > 2.38.0 > > > > > > Thanks, > > > Olek > > > > -- > > /Horatiu > > Thanks, > Olek -- /Horatiu