Unverified Commit 0570b06b authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!4414 Support srq record doorbell and support query srq context

Merge Pull Request from: @stinft 
 
1. Compared with normal doorbell, using record doorbell can shorten the
process of ringing the doorbell and reduce the latency.
2. Dump SRQ resource in raw format. It enable drivers to
return the entire device specific SRQ context without setting each
field separately.
 Yangyang Li (1):
   RDMA/hns: Support SRQ record doorbell
 wenglianfa (3):
   RDMA/core: Add dedicated SRQ resource tracker function
   RDMA/core: Add support to dump SRQ resource in RAW format
   RDMA/hns: Support SRQ restrack ops for hns driver

https://gitee.com/openeuler/kernel/issues/I8ZWMC
https://gitee.com/openeuler/kernel/issues/I8ZWK5 
 
Link:https://gitee.com/openeuler/kernel/pulls/4414

 

Reviewed-by: default avatarChengchang Tang <tangchengchang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parents 7b5f21cc e1d3ea90
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2651,6 +2651,8 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
	SET_DEVICE_OP(dev_ops, fill_res_mr_entry_raw);
	SET_DEVICE_OP(dev_ops, fill_res_qp_entry);
	SET_DEVICE_OP(dev_ops, fill_res_qp_entry_raw);
	SET_DEVICE_OP(dev_ops, fill_res_srq_entry);
	SET_DEVICE_OP(dev_ops, fill_res_srq_entry_raw);
	SET_DEVICE_OP(dev_ops, fill_stat_mr_entry);
	SET_DEVICE_OP(dev_ops, get_dev_fw_str);
	SET_DEVICE_OP(dev_ops, get_dma_mr);
+25 −1
Original line number Diff line number Diff line
@@ -818,6 +818,7 @@ static int fill_res_srq_entry(struct sk_buff *msg, bool has_cap_net_admin,
			      struct rdma_restrack_entry *res, uint32_t port)
{
	struct ib_srq *srq = container_of(res, struct ib_srq, res);
	struct ib_device *dev = srq->device;

	if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_SRQN, srq->res.id))
		goto err;
@@ -837,12 +838,29 @@ static int fill_res_srq_entry(struct sk_buff *msg, bool has_cap_net_admin,
	if (fill_res_srq_qps(msg, srq))
		goto err;

	return fill_res_name_pid(msg, res);
	if (fill_res_name_pid(msg, res))
		goto err;

	if (dev->ops.fill_res_srq_entry)
		return dev->ops.fill_res_srq_entry(msg, srq);

	return 0;

err:
	return -EMSGSIZE;
}

static int fill_res_srq_raw_entry(struct sk_buff *msg, bool has_cap_net_admin,
				 struct rdma_restrack_entry *res, uint32_t port)
{
	struct ib_srq *srq = container_of(res, struct ib_srq, res);
	struct ib_device *dev = srq->device;

	if (!dev->ops.fill_res_srq_entry_raw)
		return -EINVAL;
	return dev->ops.fill_res_srq_entry_raw(msg, srq);
}

static int fill_stat_counter_mode(struct sk_buff *msg,
				  struct rdma_counter *counter)
{
@@ -1652,6 +1670,7 @@ RES_GET_FUNCS(mr_raw, RDMA_RESTRACK_MR);
RES_GET_FUNCS(counter, RDMA_RESTRACK_COUNTER);
RES_GET_FUNCS(ctx, RDMA_RESTRACK_CTX);
RES_GET_FUNCS(srq, RDMA_RESTRACK_SRQ);
RES_GET_FUNCS(srq_raw, RDMA_RESTRACK_SRQ);

static LIST_HEAD(link_ops);
static DECLARE_RWSEM(link_ops_rwsem);
@@ -2558,6 +2577,11 @@ static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
		.dump = nldev_res_get_mr_raw_dumpit,
		.flags = RDMA_NL_ADMIN_PERM,
	},
	[RDMA_NLDEV_CMD_RES_SRQ_GET_RAW] = {
		.doit = nldev_res_get_srq_raw_doit,
		.dump = nldev_res_get_srq_raw_dumpit,
		.flags = RDMA_NL_ADMIN_PERM,
	},
	[RDMA_NLDEV_CMD_STAT_GET_STATUS] = {
		.doit = nldev_stat_get_counter_status_doit,
	},
+6 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ enum {
	HNS_ROCE_CAP_FLAG_SDI_MODE		= BIT(14),
	HNS_ROCE_CAP_FLAG_STASH			= BIT(17),
	HNS_ROCE_CAP_FLAG_CQE_INLINE		= BIT(19),
	HNS_ROCE_CAP_FLAG_SRQ_RECORD_DB         = BIT(22),
};

#define HNS_ROCE_DB_TYPE_COUNT			2
@@ -453,6 +454,8 @@ struct hns_roce_srq {
	spinlock_t		lock;
	struct mutex		mutex;
	void (*event)(struct hns_roce_srq *srq, enum hns_roce_event event);
	struct hns_roce_db	rdb;
	u32			cap_flags;
};

struct hns_roce_uar_table {
@@ -908,6 +911,7 @@ struct hns_roce_hw {
	int (*query_cqc)(struct hns_roce_dev *hr_dev, u32 cqn, void *buffer);
	int (*query_qpc)(struct hns_roce_dev *hr_dev, u32 qpn, void *buffer);
	int (*query_mpt)(struct hns_roce_dev *hr_dev, u32 key, void *buffer);
	int (*query_srqc)(struct hns_roce_dev *hr_dev, u32 srqn, void *buffer);
	int (*query_hw_counter)(struct hns_roce_dev *hr_dev,
				u64 *stats, u32 port, int *hw_counters);
	const struct ib_device_ops *hns_roce_dev_ops;
@@ -1239,6 +1243,8 @@ int hns_roce_fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ib_qp);
int hns_roce_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ib_qp);
int hns_roce_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ib_mr);
int hns_roce_fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ib_mr);
int hns_roce_fill_res_srq_entry(struct sk_buff *msg, struct ib_srq *ib_srq);
int hns_roce_fill_res_srq_entry_raw(struct sk_buff *msg, struct ib_srq *ib_srq);
struct hns_user_mmap_entry *
hns_roce_user_mmap_entry_insert(struct ib_ucontext *ucontext, u64 address,
				size_t length,
+47 −9
Original line number Diff line number Diff line
@@ -941,20 +941,23 @@ static void fill_wqe_idx(struct hns_roce_srq *srq, unsigned int wqe_idx)
	idx_que->head++;
}

static void update_srq_db(struct hns_roce_v2_db *db, struct hns_roce_srq *srq)
static void update_srq_db(struct hns_roce_srq *srq)
{
	hr_reg_write(db, DB_TAG, srq->srqn);
	hr_reg_write(db, DB_CMD, HNS_ROCE_V2_SRQ_DB);
	hr_reg_write(db, DB_PI, srq->idx_que.head);
	struct hns_roce_dev *hr_dev = to_hr_dev(srq->ibsrq.device);
	struct hns_roce_v2_db db;

	hr_reg_write(&db, DB_TAG, srq->srqn);
	hr_reg_write(&db, DB_CMD, HNS_ROCE_V2_SRQ_DB);
	hr_reg_write(&db, DB_PI, srq->idx_que.head);

	hns_roce_write64(hr_dev, (__le32 *)&db, srq->db_reg);
}

static int hns_roce_v2_post_srq_recv(struct ib_srq *ibsrq,
				     const struct ib_recv_wr *wr,
				     const struct ib_recv_wr **bad_wr)
{
	struct hns_roce_dev *hr_dev = to_hr_dev(ibsrq->device);
	struct hns_roce_srq *srq = to_hr_srq(ibsrq);
	struct hns_roce_v2_db srq_db;
	unsigned long flags;
	int ret = 0;
	u32 max_sge;
@@ -985,9 +988,11 @@ static int hns_roce_v2_post_srq_recv(struct ib_srq *ibsrq,
	}

	if (likely(nreq)) {
		update_srq_db(&srq_db, srq);

		hns_roce_write64(hr_dev, (__le32 *)&srq_db, srq->db_reg);
		if (srq->cap_flags & HNS_ROCE_SRQ_CAP_RECORD_DB)
			*srq->rdb.db_record = srq->idx_que.head &
					      V2_DB_PRODUCER_IDX_M;
		else
			update_srq_db(srq);
	}

	spin_unlock_irqrestore(&srq->lock, flags);
@@ -5283,6 +5288,30 @@ static int hns_roce_v2_query_qpc(struct hns_roce_dev *hr_dev, u32 qpn,
	return ret;
}

static int hns_roce_v2_query_srqc(struct hns_roce_dev *hr_dev, u32 srqn,
				 void *buffer)
{
	struct hns_roce_srq_context *context;
	struct hns_roce_cmd_mailbox *mailbox;
	int ret;

	mailbox = hns_roce_alloc_cmd_mailbox(hr_dev);
	if (IS_ERR(mailbox))
		return PTR_ERR(mailbox);

	context = mailbox->buf;
	ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_SRQC,
				srqn);
	if (ret)
		goto out;

	memcpy(buffer, context, sizeof(*context));

out:
	hns_roce_free_cmd_mailbox(hr_dev, mailbox);
	return ret;
}

static u8 get_qp_timeout_attr(struct hns_roce_dev *hr_dev,
			      struct hns_roce_v2_qp_context *context)
{
@@ -5617,6 +5646,14 @@ static int hns_roce_v2_write_srqc(struct hns_roce_srq *srq, void *mb_buf)
	hr_reg_write(ctx, SRQC_WQE_BUF_PG_SZ,
		     to_hr_hw_page_shift(srq->buf_mtr.hem_cfg.buf_pg_shift));

	if (srq->cap_flags & HNS_ROCE_SRQ_CAP_RECORD_DB) {
		hr_reg_enable(ctx, SRQC_DB_RECORD_EN);
		hr_reg_write(ctx, SRQC_DB_RECORD_ADDR_L,
			     lower_32_bits(srq->rdb.dma) >> 1);
		hr_reg_write(ctx, SRQC_DB_RECORD_ADDR_H,
			     upper_32_bits(srq->rdb.dma));
	}

	return hns_roce_v2_write_srqc_index_queue(srq, ctx);
}

@@ -6643,6 +6680,7 @@ static const struct hns_roce_hw hns_roce_hw_v2 = {
	.query_cqc = hns_roce_v2_query_cqc,
	.query_qpc = hns_roce_v2_query_qpc,
	.query_mpt = hns_roce_v2_query_mpt,
	.query_srqc = hns_roce_v2_query_srqc,
	.query_hw_counter = hns_roce_hw_v2_query_counter,
	.hns_roce_dev_ops = &hns_roce_v2_dev_ops,
	.hns_roce_dev_srq_ops = &hns_roce_v2_dev_srq_ops,
+2 −0
Original line number Diff line number Diff line
@@ -675,6 +675,8 @@ static const struct ib_device_ops hns_roce_dev_restrack_ops = {
	.fill_res_qp_entry_raw = hns_roce_fill_res_qp_entry_raw,
	.fill_res_mr_entry = hns_roce_fill_res_mr_entry,
	.fill_res_mr_entry_raw = hns_roce_fill_res_mr_entry_raw,
	.fill_res_srq_entry = hns_roce_fill_res_srq_entry,
	.fill_res_srq_entry_raw = hns_roce_fill_res_srq_entry_raw,
};

static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
Loading