static int spdk_nvmf_initialize_pools(void) { SPDK_NOTICELOG("\n*** NVMf Pool Creation ***\n"); g_num_requests = MAX_SUBSYSTEMS * g_nvmf_tgt.MaxConnectionsPerSession * g_nvmf_tgt.MaxQueueDepth; /* create NVMe backend request pool */ request_mempool = rte_mempool_create("NVMe_Pool", g_num_requests, spdk_nvme_request_size(), 128, 0, NULL, NULL, NULL, NULL, SOCKET_ID_ANY, 0); if (!request_mempool) { SPDK_ERRLOG("create NVMe request pool failed\n"); return -1; } SPDK_TRACELOG(SPDK_TRACE_DEBUG, "NVMe request_mempool %p, size %" PRIu64 " bytes\n", request_mempool, (uint64_t)g_num_requests * spdk_nvme_request_size()); return 0; }
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; }
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; int i; rc = parse_args(argc, argv); if (rc != 0) { return rc; } rc = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), ealargs); if (rc < 0) { fprintf(stderr, "could not initialize dpdk\n"); return 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"); return 1; } task_pool = rte_mempool_create("task_pool", 8192, sizeof(struct reset_task), 64, 0, NULL, NULL, task_ctor, NULL, SOCKET_ID_ANY, 0); g_tsc_rate = rte_get_timer_hz(); if (register_workers() != 0) { return 1; } if (register_controllers() != 0) { return 1; } if (associate_workers_with_ns() != 0) { rc = 1; goto cleanup; } printf("Initialization complete. Launching workers.\n"); for (i = 2; i >= 0; i--) { rc = run_nvme_reset_cycle(i); if (rc != 0) { goto cleanup; } } cleanup: unregister_controllers(); if (rc != 0) { fprintf(stderr, "%s: errors occured\n", argv[0]); } return rc; }
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; }
int main(int argc, char **argv) { int rc; struct worker_thread *worker; rc = parse_args(argc, argv); if (rc != 0) { return rc; } ealargs[1] = spdk_sprintf_alloc("-c %s", g_core_mask ? g_core_mask : "0x1"); if (ealargs[1] == NULL) { perror("ealargs spdk_sprintf_alloc"); return 1; } rc = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), ealargs); free(ealargs[1]); if (rc < 0) { fprintf(stderr, "could not initialize dpdk\n"); return 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"); return 1; } task_pool = rte_mempool_create("task_pool", 8192, sizeof(struct perf_task), 64, 0, NULL, NULL, task_ctor, NULL, SOCKET_ID_ANY, 0); g_tsc_rate = rte_get_timer_hz(); if (register_workers() != 0) { rc = -1; goto cleanup; } if (register_aio_files(argc, argv) != 0) { rc = -1; goto cleanup; } if (register_controllers() != 0) { rc = -1; goto cleanup; } if (associate_workers_with_ns() != 0) { rc = -1; goto cleanup; } printf("Initialization complete. Launching workers.\n"); /* Launch all of the slave workers */ worker = g_workers->next; while (worker != NULL) { rte_eal_remote_launch(work_fn, worker, worker->lcore); worker = worker->next; } rc = work_fn(g_workers); worker = g_workers->next; while (worker != NULL) { if (rte_eal_wait_lcore(worker->lcore) < 0) { rc = -1; } worker = worker->next; } print_stats(); cleanup: unregister_namespaces(); unregister_controllers(); unregister_workers(); if (rc != 0) { fprintf(stderr, "%s: errors occured\n", argv[0]); } return rc; }