Skip to content

Commit

Permalink
core: Remove internally used definitions from public headers
Browse files Browse the repository at this point in the history
Several defines and values should not have been exposed in the
public header files.  Remove or move the definitions into internal
headers.  This removes the chance of possible conflicts with
application definitions and API breakage.

Signed-off-by: Sean Hefty <[email protected]>
  • Loading branch information
shefty committed Oct 5, 2023
1 parent 8ddd37e commit 8a2af9d
Show file tree
Hide file tree
Showing 27 changed files with 131 additions and 131 deletions.
6 changes: 3 additions & 3 deletions fabtests/functional/rdm_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static enum fi_op get_fi_op(char *op)
return FI_MSWAP;
else {
fprintf(stderr, "Not a valid atomic operation\n");
return FI_ATOMIC_OP_LAST;
return OFI_ATOMIC_OP_CNT;
}
}

Expand Down Expand Up @@ -342,7 +342,7 @@ static int run_ops(void)
{
int ret;

for (op_type = FI_MIN; op_type < FI_ATOMIC_OP_LAST; op_type++) {
for (op_type = FI_MIN; op_type < OFI_ATOMIC_OP_CNT; op_type++) {
ret = run_op();
if (ret && ret != -FI_ENOSYS && ret != -FI_EOPNOTSUPP) {
FT_PRINTERR("run_op", ret);
Expand Down Expand Up @@ -464,7 +464,7 @@ int main(int argc, char **argv)
} else {
run_all_ops = 0;
op_type = get_fi_op(optarg);
if (op_type == FI_ATOMIC_OP_LAST) {
if (op_type == OFI_ATOMIC_OP_CNT) {
print_opts_usage(argv[0]);
return EXIT_FAILURE;
}
Expand Down
1 change: 1 addition & 0 deletions fabtests/include/ft_osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#endif

#define OFI_DATATYPE_CNT (FI_UINT128 + 1)
#define OFI_ATOMIC_OP_CNT (FI_MSWAP + 1)

#ifdef HAVE___INT128
typedef __int128 ofi_int128_t;
Expand Down
5 changes: 5 additions & 0 deletions fabtests/include/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ extern "C" {
#define ALIGN(x, a) ALIGN_MASK(x, (typeof(x))(a) - 1)
#define ALIGN_DOWN(x, a) ALIGN((x) - ((a) - 1), (a))

#ifndef container_of
#define container_of(ptr, type, field) \
((type *) ((char *)ptr - offsetof(type, field)))
#endif

#define OFI_MR_BASIC_MAP (FI_MR_ALLOCATED | FI_MR_PROV_KEY | FI_MR_VIRT_ADDR)

/* exit codes must be 0-255 */
Expand Down
2 changes: 1 addition & 1 deletion fabtests/ubertest/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static struct key_t keys[] = {
.str = "op",
.offset = offsetof(struct ft_set, op),
.val_type = VAL_NUM,
.val_size = sizeof(((struct ft_set *)0)->op) / FI_ATOMIC_OP_LAST,
.val_size = sizeof(((struct ft_set *)0)->op) / OFI_ATOMIC_OP_CNT,
},
{
.str = "datatype",
Expand Down
20 changes: 12 additions & 8 deletions fabtests/ubertest/fabtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,18 @@ enum ft_class_function {
x == FT_FUNC_FETCH_ATOMICMSG || \
x == FT_FUNC_COMPARE_ATOMICMSG)

enum {
FT_NAME_MAX = 64
};

struct ft_set {
char node[FI_NAME_MAX];
char service[FI_NAME_MAX];
char prov_name[FI_NAME_MAX];
char node[FT_NAME_MAX];
char service[FT_NAME_MAX];
char prov_name[FT_NAME_MAX];
enum ft_test_type test_type[FT_MAX_TEST];
enum ft_class_function class_function[FT_MAX_FUNCTIONS];
uint64_t msg_flags;
enum fi_op op[FI_ATOMIC_OP_LAST];
enum fi_op op[OFI_ATOMIC_OP_CNT];
enum fi_datatype datatype[OFI_DATATYPE_CNT];
enum fi_ep_type ep_type[FT_MAX_EP_TYPES];
enum fi_av_type av_type[FT_MAX_AV_TYPES];
Expand Down Expand Up @@ -308,10 +312,10 @@ struct ft_info {
enum fi_threading threading;
uint32_t protocol;
uint32_t protocol_version;
char node[FI_NAME_MAX];
char service[FI_NAME_MAX];
char prov_name[FI_NAME_MAX];
char fabric_name[FI_NAME_MAX];
char node[FT_NAME_MAX];
char service[FT_NAME_MAX];
char prov_name[FT_NAME_MAX];
char fabric_name[FT_NAME_MAX];
uint64_t rx_cq_bind_flags;
uint64_t tx_cq_bind_flags;
uint64_t rx_op_flags;
Expand Down
15 changes: 15 additions & 0 deletions include/ofi.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ extern "C" {
FI_VERSION(FI_MAJOR_VERSION * 100 + FI_MINOR_VERSION, \
FI_REVISION_VERSION * 10)

enum {
OFI_NAME_MAX = 64,
OFI_ATOMIC_OP_LAST = FI_MSWAP + 1, /* last pt 2 pt atomic */
OFI_DATATYPE_LAST = FI_LONG_DOUBLE_COMPLEX + 1, /* compatibility */
};

#define OFI_GETINFO_INTERNAL (1ULL << 58)
#define OFI_CORE_PROV_ONLY (1ULL << 59)
#define OFI_GETINFO_HIDDEN (1ULL << 60)
Expand Down Expand Up @@ -132,6 +138,15 @@ extern "C" {
#define OFI_RX_OP_FLAGS \
(FI_COMPLETION | FI_MULTI_RECV)

#ifndef container_of
#define container_of(ptr, type, field) \
((type *) ((char *)ptr - offsetof(type, field)))
#endif

#ifndef count_of
#define count_of(x) \
((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
#endif

#define sizeof_field(type, field) sizeof(((type *)0)->field)

Expand Down
16 changes: 0 additions & 16 deletions include/rdma/fabric.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,10 @@ typedef SSIZE_T ssize_t;
extern "C" {
#endif

#ifndef container_of
#define container_of(ptr, type, field) \
((type *) ((char *)ptr - offsetof(type, field)))
#endif

#ifndef count_of
#define count_of(x) \
((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
#endif

#define FI_MAJOR_VERSION 1
#define FI_MINOR_VERSION 19
#define FI_REVISION_VERSION 0

enum {
FI_PATH_MAX = 256,
FI_NAME_MAX = 64,
FI_VERSION_MAX = 64
};

#define FI_VERSION(major, minor) (((major) << 16) | (minor))
#define FI_MAJOR(version) (version >> 16)
#define FI_MINOR(version) (version & 0xFFFF)
Expand Down
4 changes: 2 additions & 2 deletions include/rdma/fi_cm.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ struct fi_ops_cm {

static inline int fi_setname(fid_t fid, void *addr, size_t addrlen)
{
struct fid_ep *ep = container_of(fid, struct fid_ep, fid);
struct fid_ep *ep = (struct fid_ep *) fid;
return ep->cm->setname(fid, addr, addrlen);
}

static inline int fi_getname(fid_t fid, void *addr, size_t *addrlen)
{
struct fid_ep *ep = container_of(fid, struct fid_ep, fid);
struct fid_ep *ep = (struct fid_ep *) fid;
return ep->cm->getname(fid, addr, addrlen);
}

Expand Down
10 changes: 1 addition & 9 deletions include/rdma/fi_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,7 @@ enum fi_datatype {
FI_DOUBLE_COMPLEX,
FI_LONG_DOUBLE,
FI_LONG_DOUBLE_COMPLEX,
/* End of point to point atomic datatypes */
FI_DATATYPE_LAST,
/*
* enums for 128-bit integer atomics, existing ordering and
* FI_DATATYPE_LAST preserved for compatabilty.
*/
FI_INT128 = FI_DATATYPE_LAST,
FI_INT128,
FI_UINT128,

/* Collective datatypes */
Expand All @@ -243,8 +237,6 @@ enum fi_op {
FI_CSWAP_GE,
FI_CSWAP_GT,
FI_MSWAP,
/* End of point to point atomic ops */
FI_ATOMIC_OP_LAST,

/* Collective datatypes */
FI_NOOP = FI_COLLECTIVE_OFFSET,
Expand Down
8 changes: 4 additions & 4 deletions include/rdma/fi_endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,23 @@ static inline int fi_enable(struct fid_ep *ep)

static inline ssize_t fi_cancel(fid_t fid, void *context)
{
struct fid_ep *ep = container_of(fid, struct fid_ep, fid);
struct fid_ep *ep = (struct fid_ep *) fid;
return ep->ops->cancel(fid, context);
}

static inline int
fi_setopt(fid_t fid, int level, int optname,
const void *optval, size_t optlen)
{
struct fid_ep *ep = container_of(fid, struct fid_ep, fid);
struct fid_ep *ep = (struct fid_ep *) fid;
return ep->ops->setopt(fid, level, optname, optval, optlen);
}

static inline int
fi_getopt(fid_t fid, int level, int optname,
void *optval, size_t *optlen)
{
struct fid_ep *ep = container_of(fid, struct fid_ep, fid);
struct fid_ep *ep = (struct fid_ep *) fid;
return ep->ops->getopt(fid, level, optname, optval, optlen);
}

Expand All @@ -246,7 +246,7 @@ static inline int fi_ep_alias(struct fid_ep *ep, struct fid_ep **alias_ep,
struct fid *fid;
ret = fi_alias(&ep->fid, &fid, flags);
if (!ret)
*alias_ep = container_of(fid, struct fid_ep, fid);
*alias_ep = (struct fid_ep *) fid;
return ret;
}

Expand Down
2 changes: 0 additions & 2 deletions include/rdma/providers/fi_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,13 @@ enum fi_log_subsys {
FI_LOG_EQ,
FI_LOG_MR,
FI_LOG_CNTR,
FI_LOG_SUBSYS_MAX
};

enum fi_log_level {
FI_LOG_WARN,
FI_LOG_TRACE,
FI_LOG_INFO,
FI_LOG_DEBUG,
FI_LOG_MAX
};

int fi_log_enabled(const struct fi_provider *prov, enum fi_log_level level,
Expand Down
2 changes: 0 additions & 2 deletions prov/opx/include/rdma/fi_direct_atomic_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ enum fi_datatype {
FI_DOUBLE_COMPLEX, /* 11 */
FI_LONG_DOUBLE, /* 12 */
FI_LONG_DOUBLE_COMPLEX, /* 13 */
FI_DATATYPE_LAST /* 14 */
};
enum fi_op {
FI_MIN,
Expand All @@ -73,7 +72,6 @@ enum fi_op {
FI_CSWAP_GE,
FI_CSWAP_GT,
FI_MSWAP,
FI_ATOMIC_OP_LAST
};
#endif

Expand Down
4 changes: 2 additions & 2 deletions prov/opx/include/rdma/opx/fi_opx_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ extern "C" {

static inline size_t sizeofdt(const enum fi_datatype datatype)
{
static const size_t sizeofdt[FI_DATATYPE_LAST] = {
static const size_t sizeofdt[OFI_DATATYPE_LAST] = {
sizeof(int8_t), /* FI_INT8 */
sizeof(uint8_t), /* FI_UINT8 */
sizeof(int16_t), /* FI_INT16 */
Expand Down Expand Up @@ -135,7 +135,7 @@ static inline size_t maxcount(const enum fi_datatype datatype, const unsigned is
maxbytes / sizeof(long double), /* FI_LONG_DOUBLE */ \
maxbytes / sizeof(complex long double) /* FI_LONG_DOUBLE_COMPLEX */

static const size_t maxcount[2][2][FI_DATATYPE_LAST] = {
static const size_t maxcount[2][2][OFI_DATATYPE_LAST] = {
{ { /* !compare, !fetch */
INIT_MAXCOUNT_ARRAY(FI_OPX_HFI1_PACKET_MTU) },
{ /* !compare, fetch */
Expand Down
2 changes: 1 addition & 1 deletion prov/opx/include/rdma/opx/fi_opx_rma_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ FI_OPX_RX_ATOMIC_SPECIALIZED_FUNCS_COMPLEX(LONG_DOUBLE_COMPLEX, complex long dou
static inline void fi_opx_rx_atomic_dispatch(const void *buf, void *addr, size_t nbytes, enum fi_datatype dt,
enum fi_op op)
{
static void (*fi_opx_rx_atomic_dispatch_table[FI_DATATYPE_LAST][FI_ATOMIC_OP_LAST])(
static void (*fi_opx_rx_atomic_dispatch_table[OFI_DATATYPE_LAST][OFI_ATOMIC_OP_LAST])(
const void *, void *,
size_t) = { { FI_OPX_RX_ATOMIC_DISPATCH_FUNC_NAMES(INT8) },
{ FI_OPX_RX_ATOMIC_DISPATCH_FUNC_NAMES(UINT8) },
Expand Down
18 changes: 9 additions & 9 deletions prov/opx/src/fi_opx_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static inline int fi_opx_check_atomic(struct fi_opx_ep *opx_ep, enum fi_datatype
default:
return -FI_EINVAL;
}
if (((int)dt >= FI_DATATYPE_LAST) || ((int)dt < 0))
if (((int)dt >= OFI_DATATYPE_LAST) || ((int)dt < 0))
return -FI_EINVAL;

if (!opx_ep)
Expand Down Expand Up @@ -127,7 +127,7 @@ void fi_opx_atomic_op_internal(struct fi_opx_ep *opx_ep,
(FI_COMPLETION | FI_DELIVERY_COMPLETE));
}

assert(dt == FI_VOID || dt < FI_DATATYPE_LAST);
assert(dt == FI_VOID || dt < OFI_DATATYPE_LAST);
union fi_opx_hfi1_deferred_work *work = ofi_buf_alloc(opx_ep->tx->work_pending_pool);
assert(work);
struct fi_opx_hfi1_dput_params *params = &work->dput;
Expand Down Expand Up @@ -224,7 +224,7 @@ size_t fi_opx_atomic_internal(struct fi_opx_ep *opx_ep,
size_t buf_len = count * sizeofdt(datatype);
if(op == FI_ATOMIC_READ) {
assert(!is_compare);
assert(datatype < FI_DATATYPE_LAST);
assert(datatype < OFI_DATATYPE_LAST);
FI_DBG_TRACE(fi_opx_global.prov, FI_LOG_EP_DATA,
"===================================== ATOMIC READ (begin)\n");
struct iovec iov = { (void*)fetch_vaddr, buf_len };
Expand Down Expand Up @@ -1106,7 +1106,7 @@ ssize_t fi_opx_atomic_compwritemsg(struct fid_ep *ep, const struct fi_msg_atomic
int fi_opx_atomic_writevalid(struct fid_ep *ep, enum fi_datatype datatype, enum fi_op op,
size_t *count)
{
static size_t sizeofdt[FI_DATATYPE_LAST] = {
static size_t sizeofdt[OFI_DATATYPE_LAST] = {
sizeof(int8_t), /* FI_INT8 */
sizeof(uint8_t), /* FI_UINT8 */
sizeof(int16_t), /* FI_INT16 */
Expand All @@ -1123,7 +1123,7 @@ int fi_opx_atomic_writevalid(struct fid_ep *ep, enum fi_datatype datatype, enum
sizeof(complex long double) /* FI_LONG_DOUBLE_COMPLEX */
};

if ((op > FI_ATOMIC_WRITE) || (datatype >= FI_DATATYPE_LAST)) {
if ((op > FI_ATOMIC_WRITE) || (datatype >= OFI_DATATYPE_LAST)) {
*count = 0;
errno = FI_EOPNOTSUPP;
return -errno;
Expand All @@ -1137,7 +1137,7 @@ int fi_opx_atomic_writevalid(struct fid_ep *ep, enum fi_datatype datatype, enum
int fi_opx_atomic_readwritevalid(struct fid_ep *ep, enum fi_datatype datatype, enum fi_op op,
size_t *count)
{
static size_t sizeofdt[FI_DATATYPE_LAST] = {
static size_t sizeofdt[OFI_DATATYPE_LAST] = {
sizeof(int8_t), /* FI_INT8 */
sizeof(uint8_t), /* FI_UINT8 */
sizeof(int16_t), /* FI_INT16 */
Expand All @@ -1154,7 +1154,7 @@ int fi_opx_atomic_readwritevalid(struct fid_ep *ep, enum fi_datatype datatype, e
sizeof(complex long double) /* FI_LONG_DOUBLE_COMPLEX */
};

if ((op > FI_ATOMIC_WRITE) || (datatype >= FI_DATATYPE_LAST)) {
if ((op > FI_ATOMIC_WRITE) || (datatype >= OFI_DATATYPE_LAST)) {
*count = 0;
errno = FI_EOPNOTSUPP;
return -errno;
Expand All @@ -1170,7 +1170,7 @@ int fi_opx_atomic_readwritevalid(struct fid_ep *ep, enum fi_datatype datatype, e
int fi_opx_atomic_compwritevalid(struct fid_ep *ep, enum fi_datatype datatype, enum fi_op op,
size_t *count)
{
static size_t sizeofdt[FI_DATATYPE_LAST] = {
static size_t sizeofdt[OFI_DATATYPE_LAST] = {
sizeof(int8_t), /* FI_INT8 */
sizeof(uint8_t), /* FI_UINT8 */
sizeof(int16_t), /* FI_INT16 */
Expand All @@ -1187,7 +1187,7 @@ int fi_opx_atomic_compwritevalid(struct fid_ep *ep, enum fi_datatype datatype, e
sizeof(complex long double) /* FI_LONG_DOUBLE_COMPLEX */
};

if ((op < FI_CSWAP) || (op >= FI_ATOMIC_OP_LAST) || (datatype >= FI_DATATYPE_LAST)) {
if ((op < FI_CSWAP) || (op >= OFI_ATOMIC_OP_LAST) || (datatype >= OFI_DATATYPE_LAST)) {
*count = 0;
errno = FI_EOPNOTSUPP;
return -errno;
Expand Down
6 changes: 3 additions & 3 deletions prov/opx/src/fi_opx_rma.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int fi_opx_readv_internal_intranode(struct fi_opx_hfi1_rx_readv_params *params)
uint64_t op64 = params->op << 40;
uint64_t dt64 = params->dt << 32;
assert(FI_OPX_HFI_DPUT_OPCODE_GET == params->opcode); // double check packet type
assert(params->dt == (FI_VOID - 1) || params->dt < FI_DATATYPE_LAST);
assert(params->dt == (FI_VOID - 1) || params->dt < OFI_DATATYPE_LAST);
tx_hdr->qw[0] = opx_ep->rx->tx.cts.hdr.qw[0] | params->lrh_dlid | (params->lrh_dws << 32);
tx_hdr->qw[1] = opx_ep->rx->tx.cts.hdr.qw[1] | params->bth_rx;
tx_hdr->qw[2] = opx_ep->rx->tx.cts.hdr.qw[2];
Expand All @@ -145,7 +145,7 @@ int fi_opx_do_readv_internal(union fi_opx_hfi1_deferred_work *work)
{
struct fi_opx_hfi1_rx_readv_params *params = &work->readv;
assert(params->niov <= 1); // TODO, support something ... bigger
assert(params->dt == (FI_VOID - 1) || params->dt < FI_DATATYPE_LAST);
assert(params->dt == (FI_VOID - 1) || params->dt < OFI_DATATYPE_LAST);

if (params->is_intranode) { /* compile-time constant expression */
return fi_opx_readv_internal_intranode(params);
Expand Down Expand Up @@ -458,7 +458,7 @@ void fi_opx_get_daos_av_addr_rank(struct fi_opx_ep *opx_ep,
if (cur_av_rank) {
union fi_opx_addr addr;
addr.fi = cur_av_rank->fi_addr;

FI_DBG_TRACE(fi_opx_global.prov, FI_LOG_EP_DATA, "Get av_rank_hashmap[%d] = rank:%d, LID:0x%x, fi:%08lx.\n",
i++, cur_av_rank->key.rank, addr.uid.lid, addr.fi);

Expand Down
Loading

0 comments on commit 8a2af9d

Please sign in to comment.