git: 759864ad7ad6 - stable/14 - nvme: Add constants and types for the discovery log page
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 27 Aug 2024 01:06:29 UTC
The branch stable/14 has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=759864ad7ad6f7ee949f496cc46ff906be9afcea
commit 759864ad7ad6f7ee949f496cc46ff906be9afcea
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-03-23 00:24:18 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-08-26 18:27:53 +0000
nvme: Add constants and types for the discovery log page
This is used in NVMe over Fabrics to enumerate a list of available
controllers.
Reviewed by: imp
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D44446
(cherry picked from commit 88ecf154c7c5a2e413a81ae1b0511b0295265b99)
---
sys/dev/nvme/nvme.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index b738ab902f89..3bbb1c326efd 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -1458,6 +1458,7 @@ enum nvme_log_page {
NVME_LOG_PERSISTENT_EVENT_LOG = 0x0d,
NVME_LOG_LBA_STATUS_INFORMATION = 0x0e,
NVME_LOG_ENDURANCE_GROUP_EVENT_AGGREGATE = 0x0f,
+ NVME_LOG_DISCOVERY = 0x70,
/* 0x06-0x7F - reserved */
/* 0x80-0xBF - I/O command set specific */
NVME_LOG_RES_NOTIFICATION = 0x80,
@@ -1590,6 +1591,48 @@ struct nvme_device_self_test_page {
_Static_assert(sizeof(struct nvme_device_self_test_page) == 564,
"bad size for nvme_device_self_test_page");
+struct nvme_discovery_log_entry {
+ uint8_t trtype;
+ uint8_t adrfam;
+ uint8_t subtype;
+ uint8_t treq;
+ uint16_t portid;
+ uint16_t cntlid;
+ uint16_t aqsz;
+ uint8_t reserved1[22];
+ uint8_t trsvcid[32];
+ uint8_t reserved2[192];
+ uint8_t subnqn[256];
+ uint8_t traddr[256];
+ union {
+ struct {
+ uint8_t rdma_qptype;
+ uint8_t rdma_prtype;
+ uint8_t rdma_cms;
+ uint8_t reserved[5];
+ uint16_t rdma_pkey;
+ } rdma;
+ struct {
+ uint8_t sectype;
+ } tcp;
+ uint8_t reserved[256];
+ } tsas;
+} __packed __aligned(4);
+
+_Static_assert(sizeof(struct nvme_discovery_log_entry) == 1024,
+ "bad size for nvme_discovery_log_entry");
+
+struct nvme_discovery_log {
+ uint64_t genctr;
+ uint64_t numrec;
+ uint16_t recfmt;
+ uint8_t reserved[1006];
+ struct nvme_discovery_log_entry entries[];
+} __packed __aligned(4);
+
+_Static_assert(sizeof(struct nvme_discovery_log) == 1024,
+ "bad size for nvme_discovery_log");
+
struct nvme_res_notification_page {
uint64_t log_page_count;
uint8_t log_page_type;
@@ -2214,4 +2257,27 @@ nvme_device_self_test_swapbytes(struct nvme_device_self_test_page *s __unused)
}
#endif
}
+
+static inline void
+nvme_discovery_log_entry_swapbytes(struct nvme_discovery_log_entry *s __unused)
+{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
+ s->portid = le16toh(s->portid);
+ s->cntlid = le16toh(s->cntlid);
+ s->aqsz = le16toh(s->aqsz);
+ if (s->trtype == 0x01 /* RDMA */) {
+ s->tsas.rdma.rdma_pkey = le16toh(s->tsas.rdma.rdma_pkey);
+ }
+#endif
+}
+
+static inline void
+nvme_discovery_log_swapbytes(struct nvme_discovery_log *s __unused)
+{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
+ s->genctr = le64toh(s->genctr);
+ s->numrec = le64toh(s->numrec);
+ s->recfmt = le16toh(s->recfmt);
+#endif
+}
#endif /* __NVME_H__ */