Commit 9a173901 authored by Greg Rose's avatar Greg Rose Committed by Jeff Kirsher

i40e/i40evf: User ether_addr_copy instead of memcpy

Linux gives us a function to copy Ethernet MAC addresses, let's use it.

Change-ID: I0c861900029ca5ea65a53ca39565852fb633f6fd
Signed-off-by: default avatarGreg Rose <gregory.v.rose@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 8c27d42e
...@@ -1202,7 +1202,7 @@ struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi, ...@@ -1202,7 +1202,7 @@ struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,
if (!f) if (!f)
goto add_filter_out; goto add_filter_out;
memcpy(f->macaddr, macaddr, ETH_ALEN); ether_addr_copy(f->macaddr, macaddr);
f->vlan = vlan; f->vlan = vlan;
f->changed = true; f->changed = true;
...@@ -1326,7 +1326,7 @@ static int i40e_set_mac(struct net_device *netdev, void *p) ...@@ -1326,7 +1326,7 @@ static int i40e_set_mac(struct net_device *netdev, void *p)
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
} }
memcpy(vsi->back->hw.mac.addr, addr->sa_data, netdev->addr_len); ether_addr_copy(vsi->back->hw.mac.addr, addr->sa_data);
} }
/* In order to be sure to not drop any packets, add the new address /* In order to be sure to not drop any packets, add the new address
...@@ -1340,7 +1340,7 @@ static int i40e_set_mac(struct net_device *netdev, void *p) ...@@ -1340,7 +1340,7 @@ static int i40e_set_mac(struct net_device *netdev, void *p)
i40e_del_filter(vsi, netdev->dev_addr, I40E_VLAN_ANY, false, false); i40e_del_filter(vsi, netdev->dev_addr, I40E_VLAN_ANY, false, false);
i40e_sync_vsi_filters(vsi); i40e_sync_vsi_filters(vsi);
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); ether_addr_copy(netdev->dev_addr, addr->sa_data);
return 0; return 0;
} }
...@@ -1597,8 +1597,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi) ...@@ -1597,8 +1597,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
cmd_flags = 0; cmd_flags = 0;
/* add to delete list */ /* add to delete list */
memcpy(del_list[num_del].mac_addr, ether_addr_copy(del_list[num_del].mac_addr, f->macaddr);
f->macaddr, ETH_ALEN);
del_list[num_del].vlan_tag = del_list[num_del].vlan_tag =
cpu_to_le16((u16)(f->vlan == cpu_to_le16((u16)(f->vlan ==
I40E_VLAN_ANY ? 0 : f->vlan)); I40E_VLAN_ANY ? 0 : f->vlan));
...@@ -1663,8 +1662,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi) ...@@ -1663,8 +1662,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
cmd_flags = 0; cmd_flags = 0;
/* add to add array */ /* add to add array */
memcpy(add_list[num_add].mac_addr, ether_addr_copy(add_list[num_add].mac_addr, f->macaddr);
f->macaddr, ETH_ALEN);
add_list[num_add].vlan_tag = add_list[num_add].vlan_tag =
cpu_to_le16( cpu_to_le16(
(u16)(f->vlan == I40E_VLAN_ANY ? 0 : f->vlan)); (u16)(f->vlan == I40E_VLAN_ANY ? 0 : f->vlan));
...@@ -7003,7 +7001,7 @@ static int i40e_config_netdev(struct i40e_vsi *vsi) ...@@ -7003,7 +7001,7 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
if (vsi->type == I40E_VSI_MAIN) { if (vsi->type == I40E_VSI_MAIN) {
SET_NETDEV_DEV(netdev, &pf->pdev->dev); SET_NETDEV_DEV(netdev, &pf->pdev->dev);
memcpy(mac_addr, hw->mac.perm_addr, ETH_ALEN); ether_addr_copy(mac_addr, hw->mac.perm_addr);
/* The following two steps are necessary to prevent reception /* The following two steps are necessary to prevent reception
* of tagged packets - by default the NVM loads a MAC-VLAN * of tagged packets - by default the NVM loads a MAC-VLAN
* filter that will accept any tagged packet. This is to * filter that will accept any tagged packet. This is to
...@@ -7021,8 +7019,8 @@ static int i40e_config_netdev(struct i40e_vsi *vsi) ...@@ -7021,8 +7019,8 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
} }
i40e_add_filter(vsi, brdcast, I40E_VLAN_ANY, false, false); i40e_add_filter(vsi, brdcast, I40E_VLAN_ANY, false, false);
memcpy(netdev->dev_addr, mac_addr, ETH_ALEN); ether_addr_copy(netdev->dev_addr, mac_addr);
memcpy(netdev->perm_addr, mac_addr, ETH_ALEN); ether_addr_copy(netdev->perm_addr, mac_addr);
/* vlan gets same features (except vlan offload) /* vlan gets same features (except vlan offload)
* after any tweaks for specific VSI types * after any tweaks for specific VSI types
*/ */
...@@ -8524,7 +8522,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -8524,7 +8522,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_mac_addr; goto err_mac_addr;
} }
dev_info(&pdev->dev, "MAC address: %pM\n", hw->mac.addr); dev_info(&pdev->dev, "MAC address: %pM\n", hw->mac.addr);
memcpy(hw->mac.perm_addr, hw->mac.addr, ETH_ALEN); ether_addr_copy(hw->mac.perm_addr, hw->mac.addr);
pci_set_drvdata(pdev, pf); pci_set_drvdata(pdev, pf);
pci_save_state(pdev); pci_save_state(pdev);
......
...@@ -2075,7 +2075,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) ...@@ -2075,7 +2075,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
ret = -EIO; ret = -EIO;
goto error_param; goto error_param;
} }
memcpy(vf->default_lan_addr.addr, mac, ETH_ALEN); ether_addr_copy(vf->default_lan_addr.addr, mac);
vf->pf_set_mac = true; vf->pf_set_mac = true;
dev_info(&pf->pdev->dev, "Reload the VF driver to make this change effective.\n"); dev_info(&pf->pdev->dev, "Reload the VF driver to make this change effective.\n");
ret = 0; ret = 0;
......
...@@ -772,7 +772,7 @@ i40evf_mac_filter *i40evf_add_filter(struct i40evf_adapter *adapter, ...@@ -772,7 +772,7 @@ i40evf_mac_filter *i40evf_add_filter(struct i40evf_adapter *adapter,
return NULL; return NULL;
} }
memcpy(f->macaddr, macaddr, ETH_ALEN); ether_addr_copy(f->macaddr, macaddr);
list_add(&f->list, &adapter->mac_filter_list); list_add(&f->list, &adapter->mac_filter_list);
f->add = true; f->add = true;
...@@ -805,9 +805,8 @@ static int i40evf_set_mac(struct net_device *netdev, void *p) ...@@ -805,9 +805,8 @@ static int i40evf_set_mac(struct net_device *netdev, void *p)
f = i40evf_add_filter(adapter, addr->sa_data); f = i40evf_add_filter(adapter, addr->sa_data);
if (f) { if (f) {
memcpy(hw->mac.addr, addr->sa_data, netdev->addr_len); ether_addr_copy(hw->mac.addr, addr->sa_data);
memcpy(netdev->dev_addr, adapter->hw.mac.addr, ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
netdev->addr_len);
} }
return (f == NULL) ? -ENOMEM : 0; return (f == NULL) ? -ENOMEM : 0;
...@@ -2059,8 +2058,8 @@ static void i40evf_init_task(struct work_struct *work) ...@@ -2059,8 +2058,8 @@ static void i40evf_init_task(struct work_struct *work)
adapter->hw.mac.addr); adapter->hw.mac.addr);
random_ether_addr(adapter->hw.mac.addr); random_ether_addr(adapter->hw.mac.addr);
} }
memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len); ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len); ether_addr_copy(netdev->perm_addr, adapter->hw.mac.addr);
INIT_LIST_HEAD(&adapter->mac_filter_list); INIT_LIST_HEAD(&adapter->mac_filter_list);
INIT_LIST_HEAD(&adapter->vlan_filter_list); INIT_LIST_HEAD(&adapter->vlan_filter_list);
...@@ -2068,7 +2067,7 @@ static void i40evf_init_task(struct work_struct *work) ...@@ -2068,7 +2067,7 @@ static void i40evf_init_task(struct work_struct *work)
if (NULL == f) if (NULL == f)
goto err_sw_init; goto err_sw_init;
memcpy(f->macaddr, adapter->hw.mac.addr, ETH_ALEN); ether_addr_copy(f->macaddr, adapter->hw.mac.addr);
f->add = true; f->add = true;
adapter->aq_required |= I40EVF_FLAG_AQ_ADD_MAC_FILTER; adapter->aq_required |= I40EVF_FLAG_AQ_ADD_MAC_FILTER;
......
...@@ -407,7 +407,7 @@ void i40evf_add_ether_addrs(struct i40evf_adapter *adapter) ...@@ -407,7 +407,7 @@ void i40evf_add_ether_addrs(struct i40evf_adapter *adapter)
veal->num_elements = count; veal->num_elements = count;
list_for_each_entry(f, &adapter->mac_filter_list, list) { list_for_each_entry(f, &adapter->mac_filter_list, list) {
if (f->add) { if (f->add) {
memcpy(veal->list[i].addr, f->macaddr, ETH_ALEN); ether_addr_copy(veal->list[i].addr, f->macaddr);
i++; i++;
f->add = false; f->add = false;
} }
...@@ -468,7 +468,7 @@ void i40evf_del_ether_addrs(struct i40evf_adapter *adapter) ...@@ -468,7 +468,7 @@ void i40evf_del_ether_addrs(struct i40evf_adapter *adapter)
veal->num_elements = count; veal->num_elements = count;
list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) {
if (f->remove) { if (f->remove) {
memcpy(veal->list[i].addr, f->macaddr, ETH_ALEN); ether_addr_copy(veal->list[i].addr, f->macaddr);
i++; i++;
list_del(&f->list); list_del(&f->list);
kfree(f); kfree(f);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment