static void register_ctrlr(struct spdk_nvme_ctrlr *ctrlr) { int num_ns; struct ctrlr_entry *entry = malloc(sizeof(struct ctrlr_entry)); const struct spdk_nvme_ctrlr_data *cdata = spdk_nvme_ctrlr_get_data(ctrlr); if (entry == NULL) { perror("ctrlr_entry malloc"); exit(1); } snprintf(entry->name, sizeof(entry->name), "%-20.20s (%-20.20s)", cdata->mn, cdata->sn); entry->ctrlr = ctrlr; g_ctrlr = entry; num_ns = spdk_nvme_ctrlr_get_num_ns(ctrlr); /* Only register the first namespace. */ if (num_ns < 1) { fprintf(stderr, "controller found with no namespaces\n"); exit(1); } register_ns(ctrlr, spdk_nvme_ctrlr_get_ns(ctrlr, 1)); }
static void register_ctrlr(struct spdk_nvme_ctrlr *ctrlr) { int nsid, num_ns; struct ctrlr_entry *entry = malloc(sizeof(struct ctrlr_entry)); const struct spdk_nvme_ctrlr_data *cdata = spdk_nvme_ctrlr_get_data(ctrlr); if (entry == NULL) { perror("ctrlr_entry malloc"); exit(1); } entry->latency_page = rte_zmalloc("nvme latency", sizeof(struct spdk_nvme_intel_rw_latency_page), 4096); if (entry->latency_page == NULL) { printf("Allocation error (latency page)\n"); exit(1); } snprintf(entry->name, sizeof(entry->name), "%-20.20s (%-20.20s)", cdata->mn, cdata->sn); entry->ctrlr = ctrlr; entry->next = g_controllers; g_controllers = entry; if (g_latency_tracking_enable && spdk_nvme_ctrlr_is_feature_supported(ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING)) set_latency_tracking_feature(ctrlr, true); num_ns = spdk_nvme_ctrlr_get_num_ns(ctrlr); for (nsid = 1; nsid <= num_ns; nsid++) { register_ns(ctrlr, spdk_nvme_ctrlr_get_ns(ctrlr, nsid)); } }
static void register_ctrlr(struct nvme_controller *ctrlr, struct pci_device *pci_dev) { int nsid, num_ns; struct ctrlr_entry *entry = malloc(sizeof(struct ctrlr_entry)); entry->ctrlr = ctrlr; entry->next = g_controllers; g_controllers = entry; num_ns = nvme_ctrlr_get_num_ns(ctrlr); for (nsid = 1; nsid <= num_ns; nsid++) { register_ns(ctrlr, pci_dev, nvme_ctrlr_get_ns(ctrlr, nsid)); } }
static void register_ctrlr(struct spdk_nvme_ctrlr *ctrlr) { int nsid, num_ns; struct ctrlr_entry *entry = malloc(sizeof(struct ctrlr_entry)); if (entry == NULL) { perror("ctrlr_entry malloc"); exit(1); } entry->ctrlr = ctrlr; entry->next = g_controllers; g_controllers = entry; num_ns = spdk_nvme_ctrlr_get_num_ns(ctrlr); for (nsid = 1; nsid <= num_ns; nsid++) { register_ns(ctrlr, spdk_nvme_ctrlr_get_ns(ctrlr, nsid)); } }
static void attach_cb(void *cb_ctx, struct spdk_pci_device *dev, struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts) { int nsid, num_ns; struct ctrlr_entry *entry; const struct spdk_nvme_ctrlr_data *cdata = spdk_nvme_ctrlr_get_data(ctrlr); entry = malloc(sizeof(struct ctrlr_entry)); if (entry == NULL) { perror("ctrlr_entry malloc"); exit(1); } printf("Attached to %04x:%02x:%02x.%02x\n", spdk_pci_device_get_domain(dev), spdk_pci_device_get_bus(dev), spdk_pci_device_get_dev(dev), spdk_pci_device_get_func(dev)); snprintf(entry->name, sizeof(entry->name), "%-20.20s (%-20.20s)", cdata->mn, cdata->sn); entry->ctrlr = ctrlr; entry->next = g_controllers; g_controllers = entry; /* * Each controller has one of more namespaces. An NVMe namespace is basically * equivalent to a SCSI LUN. The controller's IDENTIFY data tells us how * many namespaces exist on the controller. For Intel(R) P3X00 controllers, * it will just be one namespace. * * Note that in NVMe, namespace IDs start at 1, not 0. */ num_ns = spdk_nvme_ctrlr_get_num_ns(ctrlr); printf("Using controller %s with %d namespaces.\n", entry->name, num_ns); for (nsid = 1; nsid <= num_ns; nsid++) { register_ns(ctrlr, spdk_nvme_ctrlr_get_ns(ctrlr, nsid)); } }