nvmf: add spdk_nvmf_transport_get_optimal_poll_group

Add the optimal poll group get function.

Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Change-Id: Ia9e57c6924a6563d79269cf535814883e83698cd
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454549
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Ziye Yang 2019-05-15 21:53:39 +08:00 committed by Changpeng Liu
parent 09ef0593d4
commit 960460f0d1
4 changed files with 46 additions and 2 deletions

View File

@ -1169,7 +1169,7 @@ spdk_nvmf_tcp_poll_group_create(struct spdk_nvmf_transport *transport)
return NULL;
}
tgroup->sock_group = spdk_sock_group_create(NULL);
tgroup->sock_group = spdk_sock_group_create(&tgroup->group);
if (!tgroup->sock_group) {
goto cleanup;
}
@ -1184,6 +1184,22 @@ cleanup:
return NULL;
}
static struct spdk_nvmf_transport_poll_group *
spdk_nvmf_tcp_get_optimal_poll_group(struct spdk_nvmf_qpair *qpair)
{
struct spdk_nvmf_tcp_qpair *tqpair;
struct spdk_sock_group *group = NULL;
int rc;
tqpair = SPDK_CONTAINEROF(qpair, struct spdk_nvmf_tcp_qpair, qpair);
rc = spdk_sock_get_optimal_sock_group(tqpair->sock, &group);
if (!rc && group != NULL) {
return spdk_sock_group_get_ctx(group);
}
return NULL;
}
static void
spdk_nvmf_tcp_poll_group_destroy(struct spdk_nvmf_transport_poll_group *group)
{
@ -2857,6 +2873,7 @@ const struct spdk_nvmf_transport_ops spdk_nvmf_transport_tcp = {
.listener_discover = spdk_nvmf_tcp_discover,
.poll_group_create = spdk_nvmf_tcp_poll_group_create,
.get_optimal_poll_group = spdk_nvmf_tcp_get_optimal_poll_group,
.poll_group_destroy = spdk_nvmf_tcp_poll_group_destroy,
.poll_group_add = spdk_nvmf_tcp_poll_group_add,
.poll_group_remove = spdk_nvmf_tcp_poll_group_remove,

View File

@ -211,6 +211,17 @@ spdk_nvmf_transport_poll_group_create(struct spdk_nvmf_transport *transport)
return group;
}
struct spdk_nvmf_transport_poll_group *
spdk_nvmf_transport_get_optimal_poll_group(struct spdk_nvmf_transport *transport,
struct spdk_nvmf_qpair *qpair)
{
if (transport->ops->get_optimal_poll_group) {
return transport->ops->get_optimal_poll_group(qpair);
} else {
return NULL;
}
}
void
spdk_nvmf_transport_poll_group_destroy(struct spdk_nvmf_transport_poll_group *group)
{

View File

@ -101,6 +101,11 @@ struct spdk_nvmf_transport_ops {
*/
struct spdk_nvmf_transport_poll_group *(*poll_group_create)(struct spdk_nvmf_transport *transport);
/**
* Get the polling group of the queue pair optimal for the specific transport
*/
struct spdk_nvmf_transport_poll_group *(*get_optimal_poll_group)(struct spdk_nvmf_qpair *qpair);
/**
* Destroy a poll group
*/
@ -164,7 +169,6 @@ struct spdk_nvmf_transport_ops {
int (*qpair_set_sqsize)(struct spdk_nvmf_qpair *qpair);
};
int spdk_nvmf_transport_stop_listen(struct spdk_nvmf_transport *transport,
const struct spdk_nvme_transport_id *trid);
@ -176,6 +180,8 @@ void spdk_nvmf_transport_listener_discover(struct spdk_nvmf_transport *transport
struct spdk_nvmf_transport_poll_group *spdk_nvmf_transport_poll_group_create(
struct spdk_nvmf_transport *transport);
struct spdk_nvmf_transport_poll_group *spdk_nvmf_transport_get_optimal_poll_group(
struct spdk_nvmf_transport *transport, struct spdk_nvmf_qpair *qpair);
void spdk_nvmf_transport_poll_group_destroy(struct spdk_nvmf_transport_poll_group *group);

View File

@ -161,6 +161,16 @@ DEFINE_STUB(spdk_nvmf_transport_req_complete,
(struct spdk_nvmf_request *req),
0);
DEFINE_STUB(spdk_sock_get_optimal_sock_group,
int,
(struct spdk_sock *sock, struct spdk_sock_group **group),
0);
DEFINE_STUB(spdk_sock_group_get_ctx,
void *,
(struct spdk_sock_group *group),
NULL);
DEFINE_STUB_V(spdk_nvmf_ns_reservation_request, (void *ctx));
struct spdk_trace_histories *g_trace_histories;