diff mbox series

[net-next] net: hsr: Add support for MC filtering at the slave device

Message ID 20231120110105.18416-1-r-gunasekaran@ti.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: hsr: Add support for MC filtering at the slave device | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/codegen success Generated files up to date
netdev/tree_selection success Clearly marked for 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: 1127 this patch: 1127
netdev/cc_maintainers warning 1 maintainers not CCed: m-karicheri2@ti.com
netdev/build_clang success Errors and warnings before: 1154 this patch: 1154
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: 1154 this patch: 1154
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 85 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ravi Gunasekaran Nov. 20, 2023, 11:01 a.m. UTC
From: Murali Karicheri <m-karicheri2@ti.com>

When MC (multicast) list is updated by the networking layer due to a
user command and as well as when allmulti flag is set, it needs to be
passed to the enslaved Ethernet devices. This patch allows this
to happen by implementing ndo_change_rx_flags() and ndo_set_rx_mode()
API calls that in turns pass it to the slave devices using
existing API calls.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
---
 net/hsr/hsr_device.c | 67 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 66 insertions(+), 1 deletion(-)


base-commit: 5a82d69d48c82e89aef44483d2a129f869f3506a

Comments

Wojciech Drewek Nov. 20, 2023, 11:40 a.m. UTC | #1
On 20.11.2023 12:01, Ravi Gunasekaran wrote:
> From: Murali Karicheri <m-karicheri2@ti.com>
> 
> When MC (multicast) list is updated by the networking layer due to a
> user command and as well as when allmulti flag is set, it needs to be
> passed to the enslaved Ethernet devices. This patch allows this
> to happen by implementing ndo_change_rx_flags() and ndo_set_rx_mode()
> API calls that in turns pass it to the slave devices using
> existing API calls.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
> ---

One small nit, besides that:
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

>  net/hsr/hsr_device.c | 67 +++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 66 insertions(+), 1 deletion(-)
> 
> diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
> index 306f942c3b28..4e8f4a3cefbf 100644
> --- a/net/hsr/hsr_device.c
> +++ b/net/hsr/hsr_device.c
> @@ -173,7 +173,24 @@ static int hsr_dev_open(struct net_device *dev)
>  
>  static int hsr_dev_close(struct net_device *dev)
>  {
> -	/* Nothing to do here. */
> +	struct hsr_port *port;
> +	struct hsr_priv *hsr;
> +
> +	hsr = netdev_priv(dev);
> +	hsr_for_each_port(hsr, port) {
> +		if (port->type == HSR_PT_MASTER)
> +			continue;
> +		switch (port->type) {
> +		case HSR_PT_SLAVE_A:
> +		case HSR_PT_SLAVE_B:
> +			dev_uc_unsync(port->dev, dev);
> +			dev_mc_unsync(port->dev, dev);
> +			break;
> +		default:
> +			break;
> +		}
> +	}
> +
>  	return 0;
>  }
>  
> @@ -404,12 +421,60 @@ void hsr_del_ports(struct hsr_priv *hsr)
>  		hsr_del_port(port);
>  }
>  
> +static void hsr_ndo_set_rx_mode(struct net_device *dev)

I wouldn't add "ndo" to the callback name, let's not stand out from other ndo callbacks here.

> +{
> +	struct hsr_port *port;
> +	struct hsr_priv *hsr;
> +
> +	hsr = netdev_priv(dev);
> +
> +	hsr_for_each_port(hsr, port) {
> +		if (port->type == HSR_PT_MASTER)
> +			continue;
> +		switch (port->type) {
> +		case HSR_PT_SLAVE_A:
> +		case HSR_PT_SLAVE_B:
> +			dev_mc_sync_multiple(port->dev, dev);
> +			dev_uc_sync_multiple(port->dev, dev);
> +			break;
> +		default:
> +			break;
> +		}
> +	}
> +}
> +
> +static void hsr_change_rx_flags(struct net_device *dev, int change)
> +{
> +	struct hsr_port *port;
> +	struct hsr_priv *hsr;
> +
> +	hsr = netdev_priv(dev);
> +
> +	hsr_for_each_port(hsr, port) {
> +		if (port->type == HSR_PT_MASTER)
> +			continue;
> +		switch (port->type) {
> +		case HSR_PT_SLAVE_A:
> +		case HSR_PT_SLAVE_B:
> +			if (change & IFF_ALLMULTI)
> +				dev_set_allmulti(port->dev,
> +						 dev->flags &
> +						 IFF_ALLMULTI ? 1 : -1);
> +			break;
> +		default:
> +			break;
> +		}
> +	}
> +}
> +
>  static const struct net_device_ops hsr_device_ops = {
>  	.ndo_change_mtu = hsr_dev_change_mtu,
>  	.ndo_open = hsr_dev_open,
>  	.ndo_stop = hsr_dev_close,
>  	.ndo_start_xmit = hsr_dev_xmit,
> +	.ndo_change_rx_flags = hsr_change_rx_flags,
>  	.ndo_fix_features = hsr_fix_features,
> +	.ndo_set_rx_mode = hsr_ndo_set_rx_mode,
>  };
>  
>  static struct device_type hsr_type = {
> 
> base-commit: 5a82d69d48c82e89aef44483d2a129f869f3506a
Ravi Gunasekaran Nov. 21, 2023, 4:17 a.m. UTC | #2
On 11/20/2023 5:10 PM, Wojciech Drewek wrote:
>
> On 20.11.2023 12:01, Ravi Gunasekaran wrote:
>> From: Murali Karicheri <m-karicheri2@ti.com>
>>
>> When MC (multicast) list is updated by the networking layer due to a
>> user command and as well as when allmulti flag is set, it needs to be
>> passed to the enslaved Ethernet devices. This patch allows this
>> to happen by implementing ndo_change_rx_flags() and ndo_set_rx_mode()
>> API calls that in turns pass it to the slave devices using
>> existing API calls.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
>> ---
> One small nit, besides that:
> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
>
>>  net/hsr/hsr_device.c | 67 +++++++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 66 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
>> index 306f942c3b28..4e8f4a3cefbf 100644
>> --- a/net/hsr/hsr_device.c
>> +++ b/net/hsr/hsr_device.c
>> @@ -173,7 +173,24 @@ static int hsr_dev_open(struct net_device *dev)
>>  
>>  static int hsr_dev_close(struct net_device *dev)
>>  {
>> -	/* Nothing to do here. */
>> +	struct hsr_port *port;
>> +	struct hsr_priv *hsr;
>> +
>> +	hsr = netdev_priv(dev);
>> +	hsr_for_each_port(hsr, port) {
>> +		if (port->type == HSR_PT_MASTER)
>> +			continue;
>> +		switch (port->type) {
>> +		case HSR_PT_SLAVE_A:
>> +		case HSR_PT_SLAVE_B:
>> +			dev_uc_unsync(port->dev, dev);
>> +			dev_mc_unsync(port->dev, dev);
>> +			break;
>> +		default:
>> +			break;
>> +		}
>> +	}
>> +
>>  	return 0;
>>  }
>>  
>> @@ -404,12 +421,60 @@ void hsr_del_ports(struct hsr_priv *hsr)
>>  		hsr_del_port(port);
>>  }
>>  
>> +static void hsr_ndo_set_rx_mode(struct net_device *dev)
> I wouldn't add "ndo" to the callback name, let's not stand out from other ndo callbacks here.

Thank you for reviewing the patch. I will address the above comment and send out
a v2.

>> +{
>> +	struct hsr_port *port;
>> +	struct hsr_priv *hsr;
>> +
>> +	hsr = netdev_priv(dev);
>> +
>> +	hsr_for_each_port(hsr, port) {
>> +		if (port->type == HSR_PT_MASTER)
>> +			continue;
>> +		switch (port->type) {
>> +		case HSR_PT_SLAVE_A:
>> +		case HSR_PT_SLAVE_B:
>> +			dev_mc_sync_multiple(port->dev, dev);
>> +			dev_uc_sync_multiple(port->dev, dev);
>> +			break;
>> +		default:
>> +			break;
>> +		}
>> +	}
>> +}
>> +
>> +static void hsr_change_rx_flags(struct net_device *dev, int change)
>> +{
>> +	struct hsr_port *port;
>> +	struct hsr_priv *hsr;
>> +
>> +	hsr = netdev_priv(dev);
>> +
>> +	hsr_for_each_port(hsr, port) {
>> +		if (port->type == HSR_PT_MASTER)
>> +			continue;
>> +		switch (port->type) {
>> +		case HSR_PT_SLAVE_A:
>> +		case HSR_PT_SLAVE_B:
>> +			if (change & IFF_ALLMULTI)
>> +				dev_set_allmulti(port->dev,
>> +						 dev->flags &
>> +						 IFF_ALLMULTI ? 1 : -1);
>> +			break;
>> +		default:
>> +			break;
>> +		}
>> +	}
>> +}
>> +
>>  static const struct net_device_ops hsr_device_ops = {
>>  	.ndo_change_mtu = hsr_dev_change_mtu,
>>  	.ndo_open = hsr_dev_open,
>>  	.ndo_stop = hsr_dev_close,
>>  	.ndo_start_xmit = hsr_dev_xmit,
>> +	.ndo_change_rx_flags = hsr_change_rx_flags,
>>  	.ndo_fix_features = hsr_fix_features,
>> +	.ndo_set_rx_mode = hsr_ndo_set_rx_mode,
>>  };
>>  
>>  static struct device_type hsr_type = {
>>
>> base-commit: 5a82d69d48c82e89aef44483d2a129f869f3506a
diff mbox series

Patch

diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
index 306f942c3b28..4e8f4a3cefbf 100644
--- a/net/hsr/hsr_device.c
+++ b/net/hsr/hsr_device.c
@@ -173,7 +173,24 @@  static int hsr_dev_open(struct net_device *dev)
 
 static int hsr_dev_close(struct net_device *dev)
 {
-	/* Nothing to do here. */
+	struct hsr_port *port;
+	struct hsr_priv *hsr;
+
+	hsr = netdev_priv(dev);
+	hsr_for_each_port(hsr, port) {
+		if (port->type == HSR_PT_MASTER)
+			continue;
+		switch (port->type) {
+		case HSR_PT_SLAVE_A:
+		case HSR_PT_SLAVE_B:
+			dev_uc_unsync(port->dev, dev);
+			dev_mc_unsync(port->dev, dev);
+			break;
+		default:
+			break;
+		}
+	}
+
 	return 0;
 }
 
@@ -404,12 +421,60 @@  void hsr_del_ports(struct hsr_priv *hsr)
 		hsr_del_port(port);
 }
 
+static void hsr_ndo_set_rx_mode(struct net_device *dev)
+{
+	struct hsr_port *port;
+	struct hsr_priv *hsr;
+
+	hsr = netdev_priv(dev);
+
+	hsr_for_each_port(hsr, port) {
+		if (port->type == HSR_PT_MASTER)
+			continue;
+		switch (port->type) {
+		case HSR_PT_SLAVE_A:
+		case HSR_PT_SLAVE_B:
+			dev_mc_sync_multiple(port->dev, dev);
+			dev_uc_sync_multiple(port->dev, dev);
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+static void hsr_change_rx_flags(struct net_device *dev, int change)
+{
+	struct hsr_port *port;
+	struct hsr_priv *hsr;
+
+	hsr = netdev_priv(dev);
+
+	hsr_for_each_port(hsr, port) {
+		if (port->type == HSR_PT_MASTER)
+			continue;
+		switch (port->type) {
+		case HSR_PT_SLAVE_A:
+		case HSR_PT_SLAVE_B:
+			if (change & IFF_ALLMULTI)
+				dev_set_allmulti(port->dev,
+						 dev->flags &
+						 IFF_ALLMULTI ? 1 : -1);
+			break;
+		default:
+			break;
+		}
+	}
+}
+
 static const struct net_device_ops hsr_device_ops = {
 	.ndo_change_mtu = hsr_dev_change_mtu,
 	.ndo_open = hsr_dev_open,
 	.ndo_stop = hsr_dev_close,
 	.ndo_start_xmit = hsr_dev_xmit,
+	.ndo_change_rx_flags = hsr_change_rx_flags,
 	.ndo_fix_features = hsr_fix_features,
+	.ndo_set_rx_mode = hsr_ndo_set_rx_mode,
 };
 
 static struct device_type hsr_type = {