module/sock_posix: add a map file and remove spdk prefix.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Change-Id: I593c0c1500b2175c4d3dc8ac19289f854895b00f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2356
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Seth Howell 2020-05-10 12:54:24 -07:00 committed by Tomasz Zawadzki
parent 5ad576336a
commit 0bc117a470
3 changed files with 66 additions and 64 deletions

View File

@ -41,4 +41,6 @@ SO_SUFFIX := $(SO_VER).$(SO_MINOR)
LIBNAME = sock_posix LIBNAME = sock_posix
C_SRCS = posix.c C_SRCS = posix.c
SPDK_MAP_FILE = $(SPDK_ROOT_DIR)/mk/spdk_blank.map
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk

View File

@ -111,7 +111,7 @@ get_addr_str(struct sockaddr *sa, char *host, size_t hlen)
#define __posix_group_impl(group) (struct spdk_posix_sock_group_impl *)group #define __posix_group_impl(group) (struct spdk_posix_sock_group_impl *)group
static int static int
spdk_posix_sock_getaddr(struct spdk_sock *_sock, char *saddr, int slen, uint16_t *sport, posix_sock_getaddr(struct spdk_sock *_sock, char *saddr, int slen, uint16_t *sport,
char *caddr, int clen, uint16_t *cport) char *caddr, int clen, uint16_t *cport)
{ {
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
@ -181,13 +181,13 @@ spdk_posix_sock_getaddr(struct spdk_sock *_sock, char *saddr, int slen, uint16_t
return 0; return 0;
} }
enum spdk_posix_sock_create_type { enum posix_sock_create_type {
SPDK_SOCK_CREATE_LISTEN, SPDK_SOCK_CREATE_LISTEN,
SPDK_SOCK_CREATE_CONNECT, SPDK_SOCK_CREATE_CONNECT,
}; };
static int static int
spdk_posix_sock_alloc_pipe(struct spdk_posix_sock *sock, int sz) posix_sock_alloc_pipe(struct spdk_posix_sock *sock, int sz)
{ {
uint8_t *new_buf; uint8_t *new_buf;
struct spdk_pipe *new_pipe; struct spdk_pipe *new_pipe;
@ -251,14 +251,14 @@ spdk_posix_sock_alloc_pipe(struct spdk_posix_sock *sock, int sz)
} }
static int static int
spdk_posix_sock_set_recvbuf(struct spdk_sock *_sock, int sz) posix_sock_set_recvbuf(struct spdk_sock *_sock, int sz)
{ {
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
int rc; int rc;
assert(sock != NULL); assert(sock != NULL);
rc = spdk_posix_sock_alloc_pipe(sock, sz); rc = posix_sock_alloc_pipe(sock, sz);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -277,7 +277,7 @@ spdk_posix_sock_set_recvbuf(struct spdk_sock *_sock, int sz)
} }
static int static int
spdk_posix_sock_set_sendbuf(struct spdk_sock *_sock, int sz) posix_sock_set_sendbuf(struct spdk_sock *_sock, int sz)
{ {
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
int rc; int rc;
@ -297,7 +297,7 @@ spdk_posix_sock_set_sendbuf(struct spdk_sock *_sock, int sz)
} }
static struct spdk_posix_sock * static struct spdk_posix_sock *
_spdk_posix_sock_alloc(int fd, bool enable_zero_copy) posix_sock_alloc(int fd, bool enable_zero_copy)
{ {
struct spdk_posix_sock *sock; struct spdk_posix_sock *sock;
#ifdef SPDK_ZEROCOPY #ifdef SPDK_ZEROCOPY
@ -379,8 +379,8 @@ end:
} }
static struct spdk_sock * static struct spdk_sock *
spdk_posix_sock_create(const char *ip, int port, posix_sock_create(const char *ip, int port,
enum spdk_posix_sock_create_type type, enum posix_sock_create_type type,
struct spdk_sock_opts *opts) struct spdk_sock_opts *opts)
{ {
struct spdk_posix_sock *sock; struct spdk_posix_sock *sock;
@ -537,7 +537,7 @@ retry:
enable_zero_copy = false; enable_zero_copy = false;
} }
sock = _spdk_posix_sock_alloc(fd, enable_zero_copy); sock = posix_sock_alloc(fd, enable_zero_copy);
if (sock == NULL) { if (sock == NULL) {
SPDK_ERRLOG("sock allocation failed\n"); SPDK_ERRLOG("sock allocation failed\n");
close(fd); close(fd);
@ -548,19 +548,19 @@ retry:
} }
static struct spdk_sock * static struct spdk_sock *
spdk_posix_sock_listen(const char *ip, int port, struct spdk_sock_opts *opts) posix_sock_listen(const char *ip, int port, struct spdk_sock_opts *opts)
{ {
return spdk_posix_sock_create(ip, port, SPDK_SOCK_CREATE_LISTEN, opts); return posix_sock_create(ip, port, SPDK_SOCK_CREATE_LISTEN, opts);
} }
static struct spdk_sock * static struct spdk_sock *
spdk_posix_sock_connect(const char *ip, int port, struct spdk_sock_opts *opts) posix_sock_connect(const char *ip, int port, struct spdk_sock_opts *opts)
{ {
return spdk_posix_sock_create(ip, port, SPDK_SOCK_CREATE_CONNECT, opts); return posix_sock_create(ip, port, SPDK_SOCK_CREATE_CONNECT, opts);
} }
static struct spdk_sock * static struct spdk_sock *
spdk_posix_sock_accept(struct spdk_sock *_sock) posix_sock_accept(struct spdk_sock *_sock)
{ {
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
struct sockaddr_storage sa; struct sockaddr_storage sa;
@ -601,7 +601,7 @@ spdk_posix_sock_accept(struct spdk_sock *_sock)
#endif #endif
/* Inherit the zero copy feature from the listen socket */ /* Inherit the zero copy feature from the listen socket */
new_sock = _spdk_posix_sock_alloc(fd, sock->zcopy); new_sock = posix_sock_alloc(fd, sock->zcopy);
if (new_sock == NULL) { if (new_sock == NULL) {
close(fd); close(fd);
return NULL; return NULL;
@ -611,7 +611,7 @@ spdk_posix_sock_accept(struct spdk_sock *_sock)
} }
static int static int
spdk_posix_sock_close(struct spdk_sock *_sock) posix_sock_close(struct spdk_sock *_sock)
{ {
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
@ -834,13 +834,13 @@ _sock_flush(struct spdk_sock *sock)
} }
static int static int
spdk_posix_sock_flush(struct spdk_sock *_sock) posix_sock_flush(struct spdk_sock *_sock)
{ {
return _sock_flush(_sock); return _sock_flush(_sock);
} }
static ssize_t static ssize_t
spdk_posix_sock_recv_from_pipe(struct spdk_posix_sock *sock, struct iovec *diov, int diovcnt) posix_sock_recv_from_pipe(struct spdk_posix_sock *sock, struct iovec *diov, int diovcnt)
{ {
struct iovec siov[2]; struct iovec siov[2];
int sbytes; int sbytes;
@ -877,7 +877,7 @@ spdk_posix_sock_recv_from_pipe(struct spdk_posix_sock *sock, struct iovec *diov,
} }
static inline ssize_t static inline ssize_t
_spdk_posix_sock_read(struct spdk_posix_sock *sock) posix_sock_read(struct spdk_posix_sock *sock)
{ {
struct iovec iov[2]; struct iovec iov[2];
int bytes; int bytes;
@ -901,7 +901,7 @@ _spdk_posix_sock_read(struct spdk_posix_sock *sock)
} }
static ssize_t static ssize_t
spdk_posix_sock_readv(struct spdk_sock *_sock, struct iovec *iov, int iovcnt) posix_sock_readv(struct spdk_sock *_sock, struct iovec *iov, int iovcnt)
{ {
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
int rc, i; int rc, i;
@ -924,28 +924,28 @@ spdk_posix_sock_readv(struct spdk_sock *_sock, struct iovec *iov, int iovcnt)
} }
/* Otherwise, do a big read into our pipe */ /* Otherwise, do a big read into our pipe */
rc = _spdk_posix_sock_read(sock); rc = posix_sock_read(sock);
if (rc <= 0) { if (rc <= 0) {
return rc; return rc;
} }
} }
return spdk_posix_sock_recv_from_pipe(sock, iov, iovcnt); return posix_sock_recv_from_pipe(sock, iov, iovcnt);
} }
static ssize_t static ssize_t
spdk_posix_sock_recv(struct spdk_sock *sock, void *buf, size_t len) posix_sock_recv(struct spdk_sock *sock, void *buf, size_t len)
{ {
struct iovec iov[1]; struct iovec iov[1];
iov[0].iov_base = buf; iov[0].iov_base = buf;
iov[0].iov_len = len; iov[0].iov_len = len;
return spdk_posix_sock_readv(sock, iov, 1); return posix_sock_readv(sock, iov, 1);
} }
static ssize_t static ssize_t
spdk_posix_sock_writev(struct spdk_sock *_sock, struct iovec *iov, int iovcnt) posix_sock_writev(struct spdk_sock *_sock, struct iovec *iov, int iovcnt)
{ {
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
int rc; int rc;
@ -967,7 +967,7 @@ spdk_posix_sock_writev(struct spdk_sock *_sock, struct iovec *iov, int iovcnt)
} }
static void static void
spdk_posix_sock_writev_async(struct spdk_sock *sock, struct spdk_sock_request *req) posix_sock_writev_async(struct spdk_sock *sock, struct spdk_sock_request *req)
{ {
int rc; int rc;
@ -983,7 +983,7 @@ spdk_posix_sock_writev_async(struct spdk_sock *sock, struct spdk_sock_request *r
} }
static int static int
spdk_posix_sock_set_recvlowat(struct spdk_sock *_sock, int nbytes) posix_sock_set_recvlowat(struct spdk_sock *_sock, int nbytes)
{ {
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
int val; int val;
@ -1000,7 +1000,7 @@ spdk_posix_sock_set_recvlowat(struct spdk_sock *_sock, int nbytes)
} }
static bool static bool
spdk_posix_sock_is_ipv6(struct spdk_sock *_sock) posix_sock_is_ipv6(struct spdk_sock *_sock)
{ {
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
struct sockaddr_storage sa; struct sockaddr_storage sa;
@ -1021,7 +1021,7 @@ spdk_posix_sock_is_ipv6(struct spdk_sock *_sock)
} }
static bool static bool
spdk_posix_sock_is_ipv4(struct spdk_sock *_sock) posix_sock_is_ipv4(struct spdk_sock *_sock)
{ {
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
struct sockaddr_storage sa; struct sockaddr_storage sa;
@ -1042,7 +1042,7 @@ spdk_posix_sock_is_ipv4(struct spdk_sock *_sock)
} }
static bool static bool
spdk_posix_sock_is_connected(struct spdk_sock *_sock) posix_sock_is_connected(struct spdk_sock *_sock)
{ {
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
uint8_t byte; uint8_t byte;
@ -1065,7 +1065,7 @@ spdk_posix_sock_is_connected(struct spdk_sock *_sock)
} }
static int static int
spdk_posix_sock_get_placement_id(struct spdk_sock *_sock, int *placement_id) posix_sock_get_placement_id(struct spdk_sock *_sock, int *placement_id)
{ {
int rc = -1; int rc = -1;
@ -1083,7 +1083,7 @@ spdk_posix_sock_get_placement_id(struct spdk_sock *_sock, int *placement_id)
} }
static struct spdk_sock_group_impl * static struct spdk_sock_group_impl *
spdk_posix_sock_group_impl_create(void) posix_sock_group_impl_create(void)
{ {
struct spdk_posix_sock_group_impl *group_impl; struct spdk_posix_sock_group_impl *group_impl;
int fd; int fd;
@ -1111,7 +1111,7 @@ spdk_posix_sock_group_impl_create(void)
} }
static int static int
spdk_posix_sock_group_impl_add_sock(struct spdk_sock_group_impl *_group, struct spdk_sock *_sock) posix_sock_group_impl_add_sock(struct spdk_sock_group_impl *_group, struct spdk_sock *_sock)
{ {
struct spdk_posix_sock_group_impl *group = __posix_group_impl(_group); struct spdk_posix_sock_group_impl *group = __posix_group_impl(_group);
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
@ -1147,7 +1147,7 @@ spdk_posix_sock_group_impl_add_sock(struct spdk_sock_group_impl *_group, struct
} }
static int static int
spdk_posix_sock_group_impl_remove_sock(struct spdk_sock_group_impl *_group, struct spdk_sock *_sock) posix_sock_group_impl_remove_sock(struct spdk_sock_group_impl *_group, struct spdk_sock *_sock)
{ {
struct spdk_posix_sock_group_impl *group = __posix_group_impl(_group); struct spdk_posix_sock_group_impl *group = __posix_group_impl(_group);
struct spdk_posix_sock *sock = __posix_sock(_sock); struct spdk_posix_sock *sock = __posix_sock(_sock);
@ -1185,7 +1185,7 @@ spdk_posix_sock_group_impl_remove_sock(struct spdk_sock_group_impl *_group, stru
} }
static int static int
spdk_posix_sock_group_impl_poll(struct spdk_sock_group_impl *_group, int max_events, posix_sock_group_impl_poll(struct spdk_sock_group_impl *_group, int max_events,
struct spdk_sock **socks) struct spdk_sock **socks)
{ {
struct spdk_posix_sock_group_impl *group = __posix_group_impl(_group); struct spdk_posix_sock_group_impl *group = __posix_group_impl(_group);
@ -1280,7 +1280,7 @@ spdk_posix_sock_group_impl_poll(struct spdk_sock_group_impl *_group, int max_eve
} }
static int static int
spdk_posix_sock_group_impl_close(struct spdk_sock_group_impl *_group) posix_sock_group_impl_close(struct spdk_sock_group_impl *_group)
{ {
struct spdk_posix_sock_group_impl *group = __posix_group_impl(_group); struct spdk_posix_sock_group_impl *group = __posix_group_impl(_group);
int rc; int rc;
@ -1292,28 +1292,28 @@ spdk_posix_sock_group_impl_close(struct spdk_sock_group_impl *_group)
static struct spdk_net_impl g_posix_net_impl = { static struct spdk_net_impl g_posix_net_impl = {
.name = "posix", .name = "posix",
.getaddr = spdk_posix_sock_getaddr, .getaddr = posix_sock_getaddr,
.connect = spdk_posix_sock_connect, .connect = posix_sock_connect,
.listen = spdk_posix_sock_listen, .listen = posix_sock_listen,
.accept = spdk_posix_sock_accept, .accept = posix_sock_accept,
.close = spdk_posix_sock_close, .close = posix_sock_close,
.recv = spdk_posix_sock_recv, .recv = posix_sock_recv,
.readv = spdk_posix_sock_readv, .readv = posix_sock_readv,
.writev = spdk_posix_sock_writev, .writev = posix_sock_writev,
.writev_async = spdk_posix_sock_writev_async, .writev_async = posix_sock_writev_async,
.flush = spdk_posix_sock_flush, .flush = posix_sock_flush,
.set_recvlowat = spdk_posix_sock_set_recvlowat, .set_recvlowat = posix_sock_set_recvlowat,
.set_recvbuf = spdk_posix_sock_set_recvbuf, .set_recvbuf = posix_sock_set_recvbuf,
.set_sendbuf = spdk_posix_sock_set_sendbuf, .set_sendbuf = posix_sock_set_sendbuf,
.is_ipv6 = spdk_posix_sock_is_ipv6, .is_ipv6 = posix_sock_is_ipv6,
.is_ipv4 = spdk_posix_sock_is_ipv4, .is_ipv4 = posix_sock_is_ipv4,
.is_connected = spdk_posix_sock_is_connected, .is_connected = posix_sock_is_connected,
.get_placement_id = spdk_posix_sock_get_placement_id, .get_placement_id = posix_sock_get_placement_id,
.group_impl_create = spdk_posix_sock_group_impl_create, .group_impl_create = posix_sock_group_impl_create,
.group_impl_add_sock = spdk_posix_sock_group_impl_add_sock, .group_impl_add_sock = posix_sock_group_impl_add_sock,
.group_impl_remove_sock = spdk_posix_sock_group_impl_remove_sock, .group_impl_remove_sock = posix_sock_group_impl_remove_sock,
.group_impl_poll = spdk_posix_sock_group_impl_poll, .group_impl_poll = posix_sock_group_impl_poll,
.group_impl_close = spdk_posix_sock_group_impl_close, .group_impl_close = posix_sock_group_impl_close,
}; };
SPDK_NET_IMPL_REGISTER(posix, &g_posix_net_impl, DEFAULT_SOCK_PRIORITY); SPDK_NET_IMPL_REGISTER(posix, &g_posix_net_impl, DEFAULT_SOCK_PRIORITY);

View File

@ -804,7 +804,7 @@ _sock_close(const char *ip, int port, char *impl_name)
} }
static void static void
posix_sock_close(void) _posix_sock_close(void)
{ {
_sock_close("127.0.0.1", UT_PORT, "posix"); _sock_close("127.0.0.1", UT_PORT, "posix");
} }
@ -859,7 +859,7 @@ main(int argc, char **argv)
CU_ADD_TEST(suite, posix_sock_group); CU_ADD_TEST(suite, posix_sock_group);
CU_ADD_TEST(suite, ut_sock_group); CU_ADD_TEST(suite, ut_sock_group);
CU_ADD_TEST(suite, posix_sock_group_fairness); CU_ADD_TEST(suite, posix_sock_group_fairness);
CU_ADD_TEST(suite, posix_sock_close); CU_ADD_TEST(suite, _posix_sock_close);
CU_ADD_TEST(suite, sock_get_default_opts); CU_ADD_TEST(suite, sock_get_default_opts);
CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_set_mode(CU_BRM_VERBOSE);