Lines Matching refs:p_hwfn
44 int qed_ptt_pool_alloc(struct qed_hwfn *p_hwfn) in qed_ptt_pool_alloc() argument
57 p_pool->ptts[i].hwfn_id = p_hwfn->my_id; in qed_ptt_pool_alloc()
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, struct qed_ptt *p_ptt) in qed_ptt_release() argument
117 spin_lock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_release()
118 list_add(&p_ptt->list_entry, &p_hwfn->p_ptt_pool->free_list); in qed_ptt_release()
119 spin_unlock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_release()
122 u32 qed_ptt_get_hw_addr(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) in qed_ptt_get_hw_addr() argument
140 void qed_ptt_set_win(struct qed_hwfn *p_hwfn, in qed_ptt_set_win() argument
145 prev_hw_addr = qed_ptt_get_hw_addr(p_hwfn, p_ptt); in qed_ptt_set_win()
151 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_ptt_set_win()
158 REG_WR(p_hwfn, in qed_ptt_set_win()
164 static u32 qed_set_ptt(struct qed_hwfn *p_hwfn, in qed_set_ptt() argument
167 u32 win_hw_addr = qed_ptt_get_hw_addr(p_hwfn, p_ptt); in qed_set_ptt()
172 if (p_ptt->hwfn_id != p_hwfn->my_id) in qed_set_ptt()
173 DP_NOTICE(p_hwfn, in qed_set_ptt()
175 p_ptt->idx, p_ptt->hwfn_id, p_hwfn->my_id); in qed_set_ptt()
180 qed_ptt_set_win(p_hwfn, p_ptt, hw_addr); in qed_set_ptt()
187 struct qed_ptt *qed_get_reserved_ptt(struct qed_hwfn *p_hwfn, in qed_get_reserved_ptt() argument
191 DP_NOTICE(p_hwfn, in qed_get_reserved_ptt()
196 return &p_hwfn->p_ptt_pool->ptts[ptt_idx]; in qed_get_reserved_ptt()
199 void qed_wr(struct qed_hwfn *p_hwfn, in qed_wr() argument
203 u32 bar_addr = qed_set_ptt(p_hwfn, p_ptt, hw_addr); in qed_wr()
205 REG_WR(p_hwfn, bar_addr, val); in qed_wr()
206 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_wr()
211 u32 qed_rd(struct qed_hwfn *p_hwfn, in qed_rd() argument
215 u32 bar_addr = qed_set_ptt(p_hwfn, p_ptt, hw_addr); in qed_rd()
216 u32 val = REG_RD(p_hwfn, bar_addr); in qed_rd()
218 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_rd()
225 static void qed_memcpy_hw(struct qed_hwfn *p_hwfn, in qed_memcpy_hw() argument
237 if (IS_PF(p_hwfn->cdev)) { in qed_memcpy_hw()
238 qed_ptt_set_win(p_hwfn, p_ptt, hw_addr + done); in qed_memcpy_hw()
246 reg_addr = (u32 __iomem *)REG_ADDR(p_hwfn, hw_offset); in qed_memcpy_hw()
258 void qed_memcpy_from(struct qed_hwfn *p_hwfn, in qed_memcpy_from() argument
261 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_memcpy_from()
265 qed_memcpy_hw(p_hwfn, p_ptt, dest, hw_addr, n, false); in qed_memcpy_from()
268 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, struct qed_ptt *p_ptt, u16 fid) in qed_fid_pretend() argument
298 REG_WR(p_hwfn, in qed_fid_pretend()
304 void qed_port_pretend(struct qed_hwfn *p_hwfn, in qed_port_pretend() argument
315 REG_WR(p_hwfn, in qed_port_pretend()
321 void qed_port_unpretend(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) in qed_port_unpretend() argument
331 REG_WR(p_hwfn, in qed_port_unpretend()
337 void qed_port_fid_pretend(struct qed_hwfn *p_hwfn, in qed_port_fid_pretend() argument
351 REG_WR(p_hwfn, in qed_port_fid_pretend()
357 u32 qed_vfid_to_concrete(struct qed_hwfn *p_hwfn, u8 vfid) in qed_vfid_to_concrete() argument
361 SET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID, p_hwfn->rel_pf_id); in qed_vfid_to_concrete()
372 static void qed_dmae_opcode(struct qed_hwfn *p_hwfn, in qed_dmae_opcode() argument
388 p_params->src_pfid : p_hwfn->rel_pf_id; in qed_dmae_opcode()
395 p_params->dst_pfid : p_hwfn->rel_pf_id; in qed_dmae_opcode()
413 p_params->port_id : p_hwfn->port_id; in qed_dmae_opcode()
436 p_hwfn->dmae_info.p_dmae_cmd->opcode = cpu_to_le32(opcode); in qed_dmae_opcode()
437 p_hwfn->dmae_info.p_dmae_cmd->opcode_b = cpu_to_le16(opcode_b); in qed_dmae_opcode()
446 static int qed_dmae_post_command(struct qed_hwfn *p_hwfn, in qed_dmae_post_command() argument
449 struct dmae_cmd *p_command = p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_post_command()
450 u8 idx_cmd = p_hwfn->dmae_info.channel, i; in qed_dmae_post_command()
456 DP_NOTICE(p_hwfn, in qed_dmae_post_command()
471 DP_VERBOSE(p_hwfn, in qed_dmae_post_command()
493 qed_wr(p_hwfn, p_ptt, in qed_dmae_post_command()
499 qed_wr(p_hwfn, p_ptt, qed_dmae_idx_to_go_cmd(idx_cmd), DMAE_GO_VALUE); in qed_dmae_post_command()
504 int qed_dmae_info_alloc(struct qed_hwfn *p_hwfn) in qed_dmae_info_alloc() argument
506 dma_addr_t *p_addr = &p_hwfn->dmae_info.completion_word_phys_addr; in qed_dmae_info_alloc()
507 struct dmae_cmd **p_cmd = &p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_info_alloc()
508 u32 **p_buff = &p_hwfn->dmae_info.p_intermediate_buffer; in qed_dmae_info_alloc()
509 u32 **p_comp = &p_hwfn->dmae_info.p_completion_word; in qed_dmae_info_alloc()
511 *p_comp = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_alloc()
516 p_addr = &p_hwfn->dmae_info.dmae_cmd_phys_addr; in qed_dmae_info_alloc()
517 *p_cmd = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_alloc()
523 p_addr = &p_hwfn->dmae_info.intermediate_buffer_phys_addr; in qed_dmae_info_alloc()
524 *p_buff = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_alloc()
530 p_hwfn->dmae_info.channel = p_hwfn->rel_pf_id; in qed_dmae_info_alloc()
534 qed_dmae_info_free(p_hwfn); in qed_dmae_info_alloc()
538 void qed_dmae_info_free(struct qed_hwfn *p_hwfn) in qed_dmae_info_free() argument
543 mutex_lock(&p_hwfn->dmae_info.mutex); in qed_dmae_info_free()
545 if (p_hwfn->dmae_info.p_completion_word) { in qed_dmae_info_free()
546 p_phys = p_hwfn->dmae_info.completion_word_phys_addr; in qed_dmae_info_free()
547 dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_free()
549 p_hwfn->dmae_info.p_completion_word, p_phys); in qed_dmae_info_free()
550 p_hwfn->dmae_info.p_completion_word = NULL; in qed_dmae_info_free()
553 if (p_hwfn->dmae_info.p_dmae_cmd) { in qed_dmae_info_free()
554 p_phys = p_hwfn->dmae_info.dmae_cmd_phys_addr; in qed_dmae_info_free()
555 dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_free()
557 p_hwfn->dmae_info.p_dmae_cmd, p_phys); in qed_dmae_info_free()
558 p_hwfn->dmae_info.p_dmae_cmd = NULL; in qed_dmae_info_free()
561 if (p_hwfn->dmae_info.p_intermediate_buffer) { in qed_dmae_info_free()
562 p_phys = p_hwfn->dmae_info.intermediate_buffer_phys_addr; in qed_dmae_info_free()
563 dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_free()
565 p_hwfn->dmae_info.p_intermediate_buffer, in qed_dmae_info_free()
567 p_hwfn->dmae_info.p_intermediate_buffer = NULL; in qed_dmae_info_free()
570 mutex_unlock(&p_hwfn->dmae_info.mutex); in qed_dmae_info_free()
573 static int qed_dmae_operation_wait(struct qed_hwfn *p_hwfn) in qed_dmae_operation_wait() argument
579 while (*p_hwfn->dmae_info.p_completion_word != DMAE_COMPLETION_VAL) { in qed_dmae_operation_wait()
582 DP_NOTICE(p_hwfn->cdev, in qed_dmae_operation_wait()
584 *p_hwfn->dmae_info.p_completion_word, in qed_dmae_operation_wait()
597 *p_hwfn->dmae_info.p_completion_word = 0; in qed_dmae_operation_wait()
602 static int qed_dmae_execute_sub_operation(struct qed_hwfn *p_hwfn, in qed_dmae_execute_sub_operation() argument
610 dma_addr_t phys = p_hwfn->dmae_info.intermediate_buffer_phys_addr; in qed_dmae_execute_sub_operation()
611 struct dmae_cmd *cmd = p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_execute_sub_operation()
624 memcpy(&p_hwfn->dmae_info.p_intermediate_buffer[0], in qed_dmae_execute_sub_operation()
649 qed_dmae_post_command(p_hwfn, p_ptt); in qed_dmae_execute_sub_operation()
651 qed_status = qed_dmae_operation_wait(p_hwfn); in qed_dmae_execute_sub_operation()
654 DP_NOTICE(p_hwfn, in qed_dmae_execute_sub_operation()
662 &p_hwfn->dmae_info.p_intermediate_buffer[0], in qed_dmae_execute_sub_operation()
668 static int qed_dmae_execute_command(struct qed_hwfn *p_hwfn, in qed_dmae_execute_command() argument
675 dma_addr_t phys = p_hwfn->dmae_info.completion_word_phys_addr; in qed_dmae_execute_command()
677 struct dmae_cmd *cmd = p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_execute_command()
683 if (p_hwfn->cdev->recov_in_prog) { in qed_dmae_execute_command()
684 DP_VERBOSE(p_hwfn, in qed_dmae_execute_command()
694 qed_dmae_opcode(p_hwfn, in qed_dmae_execute_command()
731 qed_status = qed_dmae_execute_sub_operation(p_hwfn, in qed_dmae_execute_command()
739 qed_hw_err_notify(p_hwfn, p_ptt, QED_HW_ERR_DMAE_FAIL, in qed_dmae_execute_command()
750 int qed_dmae_host2grc(struct qed_hwfn *p_hwfn, in qed_dmae_host2grc() argument
759 mutex_lock(&p_hwfn->dmae_info.mutex); in qed_dmae_host2grc()
761 rc = qed_dmae_execute_command(p_hwfn, p_ptt, source_addr, in qed_dmae_host2grc()
767 mutex_unlock(&p_hwfn->dmae_info.mutex); in qed_dmae_host2grc()
772 int qed_dmae_grc2host(struct qed_hwfn *p_hwfn, in qed_dmae_grc2host() argument
782 mutex_lock(&p_hwfn->dmae_info.mutex); in qed_dmae_grc2host()
784 rc = qed_dmae_execute_command(p_hwfn, p_ptt, grc_addr_in_dw, in qed_dmae_grc2host()
789 mutex_unlock(&p_hwfn->dmae_info.mutex); in qed_dmae_grc2host()
794 int qed_dmae_host2host(struct qed_hwfn *p_hwfn, in qed_dmae_host2host() argument
802 mutex_lock(&(p_hwfn->dmae_info.mutex)); in qed_dmae_host2host()
804 rc = qed_dmae_execute_command(p_hwfn, p_ptt, source_addr, in qed_dmae_host2host()
810 mutex_unlock(&(p_hwfn->dmae_info.mutex)); in qed_dmae_host2host()
815 void qed_hw_err_notify(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, in qed_hw_err_notify() argument
830 DP_NOTICE(p_hwfn, "%s", buf); in qed_hw_err_notify()
834 if (p_hwfn->cdev->recov_in_prog && in qed_hw_err_notify()
836 DP_VERBOSE(p_hwfn, in qed_hw_err_notify()
843 qed_hw_error_occurred(p_hwfn, err_type); in qed_hw_err_notify()
846 qed_mcp_send_raw_debug_data(p_hwfn, p_ptt, buf, len); in qed_hw_err_notify()
849 int qed_dmae_sanity(struct qed_hwfn *p_hwfn, in qed_dmae_sanity() argument
858 p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_sanity()
861 DP_NOTICE(p_hwfn, in qed_dmae_sanity()
878 DP_VERBOSE(p_hwfn, in qed_dmae_sanity()
885 rc = qed_dmae_host2host(p_hwfn, p_ptt, p_phys, p_phys + size, in qed_dmae_sanity()
888 DP_NOTICE(p_hwfn, in qed_dmae_sanity()
901 DP_NOTICE(p_hwfn, in qed_dmae_sanity()
912 dma_free_coherent(&p_hwfn->cdev->pdev->dev, 2 * size, p_virt, p_phys); in qed_dmae_sanity()