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)
31 return -EINVAL; in ice_aq_read_nvm()
36 cmd->cmd_flags |= ICE_AQC_NVM_FLASH_ONLY; in ice_aq_read_nvm()
40 cmd->cmd_flags |= ICE_AQC_NVM_LAST_CMD; in ice_aq_read_nvm()
41 cmd->module_typeid = cpu_to_le16(module_typeid); in ice_aq_read_nvm()
42 cmd->offset_low = cpu_to_le16(offset & 0xFFFF); in ice_aq_read_nvm()
43 cmd->offset_high = (offset >> 16) & 0xFF; in ice_aq_read_nvm()
44 cmd->length = cpu_to_le16(length); in ice_aq_read_nvm()
50 * ice_read_flat_nvm - Read portion of NVM by flat offset
51 * @hw: pointer to the HW struct
53 * @length: (in) number of bytes to read; (out) number of bytes actually read
54 * @data: buffer to return data in (sized to fit the specified length)
55 * @read_shadow_ram: if true, read from shadow RAM instead of NVM
58 * breaks read requests across Shadow RAM sectors and ensures that no single
59 * read request exceeds the maximum 4KB read for a single AdminQ command.
75 /* Verify the length of the read if this is for the Shadow RAM */ in ice_read_flat_nvm()
76 if (read_shadow_ram && ((offset + inlen) > (hw->flash.sr_words * 2u))) { in ice_read_flat_nvm()
78 return -EINVAL; in ice_read_flat_nvm()
84 /* ice_aq_read_nvm cannot read more than 4KB at a time. in ice_read_flat_nvm()
85 * Additionally, a read from the Shadow RAM may not cross over in ice_read_flat_nvm()
90 read_size = min_t(u32, ICE_AQ_MAX_BUF_LEN - sector_offset, in ice_read_flat_nvm()
91 inlen - bytes_read); in ice_read_flat_nvm()
112 * @hw: pointer to the HW struct
115 * @length: length of the section to be written (in bytes from the offset)
119 * @cd: pointer to command details structure or NULL
135 return -EINVAL; in ice_aq_update_nvm()
139 cmd->cmd_flags |= command_flags; in ice_aq_update_nvm()
143 cmd->cmd_flags |= ICE_AQC_NVM_LAST_CMD; in ice_aq_update_nvm()
144 cmd->module_typeid = cpu_to_le16(module_typeid); in ice_aq_update_nvm()
145 cmd->offset_low = cpu_to_le16(offset & 0xFFFF); in ice_aq_update_nvm()
146 cmd->offset_high = (offset >> 16) & 0xFF; in ice_aq_update_nvm()
147 cmd->length = cpu_to_le16(length); in ice_aq_update_nvm()
156 * @hw: pointer to the HW struct
158 * @cd: pointer to command details structure or NULL
171 cmd->module_typeid = cpu_to_le16(module_typeid); in ice_aq_erase_nvm()
172 cmd->length = cpu_to_le16(ICE_AQC_NVM_ERASE_LEN); in ice_aq_erase_nvm()
173 cmd->offset_low = 0; in ice_aq_erase_nvm()
174 cmd->offset_high = 0; in ice_aq_erase_nvm()
180 * ice_read_sr_word_aq - Reads Shadow RAM via AQ
181 * @hw: pointer to the HW structure
182 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
183 * @data: word read from the Shadow RAM
206 * ice_acquire_nvm - Generic request for acquiring the NVM ownership
207 * @hw: pointer to the HW structure
208 * @access: NVM access type (read or write)
214 if (hw->flash.blank_nvm_mode) in ice_acquire_nvm()
221 * ice_release_nvm - Generic request for releasing the NVM ownership
222 * @hw: pointer to the HW structure
228 if (hw->flash.blank_nvm_mode) in ice_release_nvm()
235 * ice_get_flash_bank_offset - Get offset into requested flash bank
236 * @hw: pointer to the HW structure
237 * @bank: whether to read from the active or inactive flash bank
238 * @module: the module to read from
248 struct ice_bank_info *banks = &hw->flash.banks; in ice_get_flash_bank_offset()
255 offset = banks->nvm_ptr; in ice_get_flash_bank_offset()
256 size = banks->nvm_size; in ice_get_flash_bank_offset()
257 active_bank = banks->nvm_bank; in ice_get_flash_bank_offset()
260 offset = banks->orom_ptr; in ice_get_flash_bank_offset()
261 size = banks->orom_size; in ice_get_flash_bank_offset()
262 active_bank = banks->orom_bank; in ice_get_flash_bank_offset()
265 offset = banks->netlist_ptr; in ice_get_flash_bank_offset()
266 size = banks->netlist_size; in ice_get_flash_bank_offset()
267 active_bank = banks->netlist_bank; in ice_get_flash_bank_offset()
303 * ice_read_flash_module - Read a word from one of the main NVM modules
304 * @hw: pointer to the HW structure
305 * @bank: which bank of the module to read
306 * @module: the module to read
308 * @data: storage for the word read from the flash
309 * @length: bytes of data to read
311 * Read data from the specified flash module. The bank parameter indicates
312 * whether or not to read from the active bank or the inactive bank of that
315 * The word will be read using flat NVM access, and relies on the
316 * hw->flash.banks data being setup by ice_determine_active_flash_banks()
328 ice_debug(hw, ICE_DBG_NVM, "Unable to calculate flash bank offset for module 0x%04x\n", in ice_read_flash_module()
330 return -EINVAL; in ice_read_flash_module()
345 * ice_read_nvm_module - Read from the active main NVM module
346 * @hw: pointer to the HW structure
347 * @bank: whether to read from active or inactive NVM module
348 * @offset: offset into the NVM module to read, in words
351 * Read the specified word from the active NVM module. This includes the CSS
369 * ice_read_nvm_sr_copy - Read a word from the Shadow RAM copy in the NVM bank
370 * @hw: pointer to the HW structure
371 * @bank: whether to read from the active or inactive NVM module
372 * @offset: offset into the Shadow RAM copy to read, in words
375 * Read the specified word from the copy of the Shadow RAM found in the
379 * is aligned to 64-byte (32-word) offsets.
388 sr_copy = roundup(hw->flash.banks.active_css_hdr_len, 32); in ice_read_nvm_sr_copy()
391 sr_copy = roundup(hw->flash.banks.inactive_css_hdr_len, 32); in ice_read_nvm_sr_copy()
399 * ice_read_netlist_module - Read data from the netlist module area
400 * @hw: pointer to the HW structure
401 * @bank: whether to read from the active or inactive module
402 * @offset: offset into the netlist to read from
405 * Read a word from the specified netlist bank.
422 * ice_read_sr_word - Reads Shadow RAM word and acquire NVM if necessary
423 * @hw: pointer to the HW structure
424 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
425 * @data: word read from the Shadow RAM
443 * ice_get_pfa_module_tlv - Reads sub module TLV from NVM PFA
444 * @hw: pointer to hardware structure
445 * @module_tlv: pointer to module TLV to return
446 * @module_tlv_len: pointer to module TLV length to return
451 * use these to read the variable length TLV value.
467 ice_debug(hw, ICE_DBG_INIT, "Failed to read PFA length.\n"); in ice_get_pfa_module_tlv()
471 /* The Preserved Fields Area contains a sequence of Type-Length-Value in ice_get_pfa_module_tlv()
476 if (check_add_overflow(pfa_ptr, pfa_len - 1, &max_tlv)) { in ice_get_pfa_module_tlv()
477 …dev_warn(ice_hw_to_dev(hw), "PFA starts at offset %u. PFA length of %u caused 16-bit arithmetic ov… in ice_get_pfa_module_tlv()
479 return -EINVAL; in ice_get_pfa_module_tlv()
483 * of TLVs to find the requested one. in ice_get_pfa_module_tlv()
490 /* Read TLV type */ in ice_get_pfa_module_tlv()
493 ice_debug(hw, ICE_DBG_INIT, "Failed to read TLV type.\n"); in ice_get_pfa_module_tlv()
496 /* Read TLV length */ in ice_get_pfa_module_tlv()
499 ice_debug(hw, ICE_DBG_INIT, "Failed to read TLV length.\n"); in ice_get_pfa_module_tlv()
508 return -EINVAL; in ice_get_pfa_module_tlv()
513 …dev_warn(ice_hw_to_dev(hw), "TLV of type %u and length 0x%04x caused 16-bit arithmetic overflow. T… in ice_get_pfa_module_tlv()
515 return -EINVAL; in ice_get_pfa_module_tlv()
519 return -ENOENT; in ice_get_pfa_module_tlv()
523 * ice_read_pba_string - Reads part number string from NVM
524 * @hw: pointer to hardware structure
540 ice_debug(hw, ICE_DBG_INIT, "Failed to read PBA Block TLV.\n"); in ice_read_pba_string()
547 ice_debug(hw, ICE_DBG_INIT, "Failed to read PBA Section size.\n"); in ice_read_pba_string()
553 return -EINVAL; in ice_read_pba_string()
556 /* Subtract one to get PBA word count (PBA Size word is included in in ice_read_pba_string()
559 pba_size--; in ice_read_pba_string()
562 return -EINVAL; in ice_read_pba_string()
568 ice_debug(hw, ICE_DBG_INIT, "Failed to read PBA Block word %d.\n", i); in ice_read_pba_string()
581 * ice_get_nvm_ver_info - Read NVM version information
582 * @hw: pointer to the HW struct
583 * @bank: whether to read from the active or inactive flash bank
584 * @nvm: pointer to NVM info structure
586 * Read the NVM EETRACK ID and map version of the main NVM image bank, filling
597 ice_debug(hw, ICE_DBG_NVM, "Failed to read DEV starter version.\n"); in ice_get_nvm_ver_info()
601 nvm->major = FIELD_GET(ICE_NVM_VER_HI_MASK, ver); in ice_get_nvm_ver_info()
602 nvm->minor = FIELD_GET(ICE_NVM_VER_LO_MASK, ver); in ice_get_nvm_ver_info()
606 ice_debug(hw, ICE_DBG_NVM, "Failed to read EETRACK lo.\n"); in ice_get_nvm_ver_info()
611 ice_debug(hw, ICE_DBG_NVM, "Failed to read EETRACK hi.\n"); in ice_get_nvm_ver_info()
615 nvm->eetrack = (eetrack_hi << 16) | eetrack_lo; in ice_get_nvm_ver_info()
621 * ice_get_inactive_nvm_ver - Read Option ROM version from the inactive bank
622 * @hw: pointer to the HW structure
626 * inactive NVM bank. Used to access version data for a pending update that
635 * ice_get_orom_civd_data - Get the combo version information from Option ROM
636 * @hw: pointer to the HW struct
637 * @bank: whether to read from the active or inactive flash module
640 * Searches through the Option ROM flash contents to locate the CIVD data for
651 /* The CIVD section is located in the Option ROM aligned to 512 bytes. in ice_get_orom_civd_data()
657 * usually somewhere in the middle of the bank. We need to scan the in ice_get_orom_civd_data()
658 * Option ROM bank to locate it. in ice_get_orom_civd_data()
660 * It's significantly faster to read the entire Option ROM up front in ice_get_orom_civd_data()
661 * using the maximum page size, than to read each possible location in ice_get_orom_civd_data()
664 orom_data = vzalloc(hw->flash.banks.orom_size); in ice_get_orom_civd_data()
666 return -ENOMEM; in ice_get_orom_civd_data()
669 orom_data, hw->flash.banks.orom_size); in ice_get_orom_civd_data()
672 ice_debug(hw, ICE_DBG_NVM, "Unable to read Option ROM data\n"); in ice_get_orom_civd_data()
676 /* Scan the memory buffer to locate the CIVD data section */ in ice_get_orom_civd_data()
677 for (offset = 0; (offset + 512) <= hw->flash.banks.orom_size; offset += 512) { in ice_get_orom_civd_data()
684 if (memcmp("$CIV", tmp->signature, sizeof(tmp->signature)) != 0) in ice_get_orom_civd_data()
705 ice_debug(hw, ICE_DBG_NVM, "Unable to locate CIVD data within the Option ROM\n"); in ice_get_orom_civd_data()
709 return -EIO; in ice_get_orom_civd_data()
713 * ice_get_orom_ver_info - Read Option ROM version information
714 * @hw: pointer to the HW struct
715 * @bank: whether to read from the active or inactive flash module
716 * @orom: pointer to Option ROM info structure
718 * Read Option ROM version and security revision from the Option ROM flash
730 ice_debug(hw, ICE_DBG_NVM, "Failed to locate valid Option ROM CIVD data\n"); in ice_get_orom_ver_info()
736 orom->major = FIELD_GET(ICE_OROM_VER_MASK, combo_ver); in ice_get_orom_ver_info()
737 orom->patch = FIELD_GET(ICE_OROM_VER_PATCH_MASK, combo_ver); in ice_get_orom_ver_info()
738 orom->build = FIELD_GET(ICE_OROM_VER_BUILD_MASK, combo_ver); in ice_get_orom_ver_info()
744 * ice_get_inactive_orom_ver - Read Option ROM version from the inactive bank
745 * @hw: pointer to the HW structure
749 * section of flash. Used to access version data for a pending update that has
759 * @hw: pointer to the HW struct
760 * @bank: whether to read from the active or inactive flash bank
761 * @netlist: pointer to netlist version info structure
764 * Topology section to find the Netlist ID block and extract the relevant
782 return -EIO; in ice_get_netlist_info()
789 /* sanity check that we have at least enough words to store the netlist ID block */ in ice_get_netlist_info()
793 return -EIO; in ice_get_netlist_info()
803 return -ENOMEM; in ice_get_netlist_info()
805 /* Read out the entire Netlist ID Block at once. */ in ice_get_netlist_info()
815 netlist->major = id_blk[ICE_NETLIST_ID_BLK_MAJOR_VER_HIGH] << 16 | in ice_get_netlist_info()
817 netlist->minor = id_blk[ICE_NETLIST_ID_BLK_MINOR_VER_HIGH] << 16 | in ice_get_netlist_info()
819 netlist->type = id_blk[ICE_NETLIST_ID_BLK_TYPE_HIGH] << 16 | in ice_get_netlist_info()
821 netlist->rev = id_blk[ICE_NETLIST_ID_BLK_REV_HIGH] << 16 | in ice_get_netlist_info()
823 netlist->cust_ver = id_blk[ICE_NETLIST_ID_BLK_CUST_VER]; in ice_get_netlist_info()
824 /* Read the left most 4 bytes of SHA */ in ice_get_netlist_info()
825 netlist->hash = id_blk[ICE_NETLIST_ID_BLK_SHA_HASH_WORD(15)] << 16 | in ice_get_netlist_info()
836 * @hw: pointer to the HW struct
837 * @netlist: pointer to netlist version info structure
839 * Read the netlist version data from the inactive netlist bank. Used to
840 * extract version data of a pending flash update in order to display the
849 * ice_discover_flash_size - Discover the available flash size.
850 * @hw: pointer to the HW struct
852 * The device flash could be up to 16MB in size. However, it is possible that
853 * the actual size is smaller. Use bisection to determine the accessible size
865 while ((max_size - min_size) > 1) { in ice_discover_flash_size()
871 if (status == -EIO && in ice_discover_flash_size()
872 hw->adminq.sq_last_status == ICE_AQ_RC_EINVAL) { in ice_discover_flash_size()
889 hw->flash.flash_size = max_size; in ice_discover_flash_size()
898 * ice_read_sr_pointer - Read the value of a Shadow RAM pointer word
899 * @hw: pointer to the HW structure
900 * @offset: the word offset of the Shadow RAM word to read
901 * @pointer: pointer value read from Shadow RAM
903 * Read the given Shadow RAM word, and convert it to a pointer value specified
930 * ice_read_sr_area_size - Read an area size from a Shadow RAM word
931 * @hw: pointer to the HW structure
932 * @offset: the word offset of the Shadow RAM to read
933 * @size: size value read from the Shadow RAM
935 * Read the given Shadow RAM word, and convert it to an area size value
958 * ice_determine_active_flash_banks - Discover active bank for each module
959 * @hw: pointer to the HW struct
961 * Read the Shadow RAM control word and determine which banks are active for
962 * the NVM, OROM, and Netlist modules. Also read and calculate the associated
964 * structure for later use in order to calculate the correct offset to read
969 struct ice_bank_info *banks = &hw->flash.banks; in ice_determine_active_flash_banks()
975 ice_debug(hw, ICE_DBG_NVM, "Failed to read the Shadow RAM control word\n"); in ice_determine_active_flash_banks()
983 return -EIO; in ice_determine_active_flash_banks()
987 banks->nvm_bank = ICE_1ST_FLASH_BANK; in ice_determine_active_flash_banks()
989 banks->nvm_bank = ICE_2ND_FLASH_BANK; in ice_determine_active_flash_banks()
992 banks->orom_bank = ICE_1ST_FLASH_BANK; in ice_determine_active_flash_banks()
994 banks->orom_bank = ICE_2ND_FLASH_BANK; in ice_determine_active_flash_banks()
997 banks->netlist_bank = ICE_1ST_FLASH_BANK; in ice_determine_active_flash_banks()
999 banks->netlist_bank = ICE_2ND_FLASH_BANK; in ice_determine_active_flash_banks()
1001 status = ice_read_sr_pointer(hw, ICE_SR_1ST_NVM_BANK_PTR, &banks->nvm_ptr); in ice_determine_active_flash_banks()
1003 ice_debug(hw, ICE_DBG_NVM, "Failed to read NVM bank pointer\n"); in ice_determine_active_flash_banks()
1007 status = ice_read_sr_area_size(hw, ICE_SR_NVM_BANK_SIZE, &banks->nvm_size); in ice_determine_active_flash_banks()
1009 ice_debug(hw, ICE_DBG_NVM, "Failed to read NVM bank area size\n"); in ice_determine_active_flash_banks()
1013 status = ice_read_sr_pointer(hw, ICE_SR_1ST_OROM_BANK_PTR, &banks->orom_ptr); in ice_determine_active_flash_banks()
1015 ice_debug(hw, ICE_DBG_NVM, "Failed to read OROM bank pointer\n"); in ice_determine_active_flash_banks()
1019 status = ice_read_sr_area_size(hw, ICE_SR_OROM_BANK_SIZE, &banks->orom_size); in ice_determine_active_flash_banks()
1021 ice_debug(hw, ICE_DBG_NVM, "Failed to read OROM bank area size\n"); in ice_determine_active_flash_banks()
1025 status = ice_read_sr_pointer(hw, ICE_SR_NETLIST_BANK_PTR, &banks->netlist_ptr); in ice_determine_active_flash_banks()
1027 ice_debug(hw, ICE_DBG_NVM, "Failed to read Netlist bank pointer\n"); in ice_determine_active_flash_banks()
1031 status = ice_read_sr_area_size(hw, ICE_SR_NETLIST_BANK_SIZE, &banks->netlist_size); in ice_determine_active_flash_banks()
1033 ice_debug(hw, ICE_DBG_NVM, "Failed to read Netlist bank area size\n"); in ice_determine_active_flash_banks()
1041 * ice_get_nvm_css_hdr_len - Read the CSS header length from the NVM CSS header
1042 * @hw: pointer to the HW struct
1043 * @bank: whether to read from the active or inactive flash bank
1046 * Read the CSS header length from the NVM CSS header and add the Authentication
1047 * header size, and then convert to words.
1069 /* CSS header length is in DWORD, so convert to words and add in ice_get_nvm_css_hdr_len()
1079 * ice_determine_css_hdr_len - Discover CSS header length for the device
1080 * @hw: pointer to the HW struct
1090 struct ice_bank_info *banks = &hw->flash.banks; in ice_determine_css_hdr_len()
1094 &banks->active_css_hdr_len); in ice_determine_css_hdr_len()
1099 &banks->inactive_css_hdr_len); in ice_determine_css_hdr_len()
1107 * ice_init_nvm - initializes NVM setting
1108 * @hw: pointer to the HW struct
1115 struct ice_flash_info *flash = &hw->flash; in ice_init_nvm()
1126 /* Switching to words (sr_size contains power of 2) */ in ice_init_nvm()
1127 flash->sr_words = BIT(sr_size) * ICE_SR_WORDS_IN_1KB; in ice_init_nvm()
1132 flash->blank_nvm_mode = false; in ice_init_nvm()
1135 flash->blank_nvm_mode = true; in ice_init_nvm()
1137 return -EIO; in ice_init_nvm()
1142 ice_debug(hw, ICE_DBG_NVM, "NVM init error: failed to discover flash size.\n"); in ice_init_nvm()
1148 ice_debug(hw, ICE_DBG_NVM, "Failed to determine active flash banks.\n"); in ice_init_nvm()
1154 ice_debug(hw, ICE_DBG_NVM, "Failed to determine Shadow RAM copy offsets.\n"); in ice_init_nvm()
1158 status = ice_get_nvm_ver_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->nvm); in ice_init_nvm()
1160 ice_debug(hw, ICE_DBG_INIT, "Failed to read NVM info.\n"); in ice_init_nvm()
1164 status = ice_get_orom_ver_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->orom); in ice_init_nvm()
1166 ice_debug(hw, ICE_DBG_INIT, "Failed to read Option ROM info.\n"); in ice_init_nvm()
1168 /* read the netlist version information */ in ice_init_nvm()
1169 status = ice_get_netlist_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->netlist); in ice_init_nvm()
1171 ice_debug(hw, ICE_DBG_INIT, "Failed to read netlist info.\n"); in ice_init_nvm()
1178 * @hw: pointer to the HW struct
1195 cmd->flags = ICE_AQC_NVM_CHECKSUM_VERIFY; in ice_nvm_validate_checksum()
1201 if (le16_to_cpu(cmd->checksum) != ICE_AQC_NVM_CHECKSUM_CORRECT) in ice_nvm_validate_checksum()
1202 status = -EIO; in ice_nvm_validate_checksum()
1209 * @hw: pointer to the HW struct
1214 * and dumps the Shadow RAM to flash (0x0707)
1216 * cmd_flags controls which banks to activate, the preservation level to use
1236 cmd->cmd_flags = (u8)(cmd_flags & 0xFF); in ice_nvm_write_activate()
1237 cmd->offset_high = (u8)((cmd_flags >> 8) & 0xFF); in ice_nvm_write_activate()
1241 *response_flags = cmd->cmd_flags; in ice_nvm_write_activate()
1248 * @hw: pointer to the HW struct
1250 * Update empr (0x0709). This command allows SW to
1251 * request an EMPR to activate new FW.
1263 * @hw: pointer to the HW struct
1266 * If bit is set to 1, then buffer should be size 0.
1267 * @data: pointer to buffer
1269 * @cd: pointer to command details structure or NULL
1271 * Set package data (0x070A). This command is equivalent to the reception
1284 return -EINVAL; in ice_nvm_set_pkg_data()
1292 cmd->cmd_flags |= ICE_AQC_NVM_PKG_DELETE; in ice_nvm_set_pkg_data()
1298 * @hw: pointer to the HW struct
1299 * @data: pointer to buffer
1302 * @comp_response: a pointer to the response from the 0x070B AQC.
1303 * @comp_response_code: a pointer to the response code from the 0x070B AQC.
1304 * @cd: pointer to command details structure or NULL
1306 * Pass component table (0x070B). This command is equivalent to the reception
1309 * actual update. FW will assume these commands are going to be sent until
1310 * the TransferFlag is set to End or StartAndEnd.
1323 return -EINVAL; in ice_nvm_pass_component_tbl()
1331 cmd->transfer_flag = transfer_flag; in ice_nvm_pass_component_tbl()
1335 *comp_response = cmd->component_response; in ice_nvm_pass_component_tbl()
1336 *comp_response_code = cmd->component_response_code; in ice_nvm_pass_component_tbl()