aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/emulex/benet/be_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/emulex/benet/be_main.c')
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 181edb522450..29e7870e0b35 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -247,54 +247,54 @@ void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, u16 num_popped)
247static int be_mac_addr_set(struct net_device *netdev, void *p) 247static int be_mac_addr_set(struct net_device *netdev, void *p)
248{ 248{
249 struct be_adapter *adapter = netdev_priv(netdev); 249 struct be_adapter *adapter = netdev_priv(netdev);
250 struct device *dev = &adapter->pdev->dev;
250 struct sockaddr *addr = p; 251 struct sockaddr *addr = p;
251 int status = 0; 252 int status;
252 u8 current_mac[ETH_ALEN]; 253 u8 mac[ETH_ALEN];
253 u32 pmac_id = adapter->pmac_id[0]; 254 u32 old_pmac_id = adapter->pmac_id[0], curr_pmac_id = 0;
254 bool active_mac = true;
255 255
256 if (!is_valid_ether_addr(addr->sa_data)) 256 if (!is_valid_ether_addr(addr->sa_data))
257 return -EADDRNOTAVAIL; 257 return -EADDRNOTAVAIL;
258 258
259 /* For BE VF, MAC address is already activated by PF. 259 /* The PMAC_ADD cmd may fail if the VF doesn't have FILTMGMT
260 * Hence only operation left is updating netdev->devaddr. 260 * privilege or if PF did not provision the new MAC address.
261 * Update it if user is passing the same MAC which was used 261 * On BE3, this cmd will always fail if the VF doesn't have the
262 * during configuring VF MAC from PF(Hypervisor). 262 * FILTMGMT privilege. This failure is OK, only if the PF programmed
263 * the MAC for the VF.
263 */ 264 */
264 if (!lancer_chip(adapter) && !be_physfn(adapter)) { 265 status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data,
265 status = be_cmd_mac_addr_query(adapter, current_mac, 266 adapter->if_handle, &adapter->pmac_id[0], 0);
266 false, adapter->if_handle, 0); 267 if (!status) {
267 if (!status && !memcmp(current_mac, addr->sa_data, ETH_ALEN)) 268 curr_pmac_id = adapter->pmac_id[0];
268 goto done;
269 else
270 goto err;
271 }
272 269
273 if (!memcmp(addr->sa_data, netdev->dev_addr, ETH_ALEN)) 270 /* Delete the old programmed MAC. This call may fail if the
274 goto done; 271 * old MAC was already deleted by the PF driver.
272 */
273 if (adapter->pmac_id[0] != old_pmac_id)
274 be_cmd_pmac_del(adapter, adapter->if_handle,
275 old_pmac_id, 0);
276 }
275 277
276 /* For Lancer check if any MAC is active. 278 /* Decide if the new MAC is successfully activated only after
277 * If active, get its mac id. 279 * querying the FW
278 */ 280 */
279 if (lancer_chip(adapter) && !be_physfn(adapter)) 281 status = be_cmd_get_active_mac(adapter, curr_pmac_id, mac);
280 be_cmd_get_mac_from_list(adapter, current_mac, &active_mac,
281 &pmac_id, 0);
282
283 status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data,
284 adapter->if_handle,
285 &adapter->pmac_id[0], 0);
286
287 if (status) 282 if (status)
288 goto err; 283 goto err;
289 284
290 if (active_mac) 285 /* The MAC change did not happen, either due to lack of privilege
291 be_cmd_pmac_del(adapter, adapter->if_handle, 286 * or PF didn't pre-provision.
292 pmac_id, 0); 287 */
293done: 288 if (memcmp(addr->sa_data, mac, ETH_ALEN)) {
289 status = -EPERM;
290 goto err;
291 }
292
294 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); 293 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
294 dev_info(dev, "MAC address changed to %pM\n", mac);
295 return 0; 295 return 0;
296err: 296err:
297 dev_err(&adapter->pdev->dev, "MAC %pM set Failed\n", addr->sa_data); 297 dev_warn(dev, "MAC address change to %pM failed\n", addr->sa_data);
298 return status; 298 return status;
299} 299}
300 300