From 121aca0bc6adf996fe4505c4e9b4c9e72e430733 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Mon, 16 Mar 2020 22:26:50 -0400 Subject: [PATCH] nvme: add SGL dword alignment requirement flag when SGL is supported Dword alignment and granularity are required for the data blocks when the controller reports this capability. Change-Id: I6b6300515a528acb34a032050ceedf673a4b326c Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1315 Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- include/spdk/nvme.h | 3 ++- lib/nvme/nvme_ctrlr.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 0593d91ad..45a0e8b3b 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -397,10 +397,11 @@ struct spdk_nvme_host_id { * Used for identifying if the controller supports these flags. */ enum spdk_nvme_ctrlr_flags { - SPDK_NVME_CTRLR_SGL_SUPPORTED = 0x1, /**< The SGL is supported */ + SPDK_NVME_CTRLR_SGL_SUPPORTED = 0x1, /**< SGL is supported */ SPDK_NVME_CTRLR_SECURITY_SEND_RECV_SUPPORTED = 0x2, /**< security send/receive is supported */ SPDK_NVME_CTRLR_WRR_SUPPORTED = 0x4, /**< Weighted Round Robin is supported */ SPDK_NVME_CTRLR_COMPARE_AND_WRITE_SUPPORTED = 0x8, /**< Compare and write fused operations supported */ + SPDK_NVME_CTRLR_SGL_REQUIRES_DWORD_ALIGNMENT = 0x10, /**< Dword alignment is required for SGL */ }; /** diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index 0d452bcd0..21cd6304d 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -1236,7 +1236,11 @@ nvme_ctrlr_identify_done(void *arg, const struct spdk_nvme_cpl *cpl) } if (ctrlr->cdata.sgls.supported) { + assert(ctrlr->cdata.sgls.supported != 0x3); ctrlr->flags |= SPDK_NVME_CTRLR_SGL_SUPPORTED; + if (ctrlr->cdata.sgls.supported == 0x2) { + ctrlr->flags |= SPDK_NVME_CTRLR_SGL_REQUIRES_DWORD_ALIGNMENT; + } /* * Use MSDBD to ensure our max_sges doesn't exceed what the * controller supports.