Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH iwl-net] idpf: set mac type when adding and removing MAC filters
@ 2025-08-06 19:21 Emil Tantilov
  2025-08-07 13:32 ` Simon Horman
  2025-08-12 16:20 ` Hay, Joshua A
  0 siblings, 2 replies; 4+ messages in thread
From: Emil Tantilov @ 2025-08-06 19:21 UTC (permalink / raw)
  To: intel-wired-lan
  Cc: willemb, decot, netdev, Aleksandr.Loktionov, andrew+netdev,
	edumazet, jianliu, anthony.l.nguyen, przemyslaw.kitszel, kuba,
	pabeni, davem

On control planes that allow changing the MAC address of the interface,
the driver must provide a MAC type to avoid errors such as:

idpf 0000:0a:00.0: Transaction failed (op 535)
idpf 0000:0a:00.0: Received invalid MAC filter payload (op 535) (len 0)

These errors occur during driver load or when changing the MAC via:
ip link set <iface> address <mac>

Add logic to set the MAC type before performing ADD/DEL operations.
Since only one primary MAC is supported per vport, the driver only needs
to perform ADD in idpf_set_mac().

Fixes: ce1b75d0635c ("idpf: add ptypes and MAC filter support")
Reported-by: Jian Liu <jianliu@redhat.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
---
 drivers/net/ethernet/intel/idpf/idpf_lib.c      |  6 ++----
 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 11 +++++++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
index 80382ff4a5fa..77d554b0944b 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
@@ -2284,17 +2284,15 @@ static int idpf_set_mac(struct net_device *netdev, void *p)
 	if (ether_addr_equal(netdev->dev_addr, addr->sa_data))
 		goto unlock_mutex;
 
+	ether_addr_copy(vport->default_mac_addr, addr->sa_data);
 	vport_config = vport->adapter->vport_config[vport->idx];
 	err = idpf_add_mac_filter(vport, np, addr->sa_data, false);
 	if (err) {
 		__idpf_del_mac_filter(vport_config, addr->sa_data);
+		ether_addr_copy(vport->default_mac_addr, netdev->dev_addr);
 		goto unlock_mutex;
 	}
 
-	if (is_valid_ether_addr(vport->default_mac_addr))
-		idpf_del_mac_filter(vport, np, vport->default_mac_addr, false);
-
-	ether_addr_copy(vport->default_mac_addr, addr->sa_data);
 	eth_hw_addr_set(netdev, addr->sa_data);
 
 unlock_mutex:
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
index 24febaaa8fbb..7563289dc1e3 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
@@ -3507,6 +3507,15 @@ u32 idpf_get_vport_id(struct idpf_vport *vport)
 	return le32_to_cpu(vport_msg->vport_id);
 }
 
+static void idpf_set_mac_type(struct idpf_vport *vport,
+			      struct virtchnl2_mac_addr *mac_addr)
+{
+	if (ether_addr_equal(vport->default_mac_addr, mac_addr->addr))
+		mac_addr->type = VIRTCHNL2_MAC_ADDR_PRIMARY;
+	else
+		mac_addr->type = VIRTCHNL2_MAC_ADDR_EXTRA;
+}
+
 /**
  * idpf_mac_filter_async_handler - Async callback for mac filters
  * @adapter: private data struct
@@ -3636,6 +3645,7 @@ int idpf_add_del_mac_filters(struct idpf_vport *vport,
 			    list) {
 		if (add && f->add) {
 			ether_addr_copy(mac_addr[i].addr, f->macaddr);
+			idpf_set_mac_type(vport, &mac_addr[i]);
 			i++;
 			f->add = false;
 			if (i == total_filters)
@@ -3643,6 +3653,7 @@ int idpf_add_del_mac_filters(struct idpf_vport *vport,
 		}
 		if (!add && f->remove) {
 			ether_addr_copy(mac_addr[i].addr, f->macaddr);
+			idpf_set_mac_type(vport, &mac_addr[i]);
 			i++;
 			f->remove = false;
 			if (i == total_filters)
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Intel-wired-lan] [PATCH iwl-net] idpf: set mac type when adding and removing MAC filters
  2025-08-06 19:21 [Intel-wired-lan] [PATCH iwl-net] idpf: set mac type when adding and removing MAC filters Emil Tantilov
@ 2025-08-07 13:32 ` Simon Horman
  2025-08-12 16:20 ` Hay, Joshua A
  1 sibling, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-08-07 13:32 UTC (permalink / raw)
  To: Emil Tantilov
  Cc: willemb, decot, netdev, Aleksandr.Loktionov, andrew+netdev,
	edumazet, jianliu, anthony.l.nguyen, kuba, przemyslaw.kitszel,
	intel-wired-lan, pabeni, davem

On Wed, Aug 06, 2025 at 12:21:30PM -0700, Emil Tantilov wrote:
> On control planes that allow changing the MAC address of the interface,
> the driver must provide a MAC type to avoid errors such as:
> 
> idpf 0000:0a:00.0: Transaction failed (op 535)
> idpf 0000:0a:00.0: Received invalid MAC filter payload (op 535) (len 0)
> 
> These errors occur during driver load or when changing the MAC via:
> ip link set <iface> address <mac>
> 
> Add logic to set the MAC type before performing ADD/DEL operations.
> Since only one primary MAC is supported per vport, the driver only needs
> to perform ADD in idpf_set_mac().
> 
> Fixes: ce1b75d0635c ("idpf: add ptypes and MAC filter support")
> Reported-by: Jian Liu <jianliu@redhat.com>
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Intel-wired-lan] [PATCH iwl-net] idpf: set mac type when adding and removing MAC filters
  2025-08-06 19:21 [Intel-wired-lan] [PATCH iwl-net] idpf: set mac type when adding and removing MAC filters Emil Tantilov
  2025-08-07 13:32 ` Simon Horman
@ 2025-08-12 16:20 ` Hay, Joshua A
  2025-08-12 18:04   ` Tantilov, Emil S
  1 sibling, 1 reply; 4+ messages in thread
From: Hay, Joshua A @ 2025-08-12 16:20 UTC (permalink / raw)
  To: Tantilov, Emil S, intel-wired-lan@lists.osuosl.org
  Cc: willemb@google.com, decot@google.com, netdev@vger.kernel.org,
	Loktionov, Aleksandr, andrew+netdev@lunn.ch, edumazet@google.com,
	jianliu@redhat.com, Nguyen, Anthony L, Kitszel, Przemyslaw,
	kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net

> On control planes that allow changing the MAC address of the interface,
> the driver must provide a MAC type to avoid errors such as:
> 
> idpf 0000:0a:00.0: Transaction failed (op 535)
> idpf 0000:0a:00.0: Received invalid MAC filter payload (op 535) (len 0)
> 
> These errors occur during driver load or when changing the MAC via:
> ip link set <iface> address <mac>
> 
> Add logic to set the MAC type before performing ADD/DEL operations.
> Since only one primary MAC is supported per vport, the driver only needs
> to perform ADD in idpf_set_mac().
> 
> Fixes: ce1b75d0635c ("idpf: add ptypes and MAC filter support")
> Reported-by: Jian Liu <jianliu@redhat.com>
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
> ---
>  drivers/net/ethernet/intel/idpf/idpf_lib.c      |  6 ++----
>  drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 11 +++++++++++
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c
> b/drivers/net/ethernet/intel/idpf/idpf_lib.c
> index 80382ff4a5fa..77d554b0944b 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
> @@ -2284,17 +2284,15 @@ static int idpf_set_mac(struct net_device
> *netdev, void *p)
>  	if (ether_addr_equal(netdev->dev_addr, addr->sa_data))
>  		goto unlock_mutex;
> 
> +	ether_addr_copy(vport->default_mac_addr, addr->sa_data);
>  	vport_config = vport->adapter->vport_config[vport->idx];
>  	err = idpf_add_mac_filter(vport, np, addr->sa_data, false);
>  	if (err) {
>  		__idpf_del_mac_filter(vport_config, addr->sa_data);
> +		ether_addr_copy(vport->default_mac_addr, netdev-
> >dev_addr);
>  		goto unlock_mutex;
>  	}
> 
> -	if (is_valid_ether_addr(vport->default_mac_addr))
> -		idpf_del_mac_filter(vport, np, vport->default_mac_addr,
> false);

We still need the call to __idpf_del_mac_filter here with the old addr to free it from the filter list.

Thanks,
Josh

> -
> -	ether_addr_copy(vport->default_mac_addr, addr->sa_data);
>  	eth_hw_addr_set(netdev, addr->sa_data);
> 
>  unlock_mutex:
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> index 24febaaa8fbb..7563289dc1e3 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> @@ -3507,6 +3507,15 @@ u32 idpf_get_vport_id(struct idpf_vport *vport)
>  	return le32_to_cpu(vport_msg->vport_id);
>  }
> 
> +static void idpf_set_mac_type(struct idpf_vport *vport,
> +			      struct virtchnl2_mac_addr *mac_addr)
> +{
> +	if (ether_addr_equal(vport->default_mac_addr, mac_addr->addr))
> +		mac_addr->type = VIRTCHNL2_MAC_ADDR_PRIMARY;
> +	else
> +		mac_addr->type = VIRTCHNL2_MAC_ADDR_EXTRA;
> +}
> +
>  /**
>   * idpf_mac_filter_async_handler - Async callback for mac filters
>   * @adapter: private data struct
> @@ -3636,6 +3645,7 @@ int idpf_add_del_mac_filters(struct idpf_vport
> *vport,
>  			    list) {
>  		if (add && f->add) {
>  			ether_addr_copy(mac_addr[i].addr, f->macaddr);
> +			idpf_set_mac_type(vport, &mac_addr[i]);
>  			i++;
>  			f->add = false;
>  			if (i == total_filters)
> @@ -3643,6 +3653,7 @@ int idpf_add_del_mac_filters(struct idpf_vport
> *vport,
>  		}
>  		if (!add && f->remove) {
>  			ether_addr_copy(mac_addr[i].addr, f->macaddr);
> +			idpf_set_mac_type(vport, &mac_addr[i]);
>  			i++;
>  			f->remove = false;
>  			if (i == total_filters)
> --
> 2.37.3
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Intel-wired-lan] [PATCH iwl-net] idpf: set mac type when adding and removing MAC filters
  2025-08-12 16:20 ` Hay, Joshua A
@ 2025-08-12 18:04   ` Tantilov, Emil S
  0 siblings, 0 replies; 4+ messages in thread
From: Tantilov, Emil S @ 2025-08-12 18:04 UTC (permalink / raw)
  To: Hay, Joshua A, intel-wired-lan@lists.osuosl.org
  Cc: willemb@google.com, decot@google.com, netdev@vger.kernel.org,
	Loktionov, Aleksandr, andrew+netdev@lunn.ch, edumazet@google.com,
	jianliu@redhat.com, Nguyen, Anthony L, Kitszel, Przemyslaw,
	kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net



On 8/12/2025 9:20 AM, Hay, Joshua A wrote:
>> On control planes that allow changing the MAC address of the interface,
>> the driver must provide a MAC type to avoid errors such as:
>>
>> idpf 0000:0a:00.0: Transaction failed (op 535)
>> idpf 0000:0a:00.0: Received invalid MAC filter payload (op 535) (len 0)
>>
>> These errors occur during driver load or when changing the MAC via:
>> ip link set <iface> address <mac>
>>
>> Add logic to set the MAC type before performing ADD/DEL operations.
>> Since only one primary MAC is supported per vport, the driver only needs
>> to perform ADD in idpf_set_mac().
>>
>> Fixes: ce1b75d0635c ("idpf: add ptypes and MAC filter support")
>> Reported-by: Jian Liu <jianliu@redhat.com>
>> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
>> Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
>> ---
>>   drivers/net/ethernet/intel/idpf/idpf_lib.c      |  6 ++----
>>   drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 11 +++++++++++
>>   2 files changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c
>> b/drivers/net/ethernet/intel/idpf/idpf_lib.c
>> index 80382ff4a5fa..77d554b0944b 100644
>> --- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
>> +++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
>> @@ -2284,17 +2284,15 @@ static int idpf_set_mac(struct net_device
>> *netdev, void *p)
>>   	if (ether_addr_equal(netdev->dev_addr, addr->sa_data))
>>   		goto unlock_mutex;
>>
>> +	ether_addr_copy(vport->default_mac_addr, addr->sa_data);
>>   	vport_config = vport->adapter->vport_config[vport->idx];
>>   	err = idpf_add_mac_filter(vport, np, addr->sa_data, false);
>>   	if (err) {
>>   		__idpf_del_mac_filter(vport_config, addr->sa_data);
>> +		ether_addr_copy(vport->default_mac_addr, netdev-
>>> dev_addr);
>>   		goto unlock_mutex;
>>   	}
>>
>> -	if (is_valid_ether_addr(vport->default_mac_addr))
>> -		idpf_del_mac_filter(vport, np, vport->default_mac_addr,
>> false);
> 
> We still need the call to __idpf_del_mac_filter here with the old addr to free it from the filter list.

Yeah, there is no need to send the message, but the filter list needs to 
be updated accordingly. Good catch! Will submit v2 to resolve it.

Thanks,
Emil

> 
> Thanks,
> Josh
> 
>> -
>> -	ether_addr_copy(vport->default_mac_addr, addr->sa_data);
>>   	eth_hw_addr_set(netdev, addr->sa_data);
>>
>>   unlock_mutex:
>> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
>> b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
>> index 24febaaa8fbb..7563289dc1e3 100644
>> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
>> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
>> @@ -3507,6 +3507,15 @@ u32 idpf_get_vport_id(struct idpf_vport *vport)
>>   	return le32_to_cpu(vport_msg->vport_id);
>>   }
>>
>> +static void idpf_set_mac_type(struct idpf_vport *vport,
>> +			      struct virtchnl2_mac_addr *mac_addr)
>> +{
>> +	if (ether_addr_equal(vport->default_mac_addr, mac_addr->addr))
>> +		mac_addr->type = VIRTCHNL2_MAC_ADDR_PRIMARY;
>> +	else
>> +		mac_addr->type = VIRTCHNL2_MAC_ADDR_EXTRA;
>> +}
>> +
>>   /**
>>    * idpf_mac_filter_async_handler - Async callback for mac filters
>>    * @adapter: private data struct
>> @@ -3636,6 +3645,7 @@ int idpf_add_del_mac_filters(struct idpf_vport
>> *vport,
>>   			    list) {
>>   		if (add && f->add) {
>>   			ether_addr_copy(mac_addr[i].addr, f->macaddr);
>> +			idpf_set_mac_type(vport, &mac_addr[i]);
>>   			i++;
>>   			f->add = false;
>>   			if (i == total_filters)
>> @@ -3643,6 +3653,7 @@ int idpf_add_del_mac_filters(struct idpf_vport
>> *vport,
>>   		}
>>   		if (!add && f->remove) {
>>   			ether_addr_copy(mac_addr[i].addr, f->macaddr);
>> +			idpf_set_mac_type(vport, &mac_addr[i]);
>>   			i++;
>>   			f->remove = false;
>>   			if (i == total_filters)
>> --
>> 2.37.3
>>
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-12 18:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-06 19:21 [Intel-wired-lan] [PATCH iwl-net] idpf: set mac type when adding and removing MAC filters Emil Tantilov
2025-08-07 13:32 ` Simon Horman
2025-08-12 16:20 ` Hay, Joshua A
2025-08-12 18:04   ` Tantilov, Emil S

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox