Message ID | 20230614114710.31400-1-r-gunasekaran@ti.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1187989vqr; Wed, 14 Jun 2023 05:00:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5GOm+FFbA83oSY4mTQPwheGTL6ZGiDt2ixa6JUVH4Sgurz3J/oat4OBizMpaEdrgyOFJVj X-Received: by 2002:a17:907:9686:b0:978:acec:36ab with SMTP id hd6-20020a170907968600b00978acec36abmr16364110ejc.35.1686744021013; Wed, 14 Jun 2023 05:00:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686744020; cv=none; d=google.com; s=arc-20160816; b=BeQB2TDTfPGewSuK3ic9zvJitLwvGolDZkr0zPicF73qkx/gM0TyhlNLvGMsu4Vaxr kmDqAhEyHF/eKiy/lnCO8IlJWcQ2aOqbX4xjmKZwP9tU1KiRb6QD/qvya5wz+GaFFK/0 7+PgAUxApeua2+Eq/GzxXxtT+j1iNm8m5+e/3Wa8J/M6Q/b7d4Djl/bkmDsQwzN/lJlm /TbdnRCbv0fWoABXwf7Lyt1FyvUuLCjYeV2BhQn72WaaNeaDzMo9qYYSPgX6mYjY49t2 +NG6fuMmlGf5arAojGfuSUdsqCGz2BTv9Bw+ollQaTP+Ko9NyzvW2Zwm57zIoDeXOogj twag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=sA/wHQWGukp8xdptR9h0VboCMWUkFR4POYrWrCGHCeE=; b=yPIWRh/vdKaHyFUDaJBtiKmi69/TpRSXIgtYZbp1eqTPYTYpccrWOQ/Ex1RSSvSC7Y 25ETYPUj2JjXJbKguh7Ago7+xAtbO6OhmY8nm0zJxZsGQ0z9DI+EgPKuRNSyzqVRK8xd 8l+s4NIjY1gpcxhCx2Efho4lrIkfs1RVgvWBc53TSc15DKJTEZwtJcsM4qxe6gH+S/XW 1XS6z2w9o+WwdM1ZKe2IBnNeaEV/i8VjsCbF4XMj3eDQf3zBQg8v+htAbC/qAw90SHqH /E/mNWBQw51mWTpk8kXUfoycGOXFbhADUpTy4j5cpWrW8UA8M1ppIxsOEfRcWOXCADK9 Qyfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=aiOCextL; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18-20020a1709063bd200b0094f282eac9dsi7533777ejf.19.2023.06.14.04.59.52; Wed, 14 Jun 2023 05:00:20 -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=aiOCextL; 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 S234133AbjFNLrf (ORCPT <rfc822;n2h9z4@gmail.com> + 99 others); Wed, 14 Jun 2023 07:47:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241042AbjFNLrd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 14 Jun 2023 07:47:33 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A769510D8; Wed, 14 Jun 2023 04:47:26 -0700 (PDT) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 35EBlE1E109706; Wed, 14 Jun 2023 06:47:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686743234; bh=sA/wHQWGukp8xdptR9h0VboCMWUkFR4POYrWrCGHCeE=; h=From:To:CC:Subject:Date; b=aiOCextLJUKAYz8Ee3M6kzNTrmzmiNHam9Dn6cIopUZoWQot4zqGloswc3fGqZaX+ LbQSLiJO1EC0FYN3KX3uUrOzl+a5CzeOYhoP+Ym/hKPFgD178Ax/L/vqlLue456MUI +i1ZFjEHWbVimurcW1nUH0U5adayfHdxWUZ0nRIo= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 35EBlEvP110320 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Jun 2023 06:47:14 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 14 Jun 2023 06:47:14 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) 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 via Frontend Transport; Wed, 14 Jun 2023 06:47:14 -0500 Received: from uda0500640.dal.design.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 35EBlA24044618; Wed, 14 Jun 2023 06:47:11 -0500 From: Ravi Gunasekaran <r-gunasekaran@ti.com> To: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>, <bigeasy@linutronix.de>, <simon.horman@corigine.com> CC: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <rogerq@kernel.org>, <r-gunasekaran@ti.com> Subject: [PATCH v2 net-next] net: hsr: Disable promiscuous mode in offload mode Date: Wed, 14 Jun 2023 17:17:10 +0530 Message-ID: <20230614114710.31400-1-r-gunasekaran@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768491538831578986?= X-GMAIL-MSGID: =?utf-8?q?1768679298689031402?= |
Series |
[v2,net-next] net: hsr: Disable promiscuous mode in offload mode
|
|
Commit Message
Ravi Gunasekaran
June 14, 2023, 11:47 a.m. UTC
When port-to-port forwarding for interfaces in HSR node is enabled, disable promiscuous mode since L2 frame forward happens at the offloaded hardware. Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> --- 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(-)
Comments
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. > > Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com> > Reviewed-by: Simon Horman <simon.horman@corigine.com> 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; > } >
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? Thanks > > > > Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com> > > Reviewed-by: Simon Horman <simon.horman@corigine.com> > > 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; > > } > > >
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 <r-gunasekaran@ti.com> >>> Reviewed-by: Simon Horman <simon.horman@corigine.com> >> >> 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; >>> } >>> >>
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <kuba@kernel.org>: On Wed, 14 Jun 2023 17:17:10 +0530 you 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. > > Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com> > Reviewed-by: Simon Horman <simon.horman@corigine.com> > > [...] Here is the summary with links: - [v2,net-next] net: hsr: Disable promiscuous mode in offload mode https://git.kernel.org/netdev/net-next/c/e748d0fd66ab You are awesome, thank you!
On Mon, Jun 19, 2023 at 05:37:16PM +0530, Ravi Gunasekaran wrote: > > 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. Can the hardware be configured to not send to the CPU packets that the CPU is going to drop anyway? IFF_PROMISC is about receiving packets with any MAC DA, not about sending all packets to the CPU. With offloading drivers, there is a difference between the 2, because the RX path of a port is not necessarily the same as the CPU receive path - the destination of a packet can simply be another port.
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; }