Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6461917rwb; Tue, 22 Nov 2022 13:50:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf6kl0kTzFMBS1JiXUykzYl35HYMo7bmqJSuhhIZrE55qFQP/sxDOMKl+LiiQFQHlVCMOYIJ X-Received: by 2002:a17:907:77d6:b0:78d:e26f:bfd8 with SMTP id kz22-20020a17090777d600b0078de26fbfd8mr21403534ejc.482.1669153824904; Tue, 22 Nov 2022 13:50:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669153824; cv=none; d=google.com; s=arc-20160816; b=01DzhaYTyAbw60FUMgiIaUMcfeMS4cG6phTmCOGaSBp5/GL85tTr004oZOxMEQD5LA 6hOa4ww8RHhd3DFySx55+OaxZqCBLZt+4efrte1dNJfGE3+uddTjjcFcSSeTi/Gug3e8 jKh2uyDZmrh1Usix5Gt8LKWHiUqj+gNq6v2Heo0VqpBiupy6Dgk+9a5SP5mMbrACSQOf mA3Avcy3qDtnspVC+tZv1np9Nx31FagaV/Hsog8bB6D1jszSw9nSPimHMaKdhcChzw8Z LG0DDgqO804ykdcEa5uyRbiOutajd5IoQdxgzXxdh8d60YzFNarxQoilDkJVRNl11K3F KgzQ== 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=T16fpdOgA14sQ8oU0Zdc03SIxA7wHPOqq6Giqzl0hvY=; b=dHVstbM1vcHwp5tAl/fKsUQm8Yqy+92IQVU2fQpeKjI1fkbU4hlgG6GYBSuR+JVSci G3NFnHOsbnd3FZcKM5POb9nDMoeqXI6ukjTiLW88uIYqKV7ZkrU1sTPBu1Xqf+HeaQSq A+tCbPu0PKVJt5jiLKluJ82VR5cztvUb/ghuQillCioxVeunJmn1B7Q1wT0+6zwSBY2c BYw3Zb5f3MATi2/de5xtrH0S4pFAyiruWzwATNdtUjuexA3VIsD+kXf/p85emUCx0CYM UyJQQdPRRKmH0qOV0qi853e81O70+34Ag08Iwt18nr9OhWfnSOg2W9FUkwneqcF3cSnz 8iEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=niki0MW8; 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 p13-20020a05640210cd00b0046272b487cesi10100450edu.331.2022.11.22.13.50.03; Tue, 22 Nov 2022 13:50:24 -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=niki0MW8; 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 S235113AbiKVVcv (ORCPT + 89 others); Tue, 22 Nov 2022 16:32:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235069AbiKVVcq (ORCPT ); Tue, 22 Nov 2022 16:32:46 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F6B67640; Tue, 22 Nov 2022 13:32:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669152757; x=1700688757; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ISteiEafnpwfxSB+bh7FKbXTjSTCofLvMskNHi+6Jts=; b=niki0MW8zySgQId4KQJ0TaRx7tzE3ydkYA3Aeph16YmJsCLQSuu0etg+ nggM0G4A/sXdu19qPQIv+mlixWjsJTtPxWmof39W1NW37c+/WwLbRuzZL qfHEdZ3rY9RogWk+HufSt9TvmXKgP0PERhWnm48bEvECo/9/C90y3ld6k uylANtJljdfHocqWuXuo1A5wWO5rTY0ACBO6rEs1rzT2N4aRr4ZMj4sW9 Lf7WAOHReo7vrrh9V9RA8BegLgdax5oNfRWpv96oCkHTslE6+8qGedyr0 4i+LxBRTBJLP08PlblfHvS2ZzdBK3PTQOLWJhxNofIk3IphADRL3jj7s4 A==; X-IronPort-AV: E=Sophos;i="5.96,185,1665471600"; d="scan'208";a="190136597" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 Nov 2022 14:32:34 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Tue, 22 Nov 2022 14:32:33 -0700 Received: from localhost (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; Tue, 22 Nov 2022 14:32:33 -0700 Date: Tue, 22 Nov 2022 22:37:24 +0100 From: Horatiu Vultur To: Alexander Lobakin CC: , , , , , , , , , , , Subject: Re: [PATCH net-next v3 7/7] net: lan966x: Add support for XDP_REDIRECT Message-ID: <20221122213724.exqdhdxujvgtojxq@soft-dev3-1> References: <20221121212850.3212649-1-horatiu.vultur@microchip.com> <20221121212850.3212649-8-horatiu.vultur@microchip.com> <20221122120430.419770-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: <20221122120430.419770-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, RCVD_IN_MSPIKE_H2,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 The 11/22/2022 13:04, Alexander Lobakin wrote: > > From: Horatiu Vultur > Date: Mon, 21 Nov 2022 22:28:50 +0100 > > > Extend lan966x XDP support with the action XDP_REDIRECT. This is similar > > with the XDP_TX, so a lot of functionality can be reused. > > > > Signed-off-by: Horatiu Vultur > > --- > > .../ethernet/microchip/lan966x/lan966x_fdma.c | 83 +++++++++++++++---- > > .../ethernet/microchip/lan966x/lan966x_main.c | 1 + > > .../ethernet/microchip/lan966x/lan966x_main.h | 10 ++- > > .../ethernet/microchip/lan966x/lan966x_xdp.c | 31 ++++++- > > 4 files changed, 109 insertions(+), 16 deletions(-) > > [...] > > > @@ -558,6 +575,10 @@ static int lan966x_fdma_napi_poll(struct napi_struct *napi, int weight) > > case FDMA_TX: > > lan966x_fdma_rx_advance_dcb(rx); > > continue; > > + case FDMA_REDIRECT: > > + lan966x_fdma_rx_advance_dcb(rx); > > + redirect = true; > > + continue; > > I think you can save a couple lines here and avoid small code dup: > > + case FDMA_REDIRECT: > + redirect = true; > + fallthrough; > case FDMA_TX: > lan966x_fdma_rx_advance_dcb(rx); > continue; I will save only a line but I will add this change in the next version as I like it more than what I wrote. > > The logics stays the same. > > > case FDMA_DROP: > > lan966x_fdma_rx_free_page(rx); > > lan966x_fdma_rx_advance_dcb(rx); > > [...] > > > @@ -178,6 +180,7 @@ struct lan966x_tx_dcb_buf { > > struct net_device *dev; > > struct sk_buff *skb; > > struct xdp_frame *xdpf; > > + bool xdp_ndo; > > I suggest carefully inspecting this struct with pahole (or by just > printkaying its layout/sizes/offsets at runtime) and see if there's > any holes and how it could be optimized. > Also, it's just my personal preference, but it's not that unpopular: > I don't trust bools inside structures as they may surprise with > their sizes or alignment depending on the architercture. Considering > all the blah I wrote, I'd define it as: > > struct lan966x_tx_dcb_buf { > dma_addr_t dma_addr; // can be 8 bytes on 32-bit plat > struct net_device *dev; // ensure natural alignment > struct sk_buff *skb; > struct xdp_frame *xdpf; > u32 len; > u32 xdp_ndo:1; // put all your booleans here in > u32 used:1; // one u32 > ... > }; Thanks for the suggestion. I make sure not that this struct will not have any holes. Can it be a rule of thumb, that every time when a new member is added to a struct, to make sure that it doesn't introduce any holes? > > BTW, we usually do union { skb, xdpf } since they're mutually > exclusive. And to distinguish between XDP and regular Tx you can use > one more bit/bool. This can also come handy later when you add XSk > support (you will be adding it, right? Please :P). I think I will take this battle at later point when I will add XSK :) After I finish with this patch series, I will need to focus on some VCAP support for lan966x. And maybe after that I will be able to add XSK. Because I need to look more at this XSK topic as I have looked too much on it before but I heard a lot of great things about it :) > > > int len; > > dma_addr_t dma_addr; > > bool used; > > [...] > > > -- > > 2.38.0 > > Thanks, > Olek -- /Horatiu