Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7915409rwb; Wed, 23 Nov 2022 12:33:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf4sijV72/Nt+qeNXuAvEW0wIwxoY62aXUbuQjZN9gCP4yvFRYaZ/B6ODPmx1QzTeeEEZ1aw X-Received: by 2002:a17:906:6703:b0:7ae:5dd6:e62d with SMTP id a3-20020a170906670300b007ae5dd6e62dmr15622380ejp.518.1669235598569; Wed, 23 Nov 2022 12:33:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669235598; cv=none; d=google.com; s=arc-20160816; b=VvCVi9qL+5+giDXPxR68GluoIJZLX0yU5bbDyTiuLjp0nsVexVcaHwA9CaFiJzjq/P ZIHjz68N9eAIkEgDhNBWT8Y2TdbjTjjn14a+ED9flCBzMuKf+LWSn3e4l6fzvL/mvv+M XkZOnjSUON4ppa6qGiRN059T3y9aPFqnoXAA8zOf+DXm1AT/bwd9GQp3HPYa4/FD34mT RewaSpDV2o4h4D804VZ4JtG2ahIGgNXJmjGyJ8k2vDKErfjIAbe7eMe8mnuaUI3BcWbZ aK/b9D++M/3eIX0x2bSiE/W3oe/XWV0gaiiINkr/09cBkvMlNQbHKsS0PAGSgb3Cs/R8 CBIQ== 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=Rp1YULjw7EBLYdwJH/L+V0A0tT6akNtIz+fWWqCXdqs=; b=rMMyc31rku8X14iGN3EpDLM/SfvjzC8+TPLgQzSm5laR5nx0EZo4iJJuUfkDjY6BO7 8ltsAYMVmYcf4CBntG5gSWe7aTNNnB0tmvC22qeqTkA7BcqQORa32VPLejIeyMwCc85F 0KFGFnz/d+YCfPoTynOkhK4a0SBDnzn8eA0kPD78MjOYXR2lvS7paYzPFw/C81oXSKfd L55M7xLu08ZMVRLoaAAs337AYkJhW1EZihvcH/XR/QJpcmDL+81YCwxHgJW6/vHEglxX a4nTqJNQiyo/ByN8sxhaFWPFIJ/zO++dRPx9zG1nvQkvzzVzx1e3Iht1I3yufahwuSJl cvzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=WJgxBiNO; 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 eb5-20020a0564020d0500b00469054c7246si724811edb.506.2022.11.23.12.32.55; Wed, 23 Nov 2022 12:33:18 -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=WJgxBiNO; 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 S237158AbiKWUPN (ORCPT + 88 others); Wed, 23 Nov 2022 15:15:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237546AbiKWUPL (ORCPT ); Wed, 23 Nov 2022 15:15:11 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74A3556EC8; Wed, 23 Nov 2022 12:15:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669234508; x=1700770508; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=eSntQzF4q26wzrEFVAJywooKAOI3AAj+06yfqsfV9sw=; b=WJgxBiNOlToKBNACKH2VOi1WzQFZOLv+G6el085K3U7OfMW63xXpbgJJ IeUgaX48GQo+A+AKzgzr7X/LZhU1d9m1jHt3n5X/QmoaLXZGPsplRyCQq qbJeFjfV4H8ClAL4P+JiNO9PsxvNcyO2Wzn5Ff4Cm0tYC7aA+fieVWsS6 nrf4TYgTG41JMxaORfGOc4iDNibNEUomuf943E85Tc3KgjsKwCTGKNijD DxkEQ9MOI+z1e7yuewAh65dmy+J39jrTEJOvCV1XwfYKa/llolLi/4kOr 5hm2/7Tm+EwKjrIxy1ocicganBjNkCmYk9yZ8Z/6e9X9EKaEymASihDj2 g==; X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="184920813" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 23 Nov 2022 13:15:06 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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; Wed, 23 Nov 2022 13:15:05 -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, 23 Nov 2022 13:15:04 -0700 Date: Wed, 23 Nov 2022 21:19:55 +0100 From: Horatiu Vultur To: Maciej Fijalkowski CC: , , , , , , , , , , , , Subject: Re: [PATCH net-next v4 6/7] net: lan966x: Add support for XDP_TX Message-ID: <20221123201955.koaobohzf6kcm4ho@soft-dev3-1> References: <20221122214413.3446006-1-horatiu.vultur@microchip.com> <20221122214413.3446006-7-horatiu.vultur@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: 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/22/2022 23:27, Maciej Fijalkowski wrote: > > On Tue, Nov 22, 2022 at 10:44:12PM +0100, Horatiu Vultur wrote: > > Extend lan966x XDP support with the action XDP_TX. In this case when the > > received buffer needs to execute XDP_TX, the buffer will be moved to the > > TX buffers. So a new RX buffer will be allocated. > > When the TX finish with the frame, it would give back the buffer to the > > page pool. > > > > Signed-off-by: Horatiu Vultur > > --- ... > > > > struct lan966x_port; > > @@ -176,6 +178,7 @@ struct lan966x_tx_dcb_buf { > > dma_addr_t dma_addr; > > struct net_device *dev; > > struct sk_buff *skb; > > + struct xdp_frame *xdpf; > > Couldn't you make an union out of skb and xdpf? I'd say these two are > mutually exclusive, no? I believe this would simplify some things. Yes, skb and xdpf are mutually exclusive. Also Alexander Lobakin mention something similar and I was not sure. Now that I have tried it I can see it that is more clear that skb and xdpf are mutually exclusive and also reduce the size of the struct. So I will update this in the next series. > > > u32 len; > > u32 used : 1; > > u32 ptp : 1; > > @@ -360,6 +363,8 @@ bool lan966x_hw_offload(struct lan966x *lan966x, u32 port, struct sk_buff *skb); > > > > void lan966x_ifh_get_src_port(void *ifh, u64 *src_port); > > void lan966x_ifh_get_timestamp(void *ifh, u64 *timestamp); > > +void lan966x_ifh_set_bypass(void *ifh, u64 bypass); > > +void lan966x_ifh_set_port(void *ifh, u64 bypass); > > > > void lan966x_stats_get(struct net_device *dev, > > struct rtnl_link_stats64 *stats); > > @@ -460,6 +465,9 @@ u32 lan966x_ptp_get_period_ps(void); > > int lan966x_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts); > > > > int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh, struct net_device *dev); > > +int lan966x_fdma_xmit_xdpf(struct lan966x_port *port, > > + struct xdp_frame *frame, > > + struct page *page); > > int lan966x_fdma_change_mtu(struct lan966x *lan966x); > > void lan966x_fdma_netdev_init(struct lan966x *lan966x, struct net_device *dev); > > void lan966x_fdma_netdev_deinit(struct lan966x *lan966x, struct net_device *dev); > > diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c b/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c > > index a99657154cca4..e7998fef7048c 100644 > > --- a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c > > +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c > > @@ -54,6 +54,7 @@ int lan966x_xdp_run(struct lan966x_port *port, struct page *page, u32 data_len) > > { > > struct bpf_prog *xdp_prog = port->xdp_prog; > > struct lan966x *lan966x = port->lan966x; > > + struct xdp_frame *xdpf; > > struct xdp_buff xdp; > > u32 act; > > > > @@ -66,6 +67,13 @@ int lan966x_xdp_run(struct lan966x_port *port, struct page *page, u32 data_len) > > switch (act) { > > case XDP_PASS: > > return FDMA_PASS; > > + case XDP_TX: > > + xdpf = xdp_convert_buff_to_frame(&xdp); > > + if (!xdpf) > > + return FDMA_DROP; > > I would generally challenge the need for xdp_frame in XDP_TX path. You > probably would be good to go with calling directly > page_pool_put_full_page() on cleaning side. This frame is not going to be > redirected so I don't see the need for carrying additional info. I'm > bringing this up as I was observing performance improvement on ice driver > when I decided to operate directly on xdp_buff for XDP_TX. Thanks for suggestion. I definetly see your point. I would prefer for now to keep this like it is. Because I think in the near future I should do a proper investigation to see where the performance of the FDMA can be improved. And this will definetly be on the TODO. > > But it's of course up to you. > > > + > > + return lan966x_fdma_xmit_xdpf(port, xdpf, page) ? > > + FDMA_DROP : FDMA_TX; > > default: > > bpf_warn_invalid_xdp_action(port->dev, xdp_prog, act); > > fallthrough; > > -- > > 2.38.0 > > -- /Horatiu