diff mbox

[V3,for-next,3/5] RDMA/hns: Add TPQ link table support

Message ID 1530860537-42235-4-git-send-email-oulijun@huawei.com (mailing list archive)
State Superseded
Headers show

Commit Message

Lijun Ou July 6, 2018, 7:02 a.m. UTC
In hip08, the TPQ(Timer Poll Queue) should be extended
to host memory. This patch adds the support of TPQ.

Signed-off-by: Yixian Liu <liuyixian@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_device.h |  1 +
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  | 28 +++++++++++++++++++++++++++-
 drivers/infiniband/hw/hns/hns_roce_hw_v2.h  |  3 +++
 3 files changed, 31 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 0f0b6d9..d5855c5 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -722,6 +722,7 @@  struct hns_roce_caps {
 	u32		eqe_hop_num;
 	u32		sl_num;
 	u32		tsq_buf_pg_sz;
+	u32		tpq_buf_pg_sz;
 	u32		chunk_sz;	/* chunk size in non multihop mode*/
 	u64		flags;
 };
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index c189626..3122d46 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -1251,6 +1251,10 @@  static int hns_roce_config_link_table(struct hns_roce_dev *hr_dev,
 		link_tbl = &priv->tsq;
 		opcode = HNS_ROCE_OPC_CFG_EXT_LLM;
 		break;
+	case TPQ_LINK_TABLE:
+		link_tbl = &priv->tpq;
+		opcode = HNS_ROCE_OPC_CFG_TMOUT_LLM;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -1315,6 +1319,7 @@  static int hns_roce_init_link_table(struct hns_roce_dev *hr_dev,
 	struct device *dev = hr_dev->dev;
 	u32 buf_chk_sz;
 	dma_addr_t t;
+	int func_num = 1;
 	int pg_num_a;
 	int pg_num_b;
 	int pg_num;
@@ -1328,6 +1333,12 @@  static int hns_roce_init_link_table(struct hns_roce_dev *hr_dev,
 		pg_num_a = hr_dev->caps.num_qps * 8 / buf_chk_sz;
 		pg_num_b = hr_dev->caps.sl_num * 4 + 2;
 		break;
+	case TPQ_LINK_TABLE:
+		link_tbl = &priv->tpq;
+		buf_chk_sz = 1 << (hr_dev->caps.tpq_buf_pg_sz +	PAGE_SHIFT);
+		pg_num_a = hr_dev->caps.num_cqs * 4 / buf_chk_sz;
+		pg_num_b = 2 * 4 * func_num + 2;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -1410,12 +1421,26 @@  static void hns_roce_free_link_table(struct hns_roce_dev *hr_dev,
 
 static int hns_roce_v2_init(struct hns_roce_dev *hr_dev)
 {
+	struct hns_roce_v2_priv *priv = hr_dev->priv;
 	int ret;
 
 	/* TSQ includes SQ doorbell and ack doorbell */
 	ret = hns_roce_init_link_table(hr_dev, TSQ_LINK_TABLE);
-	if (ret)
+	if (ret) {
 		dev_err(hr_dev->dev, "TSQ init failed, ret = %d.\n", ret);
+		return ret;
+	}
+
+	ret = hns_roce_init_link_table(hr_dev, TPQ_LINK_TABLE);
+	if (ret) {
+		dev_err(hr_dev->dev, "TPQ init failed, ret = %d.\n", ret);
+		goto err_tpq_init_failed;
+	}
+
+	return 0;
+
+err_tpq_init_failed:
+	hns_roce_free_link_table(hr_dev, &priv->tsq);
 
 	return ret;
 }
@@ -1424,6 +1449,7 @@  static void hns_roce_v2_exit(struct hns_roce_dev *hr_dev)
 {
 	struct hns_roce_v2_priv *priv = hr_dev->priv;
 
+	hns_roce_free_link_table(hr_dev, &priv->tpq);
 	hns_roce_free_link_table(hr_dev, &priv->tsq);
 }
 
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
index 18626d3..6ad83ea 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
@@ -204,6 +204,7 @@  enum hns_roce_opcode_type {
 	HNS_ROCE_OPC_QUERY_PF_RES			= 0x8400,
 	HNS_ROCE_OPC_ALLOC_VF_RES			= 0x8401,
 	HNS_ROCE_OPC_CFG_EXT_LLM			= 0x8403,
+	HNS_ROCE_OPC_CFG_TMOUT_LLM			= 0x8404,
 	HNS_ROCE_OPC_CFG_BT_ATTR			= 0x8506,
 };
 
@@ -1339,6 +1340,7 @@  struct hns_roce_v2_cmq {
 
 enum hns_roce_link_table_type {
 	TSQ_LINK_TABLE,
+	TPQ_LINK_TABLE,
 };
 
 struct hns_roce_link_table {
@@ -1361,6 +1363,7 @@  struct hns_roce_link_table_entry {
 struct hns_roce_v2_priv {
 	struct hns_roce_v2_cmq cmq;
 	struct hns_roce_link_table tsq;
+	struct hns_roce_link_table tpq;
 };
 
 struct hns_roce_eq_context {