linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-next v2 0/4] Add support for 0xefa1 device
@ 2020-07-20  8:01 Gal Pressman
  2020-07-20  8:01 ` [PATCH for-next v2 1/4] RDMA/efa: Expose maximum TX doorbell batch Gal Pressman
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Gal Pressman @ 2020-07-20  8:01 UTC (permalink / raw)
  To: Jason Gunthorpe, Doug Ledford
  Cc: linux-rdma, Alexander Matushevsky, Gal Pressman

Hi all,

The following submission adds the needed functionality in order to
support 0xefa1 devices, and adds it to the driver pci table.

PR was sent:
https://github.com/linux-rdma/rdma-core/pull/789

Changelog -
v1->v2: https://lore.kernel.org/linux-rdma/20200709083630.21377-1-galpress@amazon.com/
* Add handshake with userspace provider to verify required features
  support.

Regards,
Gal

Gal Pressman (4):
  RDMA/efa: Expose maximum TX doorbell batch
  RDMA/efa: Expose minimum SQ size
  RDMA/efa: User/kernel compatibility handshake mechanism
  RDMA/efa: Add EFA 0xefa1 PCI ID

 .../infiniband/hw/efa/efa_admin_cmds_defs.h   | 15 ++++-
 drivers/infiniband/hw/efa/efa_com_cmd.c       |  2 +
 drivers/infiniband/hw/efa/efa_com_cmd.h       |  2 +
 drivers/infiniband/hw/efa/efa_main.c          |  6 +-
 drivers/infiniband/hw/efa/efa_verbs.c         | 62 +++++++++++++++++++
 include/uapi/rdma/efa-abi.h                   | 15 ++++-
 6 files changed, 97 insertions(+), 5 deletions(-)


base-commit: 5f0b2a6093a4d9aab093964c65083fe801ef1e58
-- 
2.27.0


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

* [PATCH for-next v2 1/4] RDMA/efa: Expose maximum TX doorbell batch
  2020-07-20  8:01 [PATCH for-next v2 0/4] Add support for 0xefa1 device Gal Pressman
@ 2020-07-20  8:01 ` Gal Pressman
  2020-07-20  8:01 ` [PATCH for-next v2 2/4] RDMA/efa: Expose minimum SQ size Gal Pressman
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Gal Pressman @ 2020-07-20  8:01 UTC (permalink / raw)
  To: Jason Gunthorpe, Doug Ledford
  Cc: linux-rdma, Alexander Matushevsky, Gal Pressman,
	Daniel Kranzdorf, Firas JahJah

The device reports the maximum number of bytes to be written before
ringing the doorbell (zero means unlimited).

This patch queries the max batch size and reports it back to the
userspace library.

Reviewed-by: Daniel Kranzdorf <dkkranzd@amazon.com>
Reviewed-by: Firas JahJah <firasj@amazon.com>
Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 drivers/infiniband/hw/efa/efa_admin_cmds_defs.h | 11 +++++++++++
 drivers/infiniband/hw/efa/efa_com_cmd.c         |  1 +
 drivers/infiniband/hw/efa/efa_com_cmd.h         |  1 +
 drivers/infiniband/hw/efa/efa_verbs.c           |  1 +
 include/uapi/rdma/efa-abi.h                     |  4 +++-
 5 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/efa/efa_admin_cmds_defs.h b/drivers/infiniband/hw/efa/efa_admin_cmds_defs.h
index bef2bd291054..03e7388af06e 100644
--- a/drivers/infiniband/hw/efa/efa_admin_cmds_defs.h
+++ b/drivers/infiniband/hw/efa/efa_admin_cmds_defs.h
@@ -632,6 +632,17 @@ struct efa_admin_feature_queue_attr_desc {
 
 	/* Maximum number of SGEs for a single RDMA read WQE */
 	u16 max_wr_rdma_sges;
+
+	/*
+	 * Maximum number of bytes that can be written to SQ between two
+	 * consecutive doorbells (in units of 64B). Driver must ensure that only
+	 * complete WQEs are written to queue before issuing a doorbell.
+	 * Examples: max_tx_batch=16 and WQE size = 64B, means up to 16 WQEs can
+	 * be written to SQ between two consecutive doorbells. max_tx_batch=11
+	 * and WQE size = 128B, means up to 5 WQEs can be written to SQ between
+	 * two consecutive doorbells. Zero means unlimited.
+	 */
+	u16 max_tx_batch;
 };
 
 struct efa_admin_feature_aenq_desc {
diff --git a/drivers/infiniband/hw/efa/efa_com_cmd.c b/drivers/infiniband/hw/efa/efa_com_cmd.c
index fabd8df2e78f..53cfde5c43d8 100644
--- a/drivers/infiniband/hw/efa/efa_com_cmd.c
+++ b/drivers/infiniband/hw/efa/efa_com_cmd.c
@@ -480,6 +480,7 @@ int efa_com_get_device_attr(struct efa_com_dev *edev,
 	result->max_llq_size = resp.u.queue_attr.max_llq_size;
 	result->sub_cqs_per_cq = resp.u.queue_attr.sub_cqs_per_cq;
 	result->max_wr_rdma_sge = resp.u.queue_attr.max_wr_rdma_sges;
+	result->max_tx_batch = resp.u.queue_attr.max_tx_batch;
 
 	err = efa_com_get_feature(edev, &resp, EFA_ADMIN_NETWORK_ATTR);
 	if (err) {
diff --git a/drivers/infiniband/hw/efa/efa_com_cmd.h b/drivers/infiniband/hw/efa/efa_com_cmd.h
index 41ce4a476ee6..8df2a26d57d4 100644
--- a/drivers/infiniband/hw/efa/efa_com_cmd.h
+++ b/drivers/infiniband/hw/efa/efa_com_cmd.h
@@ -127,6 +127,7 @@ struct efa_com_get_device_attr_result {
 	u16 max_sq_sge;
 	u16 max_rq_sge;
 	u16 max_wr_rdma_sge;
+	u16 max_tx_batch;
 	u8 db_bar;
 };
 
diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
index 08313f7c73bc..f49d14cebe4a 100644
--- a/drivers/infiniband/hw/efa/efa_verbs.c
+++ b/drivers/infiniband/hw/efa/efa_verbs.c
@@ -1525,6 +1525,7 @@ int efa_alloc_ucontext(struct ib_ucontext *ibucontext, struct ib_udata *udata)
 	resp.sub_cqs_per_cq = dev->dev_attr.sub_cqs_per_cq;
 	resp.inline_buf_size = dev->dev_attr.inline_buf_size;
 	resp.max_llq_size = dev->dev_attr.max_llq_size;
+	resp.max_tx_batch = dev->dev_attr.max_tx_batch;
 
 	if (udata && udata->outlen) {
 		err = ib_copy_to_udata(udata, &resp,
diff --git a/include/uapi/rdma/efa-abi.h b/include/uapi/rdma/efa-abi.h
index 53b6e2036a9b..10781763da37 100644
--- a/include/uapi/rdma/efa-abi.h
+++ b/include/uapi/rdma/efa-abi.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
 /*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All rights reserved.
+ * Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All rights reserved.
  */
 
 #ifndef EFA_ABI_USER_H
@@ -31,6 +31,8 @@ struct efa_ibv_alloc_ucontext_resp {
 	__u16 sub_cqs_per_cq;
 	__u16 inline_buf_size;
 	__u32 max_llq_size; /* bytes */
+	__u16 max_tx_batch; /* units of 64 bytes */
+	__u8 reserved_90[6];
 };
 
 struct efa_ibv_alloc_pd_resp {
-- 
2.27.0


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

* [PATCH for-next v2 2/4] RDMA/efa: Expose minimum SQ size
  2020-07-20  8:01 [PATCH for-next v2 0/4] Add support for 0xefa1 device Gal Pressman
  2020-07-20  8:01 ` [PATCH for-next v2 1/4] RDMA/efa: Expose maximum TX doorbell batch Gal Pressman
@ 2020-07-20  8:01 ` Gal Pressman
  2020-07-20  8:01 ` [PATCH for-next v2 3/4] RDMA/efa: User/kernel compatibility handshake mechanism Gal Pressman
  2020-07-20  8:01 ` [PATCH for-next v2 4/4] RDMA/efa: Add EFA 0xefa1 PCI ID Gal Pressman
  3 siblings, 0 replies; 10+ messages in thread
From: Gal Pressman @ 2020-07-20  8:01 UTC (permalink / raw)
  To: Jason Gunthorpe, Doug Ledford
  Cc: linux-rdma, Alexander Matushevsky, Gal Pressman, Firas JahJah,
	Shadi Ammouri

The device reports the minimum SQ size required for creation.

This patch queries the min SQ size and reports it back to the
userspace library.

Reviewed-by: Firas JahJah <firasj@amazon.com>
Reviewed-by: Shadi Ammouri <sammouri@amazon.com>
Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 drivers/infiniband/hw/efa/efa_admin_cmds_defs.h | 4 ++--
 drivers/infiniband/hw/efa/efa_com_cmd.c         | 1 +
 drivers/infiniband/hw/efa/efa_com_cmd.h         | 1 +
 drivers/infiniband/hw/efa/efa_verbs.c           | 1 +
 include/uapi/rdma/efa-abi.h                     | 3 ++-
 5 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/efa/efa_admin_cmds_defs.h b/drivers/infiniband/hw/efa/efa_admin_cmds_defs.h
index 03e7388af06e..5484b08bbc5d 100644
--- a/drivers/infiniband/hw/efa/efa_admin_cmds_defs.h
+++ b/drivers/infiniband/hw/efa/efa_admin_cmds_defs.h
@@ -606,8 +606,8 @@ struct efa_admin_feature_queue_attr_desc {
 	/* Number of sub-CQs to be created for each CQ */
 	u16 sub_cqs_per_cq;
 
-	/* MBZ */
-	u16 reserved;
+	/* Minimum number of WQEs per SQ */
+	u16 min_sq_depth;
 
 	/* Maximum number of SGEs (buffers) allowed for a single send WQE */
 	u16 max_wr_send_sges;
diff --git a/drivers/infiniband/hw/efa/efa_com_cmd.c b/drivers/infiniband/hw/efa/efa_com_cmd.c
index 53cfde5c43d8..6ac23627f65a 100644
--- a/drivers/infiniband/hw/efa/efa_com_cmd.c
+++ b/drivers/infiniband/hw/efa/efa_com_cmd.c
@@ -481,6 +481,7 @@ int efa_com_get_device_attr(struct efa_com_dev *edev,
 	result->sub_cqs_per_cq = resp.u.queue_attr.sub_cqs_per_cq;
 	result->max_wr_rdma_sge = resp.u.queue_attr.max_wr_rdma_sges;
 	result->max_tx_batch = resp.u.queue_attr.max_tx_batch;
+	result->min_sq_depth = resp.u.queue_attr.min_sq_depth;
 
 	err = efa_com_get_feature(edev, &resp, EFA_ADMIN_NETWORK_ATTR);
 	if (err) {
diff --git a/drivers/infiniband/hw/efa/efa_com_cmd.h b/drivers/infiniband/hw/efa/efa_com_cmd.h
index 8df2a26d57d4..190bac23f585 100644
--- a/drivers/infiniband/hw/efa/efa_com_cmd.h
+++ b/drivers/infiniband/hw/efa/efa_com_cmd.h
@@ -128,6 +128,7 @@ struct efa_com_get_device_attr_result {
 	u16 max_rq_sge;
 	u16 max_wr_rdma_sge;
 	u16 max_tx_batch;
+	u16 min_sq_depth;
 	u8 db_bar;
 };
 
diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
index f49d14cebe4a..26102ab333b2 100644
--- a/drivers/infiniband/hw/efa/efa_verbs.c
+++ b/drivers/infiniband/hw/efa/efa_verbs.c
@@ -1526,6 +1526,7 @@ int efa_alloc_ucontext(struct ib_ucontext *ibucontext, struct ib_udata *udata)
 	resp.inline_buf_size = dev->dev_attr.inline_buf_size;
 	resp.max_llq_size = dev->dev_attr.max_llq_size;
 	resp.max_tx_batch = dev->dev_attr.max_tx_batch;
+	resp.min_sq_wr = dev->dev_attr.min_sq_depth;
 
 	if (udata && udata->outlen) {
 		err = ib_copy_to_udata(udata, &resp,
diff --git a/include/uapi/rdma/efa-abi.h b/include/uapi/rdma/efa-abi.h
index 10781763da37..7ef2306f8dd4 100644
--- a/include/uapi/rdma/efa-abi.h
+++ b/include/uapi/rdma/efa-abi.h
@@ -32,7 +32,8 @@ struct efa_ibv_alloc_ucontext_resp {
 	__u16 inline_buf_size;
 	__u32 max_llq_size; /* bytes */
 	__u16 max_tx_batch; /* units of 64 bytes */
-	__u8 reserved_90[6];
+	__u16 min_sq_wr;
+	__u8 reserved_a0[4];
 };
 
 struct efa_ibv_alloc_pd_resp {
-- 
2.27.0


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

* [PATCH for-next v2 3/4] RDMA/efa: User/kernel compatibility handshake mechanism
  2020-07-20  8:01 [PATCH for-next v2 0/4] Add support for 0xefa1 device Gal Pressman
  2020-07-20  8:01 ` [PATCH for-next v2 1/4] RDMA/efa: Expose maximum TX doorbell batch Gal Pressman
  2020-07-20  8:01 ` [PATCH for-next v2 2/4] RDMA/efa: Expose minimum SQ size Gal Pressman
@ 2020-07-20  8:01 ` Gal Pressman
  2020-07-20 17:08   ` kernel test robot
  2020-07-20  8:01 ` [PATCH for-next v2 4/4] RDMA/efa: Add EFA 0xefa1 PCI ID Gal Pressman
  3 siblings, 1 reply; 10+ messages in thread
From: Gal Pressman @ 2020-07-20  8:01 UTC (permalink / raw)
  To: Jason Gunthorpe, Doug Ledford
  Cc: linux-rdma, Alexander Matushevsky, Gal Pressman, Shadi Ammouri,
	Yossi Leybovich

Introduce a mechanism that performs an handshake between the userspace
provider and kernel driver which verifies that the user supports all
required features in order to operate correctly.

The handshake verifies the needed functionality by comparing the
reported device caps and the provider caps. If the device reports a
non-zero capability the appropriate comp mask is required from the
userspace provider in order to allocate the context.

Reviewed-by: Shadi Ammouri <sammouri@amazon.com>
Reviewed-by: Yossi Leybovich <sleybo@amazon.com>
Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 drivers/infiniband/hw/efa/efa_verbs.c | 60 +++++++++++++++++++++++++++
 include/uapi/rdma/efa-abi.h           | 10 +++++
 2 files changed, 70 insertions(+)

diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
index 26102ab333b2..f60bf9ce656f 100644
--- a/drivers/infiniband/hw/efa/efa_verbs.c
+++ b/drivers/infiniband/hw/efa/efa_verbs.c
@@ -1501,11 +1501,59 @@ static int efa_dealloc_uar(struct efa_dev *dev, u16 uarn)
 	return efa_com_dealloc_uar(&dev->edev, &params);
 }
 
+#define DEFINE_GET_DEV_ATTR_FUNC(_attr)                                        \
+	bool dev_attr_##_attr(const struct efa_dev *dev)                       \
+	{                                                                      \
+		return dev->dev_attr._attr;                                    \
+	}
+
+#define DEFINE_CHECK_COMP_FUNC(_attr, _mask)                                   \
+	bool check_comp_##_attr(const struct efa_dev *dev, u32 comp_mask)      \
+	{                                                                      \
+		return !dev_attr_##_attr(dev) || (comp_mask & (_mask));        \
+	}
+
+#define DEFINE_COMP_HANDSHAKE(_attr, _mask)                                    \
+	{                                                                      \
+		.attr = #_attr,                                                \
+		.check_comp = ({                                               \
+			DEFINE_GET_DEV_ATTR_FUNC(_attr)                        \
+			DEFINE_CHECK_COMP_FUNC(_attr, _mask)                   \
+			check_comp_##_attr;                                    \
+		}),                                                            \
+	}
+
+int efa_user_comp_handshake(const struct ib_ucontext *ibucontext,
+			    const struct efa_ibv_alloc_ucontext_cmd *cmd)
+{
+	struct {
+		char *attr;
+		bool (*check_comp)(const struct efa_dev *dev, u32 comp_mask);
+	} user_comp_handshakes[] = {
+		DEFINE_COMP_HANDSHAKE(max_tx_batch, EFA_ALLOC_UCONTEXT_CMD_COMP_TX_BATCH),
+		DEFINE_COMP_HANDSHAKE(min_sq_depth, EFA_ALLOC_UCONTEXT_CMD_COMP_MIN_SQ_WR),
+	};
+	struct efa_dev *dev = to_edev(ibucontext->device);
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(user_comp_handshakes); i++) {
+		if (!user_comp_handshakes[i].check_comp(dev, cmd->comp_mask)) {
+			ibdev_dbg(&dev->ibdev,
+				  "Userspace handshake failed for %s attribute\n",
+				  user_comp_handshakes[i].attr);
+			return -EOPNOTSUPP;
+		}
+	}
+
+	return 0;
+}
+
 int efa_alloc_ucontext(struct ib_ucontext *ibucontext, struct ib_udata *udata)
 {
 	struct efa_ucontext *ucontext = to_eucontext(ibucontext);
 	struct efa_dev *dev = to_edev(ibucontext->device);
 	struct efa_ibv_alloc_ucontext_resp resp = {};
+	struct efa_ibv_alloc_ucontext_cmd cmd = {};
 	struct efa_com_alloc_uar_result result;
 	int err;
 
@@ -1514,6 +1562,18 @@ int efa_alloc_ucontext(struct ib_ucontext *ibucontext, struct ib_udata *udata)
 	 * we will ack input fields in our response.
 	 */
 
+	err = ib_copy_from_udata(&cmd, udata,
+				 min(sizeof(cmd), udata->inlen));
+	if (err) {
+		ibdev_dbg(&dev->ibdev,
+			  "Cannot copy udata for alloc_ucontext\n");
+		goto err_out;
+	}
+
+	err = efa_user_comp_handshake(ibucontext, &cmd);
+	if (err)
+		goto err_out;
+
 	err = efa_com_alloc_uar(&dev->edev, &result);
 	if (err)
 		goto err_out;
diff --git a/include/uapi/rdma/efa-abi.h b/include/uapi/rdma/efa-abi.h
index 7ef2306f8dd4..507a2862bedb 100644
--- a/include/uapi/rdma/efa-abi.h
+++ b/include/uapi/rdma/efa-abi.h
@@ -20,6 +20,16 @@
  * hex bit offset of the field.
  */
 
+enum {
+	EFA_ALLOC_UCONTEXT_CMD_COMP_TX_BATCH  = 1 << 0,
+	EFA_ALLOC_UCONTEXT_CMD_COMP_MIN_SQ_WR = 1 << 1,
+};
+
+struct efa_ibv_alloc_ucontext_cmd {
+	__u32 comp_mask;
+	__u8 reserved_20[4];
+};
+
 enum efa_ibv_user_cmds_supp_udata {
 	EFA_USER_CMDS_SUPP_UDATA_QUERY_DEVICE = 1 << 0,
 	EFA_USER_CMDS_SUPP_UDATA_CREATE_AH    = 1 << 1,
-- 
2.27.0


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

* [PATCH for-next v2 4/4] RDMA/efa: Add EFA 0xefa1 PCI ID
  2020-07-20  8:01 [PATCH for-next v2 0/4] Add support for 0xefa1 device Gal Pressman
                   ` (2 preceding siblings ...)
  2020-07-20  8:01 ` [PATCH for-next v2 3/4] RDMA/efa: User/kernel compatibility handshake mechanism Gal Pressman
@ 2020-07-20  8:01 ` Gal Pressman
  3 siblings, 0 replies; 10+ messages in thread
From: Gal Pressman @ 2020-07-20  8:01 UTC (permalink / raw)
  To: Jason Gunthorpe, Doug Ledford
  Cc: linux-rdma, Alexander Matushevsky, Gal Pressman, Shadi Ammouri,
	Yossi Leybovich

Add support for 0xefa1 devices.

Reviewed-by: Shadi Ammouri <sammouri@amazon.com>
Reviewed-by: Yossi Leybovich <sleybo@amazon.com>
Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 drivers/infiniband/hw/efa/efa_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/efa/efa_main.c b/drivers/infiniband/hw/efa/efa_main.c
index 82145574c928..92d701146320 100644
--- a/drivers/infiniband/hw/efa/efa_main.c
+++ b/drivers/infiniband/hw/efa/efa_main.c
@@ -12,10 +12,12 @@
 
 #include "efa.h"
 
-#define PCI_DEV_ID_EFA_VF 0xefa0
+#define PCI_DEV_ID_EFA0_VF 0xefa0
+#define PCI_DEV_ID_EFA1_VF 0xefa1
 
 static const struct pci_device_id efa_pci_tbl[] = {
-	{ PCI_VDEVICE(AMAZON, PCI_DEV_ID_EFA_VF) },
+	{ PCI_VDEVICE(AMAZON, PCI_DEV_ID_EFA0_VF) },
+	{ PCI_VDEVICE(AMAZON, PCI_DEV_ID_EFA1_VF) },
 	{ }
 };
 
-- 
2.27.0


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

* Re: [PATCH for-next v2 3/4] RDMA/efa: User/kernel compatibility handshake mechanism
  2020-07-20  8:01 ` [PATCH for-next v2 3/4] RDMA/efa: User/kernel compatibility handshake mechanism Gal Pressman
@ 2020-07-20 17:08   ` kernel test robot
  2020-07-21 11:26     ` Gal Pressman
  0 siblings, 1 reply; 10+ messages in thread
From: kernel test robot @ 2020-07-20 17:08 UTC (permalink / raw)
  To: Gal Pressman, Jason Gunthorpe, Doug Ledford
  Cc: kbuild-all, clang-built-linux, linux-rdma, Alexander Matushevsky,
	Gal Pressman, Shadi Ammouri, Yossi Leybovich

[-- Attachment #1: Type: text/plain, Size: 8817 bytes --]

Hi Gal,

I love your patch! Yet something to improve:

[auto build test ERROR on 5f0b2a6093a4d9aab093964c65083fe801ef1e58]

url:    https://github.com/0day-ci/linux/commits/Gal-Pressman/Add-support-for-0xefa1-device/20200720-160419
base:    5f0b2a6093a4d9aab093964c65083fe801ef1e58
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project cf1105069648446d58adfb7a6cc590013d6886ba)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

>> drivers/infiniband/hw/efa/efa_verbs.c:1533:3: error: function definition is not allowed here
                   DEFINE_COMP_HANDSHAKE(max_tx_batch, EFA_ALLOC_UCONTEXT_CMD_COMP_TX_BATCH),
                   ^
   drivers/infiniband/hw/efa/efa_verbs.c:1520:4: note: expanded from macro 'DEFINE_COMP_HANDSHAKE'
                           DEFINE_GET_DEV_ATTR_FUNC(_attr)                        \
                           ^
   drivers/infiniband/hw/efa/efa_verbs.c:1506:2: note: expanded from macro 'DEFINE_GET_DEV_ATTR_FUNC'
           {                                                                      \
           ^
>> drivers/infiniband/hw/efa/efa_verbs.c:1533:3: error: function definition is not allowed here
   drivers/infiniband/hw/efa/efa_verbs.c:1521:4: note: expanded from macro 'DEFINE_COMP_HANDSHAKE'
                           DEFINE_CHECK_COMP_FUNC(_attr, _mask)                   \
                           ^
   drivers/infiniband/hw/efa/efa_verbs.c:1512:2: note: expanded from macro 'DEFINE_CHECK_COMP_FUNC'
           {                                                                      \
           ^
>> drivers/infiniband/hw/efa/efa_verbs.c:1533:3: error: use of undeclared identifier 'check_comp_max_tx_batch'
   drivers/infiniband/hw/efa/efa_verbs.c:1522:4: note: expanded from macro 'DEFINE_COMP_HANDSHAKE'
                           check_comp_##_attr;                                    \
                           ^
   <scratch space>:191:1: note: expanded from here
   check_comp_max_tx_batch
   ^
   drivers/infiniband/hw/efa/efa_verbs.c:1534:3: error: function definition is not allowed here
                   DEFINE_COMP_HANDSHAKE(min_sq_depth, EFA_ALLOC_UCONTEXT_CMD_COMP_MIN_SQ_WR),
                   ^
   drivers/infiniband/hw/efa/efa_verbs.c:1520:4: note: expanded from macro 'DEFINE_COMP_HANDSHAKE'
                           DEFINE_GET_DEV_ATTR_FUNC(_attr)                        \
                           ^
   drivers/infiniband/hw/efa/efa_verbs.c:1506:2: note: expanded from macro 'DEFINE_GET_DEV_ATTR_FUNC'
           {                                                                      \
           ^
   drivers/infiniband/hw/efa/efa_verbs.c:1534:3: error: function definition is not allowed here
   drivers/infiniband/hw/efa/efa_verbs.c:1521:4: note: expanded from macro 'DEFINE_COMP_HANDSHAKE'
                           DEFINE_CHECK_COMP_FUNC(_attr, _mask)                   \
                           ^
   drivers/infiniband/hw/efa/efa_verbs.c:1512:2: note: expanded from macro 'DEFINE_CHECK_COMP_FUNC'
           {                                                                      \
           ^
>> drivers/infiniband/hw/efa/efa_verbs.c:1534:3: error: use of undeclared identifier 'check_comp_min_sq_depth'
   drivers/infiniband/hw/efa/efa_verbs.c:1522:4: note: expanded from macro 'DEFINE_COMP_HANDSHAKE'
                           check_comp_##_attr;                                    \
                           ^
   <scratch space>:196:1: note: expanded from here
   check_comp_min_sq_depth
   ^
>> drivers/infiniband/hw/efa/efa_verbs.c:1533:3: error: initializing 'bool (*)(const struct efa_dev *, u32)' (aka '_Bool (*)(const struct efa_dev *, unsigned int)') with an expression of incompatible type 'void'
                   DEFINE_COMP_HANDSHAKE(max_tx_batch, EFA_ALLOC_UCONTEXT_CMD_COMP_TX_BATCH),
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/infiniband/hw/efa/efa_verbs.c:1519:17: note: expanded from macro 'DEFINE_COMP_HANDSHAKE'
                   .check_comp = ({                                               \
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/infiniband/hw/efa/efa_verbs.c:1534:3: error: initializing 'bool (*)(const struct efa_dev *, u32)' (aka '_Bool (*)(const struct efa_dev *, unsigned int)') with an expression of incompatible type 'void'
                   DEFINE_COMP_HANDSHAKE(min_sq_depth, EFA_ALLOC_UCONTEXT_CMD_COMP_MIN_SQ_WR),
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/infiniband/hw/efa/efa_verbs.c:1519:17: note: expanded from macro 'DEFINE_COMP_HANDSHAKE'
                   .check_comp = ({                                               \
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/infiniband/hw/efa/efa_verbs.c:1539:18: error: invalid application of 'sizeof' to an incomplete type 'struct (anonymous struct at drivers/infiniband/hw/efa/efa_verbs.c:1529:2) []'
           for (i = 0; i < ARRAY_SIZE(user_comp_handshakes); i++) {
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:47:32: note: expanded from macro 'ARRAY_SIZE'
   #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                  ^~~~~
>> drivers/infiniband/hw/efa/efa_verbs.c:1526:5: warning: no previous prototype for function 'efa_user_comp_handshake' [-Wmissing-prototypes]
   int efa_user_comp_handshake(const struct ib_ucontext *ibucontext,
       ^
   drivers/infiniband/hw/efa/efa_verbs.c:1526:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int efa_user_comp_handshake(const struct ib_ucontext *ibucontext,
   ^
   static 
   1 warning and 9 errors generated.

vim +1533 drivers/infiniband/hw/efa/efa_verbs.c

  1503	
  1504	#define DEFINE_GET_DEV_ATTR_FUNC(_attr)                                        \
  1505		bool dev_attr_##_attr(const struct efa_dev *dev)                       \
  1506		{                                                                      \
  1507			return dev->dev_attr._attr;                                    \
  1508		}
  1509	
  1510	#define DEFINE_CHECK_COMP_FUNC(_attr, _mask)                                   \
  1511		bool check_comp_##_attr(const struct efa_dev *dev, u32 comp_mask)      \
  1512		{                                                                      \
  1513			return !dev_attr_##_attr(dev) || (comp_mask & (_mask));        \
  1514		}
  1515	
  1516	#define DEFINE_COMP_HANDSHAKE(_attr, _mask)                                    \
  1517		{                                                                      \
  1518			.attr = #_attr,                                                \
  1519			.check_comp = ({                                               \
  1520				DEFINE_GET_DEV_ATTR_FUNC(_attr)                        \
  1521				DEFINE_CHECK_COMP_FUNC(_attr, _mask)                   \
  1522				check_comp_##_attr;                                    \
  1523			}),                                                            \
  1524		}
  1525	
> 1526	int efa_user_comp_handshake(const struct ib_ucontext *ibucontext,
  1527				    const struct efa_ibv_alloc_ucontext_cmd *cmd)
  1528	{
  1529		struct {
  1530			char *attr;
  1531			bool (*check_comp)(const struct efa_dev *dev, u32 comp_mask);
  1532		} user_comp_handshakes[] = {
> 1533			DEFINE_COMP_HANDSHAKE(max_tx_batch, EFA_ALLOC_UCONTEXT_CMD_COMP_TX_BATCH),
> 1534			DEFINE_COMP_HANDSHAKE(min_sq_depth, EFA_ALLOC_UCONTEXT_CMD_COMP_MIN_SQ_WR),
  1535		};
  1536		struct efa_dev *dev = to_edev(ibucontext->device);
  1537		int i;
  1538	
> 1539		for (i = 0; i < ARRAY_SIZE(user_comp_handshakes); i++) {
  1540			if (!user_comp_handshakes[i].check_comp(dev, cmd->comp_mask)) {
  1541				ibdev_dbg(&dev->ibdev,
  1542					  "Userspace handshake failed for %s attribute\n",
  1543					  user_comp_handshakes[i].attr);
  1544				return -EOPNOTSUPP;
  1545			}
  1546		}
  1547	
  1548		return 0;
  1549	}
  1550	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 75288 bytes --]

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

* Re: [PATCH for-next v2 3/4] RDMA/efa: User/kernel compatibility handshake mechanism
  2020-07-20 17:08   ` kernel test robot
@ 2020-07-21 11:26     ` Gal Pressman
  2020-07-21 17:10       ` Nick Desaulniers
  0 siblings, 1 reply; 10+ messages in thread
From: Gal Pressman @ 2020-07-21 11:26 UTC (permalink / raw)
  To: kernel test robot, Jason Gunthorpe, Doug Ledford
  Cc: kbuild-all, clang-built-linux, linux-rdma, Alexander Matushevsky,
	Shadi Ammouri, Yossi Leybovich

On 20/07/2020 20:08, kernel test robot wrote:
> Hi Gal,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on 5f0b2a6093a4d9aab093964c65083fe801ef1e58]
> 
> url:    https://github.com/0day-ci/linux/commits/Gal-Pressman/Add-support-for-0xefa1-device/20200720-160419
> base:    5f0b2a6093a4d9aab093964c65083fe801ef1e58
> config: x86_64-allyesconfig (attached as .config)
> compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project cf1105069648446d58adfb7a6cc590013d6886ba)

Uh, looks like I use some gcc specific stuff here.. I guess it's time to start
checking clang compilation as well :).

Will fix and resubmit.

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

* Re: [PATCH for-next v2 3/4] RDMA/efa: User/kernel compatibility handshake mechanism
  2020-07-21 11:26     ` Gal Pressman
@ 2020-07-21 17:10       ` Nick Desaulniers
  2020-07-22  6:35         ` Gal Pressman
  0 siblings, 1 reply; 10+ messages in thread
From: Nick Desaulniers @ 2020-07-21 17:10 UTC (permalink / raw)
  To: Gal Pressman
  Cc: kernel test robot, Jason Gunthorpe, Doug Ledford, kbuild-all,
	clang-built-linux, linux-rdma, Alexander Matushevsky,
	Shadi Ammouri, Yossi Leybovich

On Tue, Jul 21, 2020 at 4:27 AM 'Gal Pressman' via Clang Built Linux
<clang-built-linux@googlegroups.com> wrote:
>
> On 20/07/2020 20:08, kernel test robot wrote:
> > Hi Gal,
> >
> > I love your patch! Yet something to improve:
> >
> > [auto build test ERROR on 5f0b2a6093a4d9aab093964c65083fe801ef1e58]
> >
> > url:    https://github.com/0day-ci/linux/commits/Gal-Pressman/Add-support-for-0xefa1-device/20200720-160419
> > base:    5f0b2a6093a4d9aab093964c65083fe801ef1e58
> > config: x86_64-allyesconfig (attached as .config)
> > compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project cf1105069648446d58adfb7a6cc590013d6886ba)
>
> Uh, looks like I use some gcc specific stuff here.. I guess it's time to start
> checking clang compilation as well :).
>
> Will fix and resubmit.

>> drivers/infiniband/hw/efa/efa_verbs.c:1539:18: error: invalid application of 'sizeof' to an incomplete type 'struct (anonymous struct at drivers/infiniband/hw/efa/efa_verbs.c:1529:2) []'
           for (i = 0; i < ARRAY_SIZE(user_comp_handshakes); i++) {
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

is user_comp_handshakes forward declared but not defined for an allyesconfig?

-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH for-next v2 3/4] RDMA/efa: User/kernel compatibility handshake mechanism
  2020-07-21 17:10       ` Nick Desaulniers
@ 2020-07-22  6:35         ` Gal Pressman
  2020-07-22 15:51           ` Nathan Chancellor
  0 siblings, 1 reply; 10+ messages in thread
From: Gal Pressman @ 2020-07-22  6:35 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: kernel test robot, Jason Gunthorpe, Doug Ledford, kbuild-all,
	clang-built-linux, linux-rdma, Alexander Matushevsky,
	Shadi Ammouri, Yossi Leybovich

On 21/07/2020 20:10, Nick Desaulniers wrote:
> On Tue, Jul 21, 2020 at 4:27 AM 'Gal Pressman' via Clang Built Linux
> <clang-built-linux@googlegroups.com> wrote:
>>
>> On 20/07/2020 20:08, kernel test robot wrote:
>>> Hi Gal,
>>>
>>> I love your patch! Yet something to improve:
>>>
>>> [auto build test ERROR on 5f0b2a6093a4d9aab093964c65083fe801ef1e58]
>>>
>>> url:    https://github.com/0day-ci/linux/commits/Gal-Pressman/Add-support-for-0xefa1-device/20200720-160419
>>> base:    5f0b2a6093a4d9aab093964c65083fe801ef1e58
>>> config: x86_64-allyesconfig (attached as .config)
>>> compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project cf1105069648446d58adfb7a6cc590013d6886ba)
>>
>> Uh, looks like I use some gcc specific stuff here.. I guess it's time to start
>> checking clang compilation as well :).
>>
>> Will fix and resubmit.
> 
>>> drivers/infiniband/hw/efa/efa_verbs.c:1539:18: error: invalid application of 'sizeof' to an incomplete type 'struct (anonymous struct at drivers/infiniband/hw/efa/efa_verbs.c:1529:2) []'
>            for (i = 0; i < ARRAY_SIZE(user_comp_handshakes); i++) {
>                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> is user_comp_handshakes forward declared but not defined for an allyesconfig?
> 

I don't think that's the issue here, the real problem is the first error:

>> drivers/infiniband/hw/efa/efa_verbs.c:1533:3: error: function definition is not allowed here
                   DEFINE_COMP_HANDSHAKE(max_tx_batch, EFA_ALLOC_UCONTEXT_CMD_COMP_TX_BATCH),
                   ^
   drivers/infiniband/hw/efa/efa_verbs.c:1520:4: note: expanded from macro 'DEFINE_COMP_HANDSHAKE'
                           DEFINE_GET_DEV_ATTR_FUNC(_attr)                        \
                           ^
   drivers/infiniband/hw/efa/efa_verbs.c:1506:2: note: expanded from macro 'DEFINE_GET_DEV_ATTR_FUNC'


Apparently the braced group (is that how its called?) is supported by gcc, but not clang.

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

* Re: [PATCH for-next v2 3/4] RDMA/efa: User/kernel compatibility handshake mechanism
  2020-07-22  6:35         ` Gal Pressman
@ 2020-07-22 15:51           ` Nathan Chancellor
  0 siblings, 0 replies; 10+ messages in thread
From: Nathan Chancellor @ 2020-07-22 15:51 UTC (permalink / raw)
  To: Gal Pressman
  Cc: Nick Desaulniers, kernel test robot, Jason Gunthorpe,
	Doug Ledford, kbuild-all, clang-built-linux, linux-rdma,
	Alexander Matushevsky, Shadi Ammouri, Yossi Leybovich

On Wed, Jul 22, 2020 at 09:35:14AM +0300, 'Gal Pressman' via Clang Built Linux wrote:
> On 21/07/2020 20:10, Nick Desaulniers wrote:
> > On Tue, Jul 21, 2020 at 4:27 AM 'Gal Pressman' via Clang Built Linux
> > <clang-built-linux@googlegroups.com> wrote:
> >>
> >> On 20/07/2020 20:08, kernel test robot wrote:
> >>> Hi Gal,
> >>>
> >>> I love your patch! Yet something to improve:
> >>>
> >>> [auto build test ERROR on 5f0b2a6093a4d9aab093964c65083fe801ef1e58]
> >>>
> >>> url:    https://github.com/0day-ci/linux/commits/Gal-Pressman/Add-support-for-0xefa1-device/20200720-160419
> >>> base:    5f0b2a6093a4d9aab093964c65083fe801ef1e58
> >>> config: x86_64-allyesconfig (attached as .config)
> >>> compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project cf1105069648446d58adfb7a6cc590013d6886ba)
> >>
> >> Uh, looks like I use some gcc specific stuff here.. I guess it's time to start
> >> checking clang compilation as well :).
> >>
> >> Will fix and resubmit.
> > 
> >>> drivers/infiniband/hw/efa/efa_verbs.c:1539:18: error: invalid application of 'sizeof' to an incomplete type 'struct (anonymous struct at drivers/infiniband/hw/efa/efa_verbs.c:1529:2) []'
> >            for (i = 0; i < ARRAY_SIZE(user_comp_handshakes); i++) {
> >                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > is user_comp_handshakes forward declared but not defined for an allyesconfig?
> > 
> 
> I don't think that's the issue here, the real problem is the first error:
> 
> >> drivers/infiniband/hw/efa/efa_verbs.c:1533:3: error: function definition is not allowed here
>                    DEFINE_COMP_HANDSHAKE(max_tx_batch, EFA_ALLOC_UCONTEXT_CMD_COMP_TX_BATCH),
>                    ^
>    drivers/infiniband/hw/efa/efa_verbs.c:1520:4: note: expanded from macro 'DEFINE_COMP_HANDSHAKE'
>                            DEFINE_GET_DEV_ATTR_FUNC(_attr)                        \
>                            ^
>    drivers/infiniband/hw/efa/efa_verbs.c:1506:2: note: expanded from macro 'DEFINE_GET_DEV_ATTR_FUNC'
> 
> 
> Apparently the braced group (is that how its called?) is supported by gcc, but not clang.
> 

I believe you are trying to use nested functions, which are not
supported by clang:

https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html

clang supports both scoped statements and GNU C statement expressions
but you are trying to define a function within a GNU C statement
expression and use it in a designated initializer (in
DEFINE_COMP_HANDSHAKE with DEFINE_GET_DEV_ATTR_FUNC and
DEFINE_CHECK_COMP_FUNC), which causes a problem with clang.

Cheers,
Nathan

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

end of thread, other threads:[~2020-07-22 15:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-20  8:01 [PATCH for-next v2 0/4] Add support for 0xefa1 device Gal Pressman
2020-07-20  8:01 ` [PATCH for-next v2 1/4] RDMA/efa: Expose maximum TX doorbell batch Gal Pressman
2020-07-20  8:01 ` [PATCH for-next v2 2/4] RDMA/efa: Expose minimum SQ size Gal Pressman
2020-07-20  8:01 ` [PATCH for-next v2 3/4] RDMA/efa: User/kernel compatibility handshake mechanism Gal Pressman
2020-07-20 17:08   ` kernel test robot
2020-07-21 11:26     ` Gal Pressman
2020-07-21 17:10       ` Nick Desaulniers
2020-07-22  6:35         ` Gal Pressman
2020-07-22 15:51           ` Nathan Chancellor
2020-07-20  8:01 ` [PATCH for-next v2 4/4] RDMA/efa: Add EFA 0xefa1 PCI ID Gal Pressman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).