-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSEFAPI.h
More file actions
2304 lines (2168 loc) · 112 KB
/
SEFAPI.h
File metadata and controls
2304 lines (2168 loc) · 112 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
/*
* SOFTWARE-ENABLED FLASH (“SEF”)
* Application Programming Interface (API)
* SEFAPI.h
*
* Copyright (C) 2018, 2019, 2020, 2021, 2022, 2023 - KIOXIA Corporation. All rights reserved.
*
* This software is licensed under the 3-Clause BSD License.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file SEF Library API
*
* Functions and structures for configuring and using SEF units
*
* @version 1.14i
* @date October 2023
* @copyright Copyright (C) 2018, 2019, 2020, 2021, 2022, 2023 - KIOXIA Corporation. All rights reserved.
*
* @defgroup ApiManCmd API Management Commands
* @defgroup ApiDataCmd Data Access Commands
* @defgroup CommonStructs Common Structures
* @defgroup CallbackStructs Callback Structures
* @defgroup EventsStructs Events
* @defgroup Enums Enumerated Types
*/
#ifndef SEFAPI_h
#define SEFAPI_h
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#if !defined(__APPLE__) && !defined(_MSC_VER)
#include <endian.h>
#endif
#if defined(_MSC_VER)
#define PACKED
#define le64toh(U) (U)
#define htole64(U) (U)
#pragma warning(disable : 4200) /* zero-sized array */
#pragma warning(disable : 4201) /* nameless struct/union */
#define NONNULL()
#else
#define PACKED __attribute__((packed))
#define NONNULL(args...) __attribute__((nonnull (args)))
#include <sys/uio.h>
#endif
#pragma pack(push,8)
#define SEFAPIVersion 0x010e
#define SEFMaxRootPointer 8
#define SEFMaxReadQueues 8
/**
* @ingroup Enums
*/
enum SEFDefectManagementMethod {
kPacked, /**< Offset address in a super block is consecutive. Size of super block is reduced with defected
block(s). This results in slower reads due to the extra level of indirection incurred. */
kFragmented, /**< Defective blocks are left in place, and are simply marked as non-addressable. Over time, this
can result in a device with a gradually decreasing usable size. This scheme has the fastest
read performance, but comes at the cost of additional management complexity that the host will
be responsible for. */
kPerfect /**< Offset address is consecutive. Size of super block is fixed. Number of super blocks is reduced
with defected block(s). This has the slowest read performance because this remapping has the
potential to cross block boundaries */
} PACKED;
/**
* @ingroup Enums
*/
enum SEFAPIIdentifier {
kSuperBlock, /**< Currently the only mode supported by the API */
kInDriveGC, /**< Reserved for future use */
kVirtualSSD /**< Reserved for future use */
} PACKED;
/**
* @ingroup Enums
*/
enum SEFErrorRecoveryMode {
kAutomatic, /**< Automatic recovery mode */
kHostControlled /**< Host is responsible for recovery */
} PACKED;
/**
* @ingroup Enums
*/
enum SEFDeadlineType {
kFastest, /**< Does not attempt a corrective action, but instead sends a notification
to allow higher layer to read from a separate redundant store. */
kTypical, /**< Attempts to perform basic error recovery in the event of a read error condition */
kLong, /**< Attempts to perform more advanced error recovery in the event of a read error condition */
kHeroic /**< Attempts to perform full recovery in the event of a read error condition */
} PACKED;
/* definition of bits in supported options field of SEFInfo struct below... */
#define kFragmentedSupported (1 << 0) /**< Fragmented defect management type supported */
#define kPackedSupported (1 << 1) /**< Packed defect management type supported */
#define kPerfectSupported (1 << 2) /**< Perfect defect management type supported */
#define kMixedDefectManagementSupported (1 << 3) /**< Mixed defect management types supported */
#define kHostSerialNumberSupported (1 << 4)
#define kCopyUserAddressRangeSupported (1 << 5) /**< User address ranges supported for nameless copy */
#define kCopyFlashAddressListSupported (1 << 6) /**< Flash address lists supported for nameless copy */
#define kSuperBlockSupported (1 << 7) /**< SEFAPIIdentifier kSuperBlock is supported */
#define kInDriveGCSupported (1 << 8) /**< SEFAPIIdentifier kInDriveGC is supported */
#define kVirtualSSDSupported (1 << 9) /**< SEFAPIIdentifier kVirtualSSD is supported */
#define kAutomaticSupported (1 << 10)/**< SEFErrorRecoveryMode kAutomatic is supported */
#define kHostControlledSupported (1 << 11)/**< SEFErrorRecoveryMode kHostControlled is supported */
#define kStableLatencySupported (1 << 12)
#define kStopSupported (1 << 13)
#define kPSLCSupported (1 << 14)/**< pSLC supported */
#define kFastestSupported (1 << 15)/**< SEFDeadlineType kFastest is supported */
#define kTypicalSupported (1 << 16)/**< SEFDeadlineType kTypical is supported */
#define kLongSupported (1 << 17)/**< SEFDeadlineType kLong is supported */
#define kHeroicSupported (1 << 18)/**< SEFDeadlineType kHeroic is supported */
#define kIdleTimeSupported (1 << 19)
#define kEncryptionSupported (1 << 20)/**< Encryption supported */
#define kDeleteVirtualDeviceSupported (1 << 21)/**< Deleting virtual devices supported */
/**
* @ingroup CommonStructs
*/
struct SEFStatus {
int32_t error; /**< Status information */
int32_t info; /**< Additional context-based descriptive information */
};
typedef struct SEFHandle_ *SEFHandle;
typedef struct SEFVDHandle_ *SEFVDHandle;
typedef struct SEFQoSHandle_ *SEFQoSHandle;
/**
* @ingroup CommonStructs
*/
struct SEFVirtualDeviceID {
uint16_t id;
};
/**
* @ingroup CommonStructs
*/
struct SEFQoSDomainID {
uint16_t id;
};
/**
* @ingroup CommonStructs
*/
struct SEFPlacementID {
uint16_t id;
};
/**
* @ingroup ApiManCmd
* @brief Initializes the SEF Library, enumerates the SEF Units present,
* and returns the number of units found.
*
* Every successful call to SEFLibraryInit() must be balanced with a call to
* SEFLibraryCleanup().
*
* @see SEFLibraryCleanup()
*
* @return Status and info summarizing result.
*
* @retval 0 The info member returns the number of units
*/
struct SEFStatus SEFLibraryInit(void);
/**
* @ingroup ApiManCmd
* @brief Returns a handle to the SEF Unit at the specified index (zero based)
*
* @param index Index of the SEF Unit
*
* @return Handle to the SEF Unit
*/
SEFHandle SEFGetHandle(uint16_t index);
/**
* @ingroup ApiManCmd
* @brief Performs cleanup of the SEF Library and releases resources.
*
* Every successful call to SEFLibraryInit() must be balanced with a call to
* SEFLibraryCleanup().
*
* @note When the returned status error and info fields are zero, all
* open handles are closed, invalidated and are unusable.
*
* @see SEFLibraryInit()
*
* @return Status and info summarizing result.
*
* @retval 0 The info field is the library's reference count.
* @retval -ENODEV The SEF Library was not initialized
* @retval -EWOULDBLOCK This function cannot be called on a callback thread
*/
struct SEFStatus SEFLibraryCleanup(void);
/**
* @ingroup CommonStructs
*
*/
struct SEFADUsize {
uint32_t data; /**< ADU data size in bytes */
uint16_t meta; /**< ADU meta data size in bytes */
uint16_t reserved; /**< Reserved/unused */
};
/**
* @ingroup CommonStructs
*
*/
struct SEFInfo {
const char *name; /**< Device Name from O/S */
char vendor[8]; /**< Vendor field */
char serialNumber[20]; /**< Device serial number */
char FWVersion[8]; /**< Device firmware version */
char HWVersion[8]; /**< Device hardware version */
uint16_t unitNumber; /**< Unit number of the SEFInfo struct */
uint16_t APIVersion; /**< API Version */
uint64_t supportedOptions; /**< Supported features - see kSupported defines */
uint32_t maxOpenSuperBlocks; /**< Firmware version specific, max number of open super blocks for the device. When
0, the limit is per Virtual Device instead. @see SEFVirtualDeviceInfo */
uint16_t maxQoSDomains; /**< Hardware version specific, may be less than 65535 defined by architecture */
uint16_t maxRootPointers; /**< Firmware version specific, may be less than 8 defined by architecture */
uint16_t maxPlacementIDs; /**< Firmware version specific, max number of auto opened super blocks per QoS Domain */
uint16_t reserved_0; /**< Reserved/unused */
uint16_t numReadQueues; /**< Firmware version specific, max number of read queues total */
uint16_t numVirtualDevices; /**< Number of currently defined virtual devices */
uint16_t numQoSDomains; /**< Number of currently defined QoS Domains */
uint16_t numBanks; /**< Number of banks per channel */
uint16_t numChannels; /**< Number of channels per SEF Unit */
uint16_t numPlanes; /**< Number of planes per die */
uint32_t pageSize; /**< Physical page size */
uint32_t numPages; /**< Number of pages per block */
uint32_t numBlocks; /**< Number of blocks per die */
uint32_t totalBandWidth; /**< Total bandwidth in MiBs corresponding to the underlying flash component on this device */
uint32_t readTime; /**< Read time in microseconds corresponding to the underlying flash components on this device */
uint32_t programTime; /**< Program time in microseconds corresponding to the underlying flash components on this device */
uint32_t eraseTime; /**< Erase time in microseconds corresponding to the underlying flash components on this device */
uint16_t minReadWeight; /**< Advisory minimum read weight to allow timely house keeping internal I/O */
uint16_t minWriteWeight; /**< Advisory minimum write weight to allow timely house keeping internal I/O */
uint32_t openExpirationPeriod;/**< Granularity in seconds for entire block */
uint16_t reserved_1; /**< Reserved/unused */
uint16_t numADUSizes; /**< Size of ADUsize array that follows at end of structure */
struct SEFADUsize ADUsize[]; /**< Array of supported ADU sizes */
};
/**
* @ingroup ApiManCmd
* @brief Gets device information.
*
* Returns ADU size(s), number of channels, number of dies, and other
* associated information. Dynamic values are refreshed just before the
* structure is returned.
*
* @param sefHandle Handle to the SEF Unit
*
* @return SEFInfo struct or NULL if sefHandle is NULL.
*/
const struct SEFInfo *SEFGetInformation(SEFHandle sefHandle) NONNULL(1);
/**
* @ingroup CommonStructs
*/
struct SEFVirtualDeviceList {
uint16_t numVirtualDevices; /**< Number of virtual devices */
struct SEFVirtualDeviceID virtualDeviceID[]; /**< An Array of all Virtual device IDs */
};
/**
* @ingroup ApiManCmd
* @brief Returns a list of the defined Virtual Devices.
*
* When list is NULL or insufficiently sized or bufferSize is 0, status.info
* returns the minimum buffer size for the complete list. The data that fits
* in an insufficiently sized buffer is valid but incomplete. The buffer must
* be at least the size of the list structure.
*
* @param sefHandle Handle to the SEF Unit
* @param[out] list Buffer for storing list of Virtual Devices
* @param bufferSize Buffer size
*
* @return Status and info summarizing result.
*
* @retval -ENODEV The SEF Handle is not valid
* @retval -EINVAL The function parameter is not valid; info returns the parameter index that is not valid
* @retval 0 info field returns the minimum buffer size if the buffer is insufficient or NULL; otherwise, 0
*/
struct SEFStatus SEFListVirtualDevices(SEFHandle sefHandle, struct SEFVirtualDeviceList *list,
size_t bufferSize) NONNULL(1);
/**
* @ingroup CommonStructs
*/
struct SEFQoSDomainList {
uint16_t numQoSDomains; /**< Number of QoS domains */
struct SEFQoSDomainID QoSDomainID[]; /**< An Array of all QoS Domain IDs */
};
/**
* @ingroup ApiManCmd
* @brief Returns a list of the defined QoS Domains.
*
* When list is NULL or insufficiently sized or bufferSize is 0, status.info
* returns the minimum buffer size for the complete list. The data that fits
* in an insufficiently sized buffer is valid but incomplete. The buffer must
* be at least the size of the list structure.
*
* @param sefHandle Handle to the SEF Unit
* @param[out] list Buffer for storing list of QoS Domains
* @param bufferSize Buffer size
*
* @return Status and info summarizing result.
*
* @retval -ENODEV The SEF Handle is not valid
* @retval -EINVAL The function parameter is not valid; info returns the parameter index that is not valid
* @retval 0 info field returns the minimum buffer size if the buffer is insufficient or NULL; otherwise, 0
*/
struct SEFStatus SEFListQoSDomains(SEFHandle sefHandle, struct SEFQoSDomainList *list,
size_t bufferSize) NONNULL(1);
/**
* @ingroup CommonStructs
* @brief Structure of SEFUserAddress may be redefined by user.
*
* The limitations for redefining the structure are:
* 1. size must be 8 bytes
* 2. multi-adu writes will auto increment the LBA value and must not
* equal SEFUserAddressIgnore. However SEFUserAddressIgnore is supported
* as a starting user address.
*
* For kSuperBlock, the LBA is limited to 40 bits and the meta to 24.
* The unformatted member is in little endian format.
*
*/
struct SEFUserAddress {
uint64_t unformatted;
};
/**
* @ingroup CommonStructs
* @brief Number of bits in a user address lba value
**/
#define SEFUserAddressLbaBits 40
/**
* @ingroup CommonStructs
* @brief Number of bits in a user address meta value
**/
#define SEFUserAddressMetaBits (64-SEFUserAddressLbaBits)
/**
* @ingroup ApiManCmd
*
* @param userAddress User address to be parsed
*
* @return Returns meta value from a user address
**/
static inline uint32_t SEFGetUserAddressMeta(struct SEFUserAddress userAddress)
{
return ((uint32_t) (le64toh(userAddress.unformatted) >> SEFUserAddressLbaBits));
}
/**
* @ingroup ApiManCmd
*
* @param userAddress User address to be parsed
*
* @return Returns LBA value from a user address
**/
static inline uint64_t SEFGetUserAddressLba(struct SEFUserAddress userAddress)
{
return (le64toh(userAddress.unformatted) & ((UINT64_C(1) << SEFUserAddressLbaBits)-1));
}
/**
* @ingroup ApiManCmd
* @brief Return LBA and meta values from a user address
*
* @param userAddress User address to be parsed
* @param[out] lba Lba parsed from the user address
* @param[out] meta Meta parsed from the user address
**/
static inline void SEFParseUserAddress(struct SEFUserAddress userAddress, uint64_t *lba, uint32_t *meta)
{
*lba = SEFGetUserAddressLba(userAddress);
*meta = SEFGetUserAddressMeta(userAddress);
}
/**
* @ingroup ApiManCmd
* @brief Creates a user address from lba and meta values
*
* @param lba lba to be used to generate user address (40 bits)
* @param meta meta to be used to generate user address (24 bits)
*
* @return Returns the user address created from lba and meta values
**/
static inline struct SEFUserAddress SEFCreateUserAddress(uint64_t lba, uint32_t meta)
{
return (struct SEFUserAddress) {
htole64(((uint64_t) meta << SEFUserAddressLbaBits) |
(lba & ((UINT64_C(1) << SEFUserAddressLbaBits)-1)))};
}
/**
* @ingroup CommonStructs
* @brief Opaque flash address value parsable by SEFParseFlashAddress()
*/
struct SEFFlashAddress {
uint64_t bits;
};
#if defined(_MSC_VER)
static inline struct SEFFlashAddress _int2fa(uint64_t v) {return {v};}
#define SEFAutoAllocate _int2fa(UINT64_C(0xffffffffffffffff))
#define SEFAutoAllocatePSLC _int2fa(htole64(UINT64_C(0xfffffffffffffffe)))
static inline struct SEFUserAddress _int2ua(uint64_t v) {return {v};}
#define SEFUserAddressIgnore _int2ua(UINT64_C(0xffffffffffffffff))
#define SEFNullFlashAddress _int2fa((int64_t)0x0)
#else
/**
* @ingroup CommonStructs
* @brief Flash address value to indicate device should allocate the super
* block from standard FLASH while doing a write
*
* @see SEFWriteWithoutPhysicalAddress()
*/
#define SEFAutoAllocate ((struct SEFFlashAddress) {UINT64_C(0xffffffffffffffff)})
/**
* @ingroup CommonStructs
* @brief Flash address value to indicate device should allocate the super
* block from pSLC while doing a write
*
* @see SEFWriteWithoutPhysicalAddress()
*/
#define SEFAutoAllocatePSLC ((struct SEFFlashAddress) { \
htole64(UINT64_C(0xfffffffffffffffe))})
/**
* @ingroup CommonStructs
* @brief User address value to indicate it should not be validated by
* the SEF device
*
* @see SEFReadWithPhysicalAddress()
*/
#define SEFUserAddressIgnore ((struct SEFUserAddress) {UINT64_C(0xffffffffffffffff)})
/**
* @ingroup CommonStructs
* @brief Flash address value indicating empty
*/
#define SEFNullFlashAddress ((struct SEFFlashAddress){(int64_t)0x0})
#endif
/**
* @ingroup CommonStructs
* @brief Checks whether the flash address is null
*
* @param flashAddress The opaque address to be checked
*
* @return Returns 1 if the flashAddress is null
*/
static inline int SEFIsNullFlashAddress(struct SEFFlashAddress flashAddress)
{
return (flashAddress.bits == SEFNullFlashAddress.bits);
}
/**
* @ingroup CommonStructs
* @brief Checks whether two flash addresses are equal
*
* @param flashAddress1 The opaque address to be compared
* @param flashAddress2 The opaque address to be compared
*
* @return Returns 1 if the flashAddress1 equals flashAddress2
*/
static inline int SEFIsEqualFlashAddress(struct SEFFlashAddress flashAddress1, struct SEFFlashAddress flashAddress2)
{
return (flashAddress1.bits == flashAddress2.bits);
}
/**
* @ingroup CommonStructs
* @brief Returns the next flash address by incrementing the ADU Offset
*
* Doesn't guarantee that the returned flash address is valid
*
* @param qosHandle Handle to a QoS Domain to interpret/parse the
* flash address.
* @param flashAddress The opaque address to be incremented
*
* @return Returns the next flash address if the qosHandle is valid,
* otherwise it returns SEFNullFlashAddress.
*/
struct SEFFlashAddress SEFNextFlashAddress(SEFQoSHandle qosHandle,
struct SEFFlashAddress flashAddress) NONNULL(1);
/**
* @ingroup Enums
* @brief Asynchronous notifications from SEF
*/
enum SEFNotificationType {
kAddressUpdate, /**< The flash address has changed */
kUnflushedData, /**< The super block data was flushed to the Flash Memory */
kRequirePatrol, /**< The super block requires to be patrolled; A list of super blocks requiring patrol can be retrieved using SEFGetCheckList */
kRequireMaintenance, /**< The super block requires maintenance; In other words, the data should be copied off and the super block should be freed */
kReducedCapacity, /**< The Virtual Device's capacity has been reduced */
kUnreadableData, /**< The data stored at the flash address cannot be read */
kSuperBlockStateChanged, /**< The super block's state has changed */
kOutOfCapacity, /**< The Virtual Device is full */
kOutOfPSLCCapacity, /**< The Virtual Device is out of pSLC */
kBufferRelease, /**< The buffer pointed to by iov can be freed */
} PACKED;
/**
* @ingroup EventsStructs
* @brief This event is issued at the QoS Domain level.
*/
struct SEFQoSNotification {
enum SEFNotificationType type; /**< See union below... */
uint8_t reserved_0[5]; /**< Reserved, must be initialized to zero */
struct SEFQoSDomainID QoSDomainID; /**< QoSDomainID for this notification */
union {
//! \unnamed{union:7}
struct SEFFlashAddress maintenanceFlashAddress; /**< Valid when type is kRequireMaintenance */
struct {
//! \unnamed{struct:3}
struct SEFUserAddress changedUserAddress; /**< User address that moved */
struct SEFFlashAddress oldFlashAddress; /**< Old flash address */
struct SEFFlashAddress newFlashAddress; /**< New flash address */
}; /**< Valid when type is kAddressUpdate */
struct SEFFlashAddress patrolFlashAddress; /**< Valid when type is kRequirePatrol */
struct {
//! \unnamed{struct:2}
struct SEFUserAddress unflushedUserAddress; /**< Affected user address */
char *userData; /**< Pointer to buffered data */
}; /**< Valid when type is kUnflushedData */
struct SEFFlashAddress unreadableFlashAddress; /**< Valid when type is kUnreadable */
struct {
//! \unamed{struct:3}
struct SEFFlashAddress changedFlashAddress; /**< Valid when type is kSuperBlockStateChanged (open=>closed) */
uint32_t writtenADUs; /**< Number of ADUs written by user i/o commands to the super block */
uint32_t numADUs; /**< Capacity of the super block in ADUs */
};
struct {
//! \unnamed{struct:2}
const struct iovec *iov; /**< A pointer to the scatter gather list */
int16_t iovcnt; /**< The number of elements in the scatter gather list */
}; /**< Valid when type is kBufferRelease */
}; /**< Notification data */
};
/**
* @ingroup EventsStructs
* @brief This event indicates to the host that it should respond in some
* appropriate manner to the reduced capacity condition.
*
* This event is issued at the Virtual Device level. Due to failure of blocks,
* actual available capacity may fall below the allocated capacity of the
* attached QoS Domains. The host should take action to release super blocks
* back to the Virtual Device's free pool before it is entirely consumed.
*/
struct SEFVDNotification {
enum SEFNotificationType type; /**< Is kReducedCapacity, kOutOfCapacity or
kOutOfPSLCCapacity */
uint8_t reserved_0; /**< Reserved, must be initialized to zero */
struct SEFVirtualDeviceID virtualDeviceID; /**< Virtual Device for this notification */
uint32_t numADUs; /**< kReducedCapacity - Amount of space that is no longer available */
};
/*
* Management operations associated with device control/configuration
*/
/**
* @ingroup CommonStructs
*/
struct SEFDieList
{
uint16_t numDies; /**< Number of dies in dieIDs */
uint16_t dieIDs[]; /**< List of dies by ID */
};
/**
* @ingroup CommonStructs
* @brief Relative die time weights for write type of I/O operations
*/
struct SEFWeights {
uint16_t programWeight; /**< Default weight for a program operation by the
Nameless Write and Nameless Copy commands */
uint16_t eraseWeight; /**< Default weight for an erase operation by SEFAllocateSuperBlock,
SEFFlushSuperBlock and SEFCloseSuperBlock */
};
/**
* @ingroup CommonStructs
*/
struct SEFVirtualDeviceConfig
{
struct SEFVirtualDeviceID virtualDeviceID; /**< Virtual Device ID */
uint8_t numReadQueues; /**< Number of read queues to define
for this Virtual Device */
uint8_t reserved; /**< Reserved, must be initialized to zero */
uint16_t readWeights[SEFMaxReadQueues]; /**< Default weight for read operations
for each possible read queue */
uint16_t superBlockDies; /**< Number of dies in a super block, 0 uses dieList.numDies */
struct SEFDieList dieList; /**< List of dies in ascending order for the Virtual Device */
};
/**
* @ingroup ApiManCmd
* @brief Creates the Virtual Devices and allocates physical resources.
*
* Configuring the virtual devices for a SEF Unit is only done during
* pre-production. Once the flash of a SEF Unit has been written to, it is
* not possible to change the Virtual Device configuration.
*
* Configuration is accomplished by supplying a array of pointers to
* virtualDeviceConfigs. Each Virtual Device being configured will have a
* single array entry. Each of those entries contains a list of die IDs that
* will define a specific Virtual Device. The superBlockDies in the config
* must be 0 or evenly divide into the number of dies specified by the die
* list.
*
* Valid die IDs start at 0 and are less than the total number of dies in a
* SEF Unit. The total number of dies is equal to SEFInfo::numBanks *
* SEFInfo::numChannels. The die ID of a die at channel CH, bank BNK, is equal
* to CH + BNK*SEFInfo::numChannels. A die ID can only be used in at most one
* Virtual Device configuration. If a die is not included in any Virtual
* Device configuration, it will be lost capacity that cannot be used.
*
* @see SEFGetInformation()
*
* @param sefHandle Handle to the SEF Unit
* @param numVirtualDevices Number of entries in virtualDeviceConfigs
* @param virtualDeviceConfigs Pointers to configurations describing how
* to create the virtual devices
*
* @return Status and info summarizing result. Returns 0 on success and negative value on error.
*
* @retval -ENODEV The SEF Handle is not valid
* @retval -EINVAL The function parameter is not valid; info returns the parameter index that is not valid
* @retval -EACCES You don't have the needed permission to perform this operation
*/
struct SEFStatus SEFCreateVirtualDevices(SEFHandle sefHandle, uint16_t numVirtualDevices,
struct SEFVirtualDeviceConfig * const virtualDeviceConfigs[]) NONNULL(1);
/**
* @ingroup ApiManCmd
* @brief Sets the number of pSLC super blocks
*
* This defines the number of regular super blocks which are transformed to
* use as pSLC super blocks. Because it applies to all the dies in the Virtual
* Device, the value must be a multiple of the ratio of the number of dies in
* the Virtual Device to the number of configured dies per super block.
*
* Once super blocks have been allocated from the Virtual Device, it may not
* be possible to modify the number of pSLC super blocks and the call will fail
* with -ENOSPC.
*
* @param vdHandle Handle to the SEF Unit
* @param numPSLCSuperBlocks The number of pSLC super blocks to set
* @retval 0 The number of pSLC super blocks has been set
* @retval -ENODEV The SEF Handle is not valid
* @retval -ENOSPC No space is available for pSLC super blocks
* @retval -EINVAL The function parameter is not valid; info returns
* the parameter index that is not valid.
*/
struct SEFStatus SEFSetNumberOfPSLCSuperBlocks(SEFVDHandle vdHandle, uint32_t numPSLCSuperBlocks) NONNULL(1);
/**
* @ingroup CommonStructs
*/
struct SEFVirtualDeviceUsage {
uint32_t eraseCount; /**< Count of super blocks erased. Used to populate
eraseOrder in SEFSuperBlockInfo */
uint32_t numUnallocatedSuperBlocks; /**< Number of unallocated super blocks */
uint32_t numSuperBlocks; /**< Number of allocated super blocks */
uint32_t numUnallocatedPSLCSuperBlocks; /**< Number of unallocated pSLC super blocks */
uint32_t numPSLCSuperBlocks; /**< Number of allocated pSLC super blocks */
struct SEFVirtualDeviceID vdID; /**< Virtual device ID of the handle */
uint8_t averagePEcount; /**< Average program/erase count */
uint8_t maxPEcount; /**< Max program/erase count */
uint16_t patrolCycleTime; /**< Recommended Patrol Cycle in minutes */
uint16_t reserved; /**< Reserved, must be initialized to zero */
};
/**
* @ingroup ApiManCmd
* @brief Returns Virtual Device usage.
*
* @param vdHandle Handle to the Virtual Device
* @param[out] usage Buffer for storing VD usage
*
* @return Status and info summarizing result.
*
* @retval -ENODEV The Virtual Device Handle is not valid
* @retval -EPERM The Virtual Device Handle is not open
*/
struct SEFStatus SEFGetVirtualDeviceUsage(SEFVDHandle vdHandle, struct SEFVirtualDeviceUsage *usage) NONNULL(1,2);
/**
* @ingroup CommonStructs
* @brief Configuration for Erase/Program suspend
*
* The weights supplied with i/o represents virtual time. These parameters
* control how often, and for how long an erase/program can be interrupted by
* reads.
*/
struct SEFVirtualDeviceSuspendConfig
{
uint32_t maxTimePerSuspend; /*< Read will issued within this time. When 0,
the number of read command is unlimited.
When larger than the device defined maximum
value, the device defined value is used. */
uint32_t minTimeUntilSuspend; /*< A suspend starts when the cumulated weights
of pending reads exceeds this value. When 0,
the suspend will start immediately for a
pending read. */
uint32_t maxSuspendInterval; /*< Suspend starts for a pending read command
after this interval since the last resume
(or start programming/erase). When larger
than the device defined minimum value, the
device defined value is used. */
};
/**
* @ingroup CommonStructs
*/
struct SEFVirtualDeviceInfo {
uint64_t flashCapacity; /**< Flash capacity in 4k ADUs */
uint64_t flashAvailable; /**< Available flash capacity in 4k ADUs */
uint64_t pSLCFlashCapacity; /**< pSLC Flash capacity in 4k ADUs */
uint64_t pSLCFlashAvailable; /**< pSLC Available flash capacity in 4k ADUs */
uint32_t superBlockCapacity; /**< Super block capacity in 4k ADUs */
uint32_t pSLCSuperBlockCapacity; /**< pSLC super block capacity in 4k ADUs */
uint32_t maxOpenSuperBlocks; /**< Maximum number of open super blocks per Virtual Device. When 0,
the limit is per device instead. See SEFInfo */
uint32_t numPSLCSuperBLocks; /**< Number of pSLC super blocks */
struct SEFVirtualDeviceSuspendConfig suspendConfig; /* Configuration for how erase/program
are suspended for reads */
uint16_t superBlockDies; /**< Number of dies used for a super block */
uint8_t aduOffsetBitWidth; /**< Number of bits that make up the
adu offset in a flash address */
uint8_t superBlockIdBitWidth; /**< Number of bits that make up the
super block id in a flash address */
uint16_t readWeights[SEFMaxReadQueues]; /**< Default weight for read operations
for each possible read queue */
uint8_t numReadQueues; /**< Number of read queues defined for the Virtual Device */
uint8_t reserved[5]; /**< Reserved, must be initialized to zero */
struct SEFQoSDomainList QoSDomains; /**< List of domains */
};
/**
* @ingroup ApiManCmd
* @brief Returns Virtual Device die list.
*
* When list is NULL or insufficiently sized or bufferSize is 0, status.info
* returns the minimum buffer size for the complete list. The data that fits
* in an insufficiently sized buffer is valid but incomplete. The buffer must
* be at least the size of the list structure.
*
* @param sefHandle Handle to the SEF Unit
* @param virtualDeviceID Virtual Device ID
* @param[out] list Buffer for storing VD information
* @param bufferSize Buffer size
*
* @return Status and info summarizing result.
*
* @retval -ENODEV The SEF Handle is not valid
* @retval -EINVAL The function parameter is not valid; info returns the parameter index that is not valid
* @retval 0 info field returns the minimum buffer size if the buffer is insufficient or NULL; otherwise, 0
*/
struct SEFStatus SEFGetDieList(SEFHandle sefHandle, struct SEFVirtualDeviceID virtualDeviceID,
struct SEFDieList *list, size_t bufferSize) NONNULL(1);
/**
* @ingroup ApiManCmd
* @brief Returns Virtual Device information.
*
* When info is NULL or insufficiently sized or bufferSize is 0, status.info
* returns the minimum buffer size for the complete set of information. The
* data that fits in an insufficiently sized buffer is valid but incomplete.
* The buffer must be at least the size of the info structure.
*
* @param sefHandle Handle to the SEF Unit
* @param virtualDeviceID Virtual Device ID
* @param[out] info Buffer for storing VD information
* @param bufferSize Buffer size
*
* @return Status and info summarizing result.
*
* @retval -ENODEV The SEF Handle is not valid
* @retval -EINVAL The function parameter is not valid; info returns the parameter index that is not valid
* @retval 0 info field returns the minimum buffer size if the buffer is insufficient or NULL; otherwise, 0
*/
struct SEFStatus SEFGetVirtualDeviceInformation(SEFHandle sefHandle, struct SEFVirtualDeviceID virtualDeviceID,
struct SEFVirtualDeviceInfo *info, size_t bufferSize) NONNULL(1);
/**
* @ingroup ApiManCmd
* @brief Sets the suspend configuration for a Virtual Device
*
* @param vdHandle Handle to the SEF Unit
* @param config Suspend configuration to set
* @retval 0 The suspend configuration has been set
* @retval -ENODEV The SEF Handle is not valid
* @retval -EINVAL The function parameter is not valid; info returns
* the parameter index that is not valid.
*/
struct SEFStatus SEFSetVirtualDeviceSuspendConfig(SEFVDHandle vdHandle,
const struct SEFVirtualDeviceSuspendConfig *config) NONNULL(1);
/**
* @ingroup CommonStructs
*/
struct SEFQoSDomainCapacity {
uint64_t flashCapacity; /**< Number of ADUs to assign to a QoS Domain */
uint64_t flashQuota; /**< Maximum number of ADUs allowed for a QoS Domain */
};
/**
* @ingroup ApiManCmd
* @brief Attempts to create a QoS Domain in the specified Virtual Device.
*
* Returns an error when the target Virtual Device doesn’t have enough flash
* memory space. The actual flash capacity reserved in the
* Virtual Device is typically larger than what was requested by flashCapacity.
*
* @see SEFGetInformation()
*
* @param vdHandle Handle to the Virtual Device
* @param[out] QoSDomainID Assigned QoS Domain ID.
* @param flashCapacity Number of required/reserved/maximum ADUs regular flash
* @param pSLCFlashCapacity Number of required/reserved/maximum ADUs pSLC flash
* @param ADUindex Index into the ADUSize[] array in SEFInfo
* returned by SEFGetInformation() to select
* the data and metadata sizes of an ADU.
* @param api Specifies the API Identifier for this QoS Domain
* @param defectStrategy Specifies the defect management strategy for the QoS Domain
* @param recovery Specifies the recovery mode for this QoS Domain
* @param encryptionKey NULL for disabled.
* @param numPlacementIDs The maximum number of Placement IDs that
* can be placed on the QoS Domain.
* @param maxOpenSuperBlocks The maximum number super blocks that can be
* open in a QoS Domain. If less than numPlacementIDs
* it will be set to numPlacementIDs+2. This
* affects resource/memory usage in the device.
* @param defaultReadQueue The default read queue assignment, 0 through
* numReadQueues-1 defined for the Virtual Device.
* @param weights Weight values for each type of write I/O
* operations.
*
* @return Status and info summarizing result.
*
* @retval -ENODEV The Virtual Device Handle is not valid
* @retval -EPERM The Virtual Device Handle is not open
* @retval -EINVAL The function parameter is not valid; info returns the parameter index that is not valid
* @retval -ENOMEM The library was unable to allocate needed structures. status.info is set to the type
* of capacity that caused the failure (0 for kForWrite, 1 for kForPSLCWrite, 2 for
* QoSD max)
*/
struct SEFStatus SEFCreateQoSDomain(SEFVDHandle vdHandle, struct SEFQoSDomainID *QoSDomainID,
struct SEFQoSDomainCapacity *flashCapacity,
struct SEFQoSDomainCapacity *pSLCFlashCapacity,
int ADUindex, enum SEFAPIIdentifier api,
enum SEFDefectManagementMethod defectStrategy, enum SEFErrorRecoveryMode recovery,
const char *encryptionKey, uint16_t numPlacementIDs, uint16_t maxOpenSuperBlocks,
uint8_t defaultReadQueue, struct SEFWeights weights) NONNULL(1,2);
/**
* @ingroup Enums
*/
enum SEFSuperBlockType {
kForWrite, /**< Super block is for writes */
kForPSLCWrite /**< Super block is for pSLC writes */
} PACKED;
/**
* @ingroup ApiManCmd
* @brief Resets the capacity of a QoS Domain
*
* Sets a new capacity and quota for the QoS Domain. When the flashQuota is
* less than the flashCapacity or the used flashedCapacity, it will be set to
* the larger of the two.
*
* @param vdHandle Handle to the Virtual Device
* @param QoSDomainID QoS Domain ID
* @param type Type of super block
* @param capacity Number of required/reserved/maximum ADUs the flash type
*
* @return Status and info summarizing result.
*
* @retval -ENODEV The Virtual Device Handle is not valid
* @retval -EPERM The Virtual Device Handle is not open
* @retval -EINVAL The function parameter is not valid; info returns the parameter index that is not valid
* @retval -ENOSPC The Virtual Device does not have enough space
*/
struct SEFStatus SEFSetQoSDomainCapacity(SEFVDHandle vdHandle, struct SEFQoSDomainID QoSDomainID,
enum SEFSuperBlockType type, struct SEFQoSDomainCapacity *capacity) NONNULL(1);
/**
* @ingroup ApiManCmd
* @brief Sets the value of a QoSDomain root pointer.
*
* A root pointer may be set to any value. Root pointer values are read back
* using SEFGetQoSDomainInformation(). When a root pointer is set to a flash
* address that is valid for the QoS Domain it's stored in, the ADU it points to
* can be read by SEFReadWithPhysicalAddress() using a flash address of just
* the root pointer index as the ADU offset with zeros for the QoS DomainId
* and super block index.
*
* @see SEFReadWithPhysicalAddress()
*
* @param qosHandle Handle to the QoS Domain
* @param index The index of the root pointer
* @param value Value of the pointer
*
* @return Status and info summarizing result.
*
* @retval -ENODEV The QoS Domain handle is not valid
* @retval -EPERM The QoS Domain Handle is not open
* @retval -EINVAL The function parameter is not valid; info returns the parameter index that is not valid
*/
struct SEFStatus SEFSetRootPointer(SEFQoSHandle qosHandle, int index, struct SEFFlashAddress value) NONNULL(1);
/**
* @ingroup ApiManCmd
* @brief Sets target QoS Domain's read deadline policy.
*
* @see SEFVirtualDeviceInfo
*
* @param qosHandle Handle to the QoS Domain
* @param deadline Deadline type for this QoS Domain
*
* @return Status and info summarizing result.
*
* @retval -ENODEV The QoS Domain handle is not valid
* @retval -EPERM The QoS Domain Handle is not open
*/
struct SEFStatus SEFSetReadDeadline(SEFQoSHandle qosHandle, enum SEFDeadlineType deadline) NONNULL(1);
/**
* @ingroup ApiManCmd
* @brief Sets target QoS Domain's default program and erase weights.
*
* @see SEFQoSDomainInfo
*
* @param qosHandle Handle to the QoS Domain
* @param weights Default program and erase weights for this QoS Domain
*
* @return Status and info summarizing result.
*
* @retval -ENODEV The QoS Domain handle is not valid
* @retval -EPERM The QoS Domain Handle is not open
*/
struct SEFStatus SEFSetWeights(SEFQoSHandle qosHandle, struct SEFWeights weights) NONNULL(1);
/**
* @ingroup Enums
*/
enum SEFSuperBlockState {
kSuperBlockClosed = 1, /**< This is the state of super blocks which retain effective
data after all super pages have been programmed */
kSuperBlockOpenedByErase, /**< This is the state of super blocks in the middle of being programmed
and were allocated by SEFAllocateSuperBlock() */
kSuperBlockOpenedByPlacementId, /**< This is the state of super blocks in the middle of being programmed
and were allocated automatically by placement id */
} PACKED;