Utilities and Helpers
-
uint64_t nvme_crc64(uint64_t crc, const unsigned char *buffer, size_t len)
Calculate NVMe CRC64
Parameters
uint64_t crcstarting value
const unsigned char *bufferbuffer to calculate CRC for
size_t lenlength of buffer
Return
the NVMe CRC64 calculated over buffer
-
bool nvme_cqe_ok(struct nvme_cqe *cqe)
Check the status field of CQE
Parameters
struct nvme_cqe *cqeCompletion queue entry
Description
Check the Status Field of the CQE.
Return
true on no error, false otherwise.
-
int nvme_set_errno_from_cqe(struct nvme_cqe *cqe)
Set errno from CQE
Parameters
struct nvme_cqe *cqeCompletion queue entry
Description
Set errno to an error describing the NVMe status indicated by the Status
Field in cqe.
Return
0 when no error in cqe, otherwise -1 and set errno.
Parameters
struct nvme_ctrl *ctrlController reference
void *opaqueOpaque data pointer
Description
Issue an Asynchronous Event Request command and associate opaque with the request tracker.
Return
On success, returns 0. On error, returns -1 and sets
errno.
-
int nvme_sync(struct nvme_ctrl *ctrl, struct nvme_sq *sq, union nvme_cmd *sqe, void *buf, size_t len, struct nvme_cqe *cqe_copy)
Submit a command and wait for completion
Parameters
struct nvme_ctrl *ctrlController reference
struct nvme_sq *sqSubmission queue
union nvme_cmd *sqeSubmission queue entry
void *bufCommand payload
size_t lenCommand payload length
struct nvme_cqe *cqe_copyCompletion queue entry to fill
Description
Submit a command and wait for completion in a synchronous manner. If a spurious completion queue entry is posted (i.e., the command identifier is different from the one set in sqe), the CQE is ignored and an error message is logged.
Note: This function should only be used for synchronous commands where no spurious CQEs are expected to be posted on the completion queue. Any spurious CQEs will be logged and dropped.
Return
On success, returns 0. On error, returns -1 and sets
errno.
-
int nvme_admin(struct nvme_ctrl *ctrl, union nvme_cmd *sqe, void *buf, size_t len, struct nvme_cqe *cqe_copy)
Submit an Admin command and wait for completion
Parameters
struct nvme_ctrl *ctrlSee
struct nvme_ctrlunion nvme_cmd *sqeSubmission queue entry
void *bufCommand payload
size_t lenCommand payload length
struct nvme_cqe *cqe_copyCompletion queue entry to fill
Description
Shortcut for nvme_sync(), submitting to the admin submission queue.
Return
On success, returns 0. On error, returnes -1 and sets
errno.