Collection of NVMe related functions
Methods
(static) createQueuePair() → {Number}
Creates an IO queue pair.
Example
// Creating a single IO queue pair
const qid1 = nvme.createQueuePair();
logger.info(`Created IO queue pair with Queue ID ${qid1}.`);
// Creating another IO queue pair
const qid2 = nvme.createQueuePair();
logger.info(`Created IO queue pair with Queue ID ${qid2}.`);
// If you want to create multiple queue pairs in a loop (assuming a hypothetical need to create 5 pairs)
for (let i = 0; i < 5; i++) {
const qid = nvme.createQueuePair();
logger.info(`Created IO queue pair with Queue ID ${qid}.`);
}
Returns:
Returns the created Queue ID.
- Type
- Number
(static) datasetManagement(ranges, options) → {nvme.CompletionQueueEntry}
Sends NVM Dataset Management command.
The Dataset Management command allows the host to indicate to the controller the ranges of logical blocks that the host no longer needs the data that is currently stored in those logical blocks. This command is typically used for TRIM operation in SSDs.
Example
var response = nvme.datasetManagement(
[{ length: 100, startLba: 2000 }, { length: 50, startLba: 2100 }],
{ nsid: 1, qid: 2, attributes: 0b010 }
);
logger.info("Command Status:", response.status);
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ranges |
Array.<Object> | An array of range objects where each range has a length and starting LBA. Properties
|
||||||||||||||||||||
options |
Object | Optional parameters for the command. Properties
|
Returns:
Returns an object containing the status and any additional data from the command.
(static) deleteQueuePair(qid)
Deletes an IO queue pair.
Example
// Delete a specific IO queue pair with Queue ID 5
nvme.deleteQueuePair(5);
logger.info('Deleted IO queue pair with Queue ID 5.');
// Attempting to delete another IO queue pair with Queue ID 3
nvme.deleteQueuePair(3);
logger.info('Deleted IO queue pair with Queue ID 3.');
// If you want to delete multiple queue pairs sequentially (assuming a hypothetical range for demonstration)
for (let i = 1; i <= 10; i++) {
nvme.deleteQueuePair(i);
logger.info(`Deleted IO queue pair with Queue ID ${i}.`);
}
Parameters:
Name | Type | Description |
---|---|---|
qid |
Number | Queue ID to delete. |
(static) disableCommandTracker()
Disables command history tracker
(static) disableDataValidator(optionsopt)
Disables data validation at a given namespace
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Optional Parameters Properties
|
(static) enableCommandTracker()
Enables command history tracker.
(static) enableDataValidator(optionsopt)
Enables data validation at a given namespace
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Optional Parameters Properties
|
(static) formatNvm(nsid, lbaFormat, optionsopt) → {nvme.CompletionQueueEntry}
Issues NVM Format command to a given namespace.
Example
// Format a specific namespace with default settings
nvme.formatNvm(1, 5);
// Format a specific namespace with User Data Erase secure settings and Protection Information enabled as Type 1
nvme.formatNvm(2, 7, { ses: 1, pi: 1 });
// Format with Cryptographic Erase and metadata in a separate buffer
nvme.formatNvm(3, 8, { ses: 2, mset: 0 });
// Format with Protection Information in the first bytes of metadata and metadata transferred as part of an extended LBA
nvme.formatNvm(4, 9, { pil: 1, mset: 1 });
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
nsid |
Number | Namespace ID |
||||||||||||||||||||||||||
lbaFormat |
Number | LBA Format (0 - 15) |
||||||||||||||||||||||||||
options |
Object |
<optional> |
Optional parameters Properties
|
Returns:
(static) getDeviceInfo() → {nvme.DeviceInfo}
Retrieves device information.
Returns:
- Type
- nvme.DeviceInfo
(static) getNamespaceInfo(nsid) → {nvme.NamespaceInfo}
Retrieves namespace information.
Parameters:
Name | Type | Description |
---|---|---|
nsid |
Number | Namespace ID |
Returns:
- Type
- nvme.NamespaceInfo
(static) loadDriver()
Loads the device driver. Throws an exception if the driver is not loaded correctly.
DEPRECATED - Use nvme.probeController instead.
(static) probeController(options)
Probes an NVMe controller. Throws an exception if an NVMe device is not initialized successfully.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
(static) read(startLba, numBlocks, options) → {nvme.CompletionQueueEntry}
Sends NVM Read command.
Example
const startLba = 500;
const numBlocks = 5;
// Using default nsid and qid values
const result1 = nvme.read(startLba, numBlocks);
logger.info(result1);
// Specifying nsid and qid values
const options = { nsid: 2, qid: 3 };
const result2 = nvme.read(startLba, numBlocks, options);
logger.info(result2);
// Using only the required parameters
const startLba = 1000;
const numBlocks = 2;
const result3 = nvme.read(startLba, numBlocks);
logger.info(result3);
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
startLba |
Number | Start LBA where the data should be read from. |
|||||||||||||||
numBlocks |
Number | Number of Logical Blocks to read. |
|||||||||||||||
options |
Object | Additional configuration options. Properties
|
Returns:
- Returns the completion queue entry after the command has been executed.
(static) registerPowerControl()
Registers power control script file paths
DEPRECATED - Use powerController.init instead.
(static) resetController()
Issues a controller level reset.
(static) sendAdminCommand(command, buffer, isHostToDevice) → {nvme.CompletionQueueEntry}
Sends an NVMe Admin Command.
Example
// Example: Sending an "Identify" command using the NVMe "sendAdminCommand" API
var identifyBuffer = Buffer.alloc(4096); // Allocating a 4K buffer to retrieve identify information
nvme.sendAdminCommand({
nsid: 0, // Namespace ID (0 for controller, specific ID for namespace)
opc: 0x06, // Opcode for Identify command
cdw10: 1, // Specify what to identify (1 = namespace, 2 = controller)
}, identifyBuffer, false); // Set to false since we're expecting data from the device
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
command |
Object | NVMe command queue entry Properties
|
|||||||||||||||||||||||||||||||||||||||||||||
buffer |
Buffer | Data buffer (usually a buffer to hold the retrieved information) |
|||||||||||||||||||||||||||||||||||||||||||||
isHostToDevice |
Boolean | Data transfer direction |
Returns:
(static) sendNvmCommand(qid, command, buffer, isHostToDevice) → {nvme.CompletionQueueEntry}
Sends an NVM Command.
Example
// Example: Sending a "Write" command using the NVMe "sendNvmCommand" API
var writeDataBuffer = Buffer.from('This is data to be written to NVMe drive');
var startLBA = 0x1FFFFFFFF; // starting Logical Block Address
var numLBAs = (writeDataBuffer.length / 512) - 1; // number of LBAs to write, assuming 512-byte sectors and subtracting 1 as it's 0-based.
var lower32bits = startLBA % 0x100000000; // Equivalent to startLBA & 0xFFFFFFFF for values > 32-bits
var upper32bits = Math.floor(startLBA / 0x100000000); // Obtain the upper 32 bits by dividing
nvme.sendNvmCommand(1, {
nsid: 1,
opc: 0x01, // Opcode for Write command
cdw10: lower32bits, // Starting LBA (lower 32 bits)
cdw11: upper32bits, // Starting LBA (upper 32 bits)
cdw12: numLBAs
}, writeDataBuffer, true);
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
qid |
Number | IO queue ID |
|||||||||||||||||||||||||||||||||||||||||||||
command |
Object | NVMe command queue entry Properties
|
|||||||||||||||||||||||||||||||||||||||||||||
buffer |
Buffer | Data buffer |
|||||||||||||||||||||||||||||||||||||||||||||
isHostToDevice |
Boolean | Data transfer direction |
Returns:
(static) setCommandTrackerLog(filename)
Sets the filename where command history will be dumped.
Parameters:
Name | Type | Description |
---|---|---|
filename |
String | Tracker log file path. Relative to workspace root. |
(static) shutdown()
Issues a controller shutdown.
Example
// Initiating a controller shutdown
nvme.shutdown();
// You can log the shutdown initiation for record purposes
logger.info('Controller shutdown initiated.');
(static) startWorkloadGenerator(optionsopt) → {nvme.WorkloadResult}
Generates IO workloads.
Example
// basic workload generator type
nvme.startWorkloadGenerator({
type: "basic",
nsid: 1,
queueDepth: 1024,
xferSize: 4096,
range: { startLba: 0x1234, size: 0x5 },
loops: 1,
duration: 60,
nsid: 1,
workload: 'random',
readPercent: 50,
alignment: 8, // Aligns Start LBA at 4K boundary if LBA size is 512B.
xferSize: 4096,
range: '100%'
})
// multiRange workload generator type
nvme.startWorkloadGenerator({
type: "multiRange",
nsid: 1,
queueDepth: 1024,
xferSize: 4096,
range: { startLba: 0x1234, size: 0x5 },
loops: 1,
duration: 60,
ranges: [
{
nsid: 1,
workload: 'random',
readPercent: 100,
alignment: 0,
startLba: 0,
size: 10000,
probability: 5,
xfers: [
{ size: 512, probability: 5},
{ size: 1024, probability: 10},
{ size: 2048, probability: 20},
{ size: 4096, probability: 65}
]
},
{
nsid: 1,
workload: 'sequential',
readPercent: 0,
alignment: 8,
startLba: 10000,
size: 100000,
probability: 95,
xfers: [
{ size: 512, probability: 50},
{ size: 1024, probability: 50}
]
}
]
})
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
nvme.WorkloadGeneratorBasicOptions | nvme.WorkloadGeneratorMultiRangeOptions |
<optional> |
Optional parameters. The following parameters are common across all available workload generator types Properties
|
Returns:
- Type
- nvme.WorkloadResult
(static) write(startLba, numBlocks, options) → {nvme.CompletionQueueEntry}
Sends NVM Write command.
Example
const data = Buffer.from('0102030405060708', 'hex');
const startLba = 1000;
const numBlocks = 4;
// Using default nsid and qid values
const result1 = nvme.write(startLba, numBlocks, { dataPattern: data });
logger.info(result1);
// Specifying nsid and qid values
const options = { nsid: 2, qid: 3, dataPattern: data };
const result2 = nvme.write(startLba, numBlocks, options);
logger.info(result2);
// Using only the required parameters
const startLba = 2000;
const numBlocks = 3;
const result3 = nvme.write(startLba, numBlocks);
logger.info(result3);
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
startLba |
Number | Start LBA where the data should be written. |
||||||||||||||||||||
numBlocks |
Number | Number of Logical Blocks to write. |
||||||||||||||||||||
options |
Object | Additional configuration options. Properties
|
Returns:
- Returns the completion queue entry after the command has been executed.
Type Definitions
CommandErrorHistory
Properties:
Name | Type | Description |
---|---|---|
sct |
Number | Status Code Type |
sc |
Number | Status Code |
cmd |
String | Command name |
nsid |
Number | Namespace ID |
startLba |
Number | Command Start LBA |
numBlocks |
Number | Number of blocks |
Type:
- Object
CompletionQueueEntry
Properties:
Name | Type | Description |
---|---|---|
cdw |
Number | Command Specific Response |
sqhd |
Number | SQ Head Pointer |
sqid |
Number | SQ Identifier |
cid |
Number | Command Identifier |
status |
CompletionStatus | Completion Status |
Type:
- object
CompletionStatus
Properties:
Name | Type | Description |
---|---|---|
sc |
Number | Status Code |
sct |
Number | Status Code Type |
m |
Number | More |
p |
Number | Phase Tag |
dnr |
Number | Do Not Retry |
Type:
- object
DeviceInfo
Properties:
Name | Type | Description |
---|---|---|
maxXferSize |
Number | Max Transfer Size |
maxQueueDepth |
Number | Max Queue Depth. |
maxNamespaceId |
Number | Max Namespace ID. |
Type:
- Object
NamespaceInfo
Properties:
Name | Type | Description |
---|---|---|
isActive |
Boolean | Is an active namespace. |
lbaSize |
Number | Size of LBA. |
metaSize |
Number | Size of Metadata. |
size |
Number | Size of the Namespace in LBAs. |
Type:
- Object
WorkloadGeneratorBasicOptions
Properties:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
Type:
- Object
WorkloadGeneratorFeatures
Properties:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
features |
Object |
<optional> |
Properties
|
Type:
- Object
WorkloadGeneratorMultiRangeOptions
Properties:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
Type:
- Object
WorkloadResult
Properties:
Name | Type | Description |
---|---|---|
info |
nvme.WorkloadResultBasicInfo | nvme.WorkloadResultMultiRangeInfo | Returns the parameters passed to the workload generator.
|
read |
nvme.WorkloadResultLatency | Latency information for read commands. |
write |
nvme.WorkloadResultLatency | Latency information for write commands. |
trim |
nvme.WorkloadResultLatency | Latency information for write commands. |
errorHistory |
Array.<nvme.CommandErrorHistory> | Command errors commands. |
Type:
- Object
WorkloadResultBasicInfo
Properties:
Name | Type | Description |
---|---|---|
queueDepth |
Object | Number of maximum outstanding commands. |
duration |
Object | Maximum execution time of the workload generator. |
loops |
Number | Number of loops to repeat. |
readPercent |
Number | Percentage of read commands. |
trimPercent |
Number | Percentage of trim (dataset management) commands. |
xferSize |
Number | Transfer size of each IO. |
startLba |
Number | Start LBA of workload access range.
|
size |
Number | Workload access range in LBAs.
|
workload |
String | Workload type. |
Type:
- Object
WorkloadResultLatency
Properties:
Name | Type | Description | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
perf |
Object | Performance information. Properties
|
|||||||||||||||||||||||||||||||||
latency |
Object | Returned when histogram feature is enabled Properties
|
|||||||||||||||||||||||||||||||||
histogramRawData |
Object | Histogram raw data Properties
|
|||||||||||||||||||||||||||||||||
intervalData |
Array.<Object> | Interval measurement data. Returned when interval measurement is enabled. This is a list of objects.
Properties
|
Type:
- Object
WorkloadResultMultiRangeInfo
Properties:
Name | Type | Description |
---|---|---|
queueDepth |
Object | Number of maximum outstanding commands. |
duration |
Object | Maximum execution time of the workload generator. |
loops |
Number | Number of loops to repeat. |
ranges |
Array.<Object> | Ranges |
ranges[].startLba |
Number | Start LBA of a range interval. |
ranges[].size |
Number | size of an interval in logical blocks. |
ranges[].probability |
Number | Probability that defines how often this interval will be accesse. |
ranges[].workload |
Number | Workload type. |
ranges[].readPercent |
Number | Percentage of read commands. |
ranges[].trimPercent |
Number | Percentage of trim (dataset management) commands. |
ranges[].xfers |
Array.<Object> | Data Transfers |
ranges[].xfers[].size |
Number | Transfer size. |
ranges[].xfers[].probability |
Number | Probability that defines how often this transfer size will be used. |
Type:
- Object