Lines Matching refs:hr_dev
12 void hns_roce_srq_event(struct hns_roce_dev *hr_dev, u32 srqn, int event_type) in hns_roce_srq_event() argument
14 struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; in hns_roce_srq_event()
18 srq = xa_load(&srq_table->xa, srqn & (hr_dev->caps.num_srqs - 1)); in hns_roce_srq_event()
24 dev_warn(hr_dev->dev, "Async event for bogus SRQ %08x\n", srqn); in hns_roce_srq_event()
37 struct hns_roce_dev *hr_dev = to_hr_dev(srq->ibsrq.device); in hns_roce_ib_srq_event() local
52 dev_err(hr_dev->dev, in hns_roce_ib_srq_event()
62 static int alloc_srqn(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) in alloc_srqn() argument
64 struct hns_roce_ida *srq_ida = &hr_dev->srq_table.srq_ida; in alloc_srqn()
70 ibdev_err(&hr_dev->ib_dev, "failed to alloc srq(%d).\n", id); in alloc_srqn()
79 static void free_srqn(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) in free_srqn() argument
81 ida_free(&hr_dev->srq_table.srq_ida.ida, (int)srq->srqn); in free_srqn()
84 static int hns_roce_create_srqc(struct hns_roce_dev *hr_dev, in hns_roce_create_srqc() argument
87 struct ib_device *ibdev = &hr_dev->ib_dev; in hns_roce_create_srqc()
91 mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); in hns_roce_create_srqc()
97 ret = hr_dev->hw->write_srqc(srq, mailbox->buf); in hns_roce_create_srqc()
103 ret = hns_roce_create_hw_ctx(hr_dev, mailbox, HNS_ROCE_CMD_CREATE_SRQ, in hns_roce_create_srqc()
109 hns_roce_free_cmd_mailbox(hr_dev, mailbox); in hns_roce_create_srqc()
113 static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) in alloc_srqc() argument
115 struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; in alloc_srqc()
116 struct ib_device *ibdev = &hr_dev->ib_dev; in alloc_srqc()
119 ret = hns_roce_table_get(hr_dev, &srq_table->table, srq->srqn); in alloc_srqc()
131 ret = hns_roce_create_srqc(hr_dev, srq); in alloc_srqc()
140 hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn); in alloc_srqc()
145 static void free_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) in free_srqc() argument
147 struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; in free_srqc()
150 ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_SRQ, in free_srqc()
153 dev_err(hr_dev->dev, "DESTROY_SRQ failed (%d) for SRQN %06lx\n", in free_srqc()
162 hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn); in free_srqc()
165 static int alloc_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq, in alloc_srq_idx() argument
169 struct ib_device *ibdev = &hr_dev->ib_dev; in alloc_srq_idx()
175 buf_attr.page_shift = hr_dev->caps.idx_buf_pg_sz + PAGE_SHIFT; in alloc_srq_idx()
178 buf_attr.region[0].hopnum = hr_dev->caps.idx_hop_num; in alloc_srq_idx()
181 ret = hns_roce_mtr_create(hr_dev, &idx_que->mtr, &buf_attr, in alloc_srq_idx()
182 hr_dev->caps.idx_ba_pg_sz + PAGE_SHIFT, in alloc_srq_idx()
204 hns_roce_mtr_destroy(hr_dev, &idx_que->mtr); in alloc_srq_idx()
209 static void free_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) in free_srq_idx() argument
215 hns_roce_mtr_destroy(hr_dev, &idx_que->mtr); in free_srq_idx()
218 static int alloc_srq_wqe_buf(struct hns_roce_dev *hr_dev, in alloc_srq_wqe_buf() argument
222 struct ib_device *ibdev = &hr_dev->ib_dev; in alloc_srq_wqe_buf()
230 buf_attr.page_shift = hr_dev->caps.srqwqe_buf_pg_sz + PAGE_SHIFT; in alloc_srq_wqe_buf()
233 buf_attr.region[0].hopnum = hr_dev->caps.srqwqe_hop_num; in alloc_srq_wqe_buf()
236 ret = hns_roce_mtr_create(hr_dev, &srq->buf_mtr, &buf_attr, in alloc_srq_wqe_buf()
237 hr_dev->caps.srqwqe_ba_pg_sz + PAGE_SHIFT, in alloc_srq_wqe_buf()
246 static void free_srq_wqe_buf(struct hns_roce_dev *hr_dev, in free_srq_wqe_buf() argument
249 hns_roce_mtr_destroy(hr_dev, &srq->buf_mtr); in free_srq_wqe_buf()
252 static int alloc_srq_wrid(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) in alloc_srq_wrid() argument
293 struct hns_roce_dev *hr_dev = to_hr_dev(srq->ibsrq.device); in set_srq_basic_param() local
297 max_sge = proc_srq_sge(hr_dev, srq, !!udata); in set_srq_basic_param()
298 if (attr->max_wr > hr_dev->caps.max_srq_wrs || in set_srq_basic_param()
300 ibdev_err(&hr_dev->ib_dev, in set_srq_basic_param()
342 static int alloc_srq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq, in alloc_srq_buf() argument
352 ibdev_err(&hr_dev->ib_dev, in alloc_srq_buf()
359 ret = alloc_srq_idx(hr_dev, srq, udata, ucmd.que_addr); in alloc_srq_buf()
363 ret = alloc_srq_wqe_buf(hr_dev, srq, udata, ucmd.buf_addr); in alloc_srq_buf()
368 ret = alloc_srq_wrid(hr_dev, srq); in alloc_srq_buf()
376 free_srq_wqe_buf(hr_dev, srq); in alloc_srq_buf()
378 free_srq_idx(hr_dev, srq); in alloc_srq_buf()
383 static void free_srq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) in free_srq_buf() argument
386 free_srq_wqe_buf(hr_dev, srq); in free_srq_buf()
387 free_srq_idx(hr_dev, srq); in free_srq_buf()
394 struct hns_roce_dev *hr_dev = to_hr_dev(ib_srq->device); in hns_roce_create_srq() local
406 ret = alloc_srq_buf(hr_dev, srq, udata); in hns_roce_create_srq()
410 ret = alloc_srqn(hr_dev, srq); in hns_roce_create_srq()
414 ret = alloc_srqc(hr_dev, srq); in hns_roce_create_srq()
427 srq->db_reg = hr_dev->reg_base + SRQ_DB_REG; in hns_roce_create_srq()
435 free_srqc(hr_dev, srq); in hns_roce_create_srq()
437 free_srqn(hr_dev, srq); in hns_roce_create_srq()
439 free_srq_buf(hr_dev, srq); in hns_roce_create_srq()
446 struct hns_roce_dev *hr_dev = to_hr_dev(ibsrq->device); in hns_roce_destroy_srq() local
449 free_srqc(hr_dev, srq); in hns_roce_destroy_srq()
450 free_srqn(hr_dev, srq); in hns_roce_destroy_srq()
451 free_srq_buf(hr_dev, srq); in hns_roce_destroy_srq()
455 void hns_roce_init_srq_table(struct hns_roce_dev *hr_dev) in hns_roce_init_srq_table() argument
457 struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; in hns_roce_init_srq_table()
463 srq_ida->max = hr_dev->caps.num_srqs - 1; in hns_roce_init_srq_table()
464 srq_ida->min = hr_dev->caps.reserved_srqs; in hns_roce_init_srq_table()