nvmf: Remove new_qpair callback from transport accept function pointer

Transports may now call spdk_nvmf_tgt_new_qpair() instead.

Change-Id: Ib3295c488e22517e82f2051055ae47521d76fe56
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2814
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
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:
Ben Walker 2020-06-08 14:57:25 -07:00 committed by Tomasz Zawadzki
parent 268aacb24a
commit 5584232cce
14 changed files with 39 additions and 45 deletions

View File

@ -8,7 +8,10 @@ The NVMe-oF target no longer supports connecting scheduling configuration and in
always uses what was previously called "transport" scheduling. always uses what was previously called "transport" scheduling.
`spdk_nvmf_tgt_accept` no longer takes a function pointer as an argument. New connections `spdk_nvmf_tgt_accept` no longer takes a function pointer as an argument. New connections
are automatically assigned to poll groups by the underlying transport. are automatically assigned to poll groups by the underlying transport. Further,
`spdk_nvmf_transport_ops` has changed such that the accept function pointer no longer
takes a function pointer as an argument. Instead, transports should call
`spdk_nvmf_tgt_new_qpair` whenever they previously would have called that callback.
### nvme ### nvme

View File

@ -192,14 +192,6 @@ struct spdk_nvmf_transport {
TAILQ_ENTRY(spdk_nvmf_transport) link; TAILQ_ENTRY(spdk_nvmf_transport) link;
}; };
/**
* Function to be called for each newly discovered qpair.
*
* \param qpair The newly discovered qpair.
* \param cb_arg A context argument passed to this function.
*/
typedef void (*new_qpair_fn)(struct spdk_nvmf_qpair *qpair, void *cb_arg);
struct spdk_nvmf_transport_ops { struct spdk_nvmf_transport_ops {
/** /**
* Transport name * Transport name
@ -260,7 +252,7 @@ struct spdk_nvmf_transport_ops {
/** /**
* Check for new connections on the transport. * Check for new connections on the transport.
*/ */
uint32_t (*accept)(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg); uint32_t (*accept)(struct spdk_nvmf_transport *transport);
/** /**
* Initialize subset of identify controller data. * Initialize subset of identify controller data.
@ -366,6 +358,14 @@ void spdk_nvmf_transport_register(const struct spdk_nvmf_transport_ops *ops);
int spdk_nvmf_ctrlr_connect(struct spdk_nvmf_request *req); int spdk_nvmf_ctrlr_connect(struct spdk_nvmf_request *req);
/**
* Function to be called for each newly discovered qpair.
*
* \param tgt The nvmf target
* \param qpair The newly discovered qpair.
*/
void spdk_nvmf_tgt_new_qpair(struct spdk_nvmf_tgt *tgt, struct spdk_nvmf_qpair *qpair);
/** /**
* A subset of struct spdk_nvme_registers that are emulated by a fabrics device. * A subset of struct spdk_nvme_registers that are emulated by a fabrics device.
*/ */

View File

@ -1912,7 +1912,7 @@ nvmf_fc_stop_listen(struct spdk_nvmf_transport *transport,
} }
static uint32_t static uint32_t
nvmf_fc_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg) nvmf_fc_accept(struct spdk_nvmf_transport *transport)
{ {
struct spdk_nvmf_fc_port *fc_port = NULL; struct spdk_nvmf_fc_port *fc_port = NULL;
uint32_t count = 0; uint32_t count = 0;
@ -1926,7 +1926,6 @@ nvmf_fc_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *
/* poll the LS queue on each port */ /* poll the LS queue on each port */
TAILQ_FOREACH(fc_port, &g_spdk_nvmf_fc_port_list, link) { TAILQ_FOREACH(fc_port, &g_spdk_nvmf_fc_port_list, link) {
if (fc_port->hw_port_status == SPDK_FC_PORT_ONLINE) { if (fc_port->hw_port_status == SPDK_FC_PORT_ONLINE) {
fc_port->new_qp_cb = cb_fn;
count += nvmf_fc_process_queue(&fc_port->ls_queue); count += nvmf_fc_process_queue(&fc_port->ls_queue);
} }
} }

View File

@ -564,8 +564,6 @@ nvmf_fc_ls_add_conn_to_poller(
{ {
struct nvmf_fc_ls_op_ctx *opd; struct nvmf_fc_ls_op_ctx *opd;
struct spdk_nvmf_fc_ls_add_conn_api_data *api_data; struct spdk_nvmf_fc_ls_add_conn_api_data *api_data;
struct spdk_nvmf_fc_nport *tgtport = assoc->tgtport;
struct spdk_nvmf_fc_port *fc_port = tgtport->fc_port;
SPDK_DEBUGLOG(SPDK_LOG_NVMF_FC_LS, "Add Connection to poller for " SPDK_DEBUGLOG(SPDK_LOG_NVMF_FC_LS, "Add Connection to poller for "
"assoc_id 0x%lx conn_id 0x%lx\n", assoc->assoc_id, "assoc_id 0x%lx conn_id 0x%lx\n", assoc->assoc_id,
@ -595,7 +593,7 @@ nvmf_fc_ls_add_conn_to_poller(
/* Let the nvmf_tgt decide which pollgroup to use. */ /* Let the nvmf_tgt decide which pollgroup to use. */
fc_conn->create_opd = opd; fc_conn->create_opd = opd;
fc_port->new_qp_cb(&fc_conn->qpair, fc_port->new_qp_arg); spdk_nvmf_tgt_new_qpair(ls_rqst->nvmf_tgt, &fc_conn->qpair);
} }
/* Delete association functions */ /* Delete association functions */

View File

@ -740,15 +740,12 @@ _nvmf_poll_group_add(void *_ctx)
} }
} }
static void void
_nvmf_new_qpair(struct spdk_nvmf_qpair *qpair, void *cb_arg) spdk_nvmf_tgt_new_qpair(struct spdk_nvmf_tgt *tgt, struct spdk_nvmf_qpair *qpair)
{ {
struct spdk_nvmf_poll_group *group; struct spdk_nvmf_poll_group *group;
struct spdk_nvmf_tgt *tgt;
struct nvmf_new_qpair_ctx *ctx; struct nvmf_new_qpair_ctx *ctx;
tgt = qpair->transport->tgt;
group = spdk_nvmf_get_optimal_poll_group(qpair); group = spdk_nvmf_get_optimal_poll_group(qpair);
if (group == NULL) { if (group == NULL) {
if (tgt->next_poll_group == NULL) { if (tgt->next_poll_group == NULL) {
@ -783,7 +780,7 @@ spdk_nvmf_tgt_accept(struct spdk_nvmf_tgt *tgt)
uint32_t count = 0; uint32_t count = 0;
TAILQ_FOREACH_SAFE(transport, &tgt->transports, link, tmp) { TAILQ_FOREACH_SAFE(transport, &tgt->transports, link, tmp) {
count += nvmf_transport_accept(transport, _nvmf_new_qpair, NULL); count += nvmf_transport_accept(transport);
} }
return count; return count;

View File

@ -309,8 +309,6 @@ struct spdk_nvmf_fc_port {
enum spdk_fc_port_state hw_port_status; enum spdk_fc_port_state hw_port_status;
uint16_t fcp_rq_id; uint16_t fcp_rq_id;
struct spdk_nvmf_fc_hwqp ls_queue; struct spdk_nvmf_fc_hwqp ls_queue;
new_qpair_fn new_qp_cb;
void *new_qp_arg;
uint32_t num_io_queues; uint32_t num_io_queues;
struct spdk_nvmf_fc_hwqp *io_queues; struct spdk_nvmf_fc_hwqp *io_queues;

View File

@ -1189,8 +1189,7 @@ nvmf_rdma_event_reject(struct rdma_cm_id *id, enum spdk_nvmf_rdma_transport_erro
} }
static int static int
nvmf_rdma_connect(struct spdk_nvmf_transport *transport, struct rdma_cm_event *event, nvmf_rdma_connect(struct spdk_nvmf_transport *transport, struct rdma_cm_event *event)
new_qpair_fn cb_fn, void *cb_arg)
{ {
struct spdk_nvmf_rdma_transport *rtransport; struct spdk_nvmf_rdma_transport *rtransport;
struct spdk_nvmf_rdma_qpair *rqpair = NULL; struct spdk_nvmf_rdma_qpair *rqpair = NULL;
@ -1287,7 +1286,7 @@ nvmf_rdma_connect(struct spdk_nvmf_transport *transport, struct rdma_cm_event *e
event->id->context = &rqpair->qpair; event->id->context = &rqpair->qpair;
cb_fn(&rqpair->qpair, cb_arg); spdk_nvmf_tgt_new_qpair(transport->tgt, &rqpair->qpair);
return 0; return 0;
} }
@ -2922,7 +2921,7 @@ nvmf_rdma_handle_cm_event_port_removal(struct spdk_nvmf_transport *transport,
} }
static void static void
nvmf_process_cm_event(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg) nvmf_process_cm_event(struct spdk_nvmf_transport *transport)
{ {
struct spdk_nvmf_rdma_transport *rtransport; struct spdk_nvmf_rdma_transport *rtransport;
struct rdma_cm_event *event; struct rdma_cm_event *event;
@ -2957,7 +2956,7 @@ nvmf_process_cm_event(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn,
/* No action required. The target never attempts to resolve routes. */ /* No action required. The target never attempts to resolve routes. */
break; break;
case RDMA_CM_EVENT_CONNECT_REQUEST: case RDMA_CM_EVENT_CONNECT_REQUEST:
rc = nvmf_rdma_connect(transport, event, cb_fn, cb_arg); rc = nvmf_rdma_connect(transport, event);
if (rc < 0) { if (rc < 0) {
SPDK_ERRLOG("Unable to process connect event. rc: %d\n", rc); SPDK_ERRLOG("Unable to process connect event. rc: %d\n", rc);
break; break;
@ -3162,7 +3161,7 @@ nvmf_process_ib_event(struct spdk_nvmf_rdma_device *device)
} }
static uint32_t static uint32_t
nvmf_rdma_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg) nvmf_rdma_accept(struct spdk_nvmf_transport *transport)
{ {
int nfds, i = 0; int nfds, i = 0;
struct spdk_nvmf_rdma_transport *rtransport; struct spdk_nvmf_rdma_transport *rtransport;
@ -3178,7 +3177,7 @@ nvmf_rdma_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void
/* The first poll descriptor is RDMA CM event */ /* The first poll descriptor is RDMA CM event */
if (rtransport->poll_fds[i++].revents & POLLIN) { if (rtransport->poll_fds[i++].revents & POLLIN) {
nvmf_process_cm_event(transport, cb_fn, cb_arg); nvmf_process_cm_event(transport);
nfds--; nfds--;
} }

View File

@ -94,6 +94,7 @@
# public functions in nvmf_transport.h # public functions in nvmf_transport.h
spdk_nvmf_transport_register; spdk_nvmf_transport_register;
spdk_nvmf_tgt_new_qpair;
spdk_nvmf_ctrlr_connect; spdk_nvmf_ctrlr_connect;
spdk_nvmf_ctrlr_data_init; spdk_nvmf_ctrlr_data_init;
spdk_nvmf_ctrlr_get_regs; spdk_nvmf_ctrlr_get_regs;

View File

@ -871,8 +871,7 @@ nvmf_tcp_qpair_sock_init(struct spdk_nvmf_tcp_qpair *tqpair)
static void static void
nvmf_tcp_handle_connect(struct spdk_nvmf_transport *transport, nvmf_tcp_handle_connect(struct spdk_nvmf_transport *transport,
struct spdk_nvmf_tcp_port *port, struct spdk_nvmf_tcp_port *port,
struct spdk_sock *sock, struct spdk_sock *sock)
new_qpair_fn cb_fn, void *cb_arg)
{ {
struct spdk_nvmf_tcp_qpair *tqpair; struct spdk_nvmf_tcp_qpair *tqpair;
int rc; int rc;
@ -902,12 +901,11 @@ nvmf_tcp_handle_connect(struct spdk_nvmf_transport *transport,
return; return;
} }
cb_fn(&tqpair->qpair, cb_arg); spdk_nvmf_tgt_new_qpair(transport->tgt, &tqpair->qpair);
} }
static uint32_t static uint32_t
nvmf_tcp_port_accept(struct spdk_nvmf_transport *transport, struct spdk_nvmf_tcp_port *port, 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; struct spdk_sock *sock;
uint32_t count = 0; uint32_t count = 0;
@ -919,14 +917,14 @@ nvmf_tcp_port_accept(struct spdk_nvmf_transport *transport, struct spdk_nvmf_tcp
break; break;
} }
count++; count++;
nvmf_tcp_handle_connect(transport, port, sock, cb_fn, cb_arg); nvmf_tcp_handle_connect(transport, port, sock);
} }
return count; return count;
} }
static uint32_t static uint32_t
nvmf_tcp_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg) nvmf_tcp_accept(struct spdk_nvmf_transport *transport)
{ {
struct spdk_nvmf_tcp_transport *ttransport; struct spdk_nvmf_tcp_transport *ttransport;
struct spdk_nvmf_tcp_port *port; struct spdk_nvmf_tcp_port *port;
@ -935,7 +933,7 @@ nvmf_tcp_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void
ttransport = SPDK_CONTAINEROF(transport, struct spdk_nvmf_tcp_transport, transport); ttransport = SPDK_CONTAINEROF(transport, struct spdk_nvmf_tcp_transport, transport);
TAILQ_FOREACH(port, &ttransport->ports, link) { TAILQ_FOREACH(port, &ttransport->ports, link) {
count += nvmf_tcp_port_accept(transport, port, cb_fn, cb_arg); count += nvmf_tcp_port_accept(transport, port);
} }
return count; return count;

View File

@ -255,9 +255,9 @@ spdk_nvmf_transport_stop_listen(struct spdk_nvmf_transport *transport,
} }
uint32_t uint32_t
nvmf_transport_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, void *cb_arg) nvmf_transport_accept(struct spdk_nvmf_transport *transport)
{ {
return transport->ops->accept(transport, cb_fn, cb_arg); return transport->ops->accept(transport);
} }
void void

View File

@ -40,8 +40,7 @@
#include "spdk/nvmf.h" #include "spdk/nvmf.h"
#include "spdk/nvmf_transport.h" #include "spdk/nvmf_transport.h"
uint32_t nvmf_transport_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn, uint32_t nvmf_transport_accept(struct spdk_nvmf_transport *transport);
void *cb_arg);
void nvmf_transport_listener_discover(struct spdk_nvmf_transport *transport, void nvmf_transport_listener_discover(struct spdk_nvmf_transport *transport,
struct spdk_nvme_transport_id *trid, struct spdk_nvme_transport_id *trid,

View File

@ -140,8 +140,8 @@ spdk_nvmf_qpair_disconnect(struct spdk_nvmf_qpair *qpair, nvmf_qpair_disconnect_
return 0; return 0;
} }
static void void
new_qpair(struct spdk_nvmf_qpair *qpair, void *cb_arg) spdk_nvmf_tgt_new_qpair(struct spdk_nvmf_tgt *tgt, struct spdk_nvmf_qpair *qpair)
{ {
uint32_t i; uint32_t i;
struct spdk_nvmf_fc_conn *fc_conn; struct spdk_nvmf_fc_conn *fc_conn;
@ -628,7 +628,6 @@ handle_disconn_bad_assoc_rsp(struct spdk_nvmf_fc_ls_rqst *ls_rqst)
static struct spdk_nvmf_fc_port g_fc_port = { static struct spdk_nvmf_fc_port g_fc_port = {
.num_io_queues = 16, .num_io_queues = 16,
.new_qp_cb = new_qpair,
}; };
static struct spdk_nvmf_fc_nport g_tgt_port; static struct spdk_nvmf_fc_nport g_tgt_port;

View File

@ -84,6 +84,7 @@ DEFINE_STUB(spdk_nvmf_request_get_dif_ctx, bool, (struct spdk_nvmf_request *req,
struct spdk_dif_ctx *dif_ctx), false); struct spdk_dif_ctx *dif_ctx), false);
DEFINE_STUB_V(spdk_nvme_trid_populate_transport, (struct spdk_nvme_transport_id *trid, DEFINE_STUB_V(spdk_nvme_trid_populate_transport, (struct spdk_nvme_transport_id *trid,
enum spdk_nvme_transport_type trtype)); enum spdk_nvme_transport_type trtype));
DEFINE_STUB_V(spdk_nvmf_tgt_new_qpair, (struct spdk_nvmf_tgt *tgt, struct spdk_nvmf_qpair *qpair));
const char * const char *
spdk_nvme_transport_id_trtype_str(enum spdk_nvme_transport_type trtype) spdk_nvme_transport_id_trtype_str(enum spdk_nvme_transport_type trtype)

View File

@ -198,6 +198,8 @@ DEFINE_STUB_V(spdk_nvme_trid_populate_transport, (struct spdk_nvme_transport_id
enum spdk_nvme_transport_type trtype)); enum spdk_nvme_transport_type trtype));
DEFINE_STUB_V(spdk_nvmf_transport_register, (const struct spdk_nvmf_transport_ops *ops)); DEFINE_STUB_V(spdk_nvmf_transport_register, (const struct spdk_nvmf_transport_ops *ops));
DEFINE_STUB_V(spdk_nvmf_tgt_new_qpair, (struct spdk_nvmf_tgt *tgt, struct spdk_nvmf_qpair *qpair));
struct spdk_trace_histories *g_trace_histories; struct spdk_trace_histories *g_trace_histories;
struct spdk_bdev { struct spdk_bdev {