[Pkg-ofed-commits] [libibcm] 01/14: Imported Upstream version 1.0.5
Ana Beatriz Guerrero López
ana at moszumanska.debian.org
Mon Jul 7 13:42:12 UTC 2014
This is an automated email from the git hooks/post-receive script.
ana pushed a commit to branch master
in repository libibcm.
commit 762a091de888dc4169143195f89dab4f07152382
Author: Ana Guerrero López <ana at ekaia.org>
Date: Mon Jul 7 15:10:54 2014 +0200
Imported Upstream version 1.0.5
---
autogen.sh | 9 -
configure | 20 +-
configure.in | 4 +-
examples/cmpost.c | 728 ----------------------------------------
libibcm.spec.in => libibcm.spec | 4 +-
libibcm.spec.in | 2 +-
src/cm.c | 89 ++---
7 files changed, 63 insertions(+), 793 deletions(-)
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index f433312..0000000
--- a/autogen.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#! /bin/sh
-
-set -x
-test -d ./config || mkdir ./config
-aclocal -I config
-libtoolize --force --copy
-autoheader
-automake --foreign --add-missing --copy
-autoconf
diff --git a/configure b/configure
index 697d215..2735510 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for libibcm 1.0.4.
+# Generated by GNU Autoconf 2.59 for libibcm 1.0.5.
#
# Report bugs to <general at lists@openfabrics.org>.
#
@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='libibcm'
PACKAGE_TARNAME='libibcm'
-PACKAGE_VERSION='1.0.4'
-PACKAGE_STRING='libibcm 1.0.4'
+PACKAGE_VERSION='1.0.5'
+PACKAGE_STRING='libibcm 1.0.5'
PACKAGE_BUGREPORT='general at lists@openfabrics.org'
ac_unique_file="src/cm.c"
@@ -954,7 +954,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libibcm 1.0.4 to adapt to many kinds of systems.
+\`configure' configures libibcm 1.0.5 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1020,7 +1020,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libibcm 1.0.4:";;
+ short | recursive ) echo "Configuration of libibcm 1.0.5:";;
esac
cat <<\_ACEOF
@@ -1161,7 +1161,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
-libibcm configure 1.0.4
+libibcm configure 1.0.5
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@@ -1175,7 +1175,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libibcm $as_me 1.0.4, which was
+It was created by libibcm $as_me 1.0.5, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -1821,7 +1821,7 @@ fi
# Define the identity of the package.
PACKAGE=libibcm
- VERSION=1.0.4
+ VERSION=1.0.5
cat >>confdefs.h <<_ACEOF
@@ -21056,7 +21056,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
-This file was extended by libibcm $as_me 1.0.4, which was
+This file was extended by libibcm $as_me 1.0.5, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -21119,7 +21119,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-libibcm config.status 1.0.4
+libibcm config.status 1.0.5
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/configure.in b/configure.in
index 4e7402d..2712969 100644
--- a/configure.in
+++ b/configure.in
@@ -1,11 +1,11 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
-AC_INIT(libibcm, 1.0.4, general at lists@openfabrics.org)
+AC_INIT(libibcm, 1.0.5, general at lists@openfabrics.org)
AC_CONFIG_SRCDIR([src/cm.c])
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libibcm, 1.0.4)
+AM_INIT_AUTOMAKE(libibcm, 1.0.5)
AM_PROG_LIBTOOL
diff --git a/examples/cmpost.c b/examples/cmpost.c
deleted file mode 100644
index a85264b..0000000
--- a/examples/cmpost.c
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id$
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <byteswap.h>
-
-#include <asm/byteorder.h>
-#include <netinet/in.h>
-
-#include <infiniband/cm.h>
-#include <rdma/rdma_cma.h>
-
-struct cmtest {
- struct ibv_device *device;
- struct ib_cm_device *cm_dev;
- struct ibv_context *verbs;
- struct ibv_pd *pd;
-
- /* cm info */
- struct ibv_sa_path_rec path_rec;
-
- struct cmtest_node *nodes;
- int conn_index;
- int connects_left;
- int disconnects_left;
-
- /* memory region info */
- struct ibv_mr *mr;
- void *mem;
-};
-
-static struct cmtest test;
-static int message_count = 10;
-static int message_size = 100;
-static int connections = 1;
-static int is_server = 1;
-
-struct cmtest_node {
- int id;
- struct ibv_cq *cq;
- struct ibv_qp *qp;
- struct ib_cm_id *cm_id;
- int connected;
-};
-
-static int post_recvs(struct cmtest_node *node)
-{
- struct ibv_recv_wr recv_wr, *recv_failure;
- struct ibv_sge sge;
- int i, ret = 0;
-
- if (!message_count)
- return 0;
-
- recv_wr.next = NULL;
- recv_wr.sg_list = &sge;
- recv_wr.num_sge = 1;
- recv_wr.wr_id = (uintptr_t) node;
-
- sge.length = message_size;
- sge.lkey = test.mr->lkey;
- sge.addr = (uintptr_t) test.mem;
-
- for (i = 0; i < message_count && !ret; i++ ) {
- ret = ibv_post_recv(node->qp, &recv_wr, &recv_failure);
- if (ret) {
- printf("failed to post receives: %d\n", ret);
- break;
- }
- }
- return ret;
-}
-
-static int modify_to_rtr(struct cmtest_node *node)
-{
- struct ibv_qp_attr qp_attr;
- int qp_attr_mask, ret;
-
- qp_attr.qp_state = IBV_QPS_INIT;
- ret = ib_cm_init_qp_attr(node->cm_id, &qp_attr, &qp_attr_mask);
- if (ret) {
- printf("failed to init QP attr for INIT: %d\n", ret);
- return ret;
- }
- ret = ibv_modify_qp(node->qp, &qp_attr, qp_attr_mask);
- if (ret) {
- printf("failed to modify QP to INIT: %d\n", ret);
- return ret;
- }
- qp_attr.qp_state = IBV_QPS_RTR;
- ret = ib_cm_init_qp_attr(node->cm_id, &qp_attr, &qp_attr_mask);
- if (ret) {
- printf("failed to init QP attr for RTR: %d\n", ret);
- return ret;
- }
- qp_attr.rq_psn = node->qp->qp_num;
- ret = ibv_modify_qp(node->qp, &qp_attr, qp_attr_mask);
- if (ret) {
- printf("failed to modify QP to RTR: %d\n", ret);
- return ret;
- }
- return 0;
-}
-
-static int modify_to_rts(struct cmtest_node *node)
-{
- struct ibv_qp_attr qp_attr;
- int qp_attr_mask, ret;
-
- qp_attr.qp_state = IBV_QPS_RTS;
- ret = ib_cm_init_qp_attr(node->cm_id, &qp_attr, &qp_attr_mask);
- if (ret) {
- printf("failed to init QP attr for RTS: %d\n", ret);
- return ret;
- }
- ret = ibv_modify_qp(node->qp, &qp_attr, qp_attr_mask);
- if (ret) {
- printf("failed to modify QP to RTS: %d\n", ret);
- return ret;
- }
- return 0;
-}
-
-static void req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
-{
- struct cmtest_node *node;
- struct ib_cm_req_event_param *req;
- struct ib_cm_rep_param rep;
- int ret;
-
- if (test.conn_index == connections)
- goto error1;
- node = &test.nodes[test.conn_index++];
-
- node->cm_id = cm_id;
- cm_id->context = node;
-
- ret = modify_to_rtr(node);
- if (ret)
- goto error2;
-
- ret = post_recvs(node);
- if (ret)
- goto error2;
-
- req = &event->param.req_rcvd;
- memset(&rep, 0, sizeof rep);
- rep.qp_num = node->qp->qp_num;
- rep.srq = (node->qp->srq != NULL);
- rep.starting_psn = node->qp->qp_num;
- rep.responder_resources = req->responder_resources;
- rep.initiator_depth = req->initiator_depth;
- rep.target_ack_delay = 20;
- rep.flow_control = req->flow_control;
- rep.rnr_retry_count = req->rnr_retry_count;
-
- ret = ib_cm_send_rep(cm_id, &rep);
- if (ret) {
- printf("failed to send CM REP: %d\n", ret);
- goto error2;
- }
- return;
-error2:
- test.disconnects_left--;
- test.connects_left--;
-error1:
- printf("failing connection request\n");
- ib_cm_send_rej(cm_id, IB_CM_REJ_UNSUPPORTED, NULL, 0, NULL, 0);
-}
-
-static void rep_handler(struct cmtest_node *node, struct ib_cm_event *event)
-{
- int ret;
-
- ret = modify_to_rtr(node);
- if (ret)
- goto error;
-
- ret = modify_to_rts(node);
- if (ret)
- goto error;
-
- ret = post_recvs(node);
- if (ret)
- goto error;
-
- ret = ib_cm_send_rtu(node->cm_id, NULL, 0);
- if (ret) {
- printf("failed to send CM RTU: %d\n", ret);
- goto error;
- }
- node->connected = 1;
- test.connects_left--;
- return;
-error:
- printf("failing connection reply\n");
- ib_cm_send_rej(node->cm_id, IB_CM_REJ_UNSUPPORTED, NULL, 0, NULL, 0);
- test.disconnects_left--;
- test.connects_left--;
-}
-
-static void rtu_handler(struct cmtest_node *node)
-{
- int ret;
-
- ret = modify_to_rts(node);
- if (ret)
- goto error;
-
- node->connected = 1;
- test.connects_left--;
- return;
-error:
- printf("aborting connection - disconnecting\n");
- ib_cm_send_dreq(node->cm_id, NULL, 0);
- test.disconnects_left--;
- test.connects_left--;
-}
-
-static void cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
-{
- struct cmtest_node *node = cm_id->context;
-
- switch (event->event) {
- case IB_CM_REQ_RECEIVED:
- req_handler(cm_id, event);
- break;
- case IB_CM_REP_RECEIVED:
- rep_handler(node, event);
- break;
- case IB_CM_RTU_RECEIVED:
- rtu_handler(node);
- break;
- case IB_CM_DREQ_RECEIVED:
- node->connected = 0;
- ib_cm_send_drep(node->cm_id, NULL, 0);
- test.disconnects_left--;
- break;
- case IB_CM_DREP_RECEIVED:
- test.disconnects_left--;
- break;
- case IB_CM_REJ_RECEIVED:
- printf("Received REJ\n");
- /* fall through */
- case IB_CM_REQ_ERROR:
- case IB_CM_REP_ERROR:
- printf("Error sending REQ or REP\n");
- test.disconnects_left--;
- test.connects_left--;
- break;
- case IB_CM_DREQ_ERROR:
- test.disconnects_left--;
- printf("Error sending DREQ\n");
- break;
- default:
- break;
- }
-}
-
-static int init_node(struct cmtest_node *node, struct ibv_qp_init_attr *qp_attr)
-{
- int cqe, ret;
-
- if (!is_server) {
- ret = ib_cm_create_id(test.cm_dev, &node->cm_id, node);
- if (ret) {
- printf("failed to create cm_id: %d\n", ret);
- return ret;
- }
- }
-
- cqe = message_count ? message_count * 2 : 2;
- node->cq = ibv_create_cq(test.verbs, cqe, node, NULL, 0);
- if (!node->cq) {
- printf("unable to create CQ\n");
- goto error1;
- }
-
- qp_attr->send_cq = node->cq;
- qp_attr->recv_cq = node->cq;
- node->qp = ibv_create_qp(test.pd, qp_attr);
- if (!node->qp) {
- printf("unable to create QP\n");
- goto error2;
- }
- return 0;
-error2:
- ibv_destroy_cq(node->cq);
-error1:
- if (!is_server)
- ib_cm_destroy_id(node->cm_id);
- return -1;
-}
-
-static void destroy_node(struct cmtest_node *node)
-{
- ibv_destroy_qp(node->qp);
- ibv_destroy_cq(node->cq);
- if (node->cm_id)
- ib_cm_destroy_id(node->cm_id);
-}
-
-static int create_nodes(void)
-{
- struct ibv_qp_init_attr qp_attr;
- int ret, i;
-
- test.nodes = malloc(sizeof *test.nodes * connections);
- if (!test.nodes) {
- printf("unable to allocate memory for test nodes\n");
- return -1;
- }
- memset(test.nodes, 0, sizeof *test.nodes * connections);
-
- memset(&qp_attr, 0, sizeof qp_attr);
- qp_attr.cap.max_send_wr = message_count ? message_count : 1;
- qp_attr.cap.max_recv_wr = message_count ? message_count : 1;
- qp_attr.cap.max_send_sge = 1;
- qp_attr.cap.max_recv_sge = 1;
- qp_attr.qp_type = IBV_QPT_RC;
-
- for (i = 0; i < connections; i++) {
- test.nodes[i].id = i;
- ret = init_node(&test.nodes[i], &qp_attr);
- if (ret)
- goto error;
- }
- return 0;
-error:
- while (--i >= 0)
- destroy_node(&test.nodes[i]);
- free(test.nodes);
- return ret;
-}
-
-static void destroy_nodes(void)
-{
- int i;
-
- for (i = 0; i < connections; i++)
- destroy_node(&test.nodes[i]);
- free(test.nodes);
-}
-
-static int create_messages(void)
-{
- if (!message_size)
- message_count = 0;
-
- if (!message_count)
- return 0;
-
- test.mem = malloc(message_size);
- if (!test.mem) {
- printf("failed message allocation\n");
- return -1;
- }
- test.mr = ibv_reg_mr(test.pd, test.mem, message_size,
- IBV_ACCESS_LOCAL_WRITE);
- if (!test.mr) {
- printf("failed to reg MR\n");
- goto err;
- }
- return 0;
-err:
- free(test.mem);
- return -1;
-}
-
-static void destroy_messages(void)
-{
- if (!message_count)
- return;
-
- ibv_dereg_mr(test.mr);
- free(test.mem);
-}
-
-static int init(void)
-{
- struct ibv_device **dev_list;
- int ret;
-
- test.connects_left = connections;
- test.disconnects_left = connections;
-
- dev_list = ibv_get_device_list(NULL);
- test.device = dev_list[0];
- if (!test.device)
- return -1;
-
- test.verbs = ibv_open_device(test.device);
- if (!test.verbs)
- return -1;
-
- test.cm_dev = ib_cm_open_device(test.verbs);
- if (!test.cm_dev)
- return -1;
-
- test.pd = ibv_alloc_pd(test.verbs);
- if (!test.pd) {
- printf("failed to alloc PD\n");
- return -1;
- }
- ret = create_messages();
- if (ret) {
- printf("unable to create test messages\n");
- goto error1;
- }
- ret = create_nodes();
- if (ret) {
- printf("unable to create test nodes\n");
- goto error2;
- }
- return 0;
-error2:
- destroy_messages();
-error1:
- ibv_dealloc_pd(test.pd);
- return -1;
-}
-
-static void cleanup(void)
-{
- destroy_nodes();
- destroy_messages();
- ibv_dealloc_pd(test.pd);
- ib_cm_close_device(test.cm_dev);
- ibv_close_device(test.verbs);
-}
-
-static int send_msgs(void)
-{
- struct ibv_send_wr send_wr, *bad_send_wr;
- struct ibv_sge sge;
- int i, m, ret;
-
- send_wr.next = NULL;
- send_wr.sg_list = &sge;
- send_wr.num_sge = 1;
- send_wr.opcode = IBV_WR_SEND;
- send_wr.send_flags = IBV_SEND_SIGNALED;
- send_wr.wr_id = 0;
-
- sge.addr = (uintptr_t) test.mem;
- sge.length = message_size;
- sge.lkey = test.mr->lkey;
-
- for (i = 0; i < connections; i++) {
- if (!test.nodes[i].connected)
- continue;
-
- for (m = 0; m < message_count; m++) {
- ret = ibv_post_send(test.nodes[i].qp, &send_wr,
- &bad_send_wr);
- if (ret)
- return ret;
- }
- }
- return 0;
-}
-
-static int poll_cqs(void)
-{
- struct ibv_wc wc[8];
- int done, i, ret;
-
- for (i = 0; i < connections; i++) {
- if (!test.nodes[i].connected)
- continue;
-
- for (done = 0; done < message_count; done += ret) {
- ret = ibv_poll_cq(test.nodes[i].cq, 8, wc);
- if (ret < 0) {
- printf("failed polling CQ: %d\n", ret);
- return ret;
- }
- }
- }
- return 0;
-}
-
-static void connect_events(void)
-{
- struct ib_cm_event *event;
- int err = 0;
-
- while (test.connects_left && !err) {
- err = ib_cm_get_event(test.cm_dev, &event);
- if (!err) {
- cm_handler(event->cm_id, event);
- ib_cm_ack_event(event);
- }
- }
-}
-
-static void disconnect_events(void)
-{
- struct ib_cm_event *event;
- int err = 0;
-
- while (test.disconnects_left && !err) {
- err = ib_cm_get_event(test.cm_dev, &event);
- if (!err) {
- cm_handler(event->cm_id, event);
- ib_cm_ack_event(event);
- }
- }
-}
-
-static void run_server(void)
-{
- struct ib_cm_id *listen_id;
- int i, ret;
-
- printf("starting server\n");
- if (ib_cm_create_id(test.cm_dev, &listen_id, &test)) {
- printf("listen request failed\n");
- return;
- }
- ret = ib_cm_listen(listen_id, __cpu_to_be64(0x1000), 0);
- if (ret) {
- printf("failure trying to listen: %d\n", ret);
- goto out;
- }
-
- connect_events();
-
- if (message_count) {
- printf("initiating data transfers\n");
- if (send_msgs())
- goto out;
- printf("receiving data transfers\n");
- if (poll_cqs())
- goto out;
- printf("data transfers complete\n");
- }
-
- printf("disconnecting\n");
- for (i = 0; i < connections; i++) {
- if (!test.nodes[i].connected)
- continue;
-
- test.nodes[i].connected = 0;
- ib_cm_send_dreq(test.nodes[i].cm_id, NULL, 0);
- }
- disconnect_events();
- printf("disconnected\n");
-out:
- ib_cm_destroy_id(listen_id);
-}
-
-static int get_dst_addr(char *dst, struct sockaddr_in *addr_in)
-{
- struct addrinfo *res;
- int ret;
-
- ret = getaddrinfo(dst, NULL, NULL, &res);
- if (ret)
- return ret;
-
- if (res->ai_family != PF_INET) {
- ret = -1;
- goto out;
- }
-
- *addr_in = *(struct sockaddr_in *) res->ai_addr;
- addr_in->sin_port = 7471;
-out:
- freeaddrinfo(res);
- return ret;
-}
-
-static int query_for_path(char *dst)
-{
- struct rdma_event_channel *channel;
- struct rdma_cm_id *id;
- struct sockaddr_in addr_in;
- struct rdma_cm_event *event;
- int ret;
-
- ret = get_dst_addr(dst, &addr_in);
- if (ret)
- return ret;
-
- channel = rdma_create_event_channel();
- if (!channel)
- return -1;
-
- ret = rdma_create_id(channel, &id, NULL, RDMA_PS_TCP);
- if (ret)
- goto destroy_channel;
-
- ret = rdma_resolve_addr(id, NULL, (struct sockaddr *) &addr_in, 2000);
- if (ret)
- goto out;
-
- ret = rdma_get_cm_event(channel, &event);
- if (!ret && event->event != RDMA_CM_EVENT_ADDR_RESOLVED)
- ret = event->status;
- rdma_ack_cm_event(event);
- if (ret)
- goto out;
-
- ret = rdma_resolve_route(id, 2000);
- if (ret)
- goto out;
-
- ret = rdma_get_cm_event(channel, &event);
- if (!ret && event->event != RDMA_CM_EVENT_ROUTE_RESOLVED)
- ret = event->status;
- rdma_ack_cm_event(event);
- if (ret)
- goto out;
-
- test.path_rec = id->route.path_rec[0];
-out:
- rdma_destroy_id(id);
-destroy_channel:
- rdma_destroy_event_channel(channel);
- return ret;
-}
-
-static void run_client(char *dst)
-{
- struct ib_cm_req_param req;
- int i, ret;
-
- printf("starting client\n");
- ret = query_for_path(dst);
- if (ret) {
- printf("failed path record query: %d\n", ret);
- return;
- }
-
- memset(&req, 0, sizeof req);
- req.primary_path = &test.path_rec;
- req.service_id = __cpu_to_be64(0x1000);
- req.responder_resources = 1;
- req.initiator_depth = 1;
- req.remote_cm_response_timeout = 20;
- req.local_cm_response_timeout = 20;
- req.retry_count = 5;
- req.max_cm_retries = 5;
-
- printf("connecting\n");
- for (i = 0; i < connections; i++) {
- req.qp_num = test.nodes[i].qp->qp_num;
- req.qp_type = IBV_QPT_RC;
- req.srq = (test.nodes[i].qp->srq != NULL);
- req.starting_psn = test.nodes[i].qp->qp_num;
- ret = ib_cm_send_req(test.nodes[i].cm_id, &req);
- if (ret) {
- printf("failure sending REQ: %d\n", ret);
- return;
- }
- }
-
- connect_events();
-
- if (message_count) {
- printf("receiving data transfers\n");
- if (poll_cqs())
- goto out;
- printf("initiating data transfers\n");
- if (send_msgs())
- goto out;
- printf("data transfers complete\n");
- }
-out:
- disconnect_events();
-}
-
-int main(int argc, char **argv)
-{
- if (argc != 1 && argc != 2) {
- printf("usage: %s [server_ip_addr]\n", argv[0]);
- exit(1);
- }
-
- is_server = (argc == 1);
- if (init())
- exit(1);
-
- if (is_server)
- run_server();
- else
- run_client(argv[1]);
-
- printf("test complete\n");
- cleanup();
- return 0;
-}
diff --git a/libibcm.spec.in b/libibcm.spec
similarity index 96%
copy from libibcm.spec.in
copy to libibcm.spec
index bf2663a..6d893eb 100644
--- a/libibcm.spec.in
+++ b/libibcm.spec
@@ -1,7 +1,7 @@
-%define ver @VERSION@
+%define ver 1.0.5
Name: libibcm
-Version: 1.0.4
+Version: 1.0.5
Release: 1%{?dist}
Summary: Userspace InfiniBand Communication Manager.
diff --git a/libibcm.spec.in b/libibcm.spec.in
index bf2663a..ce08272 100644
--- a/libibcm.spec.in
+++ b/libibcm.spec.in
@@ -1,7 +1,7 @@
%define ver @VERSION@
Name: libibcm
-Version: 1.0.4
+Version: 1.0.5
Release: 1%{?dist}
Summary: Userspace InfiniBand Communication Manager.
diff --git a/src/cm.c b/src/cm.c
index 571e28a..440ea45 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -71,6 +71,13 @@ enum {
IB_UCM_MAX_DEVICES = 32
};
+static inline int ERR(int err)
+{
+ errno = err;
+ return -1;
+}
+
+
#define CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, type, size) \
do { \
struct cm_abi_cmd_hdr *hdr; \
@@ -78,7 +85,7 @@ do { \
size = sizeof(*hdr) + sizeof(*cmd); \
msg = alloca(size); \
if (!msg) \
- return -ENOMEM; \
+ return ERR(ENOMEM); \
hdr = msg; \
cmd = msg + sizeof(*hdr); \
hdr->cmd = type; \
@@ -87,7 +94,7 @@ do { \
memset(cmd, 0, sizeof(*cmd)); \
resp = alloca(sizeof(*resp)); \
if (!resp) \
- return -ENOMEM; \
+ return ERR(ENOMEM); \
cmd->response = (uintptr_t)resp;\
} while (0)
@@ -98,7 +105,7 @@ do { \
size = sizeof(*hdr) + sizeof(*cmd); \
msg = alloca(size); \
if (!msg) \
- return -ENOMEM; \
+ return ERR(ENOMEM); \
hdr = msg; \
cmd = msg + sizeof(*hdr); \
hdr->cmd = type; \
@@ -260,7 +267,7 @@ int ib_cm_create_id(struct ib_cm_device *device,
cm_id_priv = ib_cm_alloc_id(device, context);
if (!cm_id_priv)
- return -ENOMEM;
+ return ERR(ENOMEM);
CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_CREATE_ID, size);
cmd->uid = (uintptr_t) cm_id_priv;
@@ -293,7 +300,7 @@ int ib_cm_destroy_id(struct ib_cm_id *cm_id)
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : -1;
VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
@@ -317,14 +324,14 @@ int ib_cm_attr_id(struct ib_cm_id *cm_id, struct ib_cm_attr_param *param)
int size;
if (!param)
- return -EINVAL;
+ return ERR(EINVAL);
CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_ATTR_ID, size);
cmd->id = cm_id->handle;
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : -1;
VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
@@ -346,7 +353,7 @@ int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
int size;
if (!qp_attr || !qp_attr_mask)
- return -EINVAL;
+ return ERR(EINVAL);
CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_INIT_QP_ATTR, size);
cmd->id = cm_id->handle;
@@ -354,7 +361,7 @@ int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : result;
VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
@@ -380,7 +387,7 @@ int ib_cm_listen(struct ib_cm_id *cm_id,
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : -1;
return 0;
}
@@ -395,7 +402,7 @@ int ib_cm_send_req(struct ib_cm_id *cm_id, struct ib_cm_req_param *param)
int size;
if (!param)
- return -EINVAL;
+ return ERR(EINVAL);
CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_REQ, size);
cmd->id = cm_id->handle;
@@ -417,7 +424,7 @@ int ib_cm_send_req(struct ib_cm_id *cm_id, struct ib_cm_req_param *param)
if (param->primary_path) {
p_path = alloca(sizeof(*p_path));
if (!p_path)
- return -ENOMEM;
+ return ERR(ENOMEM);
ibv_copy_path_rec_to_kern(p_path, param->primary_path);
cmd->primary_path = (uintptr_t) p_path;
@@ -426,7 +433,7 @@ int ib_cm_send_req(struct ib_cm_id *cm_id, struct ib_cm_req_param *param)
if (param->alternate_path) {
a_path = alloca(sizeof(*a_path));
if (!a_path)
- return -ENOMEM;
+ return ERR(ENOMEM);
ibv_copy_path_rec_to_kern(a_path, param->alternate_path);
cmd->alternate_path = (uintptr_t) a_path;
@@ -439,7 +446,7 @@ int ib_cm_send_req(struct ib_cm_id *cm_id, struct ib_cm_req_param *param)
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : -1;
return 0;
}
@@ -452,7 +459,7 @@ int ib_cm_send_rep(struct ib_cm_id *cm_id, struct ib_cm_rep_param *param)
int size;
if (!param)
- return -EINVAL;
+ return ERR(EINVAL);
CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_REP, size);
cmd->uid = (uintptr_t) container_of(cm_id, struct cm_id_private, id);
@@ -474,7 +481,7 @@ int ib_cm_send_rep(struct ib_cm_id *cm_id, struct ib_cm_rep_param *param)
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : -1;
return 0;
}
@@ -499,7 +506,7 @@ static inline int cm_send_private_data(struct ib_cm_id *cm_id,
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : -1;
return 0;
}
@@ -540,7 +547,7 @@ static int cm_establish(struct ib_cm_id *cm_id)
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : -1;
return 0;
}
@@ -556,7 +563,7 @@ int ib_cm_notify(struct ib_cm_id *cm_id, enum ibv_event_type event)
if (event == IBV_EVENT_COMM_EST)
return cm_establish(cm_id);
else
- return -EINVAL;
+ return ERR(EINVAL);
}
CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_NOTIFY, size);
@@ -565,7 +572,7 @@ int ib_cm_notify(struct ib_cm_id *cm_id, enum ibv_event_type event)
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : -1;
return 0;
}
@@ -599,7 +606,7 @@ static inline int cm_send_status(struct ib_cm_id *cm_id,
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : -1;
return 0;
}
@@ -649,7 +656,7 @@ int ib_cm_send_mra(struct ib_cm_id *cm_id,
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : result;
return 0;
}
@@ -671,7 +678,7 @@ int ib_cm_send_lap(struct ib_cm_id *cm_id,
if (alternate_path) {
abi_path = alloca(sizeof(*abi_path));
if (!abi_path)
- return -ENOMEM;
+ return ERR(ENOMEM);
ibv_copy_path_rec_to_kern(abi_path, alternate_path);
cmd->path = (uintptr_t) abi_path;
@@ -684,7 +691,7 @@ int ib_cm_send_lap(struct ib_cm_id *cm_id,
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : -1;
return 0;
}
@@ -699,7 +706,7 @@ int ib_cm_send_sidr_req(struct ib_cm_id *cm_id,
int size;
if (!param)
- return -EINVAL;
+ return ERR(EINVAL);
CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_SIDR_REQ, size);
cmd->id = cm_id->handle;
@@ -711,7 +718,7 @@ int ib_cm_send_sidr_req(struct ib_cm_id *cm_id,
if (param->path) {
abi_path = alloca(sizeof(*abi_path));
if (!abi_path)
- return -ENOMEM;
+ return ERR(ENOMEM);
ibv_copy_path_rec_to_kern(abi_path, param->path);
cmd->path = (uintptr_t) abi_path;
@@ -724,7 +731,7 @@ int ib_cm_send_sidr_req(struct ib_cm_id *cm_id,
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : result;
return 0;
}
@@ -738,7 +745,7 @@ int ib_cm_send_sidr_rep(struct ib_cm_id *cm_id,
int size;
if (!param)
- return -EINVAL;
+ return ERR(EINVAL);
CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_SIDR_REP, size);
cmd->id = cm_id->handle;
@@ -758,7 +765,7 @@ int ib_cm_send_sidr_rep(struct ib_cm_id *cm_id,
result = write(cm_id->device->fd, msg, size);
if (result != size)
- return (result > 0) ? -ENODATA : result;
+ return (result >= 0) ? ERR(ENODATA) : -1;
return 0;
}
@@ -827,12 +834,12 @@ int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
int size;
if (!event)
- return -EINVAL;
+ return ERR(EINVAL);
size = sizeof(*hdr) + sizeof(*cmd);
msg = alloca(size);
if (!msg)
- return -ENOMEM;
+ return ERR(ENOMEM);
hdr = msg;
cmd = msg + sizeof(*hdr);
@@ -845,7 +852,7 @@ int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
resp = alloca(sizeof(*resp));
if (!resp)
- return -ENOMEM;
+ return ERR(ENOMEM);
cmd->response = (uintptr_t) resp;
cmd->data_len = (uint8_t)(~0U);
@@ -853,13 +860,13 @@ int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
data = malloc(cmd->data_len);
if (!data) {
- result = -ENOMEM;
+ result = ERR(ENOMEM);
goto done;
}
info = malloc(cmd->info_len);
if (!info) {
- result = -ENOMEM;
+ result = ERR(ENOMEM);
goto done;
}
@@ -868,7 +875,7 @@ int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
result = write(device->fd, msg, size);
if (result != size) {
- result = (result > 0) ? -ENODATA : result;
+ result = (result >= 0) ? ERR(ENODATA) : -1;
goto done;
}
@@ -879,7 +886,7 @@ int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
*/
evt = malloc(sizeof(*evt));
if (!evt) {
- result = -ENOMEM;
+ result = ERR(ENOMEM);
goto done;
}
memset(evt, 0, sizeof(*evt));
@@ -889,7 +896,7 @@ int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
if (resp->present & CM_ABI_PRES_PRIMARY) {
path_a = malloc(sizeof(*path_a));
if (!path_a) {
- result = -ENOMEM;
+ result = ERR(ENOMEM);
goto done;
}
}
@@ -897,7 +904,7 @@ int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
if (resp->present & CM_ABI_PRES_ALTERNATE) {
path_b = malloc(sizeof(*path_b));
if (!path_b) {
- result = -ENOMEM;
+ result = ERR(ENOMEM);
goto done;
}
}
@@ -908,7 +915,7 @@ int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
cm_id_priv = ib_cm_alloc_id(evt->cm_id->device,
evt->cm_id->context);
if (!cm_id_priv) {
- result = -ENOMEM;
+ result = ERR(ENOMEM);
goto done;
}
cm_id_priv->id.handle = resp->id;
@@ -946,7 +953,7 @@ int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
cm_id_priv = ib_cm_alloc_id(evt->cm_id->device,
evt->cm_id->context);
if (!cm_id_priv) {
- result = -ENOMEM;
+ result = ERR(ENOMEM);
goto done;
}
cm_id_priv->id.handle = resp->id;
@@ -993,7 +1000,7 @@ int ib_cm_ack_event(struct ib_cm_event *event)
struct cm_id_private *cm_id_priv;
if (!event)
- return -EINVAL;
+ return ERR(EINVAL);
if (event->private_data)
free(event->private_data);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ofed/libibcm.git
More information about the Pkg-ofed-commits
mailing list