nvme: Embed a transport_id in the discovery_info struct
Instead of repeating the fields, just embed a transport_id. Change-Id: I282704c9d59784abd5f7c93be4e47c673fcf6dde Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
a2f35bcc16
commit
5f78155fde
@ -406,9 +406,9 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_probe_inf
|
||||
cdata = spdk_nvme_ctrlr_get_data(ctrlr);
|
||||
|
||||
printf("=====================================================\n");
|
||||
if (probe_info->subnqn[0]) {
|
||||
if (probe_info->trid.subnqn[0]) {
|
||||
printf("NVMe over Fabrics controller at %s:%s: %s\n",
|
||||
probe_info->traddr, probe_info->trsvcid, probe_info->subnqn);
|
||||
probe_info->trid.traddr, probe_info->trid.trsvcid, probe_info->trid.subnqn);
|
||||
} else {
|
||||
printf("NVMe Controller at %04x:%02x:%02x.%x [%04x:%04x]\n",
|
||||
probe_info->pci_addr.domain, probe_info->pci_addr.bus,
|
||||
@ -874,7 +874,8 @@ parse_args(int argc, char **argv)
|
||||
{
|
||||
int op, rc;
|
||||
|
||||
trid.subnqn = SPDK_NVMF_DISCOVERY_NQN;
|
||||
trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
|
||||
snprintf(trid.subnqn, sizeof(trid.subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
||||
|
||||
while ((op = getopt(argc, argv, "a:n:s:t:xH")) != -1) {
|
||||
switch (op) {
|
||||
@ -896,13 +897,14 @@ parse_args(int argc, char **argv)
|
||||
#endif
|
||||
break;
|
||||
case 'a':
|
||||
trid.traddr = optarg;
|
||||
trid.trtype = SPDK_NVME_TRANSPORT_RDMA;
|
||||
snprintf(trid.traddr, sizeof(trid.traddr), "%s", optarg);
|
||||
break;
|
||||
case 's':
|
||||
trid.trsvcid = optarg;
|
||||
snprintf(trid.trsvcid, sizeof(trid.trsvcid), "%s", optarg);
|
||||
break;
|
||||
case 'n':
|
||||
trid.subnqn = optarg;
|
||||
snprintf(trid.subnqn, sizeof(trid.subnqn), "%s", optarg);
|
||||
break;
|
||||
case 'H':
|
||||
default:
|
||||
@ -925,7 +927,6 @@ parse_args(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
trid.trtype = SPDK_NVME_TRANSPORT_RDMA;
|
||||
optind = 1;
|
||||
|
||||
return 0;
|
||||
|
@ -976,9 +976,10 @@ static bool
|
||||
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
||||
struct spdk_nvme_ctrlr_opts *opts)
|
||||
{
|
||||
if (probe_info->subnqn[0]) {
|
||||
if (probe_info->trid.subnqn[0]) {
|
||||
printf("Attaching to NVMe over Fabrics controller at %s:%s: %s\n",
|
||||
probe_info->traddr, probe_info->trsvcid, probe_info->subnqn);
|
||||
probe_info->trid.traddr, probe_info->trid.trsvcid,
|
||||
probe_info->trid.subnqn);
|
||||
} else {
|
||||
printf("Attaching to NVMe Controller at %04x:%02x:%02x.%x [%04x:%04x]\n",
|
||||
probe_info->pci_addr.domain, probe_info->pci_addr.bus,
|
||||
@ -993,9 +994,10 @@ static void
|
||||
attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
||||
struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts)
|
||||
{
|
||||
if (probe_info->subnqn[0]) {
|
||||
if (probe_info->trid.subnqn[0]) {
|
||||
printf("Attached to NVMe over Fabrics controller at %s:%s: %s\n",
|
||||
probe_info->traddr, probe_info->trsvcid, probe_info->subnqn);
|
||||
probe_info->trid.traddr, probe_info->trid.trsvcid,
|
||||
probe_info->trid.subnqn);
|
||||
} else {
|
||||
printf("Attached to NVMe Controller at %04x:%02x:%02x.%x [%04x:%04x]\n",
|
||||
probe_info->pci_addr.domain, probe_info->pci_addr.bus,
|
||||
@ -1021,7 +1023,7 @@ register_controllers(void)
|
||||
|
||||
/* The format of g_nvmf_discover_info should be: TRTYPE:TRADDR:TRVCSID */
|
||||
if (g_nvmf_discover_info) {
|
||||
trid.subnqn = SPDK_NVMF_DISCOVERY_NQN;
|
||||
snprintf(trid.subnqn, sizeof(trid.subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
||||
|
||||
p = (char *)g_nvmf_discover_info;
|
||||
p1 = strchr(p, ':');
|
||||
@ -1056,10 +1058,10 @@ register_controllers(void)
|
||||
return 0;
|
||||
}
|
||||
p[n] = '\0';
|
||||
trid.traddr = p;
|
||||
snprintf(trid.traddr, sizeof(trid.traddr), "%s", p);
|
||||
|
||||
p = (char *)p1 + 1;
|
||||
trid.trsvcid = p;
|
||||
snprintf(trid.trsvcid, sizeof(trid.trsvcid), "%s", p);
|
||||
if (spdk_nvme_discover(&trid, NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||
fprintf(stderr, "spdk_nvme_discover() failed\n");
|
||||
}
|
||||
|
@ -137,29 +137,29 @@ enum spdk_nvme_transport_type {
|
||||
*/
|
||||
struct spdk_nvme_transport_id {
|
||||
/**
|
||||
* NVMe over Fabrics transport type.
|
||||
* NVMe transport type.
|
||||
*/
|
||||
enum spdk_nvme_transport_type trtype;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* can either be NULL (the whole bus) or a PCI address in the format
|
||||
* DDDD:BB:DD.FF
|
||||
* can either be a zero length string (the whole bus) or a PCI address
|
||||
* in the format DDDD:BB:DD.FF
|
||||
*/
|
||||
const char *traddr;
|
||||
char traddr[SPDK_NVMF_TRADDR_MAX_LEN + 1];
|
||||
|
||||
/**
|
||||
* Transport service id of the NVMe-oF endpoint. For transports which use
|
||||
* IP addressing (e.g. RDMA), this field shoud be the port number. For PCIe,
|
||||
* this is always NULL.
|
||||
* this is always a zero length string.
|
||||
*/
|
||||
const char *trsvcid;
|
||||
char trsvcid[SPDK_NVMF_TRSVCID_MAX_LEN + 1];
|
||||
|
||||
/**
|
||||
* Subsystem NQN of the NVMe over Fabrics endpoint. May be NULL.
|
||||
* Subsystem NQN of the NVMe over Fabrics endpoint. May be a zero length string.
|
||||
*/
|
||||
const char *subnqn;
|
||||
char subnqn[SPDK_NVMF_NQN_MAX_LEN + 1];
|
||||
};
|
||||
|
||||
/**
|
||||
@ -180,31 +180,8 @@ struct spdk_nvme_probe_info {
|
||||
*/
|
||||
struct spdk_pci_id pci_id;
|
||||
|
||||
/**
|
||||
* Subsystem NQN.
|
||||
*
|
||||
* If this is not an NVMe over Fabrics controller, this field will be a zero-length string.
|
||||
*/
|
||||
char subnqn[SPDK_NVMF_NQN_MAX_LEN + 1];
|
||||
|
||||
/**
|
||||
* NVMe over Fabrics transport type.
|
||||
*
|
||||
* This field will be 0 if this is not an NVMe over Fabrics controller.
|
||||
*/
|
||||
enum spdk_nvmf_trtype trtype;
|
||||
|
||||
/**
|
||||
* Transport address of the NVMe over Fabrics target. For transports which use IP
|
||||
* addressing (e.g. RDMA), this will be an IP-based address.
|
||||
*/
|
||||
char traddr[SPDK_NVMF_TRADDR_MAX_LEN + 1];
|
||||
|
||||
/**
|
||||
* Transport service identifier. For transports which use IP addressing
|
||||
* (e.g. RDMA), this field will be the port number.
|
||||
*/
|
||||
char trsvcid[SPDK_NVMF_TRSVCID_MAX_LEN + 1];
|
||||
/* The transport identifier */
|
||||
struct spdk_nvme_transport_id trid;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -428,7 +428,7 @@ _spdk_nvme_probe(const struct spdk_nvme_transport_id *trid, void *cb_ctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
trtype = (uint8_t)trid->trtype;
|
||||
trtype = trid->trtype;
|
||||
}
|
||||
|
||||
nvme_transport_ctrlr_scan(trtype, probe_cb, cb_ctx, (void *)trid, NULL);
|
||||
@ -521,7 +521,11 @@ spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb a
|
||||
spdk_nvme_remove_cb remove_cb)
|
||||
{
|
||||
if (hotplug_fd < 0) {
|
||||
return _spdk_nvme_probe(NULL, cb_ctx, probe_cb, attach_cb, remove_cb);
|
||||
struct spdk_nvme_transport_id trid = {};
|
||||
|
||||
trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
|
||||
|
||||
return _spdk_nvme_probe(&trid, cb_ctx, probe_cb, attach_cb, remove_cb);
|
||||
} else {
|
||||
return nvme_hotplug_monitor(cb_ctx, probe_cb, attach_cb, remove_cb);
|
||||
}
|
||||
|
@ -633,8 +633,8 @@ nvme_rdma_qpair_connect(struct nvme_rdma_qpair *rqpair)
|
||||
ctrlr = rqpair->qpair.ctrlr;
|
||||
memset(&sin, 0, sizeof(struct sockaddr_storage));
|
||||
|
||||
SPDK_TRACELOG(SPDK_TRACE_DEBUG, "trsvcid is %s\n", ctrlr->probe_info.trsvcid);
|
||||
rc = nvme_rdma_parse_addr(&sin, ctrlr->probe_info.traddr, ctrlr->probe_info.trsvcid);
|
||||
SPDK_TRACELOG(SPDK_TRACE_DEBUG, "trsvcid is %s\n", ctrlr->probe_info.trid.trsvcid);
|
||||
rc = nvme_rdma_parse_addr(&sin, ctrlr->probe_info.trid.traddr, ctrlr->probe_info.trid.trsvcid);
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("nvme_rdma_parse_addr() failed\n");
|
||||
return -1;
|
||||
@ -769,7 +769,7 @@ nvme_rdma_qpair_fabric_connect(struct nvme_rdma_qpair *rqpair)
|
||||
strncpy((char *)&nvmf_data->hostid, (char *)NVME_HOST_ID_DEFAULT,
|
||||
strlen((char *)NVME_HOST_ID_DEFAULT));
|
||||
strncpy((char *)nvmf_data->hostnqn, ctrlr->opts.hostnqn, sizeof(nvmf_data->hostnqn));
|
||||
strncpy((char *)nvmf_data->subnqn, ctrlr->probe_info.subnqn, sizeof(nvmf_data->subnqn));
|
||||
strncpy((char *)nvmf_data->subnqn, ctrlr->probe_info.trid.subnqn, sizeof(nvmf_data->subnqn));
|
||||
|
||||
if (nvme_qpair_is_admin_queue(&rqpair->qpair)) {
|
||||
rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr,
|
||||
@ -1062,10 +1062,10 @@ nvme_rdma_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
||||
/* For discovery_ctrlr set the timeout to 0 */
|
||||
discovery_opts.keep_alive_timeout_ms = 0;
|
||||
|
||||
probe_info.trtype = (uint8_t)trtype;
|
||||
snprintf(probe_info.subnqn, sizeof(probe_info.subnqn), "%s", trid->subnqn);
|
||||
snprintf(probe_info.traddr, sizeof(probe_info.traddr), "%s", trid->traddr);
|
||||
snprintf(probe_info.trsvcid, sizeof(probe_info.trsvcid), "%s", trid->trsvcid);
|
||||
probe_info.trid.trtype = (uint8_t)trtype;
|
||||
snprintf(probe_info.trid.subnqn, sizeof(probe_info.trid.subnqn), "%s", trid->subnqn);
|
||||
snprintf(probe_info.trid.traddr, sizeof(probe_info.trid.traddr), "%s", trid->traddr);
|
||||
snprintf(probe_info.trid.trsvcid, sizeof(probe_info.trid.trsvcid), "%s", trid->trsvcid);
|
||||
|
||||
memset(buffer, 0x0, 4096);
|
||||
discovery_ctrlr = nvme_rdma_ctrlr_construct(trtype, &discovery_opts, &probe_info, devhandle);
|
||||
@ -1107,10 +1107,10 @@ nvme_rdma_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
||||
continue;
|
||||
}
|
||||
|
||||
probe_info.trtype = entry->trtype;
|
||||
if (!spdk_nvme_transport_available(probe_info.trtype)) {
|
||||
probe_info.trid.trtype = entry->trtype;
|
||||
if (!spdk_nvme_transport_available(probe_info.trid.trtype)) {
|
||||
SPDK_WARNLOG("NVMe transport type %u not available; skipping probe\n",
|
||||
probe_info.trtype);
|
||||
probe_info.trid.trtype);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1121,19 +1121,20 @@ nvme_rdma_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
||||
continue;
|
||||
}
|
||||
len = end - entry->subnqn;
|
||||
memcpy(probe_info.subnqn, entry->subnqn, len);
|
||||
probe_info.subnqn[len] = '\0';
|
||||
memcpy(probe_info.trid.subnqn, entry->subnqn, len);
|
||||
probe_info.trid.subnqn[len] = '\0';
|
||||
|
||||
/* Convert traddr to a null terminated string. */
|
||||
len = spdk_strlen_pad(entry->traddr, sizeof(entry->traddr), ' ');
|
||||
memcpy(probe_info.traddr, entry->traddr, len);
|
||||
memcpy(probe_info.trid.traddr, entry->traddr, len);
|
||||
|
||||
/* Convert trsvcid to a null terminated string. */
|
||||
len = spdk_strlen_pad(entry->trsvcid, sizeof(entry->trsvcid), ' ');
|
||||
memcpy(probe_info.trsvcid, entry->trsvcid, len);
|
||||
memcpy(probe_info.trid.trsvcid, entry->trsvcid, len);
|
||||
|
||||
SPDK_TRACELOG(SPDK_TRACE_DEBUG, "subnqn=%s, trtype=%u, traddr=%s, trsvcid=%s\n",
|
||||
probe_info.subnqn, probe_info.trtype, probe_info.traddr, probe_info.trsvcid);
|
||||
probe_info.trid.subnqn, probe_info.trid.trtype,
|
||||
probe_info.trid.traddr, probe_info.trid.trsvcid);
|
||||
/* Todo: need to differentiate the NVMe over fabrics to avoid duplicated connection */
|
||||
nvme_probe_one(entry->trtype, probe_cb, cb_ctx, &probe_info, NULL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user