提交 93da7d96 编写于 作者: S Simon Horman 提交者: David S. Miller

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: NSimon Horman <simon.horman@netronome.com>
Reviewed-by: NJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 758238f2
...@@ -69,7 +69,7 @@ int nfp_app_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn, ...@@ -69,7 +69,7 @@ int nfp_app_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn,
if (err) if (err)
return err < 0 ? err : 0; 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; return 0;
} }
...@@ -58,6 +58,7 @@ struct nfp_hwinfo; ...@@ -58,6 +58,7 @@ struct nfp_hwinfo;
struct nfp_mip; struct nfp_mip;
struct nfp_net; struct nfp_net;
struct nfp_nsp_identify; struct nfp_nsp_identify;
struct nfp_port;
struct nfp_rtsym_table; struct nfp_rtsym_table;
/** /**
...@@ -147,7 +148,7 @@ void nfp_hwmon_unregister(struct nfp_pf *pf); ...@@ -147,7 +148,7 @@ void nfp_hwmon_unregister(struct nfp_pf *pf);
struct nfp_eth_table_port * struct nfp_eth_table_port *
nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int id); nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int id);
void 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); 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, ...@@ -135,25 +135,24 @@ static u8 __iomem *nfp_net_map_area(struct nfp_cpp *cpp,
/** /**
* nfp_net_get_mac_addr() - Get the MAC address. * nfp_net_get_mac_addr() - Get the MAC address.
* @pf: NFP PF handle * @pf: NFP PF handle
* @nn: NFP Network structure * @port: NFP port structure
* @id: NFP port id * @id: NFP port id
* *
* First try to get the MAC address from NSP ETH table. If that * First try to get the MAC address from NSP ETH table. If that
* fails try HWInfo. As a last resort generate a random address. * fails try HWInfo. As a last resort generate a random address.
*/ */
void 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_eth_table_port *eth_port;
struct nfp_net_dp *dp = &nn->dp;
u8 mac_addr[ETH_ALEN]; u8 mac_addr[ETH_ALEN];
const char *mac_str; const char *mac_str;
char name[32]; char name[32];
eth_port = __nfp_port_get_eth_port(nn->port); eth_port = __nfp_port_get_eth_port(port);
if (eth_port) { if (eth_port) {
ether_addr_copy(dp->netdev->dev_addr, eth_port->mac_addr); ether_addr_copy(port->netdev->dev_addr, eth_port->mac_addr);
ether_addr_copy(dp->netdev->perm_addr, eth_port->mac_addr); ether_addr_copy(port->netdev->perm_addr, eth_port->mac_addr);
return; return;
} }
...@@ -161,22 +160,22 @@ nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id) ...@@ -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); mac_str = nfp_hwinfo_lookup(pf->hwinfo, name);
if (!mac_str) { if (!mac_str) {
dev_warn(dp->dev, "Can't lookup MAC address. Generate\n"); nfp_warn(pf->cpp, "Can't lookup MAC address. Generate\n");
eth_hw_addr_random(dp->netdev); eth_hw_addr_random(port->netdev);
return; return;
} }
if (sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", if (sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
&mac_addr[0], &mac_addr[1], &mac_addr[2], &mac_addr[0], &mac_addr[1], &mac_addr[2],
&mac_addr[3], &mac_addr[4], &mac_addr[5]) != 6) { &mac_addr[3], &mac_addr[4], &mac_addr[5]) != 6) {
dev_warn(dp->dev, nfp_warn(pf->cpp, "Can't parse MAC address (%s). Generate.\n",
"Can't parse MAC address (%s). Generate.\n", mac_str); mac_str);
eth_hw_addr_random(dp->netdev); eth_hw_addr_random(port->netdev);
return; return;
} }
ether_addr_copy(dp->netdev->dev_addr, mac_addr); ether_addr_copy(port->netdev->dev_addr, mac_addr);
ether_addr_copy(dp->netdev->perm_addr, mac_addr); ether_addr_copy(port->netdev->perm_addr, mac_addr);
} }
struct nfp_eth_table_port * struct nfp_eth_table_port *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册