nvme: Rename discover_info to transport_id
This is a small step toward making discovery more like scanning a local PCI bus. Change-Id: Ie7149ad060f2eeb56939b1241187bdf09681f2aa Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
f74d64f07f
commit
4af9f06c73
@ -69,7 +69,7 @@ static struct spdk_nvme_intel_marketing_description_page intel_md_page;
|
|||||||
|
|
||||||
static bool g_hex_dump = false;
|
static bool g_hex_dump = false;
|
||||||
|
|
||||||
static struct spdk_nvme_discover_info info;
|
static struct spdk_nvme_transport_id trid;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
hex_dump(const void *data, size_t size)
|
hex_dump(const void *data, size_t size)
|
||||||
@ -874,7 +874,7 @@ parse_args(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int op, rc;
|
int op, rc;
|
||||||
|
|
||||||
info.subnqn = SPDK_NVMF_DISCOVERY_NQN;
|
trid.subnqn = SPDK_NVMF_DISCOVERY_NQN;
|
||||||
|
|
||||||
while ((op = getopt(argc, argv, "a:n:s:t:xH")) != -1) {
|
while ((op = getopt(argc, argv, "a:n:s:t:xH")) != -1) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
@ -896,13 +896,13 @@ parse_args(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
info.traddr = optarg;
|
trid.traddr = optarg;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
info.trsvcid = optarg;
|
trid.trsvcid = optarg;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
info.subnqn = optarg;
|
trid.subnqn = optarg;
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
default:
|
default:
|
||||||
@ -911,21 +911,21 @@ parse_args(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!info.traddr || !info.trsvcid || !info.subnqn) {
|
if (!trid.traddr || !trid.trsvcid || !trid.subnqn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((strlen(info.traddr) > 255)) {
|
if ((strlen(trid.traddr) > 255)) {
|
||||||
printf("The string len of traddr should <= 255\n");
|
printf("The string len of traddr should <= 255\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(info.subnqn) >= SPDK_NVMF_NQN_MAX_LEN) {
|
if (strlen(trid.subnqn) >= SPDK_NVMF_NQN_MAX_LEN) {
|
||||||
printf("NQN must be less than %d bytes long\n", SPDK_NVMF_NQN_MAX_LEN);
|
printf("NQN must be less than %d bytes long\n", SPDK_NVMF_NQN_MAX_LEN);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
info.trtype = SPDK_NVMF_TRTYPE_RDMA;
|
trid.trtype = SPDK_NVME_TRANSPORT_RDMA;
|
||||||
optind = 1;
|
optind = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -972,8 +972,8 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
if (info.trtype == SPDK_NVMF_TRTYPE_RDMA) {
|
if (trid.trtype == SPDK_NVME_TRANSPORT_RDMA) {
|
||||||
if (spdk_nvme_discover(&info, NULL, probe_cb, attach_cb, NULL) != 0) {
|
if (spdk_nvme_discover(&trid, NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||||
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1009,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
static int
|
static int
|
||||||
register_controllers(void)
|
register_controllers(void)
|
||||||
{
|
{
|
||||||
struct spdk_nvme_discover_info info;
|
struct spdk_nvme_transport_id trid;
|
||||||
char *p, *p1;
|
char *p, *p1;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@ -1021,7 +1021,7 @@ register_controllers(void)
|
|||||||
|
|
||||||
/* The format of g_nvmf_discover_info should be: TRTYPE:TRADDR:TRVCSID */
|
/* The format of g_nvmf_discover_info should be: TRTYPE:TRADDR:TRVCSID */
|
||||||
if (g_nvmf_discover_info) {
|
if (g_nvmf_discover_info) {
|
||||||
info.subnqn = SPDK_NVMF_DISCOVERY_NQN;
|
trid.subnqn = SPDK_NVMF_DISCOVERY_NQN;
|
||||||
|
|
||||||
p = (char *)g_nvmf_discover_info;
|
p = (char *)g_nvmf_discover_info;
|
||||||
p1 = strchr(p, ':');
|
p1 = strchr(p, ':');
|
||||||
@ -1041,7 +1041,7 @@ register_controllers(void)
|
|||||||
fprintf(stderr, "wrong transport type \n");
|
fprintf(stderr, "wrong transport type \n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
info.trtype = SPDK_NVMF_TRTYPE_RDMA;
|
trid.trtype = SPDK_NVME_TRANSPORT_RDMA;
|
||||||
|
|
||||||
p = (char *)p1 + 1;
|
p = (char *)p1 + 1;
|
||||||
p1 = strchr(p, ':');
|
p1 = strchr(p, ':');
|
||||||
@ -1056,11 +1056,11 @@ register_controllers(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
p[n] = '\0';
|
p[n] = '\0';
|
||||||
info.traddr = p;
|
trid.traddr = p;
|
||||||
|
|
||||||
p = (char *)p1 + 1;
|
p = (char *)p1 + 1;
|
||||||
info.trsvcid = p;
|
trid.trsvcid = p;
|
||||||
if (spdk_nvme_discover(&info, NULL, probe_cb, attach_cb, NULL) != 0) {
|
if (spdk_nvme_discover(&trid, NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||||
fprintf(stderr, "spdk_nvme_discover() failed\n");
|
fprintf(stderr, "spdk_nvme_discover() failed\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,32 +110,56 @@ struct spdk_nvme_ctrlr_opts {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NVMe over Fabrics discovery parameters.
|
* NVMe library transports
|
||||||
*
|
*
|
||||||
* This structure must be provided when connecting to remote NVMe controllers via NVMe over Fabrics.
|
* NOTE: These are mapped directly to the NVMe over Fabrics TRTYPE values, except for PCIe,
|
||||||
|
* which is a special case since NVMe over Fabrics does not define a TRTYPE for local PCIe.
|
||||||
|
*
|
||||||
|
* Currently, this uses 256 for PCIe which is intentionally outside of the 8-bit range of TRTYPE.
|
||||||
|
* If the NVMe-oF specification ever defines a PCIe TRTYPE, this should be updated.
|
||||||
*/
|
*/
|
||||||
struct spdk_nvme_discover_info {
|
enum spdk_nvme_transport_type {
|
||||||
|
/**
|
||||||
|
* PCIe Transport (locally attached devices)
|
||||||
|
*/
|
||||||
|
SPDK_NVME_TRANSPORT_PCIE = 256,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RDMA Transport (RoCE, iWARP, etc.)
|
||||||
|
*/
|
||||||
|
SPDK_NVME_TRANSPORT_RDMA = SPDK_NVMF_TRTYPE_RDMA,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NVMe transport identifier.
|
||||||
|
*
|
||||||
|
* This identifies a unique endpoint on an NVMe fabric.
|
||||||
|
*/
|
||||||
|
struct spdk_nvme_transport_id {
|
||||||
/**
|
/**
|
||||||
* NVMe over Fabrics transport type.
|
* NVMe over Fabrics transport type.
|
||||||
*/
|
*/
|
||||||
enum spdk_nvmf_trtype trtype;
|
enum spdk_nvme_transport_type trtype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subsystem NQN of the NVMe over Fabrics discovery service.
|
* Transport address of the NVMe-oF endpoint. For transports which use IP
|
||||||
*/
|
* addressing (e.g. RDMA), this should be an IP address. For PCIe, this
|
||||||
const char *subnqn;
|
* can either be NULL (the whole bus) or a PCI address in the format
|
||||||
|
* DDDD:BB:DD.FF
|
||||||
/**
|
|
||||||
* Transport address of the NVMe over Fabrics discovery service. For transports which use IP
|
|
||||||
* addressing (e.g. RDMA), this should be an IP-based address.
|
|
||||||
*/
|
*/
|
||||||
const char *traddr;
|
const char *traddr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifiy the transport service identifier. For transports which use IP addressing
|
* Transport service id of the NVMe-oF endpoint. For transports which use
|
||||||
* (e.g. RDMA), this field shoud be the port number.
|
* IP addressing (e.g. RDMA), this field shoud be the port number. For PCIe,
|
||||||
|
* this is always NULL.
|
||||||
*/
|
*/
|
||||||
const char *trsvcid;
|
const char *trsvcid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subsystem NQN of the NVMe over Fabrics endpoint. May be NULL.
|
||||||
|
*/
|
||||||
|
const char *subnqn;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -190,7 +214,7 @@ struct spdk_nvme_probe_info {
|
|||||||
*
|
*
|
||||||
* \return true if trtype is supported or false if it is not supported.
|
* \return true if trtype is supported or false if it is not supported.
|
||||||
*/
|
*/
|
||||||
bool spdk_nvme_transport_available(enum spdk_nvmf_trtype trtype);
|
bool spdk_nvme_transport_available(enum spdk_nvme_transport_type trtype);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for spdk_nvme_probe() enumeration.
|
* Callback for spdk_nvme_probe() enumeration.
|
||||||
@ -229,10 +253,10 @@ typedef void (*spdk_nvme_attach_cb)(void *cb_ctx, const struct spdk_nvme_probe_i
|
|||||||
typedef void (*spdk_nvme_remove_cb)(void *cb_ctx, struct spdk_nvme_ctrlr *ctrlr);
|
typedef void (*spdk_nvme_remove_cb)(void *cb_ctx, struct spdk_nvme_ctrlr *ctrlr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief discover the remote Controller via NVMe over fabrics protocol
|
* \brief Perform a device discovery using the discovery service specified by trid.
|
||||||
*
|
*
|
||||||
|
* \param trid The address of the discovery service on which to perform the discovery.
|
||||||
* \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of the callbacks.
|
* \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of the callbacks.
|
||||||
* \param info which specifies the info used to discover the NVMe over fabrics target.
|
|
||||||
* \param probe_cb will be called once per NVMe device found in the system.
|
* \param probe_cb will be called once per NVMe device found in the system.
|
||||||
* \param attach_cb will be called for devices for which probe_cb returned true once that NVMe
|
* \param attach_cb will be called for devices for which probe_cb returned true once that NVMe
|
||||||
* controller has been attached to the userspace driver.
|
* controller has been attached to the userspace driver.
|
||||||
@ -241,8 +265,9 @@ typedef void (*spdk_nvme_remove_cb)(void *cb_ctx, struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
* desired.
|
* desired.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int spdk_nvme_discover(const struct spdk_nvme_discover_info *info,
|
int spdk_nvme_discover(const struct spdk_nvme_transport_id *trid,
|
||||||
void *cb_ctx, spdk_nvme_probe_cb probe_cb,
|
void *cb_ctx,
|
||||||
|
spdk_nvme_probe_cb probe_cb,
|
||||||
spdk_nvme_attach_cb attach_cb,
|
spdk_nvme_attach_cb attach_cb,
|
||||||
spdk_nvme_remove_cb remove_cb);
|
spdk_nvme_remove_cb remove_cb);
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ nvme_attach_one(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb a
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_spdk_nvme_probe(const struct spdk_nvme_discover_info *info, void *cb_ctx,
|
_spdk_nvme_probe(const struct spdk_nvme_transport_id *trid, void *cb_ctx,
|
||||||
spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb attach_cb,
|
spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb attach_cb,
|
||||||
spdk_nvme_remove_cb remove_cb)
|
spdk_nvme_remove_cb remove_cb)
|
||||||
{
|
{
|
||||||
@ -432,19 +432,19 @@ _spdk_nvme_probe(const struct spdk_nvme_discover_info *info, void *cb_ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!info) {
|
if (!trid) {
|
||||||
trtype = SPDK_NVME_TRANSPORT_PCIE;
|
trtype = SPDK_NVME_TRANSPORT_PCIE;
|
||||||
} else {
|
} else {
|
||||||
if (!spdk_nvme_transport_available(info->trtype)) {
|
if (!spdk_nvme_transport_available(trid->trtype)) {
|
||||||
SPDK_ERRLOG("NVMe over Fabrics trtype %u not available\n", info->trtype);
|
SPDK_ERRLOG("NVMe over Fabrics trtype %u not available\n", trid->trtype);
|
||||||
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
|
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
trtype = (uint8_t)info->trtype;
|
trtype = (uint8_t)trid->trtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
nvme_transport_ctrlr_scan(trtype, probe_cb, cb_ctx, (void *)info, NULL);
|
nvme_transport_ctrlr_scan(trtype, probe_cb, cb_ctx, (void *)trid, NULL);
|
||||||
|
|
||||||
if (!spdk_process_is_primary()) {
|
if (!spdk_process_is_primary()) {
|
||||||
TAILQ_FOREACH(ctrlr, &g_spdk_nvme_driver->attached_ctrlrs, tailq) {
|
TAILQ_FOREACH(ctrlr, &g_spdk_nvme_driver->attached_ctrlrs, tailq) {
|
||||||
@ -474,16 +474,17 @@ _spdk_nvme_probe(const struct spdk_nvme_discover_info *info, void *cb_ctx,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spdk_nvme_discover(const struct spdk_nvme_discover_info *info, void *cb_ctx,
|
int spdk_nvme_discover(const struct spdk_nvme_transport_id *trid,
|
||||||
|
void *cb_ctx,
|
||||||
spdk_nvme_probe_cb probe_cb,
|
spdk_nvme_probe_cb probe_cb,
|
||||||
spdk_nvme_attach_cb attach_cb,
|
spdk_nvme_attach_cb attach_cb,
|
||||||
spdk_nvme_remove_cb remove_cb)
|
spdk_nvme_remove_cb remove_cb)
|
||||||
{
|
{
|
||||||
if (!info || !info->traddr || !info->trsvcid || !info->subnqn) {
|
if (!trid || !trid->traddr || !trid->trsvcid || !trid->subnqn) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _spdk_nvme_probe(info, cb_ctx, probe_cb, attach_cb, remove_cb);
|
return _spdk_nvme_probe(trid, cb_ctx, probe_cb, attach_cb, remove_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -222,20 +222,6 @@ struct nvme_request {
|
|||||||
void *user_buffer;
|
void *user_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* NVMe library transports
|
|
||||||
*
|
|
||||||
* NOTE: These are mapped directly to the NVMe over Fabrics TRTYPE values, except for PCIe,
|
|
||||||
* which is a special case since NVMe over Fabrics does not define a TRTYPE for local PCIe.
|
|
||||||
*
|
|
||||||
* Currently, this uses 0 for PCIe since it is reserved by NVMe-oF. If 0 is ever assigned as a
|
|
||||||
* valid TRTYPE, this would need to be changed.
|
|
||||||
*/
|
|
||||||
enum spdk_nvme_transport_type {
|
|
||||||
SPDK_NVME_TRANSPORT_PCIE = 0,
|
|
||||||
SPDK_NVME_TRANSPORT_RDMA = SPDK_NVMF_TRTYPE_RDMA,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct nvme_completion_poll_status {
|
struct nvme_completion_poll_status {
|
||||||
struct spdk_nvme_cpl cpl;
|
struct spdk_nvme_cpl cpl;
|
||||||
bool done;
|
bool done;
|
||||||
|
@ -1048,7 +1048,7 @@ nvme_rdma_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
|||||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
||||||
void *devhandle, void *pci_address)
|
void *devhandle, void *pci_address)
|
||||||
{
|
{
|
||||||
struct spdk_nvme_discover_info *discover_info = devhandle;
|
struct spdk_nvme_transport_id *trid = devhandle;
|
||||||
struct spdk_nvme_probe_info probe_info;
|
struct spdk_nvme_probe_info probe_info;
|
||||||
struct spdk_nvme_ctrlr_opts discovery_opts;
|
struct spdk_nvme_ctrlr_opts discovery_opts;
|
||||||
struct spdk_nvme_ctrlr *discovery_ctrlr;
|
struct spdk_nvme_ctrlr *discovery_ctrlr;
|
||||||
@ -1063,9 +1063,9 @@ nvme_rdma_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
|||||||
discovery_opts.keep_alive_timeout_ms = 0;
|
discovery_opts.keep_alive_timeout_ms = 0;
|
||||||
|
|
||||||
probe_info.trtype = (uint8_t)trtype;
|
probe_info.trtype = (uint8_t)trtype;
|
||||||
snprintf(probe_info.subnqn, sizeof(probe_info.subnqn), "%s", discover_info->subnqn);
|
snprintf(probe_info.subnqn, sizeof(probe_info.subnqn), "%s", trid->subnqn);
|
||||||
snprintf(probe_info.traddr, sizeof(probe_info.traddr), "%s", discover_info->traddr);
|
snprintf(probe_info.traddr, sizeof(probe_info.traddr), "%s", trid->traddr);
|
||||||
snprintf(probe_info.trsvcid, sizeof(probe_info.trsvcid), "%s", discover_info->trsvcid);
|
snprintf(probe_info.trsvcid, sizeof(probe_info.trsvcid), "%s", trid->trsvcid);
|
||||||
|
|
||||||
memset(buffer, 0x0, 4096);
|
memset(buffer, 0x0, 4096);
|
||||||
discovery_ctrlr = nvme_attach(trtype, &discovery_opts, &probe_info, NULL);
|
discovery_ctrlr = nvme_attach(trtype, &discovery_opts, &probe_info, NULL);
|
||||||
|
@ -68,17 +68,14 @@ nvme_transport_unknown(enum spdk_nvme_transport_type trtype)
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
spdk_nvme_transport_available(enum spdk_nvmf_trtype trtype)
|
spdk_nvme_transport_available(enum spdk_nvme_transport_type trtype)
|
||||||
{
|
{
|
||||||
switch (trtype) {
|
switch (trtype) {
|
||||||
case SPDK_NVMF_TRTYPE_RDMA:
|
case SPDK_NVME_TRANSPORT_PCIE:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case SPDK_NVME_TRANSPORT_RDMA:
|
||||||
return TRANSPORT_RDMA_AVAILABLE;
|
return TRANSPORT_RDMA_AVAILABLE;
|
||||||
|
|
||||||
case SPDK_NVMF_TRTYPE_FC:
|
|
||||||
return false;
|
|
||||||
|
|
||||||
case SPDK_NVMF_TRTYPE_INTRA_HOST:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -56,7 +56,7 @@ spdk_pci_device_get_id(struct spdk_pci_device *pci_dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
spdk_nvme_transport_available(enum spdk_nvmf_trtype trtype)
|
spdk_nvme_transport_available(enum spdk_nvme_transport_type trtype)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ static int nvme_request_next_sge(void *cb_arg, void **address, uint32_t *length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
spdk_nvme_transport_available(enum spdk_nvmf_trtype trtype)
|
spdk_nvme_transport_available(enum spdk_nvme_transport_type trtype)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user