Lines Matching +full:read +full:- +full:to +full:- +full:read
1 /* SPDX-License-Identifier: BSD-3-Clause */
16 * contributors may be used to endorse or promote products derived from
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38 * @hw: pointer to the HW struct
41 * @length: length of the section to be read (in bytes from the offset)
44 * @read_shadow_ram: tell if this is a shadow RAM read
45 * @cd: pointer to command details structure or NULL
47 * Read the NVM using the admin queue commands (0x0701)
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
82 * @hw: pointer to the HW struct
84 * @length: (in) number of bytes to read; (out) number of bytes actually read
85 * @data: buffer to return data in (sized to fit the specified length)
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
90 * read request exceeds the maximum 4KB read for a single AdminQ command.
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))) {
117 /* ice_aq_read_nvm cannot read more than 4KB at a time.
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);
149 * @hw: pointer to the HW struct
152 * @length: length of the section to be written (in bytes from the offset)
156 * @cd: pointer to command details structure or NULL
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);
195 * @hw: pointer to the HW struct
197 * @cd: pointer to command details structure or NULL
210 /* read a length value from SR, so module_typeid is equal to 0 */
211 /* calculate offset where module size is placed from bytes to words */
212 /* set last command and read from SR values to true */
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
232 * @hw: pointer to the HW struct
237 * @elem_count: pointer to count of elements read by FW
238 * @cd: pointer to command details structure or NULL
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
268 * @hw: pointer to the HW struct
272 * @elem_count: count of elements to be written
273 * @cd: pointer to command details structure or NULL
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
299 * @hw: pointer to the HW structure
301 * @words: number of words to access
306 if ((offset + words) > hw->flash.sr_words) {
312 /* We can access only up to 4KB (one sector), in one AQ write */
313 ice_debug(hw, ICE_DBG_NVM, "NVM error: tried to access %d words, limit is %d.\n",
318 if (((offset + (words - 1)) / ICE_SR_SECTOR_SIZE_IN_WORDS) !=
329 * ice_read_sr_word_aq - Reads Shadow RAM via AQ
330 * @hw: pointer to the HW structure
331 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
332 * @data: word read from the Shadow RAM
344 /* Note that ice_read_flat_nvm checks if the read is past the Shadow
345 * RAM size, and ensures we don't read across a Shadow RAM sector
358 * ice_write_sr_aq - Writes Shadow RAM
359 * @hw: pointer to the HW structure
361 * @words: number of words to write
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
385 * @hw: pointer to the HW structure
386 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
387 * @words: (in) number of words to read; (out) number of words actually read
388 * @data: words read from the Shadow RAM
406 /* Report the number of words successfully read */
409 /* Byte swap the words up to the amount we actually read */
417 * ice_acquire_nvm - Generic request for acquiring the NVM ownership
418 * @hw: pointer to the HW structure
419 * @access: NVM access type (read or write)
426 if (hw->flash.blank_nvm_mode)
433 * ice_release_nvm - Generic request for releasing the NVM ownership
434 * @hw: pointer to the HW structure
442 if (hw->flash.blank_nvm_mode)
449 * ice_get_flash_bank_offset - Get offset into requested flash bank
450 * @hw: pointer to the HW structure
451 * @bank: whether to read from the active or inactive flash bank
452 * @module: the module to read from
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
518 * @hw: pointer to the HW structure
519 * @bank: which bank of the module to read
520 * @module: the module to read
522 * @data: storage for the word read from the flash
523 * @length: bytes of data to read
525 * Read data from the specified flash module. The bank parameter indicates
526 * whether or not to read from the active bank or the inactive bank of that
529 * The word will be read using flat NVM access, and relies on the
530 * hw->flash.banks data being setup by ice_determine_active_flash_banks()
544 ice_debug(hw, ICE_DBG_NVM, "Unable to calculate flash bank offset for module 0x%04x\n",
561 * ice_read_nvm_module - Read from the active main NVM module
562 * @hw: pointer to the HW structure
563 * @bank: whether to read from active or inactive NVM module
564 * @offset: offset into the NVM module to read, in words
567 * Read the specified word from the active NVM module. This includes the CSS
585 * ice_get_nvm_css_hdr_len - Read the CSS header length from the NVM CSS header
586 * @hw: pointer to the HW struct
587 * @bank: whether to read from the active or inactive flash bank
590 * Read the CSS header length from the NVM CSS header and add the Authentication
591 * header size, and then convert to words.
611 /* CSS header length is in DWORD, so convert to words and add
621 * ice_read_nvm_sr_copy - Read a word from the Shadow RAM copy in the NVM bank
622 * @hw: pointer to the HW structure
623 * @bank: whether to read from the active or inactive NVM module
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
647 * @hw: pointer to the HW structure
648 * @bank: whether to read from active or inactive OROM module
649 * @offset: offset into the OROM module to read, in words
652 * Read the specified word from the active Option ROM module of the flash.
671 * ice_read_netlist_module - Read data from the netlist module area
672 * @hw: pointer to the HW structure
673 * @bank: whether to read from the active or inactive module
674 * @offset: offset into the netlist to read from
677 * Read a word from the specified netlist bank.
694 * ice_read_sr_word - Reads Shadow RAM word and acquire NVM if necessary
695 * @hw: pointer to the HW structure
696 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
697 * @data: word read from the Shadow RAM
717 * ice_get_pfa_module_tlv - Reads sub module TLV from NVM PFA
718 * @hw: pointer to hardware structure
719 * @module_tlv: pointer to module TLV to return
720 * @module_tlv_len: pointer to module TLV length to return
725 * use these to read the variable length TLV value.
741 ice_debug(hw, ICE_DBG_INIT, "Failed to read PFA length.\n");
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",
757 * of TLVs to find the requested one.
764 /* Read TLV type */
768 ice_debug(hw, ICE_DBG_INIT, "Failed to read TLV type.\n");
771 /* Read TLV length */
774 ice_debug(hw, ICE_DBG_INIT, "Failed to read TLV length.\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
799 * @hw: pointer to hardware structure
815 ice_debug(hw, ICE_DBG_INIT, "Failed to read PBA Block TLV.\n");
822 ice_debug(hw, ICE_DBG_INIT, "Failed to read PBA Section size.\n");
831 /* Subtract one to get PBA word count (PBA Size word is included in
834 pba_size--;
843 ice_debug(hw, ICE_DBG_INIT, "Failed to read PBA Block word %d.\n", i);
856 * ice_get_nvm_srev - Read the security revision from the NVM CSS header
857 * @hw: pointer to the HW struct
858 * @bank: whether to read from the active or inactive flash bank
861 * Read the security revision out of the CSS header of the active NVM module
883 * ice_get_nvm_ver_info - Read NVM version information
884 * @hw: pointer to the HW struct
885 * @bank: whether to read from the active or inactive flash bank
886 * @nvm: pointer to NVM info structure
888 * Read the NVM EETRACK ID and map version of the main NVM image bank, filling
899 ice_debug(hw, ICE_DBG_NVM, "Failed to read DEV starter version.\n");
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;
908 ice_debug(hw, ICE_DBG_NVM, "Failed to read EETRACK lo.\n");
913 ice_debug(hw, ICE_DBG_NVM, "Failed to read EETRACK hi.\n");
917 nvm->eetrack = (eetrack_hi << 16) | eetrack_lo;
919 status = ice_get_nvm_srev(hw, bank, &nvm->srev);
921 ice_debug(hw, ICE_DBG_NVM, "Failed to read NVM security revision.\n");
927 * ice_get_inactive_nvm_ver - Read Option ROM version from the inactive bank
928 * @hw: pointer to the HW structure
932 * inactive NVM bank. Used to access version data for a pending update that
941 * ice_get_orom_srev - Read the security revision from the OROM CSS header
942 * @hw: pointer to the HW struct
943 * @bank: whether to read from active or inactive flash module
946 * Read the security revision out of the CSS header of the active OROM module
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
986 * @hw: pointer to the HW struct
987 * @bank: whether to read from the active or inactive flash module
990 * Searches through the Option ROM flash contents to locate the CIVD data for
1002 /* The CIVD section is located in the Option ROM aligned to 512 bytes.
1008 * usually somewhere in the middle of the bank. We need to scan the
1009 * Option ROM bank to locate it.
1013 /* Scan the memory buffer to locate the CIVD data section */
1014 for (offset = 0; (offset + 512) <= hw->flash.banks.orom_size; offset += 512) {
1020 ice_debug(hw, ICE_DBG_NVM, "Unable to read Option ROM data\n");
1035 ice_debug(hw, ICE_DBG_NVM, "Unable to read CIVD data\n");
1056 ice_debug(hw, ICE_DBG_NVM, "Unable to locate CIVD data within the Option ROM\n");
1063 * ice_get_orom_ver_info - Read Option ROM version information
1064 * @hw: pointer to the HW struct
1065 * @bank: whether to read from the active or inactive flash module
1066 * @orom: pointer to Option ROM info structure
1068 * Read Option ROM version and security revision from the Option ROM flash
1080 ice_debug(hw, ICE_DBG_NVM, "Failed to locate valid Option ROM CIVD data\n");
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);
1092 ice_debug(hw, ICE_DBG_NVM, "Failed to read Option ROM security revision.\n");
1100 * ice_get_inactive_orom_ver - Read Option ROM version from the inactive bank
1101 * @hw: pointer to the HW structure
1105 * section of flash. Used to access version data for a pending update that has
1115 * @hw: pointer to the HW struct
1116 * @bank: whether to read from the active or inactive flash bank
1117 * @netlist: pointer to netlist version info structure
1120 * Topology section to find the Netlist ID block and extract the relevant
1145 /* sanity check that we have at least enough words to store the netlist ID block */
1161 /* Read out the entire Netlist ID Block at once. */
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];
1180 /* Read the left most 4 bytes of SHA */
1181 netlist->hash = id_blk[ICE_NETLIST_ID_BLK_SHA_HASH_WORD(15)] << 16 |
1192 * @hw: pointer to the HW struct
1193 * @netlist: pointer to netlist version info structure
1204 * @hw: pointer to the HW struct
1205 * @netlist: pointer to netlist version info structure
1207 * Read the netlist version data from the inactive netlist bank. Used to
1208 * extract version data of a pending flash update in order to display the
1217 * ice_discover_flash_size - Discover the available flash size
1218 * @hw: pointer to the HW struct
1220 * The device flash could be up to 16MB in size. However, it is possible that
1221 * the actual size is smaller. Use bisection to determine the accessible 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
1269 * @hw: pointer to the HW structure
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
1301 * @hw: pointer to the HW structure
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
1329 * @hw: pointer to the HW struct
1331 * Read the Shadow RAM control word and determine which banks are active for
1332 * the NVM, OROM, and Netlist modules. Also read and calculate the associated
1334 * structure for later use in order to calculate the correct offset to read
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");
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);
1372 ice_debug(hw, ICE_DBG_NVM, "Failed to read NVM bank pointer\n");
1376 status = ice_read_sr_area_size(hw, ICE_SR_NVM_BANK_SIZE, &banks->nvm_size);
1378 ice_debug(hw, ICE_DBG_NVM, "Failed to read NVM bank area size\n");
1382 status = ice_read_sr_pointer(hw, ICE_SR_1ST_OROM_BANK_PTR, &banks->orom_ptr);
1384 ice_debug(hw, ICE_DBG_NVM, "Failed to read OROM bank pointer\n");
1388 status = ice_read_sr_area_size(hw, ICE_SR_OROM_BANK_SIZE, &banks->orom_size);
1390 ice_debug(hw, ICE_DBG_NVM, "Failed to read OROM bank area size\n");
1394 status = ice_read_sr_pointer(hw, ICE_SR_NETLIST_BANK_PTR, &banks->netlist_ptr);
1396 ice_debug(hw, ICE_DBG_NVM, "Failed to read Netlist bank pointer\n");
1400 status = ice_read_sr_area_size(hw, ICE_SR_NETLIST_BANK_SIZE, &banks->netlist_size);
1402 ice_debug(hw, ICE_DBG_NVM, "Failed to read Netlist bank area size\n");
1410 * ice_init_nvm - initializes NVM setting
1411 * @hw: pointer to the HW struct
1418 struct ice_flash_info *flash = &hw->flash;
1431 /* Switching to words (sr_size contains power of 2) */
1432 flash->sr_words = BIT(sr_size) * ICE_SR_WORDS_IN_1KB;
1437 flash->blank_nvm_mode = false;
1440 flash->blank_nvm_mode = true;
1447 ice_debug(hw, ICE_DBG_NVM, "NVM init error: failed to discover flash size.\n");
1453 ice_debug(hw, ICE_DBG_NVM, "Failed to determine active flash banks.\n");
1457 status = ice_get_nvm_ver_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->nvm);
1459 ice_debug(hw, ICE_DBG_INIT, "Failed to read NVM info.\n");
1463 status = ice_get_orom_ver_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->orom);
1465 ice_debug(hw, ICE_DBG_INIT, "Failed to read Option ROM info.\n");
1467 /* read the netlist version information */
1468 status = ice_get_netlist_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->netlist);
1470 ice_debug(hw, ICE_DBG_INIT, "Failed to read netlist info.\n");
1476 * ice_read_sr_buf - Reads Shadow RAM buf and acquire lock if necessary
1477 * @hw: pointer to the HW structure
1478 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
1479 * @words: (in) number of words to read; (out) number of words actually read
1480 * @data: words read from the Shadow RAM
1483 * method. The buf read is preceded by the NVM ownership take
1501 * __ice_write_sr_word - Writes Shadow RAM word
1502 * @hw: pointer to the HW structure
1503 * @offset: offset of the Shadow RAM word to write
1504 * @data: word to write to the Shadow RAM
1506 * Writes a 16 bit word to the SR using the ice_write_sr_aq method.
1507 * NVM ownership have to be acquired and released (on ARQ completion event
1508 * reception) by caller. To commit SR to NVM update checksum function
1523 * __ice_write_sr_buf - Writes Shadow RAM buf
1524 * @hw: pointer to the HW structure
1525 * @offset: offset of the Shadow RAM buffer to write
1526 * @words: number of words 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.
1531 * on ARQ completion event reception by caller. To commit SR to NVM update
1563 * ice_calc_sr_checksum - Calculates and returns Shadow RAM SW checksum
1564 * @hw: pointer to hardware structure
1565 * @checksum: pointer to the checksum
1568 * except the VPD and PCIe ALT Auto-load modules. The structure and size of VPD
1589 /* read pointer to VPD area */
1594 /* read pointer to PCIe Alt Auto-load module */
1601 * except the VPD and PCIe ALT Auto-load modules
1603 for (i = 0; i < hw->flash.sr_words; i++) {
1604 /* Read SR page */
1616 /* Skip VPD module (convert byte size to word count) */
1620 /* Skip PCIe ALT module (convert byte size to word count) */
1628 *checksum = (u16)ICE_SR_SW_CHECKSUM_BASE - checksum_local;
1636 * ice_update_sr_checksum - Updates the Shadow RAM SW checksum
1637 * @hw: pointer to hardware structure
1641 * This function will commit SR to NVM.
1661 * ice_validate_sr_checksum - Validate Shadow RAM SW checksum
1662 * @hw: pointer to hardware structure
1688 /* Verify read checksum from EEPROM is the same as
1703 * @hw: pointer to the HW struct
1720 cmd->flags = ICE_AQC_NVM_CHECKSUM_VERIFY;
1726 if (LE16_TO_CPU(cmd->checksum) != ICE_AQC_NVM_CHECKSUM_CORRECT)
1734 * @hw: pointer to the HW struct
1751 cmd->flags = ICE_AQC_NVM_CHECKSUM_RECALC;
1762 * @hw: pointer to the HW struct
1767 * and dumps the Shadow RAM to flash (0x0707)
1769 * cmd_flags controls which banks to activate, the preservation level to use
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
1801 * @hw: pointer to the HW struct
1802 * @minsrevs: structure to store NVM and OROM minsrev values
1804 * Read the Minimum Security Revision TLV and extract the revision values from
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
1857 * @hw: pointer to the HW struct
1861 * area of the flash. Reads the minsrevs->nvm_valid and minsrevs->orom_valid
1862 * fields to determine what update is being requested. If the valid bit is not
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
1917 * @cmd: NVM access command to process
1929 * error, to allow future extensions to the features structure to
1932 if (cmd->data_size < sizeof(struct ice_nvm_features))
1935 /* Initialize the data buffer to zeros */
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
1973 * Read the adapter info value out of the NVM access config field.
1977 return ((cmd->config & ICE_NVM_CFG_ADAPTER_INFO_M) >>
1982 * ice_validate_nvm_rw_reg - Check than an NVM access request is valid
1985 * Validates that an NVM access structure is request to read or write a valid
1997 offset = cmd->offset;
1999 /* Make sure the module and flags indicate a read/write request */
2002 cmd->data_size != FIELD_SIZEOF(union ice_nvm_access_data, regval))
2007 case GL_HICR_EN: /* Note, this register is read only */
2035 * ice_nvm_access_read - Handle an NVM read request
2036 * @hw: pointer to the HW struct
2037 * @cmd: NVM access command to process
2038 * @data: storage for the register value read
2040 * Process an NVM access request to read a register.
2051 ice_memset(data, 0, cmd->data_size, ICE_NONDMA_MEM);
2053 /* Make sure this is a valid read/write access request */
2059 cmd->offset);
2061 /* Read the register and store the contents in the data field */
2062 data->regval = rd32(hw, cmd->offset);
2068 * ice_nvm_access_write - Handle an NVM write request
2069 * @hw: pointer to the HW struct
2070 * @cmd: NVM access command to process
2071 * @data: NVM access data to write
2073 * Process an NVM access request to write a register.
2083 /* Make sure this is a valid read/write access 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);
2103 /* Write the data field to the specified register */
2104 wr32(hw, cmd->offset, data->regval);
2110 * ice_handle_nvm_access - Handle an NVM access request
2111 * @hw: pointer to the HW struct
2113 * @data: pointer to read or return data
2115 * Process an NVM access request. Read the command structure information and
2131 if ((cmd->config & ICE_NVM_CFG_EXT_FLAGS_M) != 0)
2136 if (adapter_info != hw->device_id)
2139 switch (cmd->command) {
2145 * command type as reading a register. Read the config field
2146 * to determine if this is a request to get features.
2150 cmd->offset == 0)
2162 * ice_nvm_sanitize_operate - Clear the user data
2163 * @hw: pointer to the HW struct
2192 * ice_nvm_sanitize - Sanitize NVM
2193 * @hw: pointer to the HW struct
2194 * @cmd_flags: flag to the ACI command
2209 cmd->cmd_flags = cmd_flags;
2213 *values = cmd->values;