diff --git a/src/mercury.c b/src/mercury.c index d29761ec..8f8dfd19 100644 --- a/src/mercury.c +++ b/src/mercury.c @@ -207,7 +207,7 @@ hg_core_respond_cb(const struct hg_core_cb_info *callback_info); /*******************/ /* Return code string table */ -#define X(a) #a, +#define X(a, b) #a, static const char *const hg_return_name[] = {HG_RETURN_VALUES}; #undef X @@ -1054,7 +1054,9 @@ HG_Version_get( const char * HG_Error_to_string(hg_return_t errnum) { - return hg_return_name[errnum]; + return hg_return_name[errnum < (hg_return_t) NA_RETURN_MAX + ? errnum + : errnum - HG_NA_ERRNO_OFFSET + NA_RETURN_MAX]; } /*---------------------------------------------------------------------------*/ diff --git a/src/mercury_core_types.h b/src/mercury_core_types.h index 7561ecc7..c4014d95 100644 --- a/src/mercury_core_types.h +++ b/src/mercury_core_types.h @@ -119,37 +119,44 @@ struct hg_init_info { unsigned int multi_recv_copy_threshold; }; +/* Keep offset to keep room for additional NA error codes */ +#define HG_NA_ERRNO_OFFSET 64 + /* Error return codes: * Functions return 0 for success or corresponding return code */ #define HG_RETURN_VALUES \ - X(HG_SUCCESS) /*!< operation succeeded */ \ - X(HG_PERMISSION) /*!< operation not permitted */ \ - X(HG_NOENTRY) /*!< no such file or directory */ \ - X(HG_INTERRUPT) /*!< operation interrupted */ \ - X(HG_AGAIN) /*!< operation must be retried */ \ - X(HG_NOMEM) /*!< out of memory */ \ - X(HG_ACCESS) /*!< permission denied */ \ - X(HG_FAULT) /*!< bad address */ \ - X(HG_BUSY) /*!< device or resource busy */ \ - X(HG_EXIST) /*!< entry already exists */ \ - X(HG_NODEV) /*!< no such device */ \ - X(HG_INVALID_ARG) /*!< invalid argument */ \ - X(HG_PROTOCOL_ERROR) /*!< protocol error */ \ - X(HG_OVERFLOW) /*!< value too large */ \ - X(HG_MSGSIZE) /*!< message size too long */ \ - X(HG_PROTONOSUPPORT) /*!< protocol not supported */ \ - X(HG_OPNOTSUPPORTED) /*!< operation not supported on endpoint */ \ - X(HG_ADDRINUSE) /*!< address already in use */ \ - X(HG_ADDRNOTAVAIL) /*!< cannot assign requested address */ \ - X(HG_HOSTUNREACH) /*!< cannot reach host during operation */ \ - X(HG_TIMEOUT) /*!< operation reached timeout */ \ - X(HG_CANCELED) /*!< operation canceled */ \ - X(HG_CHECKSUM_ERROR) /*!< checksum error */ \ - X(HG_NA_ERROR) /*!< generic NA error */ \ - X(HG_OTHER_ERROR) /*!< generic HG error */ \ - X(HG_RETURN_MAX) - -#define X(a) a, + X(HG_SUCCESS, NA_SUCCESS) /*!< operation succeeded */ \ + X(HG_PERMISSION, NA_PERMISSION) /*!< operation not permitted */ \ + X(HG_NOENTRY, NA_NOENTRY) /*!< no such file or directory */ \ + X(HG_INTERRUPT, NA_INTERRUPT) /*!< operation interrupted */ \ + X(HG_AGAIN, NA_AGAIN) /*!< operation must be retried */ \ + X(HG_NOMEM, NA_NOMEM) /*!< out of memory */ \ + X(HG_ACCESS, NA_ACCESS) /*!< permission denied */ \ + X(HG_FAULT, NA_FAULT) /*!< bad address */ \ + X(HG_BUSY, NA_BUSY) /*!< device or resource busy */ \ + X(HG_EXIST, NA_EXIST) /*!< entry already exists */ \ + X(HG_NODEV, NA_NODEV) /*!< no such device */ \ + X(HG_INVALID_ARG, NA_INVALID_ARG) /*!< invalid argument */ \ + X(HG_PROTOCOL_ERROR, NA_PROTOCOL_ERROR) /*!< protocol error */ \ + X(HG_OVERFLOW, NA_OVERFLOW) /*!< value too large */ \ + X(HG_MSGSIZE, NA_MSGSIZE) /*!< message size too long */ \ + X(HG_PROTONOSUPPORT, NA_PROTONOSUPPORT) /*!< protocol not supported */ \ + X(HG_OPNOTSUPPORTED, \ + NA_OPNOTSUPPORTED) /*!< operation not supported on endpoint */ \ + X(HG_ADDRINUSE, NA_ADDRINUSE) /*!< address already in use */ \ + X(HG_ADDRNOTAVAIL, \ + NA_ADDRNOTAVAIL) /*!< cannot assign requested address */ \ + X(HG_HOSTUNREACH, \ + NA_HOSTUNREACH) /*!< cannot reach host during operation */ \ + X(HG_TIMEOUT, NA_TIMEOUT) /*!< operation reached timeout */ \ + X(HG_CANCELED, NA_CANCELED) /*!< operation canceled */ \ + X(HG_IO_ERROR, NA_IO_ERROR) /*!< I/O error */ \ + X(HG_CHECKSUM_ERROR, HG_NA_ERRNO_OFFSET) /*!< checksum error */ \ + X(HG_NA_ERROR, HG_NA_ERRNO_OFFSET + 1) /*!< generic NA error */ \ + X(HG_OTHER_ERROR, HG_NA_ERRNO_OFFSET + 2) /*!< generic HG error */ \ + X(HG_RETURN_MAX, HG_NA_ERRNO_OFFSET + 3) + +#define X(a, b) a = b, typedef enum hg_return { HG_RETURN_VALUES } hg_return_t; #undef X diff --git a/src/na/na_ofi.c b/src/na/na_ofi.c index e4705801..8e323b7f 100644 --- a/src/na/na_ofi.c +++ b/src/na/na_ofi.c @@ -2169,13 +2169,28 @@ na_ofi_errno_to_na(int rc) case FI_EINTR: ret = NA_INTERRUPT; break; + case FI_EIO: +#if !defined(__APPLE__) + case FI_EREMOTEIO: +#endif + ret = NA_IO_ERROR; + break; case FI_EAGAIN: +#ifdef _WIN32 + case FI_EWOULDBLOCK: +#endif ret = NA_AGAIN; break; case FI_ENOMEM: + case FI_EMFILE: + case FI_ENOSPC: + case FI_ENOBUFS: ret = NA_NOMEM; break; case FI_EACCES: +#if !defined(_WIN32) && !defined(__APPLE__) + case FI_EKEYREJECTED: +#endif ret = NA_ACCESS; break; case FI_EFAULT: @@ -2187,6 +2202,8 @@ na_ofi_errno_to_na(int rc) case FI_ENODEV: ret = NA_NODEV; break; + case FI_E2BIG: + case FI_EBADF: case FI_EINVAL: ret = NA_INVALID_ARG; break; @@ -2197,6 +2214,7 @@ na_ofi_errno_to_na(int rc) ret = NA_MSGSIZE; break; case FI_ENOPROTOOPT: + case FI_ENOSYS: ret = NA_PROTONOSUPPORT; break; case FI_EOPNOTSUPP: @@ -2210,14 +2228,12 @@ na_ofi_errno_to_na(int rc) break; case FI_ENETDOWN: case FI_ENETUNREACH: - case FI_ENOTCONN: case FI_ECONNABORTED: - case FI_ECONNREFUSED: case FI_ECONNRESET: -#ifndef _WIN32 + case FI_ENOTCONN: case FI_ESHUTDOWN: + case FI_ECONNREFUSED: case FI_EHOSTDOWN: -#endif case FI_EHOSTUNREACH: ret = NA_HOSTUNREACH; break; @@ -2227,6 +2243,13 @@ na_ofi_errno_to_na(int rc) case FI_ECANCELED: ret = NA_CANCELED; break; + case FI_ENOMSG: + case FI_ENODATA: + /* In practice the following codes are not errors but treat them as is + * in this routine. */ + case FI_EISCONN: + case FI_EALREADY: + case FI_EINPROGRESS: default: ret = NA_PROTOCOL_ERROR; break; diff --git a/src/na/na_types.h b/src/na/na_types.h index e436f4dd..351087cb 100644 --- a/src/na/na_types.h +++ b/src/na/na_types.h @@ -151,6 +151,7 @@ struct na_protocol_info { X(NA_HOSTUNREACH) /*!< cannot reach host during operation */ \ X(NA_TIMEOUT) /*!< operation reached timeout */ \ X(NA_CANCELED) /*!< operation canceled */ \ + X(NA_IO_ERROR) /*!< I/O error */ \ X(NA_RETURN_MAX) #define X(a) a, diff --git a/src/na/na_ucx.c b/src/na/na_ucx.c index 84eb8b02..8facdd3d 100644 --- a/src/na/na_ucx.c +++ b/src/na/na_ucx.c @@ -1045,7 +1045,6 @@ na_ucs_status_to_na(ucs_status_t status) ret = NA_ADDRNOTAVAIL; break; - case UCS_ERR_SOME_CONNECTS_FAILED: case UCS_ERR_UNREACHABLE: case UCS_ERR_CONNECTION_RESET: case UCS_ERR_NOT_CONNECTED: @@ -1062,8 +1061,12 @@ na_ucs_status_to_na(ucs_status_t status) ret = NA_CANCELED; break; - case UCS_ERR_NO_MESSAGE: + case UCS_ERR_SOME_CONNECTS_FAILED: case UCS_ERR_IO_ERROR: + ret = NA_IO_ERROR; + break; + + case UCS_ERR_NO_MESSAGE: case UCS_ERR_SHMEM_SEGMENT: default: ret = NA_PROTOCOL_ERROR;