Allow ibping to build and run on both Linux and Windows.  Window
build files are maintained in the WinOF respository.  These changes
allow dropping the infiniband-diags into the WinOF build environment.

For portability, use complib to obtain time stamps.

Signed-off-by: Sean Hefty <[email protected]>
---
Converted another diag this afternoon.  I was able to build and execute this,
but apparently I don't have anything on my fabric that responds to the pings.

 infiniband-diags/src/ibping.c |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/infiniband-diags/src/ibping.c b/infiniband-diags/src/ibping.c
index 29c98c2..1994eba 100644
--- a/infiniband-diags/src/ibping.c
+++ b/infiniband-diags/src/ibping.c
@@ -41,24 +41,16 @@
 #include <string.h>
 #include <signal.h>
 #include <getopt.h>
-#include <sys/time.h>
 
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
+#include <complib/cl_timer.h>
 
 #include "ibdiag_common.h"
 
 static char host_and_domain[IB_VENDOR_RANGE2_DATA_SIZE];
 static char last_host[IB_VENDOR_RANGE2_DATA_SIZE];
 
-static uint64_t getcurrenttime(void)
-{
-        struct timeval tv;
-
-        gettimeofday(&tv, 0);
-        return (uint64_t)tv.tv_sec * 1000000 + tv.tv_usec;
-}
-
 static void
 get_host_and_domain(char *data, int sz)
 {
@@ -118,7 +110,7 @@ ibping(ib_portid_t *portid, int quiet)
 
        DEBUG("Ping..");
 
-       start = getcurrenttime();
+       start = cl_get_time_stamp();
 
        call.method = IB_MAD_METHOD_GET;
        call.mgmt_class = IB_VENDOR_OPENIB_PING_CLASS;
@@ -129,9 +121,9 @@ ibping(ib_portid_t *portid, int quiet)
        memset(&call.rmpp, 0, sizeof call.rmpp);
 
        if (!ib_vendor_call(data, portid, &call))
-               return ~0llu;
+               return ~0ull;
 
-       rtt = getcurrenttime() - start;
+       rtt = cl_get_time_stamp() - start;
 
        if (!last_host[0])
                memcpy(last_host, data, sizeof last_host);
@@ -149,7 +141,7 @@ static ib_portid_t portid = {0};
 
 void report(int sig)
 {
-       total_time = getcurrenttime() - start;
+       total_time = cl_get_time_stamp() - start;
 
        DEBUG("out due signal %d", sig);
 
@@ -203,7 +195,7 @@ int main(int argc, char **argv)
                { "flood", 'f', 0, NULL, "flood destination" },
                { "oui", 'o', 1, NULL, "use specified OUI number" },
                { "Server", 'S', 0, NULL, "start in server mode" },
-               { }
+               { 0 }
        };
        char usage_args[] = "<dest lid|guid>";
 
@@ -238,7 +230,7 @@ int main(int argc, char **argv)
        signal(SIGINT, report);
        signal(SIGTERM, report);
 
-       start = getcurrenttime();
+       start = cl_get_time_stamp();
 
        while (count-- > 0) {
                ntrans++;



_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

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

Reply via email to