+++ /dev/null
-
-Modifications to common code:
-
-- general openib gen2 provider support
-- dapli_evd_eh_print_cqe() changes to avoid array mapping issues
-- CQ_WAIT_OBJECT support added
-- added dapl/openib directory
-- modify doc/dat.conf to add a example openib configuration
-- dapl_ep_alloc checks default attributes against device maximums
-
- dapl/common/dapl_adapter_util.h
- dapl/common/dapl_evd_dto_callb.c
- dapl/common/dapl_evd_util.c
- dapl/common/dapl_ep_util.c
- dapl/include/dapl.h
- dapl/udapl/dapl_evd_set_unwaitable.c
- dapl/udapl/linux/dapl_osd.c
- dapl/udapl/Makefile
- dat/udat/linux/dat_osd.c
- dat/udat/Makefile
- Makefile
- doc/dat.conf
-
-New files for openib provider
-
- dapl/openib/dapl_ib_cm.c
- dapl/openib/dapl_ib_cq.c
- dapl/openib/dapl_ib_dto.h
- dapl/openib/dapl_ib_mem.c
- dapl/openib/dapl_ib_qp.c
- dapl/openib/dapl_ib_util.c
- dapl/openib/dapl_ib_util.h
-
-A simple dapl test just for initial openIB testing...
-
- test/dtest/dtest.c
- test/dtest/makefile
-
- server: dtest -s
- client: dtest -h hostname
-
-Testing: dtest, dapltest - cl.sh regress.sh
-
-Setup:
-
- dapl/udapl/Makefile
-
-Known issues:
- no memory windows support in ibverbs, dat_create_rmr fails.
-
+++ /dev/null
-
-IB Verbs:
-- CQ resize
-- memory window support
-
-DAPL:
-- reinit EP needs a QP timewait completion notification
-- shared receive queue support
-
-Under discussion:
-- Shared memory in udapl and kernel module to support
-- merged DTO/connection
-
-
+++ /dev/null
-/*
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- * copy of which is available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/***************************************************************************
- *
- * Module: uDAPL
- *
- * Filename: dapl_ib_cm.c
- *
- * Author: Arlin Davis
- *
- * Created: 3/10/2005
- *
- * Description:
- *
- * The uDAPL openib provider - connection management
- *
- ****************************************************************************
- * Source Control System Information
- *
- * $Id: $
- *
- * Copyright (c) 2005 Voltaire Inc. All rights reserved.
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- * Copyright (c) 2004-2005, Mellanox Technologies, Inc. All rights reserved.
- * Copyright (c) 2003 Topspin Corporation. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- *
- **************************************************************************/
-
-#include "dapl.h"
-#include "dapl_adapter_util.h"
-#include "dapl_ep_util.h"
-#include "dapl_evd_util.h"
-#include "dapl_cr_util.h"
-#include "dapl_name_service.h"
-#include "dapl_ib_util.h"
-#include <sys/poll.h>
-#include <signal.h>
-
-/* prototypes */
-static void dapli_path_comp_handler(uint64_t req_id, void *context, int rec_num);
-static void dapli_rt_comp_handler(uint64_t req_id, void *context, int rec_num);
-static void dapli_rep_recv(struct dapl_cm_id *conn, struct ib_cm_event *rep_recv_param);
-static struct dapl_cm_id * dapli_req_recv(struct dapl_cm_id *conn, struct ib_cm_event *event);
-static int dapli_cm_active_cb(struct dapl_cm_id *conn, struct ib_cm_event *event);
-static int dapli_cm_passive_cb(struct dapl_cm_id *conn, struct ib_cm_event *event);
-
-/* prototypes */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-static inline uint64_t cpu_to_be64(uint64_t x) { return bswap_64(x); }
-#elif __BYTE_ORDER == __BIG_ENDIAN
-static inline uint64_t cpu_to_be64(uint64_t x) { return x; }
-#endif
-
-
-void dapli_ip_comp_handler(uint64_t req_id, void *context, int rec_num)
-{
- struct dapl_at_record *at_rec = context;
- struct sockaddr_in *ipv4_addr = (struct sockaddr_in*)at_rec->addr;
- int status;
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " ip_comp_handler: rec %p ->id %lld id %lld num %d %x\n",
- context, at_rec->req_id, req_id, rec_num,
- ipv4_addr->sin_addr.s_addr);
-
- if (rec_num <= 0) {
- struct ib_at_completion at_comp;
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " ip_comp_handler: resolution err %d retry %d\n",
- rec_num, at_rec->retries + 1);
-
- ipv4_addr->sin_addr.s_addr = 0;
-
- if ((++at_rec->retries > IB_MAX_AT_RETRY) || (rec_num == -EINTR))
- goto bail;
-
- at_comp.fn = dapli_ip_comp_handler;
- at_comp.context = at_rec;
-
- status = ib_at_ips_by_gid(&at_rec->hca_ptr->ib_trans.gid,
- &ipv4_addr->sin_addr.s_addr, 1,
- &at_comp, &at_rec->req_id);
- if (status < 0)
- goto bail;
-
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
- " ip_comp_handler: ips_by_gid %d rec %p->id %lld\n",
- status, at_rec, at_rec->req_id );
- }
-
- if (ipv4_addr->sin_addr.s_addr)
- dapl_os_wait_object_wakeup(at_rec->wait_object);
-
- return;
-bail:
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " ip_comp_handler: ERR: at_rec %p, id %lld num %d\n",
- at_rec, req_id, rec_num);
-
- dapl_os_wait_object_wakeup(at_rec->wait_object);
-}
-
-static void dapli_path_comp_handler(uint64_t req_id, void *context, int rec_num)
-{
- struct dapl_cm_id *conn = context;
- int status;
- ib_cm_events_t event;
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " path_comp_handler: ctxt %p, req_id %lld rec_num %d\n",
- context, req_id, rec_num);
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " path_comp_handler: SRC GID subnet %016llx id %016llx\n",
- (unsigned long long)cpu_to_be64(conn->dapl_path.sgid.global.subnet_prefix),
- (unsigned long long)cpu_to_be64(conn->dapl_path.sgid.global.interface_id) );
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " path_comp_handler: DST GID subnet %016llx id %016llx\n",
- (unsigned long long)cpu_to_be64(conn->dapl_path.dgid.global.subnet_prefix),
- (unsigned long long)cpu_to_be64(conn->dapl_path.dgid.global.interface_id) );
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " path_comp_handler: slid %x dlid %x mtu %x(%x) pktlife %x(%x)\n",
- ntohs(conn->dapl_path.slid), ntohs(conn->dapl_path.dlid),
- conn->dapl_path.mtu, conn->dapl_path.mtu_selector,
- conn->dapl_path.packet_life_time,
- conn->dapl_path.packet_life_time_selector );
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " path_comp_handler: hops %x npaths %x pkey %x tclass %x rate %x(%x)\n",
- conn->dapl_path.hop_limit, conn->dapl_path.numb_path,
- conn->dapl_path.pkey, conn->dapl_path.traffic_class,
- conn->dapl_path.rate, conn->dapl_path.rate_selector);
-
- if (rec_num <= 0) {
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " path_comp_handler: ERR %d retry %d\n",
- rec_num, conn->retries + 1);
- if (++conn->retries > IB_MAX_AT_RETRY) {
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " path_comp_handler: ERR no PATH (ep=%p)\n",
- conn->ep);
- event = IB_CME_DESTINATION_UNREACHABLE;
- goto bail;
- }
-
- status = ib_at_paths_by_route(&conn->dapl_rt, 0,
- &conn->dapl_path, 1,
- &conn->dapl_comp,
- &conn->dapl_comp.req_id);
- if (status) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " path_by_route: retry ERR %d id %lld\n",
- status, conn->dapl_comp.req_id);
- event = IB_CME_LOCAL_FAILURE;
- goto bail;
- }
- return;
- }
-
- /* Mellanox performance workaround - best performance is MTU of 1024 */
- if (conn->dapl_path.mtu > IBV_MTU_1024)
- conn->dapl_path.mtu = IBV_MTU_1024;
-
- conn->req.service_id = cpu_to_be64(conn->service_id);
- conn->req.primary_path = &conn->dapl_path;
- conn->req.alternate_path = NULL;
-
- status = ib_cm_send_req(conn->cm_id, &conn->req);
- if (status) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR, " ib_send_cm_req failed: %s\n",
- strerror(errno));
- event = IB_CME_LOCAL_FAILURE;
- goto bail;
- }
- return;
-
-bail:
- dapl_evd_connection_callback(conn, event, NULL, conn->ep);
-}
-
-static void dapli_rt_comp_handler(uint64_t req_id, void *context, int rec_num)
-{
- struct dapl_cm_id *conn = context;
- int status;
- ib_cm_events_t event;
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " rt_comp_handler: conn %p, req_id %lld rec_num %d\n",
- conn, req_id, rec_num);
-
- if (rec_num <= 0) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " dapl_rt_comp_handler: ERROR rec %d retry %d\n",
- rec_num, conn->retries+1 );
-
- if (++conn->retries > IB_MAX_AT_RETRY) {
- event = IB_CME_DESTINATION_UNREACHABLE;
- goto bail;
- }
-
- status = ib_at_route_by_ip(
- ((struct sockaddr_in *)&conn->r_addr)->sin_addr.s_addr,
- 0, 0, IB_AT_ROUTE_FORCE_ATS,
- &conn->dapl_rt,
- &conn->dapl_comp,&conn->dapl_comp.req_id);
- if (status < 0) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR, "dapl_rt_comp_handler: "
- "ib_at_route_by_ip failed with status %d\n",
- status);
- event = IB_CME_DESTINATION_UNREACHABLE;
- goto bail;
- }
- if (status == 1)
- dapli_rt_comp_handler(conn->dapl_comp.req_id, conn, 1);
-
- return;
- }
-
- if (!conn->dapl_rt.dgid.global.subnet_prefix ||
- req_id != conn->dapl_comp.req_id) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " dapl_rt_comp_handler: ERROR: cb id=%d(%d)\n",
- req_id, conn->dapl_comp.req_id );
- return;
- }
-
- conn->dapl_comp.fn = &dapli_path_comp_handler;
- conn->dapl_comp.context = conn;
- conn->retries = 0;
- status = ib_at_paths_by_route(&conn->dapl_rt, 0, &conn->dapl_path, 1,
- &conn->dapl_comp,
- &conn->dapl_comp.req_id);
- if (status) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- "dapl_rt_comp_handler: ib_at_paths_by_route "
- "returned %d id %lld\n", status,
- conn->dapl_comp.req_id);
- event = IB_CME_LOCAL_FAILURE;
- goto bail;
- }
- return;
-
-bail:
- dapl_evd_connection_callback(conn, event, NULL, conn->ep);
-}
-
-static void dapli_destroy_cm_id(struct dapl_cm_id *conn)
-{
- int in_callback;
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " destroy_cm_id: conn %p id %d\n",conn,conn->cm_id);
-
- dapl_os_lock(&conn->lock);
- conn->destroy = 1;
- in_callback = conn->in_callback;
- dapl_os_unlock(&conn->lock);
-
- if (!in_callback) {
- ib_cm_destroy_id(conn->cm_id);
- if (conn->ep)
- conn->ep->cm_handle = IB_INVALID_HANDLE;
-
- dapl_os_free(conn, sizeof(*conn));
- }
-}
-
-static void dapli_rep_recv(struct dapl_cm_id *conn,
- struct ib_cm_event *event)
-{
- int status;
-
- if (conn->ep->qp_handle == IB_INVALID_HANDLE) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " dapli_rep_recv: invalid qp "
- "handle\n");
- goto disc;
- }
-
- /* move QP state to RTR and RTS */
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " rep_recv: RTR_RTS: id %d rqp %x rlid %x rSID %d\n",
- conn->cm_id,event->param.rep_rcvd.remote_qpn,
- ntohs(conn->req.primary_path->dlid),conn->service_id);
-
- if ( dapls_modify_qp_state( conn->ep->qp_handle,
- IBV_QPS_RTR, conn ) != DAT_SUCCESS )
- goto disc;
-
- if ( dapls_modify_qp_state( conn->ep->qp_handle,
- IBV_QPS_RTS, conn ) != DAT_SUCCESS)
- goto disc;
-
-
- status = ib_cm_send_rtu(conn->cm_id, NULL, 0);
- if (status) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " dapli_rep_recv: ib_send_cm_rtu "
- "failed: %d\n", status);
- goto disc;
- }
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " rep_recv: conn %p id %d CONNECTED!\n",
- conn, conn->cm_id );
-
- dapl_evd_connection_callback(conn, IB_CME_CONNECTED,
- event->private_data, conn->ep);
- return;
-
-disc:
- dapl_evd_connection_callback(conn, IB_CME_LOCAL_FAILURE, NULL,
- conn->ep);
-}
-
-static struct dapl_cm_id * dapli_req_recv(struct dapl_cm_id *conn,
- struct ib_cm_event *event)
-{
- struct dapl_cm_id *new_conn;
-
- if (conn->sp == NULL) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " dapli_rep_recv: on invalid listen "
- "handle\n");
- return NULL;
- }
-
- /* allocate new cm_id and merge listen parameters */
- new_conn = dapl_os_alloc(sizeof(*new_conn));
- if (new_conn) {
-
- (void)dapl_os_memzero(new_conn, sizeof(*new_conn));
- new_conn->cm_id = event->cm_id; /* provided by uCM */
- event->cm_id->context = new_conn; /* update CM_ID context */
- new_conn->sp = conn->sp;
- new_conn->hca = conn->hca;
- new_conn->service_id = conn->service_id;
-
- /* save request information in new conn */
- dapl_os_memcpy(&new_conn->req_rcvd,
- &event->param.req_rcvd,
- sizeof(struct ib_cm_req_event_param));
-
- new_conn->req_rcvd.primary_path = &new_conn->dapl_path;
- new_conn->req_rcvd.alternate_path = NULL;
-
- dapl_os_memcpy(new_conn->req_rcvd.primary_path,
- event->param.req_rcvd.primary_path,
- sizeof(struct ib_sa_path_rec));
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM, " passive_cb: "
- "REQ on HCA %p SP %p SID %d LID %d new_id %d pd %p\n",
- new_conn->hca, new_conn->sp,
- conn->service_id, conn->cm_id, new_conn->cm_id,
- event->private_data );
-
- }
- return new_conn;
-}
-
-
-static int dapli_cm_active_cb(struct dapl_cm_id *conn,
- struct ib_cm_event *event)
-{
- int destroy;
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " active_cb: conn %p id %d event %d\n",
- conn, conn->cm_id, event->event );
-
- dapl_os_lock(&conn->lock);
- if (conn->destroy) {
- dapl_os_unlock(&conn->lock);
- return 0;
- }
- conn->in_callback = 1;
- dapl_os_unlock(&conn->lock);
-
- switch (event->event) {
- case IB_CM_REQ_ERROR:
- dapl_evd_connection_callback(conn,
- IB_CME_DESTINATION_UNREACHABLE,
- NULL, conn->ep);
- break;
- case IB_CM_REJ_RECEIVED:
- dapl_evd_connection_callback(conn, IB_CME_DESTINATION_REJECT,
- NULL, conn->ep);
- break;
- case IB_CM_REP_RECEIVED:
- dapli_rep_recv(conn, event);
- break;
- case IB_CM_DREQ_RECEIVED:
- ib_cm_send_drep(conn->cm_id, NULL, 0);
- break;
- case IB_CM_DREQ_ERROR:
- case IB_CM_DREP_RECEIVED:
- /* Wait to exit timewait. */
- break;
- case IB_CM_TIMEWAIT_EXIT:
- dapl_evd_connection_callback(conn, IB_CME_DISCONNECTED,
- NULL, conn->ep);
- break;
- default:
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " dapli_cm_active_cb_handler: Unexpected CM "
- "event %d on ID 0x%p\n", event->event, conn->cm_id);
- break;
- }
-
- dapl_os_lock(&conn->lock);
- destroy = conn->destroy;
- conn->in_callback = conn->destroy;
- dapl_os_unlock(&conn->lock);
- if (destroy) {
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " active_cb: DESTROY conn %p id %d \n",
- conn, conn->cm_id );
- if (conn->ep)
- conn->ep->cm_handle = IB_INVALID_HANDLE;
-
- dapl_os_free(conn, sizeof(*conn));
- }
- return(destroy);
-}
-
-static int dapli_cm_passive_cb(struct dapl_cm_id *conn,
- struct ib_cm_event *event)
-{
- int destroy;
- struct dapl_cm_id *new_conn;
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " passive_cb: conn %p id %d event %d\n",
- conn, conn->cm_id, event->event );
-
- dapl_os_lock(&conn->lock);
- if (conn->destroy) {
- dapl_os_unlock(&conn->lock);
- return 0;
- }
- conn->in_callback = 1;
- dapl_os_unlock(&conn->lock);
-
- switch (event->event) {
- case IB_CM_REQ_RECEIVED:
- /* create new conn object with new conn_id from event */
- new_conn = dapli_req_recv(conn,event);
-
- if (new_conn)
- dapls_cr_callback(new_conn,
- IB_CME_CONNECTION_REQUEST_PENDING,
- event->private_data, new_conn->sp);
- break;
- case IB_CM_REP_ERROR:
- dapls_cr_callback(conn, IB_CME_DESTINATION_UNREACHABLE,
- NULL, conn->sp);
- break;
- case IB_CM_REJ_RECEIVED:
- dapls_cr_callback(conn, IB_CME_DESTINATION_REJECT, NULL,
- conn->sp);
- break;
- case IB_CM_RTU_RECEIVED:
- /* move QP to RTS state */
- if ( dapls_modify_qp_state(conn->ep->qp_handle,
- IBV_QPS_RTS, conn ) != DAT_SUCCESS) {
- dapls_cr_callback(conn, IB_CME_LOCAL_FAILURE,
- NULL, conn->sp);
- } else {
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " passive_cb: conn %p id %d CONNECTED!\n",
- conn, conn->cm_id );
- dapls_cr_callback(conn, IB_CME_CONNECTED,
- NULL, conn->sp);
- }
- break;
- case IB_CM_DREQ_RECEIVED:
- ib_cm_send_drep(conn->cm_id, NULL, 0);
- break;
- case IB_CM_DREQ_ERROR:
- case IB_CM_DREP_RECEIVED:
- /* Wait to exit timewait. */
- break;
- case IB_CM_TIMEWAIT_EXIT:
- dapls_cr_callback(conn, IB_CME_DISCONNECTED, NULL, conn->sp);
- break;
- default:
- dapl_dbg_log(DAPL_DBG_TYPE_ERR, " dapl_cm_passive_cb_handler: "
- "Unexpected CM event %d on ID 0x%p\n",
- event->event, conn->cm_id);
- break;
- }
-
- dapl_os_lock(&conn->lock);
- destroy = conn->destroy;
- conn->in_callback = conn->destroy;
- dapl_os_unlock(&conn->lock);
- if (destroy) {
- if (conn->ep)
- conn->ep->cm_handle = IB_INVALID_HANDLE;
-
- dapl_os_free(conn, sizeof(*conn));
- }
- return(destroy);
-}
-
-
-/************************ DAPL provider entry points **********************/
-
-/*
- * dapls_ib_connect
- *
- * Initiate a connection with the passive listener on another node
- *
- * Input:
- * ep_handle,
- * remote_ia_address,
- * remote_conn_qual,
- * prd_size size of private data and structure
- * prd_prt pointer to private data structure
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INSUFFICIENT_RESOURCES
- * DAT_INVALID_PARAMETER
- *
- */
-DAT_RETURN
-dapls_ib_connect (
- IN DAT_EP_HANDLE ep_handle,
- IN DAT_IA_ADDRESS_PTR r_addr,
- IN DAT_CONN_QUAL r_qual,
- IN DAT_COUNT p_size,
- IN void *p_data )
-{
- DAPL_EP *ep_ptr;
- ib_qp_handle_t qp_ptr;
- int status;
- DAT_RETURN dat_status = DAT_INTERNAL_ERROR;
- ib_cm_handle_t conn;
-
- /*
- * Sanity check
- */
- if ( NULL == ep_handle )
- return DAT_SUCCESS;
-
- ep_ptr = (DAPL_EP*)ep_handle;
- qp_ptr = ep_ptr->qp_handle;
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM, " connect: rSID %d, pdata %p, ln %d\n",
- r_qual,p_data,p_size);
-
- /* Allocate CM and initialize lock */
- if ((conn = dapl_os_alloc(sizeof(*conn))) == NULL)
- return DAT_INSUFFICIENT_RESOURCES;
-
- (void)dapl_os_memzero(conn, sizeof(*conn));
-
- dat_status = dapl_os_lock_init(&conn->lock);
- if (dat_status != DAT_SUCCESS) {
- dapl_os_free(conn, sizeof(*conn));
- return DAT_INTERNAL_ERROR;
- }
-
- conn->ep = ep_ptr;
- conn->hca = ep_ptr->header.owner_ia->hca_ptr;
- status = ib_cm_create_id(conn->hca->ib_hca_handle,
- &conn->cm_id, conn);
- if (status < 0) {
- dat_status = dapl_convert_errno(errno,"create_cm_id");
- dapl_os_free(conn, sizeof(*conn));
- return dat_status;
- }
- ep_ptr->cm_handle = conn;
-
- /* Setup QP/CM parameters */
- (void)dapl_os_memzero(&conn->req,sizeof(conn->req));
- conn->service_id = r_qual;
- conn->req.qp_num = ep_ptr->qp_handle->qp_num;
- conn->req.qp_type = IBV_QPT_RC;
- conn->req.starting_psn = ep_ptr->qp_handle->qp_num;
- conn->req.private_data = p_data;
- conn->req.private_data_len = p_size;
- conn->req.peer_to_peer = 0;
- conn->req.responder_resources = IB_TARGET_MAX;
- conn->req.initiator_depth = IB_INITIATOR_DEPTH;
- conn->req.remote_cm_response_timeout = IB_CM_RESPONSE_TIMEOUT;
- conn->req.flow_control = 1;
- conn->req.local_cm_response_timeout = IB_CM_RESPONSE_TIMEOUT;
- conn->req.retry_count = IB_RC_RETRY_COUNT;
- conn->req.rnr_retry_count = IB_RNR_RETRY_COUNT;
- conn->req.max_cm_retries = IB_MAX_CM_RETRIES;
- conn->req.srq = 0;
-
- conn->dapl_comp.fn = &dapli_rt_comp_handler;
- conn->dapl_comp.context = conn;
- conn->retries = 0;
- dapl_os_memcpy(&conn->r_addr, r_addr, sizeof(DAT_SOCK_ADDR6));
-
- status = ib_at_route_by_ip(
- ((struct sockaddr_in *)&conn->r_addr)->sin_addr.s_addr,
- ((struct sockaddr_in *)&conn->hca->hca_address)->sin_addr.s_addr,
- 0, 0, &conn->dapl_rt, &conn->dapl_comp, &conn->dapl_comp.req_id);
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " connect: at_route requested(ret=%d,id=%d): SRC %x DST %x\n",
- status, conn->dapl_comp.req_id,
- ntohl(((struct sockaddr_in *)&conn->hca->hca_address)->sin_addr.s_addr),
- ntohl(((struct sockaddr_in *)&conn->r_addr)->sin_addr.s_addr));
-
- if (status < 0) {
- dat_status = dapl_convert_errno(errno,"ib_at_route_by_ip");
- dapli_destroy_cm_id(conn);
- return dat_status;
- }
-
- if (status > 0)
- dapli_rt_comp_handler(conn->dapl_comp.req_id, conn, status);
-
- return DAT_SUCCESS;
-}
-
-/*
- * dapls_ib_disconnect
- *
- * Disconnect an EP
- *
- * Input:
- * ep_handle,
- * disconnect_flags
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- *
- */
-DAT_RETURN
-dapls_ib_disconnect (
- IN DAPL_EP *ep_ptr,
- IN DAT_CLOSE_FLAGS close_flags )
-{
- ib_cm_handle_t conn = ep_ptr->cm_handle;
- int status;
-
- dapl_dbg_log (DAPL_DBG_TYPE_CM,
- " disconnect(ep %p, conn %p, id %d flags %x)\n",
- ep_ptr,conn, (conn?conn->cm_id:0),close_flags);
-
- if (conn == IB_INVALID_HANDLE)
- return DAT_SUCCESS;
-
- if (close_flags == DAT_CLOSE_ABRUPT_FLAG)
- dapli_destroy_cm_id(conn);
- else {
- status = ib_cm_send_dreq(conn->cm_id, NULL, 0);
- if (status)
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- "dapl_ib_disconnect: ID %p status %d\n",
- ep_ptr->cm_handle, status);
- }
-
- dapl_ep_legacy_post_disconnect(ep_ptr, close_flags)
-
- return DAT_SUCCESS;
-}
-
-/*
- * dapls_ib_disconnect_clean
- *
- * Clean up outstanding connection data. This routine is invoked
- * after the final disconnect callback has occurred. Only on the
- * ACTIVE side of a connection.
- *
- * Input:
- * ep_ptr DAPL_EP
- * active Indicates active side of connection
- *
- * Output:
- * none
- *
- * Returns:
- * void
- *
- */
-void
-dapls_ib_disconnect_clean (
- IN DAPL_EP *ep_ptr,
- IN DAT_BOOLEAN active,
- IN const ib_cm_events_t ib_cm_event )
-{
-
- /*
- * Clean up outstanding connection state
- */
- dapls_ib_disconnect(ep_ptr, DAT_CLOSE_ABRUPT_FLAG);
-
- if (ep_ptr->qp_handle != IB_INVALID_HANDLE)
- dapls_modify_qp_state(ep_ptr->qp_handle, IBV_QPS_ERR, 0 );
-}
-
-/*
- * dapl_ib_setup_conn_listener
- *
- * Have the CM set up a connection listener.
- *
- * Input:
- * ibm_hca_handle HCA handle
- * qp_handle QP handle
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INSUFFICIENT_RESOURCES
- * DAT_INTERNAL_ERROR
- * DAT_CONN_QUAL_UNAVAILBLE
- * DAT_CONN_QUAL_IN_USE
- *
- */
-DAT_RETURN
-dapls_ib_setup_conn_listener (
- IN DAPL_IA *ia_ptr,
- IN DAT_UINT64 ServiceID,
- IN DAPL_SP *sp_ptr )
-{
- DAT_RETURN dat_status = DAT_SUCCESS;
- int status;
- ib_cm_srvc_handle_t conn;
-
-
- /* Allocate CM and initialize lock */
- if ((conn = dapl_os_alloc(sizeof(*conn))) == NULL)
- return DAT_INSUFFICIENT_RESOURCES;
-
- (void)dapl_os_memzero(conn, sizeof(*conn));
-
- dat_status = dapl_os_lock_init(&conn->lock);
- if (dat_status != DAT_SUCCESS) {
- dapl_os_free(conn, sizeof(*conn));
- return DAT_INTERNAL_ERROR;
- }
-
- status = ib_cm_create_id(ia_ptr->hca_ptr->ib_hca_handle,
- &conn->cm_id, conn);
- if (status < 0) {
- dat_status = dapl_convert_errno(errno,"create_cm_id");
- dapl_os_free(conn, sizeof(*conn));
- return dat_status;
- }
-
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " setup_listener(ia_ptr %p SID %d sp %p conn %p id %d)\n",
- ia_ptr, ServiceID, sp_ptr, conn, conn->cm_id );
-
- sp_ptr->cm_srvc_handle = conn;
- conn->sp = sp_ptr;
- conn->hca = ia_ptr->hca_ptr;
- conn->service_id = ServiceID;
-
- dapl_dbg_log(DAPL_DBG_TYPE_EP,
- " setup_listener(conn=%p cm_id=%d)\n",
- sp_ptr->cm_srvc_handle,conn->cm_id);
-
- status = ib_cm_listen(conn->cm_id,
- cpu_to_be64(ServiceID), 0);
- if (status) {
- if (status == -EBUSY)
- dat_status = DAT_CONN_QUAL_IN_USE;
- else
- dat_status = DAT_INSUFFICIENT_RESOURCES;
-
- dapli_destroy_cm_id(conn);
- return dat_status;
- }
-
- /* success */
- return DAT_SUCCESS;
-}
-
-
-/*
- * dapl_ib_remove_conn_listener
- *
- * Have the CM remove a connection listener.
- *
- * Input:
- * ia_handle IA handle
- * ServiceID IB Channel Service ID
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INVALID_STATE
- *
- */
-DAT_RETURN
-dapls_ib_remove_conn_listener (
- IN DAPL_IA *ia_ptr,
- IN DAPL_SP *sp_ptr )
-{
- ib_cm_srvc_handle_t conn = sp_ptr->cm_srvc_handle;
-
- dapl_dbg_log (DAPL_DBG_TYPE_CM,
- " remove_listener(ia_ptr %p sp_ptr %p cm_ptr %p)\n",
- ia_ptr, sp_ptr, conn );
-
- if (conn != IB_INVALID_HANDLE) {
- sp_ptr->cm_srvc_handle = NULL;
- dapli_destroy_cm_id(conn);
- }
-
- return DAT_SUCCESS;
-}
-
-/*
- * dapls_ib_accept_connection
- *
- * Perform necessary steps to accept a connection
- *
- * Input:
- * cr_handle
- * ep_handle
- * private_data_size
- * private_data
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INSUFFICIENT_RESOURCES
- * DAT_INTERNAL_ERROR
- *
- */
-DAT_RETURN
-dapls_ib_accept_connection (
- IN DAT_CR_HANDLE cr_handle,
- IN DAT_EP_HANDLE ep_handle,
- IN DAT_COUNT p_size,
- IN const DAT_PVOID p_data )
-{
- DAPL_CR *cr_ptr;
- DAPL_EP *ep_ptr;
- DAPL_IA *ia_ptr;
- DAT_RETURN dat_status;
- int status;
- struct ib_cm_rep_param passive_params;
- struct dapl_cm_id *conn;
-
- cr_ptr = (DAPL_CR *) cr_handle;
- ep_ptr = (DAPL_EP *) ep_handle;
- ia_ptr = ep_ptr->header.owner_ia;
- conn = cr_ptr->ib_cm_handle;
-
- dapl_dbg_log (DAPL_DBG_TYPE_CM,
- " accept(cr %p conn %p, id %d, p_data %p, p_sz=%d)\n",
- cr_ptr, conn, conn->cm_id, p_data, p_size );
-
- /* Obtain size of private data structure & contents */
- if (p_size > IB_MAX_REP_PDATA_SIZE) {
- dat_status = DAT_ERROR(DAT_LENGTH_ERROR, DAT_NO_SUBTYPE);
- goto reject;
- }
-
- if (ep_ptr->qp_state == DAPL_QP_STATE_UNATTACHED) {
- /*
- * If we are lazy attaching the QP then we may need to
- * hook it up here. Typically, we run this code only for
- * DAT_PSP_PROVIDER_FLAG
- */
- dat_status = dapls_ib_qp_alloc(ia_ptr, ep_ptr, NULL);
- if (dat_status != DAT_SUCCESS) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " accept: ib_qp_alloc failed: %d\n",
- dat_status);
- goto reject;
- }
- }
-
- /* move QP to RTR state */
- dat_status = dapls_modify_qp_state(ep_ptr->qp_handle,
- IBV_QPS_RTR, conn);
- if (dat_status != DAT_SUCCESS ) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " accept: modify_qp_state failed: %d\n",
- dat_status);
- goto reject;
- }
-
- cr_ptr->param.local_ep_handle = ep_handle;
- ep_ptr->cm_handle = conn;
- conn->ep = ep_ptr;
-
- memset(&passive_params, 0, sizeof(passive_params));
- passive_params.private_data = p_data;
- passive_params.private_data_len = p_size;
- passive_params.qp_num = ep_ptr->qp_handle->qp_num;
- passive_params.starting_psn = ep_ptr->qp_handle->qp_num;
- passive_params.responder_resources = IB_TARGET_MAX;
- passive_params.initiator_depth = IB_INITIATOR_DEPTH;
- passive_params.rnr_retry_count = IB_RNR_RETRY_COUNT;
-
- status = ib_cm_send_rep(conn->cm_id, &passive_params);
- if (status) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR, " accept: "
- "ib_send_cm_rep failed: %d\n", status);
- dat_status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, 0);
- goto reject;
- }
- return DAT_SUCCESS;
-
-reject:
- ib_cm_send_rej(conn->cm_id, IB_CM_REJ_CONSUMER_DEFINED, NULL, 0,
- NULL, 0);
- dapli_destroy_cm_id(conn);
- return dat_status;
-
-}
-
-
-/*
- * dapls_ib_reject_connection
- *
- * Reject a connection
- *
- * Input:
- * cr_handle
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INTERNAL_ERROR
- *
- */
-DAT_RETURN
-dapls_ib_reject_connection (
- IN ib_cm_handle_t cm_handle,
- IN int reject_reason,
- IN DAT_COUNT private_data_size,
- IN const DAT_PVOID private_data)
-{
- int status;
-
- dapl_dbg_log (DAPL_DBG_TYPE_CM,
- " reject_connection(cm_handle %p reason %x)\n",
- cm_handle, reject_reason );
-
- if (cm_handle == IB_INVALID_HANDLE) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " reject_conn: invalid handle: reason %d\n",
- reject_reason);
- return DAT_SUCCESS;
- }
-
- status = ib_cm_send_rej(cm_handle->cm_id, IB_CM_REJ_CONSUMER_DEFINED,
- NULL, 0, NULL, 0);
- if (status) {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " reject_conn: cm_rej failed: %d\n", status);
- return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, 0);
- }
- dapli_destroy_cm_id(cm_handle);
- return DAT_SUCCESS;
-}
-
-/*
- * dapls_ib_cm_remote_addr
- *
- * Obtain the remote IP address given a connection
- *
- * Input:
- * cr_handle
- *
- * Output:
- * remote_ia_address: where to place the remote address
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INVALID_HANDLE
- *
- */
-DAT_RETURN
-dapls_ib_cm_remote_addr (
- IN DAT_HANDLE dat_handle,
- OUT DAT_SOCK_ADDR6 *remote_ia_address )
-{
- DAPL_HEADER *header;
- ib_cm_handle_t ib_cm_handle;
-
- dapl_dbg_log (DAPL_DBG_TYPE_EP,
- "dapls_ib_cm_remote_addr(dat_handle %p, ....)\n",
- dat_handle );
-
- header = (DAPL_HEADER *)dat_handle;
-
- if (header->magic == DAPL_MAGIC_EP)
- ib_cm_handle = ((DAPL_EP *) dat_handle)->cm_handle;
- else if (header->magic == DAPL_MAGIC_CR)
- ib_cm_handle = ((DAPL_CR *) dat_handle)->ib_cm_handle;
- else
- return DAT_INVALID_HANDLE;
-
- dapl_os_memcpy( remote_ia_address,
- &ib_cm_handle->r_addr,
- sizeof(DAT_SOCK_ADDR6) );
-
- return DAT_SUCCESS;
-}
-
-/*
- * dapls_ib_private_data_size
- *
- * Return the size of private data given a connection op type
- *
- * Input:
- * prd_ptr private data pointer
- * conn_op connection operation type
- * hca_ptr hca pointer, needed for transport type
- *
- * If prd_ptr is NULL, this is a query for the max size supported by
- * the provider, otherwise it is the actual size of the private data
- * contained in prd_ptr.
- *
- *
- * Output:
- * None
- *
- * Returns:
- * length of private data
- *
- */
-int dapls_ib_private_data_size (
- IN DAPL_PRIVATE *prd_ptr,
- IN DAPL_PDATA_OP conn_op,
- IN DAPL_HCA *hca_ptr)
-{
- int size;
-
- switch (conn_op)
- {
- case DAPL_PDATA_CONN_REQ:
- {
- size = IB_MAX_REQ_PDATA_SIZE;
- break;
- }
- case DAPL_PDATA_CONN_REP:
- {
- size = IB_MAX_REP_PDATA_SIZE;
- break;
- }
- case DAPL_PDATA_CONN_REJ:
- {
- size = IB_MAX_REJ_PDATA_SIZE;
- break;
- }
- case DAPL_PDATA_CONN_DREQ:
- {
- size = IB_MAX_DREQ_PDATA_SIZE;
- break;
- }
- case DAPL_PDATA_CONN_DREP:
- {
- size = IB_MAX_DREP_PDATA_SIZE;
- break;
- }
- default:
- {
- size = 0;
- }
-
- } /* end case */
-
- return size;
-}
-
-/*
- * Map all socket CM event codes to the DAT equivelent.
- */
-#define DAPL_IB_EVENT_CNT 12
-
-static struct ib_cm_event_map
-{
- const ib_cm_events_t ib_cm_event;
- DAT_EVENT_NUMBER dat_event_num;
- } ib_cm_event_map[DAPL_IB_EVENT_CNT] = {
- /* 00 */ { IB_CME_CONNECTED,
- DAT_CONNECTION_EVENT_ESTABLISHED},
- /* 01 */ { IB_CME_DISCONNECTED,
- DAT_CONNECTION_EVENT_DISCONNECTED},
- /* 02 */ { IB_CME_DISCONNECTED_ON_LINK_DOWN,
- DAT_CONNECTION_EVENT_DISCONNECTED},
- /* 03 */ { IB_CME_CONNECTION_REQUEST_PENDING,
- DAT_CONNECTION_REQUEST_EVENT},
- /* 04 */ { IB_CME_CONNECTION_REQUEST_PENDING_PRIVATE_DATA,
- DAT_CONNECTION_REQUEST_EVENT},
- /* 05 */ { IB_CME_CONNECTION_REQUEST_ACKED,
- DAT_CONNECTION_REQUEST_EVENT},
- /* 06 */ { IB_CME_DESTINATION_REJECT,
- DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
- /* 07 */ { IB_CME_DESTINATION_REJECT_PRIVATE_DATA,
- DAT_CONNECTION_EVENT_PEER_REJECTED},
- /* 08 */ { IB_CME_DESTINATION_UNREACHABLE,
- DAT_CONNECTION_EVENT_UNREACHABLE},
- /* 09 */ { IB_CME_TOO_MANY_CONNECTION_REQUESTS,
- DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
- /* 10 */ { IB_CME_LOCAL_FAILURE,
- DAT_CONNECTION_EVENT_BROKEN},
- /* 11 */ { IB_CME_BROKEN,
- DAT_CONNECTION_EVENT_BROKEN}
-};
-
-/*
- * dapls_ib_get_cm_event
- *
- * Return a DAT connection event given a provider CM event.
- *
- * Input:
- * dat_event_num DAT event we need an equivelent CM event for
- *
- * Output:
- * none
- *
- * Returns:
- * ib_cm_event of translated DAPL value
- */
-DAT_EVENT_NUMBER
-dapls_ib_get_dat_event (
- IN const ib_cm_events_t ib_cm_event,
- IN DAT_BOOLEAN active)
-{
- DAT_EVENT_NUMBER dat_event_num;
- int i;
-
- active = active;
-
- if (ib_cm_event > IB_CME_BROKEN)
- return (DAT_EVENT_NUMBER) 0;
-
- dat_event_num = 0;
- for (i = 0; i < DAPL_IB_EVENT_CNT; i++) {
- if (ib_cm_event == ib_cm_event_map[i].ib_cm_event) {
- dat_event_num = ib_cm_event_map[i].dat_event_num;
- break;
- }
- }
- dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,
- "dapls_ib_get_dat_event: event(%s) ib=0x%x dat=0x%x\n",
- active ? "active" : "passive", ib_cm_event, dat_event_num);
-
- return dat_event_num;
-}
-
-
-/*
- * dapls_ib_get_dat_event
- *
- * Return a DAT connection event given a provider CM event.
- *
- * Input:
- * ib_cm_event event provided to the dapl callback routine
- * active switch indicating active or passive connection
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_EVENT_NUMBER of translated provider value
- */
-ib_cm_events_t
-dapls_ib_get_cm_event (
- IN DAT_EVENT_NUMBER dat_event_num)
-{
- ib_cm_events_t ib_cm_event;
- int i;
-
- ib_cm_event = 0;
- for (i = 0; i < DAPL_IB_EVENT_CNT; i++) {
- if ( dat_event_num == ib_cm_event_map[i].dat_event_num ) {
- ib_cm_event = ib_cm_event_map[i].ib_cm_event;
- break;
- }
- }
- return ib_cm_event;
-}
-
-
-void dapli_cm_event_cb(struct _ib_hca_transport *hca)
-{
- struct ib_cm_event *event;
-
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " dapli_cm_event()\n");
-
- /* process one CM event, fairness */
- if(!ib_cm_get_event(hca->ib_cm,&event)) {
- struct dapl_cm_id *conn;
- int ret;
- dapl_dbg_log(DAPL_DBG_TYPE_CM,
- " dapli_cm_event: EVENT=%p ID=%p CTX=%p\n",
- event->event, event->cm_id,
- event->cm_id->context);
-
- /* set proper conn from cm_id context*/
- conn = (struct dapl_cm_id*)event->cm_id->context;
-
- if (conn->sp)
- ret = dapli_cm_passive_cb(conn,event);
- else
- ret = dapli_cm_active_cb(conn,event);
-
- ib_cm_ack_event(event);
-
- if (ret)
- ib_cm_destroy_id(conn->cm_id);
- }
-}
-
-void dapli_at_event_cb()
-{
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " dapli_at_event_cb()\n");
-
- /* process one AT event, fairness */
- ib_at_callback_get_timed(0);
-}
-
-
-/*
- * Local variables:
- * c-indent-level: 4
- * c-basic-offset: 4
- * tab-width: 8
- * End:
- */
+++ /dev/null
-/*
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- * copy of which is available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/***************************************************************************
- *
- * Module: uDAPL
- *
- * Filename: dapl_ib_cq.c
- *
- * Author: Arlin Davis
- *
- * Created: 3/10/2005
- *
- * Description:
- *
- * The uDAPL openib provider - completion queue
- *
- ****************************************************************************
- * Source Control System Information
- *
- * $Id: $
- *
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- **************************************************************************/
-
-#include "dapl.h"
-#include "dapl_adapter_util.h"
-#include "dapl_lmr_util.h"
-#include "dapl_evd_util.h"
-#include "dapl_ring_buffer_util.h"
-#include <sys/poll.h>
-
-/* One CQ event channel per HCA */
-void dapli_cq_event_cb(struct _ib_hca_transport *hca)
-{
- /* check all comp events on this device */
- struct dapl_evd *evd_ptr = NULL;
- struct ibv_cq *ibv_cq = NULL;
- struct pollfd cq_fd = {
- .fd = hca->ib_cq->fd,
- .events = POLLIN,
- .revents = 0
- };
-
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL," dapli_cq_event_cb(%p)\n", hca);
-
- if ((poll(&cq_fd, 1, 0) == 1) &&
- (!ibv_get_cq_event(hca->ib_cq,
- &ibv_cq, (void*)&evd_ptr))) {
-
- if (DAPL_BAD_HANDLE(evd_ptr, DAPL_MAGIC_EVD)) {
- ibv_ack_cq_events(ibv_cq, 1);
- return;
- }
-
- /* process DTO event via callback */
- dapl_evd_dto_callback ( hca->ib_ctx,
- evd_ptr->ib_cq_handle,
- (void*)evd_ptr );
-
- ibv_ack_cq_events(ibv_cq, 1);
- }
-}
-
-/*
- * Map all verbs DTO completion codes to the DAT equivelent.
- *
- * Not returned by verbs: DAT_DTO_ERR_PARTIAL_PACKET
- */
-static struct ib_status_map
-{
- int ib_status;
- DAT_DTO_COMPLETION_STATUS dat_status;
-} ib_status_map[] = {
- /* 00 */ { IBV_WC_SUCCESS, DAT_DTO_SUCCESS},
- /* 01 */ { IBV_WC_LOC_LEN_ERR, DAT_DTO_ERR_LOCAL_LENGTH},
- /* 02 */ { IBV_WC_LOC_QP_OP_ERR, DAT_DTO_ERR_LOCAL_EP},
- /* 03 */ { IBV_WC_LOC_EEC_OP_ERR, DAT_DTO_ERR_TRANSPORT},
- /* 04 */ { IBV_WC_LOC_PROT_ERR, DAT_DTO_ERR_LOCAL_PROTECTION},
- /* 05 */ { IBV_WC_WR_FLUSH_ERR, DAT_DTO_ERR_FLUSHED},
- /* 06 */ { IBV_WC_MW_BIND_ERR, DAT_RMR_OPERATION_FAILED},
- /* 07 */ { IBV_WC_BAD_RESP_ERR, DAT_DTO_ERR_BAD_RESPONSE},
- /* 08 */ { IBV_WC_LOC_ACCESS_ERR, DAT_DTO_ERR_LOCAL_PROTECTION},
- /* 09 */ { IBV_WC_REM_INV_REQ_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
- /* 10 */ { IBV_WC_REM_ACCESS_ERR, DAT_DTO_ERR_REMOTE_ACCESS},
- /* 11 */ { IBV_WC_REM_OP_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
- /* 12 */ { IBV_WC_RETRY_EXC_ERR, DAT_DTO_ERR_TRANSPORT},
- /* 13 */ { IBV_WC_RNR_RETRY_EXC_ERR, DAT_DTO_ERR_RECEIVER_NOT_READY},
- /* 14 */ { IBV_WC_LOC_RDD_VIOL_ERR, DAT_DTO_ERR_LOCAL_PROTECTION},
- /* 15 */ { IBV_WC_REM_INV_RD_REQ_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
- /* 16 */ { IBV_WC_REM_ABORT_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
- /* 17 */ { IBV_WC_INV_EECN_ERR, DAT_DTO_ERR_TRANSPORT},
- /* 18 */ { IBV_WC_INV_EEC_STATE_ERR, DAT_DTO_ERR_TRANSPORT},
- /* 19 */ { IBV_WC_FATAL_ERR, DAT_DTO_ERR_TRANSPORT},
- /* 20 */ { IBV_WC_RESP_TIMEOUT_ERR, DAT_DTO_ERR_RECEIVER_NOT_READY},
- /* 21 */ { IBV_WC_GENERAL_ERR, DAT_DTO_ERR_TRANSPORT},
-};
-
-/*
- * dapls_ib_get_dto_status
- *
- * Return the DAT status of a DTO operation
- *
- * Input:
- * cqe_ptr pointer to completion queue entry
- *
- * Output:
- * none
- *
- * Returns:
- * Value from ib_status_map table above
- */
-
-DAT_DTO_COMPLETION_STATUS
-dapls_ib_get_dto_status (
- IN ib_work_completion_t *cqe_ptr)
-{
- uint32_t ib_status;
- int i;
-
- ib_status = DAPL_GET_CQE_STATUS (cqe_ptr);
-
- /*
- * Due to the implementation of verbs completion code, we need to
- * search the table for the correct value rather than assuming
- * linear distribution.
- */
- for (i = 0; i <= IBV_WC_GENERAL_ERR; i++) {
- if (ib_status == ib_status_map[i].ib_status) {
- if ( ib_status != IBV_WC_SUCCESS ) {
- dapl_dbg_log (DAPL_DBG_TYPE_DTO_COMP_ERR,
- " DTO completion ERROR: %d: op %#x\n",
- ib_status, DAPL_GET_CQE_OPTYPE (cqe_ptr));
- }
- return ib_status_map[i].dat_status;
- }
- }
-
- dapl_dbg_log (DAPL_DBG_TYPE_DTO_COMP_ERR,
- " DTO completion ERROR: %d: op %#x\n",
- ib_status,
- DAPL_GET_CQE_OPTYPE (cqe_ptr));
-
- return DAT_DTO_FAILURE;
-}
-
-DAT_RETURN dapls_ib_get_async_event (
- IN ib_error_record_t *err_record,
- OUT DAT_EVENT_NUMBER *async_event)
-{
- DAT_RETURN dat_status = DAT_SUCCESS;
- int err_code = err_record->event_type;
-
- switch (err_code) {
- /* OVERFLOW error */
- case IBV_EVENT_CQ_ERR:
- *async_event = DAT_ASYNC_ERROR_EVD_OVERFLOW;
- break;
- /* INTERNAL errors */
- case IBV_EVENT_DEVICE_FATAL:
- *async_event = DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR;
- break;
- /* CATASTROPHIC errors */
- case IBV_EVENT_PORT_ERR:
- *async_event = DAT_ASYNC_ERROR_IA_CATASTROPHIC;
- break;
- /* BROKEN QP error */
- case IBV_EVENT_SQ_DRAINED:
- case IBV_EVENT_QP_FATAL:
- case IBV_EVENT_QP_REQ_ERR:
- case IBV_EVENT_QP_ACCESS_ERR:
- *async_event = DAT_ASYNC_ERROR_EP_BROKEN;
- break;
-
- /* connection completion */
- case IBV_EVENT_COMM_EST:
- *async_event = DAT_CONNECTION_EVENT_ESTABLISHED;
- break;
-
- /* TODO: process HW state changes */
- case IBV_EVENT_PATH_MIG:
- case IBV_EVENT_PATH_MIG_ERR:
- case IBV_EVENT_PORT_ACTIVE:
- case IBV_EVENT_LID_CHANGE:
- case IBV_EVENT_PKEY_CHANGE:
- case IBV_EVENT_SM_CHANGE:
- default:
- dat_status = DAT_ERROR (DAT_NOT_IMPLEMENTED, 0);
- }
- return dat_status;
-}
-
-/*
- * dapl_ib_cq_alloc
- *
- * Alloc a CQ
- *
- * Input:
- * ia_handle IA handle
- * evd_ptr pointer to EVD struct
- * cqlen minimum QLen
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INSUFFICIENT_RESOURCES
- *
- */
-DAT_RETURN
-dapls_ib_cq_alloc (
- IN DAPL_IA *ia_ptr,
- IN DAPL_EVD *evd_ptr,
- IN DAT_COUNT *cqlen )
-{
- dapl_dbg_log ( DAPL_DBG_TYPE_UTIL,
- "dapls_ib_cq_alloc: evd %p cqlen=%d \n", evd_ptr, *cqlen );
-
- struct ibv_comp_channel *channel = ia_ptr->hca_ptr->ib_trans.ib_cq;
-
-#ifdef CQ_WAIT_OBJECT
- if (evd_ptr->cq_wait_obj_handle)
- channel = evd_ptr->cq_wait_obj_handle;
-#endif
-
- /* Call IB verbs to create CQ */
- evd_ptr->ib_cq_handle = ibv_create_cq(ia_ptr->hca_ptr->ib_hca_handle,
- *cqlen,
- evd_ptr,
- channel, 0);
-
- if (evd_ptr->ib_cq_handle == IB_INVALID_HANDLE)
- return DAT_INSUFFICIENT_RESOURCES;
-
- /* arm cq for events */
- dapls_set_cq_notify(ia_ptr, evd_ptr);
-
- /* update with returned cq entry size */
- *cqlen = evd_ptr->ib_cq_handle->cqe;
-
- dapl_dbg_log ( DAPL_DBG_TYPE_UTIL,
- "dapls_ib_cq_alloc: new_cq %p cqlen=%d \n",
- evd_ptr->ib_cq_handle, *cqlen );
-
- return DAT_SUCCESS;
-}
-
-
-/*
- * dapl_ib_cq_resize
- *
- * Alloc a CQ
- *
- * Input:
- * ia_handle IA handle
- * evd_ptr pointer to EVD struct
- * cqlen minimum QLen
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INVALID_PARAMETER
- *
- */
-DAT_RETURN
-dapls_ib_cq_resize (
- IN DAPL_IA *ia_ptr,
- IN DAPL_EVD *evd_ptr,
- IN DAT_COUNT *cqlen )
-{
- ib_cq_handle_t new_cq;
- struct ibv_comp_channel *channel = ia_ptr->hca_ptr->ib_trans.ib_cq;
-
- /* IB verbs doe not support resize. Try to re-create CQ
- * with new size. Can only be done if QP is not attached.
- * destroy EBUSY == QP still attached.
- */
-
-#ifdef CQ_WAIT_OBJECT
- if (evd_ptr->cq_wait_obj_handle)
- channel = evd_ptr->cq_wait_obj_handle;
-#endif
-
- /* Call IB verbs to create CQ */
- new_cq = ibv_create_cq(ia_ptr->hca_ptr->ib_hca_handle, *cqlen,
- evd_ptr, channel, 0);
-
- if (new_cq == IB_INVALID_HANDLE)
- return DAT_INSUFFICIENT_RESOURCES;
-
- /* destroy the original and replace if successful */
- if (ibv_destroy_cq(evd_ptr->ib_cq_handle)) {
- ibv_destroy_cq(new_cq);
- return(dapl_convert_errno(errno,"resize_cq"));
- }
-
- /* update EVD with new cq handle and size */
- evd_ptr->ib_cq_handle = new_cq;
- *cqlen = new_cq->cqe;
-
- /* arm cq for events */
- dapls_set_cq_notify (ia_ptr, evd_ptr);
-
- return DAT_SUCCESS;
-}
-
-/*
- * dapls_ib_cq_free
- *
- * destroy a CQ
- *
- * Input:
- * ia_handle IA handle
- * evd_ptr pointer to EVD struct
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INVALID_PARAMETER
- *
- */
-DAT_RETURN dapls_ib_cq_free (
- IN DAPL_IA *ia_ptr,
- IN DAPL_EVD *evd_ptr)
-{
- if ( evd_ptr->ib_cq_handle != IB_INVALID_HANDLE ) {
- /* copy all entries on CQ to EVD before destroying */
- dapls_evd_copy_cq(evd_ptr);
- if (ibv_destroy_cq(evd_ptr->ib_cq_handle))
- return(dapl_convert_errno(errno,"destroy_cq"));
- evd_ptr->ib_cq_handle = IB_INVALID_HANDLE;
- }
- return DAT_SUCCESS;
-}
-
-/*
- * dapls_set_cq_notify
- *
- * Set the CQ notification for next
- *
- * Input:
- * hca_handl hca handle
- * DAPL_EVD evd handle
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * dapl_convert_errno
- */
-DAT_RETURN dapls_set_cq_notify (
- IN DAPL_IA *ia_ptr,
- IN DAPL_EVD *evd_ptr)
-{
- if (ibv_req_notify_cq( evd_ptr->ib_cq_handle, 0 ))
- return(dapl_convert_errno(errno,"notify_cq"));
- else
- return DAT_SUCCESS;
-}
-
-/*
- * dapls_ib_completion_notify
- *
- * Set the CQ notification type
- *
- * Input:
- * hca_handl hca handle
- * evd_ptr evd handle
- * type notification type
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * dapl_convert_errno
- */
-DAT_RETURN dapls_ib_completion_notify (
- IN ib_hca_handle_t hca_handle,
- IN DAPL_EVD *evd_ptr,
- IN ib_notification_type_t type)
-{
- if (ibv_req_notify_cq( evd_ptr->ib_cq_handle, type ))
- return(dapl_convert_errno(errno,"notify_cq_type"));
- else
- return DAT_SUCCESS;
-}
-
-/*
- * dapls_ib_completion_poll
- *
- * CQ poll for completions
- *
- * Input:
- * hca_handl hca handle
- * evd_ptr evd handle
- * wc_ptr work completion
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_QUEUE_EMPTY
- *
- */
-DAT_RETURN dapls_ib_completion_poll (
- IN DAPL_HCA *hca_ptr,
- IN DAPL_EVD *evd_ptr,
- IN ib_work_completion_t *wc_ptr)
-{
- int ret;
-
- ret = ibv_poll_cq(evd_ptr->ib_cq_handle, 1, wc_ptr);
- if (ret == 1)
- return DAT_SUCCESS;
-
- return DAT_QUEUE_EMPTY;
-}
-
-#ifdef CQ_WAIT_OBJECT
-
-/* NEW common wait objects for providers with direct CQ wait objects */
-DAT_RETURN
-dapls_ib_wait_object_create (
- IN DAPL_EVD *evd_ptr,
- IN ib_wait_obj_handle_t *p_cq_wait_obj_handle )
-{
- dapl_dbg_log ( DAPL_DBG_TYPE_CM,
- " cq_object_create: (%p,%p)\n",
- evd_ptr, p_cq_wait_obj_handle );
-
- /* set cq_wait object to evd_ptr */
- *p_cq_wait_obj_handle =
- ibv_create_comp_channel(evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle);
-
- return DAT_SUCCESS;
-}
-
-DAT_RETURN
-dapls_ib_wait_object_destroy (
- IN ib_wait_obj_handle_t p_cq_wait_obj_handle)
-{
- dapl_dbg_log ( DAPL_DBG_TYPE_UTIL,
- " cq_object_destroy: wait_obj=%p\n",
- p_cq_wait_obj_handle );
-
- ibv_destroy_comp_channel(p_cq_wait_obj_handle);
-
- return DAT_SUCCESS;
-}
-
-DAT_RETURN
-dapls_ib_wait_object_wakeup (
- IN ib_wait_obj_handle_t p_cq_wait_obj_handle)
-{
- dapl_dbg_log ( DAPL_DBG_TYPE_UTIL,
- " cq_object_wakeup: wait_obj=%p\n",
- p_cq_wait_obj_handle );
-
- /* no wake up mechanism */
- return DAT_SUCCESS;
-}
-
-DAT_RETURN
-dapls_ib_wait_object_wait (
- IN ib_wait_obj_handle_t p_cq_wait_obj_handle,
- IN u_int32_t timeout)
-{
- struct dapl_evd *evd_ptr;
- struct ibv_cq *ibv_cq = NULL;
- void *ibv_ctx = NULL;
- int status = 0;
- int timeout_ms = -1;
- struct pollfd cq_fd = {
- .fd = p_cq_wait_obj_handle->fd,
- .events = POLLIN,
- .revents = 0
- };
-
- dapl_dbg_log ( DAPL_DBG_TYPE_CM,
- " cq_object_wait: CQ channel %p time %d\n",
- p_cq_wait_obj_handle, timeout );
-
- /* uDAPL timeout values in usecs */
- if (timeout != DAT_TIMEOUT_INFINITE)
- timeout_ms = timeout/1000;
-
- status = poll(&cq_fd, 1, timeout_ms);
-
- /* returned event */
- if (status > 0) {
- if (!ibv_get_cq_event(p_cq_wait_obj_handle,
- &ibv_cq, (void*)&evd_ptr)) {
- ibv_ack_cq_events(ibv_cq, 1);
- }
- status = 0;
-
- /* timeout */
- } else if (status == 0)
- status = ETIMEDOUT;
-
- dapl_dbg_log (DAPL_DBG_TYPE_CM,
- " cq_object_wait: RET evd %p ibv_cq %p ibv_ctx %p %s\n",
- evd_ptr, ibv_cq,ibv_ctx,strerror(errno));
-
- return(dapl_convert_errno(status,"cq_wait_object_wait"));
-
-}
-#endif
-
-/*
- * Local variables:
- * c-indent-level: 4
- * c-basic-offset: 4
- * tab-width: 8
- * End:
- */
-
+++ /dev/null
-/*
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- * copy of which is available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/***************************************************************************
- *
- * Module: uDAPL
- *
- * Filename: dapl_ib_dto.h
- *
- * Author: Arlin Davis
- *
- * Created: 3/10/2005
- *
- * Description:
- *
- * The uDAPL openib provider - DTO operations and CQE macros
- *
- ****************************************************************************
- * Source Control System Information
- *
- * $Id: $
- *
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- **************************************************************************/
-#ifndef _DAPL_IB_DTO_H_
-#define _DAPL_IB_DTO_H_
-
-#include "dapl_ib_util.h"
-
-#define DEFAULT_DS_ENTRIES 8
-
-STATIC _INLINE_ int dapls_cqe_opcode(ib_work_completion_t *cqe_p);
-
-/*
- * dapls_ib_post_recv
- *
- * Provider specific Post RECV function
- */
-STATIC _INLINE_ DAT_RETURN
-dapls_ib_post_recv (
- IN DAPL_EP *ep_ptr,
- IN DAPL_COOKIE *cookie,
- IN DAT_COUNT segments,
- IN DAT_LMR_TRIPLET *local_iov )
-{
- ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
- ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
- struct ibv_recv_wr wr;
- struct ibv_recv_wr *bad_wr;
- DAT_COUNT i, total_len;
- int ret;
-
- dapl_dbg_log (DAPL_DBG_TYPE_EP,
- " post_rcv: ep %p cookie %p segs %d l_iov %p\n",
- ep_ptr, cookie, segments, local_iov);
-
- if ( segments <= DEFAULT_DS_ENTRIES )
- ds_array_p = ds_array;
- else
- ds_array_start_p = ds_array_p =
- dapl_os_alloc(segments * sizeof(ib_data_segment_t));
-
- if (NULL == ds_array_p)
- return (DAT_INSUFFICIENT_RESOURCES);
-
- /* setup work request */
- total_len = 0;
- wr.next = 0;
- wr.num_sge = 0;
- wr.wr_id = (uint64_t)(uintptr_t)cookie;
- wr.sg_list = ds_array_p;
-
- for (i = 0; i < segments; i++ ) {
- if ( !local_iov[i].segment_length )
- continue;
-
- ds_array_p->addr = (uint64_t) local_iov[i].virtual_address;
- ds_array_p->length = local_iov[i].segment_length;
- ds_array_p->lkey = local_iov[i].lmr_context;
-
- dapl_dbg_log ( DAPL_DBG_TYPE_EP,
- " post_rcv: l_key 0x%x va %p len %d\n",
- ds_array_p->lkey, ds_array_p->addr,
- ds_array_p->length );
-
- total_len += ds_array_p->length;
- wr.num_sge++;
- ds_array_p++;
- }
-
- if (cookie != NULL)
- cookie->val.dto.size = total_len;
-
- ret = ibv_post_recv(ep_ptr->qp_handle, &wr, &bad_wr);
-
- if (ds_array_start_p != NULL)
- dapl_os_free(ds_array_start_p, segments * sizeof(ib_data_segment_t));
-
- if (ret)
- return( dapl_convert_errno(EFAULT,"ibv_recv") );
-
- return DAT_SUCCESS;
-}
-
-
-/*
- * dapls_ib_post_send
- *
- * Provider specific Post SEND function
- */
-STATIC _INLINE_ DAT_RETURN
-dapls_ib_post_send (
- IN DAPL_EP *ep_ptr,
- IN ib_send_op_type_t op_type,
- IN DAPL_COOKIE *cookie,
- IN DAT_COUNT segments,
- IN DAT_LMR_TRIPLET *local_iov,
- IN const DAT_RMR_TRIPLET *remote_iov,
- IN DAT_COMPLETION_FLAGS completion_flags)
-{
- dapl_dbg_log (DAPL_DBG_TYPE_EP,
- " post_snd: ep %p op %d ck %p sgs %d l_iov %p r_iov %p f %d\n",
- ep_ptr, op_type, cookie, segments, local_iov,
- remote_iov, completion_flags);
-
- ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
- ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
- struct ibv_send_wr wr;
- struct ibv_send_wr *bad_wr;
- ib_hca_transport_t *ibt_ptr = &ep_ptr->header.owner_ia->hca_ptr->ib_trans;
- DAT_COUNT i, total_len;
- int ret;
-
- dapl_dbg_log (DAPL_DBG_TYPE_EP,
- " post_snd: ep %p cookie %p segs %d l_iov %p\n",
- ep_ptr, cookie, segments, local_iov);
-
- if( segments <= DEFAULT_DS_ENTRIES )
- ds_array_p = ds_array;
- else
- ds_array_start_p = ds_array_p =
- dapl_os_alloc(segments * sizeof(ib_data_segment_t));
-
- if (NULL == ds_array_p)
- return (DAT_INSUFFICIENT_RESOURCES);
-
- /* setup the work request */
- wr.next = 0;
- wr.opcode = op_type;
- wr.num_sge = 0;
- wr.send_flags = 0;
- wr.wr_id = (uint64_t)(uintptr_t)cookie;
- wr.sg_list = ds_array_p;
- total_len = 0;
-
- for (i = 0; i < segments; i++ ) {
- if ( !local_iov[i].segment_length )
- continue;
-
- ds_array_p->addr = (uint64_t) local_iov[i].virtual_address;
- ds_array_p->length = local_iov[i].segment_length;
- ds_array_p->lkey = local_iov[i].lmr_context;
-
- dapl_dbg_log ( DAPL_DBG_TYPE_EP,
- " post_snd: lkey 0x%x va %p len %d \n",
- ds_array_p->lkey, ds_array_p->addr,
- ds_array_p->length );
-
- total_len += ds_array_p->length;
- wr.num_sge++;
- ds_array_p++;
- }
-
- if (cookie != NULL)
- cookie->val.dto.size = total_len;
-
- if ((op_type == OP_RDMA_WRITE) || (op_type == OP_RDMA_READ)) {
- wr.wr.rdma.remote_addr = remote_iov->target_address;
- wr.wr.rdma.rkey = remote_iov->rmr_context;
- dapl_dbg_log ( DAPL_DBG_TYPE_EP,
- " post_snd_rdma: rkey 0x%x va %#016Lx\n",
- wr.wr.rdma.rkey, wr.wr.rdma.remote_addr );
- }
-
- /* inline data for send or write ops */
- if ((total_len <= ibt_ptr->max_inline_send ) &&
- ((op_type == OP_SEND) || (op_type == OP_RDMA_WRITE)))
- wr.send_flags |= IBV_SEND_INLINE;
-
- /* set completion flags in work request */
- wr.send_flags |= (DAT_COMPLETION_SUPPRESS_FLAG &
- completion_flags) ? 0 : IBV_SEND_SIGNALED;
- wr.send_flags |= (DAT_COMPLETION_BARRIER_FENCE_FLAG &
- completion_flags) ? IBV_SEND_FENCE : 0;
- wr.send_flags |= (DAT_COMPLETION_SOLICITED_WAIT_FLAG &
- completion_flags) ? IBV_SEND_SOLICITED : 0;
-
- dapl_dbg_log (DAPL_DBG_TYPE_EP,
- " post_snd: op 0x%x flags 0x%x sglist %p, %d\n",
- wr.opcode, wr.send_flags, wr.sg_list, wr.num_sge);
-
- ret = ibv_post_send(ep_ptr->qp_handle, &wr, &bad_wr);
-
- if (ds_array_start_p != NULL)
- dapl_os_free(ds_array_start_p, segments * sizeof(ib_data_segment_t));
-
- if (ret)
- return( dapl_convert_errno(EFAULT,"ibv_send") );
-
- dapl_dbg_log (DAPL_DBG_TYPE_EP," post_snd: returned\n");
- return DAT_SUCCESS;
-}
-
-STATIC _INLINE_ DAT_RETURN
-dapls_ib_optional_prv_dat (
- IN DAPL_CR *cr_ptr,
- IN const void *event_data,
- OUT DAPL_CR **cr_pp)
-{
- return DAT_SUCCESS;
-}
-
-STATIC _INLINE_ int dapls_cqe_opcode(ib_work_completion_t *cqe_p)
-{
- switch (cqe_p->opcode) {
- case IBV_WC_SEND:
- return (OP_SEND);
- case IBV_WC_RDMA_WRITE:
- return (OP_RDMA_WRITE);
- case IBV_WC_RDMA_READ:
- return (OP_RDMA_READ);
- case IBV_WC_COMP_SWAP:
- return (OP_COMP_AND_SWAP);
- case IBV_WC_FETCH_ADD:
- return (OP_FETCH_AND_ADD);
- case IBV_WC_BIND_MW:
- return (OP_BIND_MW);
- case IBV_WC_RECV:
- return (OP_RECEIVE);
- case IBV_WC_RECV_RDMA_WITH_IMM:
- return (OP_RECEIVE_IMM);
- default:
- return (OP_INVALID);
- }
-}
-
-#define DAPL_GET_CQE_OPTYPE(cqe_p) dapls_cqe_opcode(cqe_p)
-#define DAPL_GET_CQE_WRID(cqe_p) ((ib_work_completion_t*)cqe_p)->wr_id
-#define DAPL_GET_CQE_STATUS(cqe_p) ((ib_work_completion_t*)cqe_p)->status
-#define DAPL_GET_CQE_BYTESNUM(cqe_p) ((ib_work_completion_t*)cqe_p)->byte_len
-#define DAPL_GET_CQE_IMMED_DATA(cqe_p) ((ib_work_completion_t*)cqe_p)->imm_data
-
-#endif /* _DAPL_IB_DTO_H_ */
+++ /dev/null
-/*
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- * copy of which is available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/**********************************************************************
- *
- * MODULE: dapl_det_mem.c
- *
- * PURPOSE: Intel DET APIs: Memory windows, registration,
- * and protection domain
- *
- * $Id: $
- *
- **********************************************************************/
-
-#include <sys/ioctl.h> /* for IOCTL's */
-#include <sys/types.h> /* for socket(2) and related bits and pieces */
-#include <sys/socket.h> /* for socket(2) */
-#include <net/if.h> /* for struct ifreq */
-#include <net/if_arp.h> /* for ARPHRD_ETHER */
-#include <unistd.h> /* for _SC_CLK_TCK */
-
-#include "dapl.h"
-#include "dapl_adapter_util.h"
-#include "dapl_lmr_util.h"
-
-/*
- * dapls_convert_privileges
- *
- * Convert LMR privileges to provider
- *
- * Input:
- * DAT_MEM_PRIV_FLAGS
- *
- * Output:
- * none
- *
- * Returns:
- * ibv_access_flags
- *
- */
-STATIC _INLINE_ int
-dapls_convert_privileges (
- IN DAT_MEM_PRIV_FLAGS privileges)
-{
- int access = 0;
-
- /*
- * if (DAT_MEM_PRIV_LOCAL_READ_FLAG & privileges) do nothing
- */
- if (DAT_MEM_PRIV_LOCAL_WRITE_FLAG & privileges)
- access |= IBV_ACCESS_LOCAL_WRITE;
- if (DAT_MEM_PRIV_REMOTE_WRITE_FLAG & privileges)
- access |= IBV_ACCESS_REMOTE_WRITE;
- if (DAT_MEM_PRIV_REMOTE_READ_FLAG & privileges)
- access |= IBV_ACCESS_REMOTE_READ;
- if (DAT_MEM_PRIV_REMOTE_READ_FLAG & privileges)
- access |= IBV_ACCESS_REMOTE_READ;
- if (DAT_MEM_PRIV_REMOTE_READ_FLAG & privileges)
- access |= IBV_ACCESS_REMOTE_READ;
-
- return access;
-}
-
-/*
- * dapl_ib_pd_alloc
- *
- * Alloc a PD
- *
- * Input:
- * ia_handle IA handle
- * pz pointer to PZ struct
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INSUFFICIENT_RESOURCES
- *
- */
-DAT_RETURN
-dapls_ib_pd_alloc (
- IN DAPL_IA *ia_ptr,
- IN DAPL_PZ *pz )
-{
- /* get a protection domain */
- pz->pd_handle = ibv_alloc_pd(ia_ptr->hca_ptr->ib_hca_handle);
- if (!pz->pd_handle)
- return(dapl_convert_errno(ENOMEM,"alloc_pd"));
-
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " pd_alloc: pd_handle=%p\n",
- pz->pd_handle );
-
- return DAT_SUCCESS;
-}
-
-/*
- * dapl_ib_pd_free
- *
- * Free a PD
- *
- * Input:
- * ia_handle IA handle
- * PZ_ptr pointer to PZ struct
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INVALID_STATE
- *
- */
-DAT_RETURN
-dapls_ib_pd_free (
- IN DAPL_PZ *pz )
-{
- if (pz->pd_handle != IB_INVALID_HANDLE) {
- if (ibv_dealloc_pd(pz->pd_handle))
- return(dapl_convert_errno(errno,"dealloc_pd"));
- pz->pd_handle = IB_INVALID_HANDLE;
- }
- return DAT_SUCCESS;
-}
-
-/*
- * dapl_ib_mr_register
- *
- * Register a virtual memory region
- *
- * Input:
- * ia_handle IA handle
- * lmr pointer to dapl_lmr struct
- * virt_addr virtual address of beginning of mem region
- * length length of memory region
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INSUFFICIENT_RESOURCES
- *
- */
-DAT_RETURN
-dapls_ib_mr_register (
- IN DAPL_IA *ia_ptr,
- IN DAPL_LMR *lmr,
- IN DAT_PVOID virt_addr,
- IN DAT_VLEN length,
- IN DAT_MEM_PRIV_FLAGS privileges)
-{
- ib_pd_handle_t ib_pd_handle;
-
- ib_pd_handle = ((DAPL_PZ *)lmr->param.pz_handle)->pd_handle;
-
- dapl_dbg_log ( DAPL_DBG_TYPE_UTIL,
- " mr_register: ia=%p, lmr=%p va=%p ln=%d pv=0x%x\n",
- ia_ptr, lmr, virt_addr, length, privileges );
-
- /* TODO: shared memory */
- if (lmr->param.mem_type == DAT_MEM_TYPE_SHARED_VIRTUAL) {
- dapl_dbg_log( DAPL_DBG_TYPE_ERR,
- " mr_register_shared: NOT IMPLEMENTED\n");
- return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
- }
-
- /* local read is default on IB */
- lmr->mr_handle =
- ibv_reg_mr(((DAPL_PZ *)lmr->param.pz_handle)->pd_handle,
- virt_addr,
- length,
- dapls_convert_privileges(privileges));
-
- if (!lmr->mr_handle)
- return(dapl_convert_errno(ENOMEM,"reg_mr"));
-
- lmr->param.lmr_context = lmr->mr_handle->lkey;
- lmr->param.rmr_context = lmr->mr_handle->rkey;
- lmr->param.registered_size = length;
- lmr->param.registered_address = (DAT_VADDR)(uintptr_t) virt_addr;
-
- dapl_dbg_log ( DAPL_DBG_TYPE_UTIL,
- " mr_register: mr=%p h %x pd %p ctx %p ,lkey=0x%x, rkey=0x%x priv=%x\n",
- lmr->mr_handle, lmr->mr_handle->handle,
- lmr->mr_handle->pd,
- lmr->mr_handle->context,
- lmr->mr_handle->lkey,
- lmr->mr_handle->rkey,
- length, dapls_convert_privileges(privileges) );
-
- return DAT_SUCCESS;
-}
-
-/*
- * dapl_ib_mr_deregister
- *
- * Free a memory region
- *
- * Input:
- * lmr pointer to dapl_lmr struct
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INVALID_STATE
- *
- */
-DAT_RETURN
-dapls_ib_mr_deregister (
- IN DAPL_LMR *lmr )
-{
- if (lmr->mr_handle != IB_INVALID_HANDLE) {
- if (ibv_dereg_mr(lmr->mr_handle))
- return(dapl_convert_errno(errno,"dereg_pd"));
- lmr->mr_handle = IB_INVALID_HANDLE;
- }
- return DAT_SUCCESS;
-}
-
-
-/*
- * dapl_ib_mr_register_shared
- *
- * Register a virtual memory region
- *
- * Input:
- * ia_ptr IA handle
- * lmr pointer to dapl_lmr struct
- * virt_addr virtual address of beginning of mem region
- * length length of memory region
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INSUFFICIENT_RESOURCES
- *
- */
-DAT_RETURN
-dapls_ib_mr_register_shared (
- IN DAPL_IA *ia_ptr,
- IN DAPL_LMR *lmr,
- IN DAT_MEM_PRIV_FLAGS privileges )
-{
- dapl_dbg_log(DAPL_DBG_TYPE_ERR," mr_register_shared: NOT IMPLEMENTED\n");
- return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
-}
-
-/*
- * dapls_ib_mw_alloc
- *
- * Bind a protection domain to a memory window
- *
- * Input:
- * rmr Initialized rmr to hold binding handles
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INSUFFICIENT_RESOURCES
- *
- */
-DAT_RETURN
-dapls_ib_mw_alloc (
- IN DAPL_RMR *rmr )
-{
-
- dapl_dbg_log(DAPL_DBG_TYPE_ERR," mw_alloc: NOT IMPLEMENTED\n");
- return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
-}
-
-/*
- * dapls_ib_mw_free
- *
- * Release bindings of a protection domain to a memory window
- *
- * Input:
- * rmr Initialized rmr to hold binding handles
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INVALID_STATE
- *
- */
-DAT_RETURN
-dapls_ib_mw_free (
- IN DAPL_RMR *rmr )
-{
- dapl_dbg_log(DAPL_DBG_TYPE_ERR," mw_free: NOT IMPLEMENTED\n");
- return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
-}
-
-/*
- * dapls_ib_mw_bind
- *
- * Bind a protection domain to a memory window
- *
- * Input:
- * rmr Initialized rmr to hold binding handles
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INVALID_PARAMETER;
- * DAT_INSUFFICIENT_RESOURCES
- *
- */
-DAT_RETURN
-dapls_ib_mw_bind (
- IN DAPL_RMR *rmr,
- IN DAPL_LMR *lmr,
- IN DAPL_EP *ep,
- IN DAPL_COOKIE *cookie,
- IN DAT_VADDR virtual_address,
- IN DAT_VLEN length,
- IN DAT_MEM_PRIV_FLAGS mem_priv,
- IN DAT_BOOLEAN is_signaled)
-{
- dapl_dbg_log(DAPL_DBG_TYPE_ERR," mw_bind: NOT IMPLEMENTED\n");
- return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
-}
-
-/*
- * dapls_ib_mw_unbind
- *
- * Unbind a protection domain from a memory window
- *
- * Input:
- * rmr Initialized rmr to hold binding handles
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INVALID_PARAMETER;
- * DAT_INVALID_STATE;
- * DAT_INSUFFICIENT_RESOURCES
- *
- */
-DAT_RETURN
-dapls_ib_mw_unbind (
- IN DAPL_RMR *rmr,
- IN DAPL_EP *ep,
- IN DAPL_COOKIE *cookie,
- IN DAT_BOOLEAN is_signaled )
-{
- dapl_dbg_log(DAPL_DBG_TYPE_ERR," mw_unbind: NOT IMPLEMENTED\n");
- return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
-}
-
-/*
- * Local variables:
- * c-indent-level: 4
- * c-basic-offset: 4
- * tab-width: 8
- * End:
- */
-
+++ /dev/null
-/*
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- * copy of which is available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/**********************************************************************
- *
- * MODULE: dapl_det_qp.c
- *
- * PURPOSE: QP routines for access to DET Verbs
- *
- * $Id: $
- **********************************************************************/
-
-#include "dapl.h"
-#include "dapl_adapter_util.h"
-
-/*
- * dapl_ib_qp_alloc
- *
- * Alloc a QP
- *
- * Input:
- * *ep_ptr pointer to EP INFO
- * ib_hca_handle provider HCA handle
- * ib_pd_handle provider protection domain handle
- * cq_recv provider recv CQ handle
- * cq_send provider send CQ handle
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INSUFFICIENT_RESOURCES
- * DAT_INTERNAL_ERROR
- *
- */
-DAT_RETURN
-dapls_ib_qp_alloc (
- IN DAPL_IA *ia_ptr,
- IN DAPL_EP *ep_ptr,
- IN DAPL_EP *ep_ctx_ptr )
-{
- DAT_EP_ATTR *attr;
- DAPL_EVD *rcv_evd, *req_evd;
- ib_cq_handle_t rcv_cq, req_cq;
- ib_pd_handle_t ib_pd_handle;
- struct ibv_qp_init_attr qp_create;
-
- dapl_dbg_log (DAPL_DBG_TYPE_EP,
- " qp_alloc: ia_ptr %p ep_ptr %p ep_ctx_ptr %p\n",
- ia_ptr, ep_ptr, ep_ctx_ptr);
-
- attr = &ep_ptr->param.ep_attr;
- ib_pd_handle = ((DAPL_PZ *)ep_ptr->param.pz_handle)->pd_handle;
- rcv_evd = (DAPL_EVD *) ep_ptr->param.recv_evd_handle;
- req_evd = (DAPL_EVD *) ep_ptr->param.request_evd_handle;
-
- /*
- * DAT allows usage model of EP's with no EVD's but IB does not.
- * Create a CQ with zero entries under the covers to support and
- * catch any invalid posting.
- */
- if (rcv_evd != DAT_HANDLE_NULL)
- rcv_cq = rcv_evd->ib_cq_handle;
- else if (!ia_ptr->hca_ptr->ib_trans.ib_cq_empty)
- rcv_cq = ia_ptr->hca_ptr->ib_trans.ib_cq_empty;
- else {
- struct ibv_comp_channel *channel =
- ia_ptr->hca_ptr->ib_trans.ib_cq;
-#ifdef CQ_WAIT_OBJECT
- if (rcv_evd->cq_wait_obj_handle)
- channel = rcv_evd->cq_wait_obj_handle;
-#endif
- /* Call IB verbs to create CQ */
- rcv_cq = ibv_create_cq(ia_ptr->hca_ptr->ib_hca_handle,
- 0, NULL, channel, 0);
-
- if (rcv_cq == IB_INVALID_HANDLE)
- return(dapl_convert_errno(ENOMEM, "create_cq"));
-
- ia_ptr->hca_ptr->ib_trans.ib_cq_empty = rcv_cq;
- }
- if (req_evd != DAT_HANDLE_NULL)
- req_cq = req_evd->ib_cq_handle;
- else
- req_cq = ia_ptr->hca_ptr->ib_trans.ib_cq_empty;
-
- /* Setup attributes and create qp */
- dapl_os_memzero((void*)&qp_create, sizeof(qp_create));
- qp_create.send_cq = req_cq;
- qp_create.recv_cq = rcv_cq;
- qp_create.cap.max_send_wr = attr->max_request_dtos;
- qp_create.cap.max_recv_wr = attr->max_recv_dtos;
- qp_create.cap.max_send_sge = attr->max_request_iov;
- qp_create.cap.max_recv_sge = attr->max_recv_iov;
- /* TODO: extend ep_attr so user can set */
- qp_create.cap.max_inline_data = ia_ptr->hca_ptr->ib_trans.max_inline_send;
- qp_create.qp_type = IBV_QPT_RC;
- qp_create.qp_context = (void*)ep_ptr;
-
- ep_ptr->qp_handle = ibv_create_qp(ib_pd_handle, &qp_create);
- if (!ep_ptr->qp_handle)
- return(dapl_convert_errno(ENOMEM, "create_qp"));
-
- dapl_dbg_log ( DAPL_DBG_TYPE_EP,
- " qp_alloc: qpn %p sq %d,%d rq %d,%d\n",
- ep_ptr->qp_handle->qp_num,
- qp_create.cap.max_send_wr,qp_create.cap.max_send_sge,
- qp_create.cap.max_recv_wr,qp_create.cap.max_recv_sge );
-
- /* Setup QP attributes for INIT state on the way out */
- if (dapls_modify_qp_state(ep_ptr->qp_handle,
- IBV_QPS_INIT, 0) != DAT_SUCCESS ) {
- ibv_destroy_qp(ep_ptr->qp_handle);
- ep_ptr->qp_handle = IB_INVALID_HANDLE;
- return DAT_INTERNAL_ERROR;
- }
-
- ep_ptr->qp_state = IB_QP_STATE_INIT;
- return DAT_SUCCESS;
-}
-
-/*
- * dapl_ib_qp_free
- *
- * Free a QP
- *
- * Input:
- * ia_handle IA handle
- * *ep_ptr pointer to EP INFO
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * dapl_convert_errno
- *
- */
-DAT_RETURN
-dapls_ib_qp_free (
- IN DAPL_IA *ia_ptr,
- IN DAPL_EP *ep_ptr )
-{
- dapl_dbg_log (DAPL_DBG_TYPE_EP, " qp_free: ep_ptr %p qp %p\n",
- ep_ptr, ep_ptr->qp_handle);
-
- if (ep_ptr->qp_handle != IB_INVALID_HANDLE) {
- /* force error state to flush queue, then destroy */
- dapls_modify_qp_state(ep_ptr->qp_handle, IBV_QPS_ERR, 0);
-
- if (ibv_destroy_qp(ep_ptr->qp_handle))
- return(dapl_convert_errno(errno,"destroy_qp"));
-
- ep_ptr->qp_handle = IB_INVALID_HANDLE;
- ep_ptr->qp_state = IB_QP_STATE_ERROR;
- }
-
- return DAT_SUCCESS;
-}
-
-/*
- * dapl_ib_qp_modify
- *
- * Set the QP to the parameters specified in an EP_PARAM
- *
- * The EP_PARAM structure that is provided has been
- * sanitized such that only non-zero values are valid.
- *
- * Input:
- * ib_hca_handle HCA handle
- * qp_handle QP handle
- * ep_attr Sanitized EP Params
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INSUFFICIENT_RESOURCES
- * DAT_INVALID_PARAMETER
- *
- */
-DAT_RETURN
-dapls_ib_qp_modify (
- IN DAPL_IA *ia_ptr,
- IN DAPL_EP *ep_ptr,
- IN DAT_EP_ATTR *attr )
-{
- struct ibv_qp_attr qp_attr;
-
- if (ep_ptr->qp_handle == IB_INVALID_HANDLE)
- return DAT_INVALID_PARAMETER;
-
- /*
- * EP state, qp_handle state should be an indication
- * of current state but the only way to be sure is with
- * a user mode ibv_query_qp call which is NOT available
- */
-
- /* move to error state if necessary */
- if ((ep_ptr->qp_state == IB_QP_STATE_ERROR) &&
- (ep_ptr->qp_handle->state != IBV_QPS_ERR)) {
- ep_ptr->qp_state = IB_QP_STATE_ERROR;
- return (dapls_modify_qp_state(ep_ptr->qp_handle,
- IBV_QPS_ERR, 0));
- }
-
- /*
- * Check if we have the right qp_state to modify attributes
- */
- if ((ep_ptr->qp_handle->state != IBV_QPS_RTR ) &&
- (ep_ptr->qp_handle->state != IBV_QPS_RTS ))
- return DAT_INVALID_STATE;
-
- /* Adjust to current EP attributes */
- dapl_os_memzero((void*)&qp_attr, sizeof(qp_attr));
- qp_attr.cap.max_send_wr = attr->max_request_dtos;
- qp_attr.cap.max_recv_wr = attr->max_recv_dtos;
- qp_attr.cap.max_send_sge = attr->max_request_iov;
- qp_attr.cap.max_recv_sge = attr->max_recv_iov;
-
- dapl_dbg_log (DAPL_DBG_TYPE_EP,
- "modify_qp: qp %p sq %d,%d, rq %d,%d\n",
- ep_ptr->qp_handle,
- qp_attr.cap.max_send_wr, qp_attr.cap.max_send_sge,
- qp_attr.cap.max_recv_wr, qp_attr.cap.max_recv_sge );
-
- if (ibv_modify_qp(ep_ptr->qp_handle, &qp_attr, IBV_QP_CAP)) {
- dapl_dbg_log (DAPL_DBG_TYPE_ERR,
- "modify_qp: modify ep %p qp %p failed\n",
- ep_ptr, ep_ptr->qp_handle);
- return(dapl_convert_errno(errno,"modify_qp_state"));
- }
-
- return DAT_SUCCESS;
-}
-
-/*
- * dapls_ib_reinit_ep
- *
- * Move the QP to INIT state again.
- *
- * Input:
- * ep_ptr DAPL_EP
- *
- * Output:
- * none
- *
- * Returns:
- * void
- *
- */
-void
-dapls_ib_reinit_ep (
- IN DAPL_EP *ep_ptr)
-{
-
- if ( ep_ptr->qp_handle != IB_INVALID_HANDLE ) {
- /* move to RESET state and then to INIT */
- dapls_modify_qp_state(ep_ptr->qp_handle, IBV_QPS_RESET, 0);
- dapls_modify_qp_state(ep_ptr->qp_handle, IBV_QPS_INIT, 0);
- ep_ptr->qp_state = IB_QP_STATE_INIT;
- }
-
- /* TODO: When IB-CM is implement then handle timewait before
- * allowing re-use of this QP
- */
-}
-
-/*
- * Generic QP modify for reset, error, INIT, RTS, RTR
- */
-DAT_RETURN
-dapls_modify_qp_state ( IN ib_qp_handle_t qp_handle,
- IN ib_qp_state_t qp_state,
- IN struct dapl_cm_id *conn )
-{
- struct ibv_qp_attr attr;
- int mask = 0;
-
- dapl_dbg_log (DAPL_DBG_TYPE_EP,
- " modify_qp: qp %p, state %d qp_num 0x%x\n",
- qp_handle, qp_state, qp_handle->qp_num);
-
- dapl_os_memzero((void*)&attr, sizeof(attr));
- attr.qp_state = qp_state;
-
- switch (qp_state) {
- case IBV_QPS_INIT:
- {
- DAPL_IA *ia_ptr;
- DAPL_EP *ep_ptr;
-
- /* need to find way back to port num */
- ep_ptr = (DAPL_EP*)qp_handle->qp_context;
- if (ep_ptr)
- ia_ptr = ep_ptr->header.owner_ia;
- else
- return(dapl_convert_errno(EINVAL," qp_CTX"));
-
- /*
- * Set qp attributes by hand for INIT state. Allows
- * consumers to pre-post receives, per uDAPL
- * specification, before IB has path record info
- * with connect request processing
- */
- mask = IBV_QP_STATE | IBV_QP_PKEY_INDEX |
- IBV_QP_PORT | IBV_QP_ACCESS_FLAGS;
-
- attr.pkey_index = 0;
- attr.port_num = ia_ptr->hca_ptr->port_num;
- attr.qp_access_flags =
- IBV_ACCESS_LOCAL_WRITE |
- IBV_ACCESS_REMOTE_WRITE |
- IBV_ACCESS_REMOTE_READ |
- IBV_ACCESS_REMOTE_ATOMIC;
-
- ep_ptr->qp_state = IB_QP_STATE_INIT;
- break;
- }
- case IBV_QPS_RTR:
- if (!conn)
- return(dapl_convert_errno(EINVAL," qp_RTR"));
- /*
- * Get pkey_index from CM, move from INIT to INIT
- * to update index. The initial value was set by hand
- * to allow consumers to pre-post receives.
- */
- attr.qp_state = IBV_QPS_INIT;
-
- /* get pkey_index from CM, move from INIT to INIT */
- if (ib_cm_init_qp_attr(conn->cm_id, &attr, &mask))
- return(dapl_convert_errno(errno," qp_cINIT"));
-
- mask = IBV_QP_PKEY_INDEX;
- if (ibv_modify_qp(qp_handle, &attr, mask))
- return(dapl_convert_errno(errno," reINIT"));
-
- /* get qp attributes from CM, move to RTR */
- attr.qp_state = IBV_QPS_RTR;
- if (ib_cm_init_qp_attr(conn->cm_id, &attr, &mask))
- return(dapl_convert_errno(errno," qp_cRTR"));
-
- attr.path_mtu = IBV_MTU_1024;
-
- /* FIXME: RDMA read performance anomaly, high value psn ? */
- /* attr.rq_psn = qp_handle->qp_num */;
- attr.rq_psn = 1;
-
- break;
-
- case IBV_QPS_RTS:
- if (!conn)
- return(dapl_convert_errno(EINVAL," qp_RTS"));
-
- /* get qp attributes from CM, move to RTS */
- if (ib_cm_init_qp_attr(conn->cm_id, &attr, &mask))
- return(dapl_convert_errno(errno," qp_cRTS"));
-
- /* FIXME: RDMA read performance anomaly, high value psn ? */
- attr.sq_psn = 1;
-
- break;
-
- default:
- mask = IBV_QP_STATE;
- break;
- }
-
- if (ibv_modify_qp(qp_handle, &attr, mask))
- return(dapl_convert_errno(errno," modify_qp"));
-
- return DAT_SUCCESS;
-}
-
-/*
- * Local variables:
- * c-indent-level: 4
- * c-basic-offset: 4
- * tab-width: 8
- * End:
- */
+++ /dev/null
-/*
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- * copy of which is available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/***************************************************************************
- *
- * Module: uDAPL
- *
- * Filename: dapl_ib_util.c
- *
- * Author: Arlin Davis
- *
- * Created: 3/10/2005
- *
- * Description:
- *
- * The uDAPL openib provider - init, open, close, utilities, work thread
- *
- ****************************************************************************
- * Source Control System Information
- *
- * $Id: $
- *
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- **************************************************************************/
-#ifdef RCSID
-static const char rcsid[] = "$Id: $";
-#endif
-
-#include "dapl.h"
-#include "dapl_adapter_util.h"
-#include "dapl_ib_util.h"
-
-#include <stdlib.h>
-#include <netinet/tcp.h>
-#include <sys/poll.h>
-#include <fcntl.h>
-
-int g_dapl_loopback_connection = 0;
-int g_ib_destroy = 0;
-int g_ib_pipe[2];
-DAPL_OS_THREAD g_ib_thread;
-DAPL_OS_LOCK g_hca_lock;
-struct dapl_llist_entry *g_hca_list;
-
-/* just get IP address, IPv4 only for now */
-int dapli_get_hca_addr( struct dapl_hca *hca_ptr )
-{
- struct sockaddr_in *ipv4_addr;
- struct ib_at_completion at_comp;
- struct dapl_at_record at_rec;
- int status;
- DAT_RETURN dat_status;
-
- ipv4_addr = (struct sockaddr_in*)&hca_ptr->hca_address;
- ipv4_addr->sin_family = AF_INET;
- ipv4_addr->sin_addr.s_addr = 0;
-
- at_comp.fn = dapli_ip_comp_handler;
- at_comp.context = &at_rec;
- at_rec.addr = &hca_ptr->hca_address;
- at_rec.wait_object = &hca_ptr->ib_trans.wait_object;
- at_rec.hca_ptr = hca_ptr;
- at_rec.retries = 0;
-
- /* call with async_comp until the sync version works */
- status = ib_at_ips_by_gid(&hca_ptr->ib_trans.gid,
- &ipv4_addr->sin_addr.s_addr, 1,
- &at_comp, &at_rec.req_id);
-
- if (status < 0) {
- dapl_dbg_log (DAPL_DBG_TYPE_ERR,
- " ips_by_gid: ERR ips_by_gid %d %s \n",
- status, strerror(errno));
- return 1;
- }
-
- dapl_dbg_log (DAPL_DBG_TYPE_UTIL,
- " ips_by_gid: RET %d at_rec %p -> id %lld\n",
- status, &at_rec, at_rec.req_id );
-
- if (status > 0) {
- dapli_ip_comp_handler(at_rec.req_id, (void*)&at_rec, status);
- } else {
- /* limit the resolution and cancel times */
- dat_status = dapl_os_wait_object_wait(
- &hca_ptr->ib_trans.wait_object,
- 500000);
- if (dat_status != DAT_SUCCESS) {
- dapl_dbg_log(
- DAPL_DBG_TYPE_UTIL,
- " ips_by_gid: REQ TIMEOUT, cancel %lld\n",
- at_rec.req_id);
-
- /*
- * FIX: indeterministic
- * AT may or may not provide -EINTR event
- */
- ib_at_cancel(at_rec.req_id);
-
- if (dapl_os_wait_object_wait(
- &hca_ptr->ib_trans.wait_object,
- 500000) != DAT_SUCCESS)
- {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " ips_by_gid: cancel %lld failed\n",
- at_rec.req_id);
- }
- }
- }
-
- if (!ipv4_addr->sin_addr.s_addr)
- return 1;
-
- return 0;
-}
-
-/*
- * dapls_ib_init, dapls_ib_release
- *
- * Initialize Verb related items for device open
- *
- * Input:
- * none
- *
- * Output:
- * none
- *
- * Returns:
- * 0 success, -1 error
- *
- */
-int32_t dapls_ib_init (void)
-{
- long opts;
- dapl_dbg_log (DAPL_DBG_TYPE_UTIL, " dapl_ib_init: \n" );
-
- /* initialize hca_list lock */
- dapl_os_lock_init(&g_hca_lock);
-
- /* initialize hca list for CQ events */
- dapl_llist_init_head(&g_hca_list);
-
- /* create pipe for waking up work thread */
- if (pipe(g_ib_pipe))
- return 1;
-
- /* set AT fd to non-blocking */
- opts = fcntl(ib_at_get_fd(), F_GETFL);
- if (fcntl(ib_at_get_fd(), F_SETFL, opts | O_NONBLOCK) < 0)
- return 1;
-
- if (dapli_ib_thread_init())
- return 1;
-
- return 0;
-}
-
-int32_t dapls_ib_release (void)
-{
- dapl_dbg_log (DAPL_DBG_TYPE_UTIL, " dapl_ib_release: \n" );
- dapli_ib_thread_destroy();
- return 0;
-}
-
-/*
- * dapls_ib_open_hca
- *
- * Open HCA
- *
- * Input:
- * *hca_name pointer to provider device name
- * *ib_hca_handle_p pointer to provide HCA handle
- *
- * Output:
- * none
- *
- * Return:
- * DAT_SUCCESS
- * dapl_convert_errno
- *
- */
-DAT_RETURN dapls_ib_open_hca (
- IN IB_HCA_NAME hca_name,
- IN DAPL_HCA *hca_ptr)
-{
- struct ibv_device **dev_list;
- long opts;
- int i;
- dapl_dbg_log (DAPL_DBG_TYPE_UTIL,
- " open_hca: %s - %p\n", hca_name, hca_ptr );
-
- /* Get list of all IB devices, find match, open */
- dev_list = ibv_get_device_list(NULL);
- if (!dev_list) {
- dapl_dbg_log (DAPL_DBG_TYPE_ERR,
- " open_hca: ibv_get_device_list() failed\n",
- hca_name);
- return DAT_INTERNAL_ERROR;
- }
-
- for (i = 0; dev_list[i]; ++i) {
- hca_ptr->ib_trans.ib_dev = dev_list[i];
- if (!strcmp(ibv_get_device_name(hca_ptr->ib_trans.ib_dev),
- hca_name))
- goto found;
- }
-
- dapl_dbg_log (DAPL_DBG_TYPE_ERR,
- " open_hca: IB device %s not found\n",
- hca_name);
- goto err;
-
-found:
- dapl_dbg_log (
- DAPL_DBG_TYPE_UTIL," open_hca: Found dev %s %016llx\n",
- ibv_get_device_name(hca_ptr->ib_trans.ib_dev),
- (unsigned long long)
- bswap_64(ibv_get_device_guid(hca_ptr->ib_trans.ib_dev)));
-
- hca_ptr->ib_hca_handle = ibv_open_device(hca_ptr->ib_trans.ib_dev);
- if (!hca_ptr->ib_hca_handle) {
- dapl_dbg_log (DAPL_DBG_TYPE_ERR,
- " open_hca: IB dev open failed for %s\n",
- ibv_get_device_name(hca_ptr->ib_trans.ib_dev));
- goto err;
- }
- hca_ptr->ib_trans.ib_ctx = hca_ptr->ib_hca_handle;
-
- /* set inline max with env or default, get local lid and gid 0 */
- hca_ptr->ib_trans.max_inline_send =
- dapl_os_get_env_val("DAPL_MAX_INLINE", INLINE_SEND_DEFAULT);
-
- /* GID with port_num provided, index 0 for now */
- if (ibv_query_gid(hca_ptr->ib_hca_handle,
- hca_ptr->port_num, 0, &hca_ptr->ib_trans.gid)) {
- dapl_dbg_log (DAPL_DBG_TYPE_ERR,
- " open_hca: IB get GID failed for %s\n",
- ibv_get_device_name(hca_ptr->ib_trans.ib_dev));
- goto bail;
- }
-
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
- " open_hca: GID subnet %016llx id %016llx\n",
- (unsigned long long)
- bswap_64(hca_ptr->ib_trans.gid.global.subnet_prefix),
- (unsigned long long)
- bswap_64(hca_ptr->ib_trans.gid.global.interface_id));
-
- /* get the IP address of the device using GID */
- if (dapli_get_hca_addr(hca_ptr)) {
- dapl_dbg_log (DAPL_DBG_TYPE_ERR,
- " open_hca: ERR ib_at_ips_by_gid for %s\n",
- ibv_get_device_name(hca_ptr->ib_trans.ib_dev));
- goto bail;
- }
-
- /* initialize hca wait object for uAT event */
- dapl_os_wait_object_init(&hca_ptr->ib_trans.wait_object);
-
- /* set event FD's to non-blocking */
- opts = fcntl(hca_ptr->ib_hca_handle->async_fd, F_GETFL); /* uASYNC */
- if (opts < 0 || fcntl(hca_ptr->ib_hca_handle->async_fd,
- F_SETFL, opts | O_NONBLOCK) < 0) {
- dapl_dbg_log (DAPL_DBG_TYPE_ERR,
- " open_hca: ERR with async FD\n" );
- goto bail;
- }
-
- /* EVD events without direct CQ channels, non-blocking */
- hca_ptr->ib_trans.ib_cq =
- ibv_create_comp_channel(hca_ptr->ib_hca_handle);
- opts = fcntl(hca_ptr->ib_trans.ib_cq->fd, F_GETFL); /* uCQ */
- if (opts < 0 || fcntl(hca_ptr->ib_trans.ib_cq->fd,
- F_SETFL, opts | O_NONBLOCK) < 0) {
- dapl_dbg_log (DAPL_DBG_TYPE_ERR,
- " open_hca: ERR with CQ FD\n" );
- goto bail;
- }
-
- /* Get CM device handle for events, and set to non-blocking */
- hca_ptr->ib_trans.ib_cm = ib_cm_get_device(hca_ptr->ib_hca_handle);
- opts = fcntl(hca_ptr->ib_trans.ib_cm->fd, F_GETFL); /* uCM */
- if (opts < 0 || fcntl(hca_ptr->ib_trans.ib_cm->fd,
- F_SETFL, opts | O_NONBLOCK) < 0) {
- dapl_dbg_log (DAPL_DBG_TYPE_ERR,
- " open_hca: ERR with CM FD\n" );
- goto bail;
- }
-
- /*
- * Put new hca_transport on list for async and CQ event processing
- * Wakeup work thread to add to polling list
- */
- dapl_llist_init_entry((DAPL_LLIST_ENTRY*)&hca_ptr->ib_trans.entry);
- dapl_os_lock( &g_hca_lock );
- dapl_llist_add_tail(&g_hca_list,
- (DAPL_LLIST_ENTRY*)&hca_ptr->ib_trans.entry,
- &hca_ptr->ib_trans.entry);
- write(g_ib_pipe[1], "w", sizeof "w");
- dapl_os_unlock(&g_hca_lock);
-
- dapl_dbg_log (
- DAPL_DBG_TYPE_UTIL,
- " open_hca: %s, port %d, %s %d.%d.%d.%d INLINE_MAX=%d\n",
- ibv_get_device_name(hca_ptr->ib_trans.ib_dev),
- hca_ptr->port_num,
- ((struct sockaddr_in *)
- &hca_ptr->hca_address)->sin_family == AF_INET ?
- "AF_INET":"AF_INET6",
- ((struct sockaddr_in *)
- &hca_ptr->hca_address)->sin_addr.s_addr >> 0 & 0xff,
- ((struct sockaddr_in *)
- &hca_ptr->hca_address)->sin_addr.s_addr >> 8 & 0xff,
- ((struct sockaddr_in *)
- &hca_ptr->hca_address)->sin_addr.s_addr >> 16 & 0xff,
- ((struct sockaddr_in *)
- &hca_ptr->hca_address)->sin_addr.s_addr >> 24 & 0xff,
- hca_ptr->ib_trans.max_inline_send );
-
- hca_ptr->ib_trans.d_hca = hca_ptr;
- ibv_free_device_list(dev_list);
- return DAT_SUCCESS;
-
-bail:
- ibv_close_device(hca_ptr->ib_hca_handle);
- hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
-err:
- ibv_free_device_list(dev_list);
- return DAT_INTERNAL_ERROR;
-}
-
-
-/*
- * dapls_ib_close_hca
- *
- * Open HCA
- *
- * Input:
- * DAPL_HCA provide CA handle
- *
- * Output:
- * none
- *
- * Return:
- * DAT_SUCCESS
- * dapl_convert_errno
- *
- */
-DAT_RETURN dapls_ib_close_hca ( IN DAPL_HCA *hca_ptr )
-{
- dapl_dbg_log (DAPL_DBG_TYPE_UTIL," close_hca: %p->%p\n",
- hca_ptr,hca_ptr->ib_hca_handle);
-
- if (hca_ptr->ib_hca_handle != IB_INVALID_HANDLE) {
- if (ibv_close_device(hca_ptr->ib_hca_handle))
- return(dapl_convert_errno(errno,"ib_close_device"));
- hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
- }
-
- /*
- * Remove hca from async and CQ event processing list
- * Wakeup work thread to remove from polling list
- */
- hca_ptr->ib_trans.destroy = 1;
- write(g_ib_pipe[1], "w", sizeof "w");
-
- /* wait for thread to remove HCA references */
- while (hca_ptr->ib_trans.destroy != 2) {
- struct timespec sleep, remain;
- sleep.tv_sec = 0;
- sleep.tv_nsec = 10000000; /* 10 ms */
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
- " ib_thread_destroy: wait on hca %p destroy\n");
- nanosleep (&sleep, &remain);
- }
- return (DAT_SUCCESS);
-}
-
-/*
- * dapls_ib_query_hca
- *
- * Query the hca attribute
- *
- * Input:
- * hca_handl hca handle
- * ia_attr attribute of the ia
- * ep_attr attribute of the ep
- * ip_addr ip address of DET NIC
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INVALID_HANDLE
- */
-
-DAT_RETURN dapls_ib_query_hca (
- IN DAPL_HCA *hca_ptr,
- OUT DAT_IA_ATTR *ia_attr,
- OUT DAT_EP_ATTR *ep_attr,
- OUT DAT_SOCK_ADDR6 *ip_addr)
-{
- struct ibv_device_attr dev_attr;
- struct ibv_port_attr port_attr;
-
- if (hca_ptr->ib_hca_handle == NULL) {
- dapl_dbg_log (DAPL_DBG_TYPE_ERR," query_hca: BAD handle\n");
- return (DAT_INVALID_HANDLE);
- }
-
- /* local IP address of device, set during ia_open */
- if (ip_addr != NULL)
- memcpy(ip_addr, &hca_ptr->hca_address, sizeof(DAT_SOCK_ADDR6));
-
- if (ia_attr == NULL && ep_attr == NULL)
- return DAT_SUCCESS;
-
- /* query verbs for this device and port attributes */
- if (ibv_query_device(hca_ptr->ib_hca_handle, &dev_attr) ||
- ibv_query_port(hca_ptr->ib_hca_handle,
- hca_ptr->port_num, &port_attr))
- return(dapl_convert_errno(errno,"ib_query_hca"));
-
- if (ia_attr != NULL) {
- (void) dapl_os_memzero(ia_attr, sizeof(*ia_attr));
- ia_attr->adapter_name[DAT_NAME_MAX_LENGTH - 1] = '\0';
- ia_attr->vendor_name[DAT_NAME_MAX_LENGTH - 1] = '\0';
- ia_attr->ia_address_ptr =
- (DAT_IA_ADDRESS_PTR)&hca_ptr->hca_address;
-
- dapl_dbg_log (DAPL_DBG_TYPE_UTIL,
- " query_hca: %s %s %d.%d.%d.%d\n",
- ibv_get_device_name(hca_ptr->ib_trans.ib_dev),
- ((struct sockaddr_in *)
- ia_attr->ia_address_ptr)->sin_family == AF_INET ?
- "AF_INET":"AF_INET6",
- ((struct sockaddr_in *)
- ia_attr->ia_address_ptr)->sin_addr.s_addr >> 0 & 0xff,
- ((struct sockaddr_in *)
- ia_attr->ia_address_ptr)->sin_addr.s_addr >> 8 & 0xff,
- ((struct sockaddr_in *)
- ia_attr->ia_address_ptr)->sin_addr.s_addr >> 16 & 0xff,
- ((struct sockaddr_in *)
- ia_attr->ia_address_ptr)->sin_addr.s_addr >> 24 & 0xff);
-
- ia_attr->hardware_version_major = dev_attr.hw_ver;
- /* ia_attr->hardware_version_minor = dev_attr.fw_ver; */
- ia_attr->max_eps = dev_attr.max_qp;
- ia_attr->max_dto_per_ep = dev_attr.max_qp_wr;
- ia_attr->max_rdma_read_in = dev_attr.max_qp_rd_atom;
- ia_attr->max_rdma_read_out = dev_attr.max_qp_rd_atom;
- ia_attr->max_rdma_read_per_ep_in = dev_attr.max_qp_rd_atom;
- ia_attr->max_rdma_read_per_ep_out = dev_attr.max_qp_rd_atom;
- ia_attr->max_rdma_read_per_ep_in_guaranteed = DAT_TRUE;
- ia_attr->max_rdma_read_per_ep_out_guaranteed = DAT_TRUE;
- ia_attr->max_evds = dev_attr.max_cq;
- ia_attr->max_evd_qlen = dev_attr.max_cqe;
- ia_attr->max_iov_segments_per_dto = dev_attr.max_sge;
- ia_attr->max_lmrs = dev_attr.max_mr;
- ia_attr->max_lmr_block_size = dev_attr.max_mr_size;
- ia_attr->max_rmrs = dev_attr.max_mw;
- ia_attr->max_lmr_virtual_address = dev_attr.max_mr_size;
- ia_attr->max_rmr_target_address = dev_attr.max_mr_size;
- ia_attr->max_pzs = dev_attr.max_pd;
- ia_attr->max_mtu_size = port_attr.max_msg_sz;
- ia_attr->max_rdma_size = port_attr.max_msg_sz;
- ia_attr->num_transport_attr = 0;
- ia_attr->transport_attr = NULL;
- ia_attr->num_vendor_attr = 0;
- ia_attr->vendor_attr = NULL;
-
- dapl_dbg_log (DAPL_DBG_TYPE_UTIL,
- " query_hca: (%x.%x) ep %d ep_q %d evd %d evd_q %d\n",
- ia_attr->hardware_version_major,
- ia_attr->hardware_version_minor,
- ia_attr->max_eps, ia_attr->max_dto_per_ep,
- ia_attr->max_evds, ia_attr->max_evd_qlen );
- dapl_dbg_log (DAPL_DBG_TYPE_UTIL,
- " query_hca: msg %llu rdma %llu iov %d lmr %d rmr %d\n",
- ia_attr->max_mtu_size, ia_attr->max_rdma_size,
- ia_attr->max_iov_segments_per_dto, ia_attr->max_lmrs,
- ia_attr->max_rmrs );
- }
-
- if (ep_attr != NULL) {
- (void) dapl_os_memzero(ep_attr, sizeof(*ep_attr));
- ep_attr->max_mtu_size = port_attr.max_msg_sz;
- ep_attr->max_rdma_size = port_attr.max_msg_sz;
- ep_attr->max_recv_dtos = dev_attr.max_qp_wr;
- ep_attr->max_request_dtos = dev_attr.max_qp_wr;
- ep_attr->max_recv_iov = dev_attr.max_sge;
- ep_attr->max_request_iov = dev_attr.max_sge;
- ep_attr->max_rdma_read_in = dev_attr.max_qp_rd_atom;
- ep_attr->max_rdma_read_out= dev_attr.max_qp_rd_atom;
- dapl_dbg_log (DAPL_DBG_TYPE_UTIL,
- " query_hca: MAX msg %llu dto %d iov %d rdma i%d,o%d\n",
- ep_attr->max_mtu_size,
- ep_attr->max_recv_dtos, ep_attr->max_recv_iov,
- ep_attr->max_rdma_read_in, ep_attr->max_rdma_read_out);
- }
-
- return DAT_SUCCESS;
-}
-
-/*
- * dapls_ib_setup_async_callback
- *
- * Set up an asynchronous callbacks of various kinds
- *
- * Input:
- * ia_handle IA handle
- * handler_type type of handler to set up
- * callback_handle handle param for completion callbacks
- * callback callback routine pointer
- * context argument for callback routine
- *
- * Output:
- * none
- *
- * Returns:
- * DAT_SUCCESS
- * DAT_INSUFFICIENT_RESOURCES
- * DAT_INVALID_PARAMETER
- *
- */
-DAT_RETURN dapls_ib_setup_async_callback (
- IN DAPL_IA *ia_ptr,
- IN DAPL_ASYNC_HANDLER_TYPE handler_type,
- IN DAPL_EVD *evd_ptr,
- IN ib_async_handler_t callback,
- IN void *context )
-
-{
- ib_hca_transport_t *hca_ptr;
-
- dapl_dbg_log (DAPL_DBG_TYPE_UTIL,
- " setup_async_cb: ia %p type %d hdl %p cb %p ctx %p\n",
- ia_ptr, handler_type, evd_ptr, callback, context);
-
- hca_ptr = &ia_ptr->hca_ptr->ib_trans;
- switch(handler_type)
- {
- case DAPL_ASYNC_UNAFILIATED:
- hca_ptr->async_unafiliated =
- (ib_async_handler_t)callback;
- hca_ptr->async_un_ctx = context;
- break;
- case DAPL_ASYNC_CQ_ERROR:
- hca_ptr->async_cq_error =
- (ib_async_cq_handler_t)callback;
- break;
- case DAPL_ASYNC_CQ_COMPLETION:
- hca_ptr->async_cq =
- (ib_async_dto_handler_t)callback;
- break;
- case DAPL_ASYNC_QP_ERROR:
- hca_ptr->async_qp_error =
- (ib_async_qp_handler_t)callback;
- break;
- default:
- break;
- }
- return DAT_SUCCESS;
-}
-
-int dapli_ib_thread_init(void)
-{
- DAT_RETURN dat_status;
-
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
- " ib_thread_init(%d)\n", getpid());
-
- /* create thread to process inbound connect request */
- dat_status = dapl_os_thread_create(dapli_thread, NULL, &g_ib_thread);
- if (dat_status != DAT_SUCCESS)
- {
- dapl_dbg_log(DAPL_DBG_TYPE_ERR,
- " ib_thread_init: failed to create thread\n");
- return 1;
- }
- return 0;
-}
-
-void dapli_ib_thread_destroy(void)
-{
- int retries = 10;
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
- " ib_thread_destroy(%d)\n", getpid());
- /*
- * wait for async thread to terminate.
- * pthread_join would be the correct method
- * but some applications have some issues
- */
-
- /* destroy ib_thread, wait for termination, if not already */
- dapl_os_lock( &g_hca_lock );
- g_ib_destroy = 1;
- write(g_ib_pipe[1], "w", sizeof "w");
-
- while ((g_ib_destroy != 2) && (retries--)) {
- struct timespec sleep, remain;
- sleep.tv_sec = 0;
- sleep.tv_nsec = 20000000; /* 20 ms */
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
- " ib_thread_destroy: waiting for ib_thread\n");
- write(g_ib_pipe[1], "w", sizeof "w");
- dapl_os_unlock( &g_hca_lock );
- nanosleep(&sleep, &remain);
- dapl_os_lock( &g_hca_lock );
- }
- dapl_os_unlock( &g_hca_lock );
-
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
- " ib_thread_destroy(%d) exit\n",getpid());
-}
-
-void dapli_async_event_cb(struct _ib_hca_transport *hca)
-{
- struct ibv_async_event event;
- struct pollfd async_fd = {
- .fd = hca->ib_ctx->async_fd,
- .events = POLLIN,
- .revents = 0
- };
-
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " dapli_async_event_cb(%p)\n",hca);
-
- if (hca->destroy)
- return;
-
- if ((poll(&async_fd, 1, 0)==1) &&
- (!ibv_get_async_event(hca->ib_ctx, &event))) {
-
- switch (event.event_type) {
-
- case IBV_EVENT_CQ_ERR:
- {
- struct dapl_ep *evd_ptr =
- event.element.cq->cq_context;
-
- dapl_dbg_log(
- DAPL_DBG_TYPE_WARN,
- " dapli_async_event CQ (%p) ERR %d\n",
- evd_ptr, event.event_type);
-
- /* report up if async callback still setup */
- if (hca->async_cq_error)
- hca->async_cq_error(hca->ib_ctx,
- event.element.cq,
- &event,
- (void*)evd_ptr);
- break;
- }
- case IBV_EVENT_COMM_EST:
- {
- /* Received msgs on connected QP before RTU */
- struct dapl_ep *ep_ptr =
- event.element.qp->qp_context;
-
- /* TODO: cannot process COMM_EST until ibv
- * guarantees valid QP context for events.
- * Race conditions exist with QP destroy call.
- * For now, assume the RTU will arrive.
- */
- dapl_dbg_log(
- DAPL_DBG_TYPE_UTIL,
- " dapli_async_event COMM_EST(qp=%p)\n",
- event.element.qp);
-
- if (!DAPL_BAD_HANDLE(ep_ptr, DAPL_MAGIC_EP) &&
- ep_ptr->cm_handle != IB_INVALID_HANDLE)
- ib_cm_establish(
- ep_ptr->cm_handle->cm_id);
-
- break;
- }
- case IBV_EVENT_QP_FATAL:
- case IBV_EVENT_QP_REQ_ERR:
- case IBV_EVENT_QP_ACCESS_ERR:
- case IBV_EVENT_QP_LAST_WQE_REACHED:
- case IBV_EVENT_SRQ_ERR:
- case IBV_EVENT_SRQ_LIMIT_REACHED:
- case IBV_EVENT_SQ_DRAINED:
- {
- struct dapl_ep *ep_ptr =
- event.element.qp->qp_context;
-
- dapl_dbg_log(
- DAPL_DBG_TYPE_WARN,
- " dapli_async_event QP (%p) ERR %d\n",
- ep_ptr, event.event_type);
-
- /* report up if async callback still setup */
- if (hca->async_qp_error)
- hca->async_qp_error(hca->ib_ctx,
- event.element.qp,
- &event,
- (void*)ep_ptr);
- break;
- }
- case IBV_EVENT_PATH_MIG:
- case IBV_EVENT_PATH_MIG_ERR:
- case IBV_EVENT_DEVICE_FATAL:
- case IBV_EVENT_PORT_ACTIVE:
- case IBV_EVENT_PORT_ERR:
- case IBV_EVENT_LID_CHANGE:
- case IBV_EVENT_PKEY_CHANGE:
- case IBV_EVENT_SM_CHANGE:
- {
- dapl_dbg_log(DAPL_DBG_TYPE_WARN,
- " dapli_async_event DEV ERR %d\n",
- event.event_type);
-
- /* report up if async callback still setup */
- if (hca->async_unafiliated)
- hca->async_unafiliated(
- hca->ib_ctx,
- &event,
- hca->async_un_ctx);
- break;
- }
- default:
- {
- dapl_dbg_log (DAPL_DBG_TYPE_WARN,
- "--> DsEventCb: UNKNOWN\n");
- break;
- }
- }
- ibv_ack_async_event(&event);
- }
-}
-
-/* work thread for uAT, uCM, CQ, and async events */
-void dapli_thread(void *arg)
-{
- struct pollfd ufds[__FD_SETSIZE];
- struct _ib_hca_transport *uhca[__FD_SETSIZE]={NULL};
- struct _ib_hca_transport *hca;
- int ret,idx,fds;
- char rbuf[2];
-
- dapl_dbg_log (DAPL_DBG_TYPE_UTIL,
- " ib_thread(%d,0x%x): ENTER: pipe %d at %d\n",
- getpid(), g_ib_thread,
- g_ib_pipe[0], ib_at_get_fd());
-
- /* Poll across pipe, CM, AT never changes */
- dapl_os_lock( &g_hca_lock );
-
- ufds[0].fd = g_ib_pipe[0]; /* pipe */
- ufds[0].events = POLLIN;
- ufds[1].fd = ib_at_get_fd(); /* uAT */
- ufds[1].events = POLLIN;
-
- while (!g_ib_destroy) {
-
- /* build ufds after pipe, at events */
- ufds[0].revents = 0;
- ufds[1].revents = 0;
- idx=1;
-
- /* Walk HCA list and setup async and CQ events */
- if (!dapl_llist_is_empty(&g_hca_list))
- hca = dapl_llist_peek_head(&g_hca_list);
- else
- hca = NULL;
-
- while(hca) {
- ufds[++idx].fd = hca->ib_cm->fd; /* uCM */
- ufds[idx].events = POLLIN;
- ufds[idx].revents = 0;
- uhca[idx] = hca;
- ufds[++idx].fd = hca->ib_ctx->async_fd; /* uASYNC */
- ufds[idx].events = POLLIN;
- ufds[idx].revents = 0;
- uhca[idx] = hca;
-
- if (hca->ib_cq != NULL) {
- ufds[++idx].fd = hca->ib_cq->fd; /* uCQ */
- ufds[idx].events = POLLIN;
- ufds[idx].revents = 0;
- uhca[idx] = hca;
- }
-
- hca = dapl_llist_next_entry(
- &g_hca_list,
- (DAPL_LLIST_ENTRY*)&hca->entry);
- }
-
- /* unlock, and setup poll */
- fds = idx+1;
- dapl_os_unlock(&g_hca_lock);
- ret = poll(ufds, fds, -1);
- if (ret <= 0) {
- dapl_dbg_log(DAPL_DBG_TYPE_WARN,
- " ib_thread(%d): ERR %s poll\n",
- getpid(),strerror(errno));
- dapl_os_lock(&g_hca_lock);
- continue;
- }
-
- /* check and process CM, CQ and ASYNC events, per device */
- for(idx=2;idx<fds;idx++) {
- if (ufds[idx].revents == POLLIN) {
- dapli_cq_event_cb(uhca[idx]);
- dapli_cm_event_cb(uhca[idx]);
- dapli_async_event_cb(uhca[idx]);
- }
- }
-
- /* check and process user events */
- if (ufds[0].revents == POLLIN) {
-
- read(g_ib_pipe[0], rbuf, 2);
-
- /* cleanup any device on list marked for destroy */
- for(idx=3;idx<fds;idx++) {
- if(uhca[idx] && uhca[idx]->destroy == 1) {
- dapl_os_lock(&g_hca_lock);
- dapl_llist_remove_entry(
- &g_hca_list,
- (DAPL_LLIST_ENTRY*)
- &uhca[idx]->entry);
- dapl_os_unlock(&g_hca_lock);
- uhca[idx]->destroy = 2;
- }
- }
- }
-
- /* AT events */
- if (ufds[1].revents == POLLIN)
- dapli_at_event_cb();
-
- dapl_os_lock(&g_hca_lock);
- }
- dapl_dbg_log(DAPL_DBG_TYPE_UTIL," ib_thread(%d) EXIT\n",getpid());
- g_ib_destroy = 2;
- dapl_os_unlock(&g_hca_lock);
-}
-
+++ /dev/null
-/*
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- * copy of which is available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/***************************************************************************
- *
- * Module: uDAPL
- *
- * Filename: dapl_ib_util.h
- *
- * Author: Arlin Davis
- *
- * Created: 3/10/2005
- *
- * Description:
- *
- * The uDAPL openib provider - definitions, prototypes,
- *
- ****************************************************************************
- * Source Control System Information
- *
- * $Id: $
- *
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- **************************************************************************/
-
-#ifndef _DAPL_IB_UTIL_H_
-#define _DAPL_IB_UTIL_H_
-
-#include "verbs.h"
-#include <byteswap.h>
-#include <infiniband/sa.h>
-#include <infiniband/cm.h>
-#include <infiniband/at.h>
-
-/* Typedefs to map common DAPL provider types to IB verbs */
-typedef struct ibv_qp *ib_qp_handle_t;
-typedef struct ibv_cq *ib_cq_handle_t;
-typedef struct ibv_pd *ib_pd_handle_t;
-typedef struct ibv_mr *ib_mr_handle_t;
-typedef struct ibv_mw *ib_mw_handle_t;
-typedef struct ibv_wc ib_work_completion_t;
-
-/* HCA context type maps to IB verbs */
-typedef struct ibv_context *ib_hca_handle_t;
-typedef ib_hca_handle_t dapl_ibal_ca_t;
-
-#define IB_RC_RETRY_COUNT 7
-#define IB_RNR_RETRY_COUNT 7
-#define IB_CM_RESPONSE_TIMEOUT 18 /* 1 sec */
-#define IB_MAX_CM_RETRIES 7
-
-#define IB_REQ_MRA_TIMEOUT 27 /* a little over 9 minutes */
-#define IB_MAX_AT_RETRY 3
-
-#define IB_TARGET_MAX 4 /* max_qp_ous_rd_atom */
-#define IB_INITIATOR_DEPTH 4 /* max_qp_init_rd_atom */
-
-typedef enum {
- IB_CME_CONNECTED,
- IB_CME_DISCONNECTED,
- IB_CME_DISCONNECTED_ON_LINK_DOWN,
- IB_CME_CONNECTION_REQUEST_PENDING,
- IB_CME_CONNECTION_REQUEST_PENDING_PRIVATE_DATA,
- IB_CME_CONNECTION_REQUEST_ACKED,
- IB_CME_DESTINATION_REJECT,
- IB_CME_DESTINATION_REJECT_PRIVATE_DATA,
- IB_CME_DESTINATION_UNREACHABLE,
- IB_CME_TOO_MANY_CONNECTION_REQUESTS,
- IB_CME_LOCAL_FAILURE,
- IB_CME_BROKEN
-} ib_cm_events_t;
-
-struct dapl_at_record {
- uint64_t req_id;
- DAT_SOCK_ADDR6 *addr;
- DAPL_OS_WAIT_OBJECT *wait_object;
- struct dapl_hca *hca_ptr;
- int retries;
-};
-
-/*
- * dapl_llist_entry in dapl.h but dapl.h depends on provider
- * typedef's in this file first. move dapl_llist_entry out of dapl.h
- */
-struct ib_llist_entry
-{
- struct dapl_llist_entry *flink;
- struct dapl_llist_entry *blink;
- void *data;
- struct dapl_llist_entry *list_head;
-};
-
-struct dapl_cm_id {
- struct ib_llist_entry entry;
- DAPL_OS_LOCK lock;
- DAPL_OS_WAIT_OBJECT wait_object;
- int retries;
- int destroy;
- int in_callback;
- struct ib_cm_id *cm_id;
- DAT_SOCK_ADDR6 r_addr;
- DAT_CONN_QUAL service_id;
- struct dapl_hca *hca;
- struct dapl_sp *sp;
- struct dapl_ep *ep;
- struct ib_at_ib_route dapl_rt;
- struct ib_sa_path_rec dapl_path;
- struct ib_cm_req_param req;
- struct ib_cm_req_event_param req_rcvd;
- struct ib_at_completion dapl_comp;
-};
-
-typedef struct dapl_cm_id *ib_cm_handle_t;
-typedef struct dapl_cm_id *ib_cm_srvc_handle_t;
-
-/* Operation and state mappings */
-typedef enum ibv_send_flags ib_send_op_type_t;
-typedef struct ibv_sge ib_data_segment_t;
-typedef enum ibv_qp_state ib_qp_state_t;
-typedef enum ibv_event_type ib_async_event_type;
-typedef struct ibv_async_event ib_error_record_t;
-
-/* CQ notifications */
-typedef enum
-{
- IB_NOTIFY_ON_NEXT_COMP,
- IB_NOTIFY_ON_SOLIC_COMP
-
-} ib_notification_type_t;
-
-/* other mappings */
-typedef int ib_bool_t;
-typedef union ibv_gid GID;
-typedef char *IB_HCA_NAME;
-typedef uint16_t ib_hca_port_t;
-typedef uint32_t ib_comp_handle_t;
-
-#ifdef CQ_WAIT_OBJECT
-typedef struct ibv_comp_channel *ib_wait_obj_handle_t;
-#endif
-
-/* Definitions */
-#define IB_INVALID_HANDLE NULL
-
-/* inline send rdma threshold */
-#define INLINE_SEND_DEFAULT 128
-
-/* CM private data areas */
-#define IB_MAX_REQ_PDATA_SIZE 92
-#define IB_MAX_REP_PDATA_SIZE 196
-#define IB_MAX_REJ_PDATA_SIZE 148
-#define IB_MAX_DREQ_PDATA_SIZE 220
-#define IB_MAX_DREP_PDATA_SIZE 224
-
-/* DTO OPs, ordered for DAPL ENUM definitions */
-#define OP_RDMA_WRITE IBV_WR_RDMA_WRITE
-#define OP_RDMA_WRITE_IMM IBV_WR_RDMA_WRITE_WITH_IMM
-#define OP_SEND IBV_WR_SEND
-#define OP_SEND_IMM IBV_WR_SEND_WITH_IMM
-#define OP_RDMA_READ IBV_WR_RDMA_READ
-#define OP_COMP_AND_SWAP IBV_WR_ATOMIC_CMP_AND_SWP
-#define OP_FETCH_AND_ADD IBV_WR_ATOMIC_FETCH_AND_ADD
-#define OP_RECEIVE 7 /* internal op */
-#define OP_RECEIVE_IMM 8 /* internel op */
-#define OP_BIND_MW 9 /* internal op */
-#define OP_INVALID 0xff
-
-/* Definitions to map QP state */
-#define IB_QP_STATE_RESET IBV_QPS_RESET
-#define IB_QP_STATE_INIT IBV_QPS_INIT
-#define IB_QP_STATE_RTR IBV_QPS_RTR
-#define IB_QP_STATE_RTS IBV_QPS_RTS
-#define IB_QP_STATE_SQD IBV_QPS_SQD
-#define IB_QP_STATE_SQE IBV_QPS_SQE
-#define IB_QP_STATE_ERROR IBV_QPS_ERR
-
-/* Definitions for ibverbs/mthca return codes, should be defined in verbs.h */
-/* some are errno and some are -n values */
-
-/**
- * ibv_get_device_name - Return kernel device name
- * ibv_get_device_guid - Return device's node GUID
- * ibv_open_device - Return ibv_context or NULL
- * ibv_close_device - Return 0, (errno?)
- * ibv_get_async_event - Return 0, -1
- * ibv_alloc_pd - Return ibv_pd, NULL
- * ibv_dealloc_pd - Return 0, errno
- * ibv_reg_mr - Return ibv_mr, NULL
- * ibv_dereg_mr - Return 0, errno
- * ibv_create_cq - Return ibv_cq, NULL
- * ibv_destroy_cq - Return 0, errno
- * ibv_get_cq_event - Return 0 & ibv_cq/context, int
- * ibv_poll_cq - Return n & ibv_wc, 0 ok, -1 empty, -2 error
- * ibv_req_notify_cq - Return 0 (void?)
- * ibv_create_qp - Return ibv_qp, NULL
- * ibv_modify_qp - Return 0, errno
- * ibv_destroy_qp - Return 0, errno
- * ibv_post_send - Return 0, -1 & bad_wr
- * ibv_post_recv - Return 0, -1 & bad_wr
- */
-
-/* async handler for DTO, CQ, QP, and unafiliated */
-typedef void (*ib_async_dto_handler_t)(
- IN ib_hca_handle_t ib_hca_handle,
- IN ib_error_record_t *err_code,
- IN void *context);
-
-typedef void (*ib_async_cq_handler_t)(
- IN ib_hca_handle_t ib_hca_handle,
- IN ib_cq_handle_t ib_cq_handle,
- IN ib_error_record_t *err_code,
- IN void *context);
-
-typedef void (*ib_async_qp_handler_t)(
- IN ib_hca_handle_t ib_hca_handle,
- IN ib_qp_handle_t ib_qp_handle,
- IN ib_error_record_t *err_code,
- IN void *context);
-
-typedef void (*ib_async_handler_t)(
- IN ib_hca_handle_t ib_hca_handle,
- IN ib_error_record_t *err_code,
- IN void *context);
-
-
-/* ib_hca_transport_t, specific to this implementation */
-typedef struct _ib_hca_transport
-{
- struct ib_llist_entry entry;
- int destroy;
- struct dapl_hca *d_hca;
- struct ibv_device *ib_dev;
- struct ibv_context *ib_ctx;
- struct ib_cm_device *ib_cm;
- struct ibv_comp_channel *ib_cq;
- ib_cq_handle_t ib_cq_empty;
- DAPL_OS_WAIT_OBJECT wait_object;
- int max_inline_send;
- union ibv_gid gid;
- ib_async_handler_t async_unafiliated;
- void *async_un_ctx;
- ib_async_cq_handler_t async_cq_error;
- ib_async_dto_handler_t async_cq;
- ib_async_qp_handler_t async_qp_error;
-
-} ib_hca_transport_t;
-
-/* provider specfic fields for shared memory support */
-typedef uint32_t ib_shm_transport_t;
-
-/* prototypes */
-int32_t dapls_ib_init (void);
-int32_t dapls_ib_release (void);
-void dapli_thread(void *arg);
-int dapli_ib_thread_init(void);
-void dapli_ib_thread_destroy(void);
-int dapli_get_hca_addr(struct dapl_hca *hca_ptr);
-void dapli_ip_comp_handler(uint64_t req_id, void *context, int rec_num);
-void dapli_cm_event_cb(struct _ib_hca_transport *hca);
-void dapli_at_event_cb(void);
-void dapli_cq_event_cb(struct _ib_hca_transport *hca);
-void dapli_async_event_cb(struct _ib_hca_transport *hca);
-
-DAT_RETURN
-dapls_modify_qp_state ( IN ib_qp_handle_t qp_handle,
- IN ib_qp_state_t qp_state,
- IN struct dapl_cm_id *conn );
-
-/* inline functions */
-STATIC _INLINE_ IB_HCA_NAME dapl_ib_convert_name (IN char *name)
-{
- /* use ascii; name of local device */
- return dapl_os_strdup(name);
-}
-
-STATIC _INLINE_ void dapl_ib_release_name (IN IB_HCA_NAME name)
-{
- return;
-}
-
-/*
- * Convert errno to DAT_RETURN values
- */
-STATIC _INLINE_ DAT_RETURN
-dapl_convert_errno( IN int err, IN const char *str )
-{
- if (!err) return DAT_SUCCESS;
-
-#if DAPL_DBG
- if ((err != EAGAIN) && (err != ETIME) && (err != ETIMEDOUT))
- dapl_dbg_log (DAPL_DBG_TYPE_ERR," %s %s\n", str, strerror(err));
-#endif
-
- switch( err )
- {
- case EOVERFLOW : return DAT_LENGTH_ERROR;
- case EACCES : return DAT_PRIVILEGES_VIOLATION;
- case ENXIO :
- case ERANGE :
- case EPERM : return DAT_PROTECTION_VIOLATION;
- case EINVAL :
- case EBADF :
- case ENOENT :
- case ENOTSOCK : return DAT_INVALID_HANDLE;
- case EISCONN : return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_CONNECTED;
- case ECONNREFUSED : return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_NOTREADY;
- case ETIME :
- case ETIMEDOUT : return DAT_TIMEOUT_EXPIRED;
- case ENETUNREACH: return DAT_INVALID_ADDRESS | DAT_INVALID_ADDRESS_UNREACHABLE;
- case EADDRINUSE : return DAT_CONN_QUAL_IN_USE;
- case EALREADY : return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_ACTCONNPENDING;
- case ENOSPC :
- case ENOMEM :
- case E2BIG :
- case EDQUOT : return DAT_INSUFFICIENT_RESOURCES;
- case EAGAIN : return DAT_QUEUE_EMPTY;
- case EINTR : return DAT_INTERRUPTED_CALL;
- case EAFNOSUPPORT : return DAT_INVALID_ADDRESS | DAT_INVALID_ADDRESS_MALFORMED;
- case EFAULT :
- default : return DAT_INTERNAL_ERROR;
- }
- }
-
-#endif /* _DAPL_IB_UTIL_H_ */