Skip to content

Commit 6e6588b

Browse files
committed
idpf: set mac type when adding and removing MAC filters
JIRA: https://issues.redhat.com/browse/RHEL-121482 JIRA: https://issues.redhat.com/browse/RHEL-121948 commit acf3a5c Author: Emil Tantilov <emil.s.tantilov@intel.com> Date: Thu Aug 14 16:43:00 2025 -0700 idpf: set mac type when adding and removing MAC filters 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) idpf 0000:0a:00.0: Transaction failed (op 536) 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 when sending ADD/DEL (opcodes 535/536) to the control plane. Since only one primary MAC is supported per vport, the driver only needs to send an ADD opcode when setting it. Remove the old address by calling __idpf_del_mac_filter(), which skips the message and just clears the entry from the internal list. This avoids an error on DEL as it attempts to remove an address already cleared by the preceding ADD opcode. Fixes: ce1b75d ("idpf: add ptypes and MAC filter support") Reported-by: Jian Liu <jianliu@redhat.com> Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Samuel Salin <Samuel.salin@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
1 parent b8bd692 commit 6e6588b

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

drivers/net/ethernet/intel/idpf/idpf_lib.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,6 +2267,7 @@ static int idpf_set_mac(struct net_device *netdev, void *p)
22672267
struct idpf_netdev_priv *np = netdev_priv(netdev);
22682268
struct idpf_vport_config *vport_config;
22692269
struct sockaddr *addr = p;
2270+
u8 old_mac_addr[ETH_ALEN];
22702271
struct idpf_vport *vport;
22712272
int err = 0;
22722273

@@ -2290,17 +2291,19 @@ static int idpf_set_mac(struct net_device *netdev, void *p)
22902291
if (ether_addr_equal(netdev->dev_addr, addr->sa_data))
22912292
goto unlock_mutex;
22922293

2294+
ether_addr_copy(old_mac_addr, vport->default_mac_addr);
2295+
ether_addr_copy(vport->default_mac_addr, addr->sa_data);
22932296
vport_config = vport->adapter->vport_config[vport->idx];
22942297
err = idpf_add_mac_filter(vport, np, addr->sa_data, false);
22952298
if (err) {
22962299
__idpf_del_mac_filter(vport_config, addr->sa_data);
2300+
ether_addr_copy(vport->default_mac_addr, netdev->dev_addr);
22972301
goto unlock_mutex;
22982302
}
22992303

2300-
if (is_valid_ether_addr(vport->default_mac_addr))
2301-
idpf_del_mac_filter(vport, np, vport->default_mac_addr, false);
2304+
if (is_valid_ether_addr(old_mac_addr))
2305+
__idpf_del_mac_filter(vport_config, old_mac_addr);
23022306

2303-
ether_addr_copy(vport->default_mac_addr, addr->sa_data);
23042307
eth_hw_addr_set(netdev, addr->sa_data);
23052308

23062309
unlock_mutex:

drivers/net/ethernet/intel/idpf/idpf_virtchnl.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,6 +3516,16 @@ u32 idpf_get_vport_id(struct idpf_vport *vport)
35163516
return le32_to_cpu(vport_msg->vport_id);
35173517
}
35183518

3519+
static void idpf_set_mac_type(struct idpf_vport *vport,
3520+
struct virtchnl2_mac_addr *mac_addr)
3521+
{
3522+
bool is_primary;
3523+
3524+
is_primary = ether_addr_equal(vport->default_mac_addr, mac_addr->addr);
3525+
mac_addr->type = is_primary ? VIRTCHNL2_MAC_ADDR_PRIMARY :
3526+
VIRTCHNL2_MAC_ADDR_EXTRA;
3527+
}
3528+
35193529
/**
35203530
* idpf_mac_filter_async_handler - Async callback for mac filters
35213531
* @adapter: private data struct
@@ -3645,13 +3655,15 @@ int idpf_add_del_mac_filters(struct idpf_vport *vport,
36453655
list) {
36463656
if (add && f->add) {
36473657
ether_addr_copy(mac_addr[i].addr, f->macaddr);
3658+
idpf_set_mac_type(vport, &mac_addr[i]);
36483659
i++;
36493660
f->add = false;
36503661
if (i == total_filters)
36513662
break;
36523663
}
36533664
if (!add && f->remove) {
36543665
ether_addr_copy(mac_addr[i].addr, f->macaddr);
3666+
idpf_set_mac_type(vport, &mac_addr[i]);
36553667
i++;
36563668
f->remove = false;
36573669
if (i == total_filters)

0 commit comments

Comments
 (0)