Lines Matching refs:hw

16 int i40e_init_nvm(struct i40e_hw *hw)  in i40e_init_nvm()  argument
18 struct i40e_nvm_info *nvm = &hw->nvm; in i40e_init_nvm()
26 gens = rd32(hw, I40E_GLNVM_GENS); in i40e_init_nvm()
33 fla = rd32(hw, I40E_GLNVM_FLA); in i40e_init_nvm()
41 i40e_debug(hw, I40E_DEBUG_NVM, "NVM init error: unsupported blank mode.\n"); in i40e_init_nvm()
55 int i40e_acquire_nvm(struct i40e_hw *hw, in i40e_acquire_nvm() argument
62 if (hw->nvm.blank_nvm_mode) in i40e_acquire_nvm()
65 ret_code = i40e_aq_request_resource(hw, I40E_NVM_RESOURCE_ID, access, in i40e_acquire_nvm()
68 gtime = rd32(hw, I40E_GLVFGEN_TIMER); in i40e_acquire_nvm()
71 hw->nvm.hw_semaphore_timeout = I40E_MS_TO_GTIME(time_left) + gtime; in i40e_acquire_nvm()
74 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_acquire_nvm()
76 access, time_left, ret_code, hw->aq.asq_last_status); in i40e_acquire_nvm()
83 gtime = rd32(hw, I40E_GLVFGEN_TIMER); in i40e_acquire_nvm()
84 ret_code = i40e_aq_request_resource(hw, in i40e_acquire_nvm()
89 hw->nvm.hw_semaphore_timeout = in i40e_acquire_nvm()
95 hw->nvm.hw_semaphore_timeout = 0; in i40e_acquire_nvm()
96 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_acquire_nvm()
98 time_left, ret_code, hw->aq.asq_last_status); in i40e_acquire_nvm()
112 void i40e_release_nvm(struct i40e_hw *hw) in i40e_release_nvm() argument
117 if (hw->nvm.blank_nvm_mode) in i40e_release_nvm()
120 ret_code = i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL); in i40e_release_nvm()
126 (total_delay < hw->aq.asq_cmd_timeout)) { in i40e_release_nvm()
128 ret_code = i40e_aq_release_resource(hw, in i40e_release_nvm()
141 static int i40e_poll_sr_srctl_done_bit(struct i40e_hw *hw) in i40e_poll_sr_srctl_done_bit() argument
148 srctl = rd32(hw, I40E_GLNVM_SRCTL); in i40e_poll_sr_srctl_done_bit()
156 i40e_debug(hw, I40E_DEBUG_NVM, "Done bit in GLNVM_SRCTL not set"); in i40e_poll_sr_srctl_done_bit()
168 static int i40e_read_nvm_word_srctl(struct i40e_hw *hw, u16 offset, in i40e_read_nvm_word_srctl() argument
174 if (offset >= hw->nvm.sr_size) { in i40e_read_nvm_word_srctl()
175 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_read_nvm_word_srctl()
177 offset, hw->nvm.sr_size); in i40e_read_nvm_word_srctl()
183 ret_code = i40e_poll_sr_srctl_done_bit(hw); in i40e_read_nvm_word_srctl()
188 wr32(hw, I40E_GLNVM_SRCTL, sr_reg); in i40e_read_nvm_word_srctl()
191 ret_code = i40e_poll_sr_srctl_done_bit(hw); in i40e_read_nvm_word_srctl()
193 sr_reg = rd32(hw, I40E_GLNVM_SRDATA); in i40e_read_nvm_word_srctl()
200 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_read_nvm_word_srctl()
219 static int i40e_read_nvm_aq(struct i40e_hw *hw, in i40e_read_nvm_aq() argument
228 cmd_details.wb_desc = &hw->nvm_wb_desc; in i40e_read_nvm_aq()
235 if ((offset + words) > hw->nvm.sr_size) in i40e_read_nvm_aq()
236 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_read_nvm_aq()
238 (offset + words), hw->nvm.sr_size); in i40e_read_nvm_aq()
241 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_read_nvm_aq()
247 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_read_nvm_aq()
251 ret_code = i40e_aq_read_nvm(hw, module_pointer, in i40e_read_nvm_aq()
267 static int i40e_read_nvm_word_aq(struct i40e_hw *hw, u16 offset, in i40e_read_nvm_word_aq() argument
272 ret_code = i40e_read_nvm_aq(hw, 0x0, offset, 1, data, true); in i40e_read_nvm_word_aq()
289 static int __i40e_read_nvm_word(struct i40e_hw *hw, in __i40e_read_nvm_word() argument
292 if (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE) in __i40e_read_nvm_word()
293 return i40e_read_nvm_word_aq(hw, offset, data); in __i40e_read_nvm_word()
295 return i40e_read_nvm_word_srctl(hw, offset, data); in __i40e_read_nvm_word()
306 int i40e_read_nvm_word(struct i40e_hw *hw, u16 offset, in i40e_read_nvm_word() argument
311 if (hw->flags & I40E_HW_FLAG_NVM_READ_REQUIRES_LOCK) in i40e_read_nvm_word()
312 ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ); in i40e_read_nvm_word()
316 ret_code = __i40e_read_nvm_word(hw, offset, data); in i40e_read_nvm_word()
318 if (hw->flags & I40E_HW_FLAG_NVM_READ_REQUIRES_LOCK) in i40e_read_nvm_word()
319 i40e_release_nvm(hw); in i40e_read_nvm_word()
333 int i40e_read_nvm_module_data(struct i40e_hw *hw, in i40e_read_nvm_module_data() argument
346 status = i40e_read_nvm_word(hw, module_ptr, &ptr_value); in i40e_read_nvm_module_data()
348 i40e_debug(hw, I40E_DEBUG_ALL, in i40e_read_nvm_module_data()
360 i40e_debug(hw, I40E_DEBUG_ALL, "Pointer not initialized.\n"); in i40e_read_nvm_module_data()
367 i40e_debug(hw, I40E_DEBUG_ALL, in i40e_read_nvm_module_data()
374 status = i40e_read_nvm_word(hw, ptr_value + module_offset, in i40e_read_nvm_module_data()
377 i40e_debug(hw, I40E_DEBUG_ALL, in i40e_read_nvm_module_data()
386 status = i40e_read_nvm_buffer(hw, offset, &words_data_size, in i40e_read_nvm_module_data()
389 i40e_debug(hw, I40E_DEBUG_ALL, in i40e_read_nvm_module_data()
409 static int i40e_read_nvm_buffer_srctl(struct i40e_hw *hw, u16 offset, in i40e_read_nvm_buffer_srctl() argument
418 ret_code = i40e_read_nvm_word_srctl(hw, index, &data[word]); in i40e_read_nvm_buffer_srctl()
440 static int i40e_read_nvm_buffer_aq(struct i40e_hw *hw, u16 offset, in i40e_read_nvm_buffer_aq() argument
466 ret_code = i40e_read_nvm_aq(hw, 0x0, offset, read_size, in i40e_read_nvm_buffer_aq()
496 static int __i40e_read_nvm_buffer(struct i40e_hw *hw, in __i40e_read_nvm_buffer() argument
500 if (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE) in __i40e_read_nvm_buffer()
501 return i40e_read_nvm_buffer_aq(hw, offset, words, data); in __i40e_read_nvm_buffer()
503 return i40e_read_nvm_buffer_srctl(hw, offset, words, data); in __i40e_read_nvm_buffer()
517 int i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset, in i40e_read_nvm_buffer() argument
522 if (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE) { in i40e_read_nvm_buffer()
523 ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ); in i40e_read_nvm_buffer()
525 ret_code = i40e_read_nvm_buffer_aq(hw, offset, words, in i40e_read_nvm_buffer()
527 i40e_release_nvm(hw); in i40e_read_nvm_buffer()
530 ret_code = i40e_read_nvm_buffer_srctl(hw, offset, words, data); in i40e_read_nvm_buffer()
547 static int i40e_write_nvm_aq(struct i40e_hw *hw, u8 module_pointer, in i40e_write_nvm_aq() argument
555 cmd_details.wb_desc = &hw->nvm_wb_desc; in i40e_write_nvm_aq()
562 if ((offset + words) > hw->nvm.sr_size) in i40e_write_nvm_aq()
563 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_write_nvm_aq()
565 (offset + words), hw->nvm.sr_size); in i40e_write_nvm_aq()
568 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_write_nvm_aq()
574 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_write_nvm_aq()
578 ret_code = i40e_aq_update_nvm(hw, module_pointer, in i40e_write_nvm_aq()
597 static int i40e_calc_nvm_checksum(struct i40e_hw *hw, in i40e_calc_nvm_checksum() argument
608 ret_code = i40e_allocate_virt_mem(hw, &vmem, in i40e_calc_nvm_checksum()
615 ret_code = __i40e_read_nvm_word(hw, I40E_SR_VPD_PTR, &vpd_module); in i40e_calc_nvm_checksum()
622 ret_code = __i40e_read_nvm_word(hw, I40E_SR_PCIE_ALT_AUTO_LOAD_PTR, in i40e_calc_nvm_checksum()
632 for (i = 0; i < hw->nvm.sr_size; i++) { in i40e_calc_nvm_checksum()
637 ret_code = __i40e_read_nvm_buffer(hw, i, &words, data); in i40e_calc_nvm_checksum()
666 i40e_free_virt_mem(hw, &vmem); in i40e_calc_nvm_checksum()
678 int i40e_update_nvm_checksum(struct i40e_hw *hw) in i40e_update_nvm_checksum() argument
684 ret_code = i40e_calc_nvm_checksum(hw, &checksum); in i40e_update_nvm_checksum()
687 ret_code = i40e_write_nvm_aq(hw, 0x00, I40E_SR_SW_CHECKSUM_WORD, in i40e_update_nvm_checksum()
702 int i40e_validate_nvm_checksum(struct i40e_hw *hw, in i40e_validate_nvm_checksum() argument
714 ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ); in i40e_validate_nvm_checksum()
717 ret_code = i40e_calc_nvm_checksum(hw, &checksum_local); in i40e_validate_nvm_checksum()
718 __i40e_read_nvm_word(hw, I40E_SR_SW_CHECKSUM_WORD, &checksum_sr); in i40e_validate_nvm_checksum()
719 i40e_release_nvm(hw); in i40e_validate_nvm_checksum()
736 static int i40e_nvmupd_state_init(struct i40e_hw *hw,
739 static int i40e_nvmupd_state_reading(struct i40e_hw *hw,
742 static int i40e_nvmupd_state_writing(struct i40e_hw *hw,
745 static enum i40e_nvmupd_cmd i40e_nvmupd_validate_command(struct i40e_hw *hw,
748 static int i40e_nvmupd_nvm_erase(struct i40e_hw *hw,
751 static int i40e_nvmupd_nvm_write(struct i40e_hw *hw,
754 static int i40e_nvmupd_nvm_read(struct i40e_hw *hw,
757 static int i40e_nvmupd_exec_aq(struct i40e_hw *hw,
760 static int i40e_nvmupd_get_aq_result(struct i40e_hw *hw,
763 static int i40e_nvmupd_get_aq_event(struct i40e_hw *hw,
810 int i40e_nvmupd_command(struct i40e_hw *hw, in i40e_nvmupd_command() argument
821 upd_cmd = i40e_nvmupd_validate_command(hw, cmd, perrno); in i40e_nvmupd_command()
823 …i40e_debug(hw, I40E_DEBUG_NVM, "%s state %d nvm_release_on_hold %d opc 0x%04x cmd 0x%08x config 0x… in i40e_nvmupd_command()
825 hw->nvmupd_state, in i40e_nvmupd_command()
826 hw->nvm_release_on_done, hw->nvm_wait_opcode, in i40e_nvmupd_command()
831 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_command()
845 bytes[0] = hw->nvmupd_state; in i40e_nvmupd_command()
849 *((u16 *)&bytes[2]) = hw->nvm_wait_opcode; in i40e_nvmupd_command()
853 if (hw->nvmupd_state == I40E_NVMUPD_STATE_ERROR) in i40e_nvmupd_command()
854 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT; in i40e_nvmupd_command()
860 if (hw->nvmupd_state == I40E_NVMUPD_STATE_ERROR) { in i40e_nvmupd_command()
861 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_command()
863 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT; in i40e_nvmupd_command()
874 mutex_lock(&hw->aq.arq_mutex); in i40e_nvmupd_command()
875 switch (hw->nvmupd_state) { in i40e_nvmupd_command()
877 status = i40e_nvmupd_state_init(hw, cmd, bytes, perrno); in i40e_nvmupd_command()
881 status = i40e_nvmupd_state_reading(hw, cmd, bytes, perrno); in i40e_nvmupd_command()
885 status = i40e_nvmupd_state_writing(hw, cmd, bytes, perrno); in i40e_nvmupd_command()
894 i40e_nvmupd_clear_wait_state(hw); in i40e_nvmupd_command()
905 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_command()
906 "NVMUPD: no such state %d\n", hw->nvmupd_state); in i40e_nvmupd_command()
912 mutex_unlock(&hw->aq.arq_mutex); in i40e_nvmupd_command()
926 static int i40e_nvmupd_state_init(struct i40e_hw *hw, in i40e_nvmupd_state_init() argument
933 upd_cmd = i40e_nvmupd_validate_command(hw, cmd, perrno); in i40e_nvmupd_state_init()
937 status = i40e_acquire_nvm(hw, I40E_RESOURCE_READ); in i40e_nvmupd_state_init()
940 hw->aq.asq_last_status); in i40e_nvmupd_state_init()
942 status = i40e_nvmupd_nvm_read(hw, cmd, bytes, perrno); in i40e_nvmupd_state_init()
943 i40e_release_nvm(hw); in i40e_nvmupd_state_init()
948 status = i40e_acquire_nvm(hw, I40E_RESOURCE_READ); in i40e_nvmupd_state_init()
951 hw->aq.asq_last_status); in i40e_nvmupd_state_init()
953 status = i40e_nvmupd_nvm_read(hw, cmd, bytes, perrno); in i40e_nvmupd_state_init()
955 i40e_release_nvm(hw); in i40e_nvmupd_state_init()
957 hw->nvmupd_state = I40E_NVMUPD_STATE_READING; in i40e_nvmupd_state_init()
962 status = i40e_acquire_nvm(hw, I40E_RESOURCE_WRITE); in i40e_nvmupd_state_init()
965 hw->aq.asq_last_status); in i40e_nvmupd_state_init()
967 status = i40e_nvmupd_nvm_erase(hw, cmd, perrno); in i40e_nvmupd_state_init()
969 i40e_release_nvm(hw); in i40e_nvmupd_state_init()
971 hw->nvm_release_on_done = true; in i40e_nvmupd_state_init()
972 hw->nvm_wait_opcode = i40e_aqc_opc_nvm_erase; in i40e_nvmupd_state_init()
973 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT; in i40e_nvmupd_state_init()
979 status = i40e_acquire_nvm(hw, I40E_RESOURCE_WRITE); in i40e_nvmupd_state_init()
982 hw->aq.asq_last_status); in i40e_nvmupd_state_init()
984 status = i40e_nvmupd_nvm_write(hw, cmd, bytes, perrno); in i40e_nvmupd_state_init()
986 i40e_release_nvm(hw); in i40e_nvmupd_state_init()
988 hw->nvm_release_on_done = true; in i40e_nvmupd_state_init()
989 hw->nvm_wait_opcode = i40e_aqc_opc_nvm_update; in i40e_nvmupd_state_init()
990 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT; in i40e_nvmupd_state_init()
996 status = i40e_acquire_nvm(hw, I40E_RESOURCE_WRITE); in i40e_nvmupd_state_init()
999 hw->aq.asq_last_status); in i40e_nvmupd_state_init()
1001 status = i40e_nvmupd_nvm_write(hw, cmd, bytes, perrno); in i40e_nvmupd_state_init()
1003 i40e_release_nvm(hw); in i40e_nvmupd_state_init()
1005 hw->nvm_wait_opcode = i40e_aqc_opc_nvm_update; in i40e_nvmupd_state_init()
1006 hw->nvmupd_state = I40E_NVMUPD_STATE_WRITE_WAIT; in i40e_nvmupd_state_init()
1012 status = i40e_acquire_nvm(hw, I40E_RESOURCE_WRITE); in i40e_nvmupd_state_init()
1015 hw->aq.asq_last_status); in i40e_nvmupd_state_init()
1017 status = i40e_update_nvm_checksum(hw); in i40e_nvmupd_state_init()
1019 *perrno = hw->aq.asq_last_status ? in i40e_nvmupd_state_init()
1021 hw->aq.asq_last_status) : in i40e_nvmupd_state_init()
1023 i40e_release_nvm(hw); in i40e_nvmupd_state_init()
1025 hw->nvm_release_on_done = true; in i40e_nvmupd_state_init()
1026 hw->nvm_wait_opcode = i40e_aqc_opc_nvm_update; in i40e_nvmupd_state_init()
1027 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT; in i40e_nvmupd_state_init()
1033 status = i40e_nvmupd_exec_aq(hw, cmd, bytes, perrno); in i40e_nvmupd_state_init()
1037 status = i40e_nvmupd_get_aq_result(hw, cmd, bytes, perrno); in i40e_nvmupd_state_init()
1041 status = i40e_nvmupd_get_aq_event(hw, cmd, bytes, perrno); in i40e_nvmupd_state_init()
1045 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_state_init()
1065 static int i40e_nvmupd_state_reading(struct i40e_hw *hw, in i40e_nvmupd_state_reading() argument
1072 upd_cmd = i40e_nvmupd_validate_command(hw, cmd, perrno); in i40e_nvmupd_state_reading()
1077 status = i40e_nvmupd_nvm_read(hw, cmd, bytes, perrno); in i40e_nvmupd_state_reading()
1081 status = i40e_nvmupd_nvm_read(hw, cmd, bytes, perrno); in i40e_nvmupd_state_reading()
1082 i40e_release_nvm(hw); in i40e_nvmupd_state_reading()
1083 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT; in i40e_nvmupd_state_reading()
1087 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_state_reading()
1107 static int i40e_nvmupd_state_writing(struct i40e_hw *hw, in i40e_nvmupd_state_writing() argument
1115 upd_cmd = i40e_nvmupd_validate_command(hw, cmd, perrno); in i40e_nvmupd_state_writing()
1120 status = i40e_nvmupd_nvm_write(hw, cmd, bytes, perrno); in i40e_nvmupd_state_writing()
1122 hw->nvm_wait_opcode = i40e_aqc_opc_nvm_update; in i40e_nvmupd_state_writing()
1123 hw->nvmupd_state = I40E_NVMUPD_STATE_WRITE_WAIT; in i40e_nvmupd_state_writing()
1128 status = i40e_nvmupd_nvm_write(hw, cmd, bytes, perrno); in i40e_nvmupd_state_writing()
1130 *perrno = hw->aq.asq_last_status ? in i40e_nvmupd_state_writing()
1132 hw->aq.asq_last_status) : in i40e_nvmupd_state_writing()
1134 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT; in i40e_nvmupd_state_writing()
1136 hw->nvm_release_on_done = true; in i40e_nvmupd_state_writing()
1137 hw->nvm_wait_opcode = i40e_aqc_opc_nvm_update; in i40e_nvmupd_state_writing()
1138 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT; in i40e_nvmupd_state_writing()
1144 status = i40e_update_nvm_checksum(hw); in i40e_nvmupd_state_writing()
1146 *perrno = hw->aq.asq_last_status ? in i40e_nvmupd_state_writing()
1148 hw->aq.asq_last_status) : in i40e_nvmupd_state_writing()
1150 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT; in i40e_nvmupd_state_writing()
1152 hw->nvm_wait_opcode = i40e_aqc_opc_nvm_update; in i40e_nvmupd_state_writing()
1153 hw->nvmupd_state = I40E_NVMUPD_STATE_WRITE_WAIT; in i40e_nvmupd_state_writing()
1159 status = i40e_update_nvm_checksum(hw); in i40e_nvmupd_state_writing()
1161 *perrno = hw->aq.asq_last_status ? in i40e_nvmupd_state_writing()
1163 hw->aq.asq_last_status) : in i40e_nvmupd_state_writing()
1165 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT; in i40e_nvmupd_state_writing()
1167 hw->nvm_release_on_done = true; in i40e_nvmupd_state_writing()
1168 hw->nvm_wait_opcode = i40e_aqc_opc_nvm_update; in i40e_nvmupd_state_writing()
1169 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT; in i40e_nvmupd_state_writing()
1174 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_state_writing()
1188 if (status && (hw->aq.asq_last_status == I40E_AQ_RC_EBUSY) && in i40e_nvmupd_state_writing()
1190 u32 old_asq_status = hw->aq.asq_last_status; in i40e_nvmupd_state_writing()
1194 gtime = rd32(hw, I40E_GLVFGEN_TIMER); in i40e_nvmupd_state_writing()
1195 if (gtime >= hw->nvm.hw_semaphore_timeout) { in i40e_nvmupd_state_writing()
1196 i40e_debug(hw, I40E_DEBUG_ALL, in i40e_nvmupd_state_writing()
1198 gtime, hw->nvm.hw_semaphore_timeout); in i40e_nvmupd_state_writing()
1199 i40e_release_nvm(hw); in i40e_nvmupd_state_writing()
1200 status = i40e_acquire_nvm(hw, I40E_RESOURCE_WRITE); in i40e_nvmupd_state_writing()
1202 i40e_debug(hw, I40E_DEBUG_ALL, in i40e_nvmupd_state_writing()
1204 hw->aq.asq_last_status); in i40e_nvmupd_state_writing()
1206 hw->aq.asq_last_status = old_asq_status; in i40e_nvmupd_state_writing()
1221 void i40e_nvmupd_clear_wait_state(struct i40e_hw *hw) in i40e_nvmupd_clear_wait_state() argument
1223 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_clear_wait_state()
1225 hw->nvm_wait_opcode); in i40e_nvmupd_clear_wait_state()
1227 if (hw->nvm_release_on_done) { in i40e_nvmupd_clear_wait_state()
1228 i40e_release_nvm(hw); in i40e_nvmupd_clear_wait_state()
1229 hw->nvm_release_on_done = false; in i40e_nvmupd_clear_wait_state()
1231 hw->nvm_wait_opcode = 0; in i40e_nvmupd_clear_wait_state()
1233 if (hw->aq.arq_last_status) { in i40e_nvmupd_clear_wait_state()
1234 hw->nvmupd_state = I40E_NVMUPD_STATE_ERROR; in i40e_nvmupd_clear_wait_state()
1238 switch (hw->nvmupd_state) { in i40e_nvmupd_clear_wait_state()
1240 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT; in i40e_nvmupd_clear_wait_state()
1244 hw->nvmupd_state = I40E_NVMUPD_STATE_WRITING; in i40e_nvmupd_clear_wait_state()
1258 void i40e_nvmupd_check_wait_event(struct i40e_hw *hw, u16 opcode, in i40e_nvmupd_check_wait_event() argument
1263 if (opcode == hw->nvm_wait_opcode) { in i40e_nvmupd_check_wait_event()
1264 memcpy(&hw->nvm_aq_event_desc, desc, aq_desc_len); in i40e_nvmupd_check_wait_event()
1265 i40e_nvmupd_clear_wait_state(hw); in i40e_nvmupd_check_wait_event()
1277 static enum i40e_nvmupd_cmd i40e_nvmupd_validate_command(struct i40e_hw *hw, in i40e_nvmupd_validate_command() argument
1293 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_validate_command()
1373 static int i40e_nvmupd_exec_aq(struct i40e_hw *hw, in i40e_nvmupd_exec_aq() argument
1385 i40e_debug(hw, I40E_DEBUG_NVM, "NVMUPD: %s\n", __func__); in i40e_nvmupd_exec_aq()
1390 cmd_details.wb_desc = &hw->nvm_wb_desc; in i40e_nvmupd_exec_aq()
1393 memset(&hw->nvm_wb_desc, 0, aq_desc_len); in i40e_nvmupd_exec_aq()
1397 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_exec_aq()
1409 if (!hw->nvm_buff.va) { in i40e_nvmupd_exec_aq()
1410 status = i40e_allocate_virt_mem(hw, &hw->nvm_buff, in i40e_nvmupd_exec_aq()
1411 hw->aq.asq_buf_size); in i40e_nvmupd_exec_aq()
1413 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_exec_aq()
1418 if (hw->nvm_buff.va) { in i40e_nvmupd_exec_aq()
1419 buff = hw->nvm_buff.va; in i40e_nvmupd_exec_aq()
1425 memset(&hw->nvm_aq_event_desc, 0, aq_desc_len); in i40e_nvmupd_exec_aq()
1428 status = i40e_asq_send_command(hw, aq_desc, buff, in i40e_nvmupd_exec_aq()
1431 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_exec_aq()
1434 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_nvmupd_exec_aq()
1435 *perrno = i40e_aq_rc_to_posix(status, hw->aq.asq_last_status); in i40e_nvmupd_exec_aq()
1441 hw->nvm_wait_opcode = cmd->offset; in i40e_nvmupd_exec_aq()
1442 hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT; in i40e_nvmupd_exec_aq()
1457 static int i40e_nvmupd_get_aq_result(struct i40e_hw *hw, in i40e_nvmupd_get_aq_result() argument
1466 i40e_debug(hw, I40E_DEBUG_NVM, "NVMUPD: %s\n", __func__); in i40e_nvmupd_get_aq_result()
1469 aq_total_len = aq_desc_len + le16_to_cpu(hw->nvm_wb_desc.datalen); in i40e_nvmupd_get_aq_result()
1473 i40e_debug(hw, I40E_DEBUG_NVM, "%s: offset too big %d > %d\n", in i40e_nvmupd_get_aq_result()
1483 i40e_debug(hw, I40E_DEBUG_NVM, "%s: copy length %d too big, trimming to %d\n", in i40e_nvmupd_get_aq_result()
1493 i40e_debug(hw, I40E_DEBUG_NVM, "%s: aq_desc bytes %d to %d\n", in i40e_nvmupd_get_aq_result()
1496 buff = ((u8 *)&hw->nvm_wb_desc) + cmd->offset; in i40e_nvmupd_get_aq_result()
1501 buff = hw->nvm_buff.va; in i40e_nvmupd_get_aq_result()
1503 buff = hw->nvm_buff.va + (cmd->offset - aq_desc_len); in i40e_nvmupd_get_aq_result()
1507 int start_byte = buff - (u8 *)hw->nvm_buff.va; in i40e_nvmupd_get_aq_result()
1509 i40e_debug(hw, I40E_DEBUG_NVM, "%s: databuf bytes %d to %d\n", in i40e_nvmupd_get_aq_result()
1526 static int i40e_nvmupd_get_aq_event(struct i40e_hw *hw, in i40e_nvmupd_get_aq_event() argument
1533 i40e_debug(hw, I40E_DEBUG_NVM, "NVMUPD: %s\n", __func__); in i40e_nvmupd_get_aq_event()
1536 aq_total_len = aq_desc_len + le16_to_cpu(hw->nvm_aq_event_desc.datalen); in i40e_nvmupd_get_aq_event()
1540 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_get_aq_event()
1546 memcpy(bytes, &hw->nvm_aq_event_desc, cmd->data_size); in i40e_nvmupd_get_aq_event()
1560 static int i40e_nvmupd_nvm_read(struct i40e_hw *hw, in i40e_nvmupd_nvm_read() argument
1574 cmd_details.wb_desc = &hw->nvm_wb_desc; in i40e_nvmupd_nvm_read()
1576 status = i40e_aq_read_nvm(hw, module, cmd->offset, (u16)cmd->data_size, in i40e_nvmupd_nvm_read()
1579 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_nvm_read()
1582 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_nvm_read()
1584 status, hw->aq.asq_last_status); in i40e_nvmupd_nvm_read()
1585 *perrno = i40e_aq_rc_to_posix(status, hw->aq.asq_last_status); in i40e_nvmupd_nvm_read()
1599 static int i40e_nvmupd_nvm_erase(struct i40e_hw *hw, in i40e_nvmupd_nvm_erase() argument
1613 cmd_details.wb_desc = &hw->nvm_wb_desc; in i40e_nvmupd_nvm_erase()
1615 status = i40e_aq_erase_nvm(hw, module, cmd->offset, (u16)cmd->data_size, in i40e_nvmupd_nvm_erase()
1618 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_nvm_erase()
1621 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_nvm_erase()
1623 status, hw->aq.asq_last_status); in i40e_nvmupd_nvm_erase()
1624 *perrno = i40e_aq_rc_to_posix(status, hw->aq.asq_last_status); in i40e_nvmupd_nvm_erase()
1639 static int i40e_nvmupd_nvm_write(struct i40e_hw *hw, in i40e_nvmupd_nvm_write() argument
1655 cmd_details.wb_desc = &hw->nvm_wb_desc; in i40e_nvmupd_nvm_write()
1657 status = i40e_aq_update_nvm(hw, module, cmd->offset, in i40e_nvmupd_nvm_write()
1661 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_nvm_write()
1664 i40e_debug(hw, I40E_DEBUG_NVM, in i40e_nvmupd_nvm_write()
1666 status, hw->aq.asq_last_status); in i40e_nvmupd_nvm_write()
1667 *perrno = i40e_aq_rc_to_posix(status, hw->aq.asq_last_status); in i40e_nvmupd_nvm_write()