From d61a2e5115657d6f34c2d370a20a3e70e80de2e8 Mon Sep 17 00:00:00 2001 From: yosefe Date: Thu, 23 Oct 2014 16:20:49 +0300 Subject: [PATCH] Add basic types and functions, initial makefile, and smoke test. --- .gitignore | 2 + Makefile | 33 +++++++++++++++ src/mopsy/tl/base/tl.c | 18 ++++++++ src/mopsy/tl/base/tl.h | 37 ++++++++++++++++ src/mopsy/tl/base/tl_base.h | 84 +++++++++++++++++++++++++++++++++++++ src/mopsy/tl/base/tl_def.h | 25 +++++++++++ src/services/debug/log.h | 31 ++++++++++++++ src/services/sys/compiler.h | 21 ++++++++++ src/services/sys/error.h | 22 ++++++++++ test/test.c | 25 +++++++++++ 10 files changed, 298 insertions(+) create mode 100644 Makefile create mode 100644 src/mopsy/tl/base/tl.c create mode 100644 src/mopsy/tl/base/tl.h create mode 100644 src/mopsy/tl/base/tl_base.h create mode 100644 src/mopsy/tl/base/tl_def.h create mode 100644 src/services/debug/log.h create mode 100644 src/services/sys/compiler.h create mode 100644 src/services/sys/error.h create mode 100644 test/test.c diff --git a/.gitignore b/.gitignore index c703f184acb..f63d6157c42 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .project .cproject .settings +test/test +libmopsy.so diff --git a/Makefile b/Makefile new file mode 100644 index 00000000000..971b617409a --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ + +LIBMOPSY = libmopsy.so +TEST = test/test +CC = gcc +RM = rm -f +CPPFLAGS = -Isrc +CFLAGS = -O3 -g + +LIBMOPSY_HEADERS = \ + src/mopsy/tl/base/tl_base.h \ + src/mopsy/tl/base/tl_def.h \ + src/mopsy/tl/base/tl.h \ + src/services/debug/log.h \ + src/services/sys/compiler.h \ + src/services/sys/error.h \ + +LIBMOPSY_SOURCES = \ + src/mopsy/tl/base/tl.c + +TEST_SOURCES = \ + test/test.c + +all: $(LIBMOPSY) $(TEST) + +clean: + $(RM) $(LIBMOPSY) $(TEST) + +$(LIBMOPSY): $(LIBMOPSY_SOURCES) $(LIBMOPSY_HEADERS) Makefile + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LIBMOPSY_SOURCES) -o $(LIBMOPSY) -shared -fPIC + +$(TEST): $(TEST_SOURCES) $(TEST_HEADERS) $(LIBMOPSY) Makefile + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(TEST_SOURCES) -o $(TEST) $(LIBMOPSY) -Wl,-rpath $(PWD) + \ No newline at end of file diff --git a/src/mopsy/tl/base/tl.c b/src/mopsy/tl/base/tl.c new file mode 100644 index 00000000000..64ee4eef063 --- /dev/null +++ b/src/mopsy/tl/base/tl.c @@ -0,0 +1,18 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED. +* +* $COPYRIGHT$ +* $HEADER$ +*/ + +#include "tl.h" + + +mopsy_status_t mopsy_tl_init(mopsy_tl_context_h *context_p) +{ + return MOPSY_SUCCESS; +} + +void mopsy_tl_cleanup(mopsy_tl_context_h context) +{ +} diff --git a/src/mopsy/tl/base/tl.h b/src/mopsy/tl/base/tl.h new file mode 100644 index 00000000000..520328f1af3 --- /dev/null +++ b/src/mopsy/tl/base/tl.h @@ -0,0 +1,37 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED. +* +* $COPYRIGHT$ +* $HEADER$ +*/ + +#ifndef MOPSY_TL_H_ +#define MOPSY_TL_H_ + + +#include "tl_base.h" + +#include + + +/** + * @ingroup CONTEXT + * @brief Initialize global context. + * + * @param [out] context_p Filled with context handle. + * + * @return Error code. + */ +mopsy_status_t mopsy_tl_init(mopsy_tl_context_h *context_p); + + +/** + * @ingroup CONTEXT + * @brief Destroy global context. + * + * @param [in] context Handle to context. + */ +void mopsy_tl_cleanup(mopsy_tl_context_h context); + + +#endif diff --git a/src/mopsy/tl/base/tl_base.h b/src/mopsy/tl/base/tl_base.h new file mode 100644 index 00000000000..9d75a6cb451 --- /dev/null +++ b/src/mopsy/tl/base/tl_base.h @@ -0,0 +1,84 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED. +* +* $COPYRIGHT$ +* $HEADER$ +*/ + +#ifndef TL_BASE_H_ +#define TL_BASE_H_ + +#include "tl_def.h" + +#include +#include + + +/** + * Communication interface context + */ +typedef struct mopsy_tl_iface { +} mopsy_tl_iface_t; + + +/** + * Remote endpoint + */ +typedef struct mopsy_tl_ep { + mopsy_tl_ops_t *ops; +} mopsy_tl_ep_t; + + +/** + * Send completion callback. + */ +typedef void (*mopsy_tl_completion_cb_t)(mopsy_tl_req_h req, + mopsy_status_t status); + + +/** + * Interface attributes: capabilities and limitations. + */ +typedef struct mopsy_tl_iface_attr { + size_t max_short; + size_t max_bcopy; + size_t max_zcopy; + size_t iface_addr_len; + size_t ep_addr_len; + unsigned flags; +} mopsy_tl_iface_attr_t; + + +/** + * Transport operations. + */ +struct mopsy_tl_ops { + + mopsy_status_t (*iface_open)(mopsy_tl_context_h *context, mopsy_tl_iface_h *iface_p); + void (*iface_close)(mopsy_tl_iface_h iface); + + mopsy_status_t (*iface_query)(mopsy_tl_iface_h iface, + mopsy_tl_iface_attr_t *iface_attr); + mopsy_status_t (*iface_get_address)(mopsy_tl_iface_h iface, + mopsy_tl_iface_addr_t *iface_addr); + + mopsy_status_t (*ep_create)(mopsy_tl_ep_h *ep_p); + void (*ep_destroy)(mopsy_tl_ep_h ep); + + mopsy_status_t (*ep_get_address)(mopsy_tl_ep_h *ep, + mopsy_tl_ep_addr_t *ep_addr); + mopsy_status_t (*ep_connect_to_iface)(mopsy_tl_iface_addr_t *iface_addr); + mopsy_status_t (*ep_connect_to_ep)(mopsy_tl_iface_addr_t *iface_addr, + mopsy_tl_ep_addr_t *ep_addr); + + mopsy_status_t (*ep_put_short)(mopsy_tl_ep_h ep, void *buffer, unsigned length, + mopsy_tl_rkey_t rkey, mopsy_tl_req_h *req_p, + mopsy_tl_completion_cb_t cb); + + mopsy_status_t (*iface_flush)(mopsy_tl_iface_h iface, mopsy_tl_req_h *req_p, + mopsy_tl_completion_cb_t cb); + +}; + + +#endif diff --git a/src/mopsy/tl/base/tl_def.h b/src/mopsy/tl/base/tl_def.h new file mode 100644 index 00000000000..20a407d0a66 --- /dev/null +++ b/src/mopsy/tl/base/tl_def.h @@ -0,0 +1,25 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED. +* +* $COPYRIGHT$ +* $HEADER$ +*/ + +#ifndef TL_DEF_H_ +#define TL_DEF_H_ + +#include + + +typedef struct mopsy_tl_context *mopsy_tl_context_h; +typedef struct mopsy_tl_iface *mopsy_tl_iface_h; +typedef struct mopsy_tl_iface_addr mopsy_tl_iface_addr_t; +typedef struct mopsy_tl_ep *mopsy_tl_ep_h; +typedef struct mopsy_tl_ep_addr mopsy_tl_ep_addr_t; +typedef struct mopsy_tl_ops mopsy_tl_ops_t; +typedef uint64_t mopsy_tl_lkey_t; +typedef uint64_t mopsy_tl_rkey_t; +typedef struct mopsy_tl_req *mopsy_tl_req_h; + + +#endif diff --git a/src/services/debug/log.h b/src/services/debug/log.h new file mode 100644 index 00000000000..a2b8a8bc4fa --- /dev/null +++ b/src/services/debug/log.h @@ -0,0 +1,31 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED. +* +* $COPYRIGHT$ +* $HEADER$ +*/ + +#ifndef _SYS_LOG_H_ +#define _SYS_LOG_H_ + + +/** + * Logging levels + */ +typedef enum { + MOPSY_LOG_LEVEL_FATAL, + MOPSY_LOG_LEVEL_ERROR, + MOPSY_LOG_LEVEL_WARN, + MOPSY_LOG_LEVEL_INFO, + MOPSY_LOG_LEVEL_DEBUG, + MOPSY_LOG_LEVEL_TRACE, + MOPSY_LOG_LEVEL_TRACE_REQ, + MOPSY_LOG_LEVEL_TRACE_DATA, + MOPSY_LOG_LEVEL_TRACE_ASYNC, + MOPSY_LOG_LEVEL_TRACE_FUNC, + MOPSY_LOG_LEVEL_TRACE_POLL, + MOPSY_LOG_LEVEL_LAST +} mopsy_log_level_t; + + +#endif diff --git a/src/services/sys/compiler.h b/src/services/sys/compiler.h new file mode 100644 index 00000000000..319825f2569 --- /dev/null +++ b/src/services/sys/compiler.h @@ -0,0 +1,21 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED. +* +* $COPYRIGHT$ +* $HEADER$ +*/ + +#ifndef _SYS_COMPILER_H_ +#define _SYS_COMPILER_H_ + + +#ifdef __cplusplus +# define BEGIN_C_DECLS extern "C" { +# define END_C_DECLS } +#else +# define BEGIN_C_DECLS +# define END_C_DECLS +#endif + + +#endif diff --git a/src/services/sys/error.h b/src/services/sys/error.h new file mode 100644 index 00000000000..393411edefd --- /dev/null +++ b/src/services/sys/error.h @@ -0,0 +1,22 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED. +* +* $COPYRIGHT$ +* $HEADER$ +*/ + +#ifndef _SYS_ERROR_H_ +#define _SYS_ERROR_H_ + + +/** + * Status codes + */ +typedef enum { + MOPSY_SUCCESS = 0, + MOPSY_ERR_INPROGRESS = 1, + MOPSY_ERR_INVALID_PARAM = -1 +} mopsy_status_t; + + +#endif diff --git a/test/test.c b/test/test.c new file mode 100644 index 00000000000..b06a5c9c8cc --- /dev/null +++ b/test/test.c @@ -0,0 +1,25 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED. +* +* $COPYRIGHT$ +* $HEADER$ +*/ + +#include +#include + +int main(int argc, char **argv) +{ + mopsy_status_t status; + mopsy_tl_context_h context; + + status = mopsy_tl_init(&context); + if (status != MOPSY_SUCCESS) { + fprintf(stderr, "mopsy_tl_init() failed\n"); + return -1; + } + + mopsy_tl_cleanup(context); + return 0; +} +