introduce PLDM firmware update library
Subsystems (6)
Jacob Keller
maintainercover introduce PLDM firmware update library
This series goal is to enable support for updating the ice hardware flash using the devlink flash command.
The ice firmware update files are distributed using the file format described by the "PLDM for Firmware Update" standard:
https://www.dmtf.org/documents/pmci/pldm-firmware-update-specification-100
Because this file format is standard, this series introduces a new library that handles the generic logic for parsing the PLDM file header. The library uses a design that is very similar to the Mellanox mlxfw module. That is, a simple ops table is setup and device drivers instantiate an instance of the pldmfw library with the device specific operations.
Doing so allows for each device to implement the low level behavior for how to interact with its firmware.
This series includes the library and an implementation for the ice hardware. I've removed all of the parameters, and the proposed changes to support overwrite mode. I'll be working on the overwrite mask suggestion from Jakub as a follow-up series.
Because the PLDM file format is a standard and not something that is specific to the Intel hardware, I opted to place this update library in lib/pldmfw. I should note that while I tried to make the library generic, it does not attempt to mimic the complete "Update Agent" as defined in the standard. This is mostly due to the fact that the actual interfaces exposed to software for the ice hardware would not allow this.
This series depends on some work just recently and is based on top of the patch series sent by Tony published at:
https://lore.kernel.org/netdev/[email protected]/T/#t
Changes since v2 RFC
* Removed overwrite mode patches, as this can become a follow up series with a separate discussion
* Fixed a minor bug in the pldm_timestamp structure not being packed.
* Dropped Cc for other driver maintainers, as this series no longer includes changes to the core flash update command.
* Re-ordered patches slightly.
Changes since v1 RFC
* Removed the "allow_downgrade_on_flash_update" parameter. Instead, the driver will always attempt to flash the device, even when firmware indicates that it would be a downgrade. A dev_warn is used to indicate when this occurs.
* Removed the "ignore_pending_flash_update". Instead, the driver will always check for and cancel any previous pending update. A devlink flash status message will be sent when this cancellation occurs.
* Removed the "reset_after_flash_update" parameter. This will instead be implemented as part of a devlink reset interface, work left for a future change.
* Replaced the "flash_update_preservation_level" parameter with a new "overwrite" mode attribute on the flash update command. For ice, this mode will select the preservation level. For all other drivers, I modified them to check that the mode is "OVERWRITE_NOTHING", and have Cc'd the maintainers to get their input.
Cudzilo, Szymon T (1):
ice: Add AdminQ commands for FW update
Jacek Naczyk (1):
ice: Add support for unified NVM update flow capability
Jacob Keller (3):
Add pldmfw library for PLDM firmware update
ice: add flags indicating pending update of firmware module
ice: implement device flash update via devlink
Documentation/driver-api/index.rst | 1 + .../driver-api/pldmfw/driver-ops.rst | 56 ++ .../driver-api/pldmfw/file-format.rst | 203 ++++ Documentation/driver-api/pldmfw/index.rst | 72 ++ MAINTAINERS | 7 + drivers/net/ethernet/intel/Kconfig | 1 + drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice.h | 9 + .../net/ethernet/intel/ice/ice_adminq_cmd.h | 83 ++ drivers/net/ethernet/intel/ice/ice_common.c | 21 +- drivers/net/ethernet/intel/ice/ice_common.h | 4 +- drivers/net/ethernet/intel/ice/ice_devlink.c | 54 ++ .../net/ethernet/intel/ice/ice_fw_update.c | 773 +++++++++++++++ .../net/ethernet/intel/ice/ice_fw_update.h | 12 + drivers/net/ethernet/intel/ice/ice_main.c | 154 +++ drivers/net/ethernet/intel/ice/ice_nvm.c | 186 ++++ drivers/net/ethernet/intel/ice/ice_nvm.h | 16 + drivers/net/ethernet/intel/ice/ice_type.h | 12 + include/linux/pldmfw.h | 165 ++++ lib/Kconfig | 4 + lib/Makefile | 3 + lib/pldmfw/Makefile | 2 + lib/pldmfw/pldmfw.c | 879 ++++++++++++++++++ lib/pldmfw/pldmfw_private.h | 238 +++++ 24 files changed, 2953 insertions(+), 3 deletions(-) create mode 100644 Documentation/driver-api/pldmfw/driver-ops.rst create mode 100644 Documentation/driver-api/pldmfw/file-format.rst create mode 100644 Documentation/driver-api/pldmfw/index.rst create mode 100644 drivers/net/ethernet/intel/ice/ice_fw_update.c create mode 100644 drivers/net/ethernet/intel/ice/ice_fw_update.h create mode 100644 include/linux/pldmfw.h create mode 100644 lib/pldmfw/Makefile create mode 100644 lib/pldmfw/pldmfw.c create mode 100644 lib/pldmfw/pldmfw_private.h
base-commit: 0d127fc31b70b1aa28f8bc3014c7e6d11a4dd1bc
Signature · 1 line
2.28.0.rc1.139.gd6b33fda9dd1
Jacob Keller
maintainerPATCH 1/5 Add pldmfw library for PLDM firmware update
The pldmfw library is used to implement common logic needed to flash devices based on firmware files using the format described by the PLDM for Firmware Update standard.
This library consists of logic to parse the PLDM file format from a firmware file object, as well as common logic for sending the relevant PLDM header data to the device firmware.
A simple ops table is provided so that device drivers can implement device specific hardware interactions while keeping the common logic to the pldmfw library.
This library will be used by the Intel ice networking driver as part of implementing device flash update via devlink. The library aims to be vendor and device agnostic. For this reason, it has been placed in lib/pldmfw, in the hopes that other devices which use the PLDM firmware file format may benefit from it in the future. However, do note that not all features defined in the PLDM standard have been implemented.
--- Documentation/driver-api/index.rst | 1 + .../driver-api/pldmfw/driver-ops.rst | 56 ++ .../driver-api/pldmfw/file-format.rst | 203 ++++ Documentation/driver-api/pldmfw/index.rst | 72 ++ MAINTAINERS | 7 + include/linux/pldmfw.h | 165 ++++ lib/Kconfig | 4 + lib/Makefile | 3 + lib/pldmfw/Makefile | 2 + lib/pldmfw/pldmfw.c | 879 ++++++++++++++++++ lib/pldmfw/pldmfw_private.h | 238 +++++ 11 files changed, 1630 insertions(+) create mode 100644 Documentation/driver-api/pldmfw/driver-ops.rst create mode 100644 Documentation/driver-api/pldmfw/file-format.rst create mode 100644 Documentation/driver-api/pldmfw/index.rst create mode 100644 include/linux/pldmfw.h create mode 100644 lib/pldmfw/Makefile create mode 100644 lib/pldmfw/pldmfw.c create mode 100644 lib/pldmfw/pldmfw_private.h
Documentation/driver-api/index.rst +1 -0
@@ -95,6 +95,7 @@ available subsections can be seen below. phy/index pti_intel_mid pwm + pldmfw/index rfkill serial/index sm501
Documentation/driver-api/pldmfw/driver-ops.rst new file +56 -0
56 lines not on this page · raw message
Documentation/driver-api/pldmfw/file-format.rst new file +203 -0
203 lines not on this page · raw message
Documentation/driver-api/pldmfw/index.rst new file +72 -0
72 lines not on this page · raw message
MAINTAINERS +7 -0
@@ -13593,6 +13593,13 @@ S: Maintained F: Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.yaml F: drivers/iio/chemical/pms7003.c +PLDMFW LIBRARY +M: Jacob Keller <[email protected]> +S: Maintained +F: Documentation/driver-api/pldmfw/ +F: include/linux/pldmfw.h +F: lib/pldmfw/ + PLX DMA DRIVER M: Logan Gunthorpe <[email protected]> S: Maintained
include/linux/pldmfw.h new file +165 -0
165 lines not on this page · raw message
lib/Kconfig +4 -0
@@ -676,3 +676,7 @@ config GENERIC_LIB_CMPDI2 config GENERIC_LIB_UCMPDI2 bool + +config PLDMFW + bool + default n
lib/Makefile +3 -0
@@ -315,6 +315,9 @@ obj-$(CONFIG_GENERIC_LIB_CMPDI2) += cmpdi2.o obj-$(CONFIG_GENERIC_LIB_UCMPDI2) += ucmpdi2.o obj-$(CONFIG_OBJAGG) += objagg.o +# pldmfw library +obj-$(CONFIG_PLDMFW) += pldmfw/ + # KUnit tests obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o
lib/pldmfw/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_PLDMFW) += pldmfw.o
lib/pldmfw/pldmfw.c new file +879 -0
879 lines not on this page · raw message
lib/pldmfw/pldmfw_private.h new file +238 -0
238 lines not on this page · raw message
base-commit: 0d127fc31b70b1aa28f8bc3014c7e6d11a4dd1bc
Signature · 1 line
2.28.0.rc1.139.gd6b33fda9dd1
Jacob Keller
maintainerPATCH 2/5 ice: Add support for unified NVM update flow capability
In reply to Jacob KellerFrom: Jacek Naczyk <[email protected]>
Extends function parsing response from Discover Device Capability AQC to check if the device supports unified NVM update flow.
--- drivers/net/ethernet/intel/ice/ice_adminq_cmd.h | 1 + drivers/net/ethernet/intel/ice/ice_common.c | 7 +++++++ drivers/net/ethernet/intel/ice/ice_type.h | 3 +++ 3 files changed, 11 insertions(+)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +1 -0
@@ -109,6 +109,7 @@ struct ice_aqc_list_caps_elem {#define ICE_AQC_CAPS_MSIX 0x0043#define ICE_AQC_CAPS_FD 0x0045#define ICE_AQC_CAPS_MAX_MTU 0x0047 +#define ICE_AQC_CAPS_NVM_MGMT 0x0080u8 major_ver;u8 minor_ver;
drivers/net/ethernet/intel/ice/ice_common.c +7 -0
@@ -1857,6 +1857,13 @@ ice_parse_common_caps(struct ice_hw *hw, struct ice_hw_common_caps *caps,"%s: msix_vector_first_id = %d\n" , prefix, caps->msix_vector_first_id);break ; +case ICE_AQC_CAPS_NVM_MGMT : + caps->nvm_unified_update = + (number &ICE_NVM_MGMT_UNIFIED_UPD_SUPPORT ) ? + true : false; +ice_debug (hw,ICE_DBG_INIT ,"%s: nvm_unified_update = %d\n" , prefix, + caps->nvm_unified_update); +break ;case ICE_AQC_CAPS_MAX_MTU : caps->max_mtu = number; ice_debug(hw, ICE_DBG_INIT, "%s: max_mtu = %d\n",
drivers/net/ethernet/intel/ice/ice_type.h +3 -0
@@ -244,6 +244,9 @@ struct ice_hw_common_caps {u8 rss_table_entry_width;/* RSS Entry width in bits */ u8 dcb; + +bool nvm_unified_update; +#define ICE_NVM_MGMT_UNIFIED_UPD_SUPPORT BIT(3) };/* Function specific capabilities */
Signature · 1 line
2.28.0.rc1.139.gd6b33fda9dd1
Jacob Keller
maintainerPATCH 3/5 ice: Add AdminQ commands for FW update
In reply to Jacob KellerFrom: "Cudzilo, Szymon T" <[email protected]>
Add structures, identifiers, and helper functions for several AdminQ commands related to performing a firmware update for the ice hardware. These will be used in future code for implementing the devlink .flash_update handler.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 76 +++++++ drivers/net/ethernet/intel/ice/ice_common.h | 2 - drivers/net/ethernet/intel/ice/ice_nvm.c | 186 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_nvm.h | 16 ++ drivers/net/ethernet/intel/ice/ice_type.h | 3 + 5 files changed, 281 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +76 -0
@@ -1299,7 +1299,14 @@ struct ice_aqc_nvm {#define ICE_AQC_NVM_PRESERVATION_M (3 << ICE_AQC_NVM_PRESERVATION_S)#define ICE_AQC_NVM_NO_PRESERVATION (0 << ICE_AQC_NVM_PRESERVATION_S)#define ICE_AQC_NVM_PRESERVE_ALL BIT(1) +#define ICE_AQC_NVM_FACTORY_DEFAULT (2 << ICE_AQC_NVM_PRESERVATION_S)#define ICE_AQC_NVM_PRESERVE_SELECTED (3 << ICE_AQC_NVM_PRESERVATION_S) +#define ICE_AQC_NVM_ACTIV_SEL_NVM BIT(3)/* Write Activate/SR Dump only */ +#define ICE_AQC_NVM_ACTIV_SEL_OROM BIT(4) +#define ICE_AQC_NVM_ACTIV_SEL_NETLIST BIT(5) +#define ICE_AQC_NVM_SPECIAL_UPDATE BIT(6) +#define ICE_AQC_NVM_REVERT_LAST_ACTIV BIT(6)/* Write Activate only */ +#define ICE_AQC_NVM_ACTIV_SEL_MASK ICE_M(0x7, 3)#define ICE_AQC_NVM_FLASH_ONLY BIT(7)__le16 module_typeid;__le16 length;
@@ -1348,6 +1355,67 @@ struct ice_aqc_nvm_checksum {#define ICE_AQC_NVM_NETLIST_ID_BLK_SHA_HASH 0xA#define ICE_AQC_NVM_NETLIST_ID_BLK_CUST_VER 0x2F +/* Used for NVM Set Package Data command - 0x070A */ +struct ice_aqc_nvm_pkg_data { +u8 reserved[3 ]; +u8 cmd_flags; +#define ICE_AQC_NVM_PKG_DELETE BIT(0)/* used for command call */ +#define ICE_AQC_NVM_PKG_SKIPPED BIT(0)/* used for command response */ + +u32 reserved1; +__le32 addr_high; +__le32 addr_low; +}; + +/* Used for Pass Component Table command - 0x070B */ +struct ice_aqc_nvm_pass_comp_tbl { +u8 component_response;/* Response only */ +#define ICE_AQ_NVM_PASS_COMP_CAN_BE_UPDATED 0x0 +#define ICE_AQ_NVM_PASS_COMP_CAN_MAY_BE_UPDATEABLE 0x1 +#define ICE_AQ_NVM_PASS_COMP_CAN_NOT_BE_UPDATED 0x2 +u8 component_response_code;/* Response only */ +#define ICE_AQ_NVM_PASS_COMP_CAN_BE_UPDATED_CODE 0x0 +#define ICE_AQ_NVM_PASS_COMP_STAMP_IDENTICAL_CODE 0x1 +#define ICE_AQ_NVM_PASS_COMP_STAMP_LOWER 0x2 +#define ICE_AQ_NVM_PASS_COMP_INVALID_STAMP_CODE 0x3 +#define ICE_AQ_NVM_PASS_COMP_CONFLICT_CODE 0x4 +#define ICE_AQ_NVM_PASS_COMP_PRE_REQ_NOT_MET_CODE 0x5 +#define ICE_AQ_NVM_PASS_COMP_NOT_SUPPORTED_CODE 0x6 +#define ICE_AQ_NVM_PASS_COMP_CANNOT_DOWNGRADE_CODE 0x7 +#define ICE_AQ_NVM_PASS_COMP_INCOMPLETE_IMAGE_CODE 0x8 +#define ICE_AQ_NVM_PASS_COMP_VER_STR_IDENTICAL_CODE 0xA +#define ICE_AQ_NVM_PASS_COMP_VER_STR_LOWER_CODE 0xB +u8 reserved; +u8 transfer_flag; +#define ICE_AQ_NVM_PASS_COMP_TBL_START 0x1 +#define ICE_AQ_NVM_PASS_COMP_TBL_MIDDLE 0x2 +#define ICE_AQ_NVM_PASS_COMP_TBL_END 0x4 +#define ICE_AQ_NVM_PASS_COMP_TBL_START_AND_END 0x5 +__le32 reserved1; +__le32 addr_high; +__le32 addr_low; +}; + +struct ice_aqc_nvm_comp_tbl { +__le16 comp_class; +#define NVM_COMP_CLASS_ALL_FW 0x000A + +__le16 comp_id; +#define NVM_COMP_ID_OROM 0x5 +#define NVM_COMP_ID_NVM 0x6 +#define NVM_COMP_ID_NETLIST 0x8 + +u8 comp_class_idx; +#define FWU_COMP_CLASS_IDX_NOT_USE 0x0 + +__le32 comp_cmp_stamp; +u8 cvs_type; +#define NVM_CVS_TYPE_ASCII 0x1 + +u8 cvs_len; +u8 cvs[];/* Component Version String */ +} __packed; +/** * Send to PF command (indirect 0x0801) ID is only used by PF *
@@ -1795,6 +1863,8 @@ struct ice_aq_desc {struct ice_aqc_rl_profile rl_profile;struct ice_aqc_nvm nvm;struct ice_aqc_nvm_checksum nvm_checksum; +struct ice_aqc_nvm_pkg_data pkg_data; +struct ice_aqc_nvm_pass_comp_tbl pass_comp_tbl;struct ice_aqc_pf_vf_msg virt;struct ice_aqc_lldp_get_mib lldp_get_mib;struct ice_aqc_lldp_set_mib_change lldp_set_event;
@@ -1923,7 +1993,13 @@ enum ice_adminq_opc {/* NVM commands */ ice_aqc_opc_nvm_read =0x0701 , + ice_aqc_opc_nvm_erase =0x0702 , + ice_aqc_opc_nvm_write =0x0703 , ice_aqc_opc_nvm_checksum =0x0706 , + ice_aqc_opc_nvm_write_activate =0x0707 , + ice_aqc_opc_nvm_update_empr =0x0709 , + ice_aqc_opc_nvm_pkg_data =0x070A , + ice_aqc_opc_nvm_pass_component_tbl =0x070B ,/* PF/VF mailbox commands */ ice_mbx_opc_send_msg_to_pf = 0x0801,
drivers/net/ethernet/intel/ice/ice_common.h +0 -2
@@ -11,8 +11,6 @@#include "ice_switch.h" #include <linux/avf/virtchnl.h> -enum ice_status ice_nvm_validate_checksum (struct ice_hw *hw); -enum ice_status ice_init_hw (struct ice_hw *hw);void ice_deinit_hw (struct ice_hw *hw);enum ice_status ice_check_reset (struct ice_hw *hw);
drivers/net/ethernet/intel/ice/ice_nvm.c +186 -0
195 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_nvm.h +16 -0
@@ -17,4 +17,20 @@ enum ice_status ice_read_pba_string(struct ice_hw *hw, u8 *pba_num, u32 pba_num_size);enum ice_status ice_init_nvm (struct ice_hw *hw);enum ice_status ice_read_sr_word (struct ice_hw *hw,u16 offset,u16 *data); +enum ice_status +ice_aq_update_nvm (struct ice_hw *hw,u16 module_typeid,u32 offset, +u16 length,void *data,bool last_command,u8 command_flags, +struct ice_sq_cd *cd); +enum ice_status +ice_aq_erase_nvm (struct ice_hw *hw,u16 module_typeid,struct ice_sq_cd *cd); +enum ice_status ice_nvm_validate_checksum (struct ice_hw *hw); +enum ice_status ice_nvm_write_activate (struct ice_hw *hw,u8 cmd_flags); +enum ice_status ice_aq_nvm_update_empr (struct ice_hw *hw); +enum ice_status +ice_nvm_set_pkg_data (struct ice_hw *hw,bool del_pkg_data_flag,u8 *data, +u16 length,struct ice_sq_cd *cd); +enum ice_status +ice_nvm_pass_component_tbl (struct ice_hw *hw,u8 *data,u16 length, +u8 transfer_flag,u8 *comp_response, +u8 *comp_response_code,struct ice_sq_cd *cd);#endif /* _ICE_NVM_H_ */
drivers/net/ethernet/intel/ice/ice_type.h +3 -0
@@ -774,6 +774,9 @@ struct ice_hw_port_stats {#define ICE_OROM_VER_SHIFT 24#define ICE_OROM_VER_MASK (0xff << ICE_OROM_VER_SHIFT)#define ICE_SR_PFA_PTR 0x40 +#define ICE_SR_1ST_NVM_BANK_PTR 0x42 +#define ICE_SR_1ST_OROM_BANK_PTR 0x44 +#define ICE_SR_NETLIST_BANK_PTR 0x46#define ICE_SR_SECTOR_SIZE_IN_WORDS 0x800/* Link override related */
Signature · 1 line
2.28.0.rc1.139.gd6b33fda9dd1
Jacob Keller
maintainerPATCH 4/5 ice: add flags indicating pending update of firmware module
In reply to Jacob KellerAfter a flash update, the pending status of the update can be determined from the device capabilities.
Read the appropriate device capability and store whether there is a pending update awaiting a reboot.
--- drivers/net/ethernet/intel/ice/ice_adminq_cmd.h | 6 ++++++ drivers/net/ethernet/intel/ice/ice_common.c | 12 ++++++++++++ drivers/net/ethernet/intel/ice/ice_type.h | 6 ++++++ 3 files changed, 24 insertions(+)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +6 -0
@@ -109,6 +109,12 @@ struct ice_aqc_list_caps_elem {#define ICE_AQC_CAPS_MSIX 0x0043#define ICE_AQC_CAPS_FD 0x0045#define ICE_AQC_CAPS_MAX_MTU 0x0047 +#define ICE_AQC_CAPS_NVM_VER 0x0048 +#define ICE_AQC_CAPS_PENDING_NVM_VER 0x0049 +#define ICE_AQC_CAPS_OROM_VER 0x004A +#define ICE_AQC_CAPS_PENDING_OROM_VER 0x004B +#define ICE_AQC_CAPS_NET_VER 0x004C +#define ICE_AQC_CAPS_PENDING_NET_VER 0x004D#define ICE_AQC_CAPS_NVM_MGMT 0x0080u8 major_ver;
drivers/net/ethernet/intel/ice/ice_common.c +12 -0
@@ -1857,6 +1857,18 @@ ice_parse_common_caps(struct ice_hw *hw, struct ice_hw_common_caps *caps,"%s: msix_vector_first_id = %d\n" , prefix, caps->msix_vector_first_id);break ; +case ICE_AQC_CAPS_PENDING_NVM_VER : + caps->nvm_update_pending_nvm = true; +ice_debug (hw,ICE_DBG_INIT ,"%s: update_pending_nvm\n" , prefix); +break ; +case ICE_AQC_CAPS_PENDING_OROM_VER : + caps->nvm_update_pending_orom = true; +ice_debug (hw,ICE_DBG_INIT ,"%s: update_pending_orom\n" , prefix); +break ; +case ICE_AQC_CAPS_PENDING_NET_VER : + caps->nvm_update_pending_netlist = true; +ice_debug (hw,ICE_DBG_INIT ,"%s: update_pending_netlist\n" , prefix); +break ;case ICE_AQC_CAPS_NVM_MGMT : caps->nvm_unified_update = (number & ICE_NVM_MGMT_UNIFIED_UPD_SUPPORT) ?
drivers/net/ethernet/intel/ice/ice_type.h +6 -0
@@ -245,6 +245,12 @@ struct ice_hw_common_caps {u8 dcb; +bool nvm_update_pending_nvm; +bool nvm_update_pending_orom; +bool nvm_update_pending_netlist; +#define ICE_NVM_PENDING_NVM_IMAGE BIT(0) +#define ICE_NVM_PENDING_OROM BIT(1) +#define ICE_NVM_PENDING_NETLIST BIT(2)bool nvm_unified_update;#define ICE_NVM_MGMT_UNIFIED_UPD_SUPPORT BIT(3) };
Signature · 1 line
2.28.0.rc1.139.gd6b33fda9dd1
Jacob Keller
maintainerPATCH 5/5 ice: implement device flash update via devlink
In reply to Jacob KellerUse the newly added pldmfw library to implement device flash update for the Intel ice networking device driver. This support uses the devlink flash update interface.
The main parts of the flash include the Option ROM, the netlist module, and the main NVM data. The PLDM firmware file contains modules for each of these components.
Using the pldmfw library, the provided firmware file will be scanned for the three major components, "fw.undi" for the Option ROM, "fw.mgmt" for the main NVM module containing the primary device firmware, and "fw.netlist" containing the netlist module.
The flash is separated into two banks, the active bank containing the running firmware, and the inactive bank which we use for update. Each module is updated in a staged process. First, the inactive bank is erased, preparing the device for update. Second, the contents of the component are copied to the inactive portion of the flash. After all components are updated, the driver signals the device to switch the active bank during the next EMP reset (which would usually occur during the next reboot).
Although the firmware AdminQ interface does report an immediate status for each command, the NVM erase and NVM write commands receive status asynchronously. The driver must not continue writing until previous erase and write commands have finished. The real status of the NVM commands is returned over the receive AdminQ. Implement a simple interface that uses a wait queue so that the main update thread can sleep until the completion status is reported by firmware. For erasing the inactive banks, this can take quite a while in practice.
To help visualize the process to the devlink application and other applications based on the devlink netlink interface, status is reported via the devlink_flash_update_status_notify. While we do report status after each 4k block when writing, there is no real status we can report during erasing. We simply must wait for the complete module erasure to finish.
With this implementation, basic flash update for the ice hardware is supported.
--- drivers/net/ethernet/intel/Kconfig | 1 + drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice.h | 9 + drivers/net/ethernet/intel/ice/ice_common.c | 2 +- drivers/net/ethernet/intel/ice/ice_common.h | 2 + drivers/net/ethernet/intel/ice/ice_devlink.c | 54 ++ .../net/ethernet/intel/ice/ice_fw_update.c | 773 ++++++++++++++++++ .../net/ethernet/intel/ice/ice_fw_update.h | 12 + drivers/net/ethernet/intel/ice/ice_main.c | 154 ++++ 9 files changed, 1007 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_fw_update.c create mode 100644 drivers/net/ethernet/intel/ice/ice_fw_update.h
drivers/net/ethernet/intel/Kconfig +1 -0
@@ -295,6 +295,7 @@ config ICE default n depends on PCI_MSI select NET_DEVLINK + select PLDMFW help This driver supports Intel(R) Ethernet Connection E800 Series of devices. For more information on how to identify your adapter, go
drivers/net/ethernet/intel/ice/Makefile +1 -0
@@ -23,6 +23,7 @@ ice-y := ice_main.o \ ice_flex_pipe.o \ ice_flow.o \ ice_devlink.o \ + ice_fw_update.o \ ice_ethtool.o ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o
drivers/net/ethernet/intel/ice/ice.h +9 -0
@@ -19,6 +19,7 @@#include <linux/dma-mapping.h> #include <linux/pci.h> #include <linux/workqueue.h> +#include <linux/wait.h> #include <linux/aer.h> #include <linux/interrupt.h> #include <linux/ethtool.h>
@@ -412,6 +413,12 @@ struct ice_pf {struct mutex sw_mutex;/* lock for protecting VSI alloc flow */ struct mutex tc_mutex;/* lock to protect TC changes */ u32 msg_enable; + +/* spinlock to protect the AdminQ wait list */ +spinlock_t aq_wait_lock; +struct hlist_head aq_wait_list; +wait_queue_head_t aq_wait_queue; +u32 hw_csum_rx_error;u16 oicr_idx;/* Other interrupt cause MSIX vector index */ u16 num_avail_sw_msix;/* remaining MSIX SW vectors left unclaimed */
@@ -593,6 +600,8 @@ void ice_fdir_release_flows(struct ice_hw *hw);void ice_fdir_replay_flows (struct ice_hw *hw);void ice_fdir_replay_fltrs (struct ice_pf *pf);int ice_fdir_create_dflt_rules (struct ice_pf *pf); +int ice_aq_wait_for_event (struct ice_pf *pf,u16 opcode,unsigned long timeout, +struct ice_rq_event_info *event);int ice_open (struct net_device *netdev);int ice_stop (struct net_device *netdev);void ice_service_task_schedule (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_common.c +1 -1
@@ -2223,7 +2223,7 @@ ice_aq_list_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,* Read the device capabilities and extract them into the dev_caps structure * for later use. */ -static enum ice_status +enum ice_status ice_discover_dev_caps (struct ice_hw *hw,struct ice_hw_dev_caps *dev_caps) {enum ice_status status;
drivers/net/ethernet/intel/ice/ice_common.h +2 -0
@@ -88,6 +88,8 @@ ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,enum ice_status ice_aq_list_caps (struct ice_hw *hw,void *buf,u16 buf_size,u32 *cap_count,enum ice_adminq_opc opc,struct ice_sq_cd *cd); +enum ice_status +ice_discover_dev_caps (struct ice_hw *hw,struct ice_hw_dev_caps *dev_caps);void ice_update_phy_type (u64 *phy_type_low,u64 *phy_type_high,u16 link_speeds_bitmap);
drivers/net/ethernet/intel/ice/ice_devlink.c +54 -0
68 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fw_update.c new file +773 -0
773 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fw_update.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2018-2019, Intel Corporation. */ + +#ifndef _ICE_FW_UPDATE_H_ +#define _ICE_FW_UPDATE_H_ + +int ice_flash_pldm_image (struct ice_pf *pf,const struct firmware *fw, +struct netlink_ext_ack *extack); +int ice_check_for_pending_update (struct ice_pf *pf,const char *component, +struct netlink_ext_ack *extack); + +#endif
drivers/net/ethernet/intel/ice/ice_main.c +154 -0
178 lines not on this page · raw message
Signature · 1 line
2.28.0.rc1.139.gd6b33fda9dd1
David Miller
maintainerFrom: Jacob Keller <[email protected]>
Date: Thu, 23 Jul 2020 17:21:58 -0700
Quoted 29 lines
This series goal is to enable support for updating the ice hardware flash using the devlink flash command.
The ice firmware update files are distributed using the file format described by the "PLDM for Firmware Update" standard:
https://www.dmtf.org/documents/pmci/pldm-firmware-update-specification-100
Because this file format is standard, this series introduces a new library that handles the generic logic for parsing the PLDM file header. The library uses a design that is very similar to the Mellanox mlxfw module. That is, a simple ops table is setup and device drivers instantiate an instance of the pldmfw library with the device specific operations.
Doing so allows for each device to implement the low level behavior for how to interact with its firmware.
This series includes the library and an implementation for the ice hardware. I've removed all of the parameters, and the proposed changes to support overwrite mode. I'll be working on the overwrite mask suggestion from Jakub as a follow-up series.
Because the PLDM file format is a standard and not something that is specific to the Intel hardware, I opted to place this update library in lib/pldmfw. I should note that while I tried to make the library generic, it does not attempt to mimic the complete "Update Agent" as defined in the standard. This is mostly due to the fact that the actual interfaces exposed to software for the ice hardware would not allow this.
Quoted 4 lines
This series depends on some work just recently and is based on top of the patch series sent by Tony published at:
...
Series applied, thanks.