Skip to content

Commit 93da7d9

Browse files
shorman-netronomedavem330
authored andcommitted
nfp: provide nfp_port to of nfp_net_get_mac_addr()
Provide port rather than vNIC as parameter of nfp_net_get_mac_addr. This is to allow this function to be used by representor netdevs where a vNIC may have more than one physical port none of which are associated with the vNIC. Signed-off-by: Simon Horman <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 758238f commit 93da7d9

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

drivers/net/ethernet/netronome/nfp/nfp_app_nic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int nfp_app_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn,
6969
if (err)
7070
return err < 0 ? err : 0;
7171

72-
nfp_net_get_mac_addr(app->pf, nn, id);
72+
nfp_net_get_mac_addr(app->pf, nn->port, id);
7373

7474
return 0;
7575
}

drivers/net/ethernet/netronome/nfp/nfp_main.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct nfp_hwinfo;
5858
struct nfp_mip;
5959
struct nfp_net;
6060
struct nfp_nsp_identify;
61+
struct nfp_port;
6162
struct nfp_rtsym_table;
6263

6364
/**
@@ -147,7 +148,7 @@ void nfp_hwmon_unregister(struct nfp_pf *pf);
147148
struct nfp_eth_table_port *
148149
nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int id);
149150
void
150-
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id);
151+
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_port *port, unsigned int id);
151152

152153
bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
153154

drivers/net/ethernet/netronome/nfp/nfp_net_main.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,48 +135,47 @@ static u8 __iomem *nfp_net_map_area(struct nfp_cpp *cpp,
135135
/**
136136
* nfp_net_get_mac_addr() - Get the MAC address.
137137
* @pf: NFP PF handle
138-
* @nn: NFP Network structure
138+
* @port: NFP port structure
139139
* @id: NFP port id
140140
*
141141
* First try to get the MAC address from NSP ETH table. If that
142142
* fails try HWInfo. As a last resort generate a random address.
143143
*/
144144
void
145-
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
145+
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_port *port, unsigned int id)
146146
{
147147
struct nfp_eth_table_port *eth_port;
148-
struct nfp_net_dp *dp = &nn->dp;
149148
u8 mac_addr[ETH_ALEN];
150149
const char *mac_str;
151150
char name[32];
152151

153-
eth_port = __nfp_port_get_eth_port(nn->port);
152+
eth_port = __nfp_port_get_eth_port(port);
154153
if (eth_port) {
155-
ether_addr_copy(dp->netdev->dev_addr, eth_port->mac_addr);
156-
ether_addr_copy(dp->netdev->perm_addr, eth_port->mac_addr);
154+
ether_addr_copy(port->netdev->dev_addr, eth_port->mac_addr);
155+
ether_addr_copy(port->netdev->perm_addr, eth_port->mac_addr);
157156
return;
158157
}
159158

160159
snprintf(name, sizeof(name), "eth%d.mac", id);
161160

162161
mac_str = nfp_hwinfo_lookup(pf->hwinfo, name);
163162
if (!mac_str) {
164-
dev_warn(dp->dev, "Can't lookup MAC address. Generate\n");
165-
eth_hw_addr_random(dp->netdev);
163+
nfp_warn(pf->cpp, "Can't lookup MAC address. Generate\n");
164+
eth_hw_addr_random(port->netdev);
166165
return;
167166
}
168167

169168
if (sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
170169
&mac_addr[0], &mac_addr[1], &mac_addr[2],
171170
&mac_addr[3], &mac_addr[4], &mac_addr[5]) != 6) {
172-
dev_warn(dp->dev,
173-
"Can't parse MAC address (%s). Generate.\n", mac_str);
174-
eth_hw_addr_random(dp->netdev);
171+
nfp_warn(pf->cpp, "Can't parse MAC address (%s). Generate.\n",
172+
mac_str);
173+
eth_hw_addr_random(port->netdev);
175174
return;
176175
}
177176

178-
ether_addr_copy(dp->netdev->dev_addr, mac_addr);
179-
ether_addr_copy(dp->netdev->perm_addr, mac_addr);
177+
ether_addr_copy(port->netdev->dev_addr, mac_addr);
178+
ether_addr_copy(port->netdev->perm_addr, mac_addr);
180179
}
181180

182181
struct nfp_eth_table_port *

0 commit comments

Comments
 (0)