sock: update spdk_sock_group_add_sock
And also add spdk_sock_group_get_ctx function Change-Id: I2a2a58b0588ff7d99d3538ea0a633a3b8c7a234b Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454538 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
This commit is contained in:
parent
8bb174f87d
commit
b09bd95ad3
@ -77,6 +77,9 @@ spdk_sock_group_add_sock so that a set of sockets can be polled more efficiently
|
||||
For some network devices, it is optimal to assign particular sockets to specific
|
||||
sock groups. This API is intended to provide the user with that information.
|
||||
|
||||
spdk_sock_group_get_ctx() was added to return the context of the spdk_sock_group.
|
||||
spdk_sock_group_create() is updated to allow input the user provided ctx.
|
||||
|
||||
## v19.04:
|
||||
|
||||
### nvme
|
||||
|
@ -358,7 +358,7 @@ hello_sock_listen(struct hello_context_t *ctx)
|
||||
/*
|
||||
* Create sock group for server socket
|
||||
*/
|
||||
ctx->group = spdk_sock_group_create();
|
||||
ctx->group = spdk_sock_group_create(NULL);
|
||||
|
||||
g_is_running = true;
|
||||
|
||||
|
@ -195,11 +195,21 @@ bool spdk_sock_is_ipv4(struct spdk_sock *sock);
|
||||
typedef void (*spdk_sock_cb)(void *arg, struct spdk_sock_group *group, struct spdk_sock *sock);
|
||||
|
||||
/**
|
||||
* Create a new socket group.
|
||||
* Create a new socket group with user provided pointer
|
||||
*
|
||||
* \param ctx the context provided by user.
|
||||
* \return a pointer to the created group on success, or NULL on failure.
|
||||
*/
|
||||
struct spdk_sock_group *spdk_sock_group_create(void);
|
||||
struct spdk_sock_group *spdk_sock_group_create(void *ctx);
|
||||
|
||||
/**
|
||||
* Get the ctx of the sock group
|
||||
*
|
||||
* \param sock_group Socket group.
|
||||
* \return a pointer which is ctx of the sock_group.
|
||||
*/
|
||||
void *spdk_sock_group_get_ctx(struct spdk_sock_group *sock_group);
|
||||
|
||||
|
||||
/**
|
||||
* Add a socket to the group.
|
||||
|
@ -57,6 +57,7 @@ struct spdk_sock {
|
||||
|
||||
struct spdk_sock_group {
|
||||
STAILQ_HEAD(, spdk_sock_group_impl) group_impls;
|
||||
void *ctx;
|
||||
};
|
||||
|
||||
struct spdk_sock_group_impl {
|
||||
|
@ -1203,7 +1203,7 @@ iscsi_poll_group_create(void *ctx)
|
||||
pg->core = spdk_env_get_current_core();
|
||||
|
||||
STAILQ_INIT(&pg->connections);
|
||||
pg->sock_group = spdk_sock_group_create();
|
||||
pg->sock_group = spdk_sock_group_create(NULL);
|
||||
assert(pg->sock_group != NULL);
|
||||
|
||||
pg->poller = spdk_poller_register(iscsi_poll_group_poll, pg, 0);
|
||||
|
@ -1161,7 +1161,7 @@ spdk_nvmf_tcp_poll_group_create(struct spdk_nvmf_transport *transport)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tgroup->sock_group = spdk_sock_group_create();
|
||||
tgroup->sock_group = spdk_sock_group_create(NULL);
|
||||
if (!tgroup->sock_group) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ spdk_sock_is_ipv4(struct spdk_sock *sock)
|
||||
}
|
||||
|
||||
struct spdk_sock_group *
|
||||
spdk_sock_group_create(void)
|
||||
spdk_sock_group_create(void *ctx)
|
||||
{
|
||||
struct spdk_net_impl *impl = NULL;
|
||||
struct spdk_sock_group *group;
|
||||
@ -321,9 +321,20 @@ spdk_sock_group_create(void)
|
||||
}
|
||||
}
|
||||
|
||||
group->ctx = ctx;
|
||||
return group;
|
||||
}
|
||||
|
||||
void *
|
||||
spdk_sock_group_get_ctx(struct spdk_sock_group *group)
|
||||
{
|
||||
if (group == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return group->ctx;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_sock_group_add_sock(struct spdk_sock_group *group, struct spdk_sock *sock,
|
||||
spdk_sock_cb cb_fn, void *cb_arg)
|
||||
|
@ -50,7 +50,7 @@ DEFINE_STUB(spdk_sock_set_recvbuf, int, (struct spdk_sock *sock, int sz), 0);
|
||||
DEFINE_STUB(spdk_sock_set_sendbuf, int, (struct spdk_sock *sock, int sz), 0);
|
||||
DEFINE_STUB(spdk_sock_is_ipv6, bool, (struct spdk_sock *sock), false);
|
||||
DEFINE_STUB(spdk_sock_is_ipv4, bool, (struct spdk_sock *sock), true);
|
||||
DEFINE_STUB(spdk_sock_group_create, struct spdk_sock_group *, (void), NULL);
|
||||
DEFINE_STUB(spdk_sock_group_create, struct spdk_sock_group *, (void *ctx), NULL);
|
||||
DEFINE_STUB(spdk_sock_group_add_sock, int, (struct spdk_sock_group *group, struct spdk_sock *sock,
|
||||
spdk_sock_cb cb_fn, void *cb_arg), 0);
|
||||
DEFINE_STUB(spdk_sock_group_remove_sock, int, (struct spdk_sock_group *group,
|
||||
|
@ -469,7 +469,7 @@ _sock_group(const char *ip, int port)
|
||||
server_sock = spdk_sock_accept(listen_sock);
|
||||
SPDK_CU_ASSERT_FATAL(server_sock != NULL);
|
||||
|
||||
group = spdk_sock_group_create();
|
||||
group = spdk_sock_group_create(NULL);
|
||||
SPDK_CU_ASSERT_FATAL(group != NULL);
|
||||
|
||||
/* pass null cb_fn */
|
||||
@ -581,7 +581,7 @@ posix_sock_group_fairness(void)
|
||||
listen_sock = spdk_sock_listen("127.0.0.1", UT_PORT);
|
||||
SPDK_CU_ASSERT_FATAL(listen_sock != NULL);
|
||||
|
||||
group = spdk_sock_group_create();
|
||||
group = spdk_sock_group_create(NULL);
|
||||
SPDK_CU_ASSERT_FATAL(group != NULL);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user