Skip to content

Commit 6275dc1

Browse files
etantilovgregkh
authored andcommitted
idpf: set mac type when adding and removing MAC filters
[ Upstream commit acf3a5c ] 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: Sasha Levin <sashal@kernel.org>
1 parent 923c267 commit 6275dc1

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
@@ -2277,6 +2277,7 @@ static int idpf_set_mac(struct net_device *netdev, void *p)
22772277
struct idpf_netdev_priv *np = netdev_priv(netdev);
22782278
struct idpf_vport_config *vport_config;
22792279
struct sockaddr *addr = p;
2280+
u8 old_mac_addr[ETH_ALEN];
22802281
struct idpf_vport *vport;
22812282
int err = 0;
22822283

@@ -2300,17 +2301,19 @@ static int idpf_set_mac(struct net_device *netdev, void *p)
23002301
if (ether_addr_equal(netdev->dev_addr, addr->sa_data))
23012302
goto unlock_mutex;
23022303

2304+
ether_addr_copy(old_mac_addr, vport->default_mac_addr);
2305+
ether_addr_copy(vport->default_mac_addr, addr->sa_data);
23032306
vport_config = vport->adapter->vport_config[vport->idx];
23042307
err = idpf_add_mac_filter(vport, np, addr->sa_data, false);
23052308
if (err) {
23062309
__idpf_del_mac_filter(vport_config, addr->sa_data);
2310+
ether_addr_copy(vport->default_mac_addr, netdev->dev_addr);
23072311
goto unlock_mutex;
23082312
}
23092313

2310-
if (is_valid_ether_addr(vport->default_mac_addr))
2311-
idpf_del_mac_filter(vport, np, vport->default_mac_addr, false);
2314+
if (is_valid_ether_addr(old_mac_addr))
2315+
__idpf_del_mac_filter(vport_config, old_mac_addr);
23122316

2313-
ether_addr_copy(vport->default_mac_addr, addr->sa_data);
23142317
eth_hw_addr_set(netdev, addr->sa_data);
23152318

23162319
unlock_mutex:

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

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

3510+
static void idpf_set_mac_type(struct idpf_vport *vport,
3511+
struct virtchnl2_mac_addr *mac_addr)
3512+
{
3513+
bool is_primary;
3514+
3515+
is_primary = ether_addr_equal(vport->default_mac_addr, mac_addr->addr);
3516+
mac_addr->type = is_primary ? VIRTCHNL2_MAC_ADDR_PRIMARY :
3517+
VIRTCHNL2_MAC_ADDR_EXTRA;
3518+
}
3519+
35103520
/**
35113521
* idpf_mac_filter_async_handler - Async callback for mac filters
35123522
* @adapter: private data struct
@@ -3636,13 +3646,15 @@ int idpf_add_del_mac_filters(struct idpf_vport *vport,
36363646
list) {
36373647
if (add && f->add) {
36383648
ether_addr_copy(mac_addr[i].addr, f->macaddr);
3649+
idpf_set_mac_type(vport, &mac_addr[i]);
36393650
i++;
36403651
f->add = false;
36413652
if (i == total_filters)
36423653
break;
36433654
}
36443655
if (!add && f->remove) {
36453656
ether_addr_copy(mac_addr[i].addr, f->macaddr);
3657+
idpf_set_mac_type(vport, &mac_addr[i]);
36463658
i++;
36473659
f->remove = false;
36483660
if (i == total_filters)

0 commit comments

Comments
 (0)