Skip to content

Commit 9511f29

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: look for firmware image by device serial number and PCI name
We generally look up firmware by card type, but that doesn't allow users who have more than one card of the same type in their system to select firmware per adapter. Unfortunately user space firmware helper seems fraught with difficulties and to be on its way out. In particular support for handling firmware uevents have been dropped from systemd and most distributions don't enable the FW fallback by default any more. To allow users selecting firmware for a particular device look up firmware names by serial and pci_name(). Use the direct lookup to disable generating uevents when enabled in Kconfig and not print any warnings to logs if adapter-specific files are missing. Users can place in /lib/firmware/netronome files named: pci-${pci_name}.nffw serial-${serial}.nffw to target a specific card. E.g.: pci-0000:04:00.0.nffw pci-0000:82:00.0.nffw serial-00-aa-bb-11-22-33-10-ff.nffw We use the full serial number including the interface id, as it appears in lspci output (bytes separated by '-'). Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 26a8985 commit 9511f29

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,27 @@ nfp_net_fw_find(struct pci_dev *pdev, struct nfp_pf *pf)
188188
struct nfp_eth_table_port *port;
189189
const char *fw_model;
190190
char fw_name[256];
191+
const u8 *serial;
191192
int spc, err = 0;
193+
u16 interface;
192194
int i, j;
193195

196+
/* First try to find a firmware image specific for this device */
197+
interface = nfp_cpp_interface(pf->cpp);
198+
nfp_cpp_serial(pf->cpp, &serial);
199+
sprintf(fw_name, "netronome/serial-%pMF-%02hhx-%02hhx.nffw",
200+
serial, interface >> 8, interface & 0xff);
201+
err = request_firmware_direct(&fw, fw_name, &pdev->dev);
202+
if (!err)
203+
goto done;
204+
205+
/* Then try the PCI name */
206+
sprintf(fw_name, "netronome/pci-%s.nffw", pci_name(pdev));
207+
err = request_firmware_direct(&fw, fw_name, &pdev->dev);
208+
if (!err)
209+
goto done;
210+
211+
/* Finally try the card type and media */
194212
if (!pf->eth_tbl) {
195213
dev_err(&pdev->dev, "Error: can't identify media config\n");
196214
return NULL;
@@ -226,7 +244,7 @@ nfp_net_fw_find(struct pci_dev *pdev, struct nfp_pf *pf)
226244
err = request_firmware(&fw, fw_name, &pdev->dev);
227245
if (err)
228246
return NULL;
229-
247+
done:
230248
dev_info(&pdev->dev, "Loading FW image: %s\n", fw_name);
231249

232250
return fw;

0 commit comments

Comments
 (0)