All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08
@ 2020-05-05 10:30 Weihang Li
  2020-05-05 10:30 ` [PATCH for-next 1/3] RDMA/hns: Add a macro " Weihang Li
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Weihang Li @ 2020-05-05 10:30 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

Patch #1 add a macro HIP08_C for this new pci device, #2 and #3 adjust
codes about flags.

Lang Cheng (1):
  RDMA/hns: Combine enable flags of qp

Weihang Li (2):
  RDMA/hns: Add a macro for next generation of hip08
  RDMA/hns: Extend capability flags for HIP08_C

 drivers/infiniband/hw/hns/hns_roce_device.h | 12 +++++++-----
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  |  5 ++++-
 drivers/infiniband/hw/hns/hns_roce_hw_v2.h  |  2 +-
 drivers/infiniband/hw/hns/hns_roce_qp.c     | 22 +++++++++++-----------
 4 files changed, 23 insertions(+), 18 deletions(-)

-- 
2.8.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH for-next 1/3] RDMA/hns: Add a macro for next generation of hip08
  2020-05-05 10:30 [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08 Weihang Li
@ 2020-05-05 10:30 ` Weihang Li
  2020-05-05 10:30 ` [PATCH for-next 2/3] RDMA/hns: Extend capability flags for HIP08_C Weihang Li
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Weihang Li @ 2020-05-05 10:30 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

0x30 is the new revision id for next generation of the pci device hip08,
add a macro of it for further features.

Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_device.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index ecbfeb6..c38ebce 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -37,9 +37,10 @@
 
 #define DRV_NAME "hns_roce"
 
-/* hip08 is a pci device, it includes two version according pci version id */
+/* hip08 is a pci device of three versions according to the revision id */
 #define PCI_REVISION_ID_HIP08_A			0x20
 #define PCI_REVISION_ID_HIP08_B			0x21
+#define PCI_REVISION_ID_HIP08_C			0x30
 
 #define HNS_ROCE_HW_VER1	('h' << 24 | 'i' << 16 | '0' << 8 | '6')
 
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH for-next 2/3] RDMA/hns: Extend capability flags for HIP08_C
  2020-05-05 10:30 [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08 Weihang Li
  2020-05-05 10:30 ` [PATCH for-next 1/3] RDMA/hns: Add a macro " Weihang Li
@ 2020-05-05 10:30 ` Weihang Li
  2020-05-05 10:30 ` [PATCH for-next 3/3] RDMA/hns: Combine enable flags of qp Weihang Li
  2020-05-13  0:27 ` [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08 Jason Gunthorpe
  3 siblings, 0 replies; 6+ messages in thread
From: Weihang Li @ 2020-05-05 10:30 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

12 bits is not enough for HIP08_C, so extend a new field in length of 16
bits for it.

Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_device.h | 2 ++
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  | 3 +++
 drivers/infiniband/hw/hns/hns_roce_hw_v2.h  | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index c38ebce..6ecdd7dd 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -210,6 +210,8 @@ enum {
 	HNS_ROCE_OPCODE_RDMA_WITH_IMM_RECEIVE	= 0x07,
 };
 
+#define HNS_ROCE_CAP_FLAGS_EX_SHIFT 12
+
 enum {
 	HNS_ROCE_CAP_FLAG_REREG_MR		= BIT(0),
 	HNS_ROCE_CAP_FLAG_ROCE_V1_V2		= BIT(1),
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 2a8c389..500b4c3 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -1786,6 +1786,9 @@ static int hns_roce_query_pf_caps(struct hns_roce_dev *hr_dev)
 	caps->flags = roce_get_field(resp_c->cap_flags_num_pds,
 				     V2_QUERY_PF_CAPS_C_CAP_FLAGS_M,
 				     V2_QUERY_PF_CAPS_C_CAP_FLAGS_S);
+	caps->flags |= le16_to_cpu(resp_d->cap_flags_ex) <<
+		       HNS_ROCE_CAP_FLAGS_EX_SHIFT;
+
 	caps->num_cqs = 1 << roce_get_field(resp_c->max_gid_num_cqs,
 					    V2_QUERY_PF_CAPS_C_NUM_CQS_M,
 					    V2_QUERY_PF_CAPS_C_NUM_CQS_S);
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
index 82dd9f6..dc10506 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
@@ -1648,7 +1648,7 @@ struct hns_roce_query_pf_caps_c {
 struct hns_roce_query_pf_caps_d {
 	__le32 wq_hop_num_max_srqs;
 	__le16 srq_depth;
-	__le16 rsv;
+	__le16 cap_flags_ex;
 	__le32 num_ceqs_ceq_depth;
 	__le32 arm_st_aeq_depth;
 	__le32 num_uars_rsv_pds;
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH for-next 3/3] RDMA/hns: Combine enable flags of qp
  2020-05-05 10:30 [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08 Weihang Li
  2020-05-05 10:30 ` [PATCH for-next 1/3] RDMA/hns: Add a macro " Weihang Li
  2020-05-05 10:30 ` [PATCH for-next 2/3] RDMA/hns: Extend capability flags for HIP08_C Weihang Li
@ 2020-05-05 10:30 ` Weihang Li
  2020-05-13  0:27 ` [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08 Jason Gunthorpe
  3 siblings, 0 replies; 6+ messages in thread
From: Weihang Li @ 2020-05-05 10:30 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

From: Lang Cheng <chenglang@huawei.com>

It's easier to understand and maintain enable flags of qp using a single
field in type of unsigned long than defining a field for every flags in
the structure hns_roce_qp, and we can add new flags for features more
conveniently in the future.

Signed-off-by: Lang Cheng <chenglang@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_device.h |  7 +++----
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  |  2 +-
 drivers/infiniband/hw/hns/hns_roce_qp.c     | 22 +++++++++++-----------
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 6ecdd7dd..b6ee875 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -132,8 +132,8 @@ enum {
 };
 
 enum {
-	HNS_ROCE_SUPPORT_RQ_RECORD_DB = 1 << 0,
-	HNS_ROCE_SUPPORT_SQ_RECORD_DB = 1 << 1,
+	HNS_ROCE_QP_CAP_RQ_RECORD_DB = BIT(0),
+	HNS_ROCE_QP_CAP_SQ_RECORD_DB = BIT(1),
 };
 
 enum {
@@ -677,8 +677,7 @@ struct hns_roce_qp {
 	struct hns_roce_wq	rq;
 	struct hns_roce_db	rdb;
 	struct hns_roce_db	sdb;
-	u8			rdb_en;
-	u8			sdb_en;
+	unsigned long		en_flags;
 	u32			doorbell_qpn;
 	u32			sq_signal_bits;
 	struct hns_roce_wq	sq;
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 500b4c3..5d5aedd 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -3546,7 +3546,7 @@ static void modify_qp_reset_to_init(struct ib_qp *ibqp,
 	roce_set_field(context->byte_24_mtu_tc, V2_QPC_BYTE_24_VLAN_ID_M,
 		       V2_QPC_BYTE_24_VLAN_ID_S, 0xfff);
 
-	if (hr_qp->rdb_en)
+	if (hr_qp->en_flags & HNS_ROCE_QP_CAP_RQ_RECORD_DB)
 		roce_set_bit(context->byte_68_rq_db,
 			     V2_QPC_BYTE_68_RQ_RECORD_EN_S, 1);
 
diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
index d05d3cb..5b1ef08 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -822,8 +822,8 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
 					  "Failed to map user SQ doorbell\n");
 				goto err_out;
 			}
-			hr_qp->sdb_en = 1;
-			resp->cap_flags |= HNS_ROCE_SUPPORT_SQ_RECORD_DB;
+			hr_qp->en_flags |= HNS_ROCE_QP_CAP_SQ_RECORD_DB;
+			resp->cap_flags |= HNS_ROCE_QP_CAP_SQ_RECORD_DB;
 		}
 
 		if (user_qp_has_rdb(hr_dev, init_attr, udata, resp)) {
@@ -834,8 +834,8 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
 					  "Failed to map user RQ doorbell\n");
 				goto err_sdb;
 			}
-			hr_qp->rdb_en = 1;
-			resp->cap_flags |= HNS_ROCE_SUPPORT_RQ_RECORD_DB;
+			hr_qp->en_flags |= HNS_ROCE_QP_CAP_RQ_RECORD_DB;
+			resp->cap_flags |= HNS_ROCE_QP_CAP_RQ_RECORD_DB;
 		}
 	} else {
 		/* QP doorbell register address */
@@ -852,13 +852,13 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
 				goto err_out;
 			}
 			*hr_qp->rdb.db_record = 0;
-			hr_qp->rdb_en = 1;
+			hr_qp->en_flags |= HNS_ROCE_QP_CAP_RQ_RECORD_DB;
 		}
 	}
 
 	return 0;
 err_sdb:
-	if (udata && hr_qp->sdb_en)
+	if (udata && hr_qp->en_flags & HNS_ROCE_QP_CAP_SQ_RECORD_DB)
 		hns_roce_db_unmap_user(uctx, &hr_qp->sdb);
 err_out:
 	return ret;
@@ -871,12 +871,12 @@ static void free_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
 		udata, struct hns_roce_ucontext, ibucontext);
 
 	if (udata) {
-		if (hr_qp->rdb_en)
+		if (hr_qp->en_flags & HNS_ROCE_QP_CAP_RQ_RECORD_DB)
 			hns_roce_db_unmap_user(uctx, &hr_qp->rdb);
-		if (hr_qp->sdb_en)
+		if (hr_qp->en_flags & HNS_ROCE_QP_CAP_SQ_RECORD_DB)
 			hns_roce_db_unmap_user(uctx, &hr_qp->sdb);
 	} else {
-		if (hr_qp->rdb_en)
+		if (hr_qp->en_flags & HNS_ROCE_QP_CAP_RQ_RECORD_DB)
 			hns_roce_free_db(hr_dev, &hr_qp->rdb);
 	}
 }
@@ -1249,10 +1249,10 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 
 	if (ibqp->uobject &&
 	    (attr_mask & IB_QP_STATE) && new_state == IB_QPS_ERR) {
-		if (hr_qp->sdb_en == 1) {
+		if (hr_qp->en_flags & HNS_ROCE_QP_CAP_SQ_RECORD_DB) {
 			hr_qp->sq.head = *(int *)(hr_qp->sdb.virt_addr);
 
-			if (hr_qp->rdb_en == 1)
+			if (hr_qp->en_flags & HNS_ROCE_QP_CAP_RQ_RECORD_DB)
 				hr_qp->rq.head = *(int *)(hr_qp->rdb.virt_addr);
 		} else {
 			ibdev_warn(&hr_dev->ib_dev,
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08
  2020-05-05 10:30 [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08 Weihang Li
                   ` (2 preceding siblings ...)
  2020-05-05 10:30 ` [PATCH for-next 3/3] RDMA/hns: Combine enable flags of qp Weihang Li
@ 2020-05-13  0:27 ` Jason Gunthorpe
  2020-05-13  6:47   ` liweihang
  3 siblings, 1 reply; 6+ messages in thread
From: Jason Gunthorpe @ 2020-05-13  0:27 UTC (permalink / raw)
  To: Weihang Li; +Cc: dledford, leon, linux-rdma, linuxarm

On Tue, May 05, 2020 at 06:30:04PM +0800, Weihang Li wrote:
> Patch #1 add a macro HIP08_C for this new pci device, #2 and #3 adjust
> codes about flags.
> 
> Lang Cheng (1):
>   RDMA/hns: Combine enable flags of qp
> 
> Weihang Li (2):
>   RDMA/hns: Extend capability flags for HIP08_C

These two applied to for-next

>   RDMA/hns: Add a macro for next generation of hip08

This is just dead code, send it as part of something that uses it.

Thanks,
Jason

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08
  2020-05-13  0:27 ` [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08 Jason Gunthorpe
@ 2020-05-13  6:47   ` liweihang
  0 siblings, 0 replies; 6+ messages in thread
From: liweihang @ 2020-05-13  6:47 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: dledford, leon, linux-rdma, Linuxarm

On 2020/5/13 8:27, Jason Gunthorpe wrote:
> On Tue, May 05, 2020 at 06:30:04PM +0800, Weihang Li wrote:
>> Patch #1 add a macro HIP08_C for this new pci device, #2 and #3 adjust
>> codes about flags.
>>
>> Lang Cheng (1):
>>   RDMA/hns: Combine enable flags of qp
>>
>> Weihang Li (2):
>>   RDMA/hns: Extend capability flags for HIP08_C
> 
> These two applied to for-next
> 
>>   RDMA/hns: Add a macro for next generation of hip08
> 
> This is just dead code, send it as part of something that uses it.
> > Thanks,
> Jason
> 

I see, thank you.

Weihang

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-05-13  6:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 10:30 [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08 Weihang Li
2020-05-05 10:30 ` [PATCH for-next 1/3] RDMA/hns: Add a macro " Weihang Li
2020-05-05 10:30 ` [PATCH for-next 2/3] RDMA/hns: Extend capability flags for HIP08_C Weihang Li
2020-05-05 10:30 ` [PATCH for-next 3/3] RDMA/hns: Combine enable flags of qp Weihang Li
2020-05-13  0:27 ` [PATCH for-next 0/3] RDMA/hns: Preparing for next generation of hip08 Jason Gunthorpe
2020-05-13  6:47   ` liweihang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.