@@ -265,8 +265,7 @@ nfp_abm_vnic_set_mac(struct nfp_pf *pf, struct nfp_abm *abm, struct nfp_net *nn,
if (id > pf->eth_tbl->count) {
nfp_warn(pf->cpp, "No entry for persistent MAC address\n");
- eth_hw_addr_random(nn->dp.netdev);
- return;
+ goto generate_random_address;
}
snprintf(hwinfo, sizeof(hwinfo), "eth%u.mac.pf%u",
@@ -276,14 +275,13 @@ nfp_abm_vnic_set_mac(struct nfp_pf *pf, struct nfp_abm *abm, struct nfp_net *nn,
if (IS_ERR(nsp)) {
nfp_warn(pf->cpp, "Failed to access the NSP for persistent MAC address: %ld\n",
PTR_ERR(nsp));
- eth_hw_addr_random(nn->dp.netdev);
- return;
+ goto generate_random_address;
}
if (!nfp_nsp_has_hwinfo_lookup(nsp)) {
nfp_warn(pf->cpp, "NSP doesn't support PF MAC generation\n");
- eth_hw_addr_random(nn->dp.netdev);
- return;
+ nfp_nsp_close(nsp);
+ goto generate_random_address;
}
err = nfp_nsp_hwinfo_lookup(nsp, hwinfo, sizeof(hwinfo));
@@ -291,8 +289,7 @@ nfp_abm_vnic_set_mac(struct nfp_pf *pf, struct nfp_abm *abm, struct nfp_net *nn,
if (err) {
nfp_warn(pf->cpp, "Reading persistent MAC address failed: %d\n",
err);
- eth_hw_addr_random(nn->dp.netdev);
- return;
+ goto generate_random_address;
}
if (sscanf(hwinfo, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
@@ -300,12 +297,15 @@ nfp_abm_vnic_set_mac(struct nfp_pf *pf, struct nfp_abm *abm, struct nfp_net *nn,
&mac_addr[3], &mac_addr[4], &mac_addr[5]) != 6) {
nfp_warn(pf->cpp, "Can't parse persistent MAC address (%s)\n",
hwinfo);
- eth_hw_addr_random(nn->dp.netdev);
- return;
+ goto generate_random_address;
}
ether_addr_copy(nn->dp.netdev->dev_addr, mac_addr);
ether_addr_copy(nn->dp.netdev->perm_addr, mac_addr);
+
+generate_random_address:
+ eth_hw_addr_random(nn->dp.netdev);
+ return;
}
static int