Skip to content

Commit af4fa7e

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: remove automatic caching of RTsym table
The fact that RTsym table is cached inside nfp_cpp handle is a relic of old times when nfpcore was a library module. All the nfp_cpp "caches" are awkward to deal with because of concurrency and prone to keeping stale information. Make the run time symbol table be an object read out from the device and managed by whoever requested it. Since the driver loads FW at ->probe() and never reloads, we can hold onto the table for ever. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ab832b8 commit af4fa7e

File tree

8 files changed

+63
-112
lines changed

8 files changed

+63
-112
lines changed

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

Lines changed: 5 additions & 1 deletion
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

@@ -373,6 +373,8 @@ static int nfp_pci_probe(struct pci_dev *pdev,
373373
if (err)
374374
goto err_devlink_unreg;
375375

376+
pf->rtbl = nfp_rtsym_table_read(pf->cpp);
377+
376378
err = nfp_pcie_sriov_read_nfd_limit(pf);
377379
if (err)
378380
goto err_fw_unload;
@@ -394,6 +396,7 @@ static int nfp_pci_probe(struct pci_dev *pdev,
394396
err_sriov_unlimit:
395397
pci_sriov_set_totalvfs(pf->pdev, 0);
396398
err_fw_unload:
399+
kfree(pf->rtbl);
397400
if (pf->fw_loaded)
398401
nfp_fw_unload(pf);
399402
kfree(pf->eth_tbl);
@@ -430,6 +433,7 @@ static void nfp_pci_remove(struct pci_dev *pdev)
430433

431434
devlink_unregister(devlink);
432435

436+
kfree(pf->rtbl);
433437
if (pf->fw_loaded)
434438
nfp_fw_unload(pf);
435439

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct nfp_cpp_area;
5656
struct nfp_eth_table;
5757
struct nfp_net;
5858
struct nfp_nsp_identify;
59+
struct nfp_rtsym_table;
5960

6061
/**
6162
* struct nfp_pf - NFP PF-specific device structure
@@ -70,6 +71,7 @@ struct nfp_nsp_identify;
7071
* @num_vfs: Number of SR-IOV VFs enabled
7172
* @fw_loaded: Is the firmware loaded?
7273
* @ctrl_vnic: Pointer to the control vNIC if available
74+
* @rtbl: RTsym table
7375
* @eth_tbl: NSP ETH table
7476
* @nspi: NSP identification info
7577
* @hwmon_dev: pointer to hwmon device
@@ -101,6 +103,7 @@ struct nfp_pf {
101103

102104
struct nfp_net *ctrl_vnic;
103105

106+
struct nfp_rtsym_table *rtbl;
104107
struct nfp_eth_table *eth_tbl;
105108
struct nfp_nsp_identify *nspi;
106109

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,6 @@ int nfp_cpp_serial(struct nfp_cpp *cpp, const u8 **serial);
224224

225225
void *nfp_hwinfo_cache(struct nfp_cpp *cpp);
226226
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);
231227

232228
struct nfp_cpp_area *nfp_cpp_area_alloc_with_name(struct nfp_cpp *cpp,
233229
u32 cpp_id,

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ struct nfp_cpp_resource {
7878
*
7979
* Following fields can be used only in probe() or with rtnl held:
8080
* @hwinfo: HWInfo database fetched from the device
81-
* @rtsym: firmware run time symbols
8281
*
8382
* Following fields use explicit locking:
8483
* @resource_list: NFP CPP resource list
@@ -109,7 +108,6 @@ struct nfp_cpp {
109108
struct list_head area_cache_list;
110109

111110
void *hwinfo;
112-
void *rtsym;
113111
};
114112

115113
/* Element of the area_cache_list */
@@ -234,7 +232,6 @@ void nfp_cpp_free(struct nfp_cpp *cpp)
234232
cpp->op->free(cpp);
235233

236234
kfree(cpp->hwinfo);
237-
kfree(cpp->rtsym);
238235

239236
device_unregister(&cpp->dev);
240237

@@ -286,29 +283,6 @@ void nfp_hwinfo_cache_set(struct nfp_cpp *cpp, void *val)
286283
cpp->hwinfo = val;
287284
}
288285

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-
312286
/**
313287
* nfp_cpp_area_alloc_with_name() - allocate a new CPP area
314288
* @cpp: CPP device handle

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,14 @@ struct nfp_rtsym {
8787
int domain;
8888
};
8989

90-
int nfp_rtsym_count(struct nfp_cpp *cpp);
91-
const struct nfp_rtsym *nfp_rtsym_get(struct nfp_cpp *cpp, int idx);
92-
const struct nfp_rtsym *nfp_rtsym_lookup(struct nfp_cpp *cpp, const char *name);
93-
u64 nfp_rtsym_read_le(struct nfp_cpp *cpp, const char *name, int *error);
90+
struct nfp_rtsym_table;
91+
92+
struct nfp_rtsym_table *nfp_rtsym_table_read(struct nfp_cpp *cpp);
93+
int nfp_rtsym_count(struct nfp_rtsym_table *rtbl);
94+
const struct nfp_rtsym *nfp_rtsym_get(struct nfp_rtsym_table *rtbl, int idx);
95+
const struct nfp_rtsym *
96+
nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name);
97+
u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name,
98+
int *error);
9499

95100
#endif /* NFP_NFFW_H */

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,7 @@ int nfp_nsp_wait(struct nfp_nsp *state)
474474

475475
int nfp_nsp_device_soft_reset(struct nfp_nsp *state)
476476
{
477-
int err;
478-
479-
err = nfp_nsp_command(state, SPCODE_SOFT_RESET, 0, 0, 0);
480-
481-
nfp_nffw_cache_flush(state->cpp);
482-
483-
return err;
477+
return nfp_nsp_command(state, SPCODE_SOFT_RESET, 0, 0, 0);
484478
}
485479

486480
int nfp_nsp_load_fw(struct nfp_nsp *state, const struct firmware *fw)

0 commit comments

Comments
 (0)