Skip to content

Commit 122323f

Browse files
committed
Merge branch 'nfp-extend-firmware-request-logic'
Jakub Kicinski says: ==================== nfp: extend firmware request logic We have been pondering for some time how to support loading different application firmwares onto NFP. We want to support both users selecting one of the firmware images provided by Netronome (which are optimized for different use cases each) as well as firmware images created by users themselves or other companies. In the end we decided to go with the simplest solution - depending on the right firmware image being placed in /lib/firmware. This vastly simplifies driver logic and also doesn't require any new API. Different NICs on one system may want to run different applications therefore we first try to load firmware specific to the device (by serial number of PCI slot) and if not present try the device model based name we have been using so far. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 53d56f7 + 1680a37 commit 122323f

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

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

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,21 @@ static int nfp_pcie_sriov_configure(struct pci_dev *pdev, int num_vfs)
174174
return nfp_pcie_sriov_enable(pdev, num_vfs);
175175
}
176176

177+
static const struct firmware *
178+
nfp_net_fw_request(struct pci_dev *pdev, struct nfp_pf *pf, const char *name)
179+
{
180+
const struct firmware *fw = NULL;
181+
int err;
182+
183+
err = request_firmware_direct(&fw, name, &pdev->dev);
184+
nfp_info(pf->cpp, " %s: %s\n",
185+
name, err ? "not found" : "found, loading...");
186+
if (err)
187+
return NULL;
188+
189+
return fw;
190+
}
191+
177192
/**
178193
* nfp_net_fw_find() - Find the correct firmware image for netdev mode
179194
* @pdev: PCI Device structure
@@ -184,13 +199,32 @@ static int nfp_pcie_sriov_configure(struct pci_dev *pdev, int num_vfs)
184199
static const struct firmware *
185200
nfp_net_fw_find(struct pci_dev *pdev, struct nfp_pf *pf)
186201
{
187-
const struct firmware *fw = NULL;
188202
struct nfp_eth_table_port *port;
203+
const struct firmware *fw;
189204
const char *fw_model;
190205
char fw_name[256];
191-
int spc, err = 0;
192-
int i, j;
206+
const u8 *serial;
207+
u16 interface;
208+
int spc, i, j;
193209

210+
nfp_info(pf->cpp, "Looking for firmware file in order of priority:\n");
211+
212+
/* First try to find a firmware image specific for this device */
213+
interface = nfp_cpp_interface(pf->cpp);
214+
nfp_cpp_serial(pf->cpp, &serial);
215+
sprintf(fw_name, "netronome/serial-%pMF-%02hhx-%02hhx.nffw",
216+
serial, interface >> 8, interface & 0xff);
217+
fw = nfp_net_fw_request(pdev, pf, fw_name);
218+
if (fw)
219+
return fw;
220+
221+
/* Then try the PCI name */
222+
sprintf(fw_name, "netronome/pci-%s.nffw", pci_name(pdev));
223+
fw = nfp_net_fw_request(pdev, pf, fw_name);
224+
if (fw)
225+
return fw;
226+
227+
/* Finally try the card type and media */
194228
if (!pf->eth_tbl) {
195229
dev_err(&pdev->dev, "Error: can't identify media config\n");
196230
return NULL;
@@ -223,13 +257,7 @@ nfp_net_fw_find(struct pci_dev *pdev, struct nfp_pf *pf)
223257
if (spc <= 0)
224258
return NULL;
225259

226-
err = request_firmware(&fw, fw_name, &pdev->dev);
227-
if (err)
228-
return NULL;
229-
230-
dev_info(&pdev->dev, "Loading FW image: %s\n", fw_name);
231-
232-
return fw;
260+
return nfp_net_fw_request(pdev, pf, fw_name);
233261
}
234262

235263
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
704704
if (!pf->rtbl) {
705705
nfp_err(pf->cpp, "No %s, giving up.\n",
706706
pf->fw_loaded ? "symbol table" : "firmware found");
707-
return -EPROBE_DEFER;
707+
return -EINVAL;
708708
}
709709

710710
mutex_lock(&pf->lock);

0 commit comments

Comments
 (0)