mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
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 <simon.horman@netronome.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
758238f2e7
commit
93da7d9660
3 changed files with 15 additions and 15 deletions
|
@ -69,7 +69,7 @@ int nfp_app_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn,
|
|||
if (err)
|
||||
return err < 0 ? err : 0;
|
||||
|
||||
nfp_net_get_mac_addr(app->pf, nn, id);
|
||||
nfp_net_get_mac_addr(app->pf, nn->port, id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ struct nfp_hwinfo;
|
|||
struct nfp_mip;
|
||||
struct nfp_net;
|
||||
struct nfp_nsp_identify;
|
||||
struct nfp_port;
|
||||
struct nfp_rtsym_table;
|
||||
|
||||
/**
|
||||
|
@ -147,7 +148,7 @@ void nfp_hwmon_unregister(struct nfp_pf *pf);
|
|||
struct nfp_eth_table_port *
|
||||
nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int id);
|
||||
void
|
||||
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id);
|
||||
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_port *port, unsigned int id);
|
||||
|
||||
bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
|
||||
|
||||
|
|
|
@ -135,25 +135,24 @@ static u8 __iomem *nfp_net_map_area(struct nfp_cpp *cpp,
|
|||
/**
|
||||
* nfp_net_get_mac_addr() - Get the MAC address.
|
||||
* @pf: NFP PF handle
|
||||
* @nn: NFP Network structure
|
||||
* @port: NFP port structure
|
||||
* @id: NFP port id
|
||||
*
|
||||
* First try to get the MAC address from NSP ETH table. If that
|
||||
* fails try HWInfo. As a last resort generate a random address.
|
||||
*/
|
||||
void
|
||||
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
|
||||
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_port *port, unsigned int id)
|
||||
{
|
||||
struct nfp_eth_table_port *eth_port;
|
||||
struct nfp_net_dp *dp = &nn->dp;
|
||||
u8 mac_addr[ETH_ALEN];
|
||||
const char *mac_str;
|
||||
char name[32];
|
||||
|
||||
eth_port = __nfp_port_get_eth_port(nn->port);
|
||||
eth_port = __nfp_port_get_eth_port(port);
|
||||
if (eth_port) {
|
||||
ether_addr_copy(dp->netdev->dev_addr, eth_port->mac_addr);
|
||||
ether_addr_copy(dp->netdev->perm_addr, eth_port->mac_addr);
|
||||
ether_addr_copy(port->netdev->dev_addr, eth_port->mac_addr);
|
||||
ether_addr_copy(port->netdev->perm_addr, eth_port->mac_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -161,22 +160,22 @@ nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
|
|||
|
||||
mac_str = nfp_hwinfo_lookup(pf->hwinfo, name);
|
||||
if (!mac_str) {
|
||||
dev_warn(dp->dev, "Can't lookup MAC address. Generate\n");
|
||||
eth_hw_addr_random(dp->netdev);
|
||||
nfp_warn(pf->cpp, "Can't lookup MAC address. Generate\n");
|
||||
eth_hw_addr_random(port->netdev);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
|
||||
&mac_addr[0], &mac_addr[1], &mac_addr[2],
|
||||
&mac_addr[3], &mac_addr[4], &mac_addr[5]) != 6) {
|
||||
dev_warn(dp->dev,
|
||||
"Can't parse MAC address (%s). Generate.\n", mac_str);
|
||||
eth_hw_addr_random(dp->netdev);
|
||||
nfp_warn(pf->cpp, "Can't parse MAC address (%s). Generate.\n",
|
||||
mac_str);
|
||||
eth_hw_addr_random(port->netdev);
|
||||
return;
|
||||
}
|
||||
|
||||
ether_addr_copy(dp->netdev->dev_addr, mac_addr);
|
||||
ether_addr_copy(dp->netdev->perm_addr, mac_addr);
|
||||
ether_addr_copy(port->netdev->dev_addr, mac_addr);
|
||||
ether_addr_copy(port->netdev->perm_addr, mac_addr);
|
||||
}
|
||||
|
||||
struct nfp_eth_table_port *
|
||||
|
|
Loading…
Reference in a new issue