int main(int argc, char **argv) { int rc; /* * By default, the SPDK NVMe driver uses DPDK for huge page-based * memory management and NVMe request buffer pools. Huge pages can * be either 2MB or 1GB in size (instead of 4KB) and are pinned in * memory. Pinned memory is important to ensure DMA operations * never target swapped out memory. * * So first we must initialize DPDK. "-c 0x1" indicates to only use * core 0. */ rc = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), ealargs); if (rc < 0) { fprintf(stderr, "could not initialize dpdk\n"); return 1; } /* * Create the NVMe request buffer pool. This will be used internally * by the SPDK NVMe driver to allocate an spdk_nvme_request data * structure for each I/O request. This is implicitly passed to * the SPDK NVMe driver via an extern declaration in nvme_impl.h. */ request_mempool = rte_mempool_create("nvme_request", 8192, spdk_nvme_request_size(), 128, 0, NULL, NULL, NULL, NULL, SOCKET_ID_ANY, 0); if (request_mempool == NULL) { fprintf(stderr, "could not initialize request mempool\n"); return 1; } printf("Initializing NVMe Controllers\n"); /* * Start the SPDK NVMe enumeration process. probe_cb will be called * for each NVMe controller found, giving our application a choice on * whether to attach to each controller. attach_cb will then be * called for each controller after the SPDK NVMe driver has completed * initializing the controller we chose to attach. */ rc = spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL); if (rc != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); cleanup(); return 1; } printf("Initialization complete.\n"); hello_world(); cleanup(); return 0; }
int main(int argc, char **argv) { struct dev *iter; int rc, i; printf("NVMe Write/Read with End-to-End data protection test\n"); rc = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), (char **)(void *)(uintptr_t)ealargs); if (rc < 0) { fprintf(stderr, "could not initialize dpdk\n"); exit(1); } request_mempool = rte_mempool_create("nvme_request", 8192, spdk_nvme_request_size(), 128, 0, NULL, NULL, NULL, NULL, SOCKET_ID_ANY, 0); if (request_mempool == NULL) { fprintf(stderr, "could not initialize request mempool\n"); exit(1); } if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "nvme_probe() failed\n"); exit(1); } rc = 0; foreach_dev(iter) { #define TEST(x) write_read_e2e_dp_tests(iter, x, #x) if (TEST(dp_with_pract_test) || TEST(dp_without_pract_extended_lba_test) || TEST(dp_without_flags_extended_lba_test) || TEST(dp_without_pract_separate_meta_test) || TEST(dp_without_pract_separate_meta_apptag_test) || TEST(dp_without_flags_separate_meta_test)) { #undef TEST rc = 1; printf("%s: failed End-to-End data protection tests\n", iter->name); } } printf("Cleaning up...\n"); for (i = 0; i < num_devs; i++) { struct dev *dev = &devs[i]; spdk_nvme_detach(dev->ctrlr); } return rc; }
static int register_controllers(void) { printf("Initializing NVMe Controllers\n"); if (spdk_nvme_probe(NULL, probe_cb, attach_cb) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } return 0; }
int main(int argc, char **argv) { struct dev *iter; int rc, i; rc = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), (char **)(void *)(uintptr_t)ealargs); if (rc < 0) { fprintf(stderr, "could not initialize dpdk\n"); exit(1); } request_mempool = rte_mempool_create("nvme_request", 8192, spdk_nvme_request_size(), 128, 0, NULL, NULL, NULL, NULL, SOCKET_ID_ANY, 0); if (request_mempool == NULL) { fprintf(stderr, "could not initialize request mempool\n"); exit(1); } if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } rc = 0; foreach_dev(iter) { struct spdk_nvme_qpair *qpair; qpair = spdk_nvme_ctrlr_alloc_io_qpair(iter->ctrlr, 0); if (!qpair) { fprintf(stderr, "spdk_nvme_ctrlr_alloc_io_qpair() failed\n"); rc = 1; } else { reserve_controller(iter->ctrlr, qpair, iter->pci_dev); } } printf("Cleaning up...\n"); for (i = 0; i < num_devs; i++) { struct dev *dev = &devs[i]; spdk_nvme_detach(dev->ctrlr); } return rc; }
static int u2_init(void) { if (rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]),ealargs) < 0) { fprintf(stderr, "failed to initialize DPDK EAL!\n"); return 1; } printf("\n========================================\n"); printf( " nvme_lat/u2_lat - ict.ncic.syssw.ufo" ); printf("\n========================================\n"); request_mempool = rte_mempool_create("nvme_request", U2_REQUEST_POOL_SIZE, spdk_nvme_request_size(), U2_REQUEST_CACHE_SIZE, U2_REQUEST_PRIVATE_SIZE, NULL, NULL, NULL, NULL, SOCKET_ID_ANY, 0); if (request_mempool == NULL) { fprintf(stderr, "failed to create request pool!\n"); return 1; } if (spdk_nvme_probe(NULL, probe_cb, attach_cb)) { fprintf(stderr, "failed to probe and attach to NVMe device!\n"); return 1; } if (!u2_ctrlr) { fprintf(stderr, "failed to probe a suitable controller!\n"); return 1; } if (!spdk_nvme_ns_is_active(u2_ns)) { fprintf(stderr, "namespace %d is IN-ACTIVE!\n", u2_ns_id); return 1; } if (u2_ns_size < io_size) { fprintf(stderr, "invalid I/O size %"PRIu32"!\n", io_size); return 1; } if (!u2_qpair) { fprintf(stderr, "failed to allocate queue pair!\n"); return 1; } return 0; }
int main(int argc, char **argv) { int rc, i; rc = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), (char **)(void *)(uintptr_t)ealargs); if (rc < 0) { fprintf(stderr, "could not initialize dpdk\n"); exit(1); } request_mempool = rte_mempool_create("nvme_request", 8192, spdk_nvme_request_size(), 128, 0, NULL, NULL, NULL, NULL, SOCKET_ID_ANY, 0); if (request_mempool == NULL) { fprintf(stderr, "could not initialize request mempool\n"); exit(1); } if (spdk_nvme_probe(NULL, probe_cb, attach_cb) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } qsort(devs, num_devs, sizeof(devs[0]), cmp_devs); usage(); while (1) { int cmd; bool exit_flag = false; if (!scanf("%d", &cmd)) { printf("Invalid Command\n"); while (getchar() != '\n'); return 0; } switch (cmd) { case 1: display_controller_list(); break; case 2: add_ns(); break; case 3: delete_ns(); break; case 4: attach_and_detach_ns(SPDK_NVME_NS_CTRLR_ATTACH); break; case 5: attach_and_detach_ns(SPDK_NVME_NS_CTRLR_DETACH); break; case 6: format_nvm(); break; case 7: exit_flag = true; break; default: printf("Invalid Command\n"); break; } if (exit_flag) break; while (getchar() != '\n'); printf("press Enter to display cmd menu ...\n"); while (getchar() != '\n'); usage(); } printf("Cleaning up...\n"); for (i = 0; i < num_devs; i++) { struct dev *dev = &devs[i]; spdk_nvme_detach(dev->ctrlr); } return rc; }