]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
librdmacm: update datagram tests to abort if msg size > MTU
authorSean Hefty <sean.hefty@intel.com>
Fri, 20 Apr 2007 22:16:07 +0000 (15:16 -0700)
committerSean Hefty <sean.hefty@intel.com>
Fri, 20 Apr 2007 22:16:07 +0000 (15:16 -0700)
If the user specifies a message size for mckey or udaddy tests that's
larger than the active MTU of the bound port, the sends will fail.
Detect this condition and abort the test if the message size is >
the active MTU of the port.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
examples/mckey.c
examples/udaddy.c

index 90d0873b180b86110b11771838c5de42dc8f0b87..24514a4b244dec2e53685f34cf90ba7b63e09e75 100644 (file)
@@ -108,6 +108,25 @@ err:
        return -1;
 }
 
+static int verify_test_params(struct cmatest_node *node)
+{
+       struct ibv_port_attr port_attr;
+       int ret;
+
+       ret = ibv_query_port(node->cma_id->verbs, node->cma_id->port_num,
+                            &port_attr);
+       if (ret)
+               return ret;
+
+       if (message_count && message_size > (1 << (port_attr.active_mtu + 7))) {
+               printf("mckey: message_size %d is larger than active mtu %d\n",
+                      message_size, 1 << (port_attr.active_mtu + 7));
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static int init_node(struct cmatest_node *node)
 {
        struct ibv_qp_init_attr init_qp_attr;
@@ -208,7 +227,7 @@ static int post_sends(struct cmatest_node *node, int signal_flag)
 
        for (i = 0; i < message_count && !ret; i++) {
                ret = ibv_post_send(node->cma_id->qp, &send_wr, &bad_send_wr);
-               if (ret) 
+               if (ret)
                        printf("failed to post sends: %d\n", ret);
        }
        return ret;
@@ -223,6 +242,10 @@ static int addr_handler(struct cmatest_node *node)
 {
        int ret;
 
+       ret = verify_test_params(node);
+       if (ret)
+               goto err;
+
        ret = init_node(node);
        if (ret)
                goto err;
index 91862751c42cbf4a849034488de420b54d0aff19..84ff16bcfbffeb66caecd46b23853dcbf8d4a123 100644 (file)
@@ -104,6 +104,25 @@ err:
        return -1;
 }
 
+static int verify_test_params(struct cmatest_node *node)
+{
+       struct ibv_port_attr port_attr;
+       int ret;
+
+       ret = ibv_query_port(node->cma_id->verbs, node->cma_id->port_num,
+                            &port_attr);
+       if (ret)
+               return ret;
+
+       if (message_count && message_size > (1 << (port_attr.active_mtu + 7))) {
+               printf("udaddy: message_size %d is larger than active mtu %d\n",
+                      message_size, 1 << (port_attr.active_mtu + 7));
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static int init_node(struct cmatest_node *node)
 {
        struct ibv_qp_init_attr init_qp_attr;
@@ -232,6 +251,10 @@ static int route_handler(struct cmatest_node *node)
        struct rdma_conn_param conn_param;
        int ret;
 
+       ret = verify_test_params(node);
+       if (ret)
+               goto err;
+
        ret = init_node(node);
        if (ret)
                goto err;
@@ -269,6 +292,10 @@ static int connect_handler(struct rdma_cm_id *cma_id)
        node->cma_id = cma_id;
        cma_id->context = node;
 
+       ret = verify_test_params(node);
+       if (ret)
+               goto err2;
+
        ret = init_node(node);
        if (ret)
                goto err2;