diff mbox series

[rdma-core,4/4] ucmatose: Add option to set ACK timeout

Message ID 1548683787-18270-5-git-send-email-yishaih@mellanox.com (mailing list archive)
State Not Applicable
Headers show
Series rdmacm: Add option to set ACK timeout | expand

Commit Message

Yishai Hadas Jan. 28, 2019, 1:56 p.m. UTC
From: Danit Goldberg <danitg@mellanox.com>

The option is available via "-a" flag.

Signed-off-by: Danit Goldberg <danitg@mellanox.com>
Reviewed-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 librdmacm/examples/cmatose.c | 24 ++++++++++++++++++++++--
 librdmacm/man/ucmatose.1     |  8 ++++++--
 2 files changed, 28 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/librdmacm/examples/cmatose.c b/librdmacm/examples/cmatose.c
index 457e507..1f7f315 100644
--- a/librdmacm/examples/cmatose.c
+++ b/librdmacm/examples/cmatose.c
@@ -80,6 +80,8 @@  static uint8_t migrate = 0;
 static char *dst_addr;
 static char *src_addr;
 static struct rdma_addrinfo hints;
+static uint8_t set_timeout;
+static uint8_t timeout;
 
 static int create_message(struct cmatest_node *node)
 {
@@ -223,7 +225,13 @@  static int addr_handler(struct cmatest_node *node)
 		if (ret)
 			perror("cmatose: set TOS option failed");
 	}
-
+	if (set_timeout) {
+		ret = rdma_set_option(node->cma_id, RDMA_OPTION_ID,
+				      RDMA_OPTION_ID_ACK_TIMEOUT,
+				      &timeout, sizeof(timeout));
+		if (ret)
+			perror("cmatose: set ack timeout option failed");
+	}
 	ret = rdma_resolve_route(node->cma_id, 2000);
 	if (ret) {
 		perror("cmatose: resolve route failed");
@@ -280,6 +288,13 @@  static int connect_handler(struct rdma_cm_id *cma_id)
 	if (ret)
 		goto err2;
 
+	if (set_timeout) {
+		ret = rdma_set_option(node->cma_id, RDMA_OPTION_ID,
+				      RDMA_OPTION_ID_ACK_TIMEOUT,
+				      &timeout, sizeof(timeout));
+		if (ret)
+			perror("cmatose: set ack timeout option failed");
+	}
 	ret = post_recvs(node);
 	if (ret)
 		goto err2;
@@ -635,7 +650,7 @@  int main(int argc, char **argv)
 	int op, ret;
 
 	hints.ai_port_space = RDMA_PS_TCP;
-	while ((op = getopt(argc, argv, "s:b:f:P:c:C:S:t:p:m")) != -1) {
+	while ((op = getopt(argc, argv, "s:b:f:P:c:C:S:t:p:a:m")) != -1) {
 		switch (op) {
 		case 's':
 			dst_addr = optarg;
@@ -679,6 +694,10 @@  int main(int argc, char **argv)
 		case 'm':
 			migrate = 1;
 			break;
+		case 'a':
+			set_timeout = 1;
+			timeout = (uint8_t) strtoul(optarg, NULL, 0);
+			break;
 		default:
 			printf("usage: %s\n", argv[0]);
 			printf("\t[-s server_address]\n");
@@ -693,6 +712,7 @@  int main(int argc, char **argv)
 			printf("\t[-t type_of_service]\n");
 			printf("\t[-p port_number]\n");
 			printf("\t[-m(igrate)]\n");
+			printf("\t[-a ack_timeout]\n");
 			exit(1);
 		}
 	}
diff --git a/librdmacm/man/ucmatose.1 b/librdmacm/man/ucmatose.1
index 56e0702..d672e9d 100644
--- a/librdmacm/man/ucmatose.1
+++ b/librdmacm/man/ucmatose.1
@@ -7,10 +7,10 @@  ucmatose \- RDMA CM connection and simple ping-pong test.
 .nf
 \fIucmatose\fR [-s server_address] [-b bind_address]
 		[-f address_format] [-P port_space]
-		[-c connections] [-C message_count] [-S message_size]
+		[-c connections] [-C message_count] [-S message_size] [-a ack_timeout]
 \fIucmatose\fR -s server_address [-b bind_address]
 		[-f address_format] [-P port_space]
-		[-c connections] [-C message_count] [-S message_size] [-t tos]
+		[-c connections] [-C message_count] [-S message_size] [-t tos] [-a ack_timeout]
 .fi
 .SH "DESCRIPTION"
 Establishes a set of reliable RDMA connections between two nodes using the
@@ -52,6 +52,10 @@  The size of each message transferred, in bytes.  (default 100)
 Indicates the type of service used for the communication.  Type of service
 is implementation dependent based on subnet configuration.
 .TP
+\-a ack_timeout
+Indicates the QP ACK timeout value that should be used.
+The value calculated according to the formula 4.096 * 2^(ack_timeout) usec.
+.TP
 \-m
 Tests event channel migration.  Migrates all communication identifiers to
 a different event channel for disconnect events.