Lines Matching +full:ram +full:- +full:code
1 /* SPDX-License-Identifier: BSD-3-Clause */
8 * 1. Redistributions of source code must retain the above copyright notice,
44 * @read_shadow_ram: tell if this is a shadow RAM read
67 cmd->cmd_flags |= ICE_AQC_NVM_FLASH_ONLY;
71 cmd->cmd_flags |= ICE_AQC_NVM_LAST_CMD;
72 cmd->module_typeid = CPU_TO_LE16(module_typeid);
73 cmd->offset_low = CPU_TO_LE16(offset & 0xFFFF);
74 cmd->offset_high = (offset >> 16) & 0xFF;
75 cmd->length = CPU_TO_LE16(length);
81 * ice_read_flat_nvm - Read portion of NVM by flat offset
86 * @read_shadow_ram: if true, read from shadow RAM instead of NVM
89 * breaks read requests across Shadow RAM sectors and ensures that no single
92 * Returns a status code on failure. Note that the data pointer may be
108 /* Verify the length of the read if this is for the Shadow RAM */
109 if (read_shadow_ram && ((offset + inlen) > (hw->flash.sr_words * 2u))) {
110 ice_debug(hw, ICE_DBG_NVM, "NVM error: requested data is beyond Shadow RAM limit\n");
118 * Additionally, a read from the Shadow RAM may not cross over
123 read_size = MIN_T(u32, ICE_AQ_MAX_BUF_LEN - sector_offset,
124 inlen - bytes_read);
178 cmd->cmd_flags |= command_flags;
182 cmd->cmd_flags |= ICE_AQC_NVM_LAST_CMD;
183 cmd->module_typeid = CPU_TO_LE16(module_typeid);
184 cmd->offset_low = CPU_TO_LE16(offset & 0xFFFF);
185 cmd->offset_high = (offset >> 16) & 0xFF;
186 cmd->length = CPU_TO_LE16(length);
222 cmd->module_typeid = CPU_TO_LE16(module_typeid);
223 cmd->length = len;
224 cmd->offset_low = 0;
225 cmd->offset_high = 0;
231 * ice_aq_read_nvm_cfg - read an NVM config block
256 cmd->cmd_flags = cmd_flags;
257 cmd->id = CPU_TO_LE16(field_id);
261 *elem_count = LE16_TO_CPU(cmd->count);
267 * ice_aq_write_nvm_cfg - write an NVM config block
291 cmd->count = CPU_TO_LE16(elem_count);
292 cmd->cmd_flags = cmd_flags;
298 * ice_check_sr_access_params - verify params for Shadow RAM R/W operations
306 if ((offset + words) > hw->flash.sr_words) {
318 if (((offset + (words - 1)) / ICE_SR_SECTOR_SIZE_IN_WORDS) !=
329 * ice_read_sr_word_aq - Reads Shadow RAM via AQ
331 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
332 * @data: word read from the Shadow RAM
334 * Reads one 16 bit word from the Shadow RAM using ice_read_flat_nvm.
345 * RAM size, and ensures we don't read across a Shadow RAM sector
358 * ice_write_sr_aq - Writes Shadow RAM
362 * @data: buffer with words to write to the Shadow RAM
365 * Writes a 16 bit words buffer to the Shadow RAM using the admin command.
384 * ice_read_sr_buf_aq - Reads Shadow RAM buf via AQ
386 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
388 * @data: words read from the Shadow RAM
390 * Reads 16 bit words (data buf) from the Shadow RAM. Ownership of the NVM is
401 /* ice_read_flat_nvm takes into account the 4KB AdminQ and Shadow RAM
417 * ice_acquire_nvm - Generic request for acquiring the NVM ownership
426 if (hw->flash.blank_nvm_mode)
433 * ice_release_nvm - Generic request for releasing the NVM ownership
442 if (hw->flash.blank_nvm_mode)
449 * ice_get_flash_bank_offset - Get offset into requested flash bank
462 struct ice_bank_info *banks = &hw->flash.banks;
469 offset = banks->nvm_ptr;
470 size = banks->nvm_size;
471 active_bank = banks->nvm_bank;
474 offset = banks->orom_ptr;
475 size = banks->orom_size;
476 active_bank = banks->orom_bank;
479 offset = banks->netlist_ptr;
480 size = banks->netlist_size;
481 active_bank = banks->netlist_bank;
517 * ice_read_flash_module - Read a word from one of the main NVM modules
530 * hw->flash.banks data being setup by ice_determine_active_flash_banks()
561 * ice_read_nvm_module - Read from the active main NVM module
585 * ice_get_nvm_css_hdr_len - Read the CSS header length from the NVM CSS header
621 * ice_read_nvm_sr_copy - Read a word from the Shadow RAM copy in the NVM bank
624 * @offset: offset into the Shadow RAM copy to read, in words
627 * Read the specified word from the copy of the Shadow RAM found in the
646 * ice_read_orom_module - Read from the active Option ROM module
671 * ice_read_netlist_module - Read data from the netlist module area
694 * ice_read_sr_word - Reads Shadow RAM word and acquire NVM if necessary
696 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
697 * @data: word read from the Shadow RAM
699 * Reads one 16 bit word from the Shadow RAM using the ice_read_sr_word_aq.
717 * ice_get_pfa_module_tlv - Reads sub module TLV from NVM PFA
745 if (check_add_overflow(pfa_ptr, (u16)(pfa_len - 1), &max_tlv)) {
746 ice_debug(hw, ICE_DBG_INIT, "PFA starts at offset %u. PFA length of %u caused 16-bit arithmetic overflow.\n",
788 ice_debug(hw, ICE_DBG_INIT, "TLV of type %u and length 0x%04x caused 16-bit arithmetic overflow. The PFA starts at 0x%04x and has length of 0x%04x\n",
798 * ice_read_pba_string - Reads part number string from NVM
834 pba_size--;
856 * ice_get_nvm_srev - Read the security revision from the NVM CSS header
883 * ice_get_nvm_ver_info - Read NVM version information
903 nvm->major = (ver & ICE_NVM_VER_HI_MASK) >> ICE_NVM_VER_HI_SHIFT;
904 nvm->minor = (ver & ICE_NVM_VER_LO_MASK) >> ICE_NVM_VER_LO_SHIFT;
917 nvm->eetrack = (eetrack_hi << 16) | eetrack_lo;
919 status = ice_get_nvm_srev(hw, bank, &nvm->srev);
927 * ice_get_inactive_nvm_ver - Read Option ROM version from the inactive bank
941 * ice_get_orom_srev - Read the security revision from the OROM CSS header
951 u32 orom_size_word = hw->flash.banks.orom_size / 2;
963 hw->flash.banks.orom_size);
970 css_start = orom_size_word - hdr_len;
985 * ice_get_orom_civd_data - Get the combo version information from Option ROM
1014 for (offset = 0; (offset + 512) <= hw->flash.banks.orom_size; offset += 512) {
1063 * ice_get_orom_ver_info - Read Option ROM version information
1086 orom->major = (u8)((combo_ver & ICE_OROM_VER_MASK) >> ICE_OROM_VER_SHIFT);
1087 orom->patch = (u8)(combo_ver & ICE_OROM_VER_PATCH_MASK);
1088 orom->build = (u16)((combo_ver & ICE_OROM_VER_BUILD_MASK) >> ICE_OROM_VER_BUILD_SHIFT);
1090 status = ice_get_orom_srev(hw, bank, &orom->srev);
1100 * ice_get_inactive_orom_ver - Read Option ROM version from the inactive bank
1171 netlist->major = id_blk[ICE_NETLIST_ID_BLK_MAJOR_VER_HIGH] << 16 |
1173 netlist->minor = id_blk[ICE_NETLIST_ID_BLK_MINOR_VER_HIGH] << 16 |
1175 netlist->type = id_blk[ICE_NETLIST_ID_BLK_TYPE_HIGH] << 16 |
1177 netlist->rev = id_blk[ICE_NETLIST_ID_BLK_REV_HIGH] << 16 |
1179 netlist->cust_ver = id_blk[ICE_NETLIST_ID_BLK_CUST_VER];
1181 netlist->hash = id_blk[ICE_NETLIST_ID_BLK_SHA_HASH_WORD(15)] << 16 |
1217 * ice_discover_flash_size - Discover the available flash size
1235 while ((max_size - min_size) > 1) {
1242 hw->adminq.sq_last_status == ICE_AQ_RC_EINVAL) {
1259 hw->flash.flash_size = max_size;
1268 * ice_read_sr_pointer - Read the value of a Shadow RAM pointer word
1270 * @offset: the word offset of the Shadow RAM word to read
1271 * @pointer: pointer value read from Shadow RAM
1273 * Read the given Shadow RAM word, and convert it to a pointer value specified
1300 * ice_read_sr_area_size - Read an area size from a Shadow RAM word
1302 * @offset: the word offset of the Shadow RAM to read
1303 * @size: size value read from the Shadow RAM
1305 * Read the given Shadow RAM word, and convert it to an area size value
1328 * ice_determine_active_flash_banks - Discover active bank for each module
1331 * Read the Shadow RAM control word and determine which banks are active for
1339 struct ice_bank_info *banks = &hw->flash.banks;
1345 ice_debug(hw, ICE_DBG_NVM, "Failed to read the Shadow RAM control word\n");
1351 ice_debug(hw, ICE_DBG_NVM, "Shadow RAM control word is invalid\n");
1356 banks->nvm_bank = ICE_1ST_FLASH_BANK;
1358 banks->nvm_bank = ICE_2ND_FLASH_BANK;
1361 banks->orom_bank = ICE_1ST_FLASH_BANK;
1363 banks->orom_bank = ICE_2ND_FLASH_BANK;
1366 banks->netlist_bank = ICE_1ST_FLASH_BANK;
1368 banks->netlist_bank = ICE_2ND_FLASH_BANK;
1370 status = ice_read_sr_pointer(hw, ICE_SR_1ST_NVM_BANK_PTR, &banks->nvm_ptr);
1376 status = ice_read_sr_area_size(hw, ICE_SR_NVM_BANK_SIZE, &banks->nvm_size);
1382 status = ice_read_sr_pointer(hw, ICE_SR_1ST_OROM_BANK_PTR, &banks->orom_ptr);
1388 status = ice_read_sr_area_size(hw, ICE_SR_OROM_BANK_SIZE, &banks->orom_size);
1394 status = ice_read_sr_pointer(hw, ICE_SR_NETLIST_BANK_PTR, &banks->netlist_ptr);
1400 status = ice_read_sr_area_size(hw, ICE_SR_NETLIST_BANK_SIZE, &banks->netlist_size);
1410 * ice_init_nvm - initializes NVM setting
1413 * This function reads and populates NVM settings such as Shadow RAM size,
1418 struct ice_flash_info *flash = &hw->flash;
1432 flash->sr_words = BIT(sr_size) * ICE_SR_WORDS_IN_1KB;
1437 flash->blank_nvm_mode = false;
1440 flash->blank_nvm_mode = true;
1457 status = ice_get_nvm_ver_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->nvm);
1463 status = ice_get_orom_ver_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->orom);
1468 status = ice_get_netlist_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->netlist);
1476 * ice_read_sr_buf - Reads Shadow RAM buf and acquire lock if necessary
1478 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
1480 * @data: words read from the Shadow RAM
1501 * __ice_write_sr_word - Writes Shadow RAM word
1503 * @offset: offset of the Shadow RAM word to write
1504 * @data: word to write to the Shadow RAM
1523 * __ice_write_sr_buf - Writes Shadow RAM buf
1525 * @offset: offset of the Shadow RAM buffer to write
1527 * @data: words to write to the Shadow RAM
1529 * Writes a 16 bit words buffer to the Shadow RAM using the admin command.
1553 * mirrored in the Shadow RAM is always less than 4K.
1563 * ice_calc_sr_checksum - Calculates and returns Shadow RAM SW checksum
1567 * This function calculates SW Checksum that covers the whole 64kB shadow RAM
1568 * except the VPD and PCIe ALT Auto-load modules. The structure and size of VPD
1594 /* read pointer to PCIe Alt Auto-load module */
1600 /* Calculate SW checksum that covers the whole 64kB shadow RAM
1601 * except the VPD and PCIe ALT Auto-load modules
1603 for (i = 0; i < hw->flash.sr_words; i++) {
1628 *checksum = (u16)ICE_SR_SW_CHECKSUM_BASE - checksum_local;
1636 * ice_update_sr_checksum - Updates the Shadow RAM SW checksum
1661 * ice_validate_sr_checksum - Validate Shadow RAM SW checksum
1665 * Performs checksum calculation and validates the Shadow RAM SW checksum.
1720 cmd->flags = ICE_AQC_NVM_CHECKSUM_VERIFY;
1726 if (LE16_TO_CPU(cmd->checksum) != ICE_AQC_NVM_CHECKSUM_CORRECT)
1751 cmd->flags = ICE_AQC_NVM_CHECKSUM_RECALC;
1767 * and dumps the Shadow RAM to flash (0x0707)
1789 cmd->cmd_flags = (u8)(cmd_flags & 0xFF);
1790 cmd->offset_high = (u8)((cmd_flags >> 8) & 0xFF);
1794 *response_flags = cmd->cmd_flags;
1800 * ice_get_nvm_minsrevs - Get the Minimum Security Revision values from flash
1837 minsrevs->nvm = minsrev_h << 16 | minsrev_l;
1838 minsrevs->nvm_valid = true;
1848 minsrevs->orom = minsrev_h << 16 | minsrev_l;
1849 minsrevs->orom_valid = true;
1856 * ice_update_nvm_minsrevs - Update minimum security revision TLV data in flash
1861 * area of the flash. Reads the minsrevs->nvm_valid and minsrevs->orom_valid
1873 if (!minsrevs->nvm_valid && !minsrevs->orom_valid) {
1888 if (minsrevs->nvm_valid) {
1889 data.nvm_minsrev_l = CPU_TO_LE16(minsrevs->nvm & 0xFFFF);
1890 data.nvm_minsrev_h = CPU_TO_LE16(minsrevs->nvm >> 16);
1894 if (minsrevs->orom_valid) {
1895 data.orom_minsrev_l = CPU_TO_LE16(minsrevs->orom & 0xFFFF);
1896 data.orom_minsrev_h = CPU_TO_LE16(minsrevs->orom >> 16);
1906 /* Dump the Shadow RAM to the flash */
1916 * ice_nvm_access_get_features - Return the NVM access features structure
1932 if (cmd->data_size < sizeof(struct ice_nvm_features))
1936 ice_memset(data, 0, cmd->data_size, ICE_NONDMA_MEM);
1939 data->drv_features.major = ICE_NVM_ACCESS_MAJOR_VER;
1940 data->drv_features.minor = ICE_NVM_ACCESS_MINOR_VER;
1941 data->drv_features.size = sizeof(struct ice_nvm_features);
1942 data->drv_features.features[0] = ICE_NVM_FEATURES_0_REG_ACCESS;
1948 * ice_nvm_access_get_module - Helper function to read module value
1955 return ((cmd->config & ICE_NVM_CFG_MODULE_M) >> ICE_NVM_CFG_MODULE_S);
1959 * ice_nvm_access_get_flags - Helper function to read flags value
1966 return ((cmd->config & ICE_NVM_CFG_FLAGS_M) >> ICE_NVM_CFG_FLAGS_S);
1970 * ice_nvm_access_get_adapter - Helper function to read adapter info
1977 return ((cmd->config & ICE_NVM_CFG_ADAPTER_INFO_M) >>
1982 * ice_validate_nvm_rw_reg - Check than an NVM access request is valid
1997 offset = cmd->offset;
2002 cmd->data_size != FIELD_SIZEOF(union ice_nvm_access_data, regval))
2035 * ice_nvm_access_read - Handle an NVM read request
2051 ice_memset(data, 0, cmd->data_size, ICE_NONDMA_MEM);
2059 cmd->offset);
2062 data->regval = rd32(hw, cmd->offset);
2068 * ice_nvm_access_write - Handle an NVM write request
2088 /* Reject requests to write to read-only registers */
2089 if (hw->mac_type == ICE_MAC_E830) {
2090 if (cmd->offset == E830_GL_HICR_EN)
2093 if (cmd->offset == GL_HICR_EN)
2097 if (cmd->offset == GLGEN_RSTAT)
2101 cmd->offset, data->regval);
2104 wr32(hw, cmd->offset, data->regval);
2110 * ice_handle_nvm_access - Handle an NVM access request
2131 if ((cmd->config & ICE_NVM_CFG_EXT_FLAGS_M) != 0)
2136 if (adapter_info != hw->device_id)
2139 switch (cmd->command) {
2150 cmd->offset == 0)
2162 * ice_nvm_sanitize_operate - Clear the user data
2167 * Return: the exit code of the operation.
2192 * ice_nvm_sanitize - Sanitize NVM
2199 * Return: the exit code of the operation.
2209 cmd->cmd_flags = cmd_flags;
2213 *values = cmd->values;