Lines Matching refs:p_hwfn
38 int qed_rdma_bmap_alloc(struct qed_hwfn *p_hwfn, in qed_rdma_bmap_alloc() argument
41 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "max_count = %08x\n", max_count); in qed_rdma_bmap_alloc()
52 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "0\n"); in qed_rdma_bmap_alloc()
56 int qed_rdma_bmap_alloc_id(struct qed_hwfn *p_hwfn, in qed_rdma_bmap_alloc_id() argument
65 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "%s bitmap: allocated id %d\n", in qed_rdma_bmap_alloc_id()
71 void qed_bmap_set_id(struct qed_hwfn *p_hwfn, in qed_bmap_set_id() argument
80 void qed_bmap_release_id(struct qed_hwfn *p_hwfn, in qed_bmap_release_id() argument
90 DP_NOTICE(p_hwfn, "%s bitmap: id %d already released\n", in qed_bmap_release_id()
95 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "%s bitmap: released id %d\n", in qed_bmap_release_id()
99 int qed_bmap_test_id(struct qed_hwfn *p_hwfn, in qed_bmap_test_id() argument
113 static u32 qed_rdma_get_sb_id(void *p_hwfn, u32 rel_sb_id) in qed_rdma_get_sb_id() argument
116 return FEAT_NUM((struct qed_hwfn *)p_hwfn, QED_PF_L2_QUE) + rel_sb_id; in qed_rdma_get_sb_id()
119 int qed_rdma_info_alloc(struct qed_hwfn *p_hwfn) in qed_rdma_info_alloc() argument
129 p_hwfn->p_rdma_info = p_rdma_info; in qed_rdma_info_alloc()
133 void qed_rdma_info_free(struct qed_hwfn *p_hwfn) in qed_rdma_info_free() argument
135 kfree(p_hwfn->p_rdma_info); in qed_rdma_info_free()
136 p_hwfn->p_rdma_info = NULL; in qed_rdma_info_free()
139 static int qed_rdma_alloc(struct qed_hwfn *p_hwfn) in qed_rdma_alloc() argument
141 struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info; in qed_rdma_alloc()
145 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocating RDMA\n"); in qed_rdma_alloc()
147 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) in qed_rdma_alloc()
152 num_cons = qed_cxt_get_proto_cid_count(p_hwfn, p_rdma_info->proto, in qed_rdma_alloc()
155 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) in qed_rdma_alloc()
160 num_tasks = qed_cxt_get_proto_tid_count(p_hwfn, PROTOCOLID_ROCE); in qed_rdma_alloc()
168 p_rdma_info->queue_zone_base = (u16)RESC_START(p_hwfn, QED_L2_QUEUE); in qed_rdma_alloc()
169 p_rdma_info->max_queue_zones = (u16)RESC_NUM(p_hwfn, QED_L2_QUEUE); in qed_rdma_alloc()
182 rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->pd_map, RDMA_MAX_PDS, in qed_rdma_alloc()
185 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_alloc()
192 rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->xrcd_map, in qed_rdma_alloc()
195 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_alloc()
201 rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->dpi_map, in qed_rdma_alloc()
202 p_hwfn->dpi_count, "DPI"); in qed_rdma_alloc()
204 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_alloc()
213 rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->cq_map, num_cons, "CQ"); in qed_rdma_alloc()
215 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_alloc()
224 rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->toggle_bits, in qed_rdma_alloc()
227 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_alloc()
233 rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->tid_map, in qed_rdma_alloc()
236 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_alloc()
242 rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->cid_map, num_cons, in qed_rdma_alloc()
245 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_alloc()
251 rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->real_cid_map, num_cons, in qed_rdma_alloc()
254 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_alloc()
262 p_rdma_info->srq_id_offset = p_hwfn->p_cxt_mngr->xrc_srq_count; in qed_rdma_alloc()
263 rc = qed_rdma_bmap_alloc(p_hwfn, in qed_rdma_alloc()
265 p_hwfn->p_cxt_mngr->xrc_srq_count, "XRC SRQ"); in qed_rdma_alloc()
267 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_alloc()
273 p_rdma_info->num_srqs = p_hwfn->p_cxt_mngr->srq_count; in qed_rdma_alloc()
274 rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->srq_map, in qed_rdma_alloc()
277 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_alloc()
282 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) in qed_rdma_alloc()
283 rc = qed_iwarp_alloc(p_hwfn); in qed_rdma_alloc()
288 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocation successful\n"); in qed_rdma_alloc()
319 void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn, in qed_rdma_bmap_free() argument
333 DP_NOTICE(p_hwfn, in qed_rdma_bmap_free()
340 DP_NOTICE(p_hwfn, in qed_rdma_bmap_free()
359 DP_NOTICE(p_hwfn, "%s\n", str_last_line); in qed_rdma_bmap_free()
367 static void qed_rdma_resc_free(struct qed_hwfn *p_hwfn) in qed_rdma_resc_free() argument
369 struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info; in qed_rdma_resc_free()
371 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) in qed_rdma_resc_free()
372 qed_iwarp_resc_free(p_hwfn); in qed_rdma_resc_free()
374 qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->cid_map, 1); in qed_rdma_resc_free()
375 qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->pd_map, 1); in qed_rdma_resc_free()
376 qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->dpi_map, 1); in qed_rdma_resc_free()
377 qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->cq_map, 1); in qed_rdma_resc_free()
378 qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->toggle_bits, 0); in qed_rdma_resc_free()
379 qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->tid_map, 1); in qed_rdma_resc_free()
380 qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->srq_map, 1); in qed_rdma_resc_free()
381 qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->real_cid_map, 1); in qed_rdma_resc_free()
382 qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->xrc_srq_map, 1); in qed_rdma_resc_free()
383 qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->xrcd_map, 1); in qed_rdma_resc_free()
391 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_free_tid() local
393 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "itid = %08x\n", itid); in qed_rdma_free_tid()
395 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_free_tid()
396 qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->tid_map, itid); in qed_rdma_free_tid()
397 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_free_tid()
400 static void qed_rdma_free_reserved_lkey(struct qed_hwfn *p_hwfn) in qed_rdma_free_reserved_lkey() argument
402 qed_rdma_free_tid(p_hwfn, p_hwfn->p_rdma_info->dev->reserved_lkey); in qed_rdma_free_reserved_lkey()
405 static void qed_rdma_free(struct qed_hwfn *p_hwfn) in qed_rdma_free() argument
407 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Freeing RDMA\n"); in qed_rdma_free()
409 qed_rdma_free_reserved_lkey(p_hwfn); in qed_rdma_free()
410 qed_cxt_free_proto_ilt(p_hwfn, p_hwfn->p_rdma_info->proto); in qed_rdma_free()
411 qed_rdma_resc_free(p_hwfn); in qed_rdma_free()
414 static void qed_rdma_init_events(struct qed_hwfn *p_hwfn, in qed_rdma_init_events() argument
419 events = &p_hwfn->p_rdma_info->events; in qed_rdma_init_events()
426 static void qed_rdma_init_devinfo(struct qed_hwfn *p_hwfn, in qed_rdma_init_devinfo() argument
429 struct qed_rdma_device *dev = p_hwfn->p_rdma_info->dev; in qed_rdma_init_devinfo()
430 struct qed_dev *cdev = p_hwfn->cdev; in qed_rdma_init_devinfo()
442 p_hwfn->hw_info.hw_mac_addr); in qed_rdma_init_devinfo()
453 if (p_hwfn->cdev->rdma_max_srq_sge) { in qed_rdma_init_devinfo()
455 p_hwfn->cdev->rdma_max_srq_sge, in qed_rdma_init_devinfo()
465 dev->max_cnq = (u8)FEAT_NUM(p_hwfn, QED_RDMA_CNQ); in qed_rdma_init_devinfo()
473 num_qps = min_t(u64, num_qps, p_hwfn->p_rdma_info->num_qps); in qed_rdma_init_devinfo()
482 dev->max_mr = p_hwfn->p_rdma_info->num_mrs - 1; in qed_rdma_init_devinfo()
498 if (QED_IS_ROCE_PERSONALITY(p_hwfn)) in qed_rdma_init_devinfo()
501 dev->max_srq = p_hwfn->p_rdma_info->num_srqs; in qed_rdma_init_devinfo()
508 p_hwfn->p_rdma_info->num_qps; in qed_rdma_init_devinfo()
512 dev->max_ah = p_hwfn->p_rdma_info->num_qps; in qed_rdma_init_devinfo()
513 dev->max_stats_queues = (u8)RESC_NUM(p_hwfn, QED_RDMA_STATS_QUEUE); in qed_rdma_init_devinfo()
533 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) in qed_rdma_init_devinfo()
534 qed_iwarp_init_devinfo(p_hwfn); in qed_rdma_init_devinfo()
537 static void qed_rdma_init_port(struct qed_hwfn *p_hwfn) in qed_rdma_init_port() argument
539 struct qed_rdma_port *port = p_hwfn->p_rdma_info->port; in qed_rdma_init_port()
540 struct qed_rdma_device *dev = p_hwfn->p_rdma_info->dev; in qed_rdma_init_port()
542 port->port_state = p_hwfn->mcp_info->link_output.link_up ? in qed_rdma_init_port()
547 p_hwfn->cdev->rdma_max_sge), in qed_rdma_init_port()
553 static int qed_rdma_init_hw(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) in qed_rdma_init_hw() argument
557 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Initializing HW\n"); in qed_rdma_init_hw()
558 p_hwfn->b_rdma_enabled_in_prs = false; in qed_rdma_init_hw()
560 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) in qed_rdma_init_hw()
561 qed_iwarp_init_hw(p_hwfn, p_ptt); in qed_rdma_init_hw()
563 rc = qed_roce_init_hw(p_hwfn, p_ptt); in qed_rdma_init_hw()
568 static int qed_rdma_start_fw(struct qed_hwfn *p_hwfn, in qed_rdma_start_fw() argument
582 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Starting FW\n"); in qed_rdma_start_fw()
585 p_hwfn->p_rdma_info->num_cnqs = params->desired_cnq; in qed_rdma_start_fw()
589 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_rdma_start_fw()
592 rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_FUNC_INIT, in qed_rdma_start_fw()
593 p_hwfn->p_rdma_info->proto, &init_data); in qed_rdma_start_fw()
597 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) { in qed_rdma_start_fw()
598 qed_iwarp_init_fw_ramrod(p_hwfn, in qed_rdma_start_fw()
606 p_params_header->cnq_start_offset = (u8)RESC_START(p_hwfn, in qed_rdma_start_fw()
610 cpu_to_le16(p_hwfn->p_rdma_info->srq_id_offset); in qed_rdma_start_fw()
612 cpu_to_le32(qed_cxt_get_ilt_page_size(p_hwfn, ILT_CLI_TSDM)); in qed_rdma_start_fw()
619 sb_id = qed_rdma_get_sb_id(p_hwfn, cnq_id); in qed_rdma_start_fw()
620 igu_sb_id = qed_get_igu_sb_id(p_hwfn, sb_id); in qed_rdma_start_fw()
625 p_cnq_params->sb_index = p_hwfn->pf_params.rdma_pf_params.gl_pi; in qed_rdma_start_fw()
633 cpu_to_le16(p_hwfn->p_rdma_info->queue_zone_base + in qed_rdma_start_fw()
637 return qed_spq_post(p_hwfn, p_ent, NULL); in qed_rdma_start_fw()
642 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_alloc_tid() local
645 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocate TID\n"); in qed_rdma_alloc_tid()
647 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_alloc_tid()
648 rc = qed_rdma_bmap_alloc_id(p_hwfn, in qed_rdma_alloc_tid()
649 &p_hwfn->p_rdma_info->tid_map, itid); in qed_rdma_alloc_tid()
650 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_alloc_tid()
654 rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, QED_ELEM_TASK, *itid); in qed_rdma_alloc_tid()
656 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocate TID - done, rc = %d\n", rc); in qed_rdma_alloc_tid()
660 static int qed_rdma_reserve_lkey(struct qed_hwfn *p_hwfn) in qed_rdma_reserve_lkey() argument
662 struct qed_rdma_device *dev = p_hwfn->p_rdma_info->dev; in qed_rdma_reserve_lkey()
668 qed_rdma_alloc_tid(p_hwfn, &dev->reserved_lkey); in qed_rdma_reserve_lkey()
670 DP_NOTICE(p_hwfn, in qed_rdma_reserve_lkey()
678 static int qed_rdma_setup(struct qed_hwfn *p_hwfn, in qed_rdma_setup() argument
684 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA setup\n"); in qed_rdma_setup()
686 qed_rdma_init_devinfo(p_hwfn, params); in qed_rdma_setup()
687 qed_rdma_init_port(p_hwfn); in qed_rdma_setup()
688 qed_rdma_init_events(p_hwfn, params); in qed_rdma_setup()
690 rc = qed_rdma_reserve_lkey(p_hwfn); in qed_rdma_setup()
694 rc = qed_rdma_init_hw(p_hwfn, p_ptt); in qed_rdma_setup()
698 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) { in qed_rdma_setup()
699 rc = qed_iwarp_setup(p_hwfn, params); in qed_rdma_setup()
703 rc = qed_roce_setup(p_hwfn); in qed_rdma_setup()
708 return qed_rdma_start_fw(p_hwfn, params, p_ptt); in qed_rdma_setup()
713 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_stop() local
721 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA stop\n"); in qed_rdma_stop()
723 p_ptt = qed_ptt_acquire(p_hwfn); in qed_rdma_stop()
725 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Failed to acquire PTT\n"); in qed_rdma_stop()
730 qed_wr(p_hwfn, p_ptt, p_hwfn->rdma_prs_search_reg, 0); in qed_rdma_stop()
731 p_hwfn->b_rdma_enabled_in_prs = false; in qed_rdma_stop()
732 p_hwfn->p_rdma_info->active = 0; in qed_rdma_stop()
733 qed_wr(p_hwfn, p_ptt, PRS_REG_ROCE_DEST_QP_MAX_PF, 0); in qed_rdma_stop()
735 ll2_ethertype_en = qed_rd(p_hwfn, p_ptt, PRS_REG_LIGHT_L2_ETHERTYPE_EN); in qed_rdma_stop()
737 qed_wr(p_hwfn, p_ptt, PRS_REG_LIGHT_L2_ETHERTYPE_EN, in qed_rdma_stop()
740 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) { in qed_rdma_stop()
741 rc = qed_iwarp_stop(p_hwfn); in qed_rdma_stop()
743 qed_ptt_release(p_hwfn, p_ptt); in qed_rdma_stop()
747 qed_roce_stop(p_hwfn); in qed_rdma_stop()
750 qed_ptt_release(p_hwfn, p_ptt); in qed_rdma_stop()
754 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_rdma_stop()
758 rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_FUNC_CLOSE, in qed_rdma_stop()
759 p_hwfn->p_rdma_info->proto, &init_data); in qed_rdma_stop()
765 p_ramrod->num_cnqs = p_hwfn->p_rdma_info->num_cnqs; in qed_rdma_stop()
766 p_ramrod->cnq_start_offset = (u8)RESC_START(p_hwfn, QED_RDMA_CNQ_RAM); in qed_rdma_stop()
768 rc = qed_spq_post(p_hwfn, p_ent, NULL); in qed_rdma_stop()
771 qed_rdma_free(p_hwfn); in qed_rdma_stop()
773 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA stop done, rc = %d\n", rc); in qed_rdma_stop()
780 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_add_user() local
785 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Adding User\n"); in qed_rdma_add_user()
788 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_add_user()
789 rc = qed_rdma_bmap_alloc_id(p_hwfn, &p_hwfn->p_rdma_info->dpi_map, in qed_rdma_add_user()
791 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_add_user()
796 dpi_start_offset = p_hwfn->dpi_start_offset; in qed_rdma_add_user()
798 out_params->dpi_addr = p_hwfn->doorbells + dpi_start_offset + in qed_rdma_add_user()
799 out_params->dpi * p_hwfn->dpi_size; in qed_rdma_add_user()
801 out_params->dpi_phys_addr = p_hwfn->db_phys_addr + in qed_rdma_add_user()
803 ((out_params->dpi) * p_hwfn->dpi_size); in qed_rdma_add_user()
805 out_params->dpi_size = p_hwfn->dpi_size; in qed_rdma_add_user()
806 out_params->wid_count = p_hwfn->wid_count; in qed_rdma_add_user()
808 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Adding user - done, rc = %d\n", rc); in qed_rdma_add_user()
814 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_query_port() local
815 struct qed_rdma_port *p_port = p_hwfn->p_rdma_info->port; in qed_rdma_query_port()
818 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA Query port\n"); in qed_rdma_query_port()
821 p_link_output = &QED_LEADING_HWFN(p_hwfn->cdev)->mcp_info->link_output; in qed_rdma_query_port()
835 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_query_device() local
837 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Query device\n"); in qed_rdma_query_device()
840 return p_hwfn->p_rdma_info->dev; in qed_rdma_query_device()
845 struct qed_hwfn *p_hwfn; in qed_rdma_cnq_prod_update() local
849 p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_cnq_prod_update()
851 if (qz_offset > p_hwfn->p_rdma_info->max_queue_zones) { in qed_rdma_cnq_prod_update()
852 DP_NOTICE(p_hwfn, in qed_rdma_cnq_prod_update()
854 qz_offset, p_hwfn->p_rdma_info->max_queue_zones); in qed_rdma_cnq_prod_update()
858 qz_num = p_hwfn->p_rdma_info->queue_zone_base + qz_offset; in qed_rdma_cnq_prod_update()
862 REG_WR16(p_hwfn, addr, prod); in qed_rdma_cnq_prod_update()
871 struct qed_hwfn *p_hwfn = QED_AFFIN_HWFN(cdev); in qed_fill_rdma_dev_info() local
875 info->rdma_type = QED_IS_ROCE_PERSONALITY(p_hwfn) ? in qed_fill_rdma_dev_info()
878 info->user_dpm_enabled = (p_hwfn->db_bar_no_edpm == 0); in qed_fill_rdma_dev_info()
953 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_alloc_pd() local
957 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Alloc PD\n"); in qed_rdma_alloc_pd()
960 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_alloc_pd()
961 rc = qed_rdma_bmap_alloc_id(p_hwfn, in qed_rdma_alloc_pd()
962 &p_hwfn->p_rdma_info->pd_map, &returned_id); in qed_rdma_alloc_pd()
963 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_alloc_pd()
967 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Alloc PD - done, rc = %d\n", rc); in qed_rdma_alloc_pd()
973 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_free_pd() local
975 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "pd = %08x\n", pd); in qed_rdma_free_pd()
978 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_free_pd()
979 qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->pd_map, pd); in qed_rdma_free_pd()
980 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_free_pd()
985 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_alloc_xrcd() local
989 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Alloc XRCD\n"); in qed_rdma_alloc_xrcd()
991 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_alloc_xrcd()
992 rc = qed_rdma_bmap_alloc_id(p_hwfn, in qed_rdma_alloc_xrcd()
993 &p_hwfn->p_rdma_info->xrcd_map, in qed_rdma_alloc_xrcd()
995 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_alloc_xrcd()
997 DP_NOTICE(p_hwfn, "Failed in allocating xrcd id\n"); in qed_rdma_alloc_xrcd()
1003 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Alloc XRCD - done, rc = %d\n", rc); in qed_rdma_alloc_xrcd()
1009 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_free_xrcd() local
1011 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "xrcd_id = %08x\n", xrcd_id); in qed_rdma_free_xrcd()
1013 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_free_xrcd()
1014 qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->xrcd_map, xrcd_id); in qed_rdma_free_xrcd()
1015 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_free_xrcd()
1019 qed_rdma_toggle_bit_create_resize_cq(struct qed_hwfn *p_hwfn, u16 icid) in qed_rdma_toggle_bit_create_resize_cq() argument
1021 struct qed_rdma_info *p_info = p_hwfn->p_rdma_info; in qed_rdma_toggle_bit_create_resize_cq()
1025 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", icid); in qed_rdma_toggle_bit_create_resize_cq()
1030 bmap_id = icid - qed_cxt_get_proto_cid_start(p_hwfn, p_info->proto); in qed_rdma_toggle_bit_create_resize_cq()
1037 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "QED_RDMA_TOGGLE_BIT_= %d\n", in qed_rdma_toggle_bit_create_resize_cq()
1047 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_create_cq() local
1048 struct qed_rdma_info *p_info = p_hwfn->p_rdma_info; in qed_rdma_create_cq()
1056 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "cq_handle = %08x%08x\n", in qed_rdma_create_cq()
1061 rc = qed_rdma_bmap_alloc_id(p_hwfn, &p_info->cq_map, &returned_id); in qed_rdma_create_cq()
1065 DP_NOTICE(p_hwfn, "Can't create CQ, rc = %d\n", rc); in qed_rdma_create_cq()
1069 start_cid = qed_cxt_get_proto_cid_start(p_hwfn, in qed_rdma_create_cq()
1074 rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, QED_ELEM_CXT, *icid); in qed_rdma_create_cq()
1081 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_rdma_create_cq()
1085 rc = qed_sp_init_request(p_hwfn, &p_ent, in qed_rdma_create_cq()
1100 p_ramrod->cnq_id = (u8)RESC_START(p_hwfn, QED_RDMA_CNQ_RAM) + in qed_rdma_create_cq()
1105 toggle_bit = qed_rdma_toggle_bit_create_resize_cq(p_hwfn, *icid); in qed_rdma_create_cq()
1109 rc = qed_spq_post(p_hwfn, p_ent, NULL); in qed_rdma_create_cq()
1112 qed_rdma_toggle_bit_create_resize_cq(p_hwfn, *icid); in qed_rdma_create_cq()
1116 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Created CQ, rc = %d\n", rc); in qed_rdma_create_cq()
1122 qed_bmap_release_id(p_hwfn, &p_info->cq_map, returned_id); in qed_rdma_create_cq()
1124 DP_NOTICE(p_hwfn, "Create CQ failed, rc = %d\n", rc); in qed_rdma_create_cq()
1134 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_destroy_cq() local
1143 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", in_params->icid); in qed_rdma_destroy_cq()
1146 dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_rdma_destroy_cq()
1150 DP_NOTICE(p_hwfn, in qed_rdma_destroy_cq()
1158 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_rdma_destroy_cq()
1160 proto = p_hwfn->p_rdma_info->proto; in qed_rdma_destroy_cq()
1162 rc = qed_sp_init_request(p_hwfn, &p_ent, in qed_rdma_destroy_cq()
1171 rc = qed_spq_post(p_hwfn, p_ent, NULL); in qed_rdma_destroy_cq()
1177 dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_rdma_destroy_cq()
1182 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_destroy_cq()
1184 qed_bmap_release_id(p_hwfn, in qed_rdma_destroy_cq()
1185 &p_hwfn->p_rdma_info->cq_map, in qed_rdma_destroy_cq()
1187 qed_cxt_get_proto_cid_start(p_hwfn, proto))); in qed_rdma_destroy_cq()
1189 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_destroy_cq()
1191 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Destroyed CQ, rc = %d\n", rc); in qed_rdma_destroy_cq()
1194 err: dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_rdma_destroy_cq()
1212 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_query_qp() local
1215 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); in qed_rdma_query_qp()
1239 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) in qed_rdma_query_qp()
1242 rc = qed_roce_query_qp(p_hwfn, qp, out_params); in qed_rdma_query_qp()
1244 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Query QP, rc = %d\n", rc); in qed_rdma_query_qp()
1250 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_destroy_qp() local
1253 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); in qed_rdma_destroy_qp()
1255 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) in qed_rdma_destroy_qp()
1256 rc = qed_iwarp_destroy_qp(p_hwfn, qp); in qed_rdma_destroy_qp()
1258 rc = qed_roce_destroy_qp(p_hwfn, qp); in qed_rdma_destroy_qp()
1263 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "QP destroyed\n"); in qed_rdma_destroy_qp()
1272 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_create_qp() local
1278 !p_hwfn->p_rdma_info->active) { in qed_rdma_create_qp()
1284 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_create_qp()
1289 max_stats_queues = p_hwfn->p_rdma_info->dev->max_stats_queues; in qed_rdma_create_qp()
1291 DP_ERR(p_hwfn->cdev, in qed_rdma_create_qp()
1297 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) { in qed_rdma_create_qp()
1300 DP_NOTICE(p_hwfn->cdev, in qed_rdma_create_qp()
1307 DP_NOTICE(p_hwfn->cdev, in qed_rdma_create_qp()
1342 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) { in qed_rdma_create_qp()
1343 rc = qed_iwarp_create_qp(p_hwfn, qp, out_params); in qed_rdma_create_qp()
1347 rc = qed_roce_alloc_cid(p_hwfn, &qp->icid); in qed_rdma_create_qp()
1359 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Create QP, rc = %d\n", rc); in qed_rdma_create_qp()
1367 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_modify_qp() local
1371 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x params->new_state=%d\n", in qed_rdma_modify_qp()
1375 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); in qed_rdma_modify_qp()
1419 (u8 *)&p_hwfn->hw_info.hw_mac_addr, ETH_ALEN); in qed_rdma_modify_qp()
1450 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "qp->cur_state=%d\n", in qed_rdma_modify_qp()
1466 if (QED_IS_IWARP_PERSONALITY(p_hwfn)) { in qed_rdma_modify_qp()
1470 rc = qed_iwarp_modify_qp(p_hwfn, qp, new_state, 0); in qed_rdma_modify_qp()
1472 rc = qed_roce_modify_qp(p_hwfn, qp, prev_state, params); in qed_rdma_modify_qp()
1475 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Modify QP, rc = %d\n", rc); in qed_rdma_modify_qp()
1483 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_register_tid() local
1492 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "itid = %08x\n", params->itid); in qed_rdma_register_tid()
1496 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_rdma_register_tid()
1499 rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_REGISTER_MR, in qed_rdma_register_tid()
1500 p_hwfn->p_rdma_info->proto, &init_data); in qed_rdma_register_tid()
1502 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); in qed_rdma_register_tid()
1506 if (p_hwfn->p_rdma_info->last_tid < params->itid) in qed_rdma_register_tid()
1507 p_hwfn->p_rdma_info->last_tid = params->itid; in qed_rdma_register_tid()
1562 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); in qed_rdma_register_tid()
1563 qed_sp_destroy_request(p_hwfn, p_ent); in qed_rdma_register_tid()
1586 rc = qed_spq_post(p_hwfn, p_ent, &fw_return_code); in qed_rdma_register_tid()
1591 DP_NOTICE(p_hwfn, "fw_return_code = %d\n", fw_return_code); in qed_rdma_register_tid()
1595 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Register TID, rc = %d\n", rc); in qed_rdma_register_tid()
1601 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_deregister_tid() local
1609 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "itid = %08x\n", itid); in qed_rdma_deregister_tid()
1613 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_rdma_deregister_tid()
1616 rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_DEREGISTER_MR, in qed_rdma_deregister_tid()
1617 p_hwfn->p_rdma_info->proto, &init_data); in qed_rdma_deregister_tid()
1619 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); in qed_rdma_deregister_tid()
1626 rc = qed_spq_post(p_hwfn, p_ent, &fw_return_code); in qed_rdma_deregister_tid()
1628 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); in qed_rdma_deregister_tid()
1633 DP_NOTICE(p_hwfn, "fw_return_code = %d\n", fw_return_code); in qed_rdma_deregister_tid()
1639 p_ptt = qed_ptt_acquire(p_hwfn); in qed_rdma_deregister_tid()
1642 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_deregister_tid()
1647 rc = qed_mcp_drain(p_hwfn, p_ptt); in qed_rdma_deregister_tid()
1649 qed_ptt_release(p_hwfn, p_ptt); in qed_rdma_deregister_tid()
1650 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_deregister_tid()
1655 qed_ptt_release(p_hwfn, p_ptt); in qed_rdma_deregister_tid()
1658 rc = qed_sp_init_request(p_hwfn, &p_ent, in qed_rdma_deregister_tid()
1660 p_hwfn->p_rdma_info->proto, in qed_rdma_deregister_tid()
1663 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_deregister_tid()
1668 rc = qed_spq_post(p_hwfn, p_ent, &fw_return_code); in qed_rdma_deregister_tid()
1670 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_deregister_tid()
1676 DP_NOTICE(p_hwfn, "fw_return_code = %d\n", in qed_rdma_deregister_tid()
1682 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "De-registered TID, rc = %d\n", rc); in qed_rdma_deregister_tid()
1691 static struct qed_bmap *qed_rdma_get_srq_bmap(struct qed_hwfn *p_hwfn, in qed_rdma_get_srq_bmap() argument
1695 return &p_hwfn->p_rdma_info->xrc_srq_map; in qed_rdma_get_srq_bmap()
1697 return &p_hwfn->p_rdma_info->srq_map; in qed_rdma_get_srq_bmap()
1705 struct qed_hwfn *p_hwfn = rdma_cxt; in qed_rdma_modify_srq() local
1710 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_rdma_modify_srq()
1713 rc = qed_sp_init_request(p_hwfn, &p_ent, in qed_rdma_modify_srq()
1715 p_hwfn->p_rdma_info->proto, &init_data); in qed_rdma_modify_srq()
1721 opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_rdma_modify_srq()
1725 rc = qed_spq_post(p_hwfn, p_ent, NULL); in qed_rdma_modify_srq()
1729 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "modified SRQ id = %x, is_xrc=%u\n", in qed_rdma_modify_srq()
1741 struct qed_hwfn *p_hwfn = rdma_cxt; in qed_rdma_destroy_srq() local
1748 opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_rdma_destroy_srq()
1753 rc = qed_sp_init_request(p_hwfn, &p_ent, in qed_rdma_destroy_srq()
1755 p_hwfn->p_rdma_info->proto, &init_data); in qed_rdma_destroy_srq()
1763 rc = qed_spq_post(p_hwfn, p_ent, NULL); in qed_rdma_destroy_srq()
1767 bmap = qed_rdma_get_srq_bmap(p_hwfn, in_params->is_xrc); in qed_rdma_destroy_srq()
1768 offset = (in_params->is_xrc) ? 0 : p_hwfn->p_rdma_info->srq_id_offset; in qed_rdma_destroy_srq()
1770 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_destroy_srq()
1771 qed_bmap_release_id(p_hwfn, bmap, in_params->srq_id - offset); in qed_rdma_destroy_srq()
1772 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_destroy_srq()
1774 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_destroy_srq()
1788 struct qed_hwfn *p_hwfn = rdma_cxt; in qed_rdma_create_srq() local
1797 bmap = qed_rdma_get_srq_bmap(p_hwfn, in_params->is_xrc); in qed_rdma_create_srq()
1798 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_create_srq()
1799 rc = qed_rdma_bmap_alloc_id(p_hwfn, bmap, &returned_id); in qed_rdma_create_srq()
1800 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_create_srq()
1803 DP_NOTICE(p_hwfn, in qed_rdma_create_srq()
1810 rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, elem_type, returned_id); in qed_rdma_create_srq()
1814 opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_rdma_create_srq()
1816 opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_rdma_create_srq()
1820 rc = qed_sp_init_request(p_hwfn, &p_ent, in qed_rdma_create_srq()
1822 p_hwfn->p_rdma_info->proto, &init_data); in qed_rdma_create_srq()
1833 offset = (in_params->is_xrc) ? 0 : p_hwfn->p_rdma_info->srq_id_offset; in qed_rdma_create_srq()
1844 cpu_to_le32((p_hwfn->hw_info.opaque_fid << 16) | in qed_rdma_create_srq()
1848 rc = qed_spq_post(p_hwfn, p_ent, NULL); in qed_rdma_create_srq()
1854 DP_VERBOSE(p_hwfn, in qed_rdma_create_srq()
1861 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_create_srq()
1862 qed_bmap_release_id(p_hwfn, bmap, returned_id); in qed_rdma_create_srq()
1863 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_create_srq()
1868 bool qed_rdma_allocated_qps(struct qed_hwfn *p_hwfn) in qed_rdma_allocated_qps() argument
1873 if (!p_hwfn->p_rdma_info->active) in qed_rdma_allocated_qps()
1876 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_allocated_qps()
1877 if (!p_hwfn->p_rdma_info->cid_map.bitmap) in qed_rdma_allocated_qps()
1880 result = !qed_bmap_is_empty(&p_hwfn->p_rdma_info->cid_map); in qed_rdma_allocated_qps()
1881 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_allocated_qps()
1885 void qed_rdma_dpm_conf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) in qed_rdma_dpm_conf() argument
1889 val = (p_hwfn->dcbx_no_edpm || p_hwfn->db_bar_no_edpm) ? 0 : 1; in qed_rdma_dpm_conf()
1891 qed_wr(p_hwfn, p_ptt, DORQ_REG_PF_DPM_ENABLE, val); in qed_rdma_dpm_conf()
1892 DP_VERBOSE(p_hwfn, (QED_MSG_DCB | QED_MSG_RDMA), in qed_rdma_dpm_conf()
1894 val, p_hwfn->dcbx_no_edpm, p_hwfn->db_bar_no_edpm); in qed_rdma_dpm_conf()
1897 void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) in qed_rdma_dpm_bar() argument
1899 p_hwfn->db_bar_no_edpm = true; in qed_rdma_dpm_bar()
1901 qed_rdma_dpm_conf(p_hwfn, p_ptt); in qed_rdma_dpm_bar()
1907 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_start() local
1911 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, in qed_rdma_start()
1914 p_ptt = qed_ptt_acquire(p_hwfn); in qed_rdma_start()
1918 rc = qed_rdma_alloc(p_hwfn); in qed_rdma_start()
1922 rc = qed_rdma_setup(p_hwfn, p_ptt, params); in qed_rdma_start()
1926 qed_ptt_release(p_hwfn, p_ptt); in qed_rdma_start()
1927 p_hwfn->p_rdma_info->active = 1; in qed_rdma_start()
1932 qed_rdma_free(p_hwfn); in qed_rdma_start()
1934 qed_ptt_release(p_hwfn, p_ptt); in qed_rdma_start()
1936 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA start - error, rc = %d\n", rc); in qed_rdma_start()
1948 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; in qed_rdma_remove_user() local
1950 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "dpi = %08x\n", dpi); in qed_rdma_remove_user()
1952 spin_lock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_remove_user()
1953 qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->dpi_map, dpi); in qed_rdma_remove_user()
1954 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); in qed_rdma_remove_user()