-
Notifications
You must be signed in to change notification settings - Fork 710
Expand file tree
/
Copy pathnbft.h
More file actions
278 lines (263 loc) · 9.75 KB
/
nbft.h
File metadata and controls
278 lines (263 loc) · 9.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* This file is part of libnvme.
* Copyright (c) 2021-2022, Dell Inc. or its subsidiaries. All Rights Reserved.
*
* Authors: Stuart Hayes <[email protected]>
*
*/
#pragma once
#include <stdbool.h>
#include <sys/types.h>
#include <nvme/nbft-types.h>
/**
* enum libnbft_primary_admin_host_flag - Primary Administrative Host Descriptor Flags
* @LIBNBFT_PRIMARY_ADMIN_HOST_FLAG_NOT_INDICATED: Not Indicated by Driver: The driver
* that created this NBFT provided no
* administrative priority hint for
* this NBFT.
* @LIBNBFT_PRIMARY_ADMIN_HOST_FLAG_UNSELECTED: Unselected: The driver that created
* this NBFT explicitly indicated that
* this NBFT should not be prioritized
* over any other NBFT.
* @LIBNBFT_PRIMARY_ADMIN_HOST_FLAG_SELECTED: Selected: The driver that created
* this NBFT explicitly indicated that
* this NBFT should be prioritized over
* any other NBFT.
* @LIBNBFT_PRIMARY_ADMIN_HOST_FLAG_RESERVED: Reserved.
*/
enum libnbft_primary_admin_host_flag {
LIBNBFT_PRIMARY_ADMIN_HOST_FLAG_NOT_INDICATED,
LIBNBFT_PRIMARY_ADMIN_HOST_FLAG_UNSELECTED,
LIBNBFT_PRIMARY_ADMIN_HOST_FLAG_SELECTED,
LIBNBFT_PRIMARY_ADMIN_HOST_FLAG_RESERVED,
};
/**
* struct libnbft_host - Host Descriptor
* @id: Host ID (raw UUID, length = 16 bytes).
* @nqn: Host NQN.
* @host_id_configured: HostID Configured Flag: value of True indicates that @id
* contains administratively-configured value, or driver
* default value if False.
* @host_nqn_configured: Host NQN Configured Flag: value of True indicates that
* @nqn contains administratively-configured value,
* or driver default value if False.
* @primary: Primary Administrative Host Descriptor, see
* &enum libnbft_primary_admin_host_flag.
*/
struct libnbft_host {
unsigned char *id;
char *nqn;
bool host_id_configured;
bool host_nqn_configured;
enum libnbft_primary_admin_host_flag primary;
};
/**
* struct libnbft_hfi_info_tcp - HFI Transport Info Descriptor - NVMe/TCP
* @pci_sbdf: PCI Express Routing ID for the HFI Transport Function.
* @mac_addr: MAC Address: The MAC address of this HFI,
* in EUI-48TM format.
* @vlan: The VLAN identifier if the VLAN is associated with
* this HFI, as defined in IEEE 802.1q-2018 or zeroes
* if no VLAN is associated with this HFI.
* @ip_origin: The source of Ethernet L3 configuration information
* used by the driver or 0 if not used.
* @ipaddr: The IPv4 or IPv6 address of this HFI.
* @subnet_mask_prefix: The IPv4 or IPv6 subnet mask in CIDR routing prefix
* notation.
* @gateway_ipaddr: The IPv4 or IPv6 address of the IP gateway for this
* HFI or zeroes if no IP gateway is specified.
* @route_metric: The cost value for the route indicated by this HFI.
* @primary_dns_ipaddr: The IPv4 or IPv6 address of the Primary DNS server
* for this HFI.
* @secondary_dns_ipaddr: The IPv4 or IPv6 address of the Secondary DNS server
* for this HFI.
* @dhcp_server_ipaddr: The IPv4 or IPv6 address of the DHCP server used
* to assign this HFI address.
* @host_name: The Host Name string.
* @this_hfi_is_default_route: If True, then the BIOS utilized this interface
* described by HFI to be the default route with highest
* priority. If False, then routes are local to their
* own scope.
* @dhcp_override: If True, then HFI information was populated
* by consuming the DHCP on this interface. If False,
* then the HFI information was set administratively
* by a configuration interface to the driver and
* pre-OS envrionment.
*/
struct libnbft_hfi_info_tcp {
__u32 pci_sbdf;
__u8 mac_addr[6];
__u16 vlan;
__u8 ip_origin;
char ipaddr[40];
__u8 subnet_mask_prefix;
char gateway_ipaddr[40];
__u16 route_metric;
char primary_dns_ipaddr[40];
char secondary_dns_ipaddr[40];
char dhcp_server_ipaddr[40];
char *host_name;
bool this_hfi_is_default_route;
bool dhcp_override;
};
/**
* struct libnbft_hfi - Host Fabric Interface (HFI) Descriptor
* @index: HFI Descriptor Index: indicates the number of this HFI Descriptor
* in the Host Fabric Interface Descriptor List.
* @transport: Transport Type string (e.g. 'tcp').
* @tcp_info: The HFI Transport Info Descriptor, see &struct libnbft_hfi_info_tcp.
*/
struct libnbft_hfi {
int index;
char transport[8];
struct libnbft_hfi_info_tcp tcp_info;
};
/**
* struct libnbft_discovery - Discovery Descriptor
* @index: The number of this Discovery Descriptor in the Discovery
* Descriptor List.
* @security: The Security Profile Descriptor, see &struct libnbft_security.
* @hfi: The HFI Descriptor associated with this Discovery Descriptor.
* See &struct libnbft_hfi.
* @uri: A URI which indicates an NVMe Discovery controller associated
* with this Discovery Descriptor.
* @nqn: An NVMe Discovery controller NQN.
*/
struct libnbft_discovery {
int index;
struct libnbft_security *security;
struct libnbft_hfi *hfi;
char *uri;
char *nqn;
};
/**
* struct libnbft_security - Security Profile Descriptor
* @index: The number of this Security Profile Descriptor in the Security
* Profile Descriptor List.
*/
struct libnbft_security {
int index;
/* TODO add fields */
};
/**
* enum libnbft_nid_type - Namespace Identifier Type (NIDT)
* @LIBNBFT_NID_TYPE_NONE: No identifier available.
* @LIBNBFT_NID_TYPE_EUI64: The EUI-64 identifier.
* @LIBNBFT_NID_TYPE_NGUID: The NSGUID identifier.
* @LIBNBFT_NID_TYPE_NS_UUID: The UUID identifier.
*/
enum libnbft_nid_type {
LIBNBFT_NID_TYPE_NONE = 0,
LIBNBFT_NID_TYPE_EUI64 = 1,
LIBNBFT_NID_TYPE_NGUID = 2,
LIBNBFT_NID_TYPE_NS_UUID = 3,
};
/**
* struct libnbft_subsystem_ns - Subsystem Namespace (SSNS) info
* @index: SSNS Descriptor Index in the descriptor list.
* @discovery: Primary Discovery Controller associated with
* this SSNS Descriptor.
* @security: Security Profile Descriptor associated with
* this namespace.
* @num_hfis: Number of HFIs.
* @hfis: List of HFIs associated with this namespace.
* Includes the primary HFI at the first position
* and all secondary HFIs. This array is null-terminated.
* @transport: Transport Type string (e.g. 'tcp').
* @traddr: Subsystem Transport Address.
* @trsvcid: Subsystem Transport Service Identifier.
* @subsys_port_id: The Subsystem Port ID.
* @nsid: The Namespace ID of this descriptor or when @nid
* should be used instead.
* @nid_type: Namespace Identifier Type, see &enum libnbft_nid_type.
* @nid: The Namespace Identifier value.
* @subsys_nqn: Subsystem and Namespace NQN.
* @pdu_header_digest_required: PDU Header Digest (HDGST) Flag: the use of NVM Header
* Digest Enabled is required.
* @data_digest_required: Data Digest (DDGST) Flag: the use of NVM Data Digest
* Enabled is required.
* @controller_id: Controller ID (SSNS Extended Information Descriptor):
* The controller ID associated with the Admin Queue
* or 0 if not supported.
* @asqsz: Admin Submission Queue Size (SSNS Extended Information
* Descriptor) or 0 if not supported.
* @dhcp_root_path_string: DHCP Root Path Override string (SSNS Extended
* Information Descriptor).
* @discovered: Indicates that this namespace was acquired
* through discovery.
* @unavailable: Namespace is unavailable as indicated by
* the pre-OS driver.
*/
struct libnbft_subsystem_ns {
int index;
struct libnbft_discovery *discovery;
struct libnbft_security *security;
int num_hfis;
struct libnbft_hfi **hfis;
char transport[8];
char traddr[40];
char *trsvcid;
__u16 subsys_port_id;
__u32 nsid;
enum libnbft_nid_type nid_type;
__u8 *nid;
char *subsys_nqn;
bool pdu_header_digest_required;
bool data_digest_required;
int controller_id;
int asqsz;
char *dhcp_root_path_string;
bool discovered;
bool unavailable;
};
/**
* struct libnbft_info - The parsed NBFT table data.
* @filename: Path to the NBFT table.
* @raw_nbft: The original NBFT table contents.
* @raw_nbft_size: Size of @raw_nbft.
* @host: The Host Descriptor (should match other NBFTs).
* @hfi_list: The HFI Descriptor List (null-terminated array).
* @security_list: The Security Profile Descriptor List (null-terminated array).
* @discovery_list: The Discovery Descriptor List (null-terminated array).
* @subsystem_ns_list: The SSNS Descriptor List (null-terminated array).
*/
struct libnbft_info {
char *filename;
__u8 *raw_nbft;
ssize_t raw_nbft_size;
struct libnbft_host host;
struct libnbft_hfi **hfi_list;
struct libnbft_security **security_list;
struct libnbft_discovery **discovery_list;
struct libnbft_subsystem_ns **subsystem_ns_list;
};
/**
* libnvmf_read_nbft() - Read and parse contents of an ACPI NBFT table
*
* @ctx: struct libnvme_global_ctx object
* @nbft: Parsed NBFT table data.
* @filename: Filename of the raw NBFT table to read.
*
* Read and parse the specified NBFT file into a struct libnbft_info.
* Free with libnvmf_free_nbft().
*
* Return: 0 on success, errno otherwise.
*/
int libnvmf_read_nbft(struct libnvme_global_ctx *ctx, struct libnbft_info **nbft,
const char *filename);
/**
* libnvmf_free_nbft() - Free the struct libnbft_info and its contents
* @ctx: struct libnvme_global_ctx object
* @nbft: Parsed NBFT table data.
*/
void libnvmf_free_nbft(struct libnvme_global_ctx *ctx, struct libnbft_info *nbft);
/**
* struct nbft_file_entry - Linked list entry for NBFT files
* @next: Pointer to next entry
* @nbft: Pointer to NBFT info structure
*/
struct nbft_file_entry {
struct nbft_file_entry *next;
struct libnbft_info *nbft;
};