Skip to content

Commit

Permalink
Add basic types and functions, initial makefile, and smoke test.
Browse files Browse the repository at this point in the history
  • Loading branch information
yosefe committed Oct 23, 2014
1 parent 20bf38e commit 486b253
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.project
.cproject
.settings
test/test
libmopsy.so
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)

18 changes: 18 additions & 0 deletions src/mopsy/tl/base/tl.c
Original file line number Diff line number Diff line change
@@ -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)
{
}
37 changes: 37 additions & 0 deletions src/mopsy/tl/base/tl.h
Original file line number Diff line number Diff line change
@@ -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 <services/sys/error.h>


/**
* @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
84 changes: 84 additions & 0 deletions src/mopsy/tl/base/tl_base.h
Original file line number Diff line number Diff line change
@@ -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 <services/sys/error.h>
#include <stddef.h>


/**
* 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
25 changes: 25 additions & 0 deletions src/mopsy/tl/base/tl_def.h
Original file line number Diff line number Diff line change
@@ -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 <stdint.h>


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
31 changes: 31 additions & 0 deletions src/services/debug/log.h
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions src/services/sys/compiler.h
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions src/services/sys/error.h
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions test/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED.
*
* $COPYRIGHT$
* $HEADER$
*/

#include <mopsy/tl/base/tl.h>
#include <stdio.h>


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;
}

0 comments on commit 486b253

Please sign in to comment.