Skip to content

Commit

Permalink
Merge branch 'nfp-FW-app-build-name-reporting'
Browse files Browse the repository at this point in the history
Jakub Kicinski says:

====================
nfp: FW app build name reporting

This series adds reporting FW build name in ethtool -i.  Most
of the patches are restructuring where information caching is
done.  There is also a minor error path fix.

These are last few patches finishing the basic nfp_app support.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jun 9, 2017
2 parents 7fa1365 + 76abc0f commit 9438d27
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 196 deletions.
8 changes: 8 additions & 0 deletions drivers/net/ethernet/netronome/nfp/nfp_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/slab.h>

#include "nfpcore/nfp_cpp.h"
#include "nfpcore/nfp_nffw.h"
#include "nfp_app.h"
#include "nfp_main.h"

Expand All @@ -43,6 +44,13 @@ static const struct nfp_app_type *apps[] = {
&app_bpf,
};

const char *nfp_app_mip_name(struct nfp_app *app)
{
if (!app || !app->pf->mip)
return "";
return nfp_mip_name(app->pf->mip);
}

struct sk_buff *nfp_app_ctrl_msg_alloc(struct nfp_app *app, unsigned int size)
{
struct sk_buff *skb;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/netronome/nfp/nfp_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ static inline void nfp_app_ctrl_rx(struct nfp_app *app, struct sk_buff *skb)
app->type->ctrl_msg_rx(app, skb);
}

const char *nfp_app_mip_name(struct nfp_app *app);
struct sk_buff *nfp_app_ctrl_msg_alloc(struct nfp_app *app, unsigned int size);

struct nfp_app *nfp_app_alloc(struct nfp_pf *pf, enum nfp_app_id id);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/netronome/nfp/nfp_app_nic.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,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(nn, app->cpp, id);
nfp_net_get_mac_addr(app->pf, nn, id);

return 0;
}
29 changes: 20 additions & 9 deletions drivers/net/ethernet/netronome/nfp/nfp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf)
{
int err;

pf->limit_vfs = nfp_rtsym_read_le(pf->cpp, "nfd_vf_cfg_max_vfs", &err);
pf->limit_vfs = nfp_rtsym_read_le(pf->rtbl, "nfd_vf_cfg_max_vfs", &err);
if (!err)
return pci_sriov_set_totalvfs(pf->pdev, pf->limit_vfs);

Expand Down Expand Up @@ -170,7 +170,7 @@ nfp_net_fw_find(struct pci_dev *pdev, struct nfp_pf *pf)
return NULL;
}

fw_model = nfp_hwinfo_lookup(pf->cpp, "assembly.partno");
fw_model = nfp_hwinfo_lookup(pf->hwinfo, "assembly.partno");
if (!fw_model) {
dev_err(&pdev->dev, "Error: can't read part number\n");
return NULL;
Expand Down Expand Up @@ -358,21 +358,26 @@ static int nfp_pci_probe(struct pci_dev *pdev,
goto err_disable_msix;
}

pf->hwinfo = nfp_hwinfo_read(pf->cpp);

dev_info(&pdev->dev, "Assembly: %s%s%s-%s CPLD: %s\n",
nfp_hwinfo_lookup(pf->cpp, "assembly.vendor"),
nfp_hwinfo_lookup(pf->cpp, "assembly.partno"),
nfp_hwinfo_lookup(pf->cpp, "assembly.serial"),
nfp_hwinfo_lookup(pf->cpp, "assembly.revision"),
nfp_hwinfo_lookup(pf->cpp, "cpld.version"));
nfp_hwinfo_lookup(pf->hwinfo, "assembly.vendor"),
nfp_hwinfo_lookup(pf->hwinfo, "assembly.partno"),
nfp_hwinfo_lookup(pf->hwinfo, "assembly.serial"),
nfp_hwinfo_lookup(pf->hwinfo, "assembly.revision"),
nfp_hwinfo_lookup(pf->hwinfo, "cpld.version"));

err = devlink_register(devlink, &pdev->dev);
if (err)
goto err_cpp_free;
goto err_hwinfo_free;

err = nfp_nsp_init(pdev, pf);
if (err)
goto err_devlink_unreg;

pf->mip = nfp_mip_open(pf->cpp);
pf->rtbl = __nfp_rtsym_table_read(pf->cpp, pf->mip);

err = nfp_pcie_sriov_read_nfd_limit(pf);
if (err)
goto err_fw_unload;
Expand All @@ -394,13 +399,16 @@ static int nfp_pci_probe(struct pci_dev *pdev,
err_sriov_unlimit:
pci_sriov_set_totalvfs(pf->pdev, 0);
err_fw_unload:
kfree(pf->rtbl);
nfp_mip_close(pf->mip);
if (pf->fw_loaded)
nfp_fw_unload(pf);
kfree(pf->eth_tbl);
kfree(pf->nspi);
err_devlink_unreg:
devlink_unregister(devlink);
err_cpp_free:
err_hwinfo_free:
kfree(pf->hwinfo);
nfp_cpp_free(pf->cpp);
err_disable_msix:
pci_set_drvdata(pdev, NULL);
Expand Down Expand Up @@ -430,10 +438,13 @@ static void nfp_pci_remove(struct pci_dev *pdev)

devlink_unregister(devlink);

kfree(pf->rtbl);
nfp_mip_close(pf->mip);
if (pf->fw_loaded)
nfp_fw_unload(pf);

pci_set_drvdata(pdev, NULL);
kfree(pf->hwinfo);
nfp_cpp_free(pf->cpp);

kfree(pf->eth_tbl);
Expand Down
11 changes: 10 additions & 1 deletion drivers/net/ethernet/netronome/nfp/nfp_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ struct pci_dev;
struct nfp_cpp;
struct nfp_cpp_area;
struct nfp_eth_table;
struct nfp_hwinfo;
struct nfp_mip;
struct nfp_net;
struct nfp_nsp_identify;
struct nfp_rtsym_table;

/**
* struct nfp_pf - NFP PF-specific device structure
Expand All @@ -70,6 +73,9 @@ struct nfp_nsp_identify;
* @num_vfs: Number of SR-IOV VFs enabled
* @fw_loaded: Is the firmware loaded?
* @ctrl_vnic: Pointer to the control vNIC if available
* @mip: MIP handle
* @rtbl: RTsym table
* @hwinfo: HWInfo table
* @eth_tbl: NSP ETH table
* @nspi: NSP identification info
* @hwmon_dev: pointer to hwmon device
Expand Down Expand Up @@ -101,6 +107,9 @@ struct nfp_pf {

struct nfp_net *ctrl_vnic;

const struct nfp_mip *mip;
struct nfp_rtsym_table *rtbl;
struct nfp_hwinfo *hwinfo;
struct nfp_eth_table *eth_tbl;
struct nfp_nsp_identify *nspi;

Expand Down Expand Up @@ -130,7 +139,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_net *nn, struct nfp_cpp *cpp, unsigned int id);
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id);

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

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ static void nfp_net_get_drvinfo(struct net_device *netdev,

nfp_net_get_nspinfo(nn->app, nsp_version);
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
"%d.%d.%d.%d %s %s",
"%d.%d.%d.%d %s %s %s",
nn->fw_ver.resv, nn->fw_ver.class,
nn->fw_ver.major, nn->fw_ver.minor, nsp_version,
nfp_app_name(nn->app));
nfp_app_mip_name(nn->app), nfp_app_name(nn->app));
strlcpy(drvinfo->bus_info, pci_name(nn->pdev),
sizeof(drvinfo->bus_info));

Expand Down
17 changes: 9 additions & 8 deletions drivers/net/ethernet/netronome/nfp/nfp_net_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@

#define NFP_PF_CSR_SLICE_SIZE (32 * 1024)

static int nfp_is_ready(struct nfp_cpp *cpp)
static int nfp_is_ready(struct nfp_pf *pf)
{
const char *cp;
long state;
int err;

cp = nfp_hwinfo_lookup(cpp, "board.state");
cp = nfp_hwinfo_lookup(pf->hwinfo, "board.state");
if (!cp)
return 0;

Expand Down Expand Up @@ -134,15 +134,15 @@ 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
* @cpp: NFP CPP handle
* @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_net *nn, struct nfp_cpp *cpp, unsigned int id)
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
{
struct nfp_eth_table_port *eth_port;
struct nfp_net_dp *dp = &nn->dp;
Expand All @@ -159,7 +159,7 @@ nfp_net_get_mac_addr(struct nfp_net *nn, struct nfp_cpp *cpp, unsigned int id)

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

mac_str = nfp_hwinfo_lookup(cpp, name);
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);
Expand Down Expand Up @@ -201,7 +201,7 @@ nfp_net_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,

snprintf(name, sizeof(name), format, nfp_cppcore_pcie_unit(pf->cpp));

val = nfp_rtsym_read_le(pf->cpp, name, &err);
val = nfp_rtsym_read_le(pf->rtbl, name, &err);
if (err) {
if (err == -ENOENT)
return default_val;
Expand Down Expand Up @@ -234,7 +234,7 @@ nfp_net_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt,
nfp_cppcore_pcie_unit(pf->cpp));

sym = nfp_rtsym_lookup(pf->cpp, pf_symbol);
sym = nfp_rtsym_lookup(pf->rtbl, pf_symbol);
if (!sym) {
nfp_err(pf->cpp, "Failed to find PF symbol %s\n", pf_symbol);
return (u8 __iomem *)ERR_PTR(-ENOENT);
Expand Down Expand Up @@ -713,7 +713,7 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
INIT_WORK(&pf->port_refresh_work, nfp_net_refresh_vnics);

/* Verify that the board has completed initialization */
if (!nfp_is_ready(pf->cpp)) {
if (!nfp_is_ready(pf)) {
nfp_err(pf->cpp, "NFP is not ready for NIC operation.\n");
return -EINVAL;
}
Expand Down Expand Up @@ -813,6 +813,7 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
nfp_cpp_area_release_free(pf->data_vnic_bar);
err_unlock:
mutex_unlock(&pf->lock);
cancel_work_sync(&pf->port_refresh_work);
return err;
}

Expand Down
4 changes: 3 additions & 1 deletion drivers/net/ethernet/netronome/nfp/nfpcore/nfp.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@

/* Implemented in nfp_hwinfo.c */

const char *nfp_hwinfo_lookup(struct nfp_cpp *cpp, const char *lookup);
struct nfp_hwinfo;
struct nfp_hwinfo *nfp_hwinfo_read(struct nfp_cpp *cpp);
const char *nfp_hwinfo_lookup(struct nfp_hwinfo *hwinfo, const char *lookup);

/* Implemented in nfp_nsp.c, low level functions */

Expand Down
7 changes: 0 additions & 7 deletions drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,6 @@ u32 nfp_cpp_model(struct nfp_cpp *cpp);
u16 nfp_cpp_interface(struct nfp_cpp *cpp);
int nfp_cpp_serial(struct nfp_cpp *cpp, const u8 **serial);

void *nfp_hwinfo_cache(struct nfp_cpp *cpp);
void nfp_hwinfo_cache_set(struct nfp_cpp *cpp, void *val);
void *nfp_rtsym_cache(struct nfp_cpp *cpp);
void nfp_rtsym_cache_set(struct nfp_cpp *cpp, void *val);

void nfp_nffw_cache_flush(struct nfp_cpp *cpp);

struct nfp_cpp_area *nfp_cpp_area_alloc_with_name(struct nfp_cpp *cpp,
u32 cpp_id,
const char *name,
Expand Down
43 changes: 0 additions & 43 deletions drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ struct nfp_cpp_resource {
* @serial: chip serial number
* @imb_cat_table: CPP Mapping Table
*
* Following fields can be used only in probe() or with rtnl held:
* @hwinfo: HWInfo database fetched from the device
* @rtsym: firmware run time symbols
*
* Following fields use explicit locking:
* @resource_list: NFP CPP resource list
* @resource_lock: protects @resource_list
Expand Down Expand Up @@ -107,9 +103,6 @@ struct nfp_cpp {

struct mutex area_cache_mutex;
struct list_head area_cache_list;

void *hwinfo;
void *rtsym;
};

/* Element of the area_cache_list */
Expand Down Expand Up @@ -233,9 +226,6 @@ void nfp_cpp_free(struct nfp_cpp *cpp)
if (cpp->op->free)
cpp->op->free(cpp);

kfree(cpp->hwinfo);
kfree(cpp->rtsym);

device_unregister(&cpp->dev);

kfree(cpp);
Expand Down Expand Up @@ -276,39 +266,6 @@ int nfp_cpp_serial(struct nfp_cpp *cpp, const u8 **serial)
return sizeof(cpp->serial);
}

void *nfp_hwinfo_cache(struct nfp_cpp *cpp)
{
return cpp->hwinfo;
}

void nfp_hwinfo_cache_set(struct nfp_cpp *cpp, void *val)
{
cpp->hwinfo = val;
}

void *nfp_rtsym_cache(struct nfp_cpp *cpp)
{
return cpp->rtsym;
}

void nfp_rtsym_cache_set(struct nfp_cpp *cpp, void *val)
{
cpp->rtsym = val;
}

/**
* nfp_nffw_cache_flush() - Flush cached firmware information
* @cpp: NFP CPP handle
*
* Flush cached firmware information. This function should be called
* every time firmware is loaded on unloaded.
*/
void nfp_nffw_cache_flush(struct nfp_cpp *cpp)
{
kfree(nfp_rtsym_cache(cpp));
nfp_rtsym_cache_set(cpp, NULL);
}

/**
* nfp_cpp_area_alloc_with_name() - allocate a new CPP area
* @cpp: CPP device handle
Expand Down
Loading

0 comments on commit 9438d27

Please sign in to comment.