Unverified Commit 0d6eaed4 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!2621 RDMA/hns: Append SCC context to the raw dump of QP Resource

Merge Pull Request from: @stinft 
 
Upload a patch to enable users to query SCCC information.
QP and SCC are bound one by one. Therefore, QPC and SCCC can be combined for output. When the SCC output is disabled, the QPC output is normal, and the SCCC output is all 0.
The 512-byte QP context is appended with 64-byte SCC context.

wenglianfa (1):
   RDMA/hns: Append SCC context to the raw dump of QP Resource

https://gitee.com/openeuler/kernel/issues/I8B8HH 
 
Link:https://gitee.com/openeuler/kernel/pulls/2621

 

Reviewed-by: default avatarChengchang Tang <tangchengchang@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents e741d669 0b24e733
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -108,6 +108,9 @@ enum {
	HNS_ROCE_CMD_QUERY_CEQC		= 0x92,
	HNS_ROCE_CMD_DESTROY_CEQC	= 0x93,

	/* SCC CTX commands */
	HNS_ROCE_CMD_QUERY_SCCC		= 0xa2,

	/* SCC CTX BT commands */
	HNS_ROCE_CMD_READ_SCCC_BT0	= 0xa4,
	HNS_ROCE_CMD_WRITE_SCCC_BT0	= 0xa5,
+1 −0
Original line number Diff line number Diff line
@@ -1020,6 +1020,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_sccc)(struct hns_roce_dev *hr_dev, u32 qpn, void *buffer);
	int (*get_dscp)(struct hns_roce_dev *hr_dev, u8 dscp,
			u8 *tc_mode, u8 *priority);
	int (*query_hw_counter)(struct hns_roce_dev *hr_dev,
+25 −0
Original line number Diff line number Diff line
@@ -5682,6 +5682,30 @@ static int hns_roce_v2_query_qpc(struct hns_roce_dev *hr_dev, u32 qpn,
	return ret;
}

static int hns_roce_v2_query_sccc(struct hns_roce_dev *hr_dev, u32 qpn,
				  void *buffer)
{
	struct hns_roce_v2_scc_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);

	ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_SCCC,
				qpn);
	if (ret)
		goto out;

	context = mailbox->buf;
	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)
{
@@ -7162,6 +7186,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_sccc = hns_roce_v2_query_sccc,
	.get_dscp = hns_roce_hw_v2_get_dscp,
	.hns_roce_dev_ops = &hns_roce_v2_dev_ops,
	.hns_roce_dev_srq_ops = &hns_roce_v2_dev_srq_ops,
+6 −0
Original line number Diff line number Diff line
@@ -654,6 +654,12 @@ struct hns_roce_v2_qp_context {
#define QPCEX_SQ_RQ_NOT_FORBID_EN QPCEX_FIELD_LOC(23, 23)
#define QPCEX_STASH QPCEX_FIELD_LOC(82, 82)

#define SCC_CONTEXT_SIZE 16

struct hns_roce_v2_scc_context {
	__le32 data[SCC_CONTEXT_SIZE];
};

#define	V2_QP_RWE_S 1 /* rdma write enable */
#define	V2_QP_RRE_S 2 /* rdma read enable */
#define	V2_QP_ATE_S 3 /* rdma atomic enable */
+21 −3
Original line number Diff line number Diff line
@@ -99,16 +99,34 @@ int hns_roce_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ib_qp)
{
	struct hns_roce_dev *hr_dev = to_hr_dev(ib_qp->device);
	struct hns_roce_qp *hr_qp = to_hr_qp(ib_qp);
	struct hns_roce_v2_qp_context context;
	struct hns_roce_full_qp_ctx {
		struct hns_roce_v2_qp_context qpc;
		struct hns_roce_v2_scc_context sccc;
	} context = {};
	int ret;

	if (!hr_dev->hw->query_qpc)
		return -EINVAL;

	ret = hr_dev->hw->query_qpc(hr_dev, hr_qp->qpn, &context);
	ret = hr_dev->hw->query_qpc(hr_dev, hr_qp->qpn, &context.qpc);
	if (ret)
		return -EINVAL;
		return ret;

	if (!(hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL) ||
	    !hr_dev->hw->query_sccc)
		goto out;

	/* The scc may not exist. If the scc query fails,
	 * only the qpc content is displayed, and the
	 * scc value is all 0.
	 */
	ret = hr_dev->hw->query_sccc(hr_dev, hr_qp->qpn, &context.sccc);
	if (ret)
		ibdev_warn_ratelimited(&hr_dev->ib_dev,
				       "failed to query SCCC, ret = %d.\n",
				       ret);

out:
	ret = nla_put(msg, RDMA_NLDEV_ATTR_RES_RAW, sizeof(context), &context);

	return ret;