Commit 0e8925db authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

nvmf/fc: replace use of "master" with "main"



Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I55c53e0508b7490557e8f43501581fafa435051d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5354


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAnil Veerabhadrappa <anil.veerabhadrappa@broadcom.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 92895216
Loading
Loading
Loading
Loading
+38 −38
Original line number Diff line number Diff line
@@ -53,9 +53,9 @@
#define DEV_VERIFY assert
#endif

#ifndef ASSERT_SPDK_FC_MASTER_THREAD
#define ASSERT_SPDK_FC_MASTER_THREAD() \
        DEV_VERIFY(spdk_get_thread() == nvmf_fc_get_master_thread());
#ifndef ASSERT_SPDK_FC_MAIN_THREAD
#define ASSERT_SPDK_FC_MAIN_THREAD() \
        DEV_VERIFY(spdk_get_thread() == nvmf_fc_get_main_thread());
#endif

/*
@@ -231,16 +231,16 @@ static struct spdk_nvmf_fc_transport *g_nvmf_ftransport;
static TAILQ_HEAD(, spdk_nvmf_fc_port) g_spdk_nvmf_fc_port_list =
	TAILQ_HEAD_INITIALIZER(g_spdk_nvmf_fc_port_list);

static struct spdk_thread *g_nvmf_fc_master_thread = NULL;
static struct spdk_thread *g_nvmf_fc_main_thread = NULL;

static uint32_t g_nvmf_fgroup_count = 0;
static TAILQ_HEAD(, spdk_nvmf_fc_poll_group) g_nvmf_fgroups =
	TAILQ_HEAD_INITIALIZER(g_nvmf_fgroups);

struct spdk_thread *
nvmf_fc_get_master_thread(void)
nvmf_fc_get_main_thread(void)
{
	return g_nvmf_fc_master_thread;
	return g_nvmf_fc_main_thread;
}

static inline void
@@ -522,7 +522,7 @@ nvmf_fc_poll_group_remove_hwqp(struct spdk_nvmf_fc_hwqp *hwqp)
}

/*
 * Note: This needs to be used only on master poller.
 * Note: This needs to be used only on main poller.
 */
static uint64_t
nvmf_fc_get_abts_unique_id(void)
@@ -1838,7 +1838,7 @@ nvmf_fc_create(struct spdk_nvmf_transport_opts *opts)
		return NULL;
	}

	g_nvmf_fc_master_thread = spdk_get_thread();
	g_nvmf_fc_main_thread = spdk_get_thread();
	g_nvmf_fgroup_count = 0;
	g_nvmf_ftransport = calloc(1, sizeof(*g_nvmf_ftransport));

@@ -2067,12 +2067,12 @@ nvmf_fc_close_qpair(struct spdk_nvmf_qpair *qpair,

	if (fc_conn->conn_id == NVMF_FC_INVALID_CONN_ID) {
		/* QP creation failure in FC tranport. Cleanup. */
		spdk_thread_send_msg(nvmf_fc_get_master_thread(),
		spdk_thread_send_msg(nvmf_fc_get_main_thread(),
				     nvmf_fc_handle_connection_failure, fc_conn);
	} else if (fc_conn->fc_assoc->assoc_id == fc_conn->conn_id &&
		   fc_conn->fc_assoc->assoc_state != SPDK_NVMF_FC_OBJECT_TO_BE_DELETED) {
		/* Admin connection */
		spdk_thread_send_msg(nvmf_fc_get_master_thread(),
		spdk_thread_send_msg(nvmf_fc_get_main_thread(),
				     nvmf_fc_handle_assoc_deletion, fc_conn);
	}

@@ -2176,7 +2176,7 @@ nvmf_fc_adm_hw_port_data_init(struct spdk_nvmf_fc_port *fc_port,
	 * Initialize the LS queue wherever needed.
	 */
	fc_port->ls_queue.queues = args->ls_queue;
	fc_port->ls_queue.thread = nvmf_fc_get_master_thread();
	fc_port->ls_queue.thread = nvmf_fc_get_main_thread();
	fc_port->ls_queue.hwqp_id = SPDK_MAX_NUM_OF_FC_PORTS * fc_port->num_io_queues;

	/*
@@ -2230,7 +2230,7 @@ nvmf_fc_adm_hw_port_offline_nport_delete(struct spdk_nvmf_fc_port *fc_port)
static void
nvmf_fc_adm_i_t_delete_cb(void *args, uint32_t err)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_adm_i_t_del_cb_data *cb_data = args;
	struct spdk_nvmf_fc_nport *nport = cb_data->nport;
	struct spdk_nvmf_fc_remote_port_info *rport = cb_data->rport;
@@ -2273,7 +2273,7 @@ out:
static void
nvmf_fc_adm_i_t_delete_assoc_cb(void *args, uint32_t err)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_adm_i_t_del_assoc_cb_data *cb_data = args;
	struct spdk_nvmf_fc_nport *nport = cb_data->nport;
	struct spdk_nvmf_fc_remote_port_info *rport = cb_data->rport;
@@ -2421,7 +2421,7 @@ out:
static void
nvmf_fc_adm_queue_quiesce_cb(void *cb_data, enum spdk_nvmf_fc_poller_api_ret ret)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_poller_api_quiesce_queue_args *quiesce_api_data = NULL;
	struct spdk_nvmf_fc_adm_hw_port_quiesce_ctx *port_quiesce_ctx = NULL;
	struct spdk_nvmf_fc_hwqp *hwqp = NULL;
@@ -2586,7 +2586,7 @@ out:
static void
nvmf_fc_adm_evnt_hw_port_init(void *arg)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_port *fc_port = NULL;
	struct spdk_nvmf_fc_adm_api_data *api_data = (struct spdk_nvmf_fc_adm_api_data *)arg;
	struct spdk_nvmf_fc_hw_port_init_args *args = (struct spdk_nvmf_fc_hw_port_init_args *)
@@ -2659,7 +2659,7 @@ abort_port_init:
static void
nvmf_fc_adm_evnt_hw_port_online(void *arg)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_port *fc_port = NULL;
	struct spdk_nvmf_fc_hwqp *hwqp = NULL;
	struct spdk_nvmf_fc_adm_api_data *api_data = (struct spdk_nvmf_fc_adm_api_data *)arg;
@@ -2711,7 +2711,7 @@ out:
static void
nvmf_fc_adm_evnt_hw_port_offline(void *arg)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_port *fc_port = NULL;
	struct spdk_nvmf_fc_hwqp *hwqp = NULL;
	struct spdk_nvmf_fc_adm_api_data *api_data = (struct spdk_nvmf_fc_adm_api_data *)arg;
@@ -2769,7 +2769,7 @@ struct nvmf_fc_add_rem_listener_ctx {
static void
nvmf_fc_adm_subsystem_resume_cb(struct spdk_nvmf_subsystem *subsystem, void *cb_arg, int status)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct nvmf_fc_add_rem_listener_ctx *ctx = (struct nvmf_fc_add_rem_listener_ctx *)cb_arg;
	free(ctx);
}
@@ -2777,7 +2777,7 @@ nvmf_fc_adm_subsystem_resume_cb(struct spdk_nvmf_subsystem *subsystem, void *cb_
static void
nvmf_fc_adm_listen_done(void *cb_arg, int status)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct nvmf_fc_add_rem_listener_ctx *ctx = cb_arg;

	if (spdk_nvmf_subsystem_resume(ctx->subsystem, nvmf_fc_adm_subsystem_resume_cb, ctx)) {
@@ -2789,7 +2789,7 @@ nvmf_fc_adm_listen_done(void *cb_arg, int status)
static void
nvmf_fc_adm_subsystem_paused_cb(struct spdk_nvmf_subsystem *subsystem, void *cb_arg, int status)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct nvmf_fc_add_rem_listener_ctx *ctx = (struct nvmf_fc_add_rem_listener_ctx *)cb_arg;

	if (ctx->add_listener) {
@@ -2850,7 +2850,7 @@ nvmf_fc_adm_add_rem_nport_listener(struct spdk_nvmf_fc_nport *nport, bool add)
static void
nvmf_fc_adm_evnt_nport_create(void *arg)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_adm_api_data *api_data = (struct spdk_nvmf_fc_adm_api_data *)arg;
	struct spdk_nvmf_fc_nport_create_args *args = (struct spdk_nvmf_fc_nport_create_args *)
			api_data->api_args;
@@ -2928,7 +2928,7 @@ static void
nvmf_fc_adm_delete_nport_cb(uint8_t port_handle, enum spdk_fc_event event_type,
			    void *cb_args, int spdk_err)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_adm_nport_del_cb_data *cb_data = cb_args;
	struct spdk_nvmf_fc_nport *nport = cb_data->nport;
	spdk_nvmf_fc_callback cb_func = cb_data->fc_cb_func;
@@ -2995,7 +2995,7 @@ out:
static void
nvmf_fc_adm_evnt_nport_delete(void *arg)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_adm_api_data *api_data = (struct spdk_nvmf_fc_adm_api_data *)arg;
	struct spdk_nvmf_fc_nport_delete_args *args = (struct spdk_nvmf_fc_nport_delete_args *)
			api_data->api_args;
@@ -3096,7 +3096,7 @@ nvmf_fc_adm_evnt_nport_delete(void *arg)
		it_del_args->rpi = rport_iter->rpi;
		it_del_args->s_id = rport_iter->s_id;

		nvmf_fc_master_enqueue_event(SPDK_FC_IT_DELETE, (void *)it_del_args,
		nvmf_fc_main_enqueue_event(SPDK_FC_IT_DELETE, (void *)it_del_args,
					   nvmf_fc_adm_delete_nport_cb);
	}

@@ -3130,7 +3130,7 @@ out:
static void
nvmf_fc_adm_evnt_i_t_add(void *arg)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_adm_api_data *api_data = (struct spdk_nvmf_fc_adm_api_data *)arg;
	struct spdk_nvmf_fc_hw_i_t_add_args *args = (struct spdk_nvmf_fc_hw_i_t_add_args *)
			api_data->api_args;
@@ -3219,7 +3219,7 @@ out:
static void
nvmf_fc_adm_evnt_i_t_delete(void *arg)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_adm_api_data *api_data = (struct spdk_nvmf_fc_adm_api_data *)arg;
	struct spdk_nvmf_fc_hw_i_t_delete_args *args = (struct spdk_nvmf_fc_hw_i_t_delete_args *)
			api_data->api_args;
@@ -3349,7 +3349,7 @@ out:
static void
nvmf_fc_adm_evnt_abts_recv(void *arg)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_adm_api_data *api_data = (struct spdk_nvmf_fc_adm_api_data *)arg;
	struct spdk_nvmf_fc_abts_args *args = (struct spdk_nvmf_fc_abts_args *)api_data->api_args;
	struct spdk_nvmf_fc_nport *nport = NULL;
@@ -3406,7 +3406,7 @@ out:
static void
nvmf_fc_adm_hw_port_quiesce_reset_cb(void *ctx, int err)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_adm_hw_port_reset_ctx *reset_ctx =
		(struct spdk_nvmf_fc_adm_hw_port_reset_ctx *)ctx;
	struct spdk_nvmf_fc_hw_port_reset_args *args = reset_ctx->reset_args;
@@ -3486,7 +3486,7 @@ out:
static void
nvmf_fc_adm_evnt_hw_port_reset(void *arg)
{
	ASSERT_SPDK_FC_MASTER_THREAD();
	ASSERT_SPDK_FC_MAIN_THREAD();
	struct spdk_nvmf_fc_adm_api_data *api_data = (struct spdk_nvmf_fc_adm_api_data *)arg;
	struct spdk_nvmf_fc_hw_port_reset_args *args = (struct spdk_nvmf_fc_hw_port_reset_args *)
			api_data->api_args;
@@ -3548,19 +3548,19 @@ out:
}

static inline void
nvmf_fc_adm_run_on_master_thread(spdk_msg_fn fn, void *args)
nvmf_fc_adm_run_on_main_thread(spdk_msg_fn fn, void *args)
{
	if (nvmf_fc_get_master_thread()) {
		spdk_thread_send_msg(nvmf_fc_get_master_thread(), fn, args);
	if (nvmf_fc_get_main_thread()) {
		spdk_thread_send_msg(nvmf_fc_get_main_thread(), fn, args);
	}
}

/*
 * Queue up an event in the SPDK masters event queue.
 * Used by the FC driver to notify the SPDK master of FC related events.
 * Queue up an event in the SPDK main threads event queue.
 * Used by the FC driver to notify the SPDK main thread of FC related events.
 */
int
nvmf_fc_master_enqueue_event(enum spdk_fc_event event_type, void *args,
nvmf_fc_main_enqueue_event(enum spdk_fc_event event_type, void *args,
			   spdk_nvmf_fc_callback cb_func)
{
	int err = 0;
@@ -3640,7 +3640,7 @@ done:

	if (err == 0) {
		assert(event_fn != NULL);
		nvmf_fc_adm_run_on_master_thread(event_fn, (void *)api_data);
		nvmf_fc_adm_run_on_main_thread(event_fn, (void *)api_data);
		SPDK_DEBUGLOG(nvmf_fc_adm_api, "Enqueue event %d done successfully\n", event_type);
	} else {
		SPDK_ERRLOG("Enqueue event %d failed, err = %d\n", event_type, err);
+1 −1
Original line number Diff line number Diff line
@@ -1350,7 +1350,7 @@ nvmf_fc_poller_api_perform_cb(struct spdk_nvmf_fc_poller_api_cb_info *cb_info,
{
	if (cb_info->cb_func && cb_info->cb_thread) {
		cb_info->ret = ret;
		/* callback to master thread */
		/* callback to main thread */
		spdk_thread_send_msg(cb_info->cb_thread, nvmf_fc_poller_api_cb_event,
				     (void *) cb_info);
	}
+9 −9
Original line number Diff line number Diff line
@@ -268,7 +268,7 @@ struct spdk_nvmf_fc_poll_group {
};

/*
 *  HWQP poller structure passed from Master thread
 *  HWQP poller structure passed from main thread
 */
struct spdk_nvmf_fc_hwqp {
	enum spdk_fc_hwqp_state state;  /* queue state (for poller) */
@@ -574,7 +574,7 @@ struct spdk_nvmf_fc_poller_api_queue_sync_args {
};

/**
 * Following defines and structures are used to pass messages between master thread
 * Following defines and structures are used to pass messages between main thread
 * and FCT driver.
 */
enum spdk_fc_event {
@@ -669,7 +669,7 @@ struct spdk_nvmf_fc_hw_i_t_add_args {
	uint32_t                     rpi;
	uint32_t                     s_id;
	uint32_t                     initiator_prli_info;
	uint32_t                     target_prli_info; /* populated by the SPDK master */
	uint32_t                     target_prli_info; /* populated by the SPDK main */
	struct spdk_nvmf_fc_wwn  fc_nodename;
	struct spdk_nvmf_fc_wwn  fc_portname;
	void                        *cb_ctx;
@@ -723,7 +723,7 @@ typedef void (*spdk_nvmf_fc_callback)(uint8_t port_handle,
				      void *arg, int err);

/**
 * Enqueue an FCT event to master thread
 * Enqueue an FCT event to main thread
 *
 * \param event_type Type of the event.
 * \param args Pointer to the argument structure.
@@ -732,7 +732,7 @@ typedef void (*spdk_nvmf_fc_callback)(uint8_t port_handle,
 * \return 0 on success, non-zero on failure.
 */
int
nvmf_fc_master_enqueue_event(enum spdk_fc_event event_type,
nvmf_fc_main_enqueue_event(enum spdk_fc_event event_type,
			   void *args,
			   spdk_nvmf_fc_callback cb_func);

@@ -900,7 +900,7 @@ int nvmf_fc_delete_association(struct spdk_nvmf_fc_nport *tgtport,
bool nvmf_ctrlr_is_on_nport(uint8_t port_hdl, uint16_t nport_hdl,
			    struct spdk_nvmf_ctrlr *ctrlr);

void nvmf_fc_assign_queue_to_master_thread(struct spdk_nvmf_fc_hwqp *hwqp);
void nvmf_fc_assign_queue_to_main_thread(struct spdk_nvmf_fc_hwqp *hwqp);

void nvmf_fc_poll_group_add_hwqp(struct spdk_nvmf_fc_hwqp *hwqp);

@@ -920,7 +920,7 @@ void nvmf_fc_request_abort(struct spdk_nvmf_fc_request *fc_req, bool send_abts,

struct spdk_nvmf_tgt *nvmf_fc_get_tgt(void);

struct spdk_thread *nvmf_fc_get_master_thread(void);
struct spdk_thread *nvmf_fc_get_main_thread(void);

/*
 * These functions are called by low level FC driver
+2 −2
Original line number Diff line number Diff line
@@ -351,7 +351,7 @@ create_fc_port_test(void)
	init_args.io_queues = (void *)lld_q;

	set_thread(0);
	err = nvmf_fc_master_enqueue_event(SPDK_FC_HW_PORT_INIT, (void *)&init_args, port_init_cb);
	err = nvmf_fc_main_enqueue_event(SPDK_FC_HW_PORT_INIT, (void *)&init_args, port_init_cb);
	CU_ASSERT(err == 0);
	poll_thread(0);

@@ -373,7 +373,7 @@ online_fc_port_test(void)

	set_thread(0);
	args.port_handle = g_fc_port_handle;
	err = nvmf_fc_master_enqueue_event(SPDK_FC_HW_PORT_ONLINE, (void *)&args, port_init_cb);
	err = nvmf_fc_main_enqueue_event(SPDK_FC_HW_PORT_ONLINE, (void *)&args, port_init_cb);
	CU_ASSERT(err == 0);
	poll_threads();
	set_thread(0);