components/open-fabrics/qperf/patches/base.patch
changeset 369 cc8c00719da9
child 715 eed3ed08f692
child 2291 b0bb4aa104b6
equal deleted inserted replaced
368:9a01d3a61f01 369:cc8c00719da9
       
     1 diff -r -u /tmp/730054/qperf-0.4.6/src/socket.c qperf-0.4.6/src/socket.c
       
     2 --- /tmp/730054/qperf-0.4.6/src/socket.c	Mon Aug 31 00:00:40 2009
       
     3 +++ qperf-0.4.6/src/socket.c	Mon Nov  8 11:10:20 2010
       
     4 @@ -44,7 +44,9 @@
       
     5  /*
       
     6   * Parameters.
       
     7   */
       
     8 +#if !(defined(__SVR4) && defined(__sun))
       
     9  #define AF_INET_SDP 27                  /* Family for SDP */
       
    10 +#endif
       
    11  
       
    12  
       
    13  /*
       
    14 @@ -707,10 +709,16 @@
       
    15      ailist = getaddrinfo_port(serverflag ? 0 : ServerName, port, &hints);
       
    16      for (aip = ailist; aip; aip = aip->ai_next) {
       
    17          if (kind == K_SDP) {
       
    18 +#if (defined(__SVR4) && defined(__sun))
       
    19 +		aip->ai_family = AF_INET;
       
    20 +		aip->ai_socktype = SOCK_STREAM;
       
    21 +		aip->ai_protocol = PROTO_SDP;
       
    22 +#else
       
    23              if (aip->ai_family == AF_INET || aip->ai_family == AF_INET6)
       
    24                  aip->ai_family = AF_INET_SDP;
       
    25              else
       
    26                  aip->ai_family = 0;
       
    27 +#endif
       
    28          } else if (kind == K_SCTP) {
       
    29              if (aip->ai_protocol == IPPROTO_TCP)
       
    30                  aip->ai_protocol = IPPROTO_SCTP;
       
    31 diff -r -u /tmp/730054/qperf-0.4.6/src/qperf.c qperf-0.4.6/src/qperf.c
       
    32 --- /tmp/730054/qperf-0.4.6/src/qperf.c	Mon Aug 31 00:00:40 2009
       
    33 +++ qperf-0.4.6/src/qperf.c	Mon Nov  8 11:10:17 2010
       
    34 @@ -53,7 +53,19 @@
       
    35  #include <sys/utsname.h>
       
    36  #include "qperf.h"
       
    37  
       
    38 +#if (defined(__SVR4) && defined(__sun))
       
    39 +#include <sys/filio.h>
       
    40 +#include <limits.h>	/* times() */
       
    41 +#include <kstat.h>	/* libkstat */
       
    42 +#include <sys/types.h>
       
    43 +#include <sys/processor.h>
       
    44 +#include <sys/procset.h>
       
    45 +#include <strings.h>
       
    46 +#include <infiniband/ofa_solaris.h>
       
    47  
       
    48 +static kstat_ctl_t	*kc = NULL;	/* libkstat cookie */
       
    49 +#endif
       
    50 +
       
    51  /*
       
    52   * Configurable parameters.  If your change makes this version of qperf
       
    53   * incompatible with previous versions (usually a change to the Req structure),
       
    54 @@ -224,7 +236,9 @@
       
    55  static void      sig_alrm(int signo, siginfo_t *siginfo, void *ucontext);
       
    56  static void      sig_quit(int signo, siginfo_t *siginfo, void *ucontext);
       
    57  static void      sig_urg(int signo, siginfo_t *siginfo, void *ucontext);
       
    58 -static char     *skip_colon(char *s);
       
    59 +#if !(defined(__SVR4) && defined(__sun))
       
    60 +static char    *skip_colon(char *s);
       
    61 +#endif
       
    62  static void      start_test_timer(int seconds);
       
    63  static long      str_size(char *arg, char *str);
       
    64  static void      strncopy(char *d, char *s, int n);
       
    65 @@ -257,7 +271,9 @@
       
    66  static STAT     IStat;
       
    67  static int      ListenFD;
       
    68  static LOOP    *Loops;
       
    69 +#if !(defined(__SVR4) && defined(__sun))
       
    70  static int      ProcStatFD;
       
    71 +#endif
       
    72  static STAT     RStat;
       
    73  static int      ShowIndex;
       
    74  static SHOW     ShowTable[256];
       
    75 @@ -601,6 +617,9 @@
       
    76      initialize();
       
    77      set_signals();
       
    78      do_args(&argv[1]);
       
    79 +#if (defined(__SVR4) && defined(__sun))
       
    80 +    (void) kstat_close(kc);
       
    81 +#endif
       
    82      return 0;
       
    83  }
       
    84  
       
    85 @@ -617,14 +636,24 @@
       
    86      for (i = 0; i < P_N; ++i)
       
    87          if (ParInfo[i].index != i)
       
    88              error(BUG, "initialize: ParInfo: out of order: %d", i);
       
    89 +#if (defined(__SVR4) && defined(__sun))
       
    90 +    while ((kc = kstat_open()) == NULL) {
       
    91 +	if (errno == EAGAIN)
       
    92 +	    (void) poll(NULL, 0, 200);
       
    93 +	else
       
    94 +	    error(SYS, "cannot open /dev/kstat");
       
    95 +    }
       
    96 +#else
       
    97      ProcStatFD = open("/proc/stat", 0);
       
    98      if (ProcStatFD < 0)
       
    99          error(SYS, "cannot open /proc/stat");
       
   100 +#endif
       
   101      IStat.no_cpus = sysconf(_SC_NPROCESSORS_ONLN);
       
   102      IStat.no_ticks = sysconf(_SC_CLK_TCK);
       
   103  }
       
   104  
       
   105  
       
   106 +#if !(defined(__SVR4) && defined(__sun))
       
   107  /*
       
   108   * Look for a colon and skip past it and any spaces.
       
   109   */
       
   110 @@ -643,6 +672,7 @@
       
   111          s++;
       
   112      return s;
       
   113  }
       
   114 +#endif
       
   115  
       
   116  
       
   117  /*
       
   118 @@ -1667,13 +1697,18 @@
       
   119  {
       
   120      char count[STRSIZE];
       
   121      char speed[STRSIZE];
       
   122 -    char buf[BUFSIZE];
       
   123      char cpu[BUFSIZE];
       
   124 -    char mhz[BUFSIZE];
       
   125      int cpus = 0;
       
   126 +#if !(defined(__SVR4) && defined(__sun))
       
   127 +    char buf[BUFSIZE];
       
   128 +    char mhz[BUFSIZE];
       
   129      int mixed = 0;
       
   130      FILE *fp = fopen("/proc/cpuinfo", "r");
       
   131 +#else
       
   132 +   sol_cpu_info_t	info;
       
   133 +#endif
       
   134  
       
   135 +#if !(defined(__SVR4) && defined(__sun))
       
   136      if (!fp)
       
   137          error(0, "cannot open /proc/cpuinfo");
       
   138      cpu[0] = '\0';
       
   139 @@ -1732,6 +1767,7 @@
       
   140  
       
   141      /* CPU speed */
       
   142      speed[0] = '\0';
       
   143 +
       
   144      if (!mixed) {
       
   145          int n = strlen(cpu);
       
   146          if (n < 3 || cpu[n-2] != 'H' || cpu[n-1] != 'z') {
       
   147 @@ -1745,7 +1781,23 @@
       
   148              }
       
   149          }
       
   150      }
       
   151 +#else
       
   152 +    cpu[0] = '\0';
       
   153 +    speed[0] = '\0';
       
   154  
       
   155 +    if (!sol_get_cpu_info(&info)) {
       
   156 +	(void) strcpy(cpu, info.cpu_name);
       
   157 +	cpus = info.cpu_num;
       
   158 +
       
   159 +	if (info.cpu_mhz < 1000)
       
   160 +		snprintf(speed, sizeof(speed), " %dMHz", info.cpu_mhz);
       
   161 +	else
       
   162 +		snprintf(speed, sizeof(speed), " %.1fGHz", info.cpu_mhz/1000.0);
       
   163 +    } else {
       
   164 +	return;
       
   165 +    }
       
   166 +#endif
       
   167 +
       
   168      /* Number of CPUs */
       
   169      if (cpus == 1)
       
   170          count[0] = '\0';
       
   171 @@ -2615,14 +2667,22 @@
       
   172  static void
       
   173  set_affinity(void)
       
   174  {
       
   175 +#if !(defined(__SVR4) && defined(__sun))
       
   176      cpu_set_t set;
       
   177 +#endif
       
   178      int a = Req.affinity;
       
   179  
       
   180      if (!a)
       
   181          return;
       
   182 +
       
   183 +#if defined(__SVR4) && defined(__sun)
       
   184 +    if (processor_bind(P_LWPID, P_MYID, a-1, NULL) != 0)
       
   185 +#else
       
   186 +
       
   187      CPU_ZERO(&set);
       
   188      CPU_SET(a-1, &set);
       
   189      if (sched_setaffinity(0, sizeof(set), &set) < 0)
       
   190 +#endif
       
   191          error(SYS, "cannot set processor affinity (cpu %d)", a-1);
       
   192  }
       
   193  
       
   194 @@ -2771,9 +2831,74 @@
       
   195  /*
       
   196   * Get various temporal parameters.
       
   197   */
       
   198 +#if (defined(__SVR4) && defined(__sun))
       
   199 +
       
   200 +#define	NSEC_TO_TICK(v)		(v * sysconf(_SC_CLK_TCK)/1000000000)
       
   201 +
       
   202  static void
       
   203  get_times(CLOCK timex[T_N])
       
   204  {
       
   205 +	struct tms tms;
       
   206 +	size_t	i, nr_cpus;
       
   207 +	kstat_t	*ksp;
       
   208 +	kstat_named_t	*knp;
       
   209 +	uint64_t	t_user = 0, t_kernel = 0, t_idle = 0;
       
   210 +	uint64_t	t_irq = 0, t_iowait = 0;
       
   211 +
       
   212 +	timex[T_REAL] = times(&tms);
       
   213 +
       
   214 +	nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
       
   215 +
       
   216 +	/* Aggregate the value of all CPUs */
       
   217 +	for (i = 0; i < nr_cpus; i++) {
       
   218 +		ksp = kstat_lookup(kc, "cpu", i, "sys");
       
   219 +		if (ksp == NULL)
       
   220 +	        	return;
       
   221 +
       
   222 +		if (kstat_read(kc, ksp, NULL) == -1)
       
   223 +	        	return;
       
   224 +
       
   225 +		knp = (kstat_named_t *)kstat_data_lookup(ksp, "cpu_ticks_user");
       
   226 +		if (knp == NULL)
       
   227 +			return;
       
   228 +		t_user += knp->value.ui64;
       
   229 +
       
   230 +		knp = (kstat_named_t *)kstat_data_lookup(ksp,
       
   231 +		    "cpu_ticks_kernel");
       
   232 +		if (knp == NULL)
       
   233 +			return;
       
   234 +		t_kernel += knp->value.ui64;
       
   235 +
       
   236 +		knp = (kstat_named_t *)kstat_data_lookup(ksp, "cpu_ticks_idle");
       
   237 +		if (knp == NULL)
       
   238 +			return;
       
   239 +		t_idle += knp->value.ui64;
       
   240 +
       
   241 +		knp = (kstat_named_t *)kstat_data_lookup(ksp, "cpu_ticks_wait");
       
   242 +		if (knp == NULL)
       
   243 +			return;
       
   244 +		t_iowait += knp->value.ui64;
       
   245 +
       
   246 +		knp = (kstat_named_t *)kstat_data_lookup(ksp, "cpu_nsec_intr");
       
   247 +		if (knp == NULL)
       
   248 +			return;
       
   249 +		t_irq += knp->value.ui64;	/* This is in NSEC */
       
   250 +	}
       
   251 +	timex[T_USER] = t_user;
       
   252 +	timex[T_NICE] = 0;
       
   253 +	timex[T_KERNEL] = t_kernel;
       
   254 +	timex[T_IDLE] = t_idle;
       
   255 +	timex[T_IOWAIT] = t_iowait;
       
   256 +	timex[T_IRQ] = NSEC_TO_TICK(t_irq);	 /* NSEC_TO_TICK */
       
   257 +	timex[T_SOFTIRQ] = 0;
       
   258 +	timex[T_STEAL] = 0;
       
   259 +}
       
   260 +
       
   261 +#else
       
   262 +
       
   263 +static void
       
   264 +get_times(CLOCK timex[T_N])
       
   265 +{
       
   266      int n;
       
   267      char *p;
       
   268      char buf[BUFSIZE];
       
   269 @@ -2802,6 +2927,7 @@
       
   270      while (n < T_N)
       
   271          timex[n++] = 0;
       
   272  }
       
   273 +#endif
       
   274  
       
   275  
       
   276  /*
       
   277 diff -r -u /tmp/730054/qperf-0.4.6/src/rdma.c qperf-0.4.6/src/rdma.c
       
   278 --- /tmp/730054/qperf-0.4.6/src/rdma.c	Mon Aug 31 00:00:40 2009
       
   279 +++ qperf-0.4.6/src/rdma.c	Mon Nov  8 11:10:19 2010
       
   280 @@ -37,7 +37,11 @@
       
   281  #include <errno.h>
       
   282  #include <stdio.h>
       
   283  #include <stdlib.h>
       
   284 +#if (defined(__SVR4) && defined(__sun))
       
   285 +#include <strings.h>
       
   286 +#else
       
   287  #include <string.h>
       
   288 +#endif
       
   289  #include <unistd.h>
       
   290  #include <netinet/in.h>
       
   291  #include <rdma/rdma_cma.h>
       
   292 @@ -566,11 +570,15 @@
       
   293  void
       
   294  run_client_uc_bi_bw(void)
       
   295  {
       
   296 +#if (defined(__SVR4) && defined(__sun))
       
   297 +    error(RET, "UC Not Supported");
       
   298 +#else
       
   299      par_use(L_ACCESS_RECV);
       
   300      par_use(R_ACCESS_RECV);
       
   301      rd_params(IBV_QPT_UC, K64, 1, 0);
       
   302      rd_bi_bw(IBV_QPT_UC);
       
   303      show_results(BANDWIDTH_SR);
       
   304 +#endif
       
   305  }
       
   306  
       
   307  
       
   308 @@ -580,7 +588,11 @@
       
   309  void
       
   310  run_server_uc_bi_bw(void)
       
   311  {
       
   312 +#if (defined(__SVR4) && defined(__sun))
       
   313 +    error(RET, "UC Not Supported");
       
   314 +#else
       
   315      rd_bi_bw(IBV_QPT_UC);
       
   316 +#endif
       
   317  }
       
   318  
       
   319  
       
   320 @@ -590,6 +602,9 @@
       
   321  void
       
   322  run_client_uc_bw(void)
       
   323  {
       
   324 +#if (defined(__SVR4) && defined(__sun))
       
   325 +    error(RET, "UC Not Supported");
       
   326 +#else
       
   327      par_use(L_ACCESS_RECV);
       
   328      par_use(R_ACCESS_RECV);
       
   329      par_use(L_NO_MSGS);
       
   330 @@ -597,6 +612,7 @@
       
   331      rd_params(IBV_QPT_UC, K64, 1, 0);
       
   332      rd_client_bw(IBV_QPT_UC);
       
   333      show_results(BANDWIDTH_SR);
       
   334 +#endif
       
   335  }
       
   336  
       
   337  
       
   338 @@ -606,7 +622,11 @@
       
   339  void
       
   340  run_server_uc_bw(void)
       
   341  {
       
   342 +#if (defined(__SVR4) && defined(__sun))
       
   343 +    error(RET, "UC Not Supported");
       
   344 +#else
       
   345      rd_server_def(IBV_QPT_UC);
       
   346 +#endif
       
   347  }
       
   348  
       
   349  
       
   350 @@ -616,8 +636,12 @@
       
   351  void
       
   352  run_client_uc_lat(void)
       
   353  {
       
   354 +#if (defined(__SVR4) && defined(__sun))
       
   355 +    error(RET, "UC Not Supported");
       
   356 +#else
       
   357      rd_params(IBV_QPT_UC, 1, 1, 0);
       
   358      rd_pp_lat(IBV_QPT_UC, IO_SR);
       
   359 +#endif
       
   360  }
       
   361  
       
   362  
       
   363 @@ -627,7 +651,11 @@
       
   364  void
       
   365  run_server_uc_lat(void)
       
   366  {
       
   367 +#if (defined(__SVR4) && defined(__sun))
       
   368 +    error(RET, "UC Not Supported");
       
   369 +#else
       
   370      rd_pp_lat(IBV_QPT_UC, IO_SR);
       
   371 +#endif
       
   372  }
       
   373  
       
   374  
       
   375 @@ -637,9 +665,13 @@
       
   376  void
       
   377  run_client_uc_rdma_write_bw(void)
       
   378  {
       
   379 +#if (defined(__SVR4) && defined(__sun))
       
   380 +    error(RET, "UC Not Supported");
       
   381 +#else
       
   382      rd_params(IBV_QPT_UC, K64, 1, 0);
       
   383      rd_client_rdma_bw(IBV_QPT_UC, IBV_WR_RDMA_WRITE_WITH_IMM);
       
   384      show_results(BANDWIDTH_SR);
       
   385 +#endif
       
   386  }
       
   387  
       
   388  
       
   389 @@ -649,7 +681,11 @@
       
   390  void
       
   391  run_server_uc_rdma_write_bw(void)
       
   392  {
       
   393 +#if (defined(__SVR4) && defined(__sun))
       
   394 +    error(RET, "UC Not Supported");
       
   395 +#else
       
   396      rd_server_def(IBV_QPT_UC);
       
   397 +#endif
       
   398  }
       
   399  
       
   400  
       
   401 @@ -659,8 +695,12 @@
       
   402  void
       
   403  run_client_uc_rdma_write_lat(void)
       
   404  {
       
   405 +#if (defined(__SVR4) && defined(__sun))
       
   406 +    error(RET, "UC Not Supported");
       
   407 +#else
       
   408      rd_params(IBV_QPT_UC, 1, 1, 0);
       
   409      rd_pp_lat(IBV_QPT_UC, IO_RDMA);
       
   410 +#endif
       
   411  }
       
   412  
       
   413  
       
   414 @@ -670,7 +710,11 @@
       
   415  void
       
   416  run_server_uc_rdma_write_lat(void)
       
   417  {
       
   418 +#if (defined(__SVR4) && defined(__sun))
       
   419 +    error(RET, "UC Not Supported");
       
   420 +#else
       
   421      rd_pp_lat(IBV_QPT_UC, IO_RDMA);
       
   422 +#endif
       
   423  }
       
   424  
       
   425  
       
   426 @@ -680,9 +724,13 @@
       
   427  void
       
   428  run_client_uc_rdma_write_poll_lat(void)
       
   429  {
       
   430 +#if (defined(__SVR4) && defined(__sun))
       
   431 +    error(RET, "UC Not Supported");
       
   432 +#else
       
   433      rd_params(IBV_QPT_UC, 1, 1, 0);
       
   434      rd_rdma_write_poll_lat(IBV_QPT_UC);
       
   435      show_results(LATENCY);
       
   436 +#endif
       
   437  }
       
   438  
       
   439  
       
   440 @@ -692,7 +740,11 @@
       
   441  void
       
   442  run_server_uc_rdma_write_poll_lat(void)
       
   443  {
       
   444 +#if (defined(__SVR4) && defined(__sun))
       
   445 +    error(RET, "UC Not Supported");
       
   446 +#else
       
   447      rd_rdma_write_poll_lat(IBV_QPT_UC);
       
   448 +#endif
       
   449  }
       
   450  
       
   451  
       
   452 diff -r -u /tmp/730054/qperf-0.4.6/src/rds.c qperf-0.4.6/src/rds.c
       
   453 --- /tmp/730054/qperf-0.4.6/src/rds.c	Mon Aug 31 00:00:40 2009
       
   454 +++ qperf-0.4.6/src/rds.c	Mon Nov  8 11:10:19 2010
       
   455 @@ -44,6 +44,9 @@
       
   456  #include <netinet/in.h>
       
   457  #include "qperf.h"
       
   458  
       
   459 +#if (defined(__SVR4) && defined(__sun))
       
   460 +#include <sys/rds.h>
       
   461 +#else
       
   462  
       
   463  /*
       
   464   * Parameters.
       
   465 @@ -50,6 +53,7 @@
       
   466   */
       
   467  #define AF_INET_RDS 28                  /* Family for RDS */
       
   468  
       
   469 +#endif
       
   470  
       
   471  /*
       
   472   * Function prototypes.
       
   473 @@ -352,7 +356,11 @@
       
   474      SS sockaddr;
       
   475      socklen_t socklen;
       
   476  
       
   477 +#if (defined(__SVR4) && defined(__sun))
       
   478 +    sockfd = socket(PF_RDS, SOCK_SEQPACKET, 0);
       
   479 +#else
       
   480      sockfd = socket(AF_INET_RDS, SOCK_SEQPACKET, 0);
       
   481 +#endif
       
   482      if (sockfd < 0)
       
   483          error(SYS, "socket failed");
       
   484      setsockopt_one(sockfd, SO_REUSEADDR);
       
   485 @@ -373,7 +381,11 @@
       
   486      struct sockaddr_in *sap = (struct sockaddr_in *)addr;
       
   487  
       
   488      memset(sap, 0, sizeof(*sap));
       
   489 +#if (defined(__SVR4) && defined(__sun))
       
   490 +    sap->sin_family = AF_INET_OFFLOAD;
       
   491 +#else
       
   492      sap->sin_family = AF_INET;
       
   493 +#endif
       
   494      inet_pton(AF_INET, host, &sap->sin_addr.s_addr);
       
   495      sap->sin_port = htons(port);
       
   496      *len = sizeof(struct sockaddr_in);
       
   497 @@ -431,6 +443,14 @@
       
   498  
       
   499      if (getsockname(fd, (SA *)&sa, &salen) < 0)
       
   500          error(SYS, "getsockname failed");
       
   501 +#if (defined(__SVR4) && defined(__sun))
       
   502 +    /*
       
   503 +     * getnameinfo() does not support AF_INET_OFFLOAD, so 
       
   504 +     * use ss_family as AF_INET to get port info.
       
   505 +     */ 
       
   506 +    if (sa.ss_family == AF_INET_OFFLOAD)
       
   507 +	sa.ss_family = AF_INET;
       
   508 +#endif
       
   509      qgetnameinfo((SA *)&sa, salen, 0, 0, p, sizeof(p), NI_NUMERICSERV);
       
   510      port = atoi(p);
       
   511      if (!port)