Lines Matching refs:p_hwfn
44 int qed_ptt_pool_alloc(struct qed_hwfn *p_hwfn) in qed_ptt_pool_alloc() argument
63 p_hwfn->p_ptt_pool = p_pool; in qed_ptt_pool_alloc()
69 void qed_ptt_invalidate(struct qed_hwfn *p_hwfn) in qed_ptt_invalidate() argument
75 p_ptt = &p_hwfn->p_ptt_pool->ptts[i]; in qed_ptt_invalidate()
80 void qed_ptt_pool_free(struct qed_hwfn *p_hwfn) in qed_ptt_pool_free() argument
82 kfree(p_hwfn->p_ptt_pool); in qed_ptt_pool_free()
83 p_hwfn->p_ptt_pool = NULL; in qed_ptt_pool_free()
86 struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn) in qed_ptt_acquire() argument
93 spin_lock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_acquire()
95 if (!list_empty(&p_hwfn->p_ptt_pool->free_list)) { in qed_ptt_acquire()
96 p_ptt = list_first_entry(&p_hwfn->p_ptt_pool->free_list, in qed_ptt_acquire()
100 spin_unlock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_acquire()
102 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_ptt_acquire()
107 spin_unlock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_acquire()
111 DP_NOTICE(p_hwfn, "PTT acquire timeout - failed to allocate PTT\n"); in qed_ptt_acquire()
115 void qed_ptt_release(struct qed_hwfn *p_hwfn, in qed_ptt_release() argument
118 spin_lock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_release()
119 list_add(&p_ptt->list_entry, &p_hwfn->p_ptt_pool->free_list); in qed_ptt_release()
120 spin_unlock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_release()
123 u32 qed_ptt_get_hw_addr(struct qed_hwfn *p_hwfn, in qed_ptt_get_hw_addr() argument
142 void qed_ptt_set_win(struct qed_hwfn *p_hwfn, in qed_ptt_set_win() argument
148 prev_hw_addr = qed_ptt_get_hw_addr(p_hwfn, p_ptt); in qed_ptt_set_win()
154 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_ptt_set_win()
161 REG_WR(p_hwfn, in qed_ptt_set_win()
167 static u32 qed_set_ptt(struct qed_hwfn *p_hwfn, in qed_set_ptt() argument
171 u32 win_hw_addr = qed_ptt_get_hw_addr(p_hwfn, p_ptt); in qed_set_ptt()
179 qed_ptt_set_win(p_hwfn, p_ptt, hw_addr); in qed_set_ptt()
186 struct qed_ptt *qed_get_reserved_ptt(struct qed_hwfn *p_hwfn, in qed_get_reserved_ptt() argument
190 DP_NOTICE(p_hwfn, in qed_get_reserved_ptt()
195 return &p_hwfn->p_ptt_pool->ptts[ptt_idx]; in qed_get_reserved_ptt()
198 void qed_wr(struct qed_hwfn *p_hwfn, in qed_wr() argument
202 u32 bar_addr = qed_set_ptt(p_hwfn, p_ptt, hw_addr); in qed_wr()
204 REG_WR(p_hwfn, bar_addr, val); in qed_wr()
205 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_wr()
210 u32 qed_rd(struct qed_hwfn *p_hwfn, in qed_rd() argument
214 u32 bar_addr = qed_set_ptt(p_hwfn, p_ptt, hw_addr); in qed_rd()
215 u32 val = REG_RD(p_hwfn, bar_addr); in qed_rd()
217 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_rd()
224 static void qed_memcpy_hw(struct qed_hwfn *p_hwfn, in qed_memcpy_hw() argument
239 qed_ptt_set_win(p_hwfn, p_ptt, hw_addr + done); in qed_memcpy_hw()
244 reg_addr = (u32 __iomem *)REG_ADDR(p_hwfn, hw_offset); in qed_memcpy_hw()
256 void qed_memcpy_from(struct qed_hwfn *p_hwfn, in qed_memcpy_from() argument
260 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_memcpy_from()
264 qed_memcpy_hw(p_hwfn, p_ptt, dest, hw_addr, n, false); in qed_memcpy_from()
267 void qed_memcpy_to(struct qed_hwfn *p_hwfn, in qed_memcpy_to() argument
271 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_memcpy_to()
275 qed_memcpy_hw(p_hwfn, p_ptt, src, hw_addr, n, true); in qed_memcpy_to()
278 void qed_fid_pretend(struct qed_hwfn *p_hwfn, in qed_fid_pretend() argument
300 REG_WR(p_hwfn, in qed_fid_pretend()
306 void qed_port_pretend(struct qed_hwfn *p_hwfn, in qed_port_pretend() argument
318 REG_WR(p_hwfn, in qed_port_pretend()
324 void qed_port_unpretend(struct qed_hwfn *p_hwfn, in qed_port_unpretend() argument
335 REG_WR(p_hwfn, in qed_port_unpretend()
342 static void qed_dmae_opcode(struct qed_hwfn *p_hwfn, in qed_dmae_opcode() argument
357 opcode |= ((p_hwfn->rel_pf_id & DMAE_CMD_SRC_PF_ID_MASK) << in qed_dmae_opcode()
364 opcode |= ((p_hwfn->rel_pf_id & DMAE_CMD_DST_PF_ID_MASK) << in qed_dmae_opcode()
380 opcode |= ((p_hwfn->port_id) << DMAE_CMD_PORT_ID_SHIFT); in qed_dmae_opcode()
396 p_hwfn->dmae_info.p_dmae_cmd->opcode = cpu_to_le32(opcode); in qed_dmae_opcode()
397 p_hwfn->dmae_info.p_dmae_cmd->opcode_b = cpu_to_le16(opcodeB); in qed_dmae_opcode()
407 qed_dmae_post_command(struct qed_hwfn *p_hwfn, in qed_dmae_post_command() argument
410 struct dmae_cmd *command = p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_post_command()
411 u8 idx_cmd = p_hwfn->dmae_info.channel, i; in qed_dmae_post_command()
417 DP_NOTICE(p_hwfn, in qed_dmae_post_command()
432 DP_VERBOSE(p_hwfn, in qed_dmae_post_command()
454 qed_wr(p_hwfn, p_ptt, in qed_dmae_post_command()
460 qed_wr(p_hwfn, p_ptt, in qed_dmae_post_command()
467 int qed_dmae_info_alloc(struct qed_hwfn *p_hwfn) in qed_dmae_info_alloc() argument
469 dma_addr_t *p_addr = &p_hwfn->dmae_info.completion_word_phys_addr; in qed_dmae_info_alloc()
470 struct dmae_cmd **p_cmd = &p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_info_alloc()
471 u32 **p_buff = &p_hwfn->dmae_info.p_intermediate_buffer; in qed_dmae_info_alloc()
472 u32 **p_comp = &p_hwfn->dmae_info.p_completion_word; in qed_dmae_info_alloc()
474 *p_comp = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_alloc()
479 DP_NOTICE(p_hwfn, "Failed to allocate `p_completion_word'\n"); in qed_dmae_info_alloc()
483 p_addr = &p_hwfn->dmae_info.dmae_cmd_phys_addr; in qed_dmae_info_alloc()
484 *p_cmd = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_alloc()
488 DP_NOTICE(p_hwfn, "Failed to allocate `struct dmae_cmd'\n"); in qed_dmae_info_alloc()
492 p_addr = &p_hwfn->dmae_info.intermediate_buffer_phys_addr; in qed_dmae_info_alloc()
493 *p_buff = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_alloc()
497 DP_NOTICE(p_hwfn, "Failed to allocate `intermediate_buffer'\n"); in qed_dmae_info_alloc()
501 p_hwfn->dmae_info.channel = p_hwfn->rel_pf_id; in qed_dmae_info_alloc()
505 qed_dmae_info_free(p_hwfn); in qed_dmae_info_alloc()
509 void qed_dmae_info_free(struct qed_hwfn *p_hwfn) in qed_dmae_info_free() argument
514 mutex_lock(&p_hwfn->dmae_info.mutex); in qed_dmae_info_free()
516 if (p_hwfn->dmae_info.p_completion_word) { in qed_dmae_info_free()
517 p_phys = p_hwfn->dmae_info.completion_word_phys_addr; in qed_dmae_info_free()
518 dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_free()
520 p_hwfn->dmae_info.p_completion_word, in qed_dmae_info_free()
522 p_hwfn->dmae_info.p_completion_word = NULL; in qed_dmae_info_free()
525 if (p_hwfn->dmae_info.p_dmae_cmd) { in qed_dmae_info_free()
526 p_phys = p_hwfn->dmae_info.dmae_cmd_phys_addr; in qed_dmae_info_free()
527 dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_free()
529 p_hwfn->dmae_info.p_dmae_cmd, in qed_dmae_info_free()
531 p_hwfn->dmae_info.p_dmae_cmd = NULL; in qed_dmae_info_free()
534 if (p_hwfn->dmae_info.p_intermediate_buffer) { in qed_dmae_info_free()
535 p_phys = p_hwfn->dmae_info.intermediate_buffer_phys_addr; in qed_dmae_info_free()
536 dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_free()
538 p_hwfn->dmae_info.p_intermediate_buffer, in qed_dmae_info_free()
540 p_hwfn->dmae_info.p_intermediate_buffer = NULL; in qed_dmae_info_free()
543 mutex_unlock(&p_hwfn->dmae_info.mutex); in qed_dmae_info_free()
546 static int qed_dmae_operation_wait(struct qed_hwfn *p_hwfn) in qed_dmae_operation_wait() argument
554 while (*p_hwfn->dmae_info.p_completion_word != DMAE_COMPLETION_VAL) { in qed_dmae_operation_wait()
557 DP_NOTICE(p_hwfn->cdev, in qed_dmae_operation_wait()
559 *p_hwfn->dmae_info.p_completion_word, in qed_dmae_operation_wait()
572 *p_hwfn->dmae_info.p_completion_word = 0; in qed_dmae_operation_wait()
577 static int qed_dmae_execute_sub_operation(struct qed_hwfn *p_hwfn, in qed_dmae_execute_sub_operation() argument
585 dma_addr_t phys = p_hwfn->dmae_info.intermediate_buffer_phys_addr; in qed_dmae_execute_sub_operation()
586 struct dmae_cmd *cmd = p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_execute_sub_operation()
599 memcpy(&p_hwfn->dmae_info.p_intermediate_buffer[0], in qed_dmae_execute_sub_operation()
624 qed_dmae_post_command(p_hwfn, p_ptt); in qed_dmae_execute_sub_operation()
626 qed_status = qed_dmae_operation_wait(p_hwfn); in qed_dmae_execute_sub_operation()
629 DP_NOTICE(p_hwfn, in qed_dmae_execute_sub_operation()
639 &p_hwfn->dmae_info.p_intermediate_buffer[0], in qed_dmae_execute_sub_operation()
645 static int qed_dmae_execute_command(struct qed_hwfn *p_hwfn, in qed_dmae_execute_command() argument
652 dma_addr_t phys = p_hwfn->dmae_info.completion_word_phys_addr; in qed_dmae_execute_command()
654 struct dmae_cmd *cmd = p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_execute_command()
660 qed_dmae_opcode(p_hwfn, in qed_dmae_execute_command()
697 qed_status = qed_dmae_execute_sub_operation(p_hwfn, in qed_dmae_execute_command()
705 DP_NOTICE(p_hwfn, in qed_dmae_execute_command()
718 int qed_dmae_host2grc(struct qed_hwfn *p_hwfn, in qed_dmae_host2grc() argument
732 mutex_lock(&p_hwfn->dmae_info.mutex); in qed_dmae_host2grc()
734 rc = qed_dmae_execute_command(p_hwfn, p_ptt, source_addr, in qed_dmae_host2grc()
740 mutex_unlock(&p_hwfn->dmae_info.mutex); in qed_dmae_host2grc()
745 u16 qed_get_qm_pq(struct qed_hwfn *p_hwfn, in qed_get_qm_pq() argument
753 DP_NOTICE(p_hwfn, in qed_get_qm_pq()
762 pq_id = p_hwfn->qm_info.pure_lb_pq; in qed_get_qm_pq()
764 pq_id = p_hwfn->qm_info.offload_pq; in qed_get_qm_pq()
773 pq_id = CM_TX_PQ_BASE + pq_id + RESC_START(p_hwfn, QED_PQ); in qed_get_qm_pq()