drivers/net/ethernet/intel/i40e/i40e_nvm.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/i40e/i40e_nvm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/i40e/i40e_nvm.c- Extension
.c- Size
- 46367 bytes
- Lines
- 1640
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/delay.hi40e_alloc.hi40e_prototype.h
Detected Declarations
function herefunction i40e_acquire_nvmfunction i40e_release_nvmfunction i40e_poll_sr_srctl_done_bitfunction i40e_read_nvm_word_srctlfunction i40e_read_nvm_aqfunction i40e_read_nvm_word_aqfunction i40e_acquire_nvmfunction i40e_read_nvm_wordfunction i40e_read_nvm_module_datafunction wordsfunction wordsfunction wordsfunction wordsfunction i40e_write_nvm_aqfunction VPDfunction i40e_update_nvm_checksumfunction i40e_validate_nvm_checksumfunction i40e_nvmupd_get_modulefunction i40e_nvmupd_get_transactionfunction i40e_nvmupd_get_preservation_flagsfunction i40e_nvmupd_validate_commandfunction i40e_nvmupd_nvm_erasefunction i40e_nvmupd_nvm_writefunction i40e_nvmupd_nvm_readfunction i40e_nvmupd_exec_aqfunction i40e_nvmupd_get_aq_resultfunction i40e_nvmupd_get_aq_eventfunction i40e_nvmupd_state_initfunction i40e_nvmupd_state_readingfunction i40e_nvmupd_state_writingfunction i40e_nvmupd_commandfunction i40e_nvmupd_clear_wait_statefunction i40e_nvmupd_check_wait_event
Annotated Snippet
while ((gtime < timeout) && time_left) {
usleep_range(10000, 20000);
gtime = rd32(hw, I40E_GLVFGEN_TIMER);
ret_code = i40e_aq_request_resource(hw,
I40E_NVM_RESOURCE_ID,
access, 0, &time_left,
NULL);
if (!ret_code) {
hw->nvm.hw_semaphore_timeout =
I40E_MS_TO_GTIME(time_left) + gtime;
break;
}
}
if (ret_code) {
hw->nvm.hw_semaphore_timeout = 0;
i40e_debug(hw, I40E_DEBUG_NVM,
"NVM acquire timed out, wait %llu ms before trying again. status=%d aq_err=%d\n",
time_left, ret_code, hw->aq.asq_last_status);
}
}
i40e_i40e_acquire_nvm_exit:
return ret_code;
}
/**
* i40e_release_nvm - Generic request for releasing the NVM ownership
* @hw: pointer to the HW structure
*
* This function will release NVM resource via the proper Admin Command.
**/
void i40e_release_nvm(struct i40e_hw *hw)
{
u32 total_delay = 0;
int ret_code = 0;
if (hw->nvm.blank_nvm_mode)
return;
ret_code = i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
/* there are some rare cases when trying to release the resource
* results in an admin Q timeout, so handle them correctly
*/
while ((ret_code == -EIO) &&
(total_delay < hw->aq.asq_cmd_timeout)) {
usleep_range(1000, 2000);
ret_code = i40e_aq_release_resource(hw,
I40E_NVM_RESOURCE_ID,
0, NULL);
total_delay++;
}
}
/**
* i40e_poll_sr_srctl_done_bit - Polls the GLNVM_SRCTL done bit
* @hw: pointer to the HW structure
*
* Polls the SRCTL Shadow RAM register done bit.
**/
static int i40e_poll_sr_srctl_done_bit(struct i40e_hw *hw)
{
int ret_code = -EIO;
u32 srctl, wait_cnt;
/* Poll the I40E_GLNVM_SRCTL until the done bit is set */
for (wait_cnt = 0; wait_cnt < I40E_SRRD_SRCTL_ATTEMPTS; wait_cnt++) {
srctl = rd32(hw, I40E_GLNVM_SRCTL);
if (srctl & I40E_GLNVM_SRCTL_DONE_MASK) {
ret_code = 0;
break;
}
udelay(5);
}
if (ret_code == -EIO)
i40e_debug(hw, I40E_DEBUG_NVM, "Done bit in GLNVM_SRCTL not set");
return ret_code;
}
/**
* i40e_read_nvm_word_srctl - Reads Shadow RAM via SRCTL register
* @hw: pointer to the HW structure
* @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
* @data: word read from the Shadow RAM
*
* Reads one 16 bit word from the Shadow RAM using the GLNVM_SRCTL register.
**/
static int i40e_read_nvm_word_srctl(struct i40e_hw *hw, u16 offset,
u16 *data)
{
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `i40e_alloc.h`, `i40e_prototype.h`.
- Detected declarations: `function here`, `function i40e_acquire_nvm`, `function i40e_release_nvm`, `function i40e_poll_sr_srctl_done_bit`, `function i40e_read_nvm_word_srctl`, `function i40e_read_nvm_aq`, `function i40e_read_nvm_word_aq`, `function i40e_acquire_nvm`, `function i40e_read_nvm_word`, `function i40e_read_nvm_module_data`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.