Lines Matching refs:p_hwfn
47 int qed_ptt_pool_alloc(struct qed_hwfn *p_hwfn) in qed_ptt_pool_alloc() argument
60 p_pool->ptts[i].hwfn_id = p_hwfn->my_id; in qed_ptt_pool_alloc()
66 p_hwfn->p_ptt_pool = p_pool; in qed_ptt_pool_alloc()
72 void qed_ptt_invalidate(struct qed_hwfn *p_hwfn) in qed_ptt_invalidate() argument
78 p_ptt = &p_hwfn->p_ptt_pool->ptts[i]; in qed_ptt_invalidate()
83 void qed_ptt_pool_free(struct qed_hwfn *p_hwfn) in qed_ptt_pool_free() argument
85 kfree(p_hwfn->p_ptt_pool); in qed_ptt_pool_free()
86 p_hwfn->p_ptt_pool = NULL; in qed_ptt_pool_free()
89 struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn) in qed_ptt_acquire() argument
91 return qed_ptt_acquire_context(p_hwfn, false); in qed_ptt_acquire()
94 struct qed_ptt *qed_ptt_acquire_context(struct qed_hwfn *p_hwfn, bool is_atomic) in qed_ptt_acquire_context() argument
106 spin_lock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_acquire_context()
108 if (!list_empty(&p_hwfn->p_ptt_pool->free_list)) { in qed_ptt_acquire_context()
109 p_ptt = list_first_entry(&p_hwfn->p_ptt_pool->free_list, in qed_ptt_acquire_context()
113 spin_unlock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_acquire_context()
115 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_ptt_acquire_context()
120 spin_unlock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_acquire_context()
129 DP_NOTICE(p_hwfn, "PTT acquire timeout - failed to allocate PTT\n"); in qed_ptt_acquire_context()
133 void qed_ptt_release(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) in qed_ptt_release() argument
135 spin_lock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_release()
136 list_add(&p_ptt->list_entry, &p_hwfn->p_ptt_pool->free_list); in qed_ptt_release()
137 spin_unlock_bh(&p_hwfn->p_ptt_pool->lock); in qed_ptt_release()
140 u32 qed_ptt_get_hw_addr(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) in qed_ptt_get_hw_addr() argument
158 void qed_ptt_set_win(struct qed_hwfn *p_hwfn, in qed_ptt_set_win() argument
163 prev_hw_addr = qed_ptt_get_hw_addr(p_hwfn, p_ptt); in qed_ptt_set_win()
169 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_ptt_set_win()
176 REG_WR(p_hwfn, in qed_ptt_set_win()
182 static u32 qed_set_ptt(struct qed_hwfn *p_hwfn, in qed_set_ptt() argument
185 u32 win_hw_addr = qed_ptt_get_hw_addr(p_hwfn, p_ptt); in qed_set_ptt()
190 if (p_ptt->hwfn_id != p_hwfn->my_id) in qed_set_ptt()
191 DP_NOTICE(p_hwfn, in qed_set_ptt()
193 p_ptt->idx, p_ptt->hwfn_id, p_hwfn->my_id); in qed_set_ptt()
198 qed_ptt_set_win(p_hwfn, p_ptt, hw_addr); in qed_set_ptt()
205 struct qed_ptt *qed_get_reserved_ptt(struct qed_hwfn *p_hwfn, in qed_get_reserved_ptt() argument
209 DP_NOTICE(p_hwfn, in qed_get_reserved_ptt()
214 return &p_hwfn->p_ptt_pool->ptts[ptt_idx]; in qed_get_reserved_ptt()
217 void qed_wr(struct qed_hwfn *p_hwfn, in qed_wr() argument
221 u32 bar_addr = qed_set_ptt(p_hwfn, p_ptt, hw_addr); in qed_wr()
223 REG_WR(p_hwfn, bar_addr, val); in qed_wr()
224 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_wr()
229 u32 qed_rd(struct qed_hwfn *p_hwfn, in qed_rd() argument
233 u32 bar_addr = qed_set_ptt(p_hwfn, p_ptt, hw_addr); in qed_rd()
234 u32 val = REG_RD(p_hwfn, bar_addr); in qed_rd()
236 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_rd()
243 static void qed_memcpy_hw(struct qed_hwfn *p_hwfn, in qed_memcpy_hw() argument
255 if (IS_PF(p_hwfn->cdev)) { in qed_memcpy_hw()
256 qed_ptt_set_win(p_hwfn, p_ptt, hw_addr + done); in qed_memcpy_hw()
264 reg_addr = (u32 __iomem *)REG_ADDR(p_hwfn, hw_offset); in qed_memcpy_hw()
276 void qed_memcpy_from(struct qed_hwfn *p_hwfn, in qed_memcpy_from() argument
279 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_memcpy_from()
283 qed_memcpy_hw(p_hwfn, p_ptt, dest, hw_addr, n, false); in qed_memcpy_from()
286 void qed_memcpy_to(struct qed_hwfn *p_hwfn, in qed_memcpy_to() argument
289 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_memcpy_to()
293 qed_memcpy_hw(p_hwfn, p_ptt, src, hw_addr, n, true); in qed_memcpy_to()
296 void qed_fid_pretend(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, u16 fid) in qed_fid_pretend() argument
316 REG_WR(p_hwfn, in qed_fid_pretend()
322 void qed_port_pretend(struct qed_hwfn *p_hwfn, in qed_port_pretend() argument
333 REG_WR(p_hwfn, in qed_port_pretend()
339 void qed_port_unpretend(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) in qed_port_unpretend() argument
349 REG_WR(p_hwfn, in qed_port_unpretend()
355 void qed_port_fid_pretend(struct qed_hwfn *p_hwfn, in qed_port_fid_pretend() argument
369 REG_WR(p_hwfn, in qed_port_fid_pretend()
375 u32 qed_vfid_to_concrete(struct qed_hwfn *p_hwfn, u8 vfid) in qed_vfid_to_concrete() argument
379 SET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID, p_hwfn->rel_pf_id); in qed_vfid_to_concrete()
390 static void qed_dmae_opcode(struct qed_hwfn *p_hwfn, in qed_dmae_opcode() argument
406 p_params->src_pfid : p_hwfn->rel_pf_id; in qed_dmae_opcode()
413 p_params->dst_pfid : p_hwfn->rel_pf_id; in qed_dmae_opcode()
431 p_params->port_id : p_hwfn->port_id; in qed_dmae_opcode()
454 p_hwfn->dmae_info.p_dmae_cmd->opcode = cpu_to_le32(opcode); in qed_dmae_opcode()
455 p_hwfn->dmae_info.p_dmae_cmd->opcode_b = cpu_to_le16(opcode_b); in qed_dmae_opcode()
464 static int qed_dmae_post_command(struct qed_hwfn *p_hwfn, in qed_dmae_post_command() argument
467 struct dmae_cmd *p_command = p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_post_command()
468 u8 idx_cmd = p_hwfn->dmae_info.channel, i; in qed_dmae_post_command()
474 DP_NOTICE(p_hwfn, in qed_dmae_post_command()
489 DP_VERBOSE(p_hwfn, in qed_dmae_post_command()
511 qed_wr(p_hwfn, p_ptt, in qed_dmae_post_command()
517 qed_wr(p_hwfn, p_ptt, qed_dmae_idx_to_go_cmd(idx_cmd), DMAE_GO_VALUE); in qed_dmae_post_command()
522 int qed_dmae_info_alloc(struct qed_hwfn *p_hwfn) in qed_dmae_info_alloc() argument
524 dma_addr_t *p_addr = &p_hwfn->dmae_info.completion_word_phys_addr; in qed_dmae_info_alloc()
525 struct dmae_cmd **p_cmd = &p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_info_alloc()
526 u32 **p_buff = &p_hwfn->dmae_info.p_intermediate_buffer; in qed_dmae_info_alloc()
527 u32 **p_comp = &p_hwfn->dmae_info.p_completion_word; in qed_dmae_info_alloc()
529 *p_comp = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_alloc()
534 p_addr = &p_hwfn->dmae_info.dmae_cmd_phys_addr; in qed_dmae_info_alloc()
535 *p_cmd = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_alloc()
541 p_addr = &p_hwfn->dmae_info.intermediate_buffer_phys_addr; in qed_dmae_info_alloc()
542 *p_buff = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_alloc()
548 p_hwfn->dmae_info.channel = p_hwfn->rel_pf_id; in qed_dmae_info_alloc()
552 qed_dmae_info_free(p_hwfn); in qed_dmae_info_alloc()
556 void qed_dmae_info_free(struct qed_hwfn *p_hwfn) in qed_dmae_info_free() argument
561 mutex_lock(&p_hwfn->dmae_info.mutex); in qed_dmae_info_free()
563 if (p_hwfn->dmae_info.p_completion_word) { in qed_dmae_info_free()
564 p_phys = p_hwfn->dmae_info.completion_word_phys_addr; in qed_dmae_info_free()
565 dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_free()
567 p_hwfn->dmae_info.p_completion_word, p_phys); in qed_dmae_info_free()
568 p_hwfn->dmae_info.p_completion_word = NULL; in qed_dmae_info_free()
571 if (p_hwfn->dmae_info.p_dmae_cmd) { in qed_dmae_info_free()
572 p_phys = p_hwfn->dmae_info.dmae_cmd_phys_addr; in qed_dmae_info_free()
573 dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_free()
575 p_hwfn->dmae_info.p_dmae_cmd, p_phys); in qed_dmae_info_free()
576 p_hwfn->dmae_info.p_dmae_cmd = NULL; in qed_dmae_info_free()
579 if (p_hwfn->dmae_info.p_intermediate_buffer) { in qed_dmae_info_free()
580 p_phys = p_hwfn->dmae_info.intermediate_buffer_phys_addr; in qed_dmae_info_free()
581 dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_info_free()
583 p_hwfn->dmae_info.p_intermediate_buffer, in qed_dmae_info_free()
585 p_hwfn->dmae_info.p_intermediate_buffer = NULL; in qed_dmae_info_free()
588 mutex_unlock(&p_hwfn->dmae_info.mutex); in qed_dmae_info_free()
591 static int qed_dmae_operation_wait(struct qed_hwfn *p_hwfn) in qed_dmae_operation_wait() argument
597 while (*p_hwfn->dmae_info.p_completion_word != DMAE_COMPLETION_VAL) { in qed_dmae_operation_wait()
600 DP_NOTICE(p_hwfn->cdev, in qed_dmae_operation_wait()
602 *p_hwfn->dmae_info.p_completion_word, in qed_dmae_operation_wait()
615 *p_hwfn->dmae_info.p_completion_word = 0; in qed_dmae_operation_wait()
620 static int qed_dmae_execute_sub_operation(struct qed_hwfn *p_hwfn, in qed_dmae_execute_sub_operation() argument
628 dma_addr_t phys = p_hwfn->dmae_info.intermediate_buffer_phys_addr; in qed_dmae_execute_sub_operation()
629 struct dmae_cmd *cmd = p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_execute_sub_operation()
642 memcpy(&p_hwfn->dmae_info.p_intermediate_buffer[0], in qed_dmae_execute_sub_operation()
667 qed_dmae_post_command(p_hwfn, p_ptt); in qed_dmae_execute_sub_operation()
669 qed_status = qed_dmae_operation_wait(p_hwfn); in qed_dmae_execute_sub_operation()
672 DP_NOTICE(p_hwfn, in qed_dmae_execute_sub_operation()
680 &p_hwfn->dmae_info.p_intermediate_buffer[0], in qed_dmae_execute_sub_operation()
686 static int qed_dmae_execute_command(struct qed_hwfn *p_hwfn, in qed_dmae_execute_command() argument
693 dma_addr_t phys = p_hwfn->dmae_info.completion_word_phys_addr; in qed_dmae_execute_command()
695 struct dmae_cmd *cmd = p_hwfn->dmae_info.p_dmae_cmd; in qed_dmae_execute_command()
701 if (p_hwfn->cdev->recov_in_prog) { in qed_dmae_execute_command()
702 DP_VERBOSE(p_hwfn, in qed_dmae_execute_command()
712 qed_dmae_opcode(p_hwfn, in qed_dmae_execute_command()
749 qed_status = qed_dmae_execute_sub_operation(p_hwfn, in qed_dmae_execute_command()
757 qed_hw_err_notify(p_hwfn, p_ptt, QED_HW_ERR_DMAE_FAIL, in qed_dmae_execute_command()
768 int qed_dmae_host2grc(struct qed_hwfn *p_hwfn, in qed_dmae_host2grc() argument
777 mutex_lock(&p_hwfn->dmae_info.mutex); in qed_dmae_host2grc()
779 rc = qed_dmae_execute_command(p_hwfn, p_ptt, source_addr, in qed_dmae_host2grc()
785 mutex_unlock(&p_hwfn->dmae_info.mutex); in qed_dmae_host2grc()
790 int qed_dmae_grc2host(struct qed_hwfn *p_hwfn, in qed_dmae_grc2host() argument
800 mutex_lock(&p_hwfn->dmae_info.mutex); in qed_dmae_grc2host()
802 rc = qed_dmae_execute_command(p_hwfn, p_ptt, grc_addr_in_dw, in qed_dmae_grc2host()
807 mutex_unlock(&p_hwfn->dmae_info.mutex); in qed_dmae_grc2host()
812 int qed_dmae_host2host(struct qed_hwfn *p_hwfn, in qed_dmae_host2host() argument
820 mutex_lock(&(p_hwfn->dmae_info.mutex)); in qed_dmae_host2host()
822 rc = qed_dmae_execute_command(p_hwfn, p_ptt, source_addr, in qed_dmae_host2host()
828 mutex_unlock(&(p_hwfn->dmae_info.mutex)); in qed_dmae_host2host()
833 void qed_hw_err_notify(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, in qed_hw_err_notify() argument
848 DP_NOTICE(p_hwfn, "%s", buf); in qed_hw_err_notify()
852 if (p_hwfn->cdev->recov_in_prog && in qed_hw_err_notify()
854 DP_VERBOSE(p_hwfn, in qed_hw_err_notify()
861 qed_hw_error_occurred(p_hwfn, err_type); in qed_hw_err_notify()
864 qed_mcp_send_raw_debug_data(p_hwfn, p_ptt, buf, len); in qed_hw_err_notify()
867 int qed_dmae_sanity(struct qed_hwfn *p_hwfn, in qed_dmae_sanity() argument
876 p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_dmae_sanity()
879 DP_NOTICE(p_hwfn, in qed_dmae_sanity()
896 DP_VERBOSE(p_hwfn, in qed_dmae_sanity()
903 rc = qed_dmae_host2host(p_hwfn, p_ptt, p_phys, p_phys + size, in qed_dmae_sanity()
906 DP_NOTICE(p_hwfn, in qed_dmae_sanity()
919 DP_NOTICE(p_hwfn, in qed_dmae_sanity()
930 dma_free_coherent(&p_hwfn->cdev->pdev->dev, 2 * size, p_virt, p_phys); in qed_dmae_sanity()