Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 340414
b: refs/heads/master
c: 704e4c8
h: refs/heads/master
v: v3
  • Loading branch information
Padmanabh Ratnakar authored and David S. Miller committed Oct 22, 2012
1 parent 7745370 commit 9aff729
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d5c184731fad8018084f5d8c4850f0b9cb5336e5
refs/heads/master: 704e4c88f0274e554439cc48b06ccc4fdfccc568
52 changes: 42 additions & 10 deletions trunk/drivers/net/ethernet/emulex/benet/be_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,23 +237,46 @@ static int be_mac_addr_set(struct net_device *netdev, void *p)
int status = 0;
u8 current_mac[ETH_ALEN];
u32 pmac_id = adapter->pmac_id[0];
bool active_mac = true;

if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;

status = be_cmd_mac_addr_query(adapter, current_mac, false,
adapter->if_handle, 0);
/* For BE VF, MAC address is already activated by PF.
* Hence only operation left is updating netdev->devaddr.
* Update it if user is passing the same MAC which was used
* during configuring VF MAC from PF(Hypervisor).
*/
if (!lancer_chip(adapter) && !be_physfn(adapter)) {
status = be_cmd_mac_addr_query(adapter, current_mac,
false, adapter->if_handle, 0);
if (!status && !memcmp(current_mac, addr->sa_data, ETH_ALEN))
goto done;
else
goto err;
}

if (!memcmp(addr->sa_data, netdev->dev_addr, ETH_ALEN))
goto done;

/* For Lancer check if any MAC is active.
* If active, get its mac id.
*/
if (lancer_chip(adapter) && !be_physfn(adapter))
be_cmd_get_mac_from_list(adapter, current_mac, &active_mac,
&pmac_id, 0);

status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data,
adapter->if_handle,
&adapter->pmac_id[0], 0);

if (status)
goto err;

if (memcmp(addr->sa_data, current_mac, ETH_ALEN)) {
status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data,
adapter->if_handle, &adapter->pmac_id[0], 0);
if (status)
goto err;

be_cmd_pmac_del(adapter, adapter->if_handle, pmac_id, 0);
}
if (active_mac)
be_cmd_pmac_del(adapter, adapter->if_handle,
pmac_id, 0);
done:
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
return 0;
err:
Expand Down Expand Up @@ -962,6 +985,9 @@ static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
struct be_adapter *adapter = netdev_priv(netdev);
struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf];
int status;
bool active_mac = false;
u32 pmac_id;
u8 old_mac[ETH_ALEN];

if (!sriov_enabled(adapter))
return -EPERM;
Expand All @@ -970,6 +996,12 @@ static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
return -EINVAL;

if (lancer_chip(adapter)) {
status = be_cmd_get_mac_from_list(adapter, old_mac, &active_mac,
&pmac_id, vf + 1);
if (!status && active_mac)
be_cmd_pmac_del(adapter, vf_cfg->if_handle,
pmac_id, vf + 1);

status = be_cmd_set_mac_list(adapter, mac, 1, vf + 1);
} else {
status = be_cmd_pmac_del(adapter, vf_cfg->if_handle,
Expand Down

0 comments on commit 9aff729

Please sign in to comment.