Lines Matching full:hw
12 * @hw: pointer to the hardware structure
14 static enum iavf_status iavf_alloc_adminq_asq_ring(struct iavf_hw *hw) in iavf_alloc_adminq_asq_ring() argument
18 ret_code = iavf_allocate_dma_mem(hw, &hw->aq.asq.desc_buf, in iavf_alloc_adminq_asq_ring()
20 (hw->aq.num_asq_entries * in iavf_alloc_adminq_asq_ring()
26 ret_code = iavf_allocate_virt_mem(hw, &hw->aq.asq.cmd_buf, in iavf_alloc_adminq_asq_ring()
27 (hw->aq.num_asq_entries * in iavf_alloc_adminq_asq_ring()
30 iavf_free_dma_mem(hw, &hw->aq.asq.desc_buf); in iavf_alloc_adminq_asq_ring()
39 * @hw: pointer to the hardware structure
41 static enum iavf_status iavf_alloc_adminq_arq_ring(struct iavf_hw *hw) in iavf_alloc_adminq_arq_ring() argument
45 ret_code = iavf_allocate_dma_mem(hw, &hw->aq.arq.desc_buf, in iavf_alloc_adminq_arq_ring()
47 (hw->aq.num_arq_entries * in iavf_alloc_adminq_arq_ring()
56 * @hw: pointer to the hardware structure
61 static void iavf_free_adminq_asq(struct iavf_hw *hw) in iavf_free_adminq_asq() argument
63 iavf_free_dma_mem(hw, &hw->aq.asq.desc_buf); in iavf_free_adminq_asq()
68 * @hw: pointer to the hardware structure
73 static void iavf_free_adminq_arq(struct iavf_hw *hw) in iavf_free_adminq_arq() argument
75 iavf_free_dma_mem(hw, &hw->aq.arq.desc_buf); in iavf_free_adminq_arq()
80 * @hw: pointer to the hardware structure
82 static enum iavf_status iavf_alloc_arq_bufs(struct iavf_hw *hw) in iavf_alloc_arq_bufs() argument
94 ret_code = iavf_allocate_virt_mem(hw, &hw->aq.arq.dma_head, in iavf_alloc_arq_bufs()
95 (hw->aq.num_arq_entries * in iavf_alloc_arq_bufs()
99 hw->aq.arq.r.arq_bi = (struct iavf_dma_mem *)hw->aq.arq.dma_head.va; in iavf_alloc_arq_bufs()
102 for (i = 0; i < hw->aq.num_arq_entries; i++) { in iavf_alloc_arq_bufs()
103 bi = &hw->aq.arq.r.arq_bi[i]; in iavf_alloc_arq_bufs()
104 ret_code = iavf_allocate_dma_mem(hw, bi, in iavf_alloc_arq_bufs()
106 hw->aq.arq_buf_size, in iavf_alloc_arq_bufs()
112 desc = IAVF_ADMINQ_DESC(hw->aq.arq, i); in iavf_alloc_arq_bufs()
115 if (hw->aq.arq_buf_size > IAVF_AQ_LARGE_BUF) in iavf_alloc_arq_bufs()
140 iavf_free_dma_mem(hw, &hw->aq.arq.r.arq_bi[i]); in iavf_alloc_arq_bufs()
141 iavf_free_virt_mem(hw, &hw->aq.arq.dma_head); in iavf_alloc_arq_bufs()
148 * @hw: pointer to the hardware structure
150 static enum iavf_status iavf_alloc_asq_bufs(struct iavf_hw *hw) in iavf_alloc_asq_bufs() argument
157 ret_code = iavf_allocate_virt_mem(hw, &hw->aq.asq.dma_head, in iavf_alloc_asq_bufs()
158 (hw->aq.num_asq_entries * in iavf_alloc_asq_bufs()
162 hw->aq.asq.r.asq_bi = (struct iavf_dma_mem *)hw->aq.asq.dma_head.va; in iavf_alloc_asq_bufs()
165 for (i = 0; i < hw->aq.num_asq_entries; i++) { in iavf_alloc_asq_bufs()
166 bi = &hw->aq.asq.r.asq_bi[i]; in iavf_alloc_asq_bufs()
167 ret_code = iavf_allocate_dma_mem(hw, bi, in iavf_alloc_asq_bufs()
169 hw->aq.asq_buf_size, in iavf_alloc_asq_bufs()
181 iavf_free_dma_mem(hw, &hw->aq.asq.r.asq_bi[i]); in iavf_alloc_asq_bufs()
182 iavf_free_virt_mem(hw, &hw->aq.asq.dma_head); in iavf_alloc_asq_bufs()
189 * @hw: pointer to the hardware structure
191 static void iavf_free_arq_bufs(struct iavf_hw *hw) in iavf_free_arq_bufs() argument
196 for (i = 0; i < hw->aq.num_arq_entries; i++) in iavf_free_arq_bufs()
197 iavf_free_dma_mem(hw, &hw->aq.arq.r.arq_bi[i]); in iavf_free_arq_bufs()
200 iavf_free_dma_mem(hw, &hw->aq.arq.desc_buf); in iavf_free_arq_bufs()
203 iavf_free_virt_mem(hw, &hw->aq.arq.dma_head); in iavf_free_arq_bufs()
208 * @hw: pointer to the hardware structure
210 static void iavf_free_asq_bufs(struct iavf_hw *hw) in iavf_free_asq_bufs() argument
215 for (i = 0; i < hw->aq.num_asq_entries; i++) in iavf_free_asq_bufs()
216 if (hw->aq.asq.r.asq_bi[i].pa) in iavf_free_asq_bufs()
217 iavf_free_dma_mem(hw, &hw->aq.asq.r.asq_bi[i]); in iavf_free_asq_bufs()
220 iavf_free_virt_mem(hw, &hw->aq.asq.cmd_buf); in iavf_free_asq_bufs()
223 iavf_free_dma_mem(hw, &hw->aq.asq.desc_buf); in iavf_free_asq_bufs()
226 iavf_free_virt_mem(hw, &hw->aq.asq.dma_head); in iavf_free_asq_bufs()
231 * @hw: pointer to the hardware structure
235 static enum iavf_status iavf_config_asq_regs(struct iavf_hw *hw) in iavf_config_asq_regs() argument
241 wr32(hw, IAVF_VF_ATQH1, 0); in iavf_config_asq_regs()
242 wr32(hw, IAVF_VF_ATQT1, 0); in iavf_config_asq_regs()
245 wr32(hw, IAVF_VF_ATQLEN1, (hw->aq.num_asq_entries | in iavf_config_asq_regs()
247 wr32(hw, IAVF_VF_ATQBAL1, lower_32_bits(hw->aq.asq.desc_buf.pa)); in iavf_config_asq_regs()
248 wr32(hw, IAVF_VF_ATQBAH1, upper_32_bits(hw->aq.asq.desc_buf.pa)); in iavf_config_asq_regs()
251 reg = rd32(hw, IAVF_VF_ATQBAL1); in iavf_config_asq_regs()
252 if (reg != lower_32_bits(hw->aq.asq.desc_buf.pa)) in iavf_config_asq_regs()
260 * @hw: pointer to the hardware structure
264 static enum iavf_status iavf_config_arq_regs(struct iavf_hw *hw) in iavf_config_arq_regs() argument
270 wr32(hw, IAVF_VF_ARQH1, 0); in iavf_config_arq_regs()
271 wr32(hw, IAVF_VF_ARQT1, 0); in iavf_config_arq_regs()
274 wr32(hw, IAVF_VF_ARQLEN1, (hw->aq.num_arq_entries | in iavf_config_arq_regs()
276 wr32(hw, IAVF_VF_ARQBAL1, lower_32_bits(hw->aq.arq.desc_buf.pa)); in iavf_config_arq_regs()
277 wr32(hw, IAVF_VF_ARQBAH1, upper_32_bits(hw->aq.arq.desc_buf.pa)); in iavf_config_arq_regs()
279 /* Update tail in the HW to post pre-allocated buffers */ in iavf_config_arq_regs()
280 wr32(hw, IAVF_VF_ARQT1, hw->aq.num_arq_entries - 1); in iavf_config_arq_regs()
283 reg = rd32(hw, IAVF_VF_ARQBAL1); in iavf_config_arq_regs()
284 if (reg != lower_32_bits(hw->aq.arq.desc_buf.pa)) in iavf_config_arq_regs()
292 * @hw: pointer to the hardware structure
296 * in the hw->aq structure:
297 * - hw->aq.num_asq_entries
298 * - hw->aq.arq_buf_size
303 static enum iavf_status iavf_init_asq(struct iavf_hw *hw) in iavf_init_asq() argument
308 if (hw->aq.asq.count > 0) { in iavf_init_asq()
315 if ((hw->aq.num_asq_entries == 0) || in iavf_init_asq()
316 (hw->aq.asq_buf_size == 0)) { in iavf_init_asq()
321 hw->aq.asq.next_to_use = 0; in iavf_init_asq()
322 hw->aq.asq.next_to_clean = 0; in iavf_init_asq()
325 ret_code = iavf_alloc_adminq_asq_ring(hw); in iavf_init_asq()
330 ret_code = iavf_alloc_asq_bufs(hw); in iavf_init_asq()
335 ret_code = iavf_config_asq_regs(hw); in iavf_init_asq()
340 hw->aq.asq.count = hw->aq.num_asq_entries; in iavf_init_asq()
344 for (i = 0; i < hw->aq.num_asq_entries; i++) in iavf_init_asq()
345 iavf_free_dma_mem(hw, &hw->aq.asq.r.asq_bi[i]); in iavf_init_asq()
346 iavf_free_virt_mem(hw, &hw->aq.asq.dma_head); in iavf_init_asq()
349 iavf_free_adminq_asq(hw); in iavf_init_asq()
357 * @hw: pointer to the hardware structure
361 * in the hw->aq structure:
362 * - hw->aq.num_asq_entries
363 * - hw->aq.arq_buf_size
368 static enum iavf_status iavf_init_arq(struct iavf_hw *hw) in iavf_init_arq() argument
373 if (hw->aq.arq.count > 0) { in iavf_init_arq()
380 if ((hw->aq.num_arq_entries == 0) || in iavf_init_arq()
381 (hw->aq.arq_buf_size == 0)) { in iavf_init_arq()
386 hw->aq.arq.next_to_use = 0; in iavf_init_arq()
387 hw->aq.arq.next_to_clean = 0; in iavf_init_arq()
390 ret_code = iavf_alloc_adminq_arq_ring(hw); in iavf_init_arq()
395 ret_code = iavf_alloc_arq_bufs(hw); in iavf_init_arq()
400 ret_code = iavf_config_arq_regs(hw); in iavf_init_arq()
405 hw->aq.arq.count = hw->aq.num_arq_entries; in iavf_init_arq()
409 for (i = 0; i < hw->aq.num_arq_entries; i++) in iavf_init_arq()
410 iavf_free_dma_mem(hw, &hw->aq.arq.r.arq_bi[i]); in iavf_init_arq()
411 iavf_free_virt_mem(hw, &hw->aq.arq.dma_head); in iavf_init_arq()
413 iavf_free_adminq_arq(hw); in iavf_init_arq()
421 * @hw: pointer to the hardware structure
425 static enum iavf_status iavf_shutdown_asq(struct iavf_hw *hw) in iavf_shutdown_asq() argument
429 mutex_lock(&hw->aq.asq_mutex); in iavf_shutdown_asq()
431 if (hw->aq.asq.count == 0) { in iavf_shutdown_asq()
437 wr32(hw, IAVF_VF_ATQH1, 0); in iavf_shutdown_asq()
438 wr32(hw, IAVF_VF_ATQT1, 0); in iavf_shutdown_asq()
439 wr32(hw, IAVF_VF_ATQLEN1, 0); in iavf_shutdown_asq()
440 wr32(hw, IAVF_VF_ATQBAL1, 0); in iavf_shutdown_asq()
441 wr32(hw, IAVF_VF_ATQBAH1, 0); in iavf_shutdown_asq()
443 hw->aq.asq.count = 0; /* to indicate uninitialized queue */ in iavf_shutdown_asq()
446 iavf_free_asq_bufs(hw); in iavf_shutdown_asq()
449 mutex_unlock(&hw->aq.asq_mutex); in iavf_shutdown_asq()
455 * @hw: pointer to the hardware structure
459 static enum iavf_status iavf_shutdown_arq(struct iavf_hw *hw) in iavf_shutdown_arq() argument
463 mutex_lock(&hw->aq.arq_mutex); in iavf_shutdown_arq()
465 if (hw->aq.arq.count == 0) { in iavf_shutdown_arq()
471 wr32(hw, IAVF_VF_ARQH1, 0); in iavf_shutdown_arq()
472 wr32(hw, IAVF_VF_ARQT1, 0); in iavf_shutdown_arq()
473 wr32(hw, IAVF_VF_ARQLEN1, 0); in iavf_shutdown_arq()
474 wr32(hw, IAVF_VF_ARQBAL1, 0); in iavf_shutdown_arq()
475 wr32(hw, IAVF_VF_ARQBAH1, 0); in iavf_shutdown_arq()
477 hw->aq.arq.count = 0; /* to indicate uninitialized queue */ in iavf_shutdown_arq()
480 iavf_free_arq_bufs(hw); in iavf_shutdown_arq()
483 mutex_unlock(&hw->aq.arq_mutex); in iavf_shutdown_arq()
489 * @hw: pointer to the hardware structure
492 * in the hw->aq structure:
493 * - hw->aq.num_asq_entries
494 * - hw->aq.num_arq_entries
495 * - hw->aq.arq_buf_size
496 * - hw->aq.asq_buf_size
498 enum iavf_status iavf_init_adminq(struct iavf_hw *hw) in iavf_init_adminq() argument
503 if ((hw->aq.num_arq_entries == 0) || in iavf_init_adminq()
504 (hw->aq.num_asq_entries == 0) || in iavf_init_adminq()
505 (hw->aq.arq_buf_size == 0) || in iavf_init_adminq()
506 (hw->aq.asq_buf_size == 0)) { in iavf_init_adminq()
512 hw->aq.asq_cmd_timeout = IAVF_ASQ_CMD_TIMEOUT; in iavf_init_adminq()
515 ret_code = iavf_init_asq(hw); in iavf_init_adminq()
520 ret_code = iavf_init_arq(hw); in iavf_init_adminq()
528 iavf_shutdown_asq(hw); in iavf_init_adminq()
537 * @hw: pointer to the hardware structure
539 enum iavf_status iavf_shutdown_adminq(struct iavf_hw *hw) in iavf_shutdown_adminq() argument
541 if (iavf_check_asq_alive(hw)) in iavf_shutdown_adminq()
542 iavf_aq_queue_shutdown(hw, true); in iavf_shutdown_adminq()
544 iavf_shutdown_asq(hw); in iavf_shutdown_adminq()
545 iavf_shutdown_arq(hw); in iavf_shutdown_adminq()
552 * @hw: pointer to the hardware structure
556 static u16 iavf_clean_asq(struct iavf_hw *hw) in iavf_clean_asq() argument
558 struct iavf_adminq_ring *asq = &hw->aq.asq; in iavf_clean_asq()
566 while (rd32(hw, IAVF_VF_ATQH1) != ntc) { in iavf_clean_asq()
567 iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE, in iavf_clean_asq()
568 "ntc %d head %d.\n", ntc, rd32(hw, IAVF_VF_ATQH1)); in iavf_clean_asq()
574 cb_func(hw, &desc_cb); in iavf_clean_asq()
593 * @hw: pointer to the hw struct
598 bool iavf_asq_done(struct iavf_hw *hw) in iavf_asq_done() argument
603 return rd32(hw, IAVF_VF_ATQH1) == hw->aq.asq.next_to_use; in iavf_asq_done()
608 * @hw: pointer to the hw struct
617 enum iavf_status iavf_asq_send_command(struct iavf_hw *hw, in iavf_asq_send_command() argument
631 mutex_lock(&hw->aq.asq_mutex); in iavf_asq_send_command()
633 if (hw->aq.asq.count == 0) { in iavf_asq_send_command()
634 iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE, in iavf_asq_send_command()
640 hw->aq.asq_last_status = IAVF_AQ_RC_OK; in iavf_asq_send_command()
642 val = rd32(hw, IAVF_VF_ATQH1); in iavf_asq_send_command()
643 if (val >= hw->aq.num_asq_entries) { in iavf_asq_send_command()
644 iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE, in iavf_asq_send_command()
650 details = IAVF_ADMINQ_DETAILS(hw->aq.asq, hw->aq.asq.next_to_use); in iavf_asq_send_command()
672 if (buff_size > hw->aq.asq_buf_size) { in iavf_asq_send_command()
673 iavf_debug(hw, in iavf_asq_send_command()
682 iavf_debug(hw, in iavf_asq_send_command()
696 if (iavf_clean_asq(hw) == 0) { in iavf_asq_send_command()
697 iavf_debug(hw, in iavf_asq_send_command()
705 desc_on_ring = IAVF_ADMINQ_DESC(hw->aq.asq, hw->aq.asq.next_to_use); in iavf_asq_send_command()
712 dma_buff = &hw->aq.asq.r.asq_bi[hw->aq.asq.next_to_use]; in iavf_asq_send_command()
727 iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE, "AQTX: desc and buffer:\n"); in iavf_asq_send_command()
728 iavf_debug_aq(hw, IAVF_DEBUG_AQ_COMMAND, (void *)desc_on_ring, in iavf_asq_send_command()
730 (hw->aq.asq.next_to_use)++; in iavf_asq_send_command()
731 if (hw->aq.asq.next_to_use == hw->aq.asq.count) in iavf_asq_send_command()
732 hw->aq.asq.next_to_use = 0; in iavf_asq_send_command()
734 wr32(hw, IAVF_VF_ATQT1, hw->aq.asq.next_to_use); in iavf_asq_send_command()
746 if (iavf_asq_done(hw)) in iavf_asq_send_command()
750 } while (total_delay < hw->aq.asq_cmd_timeout); in iavf_asq_send_command()
754 if (iavf_asq_done(hw)) { in iavf_asq_send_command()
760 iavf_debug(hw, in iavf_asq_send_command()
775 hw->aq.asq_last_status = (enum iavf_admin_queue_err)retval; in iavf_asq_send_command()
778 iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE, in iavf_asq_send_command()
780 iavf_debug_aq(hw, IAVF_DEBUG_AQ_COMMAND, (void *)desc, buff, buff_size); in iavf_asq_send_command()
789 if (rd32(hw, IAVF_VF_ATQLEN1) & IAVF_VF_ATQLEN1_ATQCRIT_MASK) { in iavf_asq_send_command()
790 iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE, in iavf_asq_send_command()
794 iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE, in iavf_asq_send_command()
801 mutex_unlock(&hw->aq.asq_mutex); in iavf_asq_send_command()
822 * @hw: pointer to the hw struct
830 enum iavf_status iavf_clean_arq_element(struct iavf_hw *hw, in iavf_clean_arq_element() argument
834 u16 ntc = hw->aq.arq.next_to_clean; in iavf_clean_arq_element()
847 mutex_lock(&hw->aq.arq_mutex); in iavf_clean_arq_element()
849 if (hw->aq.arq.count == 0) { in iavf_clean_arq_element()
850 iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE, in iavf_clean_arq_element()
857 ntu = rd32(hw, IAVF_VF_ARQH1) & IAVF_VF_ARQH1_ARQH_MASK; in iavf_clean_arq_element()
865 desc = IAVF_ADMINQ_DESC(hw->aq.arq, ntc); in iavf_clean_arq_element()
868 hw->aq.arq_last_status = in iavf_clean_arq_element()
873 iavf_debug(hw, in iavf_clean_arq_element()
876 hw->aq.arq_last_status); in iavf_clean_arq_element()
883 memcpy(e->msg_buf, hw->aq.arq.r.arq_bi[desc_idx].va, in iavf_clean_arq_element()
886 iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE, "AQRX: desc and buffer:\n"); in iavf_clean_arq_element()
887 iavf_debug_aq(hw, IAVF_DEBUG_AQ_COMMAND, (void *)desc, e->msg_buf, in iavf_clean_arq_element()
888 hw->aq.arq_buf_size); in iavf_clean_arq_element()
894 bi = &hw->aq.arq.r.arq_bi[ntc]; in iavf_clean_arq_element()
898 if (hw->aq.arq_buf_size > IAVF_AQ_LARGE_BUF) in iavf_clean_arq_element()
905 wr32(hw, IAVF_VF_ARQT1, ntc); in iavf_clean_arq_element()
908 if (ntc == hw->aq.num_arq_entries) in iavf_clean_arq_element()
910 hw->aq.arq.next_to_clean = ntc; in iavf_clean_arq_element()
911 hw->aq.arq.next_to_use = ntu; in iavf_clean_arq_element()
916 *pending = (ntc > ntu ? hw->aq.arq.count : 0) + (ntu - ntc); in iavf_clean_arq_element()
919 mutex_unlock(&hw->aq.arq_mutex); in iavf_clean_arq_element()