From 6f3e277885bbcd9cbf216424ba00ea58f2197fc7 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 21 Feb 2024 16:11:17 +0000 Subject: [PATCH] nvme: add spdk_nvme_ctrlr_get_max_sges Signed-off-by: Jim Harris Change-Id: I41ecc9243c8d5b3969e9cc13dde9a538b13d71a3 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21956 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Konrad Sztyber --- CHANGELOG.md | 4 ++++ include/spdk/nvme.h | 11 +++++++++++ lib/nvme/nvme_ctrlr.c | 10 ++++++++++ lib/nvme/spdk_nvme.map | 1 + 4 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d1476cb66b..3f96707db04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ SPDK applications can now start with `--wait-for-rpc` and JSON configuration pro Function `spdk_subsystem_init_from_json_config` is deprecated and will be removed in 24.09 release. Please use `spdk_subsystem_load_config` instead. +### nvme + +Added `spdk_nvme_ctrlr_get_max_sges`. + ### bdev_uring Added `bdev_uring_rescan` RPC to allow rescaning the size of uring bdev. diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 35df561f4a0..8930707a228 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -1330,6 +1330,17 @@ struct spdk_pci_device *spdk_nvme_ctrlr_get_pci_device(struct spdk_nvme_ctrlr *c */ uint32_t spdk_nvme_ctrlr_get_max_xfer_size(const struct spdk_nvme_ctrlr *ctrlr); +/** + * Get the maximum number of SGEs per request for the given NVMe controller. + * + * Controllers that do not support SGL will return UINT16_MAX. + * + * \param ctrlr Opaque handle to NVMe controller. + * + * \return Maximum number of SGEs per request + */ +uint16_t spdk_nvme_ctrlr_get_max_sges(const struct spdk_nvme_ctrlr *ctrlr); + /** * Check whether the nsid is an active nv for the given NVMe controller. * diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index 91220e2d8ca..8ed095c6ec0 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -4571,6 +4571,16 @@ spdk_nvme_ctrlr_get_max_xfer_size(const struct spdk_nvme_ctrlr *ctrlr) return ctrlr->max_xfer_size; } +uint16_t +spdk_nvme_ctrlr_get_max_sges(const struct spdk_nvme_ctrlr *ctrlr) +{ + if (ctrlr->flags & SPDK_NVME_CTRLR_SGL_SUPPORTED) { + return ctrlr->max_sges; + } else { + return UINT16_MAX; + } +} + void spdk_nvme_ctrlr_register_aer_callback(struct spdk_nvme_ctrlr *ctrlr, spdk_nvme_aer_cb aer_cb_fn, diff --git a/lib/nvme/spdk_nvme.map b/lib/nvme/spdk_nvme.map index aabacddcbd9..03a7bfa0f51 100644 --- a/lib/nvme/spdk_nvme.map +++ b/lib/nvme/spdk_nvme.map @@ -56,6 +56,7 @@ spdk_nvme_ctrlr_get_num_ns; spdk_nvme_ctrlr_get_pci_device; spdk_nvme_ctrlr_get_max_xfer_size; + spdk_nvme_ctrlr_get_max_sges; spdk_nvme_ctrlr_is_active_ns; spdk_nvme_ctrlr_get_first_active_ns; spdk_nvme_ctrlr_get_next_active_ns;