The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=88ecf154c7c5a2e413a81ae1b0511b0295265b99

commit 88ecf154c7c5a2e413a81ae1b0511b0295265b99
Author:     John Baldwin <[email protected]>
AuthorDate: 2024-03-23 00:24:18 +0000
Commit:     John Baldwin <[email protected]>
CommitDate: 2024-03-23 00:24:18 +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
---
 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 ef262a864121..fcc96a26eeb1 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -1459,6 +1459,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,
@@ -1591,6 +1592,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;
@@ -2215,4 +2258,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__ */

Reply via email to