nfp: don't depend on eth_tbl being available
For very very old generation of the management FW Ethernet port information table may theoretically not be available. This in turn will cause the nfp_port structures to not be allocated. Make sure we don't crash the kernel when there is no eth_tbl: RIP: 0010:nfp_net_pci_probe+0xf2/0xb40 [nfp] ... Call Trace: nfp_pci_probe+0x6de/0xab0 [nfp] local_pci_probe+0x47/0xa0 work_for_cpu_fn+0x1a/0x30 process_one_work+0x1de/0x3e0 Found while working with broken/development version of management FW. Fixes:a5950182c0
("nfp: map mac_stats and vf_cfg BARs") Fixes:93da7d9660
("nfp: provide nfp_port to of nfp_net_get_mac_addr()") Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7dbc73e612
commit
c55ca688ed
|
@ -360,7 +360,7 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv)
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_NETDEV_DEV(repr, &priv->nn->pdev->dev);
|
SET_NETDEV_DEV(repr, &priv->nn->pdev->dev);
|
||||||
nfp_net_get_mac_addr(app->pf, port);
|
nfp_net_get_mac_addr(app->pf, repr, port);
|
||||||
|
|
||||||
cmsg_port_id = nfp_flower_cmsg_phys_port(phys_port);
|
cmsg_port_id = nfp_flower_cmsg_phys_port(phys_port);
|
||||||
err = nfp_repr_init(app, repr,
|
err = nfp_repr_init(app, repr,
|
||||||
|
|
|
@ -69,7 +69,7 @@ int nfp_app_nic_vnic_alloc(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->port);
|
nfp_net_get_mac_addr(app->pf, nn->dp.netdev, nn->port);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,9 @@ void nfp_net_pci_remove(struct nfp_pf *pf);
|
||||||
int nfp_hwmon_register(struct nfp_pf *pf);
|
int nfp_hwmon_register(struct nfp_pf *pf);
|
||||||
void nfp_hwmon_unregister(struct nfp_pf *pf);
|
void nfp_hwmon_unregister(struct nfp_pf *pf);
|
||||||
|
|
||||||
void nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_port *port);
|
void
|
||||||
|
nfp_net_get_mac_addr(struct nfp_pf *pf, struct net_device *netdev,
|
||||||
|
struct nfp_port *port);
|
||||||
|
|
||||||
bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
|
bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
|
||||||
|
|
||||||
|
|
|
@ -67,23 +67,26 @@
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
* @netdev: net_device to set MAC address on
|
||||||
* @port: NFP port structure
|
* @port: NFP port structure
|
||||||
*
|
*
|
||||||
* 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 generate a random address.
|
* fails generate a random address.
|
||||||
*/
|
*/
|
||||||
void nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_port *port)
|
void
|
||||||
|
nfp_net_get_mac_addr(struct nfp_pf *pf, struct net_device *netdev,
|
||||||
|
struct nfp_port *port)
|
||||||
{
|
{
|
||||||
struct nfp_eth_table_port *eth_port;
|
struct nfp_eth_table_port *eth_port;
|
||||||
|
|
||||||
eth_port = __nfp_port_get_eth_port(port);
|
eth_port = __nfp_port_get_eth_port(port);
|
||||||
if (!eth_port) {
|
if (!eth_port) {
|
||||||
eth_hw_addr_random(port->netdev);
|
eth_hw_addr_random(netdev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ether_addr_copy(port->netdev->dev_addr, eth_port->mac_addr);
|
ether_addr_copy(netdev->dev_addr, eth_port->mac_addr);
|
||||||
ether_addr_copy(port->netdev->perm_addr, eth_port->mac_addr);
|
ether_addr_copy(netdev->perm_addr, eth_port->mac_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct nfp_eth_table_port *
|
static struct nfp_eth_table_port *
|
||||||
|
@ -511,16 +514,18 @@ static int nfp_net_pci_map_mem(struct nfp_pf *pf)
|
||||||
return PTR_ERR(mem);
|
return PTR_ERR(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
min_size = NFP_MAC_STATS_SIZE * (pf->eth_tbl->max_index + 1);
|
if (pf->eth_tbl) {
|
||||||
pf->mac_stats_mem = nfp_rtsym_map(pf->rtbl, "_mac_stats",
|
min_size = NFP_MAC_STATS_SIZE * (pf->eth_tbl->max_index + 1);
|
||||||
"net.macstats", min_size,
|
pf->mac_stats_mem = nfp_rtsym_map(pf->rtbl, "_mac_stats",
|
||||||
&pf->mac_stats_bar);
|
"net.macstats", min_size,
|
||||||
if (IS_ERR(pf->mac_stats_mem)) {
|
&pf->mac_stats_bar);
|
||||||
if (PTR_ERR(pf->mac_stats_mem) != -ENOENT) {
|
if (IS_ERR(pf->mac_stats_mem)) {
|
||||||
err = PTR_ERR(pf->mac_stats_mem);
|
if (PTR_ERR(pf->mac_stats_mem) != -ENOENT) {
|
||||||
goto err_unmap_ctrl;
|
err = PTR_ERR(pf->mac_stats_mem);
|
||||||
|
goto err_unmap_ctrl;
|
||||||
|
}
|
||||||
|
pf->mac_stats_mem = NULL;
|
||||||
}
|
}
|
||||||
pf->mac_stats_mem = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pf->vf_cfg_mem = nfp_net_pf_map_rtsym(pf, "net.vfcfg",
|
pf->vf_cfg_mem = nfp_net_pf_map_rtsym(pf, "net.vfcfg",
|
||||||
|
|
Loading…
Reference in New Issue