Skip to content

Commit 540d483

Browse files
author
Brad Penoff
committed
64 bit fix and initial Solaris support
This commit was SVN r16967.
1 parent a20a1a8 commit 540d483

File tree

6 files changed

+73
-12
lines changed

6 files changed

+73
-12
lines changed

ompi/mca/btl/sctp/btl_sctp_component.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,11 @@ int mca_btl_sctp_component_open(void)
237237
!mca_btl_sctp_param_register_int ("use_nagle", 0);
238238
/* port_min */
239239
/* port_range */
240-
/* use a single one-to-many socket by default */
240+
/* use a single one-to-many socket by default except in Solaris (see
241+
* the configure.m4 file)
242+
*/
241243
mca_btl_sctp_component.sctp_if_11 =
242-
mca_btl_sctp_param_register_int ("if_11", 0);
244+
mca_btl_sctp_param_register_int ("if_11", OMPI_MCA_BTL_SCTP_USE_ONE_TO_ONE_SOCKET);
243245

244246
/* have lower exclusivity than tcp */
245247
mca_btl_sctp_module.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_LOW;

ompi/mca/btl/sctp/btl_sctp_proc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ bool mca_btl_sctp_proc_accept(mca_btl_sctp_proc_t* btl_proc, struct sockaddr_in*
362362
*
363363
* TODO - change this to use a hash for constant time performance
364364
*/
365-
int mca_btl_sctp_proc_check(uint32_t id, struct mca_btl_sctp_proc_table_node *table) {
365+
int mca_btl_sctp_proc_check(sctp_assoc_t id, struct mca_btl_sctp_proc_table_node *table) {
366366
#if MCA_BTL_SCTP_DONT_USE_HASH
367367
int i;
368368
for(i = 0; i < MCA_BTL_SCTP_PROC_TABLE_SIZE; i++) {
@@ -376,6 +376,7 @@ int mca_btl_sctp_proc_check(uint32_t id, struct mca_btl_sctp_proc_table_node *ta
376376
return INVALID_ENTRY;
377377
#else
378378
mca_btl_sctp_proc_t *val;
379+
/* TODO fix if sctp_assoc_t is 64 bit (once we change to hash) */
379380
int rc = opal_hash_table_get_value_uint32(&mca_btl_sctp_component.sctp_assocID_hash, id, &val);
380381
if(OPAL_SUCCESS == rc) {
381382
return VALID_ENTRY;
@@ -394,7 +395,7 @@ int mca_btl_sctp_proc_check(uint32_t id, struct mca_btl_sctp_proc_table_node *ta
394395
* TODO change this to a hash table that can expand to eliminate
395396
* MCA_BTL_SCTP_PROC_TABLE_SIZE limitation
396397
*/
397-
void mca_btl_sctp_proc_add(uint32_t id, struct mca_btl_sctp_proc_t *proc, struct mca_btl_sctp_proc_table_node *table) {
398+
void mca_btl_sctp_proc_add(sctp_assoc_t id, struct mca_btl_sctp_proc_t *proc, struct mca_btl_sctp_proc_table_node *table) {
398399
#if MCA_BTL_SCTP_DONT_USE_HASH
399400
int i;
400401
for(i = 0; i < MCA_BTL_SCTP_PROC_TABLE_SIZE; i++) {
@@ -406,6 +407,7 @@ void mca_btl_sctp_proc_add(uint32_t id, struct mca_btl_sctp_proc_t *proc, struct
406407
}
407408
}
408409
#else
410+
/* TODO fix if sctp_assoc_t is 64 bit (once we change to hash) */
409411
int rc = opal_hash_table_set_value_uint32(&mca_btl_sctp_component.sctp_assocID_hash, id, proc);
410412
/* TODO handle return code */
411413
#endif
@@ -417,7 +419,7 @@ void mca_btl_sctp_proc_add(uint32_t id, struct mca_btl_sctp_proc_t *proc, struct
417419
* ------------------------------------------
418420
* Returns pointer to a proc that is indexed by the association id.
419421
*/
420-
mca_btl_sctp_proc_t *mca_btl_sctp_proc_get(uint32_t id, struct mca_btl_sctp_proc_table_node *table) {
422+
mca_btl_sctp_proc_t *mca_btl_sctp_proc_get(sctp_assoc_t id, struct mca_btl_sctp_proc_table_node *table) {
421423
#if MCA_BTL_SCTP_DONT_USE_HASH
422424
int i;
423425
for(i = 0; i < MCA_BTL_SCTP_PROC_TABLE_SIZE; i++){
@@ -428,6 +430,7 @@ mca_btl_sctp_proc_t *mca_btl_sctp_proc_get(uint32_t id, struct mca_btl_sctp_proc
428430
return NULL;
429431
#else
430432
mca_btl_sctp_proc_t *val;
433+
/* TODO fix if sctp_assoc_t is 64 bit (once we change to hash) */
431434
int rc = opal_hash_table_get_value_uint32(&mca_btl_sctp_component.sctp_assocID_hash, id, &val);
432435
if(OPAL_SUCCESS == rc) {
433436
return val;

ompi/mca/btl/sctp/btl_sctp_proc.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "btl_sctp.h"
2626
#include "btl_sctp_addr.h"
2727
#include "btl_sctp_endpoint.h"
28+
#include <netinet/sctp.h>
2829

2930
#if defined(c_plusplus) || defined(__cplusplus)
3031
extern "C" {
@@ -94,17 +95,17 @@ enum {
9495
#define MCA_BTL_SCTP_PROC_TABLE_SIZE 256
9596
struct mca_btl_sctp_proc_table_node {
9697
int valid;
97-
uint32_t sctp_assoc_id;
98+
sctp_assoc_t sctp_assoc_id;
9899
struct mca_btl_sctp_proc_t *proc;
99100
};
100101
typedef struct mca_btl_sctp_proc_table_node mca_btl_sctp_proc_table_node;
101102

102103
extern struct mca_btl_sctp_proc_table_node *recvr_proc_table;
103104
extern struct mca_btl_sctp_proc_table_node *sender_proc_table;
104105

105-
int mca_btl_sctp_proc_check(uint32_t id, struct mca_btl_sctp_proc_table_node *table);
106-
void mca_btl_sctp_proc_add(uint32_t id, struct mca_btl_sctp_proc_t *proc, struct mca_btl_sctp_proc_table_node *table);
107-
mca_btl_sctp_proc_t *mca_btl_sctp_proc_get(uint32_t id, struct mca_btl_sctp_proc_table_node *table);
106+
int mca_btl_sctp_proc_check(sctp_assoc_t id, struct mca_btl_sctp_proc_table_node *table);
107+
void mca_btl_sctp_proc_add(sctp_assoc_t id, struct mca_btl_sctp_proc_t *proc, struct mca_btl_sctp_proc_table_node *table);
108+
mca_btl_sctp_proc_t *mca_btl_sctp_proc_get(sctp_assoc_t id, struct mca_btl_sctp_proc_table_node *table);
108109

109110
#if defined(c_plusplus) || defined(__cplusplus)
110111
}

ompi/mca/btl/sctp/btl_sctp_recv_handler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void mca_btl_sctp_recv_handler(int sd, short flags, void *user) {
141141

142142
/* Check if sender is known to us. */
143143

144-
if((mca_btl_sctp_proc_check(((uint32_t)(sri.sinfo_assoc_id)), recvr_proc_table)) == VALID_ENTRY) {
144+
if((mca_btl_sctp_proc_check(sri.sinfo_assoc_id, recvr_proc_table)) == VALID_ENTRY) {
145145

146146
mca_btl_base_endpoint_t *btl_endpoint;
147147
mca_btl_sctp_frag_t* frag;
@@ -233,7 +233,7 @@ void mca_btl_sctp_recv_handler(int sd, short flags, void *user) {
233233
CLOSE_THE_SOCKET(sd);
234234
return;
235235
}
236-
mca_btl_sctp_proc_add((uint32_t)sri.sinfo_assoc_id, btl_proc, recvr_proc_table);
236+
mca_btl_sctp_proc_add(sri.sinfo_assoc_id, btl_proc, recvr_proc_table);
237237

238238

239239
/* are there any existing peer instances will to accept this connection */

ompi/mca/btl/sctp/btl_sctp_utils.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,39 @@ struct sockaddr_in mca_btl_sctp_utils_sockaddr_from_endpoint(struct mca_btl_base
6363
int mca_btl_sctp_utils_writev(int sd, struct iovec *vec, size_t len,
6464
struct sockaddr *to_addr, socklen_t to_len, uint16_t stream_no) {
6565

66+
#if OMPI_MCA_BTL_SCTP_CONCATENATES_IOVS
67+
/* required for Solaris since struct msghdr has no msg_control field */
68+
69+
int current_cnt=0, total_offset=0, total=0, byte_sent;
70+
char *send_buf;
71+
72+
/* count the total and allocate space to copy to */
73+
while(current_cnt < len) {
74+
total += vec[current_cnt].iov_len;
75+
current_cnt++;
76+
}
77+
if(NULL == (send_buf = (char *) malloc(total))) {
78+
BTL_ERROR(("Ran out of memory."));
79+
return 0;
80+
}
81+
82+
/* combine all iovcnt's into one message. write all or nothing */
83+
current_cnt=0;
84+
while(current_cnt < len) {
85+
memcpy(send_buf+total_offset, vec[current_cnt].iov_base, vec[current_cnt].iov_len);
86+
total_offset += vec[current_cnt].iov_len;
87+
current_cnt++;
88+
}
89+
90+
byte_sent = sctp_sendmsg(sd, send_buf, total, (struct sockaddr *) to_addr,
91+
sizeof(*to_addr), 0, 0, stream_no, 0, 0);
92+
free(send_buf);
93+
94+
return byte_sent;
95+
96+
#else
97+
/* uses iovec directly */
98+
6699
char outcmesg[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
67100
struct cmsghdr *cmesg;
68101
struct msghdr outmesg;
@@ -97,4 +130,5 @@ int mca_btl_sctp_utils_writev(int sd, struct iovec *vec, size_t len,
97130
srinfo->sinfo_context = cxt;
98131

99132
return sendmsg(sd, &outmesg, 0);
133+
#endif
100134
}

ompi/mca/btl/sctp/configure.m4

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,20 @@ AC_DEFUN([OMPI_CHECK_SCTP],[
3737
case "$host" in
3838
*linux*)
3939
ompi_sctp_try_to_build="yes"
40+
AC_DEFINE(OMPI_MCA_BTL_SCTP_USE_ONE_TO_ONE_SOCKET, 0,
41+
[Default value for socket style to use with SCTP BTL])
42+
AC_DEFINE(OMPI_MCA_BTL_SCTP_CONCATENATES_IOVS, 0,
43+
[False if you can use iovec's directly with SCTP BTL])
4044
;;
4145
*bsd*)
4246
# only add -DFREEBSD once to get extra sin_len field
4347
btl_sctp_CFLAGS="`echo $btl_sctp_CFLAGS | sed 's/-DFREEBSD//g'`"
4448
btl_sctp_CFLAGS="$btl_sctp_CFLAGS -DFREEBSD"
4549
ompi_sctp_try_to_build="yes"
50+
AC_DEFINE(OMPI_MCA_BTL_SCTP_USE_ONE_TO_ONE_SOCKET, 0,
51+
[Default value for socket style to use with SCTP BTL])
52+
AC_DEFINE(OMPI_MCA_BTL_SCTP_CONCATENATES_IOVS, 0,
53+
[False if you can use iovec's directly with SCTP BTL])
4654
AC_MSG_WARN([Adding -DFREEBSD to set extra sin_len field in sockaddr.])
4755
;;
4856
# Mac OS X support for SCTP NKE. Adjustments should look like *bsd*...
@@ -51,10 +59,23 @@ AC_DEFUN([OMPI_CHECK_SCTP],[
5159
btl_sctp_CFLAGS="`echo $btl_sctp_CFLAGS | sed 's/-DFREEBSD//g'`"
5260
btl_sctp_CFLAGS="$btl_sctp_CFLAGS -DFREEBSD"
5361
ompi_sctp_try_to_build="yes"
62+
AC_DEFINE(OMPI_MCA_BTL_SCTP_USE_ONE_TO_ONE_SOCKET, 0,
63+
[Default value for socket style to use with SCTP BTL])
64+
AC_DEFINE(OMPI_MCA_BTL_SCTP_CONCATENATES_IOVS, 0,
65+
[False if you can use iovec's directly with SCTP BTL])
5466
AC_MSG_WARN([Adding -DFREEBSD to set extra sin_len field in sockaddr.])
5567
;;
68+
*solaris*)
69+
# Solaris SCTP stack makes different assumptions about one-to-many
70+
# sockets so change the default to use one-to-one sockets
71+
ompi_sctp_try_to_build="yes"
72+
AC_DEFINE(OMPI_MCA_BTL_SCTP_USE_ONE_TO_ONE_SOCKET, 1,
73+
[Default value for socket style to use with SCTP BTL])
74+
AC_DEFINE(OMPI_MCA_BTL_SCTP_CONCATENATES_IOVS, 1,
75+
[False if you can use iovec's directly with SCTP BTL])
76+
;;
5677
*)
57-
AC_MSG_WARN([Only build sctp BTL on Linux, Mac OS X, and BSD variants])
78+
AC_MSG_WARN([Only build sctp BTL on Solaris, Linux, Mac OS X, and BSD variants])
5879
;;
5980
esac
6081

0 commit comments

Comments
 (0)