[RFC PATCH 2/3] nvme: add NVM set structures
Andrey Nikitin
nikitina at amazon.com
Fri Sep 24 14:08:08 PDT 2021
This patch adds NVM set and SQ association structure as defined by
NVMe 1.4 specification along with a helper function to check for
NVM sets and SQ associations support presented by the controller.
Signed-off-by: Andrey Nikitin <nikitina at amazon.com>
---
drivers/nvme/host/core.c | 1 +
drivers/nvme/host/nvme.h | 8 ++++++++
include/linux/nvme.h | 11 +++++++++--
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 8679a108f571..63d6a2162e72 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2889,6 +2889,7 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
ctrl->kas = le16_to_cpu(id->kas);
ctrl->max_namespaces = le32_to_cpu(id->mnan);
ctrl->ctratt = le32_to_cpu(id->ctratt);
+ ctrl->nsetidmax = le16_to_cpu(id->nsetidmax);
if (id->rtd3e) {
/* us -> s */
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index a2e1f298b217..03be6c913216 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -290,6 +290,7 @@ struct nvme_ctrl {
u32 oaes;
u32 aen_result;
u32 ctratt;
+ u16 nsetidmax;
unsigned int shutdown_timeout;
unsigned int kato;
bool subsystem;
@@ -630,6 +631,13 @@ static inline bool nvme_is_aen_req(u16 qid, __u16 command_id)
nvme_tag_from_cid(command_id) >= NVME_AQ_BLK_MQ_DEPTH;
}
+static inline bool nvme_is_qassoc_supported(struct nvme_ctrl *ctrl)
+{
+ return (ctrl->ctratt & NVME_CTRL_ATTR_NVM_SETS) &&
+ (ctrl->ctratt & NVME_CTRL_ATTR_SQ_ASSOC) &&
+ ctrl->nsetidmax > 0;
+}
+
void nvme_complete_rq(struct request *req);
blk_status_t nvme_host_path_error(struct request *req);
bool nvme_cancel_request(struct request *req, void *data, bool reserved);
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index b7c4c4130b65..04aaeb937c94 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -25,6 +25,7 @@
#define NVME_RDMA_IP_PORT 4420
#define NVME_NSID_ALL 0xffffffff
+#define NVME_MAX_QID 0xffff
enum nvme_subsys_type {
NVME_NQN_DISC = 1, /* Discovery type target subsystem */
@@ -225,7 +226,9 @@ enum {
enum nvme_ctrl_attr {
NVME_CTRL_ATTR_HID_128_BIT = (1 << 0),
+ NVME_CTRL_ATTR_NVM_SETS = (1 << 2),
NVME_CTRL_ATTR_TBKAS = (1 << 6),
+ NVME_CTRL_ATTR_SQ_ASSOC = (1 << 8),
};
struct nvme_id_ctrl {
@@ -276,7 +279,8 @@ struct nvme_id_ctrl {
__le32 sanicap;
__le32 hmminds;
__le16 hmmaxd;
- __u8 rsvd338[4];
+ __le16 nsetidmax;
+ __le16 endgidmax;
__u8 anatt;
__u8 anacap;
__le32 anagrpmax;
@@ -420,6 +424,7 @@ enum {
NVME_ID_CNS_CTRL = 0x01,
NVME_ID_CNS_NS_ACTIVE_LIST = 0x02,
NVME_ID_CNS_NS_DESC_LIST = 0x03,
+ NVME_ID_CNS_NVMSET_LIST = 0x04,
NVME_ID_CNS_CS_NS = 0x05,
NVME_ID_CNS_CS_CTRL = 0x06,
NVME_ID_CNS_NS_PRESENT_LIST = 0x10,
@@ -1166,7 +1171,9 @@ struct nvme_create_sq {
__le16 qsize;
__le16 sq_flags;
__le16 cqid;
- __u32 rsvd12[4];
+ __le16 nvmsetid;
+ __u16 rsvd3;
+ __u32 rsvd13[3];
};
struct nvme_delete_queue {
--
2.32.0
More information about the Linux-nvme
mailing list