diff mbox series

net: hsr: Disable promiscuous mode in offload mode

Message ID 20230612093933.13267-1-r-gunasekaran@ti.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: hsr: Disable promiscuous mode in offload mode | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 1 maintainers not CCed: kurt@linutronix.de
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch warning WARNING: line length of 83 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ravi Gunasekaran June 12, 2023, 9:39 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>
---
 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

Simon Horman June 14, 2023, 8:01 a.m. UTC | #1
On Mon, Jun 12, 2023 at 03:09:33PM +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>
Paolo Abeni June 14, 2023, 9:42 a.m. UTC | #2
On Mon, 2023-06-12 at 15:09 +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>
> ---
>  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..0225fabbe6d1 100644
> --- a/net/hsr/hsr_main.h
> +++ b/net/hsr/hsr_main.h
> @@ -195,6 +195,7 @@ struct hsr_priv {
>  	struct hsr_self_node	__rcu *self_node;	/* MACs of slaves */
>  	struct timer_list	announce_timer;	/* Supervision frame dispatch */
>  	struct timer_list	prune_timer;
> +	unsigned int            fwd_offloaded : 1; /* Forwarding offloaded to HW */

Please use plain 'bool' instead.

Also there is an hole in 'struct hsr_priv' just after 'net_id', you
could consider moving this new field there.


Thanks!

Paolo
Paolo Abeni June 14, 2023, 9:44 a.m. UTC | #3
On Wed, 2023-06-14 at 11:42 +0200, Paolo Abeni wrote:
> On Mon, 2023-06-12 at 15:09 +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>
> > ---
> >  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..0225fabbe6d1 100644
> > --- a/net/hsr/hsr_main.h
> > +++ b/net/hsr/hsr_main.h
> > @@ -195,6 +195,7 @@ struct hsr_priv {
> >  	struct hsr_self_node	__rcu *self_node;	/* MACs of slaves */
> >  	struct timer_list	announce_timer;	/* Supervision frame dispatch */
> >  	struct timer_list	prune_timer;
> > +	unsigned int            fwd_offloaded : 1; /* Forwarding offloaded to HW */
> 
> Please use plain 'bool' instead.
> 
> Also there is an hole in 'struct hsr_priv' just after 'net_id', you
> could consider moving this new field there.

Oops, I almost forgot! Please include the target tree (net-next in this
case) in the subj prefix on your next submission.

Thanks,

Paolo
Ravi Gunasekaran June 14, 2023, 10:05 a.m. UTC | #4
On 6/14/23 3:12 PM, Paolo Abeni wrote:
> On Mon, 2023-06-12 at 15:09 +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>
>> ---
>>  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..0225fabbe6d1 100644
>> --- a/net/hsr/hsr_main.h
>> +++ b/net/hsr/hsr_main.h
>> @@ -195,6 +195,7 @@ struct hsr_priv {
>>  	struct hsr_self_node	__rcu *self_node;	/* MACs of slaves */
>>  	struct timer_list	announce_timer;	/* Supervision frame dispatch */
>>  	struct timer_list	prune_timer;
>> +	unsigned int            fwd_offloaded : 1; /* Forwarding offloaded to HW */
> 
> Please use plain 'bool' instead.
> 
> Also there is an hole in 'struct hsr_priv' just after 'net_id', you
> could consider moving this new field there.
> 

Sure. I will use "bool" and insert it after "net_id" and send out v2

> 
> Thanks!
> 
> Paolo
>
Ravi Gunasekaran June 14, 2023, 10:05 a.m. UTC | #5
On 6/14/23 3:14 PM, Paolo Abeni wrote:
> On Wed, 2023-06-14 at 11:42 +0200, Paolo Abeni wrote:
>> On Mon, 2023-06-12 at 15:09 +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>
>>> ---
>>>  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..0225fabbe6d1 100644
>>> --- a/net/hsr/hsr_main.h
>>> +++ b/net/hsr/hsr_main.h
>>> @@ -195,6 +195,7 @@ struct hsr_priv {
>>>  	struct hsr_self_node	__rcu *self_node;	/* MACs of slaves */
>>>  	struct timer_list	announce_timer;	/* Supervision frame dispatch */
>>>  	struct timer_list	prune_timer;
>>> +	unsigned int            fwd_offloaded : 1; /* Forwarding offloaded to HW */
>>
>> Please use plain 'bool' instead.
>>
>> Also there is an hole in 'struct hsr_priv' just after 'net_id', you
>> could consider moving this new field there.
> 
> Oops, I almost forgot! Please include the target tree (net-next in this
> case) in the subj prefix on your next submission.
> 

I will take care of this from next submission onwards.

> Thanks,
> 
> Paolo
>
diff mbox series

Patch

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..0225fabbe6d1 100644
--- a/net/hsr/hsr_main.h
+++ b/net/hsr/hsr_main.h
@@ -195,6 +195,7 @@  struct hsr_priv {
 	struct hsr_self_node	__rcu *self_node;	/* MACs of slaves */
 	struct timer_list	announce_timer;	/* Supervision frame dispatch */
 	struct timer_list	prune_timer;
+	unsigned int            fwd_offloaded : 1; /* Forwarding offloaded to HW */
 	int announce_count;
 	u16 sequence_nr;
 	u16 sup_sequence_nr;	/* For HSRv1 separate seq_nr for supervision */
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;
 }