Skip to content

Commit 9438d27

Browse files
committed
Merge branch 'nfp-FW-app-build-name-reporting'
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>
2 parents 7fa1365 + 76abc0f commit 9438d27

File tree

15 files changed

+158
-196
lines changed

15 files changed

+158
-196
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/slab.h>
3636

3737
#include "nfpcore/nfp_cpp.h"
38+
#include "nfpcore/nfp_nffw.h"
3839
#include "nfp_app.h"
3940
#include "nfp_main.h"
4041

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

47+
const char *nfp_app_mip_name(struct nfp_app *app)
48+
{
49+
if (!app || !app->pf->mip)
50+
return "";
51+
return nfp_mip_name(app->pf->mip);
52+
}
53+
4654
struct sk_buff *nfp_app_ctrl_msg_alloc(struct nfp_app *app, unsigned int size)
4755
{
4856
struct sk_buff *skb;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ static inline void nfp_app_ctrl_rx(struct nfp_app *app, struct sk_buff *skb)
216216
app->type->ctrl_msg_rx(app, skb);
217217
}
218218

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

221222
struct nfp_app *nfp_app_alloc(struct nfp_pf *pf, enum nfp_app_id id);

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

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

83-
nfp_net_get_mac_addr(nn, app->cpp, id);
83+
nfp_net_get_mac_addr(app->pf, nn, id);
8484

8585
return 0;
8686
}

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf)
7777
{
7878
int err;
7979

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

@@ -170,7 +170,7 @@ nfp_net_fw_find(struct pci_dev *pdev, struct nfp_pf *pf)
170170
return NULL;
171171
}
172172

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

361+
pf->hwinfo = nfp_hwinfo_read(pf->cpp);
362+
361363
dev_info(&pdev->dev, "Assembly: %s%s%s-%s CPLD: %s\n",
362-
nfp_hwinfo_lookup(pf->cpp, "assembly.vendor"),
363-
nfp_hwinfo_lookup(pf->cpp, "assembly.partno"),
364-
nfp_hwinfo_lookup(pf->cpp, "assembly.serial"),
365-
nfp_hwinfo_lookup(pf->cpp, "assembly.revision"),
366-
nfp_hwinfo_lookup(pf->cpp, "cpld.version"));
364+
nfp_hwinfo_lookup(pf->hwinfo, "assembly.vendor"),
365+
nfp_hwinfo_lookup(pf->hwinfo, "assembly.partno"),
366+
nfp_hwinfo_lookup(pf->hwinfo, "assembly.serial"),
367+
nfp_hwinfo_lookup(pf->hwinfo, "assembly.revision"),
368+
nfp_hwinfo_lookup(pf->hwinfo, "cpld.version"));
367369

368370
err = devlink_register(devlink, &pdev->dev);
369371
if (err)
370-
goto err_cpp_free;
372+
goto err_hwinfo_free;
371373

372374
err = nfp_nsp_init(pdev, pf);
373375
if (err)
374376
goto err_devlink_unreg;
375377

378+
pf->mip = nfp_mip_open(pf->cpp);
379+
pf->rtbl = __nfp_rtsym_table_read(pf->cpp, pf->mip);
380+
376381
err = nfp_pcie_sriov_read_nfd_limit(pf);
377382
if (err)
378383
goto err_fw_unload;
@@ -394,13 +399,16 @@ static int nfp_pci_probe(struct pci_dev *pdev,
394399
err_sriov_unlimit:
395400
pci_sriov_set_totalvfs(pf->pdev, 0);
396401
err_fw_unload:
402+
kfree(pf->rtbl);
403+
nfp_mip_close(pf->mip);
397404
if (pf->fw_loaded)
398405
nfp_fw_unload(pf);
399406
kfree(pf->eth_tbl);
400407
kfree(pf->nspi);
401408
err_devlink_unreg:
402409
devlink_unregister(devlink);
403-
err_cpp_free:
410+
err_hwinfo_free:
411+
kfree(pf->hwinfo);
404412
nfp_cpp_free(pf->cpp);
405413
err_disable_msix:
406414
pci_set_drvdata(pdev, NULL);
@@ -430,10 +438,13 @@ static void nfp_pci_remove(struct pci_dev *pdev)
430438

431439
devlink_unregister(devlink);
432440

441+
kfree(pf->rtbl);
442+
nfp_mip_close(pf->mip);
433443
if (pf->fw_loaded)
434444
nfp_fw_unload(pf);
435445

436446
pci_set_drvdata(pdev, NULL);
447+
kfree(pf->hwinfo);
437448
nfp_cpp_free(pf->cpp);
438449

439450
kfree(pf->eth_tbl);

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ struct pci_dev;
5454
struct nfp_cpp;
5555
struct nfp_cpp_area;
5656
struct nfp_eth_table;
57+
struct nfp_hwinfo;
58+
struct nfp_mip;
5759
struct nfp_net;
5860
struct nfp_nsp_identify;
61+
struct nfp_rtsym_table;
5962

6063
/**
6164
* struct nfp_pf - NFP PF-specific device structure
@@ -70,6 +73,9 @@ struct nfp_nsp_identify;
7073
* @num_vfs: Number of SR-IOV VFs enabled
7174
* @fw_loaded: Is the firmware loaded?
7275
* @ctrl_vnic: Pointer to the control vNIC if available
76+
* @mip: MIP handle
77+
* @rtbl: RTsym table
78+
* @hwinfo: HWInfo table
7379
* @eth_tbl: NSP ETH table
7480
* @nspi: NSP identification info
7581
* @hwmon_dev: pointer to hwmon device
@@ -101,6 +107,9 @@ struct nfp_pf {
101107

102108
struct nfp_net *ctrl_vnic;
103109

110+
const struct nfp_mip *mip;
111+
struct nfp_rtsym_table *rtbl;
112+
struct nfp_hwinfo *hwinfo;
104113
struct nfp_eth_table *eth_tbl;
105114
struct nfp_nsp_identify *nspi;
106115

@@ -130,7 +139,7 @@ void nfp_hwmon_unregister(struct nfp_pf *pf);
130139
struct nfp_eth_table_port *
131140
nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int id);
132141
void
133-
nfp_net_get_mac_addr(struct nfp_net *nn, struct nfp_cpp *cpp, unsigned int id);
142+
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id);
134143

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ static void nfp_net_get_drvinfo(struct net_device *netdev,
166166

167167
nfp_net_get_nspinfo(nn->app, nsp_version);
168168
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
169-
"%d.%d.%d.%d %s %s",
169+
"%d.%d.%d.%d %s %s %s",
170170
nn->fw_ver.resv, nn->fw_ver.class,
171171
nn->fw_ver.major, nn->fw_ver.minor, nsp_version,
172-
nfp_app_name(nn->app));
172+
nfp_app_mip_name(nn->app), nfp_app_name(nn->app));
173173
strlcpy(drvinfo->bus_info, pci_name(nn->pdev),
174174
sizeof(drvinfo->bus_info));
175175

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@
6363

6464
#define NFP_PF_CSR_SLICE_SIZE (32 * 1024)
6565

66-
static int nfp_is_ready(struct nfp_cpp *cpp)
66+
static int nfp_is_ready(struct nfp_pf *pf)
6767
{
6868
const char *cp;
6969
long state;
7070
int err;
7171

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

@@ -134,15 +134,15 @@ static u8 __iomem *nfp_net_map_area(struct nfp_cpp *cpp,
134134

135135
/**
136136
* nfp_net_get_mac_addr() - Get the MAC address.
137+
* @pf: NFP PF handle
137138
* @nn: NFP Network structure
138-
* @cpp: NFP CPP handle
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_net *nn, struct nfp_cpp *cpp, unsigned int id)
145+
nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
146146
{
147147
struct nfp_eth_table_port *eth_port;
148148
struct nfp_net_dp *dp = &nn->dp;
@@ -159,7 +159,7 @@ nfp_net_get_mac_addr(struct nfp_net *nn, struct nfp_cpp *cpp, unsigned int id)
159159

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

162-
mac_str = nfp_hwinfo_lookup(cpp, name);
162+
mac_str = nfp_hwinfo_lookup(pf->hwinfo, name);
163163
if (!mac_str) {
164164
dev_warn(dp->dev, "Can't lookup MAC address. Generate\n");
165165
eth_hw_addr_random(dp->netdev);
@@ -201,7 +201,7 @@ nfp_net_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,
201201

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

204-
val = nfp_rtsym_read_le(pf->cpp, name, &err);
204+
val = nfp_rtsym_read_le(pf->rtbl, name, &err);
205205
if (err) {
206206
if (err == -ENOENT)
207207
return default_val;
@@ -234,7 +234,7 @@ nfp_net_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
234234
snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt,
235235
nfp_cppcore_pcie_unit(pf->cpp));
236236

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

715715
/* Verify that the board has completed initialization */
716-
if (!nfp_is_ready(pf->cpp)) {
716+
if (!nfp_is_ready(pf)) {
717717
nfp_err(pf->cpp, "NFP is not ready for NIC operation.\n");
718718
return -EINVAL;
719719
}
@@ -813,6 +813,7 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
813813
nfp_cpp_area_release_free(pf->data_vnic_bar);
814814
err_unlock:
815815
mutex_unlock(&pf->lock);
816+
cancel_work_sync(&pf->port_refresh_work);
816817
return err;
817818
}
818819

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646

4747
/* Implemented in nfp_hwinfo.c */
4848

49-
const char *nfp_hwinfo_lookup(struct nfp_cpp *cpp, const char *lookup);
49+
struct nfp_hwinfo;
50+
struct nfp_hwinfo *nfp_hwinfo_read(struct nfp_cpp *cpp);
51+
const char *nfp_hwinfo_lookup(struct nfp_hwinfo *hwinfo, const char *lookup);
5052

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

drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpp.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,6 @@ u32 nfp_cpp_model(struct nfp_cpp *cpp);
222222
u16 nfp_cpp_interface(struct nfp_cpp *cpp);
223223
int nfp_cpp_serial(struct nfp_cpp *cpp, const u8 **serial);
224224

225-
void *nfp_hwinfo_cache(struct nfp_cpp *cpp);
226-
void nfp_hwinfo_cache_set(struct nfp_cpp *cpp, void *val);
227-
void *nfp_rtsym_cache(struct nfp_cpp *cpp);
228-
void nfp_rtsym_cache_set(struct nfp_cpp *cpp, void *val);
229-
230-
void nfp_nffw_cache_flush(struct nfp_cpp *cpp);
231-
232225
struct nfp_cpp_area *nfp_cpp_area_alloc_with_name(struct nfp_cpp *cpp,
233226
u32 cpp_id,
234227
const char *name,

drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ struct nfp_cpp_resource {
7676
* @serial: chip serial number
7777
* @imb_cat_table: CPP Mapping Table
7878
*
79-
* Following fields can be used only in probe() or with rtnl held:
80-
* @hwinfo: HWInfo database fetched from the device
81-
* @rtsym: firmware run time symbols
82-
*
8379
* Following fields use explicit locking:
8480
* @resource_list: NFP CPP resource list
8581
* @resource_lock: protects @resource_list
@@ -107,9 +103,6 @@ struct nfp_cpp {
107103

108104
struct mutex area_cache_mutex;
109105
struct list_head area_cache_list;
110-
111-
void *hwinfo;
112-
void *rtsym;
113106
};
114107

115108
/* Element of the area_cache_list */
@@ -233,9 +226,6 @@ void nfp_cpp_free(struct nfp_cpp *cpp)
233226
if (cpp->op->free)
234227
cpp->op->free(cpp);
235228

236-
kfree(cpp->hwinfo);
237-
kfree(cpp->rtsym);
238-
239229
device_unregister(&cpp->dev);
240230

241231
kfree(cpp);
@@ -276,39 +266,6 @@ int nfp_cpp_serial(struct nfp_cpp *cpp, const u8 **serial)
276266
return sizeof(cpp->serial);
277267
}
278268

279-
void *nfp_hwinfo_cache(struct nfp_cpp *cpp)
280-
{
281-
return cpp->hwinfo;
282-
}
283-
284-
void nfp_hwinfo_cache_set(struct nfp_cpp *cpp, void *val)
285-
{
286-
cpp->hwinfo = val;
287-
}
288-
289-
void *nfp_rtsym_cache(struct nfp_cpp *cpp)
290-
{
291-
return cpp->rtsym;
292-
}
293-
294-
void nfp_rtsym_cache_set(struct nfp_cpp *cpp, void *val)
295-
{
296-
cpp->rtsym = val;
297-
}
298-
299-
/**
300-
* nfp_nffw_cache_flush() - Flush cached firmware information
301-
* @cpp: NFP CPP handle
302-
*
303-
* Flush cached firmware information. This function should be called
304-
* every time firmware is loaded on unloaded.
305-
*/
306-
void nfp_nffw_cache_flush(struct nfp_cpp *cpp)
307-
{
308-
kfree(nfp_rtsym_cache(cpp));
309-
nfp_rtsym_cache_set(cpp, NULL);
310-
}
311-
312269
/**
313270
* nfp_cpp_area_alloc_with_name() - allocate a new CPP area
314271
* @cpp: CPP device handle

0 commit comments

Comments
 (0)