This patch adds a new -m <mtu_size> option to the ping pong
programs which have a path MTU parameter to ib_modify_qp().

Signed-off-by: Ralph Campbell <[EMAIL PROTECTED]>

Index: libibverbs/examples/rc_pingpong.c
===================================================================
--- libibverbs/examples/rc_pingpong.c   (revision 5065)
+++ libibverbs/examples/rc_pingpong.c   (working copy)
@@ -59,6 +59,7 @@
 };
 
 static int page_size;
+static int path_mtu;
 
 struct pingpong_context {
        struct ibv_context      *context;
@@ -94,7 +95,7 @@
 {
        struct ibv_qp_attr attr = {
                .qp_state               = IBV_QPS_RTR,
-               .path_mtu               = IBV_MTU_1024,
+               .path_mtu               = path_mtu,
                .dest_qp_num            = dest->qpn,
                .rq_psn                 = dest->psn,
                .max_dest_rd_atomic     = 1,
@@ -440,6 +441,7 @@
        printf("  -d, --ib-dev=<dev>     use IB device <dev> (default first 
device found)\n");
        printf("  -i, --ib-port=<port>   use port <port> of IB device (default 
1)\n");
        printf("  -s, --size=<size>      size of message to exchange (default 
4096)\n");
+       printf("  -m, --mtu=<size>       path MTU (default 1024)\n");
        printf("  -r, --rx-depth=<dep>   number of receives to post at a time 
(default 500)\n");
        printf("  -n, --iters=<iters>    number of exchanges (default 1000)\n");
        printf("  -e, --events           sleep on CQ events (default poll)\n");
@@ -458,6 +460,7 @@
        int                      port = 18515;
        int                      ib_port = 1;
        int                      size = 4096;
+       int                      mtu = 1024;
        int                      rx_depth = 500;
        int                      iters = 1000;
        int                      use_event = 0;
@@ -474,13 +477,14 @@
                        { .name = "ib-dev",   .has_arg = 1, .val = 'd' },
                        { .name = "ib-port",  .has_arg = 1, .val = 'i' },
                        { .name = "size",     .has_arg = 1, .val = 's' },
+                       { .name = "mtu",      .has_arg = 1, .val = 'm' },
                        { .name = "rx-depth", .has_arg = 1, .val = 'r' },
                        { .name = "iters",    .has_arg = 1, .val = 'n' },
                        { .name = "events",   .has_arg = 0, .val = 'e' },
                        { 0 }
                };
 
-               c = getopt_long(argc, argv, "p:d:i:s:r:n:e", long_options, 
NULL);
+               c = getopt_long(argc, argv, "p:d:i:s:m:r:n:e", long_options, 
NULL);
                if (c == -1)
                        break;
 
@@ -509,6 +513,10 @@
                        size = strtol(optarg, NULL, 0);
                        break;
 
+               case 'm':
+                       mtu = strtol(optarg, NULL, 0);
+                       break;
+
                case 'r':
                        rx_depth = strtol(optarg, NULL, 0);
                        break;
@@ -534,6 +542,32 @@
                return 1;
        }
 
+       switch (mtu) {
+       case 256:
+               path_mtu = IBV_MTU_256;
+               break;
+
+       case 512:
+               path_mtu = IBV_MTU_512;
+               break;
+
+       case 1024:
+               path_mtu = IBV_MTU_1024;
+               break;
+
+       case 2048:
+               path_mtu = IBV_MTU_2048;
+               break;
+
+       case 4096:
+               path_mtu = IBV_MTU_4096;
+               break;
+
+       default:
+               usage(argv[0]);
+               return 1;
+       }
+
        page_size = sysconf(_SC_PAGESIZE);
 
        dev_list = ibv_get_device_list(NULL);
Index: libibverbs/examples/uc_pingpong.c
===================================================================
--- libibverbs/examples/uc_pingpong.c   (revision 5065)
+++ libibverbs/examples/uc_pingpong.c   (working copy)
@@ -59,6 +59,7 @@
 };
 
 static int page_size;
+static int path_mtu;
 
 struct pingpong_context {
        struct ibv_context      *context;
@@ -94,7 +95,7 @@
 {
        struct ibv_qp_attr attr = {
                .qp_state               = IBV_QPS_RTR,
-               .path_mtu               = IBV_MTU_1024,
+               .path_mtu               = path_mtu,
                .dest_qp_num            = dest->qpn,
                .rq_psn                 = dest->psn,
                .ah_attr                = {
@@ -428,6 +429,7 @@
        printf("  -d, --ib-dev=<dev>     use IB device <dev> (default first 
device found)\n");
        printf("  -i, --ib-port=<port>   use port <port> of IB device (default 
1)\n");
        printf("  -s, --size=<size>      size of message to exchange (default 
4096)\n");
+       printf("  -m, --mtu=<size>       path MTU (default 1024)\n");
        printf("  -r, --rx-depth=<dep>   number of receives to post at a time 
(default 500)\n");
        printf("  -n, --iters=<iters>    number of exchanges (default 1000)\n");
        printf("  -e, --events           sleep on CQ events (default poll)\n");
@@ -446,6 +448,7 @@
        int                      port = 18515;
        int                      ib_port = 1;
        int                      size = 4096;
+       int                      mtu = 1024;
        int                      rx_depth = 500;
        int                      iters = 1000;
        int                      use_event = 0;
@@ -462,13 +465,14 @@
                        { .name = "ib-dev",   .has_arg = 1, .val = 'd' },
                        { .name = "ib-port",  .has_arg = 1, .val = 'i' },
                        { .name = "size",     .has_arg = 1, .val = 's' },
+                       { .name = "mtu",      .has_arg = 1, .val = 'm' },
                        { .name = "rx-depth", .has_arg = 1, .val = 'r' },
                        { .name = "iters",    .has_arg = 1, .val = 'n' },
                        { .name = "events",   .has_arg = 0, .val = 'e' },
                        { 0 }
                };
 
-               c = getopt_long(argc, argv, "p:d:i:s:r:n:e", long_options, 
NULL);
+               c = getopt_long(argc, argv, "p:d:i:s:m:r:n:e", long_options, 
NULL);
                if (c == -1)
                        break;
 
@@ -497,6 +501,10 @@
                        size = strtol(optarg, NULL, 0);
                        break;
 
+               case 'm':
+                       mtu = strtol(optarg, NULL, 0);
+                       break;
+
                case 'r':
                        rx_depth = strtol(optarg, NULL, 0);
                        break;
@@ -522,6 +530,32 @@
                return 1;
        }
 
+       switch (mtu) {
+       case 256:
+               path_mtu = IBV_MTU_256;
+               break;
+
+       case 512:
+               path_mtu = IBV_MTU_512;
+               break;
+
+       case 1024:
+               path_mtu = IBV_MTU_1024;
+               break;
+
+       case 2048:
+               path_mtu = IBV_MTU_2048;
+               break;
+
+       case 4096:
+               path_mtu = IBV_MTU_4096;
+               break;
+
+       default:
+               usage(argv[0]);
+               return 1;
+       }
+
        page_size = sysconf(_SC_PAGESIZE);
 
        dev_list = ibv_get_device_list(NULL);
Index: libibverbs/examples/srq_pingpong.c
===================================================================
--- libibverbs/examples/srq_pingpong.c  (revision 5065)
+++ libibverbs/examples/srq_pingpong.c  (working copy)
@@ -61,6 +61,7 @@
 };
 
 static int page_size;
+static int path_mtu;
 
 struct pingpong_context {
        struct ibv_context      *context;
@@ -102,7 +103,7 @@
        for (i = 0; i < ctx->num_qp; ++i) {
                struct ibv_qp_attr attr = {
                        .qp_state               = IBV_QPS_RTR,
-                       .path_mtu               = IBV_MTU_1024,
+                       .path_mtu               = path_mtu,
                        .dest_qp_num            = dest[i].qpn,
                        .rq_psn                 = dest[i].psn,
                        .max_dest_rd_atomic     = 1,
@@ -501,6 +502,7 @@
        printf("  -d, --ib-dev=<dev>     use IB device <dev> (default first 
device found)\n");
        printf("  -i, --ib-port=<port>   use port <port> of IB device (default 
1)\n");
        printf("  -s, --size=<size>      size of message to exchange (default 
4096)\n");
+       printf("  -m, --mtu=<size>       path MTU (default 1024)\n");
        printf("  -q, --num-qp=<num>     number of QPs to use (default 16)\n");
        printf("  -r, --rx-depth=<dep>   number of receives to post at a time 
(default 500)\n");
        printf("  -n, --iters=<iters>    number of exchanges per QP(default 
1000)\n");
@@ -521,6 +523,7 @@
        int                      port = 18515;
        int                      ib_port = 1;
        int                      size = 4096;
+       int                      mtu = 1024;
        int                      num_qp = 16;
        int                      rx_depth = 500;
        int                      iters = 1000;
@@ -540,6 +543,7 @@
                        { .name = "ib-dev",   .has_arg = 1, .val = 'd' },
                        { .name = "ib-port",  .has_arg = 1, .val = 'i' },
                        { .name = "size",     .has_arg = 1, .val = 's' },
+                       { .name = "mtu",      .has_arg = 1, .val = 'm' },
                        { .name = "num-qp",   .has_arg = 1, .val = 'q' },
                        { .name = "rx-depth", .has_arg = 1, .val = 'r' },
                        { .name = "iters",    .has_arg = 1, .val = 'n' },
@@ -547,7 +551,7 @@
                        { 0 }
                };
 
-               c = getopt_long(argc, argv, "p:d:i:s:q:r:n:e", long_options, 
NULL);
+               c = getopt_long(argc, argv, "p:d:i:s:m:q:r:n:e", long_options, 
NULL);
                if (c == -1)
                        break;
 
@@ -576,6 +580,10 @@
                        size = strtol(optarg, NULL, 0);
                        break;
 
+               case 'm':
+                       mtu = strtol(optarg, NULL, 0);
+                       break;
+
                case 'q':
                        num_qp = strtol(optarg, NULL, 0);
                        break;
@@ -605,6 +613,32 @@
                return 1;
        }
 
+       switch (mtu) {
+       case 256:
+               path_mtu = IBV_MTU_256;
+               break;
+
+       case 512:
+               path_mtu = IBV_MTU_512;
+               break;
+
+       case 1024:
+               path_mtu = IBV_MTU_1024;
+               break;
+
+       case 2048:
+               path_mtu = IBV_MTU_2048;
+               break;
+
+       case 4096:
+               path_mtu = IBV_MTU_4096;
+               break;
+
+       default:
+               usage(argv[0]);
+               return 1;
+       }
+
        if (num_qp > rx_depth) {
                fprintf(stderr, "rx_depth %d is too small for %d QPs -- "
                        "must have at least one receive per QP.\n",

-- 
Ralph Campbell <[EMAIL PROTECTED]>

_______________________________________________
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to