Skip to content

Commit

Permalink
Merge branch 'upstream-EVPath' into DPBestEffort
Browse files Browse the repository at this point in the history
# By EVPath Upstream
* upstream-EVPath:
  EVPath 2022-10-04 (e26cc585)
  • Loading branch information
eisenhauer committed Oct 4, 2022
2 parents 508b81a + a346abb commit 455b87f
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 75 deletions.
2 changes: 1 addition & 1 deletion thirdparty/EVPath/EVPath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ cmake_dependent_option(EVPATH_TRANSPORT_MODULES

list(INSERT CMAKE_PREFIX_PATH 0 ${CMAKE_INSTALL_PREFIX})
find_package(atl 2.2.1 REQUIRED)
find_package(ffs 1.5.1 REQUIRED)
find_package(ffs 2.0.0 REQUIRED)
_pkg_get_target_prefix(atl::atl atl_PREFIX)
_pkg_get_target_prefix(ffs::ffs ffs_PREFIX)
list(APPEND _pkg_config_pfxs "${atl_PREFIX}" "${ffs_PREFIX}")
Expand Down
125 changes: 89 additions & 36 deletions thirdparty/EVPath/EVPath/cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,11 @@ timeout_conn(CManager cm, void *client_data)
byte_swap = 1;
case 0x004d4400: /* CMD\0 */
break;
case 0x00444d01: /* \1DMC reversed byte order long msg*/
byte_swap = 1;
case 0x004d4401: /* CMD\1 long msg*/
short_length = 0;
break;
case 0x00414d00: /* \0AMC reversed byte order */
byte_swap = 1;
case 0x004d4100: /* CMA\0 */
Expand Down Expand Up @@ -2357,6 +2362,9 @@ timeout_conn(CManager cm, void *client_data)
} else {
header_len = 16;
}
if (!short_length) {
header_len += 4; /* extra data length bytes */
}
} else {
if (short_length) {
header_len = 8; /* magic plus 4-byte size */
Expand Down Expand Up @@ -2446,13 +2454,25 @@ timeout_conn(CManager cm, void *client_data)
data_length -= 8; /* subtract off header size */
}
if (event_msg) {
if (byte_swap) {
((char*)&stone_id)[0] = base[11];
((char*)&stone_id)[1] = base[10];
((char*)&stone_id)[2] = base[9];
((char*)&stone_id)[3] = base[8];
} else {
stone_id = ((int *) base)[2];
char *stone_base = base;
if (header_len == 16) {
if (byte_swap) {
((char*)&stone_id)[0] = stone_base[11];
((char*)&stone_id)[1] = stone_base[10];
((char*)&stone_id)[2] = stone_base[9];
((char*)&stone_id)[3] = stone_base[8];
} else {
stone_id = ((int *) stone_base)[2];
}
} else if (header_len == 20) {
if (byte_swap) {
((char*)&stone_id)[0] = stone_base[15];
((char*)&stone_id)[1] = stone_base[14];
((char*)&stone_id)[2] = stone_base[13];
((char*)&stone_id)[3] = stone_base[12];
} else {
stone_id = ((int *) stone_base)[3];
}
}
}

Expand Down Expand Up @@ -2698,28 +2718,33 @@ timeout_conn(CManager cm, void *client_data)
cm_return_data_buf(cm, buf);
}

void
INT_CMregister_handler(CMFormat format, CMHandlerFunc handler,
void *client_data)
{
CManager cm = format->cm;
int i;
format->handler = handler;
format->client_data = client_data;
void
INT_CMregister_handler(CMFormat format, CMHandlerFunc handler,
void *client_data)
{
CManager cm = format->cm;
int i;
format->handler = handler;
format->client_data = client_data;

for (i=0; i< cm->in_format_count; i++) {
if (cm->in_formats[i].format == format->ffsformat) {
if (!cm->in_formats[i].handler) {
cm->in_formats[i].handler = handler;
cm->in_formats[i].client_data = client_data;
} else if ((cm->in_formats[i].handler != handler) ||
(cm->in_formats[i].client_data != client_data)) {
fprintf(stderr, "Warning, CMregister_handler() called multiple times for the same format with different handler or client_data\n");
fprintf(stderr, "Repeated calls will be ignored\n");
}
}
}
}
for (i=0; i< cm->in_format_count; i++) {
if (strcmp(name_of_FMformat(FMFormat_of_original(cm->in_formats[i].format)), format->format_name) == 0) {
if (format->registration_pending) {
CMcomplete_format_registration(format, 1);
}
if (cm->in_formats[i].format == format->ffsformat) {
if (!cm->in_formats[i].handler) {
cm->in_formats[i].handler = handler;
cm->in_formats[i].client_data = client_data;
} else if ((cm->in_formats[i].handler != handler) ||
(cm->in_formats[i].client_data != client_data)) {
fprintf(stderr, "Warning, CMregister_handler() called multiple times for the same format with different handler or client_data\n");
fprintf(stderr, "Repeated calls will be ignored\n");
}
}
}
}
}

extern void
INT_CMregister_invalid_message_handler(CManager cm, CMUnregCMHandler handler)
Expand Down Expand Up @@ -3202,14 +3227,18 @@ INT_CMregister_invalid_message_handler(CManager cm, CMUnregCMHandler handler)
INT_CMwrite_attr(CMConnection conn, CMFormat format, void *data,
attr_list attrs)
{
/* GSE MUST FIX for LONG */
void *header_ptr = NULL;
int header_len = 0;
int no_attr_header[2] = {0x434d4400, 0}; /* CMD\0 in first entry */
int attr_header[4] = {0x434d4100, 0x434d4100, 0, 0}; /* CMA\0 in first entry */
int no_attr_long_header[4] = {0x434d4401, 0x434d4401, 0, 0}; /* CMD\1 in first entry, pad to 16 */
int attr_header[4] = {0x434d4100, 0x434d4100, 0, 0}; /* CMA\0 in first entry, pad to 16 */
int attr_long_header[4] = {0x434d4101, 0, 0, 0}; /* CMA\1 in first entry */
FFSEncodeVector vec;
size_t length = 0, vec_count = 0, actual;
int do_write = 1;
void *encoded_attrs = NULL;
int attrs_present = 0;
int long_message = 0;
CManager cm = conn->cm;

/* ensure conn is open */
Expand Down Expand Up @@ -3279,13 +3308,38 @@ INT_CMregister_invalid_message_handler(CManager cm, CMUnregCMHandler handler)
length += vec[vec_count].iov_len;
vec_count++;
}
no_attr_header[1] = length;
attr_header[2] = length;
if ((length & 0x7fffffff) == 0) {
long_message = 1;
}
if (attrs != NULL) {
attrs_present++;
}
if (!long_message) {
if (attrs_present) {
attr_header[2] = length;
header_ptr = &attr_header;
header_len = sizeof(attr_header);
} else {
no_attr_header[1] = length;
header_ptr = &no_attr_header;
header_len = sizeof(no_attr_header);
}
} else {
if (attrs_present) {
memcpy((void*) &attr_long_header[1], &length, sizeof(length));
header_ptr = &attr_long_header;
header_len = sizeof(attr_long_header);
} else {
memcpy((void*) &attr_long_header[2], &length, sizeof(length));
header_ptr = no_attr_header;
header_len = sizeof(no_attr_header);
}
}
if (attrs_present) {
encoded_attrs = encode_attr_for_xmit(attrs, conn->attr_encode_buffer,
&attr_header[3]);
attr_header[3] = (attr_header[3] +7) & -8; /* round up to even 8 */
attr_long_header[3] = (attr_header[3] +7) & -8; /* round up to even 8 */
}
CMtrace_out(conn->cm, CMDataVerbose, "CM - Total write size is %zu bytes data + %d bytes attrs\n", length, attr_header[3]);
if (cm_write_hook != NULL) {
Expand All @@ -3298,18 +3352,16 @@ INT_CMregister_invalid_message_handler(CManager cm, CMUnregCMHandler handler)
if (vec_count >= sizeof(static_vec)/ sizeof(static_vec[0])) {
tmp_vec = INT_CMmalloc((vec_count+1) * sizeof(*tmp_vec));
}
tmp_vec[0].iov_base = header_ptr;
tmp_vec[0].iov_len = header_len;
if (attrs == NULL) {
tmp_vec[0].iov_base = &no_attr_header;
tmp_vec[0].iov_len = sizeof(no_attr_header);
memcpy(&tmp_vec[1], vec, sizeof(*tmp_vec) * vec_count);
vec_count++;
byte_count += sizeof(no_attr_header);
CMtrace_out(conn->cm, CMLowLevelVerbose,
"Writing %zu vectors, total %zu bytes in writev\n",
vec_count, byte_count);
} else {
tmp_vec[0].iov_base = &attr_header;
tmp_vec[0].iov_len = sizeof(attr_header);
tmp_vec[1].iov_base = encoded_attrs;
tmp_vec[1].iov_len = attr_header[3];
memcpy(&tmp_vec[2], vec, sizeof(*tmp_vec) * vec_count);
Expand Down Expand Up @@ -3483,6 +3535,7 @@ INT_CMregister_invalid_message_handler(CManager cm, CMUnregCMHandler handler)
"Writing %zu vectors, total %zu bytes (including attrs) in writev\n",
vec_count, byte_count);
}
char *header_ptr = (char*)&header[0];
actual = INT_CMwrite_raw(conn, tmp_vec, vec, vec_count, byte_count, attrs,
vec == &preencoded_vec[0]);
if (tmp_vec != &static_vec[0]) {
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/EVPath/EVPath/cmfabric.c
Original file line number Diff line number Diff line change
Expand Up @@ -2263,7 +2263,7 @@ libcmfabric_LTX_non_blocking_listen(CManager cm, CMtrans_services svc, transport
#ifdef NEED_IOVEC_DEFINE
struct iovec {
void *iov_base;
int iov_len;
size_t iov_len;
};

#endif
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/EVPath/EVPath/cmib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ attr_list listen_info;
#ifdef NEED_IOVEC_DEFINE
struct iovec {
void *iov_base;
int iov_len;
long iov_len;
};

#endif
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/EVPath/EVPath/cmmulticast.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ attr_list listen_info;
#ifdef NEED_IOVEC_DEFINE
struct iovec {
void *iov_base;
int iov_len;
size_t iov_len;
};

#endif
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/EVPath/EVPath/cmnnti.c
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ attr_list listen_info;
#ifdef NEED_IOVEC_DEFINE
struct iovec {
void *iov_base;
int iov_len;
long iov_len;
};

#endif
Expand Down
Loading

0 comments on commit 455b87f

Please sign in to comment.