Lines Matching refs:srq

862 static void *get_srq_wqe_buf(struct hns_roce_srq *srq, u32 n)
864 return hns_roce_buf_offset(srq->buf_mtr.kmem, n << srq->wqe_shift);
873 static void hns_roce_free_srq_wqe(struct hns_roce_srq *srq, u32 wqe_index)
876 spin_lock(&srq->lock);
878 bitmap_clear(srq->idx_que.bitmap, wqe_index, 1);
879 srq->idx_que.tail++;
881 spin_unlock(&srq->lock);
884 static int hns_roce_srqwq_overflow(struct hns_roce_srq *srq)
886 struct hns_roce_idx_que *idx_que = &srq->idx_que;
888 return idx_que->head - idx_que->tail >= srq->wqe_cnt;
891 static int check_post_srq_valid(struct hns_roce_srq *srq, u32 max_sge,
894 struct ib_device *ib_dev = srq->ibsrq.device;
903 if (unlikely(hns_roce_srqwq_overflow(srq))) {
912 static int get_srq_wqe_idx(struct hns_roce_srq *srq, u32 *wqe_idx)
914 struct hns_roce_idx_que *idx_que = &srq->idx_que;
917 pos = find_first_zero_bit(idx_que->bitmap, srq->wqe_cnt);
918 if (unlikely(pos == srq->wqe_cnt))
926 static void fill_wqe_idx(struct hns_roce_srq *srq, unsigned int wqe_idx)
928 struct hns_roce_idx_que *idx_que = &srq->idx_que;
932 head = idx_que->head & (srq->wqe_cnt - 1);
940 static void update_srq_db(struct hns_roce_srq *srq)
942 struct hns_roce_dev *hr_dev = to_hr_dev(srq->ibsrq.device);
945 hr_reg_write(&db, DB_TAG, srq->srqn);
947 hr_reg_write(&db, DB_PI, srq->idx_que.head);
949 hns_roce_write64(hr_dev, (__le32 *)&db, srq->db_reg);
956 struct hns_roce_srq *srq = to_hr_srq(ibsrq);
964 spin_lock_irqsave(&srq->lock, flags);
966 max_sge = srq->max_gs - srq->rsv_sge;
968 ret = check_post_srq_valid(srq, max_sge, wr);
974 ret = get_srq_wqe_idx(srq, &wqe_idx);
980 wqe = get_srq_wqe_buf(srq, wqe_idx);
981 fill_recv_sge_to_wqe(wr, wqe, max_sge, srq->rsv_sge);
982 fill_wqe_idx(srq, wqe_idx);
983 srq->wrid[wqe_idx] = wr->wr_id;
987 if (srq->cap_flags & HNS_ROCE_SRQ_CAP_RECORD_DB)
988 *srq->rdb.db_record = srq->idx_que.head &
991 update_srq_db(srq);
994 spin_unlock_irqrestore(&srq->lock, flags);
3502 struct hns_roce_srq *srq)
3524 if (srq && hr_reg_read(cqe, CQE_S_R)) {
3526 hns_roce_free_srq_wqe(srq, wqe_index);
3545 struct hns_roce_srq *srq)
3548 __hns_roce_v2_cq_clean(hr_cq, qpn, srq);
3891 struct hns_roce_srq *srq = NULL;
3931 if (qp->ibqp.srq) {
3932 srq = to_hr_srq(qp->ibqp.srq);
3933 wc->wr_id = srq->wrid[wqe_idx];
3934 hns_roce_free_srq_wqe(srq, wqe_idx);
4287 if (ibqp->srq) {
4289 hr_reg_write(context, QPC_SRQN, to_hr_srq(ibqp->srq)->srqn);
4325 if (ibqp->srq) {
4328 hr_reg_write(context, QPC_SRQN, to_hr_srq(ibqp->srq)->srqn);
5203 hr_qp->qpn, ibqp->srq ?
5204 to_hr_srq(ibqp->srq) : NULL);
5233 if (ibqp->srq || ibqp->qp_type == IB_QPT_XRC_INI) /* no RQ */
5284 ibqp->srq);
5501 qp_init_attr->srq = ibqp->srq;
5547 (hr_qp->ibqp.srq ?
5548 to_hr_srq(hr_qp->ibqp.srq) :
5641 static int hns_roce_v2_write_srqc_index_queue(struct hns_roce_srq *srq,
5644 struct hns_roce_idx_que *idx_que = &srq->idx_que;
5645 struct ib_device *ibdev = srq->ibsrq.device;
5663 to_hr_hem_hopnum(hr_dev->caps.idx_hop_num, srq->wqe_cnt));
5687 static int hns_roce_v2_write_srqc(struct hns_roce_srq *srq, void *mb_buf)
5689 struct ib_device *ibdev = srq->ibsrq.device;
5698 /* Get the physical address of srq buf */
5699 ret = hns_roce_mtr_find(hr_dev, &srq->buf_mtr, 0, mtts_wqe,
5707 dma_handle_wqe = hns_roce_get_mtr_ba(&srq->buf_mtr);
5711 srq->ibsrq.srq_type == IB_SRQT_XRC);
5712 hr_reg_write(ctx, SRQC_PD, to_hr_pd(srq->ibsrq.pd)->pdn);
5713 hr_reg_write(ctx, SRQC_SRQN, srq->srqn);
5714 hr_reg_write(ctx, SRQC_XRCD, srq->xrcdn);
5715 hr_reg_write(ctx, SRQC_XRC_CQN, srq->cqn);
5716 hr_reg_write(ctx, SRQC_SHIFT, ilog2(srq->wqe_cnt));
5718 srq->max_gs <= 0 ? 0 : fls(srq->max_gs - 1));
5722 srq->wqe_cnt));
5729 to_hr_hw_page_shift(srq->buf_mtr.hem_cfg.ba_pg_shift));
5731 to_hr_hw_page_shift(srq->buf_mtr.hem_cfg.buf_pg_shift));
5733 if (srq->cap_flags & HNS_ROCE_SRQ_CAP_RECORD_DB) {
5736 lower_32_bits(srq->rdb.dma) >> 1);
5738 upper_32_bits(srq->rdb.dma));
5741 return hns_roce_v2_write_srqc_index_queue(srq, ctx);
5750 struct hns_roce_srq *srq = to_hr_srq(ibsrq);
5763 if (srq_attr->srq_limit > srq->wqe_cnt) {
5783 HNS_ROCE_CMD_MODIFY_SRQC, srq->srqn);
5801 struct hns_roce_srq *srq = to_hr_srq(ibsrq);
5812 HNS_ROCE_CMD_QUERY_SRQC, srq->srqn);
5821 attr->max_wr = srq->wqe_cnt;
5822 attr->max_sge = srq->max_gs - srq->rsv_sge;