linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rdma-next 00/16] MAD cleanup
@ 2019-10-29  6:27 Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 01/16] RDMA/mad: Delete never implemented functions Leon Romanovsky
                   ` (17 more replies)
  0 siblings, 18 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

Let's clean MAD code a little bit.

It is based on
https://lore.kernel.org/linux-rdma/20191027070621.11711-1-leon@kernel.org

Thanks

Leon Romanovsky (16):
  RDMA/mad: Delete never implemented functions
  RDMA/mad: Allocate zeroed MAD buffer
  RDMA/mlx4: Delete redundant zero memset
  RDMA/mlx5: Delete redundant zero memset
  RDMA/ocrdma: Clean MAD processing logic
  RDMA/qib: Delete redundant memset for MAD output buffer
  RDMA/hfi1: Delete unreachable code
  RDMA/mlx4: Delete unreachable code
  RDMA/mlx5: Delete unreachable code
  RDMA/mthca: Delete unreachable code
  RDMA/ocrdma: Simplify process_mad function
  RDMA/qib: Delete unreachable code
  RDMA/mlx5: Rewrite MAD processing logic to be readable
  RDMA/qib: Delete extra line
  RDMA/qib: Delete unused variable in process_cc call
  RDMA: Change MAD processing function to remove extra casting and
    parameter

 drivers/infiniband/core/mad.c               |  31 +----
 drivers/infiniband/core/sysfs.c             |  10 +-
 drivers/infiniband/hw/hfi1/mad.c            |  17 +--
 drivers/infiniband/hw/hfi1/verbs.h          |   5 +-
 drivers/infiniband/hw/mlx4/mad.c            |  30 ++---
 drivers/infiniband/hw/mlx4/mlx4_ib.h        |   7 +-
 drivers/infiniband/hw/mlx5/mad.c            | 124 +++++++++-----------
 drivers/infiniband/hw/mlx5/mlx5_ib.h        |   5 +-
 drivers/infiniband/hw/mthca/mthca_dev.h     |  12 +-
 drivers/infiniband/hw/mthca/mthca_mad.c     |  74 +++++-------
 drivers/infiniband/hw/ocrdma/ocrdma_ah.c    |  33 ++----
 drivers/infiniband/hw/ocrdma/ocrdma_ah.h    |  11 +-
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c |   5 +-
 drivers/infiniband/hw/ocrdma/ocrdma_stats.h |   3 +-
 drivers/infiniband/hw/qedr/verbs.c          |  17 +--
 drivers/infiniband/hw/qedr/verbs.h          |   7 +-
 drivers/infiniband/hw/qib/qib_iba6120.c     |   1 -
 drivers/infiniband/hw/qib/qib_mad.c         |  38 +-----
 drivers/infiniband/hw/qib/qib_verbs.h       |   5 +-
 include/rdma/ib_mad.h                       |  40 -------
 include/rdma/ib_verbs.h                     |   7 +-
 21 files changed, 155 insertions(+), 327 deletions(-)

--
2.20.1


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

* [PATCH rdma-next 01/16] RDMA/mad: Delete never implemented functions
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 02/16] RDMA/mad: Allocate zeroed MAD buffer Leon Romanovsky
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

Delete never implemented and used MAD functions.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/core/mad.c | 19 -----------------
 include/rdma/ib_mad.h         | 40 -----------------------------------
 2 files changed, 59 deletions(-)

diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 9947d16edef2..8adb487eb314 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -1397,25 +1397,6 @@ void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc)
 }
 EXPORT_SYMBOL(ib_free_recv_mad);
 
-struct ib_mad_agent *ib_redirect_mad_qp(struct ib_qp *qp,
-					u8 rmpp_version,
-					ib_mad_send_handler send_handler,
-					ib_mad_recv_handler recv_handler,
-					void *context)
-{
-	return ERR_PTR(-EINVAL);	/* XXX: for now */
-}
-EXPORT_SYMBOL(ib_redirect_mad_qp);
-
-int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
-		      struct ib_wc *wc)
-{
-	dev_err(&mad_agent->device->dev,
-		"ib_process_mad_wc() not implemented yet\n");
-	return 0;
-}
-EXPORT_SYMBOL(ib_process_mad_wc);
-
 static int method_in_use(struct ib_mad_mgmt_method_table **method,
 			 struct ib_mad_reg_req *mad_reg_req)
 {
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
index eea946fcc819..4e62650e2127 100644
--- a/include/rdma/ib_mad.h
+++ b/include/rdma/ib_mad.h
@@ -814,46 +814,6 @@ void ib_cancel_mad(struct ib_mad_agent *mad_agent,
 int ib_modify_mad(struct ib_mad_agent *mad_agent,
 		  struct ib_mad_send_buf *send_buf, u32 timeout_ms);
 
-/**
- * ib_redirect_mad_qp - Registers a QP for MAD services.
- * @qp: Reference to a QP that requires MAD services.
- * @rmpp_version: If set, indicates that the client will send
- *   and receive MADs that contain the RMPP header for the given version.
- *   If set to 0, indicates that RMPP is not used by this client.
- * @send_handler: The completion callback routine invoked after a send
- *   request has completed.
- * @recv_handler: The completion callback routine invoked for a received
- *   MAD.
- * @context: User specified context associated with the registration.
- *
- * Use of this call allows clients to use MAD services, such as RMPP,
- * on user-owned QPs.  After calling this routine, users may send
- * MADs on the specified QP by calling ib_mad_post_send.
- */
-struct ib_mad_agent *ib_redirect_mad_qp(struct ib_qp *qp,
-					u8 rmpp_version,
-					ib_mad_send_handler send_handler,
-					ib_mad_recv_handler recv_handler,
-					void *context);
-
-/**
- * ib_process_mad_wc - Processes a work completion associated with a
- *   MAD sent or received on a redirected QP.
- * @mad_agent: Specifies the registered MAD service using the redirected QP.
- * @wc: References a work completion associated with a sent or received
- *   MAD segment.
- *
- * This routine is used to complete or continue processing on a MAD request.
- * If the work completion is associated with a send operation, calling
- * this routine is required to continue an RMPP transfer or to wait for a
- * corresponding response, if it is a request.  If the work completion is
- * associated with a receive operation, calling this routine is required to
- * process an inbound or outbound RMPP transfer, or to match a response MAD
- * with its corresponding request.
- */
-int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
-		      struct ib_wc *wc);
-
 /**
  * ib_create_send_mad - Allocate and initialize a data buffer and work request
  *   for sending a MAD.
-- 
2.20.1


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

* [PATCH rdma-next 02/16] RDMA/mad: Allocate zeroed MAD buffer
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 01/16] RDMA/mad: Delete never implemented functions Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 03/16] RDMA/mlx4: Delete redundant zero memset Leon Romanovsky
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

Ensure that MAD output buffer is zero-based allocated.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/core/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 92c932c067cb..62c756ea5668 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -481,8 +481,8 @@ static int get_perf_mad(struct ib_device *dev, int port_num, __be16 attr,
 	if (!dev->ops.process_mad)
 		return -ENOSYS;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kzalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad) {
 		ret = -ENOMEM;
 		goto out;
-- 
2.20.1


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

* [PATCH rdma-next 03/16] RDMA/mlx4: Delete redundant zero memset
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 01/16] RDMA/mad: Delete never implemented functions Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 02/16] RDMA/mad: Allocate zeroed MAD buffer Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 04/16] RDMA/mlx5: " Leon Romanovsky
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

All callers to process_mad() allocate MAD output buffer
with kzalloc, so there is no need to clear memory again.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx4/mad.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 57079110af9b..985cced5d509 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -966,7 +966,6 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	}
 	mutex_unlock(&dev->counters_table[port_num - 1].mutex);
 	if (stats_avail) {
-		memset(out_mad->data, 0, sizeof out_mad->data);
 		switch (counter_stats.counter_mode & 0xf) {
 		case 0:
 			edit_counter(&counter_stats,
-- 
2.20.1


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

* [PATCH rdma-next 04/16] RDMA/mlx5: Delete redundant zero memset
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (2 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 03/16] RDMA/mlx4: Delete redundant zero memset Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 05/16] RDMA/ocrdma: Clean MAD processing logic Leon Romanovsky
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

All callers to process_mad() allocate MAD output buffer
with kzalloc, so there is no need to clear memory again.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx5/mad.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/mad.c b/drivers/infiniband/hw/mlx5/mad.c
index 348c1df69cdc..0a5eb6e1798c 100644
--- a/drivers/infiniband/hw/mlx5/mad.c
+++ b/drivers/infiniband/hw/mlx5/mad.c
@@ -284,8 +284,6 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 			 *out_mad_size != sizeof(*out_mad)))
 		return IB_MAD_RESULT_FAILURE;
 
-	memset(out_mad->data, 0, sizeof(out_mad->data));
-
 	if (MLX5_CAP_GEN(dev->mdev, vport_counters) &&
 	    in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
 	    in_mad->mad_hdr.method == IB_MGMT_METHOD_GET) {
-- 
2.20.1


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

* [PATCH rdma-next 05/16] RDMA/ocrdma: Clean MAD processing logic
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (3 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 04/16] RDMA/mlx5: " Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 06/16] RDMA/qib: Delete redundant memset for MAD output buffer Leon Romanovsky
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

Remove redundant memset and useless return value.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/ocrdma/ocrdma_ah.c    | 6 ++----
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c | 5 +----
 drivers/infiniband/hw/ocrdma/ocrdma_stats.h | 3 +--
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index 8d3e36d548aa..f8ebdf7086a1 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -268,10 +268,8 @@ int ocrdma_process_mad(struct ib_device *ibdev,
 	switch (in_mad->mad_hdr.mgmt_class) {
 	case IB_MGMT_CLASS_PERF_MGMT:
 		dev = get_ocrdma_dev(ibdev);
-		if (!ocrdma_pma_counters(dev, out_mad))
-			status = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
-		else
-			status = IB_MAD_RESULT_SUCCESS;
+		ocrdma_pma_counters(dev, out_mad);
+		status = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
 		break;
 	default:
 		status = IB_MAD_RESULT_SUCCESS;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
index a902942adb5d..95e8c1560cc2 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
@@ -670,12 +670,10 @@ static ssize_t ocrdma_dbgfs_ops_write(struct file *filp,
 	return -EFAULT;
 }
 
-int ocrdma_pma_counters(struct ocrdma_dev *dev,
-			struct ib_mad *out_mad)
+void ocrdma_pma_counters(struct ocrdma_dev *dev, struct ib_mad *out_mad)
 {
 	struct ib_pma_portcounters *pma_cnt;
 
-	memset(out_mad->data, 0, sizeof out_mad->data);
 	pma_cnt = (void *)(out_mad->data + 40);
 	ocrdma_update_stats(dev);
 
@@ -683,7 +681,6 @@ int ocrdma_pma_counters(struct ocrdma_dev *dev,
 	pma_cnt->port_rcv_data     = cpu_to_be32(ocrdma_sysfs_rcv_data(dev));
 	pma_cnt->port_xmit_packets = cpu_to_be32(ocrdma_sysfs_xmit_pkts(dev));
 	pma_cnt->port_rcv_packets  = cpu_to_be32(ocrdma_sysfs_rcv_pkts(dev));
-	return 0;
 }
 
 static ssize_t ocrdma_dbgfs_ops_read(struct file *filp, char __user *buffer,
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.h b/drivers/infiniband/hw/ocrdma/ocrdma_stats.h
index bba1fec4f11f..98feca26ac55 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.h
@@ -69,7 +69,6 @@ bool ocrdma_alloc_stats_resources(struct ocrdma_dev *dev);
 void ocrdma_release_stats_resources(struct ocrdma_dev *dev);
 void ocrdma_rem_port_stats(struct ocrdma_dev *dev);
 void ocrdma_add_port_stats(struct ocrdma_dev *dev);
-int ocrdma_pma_counters(struct ocrdma_dev *dev,
-			struct ib_mad *out_mad);
+void ocrdma_pma_counters(struct ocrdma_dev *dev, struct ib_mad *out_mad);
 
 #endif	/* __OCRDMA_STATS_H__ */
-- 
2.20.1


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

* [PATCH rdma-next 06/16] RDMA/qib: Delete redundant memset for MAD output buffer
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (4 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 05/16] RDMA/ocrdma: Clean MAD processing logic Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 07/16] RDMA/hfi1: Delete unreachable code Leon Romanovsky
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

There is no need to clear MAD output buffer, because all
callers are calling process_mad() with cleared output buffer.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/qib/qib_mad.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
index f92faf5ec369..5a1e6371ea57 100644
--- a/drivers/infiniband/hw/qib/qib_mad.c
+++ b/drivers/infiniband/hw/qib/qib_mad.c
@@ -2098,8 +2098,6 @@ static int cc_get_classportinfo(struct ib_cc_mad *ccp,
 	struct ib_cc_classportinfo_attr *p =
 		(struct ib_cc_classportinfo_attr *)ccp->mgmt_data;
 
-	memset(ccp->mgmt_data, 0, sizeof(ccp->mgmt_data));
-
 	p->base_version = 1;
 	p->class_version = 1;
 	p->cap_mask = 0;
@@ -2120,8 +2118,6 @@ static int cc_get_congestion_info(struct ib_cc_mad *ccp,
 	struct qib_ibport *ibp = to_iport(ibdev, port);
 	struct qib_pportdata *ppd = ppd_from_ibp(ibp);
 
-	memset(ccp->mgmt_data, 0, sizeof(ccp->mgmt_data));
-
 	p->congestion_info = 0;
 	p->control_table_cap = ppd->cc_max_table_entries;
 
@@ -2138,8 +2134,6 @@ static int cc_get_congestion_setting(struct ib_cc_mad *ccp,
 	struct qib_pportdata *ppd = ppd_from_ibp(ibp);
 	struct ib_cc_congestion_entry_shadow *entries;
 
-	memset(ccp->mgmt_data, 0, sizeof(ccp->mgmt_data));
-
 	spin_lock(&ppd->cc_shadow_lock);
 
 	entries = ppd->congestion_entries_shadow->entries;
@@ -2176,8 +2170,6 @@ static int cc_get_congestion_control_table(struct ib_cc_mad *ccp,
 	if (cct_block_index > IB_CC_TABLE_CAP_DEFAULT - 1)
 		goto bail;
 
-	memset(ccp->mgmt_data, 0, sizeof(ccp->mgmt_data));
-
 	spin_lock(&ppd->cc_shadow_lock);
 
 	max_cct_block =
@@ -2296,12 +2288,6 @@ static int cc_set_congestion_control_table(struct ib_cc_mad *ccp,
 	return reply_failure((struct ib_smp *) ccp);
 }
 
-static int check_cc_key(struct qib_ibport *ibp,
-			struct ib_cc_mad *ccp, int mad_flags)
-{
-	return 0;
-}
-
 static int process_cc(struct ib_device *ibdev, int mad_flags,
 			u8 port, const struct ib_mad *in_mad,
 			struct ib_mad *out_mad)
@@ -2318,10 +2304,6 @@ static int process_cc(struct ib_device *ibdev, int mad_flags,
 		goto bail;
 	}
 
-	ret = check_cc_key(ibp, ccp, mad_flags);
-	if (ret)
-		goto bail;
-
 	switch (ccp->method) {
 	case IB_MGMT_METHOD_GET:
 		switch (ccp->attr_id) {
-- 
2.20.1


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

* [PATCH rdma-next 07/16] RDMA/hfi1: Delete unreachable code
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (5 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 06/16] RDMA/qib: Delete redundant memset for MAD output buffer Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29 23:33   ` Ira Weiny
  2019-10-29  6:27 ` [PATCH rdma-next 08/16] RDMA/mlx4: " Leon Romanovsky
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

All callers allocate MAD structures with proper sizes,
there is no need to recheck it.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/hfi1/mad.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index d8ff063a5419..a54746f4a0ae 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -4921,10 +4921,6 @@ int hfi1_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 {
 	switch (in_mad->base_version) {
 	case OPA_MGMT_BASE_VERSION:
-		if (unlikely(in_mad_size != sizeof(struct opa_mad))) {
-			dev_err(ibdev->dev.parent, "invalid in_mad_size\n");
-			return IB_MAD_RESULT_FAILURE;
-		}
 		return hfi1_process_opa_mad(ibdev, mad_flags, port,
 					    in_wc, in_grh,
 					    (struct opa_mad *)in_mad,
-- 
2.20.1


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

* [PATCH rdma-next 08/16] RDMA/mlx4: Delete unreachable code
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (6 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 07/16] RDMA/hfi1: Delete unreachable code Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 09/16] RDMA/mlx5: " Leon Romanovsky
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

All callers allocate MAD structures with proper sizes,
there is no need to recheck it.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx4/mad.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 985cced5d509..c6ea4c50da1e 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -992,10 +992,6 @@ int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	struct ib_mad *out_mad = (struct ib_mad *)out;
 	enum rdma_link_layer link = rdma_port_get_link_layer(ibdev, port_num);
 
-	if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) ||
-			 *out_mad_size != sizeof(*out_mad)))
-		return IB_MAD_RESULT_FAILURE;
-
 	/* iboe_process_mad() which uses the HCA flow-counters to implement IB PMA
 	 * queries, should be called only by VFs and for that specific purpose
 	 */
-- 
2.20.1


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

* [PATCH rdma-next 09/16] RDMA/mlx5: Delete unreachable code
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (7 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 08/16] RDMA/mlx4: " Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 10/16] RDMA/mthca: " Leon Romanovsky
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

All callers allocate MAD structures with proper sizes,
there is no need to recheck it.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx5/mad.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/mad.c b/drivers/infiniband/hw/mlx5/mad.c
index 0a5eb6e1798c..f49d9c70246e 100644
--- a/drivers/infiniband/hw/mlx5/mad.c
+++ b/drivers/infiniband/hw/mlx5/mad.c
@@ -280,10 +280,6 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	struct ib_mad *out_mad = (struct ib_mad *)out;
 	int ret;
 
-	if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) ||
-			 *out_mad_size != sizeof(*out_mad)))
-		return IB_MAD_RESULT_FAILURE;
-
 	if (MLX5_CAP_GEN(dev->mdev, vport_counters) &&
 	    in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
 	    in_mad->mad_hdr.method == IB_MGMT_METHOD_GET) {
-- 
2.20.1


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

* [PATCH rdma-next 10/16] RDMA/mthca: Delete unreachable code
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (8 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 09/16] RDMA/mlx5: " Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 11/16] RDMA/ocrdma: Simplify process_mad function Leon Romanovsky
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

All callers allocate MAD structures with proper sizes,
there is no need to recheck it.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mthca/mthca_mad.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c
index 7ad517da4917..0893604d2a62 100644
--- a/drivers/infiniband/hw/mthca/mthca_mad.c
+++ b/drivers/infiniband/hw/mthca/mthca_mad.c
@@ -212,10 +212,6 @@ int mthca_process_mad(struct ib_device *ibdev,
 	const struct ib_mad *in_mad = (const struct ib_mad *)in;
 	struct ib_mad *out_mad = (struct ib_mad *)out;
 
-	if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) ||
-			 *out_mad_size != sizeof(*out_mad)))
-		return IB_MAD_RESULT_FAILURE;
-
 	/* Forward locally generated traps to the SM */
 	if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP &&
 	    slid == 0) {
-- 
2.20.1


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

* [PATCH rdma-next 11/16] RDMA/ocrdma: Simplify process_mad function
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (9 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 10/16] RDMA/mthca: " Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 12/16] RDMA/qib: Delete unreachable code Leon Romanovsky
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

Rewrite ocrdma implementation of process_mad in order to simplify code.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index f8ebdf7086a1..4098508b9240 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -256,24 +256,16 @@ int ocrdma_process_mad(struct ib_device *ibdev,
 		       struct ib_mad_hdr *out, size_t *out_mad_size,
 		       u16 *out_mad_pkey_index)
 {
-	int status;
+	int status = IB_MAD_RESULT_SUCCESS;
 	struct ocrdma_dev *dev;
 	const struct ib_mad *in_mad = (const struct ib_mad *)in;
 	struct ib_mad *out_mad = (struct ib_mad *)out;
 
-	if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) ||
-			 *out_mad_size != sizeof(*out_mad)))
-		return IB_MAD_RESULT_FAILURE;
-
-	switch (in_mad->mad_hdr.mgmt_class) {
-	case IB_MGMT_CLASS_PERF_MGMT:
+	if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT) {
 		dev = get_ocrdma_dev(ibdev);
 		ocrdma_pma_counters(dev, out_mad);
-		status = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
-		break;
-	default:
-		status = IB_MAD_RESULT_SUCCESS;
-		break;
+		status |= IB_MAD_RESULT_REPLY;
 	}
+
 	return status;
 }
-- 
2.20.1


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

* [PATCH rdma-next 12/16] RDMA/qib: Delete unreachable code
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (10 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 11/16] RDMA/ocrdma: Simplify process_mad function Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 13/16] RDMA/mlx5: Rewrite MAD processing logic to be readable Leon Romanovsky
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

All callers allocate MAD structures with proper sizes,
there is no need to recheck it.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/qib/qib_mad.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
index 5a1e6371ea57..ba8c81e486be 100644
--- a/drivers/infiniband/hw/qib/qib_mad.c
+++ b/drivers/infiniband/hw/qib/qib_mad.c
@@ -2397,10 +2397,6 @@ int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 	const struct ib_mad *in_mad = (const struct ib_mad *)in;
 	struct ib_mad *out_mad = (struct ib_mad *)out;
 
-	if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) ||
-			 *out_mad_size != sizeof(*out_mad)))
-		return IB_MAD_RESULT_FAILURE;
-
 	switch (in_mad->mad_hdr.mgmt_class) {
 	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
 	case IB_MGMT_CLASS_SUBN_LID_ROUTED:
-- 
2.20.1


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

* [PATCH rdma-next 13/16] RDMA/mlx5: Rewrite MAD processing logic to be readable
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (11 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 12/16] RDMA/qib: Delete unreachable code Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 14/16] RDMA/qib: Delete extra line Leon Romanovsky
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

Multiple "if"s and "||" make extension of process_mad() function
as a tedious task, rewrite that function to be more readable.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx5/mad.c | 116 +++++++++++++++----------------
 1 file changed, 55 insertions(+), 61 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/mad.c b/drivers/infiniband/hw/mlx5/mad.c
index f49d9c70246e..1c87412a162f 100644
--- a/drivers/infiniband/hw/mlx5/mad.c
+++ b/drivers/infiniband/hw/mlx5/mad.c
@@ -74,58 +74,6 @@ static int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey,
 				port);
 }
 
-static int process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
-		       const struct ib_wc *in_wc, const struct ib_grh *in_grh,
-		       const struct ib_mad *in_mad, struct ib_mad *out_mad)
-{
-	u16 slid;
-	int err;
-
-	slid = in_wc ? ib_lid_cpu16(in_wc->slid) : be16_to_cpu(IB_LID_PERMISSIVE);
-
-	if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP && slid == 0)
-		return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
-
-	if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
-	    in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
-		if (in_mad->mad_hdr.method   != IB_MGMT_METHOD_GET &&
-		    in_mad->mad_hdr.method   != IB_MGMT_METHOD_SET &&
-		    in_mad->mad_hdr.method   != IB_MGMT_METHOD_TRAP_REPRESS)
-			return IB_MAD_RESULT_SUCCESS;
-
-		/* Don't process SMInfo queries -- the SMA can't handle them.
-		 */
-		if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO)
-			return IB_MAD_RESULT_SUCCESS;
-	} else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
-		   in_mad->mad_hdr.mgmt_class == MLX5_IB_VENDOR_CLASS1   ||
-		   in_mad->mad_hdr.mgmt_class == MLX5_IB_VENDOR_CLASS2   ||
-		   in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_CONG_MGMT) {
-		if (in_mad->mad_hdr.method  != IB_MGMT_METHOD_GET &&
-		    in_mad->mad_hdr.method  != IB_MGMT_METHOD_SET)
-			return IB_MAD_RESULT_SUCCESS;
-	} else {
-		return IB_MAD_RESULT_SUCCESS;
-	}
-
-	err = mlx5_MAD_IFC(to_mdev(ibdev),
-			   mad_flags & IB_MAD_IGNORE_MKEY,
-			   mad_flags & IB_MAD_IGNORE_BKEY,
-			   port_num, in_wc, in_grh, in_mad, out_mad);
-	if (err)
-		return IB_MAD_RESULT_FAILURE;
-
-	/* set return bit in status of directed route responses */
-	if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
-		out_mad->mad_hdr.status |= cpu_to_be16(1 << 15);
-
-	if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS)
-		/* no response for trap repress */
-		return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
-
-	return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
-}
-
 static void pma_cnt_ext_assign(struct ib_pma_portcounters_ext *pma_cnt_ext,
 			       void *out)
 {
@@ -278,17 +226,63 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	struct mlx5_ib_dev *dev = to_mdev(ibdev);
 	const struct ib_mad *in_mad = (const struct ib_mad *)in;
 	struct ib_mad *out_mad = (struct ib_mad *)out;
-	int ret;
+	u8 mgmt_class = in_mad->mad_hdr.mgmt_class;
+	u8 method = in_mad->mad_hdr.method;
+	u16 slid;
+	int err;
 
-	if (MLX5_CAP_GEN(dev->mdev, vport_counters) &&
-	    in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
-	    in_mad->mad_hdr.method == IB_MGMT_METHOD_GET) {
-		ret = process_pma_cmd(dev, port_num, in_mad, out_mad);
-	} else {
-		ret =  process_mad(ibdev, mad_flags, port_num, in_wc, in_grh,
-				   in_mad, out_mad);
+	slid = in_wc ? ib_lid_cpu16(in_wc->slid) :
+		       be16_to_cpu(IB_LID_PERMISSIVE);
+
+	if (method == IB_MGMT_METHOD_TRAP && !slid)
+		return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
+
+	switch (mgmt_class) {
+	case IB_MGMT_CLASS_SUBN_LID_ROUTED:
+	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE: {
+		if (method != IB_MGMT_METHOD_GET &&
+		    method != IB_MGMT_METHOD_SET &&
+		    method != IB_MGMT_METHOD_TRAP_REPRESS)
+			return IB_MAD_RESULT_SUCCESS;
+
+		/* Don't process SMInfo queries -- the SMA can't handle them.
+		 */
+		if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO)
+			return IB_MAD_RESULT_SUCCESS;
+	} break;
+	case IB_MGMT_CLASS_PERF_MGMT:
+		if (MLX5_CAP_GEN(dev->mdev, vport_counters) &&
+		    method == IB_MGMT_METHOD_GET)
+			return process_pma_cmd(dev, port_num, in_mad, out_mad);
+		/* fallthrough */
+	case MLX5_IB_VENDOR_CLASS1:
+		/* fallthrough */
+	case MLX5_IB_VENDOR_CLASS2:
+	case IB_MGMT_CLASS_CONG_MGMT: {
+		if (method != IB_MGMT_METHOD_GET &&
+		    method != IB_MGMT_METHOD_SET)
+			return IB_MAD_RESULT_SUCCESS;
+	} break;
+	default:
+		return IB_MAD_RESULT_SUCCESS;
 	}
-	return ret;
+
+	err = mlx5_MAD_IFC(to_mdev(ibdev),
+			   mad_flags & IB_MAD_IGNORE_MKEY,
+			   mad_flags & IB_MAD_IGNORE_BKEY,
+			   port_num, in_wc, in_grh, in_mad, out_mad);
+	if (err)
+		return IB_MAD_RESULT_FAILURE;
+
+	/* set return bit in status of directed route responses */
+	if (mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+		out_mad->mad_hdr.status |= cpu_to_be16(1 << 15);
+
+	if (method == IB_MGMT_METHOD_TRAP_REPRESS)
+		/* no response for trap repress */
+		return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
+
+	return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
 }
 
 int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port)
-- 
2.20.1


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

* [PATCH rdma-next 14/16] RDMA/qib: Delete extra line
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (12 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 13/16] RDMA/mlx5: Rewrite MAD processing logic to be readable Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 15/16] RDMA/qib: Delete unused variable in process_cc call Leon Romanovsky
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

Trivial cleanup to fix the following warning:
 drivers/infiniband/hw/qib/qib_iba6120.c:1420: warning: bad line:

Fixes: f931551bafe1 ("IB/qib: Add new qib driver for QLogic PCIe InfiniBand adapters")
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/qib/qib_iba6120.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/infiniband/hw/qib/qib_iba6120.c b/drivers/infiniband/hw/qib/qib_iba6120.c
index 531d8a1db2c3..ca5ea734e3d0 100644
--- a/drivers/infiniband/hw/qib/qib_iba6120.c
+++ b/drivers/infiniband/hw/qib/qib_iba6120.c
@@ -1417,7 +1417,6 @@ static void qib_6120_quiet_serdes(struct qib_pportdata *ppd)
  *
  * The exact combo of LEDs if on is true is determined by looking
  * at the ibcstatus.
-
  * These LEDs indicate the physical and logical state of IB link.
  * For this chip (at least with recommended board pinouts), LED1
  * is Yellow (logical state) and LED2 is Green (physical state),
-- 
2.20.1


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

* [PATCH rdma-next 15/16] RDMA/qib: Delete unused variable in process_cc call
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (13 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 14/16] RDMA/qib: Delete extra line Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-10-29  6:27 ` [PATCH rdma-next 16/16] RDMA: Change MAD processing function to remove extra casting and parameter Leon Romanovsky
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

Trivial cleanup to the following compilation warning:
drivers/infiniband/hw/qib/qib_mad.c: In function _process_cc_:
drivers/infiniband/hw/qib/qib_mad.c:2296:21: warning: unused variable _ibp_ [-Wunused-variable]
 2296 |  struct qib_ibport *ibp = to_iport(ibdev, port);
      |                     ^~~

Fixes: 36a8f01cd24b ("IB/qib: Add congestion control agent implementation")
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/qib/qib_mad.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
index ba8c81e486be..b259aaf85d4a 100644
--- a/drivers/infiniband/hw/qib/qib_mad.c
+++ b/drivers/infiniband/hw/qib/qib_mad.c
@@ -2293,7 +2293,6 @@ static int process_cc(struct ib_device *ibdev, int mad_flags,
 			struct ib_mad *out_mad)
 {
 	struct ib_cc_mad *ccp = (struct ib_cc_mad *)out_mad;
-	struct qib_ibport *ibp = to_iport(ibdev, port);
 	int ret;
 
 	*out_mad = *in_mad;
-- 
2.20.1


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

* [PATCH rdma-next 16/16] RDMA: Change MAD processing function to remove extra casting and parameter
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (14 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 15/16] RDMA/qib: Delete unused variable in process_cc call Leon Romanovsky
@ 2019-10-29  6:27 ` Leon Romanovsky
  2019-11-11 13:33   ` Marciniszyn, Mike
  2019-11-06 20:14 ` [PATCH rdma-next 00/16] MAD cleanup Jason Gunthorpe
  2019-11-13  0:37 ` Jason Gunthorpe
  17 siblings, 1 reply; 24+ messages in thread
From: Leon Romanovsky @ 2019-10-29  6:27 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

From: Leon Romanovsky <leonro@mellanox.com>

All users of process_mad() converts input pointers from ib_mad_hdr
to be ib_mad, update the function declaration to use ib_mad directly.

Also remove not used input MAD size parameter.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/core/mad.c            | 12 ++--
 drivers/infiniband/core/sysfs.c          |  6 +-
 drivers/infiniband/hw/hfi1/mad.c         | 13 ++---
 drivers/infiniband/hw/hfi1/verbs.h       |  5 +-
 drivers/infiniband/hw/mlx4/mad.c         | 25 ++++-----
 drivers/infiniband/hw/mlx4/mlx4_ib.h     |  7 +--
 drivers/infiniband/hw/mlx5/mad.c         | 24 ++++----
 drivers/infiniband/hw/mlx5/mlx5_ib.h     |  5 +-
 drivers/infiniband/hw/mthca/mthca_dev.h  | 12 ++--
 drivers/infiniband/hw/mthca/mthca_mad.c  | 70 +++++++++++-------------
 drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 17 ++----
 drivers/infiniband/hw/ocrdma/ocrdma_ah.h | 11 ++--
 drivers/infiniband/hw/qedr/verbs.c       | 17 ++----
 drivers/infiniband/hw/qedr/verbs.h       |  7 +--
 drivers/infiniband/hw/qib/qib_mad.c      | 15 ++---
 drivers/infiniband/hw/qib/qib_verbs.h    |  5 +-
 include/rdma/ib_verbs.h                  |  7 +--
 17 files changed, 104 insertions(+), 154 deletions(-)

diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 8adb487eb314..c54db13fa9b0 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -913,9 +913,9 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
 
 	/* No GRH for DR SMP */
 	ret = device->ops.process_mad(device, 0, port_num, &mad_wc, NULL,
-				      (const struct ib_mad_hdr *)smp, mad_size,
-				      (struct ib_mad_hdr *)mad_priv->mad,
-				      &mad_size, &out_mad_pkey_index);
+				      (const struct ib_mad *)smp,
+				      (struct ib_mad *)mad_priv->mad, &mad_size,
+				      &out_mad_pkey_index);
 	switch (ret)
 	{
 	case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY:
@@ -2321,9 +2321,9 @@ static void ib_mad_recv_done(struct ib_cq *cq, struct ib_wc *wc)
 	if (port_priv->device->ops.process_mad) {
 		ret = port_priv->device->ops.process_mad(
 			port_priv->device, 0, port_priv->port_num, wc,
-			&recv->grh, (const struct ib_mad_hdr *)recv->mad,
-			recv->mad_size, (struct ib_mad_hdr *)response->mad,
-			&mad_size, &resp_mad_pkey_index);
+			&recv->grh, (const struct ib_mad *)recv->mad,
+			(struct ib_mad *)response->mad, &mad_size,
+			&resp_mad_pkey_index);
 
 		if (opa)
 			wc->pkey_index = resp_mad_pkey_index;
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 62c756ea5668..087682e6969e 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -497,10 +497,8 @@ static int get_perf_mad(struct ib_device *dev, int port_num, __be16 attr,
 	if (attr != IB_PMA_CLASS_PORT_INFO)
 		in_mad->data[41] = port_num;	/* PortSelect field */
 
-	if ((dev->ops.process_mad(dev, IB_MAD_IGNORE_MKEY,
-				  port_num, NULL, NULL,
-				  (const struct ib_mad_hdr *)in_mad, mad_size,
-				  (struct ib_mad_hdr *)out_mad, &mad_size,
+	if ((dev->ops.process_mad(dev, IB_MAD_IGNORE_MKEY, port_num, NULL, NULL,
+				  in_mad, out_mad, &mad_size,
 				  &out_mad_pkey_index) &
 	     (IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY)) !=
 	    (IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY)) {
diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index a54746f4a0ae..a51bcd2b4391 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -4915,11 +4915,10 @@ static int hfi1_process_ib_mad(struct ib_device *ibdev, int mad_flags, u8 port,
  */
 int hfi1_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 		     const struct ib_wc *in_wc, const struct ib_grh *in_grh,
-		     const struct ib_mad_hdr *in_mad, size_t in_mad_size,
-		     struct ib_mad_hdr *out_mad, size_t *out_mad_size,
-		     u16 *out_mad_pkey_index)
+		     const struct ib_mad *in_mad, struct ib_mad *out_mad,
+		     size_t *out_mad_size, u16 *out_mad_pkey_index)
 {
-	switch (in_mad->base_version) {
+	switch (in_mad->mad_hdr.base_version) {
 	case OPA_MGMT_BASE_VERSION:
 		return hfi1_process_opa_mad(ibdev, mad_flags, port,
 					    in_wc, in_grh,
@@ -4928,10 +4927,8 @@ int hfi1_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 					    out_mad_size,
 					    out_mad_pkey_index);
 	case IB_MGMT_BASE_VERSION:
-		return hfi1_process_ib_mad(ibdev, mad_flags, port,
-					  in_wc, in_grh,
-					  (const struct ib_mad *)in_mad,
-					  (struct ib_mad *)out_mad);
+		return hfi1_process_ib_mad(ibdev, mad_flags, port, in_wc,
+					   in_grh, in_mad, out_mad);
 	default:
 		break;
 	}
diff --git a/drivers/infiniband/hw/hfi1/verbs.h b/drivers/infiniband/hw/hfi1/verbs.h
index ae9582ddbc8f..b0e9bf7cd150 100644
--- a/drivers/infiniband/hw/hfi1/verbs.h
+++ b/drivers/infiniband/hw/hfi1/verbs.h
@@ -330,9 +330,8 @@ void hfi1_sys_guid_chg(struct hfi1_ibport *ibp);
 void hfi1_node_desc_chg(struct hfi1_ibport *ibp);
 int hfi1_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 		     const struct ib_wc *in_wc, const struct ib_grh *in_grh,
-		     const struct ib_mad_hdr *in_mad, size_t in_mad_size,
-		     struct ib_mad_hdr *out_mad, size_t *out_mad_size,
-		     u16 *out_mad_pkey_index);
+		     const struct ib_mad *in_mad, struct ib_mad *out_mad,
+		     size_t *out_mad_size, u16 *out_mad_pkey_index);
 
 /*
  * The PSN_MASK and PSN_SHIFT allow for
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index c6ea4c50da1e..abe68708d6d6 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -983,13 +983,10 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 
 int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 			const struct ib_wc *in_wc, const struct ib_grh *in_grh,
-			const struct ib_mad_hdr *in, size_t in_mad_size,
-			struct ib_mad_hdr *out, size_t *out_mad_size,
-			u16 *out_mad_pkey_index)
+			const struct ib_mad *in, struct ib_mad *out,
+			size_t *out_mad_size, u16 *out_mad_pkey_index)
 {
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	const struct ib_mad *in_mad = (const struct ib_mad *)in;
-	struct ib_mad *out_mad = (struct ib_mad *)out;
 	enum rdma_link_layer link = rdma_port_get_link_layer(ibdev, port_num);
 
 	/* iboe_process_mad() which uses the HCA flow-counters to implement IB PMA
@@ -997,20 +994,20 @@ int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	 */
 	if (link == IB_LINK_LAYER_INFINIBAND) {
 		if (mlx4_is_slave(dev->dev) &&
-		    (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
-		     (in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS ||
-		      in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS_EXT ||
-		      in_mad->mad_hdr.attr_id == IB_PMA_CLASS_PORT_INFO)))
-			return iboe_process_mad(ibdev, mad_flags, port_num, in_wc,
-						in_grh, in_mad, out_mad);
+		    (in->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
+		     (in->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS ||
+		      in->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS_EXT ||
+		      in->mad_hdr.attr_id == IB_PMA_CLASS_PORT_INFO)))
+			return iboe_process_mad(ibdev, mad_flags, port_num,
+						in_wc, in_grh, in, out);
 
-		return ib_process_mad(ibdev, mad_flags, port_num, in_wc,
-				      in_grh, in_mad, out_mad);
+		return ib_process_mad(ibdev, mad_flags, port_num, in_wc, in_grh,
+				      in, out);
 	}
 
 	if (link == IB_LINK_LAYER_ETHERNET)
 		return iboe_process_mad(ibdev, mad_flags, port_num, in_wc,
-					in_grh, in_mad, out_mad);
+					in_grh, in, out);
 
 	return -EINVAL;
 }
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index eb53bb4c0c91..0d846fea8fdc 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -786,11 +786,10 @@ int mlx4_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
 int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags,
 		 int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
 		 const void *in_mad, void *response_mad);
-int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags,	u8 port_num,
+int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 			const struct ib_wc *in_wc, const struct ib_grh *in_grh,
-			const struct ib_mad_hdr *in, size_t in_mad_size,
-			struct ib_mad_hdr *out, size_t *out_mad_size,
-			u16 *out_mad_pkey_index);
+			const struct ib_mad *in, struct ib_mad *out,
+			size_t *out_mad_size, u16 *out_mad_pkey_index);
 int mlx4_ib_mad_init(struct mlx4_ib_dev *dev);
 void mlx4_ib_mad_cleanup(struct mlx4_ib_dev *dev);
 
diff --git a/drivers/infiniband/hw/mlx5/mad.c b/drivers/infiniband/hw/mlx5/mad.c
index 1c87412a162f..14e0c17de6a9 100644
--- a/drivers/infiniband/hw/mlx5/mad.c
+++ b/drivers/infiniband/hw/mlx5/mad.c
@@ -219,15 +219,12 @@ static int process_pma_cmd(struct mlx5_ib_dev *dev, u8 port_num,
 
 int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 			const struct ib_wc *in_wc, const struct ib_grh *in_grh,
-			const struct ib_mad_hdr *in, size_t in_mad_size,
-			struct ib_mad_hdr *out, size_t *out_mad_size,
-			u16 *out_mad_pkey_index)
+			const struct ib_mad *in, struct ib_mad *out,
+			size_t *out_mad_size, u16 *out_mad_pkey_index)
 {
 	struct mlx5_ib_dev *dev = to_mdev(ibdev);
-	const struct ib_mad *in_mad = (const struct ib_mad *)in;
-	struct ib_mad *out_mad = (struct ib_mad *)out;
-	u8 mgmt_class = in_mad->mad_hdr.mgmt_class;
-	u8 method = in_mad->mad_hdr.method;
+	u8 mgmt_class = in->mad_hdr.mgmt_class;
+	u8 method = in->mad_hdr.method;
 	u16 slid;
 	int err;
 
@@ -247,13 +244,13 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 
 		/* Don't process SMInfo queries -- the SMA can't handle them.
 		 */
-		if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO)
+		if (in->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO)
 			return IB_MAD_RESULT_SUCCESS;
 	} break;
 	case IB_MGMT_CLASS_PERF_MGMT:
 		if (MLX5_CAP_GEN(dev->mdev, vport_counters) &&
 		    method == IB_MGMT_METHOD_GET)
-			return process_pma_cmd(dev, port_num, in_mad, out_mad);
+			return process_pma_cmd(dev, port_num, in, out);
 		/* fallthrough */
 	case MLX5_IB_VENDOR_CLASS1:
 		/* fallthrough */
@@ -267,16 +264,15 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 		return IB_MAD_RESULT_SUCCESS;
 	}
 
-	err = mlx5_MAD_IFC(to_mdev(ibdev),
-			   mad_flags & IB_MAD_IGNORE_MKEY,
-			   mad_flags & IB_MAD_IGNORE_BKEY,
-			   port_num, in_wc, in_grh, in_mad, out_mad);
+	err = mlx5_MAD_IFC(to_mdev(ibdev), mad_flags & IB_MAD_IGNORE_MKEY,
+			   mad_flags & IB_MAD_IGNORE_BKEY, port_num, in_wc,
+			   in_grh, in, out);
 	if (err)
 		return IB_MAD_RESULT_FAILURE;
 
 	/* set return bit in status of directed route responses */
 	if (mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
-		out_mad->mad_hdr.status |= cpu_to_be16(1 << 15);
+		out->mad_hdr.status |= cpu_to_be16(1 << 15);
 
 	if (method == IB_MGMT_METHOD_TRAP_REPRESS)
 		/* no response for trap repress */
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 0fb58ecccb7e..cc5568637857 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -1192,9 +1192,8 @@ int mlx5_ib_map_mr_sg_pi(struct ib_mr *ibmr, struct scatterlist *data_sg,
 			 unsigned int *meta_sg_offset);
 int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 			const struct ib_wc *in_wc, const struct ib_grh *in_grh,
-			const struct ib_mad_hdr *in, size_t in_mad_size,
-			struct ib_mad_hdr *out, size_t *out_mad_size,
-			u16 *out_mad_pkey_index);
+			const struct ib_mad *in, struct ib_mad *out,
+			size_t *out_mad_size, u16 *out_mad_pkey_index);
 struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
 				   struct ib_udata *udata);
 int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd, struct ib_udata *udata);
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h
index bfd4eebc1182..599794c5a78f 100644
--- a/drivers/infiniband/hw/mthca/mthca_dev.h
+++ b/drivers/infiniband/hw/mthca/mthca_dev.h
@@ -576,14 +576,10 @@ enum ib_rate mthca_rate_to_ib(struct mthca_dev *dev, u8 mthca_rate, u8 port);
 int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
 int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
 
-int mthca_process_mad(struct ib_device *ibdev,
-		      int mad_flags,
-		      u8 port_num,
-		      const struct ib_wc *in_wc,
-		      const struct ib_grh *in_grh,
-		      const struct ib_mad_hdr *in, size_t in_mad_size,
-		      struct ib_mad_hdr *out, size_t *out_mad_size,
-		      u16 *out_mad_pkey_index);
+int mthca_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
+		      const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+		      const struct ib_mad *in, struct ib_mad *out,
+		      size_t *out_mad_size, u16 *out_mad_pkey_index);
 int mthca_create_agents(struct mthca_dev *dev);
 void mthca_free_agents(struct mthca_dev *dev);
 
diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c
index 0893604d2a62..99aa8183a7f2 100644
--- a/drivers/infiniband/hw/mthca/mthca_mad.c
+++ b/drivers/infiniband/hw/mthca/mthca_mad.c
@@ -196,26 +196,19 @@ static void forward_trap(struct mthca_dev *dev,
 	}
 }
 
-int mthca_process_mad(struct ib_device *ibdev,
-		      int mad_flags,
-		      u8 port_num,
-		      const struct ib_wc *in_wc,
-		      const struct ib_grh *in_grh,
-		      const struct ib_mad_hdr *in, size_t in_mad_size,
-		      struct ib_mad_hdr *out, size_t *out_mad_size,
-		      u16 *out_mad_pkey_index)
+int mthca_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
+		      const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+		      const struct ib_mad *in, struct ib_mad *out,
+		      size_t *out_mad_size, u16 *out_mad_pkey_index)
 {
 	int err;
 	u16 slid = in_wc ? ib_lid_cpu16(in_wc->slid) : be16_to_cpu(IB_LID_PERMISSIVE);
 	u16 prev_lid = 0;
 	struct ib_port_attr pattr;
-	const struct ib_mad *in_mad = (const struct ib_mad *)in;
-	struct ib_mad *out_mad = (struct ib_mad *)out;
 
 	/* Forward locally generated traps to the SM */
-	if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP &&
-	    slid == 0) {
-		forward_trap(to_mdev(ibdev), port_num, in_mad);
+	if (in->mad_hdr.method == IB_MGMT_METHOD_TRAP && !slid) {
+		forward_trap(to_mdev(ibdev), port_num, in);
 		return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
 	}
 
@@ -225,40 +218,39 @@ int mthca_process_mad(struct ib_device *ibdev,
 	 * Only handle PMA and Mellanox vendor-specific class gets and
 	 * sets for other classes.
 	 */
-	if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
-	    in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
-		if (in_mad->mad_hdr.method   != IB_MGMT_METHOD_GET &&
-		    in_mad->mad_hdr.method   != IB_MGMT_METHOD_SET &&
-		    in_mad->mad_hdr.method   != IB_MGMT_METHOD_TRAP_REPRESS)
+	if (in->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
+	    in->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
+		if (in->mad_hdr.method != IB_MGMT_METHOD_GET &&
+		    in->mad_hdr.method != IB_MGMT_METHOD_SET &&
+		    in->mad_hdr.method != IB_MGMT_METHOD_TRAP_REPRESS)
 			return IB_MAD_RESULT_SUCCESS;
 
 		/*
 		 * Don't process SMInfo queries or vendor-specific
 		 * MADs -- the SMA can't handle them.
 		 */
-		if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO ||
-		    ((in_mad->mad_hdr.attr_id & IB_SMP_ATTR_VENDOR_MASK) ==
+		if (in->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO ||
+		    ((in->mad_hdr.attr_id & IB_SMP_ATTR_VENDOR_MASK) ==
 		     IB_SMP_ATTR_VENDOR_MASK))
 			return IB_MAD_RESULT_SUCCESS;
-	} else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
-		   in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS1     ||
-		   in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS2) {
-		if (in_mad->mad_hdr.method  != IB_MGMT_METHOD_GET &&
-		    in_mad->mad_hdr.method  != IB_MGMT_METHOD_SET)
+	} else if (in->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
+		   in->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS1     ||
+		   in->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS2) {
+		if (in->mad_hdr.method != IB_MGMT_METHOD_GET &&
+		    in->mad_hdr.method != IB_MGMT_METHOD_SET)
 			return IB_MAD_RESULT_SUCCESS;
 	} else
 		return IB_MAD_RESULT_SUCCESS;
-	if ((in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
-	     in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
-	    in_mad->mad_hdr.method == IB_MGMT_METHOD_SET &&
-	    in_mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO &&
+	if ((in->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
+	     in->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
+	    in->mad_hdr.method == IB_MGMT_METHOD_SET &&
+	    in->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO &&
 	    !ib_query_port(ibdev, port_num, &pattr))
 		prev_lid = ib_lid_cpu16(pattr.lid);
 
-	err = mthca_MAD_IFC(to_mdev(ibdev),
-			    mad_flags & IB_MAD_IGNORE_MKEY,
-			    mad_flags & IB_MAD_IGNORE_BKEY,
-			    port_num, in_wc, in_grh, in_mad, out_mad);
+	err = mthca_MAD_IFC(to_mdev(ibdev), mad_flags & IB_MAD_IGNORE_MKEY,
+			    mad_flags & IB_MAD_IGNORE_BKEY, port_num, in_wc,
+			    in_grh, in, out);
 	if (err == -EBADMSG)
 		return IB_MAD_RESULT_SUCCESS;
 	else if (err) {
@@ -266,16 +258,16 @@ int mthca_process_mad(struct ib_device *ibdev,
 		return IB_MAD_RESULT_FAILURE;
 	}
 
-	if (!out_mad->mad_hdr.status) {
-		smp_snoop(ibdev, port_num, in_mad, prev_lid);
-		node_desc_override(ibdev, out_mad);
+	if (!out->mad_hdr.status) {
+		smp_snoop(ibdev, port_num, in, prev_lid);
+		node_desc_override(ibdev, out);
 	}
 
 	/* set return bit in status of directed route responses */
-	if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
-		out_mad->mad_hdr.status |= cpu_to_be16(1 << 15);
+	if (in->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+		out->mad_hdr.status |= cpu_to_be16(1 << 15);
 
-	if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS)
+	if (in->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS)
 		/* no response for trap repress */
 		return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
 
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index 4098508b9240..2b7f00ac41b0 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -247,23 +247,18 @@ int ocrdma_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *attr)
 	return 0;
 }
 
-int ocrdma_process_mad(struct ib_device *ibdev,
-		       int process_mad_flags,
-		       u8 port_num,
-		       const struct ib_wc *in_wc,
-		       const struct ib_grh *in_grh,
-		       const struct ib_mad_hdr *in, size_t in_mad_size,
-		       struct ib_mad_hdr *out, size_t *out_mad_size,
+int ocrdma_process_mad(struct ib_device *ibdev, int process_mad_flags,
+		       u8 port_num, const struct ib_wc *in_wc,
+		       const struct ib_grh *in_grh, const struct ib_mad *in,
+		       struct ib_mad *out, size_t *out_mad_size,
 		       u16 *out_mad_pkey_index)
 {
 	int status = IB_MAD_RESULT_SUCCESS;
 	struct ocrdma_dev *dev;
-	const struct ib_mad *in_mad = (const struct ib_mad *)in;
-	struct ib_mad *out_mad = (struct ib_mad *)out;
 
-	if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT) {
+	if (in->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT) {
 		dev = get_ocrdma_dev(ibdev);
-		ocrdma_pma_counters(dev, out_mad);
+		ocrdma_pma_counters(dev, out);
 		status |= IB_MAD_RESULT_REPLY;
 	}
 
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.h b/drivers/infiniband/hw/ocrdma/ocrdma_ah.h
index 64cb82c08664..9780afcde780 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.h
@@ -56,12 +56,9 @@ int ocrdma_create_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr, u32 flags,
 void ocrdma_destroy_ah(struct ib_ah *ah, u32 flags);
 int ocrdma_query_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
 
-int ocrdma_process_mad(struct ib_device *,
-		       int process_mad_flags,
-		       u8 port_num,
-		       const struct ib_wc *in_wc,
-		       const struct ib_grh *in_grh,
-		       const struct ib_mad_hdr *in, size_t in_mad_size,
-		       struct ib_mad_hdr *out, size_t *out_mad_size,
+int ocrdma_process_mad(struct ib_device *dev, int process_mad_flags,
+		       u8 port_num, const struct ib_wc *in_wc,
+		       const struct ib_grh *in_grh, const struct ib_mad *in,
+		       struct ib_mad *out, size_t *out_mad_size,
 		       u16 *out_mad_pkey_index);
 #endif				/* __OCRDMA_AH_H__ */
diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
index 8b4240c1cc76..0f82c86dfc6f 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -4130,19 +4130,10 @@ int qedr_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
 }
 
 int qedr_process_mad(struct ib_device *ibdev, int process_mad_flags,
-		     u8 port_num,
-		     const struct ib_wc *in_wc,
-		     const struct ib_grh *in_grh,
-		     const struct ib_mad_hdr *mad_hdr,
-		     size_t in_mad_size, struct ib_mad_hdr *out_mad,
-		     size_t *out_mad_size, u16 *out_mad_pkey_index)
+		     u8 port_num, const struct ib_wc *in_wc,
+		     const struct ib_grh *in_grh, const struct ib_mad *in,
+		     struct ib_mad *out_mad, size_t *out_mad_size,
+		     u16 *out_mad_pkey_index)
 {
-	struct qedr_dev *dev = get_qedr_dev(ibdev);
-
-	DP_DEBUG(dev, QEDR_MSG_GSI,
-		 "QEDR_PROCESS_MAD in_mad %x %x %x %x %x %x %x %x\n",
-		 mad_hdr->attr_id, mad_hdr->base_version, mad_hdr->attr_mod,
-		 mad_hdr->class_specific, mad_hdr->class_version,
-		 mad_hdr->method, mad_hdr->mgmt_class, mad_hdr->status);
 	return IB_MAD_RESULT_SUCCESS;
 }
diff --git a/drivers/infiniband/hw/qedr/verbs.h b/drivers/infiniband/hw/qedr/verbs.h
index 9aaa90283d6e..43bd84f98a0a 100644
--- a/drivers/infiniband/hw/qedr/verbs.h
+++ b/drivers/infiniband/hw/qedr/verbs.h
@@ -93,10 +93,9 @@ int qedr_post_recv(struct ib_qp *, const struct ib_recv_wr *,
 		   const struct ib_recv_wr **bad_wr);
 int qedr_process_mad(struct ib_device *ibdev, int process_mad_flags,
 		     u8 port_num, const struct ib_wc *in_wc,
-		     const struct ib_grh *in_grh,
-		     const struct ib_mad_hdr *in_mad,
-		     size_t in_mad_size, struct ib_mad_hdr *out_mad,
-		     size_t *out_mad_size, u16 *out_mad_pkey_index);
+		     const struct ib_grh *in_grh, const struct ib_mad *in_mad,
+		     struct ib_mad *out_mad, size_t *out_mad_size,
+		     u16 *out_mad_pkey_index);
 
 int qedr_port_immutable(struct ib_device *ibdev, u8 port_num,
 			struct ib_port_immutable *immutable);
diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
index b259aaf85d4a..79bb83222e8d 100644
--- a/drivers/infiniband/hw/qib/qib_mad.c
+++ b/drivers/infiniband/hw/qib/qib_mad.c
@@ -2386,24 +2386,21 @@ static int process_cc(struct ib_device *ibdev, int mad_flags,
  */
 int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 		    const struct ib_wc *in_wc, const struct ib_grh *in_grh,
-		    const struct ib_mad_hdr *in, size_t in_mad_size,
-		    struct ib_mad_hdr *out, size_t *out_mad_size,
-		    u16 *out_mad_pkey_index)
+		    const struct ib_mad *in, struct ib_mad *out,
+		    size_t *out_mad_size, u16 *out_mad_pkey_index)
 {
 	int ret;
 	struct qib_ibport *ibp = to_iport(ibdev, port);
 	struct qib_pportdata *ppd = ppd_from_ibp(ibp);
-	const struct ib_mad *in_mad = (const struct ib_mad *)in;
-	struct ib_mad *out_mad = (struct ib_mad *)out;
 
-	switch (in_mad->mad_hdr.mgmt_class) {
+	switch (in->mad_hdr.mgmt_class) {
 	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
 	case IB_MGMT_CLASS_SUBN_LID_ROUTED:
-		ret = process_subn(ibdev, mad_flags, port, in_mad, out_mad);
+		ret = process_subn(ibdev, mad_flags, port, in, out);
 		goto bail;
 
 	case IB_MGMT_CLASS_PERF_MGMT:
-		ret = process_perf(ibdev, port, in_mad, out_mad);
+		ret = process_perf(ibdev, port, in, out);
 		goto bail;
 
 	case IB_MGMT_CLASS_CONG_MGMT:
@@ -2412,7 +2409,7 @@ int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 			ret = IB_MAD_RESULT_SUCCESS;
 			goto bail;
 		}
-		ret = process_cc(ibdev, mad_flags, port, in_mad, out_mad);
+		ret = process_cc(ibdev, mad_flags, port, in, out);
 		goto bail;
 
 	default:
diff --git a/drivers/infiniband/hw/qib/qib_verbs.h b/drivers/infiniband/hw/qib/qib_verbs.h
index 17bdf8acee2f..8bf414b47b96 100644
--- a/drivers/infiniband/hw/qib/qib_verbs.h
+++ b/drivers/infiniband/hw/qib/qib_verbs.h
@@ -245,9 +245,8 @@ void qib_sys_guid_chg(struct qib_ibport *ibp);
 void qib_node_desc_chg(struct qib_ibport *ibp);
 int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 		    const struct ib_wc *in_wc, const struct ib_grh *in_grh,
-		    const struct ib_mad_hdr *in, size_t in_mad_size,
-		    struct ib_mad_hdr *out, size_t *out_mad_size,
-		    u16 *out_mad_pkey_index);
+		    const struct ib_mad *in, struct ib_mad *out,
+		    size_t *out_mad_size, u16 *out_mad_pkey_index);
 void qib_notify_create_mad_agent(struct rvt_dev_info *rdi, int port_idx);
 void qib_notify_free_mad_agent(struct rvt_dev_info *rdi, int port_idx);
 
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index d78abb616096..8333fd70350c 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2122,7 +2122,7 @@ struct ib_flow_action {
 	atomic_t			usecnt;
 };
 
-struct ib_mad_hdr;
+struct ib_mad;
 struct ib_grh;
 
 enum ib_process_mad_flags {
@@ -2280,9 +2280,8 @@ struct ib_device_ops {
 	int (*process_mad)(struct ib_device *device, int process_mad_flags,
 			   u8 port_num, const struct ib_wc *in_wc,
 			   const struct ib_grh *in_grh,
-			   const struct ib_mad_hdr *in_mad, size_t in_mad_size,
-			   struct ib_mad_hdr *out_mad, size_t *out_mad_size,
-			   u16 *out_mad_pkey_index);
+			   const struct ib_mad *in_mad, struct ib_mad *out_mad,
+			   size_t *out_mad_size, u16 *out_mad_pkey_index);
 	int (*query_device)(struct ib_device *device,
 			    struct ib_device_attr *device_attr,
 			    struct ib_udata *udata);
-- 
2.20.1


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

* Re: [PATCH rdma-next 07/16] RDMA/hfi1: Delete unreachable code
  2019-10-29  6:27 ` [PATCH rdma-next 07/16] RDMA/hfi1: Delete unreachable code Leon Romanovsky
@ 2019-10-29 23:33   ` Ira Weiny
  2019-10-30  0:02     ` Ira Weiny
  0 siblings, 1 reply; 24+ messages in thread
From: Ira Weiny @ 2019-10-29 23:33 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Doug Ledford, Jason Gunthorpe, Leon Romanovsky,
	RDMA mailing list, Mike Marciniszyn, Ralph Campbell

On Tue, Oct 29, 2019 at 08:27:36AM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
> 
> All callers allocate MAD structures with proper sizes,
> there is no need to recheck it.
> 
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  drivers/infiniband/hw/hfi1/mad.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
> index d8ff063a5419..a54746f4a0ae 100644
> --- a/drivers/infiniband/hw/hfi1/mad.c
> +++ b/drivers/infiniband/hw/hfi1/mad.c
> @@ -4921,10 +4921,6 @@ int hfi1_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
>  {
>  	switch (in_mad->base_version) {
>  	case OPA_MGMT_BASE_VERSION:
> -		if (unlikely(in_mad_size != sizeof(struct opa_mad))) {
> -			dev_err(ibdev->dev.parent, "invalid in_mad_size\n");
> -			return IB_MAD_RESULT_FAILURE;
> -		}

It's been a while but I'm not 100% sure we can safely remove this check.  A
user can send an IB sized MAD to an OPA device and AFAIR there is nothing
checking that the base version is set correctly for the size of mad received by
the mad stack.

Are you 100% sure that the in_mad_size is based off the management base
version?

Also, regarding the patches to remove the checks on the IB devices I would want
to see that check in the core MAD stack to verify we are not sending an OPA mad
to an IB device.  I may have put a check in there already so removing the code
in those drivers may be ok.  I'm not sure off the top of my head...

Ira

>  		return hfi1_process_opa_mad(ibdev, mad_flags, port,
>  					    in_wc, in_grh,
>  					    (struct opa_mad *)in_mad,
> -- 
> 2.20.1
> 

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

* Re: [PATCH rdma-next 07/16] RDMA/hfi1: Delete unreachable code
  2019-10-29 23:33   ` Ira Weiny
@ 2019-10-30  0:02     ` Ira Weiny
  0 siblings, 0 replies; 24+ messages in thread
From: Ira Weiny @ 2019-10-30  0:02 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Doug Ledford, Jason Gunthorpe, Leon Romanovsky,
	RDMA mailing list, Mike Marciniszyn, Ralph Campbell

On Tue, Oct 29, 2019 at 04:33:27PM -0700, 'Ira Weiny' wrote:
> On Tue, Oct 29, 2019 at 08:27:36AM +0200, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@mellanox.com>
> > 
> > All callers allocate MAD structures with proper sizes,
> > there is no need to recheck it.
> > 
> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> > ---
> >  drivers/infiniband/hw/hfi1/mad.c | 4 ----
> >  1 file changed, 4 deletions(-)
> > 
> > diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
> > index d8ff063a5419..a54746f4a0ae 100644
> > --- a/drivers/infiniband/hw/hfi1/mad.c
> > +++ b/drivers/infiniband/hw/hfi1/mad.c
> > @@ -4921,10 +4921,6 @@ int hfi1_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
> >  {
> >  	switch (in_mad->base_version) {
> >  	case OPA_MGMT_BASE_VERSION:
> > -		if (unlikely(in_mad_size != sizeof(struct opa_mad))) {
> > -			dev_err(ibdev->dev.parent, "invalid in_mad_size\n");
> > -			return IB_MAD_RESULT_FAILURE;
> > -		}
> 
> It's been a while but I'm not 100% sure we can safely remove this check.  A
> user can send an IB sized MAD to an OPA device and AFAIR there is nothing
> checking that the base version is set correctly for the size of mad received by
> the mad stack.
> 
> Are you 100% sure that the in_mad_size is based off the management base
> version?

Ok, I _think_ this check may actually be wrong and we were just lucky because
handle_outgoing_dr_smp() uses the port _max_ MAD size as the in_mad_size which is
not _technically_ correct.  And in normal RX we are passing 2K as
in_mad_size...  Again _not_ technically correct but irrelevant because it looks
like we pass the actual bytes received in mad_priv->header.recv_wc->mad_len.

After looking at your last patch I started to remember more.  OPA MADs are
variable size so this was the reasoning for the addition of the in/out size
parameters.

But I see that nothing in the hfi1 driver is actually using the in_mad_size.
So I think we may be ok here but...

Denny, would be nice to get this patch set tested though...  Just to make sure.

Thanks, and sorry for the noise.
Ira

> 
> Also, regarding the patches to remove the checks on the IB devices I would want
> to see that check in the core MAD stack to verify we are not sending an OPA mad
> to an IB device.  I may have put a check in there already so removing the code
> in those drivers may be ok.  I'm not sure off the top of my head...
> 
> Ira
> 
> >  		return hfi1_process_opa_mad(ibdev, mad_flags, port,
> >  					    in_wc, in_grh,
> >  					    (struct opa_mad *)in_mad,
> > -- 
> > 2.20.1
> > 

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

* Re: [PATCH rdma-next 00/16] MAD cleanup
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (15 preceding siblings ...)
  2019-10-29  6:27 ` [PATCH rdma-next 16/16] RDMA: Change MAD processing function to remove extra casting and parameter Leon Romanovsky
@ 2019-11-06 20:14 ` Jason Gunthorpe
  2019-11-11 15:06   ` Leon Romanovsky
  2019-11-13  0:37 ` Jason Gunthorpe
  17 siblings, 1 reply; 24+ messages in thread
From: Jason Gunthorpe @ 2019-11-06 20:14 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Doug Ledford, Leon Romanovsky, RDMA mailing list,
	Mike Marciniszyn, Ralph Campbell

On Tue, Oct 29, 2019 at 08:27:29AM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
> 
> Let's clean MAD code a little bit.
> 
> It is based on
> https://lore.kernel.org/linux-rdma/20191027070621.11711-1-leon@kernel.org

It doesn't seem related to this at all

> Leon Romanovsky (16):
>   RDMA/mad: Delete never implemented functions
>   RDMA/mad: Allocate zeroed MAD buffer
>   RDMA/mlx4: Delete redundant zero memset
>   RDMA/mlx5: Delete redundant zero memset

We don't need a patch for every driver just to change the same
repeating 2 line pattern, I squashed these

>   RDMA/ocrdma: Clean MAD processing logic
>   RDMA/qib: Delete redundant memset for MAD output buffer
>   RDMA/mlx4: Delete unreachable code
>   RDMA/mlx5: Delete unreachable code
>   RDMA/mthca: Delete unreachable code

Same here

>   RDMA/ocrdma: Simplify process_mad function
>   RDMA/qib: Delete unreachable code
>   RDMA/mlx5: Rewrite MAD processing logic to be readable
>   RDMA/qib: Delete extra line

>   RDMA/qib: Delete unused variable in process_cc call

This is actually a bug from an earlier patch that oddly removed
check_cc_key, I put that into its own patch

>   RDMA/hfi1: Delete unreachable code
>   RDMA: Change MAD processing function to remove extra casting and
>     parameter
 
Ira seems concerned, so I didn't apply these until we hear from Dennis

Otherwise the rest were applied with re-organization to for-next

Thanks,
Jason

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

* RE: [PATCH rdma-next 16/16] RDMA: Change MAD processing function to remove extra casting and parameter
  2019-10-29  6:27 ` [PATCH rdma-next 16/16] RDMA: Change MAD processing function to remove extra casting and parameter Leon Romanovsky
@ 2019-11-11 13:33   ` Marciniszyn, Mike
  2019-11-11 15:06     ` Leon Romanovsky
  0 siblings, 1 reply; 24+ messages in thread
From: Marciniszyn, Mike @ 2019-11-11 13:33 UTC (permalink / raw)
  To: Leon Romanovsky, Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Ralph Campbell

> Subject: [PATCH rdma-next 16/16] RDMA: Change MAD processing function
> to remove extra casting and parameter
> 
> From: Leon Romanovsky <leonro@mellanox.com>
> 
> All users of process_mad() converts input pointers from ib_mad_hdr
> to be ib_mad, update the function declaration to use ib_mad directly.
> 
> Also remove not used input MAD size parameter.
> 
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> ---

One workqueue failure we have been fighting  for a while, so the mad stuff looks fine.

Tested-By: Mike Marciniszyn <mike.marciniszyn@intel.com>

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

* Re: [PATCH rdma-next 16/16] RDMA: Change MAD processing function to remove extra casting and parameter
  2019-11-11 13:33   ` Marciniszyn, Mike
@ 2019-11-11 15:06     ` Leon Romanovsky
  0 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-11-11 15:06 UTC (permalink / raw)
  To: Marciniszyn, Mike
  Cc: Doug Ledford, Jason Gunthorpe, RDMA mailing list, Ralph Campbell

On Mon, Nov 11, 2019 at 01:33:57PM +0000, Marciniszyn, Mike wrote:
> > Subject: [PATCH rdma-next 16/16] RDMA: Change MAD processing function
> > to remove extra casting and parameter
> >
> > From: Leon Romanovsky <leonro@mellanox.com>
> >
> > All users of process_mad() converts input pointers from ib_mad_hdr
> > to be ib_mad, update the function declaration to use ib_mad directly.
> >
> > Also remove not used input MAD size parameter.
> >
> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> > ---
>
> One workqueue failure we have been fighting  for a while, so the mad stuff looks fine.
>
> Tested-By: Mike Marciniszyn <mike.marciniszyn@intel.com>

Thanks a lot.

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

* Re: [PATCH rdma-next 00/16] MAD cleanup
  2019-11-06 20:14 ` [PATCH rdma-next 00/16] MAD cleanup Jason Gunthorpe
@ 2019-11-11 15:06   ` Leon Romanovsky
  0 siblings, 0 replies; 24+ messages in thread
From: Leon Romanovsky @ 2019-11-11 15:06 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Doug Ledford, RDMA mailing list, Mike Marciniszyn, Ralph Campbell

On Wed, Nov 06, 2019 at 04:14:48PM -0400, Jason Gunthorpe wrote:
> On Tue, Oct 29, 2019 at 08:27:29AM +0200, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@mellanox.com>
> >
> > Let's clean MAD code a little bit.
> >
> > It is based on
> > https://lore.kernel.org/linux-rdma/20191027070621.11711-1-leon@kernel.org
>
> It doesn't seem related to this at all
>
> > Leon Romanovsky (16):
> >   RDMA/mad: Delete never implemented functions
> >   RDMA/mad: Allocate zeroed MAD buffer
> >   RDMA/mlx4: Delete redundant zero memset
> >   RDMA/mlx5: Delete redundant zero memset
>
> We don't need a patch for every driver just to change the same
> repeating 2 line pattern, I squashed these
>
> >   RDMA/ocrdma: Clean MAD processing logic
> >   RDMA/qib: Delete redundant memset for MAD output buffer
> >   RDMA/mlx4: Delete unreachable code
> >   RDMA/mlx5: Delete unreachable code
> >   RDMA/mthca: Delete unreachable code
>
> Same here
>
> >   RDMA/ocrdma: Simplify process_mad function
> >   RDMA/qib: Delete unreachable code
> >   RDMA/mlx5: Rewrite MAD processing logic to be readable
> >   RDMA/qib: Delete extra line
>
> >   RDMA/qib: Delete unused variable in process_cc call
>
> This is actually a bug from an earlier patch that oddly removed
> check_cc_key, I put that into its own patch
>
> >   RDMA/hfi1: Delete unreachable code
> >   RDMA: Change MAD processing function to remove extra casting and
> >     parameter
>
> Ira seems concerned, so I didn't apply these until we hear from Dennis
>
> Otherwise the rest were applied with re-organization to for-next

Jason,

Can you please take missing two patches?

Thanks

>
> Thanks,
> Jason

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

* Re: [PATCH rdma-next 00/16] MAD cleanup
  2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
                   ` (16 preceding siblings ...)
  2019-11-06 20:14 ` [PATCH rdma-next 00/16] MAD cleanup Jason Gunthorpe
@ 2019-11-13  0:37 ` Jason Gunthorpe
  17 siblings, 0 replies; 24+ messages in thread
From: Jason Gunthorpe @ 2019-11-13  0:37 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Doug Ledford, Leon Romanovsky, RDMA mailing list,
	Mike Marciniszyn, Ralph Campbell

On Tue, Oct 29, 2019 at 08:27:29AM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
> 
> Let's clean MAD code a little bit.
> 
> It is based on
> https://lore.kernel.org/linux-rdma/20191027070621.11711-1-leon@kernel.org
> 
>   RDMA/hfi1: Delete unreachable code
>   RDMA: Change MAD processing function to remove extra casting and
>     parameter

Applied to for-next, thanks

Jason

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

end of thread, other threads:[~2019-11-13  0:37 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-29  6:27 [PATCH rdma-next 00/16] MAD cleanup Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 01/16] RDMA/mad: Delete never implemented functions Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 02/16] RDMA/mad: Allocate zeroed MAD buffer Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 03/16] RDMA/mlx4: Delete redundant zero memset Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 04/16] RDMA/mlx5: " Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 05/16] RDMA/ocrdma: Clean MAD processing logic Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 06/16] RDMA/qib: Delete redundant memset for MAD output buffer Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 07/16] RDMA/hfi1: Delete unreachable code Leon Romanovsky
2019-10-29 23:33   ` Ira Weiny
2019-10-30  0:02     ` Ira Weiny
2019-10-29  6:27 ` [PATCH rdma-next 08/16] RDMA/mlx4: " Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 09/16] RDMA/mlx5: " Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 10/16] RDMA/mthca: " Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 11/16] RDMA/ocrdma: Simplify process_mad function Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 12/16] RDMA/qib: Delete unreachable code Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 13/16] RDMA/mlx5: Rewrite MAD processing logic to be readable Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 14/16] RDMA/qib: Delete extra line Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 15/16] RDMA/qib: Delete unused variable in process_cc call Leon Romanovsky
2019-10-29  6:27 ` [PATCH rdma-next 16/16] RDMA: Change MAD processing function to remove extra casting and parameter Leon Romanovsky
2019-11-11 13:33   ` Marciniszyn, Mike
2019-11-11 15:06     ` Leon Romanovsky
2019-11-06 20:14 ` [PATCH rdma-next 00/16] MAD cleanup Jason Gunthorpe
2019-11-11 15:06   ` Leon Romanovsky
2019-11-13  0:37 ` Jason Gunthorpe

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).