Debian Codegraph @

src/nvme/nbft.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3 * This file is part of libnvme.
4 * Copyright (c) 2021-2022, Dell Inc. or its subsidiaries. All Rights Reserved.
5 *
6 * Authors: Stuart Hayes <[email protected]>
7 *
8 */
9 #ifndef _NBFT_H
10 #define _NBFT_H
11
12 #include <sys/types.h>
13
14 #include <nvme/util.h>
15
16 /**
17 * DOC: nbft.h
18 *
19 * NVM Express Boot Specification, Revision 1.0
20 *
21 * Note: this API is currently unstable, subject to further additions.
22 */
23
24 /*
25 * ACPI NBFT table structures (TP8012 Boot Specification rev. 1.0)
26 */
27
28 /**
29 * enum nbft_desc_type - NBFT Elements - Descriptor Types (Figure 5)
30 * @NBFT_DESC_HEADER: Header: an ACPI structure header with some additional
31 * NBFT specific info.
32 * @NBFT_DESC_CONTROL: Control Descriptor: indicates the location of host,
33 * HFI, SSNS, security, and discovery descriptors.
34 * @NBFT_DESC_HOST: Host Descriptor: host information.
35 * @NBFT_DESC_HFI: HFI Descriptor: an indexable table of HFI Descriptors,
36 * one for each fabric interface on the host.
37 * @NBFT_DESC_SSNS: Subsystem Namespace Descriptor: an indexable table
38 * of SSNS Descriptors.
39 * @NBFT_DESC_SECURITY: Security Descriptor: an indexable table of Security
40 * descriptors.
41 * @NBFT_DESC_DISCOVERY: Discovery Descriptor: an indexable table of Discovery
42 * Descriptors.
43 * @NBFT_DESC_HFI_TRINFO: HFI Transport Descriptor: indicated by an HFI Descriptor,
44 * corresponds to a specific transport for a single HFI.
45 * @NBFT_DESC_RESERVED_8: Reserved.
46 * @NBFT_DESC_SSNS_EXT_INFO: SSNS Extended Info Descriptor: indicated by an SSNS
47 * Descriptor if required.
48 */
49 enum nbft_desc_type {
50 NBFT_DESC_HEADER = 0,
51 NBFT_DESC_CONTROL = 1,
52 NBFT_DESC_HOST = 2,
53 NBFT_DESC_HFI = 3,
54 NBFT_DESC_SSNS = 4,
55 NBFT_DESC_SECURITY = 5,
56 NBFT_DESC_DISCOVERY = 6,
57 NBFT_DESC_HFI_TRINFO = 7,
58 NBFT_DESC_RESERVED_8 = 8,
59 NBFT_DESC_SSNS_EXT_INFO = 9,
60 };
61
62 /**
63 * enum nbft_trtype - NBFT Interface Transport Types (Figure 7)
64 * @NBFT_TRTYPE_TCP: NVMe/TCP (802.3 + TCP/IP). String Designator "tcp".
65 */
66 enum nbft_trtype {
67 NBFT_TRTYPE_TCP = 3,
68 };
69
70 #define NBFT_HEADER_SIG "NBFT"
71
72 /**
73 * struct nbft_heap_obj - NBFT Header Driver Signature
74 * @offset: Offset in bytes of the heap object, if any, from byte offset 0h
75 * of the NBFT Table Header.
76 * @length: Length in bytes of the heap object, if any.
77 */
78 struct nbft_heap_obj {
79 __le32 offset;
80 __le16 length;
81 } __attribute__((packed));
82
83 /**
84 * struct nbft_header - NBFT Table - Header (Figure 8)
85 * @signature: Signature: An ASCII string representation of the table
86 * identifier. This field shall be set to the value 4E424654h
87 * (i.e. "NBFT", see #NBFT_HEADER_SIG).
88 * @length: Length: The length of the table, in bytes, including the
89 * header, starting from offset 0h. This field is used to record
90 * the size of the entire table.
91 * @major_revision: Major Revision: The major revision of the structure
92 * corresponding to the Signature field. Larger major revision
93 * numbers should not be assumed backward compatible to lower
94 * major revision numbers with the same signature.
95 * @checksum: Checksum: The entire table, including the Checksum field,
96 * shall sum to 0h to be considered valid.
97 * @oem_id: OEMID shall be populated by the NBFT driver writer by
98 * an OEM-supplied string that identifies the OEM. All
99 * trailing bytes shall be NULL.
100 * @oem_table_id: OEM Table ID: This field shall be populated by the NBFT
101 * driver writer with an OEM-supplied string that the OEM
102 * uses to identify the particular data table. This field is
103 * particularly useful when defining a definition block to
104 * distinguish definition block functions. The OEM assigns
105 * each dissimilar table a new OEM Table ID.
106 * @oem_revision: OEM Revision: An OEM-supplied revision number. Larger
107 * numbers are assumed to be newer revisions.
108 * @creator_id: Creator ID: Vendor ID of utility that created the table.
109 * For instance, this may be the ID for the ASL Compiler.
110 * @creator_revision: Creator Revision: Revision of utility that created the
111 * table. For instance, this may be the ID for the ASL Compiler.
112 * @heap_offset: Heap Offset (HO): This field indicates the offset in bytes
113 * of the heap, if any, from byte offset 0h of the NBFT
114 * Table Header.
115 * @heap_length: Heap Length (HL): The length of the heap, if any.
116 * @driver_dev_path_sig: Driver Signature Heap Object Reference: This field indicates
117 * the offset in bytes of a heap object containing the Driver
118 * Signature, if any, from byte offset 0h of the NBFT Table
119 * Header.
120 * @minor_revision: Minor Revision: The minor revision of the structure
121 * corresponding to the Signature field. If the major revision
122 * numbers are the same, any minor revision number differences
123 * shall be backwards compatible with the same signature.
124 * @reserved: Reserved.
125 */
126 struct nbft_header {
127 char signature[4];
128 __le32 length;
129 __u8 major_revision;
130 __u8 checksum;
131 char oem_id[6];
132 char oem_table_id[8];
133 __le32 oem_revision;
134 __le32 creator_id;
135 __le32 creator_revision;
136 __le32 heap_offset;
137 __le32 heap_length;
138 struct nbft_heap_obj driver_dev_path_sig;
139 __u8 minor_revision;
140 __u8 reserved[13];
141 };
142
143 /**
144 * struct nbft_control - NBFT Table - Control Descriptor (Figure 8)
145 * @structure_id: Structure ID: This field specifies the element (refer to
146 * &enum nbft_desc_type). This field shall be set to 1h (i.e.,
147 * Control, #NBFT_DESC_CONTROL).
148 * @major_revision: Major Revision: The major revision of the structure corresponding
149 * to the Signature field. Larger major revision numbers should
150 * not be assumed backward compatible to lower major revision
151 * numbers with the same signature.
152 * @minor_revision: Minor Revision: The minor revision of the structure corresponding
153 * to the signature field. If the major revision numbers are
154 * the same, any minor revision number differences shall be backwards
155 * compatible with the same signature.
156 * @reserved1: Reserved.
157 * @csl: Control Structure Length (CSL): This field indicates the length
158 * in bytes of the Control Descriptor.
159 * @flags: Flags, see &enum nbft_control_flags.
160 * @reserved2: Reserved.
161 * @hdesc: Host Descriptor (HDESC): This field indicates the location
162 * and length of the Host Descriptor (see &struct nbft_host).
163 * @hsv: Host Descriptor Version (HSV): This field indicates the version
164 * of the Host Descriptor.
165 * @reserved3: Reserved.
166 * @hfio: HFI Descriptor List Offset (HFIO): If this field is set to
167 * a non-zero value, then this field indicates the offset in bytes
168 * of the HFI Descriptor List, if any, from byte offset 0h of the
169 * NBFT Table Header. If the @num_hfi field is cleared to 0h,
170 * then this field is reserved.
171 * @hfil: HFI Descriptor Length (HFIL): This field indicates the length
172 * in bytes of each HFI Descriptor, if any. If the @num_hfi field
173 * is cleared to 0h, then this field is reserved.
174 * @hfiv: HFI Descriptor Version (HFIV): This field indicates the version
175 * of each HFI Descriptor.
176 * @num_hfi: Number of Host Fabric Interface Descriptors (NumHFI): This field
177 * indicates the number of HFI Descriptors (see &struct nbft_hfi)
178 * in the HFI Descriptor List, if any. If no interfaces have been
179 * configured, then this field shall be cleared to 0h.
180 * @ssnso: SSNS Descriptor List Offset (SSNSO):: This field indicates
181 * the offset in bytes of the SSNS Descriptor List, if any, from
182 * byte offset 0h of the NBFT Table Header. If the @num_ssns field
183 * is cleared to 0h, then this field is reserved.
184 * @ssnsl: SSNS Descriptor Length (SSNSL): This field indicates the length
185 * in bytes of each SSNS Descriptor, if any. If the @num_ssns
186 * field is cleared to 0h, then this field is reserved.
187 * @ssnsv: SSNS Descriptor Version (SSNSV): This field indicates the version
188 * of the SSNS Descriptor.
189 * @num_ssns: Number of Subsystem and Namespace Descriptors (NumSSNS): This
190 * field indicates the number of Subsystem Namespace (SSNS)
191 * Descriptors (see &struct nbft_ssns) in the SSNS Descriptor List,
192 * if any.
193 * @seco: Security Profile Descriptor List Offset (SECO): This field
194 * indicates the offset in bytes of the Security Profile Descriptor
195 * List, if any, from byte offset 0h of the NBFT Table Header.
196 * If the @num_sec field is cleared to 0h, then this field
197 * is reserved.
198 * @secl: Security Profile Descriptor Length (SECL): This field indicates
199 * the length in bytes of each Security Profile Descriptor, if any.
200 * If the @num_sec field is cleared to 0h, then this field
201 * is reserved.
202 * @secv: Security Profile Descriptor Version (SECV): This field indicates
203 * the version of the Security Profile Descriptor.
204 * @num_sec: Number of Security Profile Descriptors (NumSec): This field
205 * indicates the number of Security Profile Descriptors
206 * (see &struct nbft_security), if any, in the Security Profile
207 * Descriptor List.
208 * @disco: Discovery Descriptor Offset (DISCO): This field indicates
209 * the offset in bytes of the Discovery Descriptor List, if any,
210 * from byte offset 0h of the NBFT Table Header. If the @num_disc
211 * field is cleared to 0h, then this field is reserved.
212 * @discl: Discovery Descriptor Length (DISCL): This field indicates
213 * the length in bytes of each Discovery Descriptor, if any.
214 * If the @num_disc field is cleared to 0h, then this field
215 * is reserved.
216 * @discv: Discovery Descriptor Version (DISCV): This field indicates
217 * the version of the Discovery Descriptor.
218 * @num_disc: Number of Discovery Descriptors (NumDisc): This field indicates
219 * the number of Discovery Descriptors (see &struct nbft_discovery),
220 * if any, in the Discovery Descriptor List, if any.
221 * @reserved4: Reserved.
222 */
223 struct nbft_control {
224 __u8 structure_id;
225 __u8 major_revision;
226 __u8 minor_revision;
227 __u8 reserved1;
228 __le16 csl;
229 __u8 flags;
230 __u8 reserved2;
231 struct nbft_heap_obj hdesc;
232 __u8 hsv;
233 __u8 reserved3;
234 __le32 hfio;
235 __le16 hfil;
236 __u8 hfiv;
237 __u8 num_hfi;
238 __le32 ssnso;
239 __le16 ssnsl;
240 __u8 ssnsv;
241 __u8 num_ssns;
242 __le32 seco;
243 __le16 secl;
244 __u8 secv;
245 __u8 num_sec;
246 __le32 disco;
247 __le16 discl;
248 __u8 discv;
249 __u8 num_disc;
250 __u8 reserved4[16];
251 };
252
253 /**
254 * enum nbft_control_flags - Control Descriptor Flags
255 * @NBFT_CONTROL_VALID: Block Valid: indicates that the structure is valid.
256 */
257 enum nbft_control_flags {
258 NBFT_CONTROL_VALID = 1 << 0,
259 };
260
261 /**
262 * struct nbft_host - Host Descriptor (Figure 9)
263 * @structure_id: Structure ID: This field shall be set to 2h (i.e.,
264 * Host Descriptor; #NBFT_DESC_HOST).
265 * @flags: Host Flags, see &enum nbft_host_flags.
266 * @host_id: Host ID: This field shall be set to the Host Identifier. This
267 * field shall not be empty if the NBFT and NVMe Boot are supported
268 * by the Platform.
269 * @host_nqn_obj: Host NQN Heap Object Reference: this field indicates a heap
270 * object containing a Host NQN. This object shall not be empty
271 * if the NBFT and NVMe Boot are supported by the Platform.
272 * @reserved: Reserved.
273 */
274 struct nbft_host {
275 __u8 structure_id;
276 __u8 flags;
277 __u8 host_id[16];
278 struct nbft_heap_obj host_nqn_obj;
279 __u8 reserved[8];
280 };
281
282 /**
283 * enum nbft_host_flags - Host Flags
284 * @NBFT_HOST_VALID: Descriptor Valid: If set to 1h, then this
285 * descriptor is valid. If cleared to 0h, then
286 * this descriptor is reserved.
287 * @NBFT_HOST_HOSTID_CONFIGURED: HostID Configured: If set to 1h, then the
288 * Host ID field contains an administratively-configured
289 * value. If cleared to 0h, then the Host ID
290 * field contains a driver default value.
291 * @NBFT_HOST_HOSTNQN_CONFIGURED: Host NQN Configured: If set to 1h, then the
292 * Host NQN indicated by the Host NQN Heap Object
293 * Reference field (&struct nbft_host.host_nqn)
294 * contains an administratively-configured value.
295 * If cleared to 0h, then the Host NQN indicated
296 * by the Host NQN Offset field contains a driver
297 * default value.
298 * @NBFT_HOST_PRIMARY_ADMIN_MASK: Mask to get Primary Administrative Host Descriptor:
299 * indicates whether the Host Descriptor in this
300 * NBFT was selected as the primary NBFT for
301 * administrative purposes of platform identity
302 * as a hint to the OS. If multiple NBFT tables
303 * are present, only one NBFT should be administratively
304 * selected. There is no enforcement mechanism
305 * for this to be coordinated between multiple NBFT
306 * tables, but this field should be set to Selected
307 * (#NBFT_HOST_PRIMARY_ADMIN_SELECTED) if
308 * more than one NBFT is present.
309 * @NBFT_HOST_PRIMARY_ADMIN_NOT_INDICATED: Not Indicated by Driver: The driver that created
310 * this NBFT provided no administrative priority
311 * hint for this NBFT.
312 * @NBFT_HOST_PRIMARY_ADMIN_UNSELECTED: Unselected: The driver that created this NBFT
313 * explicitly indicated that this NBFT should
314 * not be prioritized over any other NBFT.
315 * @NBFT_HOST_PRIMARY_ADMIN_SELECTED: Selected: The driver that created this NBFT
316 * explicitly indicated that this NBFT should
317 * be prioritized over any other NBFT.
318 */
319 enum nbft_host_flags {
320 NBFT_HOST_VALID = 1 << 0,
321 NBFT_HOST_HOSTID_CONFIGURED = 1 << 1,
322 NBFT_HOST_HOSTNQN_CONFIGURED = 1 << 2,
323 NBFT_HOST_PRIMARY_ADMIN_MASK = 0x18,
324 NBFT_HOST_PRIMARY_ADMIN_NOT_INDICATED = 0x00,
325 NBFT_HOST_PRIMARY_ADMIN_UNSELECTED = 0x08,
326 NBFT_HOST_PRIMARY_ADMIN_SELECTED = 0x10,
327 };
328
329 /**
330 * struct nbft_hfi - Host Fabric Interface (HFI) Descriptor (Figure 11)
331 * @structure_id: Structure ID: This field shall be set to 3h (i.e., Host Fabric
332 * Interface Descriptor; #NBFT_DESC_HFI).
333 * @index: HFI Descriptor Index: This field indicates the number of this
334 * HFI Descriptor in the Host Fabric Interface Descriptor List.
335 * @flags: HFI Descriptor Flags, see &enum nbft_hfi_flags.
336 * @trtype: HFI Transport Type, see &enum nbft_trtype.
337 * @reserved1: Reserved.
338 * @trinfo_obj: HFI Transport Info Descriptor Heap Object Reference: If this
339 * field is set to a non-zero value, then this field indicates
340 * the location and size of a heap object containing
341 * a HFI Transport Info.
342 * @reserved2: Reserved.
343 */
344 struct nbft_hfi {
345 __u8 structure_id;
346 __u8 index;
347 __u8 flags;
348 __u8 trtype;
349 __u8 reserved1[12];
350 struct nbft_heap_obj trinfo_obj;
351 __u8 reserved2[10];
352 };
353
354 /**
355 * enum nbft_hfi_flags - HFI Descriptor Flags
356 * @NBFT_HFI_VALID: Descriptor Valid: If set to 1h, then this descriptor is valid.
357 * If cleared to 0h, then this descriptor is reserved.
358 */
359 enum nbft_hfi_flags {
360 NBFT_HFI_VALID = 1 << 0,
361 };
362
363 /**
364 * struct nbft_hfi_info_tcp - HFI Transport Info Descriptor - NVMe/TCP (Figure 13)
365 * @structure_id: Structure ID: This field shall be set to 7h (i.e.,
366 * HFI Transport Info; #NBFT_DESC_HFI_TRINFO).
367 * @version: Version: This field shall be set to 1h.
368 * @trtype: HFI Transport Type, see &enum nbft_trtype: This field
369 * shall be set to 03h (i.e., NVMe/TCP; #NBFT_TRTYPE_TCP).
370 * @trinfo_version: Transport Info Version: Implementations compliant to this
371 * specification shall set this field to 1h.
372 * @hfi_index: HFI Descriptor Index: The value of the HFI Descriptor Index
373 * field of the HFI Descriptor (see &struct nbft_hfi.index)
374 * whose HFI Transport Info Descriptor Heap Object Reference
375 * field indicates this HFI Transport Info Descriptor.
376 * @flags: HFI Transport Flags, see &enum nbft_hfi_info_tcp_flags.
377 * @pci_sbdf: PCI Express Routing ID for the HFI Transport Function:
378 * This field indicates the PCI Express Routing ID as specified
379 * in the PCI Express Base Specification.
380 * @mac_addr: MAC Address: The MAC address of this HFI, in EUI-48TM format,
381 * as defined in the IEEE Guidelines for Use of Extended Unique
382 * Identifiers. This field shall be set to a non-zero value.
383 * @vlan: VLAN: If this field is set to a non-zero value, then this
384 * field contains the VLAN identifier if the VLAN associated
385 * with this HFI, as defined in IEEE 802.1q-2018. If no VLAN
386 * is associated with this HFI, then this field shall be cleared
387 * to 0h.
388 * @ip_origin: IP Origin: If this field is set to a non-zero value, then
389 * this field indicates the source of Ethernet L3 configuration
390 * information used by the driver for this interface. Valid
391 * values are defined in the Win 32 API: NL_PREFIX_ORIGIN
392 * enumeration specification. This field should be cleared
393 * to 0h if the IP Origin field is unused by driver.
394 * @ip_address: IP Address: This field indicates the IPv4 or IPv6 address
395 * of this HFI. This field shall be set to a non-zero value.
396 * @subnet_mask_prefix: Subnet Mask Prefix: This field indicates the IPv4 or IPv6
397 * subnet mask in CIDR routing prefix notation.
398 * @ip_gateway: IP Gateway: If this field is set to a non-zero value, this
399 * field indicates the IPv4 or IPv6 address of the IP gateway
400 * for this HFI. If this field is cleared to 0h, then
401 * no IP gateway is specified.
402 * @reserved1: Reserved.
403 * @route_metric: Route Metric: If this field is set to a non-zero value,
404 * this field indicates the cost value for the route indicated
405 * by this HF. This field contains the value utilized by the
406 * pre-OS driver when chosing among all available routes. Lower
407 * values relate to higher priority. Refer to IETF RFC 4249.
408 * If the pre-OS driver supports routing and did not configure
409 * a specific route metric for this interface, then the pre-OS
410 * driver should set this value to 500. If the pre-OS driver
411 * does not support routing, then this field should be cleared
412 * to 0h.
413 * @primary_dns: Primary DNS: If this field is set to a non-zero value,
414 * this field indicates the IPv4 or IPv6 address of the
415 * Primary DNS server for this HFI, if any, from byte offset
416 * 0h of the NBFT Table Header. If this field is cleared to 0h,
417 * then no Primary DNS is specified.
418 * @secondary_dns: Secondary DNS: If this field is set to a non-zero value,
419 * this field indicates the IPv4 or IPv6 address of
420 * the Secondary DNS server for this HFI, if any, from byte
421 * offset 0h of the NBFT Table Header. If this field is
422 * cleared to 0h, then no Secondary DNS is specified.
423 * @dhcp_server: DHCP Server: If the DHCP Override bit is set to 1h, then
424 * this field indicates the IPv4 or IPv6 address of the DHCP
425 * server used to assign this HFI address. If that bit is
426 * cleared to 0h, then this field is reserved.
427 * @host_name_obj: Host Name Heap Object Reference: If this field is set
428 * to a non-zero value, then this field indicates the location
429 * and size of a heap object containing a Host Name string.
430 * @reserved2: Reserved.
431 */
432 struct nbft_hfi_info_tcp {
433 __u8 structure_id;
434 __u8 version;
435 __u8 trtype;
436 __u8 trinfo_version;
437 __le16 hfi_index;
438 __u8 flags;
439 __le32 pci_sbdf;
440 __u8 mac_addr[6];
441 __le16 vlan;
442 __u8 ip_origin;
443 __u8 ip_address[16];
444 __u8 subnet_mask_prefix;
445 __u8 ip_gateway[16];
446 __u8 reserved1;
447 __le16 route_metric;
448 __u8 primary_dns[16];
449 __u8 secondary_dns[16];
450 __u8 dhcp_server[16];
451 struct nbft_heap_obj host_name_obj;
452 __u8 reserved2[18];
453 } __attribute__((packed));
454
455 /**
456 * enum nbft_hfi_info_tcp_flags - HFI Transport Flags
457 * @NBFT_HFI_INFO_TCP_VALID: Descriptor Valid: if set to 1h, then this
458 * descriptor is valid. If cleared to 0h, then
459 * this descriptor is reserved.
460 * @NBFT_HFI_INFO_TCP_GLOBAL_ROUTE: Global Route vs. Link Local Override Flag:
461 * if set to 1h, then the BIOS utilized this
462 * interface described by HFI to be the default
463 * route with highest priority. If cleared to 0h,
464 * then routes are local to their own scope.
465 * @NBFT_HFI_INFO_TCP_DHCP_OVERRIDE: DHCP Override: if set to 1, then HFI information
466 * was populated by consuming the DHCP on this
467 * interface. If cleared to 0h, then the HFI
468 * information was set administratively by
469 * a configuration interface to the driver and
470 * pre-OS envrionment.
471 */
472 enum nbft_hfi_info_tcp_flags {
473 NBFT_HFI_INFO_TCP_VALID = 1 << 0,
474 NBFT_HFI_INFO_TCP_GLOBAL_ROUTE = 1 << 1,
475 NBFT_HFI_INFO_TCP_DHCP_OVERRIDE = 1 << 2,
476 };
477
478 /**
479 * struct nbft_ssns - Subsystem Namespace (SSNS) Descriptor (Figure 15)
480 * @structure_id: Structure ID: This field shall be set to 4h
481 * (i.e., SSNS; #NBFT_DESC_SSNS).
482 * @index: SSNS Descriptor Index: This field indicates the number
483 * of this Subsystem Namespace Descriptor in the
484 * Subsystem Namespace Descriptor List.
485 * @flags: SSNS Flags, see &enum nbft_ssns_flags.
486 * @trtype: Transport Type, see &enum nbft_trtype.
487 * @trflags: Transport Specific Flags, see &enum nbft_ssns_trflags.
488 * @primary_discovery_ctrl_index: Primary Discovery Controller Index: The Discovery
489 * Descriptor Index field of the Discovery Descriptor
490 * (see &struct nbft_discovery) that is associated with
491 * this SSNS Descriptor. If a Discovery controller was
492 * used to establish this record this value shall
493 * be set to a non-zero value. If this namespace was
494 * associated with multiple Discovery controllers,
495 * those Discovery controllers shall have records
496 * in the Discovery Descriptor to facilitate multi-path
497 * rediscovery as required. If no Discovery controller
498 * was utilized to inform this namespace record,
499 * this field shall be cleared to 0h.
500 * @reserved1: Reserved.
501 * @subsys_traddr_obj: Subsystem Transport Address Heap Object Reference:
502 * This field indicates the location and size of a heap
503 * object containing the Subsystem Transport Address.
504 * For IP based transports types, shall be an IP Address.
505 * @subsys_trsvcid_obj: Subsystem Transport Service Identifier Heap Object Reference:
506 * This field indicates the location and size of a heap
507 * object containing an array of bytes indicating
508 * the Subsystem Transport Service Identifier.
509 * See &enum nbft_trtype.
510 * @subsys_port_id: Subsystem Port ID: Port in the NVM subsystem
511 * associated with this transport address used by
512 * the pre-OS driver.
513 * @nsid: Namespace ID: This field indicates the namespace
514 * identifier (NSID) of the namespace indicated by
515 * this descriptor. This field shall be cleared to 0h
516 * if not specified by the user. If this value is cleared
517 * to 0h, then consumers of the NBFT shall rely
518 * on the NID.
519 * @nidt: Namespace Identifier Type (NIDT): This field
520 * contains the value of the Namespace Identifier Type (NIDT)
521 * field in the Namespace Identification Descriptor
522 * for the namespace indicated by this descriptor.
523 * If a namespace supports multiple NIDT entries
524 * for uniqueness, the order of preference is NIDT field
525 * value of 3h (i.e., UUID) before 2h (i.e., NSGUID),
526 * and 2h before 1h (i.e., EUI-64).
527 * @nid: Namespace Identifier (NID): This field contains
528 * the value of the Namespace Identifier (NID) field
529 * in the Namespace Identification Descriptor for
530 * the namespace indicated by this descriptor.
531 * @security_desc_index: Security Profile Descriptor Index: If the Use Security
532 * Flag bit in the SSNS Flags field is set to 1h, then
533 * this field indicates the value of the Security Profile
534 * Descriptor Index field of the Security Profile
535 * Descriptor (see &struct nbft_security) associated
536 * with this namespace. If the Use Security Flag bit
537 * is cleared to 0h, then no Security Profile Descriptor
538 * is associated with this namespace and this field
539 * is reserved.
540 * @primary_hfi_desc_index: Primary HFI Descriptor Index: This field indicates
541 * the value of the HFI Descriptor Index field of the
542 * HFI Descriptor (see &struct nbft_hfi) for the
543 * interface associated with this namespace. If multiple
544 * HFIs are associated with this record, subsequent
545 * interfaces should be populated in the Secondary
546 * HFI Associations field.
547 * @reserved2: Reserved.
548 * @secondary_hfi_assoc_obj: Secondary HFI Associations Heap Object Reference:
549 * If this field is set to a non-zero value, then
550 * this field indicates an array of bytes, in which
551 * each byte contains the value of the HFI Descriptor
552 * Index field of an HFI Descriptor in the HFI Descriptor
553 * List. If this field is cleared to 0h, then no
554 * secondary HFI associations are specified.
555 * @subsys_ns_nqn_obj: Subsystem and Namespace NQN Heap Object Reference:
556 * This field indicates the location and size of
557 * a heap object containing the Subsystem and Namespace NQN.
558 * @ssns_extended_info_desc_obj: SSNS Extended Information Descriptor Heap Object
559 * Reference: If the SSNS Extended Info In-use Flag
560 * bit is set to 1h, then this field indicates the
561 * offset in bytes of a heap object containing an
562 * SSNS Extended Information Descriptor
563 * (see &struct nbft_ssns_ext_info) heap object
564 * from byte offset 0h of the NBFT Table Header.
565 * If the SSNS Extended Info In-use Flag bit is cleared
566 * to 0h, then this field is reserved.
567 * @reserved3: Reserved.
568 */
569 struct nbft_ssns {
570 __u8 structure_id;
571 __le16 index;
572 __le16 flags;
573 __u8 trtype;
574 __le16 trflags;
575 __u8 primary_discovery_ctrl_index;
576 __u8 reserved1;
577 struct nbft_heap_obj subsys_traddr_obj;
578 struct nbft_heap_obj subsys_trsvcid_obj;
579 __le16 subsys_port_id;
580 __le32 nsid;
581 __u8 nidt;
582 __u8 nid[16];
583 __u8 security_desc_index;
584 __u8 primary_hfi_desc_index;
585 __u8 reserved2;
586 struct nbft_heap_obj secondary_hfi_assoc_obj;
587 struct nbft_heap_obj subsys_ns_nqn_obj;
588 struct nbft_heap_obj ssns_extended_info_desc_obj;
589 __u8 reserved3[62];
590 } __attribute__((packed));
591
592 /**
593 * enum nbft_ssns_flags - Subsystem and Namespace Specific Flags Field (Figure 16)
594 * @NBFT_SSNS_VALID: Descriptor Valid: If set to 1h, then this descriptor
595 * is valid. If cleared to 0h, then this descriptor
596 * is not valid. A host that supports NVMe-oF Boot,
597 * but does not currently have a remote Subsystem
598 * and Namespace assigned may clear this bit to 0h.
599 * @NBFT_SSNS_NON_BOOTABLE_ENTRY: Non-bootable Entry Flag: If set to 1h, this flag
600 * indicates that this SSNS Descriptor contains
601 * a namespace of administrative purpose to the boot
602 * process, but the pre-OS may not have established
603 * connectivity to or evaluated the contents of this
604 * Descriptor. Such namespaces may contain supplemental
605 * data deemed relevant by the Administrator as part
606 * of the pre-OS to OS hand off. This may include
607 * properties such as a UEFI device path that may
608 * not have been created for this namespace. This means
609 * an OS runtime may still require the contents
610 * of such a namespace to complete later stages
611 * of boot. If cleared to 0h, then this namespace did
612 * not have any special administrative intent.
613 * @NBFT_SSNS_USE_SECURITY_FIELD: Use Security Flag: If set to 1h, then there is
614 * a Security Profile Descriptor associated with this
615 * SSNS record and the Security Profile Descriptor Index
616 * field is valid. If cleared to 0h, then there is
617 * no Security Profile Descriptor associated with this
618 * SSNS record and the Security Profile Descriptor Index
619 * field is not valid.
620 * @NBFT_SSNS_DHCP_ROOT_PATH_OVERRIDE: DHCP Root-Path Override Flag: If set to 1h, then
621 * this SSNS descriptor was populated by consuming
622 * the DHCP Root-Path on this interface. If cleared
623 * to 0h, then the DHCP Root-Path was not used
624 * in populating the SSNS descriptor.
625 * @NBFT_SSNS_EXTENDED_INFO_IN_USE: SSNS Extended Info In-use Flag: If set to 1h,
626 * then the SSNS Extended Information Offset field
627 * and the SSNS Extended Information Length field
628 * are valid. This flag, if set to 1h, indicates
629 * that a Subsystem and Namespace Extended Information
630 * Descriptor corresponding to this descriptor is present.
631 * @NBFT_SSNS_SEPARATE_DISCOVERY_CTRL: Separate Discovery Controller Flag: If set to 1h,
632 * then the Discovery controller associated with
633 * this volume is on a different transport address
634 * than the specified in the Subsystem Transport
635 * Address Heap Object Reference. If cleared to 0h,
636 * then the Discovery controller is the same as the
637 * Subsystem Transport Address Heap Object Reference.
638 * @NBFT_SSNS_DISCOVERED_NAMESPACE: Discovered Namespace Flag: If set to 1h, then
639 * this namespace was acquired through discovery.
640 * If cleared to 0h, then this namespace was
641 * explicitly configured in the system.
642 * @NBFT_SSNS_UNAVAIL_NAMESPACE_MASK: Mask to get Unavailable Namespace Flag: This
643 * field indicates the availability of the namespace
644 * at a specific point in time. Such use is only
645 * a hint and its use does not guarantee the availability
646 * of that referenced namespace at any future point in time.
647 * @NBFT_SSNS_UNAVAIL_NAMESPACE_NOTIND: Not Indicated by Driver: No information is provided.
648 * @NBFT_SSNS_UNAVAIL_NAMESPACE_AVAIL: Available: A referenced namespace described by this
649 * flag was previously accessible by the pre-OS driver.
650 * @NBFT_SSNS_UNAVAIL_NAMESPACE_UNAVAIL: Unavailable: This namespace was administratively
651 * configured but unattempted, unavailable or
652 * inaccessible when establishing connectivity
653 * by the pre-OS driver.
654 */
655 enum nbft_ssns_flags {
656 NBFT_SSNS_VALID = 1 << 0,
657 NBFT_SSNS_NON_BOOTABLE_ENTRY = 1 << 1,
658 NBFT_SSNS_USE_SECURITY_FIELD = 1 << 2,
659 NBFT_SSNS_DHCP_ROOT_PATH_OVERRIDE = 1 << 3,
660 NBFT_SSNS_EXTENDED_INFO_IN_USE = 1 << 4,
661 NBFT_SSNS_SEPARATE_DISCOVERY_CTRL = 1 << 5,
662 NBFT_SSNS_DISCOVERED_NAMESPACE = 1 << 6,
663 NBFT_SSNS_UNAVAIL_NAMESPACE_MASK = 0x0180,
664 NBFT_SSNS_UNAVAIL_NAMESPACE_NOTIND = 0x0000,
665 NBFT_SSNS_UNAVAIL_NAMESPACE_AVAIL = 0x0080,
666 NBFT_SSNS_UNAVAIL_NAMESPACE_UNAVAIL = 0x0100,
667 };
668
669 /**
670 * enum nbft_ssns_trflags - SSNS Transport Specific Flags Field (Figure 17)
671 * @NBFT_SSNS_TRFLAG_VALID: Transport Specific Flags in Use: If set to 1h, then
672 * this descriptor is valid. If cleared to 0h, then
673 * this descriptor is not valid.
674 * @NBFT_SSNS_PDU_HEADER_DIGEST: PDU Header Digest (HDGST) Flag: If set to 1h, then
675 * the host or administrator required the connection
676 * described by this Subsystem and Namespace Descriptor
677 * to use the NVM Header Digest Enabled. A consumer
678 * of this information should attempt to use NVM Header
679 * Digest when recreating this connection if enabled.
680 * If cleared to 0h, then the host or administrator
681 * did not require the connection described by this
682 * Subsystem and Namespace Descriptor to use the
683 * NVM Header Digest Enabled.
684 * @NBFT_SSNS_DATA_DIGEST: Data Digest (DDGST) Flag: If set to 1h, then
685 * the host or administrator required the connection
686 * described by this Subsystem and Namespace Descriptor
687 * to use the NVM Data Digest Enabled. If cleared
688 * to 0h, then the host or administrator did not
689 * require the connection described by this Subsystem
690 * and Namespace Descriptor to use the NVM Data Digest
691 * Enabled. A consumer of this field should attempt
692 * to use NVM Data Digest when recreating this
693 * connection if enabled.
694 */
695 enum nbft_ssns_trflags {
696 NBFT_SSNS_TRFLAG_VALID = 1 << 0,
697 NBFT_SSNS_PDU_HEADER_DIGEST = 1 << 1,
698 NBFT_SSNS_DATA_DIGEST = 1 << 2,
699 };
700
701 /**
702 * struct nbft_ssns_ext_info - Subsystem and Namespace Extended Information
703 * Descriptor (Figure 19)
704 * @structure_id: Structure ID: This field shall be set to 9h
705 * (i.e., SSNS Extended Info; #NBFT_DESC_SSNS_EXT_INFO).
706 * @version: Version: This field shall be set to 1h.
707 * @ssns_index: SSNS Descriptor Index: This field indicates the value
708 * of the SSNS Descriptor Index field of the Subsystem
709 * and Namespace Descriptor (see &struct nbft_ssns) whose
710 * SSNS Extended Information Descriptor Heap Object
711 * Reference field indicates this descriptor.
712 * @flags: Flags, see &enum nbft_ssns_ext_info_flags.
713 * @cntlid: Controller ID: The controller identifier of the first
714 * controller associated with the Admin Queue by the driver.
715 * If a controller identifier is not administratively
716 * specified or direct configuration is not supported
717 * by the driver, then this field shall be cleared to 0h.
718 * @asqsz: Admin Submission Queue Size (ASQSZ): The Admin Submission
719 * Queue Size utilized for the respective SSNS by the driver.
720 * @dhcp_root_path_str_obj: DHCP Root Path String Heap Object Reference: If the
721 * SSNS DHCP Root Path Override (#NBFT_SSNS_DHCP_ROOT_PATH_OVERRIDE)
722 * flag bit is set to 1h, then this field indicates
723 * the offset in bytes of a heap object containing
724 * an DHCP Root Path String used by the driver. If the
725 * SNSS DHCP Root Path Override flag bit is cleared to 0h,
726 * then this field is reserved.
727 */
728 struct nbft_ssns_ext_info {
729 __u8 structure_id;
730 __u8 version;
731 __le16 ssns_index;
732 __le32 flags;
733 __le16 cntlid;
734 __le16 asqsz;
735 struct nbft_heap_obj dhcp_root_path_str_obj;
736 } __attribute__((packed));
737
738 /**
739 * enum nbft_ssns_ext_info_flags - Subsystem and Namespace Extended Information
740 * Descriptor Flags
741 * @NBFT_SSNS_EXT_INFO_VALID: Descriptor Valid: If set to 1h, then this descriptor
742 * is valid. If cleared to 0h, then this descriptor
743 * is reserved.
744 * @NBFT_SSNS_EXT_INFO_ADMIN_ASQSZ: Administrative ASQSZ: If set to 1h, then the value
745 * of the ASQSZ field was provided by administrative
746 * configuration for this SSNS record. If cleared
747 * to 0h, then the value of the ASQSZ field was
748 * either obtained by discovery or assumed
749 * by the driver.
750 */
751 enum nbft_ssns_ext_info_flags {
752 NBFT_SSNS_EXT_INFO_VALID = 1 << 0,
753 NBFT_SSNS_EXT_INFO_ADMIN_ASQSZ = 1 << 1,
754 };
755
756 /**
757 * struct nbft_security - Security Profile Descriptor (Figure 21)
758 * @structure_id: Structure ID: This field shall be set to 5h
759 * (i.e., Security; #NBFT_DESC_SECURITY).
760 * @index: Security Profile Descriptor Index: This field indicates
761 * the number of this Security Profile Descriptor in the
762 * Security Profile Descriptor List.
763 * @flags: Security Profile Descriptor Flags, see &enum nbft_security_flags.
764 * @secret_type: Secret Type, see &enum nbft_security_secret_type.
765 * @reserved1: Reserved.
766 * @sec_chan_alg_obj: Secure Channel Algorithm Heap Object Reference: If the
767 * Security Policy List field is set to 1h, then this field
768 * indicates the location and size of a heap object containing
769 * a list of secure channel algorithms. The list is an array
770 * of bytes and the values are defined in the Security Type
771 * (SECTYPE) field in the Transport Specific Address Subtype
772 * Definition in the NVMe TCP Transport Specification.
773 * If the Security Policy List field is cleared to 0h, then
774 * this field is reserved.
775 * @auth_proto_obj: Authentication Protocols Heap Object Reference: If the
776 * Authentication Policy List field is set to 1h, then this
777 * field indicates the location and size of a heap object
778 * containing a list of authentication protocol identifiers.
779 * If the Authentication Policy List field is cleared to 0h,
780 * then this field is reserved.
781 * @cipher_suite_obj: Cipher Suite Offset Heap Object Reference: If the Cipher
782 * Suites Restricted by Policy bit is set to 1h, then this
783 * field indicates the location and size of a heap object
784 * containing a list of cipher suite identifiers. The list,
785 * if any, is an array of bytes and the values are defined
786 * in the IANA TLS Parameters Registry. If the Cipher Suites
787 * Restricted by Policy bit is cleared to 0h, then this field
788 * is reserved.
789 * @dh_grp_obj: DH Groups Heap Object Reference: If the Authentication DH Groups
790 * Restricted by Policy List bit is set to 1h, then this field
791 * indicates the location and size of a heap object containing
792 * a list of DH-HMAC-CHAP Diffie-Hellman (DH) group identifiers.
793 * If the Authentication DH Groups Restricted by Policy List
794 * bit is cleared to 0h, then this field is reserved.
795 * @sec_hash_func_obj: Secure Hash Functions Offset Heap Object Reference: If the
796 * Secure Hash Functions Policy List bit is set to 1h, then
797 * this field indicates the offset in bytes of a heap object
798 * containing a list of DH-HMAC-CHAP hash function identifiers.
799 * The list is an array of bytes and the values are defined
800 * in the NVM Express Base Specification. If the Secure Hash
801 * Functions Policy List bit is cleared to 0h, then this
802 * field is reserved.
803 * @sec_keypath_obj: Secret Keypath Offset Heap Object Reference: if this field
804 * is set to a non-zero value, then this field indicates
805 * the location and size of a heap object containing a URI.
806 * The type of the URI is specified in the Secret Type field.
807 * If this field is cleared to 0h, then this field is reserved.
808 * @reserved2: Reserved.
809 */
810 struct nbft_security {
811 __u8 structure_id;
812 __u8 index;
813 __le16 flags;
814 __u8 secret_type;
815 __u8 reserved1;
816 struct nbft_heap_obj sec_chan_alg_obj;
817 struct nbft_heap_obj auth_proto_obj;
818 struct nbft_heap_obj cipher_suite_obj;
819 struct nbft_heap_obj dh_grp_obj;
820 struct nbft_heap_obj sec_hash_func_obj;
821 struct nbft_heap_obj sec_keypath_obj;
822 __u8 reserved2[22];
823 };
824
825 /**
826 * enum nbft_security_flags - Security Profile Descriptor Flags (Figure 22)
827 * @NBFT_SECURITY_VALID: Descriptor Valid: If set to 1h, then
828 * this descriptor is valid. If cleared
829 * to 0h, then this descriptor is not valid.
830 * @NBFT_SECURITY_IN_BAND_AUTH_MASK: Mask to get the In-Band Authentication
831 * Required field.
832 * @NBFT_SECURITY_IN_BAND_AUTH_NOT_SUPPORTED: In-band authentication is not supported
833 * by the NVM subsystem.
834 * @NBFT_SECURITY_IN_BAND_AUTH_NOT_REQUIRED: In-band authentication is supported by
835 * the NVM subsystem and is not required.
836 * @NBFT_SECURITY_IN_BAND_AUTH_REQUIRED: In-band authentication is supported by
837 * the NVM subsystem and is required.
838 * @NBFT_SECURITY_AUTH_POLICY_LIST_MASK: Mask to get the Authentication Policy List
839 * flag: This field indicates whether
840 * authentication protocols were indicated
841 * by policy from driver defaults or
842 * administrative configuration.
843 * @NBFT_SECURITY_AUTH_POLICY_LIST_NOT_SUPPORTED: Authentication Protocols Heap Object Reference
844 * field Offset and Length are reserved.
845 * @NBFT_SECURITY_AUTH_POLICY_LIST_DRIVER: Authentication Protocols Offset field and
846 * the Authentication Protocols Length field
847 * indicate a list of authentication protocols
848 * used by the driver.
849 * @NBFT_SECURITY_AUTH_POLICY_LIST_ADMIN: Authentication Protocols Offset field and
850 * the Authentication Protocols Length field
851 * indicate a list of authentication protocols
852 * that were administratively set and used
853 * by the driver.
854 * @NBFT_SECURITY_SEC_CHAN_NEG_MASK: Mask to get the Secure Channel Negotiation
855 * Required flag: This field indicates whether
856 * secure channel negotiation (e.g. TLS)
857 * is required.
858 * @NBFT_SECURITY_SEC_CHAN_NEG_NOT_SUPPORTED: Secure channel negotiation is not supported
859 * by the NVM subsystem.
860 * @NBFT_SECURITY_SEC_CHAN_NEG_NOT_REQUIRED: Secure channel negotiation is supported
861 * by the NVM subsystem and is not required.
862 * @NBFT_SECURITY_SEC_CHAN_NEG_REQUIRED: Secure channel negotiation is supported
863 * by the NVM subsystem and is required.
864 * @NBFT_SECURITY_SEC_POLICY_LIST_MASK: Mask to get the Security Policy List flag:
865 * This field indicates whether secure channel
866 * protocols were indicated by policy from driver
867 * defaults or administrative configuration.
868 * @NBFT_SECURITY_SEC_POLICY_LIST_NOT_SUPPORTED: The Offset field and Length field in the
869 * Secure Channel Algorithm Heap Object Reference
870 * field are reserved.
871 * @NBFT_SECURITY_SEC_POLICY_LIST_DRIVER: The Heap Object specified by the Secure Channel
872 * Algorithm Heap Object Reference field indicates
873 * a list of authentication protocols used
874 * by the driver.
875 * @NBFT_SECURITY_SEC_POLICY_LIST_ADMIN: The Heap Object specified by the Secure Channel
876 * Algorithm Heap Object Reference field indicates
877 * a list of authentication protocols that were
878 * administratively set and used by the driver.
879 * @NBFT_SECURITY_CIPHER_RESTRICTED: Cipher Suites Restricted by Policy: If set to 1h,
880 * then the Cipher Suite Offset field and the
881 * Ciper Suite Length field indicate a list
882 * of supported cipher suites by the driver.
883 * If cleared to 0h, then the Cipher Suite Offset
884 * field and the Cipher Suite Length field
885 * are reserved.
886 * @NBFT_SECURITY_AUTH_DH_GROUPS_RESTRICTED: Authentication DH Groups Restricted
887 * by Policy List: If set to 1h, then connections
888 * shall use one of the authentication DH groups
889 * in the Authentication DH Groups List is required.
890 * If cleared to 0h, then no Authentication DH Groups
891 * List is indicated and use of an authentication
892 * DH Group is not required.
893 * @NBFT_SECURITY_SEC_HASH_FUNC_POLICY_LIST: Secure Hash Functions Policy List: If set to 1h,
894 * then connections shall use one of the secure
895 * hash functions in the Secure Hash Functions
896 * Policy List is required. If cleared to 0h,
897 * then no Secure Hash Functions Policy
898 * List is indicated and use of a secure
899 * hash function is not required.
900 */
901 enum nbft_security_flags {
902 NBFT_SECURITY_VALID = 1 << 0,
903 NBFT_SECURITY_IN_BAND_AUTH_MASK = 0x0006,
904 NBFT_SECURITY_IN_BAND_AUTH_NOT_SUPPORTED = 0x0000,
905 NBFT_SECURITY_IN_BAND_AUTH_NOT_REQUIRED = 0x0002,
906 NBFT_SECURITY_IN_BAND_AUTH_REQUIRED = 0x0004,
907 NBFT_SECURITY_AUTH_POLICY_LIST_MASK = 0x0018,
908 NBFT_SECURITY_AUTH_POLICY_LIST_NOT_SUPPORTED = 0x0000,
909 NBFT_SECURITY_AUTH_POLICY_LIST_DRIVER = 0x0008,
910 NBFT_SECURITY_AUTH_POLICY_LIST_ADMIN = 0x0010,
911 NBFT_SECURITY_SEC_CHAN_NEG_MASK = 0x0060,
912 NBFT_SECURITY_SEC_CHAN_NEG_NOT_SUPPORTED = 0x0000,
913 NBFT_SECURITY_SEC_CHAN_NEG_NOT_REQUIRED = 0x0020,
914 NBFT_SECURITY_SEC_CHAN_NEG_REQUIRED = 0x0040,
915 NBFT_SECURITY_SEC_POLICY_LIST_MASK = 0x0180,
916 NBFT_SECURITY_SEC_POLICY_LIST_NOT_SUPPORTED = 0x0000,
917 NBFT_SECURITY_SEC_POLICY_LIST_DRIVER = 0x0080,
918 NBFT_SECURITY_SEC_POLICY_LIST_ADMIN = 0x0100,
919 NBFT_SECURITY_CIPHER_RESTRICTED = 1 << 9,
920 NBFT_SECURITY_AUTH_DH_GROUPS_RESTRICTED = 1 << 10,
921 NBFT_SECURITY_SEC_HASH_FUNC_POLICY_LIST = 1 << 11,
922 };
923
924 /**
925 * enum nbft_security_secret_type - Security Profile Descriptor Secret Type
926 * @NBFT_SECURITY_SECRET_REDFISH_HOST_IFACE_URI: Redfish Host Interface URI:
927 * If set to 1h, then the Secret Keypath
928 * Object Reference is a URI pointing
929 * to a Redfish Key Collection Object
930 * that contains the PSK.
931 */
932 enum nbft_security_secret_type {
933 NBFT_SECURITY_SECRET_REDFISH_HOST_IFACE_URI = 1 << 1,
934 };
935
936 /**
937 * struct nbft_discovery - Discovery Descriptor (Figure 24)
938 * @structure_id: Structure ID: This field shall be set to 6h
939 * (i.e., Discovery Descriptor; #NBFT_DESC_DISCOVERY).
940 * @flags: Discovery Descriptor Flags, see &enum nbft_discovery_flags.
941 * @index: Discovery Descriptor Index: This field indicates
942 * the number of this Discovery Descriptor in
943 * the Discovery Descriptor List.
944 * @hfi_index: HFI Descriptor Index: This field indicates the value
945 * of the HFI Descriptor Index field of the HFI Descriptor
946 * associated with this Discovery Descriptor. If multiple
947 * HFIs share a common Discovery controller, there shall
948 * be multiple Discovery Descriptor entries with one per HFI.
949 * @sec_index: Security Profile Descriptor Index: This field indicates
950 * the value of the Security Profile Descriptor Index
951 * field of the Security Descriptor associated with
952 * this Discovery Descriptor.
953 * @reserved1: Reserved.
954 * @discovery_ctrl_addr_obj: Discovery Controller Address Heap Object Reference:
955 * This field indicates the location and size of a heap
956 * object containing a URI which indicates an NVMe Discovery
957 * controller associated with this Discovery Descriptor.
958 * If this field is cleared to 0h, then no URI is specified.
959 * @discovery_ctrl_nqn_obj: Discovery Controller NQN Heap Object Reference:
960 * If set to a non-zero value, this field indicates
961 * the location and size of a heap object containing
962 * an NVMe Discovery controller NQN. If the NVMe Discovery
963 * controller referenced by this record requires secure
964 * authentication with a well known Subsystem NQN, this
965 * field indicates the unique NQN for that NVMe Discovery
966 * controller. This record is involved formatted as an NQN
967 * string. If this field is cleared to 0h, then this
968 * field is reserved and the OS shall use the well
969 * known discovery NQN for this record.
970 * @reserved2: Reserved.
971 */
972 struct nbft_discovery {
973 __u8 structure_id;
974 __u8 flags;
975 __u8 index;
976 __u8 hfi_index;
977 __u8 sec_index;
978 __u8 reserved1;
979 struct nbft_heap_obj discovery_ctrl_addr_obj;
980 struct nbft_heap_obj discovery_ctrl_nqn_obj;
981 __u8 reserved2[14];
982 };
983
984 /**
985 * enum nbft_discovery_flags - Discovery Descriptor Flags
986 * @NBFT_DISCOVERY_VALID: Descriptor Valid: if set to 1h, then this descriptor
987 * is valid. If cleared to 0h, then this descriptor
988 * is reserved.
989 */
990 enum nbft_discovery_flags {
991 NBFT_DISCOVERY_VALID = 1 << 0,
992 };
993
994 /*
995 * End of NBFT ACPI table definitions
996 */
997
998
999 /*
1000 * Convenient NBFT table parser ('nbft_info' prefix)
1001 */
1002
1003 /**
1004 * enum nbft_info_primary_admin_host_flag - Primary Administrative Host Descriptor Flags
1005 * @NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_NOT_INDICATED: Not Indicated by Driver: The driver
1006 * that created this NBFT provided no
1007 * administrative priority hint for
1008 * this NBFT.
1009 * @NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_UNSELECTED: Unselected: The driver that created
1010 * this NBFT explicitly indicated that
1011 * this NBFT should not be prioritized
1012 * over any other NBFT.
1013 * @NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_SELECTED: Selected: The driver that created
1014 * this NBFT explicitly indicated that
1015 * this NBFT should be prioritized over
1016 * any other NBFT.
1017 * @NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_RESERVED: Reserved.
1018 */
1019 enum nbft_info_primary_admin_host_flag {
1020 NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_NOT_INDICATED,
1021 NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_UNSELECTED,
1022 NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_SELECTED,
1023 NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_RESERVED,
1024 };
1025
1026 /**
1027 * struct nbft_info_host - Host Descriptor
1028 * @id: Host ID (raw UUID, length = 16 bytes).
1029 * @nqn: Host NQN.
1030 * @host_id_configured: HostID Configured Flag: value of True indicates that @id
1031 * contains administratively-configured value, or driver
1032 * default value if False.
1033 * @host_nqn_configured: Host NQN Configured Flag: value of True indicates that
1034 * @nqn contains administratively-configured value,
1035 * or driver default value if False.
1036 * @primary: Primary Administrative Host Descriptor, see
1037 * &enum nbft_info_primary_admin_host_flag.
1038 */
1039 struct nbft_info_host {
1040 unsigned char *id;
1041 char *nqn;
1042 bool host_id_configured;
1043 bool host_nqn_configured;
1044 enum nbft_info_primary_admin_host_flag primary;
1045 };
1046
1047 /**
1048 * struct nbft_info_hfi_info_tcp - HFI Transport Info Descriptor - NVMe/TCP
1049 * @pci_sbdf: PCI Express Routing ID for the HFI Transport Function.
1050 * @mac_addr: MAC Address: The MAC address of this HFI,
1051 * in EUI-48TM format.
1052 * @vlan: The VLAN identifier if the VLAN is associated with
1053 * this HFI, as defined in IEEE 802.1q-2018 or zeroes
1054 * if no VLAN is associated with this HFI.
1055 * @ip_origin: The source of Ethernet L3 configuration information
1056 * used by the driver or 0 if not used.
1057 * @ipaddr: The IPv4 or IPv6 address of this HFI.
1058 * @subnet_mask_prefix: The IPv4 or IPv6 subnet mask in CIDR routing prefix
1059 * notation.
1060 * @gateway_ipaddr: The IPv4 or IPv6 address of the IP gateway for this
1061 * HFI or zeroes if no IP gateway is specified.
1062 * @route_metric: The cost value for the route indicated by this HFI.
1063 * @primary_dns_ipaddr: The IPv4 or IPv6 address of the Primary DNS server
1064 * for this HFI.
1065 * @secondary_dns_ipaddr: The IPv4 or IPv6 address of the Secondary DNS server
1066 * for this HFI.
1067 * @dhcp_server_ipaddr: The IPv4 or IPv6 address of the DHCP server used
1068 * to assign this HFI address.
1069 * @host_name: The Host Name string.
1070 * @this_hfi_is_default_route: If True, then the BIOS utilized this interface
1071 * described by HFI to be the default route with highest
1072 * priority. If False, then routes are local to their
1073 * own scope.
1074 * @dhcp_override: If True, then HFI information was populated
1075 * by consuming the DHCP on this interface. If False,
1076 * then the HFI information was set administratively
1077 * by a configuration interface to the driver and
1078 * pre-OS envrionment.
1079 */
1080 struct nbft_info_hfi_info_tcp {
1081 __u32 pci_sbdf;
1082 __u8 mac_addr[6];
1083 __u16 vlan;
1084 __u8 ip_origin;
1085 char ipaddr[40];
1086 __u8 subnet_mask_prefix;
1087 char gateway_ipaddr[40];
1088 __u16 route_metric;
1089 char primary_dns_ipaddr[40];
1090 char secondary_dns_ipaddr[40];
1091 char dhcp_server_ipaddr[40];
1092 char *host_name;
1093 bool this_hfi_is_default_route;
1094 bool dhcp_override;
1095 };
1096
1097 /**
1098 * struct nbft_info_hfi - Host Fabric Interface (HFI) Descriptor
1099 * @index: HFI Descriptor Index: indicates the number of this HFI Descriptor
1100 * in the Host Fabric Interface Descriptor List.
1101 * @transport: Transport Type string (e.g. 'tcp').
1102 * @tcp_info: The HFI Transport Info Descriptor, see &struct nbft_info_hfi_info_tcp.
1103 */
1104 struct nbft_info_hfi {
1105 int index;
1106 char transport[8];
1107 struct nbft_info_hfi_info_tcp tcp_info;
1108 };
1109
1110 /**
1111 * struct nbft_info_discovery - Discovery Descriptor
1112 * @index: The number of this Discovery Descriptor in the Discovery
1113 * Descriptor List.
1114 * @security: The Security Profile Descriptor, see &struct nbft_info_security.
1115 * @hfi: The HFI Descriptor associated with this Discovery Descriptor.
1116 * See &struct nbft_info_hfi.
1117 * @uri: A URI which indicates an NVMe Discovery controller associated
1118 * with this Discovery Descriptor.
1119 * @nqn: An NVMe Discovery controller NQN.
1120 */
1121 struct nbft_info_discovery {
1122 int index;
1123 struct nbft_info_security *security;
1124 struct nbft_info_hfi *hfi;
1125 char *uri;
1126 char *nqn;
1127 };
1128
1129 /**
1130 * struct nbft_info_security - Security Profile Descriptor
1131 * @index: The number of this Security Profile Descriptor in the Security
1132 * Profile Descriptor List.
1133 */
1134 struct nbft_info_security {
1135 int index;
1136 /* TODO add fields */
1137 };
1138
1139 /**
1140 * enum nbft_info_nid_type - Namespace Identifier Type (NIDT)
1141 * @NBFT_INFO_NID_TYPE_NONE: No identifier available.
1142 * @NBFT_INFO_NID_TYPE_EUI64: The EUI-64 identifier.
1143 * @NBFT_INFO_NID_TYPE_NGUID: The NSGUID identifier.
1144 * @NBFT_INFO_NID_TYPE_NS_UUID: The UUID identifier.
1145 */
1146 enum nbft_info_nid_type {
1147 NBFT_INFO_NID_TYPE_NONE = 0,
1148 NBFT_INFO_NID_TYPE_EUI64 = 1,
1149 NBFT_INFO_NID_TYPE_NGUID = 2,
1150 NBFT_INFO_NID_TYPE_NS_UUID = 3,
1151 };
1152
1153 /**
1154 * struct nbft_info_subsystem_ns - Subsystem Namespace (SSNS) info
1155 * @index: SSNS Descriptor Index in the descriptor list.
1156 * @discovery: Primary Discovery Controller associated with
1157 * this SSNS Descriptor.
1158 * @security: Security Profile Descriptor associated with
1159 * this namespace.
1160 * @num_hfis: Number of HFIs.
1161 * @hfis: List of HFIs associated with this namespace.
1162 * Includes the primary HFI at the first position
1163 * and all secondary HFIs. This array is null-terminated.
1164 * @transport: Transport Type string (e.g. 'tcp').
1165 * @traddr: Subsystem Transport Address.
1166 * @trsvcid: Subsystem Transport Service Identifier.
1167 * @subsys_port_id: The Subsystem Port ID.
1168 * @nsid: The Namespace ID of this descriptor or when @nid
1169 * should be used instead.
1170 * @nid_type: Namespace Identifier Type, see &enum nbft_info_nid_type.
1171 * @nid: The Namespace Identifier value.
1172 * @subsys_nqn: Subsystem and Namespace NQN.
1173 * @pdu_header_digest_required: PDU Header Digest (HDGST) Flag: the use of NVM Header
1174 * Digest Enabled is required.
1175 * @data_digest_required: Data Digest (DDGST) Flag: the use of NVM Data Digest
1176 * Enabled is required.
1177 * @controller_id: Controller ID (SSNS Extended Information Descriptor):
1178 * The controller ID associated with the Admin Queue
1179 * or 0 if not supported.
1180 * @asqsz: Admin Submission Queue Size (SSNS Extended Information
1181 * Descriptor) or 0 if not supported.
1182 * @dhcp_root_path_string: DHCP Root Path Override string (SSNS Extended
1183 * Information Descriptor).
1184 * @discovered: Indicates that this namespace was acquired
1185 * through discovery.
1186 * @unavailable: Namespace is unavailable as indicated by
1187 * the pre-OS driver.
1188 */
1189 struct nbft_info_subsystem_ns {
1190 int index;
1191 struct nbft_info_discovery *discovery;
1192 struct nbft_info_security *security;
1193 int num_hfis;
1194 struct nbft_info_hfi **hfis;
1195 char transport[8];
1196 char traddr[40];
1197 char *trsvcid;
1198 __u16 subsys_port_id;
1199 __u32 nsid;
1200 enum nbft_info_nid_type nid_type;
1201 __u8 *nid;
1202 char *subsys_nqn;
1203 bool pdu_header_digest_required;
1204 bool data_digest_required;
1205 int controller_id;
1206 int asqsz;
1207 char *dhcp_root_path_string;
1208 bool discovered;
1209 bool unavailable;
1210 };
1211
1212 /**
1213 * struct nbft_info - The parsed NBFT table data.
1214 * @filename: Path to the NBFT table.
1215 * @raw_nbft: The original NBFT table contents.
1216 * @raw_nbft_size: Size of @raw_nbft.
1217 * @host: The Host Descriptor (should match other NBFTs).
1218 * @hfi_list: The HFI Descriptor List (null-terminated array).
1219 * @security_list: The Security Profile Descriptor List (null-terminated array).
1220 * @discovery_list: The Discovery Descriptor List (null-terminated array).
1221 * @subsystem_ns_list: The SSNS Descriptor List (null-terminated array).
1222 */
1223 struct nbft_info {
1224 char *filename;
1225 __u8 *raw_nbft;
1226 ssize_t raw_nbft_size;
1227 struct nbft_info_host host;
1228 struct nbft_info_hfi **hfi_list;
1229 struct nbft_info_security **security_list;
1230 struct nbft_info_discovery **discovery_list;
1231 struct nbft_info_subsystem_ns **subsystem_ns_list;
1232 };
1233
1234 /**
1235 * nvme_nbft_read() - Read and parse contents of an ACPI NBFT table
1236 *
1237 * @nbft: Parsed NBFT table data.
1238 * @filename: Filename of the raw NBFT table to read.
1239 *
1240 * Read and parse the specified NBFT file into a struct nbft_info.
1241 * Free with nvme_nbft_free().
1242 *
1243 * Return: 0 on success, errno otherwise.
1244 */
1245 int nvme_nbft_read(struct nbft_info **nbft, const char *filename);
1246
1247 /**
1248 * nvme_nbft_free() - Free the struct nbft_info and its contents
1249 * @nbft: Parsed NBFT table data.
1250 */
1251 void nvme_nbft_free(struct nbft_info *nbft);
1252
1253 #endif