forked from linux-nvme/libnvme
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.h
More file actions
10137 lines (9678 loc) · 374 KB
/
types.h
File metadata and controls
10137 lines (9678 loc) · 374 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]>
*/
#ifndef _LIBNVME_TYPES_H
#define _LIBNVME_TYPES_H
#include <stdbool.h>
#include <stdint.h>
#include <linux/types.h>
/**
* DOC: types.h
*
* NVMe standard definitions
*/
/**
* NVME_GET() - extract field from complex value
* @value: The original value of a complex field
* @name: The name of the sub-field within an nvme value
*
* By convention, this library defines _SHIFT and _MASK such that mask can be
* applied after the shift to isolate a specific set of bits that decode to a
* sub-field.
*
* Returns: The 'name' field from 'value'
*/
#define NVME_GET(value, name) \
(((value) >> NVME_##name##_SHIFT) & NVME_##name##_MASK)
/**
* NVME_SET() - set field into complex value
* @value: The value to be set in its completed position
* @name: The name of the sub-field within an nvme value
*
* Returns: The 'name' field from 'value'
*/
#define NVME_SET(value, name) \
(((__u32)(value) & NVME_##name##_MASK) << NVME_##name##_SHIFT)
/**
* NVME_CHECK() - check value to compare field value
* @value: The value to be checked
* @name: The name of the sub-field within an nvme value
* @check: The sub-field value to check
*
* Returns: The result of compare the value and the sub-field value
*/
#define NVME_CHECK(value, name, check) ((value) == NVME_##name##_##check)
/**
* NVME_VAL() - get mask value shifted
* @name: The name of the sub-field within an nvme value
*
* Returns: The mask value shifted
*/
#define NVME_VAL(name) (NVME_##name##_MASK << NVME_##name##_SHIFT)
/**
* enum nvme_constants - A place to stash various constant nvme values
* @NVME_NSID_ALL: A broadcast value that is used to specify all
* namespaces
* @NVME_NSID_NONE: The invalid namespace id, for when the nsid
* parameter is not used in a command
* @NVME_UUID_NONE: Use to omit a uuid command parameter
* @NVME_CNTLID_NONE: Use to omit a cntlid command parameter
* @NVME_CNSSPECID_NONE: Use to omit a cns_specific_id command parameter
* @NVME_LOG_LSP_NONE: Use to omit a log lsp command parameter
* @NVME_LOG_LSI_NONE: Use to omit a log lsi command parameter
* @NVME_LOG_LPO_NONE: Use to omit a log lpo command parameter
* @NVME_IDENTIFY_DATA_SIZE: The transfer size for nvme identify commands
* @NVME_LOG_SUPPORTED_LOG_PAGES_MAX: The largest possible index in the supported
* log pages log.
* @NVME_ID_NVMSET_LIST_MAX: The largest possible nvmset index in identify
* nvmeset
* @NVME_ID_UUID_LIST_MAX: The largest possible uuid index in identify
* uuid list
* @NVME_ID_CTRL_LIST_MAX: The largest possible controller index in
* identify controller list
* @NVME_ID_NS_LIST_MAX: The largest possible namespace index in
* identify namespace list
* @NVME_ID_SECONDARY_CTRL_MAX: The largest possible secondary controller index
* in identify secondary controller
* @NVME_ID_DOMAIN_LIST_MAX: The largest possible domain index in the
* in domain list
* @NVME_ID_ENDURANCE_GROUP_LIST_MAX: The largest possible endurance group
* index in the endurance group list
* @NVME_ID_ND_DESCRIPTOR_MAX: The largest possible namespace granularity
* index in the namespace granularity descriptor
* list
* @NVME_FEAT_LBA_RANGE_MAX: The largest possible LBA range index in feature
* lba range type
* @NVME_LOG_ST_MAX_RESULTS: The largest possible self test result index in the
* device self test log
* @NVME_LOG_FID_SUPPORTED_EFFECTS_MAX: The largest possible FID index in the
* feature identifiers effects log.
* @NVME_LOG_MI_CMD_SUPPORTED_EFFECTS_MAX: The largest possible MI Command index
* in the MI Command effects log.
* @NVME_LOG_MI_CMD_SUPPORTED_EFFECTS_RESERVED: The reserved space in the MI Command
* effects log.
* @NVME_LOG_TELEM_BLOCK_SIZE: Specification defined size of Telemetry Data Blocks
* @NVME_DSM_MAX_RANGES: The largest possible range index in a data-set
* management command
* @NVME_NQN_LENGTH: Max length for NVMe Qualified Name
* @NVMF_TRADDR_SIZE: Max Transport Address size
* @NVMF_TSAS_SIZE: Max Transport Specific Address Subtype size
* @NVME_ZNS_CHANGED_ZONES_MAX: Max number of zones in the changed zones log
* page
*/
enum nvme_constants {
NVME_NSID_ALL = 0xffffffff,
NVME_NSID_NONE = 0,
NVME_UUID_NONE = 0,
NVME_CNTLID_NONE = 0,
NVME_CNSSPECID_NONE = 0,
NVME_LOG_LSP_NONE = 0,
NVME_LOG_LSI_NONE = 0,
NVME_LOG_LPO_NONE = 0,
NVME_IDENTIFY_DATA_SIZE = 4096,
NVME_LOG_SUPPORTED_LOG_PAGES_MAX = 256,
NVME_ID_NVMSET_LIST_MAX = 31,
NVME_ID_UUID_LIST_MAX = 127,
NVME_ID_CTRL_LIST_MAX = 2047,
NVME_ID_NS_LIST_MAX = 1024,
NVME_ID_SECONDARY_CTRL_MAX = 127,
NVME_ID_DOMAIN_LIST_MAX = 31,
NVME_ID_ENDURANCE_GROUP_LIST_MAX = 2047,
NVME_ID_ND_DESCRIPTOR_MAX = 16,
NVME_FEAT_LBA_RANGE_MAX = 64,
NVME_LOG_ST_MAX_RESULTS = 20,
NVME_LOG_TELEM_BLOCK_SIZE = 512,
NVME_LOG_FID_SUPPORTED_EFFECTS_MAX = 256,
NVME_LOG_MI_CMD_SUPPORTED_EFFECTS_MAX = 256,
NVME_LOG_MI_CMD_SUPPORTED_EFFECTS_RESERVED = 768,
NVME_DSM_MAX_RANGES = 256,
NVME_NQN_LENGTH = 256,
NVMF_TRADDR_SIZE = 256,
NVMF_TSAS_SIZE = 256,
NVME_ZNS_CHANGED_ZONES_MAX = 511,
};
/**
* enum nvme_csi - Defined command set indicators
* @NVME_CSI_NVM: NVM Command Set Indicator
* @NVME_CSI_KV: Key Value Command Set
* @NVME_CSI_ZNS: Zoned Namespace Command Set
* @NVME_CSI_SLM: Subsystem Local Memory Command Set
* @NVME_CSI_CP: Computational Programs Command Set
*/
enum nvme_csi {
NVME_CSI_NVM = 0,
NVME_CSI_KV = 1,
NVME_CSI_ZNS = 2,
NVME_CSI_SLM = 3,
NVME_CSI_CP = 4,
};
/**
* enum nvme_register_offsets - controller registers for all transports. This
* is the layout of BAR0/1 for PCIe, and
* properties for fabrics.
* @NVME_REG_CAP: Controller Capabilities
* @NVME_REG_VS: Version
* @NVME_REG_INTMS: Interrupt Mask Set
* @NVME_REG_INTMC: Interrupt Mask Clear
* @NVME_REG_CC: Controller Configuration
* @NVME_REG_CSTS: Controller Status
* @NVME_REG_NSSR: NVM Subsystem Reset
* @NVME_REG_AQA: Admin Queue Attributes
* @NVME_REG_ASQ: Admin SQ Base Address
* @NVME_REG_ACQ: Admin CQ Base Address
* @NVME_REG_CMBLOC: Controller Memory Buffer Location
* @NVME_REG_CMBSZ: Controller Memory Buffer Size
* @NVME_REG_BPINFO: Boot Partition Information
* @NVME_REG_BPRSEL: Boot Partition Read Select
* @NVME_REG_BPMBL: Boot Partition Memory Buffer Location
* @NVME_REG_CMBMSC: Controller Memory Buffer Memory Space Control
* @NVME_REG_CMBSTS: Controller Memory Buffer Status
* @NVME_REG_CMBEBS: Controller Memory Buffer Elasticity Buffer Size
* @NVME_REG_CMBSWTP: Controller Memory Buffer Sustained Write Throughput
* @NVME_REG_NSSD: NVM Subsystem Shutdown
* @NVME_REG_CRTO: Controller Ready Timeouts
* @NVME_REG_PMRCAP: Persistent Memory Capabilities
* @NVME_REG_PMRCTL: Persistent Memory Region Control
* @NVME_REG_PMRSTS: Persistent Memory Region Status
* @NVME_REG_PMREBS: Persistent Memory Region Elasticity Buffer Size
* @NVME_REG_PMRSWTP: Memory Region Sustained Write Throughput
* @NVME_REG_PMRMSCL: Persistent Memory Region Controller Memory Space Control Lower
* @NVME_REG_PMRMSCU: Persistent Memory Region Controller Memory Space Control Upper
*/
enum nvme_register_offsets {
NVME_REG_CAP = 0x0000,
NVME_REG_VS = 0x0008,
NVME_REG_INTMS = 0x000c,
NVME_REG_INTMC = 0x0010,
NVME_REG_CC = 0x0014,
NVME_REG_CSTS = 0x001c,
NVME_REG_NSSR = 0x0020,
NVME_REG_AQA = 0x0024,
NVME_REG_ASQ = 0x0028,
NVME_REG_ACQ = 0x0030,
NVME_REG_CMBLOC = 0x0038,
NVME_REG_CMBSZ = 0x003c,
NVME_REG_BPINFO = 0x0040,
NVME_REG_BPRSEL = 0x0044,
NVME_REG_BPMBL = 0x0048,
NVME_REG_CMBMSC = 0x0050,
NVME_REG_CMBSTS = 0x0058,
NVME_REG_CMBEBS = 0x005c,
NVME_REG_CMBSWTP = 0x0060,
NVME_REG_NSSD = 0x0064,
NVME_REG_CRTO = 0x0068,
NVME_REG_PMRCAP = 0x0e00,
NVME_REG_PMRCTL = 0x0e04,
NVME_REG_PMRSTS = 0x0e08,
NVME_REG_PMREBS = 0x0e0c,
NVME_REG_PMRSWTP = 0x0e10,
NVME_REG_PMRMSCL = 0x0e14,
NVME_REG_PMRMSCU = 0x0e18,
};
/**
* nvme_is_64bit_reg() - Checks if offset of the controller register is a know
* 64bit value.
* @offset: Offset of controller register field in bytes
*
* This function does not care about transport so that the offset is not going
* to be checked inside of this function for the unsupported fields in a
* specific transport. For example, BPMBL(Boot Partition Memory Buffer
* Location) register is not supported by fabrics, but it can be checked here.
*
* Returns: true if given offset is 64bit register, otherwise it returns false.
*/
static inline bool nvme_is_64bit_reg(__u32 offset)
{
switch (offset) {
case NVME_REG_CAP:
case NVME_REG_ASQ:
case NVME_REG_ACQ:
case NVME_REG_BPMBL:
case NVME_REG_CMBMSC:
return true;
default:
return false;
}
}
/**
* enum nvme_cap - This field indicates the controller capabilities register
* @NVME_CAP_MQES_SHIFT: Shift amount to get the maximum queue entries supported
* @NVME_CAP_CQR_SHIFT: Shift amount to get the contiguous queues required
* @NVME_CAP_AMS_SHIFT: Shift amount to get the arbitration mechanism supported
* @NVME_CAP_TO_SHIFT: Shift amount to get the timeout
* @NVME_CAP_DSTRD_SHIFT: Shift amount to get the doorbell stride
* @NVME_CAP_NSSRC_SHIFT: Shift amount to get the NVM subsystem reset supported
* @NVME_CAP_CSS_SHIFT: Shift amount to get the command sets supported
* @NVME_CAP_BPS_SHIFT: Shift amount to get the boot partition support
* @NVME_CAP_CPS_SHIFT: Shift amount to get the controller power scope
* @NVME_CAP_MPSMIN_SHIFT: Shift amount to get the memory page size minimum
* @NVME_CAP_MPSMAX_SHIFT: Shift amount to get the memory page size maximum
* @NVME_CAP_PMRS_SHIFT: Shift amount to get the persistent memory region supported
* @NVME_CAP_CMBS_SHIFT: Shift amount to get the controller memory buffer supported
* @NVME_CAP_NSSS_SHIFT: Shift amount to get the NVM subsystem shutdown supported
* @NVME_CAP_CRMS_SHIFT: Shift amount to get the controller ready modes supported
* @NVME_CAP_MQES_MASK: Mask to get the maximum queue entries supported
* @NVME_CAP_CQR_MASK: Mask to get the contiguous queues required
* @NVME_CAP_AMS_MASK: Mask to get the arbitration mechanism supported
* @NVME_CAP_TO_MASK: Mask to get the timeout
* @NVME_CAP_DSTRD_MASK: Mask to get the doorbell stride
* @NVME_CAP_NSSRC_MASK: Mask to get the NVM subsystem reset supported
* @NVME_CAP_CSS_MASK: Mask to get the command sets supported
* @NVME_CAP_BPS_MASK: Mask to get the boot partition support
* @NVME_CAP_CPS_MASK: Mask to get the controller power scope
* @NVME_CAP_MPSMIN_MASK: Mask to get the memory page size minimum
* @NVME_CAP_MPSMAX_MASK: Mask to get the memory page size maximum
* @NVME_CAP_PMRS_MASK: Mask to get the persistent memory region supported
* @NVME_CAP_CMBS_MASK: Mask to get the controller memory buffer supported
* @NVME_CAP_NSSS_MASK: Mask to get the NVM subsystem shutdown supported
* @NVME_CAP_CRMS_MASK: Mask to get the controller ready modes supported
* @NVME_CAP_AMS_WRR: Weighted round robin with urgent priority class
* @NVME_CAP_AMS_VS: Vendor specific
* @NVME_CAP_CSS_NVM: NVM command set or a discovery controller
* @NVME_CAP_CSS_CSI: Controller supports one or more I/O command sets
* @NVME_CAP_CSS_ADMIN: No I/O command set is supported
* @NVME_CAP_CPS_NONE: Not reported
* @NVME_CAP_CPS_CTRL: Controller scope
* @NVME_CAP_CPS_DOMAIN: Domain scope
* @NVME_CAP_CPS_NVMS: NVM subsystem scope
* @NVME_CAP_CRWMS: Controller ready with media support
* @NVME_CAP_CRIMS: Controller ready independent of media support
*/
enum nvme_cap {
NVME_CAP_MQES_SHIFT = 0,
NVME_CAP_CQR_SHIFT = 16,
NVME_CAP_AMS_SHIFT = 17,
NVME_CAP_TO_SHIFT = 24,
NVME_CAP_DSTRD_SHIFT = 32,
NVME_CAP_NSSRC_SHIFT = 36,
NVME_CAP_CSS_SHIFT = 37,
NVME_CAP_BPS_SHIFT = 45,
NVME_CAP_CPS_SHIFT = 46,
NVME_CAP_MPSMIN_SHIFT = 48,
NVME_CAP_MPSMAX_SHIFT = 52,
NVME_CAP_PMRS_SHIFT = 56,
NVME_CAP_CMBS_SHIFT = 57,
NVME_CAP_NSSS_SHIFT = 58,
NVME_CAP_CRMS_SHIFT = 59,
NVME_CAP_MQES_MASK = 0xffff,
NVME_CAP_CQR_MASK = 0x1,
NVME_CAP_AMS_MASK = 0x3,
NVME_CAP_TO_MASK = 0xff,
NVME_CAP_DSTRD_MASK = 0xf,
NVME_CAP_NSSRC_MASK = 0x1,
NVME_CAP_CSS_MASK = 0xff,
NVME_CAP_BPS_MASK = 0x1,
NVME_CAP_CPS_MASK = 0x3,
NVME_CAP_MPSMIN_MASK = 0xf,
NVME_CAP_MPSMAX_MASK = 0xf,
NVME_CAP_PMRS_MASK = 0x1,
NVME_CAP_CMBS_MASK = 0x1,
NVME_CAP_NSSS_MASK = 0x1,
NVME_CAP_CRMS_MASK = 0x3,
NVME_CAP_AMS_WRR = 1 << 0,
NVME_CAP_AMS_VS = 1 << 1,
NVME_CAP_CSS_NVM = 1 << 0,
NVME_CAP_CSS_CSI = 1 << 6,
NVME_CAP_CSS_ADMIN = 1 << 7,
NVME_CAP_CPS_NONE = 0,
NVME_CAP_CPS_CTRL = 1,
NVME_CAP_CPS_DOMAIN = 2,
NVME_CAP_CPS_NVMS = 3,
NVME_CAP_CRWMS = 1 << 0,
NVME_CAP_CRIMS = 1 << 1,
};
#define NVME_CAP_MQES(cap) NVME_GET(cap, CAP_MQES)
#define NVME_CAP_CQR(cap) NVME_GET(cap, CAP_CQR)
#define NVME_CAP_AMS(cap) NVME_GET(cap, CAP_AMS)
#define NVME_CAP_TO(cap) NVME_GET(cap, CAP_TO)
#define NVME_CAP_DSTRD(cap) NVME_GET(cap, CAP_DSTRD)
#define NVME_CAP_NSSRC(cap) NVME_GET(cap, CAP_NSSRC)
#define NVME_CAP_CSS(cap) NVME_GET(cap, CAP_CSS)
#define NVME_CAP_BPS(cap) NVME_GET(cap, CAP_BPS)
#define NVME_CAP_CPS(cap) NVME_GET(cap, CAP_CPS)
#define NVME_CAP_MPSMIN(cap) NVME_GET(cap, CAP_MPSMIN)
#define NVME_CAP_MPSMAX(cap) NVME_GET(cap, CAP_MPSMAX)
#define NVME_CAP_PMRS(cap) NVME_GET(cap, CAP_PMRS)
#define NVME_CAP_CMBS(cap) NVME_GET(cap, CAP_CMBS)
#define NVME_CAP_NSSS(cap) NVME_GET(cap, CAP_NSSS)
#define NVME_CAP_CRMS(cap) NVME_GET(cap, CAP_CRMS)
/**
* enum nvme_vs - This field indicates the version
* @NVME_VS_TER_SHIFT: Shift amount to get the tertiary version
* @NVME_VS_MNR_SHIFT: Shift amount to get the minor version
* @NVME_VS_MJR_SHIFT: Shift amount to get the major version
* @NVME_VS_TER_MASK: Mask to get the tertiary version
* @NVME_VS_MNR_MASK: Mask to get the minor version
* @NVME_VS_MJR_MASK: Mask to get the major version
*/
enum nvme_vs {
NVME_VS_TER_SHIFT = 0,
NVME_VS_MNR_SHIFT = 8,
NVME_VS_MJR_SHIFT = 16,
NVME_VS_TER_MASK = 0xff,
NVME_VS_MNR_MASK = 0xff,
NVME_VS_MJR_MASK = 0xffff,
};
#define NVME_VS_TER(vs) NVME_GET(vs, VS_TER)
#define NVME_VS_MNR(vs) NVME_GET(vs, VS_MNR)
#define NVME_VS_MJR(vs) NVME_GET(vs, VS_MJR)
#define NVME_MAJOR(ver) NVME_VS_MJR(ver)
#define NVME_MINOR(ver) NVME_VS_MNR(ver)
#define NVME_TERTIARY(ver) NVME_VS_TER(ver)
/**
* enum nvme_cc - This field indicates the controller configuration
* @NVME_CC_EN_SHIFT: Shift amount to get the enable
* @NVME_CC_CSS_SHIFT: Shift amount to get the I/O command set selected
* @NVME_CC_MPS_SHIFT: Shift amount to get the memory page size
* @NVME_CC_AMS_SHIFT: Shift amount to get the arbitration mechanism selected
* @NVME_CC_SHN_SHIFT: Shift amount to get the shutdown notification
* @NVME_CC_IOSQES_SHIFT: Shift amount to get the I/O submission queue entry size
* @NVME_CC_IOCQES_SHIFT: Shift amount to get the I/O completion queue entry size
* @NVME_CC_CRIME_SHIFT: Shift amount to get the controller ready independent of media enable
* @NVME_CC_EN_MASK: Mask to get the enable
* @NVME_CC_CSS_MASK: Mask to get the I/O command set selected
* @NVME_CC_MPS_MASK: Mask to get the memory page size
* @NVME_CC_AMS_MASK: Mask to get the arbitration mechanism selected
* @NVME_CC_SHN_MASK: Mask to get the shutdown notification
* @NVME_CC_CRIME_MASK: Mask to get the I/O submission queue entry size
* @NVME_CC_IOSQES_MASK: Mask to get the I/O completion queue entry size
* @NVME_CC_IOCQES_MASK: Mask to get the controller ready independent of media enable
* @NVME_CC_CSS_NVM: NVM command set
* @NVME_CC_CSS_CSI: All supported I/O command sets
* @NVME_CC_CSS_ADMIN: Admin command set only
* @NVME_CC_AMS_RR: Round robin
* @NVME_CC_AMS_WRRU: Weighted round robin with urgent priority class
* @NVME_CC_AMS_VS: Vendor specific
* @NVME_CC_SHN_NONE: No notification; no effect
* @NVME_CC_SHN_NORMAL: Normal shutdown notification
* @NVME_CC_SHN_ABRUPT: Abrupt shutdown notification
* @NVME_CC_CRWME: Controller ready with media enable
* @NVME_CC_CRIME: Controller ready independent of media enable
*/
enum nvme_cc {
NVME_CC_EN_SHIFT = 0,
NVME_CC_CSS_SHIFT = 4,
NVME_CC_MPS_SHIFT = 7,
NVME_CC_AMS_SHIFT = 11,
NVME_CC_SHN_SHIFT = 14,
NVME_CC_IOSQES_SHIFT = 16,
NVME_CC_IOCQES_SHIFT = 20,
NVME_CC_CRIME_SHIFT = 24,
NVME_CC_EN_MASK = 0x1,
NVME_CC_CSS_MASK = 0x7,
NVME_CC_MPS_MASK = 0xf,
NVME_CC_AMS_MASK = 0x7,
NVME_CC_SHN_MASK = 0x3,
NVME_CC_CRIME_MASK = 0x1,
NVME_CC_IOSQES_MASK = 0xf,
NVME_CC_IOCQES_MASK = 0xf,
NVME_CC_CSS_NVM = 0,
NVME_CC_CSS_CSI = 6,
NVME_CC_CSS_ADMIN = 7,
NVME_CC_AMS_RR = 0,
NVME_CC_AMS_WRRU = 1,
NVME_CC_AMS_VS = 7,
NVME_CC_SHN_NONE = 0,
NVME_CC_SHN_NORMAL = 1,
NVME_CC_SHN_ABRUPT = 2,
NVME_CC_CRWME = 0,
NVME_CC_CRIME = 1,
};
#define NVME_CC_EN(cc) NVME_GET(cc, CC_EN)
#define NVME_CC_CSS(cc) NVME_GET(cc, CC_CSS)
#define NVME_CC_MPS(cc) NVME_GET(cc, CC_MPS)
#define NVME_CC_AMS(cc) NVME_GET(cc, CC_AMS)
#define NVME_CC_SHN(cc) NVME_GET(cc, CC_SHN)
#define NVME_CC_IOSQES(cc) NVME_GET(cc, CC_IOSQES)
#define NVME_CC_IOCQES(cc) NVME_GET(cc, CC_IOCQES)
#define NVME_CC_CRIME(cc) NVME_GET(cc, CC_CRIME)
/**
* enum nvme_csts - This field indicates the controller status register
* @NVME_CSTS_RDY_SHIFT: Shift amount to get the ready
* @NVME_CSTS_CFS_SHIFT: Shift amount to get the controller fatal status
* @NVME_CSTS_SHST_SHIFT: Shift amount to get the shutdown status
* @NVME_CSTS_NSSRO_SHIFT: Shift amount to get the NVM subsystem reset occurred
* @NVME_CSTS_PP_SHIFT: Shift amount to get the processing paused
* @NVME_CSTS_ST_SHIFT: Shift amount to get the shutdown type
* @NVME_CSTS_RDY_MASK: Mask to get the ready
* @NVME_CSTS_CFS_MASK: Mask to get the controller fatal status
* @NVME_CSTS_SHST_MASK: Mask to get the shutdown status
* @NVME_CSTS_NSSRO_MASK: Mask to get the NVM subsystem reset occurred
* @NVME_CSTS_PP_MASK: Mask to get the processing paused
* @NVME_CSTS_ST_MASK: Mask to get the shutdown type
* @NVME_CSTS_SHST_NORMAL: Normal operation
* @NVME_CSTS_SHST_OCCUR: Shutdown processing occurring
* @NVME_CSTS_SHST_CMPLT: Shutdown processing complete
* @NVME_CSTS_SHN_MASK: Deprecated mask to get the shutdown status
*/
enum nvme_csts {
NVME_CSTS_RDY_SHIFT = 0,
NVME_CSTS_CFS_SHIFT = 1,
NVME_CSTS_SHST_SHIFT = 2,
NVME_CSTS_NSSRO_SHIFT = 4,
NVME_CSTS_PP_SHIFT = 5,
NVME_CSTS_ST_SHIFT = 6,
NVME_CSTS_RDY_MASK = 0x1,
NVME_CSTS_CFS_MASK = 0x1,
NVME_CSTS_SHST_MASK = 0x3,
NVME_CSTS_NSSRO_MASK = 0x1,
NVME_CSTS_PP_MASK = 0x1,
NVME_CSTS_ST_MASK = 0x1,
NVME_CSTS_SHST_NORMAL = 0,
NVME_CSTS_SHST_OCCUR = 1,
NVME_CSTS_SHST_CMPLT = 2,
NVME_CSTS_SHN_MASK = NVME_CSTS_SHST_MASK, /* Deprecated */
};
#define NVME_CSTS_RDY(csts) NVME_GET(csts, CSTS_RDY)
#define NVME_CSTS_CFS(csts) NVME_GET(csts, CSTS_CFS)
#define NVME_CSTS_SHST(csts) NVME_GET(csts, CSTS_SHST)
#define NVME_CSTS_NSSRO(csts) NVME_GET(csts, CSTS_NSSRO)
#define NVME_CSTS_PP(csts) NVME_GET(csts, CSTS_PP)
#define NVME_CSTS_ST(csts) NVME_GET(csts, CSTS_ST)
/**
* enum nvme_aqa - This field indicates the admin queue attributes
* @NVME_AQA_ASQS_SHIFT: Shift amount to get the admin submission queue size
* @NVME_AQA_ACQS_SHIFT: Shift amount to get the admin completion queue size
* @NVME_AQA_ASQS_MASK: Mask to get the admin submission queue size
* @NVME_AQA_ACQS_MASK: Mask to get the admin completion queue size
*/
enum nvme_aqa {
NVME_AQA_ASQS_SHIFT = 0,
NVME_AQA_ACQS_SHIFT = 16,
NVME_AQA_ASQS_MASK = 0xfff,
NVME_AQA_ACQS_MASK = 0xfff,
};
#define NVME_AQA_ASQS(aqa) NVME_GET(aqa, AQA_ASQS)
#define NVME_AQA_ACQS(aqa) NVME_GET(aqa, AQA_ACQS)
/**
* enum nvme_asq - This field indicates the admin submission queue base address
* @NVME_ASQ_ASQB_SHIFT: Shift amount to get the admin submission queue base
*/
enum nvme_asq {
NVME_ASQ_ASQB_SHIFT = 12,
};
static const __u64 NVME_ASQ_ASQB_MASK = 0xfffffffffffffull;
#define NVME_ASQ_ASQB(asq) NVME_GET(asq, ASQ_ASQB)
/**
* enum nvme_acq - This field indicates the admin completion queue base address
* @NVME_ACQ_ACQB_SHIFT: Shift amount to get the admin completion queue base
*/
enum nvme_acq {
NVME_ACQ_ACQB_SHIFT = 12,
};
static const __u64 NVME_ACQ_ACQB_MASK = 0xfffffffffffffull;
#define NVME_ACQ_ACQB(acq) NVME_GET(acq, ACQ_ACQB)
/**
* enum nvme_cmbloc - This field indicates the controller memory buffer location
* @NVME_CMBLOC_BIR_SHIFT: Shift amount to get the base indicator register
* @NVME_CMBLOC_CQMMS_SHIFT: Shift amount to get the CMB queue mixed memory support
* @NVME_CMBLOC_CQPDS_SHIFT: Shift amount to get the CMB queue physically discontiguous support
* @NVME_CMBLOC_CDPLMS_SHIFT: Shift amount to get the CMB data pointer mixed locations support
* @NVME_CMBLOC_CDPCILS_SHIFT: Shift amount to get the CMB data pointer and command independent locations support
* @NVME_CMBLOC_CDMMMS_SHIFT: Shift amount to get the CMB data metadata mixed memory support
* @NVME_CMBLOC_CQDA_SHIFT: Shift amount to get the CMB queue dword alignment
* @NVME_CMBLOC_OFST_SHIFT: Shift amount to get the offset
* @NVME_CMBLOC_BIR_MASK: Mask to get the base indicator register
* @NVME_CMBLOC_CQMMS_MASK: Mask to get the CMB queue mixed memory support
* @NVME_CMBLOC_CQPDS_MASK: Mask to get the CMB queue physically discontiguous support
* @NVME_CMBLOC_CDPLMS_MASK: Mask to get the CMB data pointer mixed locations support
* @NVME_CMBLOC_CDPCILS_MASK: Mask to get the CMB data pointer and command independent locations support
* @NVME_CMBLOC_CDMMMS_MASK: Mask to get the CMB data metadata mixed memory support
* @NVME_CMBLOC_CQDA_MASK: Mask to get the CMB queue dword alignment
* @NVME_CMBLOC_OFST_MASK: Mask to get the offset
*/
enum nvme_cmbloc {
NVME_CMBLOC_BIR_SHIFT = 0,
NVME_CMBLOC_CQMMS_SHIFT = 3,
NVME_CMBLOC_CQPDS_SHIFT = 4,
NVME_CMBLOC_CDPLMS_SHIFT = 5,
NVME_CMBLOC_CDPCILS_SHIFT = 6,
NVME_CMBLOC_CDMMMS_SHIFT = 7,
NVME_CMBLOC_CQDA_SHIFT = 8,
NVME_CMBLOC_OFST_SHIFT = 12,
NVME_CMBLOC_BIR_MASK = 0x7,
NVME_CMBLOC_CQMMS_MASK = 0x1,
NVME_CMBLOC_CQPDS_MASK = 0x1,
NVME_CMBLOC_CDPLMS_MASK = 0x1,
NVME_CMBLOC_CDPCILS_MASK = 0x1,
NVME_CMBLOC_CDMMMS_MASK = 0x1,
NVME_CMBLOC_CQDA_MASK = 0x1,
NVME_CMBLOC_OFST_MASK = 0xfffff,
};
#define NVME_CMBLOC_BIR(cmbloc) NVME_GET(cmbloc, CMBLOC_BIR)
#define NVME_CMBLOC_CQMMS(cmbloc) NVME_GET(cmbloc, CMBLOC_CQMMS)
#define NVME_CMBLOC_CQPDS(cmbloc) NVME_GET(cmbloc, CMBLOC_CQPDS)
#define NVME_CMBLOC_CDPLMS(cmbloc) NVME_GET(cmbloc, CMBLOC_CDPLMS)
#define NVME_CMBLOC_CDPCILS(cmbloc) NVME_GET(cmbloc, CMBLOC_CDPCILS)
#define NVME_CMBLOC_CDMMMS(cmbloc) NVME_GET(cmbloc, CMBLOC_CDMMMS)
#define NVME_CMBLOC_CQDA(cmbloc) NVME_GET(cmbloc, CMBLOC_CQDA)
#define NVME_CMBLOC_OFST(cmbloc) NVME_GET(cmbloc, CMBLOC_OFST)
/**
* enum nvme_cmbsz - This field indicates the controller memory buffer size
* @NVME_CMBSZ_SQS_SHIFT: Shift amount to get the submission queue support
* @NVME_CMBSZ_CQS_SHIFT: Shift amount to get the completion queue support
* @NVME_CMBSZ_LISTS_SHIFT: Shift amount to get the PLP SGL list support
* @NVME_CMBSZ_RDS_SHIFT: Shift amount to get the read data support
* @NVME_CMBSZ_WDS_SHIFT: Shift amount to get the write data support
* @NVME_CMBSZ_SZU_SHIFT: Shift amount to get the size units
* @NVME_CMBSZ_SZ_SHIFT: Shift amount to get the size
* @NVME_CMBSZ_SQS_MASK: Mask to get the submission queue support
* @NVME_CMBSZ_CQS_MASK: Mask to get the completion queue support
* @NVME_CMBSZ_LISTS_MASK: Mask to get the PLP SGL list support
* @NVME_CMBSZ_RDS_MASK: Mask to get the read data support
* @NVME_CMBSZ_WDS_MASK: Mask to get the write data support
* @NVME_CMBSZ_SZU_MASK: Mask to get the size units
* @NVME_CMBSZ_SZ_MASK: Mask to get the size
* @NVME_CMBSZ_SZU_4K: 4 KiB
* @NVME_CMBSZ_SZU_64K: 64 KiB
* @NVME_CMBSZ_SZU_1M: 1 MiB
* @NVME_CMBSZ_SZU_16M: 16 MiB
* @NVME_CMBSZ_SZU_256M: 256 MiB
* @NVME_CMBSZ_SZU_4G: 4 GiB
* @NVME_CMBSZ_SZU_64G: 64 GiB
*/
enum nvme_cmbsz {
NVME_CMBSZ_SQS_SHIFT = 0,
NVME_CMBSZ_CQS_SHIFT = 1,
NVME_CMBSZ_LISTS_SHIFT = 2,
NVME_CMBSZ_RDS_SHIFT = 3,
NVME_CMBSZ_WDS_SHIFT = 4,
NVME_CMBSZ_SZU_SHIFT = 8,
NVME_CMBSZ_SZ_SHIFT = 12,
NVME_CMBSZ_SQS_MASK = 0x1,
NVME_CMBSZ_CQS_MASK = 0x1,
NVME_CMBSZ_LISTS_MASK = 0x1,
NVME_CMBSZ_RDS_MASK = 0x1,
NVME_CMBSZ_WDS_MASK = 0x1,
NVME_CMBSZ_SZU_MASK = 0xf,
NVME_CMBSZ_SZ_MASK = 0xfffff,
NVME_CMBSZ_SZU_4K = 0,
NVME_CMBSZ_SZU_64K = 1,
NVME_CMBSZ_SZU_1M = 2,
NVME_CMBSZ_SZU_16M = 3,
NVME_CMBSZ_SZU_256M = 4,
NVME_CMBSZ_SZU_4G = 5,
NVME_CMBSZ_SZU_64G = 6,
};
#define NVME_CMBSZ_SQS(cmbsz) NVME_GET(cmbsz, CMBSZ_SQS)
#define NVME_CMBSZ_CQS(cmbsz) NVME_GET(cmbsz, CMBSZ_CQS)
#define NVME_CMBSZ_LISTS(cmbsz) NVME_GET(cmbsz, CMBSZ_LISTS)
#define NVME_CMBSZ_RDS(cmbsz) NVME_GET(cmbsz, CMBSZ_RDS)
#define NVME_CMBSZ_WDS(cmbsz) NVME_GET(cmbsz, CMBSZ_WDS)
#define NVME_CMBSZ_SZU(cmbsz) NVME_GET(cmbsz, CMBSZ_SZU)
#define NVME_CMBSZ_SZ(cmbsz) NVME_GET(cmbsz, CMBSZ_SZ)
/**
* nvme_cmb_size() - Calculate size of the controller memory buffer
* @cmbsz: Value from controller register %NVME_REG_CMBSZ
*
* Returns: size of controller memory buffer in bytes
*/
static inline __u64 nvme_cmb_size(__u32 cmbsz)
{
return ((__u64)NVME_CMBSZ_SZ(cmbsz)) *
(1ULL << (12 + 4 * NVME_CMBSZ_SZU(cmbsz)));
}
/**
* enum nvme_bpinfo - This field indicates the boot partition information
* @NVME_BPINFO_BPSZ_SHIFT: Shift amount to get the boot partition size
* @NVME_BPINFO_BRS_SHIFT: Shift amount to get the boot read status
* @NVME_BPINFO_ABPID_SHIFT: Shift amount to get the active boot partition ID
* @NVME_BPINFO_BPSZ_MASK: Mask to get the boot partition size
* @NVME_BPINFO_BRS_MASK: Mask to get the boot read status
* @NVME_BPINFO_ABPID_MASK: Mask to get the active boot partition ID
* @NVME_BPINFO_BRS_NONE: No boot partition read operation requested
* @NVME_BPINFO_BRS_READ_IN_PROGRESS: Boot partition read in progress
* @NVME_BPINFO_BRS_READ_SUCCESS: Boot partition read completed successfully
* @NVME_BPINFO_BRS_READ_ERROR: Error completing boot partition read
*/
enum nvme_bpinfo {
NVME_BPINFO_BPSZ_SHIFT = 0,
NVME_BPINFO_BRS_SHIFT = 24,
NVME_BPINFO_ABPID_SHIFT = 31,
NVME_BPINFO_BPSZ_MASK = 0x7fff,
NVME_BPINFO_BRS_MASK = 0x3,
NVME_BPINFO_ABPID_MASK = 0x1,
NVME_BPINFO_BRS_NONE = 0,
NVME_BPINFO_BRS_READ_IN_PROGRESS = 1,
NVME_BPINFO_BRS_READ_SUCCESS = 2,
NVME_BPINFO_BRS_READ_ERROR = 3,
};
#define NVME_BPINFO_BPSZ(bpinfo) NVME_GET(bpinfo, BPINFO_BPSZ)
#define NVME_BPINFO_BRS(bpinfo) NVME_GET(bpinfo, BPINFO_BRS)
#define NVME_BPINFO_ABPID(bpinfo) NVME_GET(bpinfo, BPINFO_ABPID)
/**
* enum nvme_bprsel - This field indicates the boot partition read select
* @NVME_BPRSEL_BPRSZ_SHIFT: Shift amount to get the boot partition read size
* @NVME_BPRSEL_BPROF_SHIFT: Shift amount to get the boot partition read offset
* @NVME_BPRSEL_BPID_SHIFT: Shift amount to get the boot partition identifier
* @NVME_BPRSEL_BPRSZ_MASK: Mask to get the boot partition read size
* @NVME_BPRSEL_BPROF_MASK: Mask to get the boot partition read offset
* @NVME_BPRSEL_BPID_MASK: Mask to get the boot partition identifier
*/
enum nvme_bprsel {
NVME_BPRSEL_BPRSZ_SHIFT = 0,
NVME_BPRSEL_BPROF_SHIFT = 10,
NVME_BPRSEL_BPID_SHIFT = 31,
NVME_BPRSEL_BPRSZ_MASK = 0x3ff,
NVME_BPRSEL_BPROF_MASK = 0xfffff,
NVME_BPRSEL_BPID_MASK = 0x1,
};
#define NVME_BPRSEL_BPRSZ(bprsel) NVME_GET(bprsel, BPRSEL_BPRSZ)
#define NVME_BPRSEL_BPROF(bprsel) NVME_GET(bprsel, BPRSEL_BPROF)
#define NVME_BPRSEL_BPID(bprsel) NVME_GET(bprsel, BPRSEL_BPID)
/**
* enum nvme_bpmbl - This field indicates the boot partition memory buffer location
* @NVME_BPMBL_BMBBA_SHIFT: Shift amount to get the boot partition memory buffer base address
*/
enum nvme_bpmbl {
NVME_BPMBL_BMBBA_SHIFT = 12,
};
static const __u64 NVME_BPMBL_BMBBA_MASK = 0xfffffffffffffull;
#define NVME_BPMBL_BMBBA(bpmbl) NVME_GET(bpmbl, BPMBL_BMBBA)
/**
* enum nvme_cmbmsc - This field indicates the controller memory buffer memory space control
* @NVME_CMBMSC_CRE_SHIFT: Shift amount to get the capabilities registers enabled
* @NVME_CMBMSC_CMSE_SHIFT: Shift amount to get the controller memory space enable
* @NVME_CMBMSC_CBA_SHIFT: Shift amount to get the controller base address
* @NVME_CMBMSC_CRE_MASK: Mask to get the capabilities registers enabled
* @NVME_CMBMSC_CMSE_MASK: Mask to get the controller memory space enable
*/
enum nvme_cmbmsc {
NVME_CMBMSC_CRE_SHIFT = 0,
NVME_CMBMSC_CMSE_SHIFT = 1,
NVME_CMBMSC_CBA_SHIFT = 12,
NVME_CMBMSC_CRE_MASK = 0x1,
NVME_CMBMSC_CMSE_MASK = 0x1,
};
static const __u64 NVME_CMBMSC_CBA_MASK = 0xfffffffffffffull;
#define NVME_CMBMSC_CRE(cmbmsc) NVME_GET(cmbmsc, CMBMSC_CRE)
#define NVME_CMBMSC_CMSE(cmbmsc) NVME_GET(cmbmsc, CMBMSC_CMSE)
#define NVME_CMBMSC_CBA(cmbmsc) NVME_GET(cmbmsc, CMBMSC_CBA)
/**
* enum nvme_cmbsts - This field indicates the controller memory buffer status
* @NVME_CMBSTS_CBAI_SHIFT: Shift amount to get the controller base address invalid
* @NVME_CMBSTS_CBAI_MASK: Mask to get the controller base address invalid
*/
enum nvme_cmbsts {
NVME_CMBSTS_CBAI_SHIFT = 0,
NVME_CMBSTS_CBAI_MASK = 0x1,
};
#define NVME_CMBSTS_CBAI(cmbsts) NVME_GET(cmbsts, CMBSTS_CBAI)
/**
* enum nvme_unit - Defined buffer size and write throughput granularity units
* @NVME_UNIT_B: Bytes or Bytes/second
* @NVME_UNIT_1K: 1 KiB or 1 KiB/second
* @NVME_UNIT_1M: 1 MiB or 1 MiB/second
* @NVME_UNIT_1G: 1 GiB or 1 GiB/second
*/
enum nvme_unit {
NVME_UNIT_B = 0,
NVME_UNIT_1K = 1,
NVME_UNIT_1M = 2,
NVME_UNIT_1G = 3,
};
/**
* enum nvme_cmbebs - This field indicates the controller memory buffer elasticity buffer size
* @NVME_CMBEBS_CMBSZU_SHIFT: Shift amount to get the CMB elasticity buffer size units
* @NVME_CMBEBS_RBB_SHIFT: Shift amount to get the read bypass behavior
* @NVME_CMBEBS_CMBWBZ_SHIFT: Shift amount to get the CMB elasiticity buffer size base
* @NVME_CMBEBS_CMBSZU_MASK: Mask to get the CMB elasticity buffer size units
* @NVME_CMBEBS_RBB_MASK: Mask to get the read bypass behavior
* @NVME_CMBEBS_CMBWBZ_MASK: Mask to get the CMB elasiticity buffer size base
* @NVME_CMBEBS_CMBSZU_B: Bytes granularity
* @NVME_CMBEBS_CMBSZU_1K: 1 KiB granularity
* @NVME_CMBEBS_CMBSZU_1M: 1 MiB granularity
* @NVME_CMBEBS_CMBSZU_1G: 1 GiB granularity
*/
enum nvme_cmbebs {
NVME_CMBEBS_CMBSZU_SHIFT = 0,
NVME_CMBEBS_RBB_SHIFT = 4,
NVME_CMBEBS_CMBWBZ_SHIFT = 8,
NVME_CMBEBS_CMBSZU_MASK = 0xf,
NVME_CMBEBS_RBB_MASK = 0x1,
NVME_CMBEBS_CMBWBZ_MASK = 0xffffff,
NVME_CMBEBS_CMBSZU_B = NVME_UNIT_B,
NVME_CMBEBS_CMBSZU_1K = NVME_UNIT_1K,
NVME_CMBEBS_CMBSZU_1M = NVME_UNIT_1M,
NVME_CMBEBS_CMBSZU_1G = NVME_UNIT_1G,
};
#define NVME_CMBEBS_CMBSZU(cmbebs) NVME_GET(cmbebs, CMBEBS_CMBSZU)
#define NVME_CMBEBS_RBB(cmbebs) NVME_GET(cmbebs, CMBEBS_RBB)
#define NVME_CMBEBS_CMBWBZ(cmbebs) NVME_GET(cmbebs, CMBEBS_CMBWBZ)
/**
* enum nvme_cmbswtp - This field indicates the controller memory buffer sustained write throughput
* @NVME_CMBSWTP_CMBSWTU_SHIFT: Shift amount to get the CMB sustained write throughput units
* @NVME_CMBSWTP_CMBSWTV_SHIFT: Shift amount to get the CMB sustained write throughput
* @NVME_CMBSWTP_CMBSWTU_MASK: Mask to get the CMB sustained write throughput units
* @NVME_CMBSWTP_CMBSWTV_MASK: Mask to get the CMB sustained write throughput
* @NVME_CMBSWTP_CMBSWTU_B: Bytes/second granularity
* @NVME_CMBSWTP_CMBSWTU_1K: 1 KiB/second granularity
* @NVME_CMBSWTP_CMBSWTU_1M: 1 MiB/second granularity
* @NVME_CMBSWTP_CMBSWTU_1G: 1 GiB/second granularity
*/
enum nvme_cmbswtp {
NVME_CMBSWTP_CMBSWTU_SHIFT = 0,
NVME_CMBSWTP_CMBSWTV_SHIFT = 8,
NVME_CMBSWTP_CMBSWTU_MASK = 0xf,
NVME_CMBSWTP_CMBSWTV_MASK = 0xffffff,
NVME_CMBSWTP_CMBSWTU_B = NVME_UNIT_B,
NVME_CMBSWTP_CMBSWTU_1K = NVME_UNIT_1K,
NVME_CMBSWTP_CMBSWTU_1M = NVME_UNIT_1M,
NVME_CMBSWTP_CMBSWTU_1G = NVME_UNIT_1G,
};
#define NVME_CMBSWTP_CMBSWTU(cmbswtp) NVME_GET(cmbswtp, CMBSWTP_CMBSWTU)
#define NVME_CMBSWTP_CMBSWTV(cmbswtp) NVME_GET(cmbswtp, CMBSWTP_CMBSWTV)
/**
* enum nvme_crto - This field indicates the controller ready timeouts
* @NVME_CRTO_CRWMT_SHIFT: Shift amount to get the controller ready with media timeout
* @NVME_CRTO_CRIMT_SHIFT: Shift amount to get the controller ready independent of media timeout
* @NVME_CRTO_CRWMT_MASK: Mask to get the controller ready with media timeout
* @NVME_CRTO_CRIMT_MASK: Mask to get the controller ready independent of media timeout
*/
enum nvme_crto {
NVME_CRTO_CRWMT_SHIFT = 0,
NVME_CRTO_CRIMT_SHIFT = 16,
NVME_CRTO_CRWMT_MASK = 0xffff,
NVME_CRTO_CRIMT_MASK = 0xffff,
};
#define NVME_CRTO_CRIMT(crto) NVME_GET(crto, CRTO_CRIMT)
#define NVME_CRTO_CRWMT(crto) NVME_GET(crto, CRTO_CRWMT)
/**
* enum nvme_pmrcap - This field indicates the persistent memory region capabilities
* @NVME_PMRCAP_RDS_SHIFT: Shift amount to get the read data support
* @NVME_PMRCAP_WDS_SHIFT: Shift amount to get the write data support
* @NVME_PMRCAP_BIR_SHIFT: Shift amount to get the base indicator register
* @NVME_PMRCAP_PMRTU_SHIFT: Shift amount to get the persistent memory region time units
* @NVME_PMRCAP_PMRWBM_SHIFT: Shift amount to get the persistent memory region write barrier mechanisms
* @NVME_PMRCAP_PMRTO_SHIFT: Shift amount to get the persistent memory region timeout
* @NVME_PMRCAP_CMSS_SHIFT: Shift amount to get the controller memory space supported
* @NVME_PMRCAP_PMRWMB_SHIFT: Deprecated shift amount to get the persistent memory region write barrier mechanisms
* @NVME_PMRCAP_RDS_MASK: Mask to get the read data support
* @NVME_PMRCAP_WDS_MASK: Mask to get the write data support
* @NVME_PMRCAP_BIR_MASK: Mask to get the base indicator register
* @NVME_PMRCAP_PMRTU_MASK: Mask to get the persistent memory region time units
* @NVME_PMRCAP_PMRWBM_MASK: Mask to get the persistent memory region write barrier mechanisms
* @NVME_PMRCAP_PMRTO_MASK: Mask to get the persistent memory region timeout
* @NVME_PMRCAP_CMSS_MASK: Mask to get the controller memory space supported
* @NVME_PMRCAP_PMRWMB_MASK: Deprecated mask to get the persistent memory region write barrier mechanisms
* @NVME_PMRCAP_PMRTU_500MS: 500 milliseconds
* @NVME_PMRCAP_PMRTU_60S: minutes
*/
enum nvme_pmrcap {
NVME_PMRCAP_RDS_SHIFT = 3,
NVME_PMRCAP_WDS_SHIFT = 4,
NVME_PMRCAP_BIR_SHIFT = 5,
NVME_PMRCAP_PMRTU_SHIFT = 8,
NVME_PMRCAP_PMRWBM_SHIFT = 10,
NVME_PMRCAP_PMRTO_SHIFT = 16,
NVME_PMRCAP_CMSS_SHIFT = 24,
NVME_PMRCAP_PMRWMB_SHIFT = NVME_PMRCAP_PMRWBM_SHIFT, /* Deprecated */
NVME_PMRCAP_RDS_MASK = 0x1,
NVME_PMRCAP_WDS_MASK = 0x1,
NVME_PMRCAP_BIR_MASK = 0x7,
NVME_PMRCAP_PMRTU_MASK = 0x3,
NVME_PMRCAP_PMRWBM_MASK = 0xf,
NVME_PMRCAP_PMRTO_MASK = 0xff,
NVME_PMRCAP_CMSS_MASK = 0x1,
NVME_PMRCAP_PMRWMB_MASK = NVME_PMRCAP_PMRWBM_MASK, /* Deprecated */
NVME_PMRCAP_PMRTU_500MS = 0,
NVME_PMRCAP_PMRTU_60S = 1,
};
#define NVME_PMRCAP_RDS(pmrcap) NVME_GET(pmrcap, PMRCAP_RDS)
#define NVME_PMRCAP_WDS(pmrcap) NVME_GET(pmrcap, PMRCAP_WDS)
#define NVME_PMRCAP_BIR(pmrcap) NVME_GET(pmrcap, PMRCAP_BIR)
#define NVME_PMRCAP_PMRTU(pmrcap) NVME_GET(pmrcap, PMRCAP_PMRTU)
#define NVME_PMRCAP_PMRWBM(pmrcap) NVME_GET(pmrcap, PMRCAP_PMRWBM)
#define NVME_PMRCAP_PMRTO(pmrcap) NVME_GET(pmrcap, PMRCAP_PMRTO)
#define NVME_PMRCAP_CMSS(pmrcap) NVME_GET(pmrcap, PMRCAP_CMSS)
#define NVME_PMRCAP_PMRWMB(pmrcap) NVME_GET(pmrcap, PMRCAP_PMRWMB) /* Deprecated */
/**
* enum nvme_pmrctl - This field indicates the persistent memory region control
* @NVME_PMRCTL_EN_SHIFT: Shift amount to get the enable
* @NVME_PMRCTL_EN_MASK: Mask to get the enable
*/
enum nvme_pmrctl {
NVME_PMRCTL_EN_SHIFT = 0,
NVME_PMRCTL_EN_MASK = 0x1,
};
#define NVME_PMRCTL_EN(pmrctl) NVME_GET(pmrctl, PMRCTL_EN)
/**
* enum nvme_pmrsts - This field indicates the persistent memory region status
* @NVME_PMRSTS_ERR_SHIFT: Shift amount to get the error
* @NVME_PMRSTS_NRDY_SHIFT: Shift amount to get the not ready
* @NVME_PMRSTS_HSTS_SHIFT: Shift amount to get the health status
* @NVME_PMRSTS_CBAI_SHIFT: Shift amount to get the controller base address invalid
* @NVME_PMRSTS_ERR_MASK: Mask to get the error
* @NVME_PMRSTS_NRDY_MASK: Mask to get the not ready
* @NVME_PMRSTS_HSTS_MASK: Mask to get the health status
* @NVME_PMRSTS_CBAI_MASK: Mask to get the controller base address invalid
*/
enum nvme_pmrsts {
NVME_PMRSTS_ERR_SHIFT = 0,
NVME_PMRSTS_NRDY_SHIFT = 8,
NVME_PMRSTS_HSTS_SHIFT = 9,
NVME_PMRSTS_CBAI_SHIFT = 12,
NVME_PMRSTS_ERR_MASK = 0xff,
NVME_PMRSTS_NRDY_MASK = 0x1,
NVME_PMRSTS_HSTS_MASK = 0x7,
NVME_PMRSTS_CBAI_MASK = 0x1,
};
#define NVME_PMRSTS_ERR(pmrsts) NVME_GET(pmrsts, PMRSTS_ERR)
#define NVME_PMRSTS_NRDY(pmrsts) NVME_GET(pmrsts, PMRSTS_NRDY)
#define NVME_PMRSTS_HSTS(pmrsts) NVME_GET(pmrsts, PMRSTS_HSTS)
#define NVME_PMRSTS_CBAI(pmrsts) NVME_GET(pmrsts, PMRSTS_CBAI)
/**
* enum nvme_pmrebs - This field indicates the persistent memory region elasticity buffer size
* @NVME_PMREBS_PMRSZU_SHIFT: Shift amount to get the PMR elasticity buffer size units
* @NVME_PMREBS_RBB_SHIFT: Shift amount to get the read bypass behavior
* @NVME_PMREBS_PMRWBZ_SHIFT: Shift amount to get the PMR elasticity buffer size base
* @NVME_PMREBS_PMRSZU_MASK: Mask to get the PMR elasticity buffer size units
* @NVME_PMREBS_RBB_MASK: Mask to get the read bypass behavior
* @NVME_PMREBS_PMRWBZ_MASK: Mask to get the PMR elasticity buffer size base
* @NVME_PMREBS_PMRSZU_B: Bytes
* @NVME_PMREBS_PMRSZU_1K: 1 KiB
* @NVME_PMREBS_PMRSZU_1M: 1 MiB
* @NVME_PMREBS_PMRSZU_1G: 1 GiB
*/
enum nvme_pmrebs {
NVME_PMREBS_PMRSZU_SHIFT = 0,
NVME_PMREBS_RBB_SHIFT = 4,
NVME_PMREBS_PMRWBZ_SHIFT = 8,
NVME_PMREBS_PMRSZU_MASK = 0xf,
NVME_PMREBS_RBB_MASK = 0x1,
NVME_PMREBS_PMRWBZ_MASK = 0xffffff,
NVME_PMREBS_PMRSZU_B = NVME_UNIT_B,
NVME_PMREBS_PMRSZU_1K = NVME_UNIT_1K,
NVME_PMREBS_PMRSZU_1M = NVME_UNIT_1M,
NVME_PMREBS_PMRSZU_1G = NVME_UNIT_1G,
};
#define NVME_PMREBS_PMRSZU(pmrebs) NVME_GET(pmrebs, PMREBS_PMRSZU)
#define NVME_PMREBS_RBB(pmrebs) NVME_GET(pmrebs, PMREBS_RBB)
#define NVME_PMREBS_PMRWBZ(pmrebs) NVME_GET(pmrebs, PMREBS_PMRWBZ)
/**
* nvme_pmr_size() - Calculate size of persistent memory region elasticity
* buffer
* @pmrebs: Value from controller register %NVME_REG_PMREBS
*
* Returns: size of controller persistent memory buffer in bytes
*/
static inline __u64 nvme_pmr_size(__u32 pmrebs)
{
return ((__u64)NVME_PMREBS_PMRWBZ(pmrebs)) *
(1ULL << (10 * NVME_PMREBS_PMRSZU(pmrebs)));
}
/**
* enum nvme_pmrswtp - This field indicates the persistent memory region sustained write throughput
* @NVME_PMRSWTP_PMRSWTU_SHIFT: Shift amount to get the PMR sustained write throughput units
* @NVME_PMRSWTP_PMRSWTV_SHIFT: Shift amount to get the PMR sustained write throughput
* @NVME_PMRSWTP_PMRSWTU_MASK: Mask to get the PMR sustained write throughput units
* @NVME_PMRSWTP_PMRSWTV_MASK: Mask to get the PMR sustained write throughput
* @NVME_PMRSWTP_PMRSWTU_BPS: Bytes per second
* @NVME_PMRSWTP_PMRSWTU_KBPS: 1 KiB / s
* @NVME_PMRSWTP_PMRSWTU_MBPS: 1 MiB / s
* @NVME_PMRSWTP_PMRSWTU_GBPS: 1 GiB / s
*/
enum nvme_pmrswtp {
NVME_PMRSWTP_PMRSWTU_SHIFT = 0,
NVME_PMRSWTP_PMRSWTV_SHIFT = 8,
NVME_PMRSWTP_PMRSWTU_MASK = 0xf,
NVME_PMRSWTP_PMRSWTV_MASK = 0xffffff,
NVME_PMRSWTP_PMRSWTU_BPS = NVME_UNIT_B,
NVME_PMRSWTP_PMRSWTU_KBPS = NVME_UNIT_1K,
NVME_PMRSWTP_PMRSWTU_MBPS = NVME_UNIT_1M,
NVME_PMRSWTP_PMRSWTU_GBPS = NVME_UNIT_1G,
};
#define NVME_PMRSWTP_PMRSWTU(pmrswtp) NVME_GET(pmrswtp, PMRSWTP_PMRSWTU)
#define NVME_PMRSWTP_PMRSWTV(pmrswtp) NVME_GET(pmrswtp, PMRSWTP_PMRSWTU)
/**
* nvme_pmr_throughput() - Calculate throughput of persistent memory buffer
* @pmrswtp: Value from controller register %NVME_REG_PMRSWTP
*
* Returns: throughput of controller persistent memory buffer in bytes/second
*/
static inline __u64 nvme_pmr_throughput(__u32 pmrswtp)
{