Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ixl/i40e_nvm.c
Show All 29 Lines | /****************************************************************************** | ||||
POSSIBILITY OF SUCH DAMAGE. | POSSIBILITY OF SUCH DAMAGE. | ||||
******************************************************************************/ | ******************************************************************************/ | ||||
/*$FreeBSD$*/ | /*$FreeBSD$*/ | ||||
#include "i40e_prototype.h" | #include "i40e_prototype.h" | ||||
/** | /** | ||||
* i40e_init_nvm_ops - Initialize NVM function pointers | * i40e_init_nvm - Initialize NVM function pointers | ||||
* @hw: pointer to the HW structure | * @hw: pointer to the HW structure | ||||
* | * | ||||
* Setup the function pointers and the NVM info structure. Should be called | * Setup the function pointers and the NVM info structure. Should be called | ||||
* once per NVM initialization, e.g. inside the i40e_init_shared_code(). | * once per NVM initialization, e.g. inside the i40e_init_shared_code(). | ||||
* Please notice that the NVM term is used here (& in all methods covered | * Please notice that the NVM term is used here (& in all methods covered | ||||
* in this file) as an equivalent of the FLASH part mapped into the SR. | * in this file) as an equivalent of the FLASH part mapped into the SR. | ||||
* We are accessing FLASH always through the Shadow RAM. | * We are accessing FLASH always through the Shadow RAM. | ||||
**/ | **/ | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | enum i40e_status_code i40e_acquire_nvm(struct i40e_hw *hw, | ||||
gtime = rd32(hw, I40E_GLVFGEN_TIMER); | gtime = rd32(hw, I40E_GLVFGEN_TIMER); | ||||
/* Store the timeout */ | /* Store the timeout */ | ||||
hw->nvm.hw_semaphore_timeout = I40E_MS_TO_GTIME(time_left) + gtime; | hw->nvm.hw_semaphore_timeout = I40E_MS_TO_GTIME(time_left) + gtime; | ||||
if (ret_code) | if (ret_code) | ||||
i40e_debug(hw, I40E_DEBUG_NVM, | i40e_debug(hw, I40E_DEBUG_NVM, | ||||
"NVM acquire type %d failed time_left=%llu ret=%d aq_err=%d\n", | "NVM acquire type %d failed time_left=%llu ret=%d aq_err=%d\n", | ||||
access, time_left, ret_code, hw->aq.asq_last_status); | access, (unsigned long long)time_left, ret_code, | ||||
hw->aq.asq_last_status); | |||||
if (ret_code && time_left) { | if (ret_code && time_left) { | ||||
/* Poll until the current NVM owner timeouts */ | /* Poll until the current NVM owner timeouts */ | ||||
timeout = I40E_MS_TO_GTIME(I40E_MAX_NVM_TIMEOUT) + gtime; | timeout = I40E_MS_TO_GTIME(I40E_MAX_NVM_TIMEOUT) + gtime; | ||||
while ((gtime < timeout) && time_left) { | while ((gtime < timeout) && time_left) { | ||||
i40e_msec_delay(10); | i40e_msec_delay(10); | ||||
gtime = rd32(hw, I40E_GLVFGEN_TIMER); | gtime = rd32(hw, I40E_GLVFGEN_TIMER); | ||||
ret_code = i40e_aq_request_resource(hw, | ret_code = i40e_aq_request_resource(hw, | ||||
I40E_NVM_RESOURCE_ID, | I40E_NVM_RESOURCE_ID, | ||||
access, 0, &time_left, | access, 0, &time_left, | ||||
NULL); | NULL); | ||||
if (ret_code == I40E_SUCCESS) { | if (ret_code == I40E_SUCCESS) { | ||||
hw->nvm.hw_semaphore_timeout = | hw->nvm.hw_semaphore_timeout = | ||||
I40E_MS_TO_GTIME(time_left) + gtime; | I40E_MS_TO_GTIME(time_left) + gtime; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (ret_code != I40E_SUCCESS) { | if (ret_code != I40E_SUCCESS) { | ||||
hw->nvm.hw_semaphore_timeout = 0; | hw->nvm.hw_semaphore_timeout = 0; | ||||
i40e_debug(hw, I40E_DEBUG_NVM, | i40e_debug(hw, I40E_DEBUG_NVM, | ||||
"NVM acquire timed out, wait %llu ms before trying again. status=%d aq_err=%d\n", | "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); | (unsigned long long)time_left, ret_code, | ||||
hw->aq.asq_last_status); | |||||
} | } | ||||
} | } | ||||
i40e_i40e_acquire_nvm_exit: | i40e_i40e_acquire_nvm_exit: | ||||
return ret_code; | return ret_code; | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 635 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
enum i40e_status_code ret_code = I40E_SUCCESS; | enum i40e_status_code ret_code = I40E_SUCCESS; | ||||
u16 checksum; | u16 checksum; | ||||
__le16 le_sum; | __le16 le_sum; | ||||
DEBUGFUNC("i40e_update_nvm_checksum"); | DEBUGFUNC("i40e_update_nvm_checksum"); | ||||
ret_code = i40e_calc_nvm_checksum(hw, &checksum); | ret_code = i40e_calc_nvm_checksum(hw, &checksum); | ||||
if (ret_code == I40E_SUCCESS) { | |||||
le_sum = CPU_TO_LE16(checksum); | le_sum = CPU_TO_LE16(checksum); | ||||
if (ret_code == I40E_SUCCESS) | |||||
ret_code = i40e_write_nvm_aq(hw, 0x00, I40E_SR_SW_CHECKSUM_WORD, | ret_code = i40e_write_nvm_aq(hw, 0x00, I40E_SR_SW_CHECKSUM_WORD, | ||||
1, &le_sum, TRUE); | 1, &le_sum, TRUE); | ||||
} | |||||
return ret_code; | return ret_code; | ||||
} | } | ||||
/** | /** | ||||
* i40e_validate_nvm_checksum - Validate EEPROM checksum | * i40e_validate_nvm_checksum - Validate EEPROM checksum | ||||
* @hw: pointer to hardware structure | * @hw: pointer to hardware structure | ||||
* @checksum: calculated checksum | * @checksum: calculated checksum | ||||
▲ Show 20 Lines • Show All 1,025 Lines • Show Last 20 Lines |