From 3eed8456d9b52478f23ff8b5b252ef55d3e16c92 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Tue, 13 Jul 2021 23:51:06 +0800 Subject: [PATCH] nvmf: support get_features with Interrupt Coalescing and Interrupt Vector Configuration The NVMf library will not implement interrupt coalescing and ignore them, but we can report this via get_features. Some OS may check the result from get_features so that it will not send set_features for interrupt coalescing. Change-Id: I7466bcbc0ea5b3b067751cdf1979b2e0681c0043 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8765 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/nvmf/ctrlr.c | 23 +++++++++++++++++++++++ lib/nvmf/nvmf_internal.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index cebe7a6bc8..3abce3450f 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -359,6 +359,8 @@ nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem, ctrlr->feat.async_event_configuration.bits.ana_change_notice = 1; } ctrlr->feat.volatile_write_cache.bits.wce = 1; + /* Coalescing Disable */ + ctrlr->feat.interrupt_vector_configuration.bits.cd = 1; if (ctrlr->subsys->subtype == SPDK_NVMF_SUBTYPE_DISCOVERY) { /* @@ -1427,6 +1429,23 @@ nvmf_ctrlr_get_features_temperature_threshold(struct spdk_nvmf_request *req) return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; } +static int +nvmf_ctrlr_get_features_interrupt_vector_configuration(struct spdk_nvmf_request *req) +{ + struct spdk_nvmf_ctrlr *ctrlr = req->qpair->ctrlr; + struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd; + struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl; + union spdk_nvme_feat_interrupt_vector_configuration iv_conf = {}; + + SPDK_DEBUGLOG(nvmf, "Get Features - Interrupt Vector Configuration (cdw11 = 0x%0x)\n", cmd->cdw11); + + iv_conf.bits.iv = cmd->cdw11_bits.feat_interrupt_vector_configuration.bits.iv; + iv_conf.bits.cd = ctrlr->feat.interrupt_vector_configuration.bits.cd; + rsp->cdw0 = iv_conf.raw; + + return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; +} + static int nvmf_ctrlr_set_features_error_recovery(struct spdk_nvmf_request *req) { @@ -2779,6 +2798,10 @@ nvmf_ctrlr_get_features(struct spdk_nvmf_request *req) return get_features_generic(req, ctrlr->feat.volatile_write_cache.raw); case SPDK_NVME_FEAT_NUMBER_OF_QUEUES: return get_features_generic(req, ctrlr->feat.number_of_queues.raw); + case SPDK_NVME_FEAT_INTERRUPT_COALESCING: + return get_features_generic(req, ctrlr->feat.interrupt_coalescing.raw); + case SPDK_NVME_FEAT_INTERRUPT_VECTOR_CONFIGURATION: + return nvmf_ctrlr_get_features_interrupt_vector_configuration(req); case SPDK_NVME_FEAT_WRITE_ATOMICITY: return get_features_generic(req, ctrlr->feat.write_atomicity.raw); case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION: diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index bfa2dc1c89..92f7ef6227 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -198,6 +198,8 @@ struct spdk_nvmf_ctrlr_feat { union spdk_nvme_feat_error_recovery error_recovery; union spdk_nvme_feat_volatile_write_cache volatile_write_cache; union spdk_nvme_feat_number_of_queues number_of_queues; + union spdk_nvme_feat_interrupt_coalescing interrupt_coalescing; + union spdk_nvme_feat_interrupt_vector_configuration interrupt_vector_configuration; union spdk_nvme_feat_write_atomicity write_atomicity; union spdk_nvme_feat_async_event_configuration async_event_configuration; union spdk_nvme_feat_keep_alive_timer keep_alive_timer;