nvmf: Make spdk_nvmf_tgt_accept return the number of events accepted
This will be usefull for pollers/threads stats. Signed-off-by: Maciej Szwed <maciej.szwed@intel.com> Change-Id: I4d1651f3ff6410c258c8bc75c2a68640b67d2ed9 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2849 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Anil Veerabhadrappa <anil.veerabhadrappa@broadcom.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
d5ebb7e118
commit
e7e10859d3
@ -241,7 +241,7 @@ int spdk_nvmf_tgt_stop_listen(struct spdk_nvmf_tgt *tgt,
|
||||
* \param cb_fn Called for each newly discovered qpair.
|
||||
* \param cb_arg A context argument passed to cb_fn.
|
||||
*/
|
||||
void spdk_nvmf_tgt_accept(struct spdk_nvmf_tgt *tgt, new_qpair_fn cb_fn, void *cb_arg);
|
||||
uint32_t spdk_nvmf_tgt_accept(struct spdk_nvmf_tgt *tgt, new_qpair_fn cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Create a poll group.
|
||||
|
@ -252,7 +252,7 @@ struct spdk_nvmf_transport_ops {
|
||||
/**
|
||||
* Check for new connections on the transport.
|
||||
*/
|
||||
void (*accept)(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg);
|
||||
uint32_t (*accept)(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Initialize subset of identify controller data.
|
||||
|
@ -1908,10 +1908,11 @@ nvmf_fc_stop_listen(struct spdk_nvmf_transport *transport,
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
static uint32_t
|
||||
nvmf_fc_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_nvmf_fc_port *fc_port = NULL;
|
||||
uint32_t count = 0;
|
||||
static bool start_lld = false;
|
||||
|
||||
if (spdk_unlikely(!start_lld)) {
|
||||
@ -1923,9 +1924,11 @@ nvmf_fc_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *
|
||||
TAILQ_FOREACH(fc_port, &g_spdk_nvmf_fc_port_list, link) {
|
||||
if (fc_port->hw_port_status == SPDK_FC_PORT_ONLINE) {
|
||||
fc_port->new_qp_cb = cb_fn;
|
||||
nvmf_fc_process_queue(&fc_port->ls_queue);
|
||||
count += nvmf_fc_process_queue(&fc_port->ls_queue);
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -720,14 +720,17 @@ spdk_nvmf_tgt_get_transport(struct spdk_nvmf_tgt *tgt, const char *transport_nam
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
uint32_t
|
||||
spdk_nvmf_tgt_accept(struct spdk_nvmf_tgt *tgt, new_qpair_fn cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_nvmf_transport *transport, *tmp;
|
||||
uint32_t count = 0;
|
||||
|
||||
TAILQ_FOREACH_SAFE(transport, &tgt->transports, link, tmp) {
|
||||
nvmf_transport_accept(transport, cb_fn, cb_arg);
|
||||
count += nvmf_transport_accept(transport, cb_fn, cb_arg);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
struct spdk_nvmf_poll_group *
|
||||
|
@ -3157,18 +3157,19 @@ nvmf_process_ib_event(struct spdk_nvmf_rdma_device *device)
|
||||
ibv_ack_async_event(&event);
|
||||
}
|
||||
|
||||
static void
|
||||
static uint32_t
|
||||
nvmf_rdma_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg)
|
||||
{
|
||||
int nfds, i = 0;
|
||||
struct spdk_nvmf_rdma_transport *rtransport;
|
||||
struct spdk_nvmf_rdma_device *device, *tmp;
|
||||
uint32_t count;
|
||||
|
||||
rtransport = SPDK_CONTAINEROF(transport, struct spdk_nvmf_rdma_transport, transport);
|
||||
nfds = poll(rtransport->poll_fds, rtransport->npoll_fds, 0);
|
||||
count = nfds = poll(rtransport->poll_fds, rtransport->npoll_fds, 0);
|
||||
|
||||
if (nfds <= 0) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The first poll descriptor is RDMA CM event */
|
||||
@ -3178,7 +3179,7 @@ nvmf_rdma_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void
|
||||
}
|
||||
|
||||
if (nfds == 0) {
|
||||
return;
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Second and subsequent poll descriptors are IB async events */
|
||||
@ -3190,6 +3191,8 @@ nvmf_rdma_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void
|
||||
}
|
||||
/* check all flagged fd's have been served */
|
||||
assert(nfds == 0);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -905,11 +905,12 @@ nvmf_tcp_handle_connect(struct spdk_nvmf_transport *transport,
|
||||
cb_fn(&tqpair->qpair, cb_arg);
|
||||
}
|
||||
|
||||
static void
|
||||
static uint32_t
|
||||
nvmf_tcp_port_accept(struct spdk_nvmf_transport *transport, struct spdk_nvmf_tcp_port *port,
|
||||
new_qpair_fn cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_sock *sock;
|
||||
uint32_t count = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NVMF_TCP_MAX_ACCEPT_SOCK_ONE_TIME; i++) {
|
||||
@ -917,21 +918,27 @@ nvmf_tcp_port_accept(struct spdk_nvmf_transport *transport, struct spdk_nvmf_tcp
|
||||
if (sock == NULL) {
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
nvmf_tcp_handle_connect(transport, port, sock, cb_fn, cb_arg);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static void
|
||||
static uint32_t
|
||||
nvmf_tcp_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_nvmf_tcp_transport *ttransport;
|
||||
struct spdk_nvmf_tcp_port *port;
|
||||
uint32_t count = 0;
|
||||
|
||||
ttransport = SPDK_CONTAINEROF(transport, struct spdk_nvmf_tcp_transport, transport);
|
||||
|
||||
TAILQ_FOREACH(port, &ttransport->ports, link) {
|
||||
nvmf_tcp_port_accept(transport, port, cb_fn, cb_arg);
|
||||
count += nvmf_tcp_port_accept(transport, port, cb_fn, cb_arg);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -254,10 +254,10 @@ spdk_nvmf_transport_stop_listen(struct spdk_nvmf_transport *transport,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
uint32_t
|
||||
nvmf_transport_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg)
|
||||
{
|
||||
transport->ops->accept(transport, cb_fn, cb_arg);
|
||||
return transport->ops->accept(transport, cb_fn, cb_arg);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -40,8 +40,8 @@
|
||||
#include "spdk/nvmf.h"
|
||||
#include "spdk/nvmf_transport.h"
|
||||
|
||||
void nvmf_transport_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn,
|
||||
void *cb_arg);
|
||||
uint32_t nvmf_transport_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn,
|
||||
void *cb_arg);
|
||||
|
||||
void nvmf_transport_listener_discover(struct spdk_nvmf_transport *transport,
|
||||
struct spdk_nvme_transport_id *trid,
|
||||
|
@ -302,10 +302,11 @@ static int
|
||||
acceptor_poll(void *arg)
|
||||
{
|
||||
struct spdk_nvmf_tgt *tgt = arg;
|
||||
uint32_t count;
|
||||
|
||||
spdk_nvmf_tgt_accept(tgt, new_qpair, NULL);
|
||||
count = spdk_nvmf_tgt_accept(tgt, new_qpair, NULL);
|
||||
|
||||
return -1;
|
||||
return count;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user