#This patch was developed both in-house and from outside. We plan to submit it
#upstream, but do not yet have a target date for doing so
#
# HG changeset patch
# Parent 6728b98439b2997b8420c1b74055a7a118b2d9af
qperf solaris specific changes.
diff -r 6728b98439b2 src/qperf.c
--- a/src/qperf.c Wed Oct 14 12:54:37 2015 -0700
+++ b/src/qperf.c Fri Nov 13 07:33:20 2015 -0800
@@ -53,6 +53,16 @@
#include <sys/utsname.h>
#include "qperf.h"
+#if (defined(__SVR4) && defined(__sun))
+#include <sys/filio.h>
+#include <limits.h> /* times() */
+#include <sys/types.h>
+#include <sys/processor.h>
+#include <sys/procset.h>
+#include <strings.h>
+#include <infiniband/ofa_solaris.h>
+
+#endif
/*
* Configurable parameters. If your change makes this version of qperf
@@ -165,6 +175,10 @@
char qperf[STRSIZE]; /* Qperf version */
} CONF;
+char *t_bits[] ={ "bits/sec", "Kb/sec", "Mb/sec", "Gb/sec", "Tb/sec" };
+int s_bits = cardof(t_bits);
+char *t_bytes[] ={ "bytes/sec", "KB/sec", "MB/sec", "GB/sec", "TB/sec" };
+int s_bytes = cardof(t_bytes);
/*
* Function prototypes.
@@ -177,7 +191,9 @@
static void calc_node(RESN *resn, STAT *stat);
static void calc_results(void);
static void client(TEST *test);
+#if !(defined(__SVR4) && defined(__sun))
static int cmpsub(char *s2, char *s1);
+#endif
static char *commify(char *data);
static void dec_req_data(REQ *host);
static void dec_req_version(REQ *host);
@@ -224,7 +240,9 @@
static void sig_alrm(int signo, siginfo_t *siginfo, void *ucontext);
static void sig_quit(int signo, siginfo_t *siginfo, void *ucontext);
static void sig_urg(int signo, siginfo_t *siginfo, void *ucontext);
-static char *skip_colon(char *s);
+#if !(defined(__SVR4) && defined(__sun))
+static char *skip_colon(char *s);
+#endif
static void start_test_timer(int seconds);
static long str_size(char *arg, char *str);
static void strncopy(char *d, char *s, int n);
@@ -257,9 +275,11 @@
static STAT IStat;
static int ListenFD;
static LOOP *Loops;
+#if !(defined(__SVR4) && defined(__sun))
static int ProcStatFD;
+#endif
static STAT RStat;
-static int ShowIndex;
+volatile static int ShowIndex = 0;
static SHOW ShowTable[256];
static int UnifyUnits;
static int UnifyNodes;
@@ -281,7 +301,7 @@
int ServerAddrLen;
int RemoteFD;
int Debug;
-volatile int Finished;
+volatile int Finished = 0;
/*
@@ -603,6 +623,9 @@
initialize();
set_signals();
do_args(&argv[1]);
+#if (defined(__SVR4) && defined(__sun))
+ solaris_fini();
+#endif
return 0;
}
@@ -619,14 +642,19 @@
for (i = 0; i < P_N; ++i)
if (ParInfo[i].index != i)
error(BUG, "initialize: ParInfo: out of order: %d", i);
+#if (defined(__SVR4) && defined(__sun))
+ solaris_init();
+#else
ProcStatFD = open("/proc/stat", 0);
if (ProcStatFD < 0)
error(SYS, "cannot open /proc/stat");
+#endif
IStat.no_cpus = sysconf(_SC_NPROCESSORS_ONLN);
IStat.no_ticks = sysconf(_SC_CLK_TCK);
}
+#if !(defined(__SVR4) && defined(__sun))
/*
* Look for a colon and skip past it and any spaces.
*/
@@ -645,12 +673,14 @@
s++;
return s;
}
+#endif
/*
* A case insensitive string compare. s2 must at least contain all of s1 but
* can be longer.
*/
+#if !(defined(__SVR4) && defined(__sun))
static int
cmpsub(char *s2, char *s1)
{
@@ -666,6 +696,7 @@
return 0;
}
}
+#endif
/*
@@ -1669,13 +1700,18 @@
{
char count[STRSIZE];
char speed[STRSIZE];
+ char cpu[BUFSIZE];
+ int cpus = 0;
+#if !(defined(__SVR4) && defined(__sun))
char buf[BUFSIZE];
- char cpu[BUFSIZE];
char mhz[BUFSIZE];
- int cpus = 0;
int mixed = 0;
FILE *fp = fopen("/proc/cpuinfo", "r");
-
+#else
+ sol_cpu_info_t *info;
+#endif
+
+#if !(defined(__SVR4) && defined(__sun))
if (!fp)
error(0, "cannot open /proc/cpuinfo");
cpu[0] = '\0';
@@ -1734,6 +1770,7 @@
/* CPU speed */
speed[0] = '\0';
+
if (!mixed) {
int n = strlen(cpu);
if (n < 3 || cpu[n-2] != 'H' || cpu[n-1] != 'z') {
@@ -1747,6 +1784,23 @@
}
}
}
+#else
+ cpu[0] = '\0';
+ speed[0] = '\0';
+
+ if ((cpus = sol_get_cpu_info(&info)) > 0 ) {
+ (void) strcpy(cpu, info[0].cpu_name);
+
+ if (info[0].cpu_mhz < 1000)
+ snprintf(speed, sizeof(speed), " %dMHz", info[0].cpu_mhz);
+ else
+ snprintf(speed, sizeof(speed), " %.1fGHz",
+ info[0].cpu_mhz/1000.0);
+ free(info);
+ } else {
+ return;
+ }
+#endif
/* Number of CPUs */
if (cpus == 1)
@@ -2297,6 +2351,7 @@
char *tab[] ={ "ns/GB", "us/GB", "ms/GB", "sec/GB" };
value *= 1E9;
+
if (!verbose(type, value))
return;
if (!UnifyUnits) {
@@ -2372,21 +2427,21 @@
view_band(int type, char *pref, char *name, double value)
{
int n, s;
- char **tab;
-
+ char **tab, **t;
+
+ n = s = 0;
if (!verbose(type, value))
return;
if (UseBitsPerSec) {
- static char *t[] ={ "bits/sec", "Kb/sec", "Mb/sec", "Gb/sec", "Tb/sec" };
- s = cardof(t);
+ t=&t_bits[0];
+ s = s_bits;
tab = t;
value *= 8;
} else {
- static char *t[] ={ "bytes/sec", "KB/sec", "MB/sec", "GB/sec", "TB/sec" };
- s = cardof(t);
+ t=&t_bytes[0];
+ s = s_bytes;
tab = t;
}
-
n = 0;
if (!UnifyUnits) {
while (value >= 1000 && n < s-1) {
@@ -2516,10 +2571,13 @@
static void
place_val(char *pref, char *name, char *unit, double value)
{
- char *data = qasprintf("%.0f", value);
- char *p = data;
+ char *data;
+ char *p;
int n = Precision;
+
+ data = qasprintf("%.0f", value);
+ p = data;
if (*p == '-')
++p;
while (isdigit(*p++))
@@ -2571,6 +2629,7 @@
for (i = 0; i < ShowIndex; ++i) {
int n;
SHOW *show = &ShowTable[i];
+
n = (show->pref ? strlen(show->pref) : 0) + strlen(show->name);
if (n > nameLen)
nameLen = n;
@@ -2616,14 +2675,20 @@
static void
set_affinity(void)
{
+#if !(defined(__SVR4) && defined(__sun))
cpu_set_t set;
+#endif
int a = Req.affinity;
if (!a)
return;
+#if defined(__SVR4) && defined(__sun)
+ if (processor_bind(P_LWPID, P_MYID, a - 1, NULL) != 0)
+#else
CPU_ZERO(&set);
CPU_SET(a-1, &set);
if (sched_setaffinity(0, sizeof(set), &set) < 0)
+#endif
error(SYS, "cannot set processor affinity (cpu %d)", a-1);
}
@@ -2772,6 +2837,33 @@
/*
* Get various temporal parameters.
*/
+#if (defined(__SVR4) && defined(__sun))
+
+#define NSEC_TO_TICK(v) (v * sysconf(_SC_CLK_TCK)/1000000000)
+
+static void
+get_times(CLOCK timex[T_N])
+{
+ struct tms tms;
+ sol_cpu_stats_t stats;
+
+ timex[T_REAL] = times(&tms);
+
+ if ((sol_get_cpu_stats(&stats)) < 0)
+ return;
+
+ timex[T_USER] = stats.t_user;
+ timex[T_NICE] = 0;
+ timex[T_KERNEL] = stats.t_kernel;
+ timex[T_IDLE] = stats.t_idle;
+ timex[T_IOWAIT] = stats.t_iowait;
+ timex[T_IRQ] = NSEC_TO_TICK(stats.t_intr); /* NSEC_TO_TICK */
+ timex[T_SOFTIRQ] = 0;
+ timex[T_STEAL] = 0;
+}
+
+#else
+
static void
get_times(CLOCK timex[T_N])
{
@@ -2803,6 +2895,7 @@
while (n < T_N)
timex[n++] = 0;
}
+#endif
/*
diff -r 6728b98439b2 src/qperf.h
--- a/src/qperf.h Wed Oct 14 12:54:37 2015 -0700
+++ b/src/qperf.h Fri Nov 13 07:33:20 2015 -0800
@@ -193,6 +193,7 @@
uint32_t no_cpus; /* Number of processors */
uint32_t no_ticks; /* Ticks per second */
uint32_t max_cqes; /* Maximum CQ entries */
+ __attribute__ ((aligned (8))) /* align with 32-bit & 64-bit binary */
CLOCK time_s[T_N]; /* Start times */
CLOCK time_e[T_N]; /* End times */
USTAT s; /* Send statistics */
diff -r 6728b98439b2 src/rdma.c
--- a/src/rdma.c Wed Oct 14 12:54:37 2015 -0700
+++ b/src/rdma.c Fri Nov 13 07:33:20 2015 -0800
@@ -37,7 +37,11 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#if (defined(__SVR4) && defined(__sun))
+#include <strings.h>
+#else
#include <string.h>
+#endif
#include <unistd.h>
#include <netinet/in.h>
#include <rdma/rdma_cma.h>
@@ -110,7 +114,8 @@
uint32_t srqn; /* Shared queue number */
uint32_t rkey; /* Remote key */
uint32_t alt_lid; /* Alternate Path Local LID */
- uint32_t rd_atomic; /* Number of read/atomics supported */
+ uint32_t rd_atomic /* Number of read/atomics supported */
+ __attribute__ ((aligned (8))); /* align struct size to 64-bit binary */
} NODE;
@@ -566,11 +571,15 @@
void
run_client_uc_bi_bw(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
par_use(L_ACCESS_RECV);
par_use(R_ACCESS_RECV);
rd_params(IBV_QPT_UC, K64, 1, 0);
rd_bi_bw(IBV_QPT_UC);
show_results(BANDWIDTH_SR);
+#endif
}
@@ -580,7 +589,11 @@
void
run_server_uc_bi_bw(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
rd_bi_bw(IBV_QPT_UC);
+#endif
}
@@ -590,6 +603,9 @@
void
run_client_uc_bw(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
par_use(L_ACCESS_RECV);
par_use(R_ACCESS_RECV);
par_use(L_NO_MSGS);
@@ -597,6 +613,7 @@
rd_params(IBV_QPT_UC, K64, 1, 0);
rd_client_bw(IBV_QPT_UC);
show_results(BANDWIDTH_SR);
+#endif
}
@@ -606,7 +623,11 @@
void
run_server_uc_bw(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
rd_server_def(IBV_QPT_UC);
+#endif
}
@@ -616,8 +637,12 @@
void
run_client_uc_lat(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
rd_params(IBV_QPT_UC, 1, 1, 0);
rd_pp_lat(IBV_QPT_UC, IO_SR);
+#endif
}
@@ -627,7 +652,11 @@
void
run_server_uc_lat(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
rd_pp_lat(IBV_QPT_UC, IO_SR);
+#endif
}
@@ -637,9 +666,13 @@
void
run_client_uc_rdma_write_bw(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
rd_params(IBV_QPT_UC, K64, 1, 0);
rd_client_rdma_bw(IBV_QPT_UC, IBV_WR_RDMA_WRITE_WITH_IMM);
show_results(BANDWIDTH_SR);
+#endif
}
@@ -649,7 +682,11 @@
void
run_server_uc_rdma_write_bw(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
rd_server_def(IBV_QPT_UC);
+#endif
}
@@ -659,8 +696,12 @@
void
run_client_uc_rdma_write_lat(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
rd_params(IBV_QPT_UC, 1, 1, 0);
rd_pp_lat(IBV_QPT_UC, IO_RDMA);
+#endif
}
@@ -670,7 +711,11 @@
void
run_server_uc_rdma_write_lat(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
rd_pp_lat(IBV_QPT_UC, IO_RDMA);
+#endif
}
@@ -680,9 +725,13 @@
void
run_client_uc_rdma_write_poll_lat(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
rd_params(IBV_QPT_UC, 1, 1, 0);
rd_rdma_write_poll_lat(IBV_QPT_UC);
show_results(LATENCY);
+#endif
}
@@ -692,7 +741,11 @@
void
run_server_uc_rdma_write_poll_lat(void)
{
+#if (defined(__SVR4) && defined(__sun))
+ error(RET, "UC Not Supported");
+#else
rd_rdma_write_poll_lat(IBV_QPT_UC);
+#endif
}
@@ -1874,10 +1927,16 @@
error(0, "rdma_bind_addr failed");
port = ntohs(rdma_get_src_port(cm->id));
encode_uint32(&port, port);
+#if !(defined(__SVR4) && defined(__sun))
send_mesg(&port, sizeof(port), "RDMA CM TCP IPv4 server port");
+#endif
if (rdma_listen(cm->id, 0) != 0)
error(0, "rdma_listen failed");
+
+#if (defined(__SVR4) && defined(__sun))
+ send_mesg(&port, sizeof(port), "RDMA CM TCP IPv4 server port");
+#endif
cm_expect_event(dev, RDMA_CM_EVENT_CONNECT_REQUEST);
rd_create_qp(dev, cm->event->id->verbs, cm->event->id);
diff -r 6728b98439b2 src/rds.c
--- a/src/rds.c Wed Oct 14 12:54:37 2015 -0700
+++ b/src/rds.c Fri Nov 13 07:33:20 2015 -0800
@@ -45,6 +45,9 @@
#include <netinet/in.h>
#include "qperf.h"
+#if (defined(__SVR4) && defined(__sun))
+#include <sys/rds.h>
+#else
/*
* Parameters.
@@ -90,6 +93,7 @@
#define AF_RDS get_af_rds()
#endif
+#endif
/*
* Function prototypes.
@@ -338,13 +342,19 @@
if (bind(lfd, (SA *)&laddr, sizeof(laddr)) < 0)
error(SYS, "bind INET failed");
+ /*
+ * OFED generic fix - listen() should be setup first before sending server
+ * port message to the client. There is a window that the client's
+ * connect() would fail after receiving the "server port" message if the
+ * server hasn't completed the listen().
+ */
+ if (listen(lfd, 1) < 0)
+ error(SYS, "listen failed");
+
port = get_socket_port(lfd);
encode_uint32(&port, port);
send_mesg(&port, sizeof(port), "TCP IPv4 server port");
- if (listen(lfd, 1) < 0)
- error(SYS, "listen failed");
-
rlen = sizeof(raddr);
fd = accept(lfd, (SA *)&raddr, &rlen);
if (fd < 0)
@@ -392,7 +402,11 @@
SS sockaddr;
socklen_t socklen;
+#if (defined(__SVR4) && defined(__sun))
+ sockfd = socket(PF_RDS, SOCK_SEQPACKET, 0);
+#else
sockfd = socket(AF_RDS, SOCK_SEQPACKET, 0);
+#endif
if (sockfd < 0)
error(SYS, "socket failed");
setsockopt_one(sockfd, SO_REUSEADDR);
@@ -413,7 +427,11 @@
struct sockaddr_in *sap = (struct sockaddr_in *)addr;
memset(sap, 0, sizeof(*sap));
+#if (defined(__SVR4) && defined(__sun))
+ sap->sin_family = AF_INET_OFFLOAD;
+#else
sap->sin_family = AF_INET;
+#endif
inet_pton(AF_INET, host, &sap->sin_addr.s_addr);
sap->sin_port = htons(port);
*len = sizeof(struct sockaddr_in);
@@ -471,6 +489,14 @@
if (getsockname(fd, (SA *)&sa, &salen) < 0)
error(SYS, "getsockname failed");
+#if (defined(__SVR4) && defined(__sun))
+ /*
+ * getnameinfo() does not support AF_INET_OFFLOAD, so
+ * use ss_family as AF_INET to get port info.
+ */
+ if (sa.ss_family == AF_INET_OFFLOAD)
+ sa.ss_family = AF_INET;
+#endif
qgetnameinfo((SA *)&sa, salen, 0, 0, p, sizeof(p), NI_NUMERICSERV);
port = atoi(p);
if (!port)
diff -r 6728b98439b2 src/socket.c
--- a/src/socket.c Wed Oct 14 12:54:37 2015 -0700
+++ b/src/socket.c Fri Nov 13 07:33:20 2015 -0800
@@ -44,7 +44,9 @@
/*
* Parameters.
*/
+#if !(defined(__SVR4) && defined(__sun))
#define AF_INET_SDP 27 /* Family for SDP */
+#endif
/*
@@ -707,10 +709,14 @@
ailist = getaddrinfo_port(serverflag ? 0 : ServerName, port, &hints);
for (aip = ailist; aip; aip = aip->ai_next) {
if (kind == K_SDP) {
+#if (defined(__SVR4) && defined(__sun))
+ aip->ai_protocol = PROTO_SDP;
+#else
if (aip->ai_family == AF_INET || aip->ai_family == AF_INET6)
aip->ai_family = AF_INET_SDP;
else
aip->ai_family = 0;
+#endif
} else if (kind == K_SCTP) {
if (aip->ai_protocol == IPPROTO_TCP)
aip->ai_protocol = IPPROTO_SCTP;
diff -r 6728b98439b2 src/support.c
--- a/src/support.c Wed Oct 14 12:54:37 2015 -0700
+++ b/src/support.c Fri Nov 13 07:33:20 2015 -0800
@@ -215,14 +215,14 @@
volatile uint64_t *p64 = p;
while (n >= sizeof(*p64)) {
- (void) *p64++;
n -= sizeof(*p64);
+ *p64++;
}
if (n) {
volatile uint8_t *p8 = (uint8_t *)p64;
while (n >= sizeof(*p8)) {
- (void) *p8++;
n -= sizeof(*p8);
+ *p8++;
}
}
}