MCPcopy Create free account
hub / github.com/F-Stack/f-stack / nfp_fw_upload

Function nfp_fw_upload

dpdk/drivers/net/nfp/nfp_ethdev.c:769–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767#define DEFAULT_FW_PATH "/lib/firmware/netronome"
768
769static int
770nfp_fw_upload(struct rte_pci_device *dev,
771 struct nfp_nsp *nsp,
772 char *card)
773{
774 void *fw_buf;
775 size_t fsize;
776 char serial[40];
777 char fw_name[125];
778 uint16_t interface;
779 uint32_t cpp_serial_len;
780 const uint8_t *cpp_serial;
781 struct nfp_cpp *cpp = nfp_nsp_cpp(nsp);
782
783 cpp_serial_len = nfp_cpp_serial(cpp, &cpp_serial);
784 if (cpp_serial_len != NFP_SERIAL_LEN)
785 return -ERANGE;
786
787 interface = nfp_cpp_interface(cpp);
788
789 /* Looking for firmware file in order of priority */
790
791 /* First try to find a firmware image specific for this device */
792 snprintf(serial, sizeof(serial),
793 "serial-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
794 cpp_serial[0], cpp_serial[1], cpp_serial[2], cpp_serial[3],
795 cpp_serial[4], cpp_serial[5], interface >> 8, interface & 0xff);
796 snprintf(fw_name, sizeof(fw_name), "%s/%s.nffw", DEFAULT_FW_PATH, serial);
797
798 PMD_DRV_LOG(DEBUG, "Trying with fw file: %s", fw_name);
799 if (rte_firmware_read(fw_name, &fw_buf, &fsize) == 0)
800 goto load_fw;
801
802 /* Then try the PCI name */
803 snprintf(fw_name, sizeof(fw_name), "%s/pci-%s.nffw", DEFAULT_FW_PATH,
804 dev->name);
805
806 PMD_DRV_LOG(DEBUG, "Trying with fw file: %s", fw_name);
807 if (rte_firmware_read(fw_name, &fw_buf, &fsize) == 0)
808 goto load_fw;
809
810 /* Finally try the card type and media */
811 snprintf(fw_name, sizeof(fw_name), "%s/%s", DEFAULT_FW_PATH, card);
812 PMD_DRV_LOG(DEBUG, "Trying with fw file: %s", fw_name);
813 if (rte_firmware_read(fw_name, &fw_buf, &fsize) == 0)
814 goto load_fw;
815
816 PMD_DRV_LOG(ERR, "Can't find suitable firmware.");
817 return -ENOENT;
818
819load_fw:
820 PMD_DRV_LOG(INFO, "Firmware file found at %s with size: %zu",
821 fw_name, fsize);
822 PMD_DRV_LOG(INFO, "Uploading the firmware ...");
823 if (nfp_nsp_load_fw(nsp, fw_buf, fsize) < 0) {
824 free(fw_buf);
825 PMD_DRV_LOG(ERR, "Firmware load failed.");
826 return -EIO;

Callers 1

nfp_fw_reloadFunction · 0.85

Calls 7

nfp_nsp_cppFunction · 0.85
nfp_cpp_serialFunction · 0.85
nfp_cpp_interfaceFunction · 0.85
snprintfFunction · 0.85
nfp_nsp_load_fwFunction · 0.85
rte_firmware_readFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected