diff mbox series

[rdma-next,5/9] IB/umad: Set deadline when sending non-RMPP MADs

Message ID 3ddefc7bd188b15b9f03aebf469630f30f62bea2.1733405453.git.leon@kernel.org (mailing list archive)
State New
Headers show
Series Rework retry algorithm used when sending MADs | expand

Commit Message

Leon Romanovsky Dec. 5, 2024, 1:49 p.m. UTC
From: Vlad Dumitrescu <vdumitrescu@nvidia.com>

Change semantics of the UAPI struct ib_user_mad_hdr retries and
timeout_ms fields.  Given the current implementation, users likely
expect the total timeout to be (retries + 1) * timeout_ms.  Use that
as MAD deadline.

This allows changes to the MAD layer's internal retry algorithm, for
non-RMPP agents, without affecting the total timeout experienced by
userspace.

Signed-off-by: Vlad Dumitrescu <vdumitrescu@nvidia.com>
Reviewed-by: Sean Hefty <shefty@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/core/user_mad.c |  8 ++++++++
 include/uapi/rdma/ib_user_mad.h    | 12 ++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index fd67fc9fe85a..3da6c0295657 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -650,6 +650,14 @@  static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 		}
 	}
 
+	if (!ib_mad_kernel_rmpp_agent(agent) && packet->mad.hdr.timeout_ms) {
+		ret = ib_set_mad_deadline(packet->msg,
+					  (packet->mad.hdr.retries + 1) *
+						  packet->mad.hdr.timeout_ms);
+		if (ret)
+			goto err_send;
+	}
+
 	ret = ib_post_send_mad(packet->msg, NULL);
 	if (ret)
 		goto err_send;
diff --git a/include/uapi/rdma/ib_user_mad.h b/include/uapi/rdma/ib_user_mad.h
index 10b5f6a4c677..1e9c20a44e50 100644
--- a/include/uapi/rdma/ib_user_mad.h
+++ b/include/uapi/rdma/ib_user_mad.h
@@ -57,7 +57,11 @@ 
  *   received (transaction ID in data[] will be set to TID of original
  *   request) (ignored on send)
  * @timeout_ms - Milliseconds to wait for response (unset on receive)
- * @retries - Number of automatic retries to attempt
+ *   before issuing a retry
+ * @retries - Maximum number of automatic retries to attempt. Actual
+ *   number of retries could be less if (@retries + 1) * @timeout_ms
+ *   is exceeded. When the registration request sets @rmpp_version,
+ *   it applies per RMPP window
  * @qpn - Remote QP number received from/to be sent to
  * @qkey - Remote Q_Key to be sent with (unset on receive)
  * @lid - Remote lid received from/to be sent to
@@ -100,7 +104,11 @@  struct ib_user_mad_hdr_old {
  *   received (transaction ID in data[] will be set to TID of original
  *   request) (ignored on send)
  * @timeout_ms - Milliseconds to wait for response (unset on receive)
- * @retries - Number of automatic retries to attempt
+ *   before issuing a retry
+ * @retries - Maximum number of automatic retries to attempt. Actual
+ *   number of retries could be less if (@retries + 1) * @timeout_ms
+ *   is exceeded. When the registration request sets @rmpp_version,
+ *   it applies per RMPP window
  * @qpn - Remote QP number received from/to be sent to
  * @qkey - Remote Q_Key to be sent with (unset on receive)
  * @lid - Remote lid received from/to be sent to