Skip to content

Commit 124a9fb

Browse files
wenglianfarleon
authored andcommitted
RDMA/hns: Append SCC context to the raw dump of QPC
SCCC (SCC Context) is a context with QP granularity that contains information about congestion control. Dump SCCC and QPC together to improve troubleshooting. When dumping raw QPC with rdmatool, there will be a total of 576 bytes data output, where the first 512 bytes is QPC and the last 64 bytes is SCCC. When congestion control is disabled, the 64 byte SCCC will be all 0. Example: $rdma res show qp -jpr [ { "ifindex": 0, "ifname": "hns_0", "data": [ 67,0,0,0... 512bytes 4,0,2... 64bytes] },... } ] Signed-off-by: wenglianfa <[email protected]> Signed-off-by: Junxian Huang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 155f043 commit 124a9fb

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed

drivers/infiniband/hw/hns/hns_roce_cmd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ enum {
108108
HNS_ROCE_CMD_QUERY_CEQC = 0x92,
109109
HNS_ROCE_CMD_DESTROY_CEQC = 0x93,
110110

111+
/* SCC CTX commands */
112+
HNS_ROCE_CMD_QUERY_SCCC = 0xa2,
113+
111114
/* SCC CTX BT commands */
112115
HNS_ROCE_CMD_READ_SCCC_BT0 = 0xa4,
113116
HNS_ROCE_CMD_WRITE_SCCC_BT0 = 0xa5,

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ struct hns_roce_hw {
947947
int (*query_qpc)(struct hns_roce_dev *hr_dev, u32 qpn, void *buffer);
948948
int (*query_mpt)(struct hns_roce_dev *hr_dev, u32 key, void *buffer);
949949
int (*query_srqc)(struct hns_roce_dev *hr_dev, u32 srqn, void *buffer);
950+
int (*query_sccc)(struct hns_roce_dev *hr_dev, u32 qpn, void *buffer);
950951
int (*query_hw_counter)(struct hns_roce_dev *hr_dev,
951952
u64 *stats, u32 port, int *hw_counters);
952953
const struct ib_device_ops *hns_roce_dev_ops;

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5317,6 +5317,30 @@ static int hns_roce_v2_query_srqc(struct hns_roce_dev *hr_dev, u32 srqn,
53175317
return ret;
53185318
}
53195319

5320+
static int hns_roce_v2_query_sccc(struct hns_roce_dev *hr_dev, u32 qpn,
5321+
void *buffer)
5322+
{
5323+
struct hns_roce_v2_scc_context *context;
5324+
struct hns_roce_cmd_mailbox *mailbox;
5325+
int ret;
5326+
5327+
mailbox = hns_roce_alloc_cmd_mailbox(hr_dev);
5328+
if (IS_ERR(mailbox))
5329+
return PTR_ERR(mailbox);
5330+
5331+
ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_SCCC,
5332+
qpn);
5333+
if (ret)
5334+
goto out;
5335+
5336+
context = mailbox->buf;
5337+
memcpy(buffer, context, sizeof(*context));
5338+
5339+
out:
5340+
hns_roce_free_cmd_mailbox(hr_dev, mailbox);
5341+
return ret;
5342+
}
5343+
53205344
static u8 get_qp_timeout_attr(struct hns_roce_dev *hr_dev,
53215345
struct hns_roce_v2_qp_context *context)
53225346
{
@@ -6709,6 +6733,7 @@ static const struct hns_roce_hw hns_roce_hw_v2 = {
67096733
.query_qpc = hns_roce_v2_query_qpc,
67106734
.query_mpt = hns_roce_v2_query_mpt,
67116735
.query_srqc = hns_roce_v2_query_srqc,
6736+
.query_sccc = hns_roce_v2_query_sccc,
67126737
.query_hw_counter = hns_roce_hw_v2_query_counter,
67136738
.hns_roce_dev_ops = &hns_roce_v2_dev_ops,
67146739
.hns_roce_dev_srq_ops = &hns_roce_v2_dev_srq_ops,

drivers/infiniband/hw/hns/hns_roce_hw_v2.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,12 @@ struct hns_roce_v2_qp_context {
646646
#define QPCEX_SQ_RQ_NOT_FORBID_EN QPCEX_FIELD_LOC(23, 23)
647647
#define QPCEX_STASH QPCEX_FIELD_LOC(82, 82)
648648

649+
#define SCC_CONTEXT_SIZE 16
650+
651+
struct hns_roce_v2_scc_context {
652+
__le32 data[SCC_CONTEXT_SIZE];
653+
};
654+
649655
#define V2_QP_RWE_S 1 /* rdma write enable */
650656
#define V2_QP_RRE_S 2 /* rdma read enable */
651657
#define V2_QP_ATE_S 3 /* rdma atomic enable */

drivers/infiniband/hw/hns/hns_roce_restrack.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,33 @@ int hns_roce_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ib_qp)
9797
{
9898
struct hns_roce_dev *hr_dev = to_hr_dev(ib_qp->device);
9999
struct hns_roce_qp *hr_qp = to_hr_qp(ib_qp);
100-
struct hns_roce_v2_qp_context context;
100+
struct hns_roce_full_qp_ctx {
101+
struct hns_roce_v2_qp_context qpc;
102+
struct hns_roce_v2_scc_context sccc;
103+
} context = {};
101104
int ret;
102105

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

106-
ret = hr_dev->hw->query_qpc(hr_dev, hr_qp->qpn, &context);
109+
ret = hr_dev->hw->query_qpc(hr_dev, hr_qp->qpn, &context.qpc);
107110
if (ret)
108-
return -EINVAL;
111+
return ret;
112+
113+
/* If SCC is disabled or the query fails, the queried SCCC will
114+
* be all 0.
115+
*/
116+
if (!(hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL) ||
117+
!hr_dev->hw->query_sccc)
118+
goto out;
119+
120+
ret = hr_dev->hw->query_sccc(hr_dev, hr_qp->qpn, &context.sccc);
121+
if (ret)
122+
ibdev_warn_ratelimited(&hr_dev->ib_dev,
123+
"failed to query SCCC, ret = %d.\n",
124+
ret);
109125

126+
out:
110127
ret = nla_put(msg, RDMA_NLDEV_ATTR_RES_RAW, sizeof(context), &context);
111128

112129
return ret;

0 commit comments

Comments
 (0)