Skip to content

Commit acf3a5c

Browse files
etantilovanguy11
authored andcommitted
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 <[email protected]> Signed-off-by: Emil Tantilov <[email protected]> Reviewed-by: Aleksandr Loktionov <[email protected]> Reviewed-by: Paul Menzel <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Samuel Salin <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 65637c3 commit acf3a5c

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
@@ -2344,6 +2344,7 @@ static int idpf_set_mac(struct net_device *netdev, void *p)
23442344
struct idpf_netdev_priv *np = netdev_priv(netdev);
23452345
struct idpf_vport_config *vport_config;
23462346
struct sockaddr *addr = p;
2347+
u8 old_mac_addr[ETH_ALEN];
23472348
struct idpf_vport *vport;
23482349
int err = 0;
23492350

@@ -2367,17 +2368,19 @@ static int idpf_set_mac(struct net_device *netdev, void *p)
23672368
if (ether_addr_equal(netdev->dev_addr, addr->sa_data))
23682369
goto unlock_mutex;
23692370

2371+
ether_addr_copy(old_mac_addr, vport->default_mac_addr);
2372+
ether_addr_copy(vport->default_mac_addr, addr->sa_data);
23702373
vport_config = vport->adapter->vport_config[vport->idx];
23712374
err = idpf_add_mac_filter(vport, np, addr->sa_data, false);
23722375
if (err) {
23732376
__idpf_del_mac_filter(vport_config, addr->sa_data);
2377+
ether_addr_copy(vport->default_mac_addr, netdev->dev_addr);
23742378
goto unlock_mutex;
23752379
}
23762380

2377-
if (is_valid_ether_addr(vport->default_mac_addr))
2378-
idpf_del_mac_filter(vport, np, vport->default_mac_addr, false);
2381+
if (is_valid_ether_addr(old_mac_addr))
2382+
__idpf_del_mac_filter(vport_config, old_mac_addr);
23792383

2380-
ether_addr_copy(vport->default_mac_addr, addr->sa_data);
23812384
eth_hw_addr_set(netdev, addr->sa_data);
23822385

23832386
unlock_mutex:

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

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

3768+
static void idpf_set_mac_type(struct idpf_vport *vport,
3769+
struct virtchnl2_mac_addr *mac_addr)
3770+
{
3771+
bool is_primary;
3772+
3773+
is_primary = ether_addr_equal(vport->default_mac_addr, mac_addr->addr);
3774+
mac_addr->type = is_primary ? VIRTCHNL2_MAC_ADDR_PRIMARY :
3775+
VIRTCHNL2_MAC_ADDR_EXTRA;
3776+
}
3777+
37683778
/**
37693779
* idpf_mac_filter_async_handler - Async callback for mac filters
37703780
* @adapter: private data struct
@@ -3894,13 +3904,15 @@ int idpf_add_del_mac_filters(struct idpf_vport *vport,
38943904
list) {
38953905
if (add && f->add) {
38963906
ether_addr_copy(mac_addr[i].addr, f->macaddr);
3907+
idpf_set_mac_type(vport, &mac_addr[i]);
38973908
i++;
38983909
f->add = false;
38993910
if (i == total_filters)
39003911
break;
39013912
}
39023913
if (!add && f->remove) {
39033914
ether_addr_copy(mac_addr[i].addr, f->macaddr);
3915+
idpf_set_mac_type(vport, &mac_addr[i]);
39043916
i++;
39053917
f->remove = false;
39063918
if (i == total_filters)

0 commit comments

Comments
 (0)