Blame libnvme-1.5-nbft.patch

Tomas Bzatek aa9c0e
From 28ad0e9f6ff0bdd56c6afae73072299c4cd71c3a Mon Sep 17 00:00:00 2001
Tomas Bzatek aa9c0e
From: Stuart Hayes <stuart_hayes@dell.com>
Tomas Bzatek aa9c0e
Date: Thu, 31 Mar 2022 13:47:11 -0500
Tomas Bzatek aa9c0e
Subject: [PATCH 01/18] nbft: add NBFT v1.0 table support
Tomas Bzatek aa9c0e
Tomas Bzatek aa9c0e
Added support for parsing and printing the contents
Tomas Bzatek aa9c0e
of the NBFT table (per NVMe-oF boot specification v1.0).
Tomas Bzatek aa9c0e
Tomas Bzatek aa9c0e
Signed-off-by: Stuart Hayes <stuart_hayes@dell.com>
Tomas Bzatek aa9c0e
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Tomas Bzatek aa9c0e
Signed-off-by: Martin Wilck <mwilck@suse.com>
Tomas Bzatek aa9c0e
Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
Tomas Bzatek aa9c0e
Signed-off-by: John Meneghini <jmeneghi@redhat.com>
Tomas Bzatek aa9c0e
---
Tomas Bzatek aa9c0e
 doc/meson.build |    3 +-
Tomas Bzatek aa9c0e
 src/libnvme.h   |    1 +
Tomas Bzatek aa9c0e
 src/libnvme.map |    2 +
Tomas Bzatek aa9c0e
 src/meson.build |    2 +
Tomas Bzatek aa9c0e
 src/nvme/nbft.c |  739 ++++++++++++++++++++++++++++
Tomas Bzatek aa9c0e
 src/nvme/nbft.h | 1238 +++++++++++++++++++++++++++++++++++++++++++++++
Tomas Bzatek aa9c0e
 6 files changed, 1984 insertions(+), 1 deletion(-)
Tomas Bzatek aa9c0e
 create mode 100644 src/nvme/nbft.c
Tomas Bzatek aa9c0e
 create mode 100644 src/nvme/nbft.h
Tomas Bzatek aa9c0e
Tomas Bzatek aa9c0e
diff --git a/doc/meson.build b/doc/meson.build
Tomas Bzatek aa9c0e
index edbc3be..480db17 100644
Tomas Bzatek aa9c0e
--- a/doc/meson.build
Tomas Bzatek aa9c0e
+++ b/doc/meson.build
Tomas Bzatek aa9c0e
@@ -9,14 +9,15 @@
Tomas Bzatek aa9c0e
 #
Tomas Bzatek aa9c0e
 
Tomas Bzatek aa9c0e
 api_files = [
Tomas Bzatek aa9c0e
+  'fabrics.h',
Tomas Bzatek aa9c0e
   'filters.h',
Tomas Bzatek aa9c0e
   'ioctl.h',
Tomas Bzatek aa9c0e
   'linux.h',
Tomas Bzatek aa9c0e
   'log.h',
Tomas Bzatek aa9c0e
   'mi.h',
Tomas Bzatek aa9c0e
+  'nbft.h',
Tomas Bzatek aa9c0e
   'tree.h',
Tomas Bzatek aa9c0e
   'types.h',
Tomas Bzatek aa9c0e
-  'fabrics.h',
Tomas Bzatek aa9c0e
   'util.h'
Tomas Bzatek aa9c0e
 ]
Tomas Bzatek aa9c0e
 
Tomas Bzatek aa9c0e
diff --git a/src/libnvme.h b/src/libnvme.h
Tomas Bzatek aa9c0e
index 6be9058..2c7fe3a 100644
Tomas Bzatek aa9c0e
--- a/src/libnvme.h
Tomas Bzatek aa9c0e
+++ b/src/libnvme.h
Tomas Bzatek aa9c0e
@@ -17,6 +17,7 @@ extern "C" {
Tomas Bzatek aa9c0e
 #include "nvme/types.h"
Tomas Bzatek aa9c0e
 #include "nvme/linux.h"
Tomas Bzatek aa9c0e
 #include "nvme/ioctl.h"
Tomas Bzatek aa9c0e
+#include "nvme/nbft.h"
Tomas Bzatek aa9c0e
 #include "nvme/fabrics.h"
Tomas Bzatek aa9c0e
 #include "nvme/filters.h"
Tomas Bzatek aa9c0e
 #include "nvme/tree.h"
Tomas Bzatek aa9c0e
diff --git a/src/libnvme.map b/src/libnvme.map
Tomas Bzatek aa9c0e
index a1294f4..6aa9fd0 100644
Tomas Bzatek aa9c0e
--- a/src/libnvme.map
Tomas Bzatek aa9c0e
+++ b/src/libnvme.map
Tomas Bzatek aa9c0e
@@ -7,6 +7,8 @@ LIBNVME_1_4 {
Tomas Bzatek aa9c0e
 		nvme_lookup_key;
Tomas Bzatek aa9c0e
 		nvme_set_keyring;
Tomas Bzatek aa9c0e
 		nvme_insert_tls_key;
Tomas Bzatek aa9c0e
+		nvme_nbft_read;
Tomas Bzatek aa9c0e
+		nvme_nbft_free;
Tomas Bzatek aa9c0e
 };
Tomas Bzatek aa9c0e
 
Tomas Bzatek aa9c0e
 LIBNVME_1_3 {
Tomas Bzatek aa9c0e
diff --git a/src/meson.build b/src/meson.build
Tomas Bzatek aa9c0e
index 3732f8c..e8b667c 100644
Tomas Bzatek aa9c0e
--- a/src/meson.build
Tomas Bzatek aa9c0e
+++ b/src/meson.build
Tomas Bzatek aa9c0e
@@ -7,6 +7,7 @@
Tomas Bzatek aa9c0e
 #
Tomas Bzatek aa9c0e
 sources = [
Tomas Bzatek aa9c0e
     'nvme/cleanup.c',
Tomas Bzatek aa9c0e
+    'nvme/nbft.c',
Tomas Bzatek aa9c0e
     'nvme/fabrics.c',
Tomas Bzatek aa9c0e
     'nvme/filters.c',
Tomas Bzatek aa9c0e
     'nvme/ioctl.c',
Tomas Bzatek aa9c0e
@@ -125,6 +126,7 @@ install_headers([
Tomas Bzatek aa9c0e
         'nvme/ioctl.h',
Tomas Bzatek aa9c0e
         'nvme/linux.h',
Tomas Bzatek aa9c0e
         'nvme/log.h',
Tomas Bzatek aa9c0e
+        'nvme/nbft.h',
Tomas Bzatek aa9c0e
         'nvme/tree.h',
Tomas Bzatek aa9c0e
         'nvme/types.h',
Tomas Bzatek aa9c0e
         'nvme/util.h',
Tomas Bzatek aa9c0e
diff --git a/src/nvme/nbft.c b/src/nvme/nbft.c
Tomas Bzatek aa9c0e
new file mode 100644
Tomas Bzatek aa9c0e
index 0000000..f91d21b
Tomas Bzatek aa9c0e
--- /dev/null
Tomas Bzatek aa9c0e
+++ b/src/nvme/nbft.c
Tomas Bzatek aa9c0e
@@ -0,0 +1,739 @@
Tomas Bzatek aa9c0e
+// SPDX-License-Identifier: LGPL-2.1-or-later
Tomas Bzatek aa9c0e
+/*
Tomas Bzatek aa9c0e
+ * This file is part of libnvme.
Tomas Bzatek aa9c0e
+ * Copyright (c) 2021-2022, Dell Inc. or its subsidiaries.  All Rights Reserved.
Tomas Bzatek aa9c0e
+ *
Tomas Bzatek aa9c0e
+ * Authors: Stuart Hayes <Stuart_Hayes@Dell.com>
Tomas Bzatek aa9c0e
+ *
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+#include <errno.h>
Tomas Bzatek aa9c0e
+#include <stdio.h>
Tomas Bzatek aa9c0e
+#include <stdlib.h>
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+#include <arpa/inet.h>
Tomas Bzatek aa9c0e
+#include <ccan/endian/endian.h>
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+#include "private.h"
Tomas Bzatek aa9c0e
+#include "nbft.h"
Tomas Bzatek aa9c0e
+#include "log.h"
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static __u8 csum(const __u8 *buffer, ssize_t length)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	int n;
Tomas Bzatek aa9c0e
+	__u8 sum = 0;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	for (n = 0; n < length; n++)
Tomas Bzatek aa9c0e
+		sum = (__u8)(sum + ((__u8 *)buffer)[n]);
Tomas Bzatek aa9c0e
+	return sum;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static void format_ip_addr(char *buf, size_t buflen, __u8 *addr)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	struct in6_addr *addr_ipv6;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	addr_ipv6 = (struct in6_addr *)addr;
Tomas Bzatek aa9c0e
+	if (addr_ipv6->s6_addr32[0] == 0 &&
Tomas Bzatek aa9c0e
+	    addr_ipv6->s6_addr32[1] == 0 &&
Tomas Bzatek aa9c0e
+	    ntohl(addr_ipv6->s6_addr32[2]) == 0xffff)
Tomas Bzatek aa9c0e
+		/* ipv4 */
Tomas Bzatek aa9c0e
+		inet_ntop(AF_INET, &(addr_ipv6->s6_addr32[3]), buf, buflen);
Tomas Bzatek aa9c0e
+	else
Tomas Bzatek aa9c0e
+		/* ipv6 */
Tomas Bzatek aa9c0e
+		inet_ntop(AF_INET6, addr_ipv6, buf, buflen);
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static bool in_heap(struct nbft_header *header, struct nbft_heap_obj obj)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	if (le16_to_cpu(obj.length) == 0)
Tomas Bzatek aa9c0e
+		return true;
Tomas Bzatek aa9c0e
+	if (le32_to_cpu(obj.offset) < le32_to_cpu(header->heap_offset))
Tomas Bzatek aa9c0e
+		return false;
Tomas Bzatek aa9c0e
+	if (le32_to_cpu(obj.offset) >
Tomas Bzatek aa9c0e
+	    le32_to_cpu(header->heap_offset) + le32_to_cpu(header->heap_length))
Tomas Bzatek aa9c0e
+		return false;
Tomas Bzatek aa9c0e
+	if (le32_to_cpu(obj.offset) + le16_to_cpu(obj.length) >
Tomas Bzatek aa9c0e
+	    le32_to_cpu(header->heap_offset) + le32_to_cpu(header->heap_length))
Tomas Bzatek aa9c0e
+		return false;
Tomas Bzatek aa9c0e
+	return true;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/*
Tomas Bzatek aa9c0e
+ *  Return transport_type string (NBFT Table 2)
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+static char *trtype_to_string(__u8 transport_type)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	switch (transport_type) {
Tomas Bzatek aa9c0e
+	case 3:
Tomas Bzatek aa9c0e
+		return "tcp";
Tomas Bzatek aa9c0e
+	default:
Tomas Bzatek aa9c0e
+		return "invalid";
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+#define verify(condition, message)					\
Tomas Bzatek aa9c0e
+	do {								\
Tomas Bzatek aa9c0e
+		if (!(condition)) {					\
Tomas Bzatek aa9c0e
+			nvme_msg(NULL, LOG_DEBUG, "file %s: " message "\n", \
Tomas Bzatek aa9c0e
+				 nbft->filename);			\
Tomas Bzatek aa9c0e
+			return -EINVAL;					\
Tomas Bzatek aa9c0e
+		}							\
Tomas Bzatek aa9c0e
+	} while (0)
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static int __get_heap_obj(struct nbft_header *header, const char *filename,
Tomas Bzatek aa9c0e
+			  const char *descriptorname, const char *fieldname,
Tomas Bzatek aa9c0e
+			  struct nbft_heap_obj obj, bool is_string,
Tomas Bzatek aa9c0e
+			  char **output)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	if (le16_to_cpu(obj.length) == 0)
Tomas Bzatek aa9c0e
+		return -ENOENT;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if (!in_heap(header, obj)) {
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_DEBUG,
Tomas Bzatek aa9c0e
+			 "file %s: field '%s' in descriptor '%s' has invalid offset or length\n",
Tomas Bzatek aa9c0e
+			 filename, fieldname, descriptorname);
Tomas Bzatek aa9c0e
+		return -EINVAL;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* check that string is zero terminated correctly */
Tomas Bzatek aa9c0e
+	*output = (char *)header + le32_to_cpu(obj.offset);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if (is_string) {
Tomas Bzatek aa9c0e
+		if (strnlen(*output, le16_to_cpu(obj.length) + 1) < le16_to_cpu(obj.length))
Tomas Bzatek aa9c0e
+			nvme_msg(NULL, LOG_DEBUG,
Tomas Bzatek aa9c0e
+				"file %s: string '%s' in descriptor '%s' is shorter (%zd) than specified length (%d)\n",
Tomas Bzatek aa9c0e
+				filename, fieldname, descriptorname,
Tomas Bzatek aa9c0e
+				strnlen(*output, le16_to_cpu(obj.length) + 1),
Tomas Bzatek aa9c0e
+					le16_to_cpu(obj.length));
Tomas Bzatek aa9c0e
+		else if (strnlen(*output, le16_to_cpu(obj.length) + 1) >
Tomas Bzatek aa9c0e
+			le16_to_cpu(obj.length)) {
Tomas Bzatek aa9c0e
+			nvme_msg(NULL, LOG_DEBUG,
Tomas Bzatek aa9c0e
+				 "file %s: string '%s' in descriptor '%s' is not zero terminated\n",
Tomas Bzatek aa9c0e
+				 filename, fieldname, descriptorname);
Tomas Bzatek aa9c0e
+			return -EINVAL;
Tomas Bzatek aa9c0e
+		}
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	return 0;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+#define get_heap_obj(descriptor, obj, is_string, output)	\
Tomas Bzatek aa9c0e
+	__get_heap_obj(header, nbft->filename,			\
Tomas Bzatek aa9c0e
+		       stringify(descriptor), stringify(obj),	\
Tomas Bzatek aa9c0e
+		       descriptor->obj, is_string,		\
Tomas Bzatek aa9c0e
+		       output)
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static struct nbft_info_discovery *discovery_from_index(struct nbft_info *nbft, int i)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	struct nbft_info_discovery **d;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	for (d = nbft->discovery_list; d && *d; d++) {
Tomas Bzatek aa9c0e
+		if ((*d)->index == i)
Tomas Bzatek aa9c0e
+			return *d;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+	return NULL;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static struct nbft_info_hfi *hfi_from_index(struct nbft_info *nbft, int i)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	struct nbft_info_hfi **h;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	for (h = nbft->hfi_list; h && *h; h++) {
Tomas Bzatek aa9c0e
+		if ((*h)->index == i)
Tomas Bzatek aa9c0e
+			return *h;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+	return NULL;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static struct nbft_info_security *security_from_index(struct nbft_info *nbft, int i)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	struct nbft_info_security **s;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	for (s = nbft->security_list; s && *s; s++) {
Tomas Bzatek aa9c0e
+		if ((*s)->index == i)
Tomas Bzatek aa9c0e
+			return *s;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+	return NULL;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static int read_ssns_exended_info(struct nbft_info *nbft,
Tomas Bzatek aa9c0e
+				  struct nbft_info_subsystem_ns *ssns,
Tomas Bzatek aa9c0e
+				  struct nbft_ssns_ext_info *raw_ssns_ei)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	struct nbft_header *header = (struct nbft_header *)nbft->raw_nbft;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	verify(raw_ssns_ei->structure_id == NBFT_DESC_SSNS_EXT_INFO,
Tomas Bzatek aa9c0e
+	       "invalid ID in SSNS extended info descriptor");
Tomas Bzatek aa9c0e
+	verify(raw_ssns_ei->version == 1,
Tomas Bzatek aa9c0e
+	       "invalid version in SSNS extended info descriptor");
Tomas Bzatek aa9c0e
+	verify(le16_to_cpu(raw_ssns_ei->ssns_index) == le16_to_cpu(ssns->index),
Tomas Bzatek aa9c0e
+	       "SSNS index doesn't match extended info descriptor index");
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if (!(le32_to_cpu(raw_ssns_ei->flags) & NBFT_SSNS_EXT_INFO_VALID))
Tomas Bzatek aa9c0e
+		return -EINVAL;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if (le32_to_cpu(raw_ssns_ei->flags) & NBFT_SSNS_EXT_INFO_ADMIN_ASQSZ)
Tomas Bzatek aa9c0e
+		ssns->asqsz = le16_to_cpu(raw_ssns_ei->asqsz);
Tomas Bzatek aa9c0e
+	ssns->controller_id = le16_to_cpu(raw_ssns_ei->cntlid);
Tomas Bzatek aa9c0e
+	get_heap_obj(raw_ssns_ei, dhcp_root_path_str_obj, 1, &ssns->dhcp_root_path_string);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	return 0;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static int read_ssns(struct nbft_info *nbft,
Tomas Bzatek aa9c0e
+		     struct nbft_ssns *raw_ssns,
Tomas Bzatek aa9c0e
+		     struct nbft_info_subsystem_ns **s)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	struct nbft_header *header = (struct nbft_header *)nbft->raw_nbft;
Tomas Bzatek aa9c0e
+	struct nbft_info_subsystem_ns *ssns;
Tomas Bzatek aa9c0e
+	__u8 *ss_hfi_indexes = NULL;
Tomas Bzatek aa9c0e
+	__u8 *tmp = NULL;
Tomas Bzatek aa9c0e
+	int i, ret;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if (!(le16_to_cpu(raw_ssns->flags) & NBFT_SSNS_VALID))
Tomas Bzatek aa9c0e
+		return -EINVAL;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	verify(raw_ssns->structure_id == NBFT_DESC_SSNS,
Tomas Bzatek aa9c0e
+	       "invalid ID in SSNS descriptor");
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	ssns = calloc(1, sizeof(*ssns));
Tomas Bzatek aa9c0e
+	if (!ssns)
Tomas Bzatek aa9c0e
+		return -ENOMEM;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	ssns->index = le16_to_cpu(raw_ssns->index);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* transport type */
Tomas Bzatek aa9c0e
+	verify(raw_ssns->trtype == NBFT_TRTYPE_TCP,
Tomas Bzatek aa9c0e
+	       "invalid transport type in SSNS descriptor");
Tomas Bzatek aa9c0e
+	strncpy(ssns->transport, trtype_to_string(raw_ssns->trtype), sizeof(ssns->transport));
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* transport specific flags */
Tomas Bzatek aa9c0e
+	if (raw_ssns->trtype == NBFT_TRTYPE_TCP) {
Tomas Bzatek aa9c0e
+		if (le16_to_cpu(raw_ssns->trflags) & NBFT_SSNS_PDU_HEADER_DIGEST)
Tomas Bzatek aa9c0e
+			ssns->pdu_header_digest_required = true;
Tomas Bzatek aa9c0e
+		if (le16_to_cpu(raw_ssns->trflags) & NBFT_SSNS_DATA_DIGEST)
Tomas Bzatek aa9c0e
+			ssns->data_digest_required = true;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* primary discovery controller */
Tomas Bzatek aa9c0e
+	if (raw_ssns->primary_discovery_ctrl_index) {
Tomas Bzatek aa9c0e
+		ssns->discovery = discovery_from_index(nbft,
Tomas Bzatek aa9c0e
+						       raw_ssns->primary_discovery_ctrl_index);
Tomas Bzatek aa9c0e
+		if (!ssns->discovery)
Tomas Bzatek aa9c0e
+			nvme_msg(NULL, LOG_DEBUG,
Tomas Bzatek aa9c0e
+				 "file %s: namespace %d discovery controller not found\n",
Tomas Bzatek aa9c0e
+				 nbft->filename, ssns->index);
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* subsystem transport address */
Tomas Bzatek aa9c0e
+	ret = get_heap_obj(raw_ssns, subsys_traddr_obj, 0, (char **)&tmp);
Tomas Bzatek aa9c0e
+	if (ret)
Tomas Bzatek aa9c0e
+		goto fail;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	format_ip_addr(ssns->traddr, sizeof(ssns->traddr), tmp);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* subsystem transport service identifier */
Tomas Bzatek aa9c0e
+	ret = get_heap_obj(raw_ssns, subsys_trsvcid_obj, 1, &ssns->trsvcid);
Tomas Bzatek aa9c0e
+	if (ret)
Tomas Bzatek aa9c0e
+		goto fail;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* subsystem port ID */
Tomas Bzatek aa9c0e
+	ssns->subsys_port_id = le16_to_cpu(raw_ssns->subsys_port_id);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* NSID, NID type, & NID */
Tomas Bzatek aa9c0e
+	ssns->nsid = le32_to_cpu(raw_ssns->nsid);
Tomas Bzatek aa9c0e
+	ssns->nid_type = raw_ssns->nidt;
Tomas Bzatek aa9c0e
+	ssns->nid = raw_ssns->nid;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* security profile */
Tomas Bzatek aa9c0e
+	if (raw_ssns->security_desc_index) {
Tomas Bzatek aa9c0e
+		ssns->security = security_from_index(nbft, raw_ssns->security_desc_index);
Tomas Bzatek aa9c0e
+		if (!ssns->security)
Tomas Bzatek aa9c0e
+			nvme_msg(NULL, LOG_DEBUG,
Tomas Bzatek aa9c0e
+				 "file %s: namespace %d security controller not found\n",
Tomas Bzatek aa9c0e
+				 nbft->filename, ssns->index);
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* HFI descriptors */
Tomas Bzatek aa9c0e
+	ret = get_heap_obj(raw_ssns, secondary_hfi_assoc_obj, 0, (char **)&ss_hfi_indexes);
Tomas Bzatek aa9c0e
+	if (ret)
Tomas Bzatek aa9c0e
+		goto fail;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	ssns->hfis = calloc(le16_to_cpu(raw_ssns->secondary_hfi_assoc_obj.length) + 2,
Tomas Bzatek aa9c0e
+			    sizeof(*ssns->hfis));
Tomas Bzatek aa9c0e
+	if (!ssns->hfis) {
Tomas Bzatek aa9c0e
+		ret = -ENOMEM;
Tomas Bzatek aa9c0e
+		goto fail;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+	ssns->hfis[0] = hfi_from_index(nbft, raw_ssns->primary_hfi_desc_index);
Tomas Bzatek aa9c0e
+	if (!ssns->hfis[0]) {
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_DEBUG,
Tomas Bzatek aa9c0e
+			 "file %s: SSNS %d: HFI %d not found\n",
Tomas Bzatek aa9c0e
+			 nbft->filename, ssns->index, raw_ssns->primary_hfi_desc_index);
Tomas Bzatek aa9c0e
+		ret = -EINVAL;
Tomas Bzatek aa9c0e
+		goto fail;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+	for (i = 0; i < le16_to_cpu(raw_ssns->secondary_hfi_assoc_obj.length); i++) {
Tomas Bzatek aa9c0e
+		ssns->hfis[i + 1] = hfi_from_index(nbft, ss_hfi_indexes[i]);
Tomas Bzatek aa9c0e
+		if (ss_hfi_indexes[i] && !ssns->hfis[i + 1])
Tomas Bzatek aa9c0e
+			nvme_msg(NULL, LOG_DEBUG,
Tomas Bzatek aa9c0e
+				 "file %s: SSNS %d HFI %d not found\n",
Tomas Bzatek aa9c0e
+				 nbft->filename, ssns->index, ss_hfi_indexes[i]);
Tomas Bzatek aa9c0e
+		else
Tomas Bzatek aa9c0e
+			ssns->num_hfis++;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* SSNS NQN */
Tomas Bzatek aa9c0e
+	ret = get_heap_obj(raw_ssns, subsys_ns_nqn_obj, 1, &ssns->subsys_nqn);
Tomas Bzatek aa9c0e
+	if (ret)
Tomas Bzatek aa9c0e
+		goto fail;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/* SSNS extended info */
Tomas Bzatek aa9c0e
+	if (raw_ssns->flags & NBFT_SSNS_EXTENDED_INFO_IN_USE) {
Tomas Bzatek aa9c0e
+		struct nbft_ssns_ext_info *ssns_extended_info;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+		if (!get_heap_obj(raw_ssns, ssns_extended_info_desc_obj, 0,
Tomas Bzatek aa9c0e
+				  (char **)&ssns_extended_info))
Tomas Bzatek aa9c0e
+			read_ssns_exended_info(nbft, ssns, ssns_extended_info);
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	*s = ssns;
Tomas Bzatek aa9c0e
+	return 0;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+fail:
Tomas Bzatek aa9c0e
+	free(ssns);
Tomas Bzatek aa9c0e
+	return ret;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static int read_hfi_info_tcp(struct nbft_info *nbft,
Tomas Bzatek aa9c0e
+			     struct nbft_hfi_info_tcp *raw_hfi_info_tcp,
Tomas Bzatek aa9c0e
+			     struct nbft_info_hfi *hfi)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	struct nbft_header *header = (struct nbft_header *)nbft->raw_nbft;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if ((raw_hfi_info_tcp->flags & NBFT_HFI_INFO_TCP_VALID) == 0)
Tomas Bzatek aa9c0e
+		return -EINVAL;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	verify(raw_hfi_info_tcp->structure_id == NBFT_DESC_HFI_TRINFO,
Tomas Bzatek aa9c0e
+	       "invalid ID in HFI transport descriptor");
Tomas Bzatek aa9c0e
+	verify(raw_hfi_info_tcp->version == 1,
Tomas Bzatek aa9c0e
+	       "invalid version in HFI transport descriptor");
Tomas Bzatek aa9c0e
+	if (le16_to_cpu(raw_hfi_info_tcp->hfi_index) != hfi->index)
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_DEBUG,
Tomas Bzatek aa9c0e
+			 "file %s: HFI descriptor index %d does not match index in HFI transport descriptor\n",
Tomas Bzatek aa9c0e
+			 nbft->filename, hfi->index);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	hfi->tcp_info.pci_sbdf = le32_to_cpu(raw_hfi_info_tcp->pci_sbdf);
Tomas Bzatek aa9c0e
+	memcpy(hfi->tcp_info.mac_addr, raw_hfi_info_tcp->mac_addr,
Tomas Bzatek aa9c0e
+	       sizeof(raw_hfi_info_tcp->mac_addr));
Tomas Bzatek aa9c0e
+	hfi->tcp_info.vlan = le16_to_cpu(raw_hfi_info_tcp->vlan);
Tomas Bzatek aa9c0e
+	hfi->tcp_info.ip_origin = raw_hfi_info_tcp->ip_origin;
Tomas Bzatek aa9c0e
+	format_ip_addr(hfi->tcp_info.ipaddr, sizeof(hfi->tcp_info.ipaddr),
Tomas Bzatek aa9c0e
+		       raw_hfi_info_tcp->ip_address);
Tomas Bzatek aa9c0e
+	hfi->tcp_info.subnet_mask_prefix = raw_hfi_info_tcp->subnet_mask_prefix;
Tomas Bzatek aa9c0e
+	format_ip_addr(hfi->tcp_info.gateway_ipaddr, sizeof(hfi->tcp_info.ipaddr),
Tomas Bzatek aa9c0e
+		       raw_hfi_info_tcp->ip_gateway);
Tomas Bzatek aa9c0e
+	hfi->tcp_info.route_metric = le16_to_cpu(raw_hfi_info_tcp->route_metric);
Tomas Bzatek aa9c0e
+	format_ip_addr(hfi->tcp_info.primary_dns_ipaddr,
Tomas Bzatek aa9c0e
+		       sizeof(hfi->tcp_info.primary_dns_ipaddr),
Tomas Bzatek aa9c0e
+		       raw_hfi_info_tcp->primary_dns);
Tomas Bzatek aa9c0e
+	format_ip_addr(hfi->tcp_info.secondary_dns_ipaddr,
Tomas Bzatek aa9c0e
+		       sizeof(hfi->tcp_info.secondary_dns_ipaddr),
Tomas Bzatek aa9c0e
+		       raw_hfi_info_tcp->secondary_dns);
Tomas Bzatek aa9c0e
+	if (raw_hfi_info_tcp->flags & NBFT_HFI_INFO_TCP_DHCP_OVERRIDE) {
Tomas Bzatek aa9c0e
+		hfi->tcp_info.dhcp_override = true;
Tomas Bzatek aa9c0e
+		format_ip_addr(hfi->tcp_info.dhcp_server_ipaddr,
Tomas Bzatek aa9c0e
+			       sizeof(hfi->tcp_info.dhcp_server_ipaddr),
Tomas Bzatek aa9c0e
+			       raw_hfi_info_tcp->dhcp_server);
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+	get_heap_obj(raw_hfi_info_tcp, host_name_obj, 1, &hfi->tcp_info.host_name);
Tomas Bzatek aa9c0e
+	if (raw_hfi_info_tcp->flags & NBFT_HFI_INFO_TCP_GLOBAL_ROUTE)
Tomas Bzatek aa9c0e
+		hfi->tcp_info.this_hfi_is_default_route = true;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	return 0;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static int read_hfi(struct nbft_info *nbft,
Tomas Bzatek aa9c0e
+		    struct nbft_hfi *raw_hfi,
Tomas Bzatek aa9c0e
+		    struct nbft_info_hfi **h)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	int ret;
Tomas Bzatek aa9c0e
+	struct nbft_info_hfi *hfi;
Tomas Bzatek aa9c0e
+	struct nbft_header *header = (struct nbft_header *)nbft->raw_nbft;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if (!(raw_hfi->flags & NBFT_HFI_VALID))
Tomas Bzatek aa9c0e
+		return -EINVAL;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	verify(raw_hfi->structure_id == NBFT_DESC_HFI,
Tomas Bzatek aa9c0e
+	       "invalid ID in HFI descriptor");
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	hfi = calloc(1, sizeof(struct nbft_info_hfi));
Tomas Bzatek aa9c0e
+	if (!hfi)
Tomas Bzatek aa9c0e
+		return -ENOMEM;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	hfi->index = raw_hfi->index;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/*
Tomas Bzatek aa9c0e
+	 * read HFI transport descriptor for this HFI
Tomas Bzatek aa9c0e
+	 */
Tomas Bzatek aa9c0e
+	if (raw_hfi->trtype == NBFT_TRTYPE_TCP) {
Tomas Bzatek aa9c0e
+		/* TCP */
Tomas Bzatek aa9c0e
+		struct nbft_hfi_info_tcp *raw_hfi_info_tcp;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+		strncpy(hfi->transport, trtype_to_string(raw_hfi->trtype),
Tomas Bzatek aa9c0e
+			sizeof(hfi->transport));
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+		ret = get_heap_obj(raw_hfi, trinfo_obj, 0, (char **)&raw_hfi_info_tcp);
Tomas Bzatek aa9c0e
+		if (ret)
Tomas Bzatek aa9c0e
+			goto fail;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+		ret = read_hfi_info_tcp(nbft, raw_hfi_info_tcp, hfi);
Tomas Bzatek aa9c0e
+		if (ret)
Tomas Bzatek aa9c0e
+			goto fail;
Tomas Bzatek aa9c0e
+	} else {
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_DEBUG,
Tomas Bzatek aa9c0e
+			 "file %s: invalid transport type %d\n",
Tomas Bzatek aa9c0e
+			 nbft->filename, raw_hfi->trtype);
Tomas Bzatek aa9c0e
+		ret = -EINVAL;
Tomas Bzatek aa9c0e
+		goto fail;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	*h = hfi;
Tomas Bzatek aa9c0e
+	return 0;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+fail:
Tomas Bzatek aa9c0e
+	free(hfi);
Tomas Bzatek aa9c0e
+	return ret;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static int read_discovery(struct nbft_info *nbft,
Tomas Bzatek aa9c0e
+			  struct nbft_discovery *raw_discovery,
Tomas Bzatek aa9c0e
+			  struct nbft_info_discovery **d)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	struct nbft_info_discovery *discovery;
Tomas Bzatek aa9c0e
+	struct nbft_header *header = (struct nbft_header *)nbft->raw_nbft;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if (!(raw_discovery->flags & NBFT_DISCOVERY_VALID))
Tomas Bzatek aa9c0e
+		return -EINVAL;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	verify(raw_discovery->structure_id == NBFT_DESC_DISCOVERY,
Tomas Bzatek aa9c0e
+	       "invalid ID in discovery descriptor");
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	discovery = calloc(1, sizeof(struct nbft_info_discovery));
Tomas Bzatek aa9c0e
+	if (!discovery)
Tomas Bzatek aa9c0e
+		return -ENOMEM;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	discovery->index = raw_discovery->index;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if (get_heap_obj(raw_discovery, discovery_ctrl_addr_obj, 1, &discovery->uri))
Tomas Bzatek aa9c0e
+		return -EINVAL;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if (get_heap_obj(raw_discovery, discovery_ctrl_nqn_obj, 1, &discovery->nqn))
Tomas Bzatek aa9c0e
+		return -EINVAL;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	discovery->hfi = hfi_from_index(nbft, raw_discovery->hfi_index);
Tomas Bzatek aa9c0e
+	if (raw_discovery->hfi_index && !discovery->hfi)
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_DEBUG,
Tomas Bzatek aa9c0e
+			 "file %s: discovery %d HFI not found\n",
Tomas Bzatek aa9c0e
+			 nbft->filename, discovery->index);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	discovery->security = security_from_index(nbft, raw_discovery->sec_index);
Tomas Bzatek aa9c0e
+	if (raw_discovery->sec_index && !discovery->security)
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_DEBUG,
Tomas Bzatek aa9c0e
+			 "file %s: discovery %d security descriptor not found\n",
Tomas Bzatek aa9c0e
+			 nbft->filename, discovery->index);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	*d = discovery;
Tomas Bzatek aa9c0e
+	return 0;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static int read_security(struct nbft_info *nbft,
Tomas Bzatek aa9c0e
+			 struct nbft_security *raw_security,
Tomas Bzatek aa9c0e
+			 struct nbft_info_security **s)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	return -EINVAL;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static void read_hfi_descriptors(struct nbft_info *nbft, int num_hfi,
Tomas Bzatek aa9c0e
+				 struct nbft_hfi *raw_hfi_array, int hfi_len)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	int i, cnt;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	nbft->hfi_list = calloc(num_hfi + 1, sizeof(struct nbft_info_hfi));
Tomas Bzatek aa9c0e
+	for (i = 0, cnt = 0; i < num_hfi; i++) {
Tomas Bzatek aa9c0e
+		if (read_hfi(nbft, &raw_hfi_array[i], &nbft->hfi_list[cnt]) == 0)
Tomas Bzatek aa9c0e
+			cnt++;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static void read_security_descriptors(struct nbft_info *nbft, int num_sec,
Tomas Bzatek aa9c0e
+				      struct nbft_security *raw_sec_array, int sec_len)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	int i, cnt;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	nbft->security_list = calloc(num_sec + 1, sizeof(struct nbft_info_security));
Tomas Bzatek aa9c0e
+	for (i = 0, cnt = 0; i < num_sec; i++) {
Tomas Bzatek aa9c0e
+		if (read_security(nbft, &raw_sec_array[i], &nbft->security_list[cnt]) == 0)
Tomas Bzatek aa9c0e
+			cnt++;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static void read_discovery_descriptors(struct nbft_info *nbft, int num_disc,
Tomas Bzatek aa9c0e
+				       struct nbft_discovery *raw_disc_array, int disc_len)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	int i, cnt;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	nbft->discovery_list = calloc(num_disc + 1, sizeof(struct nbft_info_discovery));
Tomas Bzatek aa9c0e
+	for (i = 0, cnt = 0; i < num_disc; i++) {
Tomas Bzatek aa9c0e
+		if (read_discovery(nbft, &raw_disc_array[i], &nbft->discovery_list[cnt]) == 0)
Tomas Bzatek aa9c0e
+			cnt++;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+static void read_ssns_descriptors(struct nbft_info *nbft, int num_ssns,
Tomas Bzatek aa9c0e
+				  struct nbft_ssns *raw_ssns_array, int ssns_len)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	int i, cnt;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	nbft->subsystem_ns_list = calloc(num_ssns + 1, sizeof(struct nbft_info_subsystem_ns));
Tomas Bzatek aa9c0e
+	for (i = 0, cnt = 0; i < num_ssns; i++) {
Tomas Bzatek aa9c0e
+		if (read_ssns(nbft, &raw_ssns_array[i], &nbft->subsystem_ns_list[cnt]) == 0)
Tomas Bzatek aa9c0e
+			cnt++;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * parse_raw_nbft - parses raw ACPI NBFT table and fill in abstracted nbft_info structure
Tomas Bzatek aa9c0e
+ * @nbft: nbft_info struct containing only raw_nbft and raw_nbft_size
Tomas Bzatek aa9c0e
+ *
Tomas Bzatek aa9c0e
+ * Returns 0 on success, errno otherwise.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+static int parse_raw_nbft(struct nbft_info *nbft)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	__u8 *raw_nbft = nbft->raw_nbft;
Tomas Bzatek aa9c0e
+	int raw_nbft_size = nbft->raw_nbft_size;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	struct nbft_header *header;
Tomas Bzatek aa9c0e
+	struct nbft_control *control;
Tomas Bzatek aa9c0e
+	struct nbft_host *host;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	verify(raw_nbft_size >= sizeof(struct nbft_header) + sizeof(struct nbft_control),
Tomas Bzatek aa9c0e
+	       "table is too short");
Tomas Bzatek aa9c0e
+	verify(csum(raw_nbft, raw_nbft_size) == 0, "invalid checksum");
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/*
Tomas Bzatek aa9c0e
+	 * header
Tomas Bzatek aa9c0e
+	 */
Tomas Bzatek aa9c0e
+	header = (struct nbft_header *)raw_nbft;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	verify(strncmp(header->signature, NBFT_HEADER_SIG, 4) == 0, "invalid signature");
Tomas Bzatek aa9c0e
+	verify(le32_to_cpu(header->length) <= raw_nbft_size, "length in header exceeds table length");
Tomas Bzatek aa9c0e
+	verify(header->major_revision == 1, "unsupported major revision");
Tomas Bzatek aa9c0e
+	verify(header->minor_revision == 0, "unsupported minor revision");
Tomas Bzatek aa9c0e
+	verify(le32_to_cpu(header->heap_length) + le32_to_cpu(header->heap_offset) <=
Tomas Bzatek aa9c0e
+	       le32_to_cpu(header->length), "heap exceeds table length");
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/*
Tomas Bzatek aa9c0e
+	 * control
Tomas Bzatek aa9c0e
+	 */
Tomas Bzatek aa9c0e
+	control = (struct nbft_control *)(raw_nbft + sizeof(struct nbft_header));
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if ((control->flags & NBFT_CONTROL_VALID) == 0)
Tomas Bzatek aa9c0e
+		return 0;
Tomas Bzatek aa9c0e
+	verify(control->structure_id == NBFT_DESC_CONTROL,
Tomas Bzatek aa9c0e
+	       "invalid ID in control structure");
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/*
Tomas Bzatek aa9c0e
+	 * host
Tomas Bzatek aa9c0e
+	 */
Tomas Bzatek aa9c0e
+	verify(le32_to_cpu(control->hdesc.offset) + sizeof(struct nbft_host) <=
Tomas Bzatek aa9c0e
+	       le32_to_cpu(header->length) &&
Tomas Bzatek aa9c0e
+	       le32_to_cpu(control->hdesc.offset) >= sizeof(struct nbft_host),
Tomas Bzatek aa9c0e
+	       "host descriptor offset/length is invalid");
Tomas Bzatek aa9c0e
+	host = (struct nbft_host *)(raw_nbft + le32_to_cpu(control->hdesc.offset));
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	verify(host->flags & NBFT_HOST_VALID, "host descriptor valid flag not set");
Tomas Bzatek aa9c0e
+	verify(host->structure_id == NBFT_DESC_HOST, "invalid ID in HOST descriptor");
Tomas Bzatek aa9c0e
+	nbft->host.id = (unsigned char *) &(host->host_id);
Tomas Bzatek aa9c0e
+	if (get_heap_obj(host, host_nqn_obj, 1, &nbft->host.nqn) != 0)
Tomas Bzatek aa9c0e
+		return -EINVAL;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/*
Tomas Bzatek aa9c0e
+	 * HFI
Tomas Bzatek aa9c0e
+	 */
Tomas Bzatek aa9c0e
+	if (control->num_hfi > 0) {
Tomas Bzatek aa9c0e
+		struct nbft_hfi *raw_hfi_array;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+		verify(le32_to_cpu(control->hfio) + sizeof(struct nbft_hfi) *
Tomas Bzatek aa9c0e
+		       control->num_hfi <= le32_to_cpu(header->length),
Tomas Bzatek aa9c0e
+		       "invalid hfi descriptor list offset");
Tomas Bzatek aa9c0e
+		raw_hfi_array = (struct nbft_hfi *)(raw_nbft + le32_to_cpu(control->hfio));
Tomas Bzatek aa9c0e
+		read_hfi_descriptors(nbft, control->num_hfi, raw_hfi_array,
Tomas Bzatek aa9c0e
+				     le16_to_cpu(control->hfil));
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/*
Tomas Bzatek aa9c0e
+	 * security
Tomas Bzatek aa9c0e
+	 */
Tomas Bzatek aa9c0e
+	if (control->num_sec > 0) {
Tomas Bzatek aa9c0e
+		struct nbft_security *raw_security_array;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+		verify(le32_to_cpu(control->seco) + le16_to_cpu(control->secl) *
Tomas Bzatek aa9c0e
+		       control->num_sec <= le32_to_cpu(header->length),
Tomas Bzatek aa9c0e
+		       "invalid security profile desciptor list offset");
Tomas Bzatek aa9c0e
+		raw_security_array = (struct nbft_security *)(raw_nbft +
Tomas Bzatek aa9c0e
+				     le32_to_cpu(control->seco));
Tomas Bzatek aa9c0e
+		read_security_descriptors(nbft, control->num_sec,
Tomas Bzatek aa9c0e
+					  raw_security_array,
Tomas Bzatek aa9c0e
+					  le16_to_cpu(control->secl));
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/*
Tomas Bzatek aa9c0e
+	 * discovery
Tomas Bzatek aa9c0e
+	 */
Tomas Bzatek aa9c0e
+	if (control->num_disc > 0) {
Tomas Bzatek aa9c0e
+		struct nbft_discovery *raw_discovery_array;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+		verify(le32_to_cpu(control->disco) + le16_to_cpu(control->discl) *
Tomas Bzatek aa9c0e
+		       control->num_disc <= le32_to_cpu(header->length),
Tomas Bzatek aa9c0e
+		       "invalid discovery profile descriptor list offset");
Tomas Bzatek aa9c0e
+		raw_discovery_array = (struct nbft_discovery *)(raw_nbft +
Tomas Bzatek aa9c0e
+				      le32_to_cpu(control->disco));
Tomas Bzatek aa9c0e
+		read_discovery_descriptors(nbft, control->num_disc, raw_discovery_array,
Tomas Bzatek aa9c0e
+					   le16_to_cpu(control->discl));
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/*
Tomas Bzatek aa9c0e
+	 * subsystem namespace
Tomas Bzatek aa9c0e
+	 */
Tomas Bzatek aa9c0e
+	if (control->num_ssns > 0) {
Tomas Bzatek aa9c0e
+		struct nbft_ssns *raw_ssns_array;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+		verify(le32_to_cpu(control->ssnso) + le16_to_cpu(control->ssnsl) *
Tomas Bzatek aa9c0e
+		       control->num_ssns <= le32_to_cpu(header->length),
Tomas Bzatek aa9c0e
+		       "invalid subsystem namespace descriptor list offset");
Tomas Bzatek aa9c0e
+		raw_ssns_array = (struct nbft_ssns *)(raw_nbft +
Tomas Bzatek aa9c0e
+				 le32_to_cpu(control->ssnso));
Tomas Bzatek aa9c0e
+		read_ssns_descriptors(nbft, control->num_ssns, raw_ssns_array,
Tomas Bzatek aa9c0e
+				      le16_to_cpu(control->ssnsl));
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	return 0;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * nvme_nbft_free() - Free the struct nbft_info and its contents
Tomas Bzatek aa9c0e
+ * @nbft: Parsed NBFT table data.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+void nvme_nbft_free(struct nbft_info *nbft)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	struct nbft_info_hfi **hfi;
Tomas Bzatek aa9c0e
+	struct nbft_info_security **sec;
Tomas Bzatek aa9c0e
+	struct nbft_info_discovery **disc;
Tomas Bzatek aa9c0e
+	struct nbft_info_subsystem_ns **ns;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	for (hfi = nbft->hfi_list; hfi && *hfi; hfi++)
Tomas Bzatek aa9c0e
+		free(*hfi);
Tomas Bzatek aa9c0e
+	free(nbft->hfi_list);
Tomas Bzatek aa9c0e
+	for (disc = nbft->discovery_list; disc && *disc; disc++)
Tomas Bzatek aa9c0e
+		free(*disc);
Tomas Bzatek aa9c0e
+	free(nbft->discovery_list);
Tomas Bzatek aa9c0e
+	for (sec = nbft->security_list; sec && *sec; sec++)
Tomas Bzatek aa9c0e
+		free(*sec);
Tomas Bzatek aa9c0e
+	free(nbft->security_list);
Tomas Bzatek aa9c0e
+	for (ns = nbft->subsystem_ns_list; ns && *ns; ns++) {
Tomas Bzatek aa9c0e
+		free((*ns)->hfis);
Tomas Bzatek aa9c0e
+		free(*ns);
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+	free(nbft->subsystem_ns_list);
Tomas Bzatek aa9c0e
+	free(nbft->raw_nbft);
Tomas Bzatek aa9c0e
+	free(nbft->filename);
Tomas Bzatek aa9c0e
+	free(nbft);
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * nvme_nbft_read() - Read and parse contents of an ACPI NBFT table
Tomas Bzatek aa9c0e
+ *
Tomas Bzatek aa9c0e
+ * @nbft:     Parsed NBFT table data.
Tomas Bzatek aa9c0e
+ * @filename: Filename of the raw NBFT table to read.
Tomas Bzatek aa9c0e
+ *
Tomas Bzatek aa9c0e
+ * Read and parse the specified NBFT file into a struct nbft_info.
Tomas Bzatek aa9c0e
+ * Free with nbft_free().
Tomas Bzatek aa9c0e
+ *
Tomas Bzatek aa9c0e
+ * Return: 0 on success, errno otherwise.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+int nvme_nbft_read(struct nbft_info **nbft, const char *filename)
Tomas Bzatek aa9c0e
+{
Tomas Bzatek aa9c0e
+	__u8 *raw_nbft = NULL;
Tomas Bzatek aa9c0e
+	size_t raw_nbft_size;
Tomas Bzatek aa9c0e
+	FILE *raw_nbft_fp = NULL;
Tomas Bzatek aa9c0e
+	int i;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/*
Tomas Bzatek aa9c0e
+	 * read in raw nbft file
Tomas Bzatek aa9c0e
+	 */
Tomas Bzatek aa9c0e
+	raw_nbft_fp = fopen(filename, "rb");
Tomas Bzatek aa9c0e
+	if (raw_nbft_fp == NULL) {
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_ERR, "Failed to open %s: %s\n",
Tomas Bzatek aa9c0e
+			 filename, strerror(errno));
Tomas Bzatek aa9c0e
+		errno = EINVAL;
Tomas Bzatek aa9c0e
+		return 1;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	i = fseek(raw_nbft_fp, 0L, SEEK_END);
Tomas Bzatek aa9c0e
+	if (i) {
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_ERR, "Failed to read from %s: %s\n",
Tomas Bzatek aa9c0e
+			 filename, strerror(errno));
Tomas Bzatek aa9c0e
+		fclose(raw_nbft_fp);
Tomas Bzatek aa9c0e
+		errno = EINVAL;
Tomas Bzatek aa9c0e
+		return 1;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	raw_nbft_size = ftell(raw_nbft_fp);
Tomas Bzatek aa9c0e
+	rewind(raw_nbft_fp);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	raw_nbft = malloc(raw_nbft_size);
Tomas Bzatek aa9c0e
+	if (!raw_nbft) {
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_ERR, "Failed to allocate memory for NBFT table");
Tomas Bzatek aa9c0e
+		fclose(raw_nbft_fp);
Tomas Bzatek aa9c0e
+		errno = ENOMEM;
Tomas Bzatek aa9c0e
+		return 1;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	i = fread(raw_nbft, sizeof(*raw_nbft), raw_nbft_size, raw_nbft_fp);
Tomas Bzatek aa9c0e
+	if (i != raw_nbft_size) {
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_ERR, "Failed to read from %s: %s\n",
Tomas Bzatek aa9c0e
+			 filename, strerror(errno));
Tomas Bzatek aa9c0e
+		fclose(raw_nbft_fp);
Tomas Bzatek aa9c0e
+		free(raw_nbft);
Tomas Bzatek aa9c0e
+		errno = EINVAL;
Tomas Bzatek aa9c0e
+		return 1;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+	fclose(raw_nbft_fp);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	/*
Tomas Bzatek aa9c0e
+	 * alloc new struct nbft_info, add raw nbft & filename to it, and add it to the list
Tomas Bzatek aa9c0e
+	 */
Tomas Bzatek aa9c0e
+	*nbft = calloc(1, sizeof(struct nbft_info));
Tomas Bzatek aa9c0e
+	if (!*nbft) {
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_ERR, "Could not allocate memory for NBFT\n");
Tomas Bzatek aa9c0e
+		free(raw_nbft);
Tomas Bzatek aa9c0e
+		errno = ENOMEM;
Tomas Bzatek aa9c0e
+		return 1;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	(*nbft)->filename = strdup(filename);
Tomas Bzatek aa9c0e
+	(*nbft)->raw_nbft = raw_nbft;
Tomas Bzatek aa9c0e
+	(*nbft)->raw_nbft_size = raw_nbft_size;
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+	if (parse_raw_nbft(*nbft)) {
Tomas Bzatek aa9c0e
+		nvme_msg(NULL, LOG_ERR, "Failed to parse %s\n", filename);
Tomas Bzatek aa9c0e
+		nvme_nbft_free(*nbft);
Tomas Bzatek aa9c0e
+		errno = EINVAL;
Tomas Bzatek aa9c0e
+		return 1;
Tomas Bzatek aa9c0e
+	}
Tomas Bzatek aa9c0e
+	return 0;
Tomas Bzatek aa9c0e
+}
Tomas Bzatek aa9c0e
diff --git a/src/nvme/nbft.h b/src/nvme/nbft.h
Tomas Bzatek aa9c0e
new file mode 100644
Tomas Bzatek aa9c0e
index 0000000..c3caa85
Tomas Bzatek aa9c0e
--- /dev/null
Tomas Bzatek aa9c0e
+++ b/src/nvme/nbft.h
Tomas Bzatek aa9c0e
@@ -0,0 +1,1238 @@
Tomas Bzatek aa9c0e
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
Tomas Bzatek aa9c0e
+/*
Tomas Bzatek aa9c0e
+ * This file is part of libnvme.
Tomas Bzatek aa9c0e
+ * Copyright (c) 2021-2022, Dell Inc. or its subsidiaries.  All Rights Reserved.
Tomas Bzatek aa9c0e
+ *
Tomas Bzatek aa9c0e
+ * Authors: Stuart Hayes <Stuart_Hayes@Dell.com>
Tomas Bzatek aa9c0e
+ *
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+#ifndef _NBFT_H
Tomas Bzatek aa9c0e
+#define _NBFT_H
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+#include <sys/types.h>
Tomas Bzatek aa9c0e
+#include "util.h"
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/*
Tomas Bzatek aa9c0e
+ *  ACPI NBFT table structures (TP8012 Boot Specification rev. 1.0)
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_desc_type - NBFT Elements - Descriptor Types (Figure 5)
Tomas Bzatek aa9c0e
+ * @NBFT_DESC_HEADER:	     Header: an ACPI structure header with some additional
Tomas Bzatek aa9c0e
+ *			     NBFT specific info.
Tomas Bzatek aa9c0e
+ * @NBFT_DESC_CONTROL:	     Control Descriptor: indicates the location of host,
Tomas Bzatek aa9c0e
+ *			     HFI, SSNS, security, and discovery descriptors.
Tomas Bzatek aa9c0e
+ * @NBFT_DESC_HOST:	     Host Descriptor: host information.
Tomas Bzatek aa9c0e
+ * @NBFT_DESC_HFI:	     HFI Descriptor: an indexable table of HFI Descriptors,
Tomas Bzatek aa9c0e
+ *			     one for each fabric interface on the host.
Tomas Bzatek aa9c0e
+ * @NBFT_DESC_SSNS:	     Subsystem Namespace Descriptor: an indexable table
Tomas Bzatek aa9c0e
+ *			     of SSNS Descriptors.
Tomas Bzatek aa9c0e
+ * @NBFT_DESC_SECURITY:	     Security Descriptor: an indexable table of Security
Tomas Bzatek aa9c0e
+ *			     descriptors.
Tomas Bzatek aa9c0e
+ * @NBFT_DESC_DISCOVERY:     Discovery Descriptor: an indexable table of Discovery
Tomas Bzatek aa9c0e
+ *			     Descriptors.
Tomas Bzatek aa9c0e
+ * @NBFT_DESC_HFI_TRINFO:    HFI Transport Descriptor: indicated by an HFI Descriptor,
Tomas Bzatek aa9c0e
+ *			     corresponds to a specific transport for a single HFI.
Tomas Bzatek aa9c0e
+ * @NBFT_DESC_RESERVED_8:    Reserved.
Tomas Bzatek aa9c0e
+ * @NBFT_DESC_SSNS_EXT_INFO: SSNS Extended Info Descriptor: indicated by an SSNS
Tomas Bzatek aa9c0e
+ *			     Descriptor if required.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_desc_type {
Tomas Bzatek aa9c0e
+	NBFT_DESC_HEADER	= 0,
Tomas Bzatek aa9c0e
+	NBFT_DESC_CONTROL	= 1,
Tomas Bzatek aa9c0e
+	NBFT_DESC_HOST		= 2,
Tomas Bzatek aa9c0e
+	NBFT_DESC_HFI		= 3,
Tomas Bzatek aa9c0e
+	NBFT_DESC_SSNS		= 4,
Tomas Bzatek aa9c0e
+	NBFT_DESC_SECURITY	= 5,
Tomas Bzatek aa9c0e
+	NBFT_DESC_DISCOVERY	= 6,
Tomas Bzatek aa9c0e
+	NBFT_DESC_HFI_TRINFO	= 7,
Tomas Bzatek aa9c0e
+	NBFT_DESC_RESERVED_8	= 8,
Tomas Bzatek aa9c0e
+	NBFT_DESC_SSNS_EXT_INFO	= 9,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_trtype - NBFT Interface Transport Types (Figure 7)
Tomas Bzatek aa9c0e
+ * @NBFT_TRTYPE_TCP: NVMe/TCP (802.3 + TCP/IP). String Designator "tcp".
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_trtype {
Tomas Bzatek aa9c0e
+	NBFT_TRTYPE_TCP	= 3,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+#define NBFT_HEADER_SIG		"NBFT"
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_heap_obj - NBFT Header Driver Signature
Tomas Bzatek aa9c0e
+ * @offset: Offset in bytes of the heap object, if any, from byte offset 0h
Tomas Bzatek aa9c0e
+ *	    of the NBFT Table Header.
Tomas Bzatek aa9c0e
+ * @length: Length in bytes of the heap object, if any.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_heap_obj {
Tomas Bzatek aa9c0e
+	__le32 offset;
Tomas Bzatek aa9c0e
+	__le16 length;
Tomas Bzatek aa9c0e
+} __attribute__((packed));
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_header - NBFT Table - Header (Figure 8)
Tomas Bzatek aa9c0e
+ * @signature:		 Signature: An ASCII string representation of the table
Tomas Bzatek aa9c0e
+ *			 identifier. This field shall be set to the value 4E424654h
Tomas Bzatek aa9c0e
+ *			 (i.e. "NBFT", see #NBFT_HEADER_SIG).
Tomas Bzatek aa9c0e
+ * @length:		 Length: The length of the table, in bytes, including the
Tomas Bzatek aa9c0e
+ *			 header, starting from offset 0h. This field is used to record
Tomas Bzatek aa9c0e
+ *			 the size of the entire table.
Tomas Bzatek aa9c0e
+ * @major_revision:	 Major Revision: The major revision of the structure
Tomas Bzatek aa9c0e
+ *			 corresponding to the Signature field. Larger major revision
Tomas Bzatek aa9c0e
+ *			 numbers should not be assumed backward compatible to lower
Tomas Bzatek aa9c0e
+ *			 major revision numbers with the same signature.
Tomas Bzatek aa9c0e
+ * @checksum:		 Checksum: The entire table, including the Checksum field,
Tomas Bzatek aa9c0e
+ *			 shall sum to 0h to be considered valid.
Tomas Bzatek aa9c0e
+ * @oem_id:		 OEMID shall be populated by the NBFT driver writer by
Tomas Bzatek aa9c0e
+ *			 an OEM-supplied string that identifies the OEM. All
Tomas Bzatek aa9c0e
+ *			 trailing bytes shall be NULL.
Tomas Bzatek aa9c0e
+ * @oem_table_id:	 OEM Table ID: This field shall be populated by the NBFT
Tomas Bzatek aa9c0e
+ *			 driver writer with an OEM-supplied string that the OEM
Tomas Bzatek aa9c0e
+ *			 uses to identify the particular data table. This field is
Tomas Bzatek aa9c0e
+ *			 particularly useful when defining a definition block to
Tomas Bzatek aa9c0e
+ *			 distinguish definition block functions. The OEM assigns
Tomas Bzatek aa9c0e
+ *			 each dissimilar table a new OEM Table ID.
Tomas Bzatek aa9c0e
+ * @oem_revision:	 OEM Revision: An OEM-supplied revision number. Larger
Tomas Bzatek aa9c0e
+ *			 numbers are assumed to be newer revisions.
Tomas Bzatek aa9c0e
+ * @creator_id:		 Creator ID: Vendor ID of utility that created the table.
Tomas Bzatek aa9c0e
+ *			 For instance, this may be the ID for the ASL Compiler.
Tomas Bzatek aa9c0e
+ * @creator_revision:	 Creator Revision: Revision of utility that created the
Tomas Bzatek aa9c0e
+ *			 table. For instance, this may be the ID for the ASL Compiler.
Tomas Bzatek aa9c0e
+ * @heap_offset:	 Heap Offset (HO): This field indicates the offset in bytes
Tomas Bzatek aa9c0e
+ *			 of the heap, if any, from byte offset 0h of the NBFT
Tomas Bzatek aa9c0e
+ *			 Table Header.
Tomas Bzatek aa9c0e
+ * @heap_length:	 Heap Length (HL): The length of the heap, if any.
Tomas Bzatek aa9c0e
+ * @driver_dev_path_sig: Driver Signature Heap Object Reference: This field indicates
Tomas Bzatek aa9c0e
+ *			 the offset in bytes of a heap object containing the Driver
Tomas Bzatek aa9c0e
+ *			 Signature, if any, from byte offset 0h of the NBFT Table
Tomas Bzatek aa9c0e
+ *			 Header.
Tomas Bzatek aa9c0e
+ * @minor_revision:	 Minor Revision: The minor revision of the structure
Tomas Bzatek aa9c0e
+ *			 corresponding to the Signature field. If the major revision
Tomas Bzatek aa9c0e
+ *			 numbers are the same, any minor revision number differences
Tomas Bzatek aa9c0e
+ *			 shall be backwards compatible with the same signature.
Tomas Bzatek aa9c0e
+ * @reserved:		 Reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_header {
Tomas Bzatek aa9c0e
+	char signature[4];
Tomas Bzatek aa9c0e
+	__le32 length;
Tomas Bzatek aa9c0e
+	__u8 major_revision;
Tomas Bzatek aa9c0e
+	__u8 checksum;
Tomas Bzatek aa9c0e
+	char oem_id[6];
Tomas Bzatek aa9c0e
+	char oem_table_id[8];
Tomas Bzatek aa9c0e
+	__le32 oem_revision;
Tomas Bzatek aa9c0e
+	__le32 creator_id;
Tomas Bzatek aa9c0e
+	__le32 creator_revision;
Tomas Bzatek aa9c0e
+	__le32 heap_offset;
Tomas Bzatek aa9c0e
+	__le32 heap_length;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj driver_dev_path_sig;
Tomas Bzatek aa9c0e
+	__u8 minor_revision;
Tomas Bzatek aa9c0e
+	__u8 reserved[13];
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_control - NBFT Table - Control Descriptor (Figure 8)
Tomas Bzatek aa9c0e
+ * @structure_id:   Structure ID: This field specifies the element (refer to
Tomas Bzatek aa9c0e
+ *		    &enum nbft_desc_type). This field shall be set to 1h (i.e.,
Tomas Bzatek aa9c0e
+ *		    Control, #NBFT_DESC_CONTROL).
Tomas Bzatek aa9c0e
+ * @major_revision: Major Revision: The major revision of the structure corresponding
Tomas Bzatek aa9c0e
+ *		    to the Signature field. Larger major revision numbers should
Tomas Bzatek aa9c0e
+ *		    not be assumed backward compatible to lower major revision
Tomas Bzatek aa9c0e
+ *		    numbers with the same signature.
Tomas Bzatek aa9c0e
+ * @minor_revision: Minor Revision: The minor revision of the structure corresponding
Tomas Bzatek aa9c0e
+ *		    to the signature field. If the major revision numbers are
Tomas Bzatek aa9c0e
+ *		    the same, any minor revision number differences shall be backwards
Tomas Bzatek aa9c0e
+ *		    compatible with the same signature.
Tomas Bzatek aa9c0e
+ * @reserved1:	    Reserved.
Tomas Bzatek aa9c0e
+ * @csl:	    Control Structure Length (CSL): This field indicates the length
Tomas Bzatek aa9c0e
+ *		    in bytes of the Control Descriptor.
Tomas Bzatek aa9c0e
+ * @flags:	    Flags, see &enum nbft_control_flags.
Tomas Bzatek aa9c0e
+ * @reserved2:	    Reserved.
Tomas Bzatek aa9c0e
+ * @hdesc:	    Host Descriptor (HDESC): This field indicates the location
Tomas Bzatek aa9c0e
+ *		    and length of the Host Descriptor (see &struct nbft_host).
Tomas Bzatek aa9c0e
+ * @hsv:	    Host Descriptor Version (HSV): This field indicates the version
Tomas Bzatek aa9c0e
+ *		    of the Host Descriptor.
Tomas Bzatek aa9c0e
+ * @reserved3:	    Reserved.
Tomas Bzatek aa9c0e
+ * @hfio:	    HFI Descriptor List Offset (HFIO): If this field is set to
Tomas Bzatek aa9c0e
+ *		    a non-zero value, then this field indicates the offset in bytes
Tomas Bzatek aa9c0e
+ *		    of the HFI Descriptor List, if any, from byte offset 0h of the
Tomas Bzatek aa9c0e
+ *		    NBFT Table Header. If the @num_hfi field is cleared to 0h,
Tomas Bzatek aa9c0e
+ *		    then this field is reserved.
Tomas Bzatek aa9c0e
+ * @hfil:	    HFI Descriptor Length (HFIL): This field indicates the length
Tomas Bzatek aa9c0e
+ *		    in bytes of each HFI Descriptor, if any. If the @num_hfi field
Tomas Bzatek aa9c0e
+ *		    is cleared to 0h, then this field is reserved.
Tomas Bzatek aa9c0e
+ * @hfiv:	    HFI Descriptor Version (HFIV): This field indicates the version
Tomas Bzatek aa9c0e
+ *		    of each HFI Descriptor.
Tomas Bzatek aa9c0e
+ * @num_hfi:	    Number of Host Fabric Interface Descriptors (NumHFI): This field
Tomas Bzatek aa9c0e
+ *		    indicates the number of HFI Descriptors (see &struct nbft_hfi)
Tomas Bzatek aa9c0e
+ *		    in the HFI Descriptor List, if any. If no interfaces have been
Tomas Bzatek aa9c0e
+ *		    configured, then this field shall be cleared to 0h.
Tomas Bzatek aa9c0e
+ * @ssnso:	    SSNS Descriptor List Offset (SSNSO):: This field indicates
Tomas Bzatek aa9c0e
+ *		    the offset in bytes of the SSNS Descriptor List, if any, from
Tomas Bzatek aa9c0e
+ *		    byte offset 0h of the NBFT Table Header. If the @num_ssns field
Tomas Bzatek aa9c0e
+ *		    is cleared to 0h, then this field is reserved.
Tomas Bzatek aa9c0e
+ * @ssnsl:	    SSNS Descriptor Length (SSNSL): This field indicates the length
Tomas Bzatek aa9c0e
+ *		    in bytes of each SSNS Descriptor, if any. If the @num_ssns
Tomas Bzatek aa9c0e
+ *		    field is cleared to 0h, then this field is reserved.
Tomas Bzatek aa9c0e
+ * @ssnsv:	    SSNS Descriptor Version (SSNSV): This field indicates the version
Tomas Bzatek aa9c0e
+ *		    of the SSNS Descriptor.
Tomas Bzatek aa9c0e
+ * @num_ssns:	    Number of Subsystem and Namespace Descriptors (NumSSNS): This
Tomas Bzatek aa9c0e
+ *		    field indicates the number of Subsystem Namespace (SSNS)
Tomas Bzatek aa9c0e
+ *		    Descriptors (see &struct nbft_ssns) in the SSNS Descriptor List,
Tomas Bzatek aa9c0e
+ *		    if any.
Tomas Bzatek aa9c0e
+ * @seco:	    Security Profile Descriptor List Offset (SECO): This field
Tomas Bzatek aa9c0e
+ *		    indicates the offset in bytes of the Security Profile Descriptor
Tomas Bzatek aa9c0e
+ *		    List, if any, from byte offset 0h of the NBFT Table Header.
Tomas Bzatek aa9c0e
+ *		    If the @num_sec field is cleared to 0h, then this field
Tomas Bzatek aa9c0e
+ *		    is reserved.
Tomas Bzatek aa9c0e
+ * @secl:	    Security Profile Descriptor Length (SECL): This field indicates
Tomas Bzatek aa9c0e
+ *		    the length in bytes of each Security Profile Descriptor, if any.
Tomas Bzatek aa9c0e
+ *		    If the @num_sec field is cleared to 0h, then this field
Tomas Bzatek aa9c0e
+ *		    is reserved.
Tomas Bzatek aa9c0e
+ * @secv:	    Security Profile Descriptor Version (SECV): This field indicates
Tomas Bzatek aa9c0e
+ *		    the version of the Security Profile Descriptor.
Tomas Bzatek aa9c0e
+ * @num_sec:	    Number of Security Profile Descriptors (NumSec): This field
Tomas Bzatek aa9c0e
+ *		    indicates the number of Security Profile Descriptors
Tomas Bzatek aa9c0e
+ *		    (see &struct nbft_security), if any, in the Security Profile
Tomas Bzatek aa9c0e
+ *		    Descriptor List.
Tomas Bzatek aa9c0e
+ * @disco:	    Discovery Descriptor Offset (DISCO): This field indicates
Tomas Bzatek aa9c0e
+ *		    the offset in bytes of the Discovery Descriptor List, if any,
Tomas Bzatek aa9c0e
+ *		    from byte offset 0h of the NBFT Table Header. If the @num_disc
Tomas Bzatek aa9c0e
+ *		    field is cleared to 0h, then this field is reserved.
Tomas Bzatek aa9c0e
+ * @discl:	    Discovery Descriptor Length (DISCL): This field indicates
Tomas Bzatek aa9c0e
+ *		    the length in bytes of each Discovery Descriptor, if any.
Tomas Bzatek aa9c0e
+ *		    If the @num_disc field is cleared to 0h, then this field
Tomas Bzatek aa9c0e
+ *		    is reserved.
Tomas Bzatek aa9c0e
+ * @discv:	    Discovery Descriptor Version (DISCV): This field indicates
Tomas Bzatek aa9c0e
+ *		    the version of the Discovery Descriptor.
Tomas Bzatek aa9c0e
+ * @num_disc:	    Number of Discovery Descriptors (NumDisc): This field indicates
Tomas Bzatek aa9c0e
+ *		    the number of Discovery Descriptors (see &struct nbft_discovery),
Tomas Bzatek aa9c0e
+ *		    if any, in the Discovery Descriptor List, if any.
Tomas Bzatek aa9c0e
+ * @reserved4:	    Reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_control {
Tomas Bzatek aa9c0e
+	__u8 structure_id;
Tomas Bzatek aa9c0e
+	__u8 major_revision;
Tomas Bzatek aa9c0e
+	__u8 minor_revision;
Tomas Bzatek aa9c0e
+	__u8 reserved1;
Tomas Bzatek aa9c0e
+	__le16 csl;
Tomas Bzatek aa9c0e
+	__u8 flags;
Tomas Bzatek aa9c0e
+	__u8 reserved2;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj hdesc;
Tomas Bzatek aa9c0e
+	__u8 hsv;
Tomas Bzatek aa9c0e
+	__u8 reserved3;
Tomas Bzatek aa9c0e
+	__le32 hfio;
Tomas Bzatek aa9c0e
+	__le16 hfil;
Tomas Bzatek aa9c0e
+	__u8 hfiv;
Tomas Bzatek aa9c0e
+	__u8 num_hfi;
Tomas Bzatek aa9c0e
+	__le32 ssnso;
Tomas Bzatek aa9c0e
+	__le16 ssnsl;
Tomas Bzatek aa9c0e
+	__u8 ssnsv;
Tomas Bzatek aa9c0e
+	__u8 num_ssns;
Tomas Bzatek aa9c0e
+	__le32 seco;
Tomas Bzatek aa9c0e
+	__le16 secl;
Tomas Bzatek aa9c0e
+	__u8 secv;
Tomas Bzatek aa9c0e
+	__u8 num_sec;
Tomas Bzatek aa9c0e
+	__le32 disco;
Tomas Bzatek aa9c0e
+	__le16 discl;
Tomas Bzatek aa9c0e
+	__u8 discv;
Tomas Bzatek aa9c0e
+	__u8 num_disc;
Tomas Bzatek aa9c0e
+	__u8 reserved4[16];
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_control_flags - Control Descriptor Flags
Tomas Bzatek aa9c0e
+ * @NBFT_CONTROL_VALID:	Block Valid: indicates that the structure is valid.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_control_flags {
Tomas Bzatek aa9c0e
+	NBFT_CONTROL_VALID	= 1 << 0,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_host - Host Descriptor (Figure 9)
Tomas Bzatek aa9c0e
+ * @structure_id: Structure ID: This field shall be set to 2h (i.e.,
Tomas Bzatek aa9c0e
+ *		  Host Descriptor; #NBFT_DESC_HOST).
Tomas Bzatek aa9c0e
+ * @flags:	  Host Flags, see &enum nbft_host_flags.
Tomas Bzatek aa9c0e
+ * @host_id:	  Host ID: This field shall be set to the Host Identifier. This
Tomas Bzatek aa9c0e
+ *		  field shall not be empty if the NBFT and NVMe Boot are supported
Tomas Bzatek aa9c0e
+ *		  by the Platform.
Tomas Bzatek aa9c0e
+ * @host_nqn_obj: Host NQN Heap Object Reference: this field indicates a heap
Tomas Bzatek aa9c0e
+ *		  object containing a Host NQN. This object shall not be empty
Tomas Bzatek aa9c0e
+ *		  if the NBFT and NVMe Boot are supported by the Platform.
Tomas Bzatek aa9c0e
+ * @reserved:	  Reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_host {
Tomas Bzatek aa9c0e
+	__u8 structure_id;
Tomas Bzatek aa9c0e
+	__u8 flags;
Tomas Bzatek aa9c0e
+	__u8 host_id[16];
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj host_nqn_obj;
Tomas Bzatek aa9c0e
+	__u8 reserved[8];
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_host_flags - Host Flags
Tomas Bzatek aa9c0e
+ * @NBFT_HOST_VALID:			   Descriptor Valid: If set to 1h, then this
Tomas Bzatek aa9c0e
+ *					   descriptor is valid. If cleared to 0h, then
Tomas Bzatek aa9c0e
+ *					   this descriptor is reserved.
Tomas Bzatek aa9c0e
+ * @NBFT_HOST_HOSTID_CONFIGURED:	   HostID Configured: If set to 1h, then the
Tomas Bzatek aa9c0e
+ *					   Host ID field contains an administratively-configured
Tomas Bzatek aa9c0e
+ *					   value. If cleared to 0h, then the Host ID
Tomas Bzatek aa9c0e
+ *					   field contains a driver default value.
Tomas Bzatek aa9c0e
+ * @NBFT_HOST_HOSTNQN_CONFIGURED:	   Host NQN Configured: If set to 1h, then the
Tomas Bzatek aa9c0e
+ *					   Host NQN indicated by the Host NQN Heap Object
Tomas Bzatek aa9c0e
+ *					   Reference field (&struct nbft_host.host_nqn)
Tomas Bzatek aa9c0e
+ *					   contains an administratively-configured value.
Tomas Bzatek aa9c0e
+ *					   If cleared to 0h, then the Host NQN indicated
Tomas Bzatek aa9c0e
+ *					   by the Host NQN Offset field contains a driver
Tomas Bzatek aa9c0e
+ *					   default value.
Tomas Bzatek aa9c0e
+ * @NBFT_HOST_PRIMARY_ADMIN_MASK:	   Mask to get Primary Administrative Host Descriptor:
Tomas Bzatek aa9c0e
+ *					   indicates whether the Host Descriptor in this
Tomas Bzatek aa9c0e
+ *					   NBFT was selected as the primary NBFT for
Tomas Bzatek aa9c0e
+ *					   administrative purposes of platform identity
Tomas Bzatek aa9c0e
+ *					   as a hint to the OS. If multiple NBFT tables
Tomas Bzatek aa9c0e
+ *					   are present, only one NBFT should be administratively
Tomas Bzatek aa9c0e
+ *					   selected. There is no enforcement mechanism
Tomas Bzatek aa9c0e
+ *					   for this to be coordinated between multiple NBFT
Tomas Bzatek aa9c0e
+ *					   tables, but this field should be set to Selected
Tomas Bzatek aa9c0e
+ *					   (#NBFT_HOST_PRIMARY_ADMIN_SELECTED) if
Tomas Bzatek aa9c0e
+ *					   more than one NBFT is present.
Tomas Bzatek aa9c0e
+ * @NBFT_HOST_PRIMARY_ADMIN_NOT_INDICATED: Not Indicated by Driver: The driver that created
Tomas Bzatek aa9c0e
+ *					   this NBFT provided no administrative priority
Tomas Bzatek aa9c0e
+ *					   hint for this NBFT.
Tomas Bzatek aa9c0e
+ * @NBFT_HOST_PRIMARY_ADMIN_UNSELECTED:	   Unselected: The driver that created this NBFT
Tomas Bzatek aa9c0e
+ *					   explicitly indicated that this NBFT should
Tomas Bzatek aa9c0e
+ *					   not be prioritized over any other NBFT.
Tomas Bzatek aa9c0e
+ * @NBFT_HOST_PRIMARY_ADMIN_SELECTED:	   Selected: The driver that created this NBFT
Tomas Bzatek aa9c0e
+ *					   explicitly indicated that this NBFT should
Tomas Bzatek aa9c0e
+ *					   be prioritized over any other NBFT.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_host_flags {
Tomas Bzatek aa9c0e
+	NBFT_HOST_VALID				= 1 << 0,
Tomas Bzatek aa9c0e
+	NBFT_HOST_HOSTID_CONFIGURED		= 1 << 1,
Tomas Bzatek aa9c0e
+	NBFT_HOST_HOSTNQN_CONFIGURED		= 1 << 2,
Tomas Bzatek aa9c0e
+	NBFT_HOST_PRIMARY_ADMIN_MASK		= 0x18,
Tomas Bzatek aa9c0e
+	NBFT_HOST_PRIMARY_ADMIN_NOT_INDICATED	= 0x00,
Tomas Bzatek aa9c0e
+	NBFT_HOST_PRIMARY_ADMIN_UNSELECTED	= 0x08,
Tomas Bzatek aa9c0e
+	NBFT_HOST_PRIMARY_ADMIN_SELECTED	= 0x10,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_hfi - Host Fabric Interface (HFI) Descriptor (Figure 11)
Tomas Bzatek aa9c0e
+ * @structure_id: Structure ID: This field shall be set to 3h (i.e., Host Fabric
Tomas Bzatek aa9c0e
+ *		  Interface Descriptor; #NBFT_DESC_HFI).
Tomas Bzatek aa9c0e
+ * @index:	  HFI Descriptor Index: This field indicates the number of this
Tomas Bzatek aa9c0e
+ *		  HFI Descriptor in the Host Fabric Interface Descriptor List.
Tomas Bzatek aa9c0e
+ * @flags:	  HFI Descriptor Flags, see &enum nbft_hfi_flags.
Tomas Bzatek aa9c0e
+ * @trtype:	  HFI Transport Type, see &enum nbft_trtype.
Tomas Bzatek aa9c0e
+ * @reserved1:	  Reserved.
Tomas Bzatek aa9c0e
+ * @trinfo_obj:	  HFI Transport Info Descriptor Heap Object Reference: If this
Tomas Bzatek aa9c0e
+ *		  field is set to a non-zero value, then this field indicates
Tomas Bzatek aa9c0e
+ *		  the location and size of a heap object containing
Tomas Bzatek aa9c0e
+ *		  a HFI Transport Info.
Tomas Bzatek aa9c0e
+ * @reserved2:	  Reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_hfi {
Tomas Bzatek aa9c0e
+	__u8 structure_id;
Tomas Bzatek aa9c0e
+	__u8 index;
Tomas Bzatek aa9c0e
+	__u8 flags;
Tomas Bzatek aa9c0e
+	__u8 trtype;
Tomas Bzatek aa9c0e
+	__u8 reserved1[12];
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj trinfo_obj;
Tomas Bzatek aa9c0e
+	__u8 reserved2[10];
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_hfi_flags - HFI Descriptor Flags
Tomas Bzatek aa9c0e
+ * @NBFT_HFI_VALID: Descriptor Valid: If set to 1h, then this descriptor is valid.
Tomas Bzatek aa9c0e
+ *		    If cleared to 0h, then this descriptor is reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_hfi_flags {
Tomas Bzatek aa9c0e
+	NBFT_HFI_VALID	= 1 << 0,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_hfi_info_tcp - HFI Transport Info Descriptor - NVMe/TCP (Figure 13)
Tomas Bzatek aa9c0e
+ * @structure_id:	Structure ID: This field shall be set to 7h (i.e.,
Tomas Bzatek aa9c0e
+ *			HFI Transport Info; #NBFT_DESC_HFI_TRINFO).
Tomas Bzatek aa9c0e
+ * @version:		Version: This field shall be set to 1h.
Tomas Bzatek aa9c0e
+ * @trtype:		HFI Transport Type, see &enum nbft_trtype: This field
Tomas Bzatek aa9c0e
+ *			shall be set to 03h (i.e., NVMe/TCP; #NBFT_TRTYPE_TCP).
Tomas Bzatek aa9c0e
+ * @trinfo_version:	Transport Info Version: Implementations compliant to this
Tomas Bzatek aa9c0e
+ *			specification shall set this field to 1h.
Tomas Bzatek aa9c0e
+ * @hfi_index:		HFI Descriptor Index: The value of the HFI Descriptor Index
Tomas Bzatek aa9c0e
+ *			field of the HFI Descriptor (see &struct nbft_hfi.index)
Tomas Bzatek aa9c0e
+ *			whose HFI Transport Info Descriptor Heap Object Reference
Tomas Bzatek aa9c0e
+ *			field indicates this HFI Transport Info Descriptor.
Tomas Bzatek aa9c0e
+ * @flags:		HFI Transport Flags, see &enum nbft_hfi_info_tcp_flags.
Tomas Bzatek aa9c0e
+ * @pci_sbdf:		PCI Express Routing ID for the HFI Transport Function:
Tomas Bzatek aa9c0e
+ *			This field indicates the PCI Express Routing ID as specified
Tomas Bzatek aa9c0e
+ *			in the PCI Express Base Specification.
Tomas Bzatek aa9c0e
+ * @mac_addr:		MAC Address: The MAC address of this HFI, in EUI-48TM format,
Tomas Bzatek aa9c0e
+ *			as defined in the IEEE Guidelines for Use of Extended Unique
Tomas Bzatek aa9c0e
+ *			Identifiers. This field shall be set to a non-zero value.
Tomas Bzatek aa9c0e
+ * @vlan:		VLAN: If this field is set to a non-zero value, then this
Tomas Bzatek aa9c0e
+ *			field contains the VLAN identifier if the VLAN associated
Tomas Bzatek aa9c0e
+ *			with this HFI, as defined in IEEE 802.1q-2018. If no VLAN
Tomas Bzatek aa9c0e
+ *			is associated with this HFI, then this field shall be cleared
Tomas Bzatek aa9c0e
+ *			to 0h.
Tomas Bzatek aa9c0e
+ * @ip_origin:		IP Origin: If this field is set to a non-zero value, then
Tomas Bzatek aa9c0e
+ *			this field indicates the source of Ethernet L3 configuration
Tomas Bzatek aa9c0e
+ *			information used by the driver for this interface. Valid
Tomas Bzatek aa9c0e
+ *			values are defined in the Win 32 API: NL_PREFIX_ORIGIN
Tomas Bzatek aa9c0e
+ *			enumeration specification. This field should be cleared
Tomas Bzatek aa9c0e
+ *			to 0h if the IP Origin field is unused by driver.
Tomas Bzatek aa9c0e
+ * @ip_address:		IP Address: This field indicates the IPv4 or IPv6 address
Tomas Bzatek aa9c0e
+ *			of this HFI. This field shall be set to a non-zero value.
Tomas Bzatek aa9c0e
+ * @subnet_mask_prefix:	Subnet Mask Prefix: This field indicates the IPv4 or IPv6
Tomas Bzatek aa9c0e
+ *			subnet mask in CIDR routing prefix notation.
Tomas Bzatek aa9c0e
+ * @ip_gateway:		IP Gateway: If this field is set to a non-zero value, this
Tomas Bzatek aa9c0e
+ *			field indicates the IPv4 or IPv6 address of the IP gateway
Tomas Bzatek aa9c0e
+ *			for this HFI. If this field is cleared to 0h, then
Tomas Bzatek aa9c0e
+ *			no IP gateway is specified.
Tomas Bzatek aa9c0e
+ * @reserved1:		Reserved.
Tomas Bzatek aa9c0e
+ * @route_metric:	Route Metric: If this field is set to a non-zero value,
Tomas Bzatek aa9c0e
+ *			this field indicates the cost value for the route indicated
Tomas Bzatek aa9c0e
+ *			by this HF. This field contains the value utilized by the
Tomas Bzatek aa9c0e
+ *			pre-OS driver when chosing among all available routes. Lower
Tomas Bzatek aa9c0e
+ *			values relate to higher priority. Refer to IETF RFC 4249.
Tomas Bzatek aa9c0e
+ *			If the pre-OS driver supports routing and did not configure
Tomas Bzatek aa9c0e
+ *			a specific route metric for this interface, then the pre-OS
Tomas Bzatek aa9c0e
+ *			driver should set this value to 500. If the pre-OS driver
Tomas Bzatek aa9c0e
+ *			does not support routing, then this field should be cleared
Tomas Bzatek aa9c0e
+ *			to 0h.
Tomas Bzatek aa9c0e
+ * @primary_dns:	Primary DNS: If this field is set to a non-zero value,
Tomas Bzatek aa9c0e
+ *			this field indicates the IPv4 or IPv6 address of the
Tomas Bzatek aa9c0e
+ *			Primary DNS server for this HFI, if any, from byte offset
Tomas Bzatek aa9c0e
+ *			0h of the NBFT Table Header. If this field is cleared to 0h,
Tomas Bzatek aa9c0e
+ *			then no Primary DNS is specified.
Tomas Bzatek aa9c0e
+ * @secondary_dns:	Secondary DNS: If this field is set to a non-zero value,
Tomas Bzatek aa9c0e
+ *			this field indicates the IPv4 or IPv6 address of
Tomas Bzatek aa9c0e
+ *			the Secondary DNS server for this HFI, if any, from byte
Tomas Bzatek aa9c0e
+ *			offset 0h of the NBFT Table Header. If this field is
Tomas Bzatek aa9c0e
+ *			cleared to 0h, then no Secondary DNS is specified.
Tomas Bzatek aa9c0e
+ * @dhcp_server:	DHCP Server: If the DHCP Override bit is set to 1h, then
Tomas Bzatek aa9c0e
+ *			this field indicates the IPv4 or IPv6 address of the DHCP
Tomas Bzatek aa9c0e
+ *			server used to assign this HFI address. If that bit is
Tomas Bzatek aa9c0e
+ *			cleared to 0h, then this field is reserved.
Tomas Bzatek aa9c0e
+ * @host_name_obj:	Host Name Heap Object Reference: If this field is set
Tomas Bzatek aa9c0e
+ *			to a non-zero value, then this field indicates the location
Tomas Bzatek aa9c0e
+ *			and size of a heap object containing a Host Name string.
Tomas Bzatek aa9c0e
+ * @reserved2:		Reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_hfi_info_tcp {
Tomas Bzatek aa9c0e
+	__u8 structure_id;
Tomas Bzatek aa9c0e
+	__u8 version;
Tomas Bzatek aa9c0e
+	__u8 trtype;
Tomas Bzatek aa9c0e
+	__u8 trinfo_version;
Tomas Bzatek aa9c0e
+	__le16 hfi_index;
Tomas Bzatek aa9c0e
+	__u8 flags;
Tomas Bzatek aa9c0e
+	__le32 pci_sbdf;
Tomas Bzatek aa9c0e
+	__u8 mac_addr[6];
Tomas Bzatek aa9c0e
+	__le16 vlan;
Tomas Bzatek aa9c0e
+	__u8 ip_origin;
Tomas Bzatek aa9c0e
+	__u8 ip_address[16];
Tomas Bzatek aa9c0e
+	__u8 subnet_mask_prefix;
Tomas Bzatek aa9c0e
+	__u8 ip_gateway[16];
Tomas Bzatek aa9c0e
+	__u8 reserved1;
Tomas Bzatek aa9c0e
+	__le16 route_metric;
Tomas Bzatek aa9c0e
+	__u8 primary_dns[16];
Tomas Bzatek aa9c0e
+	__u8 secondary_dns[16];
Tomas Bzatek aa9c0e
+	__u8 dhcp_server[16];
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj host_name_obj;
Tomas Bzatek aa9c0e
+	__u8 reserved2[18];
Tomas Bzatek aa9c0e
+} __attribute__((packed));
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_hfi_info_tcp_flags - HFI Transport Flags
Tomas Bzatek aa9c0e
+ * @NBFT_HFI_INFO_TCP_VALID:	     Descriptor Valid: if set to 1h, then this
Tomas Bzatek aa9c0e
+ *				     descriptor is valid. If cleared to 0h, then
Tomas Bzatek aa9c0e
+ *				     this descriptor is reserved.
Tomas Bzatek aa9c0e
+ * @NBFT_HFI_INFO_TCP_GLOBAL_ROUTE:  Global Route vs. Link Local Override Flag:
Tomas Bzatek aa9c0e
+ *				     if set to 1h, then the BIOS utilized this
Tomas Bzatek aa9c0e
+ *				     interface described by HFI to be the default
Tomas Bzatek aa9c0e
+ *				     route with highest priority. If cleared to 0h,
Tomas Bzatek aa9c0e
+ *				     then routes are local to their own scope.
Tomas Bzatek aa9c0e
+ * @NBFT_HFI_INFO_TCP_DHCP_OVERRIDE: DHCP Override: if set to 1, then HFI information
Tomas Bzatek aa9c0e
+ *				     was populated by consuming the DHCP on this
Tomas Bzatek aa9c0e
+ *				     interface. If cleared to 0h, then the HFI
Tomas Bzatek aa9c0e
+ *				     information was set administratively by
Tomas Bzatek aa9c0e
+ *				     a configuration interface to the driver and
Tomas Bzatek aa9c0e
+ *				     pre-OS envrionment.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_hfi_info_tcp_flags {
Tomas Bzatek aa9c0e
+	NBFT_HFI_INFO_TCP_VALID		= 1 << 0,
Tomas Bzatek aa9c0e
+	NBFT_HFI_INFO_TCP_GLOBAL_ROUTE	= 1 << 1,
Tomas Bzatek aa9c0e
+	NBFT_HFI_INFO_TCP_DHCP_OVERRIDE	= 1 << 2,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_ssns - Subsystem Namespace (SSNS) Descriptor (Figure 15)
Tomas Bzatek aa9c0e
+ * @structure_id:		  Structure ID: This field shall be set to 4h
Tomas Bzatek aa9c0e
+ *				  (i.e., SSNS; #NBFT_DESC_SSNS).
Tomas Bzatek aa9c0e
+ * @index:			  SSNS Descriptor Index: This field indicates the number
Tomas Bzatek aa9c0e
+ *				  of this Subsystem Namespace Descriptor in the
Tomas Bzatek aa9c0e
+ *				  Subsystem Namespace Descriptor List.
Tomas Bzatek aa9c0e
+ * @flags:			  SSNS Flags, see &enum nbft_ssns_flags.
Tomas Bzatek aa9c0e
+ * @trtype:			  Transport Type, see &enum nbft_trtype.
Tomas Bzatek aa9c0e
+ * @trflags:			  Transport Specific Flags, see &enum nbft_ssns_trflags.
Tomas Bzatek aa9c0e
+ * @primary_discovery_ctrl_index: Primary Discovery Controller Index: The Discovery
Tomas Bzatek aa9c0e
+ *				  Descriptor Index field of the Discovery Descriptor
Tomas Bzatek aa9c0e
+ *				  (see &struct nbft_discovery) that is associated with
Tomas Bzatek aa9c0e
+ *				  this SSNS Descriptor. If a Discovery controller was
Tomas Bzatek aa9c0e
+ *				  used to establish this record this value shall
Tomas Bzatek aa9c0e
+ *				  be set to a non-zero value. If this namespace was
Tomas Bzatek aa9c0e
+ *				  associated with multiple Discovery controllers,
Tomas Bzatek aa9c0e
+ *				  those Discovery controllers shall have records
Tomas Bzatek aa9c0e
+ *				  in the Discovery Descriptor to facilitate multi-path
Tomas Bzatek aa9c0e
+ *				  rediscovery as required. If no Discovery controller
Tomas Bzatek aa9c0e
+ *				  was utilized to inform this namespace record,
Tomas Bzatek aa9c0e
+ *				  this field shall be cleared to 0h.
Tomas Bzatek aa9c0e
+ * @reserved1:			  Reserved.
Tomas Bzatek aa9c0e
+ * @subsys_traddr_obj:		  Subsystem Transport Address Heap Object Reference:
Tomas Bzatek aa9c0e
+ *				  This field indicates the location and size of a heap
Tomas Bzatek aa9c0e
+ *				  object containing the Subsystem Transport Address.
Tomas Bzatek aa9c0e
+ *				  For IP based transports types, shall be an IP Address.
Tomas Bzatek aa9c0e
+ * @subsys_trsvcid_obj:		  Subsystem Transport Service Identifier Heap Object Reference:
Tomas Bzatek aa9c0e
+ *				  This field indicates the location and size of a heap
Tomas Bzatek aa9c0e
+ *				  object containing an array of bytes indicating
Tomas Bzatek aa9c0e
+ *				  the Subsystem Transport Service Identifier.
Tomas Bzatek aa9c0e
+ *				  See &enum nbft_trtype.
Tomas Bzatek aa9c0e
+ * @subsys_port_id:		  Subsystem Port ID: Port in the NVM subsystem
Tomas Bzatek aa9c0e
+ *				  associated with this transport address used by
Tomas Bzatek aa9c0e
+ *				  the pre-OS driver.
Tomas Bzatek aa9c0e
+ * @nsid:			  Namespace ID: This field indicates the namespace
Tomas Bzatek aa9c0e
+ *				  identifier (NSID) of the namespace indicated by
Tomas Bzatek aa9c0e
+ *				  this descriptor. This field shall be cleared to 0h
Tomas Bzatek aa9c0e
+ *				  if not specified by the user. If this value is cleared
Tomas Bzatek aa9c0e
+ *				  to 0h, then consumers of the NBFT shall rely
Tomas Bzatek aa9c0e
+ *				  on the NID.
Tomas Bzatek aa9c0e
+ * @nidt:			  Namespace Identifier Type (NIDT): This field
Tomas Bzatek aa9c0e
+ *				  contains the value of the Namespace Identifier Type (NIDT)
Tomas Bzatek aa9c0e
+ *				  field in the Namespace Identification Descriptor
Tomas Bzatek aa9c0e
+ *				  for the namespace indicated by this descriptor.
Tomas Bzatek aa9c0e
+ *				  If a namespace supports multiple NIDT entries
Tomas Bzatek aa9c0e
+ *				  for uniqueness, the order of preference is NIDT field
Tomas Bzatek aa9c0e
+ *				  value of 3h (i.e., UUID) before 2h (i.e., NSGUID),
Tomas Bzatek aa9c0e
+ *				  and 2h before 1h (i.e., EUI-64).
Tomas Bzatek aa9c0e
+ * @nid:			  Namespace Identifier (NID): This field contains
Tomas Bzatek aa9c0e
+ *				  the value of the Namespace Identifier (NID) field
Tomas Bzatek aa9c0e
+ *				  in the Namespace Identification Descriptor for
Tomas Bzatek aa9c0e
+ *				  the namespace indicated by this descriptor.
Tomas Bzatek aa9c0e
+ * @security_desc_index:	  Security Profile Descriptor Index: If the Use Security
Tomas Bzatek aa9c0e
+ *				  Flag bit in the SSNS Flags field is set to 1h, then
Tomas Bzatek aa9c0e
+ *				  this field indicates the value of the Security Profile
Tomas Bzatek aa9c0e
+ *				  Descriptor Index field of the Security Profile
Tomas Bzatek aa9c0e
+ *				  Descriptor (see &struct nbft_security) associated
Tomas Bzatek aa9c0e
+ *				  with this namespace. If the Use Security Flag bit
Tomas Bzatek aa9c0e
+ *				  is cleared to 0h, then no Security Profile Descriptor
Tomas Bzatek aa9c0e
+ *				  is associated with this namespace and this field
Tomas Bzatek aa9c0e
+ *				  is reserved.
Tomas Bzatek aa9c0e
+ * @primary_hfi_desc_index:	  Primary HFI Descriptor Index: This field indicates
Tomas Bzatek aa9c0e
+ *				  the value of the HFI Descriptor Index field of the
Tomas Bzatek aa9c0e
+ *				  HFI Descriptor (see &struct nbft_hfi) for the
Tomas Bzatek aa9c0e
+ *				  interface associated with this namespace. If multiple
Tomas Bzatek aa9c0e
+ *				  HFIs are associated with this record, subsequent
Tomas Bzatek aa9c0e
+ *				  interfaces should be populated in the Secondary
Tomas Bzatek aa9c0e
+ *				  HFI Associations field.
Tomas Bzatek aa9c0e
+ * @reserved2:			  Reserved.
Tomas Bzatek aa9c0e
+ * @secondary_hfi_assoc_obj:	  Secondary HFI Associations Heap Object Reference:
Tomas Bzatek aa9c0e
+ *				  If this field is set to a non-zero value, then
Tomas Bzatek aa9c0e
+ *				  this field indicates an array of bytes, in which
Tomas Bzatek aa9c0e
+ *				  each byte contains the value of the HFI Descriptor
Tomas Bzatek aa9c0e
+ *				  Index field of an HFI Descriptor in the HFI Descriptor
Tomas Bzatek aa9c0e
+ *				  List. If this field is cleared to 0h, then no
Tomas Bzatek aa9c0e
+ *				  secondary HFI associations are specified.
Tomas Bzatek aa9c0e
+ * @subsys_ns_nqn_obj:		  Subsystem and Namespace NQN Heap Object Reference:
Tomas Bzatek aa9c0e
+ *				  This field indicates the location and size of
Tomas Bzatek aa9c0e
+ *				  a heap object containing the Subsystem and Namespace NQN.
Tomas Bzatek aa9c0e
+ * @ssns_extended_info_desc_obj:  SSNS Extended Information Descriptor Heap Object
Tomas Bzatek aa9c0e
+ *				  Reference: If the SSNS Extended Info In-use Flag
Tomas Bzatek aa9c0e
+ *				  bit is set to 1h, then this field indicates the
Tomas Bzatek aa9c0e
+ *				  offset in bytes of a heap object containing an
Tomas Bzatek aa9c0e
+ *				  SSNS Extended Information Descriptor
Tomas Bzatek aa9c0e
+ *				  (see &struct nbft_ssns_ext_info) heap object
Tomas Bzatek aa9c0e
+ *				  from byte offset 0h of the NBFT Table Header.
Tomas Bzatek aa9c0e
+ *				  If the SSNS Extended Info In-use Flag bit is cleared
Tomas Bzatek aa9c0e
+ *				  to 0h, then this field is reserved.
Tomas Bzatek aa9c0e
+ * @reserved3:			  Reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_ssns {
Tomas Bzatek aa9c0e
+	__u8 structure_id;
Tomas Bzatek aa9c0e
+	__le16 index;
Tomas Bzatek aa9c0e
+	__le16 flags;
Tomas Bzatek aa9c0e
+	__u8 trtype;
Tomas Bzatek aa9c0e
+	__le16 trflags;
Tomas Bzatek aa9c0e
+	__u8 primary_discovery_ctrl_index;
Tomas Bzatek aa9c0e
+	__u8 reserved1;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj subsys_traddr_obj;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj subsys_trsvcid_obj;
Tomas Bzatek aa9c0e
+	__le16 subsys_port_id;
Tomas Bzatek aa9c0e
+	__le32 nsid;
Tomas Bzatek aa9c0e
+	__u8 nidt;
Tomas Bzatek aa9c0e
+	__u8 nid[16];
Tomas Bzatek aa9c0e
+	__u8 security_desc_index;
Tomas Bzatek aa9c0e
+	__u8 primary_hfi_desc_index;
Tomas Bzatek aa9c0e
+	__u8 reserved2;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj secondary_hfi_assoc_obj;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj subsys_ns_nqn_obj;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj ssns_extended_info_desc_obj;
Tomas Bzatek aa9c0e
+	__u8 reserved3[62];
Tomas Bzatek aa9c0e
+} __attribute__((packed));
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_ssns_flags - Subsystem and Namespace Specific Flags Field (Figure 16)
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_VALID:			 Descriptor Valid: If set to 1h, then this descriptor
Tomas Bzatek aa9c0e
+ *					 is valid. If cleared to 0h, then this descriptor
Tomas Bzatek aa9c0e
+ *					 is not valid. A host that supports NVMe-oF Boot,
Tomas Bzatek aa9c0e
+ *					 but does not currently have a remote Subsystem
Tomas Bzatek aa9c0e
+ *					 and Namespace assigned may clear this bit to 0h.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_NON_BOOTABLE_ENTRY:	 Non-bootable Entry Flag: If set to 1h, this flag
Tomas Bzatek aa9c0e
+ *					 indicates that this SSNS Descriptor contains
Tomas Bzatek aa9c0e
+ *					 a namespace of administrative purpose to the boot
Tomas Bzatek aa9c0e
+ *					 process, but the pre-OS may not have established
Tomas Bzatek aa9c0e
+ *					 connectivity to or evaluated the contents of this
Tomas Bzatek aa9c0e
+ *					 Descriptor. Such namespaces may contain supplemental
Tomas Bzatek aa9c0e
+ *					 data deemed relevant by the Administrator as part
Tomas Bzatek aa9c0e
+ *					 of the pre-OS to OS hand off. This may include
Tomas Bzatek aa9c0e
+ *					 properties such as a UEFI device path that may
Tomas Bzatek aa9c0e
+ *					 not have been created for this namespace. This means
Tomas Bzatek aa9c0e
+ *					 an OS runtime may still require the contents
Tomas Bzatek aa9c0e
+ *					 of such a namespace to complete later stages
Tomas Bzatek aa9c0e
+ *					 of boot. If cleared to 0h, then this namespace did
Tomas Bzatek aa9c0e
+ *					 not have any special administrative intent.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_USE_SECURITY_FIELD:	 Use Security Flag: If set to 1h, then there is
Tomas Bzatek aa9c0e
+ *					 a Security Profile Descriptor associated with this
Tomas Bzatek aa9c0e
+ *					 SSNS record and the Security Profile Descriptor Index
Tomas Bzatek aa9c0e
+ *					 field is valid. If cleared to 0h, then there is
Tomas Bzatek aa9c0e
+ *					 no Security Profile Descriptor associated with this
Tomas Bzatek aa9c0e
+ *					 SSNS record and the Security Profile Descriptor Index
Tomas Bzatek aa9c0e
+ *					 field is not valid.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_DHCP_ROOT_PATH_OVERRIDE:	 DHCP Root-Path Override Flag: If set to 1h, then
Tomas Bzatek aa9c0e
+ *					 this SSNS descriptor was populated by consuming
Tomas Bzatek aa9c0e
+ *					 the DHCP Root-Path on this interface. If cleared
Tomas Bzatek aa9c0e
+ *					 to 0h, then the DHCP Root-Path was not used
Tomas Bzatek aa9c0e
+ *					 in populating the SSNS descriptor.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_EXTENDED_INFO_IN_USE:	 SSNS Extended Info In-use Flag: If set to 1h,
Tomas Bzatek aa9c0e
+ *					 then the SSNS Extended Information Offset field
Tomas Bzatek aa9c0e
+ *					 and the SSNS Extended Information Length field
Tomas Bzatek aa9c0e
+ *					 are valid. This flag, if set to 1h, indicates
Tomas Bzatek aa9c0e
+ *					 that a Subsystem and Namespace Extended Information
Tomas Bzatek aa9c0e
+ *					 Descriptor corresponding to this descriptor is present.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_SEPARATE_DISCOVERY_CTRL:	 Separate Discovery Controller Flag: If set to 1h,
Tomas Bzatek aa9c0e
+ *					 then the Discovery controller associated with
Tomas Bzatek aa9c0e
+ *					 this volume is on a different transport address
Tomas Bzatek aa9c0e
+ *					 than the specified in the Subsystem Transport
Tomas Bzatek aa9c0e
+ *					 Address Heap Object Reference. If cleared to 0h,
Tomas Bzatek aa9c0e
+ *					 then the Discovery controller is the same as the
Tomas Bzatek aa9c0e
+ *					 Subsystem Transport Address Heap Object Reference.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_DISCOVERED_NAMESPACE:	 Discovered Namespace Flag: If set to 1h, then
Tomas Bzatek aa9c0e
+ *					 this namespace was acquired through discovery.
Tomas Bzatek aa9c0e
+ *					 If cleared to 0h, then this namespace was
Tomas Bzatek aa9c0e
+ *					 explicitly configured in the system.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_UNAVAIL_NAMESPACE_MASK:	 Mask to get Unavailable Namespace Flag: This
Tomas Bzatek aa9c0e
+ *					 field indicates the availability of the namespace
Tomas Bzatek aa9c0e
+ *					 at a specific point in time. Such use is only
Tomas Bzatek aa9c0e
+ *					 a hint and its use does not guarantee the availability
Tomas Bzatek aa9c0e
+ *					 of that referenced namespace at any future point in time.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_UNAVAIL_NAMESPACE_NOTIND:	 Not Indicated by Driver: No information is provided.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_UNAVAIL_NAMESPACE_AVAIL:	 Available: A referenced namespace described by this
Tomas Bzatek aa9c0e
+ *					 flag was previously accessible by the pre-OS driver.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_UNAVAIL_NAMESPACE_UNAVAIL: Unavailable: This namespace was administratively
Tomas Bzatek aa9c0e
+ *					 configured but unattempted, unavailable or
Tomas Bzatek aa9c0e
+ *					 inaccessible when establishing connectivity
Tomas Bzatek aa9c0e
+ *					 by the pre-OS driver.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_ssns_flags {
Tomas Bzatek aa9c0e
+	NBFT_SSNS_VALID				= 1 << 0,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_NON_BOOTABLE_ENTRY		= 1 << 1,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_USE_SECURITY_FIELD		= 1 << 2,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_DHCP_ROOT_PATH_OVERRIDE	= 1 << 3,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_EXTENDED_INFO_IN_USE		= 1 << 4,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_SEPARATE_DISCOVERY_CTRL	= 1 << 5,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_DISCOVERED_NAMESPACE		= 1 << 6,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_UNAVAIL_NAMESPACE_MASK	= 0x0180,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_UNAVAIL_NAMESPACE_NOTIND	= 0x0000,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_UNAVAIL_NAMESPACE_AVAIL	= 0x0080,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_UNAVAIL_NAMESPACE_UNAVAIL	= 0x0100,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_ssns_trflags - SSNS Transport Specific Flags Field (Figure 17)
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_TRFLAG_VALID:	 Transport Specific Flags in Use: If set to 1h, then
Tomas Bzatek aa9c0e
+ *				 this descriptor is valid. If cleared to 0h, then
Tomas Bzatek aa9c0e
+ *				 this descriptor is not valid.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_PDU_HEADER_DIGEST: PDU Header Digest (HDGST) Flag: If set to 1h, then
Tomas Bzatek aa9c0e
+ *				 the host or administrator required the connection
Tomas Bzatek aa9c0e
+ *				 described by this Subsystem and Namespace Descriptor
Tomas Bzatek aa9c0e
+ *				 to use the NVM Header Digest Enabled. A consumer
Tomas Bzatek aa9c0e
+ *				 of this information should attempt to use NVM Header
Tomas Bzatek aa9c0e
+ *				 Digest when recreating this connection if enabled.
Tomas Bzatek aa9c0e
+ *				 If cleared to 0h, then the host or administrator
Tomas Bzatek aa9c0e
+ *				 did not require the connection described by this
Tomas Bzatek aa9c0e
+ *				 Subsystem and Namespace Descriptor to use the
Tomas Bzatek aa9c0e
+ *				 NVM Header Digest Enabled.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_DATA_DIGEST:	 Data Digest (DDGST) Flag: If set to 1h, then
Tomas Bzatek aa9c0e
+ *				 the host or administrator required the connection
Tomas Bzatek aa9c0e
+ *				 described by this Subsystem and Namespace Descriptor
Tomas Bzatek aa9c0e
+ *				 to use the NVM Data Digest Enabled. If cleared
Tomas Bzatek aa9c0e
+ *				 to 0h, then the host or administrator did not
Tomas Bzatek aa9c0e
+ *				 require the connection described by this Subsystem
Tomas Bzatek aa9c0e
+ *				 and Namespace Descriptor to use the NVM Data Digest
Tomas Bzatek aa9c0e
+ *				 Enabled. A consumer of this field should attempt
Tomas Bzatek aa9c0e
+ *				 to use NVM Data Digest when recreating this
Tomas Bzatek aa9c0e
+ *				 connection if enabled.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_ssns_trflags {
Tomas Bzatek aa9c0e
+	NBFT_SSNS_TRFLAG_VALID		= 1 << 0,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_PDU_HEADER_DIGEST	= 1 << 1,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_DATA_DIGEST		= 1 << 2,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_ssns_ext_info - Subsystem and Namespace Extended Information
Tomas Bzatek aa9c0e
+ *			       Descriptor (Figure 19)
Tomas Bzatek aa9c0e
+ * @structure_id:	    Structure ID: This field shall be set to 9h
Tomas Bzatek aa9c0e
+ *			    (i.e., SSNS Extended Info; #NBFT_DESC_SSNS_EXT_INFO).
Tomas Bzatek aa9c0e
+ * @version:		    Version: This field shall be set to 1h.
Tomas Bzatek aa9c0e
+ * @ssns_index:		    SSNS Descriptor Index: This field indicates the value
Tomas Bzatek aa9c0e
+ *			    of the SSNS Descriptor Index field of the Subsystem
Tomas Bzatek aa9c0e
+ *			    and Namespace Descriptor (see &struct nbft_ssns) whose
Tomas Bzatek aa9c0e
+ *			    SSNS Extended Information Descriptor Heap Object
Tomas Bzatek aa9c0e
+ *			    Reference field indicates this descriptor.
Tomas Bzatek aa9c0e
+ * @flags:		    Flags, see &enum nbft_ssns_ext_info_flags.
Tomas Bzatek aa9c0e
+ * @cntlid:		    Controller ID: The controller identifier of the first
Tomas Bzatek aa9c0e
+ *			    controller associated with the Admin Queue by the driver.
Tomas Bzatek aa9c0e
+ *			    If a controller identifier is not administratively
Tomas Bzatek aa9c0e
+ *			    specified or direct configuration is not supported
Tomas Bzatek aa9c0e
+ *			    by the driver, then this field shall be cleared to 0h.
Tomas Bzatek aa9c0e
+ * @asqsz:		    Admin Submission Queue Size (ASQSZ): The Admin Submission
Tomas Bzatek aa9c0e
+ *			    Queue Size utilized for the respective SSNS by the driver.
Tomas Bzatek aa9c0e
+ * @dhcp_root_path_str_obj: DHCP Root Path String Heap Object Reference: If the
Tomas Bzatek aa9c0e
+ *			    SSNS DHCP Root Path Override (#NBFT_SSNS_DHCP_ROOT_PATH_OVERRIDE)
Tomas Bzatek aa9c0e
+ *			    flag bit is set to 1h, then this field indicates
Tomas Bzatek aa9c0e
+ *			    the offset in bytes of a heap object containing
Tomas Bzatek aa9c0e
+ *			    an DHCP Root Path String used by the driver. If the
Tomas Bzatek aa9c0e
+ *			    SNSS DHCP Root Path Override flag bit is cleared to 0h,
Tomas Bzatek aa9c0e
+ *			    then this field is reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_ssns_ext_info {
Tomas Bzatek aa9c0e
+	__u8 structure_id;
Tomas Bzatek aa9c0e
+	__u8 version;
Tomas Bzatek aa9c0e
+	__le16 ssns_index;
Tomas Bzatek aa9c0e
+	__le32 flags;
Tomas Bzatek aa9c0e
+	__le16 cntlid;
Tomas Bzatek aa9c0e
+	__le16 asqsz;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj dhcp_root_path_str_obj;
Tomas Bzatek aa9c0e
+} __attribute__((packed));
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_ssns_ext_info_flags - Subsystem and Namespace Extended Information
Tomas Bzatek aa9c0e
+ *				   Descriptor Flags
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_EXT_INFO_VALID:	    Descriptor Valid: If set to 1h, then this descriptor
Tomas Bzatek aa9c0e
+ *				    is valid. If cleared to 0h, then this descriptor
Tomas Bzatek aa9c0e
+ *				    is reserved.
Tomas Bzatek aa9c0e
+ * @NBFT_SSNS_EXT_INFO_ADMIN_ASQSZ: Administrative ASQSZ: If set to 1h, then the value
Tomas Bzatek aa9c0e
+ *				    of the ASQSZ field was provided by administrative
Tomas Bzatek aa9c0e
+ *				    configuration for this SSNS record. If cleared
Tomas Bzatek aa9c0e
+ *				    to 0h, then the value of the ASQSZ field was
Tomas Bzatek aa9c0e
+ *				    either obtained by discovery or assumed
Tomas Bzatek aa9c0e
+ *				    by the driver.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_ssns_ext_info_flags {
Tomas Bzatek aa9c0e
+	NBFT_SSNS_EXT_INFO_VALID	= 1 << 0,
Tomas Bzatek aa9c0e
+	NBFT_SSNS_EXT_INFO_ADMIN_ASQSZ	= 1 << 1,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_security - Security Profile Descriptor (Figure 21)
Tomas Bzatek aa9c0e
+ * @structure_id:      Structure ID: This field shall be set to 5h
Tomas Bzatek aa9c0e
+ *		       (i.e., Security; #NBFT_DESC_SECURITY).
Tomas Bzatek aa9c0e
+ * @index:	       Security Profile Descriptor Index: This field indicates
Tomas Bzatek aa9c0e
+ *		       the number of this Security Profile Descriptor in the
Tomas Bzatek aa9c0e
+ *		       Security Profile Descriptor List.
Tomas Bzatek aa9c0e
+ * @flags:	       Security Profile Descriptor Flags, see &enum nbft_security_flags.
Tomas Bzatek aa9c0e
+ * @secret_type:       Secret Type, see &enum nbft_security_secret_type.
Tomas Bzatek aa9c0e
+ * @reserved1:	       Reserved.
Tomas Bzatek aa9c0e
+ * @sec_chan_alg_obj:  Secure Channel Algorithm Heap Object Reference: If the
Tomas Bzatek aa9c0e
+ *		       Security Policy List field is set to 1h, then this field
Tomas Bzatek aa9c0e
+ *		       indicates the location and size of a heap object containing
Tomas Bzatek aa9c0e
+ *		       a list of secure channel algorithms. The list is an array
Tomas Bzatek aa9c0e
+ *		       of bytes and the values are defined in the Security Type
Tomas Bzatek aa9c0e
+ *		       (SECTYPE) field in the Transport Specific Address Subtype
Tomas Bzatek aa9c0e
+ *		       Definition in the NVMe TCP Transport Specification.
Tomas Bzatek aa9c0e
+ *		       If the Security Policy List field is cleared to 0h, then
Tomas Bzatek aa9c0e
+ *		       this field is reserved.
Tomas Bzatek aa9c0e
+ * @auth_proto_obj:    Authentication Protocols Heap Object Reference: If the
Tomas Bzatek aa9c0e
+ *		       Authentication Policy List field is set to 1h, then this
Tomas Bzatek aa9c0e
+ *		       field indicates the location and size of a heap object
Tomas Bzatek aa9c0e
+ *		       containing a list of authentication protocol identifiers.
Tomas Bzatek aa9c0e
+ *		       If the Authentication Policy List field is cleared to 0h,
Tomas Bzatek aa9c0e
+ *		       then this field is reserved.
Tomas Bzatek aa9c0e
+ * @cipher_suite_obj:  Cipher Suite Offset Heap Object Reference: If the Cipher
Tomas Bzatek aa9c0e
+ *		       Suites Restricted by Policy bit is set to 1h, then this
Tomas Bzatek aa9c0e
+ *		       field indicates the location and size of a heap object
Tomas Bzatek aa9c0e
+ *		       containing a list of cipher suite identifiers. The list,
Tomas Bzatek aa9c0e
+ *		       if any, is an array of bytes and the values are defined
Tomas Bzatek aa9c0e
+ *		       in the IANA TLS Parameters Registry. If the Cipher Suites
Tomas Bzatek aa9c0e
+ *		       Restricted by Policy bit is cleared to 0h, then this field
Tomas Bzatek aa9c0e
+ *		       is reserved.
Tomas Bzatek aa9c0e
+ * @dh_grp_obj:	       DH Groups Heap Object Reference: If the Authentication DH Groups
Tomas Bzatek aa9c0e
+ *		       Restricted by Policy List bit is set to 1h, then this field
Tomas Bzatek aa9c0e
+ *		       indicates the location and size of a heap object containing
Tomas Bzatek aa9c0e
+ *		       a list of DH-HMAC-CHAP Diffie-Hellman (DH) group identifiers.
Tomas Bzatek aa9c0e
+ *		       If the Authentication DH Groups Restricted by Policy List
Tomas Bzatek aa9c0e
+ *		       bit is cleared to 0h, then this field is reserved.
Tomas Bzatek aa9c0e
+ * @sec_hash_func_obj: Secure Hash Functions Offset Heap Object Reference: If the
Tomas Bzatek aa9c0e
+ *		       Secure Hash Functions Policy List bit is set to 1h, then
Tomas Bzatek aa9c0e
+ *		       this field indicates the offset in bytes of a heap object
Tomas Bzatek aa9c0e
+ *		       containing a list of DH-HMAC-CHAP hash function identifiers.
Tomas Bzatek aa9c0e
+ *		       The list is an array of bytes and the values are defined
Tomas Bzatek aa9c0e
+ *		       in the NVM Express Base Specification. If the Secure Hash
Tomas Bzatek aa9c0e
+ *		       Functions Policy List bit is cleared to 0h, then this
Tomas Bzatek aa9c0e
+ *		       field is reserved.
Tomas Bzatek aa9c0e
+ * @sec_keypath_obj:   Secret Keypath Offset Heap Object Reference: if this field
Tomas Bzatek aa9c0e
+ *		       is set to a non-zero value, then this field indicates
Tomas Bzatek aa9c0e
+ *		       the location and size of a heap object containing a URI.
Tomas Bzatek aa9c0e
+ *		       The type of the URI is specified in the Secret Type field.
Tomas Bzatek aa9c0e
+ *		       If this field is cleared to 0h, then this field is reserved.
Tomas Bzatek aa9c0e
+ * @reserved2:	       Reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_security {
Tomas Bzatek aa9c0e
+	__u8 structure_id;
Tomas Bzatek aa9c0e
+	__u8 index;
Tomas Bzatek aa9c0e
+	__le16 flags;
Tomas Bzatek aa9c0e
+	__u8 secret_type;
Tomas Bzatek aa9c0e
+	__u8 reserved1;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj sec_chan_alg_obj;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj auth_proto_obj;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj cipher_suite_obj;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj dh_grp_obj;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj sec_hash_func_obj;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj sec_keypath_obj;
Tomas Bzatek aa9c0e
+	__u8 reserved2[22];
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_security_flags - Security Profile Descriptor Flags (Figure 22)
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_VALID:			  Descriptor Valid: If set to 1h, then
Tomas Bzatek aa9c0e
+ *						  this descriptor is valid. If cleared
Tomas Bzatek aa9c0e
+ *						  to 0h, then this descriptor is not valid.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_IN_BAND_AUTH_MASK:		  Mask to get the In-Band Authentication
Tomas Bzatek aa9c0e
+ *						  Required field.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_IN_BAND_AUTH_NOT_SUPPORTED:	  In-band authentication is not supported
Tomas Bzatek aa9c0e
+ *						  by the NVM subsystem.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_IN_BAND_AUTH_NOT_REQUIRED:	  In-band authentication is supported by
Tomas Bzatek aa9c0e
+ *						  the NVM subsystem and is not required.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_IN_BAND_AUTH_REQUIRED:	  In-band authentication is supported by
Tomas Bzatek aa9c0e
+ *						  the NVM subsystem and is required.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_AUTH_POLICY_LIST_MASK:	  Mask to get the Authentication Policy List
Tomas Bzatek aa9c0e
+ *						  flag: This field indicates whether
Tomas Bzatek aa9c0e
+ *						  authentication protocols were indicated
Tomas Bzatek aa9c0e
+ *						  by policy from driver defaults or
Tomas Bzatek aa9c0e
+ *						  administrative configuration.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_AUTH_POLICY_LIST_NOT_SUPPORTED: Authentication Protocols Heap Object Reference
Tomas Bzatek aa9c0e
+ *						  field Offset and Length are reserved.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_AUTH_POLICY_LIST_DRIVER:	  Authentication Protocols Offset field and
Tomas Bzatek aa9c0e
+ *						  the Authentication Protocols Length field
Tomas Bzatek aa9c0e
+ *						  indicate a list of authentication protocols
Tomas Bzatek aa9c0e
+ *						  used by the driver.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_AUTH_POLICY_LIST_ADMIN:	  Authentication Protocols Offset field and
Tomas Bzatek aa9c0e
+ *						  the Authentication Protocols Length field
Tomas Bzatek aa9c0e
+ *						  indicate a list of authentication protocols
Tomas Bzatek aa9c0e
+ *						  that were administratively set and used
Tomas Bzatek aa9c0e
+ *						  by the driver.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_SEC_CHAN_NEG_MASK:		  Mask to get the Secure Channel Negotiation
Tomas Bzatek aa9c0e
+ *						  Required flag: This field indicates whether
Tomas Bzatek aa9c0e
+ *						  secure channel negotiation (e.g. TLS)
Tomas Bzatek aa9c0e
+ *						  is required.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_SEC_CHAN_NEG_NOT_SUPPORTED:	  Secure channel negotiation is not supported
Tomas Bzatek aa9c0e
+ *						  by the NVM subsystem.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_SEC_CHAN_NEG_NOT_REQUIRED:	  Secure channel negotiation is supported
Tomas Bzatek aa9c0e
+ *						  by the NVM subsystem and is not required.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_SEC_CHAN_NEG_REQUIRED:	  Secure channel negotiation is supported
Tomas Bzatek aa9c0e
+ *						  by the NVM subsystem and is required.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_SEC_POLICY_LIST_MASK:		  Mask to get the Security Policy List flag:
Tomas Bzatek aa9c0e
+ *						  This field indicates whether secure channel
Tomas Bzatek aa9c0e
+ *						  protocols were indicated by policy from driver
Tomas Bzatek aa9c0e
+ *						  defaults or administrative configuration.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_SEC_POLICY_LIST_NOT_SUPPORTED:  The Offset field and Length field in the
Tomas Bzatek aa9c0e
+ *						  Secure Channel Algorithm Heap Object Reference
Tomas Bzatek aa9c0e
+ *						  field are reserved.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_SEC_POLICY_LIST_DRIVER:	  The Heap Object specified by the Secure Channel
Tomas Bzatek aa9c0e
+ *						  Algorithm Heap Object Reference field indicates
Tomas Bzatek aa9c0e
+ *						  a list of authentication protocols used
Tomas Bzatek aa9c0e
+ *						  by the driver.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_SEC_POLICY_LIST_ADMIN:	  The Heap Object specified by the Secure Channel
Tomas Bzatek aa9c0e
+ *						  Algorithm Heap Object Reference field indicates
Tomas Bzatek aa9c0e
+ *						  a list of authentication protocols that were
Tomas Bzatek aa9c0e
+ *						  administratively set and used by the driver.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_CIPHER_RESTRICTED:		  Cipher Suites Restricted by Policy: If set to 1h,
Tomas Bzatek aa9c0e
+ *						  then the Cipher Suite Offset field and the
Tomas Bzatek aa9c0e
+ *						  Ciper Suite Length field indicate a list
Tomas Bzatek aa9c0e
+ *						  of supported cipher suites by the driver.
Tomas Bzatek aa9c0e
+ *						  If cleared to 0h, then the Cipher Suite Offset
Tomas Bzatek aa9c0e
+ *						  field and the Cipher Suite Length field
Tomas Bzatek aa9c0e
+ *						  are reserved.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_AUTH_DH_GROUPS_RESTRICTED:	  Authentication DH Groups Restricted
Tomas Bzatek aa9c0e
+ *						  by Policy List: If set to 1h, then connections
Tomas Bzatek aa9c0e
+ *						  shall use one of the authentication DH groups
Tomas Bzatek aa9c0e
+ *						  in the Authentication DH Groups List is required.
Tomas Bzatek aa9c0e
+ *						  If cleared to 0h, then no Authentication DH Groups
Tomas Bzatek aa9c0e
+ *						  List is indicated and use of an authentication
Tomas Bzatek aa9c0e
+ *						  DH Group is not required.
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_SEC_HASH_FUNC_POLICY_LIST:	  Secure Hash Functions Policy List: If set to 1h,
Tomas Bzatek aa9c0e
+ *						  then connections shall use one of the secure
Tomas Bzatek aa9c0e
+ *						  hash functions in the Secure Hash Functions
Tomas Bzatek aa9c0e
+ *						  Policy List is required. If cleared to 0h,
Tomas Bzatek aa9c0e
+ *						  then no Secure Hash Functions Policy
Tomas Bzatek aa9c0e
+ *						  List is indicated and use of a secure
Tomas Bzatek aa9c0e
+ *						  hash function is not required.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_security_flags {
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_VALID				= 1 << 0,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_IN_BAND_AUTH_MASK			= 0x0006,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_IN_BAND_AUTH_NOT_SUPPORTED	= 0x0000,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_IN_BAND_AUTH_NOT_REQUIRED		= 0x0002,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_IN_BAND_AUTH_REQUIRED		= 0x0004,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_AUTH_POLICY_LIST_MASK		= 0x0018,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_AUTH_POLICY_LIST_NOT_SUPPORTED	= 0x0000,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_AUTH_POLICY_LIST_DRIVER		= 0x0008,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_AUTH_POLICY_LIST_ADMIN		= 0x0010,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_SEC_CHAN_NEG_MASK			= 0x0060,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_SEC_CHAN_NEG_NOT_SUPPORTED	= 0x0000,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_SEC_CHAN_NEG_NOT_REQUIRED		= 0x0020,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_SEC_CHAN_NEG_REQUIRED		= 0x0040,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_SEC_POLICY_LIST_MASK		= 0x0180,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_SEC_POLICY_LIST_NOT_SUPPORTED	= 0x0000,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_SEC_POLICY_LIST_DRIVER		= 0x0080,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_SEC_POLICY_LIST_ADMIN		= 0x0100,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_CIPHER_RESTRICTED			= 1 << 9,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_AUTH_DH_GROUPS_RESTRICTED		= 1 << 10,
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_SEC_HASH_FUNC_POLICY_LIST		= 1 << 11,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_security_secret_type - Security Profile Descriptor Secret Type
Tomas Bzatek aa9c0e
+ * @NBFT_SECURITY_SECRET_REDFISH_HOST_IFACE_URI: Redfish Host Interface URI:
Tomas Bzatek aa9c0e
+ *						 If set to 1h, then the Secret Keypath
Tomas Bzatek aa9c0e
+ *						 Object Reference is a URI pointing
Tomas Bzatek aa9c0e
+ *						 to a Redfish Key Collection Object
Tomas Bzatek aa9c0e
+ *						 that contains the PSK.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_security_secret_type {
Tomas Bzatek aa9c0e
+	NBFT_SECURITY_SECRET_REDFISH_HOST_IFACE_URI	= 1 << 1,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_discovery - Discovery Descriptor (Figure 24)
Tomas Bzatek aa9c0e
+ * @structure_id:	     Structure ID: This field shall be set to 6h
Tomas Bzatek aa9c0e
+ *			     (i.e., Discovery Descriptor; #NBFT_DESC_DISCOVERY).
Tomas Bzatek aa9c0e
+ * @flags:		     Discovery Descriptor Flags, see &enum nbft_discovery_flags.
Tomas Bzatek aa9c0e
+ * @index:		     Discovery Descriptor Index: This field indicates
Tomas Bzatek aa9c0e
+ *			     the number of this Discovery Descriptor in
Tomas Bzatek aa9c0e
+ *			     the Discovery Descriptor List.
Tomas Bzatek aa9c0e
+ * @hfi_index:		     HFI Descriptor Index: This field indicates the value
Tomas Bzatek aa9c0e
+ *			     of the HFI Descriptor Index field of the HFI Descriptor
Tomas Bzatek aa9c0e
+ *			     associated with this Discovery Descriptor. If multiple
Tomas Bzatek aa9c0e
+ *			     HFIs share a common Discovery controller, there shall
Tomas Bzatek aa9c0e
+ *			     be multiple Discovery Descriptor entries with one per HFI.
Tomas Bzatek aa9c0e
+ * @sec_index:		     Security Profile Descriptor Index: This field indicates
Tomas Bzatek aa9c0e
+ *			     the value of the Security Profile Descriptor Index
Tomas Bzatek aa9c0e
+ *			     field of the Security Descriptor associated with
Tomas Bzatek aa9c0e
+ *			     this Discovery Descriptor.
Tomas Bzatek aa9c0e
+ * @reserved1:		     Reserved.
Tomas Bzatek aa9c0e
+ * @discovery_ctrl_addr_obj: Discovery Controller Address Heap Object Reference:
Tomas Bzatek aa9c0e
+ *			     This field indicates the location and size of a heap
Tomas Bzatek aa9c0e
+ *			     object containing a URI which indicates an NVMe Discovery
Tomas Bzatek aa9c0e
+ *			     controller associated with this Discovery Descriptor.
Tomas Bzatek aa9c0e
+ *			     If this field is cleared to 0h, then no URI is specified.
Tomas Bzatek aa9c0e
+ * @discovery_ctrl_nqn_obj:  Discovery Controller NQN Heap Object Reference:
Tomas Bzatek aa9c0e
+ *			     If set to a non-zero value, this field indicates
Tomas Bzatek aa9c0e
+ *			     the location and size of a heap object containing
Tomas Bzatek aa9c0e
+ *			     an NVMe Discovery controller NQN. If the NVMe Discovery
Tomas Bzatek aa9c0e
+ *			     controller referenced by this record requires secure
Tomas Bzatek aa9c0e
+ *			     authentication with a well known Subsystem NQN, this
Tomas Bzatek aa9c0e
+ *			     field indicates the unique NQN for that NVMe Discovery
Tomas Bzatek aa9c0e
+ *			     controller. This record is involved formatted as an NQN
Tomas Bzatek aa9c0e
+ *			     string. If this field is cleared to 0h, then this
Tomas Bzatek aa9c0e
+ *			     field is reserved and the OS shall use the well
Tomas Bzatek aa9c0e
+ *			     known discovery NQN for this record.
Tomas Bzatek aa9c0e
+ * @reserved2:		     Reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_discovery {
Tomas Bzatek aa9c0e
+	__u8 structure_id;
Tomas Bzatek aa9c0e
+	__u8 flags;
Tomas Bzatek aa9c0e
+	__u8 index;
Tomas Bzatek aa9c0e
+	__u8 hfi_index;
Tomas Bzatek aa9c0e
+	__u8 sec_index;
Tomas Bzatek aa9c0e
+	__u8 reserved1;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj discovery_ctrl_addr_obj;
Tomas Bzatek aa9c0e
+	struct nbft_heap_obj discovery_ctrl_nqn_obj;
Tomas Bzatek aa9c0e
+	__u8 reserved2[14];
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_discovery_flags - Discovery Descriptor Flags
Tomas Bzatek aa9c0e
+ * @NBFT_DISCOVERY_VALID: Descriptor Valid: if set to 1h, then this descriptor
Tomas Bzatek aa9c0e
+ *			  is valid. If cleared to 0h, then this descriptor
Tomas Bzatek aa9c0e
+ *			  is reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_discovery_flags {
Tomas Bzatek aa9c0e
+	NBFT_DISCOVERY_VALID	= 1 << 0,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/*
Tomas Bzatek aa9c0e
+ *  End of NBFT ACPI table definitions
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/*
Tomas Bzatek aa9c0e
+ *  Convenient NBFT table parser ('nbft_info' prefix)
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_info_primary_admin_host_flag - Primary Administrative Host Descriptor Flags
Tomas Bzatek aa9c0e
+ * @NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_NOT_INDICATED: Not Indicated by Driver: The driver
Tomas Bzatek aa9c0e
+ * 						     that created this NBFT provided no
Tomas Bzatek aa9c0e
+ * 						     administrative priority hint for
Tomas Bzatek aa9c0e
+ * 						     this NBFT.
Tomas Bzatek aa9c0e
+ * @NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_UNSELECTED:    Unselected: The driver that created
Tomas Bzatek aa9c0e
+ * 						     this NBFT explicitly indicated that
Tomas Bzatek aa9c0e
+ * 						     this NBFT should not be prioritized
Tomas Bzatek aa9c0e
+ * 						     over any other NBFT.
Tomas Bzatek aa9c0e
+ * @NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_SELECTED:	     Selected: The driver that created
Tomas Bzatek aa9c0e
+ * 						     this NBFT explicitly indicated that
Tomas Bzatek aa9c0e
+ * 						     this NBFT should be prioritized over
Tomas Bzatek aa9c0e
+ * 						     any other NBFT.
Tomas Bzatek aa9c0e
+ * @NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_RESERVED:	     Reserved.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_info_primary_admin_host_flag {
Tomas Bzatek aa9c0e
+	NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_NOT_INDICATED,
Tomas Bzatek aa9c0e
+	NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_UNSELECTED,
Tomas Bzatek aa9c0e
+	NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_SELECTED,
Tomas Bzatek aa9c0e
+	NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_RESERVED,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_info_host - Host Descriptor
Tomas Bzatek aa9c0e
+ * @id:			 Host ID (raw UUID, length = 16 bytes).
Tomas Bzatek aa9c0e
+ * @nqn:		 Host NQN.
Tomas Bzatek aa9c0e
+ * @host_id_configured:	 HostID Configured Flag: value of True indicates that @id
Tomas Bzatek aa9c0e
+ * 			 contains administratively-configured value, or driver
Tomas Bzatek aa9c0e
+ * 			 default value if False.
Tomas Bzatek aa9c0e
+ * @host_nqn_configured: Host NQN Configured Flag: value of True indicates that
Tomas Bzatek aa9c0e
+ * 			 @nqn contains administratively-configured value,
Tomas Bzatek aa9c0e
+ * 			 or driver default value if False.
Tomas Bzatek aa9c0e
+ * @primary:		 Primary Administrative Host Descriptor, see
Tomas Bzatek aa9c0e
+ * 			 &enum nbft_info_primary_admin_host_flag.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_info_host {
Tomas Bzatek aa9c0e
+	unsigned char *id;
Tomas Bzatek aa9c0e
+	char *nqn;
Tomas Bzatek aa9c0e
+	bool host_id_configured;
Tomas Bzatek aa9c0e
+	bool host_nqn_configured;
Tomas Bzatek aa9c0e
+	enum nbft_info_primary_admin_host_flag primary;
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_info_hfi_info_tcp - HFI Transport Info Descriptor - NVMe/TCP
Tomas Bzatek aa9c0e
+ * @pci_sbdf:		       PCI Express Routing ID for the HFI Transport Function.
Tomas Bzatek aa9c0e
+ * @mac_addr:		       MAC Address: The MAC address of this HFI,
Tomas Bzatek aa9c0e
+ * 			       in EUI-48TM format.
Tomas Bzatek aa9c0e
+ * @vlan:		       The VLAN identifier if the VLAN is associated with
Tomas Bzatek aa9c0e
+ * 			       this HFI, as defined in IEEE 802.1q-2018 or zeroes
Tomas Bzatek aa9c0e
+ * 			       if no VLAN is associated with this HFI.
Tomas Bzatek aa9c0e
+ * @ip_origin:		       The source of Ethernet L3 configuration information
Tomas Bzatek aa9c0e
+ * 			       used by the driver or 0 if not used.
Tomas Bzatek aa9c0e
+ * @ipaddr:		       The IPv4 or IPv6 address of this HFI.
Tomas Bzatek aa9c0e
+ * @subnet_mask_prefix:	       The IPv4 or IPv6 subnet mask in CIDR routing prefix
Tomas Bzatek aa9c0e
+ * 			       notation.
Tomas Bzatek aa9c0e
+ * @gateway_ipaddr:	       The IPv4 or IPv6 address of the IP gateway for this
Tomas Bzatek aa9c0e
+ * 			       HFI or zeroes if no IP gateway is specified.
Tomas Bzatek aa9c0e
+ * @route_metric:	       The cost value for the route indicated by this HFI.
Tomas Bzatek aa9c0e
+ * @primary_dns_ipaddr:	       The IPv4 or IPv6 address of the Primary DNS server
Tomas Bzatek aa9c0e
+ * 			       for this HFI.
Tomas Bzatek aa9c0e
+ * @secondary_dns_ipaddr:      The IPv4 or IPv6 address of the Secondary DNS server
Tomas Bzatek aa9c0e
+ * 			       for this HFI.
Tomas Bzatek aa9c0e
+ * @dhcp_server_ipaddr:	       The IPv4 or IPv6 address of the DHCP server used
Tomas Bzatek aa9c0e
+ * 			       to assign this HFI address.
Tomas Bzatek aa9c0e
+ * @host_name:		       The Host Name string.
Tomas Bzatek aa9c0e
+ * @this_hfi_is_default_route: If True, then the BIOS utilized this interface
Tomas Bzatek aa9c0e
+ * 			       described by HFI to be the default route with highest
Tomas Bzatek aa9c0e
+ * 			       priority. If False, then routes are local to their
Tomas Bzatek aa9c0e
+ * 			       own scope.
Tomas Bzatek aa9c0e
+ * @dhcp_override:	       If True, then HFI information was populated
Tomas Bzatek aa9c0e
+ * 			       by consuming the DHCP on this interface. If False,
Tomas Bzatek aa9c0e
+ * 			       then the HFI information was set administratively
Tomas Bzatek aa9c0e
+ * 			       by a configuration interface to the driver and
Tomas Bzatek aa9c0e
+ * 			       pre-OS envrionment.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_info_hfi_info_tcp {
Tomas Bzatek aa9c0e
+	__u32 pci_sbdf;
Tomas Bzatek aa9c0e
+	__u8 mac_addr[6];
Tomas Bzatek aa9c0e
+	__u16 vlan;
Tomas Bzatek aa9c0e
+	__u8 ip_origin;
Tomas Bzatek aa9c0e
+	char ipaddr[40];
Tomas Bzatek aa9c0e
+	__u8 subnet_mask_prefix;
Tomas Bzatek aa9c0e
+	char gateway_ipaddr[40];
Tomas Bzatek aa9c0e
+	__u16 route_metric;
Tomas Bzatek aa9c0e
+	char primary_dns_ipaddr[40];
Tomas Bzatek aa9c0e
+	char secondary_dns_ipaddr[40];
Tomas Bzatek aa9c0e
+	char dhcp_server_ipaddr[40];
Tomas Bzatek aa9c0e
+	char *host_name;
Tomas Bzatek aa9c0e
+	bool this_hfi_is_default_route;
Tomas Bzatek aa9c0e
+	bool dhcp_override;
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_info_hfi - Host Fabric Interface (HFI) Descriptor
Tomas Bzatek aa9c0e
+ * @index:     HFI Descriptor Index: indicates the number of this HFI Descriptor
Tomas Bzatek aa9c0e
+ * 	       in the Host Fabric Interface Descriptor List.
Tomas Bzatek aa9c0e
+ * @transport: Transport Type string (e.g. 'tcp').
Tomas Bzatek aa9c0e
+ * @tcp_info:  The HFI Transport Info Descriptor, see &struct nbft_info_hfi_info_tcp.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_info_hfi {
Tomas Bzatek aa9c0e
+	int index;
Tomas Bzatek aa9c0e
+	char transport[8];
Tomas Bzatek aa9c0e
+	struct nbft_info_hfi_info_tcp tcp_info;
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_info_discovery - Discovery Descriptor
Tomas Bzatek aa9c0e
+ * @index:    The number of this Discovery Descriptor in the Discovery
Tomas Bzatek aa9c0e
+ * 	      Descriptor List.
Tomas Bzatek aa9c0e
+ * @security: The Security Profile Descriptor, see &struct nbft_info_security.
Tomas Bzatek aa9c0e
+ * @hfi:      The HFI Descriptor associated with this Discovery Descriptor.
Tomas Bzatek aa9c0e
+ * 	      See &struct nbft_info_hfi.
Tomas Bzatek aa9c0e
+ * @uri:      A URI which indicates an NVMe Discovery controller associated
Tomas Bzatek aa9c0e
+ * 	      with this Discovery Descriptor.
Tomas Bzatek aa9c0e
+ * @nqn:      An NVMe Discovery controller NQN.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_info_discovery {
Tomas Bzatek aa9c0e
+	int index;
Tomas Bzatek aa9c0e
+	struct nbft_info_security *security;
Tomas Bzatek aa9c0e
+	struct nbft_info_hfi *hfi;
Tomas Bzatek aa9c0e
+	char *uri;
Tomas Bzatek aa9c0e
+	char *nqn;
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_info_security - Security Profile Descriptor
Tomas Bzatek aa9c0e
+ * @index: The number of this Security Profile Descriptor in the Security
Tomas Bzatek aa9c0e
+ * 	   Profile Descriptor List.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_info_security {
Tomas Bzatek aa9c0e
+	int index;
Tomas Bzatek aa9c0e
+	/* TODO add fields */
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * enum nbft_info_nid_type - Namespace Identifier Type (NIDT)
Tomas Bzatek aa9c0e
+ * @NBFT_INFO_NID_TYPE_NONE:	No identifier available.
Tomas Bzatek aa9c0e
+ * @NBFT_INFO_NID_TYPE_EUI64:	The EUI-64 identifier.
Tomas Bzatek aa9c0e
+ * @NBFT_INFO_NID_TYPE_NGUID:	The NSGUID identifier.
Tomas Bzatek aa9c0e
+ * @NBFT_INFO_NID_TYPE_NS_UUID:	The UUID identifier.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+enum nbft_info_nid_type {
Tomas Bzatek aa9c0e
+	NBFT_INFO_NID_TYPE_NONE		= 0,
Tomas Bzatek aa9c0e
+	NBFT_INFO_NID_TYPE_EUI64	= 1,
Tomas Bzatek aa9c0e
+	NBFT_INFO_NID_TYPE_NGUID	= 2,
Tomas Bzatek aa9c0e
+	NBFT_INFO_NID_TYPE_NS_UUID	= 3,
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_info_subsystem_ns - Subsystem Namespace (SSNS) info
Tomas Bzatek aa9c0e
+ * @index: 			SSNS Descriptor Index in the descriptor list.
Tomas Bzatek aa9c0e
+ * @discovery:			Primary Discovery Controller associated with
Tomas Bzatek aa9c0e
+ * 				this SSNS Descriptor.
Tomas Bzatek aa9c0e
+ * @security:			Security Profile Descriptor associated with
Tomas Bzatek aa9c0e
+ * 				this namespace.
Tomas Bzatek aa9c0e
+ * @num_hfis:			Number of HFIs.
Tomas Bzatek aa9c0e
+ * @hfis:			List of HFIs associated with this namespace.
Tomas Bzatek aa9c0e
+ * 				Includes the primary HFI at the first position
Tomas Bzatek aa9c0e
+ * 				and all secondary HFIs. This array is null-terminated.
Tomas Bzatek aa9c0e
+ * @transport:			Transport Type string (e.g. 'tcp').
Tomas Bzatek aa9c0e
+ * @traddr:			Subsystem Transport Address.
Tomas Bzatek aa9c0e
+ * @trsvcid:			Subsystem Transport Service Identifier.
Tomas Bzatek aa9c0e
+ * @subsys_port_id:		The Subsystem Port ID.
Tomas Bzatek aa9c0e
+ * @nsid:			The Namespace ID of this descriptor or when @nid
Tomas Bzatek aa9c0e
+ * 				should be used instead.
Tomas Bzatek aa9c0e
+ * @nid_type:			Namespace Identifier Type, see &enum nbft_info_nid_type.
Tomas Bzatek aa9c0e
+ * @nid:			The Namespace Identifier value.
Tomas Bzatek aa9c0e
+ * @subsys_nqn:			Subsystem and Namespace NQN.
Tomas Bzatek aa9c0e
+ * @pdu_header_digest_required:	PDU Header Digest (HDGST) Flag: the use of NVM Header
Tomas Bzatek aa9c0e
+ * 				Digest Enabled is required.
Tomas Bzatek aa9c0e
+ * @data_digest_required: 	Data Digest (DDGST) Flag: the use of NVM Data Digest
Tomas Bzatek aa9c0e
+ * 				Enabled is required.
Tomas Bzatek aa9c0e
+ * @controller_id:		Controller ID (SSNS Extended Information Descriptor):
Tomas Bzatek aa9c0e
+ * 				The controller ID associated with the Admin Queue
Tomas Bzatek aa9c0e
+ * 				or 0 if not supported.
Tomas Bzatek aa9c0e
+ * @asqsz:			Admin Submission Queue Size (SSNS Extended Information
Tomas Bzatek aa9c0e
+ * 				Descriptor) or 0 if not supported.
Tomas Bzatek aa9c0e
+ * @dhcp_root_path_string:	DHCP Root Path Override string (SSNS Extended
Tomas Bzatek aa9c0e
+ * 				Information Descriptor).
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_info_subsystem_ns {
Tomas Bzatek aa9c0e
+	int index;
Tomas Bzatek aa9c0e
+	struct nbft_info_discovery *discovery;
Tomas Bzatek aa9c0e
+	struct nbft_info_security *security;
Tomas Bzatek aa9c0e
+	int num_hfis;
Tomas Bzatek aa9c0e
+	struct nbft_info_hfi **hfis;
Tomas Bzatek aa9c0e
+	char transport[8];
Tomas Bzatek aa9c0e
+	char traddr[40];
Tomas Bzatek aa9c0e
+	char *trsvcid;
Tomas Bzatek aa9c0e
+	__u16 subsys_port_id;
Tomas Bzatek aa9c0e
+	__u32 nsid;
Tomas Bzatek aa9c0e
+	enum nbft_info_nid_type nid_type;
Tomas Bzatek aa9c0e
+	__u8 *nid;
Tomas Bzatek aa9c0e
+	char *subsys_nqn;
Tomas Bzatek aa9c0e
+	bool pdu_header_digest_required;
Tomas Bzatek aa9c0e
+	bool data_digest_required;
Tomas Bzatek aa9c0e
+	int controller_id;
Tomas Bzatek aa9c0e
+	int asqsz;
Tomas Bzatek aa9c0e
+	char *dhcp_root_path_string;
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * struct nbft_info - The parsed NBFT table data.
Tomas Bzatek aa9c0e
+ * @filename:	       Path to the NBFT table.
Tomas Bzatek aa9c0e
+ * @raw_nbft:	       The original NBFT table contents.
Tomas Bzatek aa9c0e
+ * @raw_nbft_size:     Size of @raw_nbft.
Tomas Bzatek aa9c0e
+ * @host:	       The Host Descriptor (should match other NBFTs).
Tomas Bzatek aa9c0e
+ * @hfi_list:	       The HFI Descriptor List (null-terminated array).
Tomas Bzatek aa9c0e
+ * @security_list:     The Security Profile Descriptor List (null-terminated array).
Tomas Bzatek aa9c0e
+ * @discovery_list:    The Discovery Descriptor List (null-terminated array).
Tomas Bzatek aa9c0e
+ * @subsystem_ns_list: The SSNS Descriptor List (null-terminated array).
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+struct nbft_info {
Tomas Bzatek aa9c0e
+	char *filename;
Tomas Bzatek aa9c0e
+	__u8 *raw_nbft;
Tomas Bzatek aa9c0e
+	ssize_t raw_nbft_size;
Tomas Bzatek aa9c0e
+	struct nbft_info_host host;
Tomas Bzatek aa9c0e
+	struct nbft_info_hfi **hfi_list;
Tomas Bzatek aa9c0e
+	struct nbft_info_security **security_list;
Tomas Bzatek aa9c0e
+	struct nbft_info_discovery **discovery_list;
Tomas Bzatek aa9c0e
+	struct nbft_info_subsystem_ns **subsystem_ns_list;
Tomas Bzatek aa9c0e
+};
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * nvme_nbft_read() - Read and parse contents of an ACPI NBFT table
Tomas Bzatek aa9c0e
+ *
Tomas Bzatek aa9c0e
+ * @nbft:     Parsed NBFT table data.
Tomas Bzatek aa9c0e
+ * @filename: Filename of the raw NBFT table to read.
Tomas Bzatek aa9c0e
+ *
Tomas Bzatek aa9c0e
+ * Read and parse the specified NBFT file into a struct nbft_info.
Tomas Bzatek aa9c0e
+ * Free with nbft_free().
Tomas Bzatek aa9c0e
+ *
Tomas Bzatek aa9c0e
+ * Return: 0 on success, errno otherwise.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+int nvme_nbft_read(struct nbft_info **nbft, const char *filename);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+/**
Tomas Bzatek aa9c0e
+ * nvme_nbft_free() - Free the struct nbft_info and its contents
Tomas Bzatek aa9c0e
+ * @nbft: Parsed NBFT table data.
Tomas Bzatek aa9c0e
+ */
Tomas Bzatek aa9c0e
+void nvme_nbft_free(struct nbft_info *nbft);
Tomas Bzatek aa9c0e
+
Tomas Bzatek aa9c0e
+#endif
Tomas Bzatek aa9c0e
-- 
Tomas Bzatek aa9c0e
2.39.2
Tomas Bzatek aa9c0e