Commit 93ab45d6 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

nvmf: Add an accessor for transport name



This allows the entire transport structure definition
to become private.

Change-Id: I9ca19edbfc3cfb75b9b113a89bb2b90bc499ab16
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 1e6ffa03
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ dump_nvmf_subsystem(struct spdk_json_write_ctx *w, struct nvmf_tgt_subsystem *tg
	TAILQ_FOREACH(listen_addr, &subsystem->listen_addrs, link) {
		spdk_json_write_object_begin(w);
		spdk_json_write_name(w, "transport");
		spdk_json_write_string(w, listen_addr->transport->name);
		spdk_json_write_string(w, spdk_nvmf_transport_get_name(listen_addr->transport));
		spdk_json_write_name(w, "traddr");
		spdk_json_write_string(w, listen_addr->traddr);
		spdk_json_write_name(w, "trsvcid");
+2 −69
Original line number Diff line number Diff line
@@ -192,78 +192,11 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd

int spdk_nvmf_subsystem_set_sn(struct spdk_nvmf_subsystem *subsystem, const char *sn);

struct spdk_nvmf_transport {
	/**
	 * Name of the transport.
	 */
	const char *name;

	/**
	 * Initialize the transport.
	 */
	int (*transport_init)(uint16_t max_queue_depth, uint32_t max_io_size,
			      uint32_t in_capsule_data_size);

	/**
	 * Shut down the transport.
	 */
	int (*transport_fini)(void);

	/**
	 * Check for new connections on the transport.
	 */
	void (*acceptor_poll)(void);

	/**
	  * Instruct the acceptor to listen on the address provided. This
	  * may be called multiple times.
	  */
	int (*listen_addr_add)(struct spdk_nvmf_listen_addr *listen_addr);

	/**
	 * Fill out a discovery log entry for a specific listen address.
	 */
	void (*listen_addr_discover)(struct spdk_nvmf_listen_addr *listen_addr,
				     struct spdk_nvmf_discovery_log_page_entry *entry);

	/**
	 * Initialize the transport for the given session
	 */
	int (*session_init)(struct spdk_nvmf_session *session, struct spdk_nvmf_conn *conn);

	/**
	 * Deinitiallize the transport for the given session
	 */
	void (*session_fini)(struct spdk_nvmf_session *session);

	/*
	 * Signal request completion, which sends a response
	 * to the originator. A request can either
	 * be completed or released, but not both.
	 */
	int (*req_complete)(struct spdk_nvmf_request *req);

	/*
	 * Signal that the request can be released without sending
	 * a response. A request can either be completed or release,
	 * but not both.
	 */
	int (*req_release)(struct spdk_nvmf_request *req);

	/*
	 * Deinitialize a connection.
	 */
	void (*conn_fini)(struct spdk_nvmf_conn *conn);

	/*
	 * Poll a connection for events.
	 */
	int (*conn_poll)(struct spdk_nvmf_conn *conn);
};

int spdk_nvmf_transport_init(void);
int spdk_nvmf_transport_fini(void);
const struct spdk_nvmf_transport *spdk_nvmf_transport_get(const char *name);
const char *spdk_nvmf_transport_get_name(const struct spdk_nvmf_transport *transport);

void spdk_nvmf_acceptor_poll(void);

void spdk_nvmf_handle_connect(struct spdk_nvmf_request *req);
+6 −0
Original line number Diff line number Diff line
@@ -108,3 +108,9 @@ spdk_nvmf_transport_get(const char *name)

	return NULL;
}

const char *
spdk_nvmf_transport_get_name(const struct spdk_nvmf_transport *transport)
{
	return transport->name;
}
+73 −0
Original line number Diff line number Diff line
@@ -34,6 +34,79 @@
#ifndef SPDK_NVMF_TRANSPORT_H
#define SPDK_NVMF_TRANSPORT_H

#include <stdint.h>

#include "spdk/nvmf.h"

struct spdk_nvmf_transport {
	/**
	 * Name of the transport.
	 */
	const char *name;

	/**
	 * Initialize the transport.
	 */
	int (*transport_init)(uint16_t max_queue_depth, uint32_t max_io_size,
			      uint32_t in_capsule_data_size);

	/**
	 * Shut down the transport.
	 */
	int (*transport_fini)(void);

	/**
	 * Check for new connections on the transport.
	 */
	void (*acceptor_poll)(void);

	/**
	  * Instruct the acceptor to listen on the address provided. This
	  * may be called multiple times.
	  */
	int (*listen_addr_add)(struct spdk_nvmf_listen_addr *listen_addr);

	/**
	 * Fill out a discovery log entry for a specific listen address.
	 */
	void (*listen_addr_discover)(struct spdk_nvmf_listen_addr *listen_addr,
				     struct spdk_nvmf_discovery_log_page_entry *entry);

	/**
	 * Initialize the transport for the given session
	 */
	int (*session_init)(struct spdk_nvmf_session *session, struct spdk_nvmf_conn *conn);

	/**
	 * Deinitiallize the transport for the given session
	 */
	void (*session_fini)(struct spdk_nvmf_session *session);

	/*
	 * Signal request completion, which sends a response
	 * to the originator. A request can either
	 * be completed or released, but not both.
	 */
	int (*req_complete)(struct spdk_nvmf_request *req);

	/*
	 * Signal that the request can be released without sending
	 * a response. A request can either be completed or release,
	 * but not both.
	 */
	int (*req_release)(struct spdk_nvmf_request *req);

	/*
	 * Deinitialize a connection.
	 */
	void (*conn_fini)(struct spdk_nvmf_conn *conn);

	/*
	 * Poll a connection for events.
	 */
	int (*conn_poll)(struct spdk_nvmf_conn *conn);
};

extern const struct spdk_nvmf_transport spdk_nvmf_transport_rdma;

#endif /* SPDK_NVMF_TRANSPORT_H */