From 8ab8f5379c9d3fc5faa3b5e1c6abbaf2c53a681b Mon Sep 17 00:00:00 2001 From: "Johann George (QLogic)" Date: Sun, 17 Feb 2008 15:37:52 -0800 Subject: [PATCH] More clean up and minor bug fixes --- README | 4 + configure.in | 4 +- qperf.spec | 2 +- src/help.txt | 149 +++++++------ src/qperf.c | 340 ++++++++++++++++------------- src/qperf.h | 9 +- src/rdma.c | 588 +++++++++++++++++++++++++-------------------------- 7 files changed, 580 insertions(+), 516 deletions(-) diff --git a/README b/README index 8748a0b..26bec3b 100644 --- a/README +++ b/README @@ -4,6 +4,10 @@ To build ./configure make +Changing version + * Change VER_MAJ, VER_MIN and VER_INC as appropriate in src/qperf.c + * Change version also in qperf.spec and configure.in + Notes * If the library ibverbs is not found, a version of qperf is built that does not support the RDMA tests. diff --git a/configure.in b/configure.in index b91fe05..dec9643 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ -AC_INIT(qperf, 0.3.0, general@lists.openfabrics.org) -AM_INIT_AUTOMAKE(qperf, 0.3.0) +AC_INIT(qperf, 0.4.0, general@lists.openfabrics.org) +AM_INIT_AUTOMAKE(qperf, 0.4.0) AC_PROG_CC AC_CHECK_LIB(ibverbs, ibv_open_device, RDMA=1) AM_CONDITIONAL(RDMA, test -n "$RDMA") diff --git a/qperf.spec b/qperf.spec index 39f9273..f9178f6 100644 --- a/qperf.spec +++ b/qperf.spec @@ -1,6 +1,6 @@ Name: qperf Summary: Measure socket and RDMA performance -Version: 0.3.0 +Version: 0.4.0 Release: 1 License: BSD 3-Clause, GPL v2 Group: Networking/Diagnostic diff --git a/src/help.txt b/src/help.txt index a338625..9b8bf30 100644 --- a/src/help.txt +++ b/src/help.txt @@ -117,30 +117,30 @@ Opts --flip OnOff (-f) Flip sender and receiver --help Topic (-h) Get more information on a topic --host Node (-H) Identify server node - --id Device:Port (-i) Set IB device and port - --loc_id Device:Port (-li) Set local IB device and port - --rem_id Device:Port (-ri) Set remote IB device and port + --id Device:Port (-i) Set RDMA device and port + --loc_id Device:Port (-li) Set local RDMA device and port + --rem_id Device:Port (-ri) Set remote RDMA device and port --listen_port Port (-lp) Set server listen port --msg_size Size (-m) Set message size - --mtu_size Size (-M) Set MTU size (IB only) + --mtu_size Size (-mt) Set MTU size (RDMA only) --no_msgs Count (-n) Send Count messages --poll OnOff (-P) Set polling mode on/off --loc_poll OnOff (-lP) Set local polling mode on/off --rem_poll OnOff (-lP) Set remote polling mode on/off --port Port (-p) Set TCP port used for tests --precision Digits (-e) Set precision reported - --rate (-r) Set IB static rate - --loc_rate (-lr) Set local IB static rate - --rem_rate (-rr) Set remote IB static rate - --rd_atomic Count (-R) Set RDMA read/atomic count - --loc_rd_atomic Count (-lR) Set local RDMA read/atomic count - --rem_rd_atomic Count (-rR) Set remote RDMA read/atomic count + --rd_atomic Max (-nr) Set RDMA read/atomic count + --loc_rd_atomic Max (-lnr) Set local RDMA read/atomic count + --rem_rd_atomic Max (-rnr) Set remote RDMA read/atomic count --service_level SL (-sl) Set service level --service_level SL (-lsl) Set local service level --service_level SL (-rsl) Set remote service level --sock_buf_size Size (-sb) Set socket buffer size --loc_sock_buf_size Size (-lsb) Set local socket buffer size --rem_sock_buf_size Size (-rsb) Set remote socket buffer size + --static_rate (-sr) Set IB static rate + --loc_rate (-lr) Set local IB static rate + --rem_rate (-rr) Set remote IB static rate --time Time (-t) Set test duration --timeout Time (-to) Set timeout --loc_timeout Time (-lto) Set local timeout @@ -198,7 +198,7 @@ Options specified in kibibytes, mebibytes or gibibytes respectively while a trailing kb or k, mb or m, or gb or g indicates kilobytes, megabytes or gigabytes respectively. - --mtu_size Size (-M) + --mtu_size Size (-mt) Set the MTU size. Only relevant to the RDMA UC/RC tests. Units are specified in the same manner as the --msg_size option. --no_msgs N (-n) @@ -218,21 +218,13 @@ Options that the test is run on. --precision Digits (-e) Set the number of significant digits that are used to report results. - --rate Rate (-r) - Force InfiniBand static rate. Rate can be one of: 2.5, 5, 10, 20, - 30, 40, 60, 80, 120, 1xSDR (2.5 Gbps), 1xDDR (5 Gbps), 1xQDR (10 - Gbps), 4xSDR (2.5 Gbps), 4xDDR (5 Gbps), 4xQDR (10 Gbps), 8xSDR (2.5 - Gbps), 8xDDR (5 Gbps), 8xQDR (10 Gbps). - --loc_rate (-lr) - Force local InfiniBand static rate - --rem_rate (-rr) - Force remote InfiniBand static rate - --rd_atomic Count (-R) + --rd_atomic Max (-nr) Set the number of in-flight operations that can be handled for a RDMA - read or atomic operation. This is only relevant to the RDMA tests. - --loc_rd_atomic Count (-lR) + read or atomic operation to Max. This is only relevant to the RDMA + Read and Atomic tests. + --loc_rd_atomic Max (-lnr) Set local read/atomic count. - --rem_rd_atomic Count (-rR) + --rem_rd_atomic Max (-rnr) Set remote read/atomic count. --service_level SL (-sl) Set RDMA service level to SL. This is only used by the RDMA tests. @@ -249,6 +241,15 @@ Options Set local socket buffer size. --rem_sock_buf_size Size (-rsb) Set remote socket buffer size. + --static_rate Rate (-sr) + Force InfiniBand static rate. Rate can be one of: 2.5, 5, 10, 20, + 30, 40, 60, 80, 120, 1xSDR (2.5 Gbps), 1xDDR (5 Gbps), 1xQDR (10 + Gbps), 4xSDR (2.5 Gbps), 4xDDR (5 Gbps), 4xQDR (10 Gbps), 8xSDR (2.5 + Gbps), 8xDDR (5 Gbps), 8xQDR (10 Gbps). + --loc_rate (-lr) + Force local InfiniBand static rate + --rem_rate (-rr) + Force remote InfiniBand static rate --time Time (-t) Set test duration to Time. Specified in seconds however a trailing m, h or d indicates that the time is specified in minutes, hours or @@ -256,10 +257,13 @@ Options --timeout Time (-to) Set timeout to Time. This is the timeout used for various things such as exchanging messages. The default is 5 seconds. - --loc_timeout Time (-lT) - Set local timeout to Time. - --rem_timeout Time (-rT) - Set local timeout to Time. + --loc_timeout Time (-lto) + Set local timeout to Time. This may be used on the server to set the + initial timeout when exchanging data with the client. As soon as we + receive the client's parameters, the client's remote timeout + overrides this parameter. + --rem_timeout Time (-rto) + Set remote timeout to Time. --unify_nodes (-un) Unify the nodes. Describe them in terms of local and remote rather than send and receive. @@ -528,12 +532,12 @@ ud_bw +RDMA UD streaming one way bandwidth Common Options --access_recv OnOff (-ar) Access received data - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --use_bits_per_sec, --verbose @@ -545,12 +549,12 @@ ud_bi_bw +RDMA UD streaming two way bandwidth Common Options --access_recv OnOff (-ar) Access received data - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --use_bits_per_sec, --verbose @@ -561,12 +565,12 @@ ud_lat +RDMA Purpose UD one way latency Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --verbose Description @@ -577,12 +581,12 @@ rc_bw +RDMA RC streaming one way bandwidth Common Options --access_recv OnOff (-ar) Access received data - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --use_bits_per_sec, --verbose @@ -594,12 +598,12 @@ rc_bi_bw +RDMA RC streaming two way bandwidth Common Options --access_recv OnOff (-ar) Access received data - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --use_bits_per_sec, --verbose @@ -610,12 +614,12 @@ rc_lat +RDMA Purpose RC one way latency Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --verbose Description @@ -626,12 +630,12 @@ uc_bw +RDMA UC streaming one way bandwidth Common Options --access_recv OnOff (-ar) Access received data - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --use_bits_per_sec, --verbose @@ -643,12 +647,12 @@ uc_bi_bw +RDMA UC streaming two way bandwidth Common Options --access_recv OnOff (-ar) Access received data - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --use_bits_per_sec, --verbose @@ -659,12 +663,12 @@ uc_lat +RDMA Purpose UC one way latency Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --verbose Description @@ -675,12 +679,13 @@ rc_rdma_read_bw +RDMA RC RDMA read streaming one way bandwidth Common Options --access_recv OnOff (-ar) Access received data - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --rd_atomic, --timeout + --affinity, --listen_port, --mtu_size, --rd_atomic, --static_rate, + --timeout Display Options --precision, --unify_nodes, --unify_units, --use_bits_per_sec, --verbose @@ -691,12 +696,12 @@ rc_rdma_read_lat +RDMA Purpose RC RDMA read one way latency Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --verbose Description @@ -706,12 +711,12 @@ rc_rdma_write_bw +RDMA Purpose RC RDMA write streaming one way bandwidth Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --use_bits_per_sec, --verbose @@ -722,12 +727,12 @@ rc_rdma_write_lat +RDMA Purpose RC RDMA write one way latency Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --verbose Description @@ -737,11 +742,11 @@ rc_rdma_write_poll_lat +RDMA Purpose RC RDMA write one way polling latency Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --verbose Description @@ -755,12 +760,12 @@ uc_rdma_write_bw +RDMA Purpose UC RDMA write streaming one way bandwidth Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --use_bits_per_sec, --verbose @@ -771,12 +776,12 @@ uc_rdma_write_lat +RDMA Purpose UC RDMA write one way latency Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --verbose Description @@ -786,11 +791,11 @@ uc_rdma_write_poll_lat +RDMA Purpose UC RDMA write one way polling latency Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --msg_size Size (-m) Set message size --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --timeout + --affinity, --listen_port, --mtu_size, --static_rate, --timeout Display Options --precision, --unify_nodes, --unify_units, --verbose Description @@ -804,11 +809,12 @@ rc_compare_swap_mr +RDMA Purpose RC compare and swap messaging rate Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --rd_atomic, --timeout + --affinity, --listen_port, --mtu_size, --rd_atomic, --static_rate, + --timeout Display Options --precision, --unify_nodes, --unify_units, --verbose Description @@ -818,11 +824,12 @@ rc_fetch_add_mr +RDMA Purpose RC fetch and add messaging rate Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --rd_atomic, --timeout + --affinity, --listen_port, --mtu_size, --rd_atomic, --static_rate, + --timeout Display Options --precision, --unify_nodes, --unify_units, --verbose Description @@ -832,11 +839,12 @@ ver_rc_compare_swap +RDMA Purpose Verify RC compare and swap Common Options - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --rd_atomic, --timeout + --affinity, --listen_port, --mtu_size, --rd_atomic, --static_rate, + --timeout Display Options --precision, --unify_nodes, --unify_units, --verbose Description @@ -848,11 +856,12 @@ ver_rc_fetch_add +RDMA Verify RC fetch and add Common Options --affinity PN (-a) Set processor affinity - --id Device:Port (-i) Set IB device and port + --id Device:Port (-i) Set RDMA device and port --poll OnOff (-P) Set polling mode on/off --time (-t) Set test duration Other Options - --affinity, --listen_port, --mtu_size, --rate, --rd_atomic, --timeout + --affinity, --listen_port, --mtu_size, --rd_atomic, --static_rate, + --timeout Display Options --precision, --unify_nodes, --unify_units, --use_bits_per_sec, --verbose diff --git a/src/qperf.c b/src/qperf.c index 0e43237..59b101b 100644 --- a/src/qperf.c +++ b/src/qperf.c @@ -60,12 +60,20 @@ * increment VER_MIN and set VER_INC to 0. Otherwise, just increment VER_INC. * VER_MAJ is reserved for major changes. */ -#define VER_MAJ 0 /* Major version */ -#define VER_MIN 3 /* Minor version */ -#define VER_INC 0 /* Incremental version */ -#define LISTENQ 5 /* Size of listen queue */ -#define ERRTIME 3 /* Error timeout in seconds */ -#define BUFSIZE 1024 /* Size of buffers */ +#define VER_MAJ 0 /* Major version */ +#define VER_MIN 4 /* Minor version */ +#define VER_INC 0 /* Incremental version */ +#define LISTENQ 5 /* Size of listen queue */ +#define BUFSIZE 1024 /* Size of buffers */ + + +/* + * Default parameter values. + */ +#define DEF_TIME 2 /* Test duration in seconds */ +#define DEF_TIMEOUT 5 /* Timeout in seconds */ +#define DEF_PRECISION 3 /* Precision of results */ +#define DEF_LISTEN_PORT 19765 /* Listen port */ /* @@ -103,6 +111,15 @@ typedef struct PAR_NAME { } PAR_NAME; +/* + * A simple mapping between two strings. + */ +typedef struct DICT { + char *str1; /* String 1 */ + char *str2; /* String 2 */ +} DICT; + + /* * Test prototype. */ @@ -209,9 +226,8 @@ static void view_time(int type, char *pref, char *name, double value); /* * Configurable variables. */ -static int ListenPort = 19765; -static int Precision = 3; -static int ServerTimeout = 5; +static int ListenPort = DEF_LISTEN_PORT; +static int Precision = DEF_PRECISION; static int UseBitsPerSec = 0; @@ -268,6 +284,7 @@ PAR_NAME ParName[] ={ { "sock_buf_size", L_SOCK_BUF_SIZE, R_SOCK_BUF_SIZE }, { "time", L_TIME, R_TIME }, { "timeout", L_TIMEOUT, R_TIMEOUT }, + { "use_cm", L_USE_CM, R_USE_CM }, }; @@ -295,18 +312,49 @@ PAR_INFO ParInfo[P_N] ={ { R_POLL_MODE, 'l', &RReq.poll_mode }, { L_PORT, 'l', &Req.port }, { R_PORT, 'l', &RReq.port }, - { L_RATE, 'p', &Req.rate }, - { R_RATE, 'p', &RReq.rate }, { L_RD_ATOMIC, 'l', &Req.rd_atomic }, { R_RD_ATOMIC, 'l', &RReq.rd_atomic }, { L_SL, 'l', &Req.sl }, { R_SL, 'l', &RReq.sl }, { L_SOCK_BUF_SIZE, 's', &Req.sock_buf_size }, { R_SOCK_BUF_SIZE, 's', &RReq.sock_buf_size }, + { L_STATIC_RATE, 'p', &Req.static_rate }, + { R_STATIC_RATE, 'p', &RReq.static_rate }, { L_TIME, 't', &Req.time }, { R_TIME, 't', &RReq.time }, { L_TIMEOUT, 't', &Req.timeout }, { R_TIMEOUT, 't', &RReq.timeout }, + { L_USE_CM, 'l', &Req.use_cm }, + { R_USE_CM, 'l', &RReq.use_cm }, +}; + + +/* + * Renamed options. First is old, second is new. + */ +DICT Renamed[] = { + { "--rate", "--static_rate" }, + { "-r", "-sr" }, + { "--loc_rate", "--loc_static_rate" }, + { "-lr", "-lsr" }, + { "--rem_rate", "--rem_static_rate" }, + { "-rr", "-rsr" }, + { "-R", "-nr" }, + { "-lR", "-lnr" }, + { "-rR", "-rnr" }, + { "-Ar", "-ar" }, + { "-M", "-mt" }, + { "-S", "-sb" }, + { "-lS", "-lsb" }, + { "-rS", "-rsb" }, + { "-T", "-to" }, + { "-lT", "-lto" }, + { "-rT", "-rto" }, + { "-u", "-uu", }, + { "-vC", "-vvc", }, + { "-vS", "-vvs", }, + { "-vT", "-vvt", }, + { "-vU", "-vvu", }, }; @@ -316,122 +364,110 @@ PAR_INFO ParInfo[P_N] ={ * obsolete and will eventually go away. */ OPTION Options[] ={ - { "--access_recv", "int", L_ACCESS_RECV, R_ACCESS_RECV }, - { "-ar", "int", L_ACCESS_RECV, R_ACCESS_RECV }, - { "--affinity", "int", L_AFFINITY, R_AFFINITY }, - { "-a", "int", L_AFFINITY, R_AFFINITY }, - { "--loc_affinity", "int", L_AFFINITY, }, - { "-la", "int", L_AFFINITY, }, - { "--rem_affinity", "int", R_AFFINITY }, - { "-ra", "int", R_AFFINITY }, - { "--debug", "Sdebug", }, - { "-D", "Sdebug", }, - { "--flip", "int", L_FLIP, R_FLIP }, - { "-f", "int", L_FLIP, R_FLIP }, - { "--help", "help" }, - { "-h", "help" }, - { "--host", "host", }, - { "-H", "host", }, - { "--id", "str", L_ID, R_ID }, - { "-i", "str", L_ID, R_ID }, - { "--loc_id", "str", L_ID, }, - { "-li", "str", L_ID, }, - { "--rem_id", "str", R_ID }, - { "-ri", "str", R_ID }, - { "--listen_port", "Slp", }, - { "-lp", "Slp", }, - { "--msg_size", "size", L_MSG_SIZE, R_MSG_SIZE }, - { "-m", "size", L_MSG_SIZE, R_MSG_SIZE }, - { "--mtu_size", "size", L_MTU_SIZE, R_MTU_SIZE }, - { "-M", "size", L_MTU_SIZE, R_MTU_SIZE }, - { "--no_msgs", "int", L_NO_MSGS, R_NO_MSGS }, - { "-n", "int", L_NO_MSGS, R_NO_MSGS }, - { "--poll", "int", L_POLL_MODE, R_POLL_MODE }, - { "-P", "int", L_POLL_MODE, R_POLL_MODE }, - { "--loc_poll", "int", L_POLL_MODE, }, - { "-lP", "int", L_POLL_MODE, }, - { "--rem_poll", "int", R_POLL_MODE }, - { "-rP", "int", R_POLL_MODE }, - { "--port", "int", L_PORT, R_PORT }, - { "-p", "int", L_PORT, R_PORT }, - { "--precision", "precision", }, - { "-e", "precision", }, - { "--rate", "str", L_RATE, R_RATE }, - { "-r", "str", L_RATE, R_RATE }, - { "--loc_rate", "str", L_RATE }, - { "-lr", "str", L_RATE }, - { "--rem_rate", "str", R_RATE }, - { "-rr", "str", R_RATE }, - { "-rd_atomic", "int", L_RD_ATOMIC, R_RD_ATOMIC }, - { "-R", "int", L_RD_ATOMIC, R_RD_ATOMIC }, - { "--loc_rd_atomic", "int", L_RD_ATOMIC, }, - { "-lR", "int", L_RD_ATOMIC, }, - { "--rem_rd_atomic", "int", R_RD_ATOMIC }, - { "-rR", "int", R_RD_ATOMIC }, - { "--service_level", "sl", L_SL, R_SL }, - { "-sl", "sl", L_SL, R_SL }, - { "--loc_service_level", "sl", L_SL }, - { "-lsl", "sl", L_SL }, - { "--rem_service_level", "sl", R_SL }, - { "-rsl", "sl", R_SL }, - { "--sock_buf_size", "size", L_SOCK_BUF_SIZE, R_SOCK_BUF_SIZE }, - { "-sb", "size", L_SOCK_BUF_SIZE, R_SOCK_BUF_SIZE }, - { "--loc_sock_buf_size", "size", L_SOCK_BUF_SIZE }, - { "-lsb", "size", L_SOCK_BUF_SIZE }, - { "--rem_sock_buf_size", "size", R_SOCK_BUF_SIZE }, - { "-rsb", "size", R_SOCK_BUF_SIZE }, - { "--time", "time", L_TIME, R_TIME }, - { "-t", "time", L_TIME, R_TIME }, - { "--timeout", "time", L_TIMEOUT, R_TIMEOUT }, - { "-to", "time", L_TIMEOUT, R_TIMEOUT }, - { "--loc_timeout", "time", L_TIMEOUT }, - { "-lto", "time", L_TIMEOUT }, - { "--rem_timeout", "time", R_TIMEOUT }, - { "-rto", "time", R_TIMEOUT }, - { "--unify_nodes", "un", }, - { "-un", "un", }, - { "--unify_units", "uu", }, - { "-uu", "uu", }, - { "--use_bits_per_sec", "ub", }, - { "-ub", "ub", }, - { "--verbose", "v", }, - { "-v", "v", }, - { "--verbose_conf", "vc", }, - { "-vc", "vc", }, - { "--verbose_stat", "vs", }, - { "-vs", "vs", }, - { "--verbose_time", "vt", }, - { "-vt", "vt", }, - { "--verbose_used", "vu", }, - { "-vu", "vu", }, - { "--verbose_more", "vv", }, - { "-vv", "vv", }, - { "--verbose_more_conf", "vvc", }, - { "-vvc", "vvc", }, - { "--verbose_more_stat", "vvs", }, - { "-vvs", "vvs", }, - { "--verbose_more_time", "vvt", }, - { "-vvt", "vvt", }, - { "--verbose_more_used", "vvu", }, - { "-vvu", "vvu", }, - { "--version", "version", }, - { "-V", "version", }, - { "--wait", "wait", }, - { "-W", "wait", }, - - /* Obsolete options */ - { "-Ar", "int", L_ACCESS_RECV, R_ACCESS_RECV }, - { "-S", "size", L_SOCK_BUF_SIZE, R_SOCK_BUF_SIZE }, - { "-T", "time", L_TIMEOUT, R_TIMEOUT }, - { "-lT", "time", L_TIMEOUT }, - { "-rT", "time", R_TIMEOUT }, - { "-lS", "size", L_SOCK_BUF_SIZE }, - { "-rS", "size", R_SOCK_BUF_SIZE }, - { "-u", "Xuu", }, - { "-vC", "Xvvc", }, - { "-vS", "Xvvs", }, - { "-vT", "Xvvt", }, - { "-vU", "Xvvu", }, + { "--access_recv", "int", L_ACCESS_RECV, R_ACCESS_RECV }, + { "-ar", "int", L_ACCESS_RECV, R_ACCESS_RECV }, + { "--affinity", "int", L_AFFINITY, R_AFFINITY }, + { "-a", "int", L_AFFINITY, R_AFFINITY }, + { "--loc_affinity", "int", L_AFFINITY, }, + { "-la", "int", L_AFFINITY, }, + { "--rem_affinity", "int", R_AFFINITY }, + { "-ra", "int", R_AFFINITY }, + { "--debug", "Sdebug", }, + { "-D", "Sdebug", }, + { "--flip", "int", L_FLIP, R_FLIP }, + { "-f", "int", L_FLIP, R_FLIP }, + { "--help", "help" }, + { "-h", "help" }, + { "--host", "host", }, + { "-H", "host", }, + { "--id", "str", L_ID, R_ID }, + { "-i", "str", L_ID, R_ID }, + { "--loc_id", "str", L_ID, }, + { "-li", "str", L_ID, }, + { "--rem_id", "str", R_ID }, + { "-ri", "str", R_ID }, + { "--listen_port", "Slp", }, + { "-lp", "Slp", }, + { "--msg_size", "size", L_MSG_SIZE, R_MSG_SIZE }, + { "-m", "size", L_MSG_SIZE, R_MSG_SIZE }, + { "--mtu_size", "size", L_MTU_SIZE, R_MTU_SIZE }, + { "-mt", "size", L_MTU_SIZE, R_MTU_SIZE }, + { "--no_msgs", "int", L_NO_MSGS, R_NO_MSGS }, + { "-n", "int", L_NO_MSGS, R_NO_MSGS }, + { "--poll", "int", L_POLL_MODE, R_POLL_MODE }, + { "-P", "int", L_POLL_MODE, R_POLL_MODE }, + { "--loc_poll", "int", L_POLL_MODE, }, + { "-lP", "int", L_POLL_MODE, }, + { "--rem_poll", "int", R_POLL_MODE }, + { "-rP", "int", R_POLL_MODE }, + { "--port", "int", L_PORT, R_PORT }, + { "-p", "int", L_PORT, R_PORT }, + { "--precision", "precision", }, + { "-e", "precision", }, + { "--rd_atomic", "int", L_RD_ATOMIC, R_RD_ATOMIC }, + { "-nr", "int", L_RD_ATOMIC, R_RD_ATOMIC }, + { "--loc_rd_atomic", "int", L_RD_ATOMIC, }, + { "-lnr", "int", L_RD_ATOMIC, }, + { "--rem_rd_atomic", "int", R_RD_ATOMIC }, + { "-rnr", "int", R_RD_ATOMIC }, + { "--service_level", "sl", L_SL, R_SL }, + { "-sl", "sl", L_SL, R_SL }, + { "--loc_service_level", "sl", L_SL }, + { "-lsl", "sl", L_SL }, + { "--rem_service_level", "sl", R_SL }, + { "-rsl", "sl", R_SL }, + { "--sock_buf_size", "size", L_SOCK_BUF_SIZE, R_SOCK_BUF_SIZE }, + { "-sb", "size", L_SOCK_BUF_SIZE, R_SOCK_BUF_SIZE }, + { "--loc_sock_buf_size", "size", L_SOCK_BUF_SIZE }, + { "-lsb", "size", L_SOCK_BUF_SIZE }, + { "--rem_sock_buf_size", "size", R_SOCK_BUF_SIZE }, + { "-rsb", "size", R_SOCK_BUF_SIZE }, + { "--static_rate", "str", L_STATIC_RATE, R_STATIC_RATE }, + { "-sr", "str", L_STATIC_RATE, R_STATIC_RATE }, + { "--loc_static_rate", "str", L_STATIC_RATE }, + { "-lsr", "str", L_STATIC_RATE }, + { "--rem_static_rate", "str", R_STATIC_RATE }, + { "-rsr", "str", R_STATIC_RATE }, + { "--time", "time", L_TIME, R_TIME }, + { "-t", "time", L_TIME, R_TIME }, + { "--timeout", "time", L_TIMEOUT, R_TIMEOUT }, + { "-to", "time", L_TIMEOUT, R_TIMEOUT }, + { "--loc_timeout", "Stime", L_TIMEOUT }, + { "-lto", "Stime", L_TIMEOUT }, + { "--rem_timeout", "time", R_TIMEOUT }, + { "-rto", "time", R_TIMEOUT }, + { "--unify_nodes", "un", }, + { "-un", "un", }, + { "--unify_units", "uu", }, + { "-uu", "uu", }, + { "--use_bits_per_sec", "ub", }, + { "-ub", "ub", }, + { "--use_cm", "int", L_USE_CM, R_USE_CM }, + { "-cm", "int", L_USE_CM, R_USE_CM }, + { "--verbose", "v", }, + { "-v", "v", }, + { "--verbose_conf", "vc", }, + { "-vc", "vc", }, + { "--verbose_stat", "vs", }, + { "-vs", "vs", }, + { "--verbose_time", "vt", }, + { "-vt", "vt", }, + { "--verbose_used", "vu", }, + { "-vu", "vu", }, + { "--verbose_more", "vv", }, + { "-vv", "vv", }, + { "--verbose_more_conf", "vvc", }, + { "-vvc", "vvc", }, + { "--verbose_more_stat", "vvs", }, + { "-vvs", "vvs", }, + { "--verbose_more_time", "vvt", }, + { "-vvt", "vvt", }, + { "--verbose_more_used", "vvu", }, + { "-vvu", "vvu", }, + { "--version", "version", }, + { "-V", "version", }, + { "--wait", "wait", }, + { "-W", "wait", }, }; @@ -645,7 +681,7 @@ do_args(char *args[]) server(); else if (!testSpecified) { if (!ServerName) - error(0, "you used a client only option but did not specify the " + error(0, "you used a client-only option but did not specify the " "server name.\nDo you want to be a client or server?"); if (find_test(ServerName)) error(0, "must specify host name first; try: qperf --help"); @@ -660,8 +696,23 @@ do_args(char *args[]) static OPTION * find_option(char *name) { - int n = cardof(Options); - OPTION *p = Options; + int n; + DICT *d; + OPTION *p; + + n = cardof(Renamed); + d = Renamed; + for (; n--; ++d) { + if (streq(name, d->str1)) { + char *msg = "warning: obsolete option: %s; use %s instead"; + error(RET, msg, name, d->str2); + name = d->str2; + break; + } + } + + n = cardof(Options); + p = Options; for (; n--; ++p) if (streq(name, p->name)) return p; @@ -694,11 +745,6 @@ do_option(OPTION *option, char ***argvp) if (*t == 'S') ++t; - if (*t == 'X') { - ++t; - error(RET, "warning: obsolete option: %s; use -%s instead", - option->name, t); - } if (streq(t, "debug")) { Debug = 1; @@ -740,7 +786,6 @@ do_option(OPTION *option, char ***argvp) setp_u32(option->name, option->arg1, v); setp_u32(option->name, option->arg2, v); } else if (streq(t, "str")) { - /* String */ char *s = arg_strn(argvp); setp_str(option->name, option->arg1, s); setp_str(option->name, option->arg2, s); @@ -763,8 +808,8 @@ do_option(OPTION *option, char ***argvp) if (VerboseStat < 1) VerboseStat = 1; if (VerboseTime < 1) - VerboseUsed = 1; - if (VerboseConf < 1) + VerboseTime = 1; + if (VerboseUsed < 1) VerboseUsed = 1; *argvp += 1; } else if (streq(t, "vc")) { @@ -1149,7 +1194,8 @@ server_listen(void) if (!ai) error(0, "unable to bind to listen port"); - Req.timeout = ServerTimeout; + if (!Req.timeout) + Req.timeout = DEF_TIMEOUT; if (listen(ListenFD, LISTENQ) < 0) error(SYS, "listen failed"); } @@ -1183,11 +1229,11 @@ client(TEST *test) for (i = 0; i < P_N; ++i) ParInfo[i].inuse = 0; if (!par_isset(L_NO_MSGS)) - setp_u32(0, L_TIME, 2); + setp_u32(0, L_TIME, DEF_TIME); if (!par_isset(R_NO_MSGS)) - setp_u32(0, R_TIME, 2); - setp_u32(0, L_TIMEOUT, 5); - setp_u32(0, R_TIMEOUT, 5); + setp_u32(0, R_TIME, DEF_TIME); + setp_u32(0, L_TIMEOUT, DEF_TIMEOUT); + setp_u32(0, R_TIMEOUT, DEF_TIMEOUT); par_use(L_AFFINITY); par_use(R_AFFINITY); par_use(L_TIME); @@ -2361,8 +2407,9 @@ enc_req(REQ *host) enc_int(host->sock_buf_size, sizeof(host->sock_buf_size)); enc_int(host->time, sizeof(host->time)); enc_int(host->timeout, sizeof(host->timeout)); + enc_int(host->use_cm, sizeof(host->use_cm)); enc_str(host->id, sizeof(host->id)); - enc_str(host->rate, sizeof(host->rate)); + enc_str(host->static_rate, sizeof(host->static_rate)); } @@ -2389,8 +2436,9 @@ dec_req(REQ *host) host->sock_buf_size = dec_int(sizeof(host->sock_buf_size)); host->time = dec_int(sizeof(host->time)); host->timeout = dec_int(sizeof(host->timeout)); - dec_str(host->id, sizeof(host->id)); - dec_str(host->rate, sizeof(host->rate)); + host->use_cm = dec_int(sizeof(host->use_cm)); + dec_str(host->id, sizeof(host->id)); + dec_str(host->static_rate,sizeof(host->static_rate)); } diff --git a/src/qperf.h b/src/qperf.h index 04359b5..2a78242 100644 --- a/src/qperf.h +++ b/src/qperf.h @@ -109,18 +109,20 @@ typedef enum { R_POLL_MODE, L_PORT, R_PORT, - L_RATE, - R_RATE, L_RD_ATOMIC, R_RD_ATOMIC, L_SL, R_SL, L_SOCK_BUF_SIZE, R_SOCK_BUF_SIZE, + L_STATIC_RATE, + R_STATIC_RATE, L_TIME, R_TIME, L_TIMEOUT, R_TIMEOUT, + L_USE_CM, + R_USE_CM, P_N } PAR_INDEX; @@ -159,8 +161,9 @@ typedef struct REQ { uint32_t sock_buf_size; /* Socket buffer size */ uint32_t time; /* Duration in seconds */ uint32_t timeout; /* Timeout for messages */ + uint32_t use_cm; /* Use Connection Manager */ char id[STRSIZE]; /* Identifier */ - char rate[STRSIZE]; /* Rate */ + char static_rate[STRSIZE]; /* Static rate */ } REQ; diff --git a/src/rdma.c b/src/rdma.c index ba5d29a..eab23f3 100644 --- a/src/rdma.c +++ b/src/rdma.c @@ -98,26 +98,26 @@ typedef enum IOMODE { /* * RDMA connection context. */ -typedef struct IBCON { +typedef struct RCON { uint32_t lid; /* Local ID */ uint32_t qpn; /* Queue pair number */ uint32_t psn; /* Packet sequence number */ uint32_t rkey; /* Remote key */ uint64_t vaddr; /* Virtual address */ -} IBCON; +} RCON; /* - * RDMA descriptor. + * RDMA device descriptor. */ -typedef struct IBDEV { - IBCON lcon; /* Local context */ - IBCON rcon; /* Remote context */ - int mtu; /* MTU */ - int port; /* Port */ - int rate; /* Rate */ - int trans; /* QP transport */ - int maxinline; /* Maximum amount of inline data */ +typedef struct RDEV { + RCON lcon; /* RDMA local context */ + RCON rcon; /* RDMA remote context */ + int mtu; /* MTU */ + int port; /* Port */ + int rate; /* Rate */ + int trans; /* QP transport */ + int maxinline; /* Maximum amount of inline data */ char *buffer; /* Buffer */ struct ibv_device **devlist; /* Device list */ struct ibv_context *context; /* Context */ @@ -127,7 +127,7 @@ typedef struct IBDEV { struct ibv_cq *cq; /* Completion queue */ struct ibv_qp *qp; /* QPair */ struct ibv_ah *ah; /* Address handle */ -} IBDEV; +} RDEV; /* @@ -152,32 +152,32 @@ typedef struct RATES { * Function prototypes. */ static void cq_error(int status); -static void dec_ibcon(IBCON *host); +static void dec_ibcon(RCON *host); static void do_error(int status, uint64_t *errors); -static void enc_ibcon(IBCON *host); +static void enc_ibcon(RCON *host); static void ib_bi_bw(int transport); static void ib_client_atomic(ATOMIC atomic); static void ib_client_bw(int transport); static void ib_client_rdma_bw(int transport, OPCODE opcode); static void ib_client_rdma_read_lat(int transport); -static void ib_close(IBDEV *ibdev); -static void ib_debug_info(IBDEV *ibdev); -static void ib_init(IBDEV *ibdev); -static void ib_mralloc(IBDEV *ibdev, int size); -static void ib_open(IBDEV *ibdev, int trans, int maxSendWR, int maxRecvWR); +static void ib_close(RDEV *rdev); +static void ib_debug_info(RDEV *rdev); +static void ib_init(RDEV *rdev); +static void ib_mralloc(RDEV *rdev, int size); +static void ib_open(RDEV *rdev, int trans, int maxSendWR, int maxRecvWR); static void ib_params_atomics(void); static void ib_params_msgs(long msgSize, int use_poll_mode); -static int ib_poll(IBDEV *ibdev, struct ibv_wc *wc, int nwc); -static void ib_post_rdma(IBDEV *ibdev, OPCODE opcode, int n); -static void ib_post_compare_swap(IBDEV *ibdev, +static int ib_poll(RDEV *rdev, struct ibv_wc *wc, int nwc); +static void ib_post_rdma(RDEV *rdev, OPCODE opcode, int n); +static void ib_post_compare_swap(RDEV *rdev, int wrid, int offset, uint64_t compare, uint64_t swap); -static void ib_post_fetch_add(IBDEV *ibdev, +static void ib_post_fetch_add(RDEV *rdev, int wrid, int offset, uint64_t add); -static void ib_post_recv(IBDEV *ibdev, int n); -static void ib_post_send(IBDEV *ibdev, int n); +static void ib_post_recv(RDEV *rdev, int n); +static void ib_post_send(RDEV *rdev, int n); static void ib_pp_lat(int transport, IOMODE iomode); -static void ib_pp_lat_loop(IBDEV *ibdev, IOMODE iomode); -static void ib_prepare(IBDEV *ibdev); +static void ib_pp_lat_loop(RDEV *rdev, IOMODE iomode); +static void ib_prepare(RDEV *rdev); static void ib_rdma_write_poll_lat(int transport); static void ib_server_def(int transport); static void ib_server_nop(int transport); @@ -690,31 +690,31 @@ run_server_ud_lat(void) void run_client_ver_rc_compare_swap(void) { - IBDEV ibdev; + int i; + int size; + RDEV rdev; uint64_t *result; uint64_t last = 0; uint64_t cur = 0; uint64_t next = 0x0123456789abcdefULL; - int i; - int size; ib_params_atomics(); - ib_open(&ibdev, IBV_QPT_RC, NCQE, 0); + ib_open(&rdev, IBV_QPT_RC, NCQE, 0); size = Req.rd_atomic * sizeof(uint64_t); setv_u32(L_MSG_SIZE, size); setv_u32(R_MSG_SIZE, size); - ib_mralloc(&ibdev, size); - ib_init(&ibdev); + ib_mralloc(&rdev, size); + ib_init(&rdev); sync_test(); for (i = 0; i < Req.rd_atomic; ++i) { - ib_post_compare_swap(&ibdev, i, i*sizeof(uint64_t), cur, next); + ib_post_compare_swap(&rdev, i, i*sizeof(uint64_t), cur, next); cur = next; next = cur + 1; } - result = (uint64_t *) ibdev.buffer; + result = (uint64_t *) rdev.buffer; while (!Finished) { struct ibv_wc wc[NCQE]; - int n = ib_poll(&ibdev, wc, cardof(wc)); + int n = ib_poll(&rdev, wc, cardof(wc)); uint64_t res; if (Finished) @@ -738,13 +738,13 @@ run_client_ver_rc_compare_swap(void) else last = 0x0123456789abcdefULL; next = cur + 1; - ib_post_compare_swap(&ibdev, x, x*sizeof(uint64_t), cur, next); + ib_post_compare_swap(&rdev, x, x*sizeof(uint64_t), cur, next); cur = next; } } stop_test_timer(); exchange_results(); - ib_close(&ibdev); + ib_close(&rdev); show_results(MSG_RATE); } @@ -765,26 +765,26 @@ run_server_ver_rc_compare_swap(void) void run_client_ver_rc_fetch_add(void) { - IBDEV ibdev; - uint64_t *result; - uint64_t last = 0; int i; int size; + RDEV rdev; + uint64_t *result; + uint64_t last = 0; ib_params_atomics(); - ib_open(&ibdev, IBV_QPT_RC, NCQE, 0); + ib_open(&rdev, IBV_QPT_RC, NCQE, 0); size = Req.rd_atomic * sizeof(uint64_t); setv_u32(L_MSG_SIZE, size); setv_u32(R_MSG_SIZE, size); - ib_mralloc(&ibdev, size); - ib_init(&ibdev); + ib_mralloc(&rdev, size); + ib_init(&rdev); sync_test(); for (i = 0; i < Req.rd_atomic; ++i) - ib_post_fetch_add(&ibdev, i, i*sizeof(uint64_t), 1); - result = (uint64_t *) ibdev.buffer; + ib_post_fetch_add(&rdev, i, i*sizeof(uint64_t), 1); + result = (uint64_t *) rdev.buffer; while (!Finished) { struct ibv_wc wc[NCQE]; - int n = ib_poll(&ibdev, wc, cardof(wc)); + int n = ib_poll(&rdev, wc, cardof(wc)); uint64_t res; if (Finished) @@ -804,12 +804,12 @@ run_client_ver_rc_fetch_add(void) error(0, "fetch and add mismatch (expected %llx vs. %llx)", (long long)last, (long long)res); last++; - ib_post_fetch_add(&ibdev, x, x*sizeof(uint64_t), 1); + ib_post_fetch_add(&rdev, x, x*sizeof(uint64_t), 1); } } stop_test_timer(); exchange_results(); - ib_close(&ibdev); + ib_close(&rdev); show_results(MSG_RATE); } @@ -831,26 +831,26 @@ static void ib_client_atomic(ATOMIC atomic) { int i; - IBDEV ibdev; + RDEV rdev; ib_params_atomics(); - ib_open(&ibdev, IBV_QPT_RC, NCQE, 0); + ib_open(&rdev, IBV_QPT_RC, NCQE, 0); setv_u32(L_MSG_SIZE, sizeof(uint64_t)); setv_u32(R_MSG_SIZE, sizeof(uint64_t)); - ib_mralloc(&ibdev, sizeof(uint64_t)); - ib_init(&ibdev); + ib_mralloc(&rdev, sizeof(uint64_t)); + ib_init(&rdev); sync_test(); for (i = 0; i < Req.rd_atomic; ++i) { if (atomic == FETCH_ADD) - ib_post_fetch_add(&ibdev, 0, 0, 0); + ib_post_fetch_add(&rdev, 0, 0, 0); else - ib_post_compare_swap(&ibdev, 0, 0, 0, 0); + ib_post_compare_swap(&rdev, 0, 0, 0, 0); } while (!Finished) { struct ibv_wc wc[NCQE]; - int n = ib_poll(&ibdev, wc, cardof(wc)); + int n = ib_poll(&rdev, wc, cardof(wc)); if (Finished) break; if (n > LStat.max_cqes) @@ -863,38 +863,38 @@ ib_client_atomic(ATOMIC atomic) } else do_error(status, &LStat.s.no_errs); if (atomic == FETCH_ADD) - ib_post_fetch_add(&ibdev, 0, 0, 0); + ib_post_fetch_add(&rdev, 0, 0, 0); else - ib_post_compare_swap(&ibdev, 0, 0, 0, 0); + ib_post_compare_swap(&rdev, 0, 0, 0, 0); } } stop_test_timer(); exchange_results(); - ib_close(&ibdev); + ib_close(&rdev); show_results(MSG_RATE); } /* - * Measure IB bandwidth (client side). + * Measure RDMA bandwidth (client side). */ static void ib_client_bw(int transport) { - IBDEV ibdev; + RDEV rdev; long sent = 0; - ib_open(&ibdev, transport, NCQE, 0); - ib_init(&ibdev); + ib_open(&rdev, transport, NCQE, 0); + ib_init(&rdev); sync_test(); - ib_post_send(&ibdev, left_to_send(&sent, NCQE)); + ib_post_send(&rdev, left_to_send(&sent, NCQE)); sent = NCQE; while (!Finished) { int i; struct ibv_wc wc[NCQE]; - int n = ib_poll(&ibdev, wc, cardof(wc)); + int n = ib_poll(&rdev, wc, cardof(wc)); if (n > LStat.max_cqes) LStat.max_cqes = n; if (Finished) @@ -912,12 +912,12 @@ ib_client_bw(int transport) break; n = left_to_send(&sent, n); } - ib_post_send(&ibdev, n); + ib_post_send(&rdev, n); sent += n; } stop_test_timer(); exchange_results(); - ib_close(&ibdev); + ib_close(&rdev); } @@ -928,16 +928,16 @@ ib_client_bw(int transport) static void ib_server_def(int transport) { - IBDEV ibdev; + RDEV rdev; - ib_open(&ibdev, transport, 0, NCQE); - ib_init(&ibdev); - ib_post_recv(&ibdev, NCQE); + ib_open(&rdev, transport, 0, NCQE); + ib_init(&rdev); + ib_post_recv(&rdev, NCQE); sync_test(); while (!Finished) { int i; struct ibv_wc wc[NCQE]; - int n = ib_poll(&ibdev, wc, cardof(wc)); + int n = ib_poll(&rdev, wc, cardof(wc)); if (Finished) break; if (n > LStat.max_cqes) @@ -948,40 +948,40 @@ ib_server_def(int transport) LStat.r.no_bytes += Req.msg_size; LStat.r.no_msgs++; if (Req.access_recv) - touch_data(ibdev.buffer, Req.msg_size); + touch_data(rdev.buffer, Req.msg_size); } else do_error(status, &LStat.r.no_errs); } if (Req.no_msgs) if (LStat.r.no_msgs + LStat.r.no_errs >= Req.no_msgs) break; - ib_post_recv(&ibdev, n); + ib_post_recv(&rdev, n); } stop_test_timer(); exchange_results(); - ib_close(&ibdev); + ib_close(&rdev); } /* - * Measure bi-directional IB bandwidth. + * Measure bi-directional RDMA bandwidth. */ static void ib_bi_bw(int transport) { - IBDEV ibdev; + RDEV rdev; - ib_open(&ibdev, transport, NCQE, NCQE); - ib_init(&ibdev); - ib_post_recv(&ibdev, NCQE); + ib_open(&rdev, transport, NCQE, NCQE); + ib_init(&rdev); + ib_post_recv(&rdev, NCQE); sync_test(); - ib_post_send(&ibdev, NCQE); + ib_post_send(&rdev, NCQE); while (!Finished) { int i; struct ibv_wc wc[NCQE]; int numSent = 0; int numRecv = 0; - int n = ib_poll(&ibdev, wc, cardof(wc)); + int n = ib_poll(&rdev, wc, cardof(wc)); if (Finished) break; if (n > LStat.max_cqes) @@ -1000,7 +1000,7 @@ ib_bi_bw(int transport) LStat.r.no_bytes += Req.msg_size; LStat.r.no_msgs++; if (Req.access_recv) - touch_data(ibdev.buffer, Req.msg_size); + touch_data(rdev.buffer, Req.msg_size); } else do_error(status, &LStat.r.no_errs); ++numRecv; @@ -1010,13 +1010,13 @@ ib_bi_bw(int transport) } } if (numRecv) - ib_post_recv(&ibdev, numRecv); + ib_post_recv(&rdev, numRecv); if (numSent) - ib_post_send(&ibdev, numSent); + ib_post_send(&rdev, numSent); } stop_test_timer(); exchange_results(); - ib_close(&ibdev); + ib_close(&rdev); } @@ -1026,14 +1026,14 @@ ib_bi_bw(int transport) static void ib_pp_lat(int transport, IOMODE iomode) { - IBDEV ibdev; + RDEV rdev; - ib_open(&ibdev, transport, 1, 1); - ib_init(&ibdev); - ib_pp_lat_loop(&ibdev, iomode); + ib_open(&rdev, transport, 1, 1); + ib_init(&rdev); + ib_pp_lat_loop(&rdev, iomode); stop_test_timer(); exchange_results(); - ib_close(&ibdev); + ib_close(&rdev); if (is_client()) show_results(LATENCY); } @@ -1043,23 +1043,23 @@ ib_pp_lat(int transport, IOMODE iomode) * Loop sending packets back and forth to measure ping-pong latency. */ static void -ib_pp_lat_loop(IBDEV *ibdev, IOMODE iomode) +ib_pp_lat_loop(RDEV *rdev, IOMODE iomode) { int done = 1; - ib_post_recv(ibdev, 1); + ib_post_recv(rdev, 1); sync_test(); if (is_client()) { if (iomode == IO_SR) - ib_post_send(ibdev, 1); + ib_post_send(rdev, 1); else - ib_post_rdma(ibdev, IBV_WR_RDMA_WRITE_WITH_IMM, 1); + ib_post_rdma(rdev, IBV_WR_RDMA_WRITE_WITH_IMM, 1); done = 0; } while (!Finished) { int i; struct ibv_wc wc[2]; - int n = ib_poll(ibdev, wc, cardof(wc)); + int n = ib_poll(rdev, wc, cardof(wc)); if (Finished) break; for (i = 0; i < n; ++i) { @@ -1076,7 +1076,7 @@ ib_pp_lat_loop(IBDEV *ibdev, IOMODE iomode) if (status == IBV_WC_SUCCESS) { LStat.r.no_bytes += Req.msg_size; LStat.r.no_msgs++; - ib_post_recv(ibdev, 1); + ib_post_recv(rdev, 1); } else do_error(status, &LStat.r.no_errs); done |= 2; @@ -1089,9 +1089,9 @@ ib_pp_lat_loop(IBDEV *ibdev, IOMODE iomode) } if (done == 3) { if (iomode == IO_SR) - ib_post_send(ibdev, 1); + ib_post_send(rdev, 1); else - ib_post_rdma(ibdev, IBV_WR_RDMA_WRITE_WITH_IMM, 1); + ib_post_rdma(rdev, IBV_WR_RDMA_WRITE_WITH_IMM, 1); done = 0; } } @@ -1106,18 +1106,18 @@ ib_pp_lat_loop(IBDEV *ibdev, IOMODE iomode) static void ib_rdma_write_poll_lat(int transport) { - IBDEV ibdev; + RDEV rdev; volatile char *p; volatile char *q; int send = is_client() ? 1 : 0; int locID = send; int remID = !locID; - ib_open(&ibdev, transport, NCQE, 0); - ib_init(&ibdev); + ib_open(&rdev, transport, NCQE, 0); + ib_init(&rdev); sync_test(); - p = &ibdev.buffer[0]; - q = &ibdev.buffer[Req.msg_size-1]; + p = &rdev.buffer[0]; + q = &rdev.buffer[Req.msg_size-1]; while (!Finished) { *p = locID; *q = locID; @@ -1126,10 +1126,10 @@ ib_rdma_write_poll_lat(int transport) int n; struct ibv_wc wc[2]; - ib_post_rdma(&ibdev, IBV_WR_RDMA_WRITE, 1); + ib_post_rdma(&rdev, IBV_WR_RDMA_WRITE, 1); if (Finished) break; - n = ibv_poll_cq(ibdev.cq, cardof(wc), wc); + n = ibv_poll_cq(rdev.cq, cardof(wc), wc); if (n < 0) error(SYS, "CQ poll failed"); for (i = 0; i < n; ++i) { @@ -1150,7 +1150,7 @@ ib_rdma_write_poll_lat(int transport) } stop_test_timer(); exchange_results(); - ib_close(&ibdev); + ib_close(&rdev); } @@ -1160,15 +1160,15 @@ ib_rdma_write_poll_lat(int transport) static void ib_client_rdma_read_lat(int transport) { - IBDEV ibdev; + RDEV rdev; - ib_open(&ibdev, transport, 1, 0); - ib_init(&ibdev); + ib_open(&rdev, transport, 1, 0); + ib_init(&rdev); sync_test(); - ib_post_rdma(&ibdev, IBV_WR_RDMA_READ, 1); + ib_post_rdma(&rdev, IBV_WR_RDMA_READ, 1); while (!Finished) { struct ibv_wc wc; - int n = ib_poll(&ibdev, &wc, 1); + int n = ib_poll(&rdev, &wc, 1); if (n == 0) continue; if (Finished) @@ -1184,11 +1184,11 @@ ib_client_rdma_read_lat(int transport) LStat.rem_s.no_msgs++; } else do_error(wc.status, &LStat.s.no_errs); - ib_post_rdma(&ibdev, IBV_WR_RDMA_READ, 1); + ib_post_rdma(&rdev, IBV_WR_RDMA_READ, 1); } stop_test_timer(); exchange_results(); - ib_close(&ibdev); + ib_close(&rdev); show_results(LATENCY); } @@ -1199,16 +1199,16 @@ ib_client_rdma_read_lat(int transport) static void ib_client_rdma_bw(int transport, OPCODE opcode) { - IBDEV ibdev; + RDEV rdev; - ib_open(&ibdev, transport, NCQE, 0); - ib_init(&ibdev); + ib_open(&rdev, transport, NCQE, 0); + ib_init(&rdev); sync_test(); - ib_post_rdma(&ibdev, opcode, NCQE); + ib_post_rdma(&rdev, opcode, NCQE); while (!Finished) { int i; struct ibv_wc wc[NCQE]; - int n = ib_poll(&ibdev, wc, cardof(wc)); + int n = ib_poll(&rdev, wc, cardof(wc)); if (Finished) break; if (n > LStat.max_cqes) @@ -1222,16 +1222,16 @@ ib_client_rdma_bw(int transport, OPCODE opcode) LStat.rem_s.no_bytes += Req.msg_size; LStat.rem_s.no_msgs++; if (Req.access_recv) - touch_data(ibdev.buffer, Req.msg_size); + touch_data(rdev.buffer, Req.msg_size); } } else do_error(status, &LStat.s.no_errs); } - ib_post_rdma(&ibdev, opcode, n); + ib_post_rdma(&rdev, opcode, n); } stop_test_timer(); exchange_results(); - ib_close(&ibdev); + ib_close(&rdev); } @@ -1241,22 +1241,22 @@ ib_client_rdma_bw(int transport, OPCODE opcode) static void ib_server_nop(int transport) { - IBDEV ibdev; + RDEV rdev; /* workaround: Size of RQ should be 0; bug in Mellanox driver */ - ib_open(&ibdev, transport, 0, 1); - ib_init(&ibdev); + ib_open(&rdev, transport, 0, 1); + ib_init(&rdev); sync_test(); while (!Finished) pause(); stop_test_timer(); exchange_results(); - ib_close(&ibdev); + ib_close(&rdev); } /* - * Set default IB parameters for tests that use messages. + * Set default RDMA parameters for tests that use messages. */ static void ib_params_msgs(long msgSize, int use_poll_mode) @@ -1269,10 +1269,10 @@ ib_params_msgs(long msgSize, int use_poll_mode) par_use(R_ID); par_use(L_MTU_SIZE); par_use(R_MTU_SIZE); - par_use(L_RATE); - par_use(R_RATE); par_use(L_SL); par_use(R_SL); + par_use(L_STATIC_RATE); + par_use(R_STATIC_RATE); if (use_poll_mode) { par_use(L_POLL_MODE); par_use(R_POLL_MODE); @@ -1282,7 +1282,7 @@ ib_params_msgs(long msgSize, int use_poll_mode) /* - * Set default IB parameters for tests that use atomics. + * Set default RDMA parameters for tests that use atomics. */ static void ib_params_atomics(void) @@ -1293,12 +1293,12 @@ ib_params_atomics(void) par_use(R_ID); par_use(L_POLL_MODE); par_use(R_POLL_MODE); - par_use(L_RATE); - par_use(R_RATE); par_use(L_RD_ATOMIC); par_use(R_RD_ATOMIC); par_use(L_SL); par_use(R_SL); + par_use(L_STATIC_RATE); + par_use(R_STATIC_RATE); opt_check(); setv_u32(L_MSG_SIZE, 0); @@ -1306,31 +1306,31 @@ ib_params_atomics(void) /* - * IB initialization. + * RDMA initialization. */ static void -ib_init(IBDEV *ibdev) +ib_init(RDEV *rdev) { - IBCON ibcon; + RCON ibcon; if (is_client()) { client_send_request(); enc_init(&ibcon); - enc_ibcon(&ibdev->lcon); - send_mesg(&ibcon, sizeof(ibcon), "IB connection"); - recv_mesg(&ibcon, sizeof(ibcon), "IB connection"); + enc_ibcon(&rdev->lcon); + send_mesg(&ibcon, sizeof(ibcon), "RDMA connection"); + recv_mesg(&ibcon, sizeof(ibcon), "RDMA connection"); dec_init(&ibcon); - dec_ibcon(&ibdev->rcon); + dec_ibcon(&rdev->rcon); } else { - recv_mesg(&ibcon, sizeof(ibcon), "IB connection"); + recv_mesg(&ibcon, sizeof(ibcon), "RDMA connection"); dec_init(&ibcon); - dec_ibcon(&ibdev->rcon); + dec_ibcon(&rdev->rcon); enc_init(&ibcon); - enc_ibcon(&ibdev->lcon); - send_mesg(&ibcon, sizeof(ibcon), "IB connection"); + enc_ibcon(&rdev->lcon); + send_mesg(&ibcon, sizeof(ibcon), "RDMA connection"); } - ib_prepare(ibdev); - ib_debug_info(ibdev); + ib_prepare(rdev); + ib_debug_info(rdev); } @@ -1338,14 +1338,14 @@ ib_init(IBDEV *ibdev) * Show debugging information. */ static void -ib_debug_info(IBDEV *ibdev) +ib_debug_info(RDEV *rdev) { debug("L: lid=%04x qpn=%06x psn=%06x rkey=%08x vaddr=%010x", - ibdev->lcon.lid, ibdev->lcon.qpn, ibdev->lcon.psn, - ibdev->lcon.rkey, ibdev->lcon.vaddr); + rdev->lcon.lid, rdev->lcon.qpn, rdev->lcon.psn, + rdev->lcon.rkey, rdev->lcon.vaddr); debug("R: lid=%04x qpn=%06x psn=%06x rkey=%08x vaddr=%010x", - ibdev->rcon.lid, ibdev->rcon.qpn, ibdev->rcon.psn, - ibdev->rcon.rkey, ibdev->rcon.vaddr); + rdev->rcon.lid, rdev->rcon.qpn, rdev->rcon.psn, + rdev->rcon.rkey, rdev->rcon.vaddr); } @@ -1353,30 +1353,30 @@ ib_debug_info(IBDEV *ibdev) * Open a RDMA device. */ static void -ib_open(IBDEV *ibdev, int trans, int maxSendWR, int maxRecvWR) +ib_open(RDEV *rdev, int trans, int maxSendWR, int maxRecvWR) { /* Clear structure */ - memset(ibdev, 0, sizeof(*ibdev)); + memset(rdev, 0, sizeof(*rdev)); /* Check and set MTU */ { int mtu = Req.mtu_size; if (mtu == 256) - ibdev->mtu = IBV_MTU_256; + rdev->mtu = IBV_MTU_256; else if (mtu == 512) - ibdev->mtu = IBV_MTU_512; + rdev->mtu = IBV_MTU_512; else if (mtu == 1024) - ibdev->mtu = IBV_MTU_1024; + rdev->mtu = IBV_MTU_1024; else if (mtu == 2048) - ibdev->mtu = IBV_MTU_2048; + rdev->mtu = IBV_MTU_2048; else if (mtu == 4096) - ibdev->mtu = IBV_MTU_4096; + rdev->mtu = IBV_MTU_4096; else error(0, "bad MTU: %d; must be 256/512/1K/2K/4K", mtu); } /* Set transport type */ - ibdev->trans = trans; + rdev->trans = trans; /* Set port */ { @@ -1388,7 +1388,7 @@ ib_open(IBDEV *ibdev, int trans, int maxSendWR, int maxRecvWR) if (port < 1) error(0, "bad IB port: %d; must be at least 1", port); } - ibdev->port = port; + rdev->port = port; } /* Set rate */ @@ -1398,9 +1398,9 @@ ib_open(IBDEV *ibdev, int trans, int maxSendWR, int maxRecvWR) for (;; ++q) { if (q >= r) - error(SYS, "bad rate: %s", Req.rate); - if (streq(Req.rate, q->name)) { - ibdev->rate = q->rate; + error(SYS, "bad static rate: %s", Req.static_rate); + if (streq(Req.static_rate, q->name)) { + rdev->rate = q->rate; break; } } @@ -1411,32 +1411,32 @@ ib_open(IBDEV *ibdev, int trans, int maxSendWR, int maxRecvWR) struct ibv_device *device; char *name = Req.id[0] ? Req.id : 0; - ibdev->devlist = ibv_get_device_list(0); - if (!ibdev->devlist) - error(SYS, "failed to find any IB devices"); + rdev->devlist = ibv_get_device_list(0); + if (!rdev->devlist) + error(SYS, "failed to find any RDMA devices"); if (!name) - device = *ibdev->devlist; + device = *rdev->devlist; else { - struct ibv_device **d = ibdev->devlist; + struct ibv_device **d = rdev->devlist; while ((device = *d++)) if (streq(ibv_get_device_name(device), name)) break; } if (!device) - error(SYS, "failed to find IB device"); - ibdev->context = ibv_open_device(device); - if (!ibdev->context) + error(SYS, "failed to find RDMA device"); + rdev->context = ibv_open_device(device); + if (!rdev->context) error(SYS, "failed to open device %s", ibv_get_device_name(device)); } /* Allocate completion channel */ - ibdev->channel = ibv_create_comp_channel(ibdev->context); - if (!ibdev->channel) + rdev->channel = ibv_create_comp_channel(rdev->context); + if (!rdev->channel) error(SYS, "failed to create completion channel"); /* Allocate protection domain */ - ibdev->pd = ibv_alloc_pd(ibdev->context); - if (!ibdev->pd) + rdev->pd = ibv_alloc_pd(rdev->context); + if (!rdev->pd) error(SYS, "failed to allocate protection domain"); /* Allocate message buffer and memory region */ @@ -1447,29 +1447,29 @@ ib_open(IBDEV *ibdev, int trans, int maxSendWR, int maxRecvWR) bufSize += GRH_SIZE; if (bufSize == 0) bufSize = 1; - if (posix_memalign((void **)&ibdev->buffer, pageSize, bufSize) != 0) + if (posix_memalign((void **)&rdev->buffer, pageSize, bufSize) != 0) error(SYS, "failed to allocate memory"); - memset(ibdev->buffer, 0, bufSize); + memset(rdev->buffer, 0, bufSize); int flags = IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_READ | IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_ATOMIC; - ibdev->mr = ibv_reg_mr(ibdev->pd, ibdev->buffer, bufSize, flags); - if (!ibdev->mr) + rdev->mr = ibv_reg_mr(rdev->pd, rdev->buffer, bufSize, flags); + if (!rdev->mr) error(SYS, "failed to allocate memory region"); } /* Create completion queue */ - ibdev->cq = ibv_create_cq(ibdev->context, - maxSendWR+maxRecvWR, 0, ibdev->channel, 0); - if (!ibdev->cq) + rdev->cq = ibv_create_cq(rdev->context, + maxSendWR+maxRecvWR, 0, rdev->channel, 0); + if (!rdev->cq) error(SYS, "failed to create completion queue"); /* Create queue pair */ { struct ibv_qp_init_attr attr ={ - .send_cq = ibdev->cq, - .recv_cq = ibdev->cq, + .send_cq = rdev->cq, + .recv_cq = rdev->cq, .cap ={ .max_send_wr = maxSendWR, .max_recv_wr = maxRecvWR, @@ -1477,10 +1477,10 @@ ib_open(IBDEV *ibdev, int trans, int maxSendWR, int maxRecvWR) .max_recv_sge = 1, .max_inline_data = 0, }, - .qp_type = ibdev->trans, + .qp_type = rdev->trans, }; - ibdev->qp = ibv_create_qp(ibdev->pd, &attr); - if (!ibdev->qp) + rdev->qp = ibv_create_qp(rdev->pd, &attr); + if (!rdev->qp) error(SYS, "failed to create QP"); } @@ -1489,24 +1489,24 @@ ib_open(IBDEV *ibdev, int trans, int maxSendWR, int maxRecvWR) struct ibv_qp_attr attr ={ .qp_state = IBV_QPS_INIT, .pkey_index = 0, - .port_num = ibdev->port + .port_num = rdev->port }; int flags = IBV_QP_STATE | IBV_QP_PKEY_INDEX | IBV_QP_PORT; - if (ibdev->trans == IBV_QPT_UD) { + if (rdev->trans == IBV_QPT_UD) { flags |= IBV_QP_QKEY; attr.qkey = QKEY; - } else if (ibdev->trans == IBV_QPT_RC) { + } else if (rdev->trans == IBV_QPT_RC) { flags |= IBV_QP_ACCESS_FLAGS; attr.qp_access_flags = IBV_ACCESS_REMOTE_READ | IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_ATOMIC; - } else if (ibdev->trans == IBV_QPT_UC) { + } else if (rdev->trans == IBV_QPT_UC) { flags |= IBV_QP_ACCESS_FLAGS; attr.qp_access_flags = IBV_ACCESS_REMOTE_WRITE; } - if (ibv_modify_qp(ibdev->qp, &attr, flags) != SUCCESS0) + if (ibv_modify_qp(rdev->qp, &attr, flags) != SUCCESS0) error(SYS, "failed to modify QP to INIT state"); } @@ -1515,16 +1515,16 @@ ib_open(IBDEV *ibdev, int trans, int maxSendWR, int maxRecvWR) struct ibv_qp_attr qp_attr; struct ibv_qp_init_attr qp_init_attr; - if (ibv_query_qp(ibdev->qp, &qp_attr, 0, &qp_init_attr) != SUCCESS0) + if (ibv_query_qp(rdev->qp, &qp_attr, 0, &qp_init_attr) != SUCCESS0) error(SYS, "query QP failed"); - ibdev->maxinline = qp_attr.cap.max_inline_data; + rdev->maxinline = qp_attr.cap.max_inline_data; } /* Get device properties */ { struct ibv_device_attr dev_attr; - if (ibv_query_device(ibdev->context, &dev_attr) != SUCCESS0) + if (ibv_query_device(rdev->context, &dev_attr) != SUCCESS0) error(SYS, "query device failed"); if (Req.rd_atomic == 0) Req.rd_atomic = dev_attr.max_qp_rd_atom; @@ -1537,20 +1537,20 @@ ib_open(IBDEV *ibdev, int trans, int maxSendWR, int maxRecvWR) { struct ibv_port_attr port_attr; - int stat = ibv_query_port(ibdev->context, ibdev->port, &port_attr); + int stat = ibv_query_port(rdev->context, rdev->port, &port_attr); if (stat != SUCCESS0) error(SYS, "query port failed"); srand48(getpid()*time(0)); - ibdev->lcon.lid = port_attr.lid; - ibdev->lcon.qpn = ibdev->qp->qp_num; - ibdev->lcon.psn = lrand48() & 0xffffff; - ibdev->lcon.rkey = 0; - ibdev->lcon.vaddr = 0; + rdev->lcon.lid = port_attr.lid; + rdev->lcon.qpn = rdev->qp->qp_num; + rdev->lcon.psn = lrand48() & 0xffffff; + rdev->lcon.rkey = 0; + rdev->lcon.vaddr = 0; } /* Allocate memory region */ - ib_mralloc(ibdev, Req.msg_size); + ib_mralloc(rdev, Req.msg_size); } @@ -1558,49 +1558,49 @@ ib_open(IBDEV *ibdev, int trans, int maxSendWR, int maxRecvWR) * Allocate a memory region. */ static void -ib_mralloc(IBDEV *ibdev, int size) +ib_mralloc(RDEV *rdev, int size) { int pageSize; if (size == 0) return; - if (ibdev->trans == IBV_QPT_UD) + if (rdev->trans == IBV_QPT_UD) size += GRH_SIZE; pageSize = sysconf(_SC_PAGESIZE); - if (posix_memalign((void **)&ibdev->buffer, pageSize, size) != 0) + if (posix_memalign((void **)&rdev->buffer, pageSize, size) != 0) error(SYS, "failed to allocate memory"); - memset(ibdev->buffer, 0, size); + memset(rdev->buffer, 0, size); int flags = IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_READ | IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_ATOMIC; - ibdev->mr = ibv_reg_mr(ibdev->pd, ibdev->buffer, size, flags); - if (!ibdev->mr) + rdev->mr = ibv_reg_mr(rdev->pd, rdev->buffer, size, flags); + if (!rdev->mr) error(SYS, "failed to allocate memory region"); - ibdev->lcon.rkey = ibdev->mr->rkey; - ibdev->lcon.vaddr = (unsigned long)ibdev->buffer; + rdev->lcon.rkey = rdev->mr->rkey; + rdev->lcon.vaddr = (unsigned long)rdev->buffer; } /* - * Prepare the IB device for receiving and sending. + * Prepare the RDMA device for receiving and sending. */ static void -ib_prepare(IBDEV *ibdev) +ib_prepare(RDEV *rdev) { int flags; struct ibv_qp_attr rtr_attr ={ .qp_state = IBV_QPS_RTR, - .path_mtu = ibdev->mtu, - .dest_qp_num = ibdev->rcon.qpn, - .rq_psn = ibdev->rcon.psn, + .path_mtu = rdev->mtu, + .dest_qp_num = rdev->rcon.qpn, + .rq_psn = rdev->rcon.psn, .min_rnr_timer = RNR_TIMER, .max_dest_rd_atomic = Req.rd_atomic, .ah_attr = { - .dlid = ibdev->rcon.lid, - .port_num = ibdev->port, - .static_rate = ibdev->rate, + .dlid = rdev->rcon.lid, + .port_num = rdev->port, + .static_rate = rdev->rate, .sl = Req.sl } }; @@ -1609,32 +1609,32 @@ ib_prepare(IBDEV *ibdev) .timeout = TIMEOUT, .retry_cnt = RETRY_CNT, .rnr_retry = RNR_RETRY, - .sq_psn = ibdev->lcon.psn, + .sq_psn = rdev->lcon.psn, .max_rd_atomic = Req.rd_atomic }; struct ibv_ah_attr ah_attr ={ - .dlid = ibdev->rcon.lid, - .port_num = ibdev->port, - .static_rate = ibdev->rate, + .dlid = rdev->rcon.lid, + .port_num = rdev->port, + .static_rate = rdev->rate, .sl = Req.sl }; - if (ibdev->trans == IBV_QPT_UD) { + if (rdev->trans == IBV_QPT_UD) { /* Modify queue pair to RTR */ flags = IBV_QP_STATE; - if (ibv_modify_qp(ibdev->qp, &rtr_attr, flags) != SUCCESS0) + if (ibv_modify_qp(rdev->qp, &rtr_attr, flags) != SUCCESS0) error(SYS, "failed to modify QP to RTR"); /* Modify queue pair to RTS */ flags = IBV_QP_STATE | IBV_QP_SQ_PSN; - if (ibv_modify_qp(ibdev->qp, &rts_attr, flags) != SUCCESS0) + if (ibv_modify_qp(rdev->qp, &rts_attr, flags) != SUCCESS0) error(SYS, "failed to modify QP to RTS"); /* Create address handle */ - ibdev->ah = ibv_create_ah(ibdev->pd, &ah_attr); - if (!ibdev->ah) + rdev->ah = ibv_create_ah(rdev->pd, &ah_attr); + if (!rdev->ah) error(SYS, "failed to create address handle"); - } else if (ibdev->trans == IBV_QPT_RC) { + } else if (rdev->trans == IBV_QPT_RC) { /* Modify queue pair to RTR */ flags = IBV_QP_STATE | IBV_QP_AV | @@ -1643,7 +1643,7 @@ ib_prepare(IBDEV *ibdev) IBV_QP_RQ_PSN | IBV_QP_MAX_DEST_RD_ATOMIC | IBV_QP_MIN_RNR_TIMER; - if (ibv_modify_qp(ibdev->qp, &rtr_attr, flags) != SUCCESS0) + if (ibv_modify_qp(rdev->qp, &rtr_attr, flags) != SUCCESS0) error(SYS, "failed to modify QP to RTR"); /* Modify queue pair to RTS */ @@ -1653,26 +1653,26 @@ ib_prepare(IBDEV *ibdev) IBV_QP_RNR_RETRY | IBV_QP_SQ_PSN | IBV_QP_MAX_QP_RD_ATOMIC; - if (ibv_modify_qp(ibdev->qp, &rts_attr, flags) != SUCCESS0) + if (ibv_modify_qp(rdev->qp, &rts_attr, flags) != SUCCESS0) error(SYS, "failed to modify QP to RTS"); - } else if (ibdev->trans == IBV_QPT_UC) { + } else if (rdev->trans == IBV_QPT_UC) { /* Modify queue pair to RTR */ flags = IBV_QP_STATE | IBV_QP_AV | IBV_QP_PATH_MTU | IBV_QP_DEST_QPN | IBV_QP_RQ_PSN; - if (ibv_modify_qp(ibdev->qp, &rtr_attr, flags) != SUCCESS0) + if (ibv_modify_qp(rdev->qp, &rtr_attr, flags) != SUCCESS0) error(SYS, "failed to modify QP to RTR"); /* Modify queue pair to RTS */ flags = IBV_QP_STATE | IBV_QP_SQ_PSN; - if (ibv_modify_qp(ibdev->qp, &rts_attr, flags) != SUCCESS0) + if (ibv_modify_qp(rdev->qp, &rts_attr, flags) != SUCCESS0) error(SYS, "failed to modify QP to RTS"); } if (!Req.poll_mode) { - if (ibv_req_notify_cq(ibdev->cq, 0) != SUCCESS0) + if (ibv_req_notify_cq(rdev->cq, 0) != SUCCESS0) error(SYS, "failed to request CQ notification"); } } @@ -1683,27 +1683,27 @@ ib_prepare(IBDEV *ibdev) * ibv_destroy_qp call might hang. */ static void -ib_close(IBDEV *ibdev) +ib_close(RDEV *rdev) { - if (ibdev->ah) - ibv_destroy_ah(ibdev->ah); - if (ibdev->cq) - ibv_destroy_cq(ibdev->cq); - if (ibdev->qp) - ibv_destroy_qp(ibdev->qp); - if (ibdev->mr) - ibv_dereg_mr(ibdev->mr); - if (ibdev->pd) - ibv_dealloc_pd(ibdev->pd); - if (ibdev->channel) - ibv_destroy_comp_channel(ibdev->channel); - if (ibdev->context) - ibv_close_device(ibdev->context); - if (ibdev->buffer) - free(ibdev->buffer); - if (ibdev->devlist) - free(ibdev->devlist); - memset(ibdev, 0, sizeof(*ibdev)); + if (rdev->ah) + ibv_destroy_ah(rdev->ah); + if (rdev->cq) + ibv_destroy_cq(rdev->cq); + if (rdev->qp) + ibv_destroy_qp(rdev->qp); + if (rdev->mr) + ibv_dereg_mr(rdev->mr); + if (rdev->pd) + ibv_dealloc_pd(rdev->pd); + if (rdev->channel) + ibv_destroy_comp_channel(rdev->channel); + if (rdev->context) + ibv_close_device(rdev->context); + if (rdev->buffer) + free(rdev->buffer); + if (rdev->devlist) + free(rdev->devlist); + memset(rdev, 0, sizeof(*rdev)); } @@ -1711,13 +1711,13 @@ ib_close(IBDEV *ibdev) * Post a compare and swap request. */ static void -ib_post_compare_swap(IBDEV *ibdev, +ib_post_compare_swap(RDEV *rdev, int wrid, int offset, uint64_t compare, uint64_t swap) { struct ibv_sge sge ={ - .addr = (uintptr_t)ibdev->buffer + offset, + .addr = (uintptr_t)rdev->buffer + offset, .length = sizeof(uint64_t), - .lkey = ibdev->mr->lkey + .lkey = rdev->mr->lkey }; struct ibv_send_wr wr ={ .wr_id = wrid, @@ -1727,8 +1727,8 @@ ib_post_compare_swap(IBDEV *ibdev, .send_flags = IBV_SEND_SIGNALED, .wr = { .atomic = { - .remote_addr = ibdev->rcon.vaddr, - .rkey = ibdev->rcon.rkey, + .remote_addr = rdev->rcon.vaddr, + .rkey = rdev->rcon.rkey, .compare_add = compare, .swap = swap } @@ -1737,7 +1737,7 @@ ib_post_compare_swap(IBDEV *ibdev, struct ibv_send_wr *badWR; errno = 0; - if (ibv_post_send(ibdev->qp, &wr, &badWR) != SUCCESS0) { + if (ibv_post_send(rdev->qp, &wr, &badWR) != SUCCESS0) { if (Finished && errno == EINTR) return; error(SYS, "failed to post compare and swap"); @@ -1752,12 +1752,12 @@ ib_post_compare_swap(IBDEV *ibdev, * Post a fetch and add request. */ static void -ib_post_fetch_add(IBDEV *ibdev, int wrid, int offset, uint64_t add) +ib_post_fetch_add(RDEV *rdev, int wrid, int offset, uint64_t add) { struct ibv_sge sge ={ - .addr = (uintptr_t) ibdev->buffer + offset, + .addr = (uintptr_t) rdev->buffer + offset, .length = sizeof(uint64_t), - .lkey = ibdev->mr->lkey + .lkey = rdev->mr->lkey }; struct ibv_send_wr wr ={ .wr_id = wrid, @@ -1767,8 +1767,8 @@ ib_post_fetch_add(IBDEV *ibdev, int wrid, int offset, uint64_t add) .send_flags = IBV_SEND_SIGNALED, .wr = { .atomic = { - .remote_addr = ibdev->rcon.vaddr, - .rkey = ibdev->rcon.rkey, + .remote_addr = rdev->rcon.vaddr, + .rkey = rdev->rcon.rkey, .compare_add = add } } @@ -1776,7 +1776,7 @@ ib_post_fetch_add(IBDEV *ibdev, int wrid, int offset, uint64_t add) struct ibv_send_wr *badWR; errno = 0; - if (ibv_post_send(ibdev->qp, &wr, &badWR) != SUCCESS0) { + if (ibv_post_send(rdev->qp, &wr, &badWR) != SUCCESS0) { if (Finished && errno == EINTR) return; error(SYS, "failed to post fetch and add"); @@ -1791,12 +1791,12 @@ ib_post_fetch_add(IBDEV *ibdev, int wrid, int offset, uint64_t add) * Post n sends. */ static void -ib_post_send(IBDEV *ibdev, int n) +ib_post_send(RDEV *rdev, int n) { struct ibv_sge sge ={ - .addr = (uintptr_t) ibdev->buffer, + .addr = (uintptr_t) rdev->buffer, .length = Req.msg_size, - .lkey = ibdev->mr->lkey + .lkey = rdev->mr->lkey }; struct ibv_send_wr wr ={ .wr_id = WRID_SEND, @@ -1807,16 +1807,16 @@ ib_post_send(IBDEV *ibdev, int n) }; struct ibv_send_wr *badWR; - if (ibdev->trans == IBV_QPT_UD) { - wr.wr.ud.ah = ibdev->ah; - wr.wr.ud.remote_qpn = ibdev->rcon.qpn; + if (rdev->trans == IBV_QPT_UD) { + wr.wr.ud.ah = rdev->ah; + wr.wr.ud.remote_qpn = rdev->rcon.qpn; wr.wr.ud.remote_qkey = QKEY; } - if (Req.msg_size <= ibdev->maxinline) + if (Req.msg_size <= rdev->maxinline) wr.send_flags |= IBV_SEND_INLINE; errno = 0; while (n-- > 0) { - if (ibv_post_send(ibdev->qp, &wr, &badWR) != SUCCESS0) { + if (ibv_post_send(rdev->qp, &wr, &badWR) != SUCCESS0) { if (Finished && errno == EINTR) return; error(SYS, "failed to post send"); @@ -1831,12 +1831,12 @@ ib_post_send(IBDEV *ibdev, int n) * Post n receives. */ static void -ib_post_recv(IBDEV *ibdev, int n) +ib_post_recv(RDEV *rdev, int n) { struct ibv_sge sge ={ - .addr = (uintptr_t) ibdev->buffer, + .addr = (uintptr_t) rdev->buffer, .length = Req.msg_size, - .lkey = ibdev->mr->lkey + .lkey = rdev->mr->lkey }; struct ibv_recv_wr wr ={ .wr_id = WRID_RECV, @@ -1845,12 +1845,12 @@ ib_post_recv(IBDEV *ibdev, int n) }; struct ibv_recv_wr *badWR; - if (ibdev->trans == IBV_QPT_UD) + if (rdev->trans == IBV_QPT_UD) sge.length += GRH_SIZE; errno = 0; while (n-- > 0) { - if (ibv_post_recv(ibdev->qp, &wr, &badWR) != SUCCESS0) { + if (ibv_post_recv(rdev->qp, &wr, &badWR) != SUCCESS0) { if (Finished && errno == EINTR) return; error(SYS, "failed to post receive"); @@ -1863,12 +1863,12 @@ ib_post_recv(IBDEV *ibdev, int n) * Post n RDMA requests. */ static void -ib_post_rdma(IBDEV *ibdev, OPCODE opcode, int n) +ib_post_rdma(RDEV *rdev, OPCODE opcode, int n) { struct ibv_sge sge ={ - .addr = (uintptr_t) ibdev->buffer, + .addr = (uintptr_t) rdev->buffer, .length = Req.msg_size, - .lkey = ibdev->mr->lkey + .lkey = rdev->mr->lkey }; struct ibv_send_wr wr ={ .wr_id = WRID_RDMA, @@ -1878,18 +1878,18 @@ ib_post_rdma(IBDEV *ibdev, OPCODE opcode, int n) .send_flags = IBV_SEND_SIGNALED, .wr = { .rdma = { - .remote_addr = ibdev->rcon.vaddr, - .rkey = ibdev->rcon.rkey + .remote_addr = rdev->rcon.vaddr, + .rkey = rdev->rcon.rkey } } }; struct ibv_send_wr *badWR; - if (opcode != IBV_WR_RDMA_READ && Req.msg_size <= ibdev->maxinline) + if (opcode != IBV_WR_RDMA_READ && Req.msg_size <= rdev->maxinline) wr.send_flags |= IBV_SEND_INLINE; errno = 0; while (n--) { - if (ibv_post_send(ibdev->qp, &wr, &badWR) != SUCCESS0) { + if (ibv_post_send(rdev->qp, &wr, &badWR) != SUCCESS0) { if (Finished && errno == EINTR) return; error(SYS, "failed to post %s", opcode_name(wr.opcode)); @@ -1906,7 +1906,7 @@ ib_post_rdma(IBDEV *ibdev, OPCODE opcode, int n) * Poll the completion queue. */ static int -ib_poll(IBDEV *ibdev, struct ibv_wc *wc, int nwc) +ib_poll(RDEV *rdev, struct ibv_wc *wc, int nwc) { int n; @@ -1914,14 +1914,14 @@ ib_poll(IBDEV *ibdev, struct ibv_wc *wc, int nwc) void *ectx; struct ibv_cq *ecq; - if (ibv_get_cq_event(ibdev->channel, &ecq, &ectx) != SUCCESS0) + if (ibv_get_cq_event(rdev->channel, &ecq, &ectx) != SUCCESS0) return maybe(0, "failed to get CQ event"); - if (ecq != ibdev->cq) + if (ecq != rdev->cq) error(0, "CQ event for unknown CQ"); - if (ibv_req_notify_cq(ibdev->cq, 0) != SUCCESS0) + if (ibv_req_notify_cq(rdev->cq, 0) != SUCCESS0) return maybe(0, "failed to request CQ notification"); } - n = ibv_poll_cq(ibdev->cq, nwc, wc); + n = ibv_poll_cq(rdev->cq, nwc, wc); if (n < 0) return maybe(0, "CQ poll failed"); return n; @@ -1943,10 +1943,10 @@ maybe(int val, char *msg) /* - * Encode a IBCON structure into a data stream. + * Encode a RCON structure into a data stream. */ static void -enc_ibcon(IBCON *host) +enc_ibcon(RCON *host) { enc_int(host->lid, sizeof(host->lid)); enc_int(host->qpn, sizeof(host->qpn)); @@ -1957,10 +1957,10 @@ enc_ibcon(IBCON *host) /* - * Decode a IBCON structure from a data stream. + * Decode a RCON structure from a data stream. */ static void -dec_ibcon(IBCON *host) +dec_ibcon(RCON *host) { host->lid = dec_int(sizeof(host->lid)); host->qpn = dec_int(sizeof(host->qpn));