Exemple #1
0
static int
set_host_identifier(struct spdk_nvme_ctrlr *ctrlr)
{
    int ret;
    uint64_t host_id;
    struct spdk_nvme_cmd cmd = {};

    cmd.opc = SPDK_NVME_OPC_SET_FEATURES;
    cmd.cdw10 = SPDK_NVME_FEAT_HOST_IDENTIFIER;

    host_id = HOST_ID;

    outstanding_commands = 0;
    set_feature_result = -1;

    fprintf(stdout, "Set Feature: Host Identifier 0x%" PRIx64 "\n", host_id);
    ret = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, &host_id, sizeof(host_id),
                                        set_feature_completion, &features[SPDK_NVME_FEAT_HOST_IDENTIFIER]);
    if (ret) {
        fprintf(stdout, "Set Feature: Failed\n");
        return -1;
    }

    outstanding_commands++;

    while (outstanding_commands) {
        spdk_nvme_ctrlr_process_admin_completions(ctrlr);
    }

    if (set_feature_result)
        fprintf(stdout, "Set Feature: Host Identifier Failed\n");

    return 0;
}
Exemple #2
0
static void
print_latency_statistics(const char *op_name, enum spdk_nvme_intel_log_page log_page)
{
	struct ctrlr_entry	*ctrlr;

	printf("%s Latency Statistics:\n", op_name);
	printf("========================================================\n");
	ctrlr = g_controllers;
	while (ctrlr) {
		if (spdk_nvme_ctrlr_is_log_page_supported(ctrlr->ctrlr, log_page)) {
			if (spdk_nvme_ctrlr_cmd_get_log_page(ctrlr->ctrlr, log_page, SPDK_NVME_GLOBAL_NS_TAG,
							     ctrlr->latency_page, sizeof(struct spdk_nvme_intel_rw_latency_page),
							     enable_latency_tracking_complete,
							     NULL)) {
				printf("nvme_ctrlr_cmd_get_log_page() failed\n");
				exit(1);
			}

			g_outstanding_commands++;
		} else {
			printf("Controller %s: %s latency statistics not supported\n", ctrlr->name, op_name);
		}
		ctrlr = ctrlr->next;
	}

	while (g_outstanding_commands) {
		ctrlr = g_controllers;
		while (ctrlr) {
			spdk_nvme_ctrlr_process_admin_completions(ctrlr->ctrlr);
			ctrlr = ctrlr->next;
		}
	}

	ctrlr = g_controllers;
	while (ctrlr) {
		if (spdk_nvme_ctrlr_is_log_page_supported(ctrlr->ctrlr, log_page)) {
			print_latency_page(ctrlr);
		}
		ctrlr = ctrlr->next;
	}
	printf("\n");
}
Exemple #3
0
static int
get_host_identifier(struct spdk_nvme_ctrlr *ctrlr)
{
	int ret;
	uint64_t *host_id;
	struct spdk_nvme_cmd cmd = {};

	cmd.opc = SPDK_NVME_OPC_GET_FEATURES;
	cmd.cdw10 = SPDK_NVME_FEAT_HOST_IDENTIFIER;

	outstanding_commands = 0;

	host_id = rte_malloc(NULL, 8, 0);
	if (host_id == NULL) {
		fprintf(stderr, "host_id allocation failed\n");
		return -1;
	}
	ret = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, host_id, 8,
					    get_feature_completion, &features[SPDK_NVME_FEAT_HOST_IDENTIFIER]);
	if (ret) {
		fprintf(stdout, "Get Feature: Failed\n");
		rte_free(host_id);
		return -1;
	}

	outstanding_commands++;

	while (outstanding_commands) {
		spdk_nvme_ctrlr_process_admin_completions(ctrlr);
	}

	if (features[SPDK_NVME_FEAT_HOST_IDENTIFIER].valid) {
		fprintf(stdout, "Get Feature: Host Identifier 0x%"PRIx64"\n", *host_id);
	}

	rte_free(host_id);
	return 0;
}
Exemple #4
0
static void
set_latency_tracking_feature(struct spdk_nvme_ctrlr *ctrlr, bool enable)
{
	int res;
	union spdk_nvme_intel_feat_latency_tracking latency_tracking;

	if (enable) {
		latency_tracking.bits.enable = 0x01;
	} else {
		latency_tracking.bits.enable = 0x00;
	}

	res = spdk_nvme_ctrlr_cmd_set_feature(ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING,
					      latency_tracking.raw, 0, NULL, 0, enable_latency_tracking_complete, NULL);
	if (res) {
		printf("fail to allocate nvme request.\n");
		return;
	}
	g_outstanding_commands++;

	while (g_outstanding_commands) {
		spdk_nvme_ctrlr_process_admin_completions(ctrlr);
	}
}
Exemple #5
0
static void
nvmf_direct_ctrlr_poll_for_completions(struct spdk_nvmf_session *session)
{
	spdk_nvme_ctrlr_process_admin_completions(session->subsys->dev.direct.ctrlr);
	spdk_nvme_qpair_process_completions(session->subsys->dev.direct.io_qpair, 0);
}