Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6291861rwd; Mon, 19 Jun 2023 05:23:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nw0B1DbatQRSf/7PE2Ex4QjNZxNljdxczrpnSQRhbWrRxIgfmdxXpU+9X4dG2ZUQkwH7/ X-Received: by 2002:a17:902:ce81:b0:1b5:522a:1578 with SMTP id f1-20020a170902ce8100b001b5522a1578mr7022718plg.29.1687177424017; Mon, 19 Jun 2023 05:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687177423; cv=none; d=google.com; s=arc-20160816; b=zsk2hnRSMQhtRx8Ah9iy7AKx6ScOSFlqHYMEjkNuUNUTyinDVxexuKJk6XAf9vSraN 3VCAsbaAKDZml4RngQC1q8WplDkZk5/9Zu9rD1biG+eTV5aoIpNcTOmU20PQP2wkaZ/Q ergNzsd1iz5fUxpBHLKkp6rzihia+0Pd4MAzZEhXNgx5zYFUJMf3CARVbVLkZ/7hhv53 GO9bPfkeCqXOl0tyyQZ4FOxtTrh1oACo9OE/NbyQ9R4ohYCiJbZyutqj+yAegrrxh54r 04cGZHEmxuaqN0HwMZruZXsrKHTX2mRPO2q7VNw0Tv+Fz8piumC69JxuuyCv7dn6nA3H OPzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=vKaxUoT+OhES6xCDoeBwVBJgDkTE4k4YTgqOonwJPL4=; b=ITCM2KVRCzTyI9HDow0fFos0IrVcHHtwAdDLvvcXtB0P++kG9SAgf8/nkNcwQzW91i TKo0oSHsw2LNlVgB6foLen5F8e43dSnKrrBrGEKaS6plHWx8DLLLN62pHoX2CT6NZwOT G4r/aSl2O8TR7uNl8Q4KgVvrKIGVGWd5jDTPvsw0mpIi/YS6dfRS6Q7Aq3SDHBQ/8YNO AepMWfQc2dj0flZFh7jY0hkvfvCLY66v84MIxCcnFuaiGHOHhbkZ4Qix+zqu4vTrAArb 8PRFy+s6NMlalhEFHDifNbV0jjXJzVx3ug3zAeS2F7NGPd7/O56YK5UP71Cq0JvVo1xc 9fqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=jSS00dSe; 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=NONE dis=NONE) header.from=ti.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v202-20020a6361d3000000b0054fd77fe97asi10811700pgb.267.2023.06.19.05.23.30; Mon, 19 Jun 2023 05:23:43 -0700 (PDT) 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=@ti.com header.s=ti-com-17Q1 header.b=jSS00dSe; 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=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbjFSMHr (ORCPT + 99 others); Mon, 19 Jun 2023 08:07:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbjFSMHq (ORCPT ); Mon, 19 Jun 2023 08:07:46 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1612611D; Mon, 19 Jun 2023 05:07:43 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 35JC7K2A099013; Mon, 19 Jun 2023 07:07:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1687176440; bh=vKaxUoT+OhES6xCDoeBwVBJgDkTE4k4YTgqOonwJPL4=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=jSS00dSeknNWOhd02gLDxY78GwOMkI0vxCZoU1/S2cdn9yCrGJmYXjJaoeHKAZlD0 2MA+EmlVcsr6cwucbD30j+fk+gjShI7UZUwlY8z1GdPWnnB3Yl6SLFJtS7ZfCdGj5s 9IlTzibPWzg5cTbNMKb/JvOENCG9R4x8R1LbTxAU= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 35JC7Kdf126513 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 19 Jun 2023 07:07:20 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 19 Jun 2023 07:07:20 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 19 Jun 2023 07:07:20 -0500 Received: from [10.24.69.79] (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 35JC7G9K042205; Mon, 19 Jun 2023 07:07:17 -0500 Message-ID: Date: Mon, 19 Jun 2023 17:37:16 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v2 net-next] net: hsr: Disable promiscuous mode in offload mode Content-Language: en-US To: Ido Schimmel CC: , Nikolay Aleksandrov , Vladimir Oltean , , , , , , , , References: <20230614114710.31400-1-r-gunasekaran@ti.com> <20230615223736.0577fb11@kernel.org> From: Ravi Gunasekaran In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 6/19/23 4:44 PM, Ido Schimmel wrote: > On Thu, Jun 15, 2023 at 10:37:36PM -0700, Jakub Kicinski wrote: >> On Wed, 14 Jun 2023 17:17:10 +0530 Ravi Gunasekaran wrote: >>> When port-to-port forwarding for interfaces in HSR node is enabled, >>> disable promiscuous mode since L2 frame forward happens at the >>> offloaded hardware. > > It's not clear to me why you want to disable promiscuous mode. I'm not > familiar with HSR, but I assume you want the hardware to forward all the > packets between the two ports and not only specific DMACs. > > How does the underlying device implement "promiscuous mode" that you > benefit from disabling it? While creating an HSR interface using two slave nodes, the promiscuous mode is set via dev_set_promiscuity() in hsr_portdev_setup() for both the ports. And then in the HSR driver, a packet is forwarded to the other slave port (physical port) and also the HSR master if it is intended for it. Before forwarding, a check is done in static void hsr_forward_do(struct hsr_frame_info *frame) { ... if (hsr->proto_ops->drop_frame && hsr->proto_ops->drop_frame(frame, port)) continue; ... } And the drop_frame callback is as below bool hsr_drop_frame(struct hsr_frame_info *frame, struct hsr_port *port) { if (port->dev->features & NETIF_F_HW_HSR_FWD) return prp_drop_frame(frame, port); return false; } The driver drops these packets and does not forward to any port at all. But since promiscuous mode is enabled, CPU cycles are consumed. So benefit of disabling promiscuous mode is saving CPU cycles. So in this patch, I check for NETIF_F_HW_HSR_FWD and then take a call to enable/disable the promiscuous mode during HSR interface creation. > > Thanks > >>> >>> Signed-off-by: Ravi Gunasekaran >>> Reviewed-by: Simon Horman >> >> Bridge folks any thoughts on this? Is this the behavior bridge has >> and if not should we try to align the two? >> >>> Changes from v1: >>> =============== >>> * Changed the data type of "fwd_offloaded" from "unsigned int" to "bool" >>> and moved it below "net_id" struct member as per Paolo's comment. >>> * Collected Reviewed-by tag from v1 patch. >>> >>> v1: https://lore.kernel.org/all/20230612093933.13267-1-r-gunasekaran@ti.com/ >>> >>> net/hsr/hsr_device.c | 5 +++++ >>> net/hsr/hsr_main.h | 1 + >>> net/hsr/hsr_slave.c | 15 +++++++++++---- >>> 3 files changed, 17 insertions(+), 4 deletions(-) >>> >>> diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c >>> index 5a236aae2366..306f942c3b28 100644 >>> --- a/net/hsr/hsr_device.c >>> +++ b/net/hsr/hsr_device.c >>> @@ -531,6 +531,11 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], >>> if (res) >>> goto err_add_master; >>> >>> + /* HSR forwarding offload supported in lower device? */ >>> + if ((slave[0]->features & NETIF_F_HW_HSR_FWD) && >>> + (slave[1]->features & NETIF_F_HW_HSR_FWD)) >>> + hsr->fwd_offloaded = true; >>> + >>> res = register_netdevice(hsr_dev); >>> if (res) >>> goto err_unregister; >>> diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h >>> index 5584c80a5c79..6851e33df7d1 100644 >>> --- a/net/hsr/hsr_main.h >>> +++ b/net/hsr/hsr_main.h >>> @@ -208,6 +208,7 @@ struct hsr_priv { >>> u8 net_id; /* for PRP, it occupies most significant 3 bits >>> * of lan_id >>> */ >>> + bool fwd_offloaded; /* Forwarding offloaded to HW */ >>> unsigned char sup_multicast_addr[ETH_ALEN] __aligned(sizeof(u16)); >>> /* Align to u16 boundary to avoid unaligned access >>> * in ether_addr_equal >>> diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c >>> index b70e6bbf6021..e5742f2a2d52 100644 >>> --- a/net/hsr/hsr_slave.c >>> +++ b/net/hsr/hsr_slave.c >>> @@ -131,9 +131,14 @@ static int hsr_portdev_setup(struct hsr_priv *hsr, struct net_device *dev, >>> struct hsr_port *master; >>> int res; >>> >>> - res = dev_set_promiscuity(dev, 1); >>> - if (res) >>> - return res; >>> + /* Don't use promiscuous mode for offload since L2 frame forward >>> + * happens at the offloaded hardware. >>> + */ >>> + if (!port->hsr->fwd_offloaded) { >>> + res = dev_set_promiscuity(dev, 1); >>> + if (res) >>> + return res; >>> + } >>> >>> master = hsr_port_get_hsr(hsr, HSR_PT_MASTER); >>> hsr_dev = master->dev; >>> @@ -152,7 +157,9 @@ static int hsr_portdev_setup(struct hsr_priv *hsr, struct net_device *dev, >>> fail_rx_handler: >>> netdev_upper_dev_unlink(dev, hsr_dev); >>> fail_upper_dev_link: >>> - dev_set_promiscuity(dev, -1); >>> + if (!port->hsr->fwd_offloaded) >>> + dev_set_promiscuity(dev, -1); >>> + >>> return res; >>> } >>> >> -- Regards, Ravi