2005-07-01 01:28:35 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-07-01 01:28:35 +04:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
Bring over all the work from the /tmp/ib-hw-detect branch. In
addition to my design and testing, it was conceptually approved by
Gil, Gleb, Pasha, Brad, and Galen. Functionally [probably somewhat
lightly] tested by Galen. We may still have to shake out some bugs
during the next few months, but it seems to be working for all the
cases that I can throw at it.
Here's a summary of the changes from that branch:
* Move MCA parameter registration to a new file (btl_openib_mca.c):
* Properly check the retun status of registering MCA params
* Check for valid values of MCA parameters
* Make help strings better
* Otherwise, the only default value of an MCA param that was
changed was max_btls; it went from 4 to -1 (meaning: use all
available)
* Properly prototyped internal functions in _component.c
* Made a bunch of functions static that didn't need to be public
* Renamed to remove "mca_" prefix from static functions
* Call new MCA param registration function
* Call new INI file read/lookup/finalize functions
* Updated a bunch of macros to be "BTL_" instead of "ORTE_"
* Be a little more consistent with return values
* Handle -1 for the max_btls MCA param
* Fixed a free() that should have been an OBJ_RELEASE()
* Some re-indenting
* Added INI-file parsing
* New flex file: btl_openib_ini.l
* New default HCA params .ini file (probably to be expanded over
time by other HCA vendors)
* Added more show_help messages for parsing problems
* Read in INI files and cache the values for later lookup
* When component opens an HCA, lookup to see if any corresponding
values were found in the INI files (ID'ed by the HCA vendor_id
and vendor_part_id)
* Added btl_openib_verbose MCA param that shows what the INI-file
stuff does (e.g., shows which MTU your HCA ends up using)
* Added btl_openib_hca_param_files as a colon-delimited list of INI
files to check for values during startup (in order,
left-to-right, just like the MCA base directory param).
* MTU is currently the only value supported in this framework.
* It is not a fatal error if we don't find params for the HCA in
the INI file(s). Instead, just print a warning. New MCA param
btl_openib_warn_no_hca_params_found can be used to disable
printing the warning.
* Add MTU to peer negotiation when making a connection
* Exchange maximum MTU; select the lesser of the two
This commit was SVN r11182.
2006-08-14 23:30:37 +04:00
|
|
|
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
|
2005-07-01 01:28:35 +04:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/types.h"
|
2006-02-07 18:20:44 +03:00
|
|
|
#include "ompi/mca/pml/base/pml_base_sendreq.h"
|
|
|
|
#include "orte/mca/ns/base/base.h"
|
|
|
|
#include "orte/mca/oob/base/base.h"
|
|
|
|
#include "orte/mca/rml/rml.h"
|
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
|
|
#include "orte/dss/dss.h"
|
2005-07-01 01:28:35 +04:00
|
|
|
#include "btl_openib.h"
|
|
|
|
#include "btl_openib_endpoint.h"
|
|
|
|
#include "btl_openib_proc.h"
|
|
|
|
#include "btl_openib_frag.h"
|
2006-02-07 18:20:44 +03:00
|
|
|
#include "ompi/class/ompi_free_list.h"
|
2005-07-15 19:13:19 +04:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
static void mca_btl_openib_endpoint_construct(mca_btl_base_endpoint_t* endpoint);
|
|
|
|
static void mca_btl_openib_endpoint_destruct(mca_btl_base_endpoint_t* endpoint);
|
|
|
|
|
|
|
|
int mca_btl_openib_endpoint_create_qp(
|
2005-07-12 17:38:54 +04:00
|
|
|
mca_btl_openib_module_t* openib_btl,
|
|
|
|
struct ibv_pd* pd,
|
|
|
|
struct ibv_cq* cq,
|
2005-10-02 22:58:57 +04:00
|
|
|
struct ibv_srq* srq,
|
2006-01-18 19:20:50 +03:00
|
|
|
struct ibv_qp_attr* qp_attr,
|
|
|
|
struct ibv_qp** qp
|
|
|
|
);
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-07-12 17:38:54 +04:00
|
|
|
int mca_btl_openib_endpoint_qp_init_query(
|
|
|
|
mca_btl_openib_module_t* openib_btl,
|
|
|
|
struct ibv_qp* qp,
|
|
|
|
struct ibv_qp_attr* attr,
|
|
|
|
uint32_t lcl_psn,
|
|
|
|
uint32_t rem_qp_num,
|
|
|
|
uint32_t rem_psn,
|
|
|
|
uint16_t rem_lid,
|
Bring over all the work from the /tmp/ib-hw-detect branch. In
addition to my design and testing, it was conceptually approved by
Gil, Gleb, Pasha, Brad, and Galen. Functionally [probably somewhat
lightly] tested by Galen. We may still have to shake out some bugs
during the next few months, but it seems to be working for all the
cases that I can throw at it.
Here's a summary of the changes from that branch:
* Move MCA parameter registration to a new file (btl_openib_mca.c):
* Properly check the retun status of registering MCA params
* Check for valid values of MCA parameters
* Make help strings better
* Otherwise, the only default value of an MCA param that was
changed was max_btls; it went from 4 to -1 (meaning: use all
available)
* Properly prototyped internal functions in _component.c
* Made a bunch of functions static that didn't need to be public
* Renamed to remove "mca_" prefix from static functions
* Call new MCA param registration function
* Call new INI file read/lookup/finalize functions
* Updated a bunch of macros to be "BTL_" instead of "ORTE_"
* Be a little more consistent with return values
* Handle -1 for the max_btls MCA param
* Fixed a free() that should have been an OBJ_RELEASE()
* Some re-indenting
* Added INI-file parsing
* New flex file: btl_openib_ini.l
* New default HCA params .ini file (probably to be expanded over
time by other HCA vendors)
* Added more show_help messages for parsing problems
* Read in INI files and cache the values for later lookup
* When component opens an HCA, lookup to see if any corresponding
values were found in the INI files (ID'ed by the HCA vendor_id
and vendor_part_id)
* Added btl_openib_verbose MCA param that shows what the INI-file
stuff does (e.g., shows which MTU your HCA ends up using)
* Added btl_openib_hca_param_files as a colon-delimited list of INI
files to check for values during startup (in order,
left-to-right, just like the MCA base directory param).
* MTU is currently the only value supported in this framework.
* It is not a fatal error if we don't find params for the HCA in
the INI file(s). Instead, just print a warning. New MCA param
btl_openib_warn_no_hca_params_found can be used to disable
printing the warning.
* Add MTU to peer negotiation when making a connection
* Exchange maximum MTU; select the lesser of the two
This commit was SVN r11182.
2006-08-14 23:30:37 +04:00
|
|
|
uint32_t rem_mtu,
|
2005-07-12 17:38:54 +04:00
|
|
|
uint32_t port_num
|
|
|
|
);
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-07-20 19:17:18 +04:00
|
|
|
/*
|
|
|
|
* post a send to the work queue
|
|
|
|
*/
|
2006-09-05 20:00:18 +04:00
|
|
|
static int btl_openib_acquire_send_resources(
|
|
|
|
mca_btl_openib_module_t *openib_btl,
|
|
|
|
mca_btl_openib_endpoint_t *endpoint,
|
|
|
|
mca_btl_openib_frag_t *frag, int prio, int *do_rdma)
|
|
|
|
{
|
|
|
|
if(OPAL_THREAD_ADD32(&endpoint->sd_wqe[prio], -1) < 0) {
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->sd_wqe[prio], 1);
|
|
|
|
opal_list_append(&endpoint->pending_frags[prio],
|
|
|
|
(opal_list_item_t *)frag);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-05 20:04:04 +04:00
|
|
|
if(BTL_OPENIB_HP_QP == prio) {
|
|
|
|
if(OPAL_THREAD_ADD32(&endpoint->eager_rdma_remote.tokens, -1) < 0) {
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->eager_rdma_remote.tokens, 1);
|
|
|
|
} else {
|
|
|
|
*do_rdma = 1;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-05 20:00:18 +04:00
|
|
|
if(mca_btl_openib_component.use_srq) {
|
|
|
|
if(OPAL_THREAD_ADD32(&openib_btl->sd_tokens[prio], -1) < 0) {
|
|
|
|
OPAL_THREAD_ADD32(&openib_btl->sd_tokens[prio], 1);
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->sd_wqe[prio], 1);
|
|
|
|
OPAL_THREAD_LOCK(&openib_btl->ib_lock);
|
|
|
|
opal_list_append(&openib_btl->pending_frags[prio],
|
|
|
|
(opal_list_item_t *)frag);
|
|
|
|
OPAL_THREAD_UNLOCK(&openib_btl->ib_lock);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(OPAL_THREAD_ADD32(&endpoint->sd_tokens[prio], -1) < 0) {
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->sd_tokens[prio], 1);
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->sd_wqe[prio], 1);
|
|
|
|
opal_list_append(&endpoint->pending_frags[prio],
|
|
|
|
(opal_list_item_t *)frag);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this function os called with endpoint->endpoint_lock held */
|
2005-07-12 17:38:54 +04:00
|
|
|
static inline int mca_btl_openib_endpoint_post_send(mca_btl_openib_module_t* openib_btl,
|
|
|
|
mca_btl_openib_endpoint_t * endpoint,
|
|
|
|
mca_btl_openib_frag_t * frag)
|
2005-07-01 01:28:35 +04:00
|
|
|
{
|
2006-09-12 13:17:59 +04:00
|
|
|
int do_rdma = 0, prio;
|
2005-07-13 04:17:08 +04:00
|
|
|
struct ibv_send_wr* bad_wr;
|
2006-09-12 13:17:59 +04:00
|
|
|
|
2005-11-18 20:08:51 +03:00
|
|
|
frag->sg_entry.addr = (unsigned long) frag->hdr;
|
2006-01-13 02:42:44 +03:00
|
|
|
|
2006-09-12 13:17:59 +04:00
|
|
|
prio = (frag->base.des_flags & MCA_BTL_DES_FLAGS_PRIORITY) ?
|
|
|
|
BTL_OPENIB_HP_QP : BTL_OPENIB_LP_QP;
|
2006-09-05 20:00:18 +04:00
|
|
|
|
2006-09-12 13:17:59 +04:00
|
|
|
if(btl_openib_acquire_send_resources(openib_btl, endpoint, frag,
|
|
|
|
prio, &do_rdma) == OMPI_ERR_OUT_OF_RESOURCE)
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
|
|
|
|
if(BTL_OPENIB_HP_QP == prio && endpoint->eager_rdma_local.credits > 0) {
|
|
|
|
frag->hdr->credits = endpoint->eager_rdma_local.credits;
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->eager_rdma_local.credits,
|
|
|
|
-frag->hdr->credits);
|
|
|
|
frag->hdr->credits |= BTL_OPENIB_RDMA_CREDITS_FLAG;
|
|
|
|
} else if(endpoint->rd_credits[prio] > 0) {
|
|
|
|
frag->hdr->credits = endpoint->rd_credits[prio];
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->rd_credits[prio], -frag->hdr->credits);
|
2005-07-01 01:28:35 +04:00
|
|
|
} else {
|
2006-09-12 13:17:59 +04:00
|
|
|
frag->hdr->credits = 0;
|
|
|
|
}
|
|
|
|
|
2006-03-26 12:30:50 +04:00
|
|
|
frag->sg_entry.length =
|
|
|
|
frag->segment.seg_len + sizeof(mca_btl_openib_header_t) +
|
|
|
|
(do_rdma ? sizeof(mca_btl_openib_footer_t) : 0);
|
2005-07-20 01:04:22 +04:00
|
|
|
if(frag->sg_entry.length <= openib_btl->ib_inline_max) {
|
2006-01-13 02:42:44 +03:00
|
|
|
frag->wr_desc.sr_desc.send_flags = IBV_SEND_SIGNALED|IBV_SEND_INLINE;
|
2005-07-25 18:57:33 +04:00
|
|
|
} else {
|
|
|
|
frag->wr_desc.sr_desc.send_flags = IBV_SEND_SIGNALED;
|
|
|
|
}
|
2006-03-26 12:30:50 +04:00
|
|
|
|
|
|
|
if(do_rdma) {
|
|
|
|
mca_btl_openib_footer_t* ftr =
|
|
|
|
(mca_btl_openib_footer_t*)(((char*)frag->segment.seg_addr.pval) +
|
|
|
|
frag->segment.seg_len);
|
|
|
|
frag->wr_desc.sr_desc.opcode = IBV_WR_RDMA_WRITE;
|
|
|
|
MCA_BTL_OPENIB_RDMA_FRAG_SET_SIZE(ftr, frag->sg_entry.length);
|
|
|
|
MCA_BTL_OPENIB_RDMA_MAKE_LOCAL(ftr);
|
2006-06-28 15:25:09 +04:00
|
|
|
#if OMPI_ENABLE_DEBUG
|
2006-03-26 12:30:50 +04:00
|
|
|
((mca_btl_openib_footer_t*)(((char*)frag->segment.seg_addr.pval) +
|
|
|
|
frag->segment.seg_len))->seq =
|
|
|
|
endpoint->eager_rdma_remote.seq++;
|
|
|
|
#endif
|
|
|
|
frag->wr_desc.sr_desc.wr.rdma.rkey = endpoint->eager_rdma_remote.rkey;
|
|
|
|
frag->wr_desc.sr_desc.wr.rdma.remote_addr =
|
2006-05-25 15:05:12 +04:00
|
|
|
(uintptr_t)endpoint->eager_rdma_remote.base.pval +
|
2006-03-26 12:30:50 +04:00
|
|
|
endpoint->eager_rdma_remote.head *
|
|
|
|
openib_btl->eager_rdma_frag_size +
|
|
|
|
sizeof(mca_btl_openib_frag_t) +
|
|
|
|
sizeof(mca_btl_openib_header_t) +
|
2006-07-27 18:09:30 +04:00
|
|
|
mca_btl_openib_component.eager_limit +
|
2006-03-26 12:30:50 +04:00
|
|
|
sizeof(mca_btl_openib_footer_t);
|
|
|
|
frag->wr_desc.sr_desc.wr.rdma.remote_addr -= frag->sg_entry.length;
|
2006-09-12 13:17:59 +04:00
|
|
|
MCA_BTL_OPENIB_RDMA_NEXT_INDEX(endpoint->eager_rdma_remote.head);
|
2006-03-26 12:30:50 +04:00
|
|
|
} else {
|
2006-09-05 20:04:04 +04:00
|
|
|
if(mca_btl_openib_component.use_srq) {
|
|
|
|
frag->wr_desc.sr_desc.opcode = IBV_WR_SEND_WITH_IMM;
|
|
|
|
frag->wr_desc.sr_desc.imm_data = endpoint->rem_info.rem_index;
|
|
|
|
} else {
|
|
|
|
frag->wr_desc.sr_desc.opcode = IBV_WR_SEND;
|
|
|
|
}
|
2006-03-26 12:30:50 +04:00
|
|
|
}
|
2006-09-05 20:00:18 +04:00
|
|
|
|
2006-09-12 13:17:59 +04:00
|
|
|
if(ibv_post_send(endpoint->lcl_qp[prio], &frag->wr_desc.sr_desc,
|
|
|
|
&bad_wr)) {
|
|
|
|
if(BTL_OPENIB_IS_RDMA_CREDITS(frag->hdr->credits)) {
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->eager_rdma_local.credits,
|
|
|
|
BTL_OPENIB_CREDITS(frag->hdr->credits));
|
|
|
|
} else {
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->rd_credits[prio], frag->hdr->credits);
|
|
|
|
}
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->sd_wqe[prio], 1);
|
|
|
|
if(do_rdma) {
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->eager_rdma_remote.tokens, 1);
|
|
|
|
} else {
|
|
|
|
if(mca_btl_openib_component.use_srq) {
|
|
|
|
OPAL_THREAD_ADD32(&openib_btl->sd_tokens[prio], 1);
|
|
|
|
} else {
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->sd_tokens[prio], 1);
|
|
|
|
}
|
|
|
|
}
|
2006-03-26 12:30:50 +04:00
|
|
|
BTL_ERROR(("error posting send request errno says %s\n",
|
|
|
|
strerror(errno)));
|
2005-07-01 01:28:35 +04:00
|
|
|
return OMPI_ERROR;
|
2005-07-12 17:38:54 +04:00
|
|
|
}
|
2005-10-02 22:58:57 +04:00
|
|
|
|
|
|
|
if(mca_btl_openib_component.use_srq) {
|
2006-09-07 17:05:41 +04:00
|
|
|
mca_btl_openib_post_srr(openib_btl, 1, BTL_OPENIB_HP_QP);
|
|
|
|
mca_btl_openib_post_srr(openib_btl, 1, BTL_OPENIB_LP_QP);
|
2005-10-02 22:58:57 +04:00
|
|
|
} else {
|
2006-09-07 17:05:41 +04:00
|
|
|
btl_openib_endpoint_post_rr(endpoint, 1, BTL_OPENIB_HP_QP);
|
|
|
|
btl_openib_endpoint_post_rr(endpoint, 1, BTL_OPENIB_LP_QP);
|
2005-10-02 22:58:57 +04:00
|
|
|
}
|
2005-07-20 19:17:18 +04:00
|
|
|
|
2006-09-05 20:00:18 +04:00
|
|
|
return OMPI_SUCCESS;
|
2005-07-01 01:28:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(mca_btl_openib_endpoint_t,
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t, mca_btl_openib_endpoint_construct,
|
2005-07-01 01:28:35 +04:00
|
|
|
mca_btl_openib_endpoint_destruct);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize state of the endpoint instance.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void mca_btl_openib_endpoint_construct(mca_btl_base_endpoint_t* endpoint)
|
|
|
|
{
|
|
|
|
endpoint->endpoint_btl = 0;
|
|
|
|
endpoint->endpoint_proc = 0;
|
|
|
|
endpoint->endpoint_tstamp = 0.0;
|
|
|
|
endpoint->endpoint_state = MCA_BTL_IB_CLOSED;
|
|
|
|
endpoint->endpoint_retries = 0;
|
2005-10-21 06:21:45 +04:00
|
|
|
OBJ_CONSTRUCT(&endpoint->endpoint_lock, opal_mutex_t);
|
2005-07-03 20:22:16 +04:00
|
|
|
OBJ_CONSTRUCT(&endpoint->pending_send_frags, opal_list_t);
|
2006-09-05 20:00:18 +04:00
|
|
|
OBJ_CONSTRUCT(&endpoint->pending_frags[BTL_OPENIB_HP_QP], opal_list_t);
|
|
|
|
OBJ_CONSTRUCT(&endpoint->pending_frags[BTL_OPENIB_LP_QP], opal_list_t);
|
2005-10-21 06:21:45 +04:00
|
|
|
|
2005-11-10 23:15:02 +03:00
|
|
|
endpoint->lcl_qp_attr_hp = (struct ibv_qp_attr *) malloc(sizeof(struct ibv_qp_attr));
|
|
|
|
endpoint->lcl_qp_attr_lp = (struct ibv_qp_attr *) malloc(sizeof(struct ibv_qp_attr));
|
|
|
|
memset(endpoint->lcl_qp_attr_hp, 0, sizeof(struct ibv_qp_attr));
|
|
|
|
memset(endpoint->lcl_qp_attr_lp, 0, sizeof(struct ibv_qp_attr));
|
|
|
|
|
2006-09-07 17:05:41 +04:00
|
|
|
endpoint->rd_posted[BTL_OPENIB_HP_QP] = 0;
|
|
|
|
endpoint->rd_posted[BTL_OPENIB_LP_QP] = 0;
|
2006-01-13 02:42:44 +03:00
|
|
|
|
|
|
|
/* number of available send wqes */
|
2006-09-05 20:00:18 +04:00
|
|
|
endpoint->sd_wqe[BTL_OPENIB_HP_QP] = mca_btl_openib_component.rd_num;
|
|
|
|
endpoint->sd_wqe[BTL_OPENIB_LP_QP] = mca_btl_openib_component.rd_num;
|
2006-01-13 02:42:44 +03:00
|
|
|
|
2005-11-10 23:15:02 +03:00
|
|
|
/* zero these out w/ initial posting, so that we start out w/
|
|
|
|
* zero credits to return to peer
|
|
|
|
*/
|
2006-09-07 17:05:41 +04:00
|
|
|
endpoint->rd_credits[BTL_OPENIB_HP_QP] = -(mca_btl_openib_component.rd_num + mca_btl_openib_component.rd_rsv);
|
|
|
|
endpoint->rd_credits[BTL_OPENIB_LP_QP] = -(mca_btl_openib_component.rd_num + mca_btl_openib_component.rd_rsv);
|
|
|
|
endpoint->sd_credits[BTL_OPENIB_HP_QP] = 0;
|
|
|
|
endpoint->sd_credits[BTL_OPENIB_LP_QP] = 0;
|
2005-11-10 23:15:02 +03:00
|
|
|
|
|
|
|
/* initialize the high and low priority tokens */
|
2006-09-05 20:00:18 +04:00
|
|
|
endpoint->sd_tokens[BTL_OPENIB_HP_QP] = mca_btl_openib_component.rd_num;
|
|
|
|
endpoint->sd_tokens[BTL_OPENIB_LP_QP] = mca_btl_openib_component.rd_num;
|
2005-11-10 23:15:02 +03:00
|
|
|
endpoint->get_tokens = mca_btl_openib_component.ib_qp_ous_rd_atom;
|
|
|
|
|
2006-03-26 12:30:50 +04:00
|
|
|
/* initialize RDMA eager related parts */
|
|
|
|
endpoint->eager_recv_count = 0;
|
|
|
|
memset(&endpoint->eager_rdma_remote, 0,
|
|
|
|
sizeof(mca_btl_openib_eager_rdma_remote_t));
|
|
|
|
memset (&endpoint->eager_rdma_local, 0,
|
|
|
|
sizeof(mca_btl_openib_eager_rdma_local_t));
|
2006-03-26 19:02:43 +04:00
|
|
|
OBJ_CONSTRUCT(&endpoint->eager_rdma_local.lock, opal_mutex_t);
|
2006-03-26 12:30:50 +04:00
|
|
|
|
2005-11-10 23:15:02 +03:00
|
|
|
endpoint->rem_info.rem_qp_num_hp = 0;
|
|
|
|
endpoint->rem_info.rem_qp_num_lp = 0;
|
2005-10-01 02:58:09 +04:00
|
|
|
endpoint->rem_info.rem_lid = 0;
|
2005-11-10 23:15:02 +03:00
|
|
|
endpoint->rem_info.rem_psn_hp = 0;
|
|
|
|
endpoint->rem_info.rem_psn_lp = 0;
|
2005-10-01 02:58:09 +04:00
|
|
|
endpoint->rem_info.rem_subnet = 0;
|
Bring over all the work from the /tmp/ib-hw-detect branch. In
addition to my design and testing, it was conceptually approved by
Gil, Gleb, Pasha, Brad, and Galen. Functionally [probably somewhat
lightly] tested by Galen. We may still have to shake out some bugs
during the next few months, but it seems to be working for all the
cases that I can throw at it.
Here's a summary of the changes from that branch:
* Move MCA parameter registration to a new file (btl_openib_mca.c):
* Properly check the retun status of registering MCA params
* Check for valid values of MCA parameters
* Make help strings better
* Otherwise, the only default value of an MCA param that was
changed was max_btls; it went from 4 to -1 (meaning: use all
available)
* Properly prototyped internal functions in _component.c
* Made a bunch of functions static that didn't need to be public
* Renamed to remove "mca_" prefix from static functions
* Call new MCA param registration function
* Call new INI file read/lookup/finalize functions
* Updated a bunch of macros to be "BTL_" instead of "ORTE_"
* Be a little more consistent with return values
* Handle -1 for the max_btls MCA param
* Fixed a free() that should have been an OBJ_RELEASE()
* Some re-indenting
* Added INI-file parsing
* New flex file: btl_openib_ini.l
* New default HCA params .ini file (probably to be expanded over
time by other HCA vendors)
* Added more show_help messages for parsing problems
* Read in INI files and cache the values for later lookup
* When component opens an HCA, lookup to see if any corresponding
values were found in the INI files (ID'ed by the HCA vendor_id
and vendor_part_id)
* Added btl_openib_verbose MCA param that shows what the INI-file
stuff does (e.g., shows which MTU your HCA ends up using)
* Added btl_openib_hca_param_files as a colon-delimited list of INI
files to check for values during startup (in order,
left-to-right, just like the MCA base directory param).
* MTU is currently the only value supported in this framework.
* It is not a fatal error if we don't find params for the HCA in
the INI file(s). Instead, just print a warning. New MCA param
btl_openib_warn_no_hca_params_found can be used to disable
printing the warning.
* Add MTU to peer negotiation when making a connection
* Exchange maximum MTU; select the lesser of the two
This commit was SVN r11182.
2006-08-14 23:30:37 +04:00
|
|
|
endpoint->rem_info.rem_mtu = 0;
|
2005-07-01 01:28:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Destroy a endpoint
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void mca_btl_openib_endpoint_destruct(mca_btl_base_endpoint_t* endpoint)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send connection information to remote endpoint using OOB
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void mca_btl_openib_endpoint_send_cb(
|
|
|
|
int status,
|
|
|
|
orte_process_name_t* endpoint,
|
|
|
|
orte_buffer_t* buffer,
|
|
|
|
orte_rml_tag_t tag,
|
|
|
|
void* cbdata)
|
|
|
|
{
|
|
|
|
OBJ_RELEASE(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-01 02:58:09 +04:00
|
|
|
static int mca_btl_openib_endpoint_send_connect_data(mca_btl_base_endpoint_t* endpoint)
|
2005-07-01 01:28:35 +04:00
|
|
|
{
|
|
|
|
orte_buffer_t* buffer = OBJ_NEW(orte_buffer_t);
|
|
|
|
int rc;
|
|
|
|
if(NULL == buffer) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pack the info in the send buffer */
|
|
|
|
|
2006-09-07 17:05:41 +04:00
|
|
|
rc = orte_dss.pack(buffer, &endpoint->lcl_qp[BTL_OPENIB_HP_QP]->qp_num, 1, ORTE_UINT32);
|
2005-07-01 01:28:35 +04:00
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-09-07 17:05:41 +04:00
|
|
|
rc = orte_dss.pack(buffer, &endpoint->lcl_qp[BTL_OPENIB_LP_QP]->qp_num, 1, ORTE_UINT32);
|
2005-07-01 01:28:35 +04:00
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-07-12 17:38:54 +04:00
|
|
|
|
2006-02-07 18:20:44 +03:00
|
|
|
rc = orte_dss.pack(buffer, &endpoint->lcl_psn_hp, 1, ORTE_UINT32);
|
2005-07-12 17:38:54 +04:00
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-02-07 18:20:44 +03:00
|
|
|
rc = orte_dss.pack(buffer, &endpoint->lcl_psn_lp, 1, ORTE_UINT32);
|
2005-07-01 01:28:35 +04:00
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-10-01 02:58:09 +04:00
|
|
|
|
2006-06-28 11:23:08 +04:00
|
|
|
rc = orte_dss.pack(buffer, &endpoint->endpoint_btl->lid, 1, ORTE_UINT16);
|
2005-07-12 17:38:54 +04:00
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-10-01 02:58:09 +04:00
|
|
|
|
|
|
|
|
Bring over all the work from the /tmp/ib-hw-detect branch. In
addition to my design and testing, it was conceptually approved by
Gil, Gleb, Pasha, Brad, and Galen. Functionally [probably somewhat
lightly] tested by Galen. We may still have to shake out some bugs
during the next few months, but it seems to be working for all the
cases that I can throw at it.
Here's a summary of the changes from that branch:
* Move MCA parameter registration to a new file (btl_openib_mca.c):
* Properly check the retun status of registering MCA params
* Check for valid values of MCA parameters
* Make help strings better
* Otherwise, the only default value of an MCA param that was
changed was max_btls; it went from 4 to -1 (meaning: use all
available)
* Properly prototyped internal functions in _component.c
* Made a bunch of functions static that didn't need to be public
* Renamed to remove "mca_" prefix from static functions
* Call new MCA param registration function
* Call new INI file read/lookup/finalize functions
* Updated a bunch of macros to be "BTL_" instead of "ORTE_"
* Be a little more consistent with return values
* Handle -1 for the max_btls MCA param
* Fixed a free() that should have been an OBJ_RELEASE()
* Some re-indenting
* Added INI-file parsing
* New flex file: btl_openib_ini.l
* New default HCA params .ini file (probably to be expanded over
time by other HCA vendors)
* Added more show_help messages for parsing problems
* Read in INI files and cache the values for later lookup
* When component opens an HCA, lookup to see if any corresponding
values were found in the INI files (ID'ed by the HCA vendor_id
and vendor_part_id)
* Added btl_openib_verbose MCA param that shows what the INI-file
stuff does (e.g., shows which MTU your HCA ends up using)
* Added btl_openib_hca_param_files as a colon-delimited list of INI
files to check for values during startup (in order,
left-to-right, just like the MCA base directory param).
* MTU is currently the only value supported in this framework.
* It is not a fatal error if we don't find params for the HCA in
the INI file(s). Instead, just print a warning. New MCA param
btl_openib_warn_no_hca_params_found can be used to disable
printing the warning.
* Add MTU to peer negotiation when making a connection
* Exchange maximum MTU; select the lesser of the two
This commit was SVN r11182.
2006-08-14 23:30:37 +04:00
|
|
|
rc = orte_dss.pack(buffer, &endpoint->subnet, 1, ORTE_UINT16);
|
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = orte_dss.pack(buffer, &endpoint->endpoint_btl->hca->mtu, 1, ORTE_UINT32);
|
2005-10-01 02:58:09 +04:00
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2006-01-13 02:42:44 +03:00
|
|
|
|
2006-09-05 20:04:04 +04:00
|
|
|
rc = orte_dss.pack(buffer, &endpoint->index, 1, ORTE_UINT32);
|
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-07-01 01:28:35 +04:00
|
|
|
/* send to endpoint */
|
|
|
|
rc = orte_rml.send_buffer_nb(&endpoint->endpoint_proc->proc_guid, buffer, ORTE_RML_TAG_DYNAMIC-1, 0,
|
|
|
|
mca_btl_openib_endpoint_send_cb, NULL);
|
|
|
|
|
|
|
|
|
2005-08-09 21:49:39 +04:00
|
|
|
BTL_VERBOSE(("Sending High Priority QP num = %d, Low Priority QP num = %d, LID = %d",
|
2006-09-07 17:05:41 +04:00
|
|
|
endpoint->lcl_qp[BTL_OPENIB_HP_QP]->qp_num,
|
|
|
|
endpoint->lcl_qp[BTL_OPENIB_LP_QP]->qp_num,
|
2006-06-28 11:23:08 +04:00
|
|
|
endpoint->endpoint_btl->lid));
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
if(rc < 0) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set remote connection info
|
2005-07-20 19:17:18 +04:00
|
|
|
* (from OOB connection)
|
2005-07-01 01:28:35 +04:00
|
|
|
*
|
|
|
|
*/
|
2005-10-01 02:58:09 +04:00
|
|
|
static int mca_btl_openib_endpoint_set_remote_info(mca_btl_base_endpoint_t* endpoint, mca_btl_openib_rem_info_t* rem_info)
|
2005-07-01 01:28:35 +04:00
|
|
|
{
|
2005-10-01 02:58:09 +04:00
|
|
|
|
|
|
|
memcpy(&((mca_btl_openib_endpoint_t*) endpoint)->rem_info, rem_info, sizeof(mca_btl_openib_rem_info_t));
|
|
|
|
|
|
|
|
BTL_VERBOSE(("Setting High Priority QP num = %d, Low Priority QP num %d, LID = %d",
|
2005-11-10 23:15:02 +03:00
|
|
|
endpoint->rem_info.rem_qp_num_hp,
|
|
|
|
endpoint->rem_info.rem_qp_num_lp,
|
2005-10-01 02:58:09 +04:00
|
|
|
endpoint->rem_info.rem_lid));
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
2005-10-01 02:58:09 +04:00
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start to connect to the endpoint. We send our Queue Pair
|
|
|
|
* information over the TCP OOB communication mechanism.
|
|
|
|
|
|
|
|
* On completion of our send, a send completion handler
|
|
|
|
* is called.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int mca_btl_openib_endpoint_start_connect(mca_btl_base_endpoint_t* endpoint)
|
|
|
|
{
|
|
|
|
int rc;
|
2005-07-12 17:38:54 +04:00
|
|
|
mca_btl_openib_module_t* openib_btl = (mca_btl_openib_module_t*) endpoint->endpoint_btl;
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* Create the High Priority Queue Pair */
|
2006-09-12 13:17:59 +04:00
|
|
|
if(OMPI_SUCCESS != (rc = mca_btl_openib_endpoint_create_qp(openib_btl,
|
|
|
|
openib_btl->hca->ib_pd,
|
|
|
|
openib_btl->ib_cq[BTL_OPENIB_HP_QP],
|
|
|
|
openib_btl->srq[BTL_OPENIB_HP_QP],
|
|
|
|
endpoint->lcl_qp_attr_hp,
|
|
|
|
&endpoint->lcl_qp[BTL_OPENIB_HP_QP]))) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error creating queue pair, error code %d", rc));
|
2005-07-01 01:28:35 +04:00
|
|
|
return rc;
|
|
|
|
}
|
2005-07-20 01:04:22 +04:00
|
|
|
srand48(getpid() * time(NULL));
|
2005-11-10 23:15:02 +03:00
|
|
|
endpoint->lcl_psn_hp = lrand48() & 0xffffff;
|
2005-07-12 17:38:54 +04:00
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
/* Create the Low Priority Queue Pair */
|
2006-09-12 13:17:59 +04:00
|
|
|
if(OMPI_SUCCESS != (rc = mca_btl_openib_endpoint_create_qp(openib_btl,
|
|
|
|
openib_btl->hca->ib_pd,
|
|
|
|
openib_btl->ib_cq[BTL_OPENIB_LP_QP],
|
|
|
|
openib_btl->srq[BTL_OPENIB_LP_QP],
|
|
|
|
endpoint->lcl_qp_attr_lp,
|
|
|
|
&endpoint->lcl_qp[BTL_OPENIB_LP_QP]))) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error creating queue pair, error code %d", rc));
|
2005-07-01 01:28:35 +04:00
|
|
|
return rc;
|
|
|
|
}
|
2005-11-10 23:15:02 +03:00
|
|
|
endpoint->lcl_psn_lp = lrand48() & 0xffffff;
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-08-09 21:49:39 +04:00
|
|
|
BTL_VERBOSE(("Initialized High Priority QP num = %d, Low Priority QP num = %d, LID = %d",
|
2006-09-07 17:05:41 +04:00
|
|
|
endpoint->lcl_qp[BTL_OPENIB_HP_QP]->qp_num,
|
|
|
|
endpoint->lcl_qp[BTL_OPENIB_LP_QP]->qp_num,
|
2006-06-28 11:23:08 +04:00
|
|
|
openib_btl->lid));
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
/* Send connection info over to remote endpoint */
|
|
|
|
endpoint->endpoint_state = MCA_BTL_IB_CONNECTING;
|
2005-10-01 02:58:09 +04:00
|
|
|
if(OMPI_SUCCESS != (rc = mca_btl_openib_endpoint_send_connect_data(endpoint))) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error sending connect request, error code %d", rc));
|
2005-07-01 01:28:35 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reply to a `start - connect' message
|
|
|
|
*
|
|
|
|
*/
|
2005-10-01 02:58:09 +04:00
|
|
|
static int mca_btl_openib_endpoint_reply_start_connect(mca_btl_openib_endpoint_t *endpoint,
|
|
|
|
mca_btl_openib_rem_info_t *rem_info)
|
2005-07-01 01:28:35 +04:00
|
|
|
{
|
|
|
|
int rc;
|
2005-07-12 17:38:54 +04:00
|
|
|
mca_btl_openib_module_t* openib_btl = (mca_btl_openib_module_t*) endpoint->endpoint_btl;
|
|
|
|
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
/* Create the High Priority Queue Pair */
|
2006-09-12 13:17:59 +04:00
|
|
|
if(OMPI_SUCCESS != (rc = mca_btl_openib_endpoint_create_qp(openib_btl,
|
|
|
|
openib_btl->hca->ib_pd,
|
|
|
|
openib_btl->ib_cq[BTL_OPENIB_HP_QP],
|
|
|
|
openib_btl->srq[BTL_OPENIB_HP_QP],
|
|
|
|
endpoint->lcl_qp_attr_hp,
|
|
|
|
&endpoint->lcl_qp[BTL_OPENIB_HP_QP]))) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error creating queue pair, error code %d", rc));
|
2005-07-01 01:28:35 +04:00
|
|
|
return rc;
|
|
|
|
}
|
2005-07-20 01:04:22 +04:00
|
|
|
srand48(getpid() * time(NULL));
|
2005-11-10 23:15:02 +03:00
|
|
|
endpoint->lcl_psn_hp = lrand48() & 0xffffff;
|
2005-07-12 17:38:54 +04:00
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
/* Create the Low Priority Queue Pair */
|
2006-09-12 13:17:59 +04:00
|
|
|
if(OMPI_SUCCESS != (rc = mca_btl_openib_endpoint_create_qp(openib_btl,
|
|
|
|
openib_btl->hca->ib_pd,
|
|
|
|
openib_btl->ib_cq[BTL_OPENIB_LP_QP],
|
|
|
|
openib_btl->srq[BTL_OPENIB_LP_QP],
|
|
|
|
endpoint->lcl_qp_attr_lp,
|
|
|
|
&endpoint->lcl_qp[BTL_OPENIB_LP_QP]))) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error creating queue pair, error code %d", rc));
|
2005-07-01 01:28:35 +04:00
|
|
|
return rc;
|
|
|
|
}
|
2005-11-10 23:15:02 +03:00
|
|
|
endpoint->lcl_psn_lp = lrand48() & 0xffffff;
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-08-09 21:49:39 +04:00
|
|
|
BTL_VERBOSE(("Initialized High Priority QP num = %d, Low Priority QP num = %d, LID = %d",
|
2006-09-07 17:05:41 +04:00
|
|
|
endpoint->lcl_qp[BTL_OPENIB_HP_QP]->qp_num,
|
|
|
|
endpoint->lcl_qp[BTL_OPENIB_LP_QP]->qp_num,
|
2006-06-28 11:23:08 +04:00
|
|
|
openib_btl->lid));
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* Set the remote side info */
|
2005-10-01 02:58:09 +04:00
|
|
|
mca_btl_openib_endpoint_set_remote_info(endpoint, rem_info);
|
2005-07-12 17:38:54 +04:00
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
/* Connect to endpoint */
|
|
|
|
|
|
|
|
rc = mca_btl_openib_endpoint_connect(endpoint);
|
|
|
|
if(rc != OMPI_SUCCESS) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error in endpoint connect error code is %d", rc));
|
2005-07-01 01:28:35 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send connection info over to remote endpoint */
|
2005-10-01 02:58:09 +04:00
|
|
|
endpoint->endpoint_state = MCA_BTL_IB_CONNECT_ACK;
|
|
|
|
if(OMPI_SUCCESS != (rc = mca_btl_openib_endpoint_send_connect_data(endpoint))) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error in endpoint send connect request error code is %d", rc));
|
2005-07-01 01:28:35 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-10-01 02:58:09 +04:00
|
|
|
/*
|
|
|
|
* endpoint is waiting ack to final connection establishment..
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void mca_btl_openib_endpoint_waiting_ack(mca_btl_openib_endpoint_t *endpoint) {
|
|
|
|
endpoint->endpoint_state = MCA_BTL_IB_WAITING_ACK;
|
|
|
|
}
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
/*
|
2005-07-20 21:43:31 +04:00
|
|
|
* called when the openib has completed setup via the
|
|
|
|
* OOB channel
|
2005-07-01 01:28:35 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void mca_btl_openib_endpoint_connected(mca_btl_openib_endpoint_t *endpoint)
|
|
|
|
{
|
2005-10-01 02:58:09 +04:00
|
|
|
opal_list_item_t *frag_item;
|
|
|
|
mca_btl_openib_frag_t *frag;
|
|
|
|
mca_btl_openib_module_t* openib_btl;
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
endpoint->endpoint_state = MCA_BTL_IB_CONNECTED;
|
2005-07-20 01:04:22 +04:00
|
|
|
endpoint->endpoint_btl->poll_cq = true;
|
2005-10-01 02:58:09 +04:00
|
|
|
|
2006-04-15 02:28:05 +04:00
|
|
|
/**
|
|
|
|
* The connection is correctly setup. Now we can decrease the event trigger.
|
|
|
|
*/
|
|
|
|
opal_progress_event_decrement();
|
|
|
|
|
2005-10-01 02:58:09 +04:00
|
|
|
/* While there are frags in the list,
|
|
|
|
* process them */
|
|
|
|
|
|
|
|
while(!opal_list_is_empty(&(endpoint->pending_send_frags))) {
|
|
|
|
frag_item = opal_list_remove_first(&(endpoint->pending_send_frags));
|
|
|
|
frag = (mca_btl_openib_frag_t *) frag_item;
|
|
|
|
openib_btl = endpoint->endpoint_btl;
|
|
|
|
/* We need to post this one */
|
|
|
|
|
2006-09-05 20:00:18 +04:00
|
|
|
if(OMPI_SUCCESS != mca_btl_openib_endpoint_post_send(openib_btl, endpoint, frag))
|
2005-10-01 02:58:09 +04:00
|
|
|
BTL_ERROR(("Error posting send"));
|
|
|
|
}
|
2005-07-01 01:28:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Non blocking OOB recv callback.
|
|
|
|
* Read incoming QP and other info, and if this endpoint
|
|
|
|
* is trying to connect, reply with our QP info,
|
|
|
|
* otherwise try to modify QP's and establish
|
|
|
|
* reliable connection
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void mca_btl_openib_endpoint_recv(
|
|
|
|
int status,
|
|
|
|
orte_process_name_t* endpoint,
|
|
|
|
orte_buffer_t* buffer,
|
|
|
|
orte_rml_tag_t tag,
|
|
|
|
void* cbdata)
|
|
|
|
{
|
|
|
|
mca_btl_openib_proc_t *ib_proc;
|
2006-09-05 13:16:22 +04:00
|
|
|
mca_btl_openib_endpoint_t *ib_endpoint = NULL;
|
2005-07-01 01:28:35 +04:00
|
|
|
int endpoint_state;
|
|
|
|
int rc;
|
2005-10-01 02:58:09 +04:00
|
|
|
uint32_t i;
|
2006-08-22 20:26:36 +04:00
|
|
|
int32_t cnt = 1;
|
2005-10-01 02:58:09 +04:00
|
|
|
mca_btl_openib_rem_info_t rem_info;
|
|
|
|
|
|
|
|
/* start by unpacking data first so we know who is knocking at
|
|
|
|
our door */
|
|
|
|
|
2006-02-07 18:20:44 +03:00
|
|
|
rc = orte_dss.unpack(buffer, &rem_info.rem_qp_num_hp, &cnt, ORTE_UINT32);
|
2005-10-01 02:58:09 +04:00
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
2006-02-07 18:20:44 +03:00
|
|
|
rc = orte_dss.unpack(buffer, &rem_info.rem_qp_num_lp, &cnt, ORTE_UINT32);
|
2005-10-01 02:58:09 +04:00
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
2006-02-07 18:20:44 +03:00
|
|
|
rc = orte_dss.unpack(buffer, &rem_info.rem_psn_hp, &cnt, ORTE_UINT32);
|
2005-10-01 02:58:09 +04:00
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
2006-02-07 18:20:44 +03:00
|
|
|
}rc = orte_dss.unpack(buffer, &rem_info.rem_psn_lp, &cnt, ORTE_UINT32);
|
2005-10-01 02:58:09 +04:00
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
2006-02-07 18:20:44 +03:00
|
|
|
rc = orte_dss.unpack(buffer, &rem_info.rem_lid, &cnt, ORTE_UINT16);
|
2005-10-01 02:58:09 +04:00
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
2006-02-07 18:20:44 +03:00
|
|
|
rc = orte_dss.unpack(buffer, &rem_info.rem_subnet, &cnt, ORTE_UINT16);
|
2005-10-01 02:58:09 +04:00
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
Bring over all the work from the /tmp/ib-hw-detect branch. In
addition to my design and testing, it was conceptually approved by
Gil, Gleb, Pasha, Brad, and Galen. Functionally [probably somewhat
lightly] tested by Galen. We may still have to shake out some bugs
during the next few months, but it seems to be working for all the
cases that I can throw at it.
Here's a summary of the changes from that branch:
* Move MCA parameter registration to a new file (btl_openib_mca.c):
* Properly check the retun status of registering MCA params
* Check for valid values of MCA parameters
* Make help strings better
* Otherwise, the only default value of an MCA param that was
changed was max_btls; it went from 4 to -1 (meaning: use all
available)
* Properly prototyped internal functions in _component.c
* Made a bunch of functions static that didn't need to be public
* Renamed to remove "mca_" prefix from static functions
* Call new MCA param registration function
* Call new INI file read/lookup/finalize functions
* Updated a bunch of macros to be "BTL_" instead of "ORTE_"
* Be a little more consistent with return values
* Handle -1 for the max_btls MCA param
* Fixed a free() that should have been an OBJ_RELEASE()
* Some re-indenting
* Added INI-file parsing
* New flex file: btl_openib_ini.l
* New default HCA params .ini file (probably to be expanded over
time by other HCA vendors)
* Added more show_help messages for parsing problems
* Read in INI files and cache the values for later lookup
* When component opens an HCA, lookup to see if any corresponding
values were found in the INI files (ID'ed by the HCA vendor_id
and vendor_part_id)
* Added btl_openib_verbose MCA param that shows what the INI-file
stuff does (e.g., shows which MTU your HCA ends up using)
* Added btl_openib_hca_param_files as a colon-delimited list of INI
files to check for values during startup (in order,
left-to-right, just like the MCA base directory param).
* MTU is currently the only value supported in this framework.
* It is not a fatal error if we don't find params for the HCA in
the INI file(s). Instead, just print a warning. New MCA param
btl_openib_warn_no_hca_params_found can be used to disable
printing the warning.
* Add MTU to peer negotiation when making a connection
* Exchange maximum MTU; select the lesser of the two
This commit was SVN r11182.
2006-08-14 23:30:37 +04:00
|
|
|
rc = orte_dss.unpack(buffer, &rem_info.rem_mtu, &cnt, ORTE_UINT32);
|
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
2006-09-05 20:04:04 +04:00
|
|
|
rc = orte_dss.unpack(buffer, &rem_info.rem_index, &cnt, ORTE_UINT32);
|
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
2005-10-01 02:58:09 +04:00
|
|
|
#if 0
|
2006-02-07 18:20:44 +03:00
|
|
|
rc = orte_dss.unpack(buffer, &ib_endpoint->rdma_buf->r_key, &cnt, ORTE_UINT32);
|
2005-10-01 02:58:09 +04:00
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-02-07 18:20:44 +03:00
|
|
|
rc = orte_dss.unpack(buffer, &ib_endpoint->rdma_buf->rem_base, &cnt, ORTE_UINT32);
|
2005-10-01 02:58:09 +04:00
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-02-07 18:20:44 +03:00
|
|
|
rc = orte_dss.unpack(buffer, &ib_endpoint->rdma_buf->rem_size, &cnt, ORTE_UINT32);
|
2005-10-01 02:58:09 +04:00
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-02-07 18:20:44 +03:00
|
|
|
rc = orte_dss.unpack(buffer, &ib_endpoint->rdma_buf->rem_cnt, &cnt, ORTE_UINT32);
|
2005-10-01 02:58:09 +04:00
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BTL_VERBOSE(("Received High Priority QP num = %d, Low Priority QP num %d, LID = %d",
|
2005-11-10 23:15:02 +03:00
|
|
|
rem_info.rem_qp_num_hp,
|
|
|
|
rem_info.rem_qp_num_lp,
|
2005-10-01 02:58:09 +04:00
|
|
|
rem_info.rem_lid));
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
for(ib_proc = (mca_btl_openib_proc_t*)
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_get_first(&mca_btl_openib_component.ib_procs);
|
2005-07-01 01:28:35 +04:00
|
|
|
ib_proc != (mca_btl_openib_proc_t*)
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_get_end(&mca_btl_openib_component.ib_procs);
|
|
|
|
ib_proc = (mca_btl_openib_proc_t*)opal_list_get_next(ib_proc)) {
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-11-17 08:32:30 +03:00
|
|
|
if(orte_ns.compare(ORTE_NS_CMP_ALL, &ib_proc->proc_guid, endpoint) == 0) {
|
2005-10-01 02:58:09 +04:00
|
|
|
bool found = false;
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
/* Try to get the endpoint instance of this proc */
|
|
|
|
|
2005-10-01 02:58:09 +04:00
|
|
|
for(i = 0; i < ib_proc->proc_endpoint_count; i++) {
|
|
|
|
mca_btl_openib_port_info_t port_info;
|
|
|
|
port_info = ib_proc->proc_ports[i];
|
|
|
|
ib_endpoint = ib_proc->proc_endpoints[i];
|
|
|
|
if(ib_endpoint->rem_info.rem_lid &&
|
2006-06-28 11:23:08 +04:00
|
|
|
(ib_endpoint->rem_info.rem_lid == rem_info.rem_lid &&
|
|
|
|
ib_endpoint->rem_info.rem_qp_num_hp == rem_info.rem_qp_num_hp)) {
|
2005-10-01 02:58:09 +04:00
|
|
|
/* we've seen them before! */
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* If we haven't seen this remote lid before then try to match on
|
|
|
|
endpoint */
|
|
|
|
for(i = 0; !found && i < ib_proc->proc_endpoint_count; i++) {
|
|
|
|
mca_btl_openib_port_info_t port_info;
|
|
|
|
port_info = ib_proc->proc_ports[i];
|
|
|
|
ib_endpoint = ib_proc->proc_endpoints[i];
|
|
|
|
if(!ib_endpoint->rem_info.rem_lid &&
|
|
|
|
ib_endpoint->subnet == rem_info.rem_subnet) {
|
|
|
|
/* found a match based on subnet! */
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* try finding an open port, even if subnets
|
|
|
|
don't match
|
|
|
|
*/
|
|
|
|
for(i = 0; !found && i < ib_proc->proc_endpoint_count; i++) {
|
|
|
|
mca_btl_openib_port_info_t port_info;
|
|
|
|
port_info = ib_proc->proc_ports[i];
|
|
|
|
ib_endpoint = ib_proc->proc_endpoints[i];
|
|
|
|
if(!ib_endpoint->rem_info.rem_lid) {
|
|
|
|
/* found an unused end-point */
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!found) {
|
|
|
|
BTL_ERROR(("can't find suitable endpoint for this peer\n"));
|
|
|
|
return;
|
|
|
|
}
|
2006-05-09 16:12:52 +04:00
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&ib_endpoint->endpoint_lock);
|
2005-07-01 01:28:35 +04:00
|
|
|
endpoint_state = ib_endpoint->endpoint_state;
|
|
|
|
|
|
|
|
/* Update status */
|
|
|
|
switch(endpoint_state) {
|
2005-07-12 17:38:54 +04:00
|
|
|
case MCA_BTL_IB_CLOSED :
|
|
|
|
/* We had this connection closed before.
|
|
|
|
* The endpoint is trying to connect. Move the
|
|
|
|
* status of this connection to CONNECTING,
|
|
|
|
* and then reply with our QP information */
|
|
|
|
|
2005-10-01 02:58:09 +04:00
|
|
|
if(OMPI_SUCCESS != (rc = mca_btl_openib_endpoint_reply_start_connect(ib_endpoint, &rem_info))) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error in endpoint reply start connect"));
|
2005-07-01 01:28:35 +04:00
|
|
|
break;
|
2005-07-12 17:38:54 +04:00
|
|
|
}
|
2006-04-15 02:28:05 +04:00
|
|
|
|
|
|
|
/** As long as we expect a message from the peer (in order to setup the connection)
|
|
|
|
* let the event engine pool the OOB events. Note: we increment it once peer active
|
|
|
|
* connection.
|
|
|
|
*/
|
|
|
|
opal_progress_event_increment();
|
2005-07-12 17:38:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_BTL_IB_CONNECTING :
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-10-01 02:58:09 +04:00
|
|
|
mca_btl_openib_endpoint_set_remote_info(ib_endpoint, &rem_info);
|
2005-07-12 17:38:54 +04:00
|
|
|
if(OMPI_SUCCESS != (rc = mca_btl_openib_endpoint_connect(ib_endpoint))) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("endpoint connect error: %d", rc));
|
2005-07-01 01:28:35 +04:00
|
|
|
break;
|
2005-07-12 17:38:54 +04:00
|
|
|
}
|
|
|
|
|
2005-10-01 02:58:09 +04:00
|
|
|
/* Setup state as awaiting ack from peer */
|
|
|
|
mca_btl_openib_endpoint_waiting_ack(ib_endpoint);
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-07-12 17:38:54 +04:00
|
|
|
/* Send him an ack */
|
2005-10-01 02:58:09 +04:00
|
|
|
mca_btl_openib_endpoint_send_connect_data(ib_endpoint);
|
2005-07-12 17:38:54 +04:00
|
|
|
break;
|
2005-10-01 02:58:09 +04:00
|
|
|
|
|
|
|
case MCA_BTL_IB_WAITING_ACK:
|
|
|
|
mca_btl_openib_endpoint_connected(ib_endpoint);
|
|
|
|
break;
|
|
|
|
|
2005-07-12 17:38:54 +04:00
|
|
|
case MCA_BTL_IB_CONNECT_ACK:
|
2005-10-01 02:58:09 +04:00
|
|
|
mca_btl_openib_endpoint_send_connect_data(ib_endpoint);
|
2005-07-12 17:38:54 +04:00
|
|
|
mca_btl_openib_endpoint_connected(ib_endpoint);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_BTL_IB_CONNECTED :
|
|
|
|
break;
|
|
|
|
default :
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("Invalid endpoint state %d", endpoint_state));
|
2005-07-01 01:28:35 +04:00
|
|
|
}
|
2006-05-09 16:12:52 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&ib_endpoint->endpoint_lock);
|
2005-07-01 01:28:35 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-20 19:17:18 +04:00
|
|
|
/*
|
|
|
|
* Post the OOB recv (for receiving the peers information)
|
|
|
|
*/
|
2005-07-01 01:28:35 +04:00
|
|
|
void mca_btl_openib_post_recv()
|
|
|
|
{
|
2005-07-13 04:17:08 +04:00
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
orte_rml.recv_buffer_nb(
|
|
|
|
ORTE_RML_NAME_ANY,
|
|
|
|
ORTE_RML_TAG_DYNAMIC-1,
|
2005-11-17 08:32:30 +03:00
|
|
|
ORTE_RML_PERSISTENT,
|
2005-07-01 01:28:35 +04:00
|
|
|
mca_btl_openib_endpoint_recv,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attempt to send a fragment using a given endpoint. If the endpoint is not
|
|
|
|
* connected, queue the fragment and start the connection as required.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int mca_btl_openib_endpoint_send(
|
|
|
|
mca_btl_base_endpoint_t* endpoint,
|
|
|
|
mca_btl_openib_frag_t* frag
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int rc;
|
2006-04-15 02:28:05 +04:00
|
|
|
bool call_progress = false;
|
2005-07-12 17:38:54 +04:00
|
|
|
mca_btl_openib_module_t *openib_btl;
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-10-21 06:21:45 +04:00
|
|
|
OPAL_THREAD_LOCK(&endpoint->endpoint_lock);
|
2005-07-01 01:28:35 +04:00
|
|
|
switch(endpoint->endpoint_state) {
|
|
|
|
case MCA_BTL_IB_CONNECTING:
|
|
|
|
|
2005-08-09 21:49:39 +04:00
|
|
|
BTL_VERBOSE(("Queing because state is connecting"));
|
2005-07-13 04:17:08 +04:00
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&endpoint->pending_send_frags,
|
|
|
|
(opal_list_item_t *)frag);
|
2006-04-15 02:28:05 +04:00
|
|
|
call_progress = true;
|
2005-07-01 01:28:35 +04:00
|
|
|
rc = OMPI_SUCCESS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_BTL_IB_CONNECT_ACK:
|
2005-10-01 02:58:09 +04:00
|
|
|
case MCA_BTL_IB_WAITING_ACK:
|
2005-08-09 21:49:39 +04:00
|
|
|
BTL_VERBOSE(("Queuing because waiting for ack"));
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&endpoint->pending_send_frags,
|
|
|
|
(opal_list_item_t *)frag);
|
2006-04-15 02:28:05 +04:00
|
|
|
call_progress = true;
|
2005-07-01 01:28:35 +04:00
|
|
|
rc = OMPI_SUCCESS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_BTL_IB_CLOSED:
|
|
|
|
|
2005-08-09 21:49:39 +04:00
|
|
|
BTL_VERBOSE(("Connection to endpoint closed ... connecting ..."));
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&endpoint->pending_send_frags,
|
|
|
|
(opal_list_item_t *)frag);
|
2005-07-01 01:28:35 +04:00
|
|
|
rc = mca_btl_openib_endpoint_start_connect(endpoint);
|
2006-04-15 02:28:05 +04:00
|
|
|
/**
|
|
|
|
* As long as we expect a message from the peer (in order to setup the connection)
|
|
|
|
* let the event engine pool the OOB events. Note: we increment it once peer active
|
|
|
|
* connection.
|
|
|
|
*/
|
|
|
|
opal_progress_event_increment();
|
|
|
|
call_progress = true;
|
2005-07-01 01:28:35 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_BTL_IB_FAILED:
|
|
|
|
|
|
|
|
rc = OMPI_ERR_UNREACH;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_BTL_IB_CONNECTED:
|
|
|
|
{
|
2005-07-12 17:38:54 +04:00
|
|
|
openib_btl = endpoint->endpoint_btl;
|
2005-10-01 02:58:09 +04:00
|
|
|
BTL_VERBOSE(("Send to : %d, len : %lu, frag : %p",
|
2005-07-20 19:17:18 +04:00
|
|
|
endpoint->endpoint_proc->proc_guid.vpid,
|
|
|
|
frag->sg_entry.length,
|
2005-10-01 02:58:09 +04:00
|
|
|
frag));
|
2005-07-12 17:38:54 +04:00
|
|
|
rc = mca_btl_openib_endpoint_post_send(openib_btl, endpoint, frag);
|
2005-07-01 01:28:35 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
rc = OMPI_ERR_UNREACH;
|
|
|
|
}
|
2005-10-21 06:21:45 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&endpoint->endpoint_lock);
|
2006-04-15 02:28:05 +04:00
|
|
|
if(call_progress) opal_progress();
|
2005-07-01 01:28:35 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Complete connection to endpoint.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int mca_btl_openib_endpoint_connect(
|
|
|
|
mca_btl_openib_endpoint_t *endpoint)
|
|
|
|
{
|
|
|
|
int rc;
|
2005-07-12 17:38:54 +04:00
|
|
|
mca_btl_openib_module_t* openib_btl = (mca_btl_openib_module_t*) endpoint->endpoint_btl;
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
/* Connection establishment RC */
|
2006-09-12 13:17:59 +04:00
|
|
|
rc = mca_btl_openib_endpoint_qp_init_query(openib_btl,
|
|
|
|
endpoint->lcl_qp[BTL_OPENIB_HP_QP],
|
|
|
|
endpoint->lcl_qp_attr_hp,
|
|
|
|
endpoint->lcl_psn_hp,
|
|
|
|
endpoint->rem_info.rem_qp_num_hp,
|
|
|
|
endpoint->rem_info.rem_psn_hp,
|
|
|
|
endpoint->rem_info.rem_lid,
|
|
|
|
endpoint->rem_info.rem_mtu,
|
|
|
|
openib_btl->port_num);
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(rc != OMPI_SUCCESS) {
|
|
|
|
return rc;
|
|
|
|
}
|
2006-09-12 13:17:59 +04:00
|
|
|
rc = mca_btl_openib_endpoint_qp_init_query(openib_btl,
|
|
|
|
endpoint->lcl_qp[BTL_OPENIB_LP_QP],
|
|
|
|
endpoint->lcl_qp_attr_lp,
|
|
|
|
endpoint->lcl_psn_lp,
|
|
|
|
endpoint->rem_info.rem_qp_num_lp,
|
|
|
|
endpoint->rem_info.rem_psn_lp,
|
|
|
|
endpoint->rem_info.rem_lid,
|
|
|
|
endpoint->rem_info.rem_mtu,
|
|
|
|
openib_btl->port_num);
|
2005-07-12 17:38:54 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(rc != OMPI_SUCCESS) {
|
|
|
|
return rc;
|
|
|
|
}
|
2005-10-02 22:58:57 +04:00
|
|
|
|
2006-09-12 13:17:59 +04:00
|
|
|
MCA_BTL_IB_FRAG_ALLOC_CREDIT_WAIT(openib_btl,
|
|
|
|
endpoint->credit_frag[BTL_OPENIB_HP_QP], rc);
|
|
|
|
MCA_BTL_IB_FRAG_ALLOC_CREDIT_WAIT(openib_btl,
|
|
|
|
endpoint->credit_frag[BTL_OPENIB_LP_QP], rc);
|
2006-07-20 18:44:35 +04:00
|
|
|
|
2005-10-02 22:58:57 +04:00
|
|
|
if(mca_btl_openib_component.use_srq) {
|
2006-09-07 17:05:41 +04:00
|
|
|
mca_btl_openib_post_srr(openib_btl, 1, BTL_OPENIB_HP_QP);
|
|
|
|
mca_btl_openib_post_srr(openib_btl, 1, BTL_OPENIB_LP_QP);
|
2005-10-02 22:58:57 +04:00
|
|
|
} else {
|
2006-09-07 17:05:41 +04:00
|
|
|
btl_openib_endpoint_post_rr(endpoint, 1, BTL_OPENIB_HP_QP);
|
|
|
|
btl_openib_endpoint_post_rr(endpoint, 1, BTL_OPENIB_LP_QP);
|
2005-10-02 22:58:57 +04:00
|
|
|
}
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-07-20 19:17:18 +04:00
|
|
|
/*
|
|
|
|
* Create the queue pair note that this is just the initial
|
|
|
|
* queue pair creation and we need to get the remote queue pair
|
|
|
|
* info from the peer before the qp is usable,
|
|
|
|
*/
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
int mca_btl_openib_endpoint_create_qp(
|
2005-07-12 17:38:54 +04:00
|
|
|
mca_btl_openib_module_t* openib_btl,
|
|
|
|
struct ibv_pd* pd,
|
|
|
|
struct ibv_cq* cq,
|
2005-10-02 22:58:57 +04:00
|
|
|
struct ibv_srq* srq,
|
2005-07-12 17:38:54 +04:00
|
|
|
struct ibv_qp_attr* qp_attr,
|
|
|
|
struct ibv_qp** qp
|
|
|
|
)
|
2005-07-01 01:28:35 +04:00
|
|
|
{
|
2005-07-12 17:38:54 +04:00
|
|
|
{
|
2005-07-20 01:04:22 +04:00
|
|
|
struct ibv_qp* my_qp;
|
2005-07-13 04:17:08 +04:00
|
|
|
struct ibv_qp_init_attr qp_init_attr;
|
2005-07-20 01:04:22 +04:00
|
|
|
|
|
|
|
memset(&qp_init_attr, 0, sizeof(struct ibv_qp_init_attr));
|
|
|
|
|
2005-07-13 04:17:08 +04:00
|
|
|
qp_init_attr.send_cq = cq;
|
|
|
|
qp_init_attr.recv_cq = cq;
|
2006-01-13 02:42:44 +03:00
|
|
|
qp_init_attr.cap.max_send_wr = mca_btl_openib_component.rd_num + 1;
|
|
|
|
qp_init_attr.cap.max_recv_wr = mca_btl_openib_component.rd_num + mca_btl_openib_component.rd_rsv;
|
2005-11-10 23:15:02 +03:00
|
|
|
qp_init_attr.cap.max_send_sge = mca_btl_openib_component.ib_sg_list_size;
|
2005-07-15 19:13:19 +04:00
|
|
|
qp_init_attr.cap.max_recv_sge = mca_btl_openib_component.ib_sg_list_size;
|
2005-07-13 04:17:08 +04:00
|
|
|
qp_init_attr.qp_type = IBV_QPT_RC;
|
2005-10-02 22:58:57 +04:00
|
|
|
if(mca_btl_openib_component.use_srq) {
|
|
|
|
qp_init_attr.srq = srq;
|
|
|
|
}
|
2005-07-20 01:04:22 +04:00
|
|
|
my_qp = ibv_create_qp(pd, &qp_init_attr);
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-07-20 01:04:22 +04:00
|
|
|
if(NULL == my_qp) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error creating qp errno says %s", strerror(errno)));
|
2005-07-12 17:38:54 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2005-07-20 01:04:22 +04:00
|
|
|
(*qp) = my_qp;
|
2006-08-08 21:24:12 +04:00
|
|
|
openib_btl->ib_inline_max = qp_init_attr.cap.max_inline_data;
|
2005-07-01 01:28:35 +04:00
|
|
|
}
|
2005-07-12 17:38:54 +04:00
|
|
|
|
|
|
|
{
|
|
|
|
qp_attr->qp_state = IBV_QPS_INIT;
|
2005-07-15 19:13:19 +04:00
|
|
|
qp_attr->pkey_index = mca_btl_openib_component.ib_pkey_ix;
|
2005-07-13 04:17:08 +04:00
|
|
|
qp_attr->port_num = openib_btl->port_num;
|
2005-08-18 21:08:27 +04:00
|
|
|
qp_attr->qp_access_flags = IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_READ;
|
2005-07-12 17:38:54 +04:00
|
|
|
|
|
|
|
if(ibv_modify_qp((*qp), qp_attr,
|
|
|
|
IBV_QP_STATE |
|
|
|
|
IBV_QP_PKEY_INDEX |
|
|
|
|
IBV_QP_PORT |
|
|
|
|
IBV_QP_ACCESS_FLAGS )) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error modifying qp to INIT errno says %s", strerror(errno)));
|
2005-07-12 17:38:54 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-07-20 19:17:18 +04:00
|
|
|
/*
|
|
|
|
* The queue pair has been created and we have received the remote
|
|
|
|
* queue pair information from the peer so we init this queue pair
|
|
|
|
* and are ready to roll.
|
|
|
|
*/
|
2005-07-01 01:28:35 +04:00
|
|
|
int mca_btl_openib_endpoint_qp_init_query(
|
2005-07-12 17:38:54 +04:00
|
|
|
mca_btl_openib_module_t* openib_btl,
|
|
|
|
struct ibv_qp* qp,
|
|
|
|
struct ibv_qp_attr* attr,
|
|
|
|
uint32_t lcl_psn,
|
|
|
|
uint32_t rem_qp_num,
|
|
|
|
uint32_t rem_psn,
|
|
|
|
uint16_t rem_lid,
|
Bring over all the work from the /tmp/ib-hw-detect branch. In
addition to my design and testing, it was conceptually approved by
Gil, Gleb, Pasha, Brad, and Galen. Functionally [probably somewhat
lightly] tested by Galen. We may still have to shake out some bugs
during the next few months, but it seems to be working for all the
cases that I can throw at it.
Here's a summary of the changes from that branch:
* Move MCA parameter registration to a new file (btl_openib_mca.c):
* Properly check the retun status of registering MCA params
* Check for valid values of MCA parameters
* Make help strings better
* Otherwise, the only default value of an MCA param that was
changed was max_btls; it went from 4 to -1 (meaning: use all
available)
* Properly prototyped internal functions in _component.c
* Made a bunch of functions static that didn't need to be public
* Renamed to remove "mca_" prefix from static functions
* Call new MCA param registration function
* Call new INI file read/lookup/finalize functions
* Updated a bunch of macros to be "BTL_" instead of "ORTE_"
* Be a little more consistent with return values
* Handle -1 for the max_btls MCA param
* Fixed a free() that should have been an OBJ_RELEASE()
* Some re-indenting
* Added INI-file parsing
* New flex file: btl_openib_ini.l
* New default HCA params .ini file (probably to be expanded over
time by other HCA vendors)
* Added more show_help messages for parsing problems
* Read in INI files and cache the values for later lookup
* When component opens an HCA, lookup to see if any corresponding
values were found in the INI files (ID'ed by the HCA vendor_id
and vendor_part_id)
* Added btl_openib_verbose MCA param that shows what the INI-file
stuff does (e.g., shows which MTU your HCA ends up using)
* Added btl_openib_hca_param_files as a colon-delimited list of INI
files to check for values during startup (in order,
left-to-right, just like the MCA base directory param).
* MTU is currently the only value supported in this framework.
* It is not a fatal error if we don't find params for the HCA in
the INI file(s). Instead, just print a warning. New MCA param
btl_openib_warn_no_hca_params_found can be used to disable
printing the warning.
* Add MTU to peer negotiation when making a connection
* Exchange maximum MTU; select the lesser of the two
This commit was SVN r11182.
2006-08-14 23:30:37 +04:00
|
|
|
uint32_t rem_mtu,
|
2005-07-12 17:38:54 +04:00
|
|
|
uint32_t port_num
|
2005-07-01 01:28:35 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
{
|
2005-07-12 17:38:54 +04:00
|
|
|
attr->qp_state = IBV_QPS_RTR;
|
Bring over all the work from the /tmp/ib-hw-detect branch. In
addition to my design and testing, it was conceptually approved by
Gil, Gleb, Pasha, Brad, and Galen. Functionally [probably somewhat
lightly] tested by Galen. We may still have to shake out some bugs
during the next few months, but it seems to be working for all the
cases that I can throw at it.
Here's a summary of the changes from that branch:
* Move MCA parameter registration to a new file (btl_openib_mca.c):
* Properly check the retun status of registering MCA params
* Check for valid values of MCA parameters
* Make help strings better
* Otherwise, the only default value of an MCA param that was
changed was max_btls; it went from 4 to -1 (meaning: use all
available)
* Properly prototyped internal functions in _component.c
* Made a bunch of functions static that didn't need to be public
* Renamed to remove "mca_" prefix from static functions
* Call new MCA param registration function
* Call new INI file read/lookup/finalize functions
* Updated a bunch of macros to be "BTL_" instead of "ORTE_"
* Be a little more consistent with return values
* Handle -1 for the max_btls MCA param
* Fixed a free() that should have been an OBJ_RELEASE()
* Some re-indenting
* Added INI-file parsing
* New flex file: btl_openib_ini.l
* New default HCA params .ini file (probably to be expanded over
time by other HCA vendors)
* Added more show_help messages for parsing problems
* Read in INI files and cache the values for later lookup
* When component opens an HCA, lookup to see if any corresponding
values were found in the INI files (ID'ed by the HCA vendor_id
and vendor_part_id)
* Added btl_openib_verbose MCA param that shows what the INI-file
stuff does (e.g., shows which MTU your HCA ends up using)
* Added btl_openib_hca_param_files as a colon-delimited list of INI
files to check for values during startup (in order,
left-to-right, just like the MCA base directory param).
* MTU is currently the only value supported in this framework.
* It is not a fatal error if we don't find params for the HCA in
the INI file(s). Instead, just print a warning. New MCA param
btl_openib_warn_no_hca_params_found can be used to disable
printing the warning.
* Add MTU to peer negotiation when making a connection
* Exchange maximum MTU; select the lesser of the two
This commit was SVN r11182.
2006-08-14 23:30:37 +04:00
|
|
|
attr->path_mtu = (openib_btl->hca->mtu < rem_mtu) ?
|
|
|
|
openib_btl->hca->mtu : rem_mtu;
|
|
|
|
if (mca_btl_openib_component.verbose) {
|
|
|
|
BTL_OUTPUT(("Set MTU to IBV value %d (%s bytes)", attr->path_mtu,
|
|
|
|
(attr->path_mtu == IBV_MTU_256) ? "256" :
|
|
|
|
(attr->path_mtu == IBV_MTU_512) ? "512" :
|
|
|
|
(attr->path_mtu == IBV_MTU_1024) ? "1024" :
|
|
|
|
(attr->path_mtu == IBV_MTU_2048) ? "2048" :
|
|
|
|
(attr->path_mtu == IBV_MTU_4096) ? "4096" :
|
|
|
|
"unknown (!)"));
|
|
|
|
}
|
2005-07-12 17:38:54 +04:00
|
|
|
attr->dest_qp_num = rem_qp_num;
|
|
|
|
attr->rq_psn = rem_psn;
|
2005-07-15 19:13:19 +04:00
|
|
|
attr->max_dest_rd_atomic = mca_btl_openib_component.ib_max_rdma_dst_ops;
|
|
|
|
attr->min_rnr_timer = mca_btl_openib_component.ib_min_rnr_timer;
|
2005-07-12 17:38:54 +04:00
|
|
|
attr->ah_attr.is_global = 0;
|
|
|
|
attr->ah_attr.dlid = rem_lid;
|
2005-07-15 19:13:19 +04:00
|
|
|
attr->ah_attr.sl = mca_btl_openib_component.ib_service_level;
|
2006-06-28 11:23:08 +04:00
|
|
|
attr->ah_attr.src_path_bits = openib_btl->src_path_bits;
|
2005-07-12 17:38:54 +04:00
|
|
|
attr->ah_attr.port_num = port_num;
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-07-12 17:38:54 +04:00
|
|
|
if(ibv_modify_qp(qp, attr,
|
|
|
|
IBV_QP_STATE |
|
|
|
|
IBV_QP_AV |
|
|
|
|
IBV_QP_PATH_MTU |
|
|
|
|
IBV_QP_DEST_QPN |
|
|
|
|
IBV_QP_RQ_PSN |
|
|
|
|
IBV_QP_MAX_DEST_RD_ATOMIC |
|
|
|
|
IBV_QP_MIN_RNR_TIMER)) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error modifing QP to RTR errno says %s", strerror(errno)));
|
2005-07-01 01:28:35 +04:00
|
|
|
return OMPI_ERROR;
|
2005-07-12 17:38:54 +04:00
|
|
|
}
|
2006-01-31 19:17:18 +03:00
|
|
|
attr->qp_state = IBV_QPS_RTS;
|
|
|
|
attr->timeout = mca_btl_openib_component.ib_timeout;
|
|
|
|
attr->retry_cnt = mca_btl_openib_component.ib_retry_count;
|
|
|
|
attr->rnr_retry = mca_btl_openib_component.ib_rnr_retry;
|
|
|
|
attr->sq_psn = lcl_psn;
|
2005-07-15 19:13:19 +04:00
|
|
|
attr->max_rd_atomic = mca_btl_openib_component.ib_max_rdma_dst_ops;
|
2005-07-12 17:38:54 +04:00
|
|
|
if (ibv_modify_qp(qp, attr,
|
|
|
|
IBV_QP_STATE |
|
|
|
|
IBV_QP_TIMEOUT |
|
|
|
|
IBV_QP_RETRY_CNT |
|
|
|
|
IBV_QP_RNR_RETRY |
|
|
|
|
IBV_QP_SQ_PSN |
|
|
|
|
IBV_QP_MAX_QP_RD_ATOMIC)) {
|
2005-08-02 17:20:50 +04:00
|
|
|
BTL_ERROR(("error modifying QP to RTS errno says %s", strerror(errno)));
|
2005-07-13 04:17:08 +04:00
|
|
|
return OMPI_ERROR;
|
2005-07-12 17:38:54 +04:00
|
|
|
}
|
2005-07-01 01:28:35 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-11-10 23:15:02 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return control fragment.
|
|
|
|
*/
|
2006-01-13 02:42:44 +03:00
|
|
|
|
2006-09-12 13:17:59 +04:00
|
|
|
static void mca_btl_openib_endpoint_credits(
|
2005-11-10 23:15:02 +03:00
|
|
|
mca_btl_base_module_t* btl,
|
2006-01-13 02:42:44 +03:00
|
|
|
struct mca_btl_base_endpoint_t* endpoint,
|
2005-11-10 23:15:02 +03:00
|
|
|
struct mca_btl_base_descriptor_t* descriptor,
|
|
|
|
int status)
|
|
|
|
{
|
2006-09-12 13:17:59 +04:00
|
|
|
int32_t credits, prio;
|
|
|
|
|
|
|
|
if((void*)descriptor == (void*)endpoint->credit_frag[BTL_OPENIB_LP_QP])
|
|
|
|
prio = BTL_OPENIB_LP_QP;
|
|
|
|
else
|
|
|
|
prio = BTL_OPENIB_HP_QP;
|
2006-01-13 02:42:44 +03:00
|
|
|
|
|
|
|
/* we don't acquire a wqe or token for credit message - so decrement */
|
2006-09-12 13:17:59 +04:00
|
|
|
OPAL_THREAD_ADD32(&endpoint->sd_wqe[prio],-1);
|
2006-01-13 02:42:44 +03:00
|
|
|
|
|
|
|
/* check to see if there are addditional credits to return */
|
2006-09-12 13:17:59 +04:00
|
|
|
if((credits = OPAL_THREAD_ADD32(&endpoint->sd_credits[prio],-1)) > 0) {
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->sd_credits[prio], -credits);
|
|
|
|
if(btl_openib_check_send_credits(endpoint, prio)) {
|
|
|
|
mca_btl_openib_endpoint_send_credits(endpoint, prio);
|
2006-01-13 02:42:44 +03:00
|
|
|
}
|
|
|
|
}
|
2005-11-10 23:15:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return credits to peer
|
|
|
|
*/
|
|
|
|
|
2006-09-12 13:17:59 +04:00
|
|
|
void mca_btl_openib_endpoint_send_credits(mca_btl_openib_endpoint_t* endpoint,
|
|
|
|
const int prio)
|
2005-11-10 23:15:02 +03:00
|
|
|
{
|
|
|
|
mca_btl_openib_module_t* openib_btl = endpoint->endpoint_btl;
|
|
|
|
mca_btl_openib_frag_t* frag;
|
|
|
|
struct ibv_send_wr* bad_wr;
|
2006-09-05 20:02:09 +04:00
|
|
|
mca_btl_openib_rdma_credits_header_t *credits_hdr;
|
2005-11-10 23:15:02 +03:00
|
|
|
|
2006-09-12 13:17:59 +04:00
|
|
|
frag = endpoint->credit_frag[prio];
|
|
|
|
credits_hdr =
|
|
|
|
(mca_btl_openib_rdma_credits_header_t*)frag->segment.seg_addr.pval;
|
2005-11-10 23:15:02 +03:00
|
|
|
|
2006-09-12 13:17:59 +04:00
|
|
|
frag->base.des_cbfunc = mca_btl_openib_endpoint_credits;
|
2005-11-10 23:15:02 +03:00
|
|
|
frag->base.des_cbdata = NULL;
|
2006-01-13 02:42:44 +03:00
|
|
|
frag->endpoint = endpoint;
|
2005-11-10 23:15:02 +03:00
|
|
|
|
|
|
|
frag->hdr->tag = MCA_BTL_TAG_BTL;
|
2006-09-12 13:17:59 +04:00
|
|
|
/* send credits for high/low prios */
|
|
|
|
if(endpoint->rd_credits[prio] > 0) {
|
|
|
|
frag->hdr->credits = endpoint->rd_credits[prio];
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->rd_credits[prio], -frag->hdr->credits);
|
2006-09-05 20:02:09 +04:00
|
|
|
} else {
|
|
|
|
frag->hdr->credits = 0;
|
|
|
|
}
|
2006-09-12 13:17:59 +04:00
|
|
|
/* send eager RDMA credits only for high prio */
|
|
|
|
if(BTL_OPENIB_HP_QP == prio && endpoint->eager_rdma_local.credits > 0) {
|
2006-09-05 20:02:09 +04:00
|
|
|
credits_hdr->rdma_credits = endpoint->eager_rdma_local.credits;
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->eager_rdma_local.credits,
|
|
|
|
-credits_hdr->rdma_credits);
|
2006-09-12 13:17:59 +04:00
|
|
|
} else {
|
2006-09-05 20:02:09 +04:00
|
|
|
credits_hdr->rdma_credits = 0;
|
2006-09-12 13:17:59 +04:00
|
|
|
}
|
2006-09-05 20:02:09 +04:00
|
|
|
credits_hdr->control.type = MCA_BTL_OPENIB_CONTROL_CREDITS;
|
2006-01-13 02:42:44 +03:00
|
|
|
|
2006-09-05 20:04:04 +04:00
|
|
|
if(mca_btl_openib_component.use_srq) {
|
|
|
|
frag->wr_desc.sr_desc.opcode = IBV_WR_SEND_WITH_IMM;
|
|
|
|
frag->wr_desc.sr_desc.imm_data = endpoint->rem_info.rem_index;
|
|
|
|
} else {
|
|
|
|
frag->wr_desc.sr_desc.opcode = IBV_WR_SEND;
|
|
|
|
}
|
2006-03-26 12:30:50 +04:00
|
|
|
frag->sg_entry.length = sizeof(mca_btl_openib_header_t) +
|
2006-09-05 20:02:09 +04:00
|
|
|
sizeof(mca_btl_openib_rdma_credits_header_t);
|
2006-01-13 02:42:44 +03:00
|
|
|
frag->sg_entry.addr = (unsigned long) frag->hdr;
|
|
|
|
|
2006-01-31 19:17:18 +03:00
|
|
|
if(frag->sg_entry.length <= openib_btl->ib_inline_max) {
|
|
|
|
frag->wr_desc.sr_desc.send_flags = IBV_SEND_INLINE | IBV_SEND_SIGNALED;
|
|
|
|
} else {
|
|
|
|
frag->wr_desc.sr_desc.send_flags = IBV_SEND_SIGNALED;
|
|
|
|
}
|
|
|
|
|
2006-09-12 13:17:59 +04:00
|
|
|
if(ibv_post_send(endpoint->lcl_qp[prio], &frag->wr_desc.sr_desc, &bad_wr)) {
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->sd_credits[prio], -1);
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->rd_credits[prio], frag->hdr->credits);
|
|
|
|
OPAL_THREAD_ADD32(&endpoint->eager_rdma_local.credits,
|
|
|
|
credits_hdr->rdma_credits);
|
|
|
|
BTL_ERROR(("error posting send request errno %d says %s",
|
2006-03-26 12:30:50 +04:00
|
|
|
strerror(errno)));
|
2005-11-10 23:15:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-26 12:30:50 +04:00
|
|
|
static void mca_btl_openib_endpoint_eager_rdma(
|
|
|
|
mca_btl_base_module_t* btl,
|
|
|
|
struct mca_btl_base_endpoint_t* endpoint,
|
|
|
|
struct mca_btl_base_descriptor_t* descriptor,
|
|
|
|
int status)
|
|
|
|
{
|
2006-07-27 18:09:30 +04:00
|
|
|
MCA_BTL_IB_FRAG_RETURN(((mca_btl_openib_module_t*)btl),
|
|
|
|
((mca_btl_openib_frag_t*)descriptor));
|
2006-03-26 12:30:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mca_btl_openib_endpoint_send_eager_rdma(
|
|
|
|
mca_btl_base_endpoint_t* endpoint)
|
|
|
|
{
|
|
|
|
mca_btl_openib_module_t* openib_btl = endpoint->endpoint_btl;
|
|
|
|
mca_btl_openib_eager_rdma_header_t *rdma_hdr;
|
|
|
|
mca_btl_openib_frag_t* frag;
|
|
|
|
int rc;
|
|
|
|
|
2006-07-27 18:09:30 +04:00
|
|
|
MCA_BTL_IB_FRAG_ALLOC_CREDIT_WAIT(openib_btl, frag, rc);
|
2006-03-26 12:30:50 +04:00
|
|
|
if(NULL == frag) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
frag->base.des_cbfunc = mca_btl_openib_endpoint_eager_rdma;
|
|
|
|
frag->base.des_cbdata = NULL;
|
|
|
|
frag->endpoint = endpoint;
|
|
|
|
frag->base.des_flags |= MCA_BTL_DES_FLAGS_PRIORITY;
|
|
|
|
|
|
|
|
frag->hdr->tag = MCA_BTL_TAG_BTL;
|
|
|
|
rdma_hdr = (mca_btl_openib_eager_rdma_header_t*)frag->segment.seg_addr.pval;
|
|
|
|
rdma_hdr->control.type = MCA_BTL_OPENIB_CONTROL_RDMA;
|
|
|
|
rdma_hdr->rkey = endpoint->eager_rdma_local.reg->mr->rkey;
|
|
|
|
rdma_hdr->rdma_start.pval = endpoint->eager_rdma_local.base.pval;
|
|
|
|
frag->segment.seg_len = sizeof(mca_btl_openib_eager_rdma_header_t);
|
2006-09-12 13:17:59 +04:00
|
|
|
if (mca_btl_openib_endpoint_send(endpoint, frag) != OMPI_SUCCESS) {
|
2006-06-01 06:32:18 +04:00
|
|
|
MCA_BTL_IB_FRAG_RETURN(openib_btl, frag);
|
2006-03-26 12:30:50 +04:00
|
|
|
BTL_ERROR(("Error sending RDMA buffer", strerror(errno)));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* create RDMA buffer for eager messages */
|
|
|
|
void mca_btl_openib_endpoint_connect_eager_rdma(
|
|
|
|
mca_btl_openib_endpoint_t* endpoint)
|
|
|
|
{
|
|
|
|
mca_btl_openib_module_t* openib_btl = endpoint->endpoint_btl;
|
|
|
|
char *buf;
|
2006-04-02 15:32:25 +04:00
|
|
|
unsigned int i;
|
2006-03-26 12:30:50 +04:00
|
|
|
|
2006-03-26 19:02:43 +04:00
|
|
|
OPAL_THREAD_LOCK(&endpoint->eager_rdma_local.lock);
|
2006-03-26 12:30:50 +04:00
|
|
|
if (endpoint->eager_rdma_local.base.pval)
|
2006-03-26 19:02:43 +04:00
|
|
|
goto unlock_rdma_local;
|
2006-03-26 12:30:50 +04:00
|
|
|
|
|
|
|
buf = openib_btl->super.btl_mpool->mpool_alloc(openib_btl->super.btl_mpool,
|
|
|
|
openib_btl->eager_rdma_frag_size *
|
2006-08-28 15:03:56 +04:00
|
|
|
mca_btl_openib_component.eager_rdma_num +
|
|
|
|
mca_btl_openib_component.buffer_alignment +
|
|
|
|
sizeof(mca_btl_openib_recv_frag_eager_t), 0, 0,
|
2006-03-26 12:30:50 +04:00
|
|
|
(mca_mpool_base_registration_t**)&endpoint->eager_rdma_local.reg);
|
|
|
|
|
|
|
|
if(!buf)
|
2006-03-26 19:02:43 +04:00
|
|
|
goto unlock_rdma_local;
|
2006-03-26 12:30:50 +04:00
|
|
|
|
2006-08-28 15:03:56 +04:00
|
|
|
buf = (char*)(((uintptr_t)buf+mca_btl_openib_component.buffer_alignment) & ~(mca_btl_openib_component.buffer_alignment-1));
|
|
|
|
buf = buf + openib_btl->eager_rdma_frag_size - sizeof(mca_btl_openib_footer_t) - openib_btl->super.btl_eager_limit - sizeof(mca_btl_openib_header_t) - sizeof(mca_btl_openib_frag_t);
|
|
|
|
|
2006-03-26 12:30:50 +04:00
|
|
|
for(i = 0; i < mca_btl_openib_component.eager_rdma_num; i++) {
|
|
|
|
ompi_free_list_item_t *item = (ompi_free_list_item_t *)(buf +
|
|
|
|
i*openib_btl->eager_rdma_frag_size);
|
|
|
|
item->user_data = endpoint->eager_rdma_local.reg;
|
|
|
|
OBJ_CONSTRUCT(item, mca_btl_openib_recv_frag_eager_t);
|
|
|
|
((mca_btl_openib_frag_t*)item)->endpoint = endpoint;
|
2006-03-30 19:26:21 +04:00
|
|
|
((mca_btl_openib_frag_t*)item)->type = MCA_BTL_OPENIB_FRAG_EAGER_RDMA;
|
2006-03-26 12:30:50 +04:00
|
|
|
}
|
|
|
|
|
2006-03-26 19:02:43 +04:00
|
|
|
OPAL_THREAD_LOCK(&openib_btl->eager_rdma_lock);
|
2006-03-26 12:30:50 +04:00
|
|
|
if(orte_pointer_array_add (&endpoint->eager_rdma_index,
|
|
|
|
openib_btl->eager_rdma_buffers, endpoint) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
endpoint->eager_rdma_local.base.pval = buf;
|
|
|
|
openib_btl->eager_rdma_buffers_count++;
|
|
|
|
if (mca_btl_openib_endpoint_send_eager_rdma(endpoint) == 0) {
|
2006-03-26 19:02:43 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&openib_btl->eager_rdma_lock);
|
|
|
|
OPAL_THREAD_UNLOCK(&endpoint->eager_rdma_local.lock);
|
|
|
|
return;
|
2006-03-26 12:30:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
openib_btl->eager_rdma_buffers_count--;
|
|
|
|
endpoint->eager_rdma_local.base.pval = NULL;
|
|
|
|
orte_pointer_array_set_item(openib_btl->eager_rdma_buffers,
|
|
|
|
endpoint->eager_rdma_index, NULL);
|
|
|
|
|
|
|
|
cleanup:
|
2006-03-26 19:02:43 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&openib_btl->eager_rdma_lock);
|
2006-03-26 12:30:50 +04:00
|
|
|
openib_btl->super.btl_mpool->mpool_free(openib_btl->super.btl_mpool,
|
2006-04-02 15:32:25 +04:00
|
|
|
buf, (mca_mpool_base_registration_t*)endpoint->eager_rdma_local.reg);
|
2006-03-26 19:02:43 +04:00
|
|
|
unlock_rdma_local:
|
|
|
|
OPAL_THREAD_UNLOCK(&endpoint->eager_rdma_local.lock);
|
2006-03-26 12:30:50 +04:00
|
|
|
}
|