-
Notifications
You must be signed in to change notification settings - Fork 710
Expand file tree
/
Copy pathnvme-cmds.h
More file actions
1775 lines (1587 loc) · 59.7 KB
/
nvme-cmds.h
File metadata and controls
1775 lines (1587 loc) · 59.7 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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* This file is part of libnvme.
* Copyright (c) 2020 Western Digital Corporation or its affiliates.
*
* Authors: Keith Busch <[email protected]>
* Chaitanya Kulkarni <[email protected]>
* Daniel Wagner <[email protected]>
*/
#ifndef NVME_CMDS
#define NVME_CMDS
#include <nvme/ioctl.h>
#include <nvme/nvme-cmds.h>
/**
* nvme_flush() - Send an nvme flush command
* @hdl: Transport handle
* @nsid: Namespace identifier
*
* The Flush command requests that the contents of volatile write cache be made
* non-volatile.
*
* Return: 0 on success, the nvme command status if a response was
* received (see &enum nvme_status_field) or a negative error otherwise.
*/
static inline int nvme_flush(struct libnvme_transport_handle *hdl, __u32 nsid)
{
struct libnvme_passthru_cmd cmd = {};
cmd.opcode = nvme_cmd_flush;
cmd.nsid = nsid;
return libnvme_submit_io_passthru(hdl, &cmd);
}
/**
* nvme_identify() - Submit a generic Identify command
* @hdl: Transport handle for the controller.
* @nsid: Namespace ID (if applicable to the requested CNS).
* @csi: Command Set Identifier.
* @cns: Identify Controller or Namespace Structure (CNS) value,
* specifying the type of data to be returned.
* @data: Pointer to the buffer where the identification data will
* be stored.
* @len: Length of the data buffer in bytes.
*
* The generic wrapper for submitting an Identify command, allowing the host
* to specify any combination of Identify parameters.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_identify(struct libnvme_transport_handle *hdl, __u32 nsid, enum nvme_csi csi,
enum nvme_identify_cns cns, void *data, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_identify(&cmd, nsid, csi, cns, data, len);
return libnvme_submit_admin_passthru(hdl, &cmd);
}
/**
* nvme_identify_ctrl() - Submit an Identify Controller command
* @hdl: Transport handle for the controller.
* @id: Pointer to the buffer (&struct nvme_id_ctrl) where the
* controller identification data will be stored upon
* successful completion.
*
* Submits the Identify Controller command to retrieve the controller's
* capabilities and configuration data.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_identify_ctrl(struct libnvme_transport_handle *hdl,
struct nvme_id_ctrl *id)
{
struct libnvme_passthru_cmd cmd;
nvme_init_identify_ctrl(&cmd, id);
return libnvme_submit_admin_passthru(hdl, &cmd);
}
/**
* nvme_identify_active_ns_list() - Submit an Identify Active Namespace
* List command
* @hdl: Transport handle for the controller.
* @nsid: The Namespace ID to query
* @ns_list: Pointer to the buffer (&struct nvme_ns_list) where the
* active namespace list will be stored.
*
* Submits the Identify command to retrieve a list of active Namespace IDs.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_identify_active_ns_list(struct libnvme_transport_handle *hdl,
__u32 nsid, struct nvme_ns_list *ns_list)
{
struct libnvme_passthru_cmd cmd;
nvme_init_identify_active_ns_list(&cmd, nsid, ns_list);
return libnvme_submit_admin_passthru(hdl, &cmd);
}
/**
* nvme_identify_ns() - Submit an Identify Namespace command
* @hdl: Transport handle for the controller.
* @nsid: The Namespace ID to identify.
* @ns: Pointer to the buffer (&struct nvme_id_ns) where the namespace
* identification data will be stored.
*
* Submits the Identify command to retrieve the Namespace Identification
* data structure for a specified namespace.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_identify_ns(struct libnvme_transport_handle *hdl,
__u32 nsid, struct nvme_id_ns *ns)
{
struct libnvme_passthru_cmd cmd;
nvme_init_identify_ns(&cmd, nsid, ns);
return libnvme_submit_admin_passthru(hdl, &cmd);
}
/**
* nvme_identify_csi_ns() - Submit a CSI-specific Identify Namespace command
* @hdl: Transport handle for the controller.
* @nsid: The Namespace ID to identify.
* @csi: The Command Set Identifier
* @uidx: The UUID Index for the command.
* @id_ns: Pointer to the buffer (@struct nvme_nvm_id_ns) where the
* CSI-specific namespace identification data will be stored.
*
* Submits the Identify command to retrieve Namespace Identification data
* specific to a Command Set Identifier (CSI).
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_identify_csi_ns(struct libnvme_transport_handle *hdl, __u32 nsid,
enum nvme_csi csi, __u8 uidx, struct nvme_nvm_id_ns *id_ns)
{
struct libnvme_passthru_cmd cmd;
nvme_init_identify_csi_ns(&cmd, nsid, csi, uidx, id_ns);
return libnvme_submit_admin_passthru(hdl, &cmd);
}
/**
* nvme_identify_uuid_list() - Submit an Identify UUID List command
* @hdl: Transport handle for the controller.
* @uuid_list: Pointer to the buffer (&struct nvme_id_uuid_list) where the
* UUID list will be stored.
*
* Submits the Identify command to retrieve a list of UUIDs associated
* with the controller.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_identify_uuid_list(struct libnvme_transport_handle *hdl,
struct nvme_id_uuid_list *uuid_list)
{
struct libnvme_passthru_cmd cmd;
nvme_init_identify_uuid_list(&cmd, uuid_list);
return libnvme_submit_admin_passthru(hdl, &cmd);
}
/**
* nvme_identify_csi_ns_user_data_format() - Submit an Identify CSI Namespace
* User Data Format command
* @hdl: Transport handle for the controller.
* @csi: Command Set Identifier.
* @fidx: Format Index, specifying which format entry to return.
* @uidx: The UUID Index for the command.
* @data: Pointer to the buffer where the format data will be stored.
*
* Submits the Identify command to retrieve a CSI-specific Namespace User
* Data Format data structure.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_identify_csi_ns_user_data_format(struct libnvme_transport_handle *hdl,
enum nvme_csi csi, __u16 fidx, __u8 uidx, void *data)
{
struct libnvme_passthru_cmd cmd;
nvme_init_identify_csi_ns_user_data_format(&cmd, csi, fidx, uidx, data);
return libnvme_submit_admin_passthru(hdl, &cmd);
}
/**
* nvme_identify_ns_granularity() - Submit an Identify Namespace Granularity
* List command
* @hdl: Transport handle for the controller.
* @gr_list: Pointer to the buffer (&struct nvme_id_ns_granularity_list)
* where the granularity list will be stored.
*
* Submits the Identify command to retrieve the Namespace Granularity List.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_identify_ns_granularity(struct libnvme_transport_handle *hdl,
struct nvme_id_ns_granularity_list *gr_list)
{
struct libnvme_passthru_cmd cmd;
nvme_init_identify_ns_granularity(&cmd, gr_list);
return libnvme_submit_admin_passthru(hdl, &cmd);
}
/**
* nvme_identify_ns_descs_list() - Submit an Identify Namespace ID Descriptor
* List command
* @hdl: Transport handle for the controller.
* @nsid: The Namespace ID to query.
* @descs: Pointer to the buffer (&struct nvme_ns_id_desc) where the
* descriptor list will be stored.
*
* Submits the Identify command to retrieve the Namespace ID Descriptor List
* for a specified namespace.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_identify_ns_descs_list(struct libnvme_transport_handle *hdl,
__u32 nsid, struct nvme_ns_id_desc *descs)
{
struct libnvme_passthru_cmd cmd;
nvme_init_identify_ns_descs_list(&cmd, nsid, descs);
return libnvme_submit_admin_passthru(hdl, &cmd);
}
/**
* nvme_zns_identify_ns() - Submit a ZNS-specific Identify Namespace command
* @hdl: Transport handle for the controller.
* @nsid: The Namespace ID to identify.
* @data: Pointer to the buffer (&struct nvme_zns_id_ns) where the ZNS
* namespace identification data will be stored.
*
* Submits the Identify command to retrieve the Zoned Namespace (ZNS)
* specific identification data structure for a specified namespace.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_zns_identify_ns(struct libnvme_transport_handle *hdl,
__u32 nsid, struct nvme_zns_id_ns *data)
{
struct libnvme_passthru_cmd cmd;
nvme_init_zns_identify_ns(&cmd, nsid, data);
return libnvme_submit_admin_passthru(hdl, &cmd);
}
/**
* nvme_get_log_simple() - Retrieve a log page using default parameters
* @hdl: Transport handle for the controller.
* @lid: Log Identifier, specifying the log page to retrieve
* (@enum nvme_cmd_get_log_lid).
* @data: Pointer to the buffer where the log page data will be stored.
* @len: Length of the data buffer in bytes.
*
* Submits the Get Log Page command using the common settings:
* NVME\_NSID\_ALL, Retain Asynchronous Event (RAE) set to false,
* and assuming the NVM Command Set.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_simple(struct libnvme_transport_handle *hdl,
enum nvme_cmd_get_log_lid lid, void *data, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log(&cmd, NVME_NSID_ALL, lid, NVME_CSI_NVM, data, len);
return libnvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE);
}
/**
* nvme_get_log_supported_log_pages() - Retrieve the Supported Log Pages
* Log Page
* @hdl: Transport handle for the controller.
* @log: Pointer to the buffer (@struct nvme_supported_log_pages) where
* the log page data will be stored.
*
* Submits the Get Log Page command specifically for the Supported Log Pages
* Log.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_supported_log_pages(struct libnvme_transport_handle *hdl,
struct nvme_supported_log_pages *log)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log(&cmd, NVME_NSID_ALL, NVME_LOG_LID_SUPPORTED_LOG_PAGES,
NVME_CSI_NVM, log, sizeof(*log));
return libnvme_get_log(hdl, &cmd, false, sizeof(*log));
}
/**
* nvme_get_log_error() - Retrieve the Error Information Log Page
* @hdl: Transport handle for the controller.
* @nsid: Namespace ID to request the log for (usually NVME_NSID_ALL).
* @nr_entries: The maximum number of error log entries to retrieve.
* @err_log: Pointer to the buffer (array of @struct nvme_error_log_page)
* where the log page data will be stored.
*
* This log page describes extended error information for a command that
* completed with error, or may report an error that is not specific to a
* particular command. The total size requested is determined by
* @nr_entries * sizeof(@struct nvme_error_log_page).
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_error(struct libnvme_transport_handle *hdl, __u32 nsid,
unsigned int nr_entries, struct nvme_error_log_page *err_log)
{
struct libnvme_passthru_cmd cmd;
size_t len = sizeof(*err_log) * nr_entries;
nvme_init_get_log(&cmd, nsid, NVME_LOG_LID_ERROR,
NVME_CSI_NVM, err_log, len);
return libnvme_get_log(hdl, &cmd, false, len);
}
/**
* nvme_get_log_fw_slot() - Retrieve the Firmware Slot Information Log Page
* @hdl: Transport handle for the controller.
* @nsid: Namespace ID to request the log for (use NVME_NSID_ALL).
* @fw_log: Pointer to the buffer (@struct nvme_firmware_slot) where the log
* page data will be stored.
*
* This log page describes the firmware revision stored in each firmware slot
* supported. The firmware revision is indicated as an ASCII string. The log
* page also indicates the active slot number.
*
* This command is typically issued for the controller scope, thus using
* NVME_NSID_ALL.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_fw_slot(struct libnvme_transport_handle *hdl, __u32 nsid,
struct nvme_firmware_slot *fw_log)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log(&cmd, nsid, NVME_LOG_LID_FW_SLOT,
NVME_CSI_NVM, fw_log, sizeof(*fw_log));
return libnvme_get_log(hdl, &cmd, false, sizeof(*fw_log));
}
/**
* nvme_get_log_changed_ns_list() - Retrieve the Namespace Change Log Page
* @hdl: Transport handle for the controller.
* @nsid: Namespace ID to request the log for (use NVME_NSID_ALL).
* @ns_log: Pointer to the buffer (@struct nvme_ns_list) where the log
* page data will be stored.
*
* This log page describes namespaces attached to this controller that have
* changed since the last time the namespace was identified, been added, or
* deleted.
*
* This command is typically issued for the controller scope, thus using
* NVME_NSID_ALL. The Retain Asynchronous Event (RAE) is true to retain
* asynchronous events associated with the log page
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_changed_ns_list(struct libnvme_transport_handle *hdl, __u32 nsid,
struct nvme_ns_list *ns_log)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log(&cmd, nsid, NVME_LOG_LID_CHANGED_NS,
NVME_CSI_NVM, ns_log, sizeof(*ns_log));
return libnvme_get_log(hdl, &cmd, true, sizeof(*ns_log));
}
/**
* nvme_get_log_cmd_effects() - Retrieve the Command Effects Log Page
* @hdl: Transport handle for the controller.
* @csi: Command Set Identifier for the requested log page.
* @effects_log:Pointer to the buffer (@struct nvme_cmd_effects_log) where the
* log page data will be stored.
*
* This log page describes the commands that the controller supports and the
* effects of those commands on the state of the NVM subsystem.
*
* It automatically sets the Log Identifier (LID) and Retain Asynchronous
* Event (RAE) to false. This command is typically issued for the controller
* scope, thus using NVME_NSID_ALL.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_cmd_effects(struct libnvme_transport_handle *hdl,
enum nvme_csi csi, struct nvme_cmd_effects_log *effects_log)
{
struct libnvme_passthru_cmd cmd;
size_t len = sizeof(*effects_log);
nvme_init_get_log_cmd_effects(&cmd, csi, effects_log);
return libnvme_get_log(hdl, &cmd, false, len);
}
/**
* nvme_get_log_device_self_test() - Retrieve the Device Self-Test Log Page
* @hdl: Transport handle for the controller.
* @log: Pointer to the buffer (@struct nvme_self_test_log) where the log
* page data will be stored.
*
* This log page indicates the status of an in-progress self-test and the
* percent complete of that operation, and the results of the previous 20
* self-test operations.
*
* It automatically sets the Log Identifier (LID) and Retain Asynchronous
* Event (RAE) to false. This command is typically issued for the controller
* scope, thus using NVME_NSID_ALL.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_device_self_test(struct libnvme_transport_handle *hdl,
struct nvme_self_test_log *log)
{
struct libnvme_passthru_cmd cmd;
size_t len = sizeof(*log);
nvme_init_get_log(&cmd, NVME_NSID_ALL, NVME_LOG_LID_DEVICE_SELF_TEST,
NVME_CSI_NVM, log, len);
return libnvme_get_log(hdl, &cmd, false, len);
}
/**
* nvme_get_log_create_telemetry_host_mcda() - Create the Host Initiated
* Telemetry Log
* @hdl: Transport handle for the controller.
* @mcda: Maximum Created Data Area. Specifies the maximum amount of data
* that may be returned by the controller.
* @log: Pointer to the buffer (@struct nvme_telemetry_log) where the log
* page data will be stored.
*
* Submits the Get Log Page command to initiate the creation of a Host Initiated
* Telemetry Log. It sets the Log Identifier (LID) to Telemetry Host and
* includes the Maximum Created Data Area (MCDA) in the Log Specific Parameter
* (LSP) field along with the Create bit.
*
* It automatically sets Retain Asynchronous Event (RAE) to false.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_create_telemetry_host_mcda(struct libnvme_transport_handle *hdl,
enum nvme_telemetry_da mcda, struct nvme_telemetry_log *log)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_create_telemetry_host_mcda(&cmd, mcda, log);
return libnvme_get_log(hdl, &cmd, false, sizeof(*log));
}
/**
* nvme_get_log_create_telemetry_host() - Create the Host Initiated Telemetry
* Log (Controller Determined Size)
* @hdl: Transport handle for the controller.
* @log: Pointer to the buffer (@struct nvme_telemetry_log) where the log
* page data will be stored.
*
* Submits the Get Log Page command to initiate the creation of a Host Initiated
* Telemetry Log. This is a convenience wrapper that automatically uses the
* Controller Determined size for the Maximum Created Data Area (MCDA).
*
* It automatically sets Retain Asynchronous Event (RAE) to false.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_create_telemetry_host(struct libnvme_transport_handle *hdl,
struct nvme_telemetry_log *log)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_create_telemetry_host(&cmd, log);
return libnvme_get_log(hdl, &cmd, false, sizeof(*log));
}
/**
* nvme_get_log_telemetry_host() - Retrieve the Host-Initiated
* Telemetry Log Page (Retain)
* @hdl: Transport handle for the controller.
* @lpo: Offset (in bytes) into the telemetry data to start the
* retrieval.
* @log: Pointer to the buffer where the log page data will be stored.
* @len: Length of the buffer provided in @log.
*
* Submits the Get Log Page command to retrieve a previously captured
* Host-Initiated Telemetry Log, starting at a specified offset (@lpo). The Log
* Specific Parameter (LSP) field is set to indicate the capture should be
* retained (not deleted after read).
*
* It automatically sets the Log Identifier (LID) and Retain Asynchronous Event
* (RAE) to false.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_telemetry_host(struct libnvme_transport_handle *hdl,
__u64 lpo, void *log, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_telemetry_host(&cmd, lpo, log, len);
return libnvme_get_log(hdl, &cmd, false, len);
}
/**
* nvme_get_log_telemetry_ctrl() - Retrieve the Controller-Initiated
* Telemetry Log Page
* @hdl: Transport handle for the controller.
* @rae: Retain asynchronous events
* @lpo: Offset (in bytes) into the telemetry data to start the
* retrieval.
* @log: Pointer to the buffer where the log page data will be stored.
* @len: Length of the buffer provided in @log.
*
* Submits the Get Log Page command specifically for the Controller-Initiated
* Telemetry Log, allowing retrieval of data starting at a specified offset
* (@lpo).
*
* It automatically sets the Log Identifier (LID).
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_telemetry_ctrl(struct libnvme_transport_handle *hdl, bool rae,
__u64 lpo, void *log, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_telemetry_ctrl(&cmd, lpo, log, len);
return libnvme_get_log(hdl, &cmd, rae, len);
}
/**
* nvme_get_log_endurance_group() - Retrieve the Endurance Group Log Page
* @hdl: Transport handle for the controller.
* @endgid: Starting Endurance Group Identifier (ENDGID) to return in
* the list.
* @log: Pointer to the buffer (@struct nvme_endurance_group_log) where
* the log page data will be stored.
*
* This log page indicates if an Endurance Group Event has occurred for a
* particular Endurance Group. The ENDGID is placed in the Log Specific
* Identifier (LSI) field of the Get Log Page command.
*
* It automatically sets the Log Identifier (LID) and Retain Asynchronous
* Event (RAE) to false. This command is typically issued for the controller
* scope, thus using NVME_NSID_NONE.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_endurance_group(struct libnvme_transport_handle *hdl,
__u16 endgid, struct nvme_endurance_group_log *log)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_endurance_group(&cmd, endgid, log);
return libnvme_get_log(hdl, &cmd, false, sizeof(*log));
}
/**
* nvme_get_log_predictable_lat_nvmset() - Retrieve the Predictable Latency
* Per NVM Set Log Page
* @hdl: Transport handle for the controller.
* @nvmsetid: The NVM Set Identifier (NVMSETID) for which to retrieve the log.
* @log: Pointer to the buffer (@struct nvme_nvmset_predictable_lat_log)
* where the log page data will be stored.
*
* Submits the Get Log Page command specifically for the Predictable Latency Per
* NVM Set Log. The NVMSETID is placed in the Log Specific Identifier (LSI)
* field of the command.
*
* It automatically sets the Log Identifier (LID) and Retain Asynchronous
* Event (RAE) to false. This command is typically issued for the controller
* scope, thus using NVME_NSID_NONE.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_predictable_lat_nvmset(struct libnvme_transport_handle *hdl,
__u16 nvmsetid, struct nvme_nvmset_predictable_lat_log *log)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_predictable_lat_nvmset(&cmd, nvmsetid, log);
return libnvme_get_log(hdl, &cmd, false, sizeof(*log));
}
/**
* nvme_get_log_predictable_lat_event() - Retrieve the Predictable Latency Event
* Aggregate Log Page
* @hdl: Transport handle for the controller.
* @rae: Retain asynchronous events
* @lpo: Offset (in bytes) into the log page data to start the retrieval.
* @log: Pointer to the buffer where the log page data will be stored.
* @len: Length of the buffer provided in @log.
*
* Submits the Get Log Page command specifically for the Predictable Latency
* Event Aggregate Log, allowing retrieval of data starting at a specified
* offset (@lpo).
*
* It automatically sets the Log Identifier (LID) to
* NVME_LOG_LID_PREDICTABLE_LAT_AGG.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_predictable_lat_event(struct libnvme_transport_handle *hdl,
bool rae, __u64 lpo, void *log, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_predictable_lat_event(&cmd, lpo, log, len);
return libnvme_get_log(hdl, &cmd, rae, len);
}
/**
* nvme_get_log_fdp_configurations() - Retrieve the Flexible Data Placement
* (FDP) Configurations Log Page
* @hdl: Transport handle for the controller.
* @egid: Endurance Group Identifier (EGID) to return in the
* list (used in LSI).
* @lpo: Offset (in bytes) into the log page data to start the retrieval.
* @log: Pointer to the buffer where the log page data will be stored.
* @len: Length of the buffer provided in @log.
*
* Submits the Get Log Page command specifically for the FDP Configurations Log.
* The EGID is placed in the Log Specific Identifier (LSI) field.
*
* It automatically sets the Log Identifier (LID) and Retain Asynchronous
* Event (RAE) to false. This command is typically issued for the controller
* scope, thus using NVME_NSID_NONE.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_fdp_configurations(struct libnvme_transport_handle *hdl,
__u16 egid, __u64 lpo, void *log, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_fdp_configurations(&cmd, egid, lpo, log, len);
return libnvme_get_log(hdl, &cmd, false, len);
}
/**
* nvme_get_log_reclaim_unit_handle_usage() - Retrieve the FDP Reclaim Unit
* Handle (RUH) Usage Log Page
* @hdl: Transport handle for the controller.
* @egid: Endurance Group Identifier (EGID) (used in LSI).
* @lpo: Offset (in bytes) into the log page data to start the retrieval.
* @log: Pointer to the buffer where the log page data will be stored.
* @len: Length of the buffer provided in @log.
*
* Submits the Get Log Page command specifically for the FDP Reclaim Unit Handle
* Usage Log. The EGID is placed in the Log Specific Identifier (LSI) field.
*
* It automatically sets the Log Identifier (LID) and Retain Asynchronous
* Event (RAE) to false. This command is typically issued for the controller
* scope, thus using NVME_NSID_NONE.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_reclaim_unit_handle_usage(struct libnvme_transport_handle *hdl,
__u16 egid, __u64 lpo, void *log, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_reclaim_unit_handle_usage(&cmd, egid, lpo, log, len);
return libnvme_get_log(hdl, &cmd, false, len);
}
/**
* nvme_get_log_fdp_stats() - Retrieve the Flexible Data Placement (FDP)
* Statistics Log Page
* @hdl: Transport handle for the controller.
* @egid: Endurance Group Identifier (EGID) (used in LSI).
* @lpo: Offset (in bytes) into the log page data to start the retrieval.
* @log: Pointer to the buffer where the log page data will be stored.
* @len: Length of the buffer provided in @log.
*
* Submits the Get Log Page command specifically for the FDP Statistics Log.
* The EGID is placed in the Log Specific Identifier (LSI) field.
*
* It automatically sets the Log Identifier (LID) and Retain Asynchronous
* Event (RAE) to false. This command is typically issued for the controller
* scope, thus using NVME_NSID_NONE.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_fdp_stats(struct libnvme_transport_handle *hdl,
__u16 egid, __u64 lpo, void *log, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_fdp_stats(&cmd, egid, lpo, log, len);
return libnvme_get_log(hdl, &cmd, false, len);
}
/**
* nvme_get_log_fdp_events() - Retrieve the Flexible Data Placement (FDP)
* Events Log Page
* @hdl: Transport handle for the controller.
* @egid: Endurance Group Identifier (EGID) (used in LSI).
* @host_events:Whether to report host-initiated events (true) or
* controller-initiated events (false).
* @lpo: Offset (in bytes) into the log page data to start the retrieval.
* @log: Pointer to the buffer where the log page data will be stored.
* @len: Length of the buffer provided in @log.
*
* Submits the Get Log Page command specifically for the FDP Events Log.
* The EGID is placed in the Log Specific Identifier (LSI) field, and the
* @host_events flag is used to set the Log Specific Parameter (LSP) field.
*
* It automatically sets the Log Identifier (LID) and Retain Asynchronous
* Event (RAE) to false. This command is typically issued for the controller
* scope, thus using NVME_NSID_NONE.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_fdp_events(struct libnvme_transport_handle *hdl,
__u16 egid, bool host_events, __u64 lpo, void *log, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_fdp_events(&cmd, egid, host_events, lpo, log, len);
return libnvme_get_log(hdl, &cmd, false, len);
}
/**
* nvme_get_log_ana() - Retrieve the Asymmetric Namespace Access (ANA) Log Page
* @hdl: Transport handle for the controller.
* @rae: Retain asynchronous events
* @lsp: Log specific parameter, see &enum nvme_get_log_ana_lsp.
* @lpo: Offset (in bytes) into the log page data to start the retrieval.
* @log: Pointer to the buffer where the log page data will be stored.
* @len: Length of the buffer provided in @log.
*
* This log consists of a header describing the log and descriptors containing
* the ANA information for groups that contain namespaces attached to the
* controller. The @lsp parameter is placed in the Log Specific Parameter field
* of the command.
*
* See &struct nvme_ana_log for the definition of the returned structure.
*
* It automatically sets the Log Identifier (LID) to NVME_LOG_LID_ANA.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_ana(struct libnvme_transport_handle *hdl, bool rae,
enum nvme_log_ana_lsp lsp, __u64 lpo, void *log, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_ana(&cmd, lsp, lpo, log, len);
return libnvme_get_log(hdl, &cmd, rae, len);
}
/**
* nvme_get_log_ana_groups() - Retrieve the Asymmetric Namespace Access (ANA)
* Groups Only Log Page
* @hdl: Transport handle for the controller.
* @rae: Retain asynchronous events
* @log: Pointer to the buffer (@struct nvme_ana_log) where the log page
* data will be stored.
* @len: Length of the buffer provided in @log.
*
* This function retrieves only the ANA Group Descriptors by setting the Log
* Specific Parameter (LSP) field to NVME_LOG_ANA_LSP_RGO_GROUPS_ONLY. It is a
* convenience wrapper around nvme_get_log_ana, using a Log Page Offset (LPO) of
* 0.
*
* See &struct nvme_ana_log for the definition of the returned structure.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_ana_groups(struct libnvme_transport_handle *hdl, bool rae,
struct nvme_ana_log *log, __u32 len)
{
return nvme_get_log_ana(hdl, rae, NVME_LOG_ANA_LSP_RGO_GROUPS_ONLY,
0, log, len);
}
/**
* nvme_get_log_lba_status() - Retrieve the LBA Status Log Page
* @hdl: Transport handle for the controller.
* @rae: Retain asynchronous events
* @lpo: Offset (in bytes) into the log page data to start the retrieval.
* @log: Pointer to the buffer where the log page data will be stored.
* @len: Length of the buffer provided in @log.
*
* Submits the Get Log Page command specifically for the LBA Status Log.
*
* It automatically sets the Log Identifier (LID) to NVME_LOG_LID_LBA_STATUS.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_lba_status(struct libnvme_transport_handle *hdl,
bool rae, __u64 lpo, void *log, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_lba_status(&cmd, lpo, log, len);
return libnvme_get_log(hdl, &cmd, rae, len);
}
/**
* nvme_get_log_endurance_grp_evt() - Retrieve the Endurance Group Event
* Aggregate Log Page
* @hdl: Transport handle for the controller.
* @rae: Retain asynchronous events
* @lpo: Offset (in bytes) into the log page data to start the retrieval.
* @log: Pointer to the buffer where the log page data will be stored.
* @len: Length of the buffer provided in @log.
*
* Submits the Get Log Page command specifically for the Endurance Group Event
* Aggregate Log, allowing retrieval of data starting at a specified offset
* (@lpo).
*
* It automatically sets the Log Identifier (LID) to
* NVME_LOG_LID_ENDURANCE_GRP_EVT.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_endurance_grp_evt(struct libnvme_transport_handle *hdl,
bool rae, __u64 lpo, void *log, __u32 len)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_endurance_grp_evt(&cmd, lpo, log, len);
return libnvme_get_log(hdl, &cmd, rae, len);
}
/**
* nvme_get_log_fid_supported_effects() - Retrieve the Feature Identifiers
* Supported and Effects Log Page
* @hdl: Transport handle for the controller.
* @csi: Command set identifier, see &enum nvme_csi for known values
* @log: Pointer to the buffer (@struct nvme_fid_supported_effects_log)
* where the log page data will be stored.
*
* Submits the Get Log Page command specifically for the Feature Identifiers
* Supported and Effects Log. It automatically sets the Log Identifier (LID).
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_fid_supported_effects(struct libnvme_transport_handle *hdl,
enum nvme_csi csi, struct nvme_fid_supported_effects_log *log)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_fid_supported_effects(&cmd, csi, log);
return libnvme_get_log(hdl, &cmd, false, sizeof(*log));
}
/**
* nvme_get_log_mi_cmd_supported_effects() - Retrieve the Management Interface
* (MI) Commands Supported and Effects Log Page
* @hdl: Transport handle for the controller.
* @log: Pointer to the buffer
* (@struct nvme_mi_cmd_supported_effects_log) where the log page
* data will be stored.
*
* Submits the Get Log Page command specifically for the MI Commands Supported
* and Effects Log. It automatically sets the Log Identifier (LID). This command
* is typically issued with a namespace ID of 0xFFFFFFFF (NVME_NSID_NONE).
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/
static inline int
nvme_get_log_mi_cmd_supported_effects(struct libnvme_transport_handle *hdl,
struct nvme_mi_cmd_supported_effects_log *log)
{
struct libnvme_passthru_cmd cmd;
nvme_init_get_log_mi_cmd_supported_effects(&cmd, log);
return libnvme_get_log(hdl, &cmd, false, sizeof(*log));
}
/**
* nvme_get_log_boot_partition() - Retrieve the Boot Partition Log Page
* @hdl: Transport handle for the controller.
* @lsp: The Log Specific Parameter (LSP) field for this Log
* Identifier (LID).
* @part: Pointer to the buffer (@struct nvme_boot_partition) where
* the log page data will be stored.
* @len: Length of the buffer provided in @part.
*
* Submits the Get Log Page command specifically for the Boot Partition Log.
* The LSP field is set based on the @lsp parameter.
*
* It automatically sets the Log Identifier (LID) to
* NVME_LOG_LID_BOOT_PARTITION.
*
* Return: 0 on success, the NVMe command status on error, or a negative
* errno otherwise.
*/