Lines Matching +full:read +full:- +full:to +full:- +full:read

1 // SPDX-License-Identifier: GPL-2.0
10 * @hw: pointer to the HW struct
13 * @length: length of the section to be read (in bytes from the offset)
16 * @read_shadow_ram: tell if this is a shadow RAM read
17 * @cd: pointer to command details structure or NULL
19 * Read the NVM using the admin queue commands (0x0701)
32 return -EINVAL; in ice_aq_read_nvm()
37 cmd->cmd_flags |= ICE_AQC_NVM_FLASH_ONLY; in ice_aq_read_nvm()
41 cmd->cmd_flags |= ICE_AQC_NVM_LAST_CMD; in ice_aq_read_nvm()
42 cmd->module_typeid = cpu_to_le16(module_typeid); in ice_aq_read_nvm()
43 cmd->offset_low = cpu_to_le16(offset & 0xFFFF); in ice_aq_read_nvm()
44 cmd->offset_high = (offset >> 16) & 0xFF; in ice_aq_read_nvm()
45 cmd->length = cpu_to_le16(length); in ice_aq_read_nvm()
51 * ice_read_flat_nvm - Read portion of NVM by flat offset
52 * @hw: pointer to the HW struct
54 * @length: (in) number of bytes to read; (out) number of bytes actually read
55 * @data: buffer to return data in (sized to fit the specified length)
56 * @read_shadow_ram: if true, read from shadow RAM instead of NVM
59 * breaks read requests across Shadow RAM sectors and ensures that no single
60 * read request exceeds the maximum 4KB read for a single AdminQ command.
76 /* Verify the length of the read if this is for the Shadow RAM */ in ice_read_flat_nvm()
77 if (read_shadow_ram && ((offset + inlen) > (hw->flash.sr_words * 2u))) { in ice_read_flat_nvm()
79 return -EINVAL; in ice_read_flat_nvm()
85 /* ice_aq_read_nvm cannot read more than 4KB at a time. in ice_read_flat_nvm()
86 * Additionally, a read from the Shadow RAM may not cross over in ice_read_flat_nvm()
91 read_size = min_t(u32, ICE_AQ_MAX_BUF_LEN - sector_offset, in ice_read_flat_nvm()
92 inlen - bytes_read); in ice_read_flat_nvm()
113 * @hw: pointer to the HW struct
116 * @length: length of the section to be written (in bytes from the offset)
120 * @cd: pointer to command details structure or NULL
136 return -EINVAL; in ice_aq_update_nvm()
140 cmd->cmd_flags |= command_flags; in ice_aq_update_nvm()
144 cmd->cmd_flags |= ICE_AQC_NVM_LAST_CMD; in ice_aq_update_nvm()
145 cmd->module_typeid = cpu_to_le16(module_typeid); in ice_aq_update_nvm()
146 cmd->offset_low = cpu_to_le16(offset & 0xFFFF); in ice_aq_update_nvm()
147 cmd->offset_high = (offset >> 16) & 0xFF; in ice_aq_update_nvm()
148 cmd->length = cpu_to_le16(length); in ice_aq_update_nvm()
157 * @hw: pointer to the HW struct
159 * @cd: pointer to command details structure or NULL
172 cmd->module_typeid = cpu_to_le16(module_typeid); in ice_aq_erase_nvm()
173 cmd->length = cpu_to_le16(ICE_AQC_NVM_ERASE_LEN); in ice_aq_erase_nvm()
174 cmd->offset_low = 0; in ice_aq_erase_nvm()
175 cmd->offset_high = 0; in ice_aq_erase_nvm()
181 * ice_read_sr_word_aq - Reads Shadow RAM via AQ
182 * @hw: pointer to the HW structure
183 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
184 * @data: word read from the Shadow RAM
207 * ice_acquire_nvm - Generic request for acquiring the NVM ownership
208 * @hw: pointer to the HW structure
209 * @access: NVM access type (read or write)
215 if (hw->flash.blank_nvm_mode) in ice_acquire_nvm()
222 * ice_release_nvm - Generic request for releasing the NVM ownership
223 * @hw: pointer to the HW structure
229 if (hw->flash.blank_nvm_mode) in ice_release_nvm()
236 * ice_get_flash_bank_offset - Get offset into requested flash bank
237 * @hw: pointer to the HW structure
238 * @bank: whether to read from the active or inactive flash bank
239 * @module: the module to read from
249 struct ice_bank_info *banks = &hw->flash.banks; in ice_get_flash_bank_offset()
256 offset = banks->nvm_ptr; in ice_get_flash_bank_offset()
257 size = banks->nvm_size; in ice_get_flash_bank_offset()
258 active_bank = banks->nvm_bank; in ice_get_flash_bank_offset()
261 offset = banks->orom_ptr; in ice_get_flash_bank_offset()
262 size = banks->orom_size; in ice_get_flash_bank_offset()
263 active_bank = banks->orom_bank; in ice_get_flash_bank_offset()
266 offset = banks->netlist_ptr; in ice_get_flash_bank_offset()
267 size = banks->netlist_size; in ice_get_flash_bank_offset()
268 active_bank = banks->netlist_bank; in ice_get_flash_bank_offset()
304 * ice_read_flash_module - Read a word from one of the main NVM modules
305 * @hw: pointer to the HW structure
306 * @bank: which bank of the module to read
307 * @module: the module to read
309 * @data: storage for the word read from the flash
310 * @length: bytes of data to read
312 * Read data from the specified flash module. The bank parameter indicates
313 * whether or not to read from the active bank or the inactive bank of that
316 * The word will be read using flat NVM access, and relies on the
317 * hw->flash.banks data being setup by ice_determine_active_flash_banks()
329 ice_debug(hw, ICE_DBG_NVM, "Unable to calculate flash bank offset for module 0x%04x\n", in ice_read_flash_module()
331 return -EINVAL; in ice_read_flash_module()
346 * ice_read_nvm_module - Read from the active main NVM module
347 * @hw: pointer to the HW structure
348 * @bank: whether to read from active or inactive NVM module
349 * @offset: offset into the NVM module to read, in words
352 * Read the specified word from the active NVM module. This includes the CSS
370 * ice_read_nvm_sr_copy - Read a word from the Shadow RAM copy in the NVM bank
371 * @hw: pointer to the HW structure
372 * @bank: whether to read from the active or inactive NVM module
373 * @offset: offset into the Shadow RAM copy to read, in words
376 * Read the specified word from the copy of the Shadow RAM found in the
386 * ice_read_netlist_module - Read data from the netlist module area
387 * @hw: pointer to the HW structure
388 * @bank: whether to read from the active or inactive module
389 * @offset: offset into the netlist to read from
392 * Read a word from the specified netlist bank.
409 * ice_read_sr_word - Reads Shadow RAM word and acquire NVM if necessary
410 * @hw: pointer to the HW structure
411 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
412 * @data: word read from the Shadow RAM
430 * ice_get_pfa_module_tlv - Reads sub module TLV from NVM PFA
431 * @hw: pointer to hardware structure
432 * @module_tlv: pointer to module TLV to return
433 * @module_tlv_len: pointer to module TLV length to return
438 * use these to read the variable length TLV value.
455 ice_debug(hw, ICE_DBG_INIT, "Failed to read PFA length.\n"); in ice_get_pfa_module_tlv()
459 * of TLVs to find the requested one. in ice_get_pfa_module_tlv()
466 /* Read TLV type */ in ice_get_pfa_module_tlv()
469 ice_debug(hw, ICE_DBG_INIT, "Failed to read TLV type.\n"); in ice_get_pfa_module_tlv()
472 /* Read TLV length */ in ice_get_pfa_module_tlv()
475 ice_debug(hw, ICE_DBG_INIT, "Failed to read TLV length.\n"); in ice_get_pfa_module_tlv()
484 return -EINVAL; in ice_get_pfa_module_tlv()
492 return -ENOENT; in ice_get_pfa_module_tlv()
496 * ice_read_pba_string - Reads part number string from NVM
497 * @hw: pointer to hardware structure
513 ice_debug(hw, ICE_DBG_INIT, "Failed to read PBA Block TLV.\n"); in ice_read_pba_string()
520 ice_debug(hw, ICE_DBG_INIT, "Failed to read PBA Section size.\n"); in ice_read_pba_string()
526 return -EINVAL; in ice_read_pba_string()
529 /* Subtract one to get PBA word count (PBA Size word is included in in ice_read_pba_string()
532 pba_size--; in ice_read_pba_string()
535 return -EINVAL; in ice_read_pba_string()
541 ice_debug(hw, ICE_DBG_INIT, "Failed to read PBA Block word %d.\n", i); in ice_read_pba_string()
554 * ice_get_nvm_ver_info - Read NVM version information
555 * @hw: pointer to the HW struct
556 * @bank: whether to read from the active or inactive flash bank
557 * @nvm: pointer to NVM info structure
559 * Read the NVM EETRACK ID and map version of the main NVM image bank, filling
570 ice_debug(hw, ICE_DBG_NVM, "Failed to read DEV starter version.\n"); in ice_get_nvm_ver_info()
574 nvm->major = FIELD_GET(ICE_NVM_VER_HI_MASK, ver); in ice_get_nvm_ver_info()
575 nvm->minor = FIELD_GET(ICE_NVM_VER_LO_MASK, ver); in ice_get_nvm_ver_info()
579 ice_debug(hw, ICE_DBG_NVM, "Failed to read EETRACK lo.\n"); in ice_get_nvm_ver_info()
584 ice_debug(hw, ICE_DBG_NVM, "Failed to read EETRACK hi.\n"); in ice_get_nvm_ver_info()
588 nvm->eetrack = (eetrack_hi << 16) | eetrack_lo; in ice_get_nvm_ver_info()
594 * ice_get_inactive_nvm_ver - Read Option ROM version from the inactive bank
595 * @hw: pointer to the HW structure
599 * inactive NVM bank. Used to access version data for a pending update that
608 * ice_get_orom_civd_data - Get the combo version information from Option ROM
609 * @hw: pointer to the HW struct
610 * @bank: whether to read from the active or inactive flash module
613 * Searches through the Option ROM flash contents to locate the CIVD data for
624 /* The CIVD section is located in the Option ROM aligned to 512 bytes. in ice_get_orom_civd_data()
630 * usually somewhere in the middle of the bank. We need to scan the in ice_get_orom_civd_data()
631 * Option ROM bank to locate it. in ice_get_orom_civd_data()
633 * It's significantly faster to read the entire Option ROM up front in ice_get_orom_civd_data()
634 * using the maximum page size, than to read each possible location in ice_get_orom_civd_data()
637 orom_data = vzalloc(hw->flash.banks.orom_size); in ice_get_orom_civd_data()
639 return -ENOMEM; in ice_get_orom_civd_data()
642 orom_data, hw->flash.banks.orom_size); in ice_get_orom_civd_data()
645 ice_debug(hw, ICE_DBG_NVM, "Unable to read Option ROM data\n"); in ice_get_orom_civd_data()
649 /* Scan the memory buffer to locate the CIVD data section */ in ice_get_orom_civd_data()
650 for (offset = 0; (offset + 512) <= hw->flash.banks.orom_size; offset += 512) { in ice_get_orom_civd_data()
657 if (memcmp("$CIV", tmp->signature, sizeof(tmp->signature)) != 0) in ice_get_orom_civd_data()
678 ice_debug(hw, ICE_DBG_NVM, "Unable to locate CIVD data within the Option ROM\n"); in ice_get_orom_civd_data()
682 return -EIO; in ice_get_orom_civd_data()
686 * ice_get_orom_ver_info - Read Option ROM version information
687 * @hw: pointer to the HW struct
688 * @bank: whether to read from the active or inactive flash module
689 * @orom: pointer to Option ROM info structure
691 * Read Option ROM version and security revision from the Option ROM flash
703 ice_debug(hw, ICE_DBG_NVM, "Failed to locate valid Option ROM CIVD data\n"); in ice_get_orom_ver_info()
709 orom->major = FIELD_GET(ICE_OROM_VER_MASK, combo_ver); in ice_get_orom_ver_info()
710 orom->patch = FIELD_GET(ICE_OROM_VER_PATCH_MASK, combo_ver); in ice_get_orom_ver_info()
711 orom->build = FIELD_GET(ICE_OROM_VER_BUILD_MASK, combo_ver); in ice_get_orom_ver_info()
717 * ice_get_inactive_orom_ver - Read Option ROM version from the inactive bank
718 * @hw: pointer to the HW structure
722 * section of flash. Used to access version data for a pending update that has
732 * @hw: pointer to the HW struct
733 * @bank: whether to read from the active or inactive flash bank
734 * @netlist: pointer to netlist version info structure
737 * Topology section to find the Netlist ID block and extract the relevant
755 return -EIO; in ice_get_netlist_info()
762 /* sanity check that we have at least enough words to store the netlist ID block */ in ice_get_netlist_info()
766 return -EIO; in ice_get_netlist_info()
776 return -ENOMEM; in ice_get_netlist_info()
778 /* Read out the entire Netlist ID Block at once. */ in ice_get_netlist_info()
788 netlist->major = id_blk[ICE_NETLIST_ID_BLK_MAJOR_VER_HIGH] << 16 | in ice_get_netlist_info()
790 netlist->minor = id_blk[ICE_NETLIST_ID_BLK_MINOR_VER_HIGH] << 16 | in ice_get_netlist_info()
792 netlist->type = id_blk[ICE_NETLIST_ID_BLK_TYPE_HIGH] << 16 | in ice_get_netlist_info()
794 netlist->rev = id_blk[ICE_NETLIST_ID_BLK_REV_HIGH] << 16 | in ice_get_netlist_info()
796 netlist->cust_ver = id_blk[ICE_NETLIST_ID_BLK_CUST_VER]; in ice_get_netlist_info()
797 /* Read the left most 4 bytes of SHA */ in ice_get_netlist_info()
798 netlist->hash = id_blk[ICE_NETLIST_ID_BLK_SHA_HASH_WORD(15)] << 16 | in ice_get_netlist_info()
809 * @hw: pointer to the HW struct
810 * @netlist: pointer to netlist version info structure
812 * Read the netlist version data from the inactive netlist bank. Used to
813 * extract version data of a pending flash update in order to display the
822 * ice_discover_flash_size - Discover the available flash size.
823 * @hw: pointer to the HW struct
825 * The device flash could be up to 16MB in size. However, it is possible that
826 * the actual size is smaller. Use bisection to determine the accessible size
838 while ((max_size - min_size) > 1) { in ice_discover_flash_size()
844 if (status == -EIO && in ice_discover_flash_size()
845 hw->adminq.sq_last_status == ICE_AQ_RC_EINVAL) { in ice_discover_flash_size()
862 hw->flash.flash_size = max_size; in ice_discover_flash_size()
871 * ice_read_sr_pointer - Read the value of a Shadow RAM pointer word
872 * @hw: pointer to the HW structure
873 * @offset: the word offset of the Shadow RAM word to read
874 * @pointer: pointer value read from Shadow RAM
876 * Read the given Shadow RAM word, and convert it to a pointer value specified
903 * ice_read_sr_area_size - Read an area size from a Shadow RAM word
904 * @hw: pointer to the HW structure
905 * @offset: the word offset of the Shadow RAM to read
906 * @size: size value read from the Shadow RAM
908 * Read the given Shadow RAM word, and convert it to an area size value
931 * ice_determine_active_flash_banks - Discover active bank for each module
932 * @hw: pointer to the HW struct
934 * Read the Shadow RAM control word and determine which banks are active for
935 * the NVM, OROM, and Netlist modules. Also read and calculate the associated
937 * structure for later use in order to calculate the correct offset to read
942 struct ice_bank_info *banks = &hw->flash.banks; in ice_determine_active_flash_banks()
948 ice_debug(hw, ICE_DBG_NVM, "Failed to read the Shadow RAM control word\n"); in ice_determine_active_flash_banks()
956 return -EIO; in ice_determine_active_flash_banks()
960 banks->nvm_bank = ICE_1ST_FLASH_BANK; in ice_determine_active_flash_banks()
962 banks->nvm_bank = ICE_2ND_FLASH_BANK; in ice_determine_active_flash_banks()
965 banks->orom_bank = ICE_1ST_FLASH_BANK; in ice_determine_active_flash_banks()
967 banks->orom_bank = ICE_2ND_FLASH_BANK; in ice_determine_active_flash_banks()
970 banks->netlist_bank = ICE_1ST_FLASH_BANK; in ice_determine_active_flash_banks()
972 banks->netlist_bank = ICE_2ND_FLASH_BANK; in ice_determine_active_flash_banks()
974 status = ice_read_sr_pointer(hw, ICE_SR_1ST_NVM_BANK_PTR, &banks->nvm_ptr); in ice_determine_active_flash_banks()
976 ice_debug(hw, ICE_DBG_NVM, "Failed to read NVM bank pointer\n"); in ice_determine_active_flash_banks()
980 status = ice_read_sr_area_size(hw, ICE_SR_NVM_BANK_SIZE, &banks->nvm_size); in ice_determine_active_flash_banks()
982 ice_debug(hw, ICE_DBG_NVM, "Failed to read NVM bank area size\n"); in ice_determine_active_flash_banks()
986 status = ice_read_sr_pointer(hw, ICE_SR_1ST_OROM_BANK_PTR, &banks->orom_ptr); in ice_determine_active_flash_banks()
988 ice_debug(hw, ICE_DBG_NVM, "Failed to read OROM bank pointer\n"); in ice_determine_active_flash_banks()
992 status = ice_read_sr_area_size(hw, ICE_SR_OROM_BANK_SIZE, &banks->orom_size); in ice_determine_active_flash_banks()
994 ice_debug(hw, ICE_DBG_NVM, "Failed to read OROM bank area size\n"); in ice_determine_active_flash_banks()
998 status = ice_read_sr_pointer(hw, ICE_SR_NETLIST_BANK_PTR, &banks->netlist_ptr); in ice_determine_active_flash_banks()
1000 ice_debug(hw, ICE_DBG_NVM, "Failed to read Netlist bank pointer\n"); in ice_determine_active_flash_banks()
1004 status = ice_read_sr_area_size(hw, ICE_SR_NETLIST_BANK_SIZE, &banks->netlist_size); in ice_determine_active_flash_banks()
1006 ice_debug(hw, ICE_DBG_NVM, "Failed to read Netlist bank area size\n"); in ice_determine_active_flash_banks()
1014 * ice_init_nvm - initializes NVM setting
1015 * @hw: pointer to the HW struct
1022 struct ice_flash_info *flash = &hw->flash; in ice_init_nvm()
1033 /* Switching to words (sr_size contains power of 2) */ in ice_init_nvm()
1034 flash->sr_words = BIT(sr_size) * ICE_SR_WORDS_IN_1KB; in ice_init_nvm()
1039 flash->blank_nvm_mode = false; in ice_init_nvm()
1042 flash->blank_nvm_mode = true; in ice_init_nvm()
1044 return -EIO; in ice_init_nvm()
1049 ice_debug(hw, ICE_DBG_NVM, "NVM init error: failed to discover flash size.\n"); in ice_init_nvm()
1055 ice_debug(hw, ICE_DBG_NVM, "Failed to determine active flash banks.\n"); in ice_init_nvm()
1059 status = ice_get_nvm_ver_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->nvm); in ice_init_nvm()
1061 ice_debug(hw, ICE_DBG_INIT, "Failed to read NVM info.\n"); in ice_init_nvm()
1065 status = ice_get_orom_ver_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->orom); in ice_init_nvm()
1067 ice_debug(hw, ICE_DBG_INIT, "Failed to read Option ROM info.\n"); in ice_init_nvm()
1069 /* read the netlist version information */ in ice_init_nvm()
1070 status = ice_get_netlist_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->netlist); in ice_init_nvm()
1072 ice_debug(hw, ICE_DBG_INIT, "Failed to read netlist info.\n"); in ice_init_nvm()
1079 * @hw: pointer to the HW struct
1096 cmd->flags = ICE_AQC_NVM_CHECKSUM_VERIFY; in ice_nvm_validate_checksum()
1102 if (le16_to_cpu(cmd->checksum) != ICE_AQC_NVM_CHECKSUM_CORRECT) in ice_nvm_validate_checksum()
1103 status = -EIO; in ice_nvm_validate_checksum()
1110 * @hw: pointer to the HW struct
1115 * and dumps the Shadow RAM to flash (0x0707)
1117 * cmd_flags controls which banks to activate, the preservation level to use
1137 cmd->cmd_flags = (u8)(cmd_flags & 0xFF); in ice_nvm_write_activate()
1138 cmd->offset_high = (u8)((cmd_flags >> 8) & 0xFF); in ice_nvm_write_activate()
1142 *response_flags = cmd->cmd_flags; in ice_nvm_write_activate()
1149 * @hw: pointer to the HW struct
1151 * Update empr (0x0709). This command allows SW to
1152 * request an EMPR to activate new FW.
1164 * @hw: pointer to the HW struct
1167 * If bit is set to 1, then buffer should be size 0.
1168 * @data: pointer to buffer
1170 * @cd: pointer to command details structure or NULL
1172 * Set package data (0x070A). This command is equivalent to the reception
1185 return -EINVAL; in ice_nvm_set_pkg_data()
1193 cmd->cmd_flags |= ICE_AQC_NVM_PKG_DELETE; in ice_nvm_set_pkg_data()
1199 * @hw: pointer to the HW struct
1200 * @data: pointer to buffer
1203 * @comp_response: a pointer to the response from the 0x070B AQC.
1204 * @comp_response_code: a pointer to the response code from the 0x070B AQC.
1205 * @cd: pointer to command details structure or NULL
1207 * Pass component table (0x070B). This command is equivalent to the reception
1210 * actual update. FW will assume these commands are going to be sent until
1211 * the TransferFlag is set to End or StartAndEnd.
1224 return -EINVAL; in ice_nvm_pass_component_tbl()
1232 cmd->transfer_flag = transfer_flag; in ice_nvm_pass_component_tbl()
1236 *comp_response = cmd->component_response; in ice_nvm_pass_component_tbl()
1237 *comp_response_code = cmd->component_response_code; in ice_nvm_pass_component_tbl()