Queue Primitives

struct nvme_cq

Completion Queue

Definition:

struct nvme_cq {
};

Members

struct nvme_sq

Submission Queue

Definition:

struct nvme_sq {
};

Members

void nvme_sq_post(struct nvme_sq *sq, const union nvme_cmd *sqe)

Add a submission queue entry to a submission queue

Parameters

struct nvme_sq *sq

Submission queue

const union nvme_cmd *sqe

Submission queue entry

Description

Add a submission queue entry to a submission queue, updating the queue tail pointer in the process.

void nvme_sq_update_tail(struct nvme_sq *sq)

Write the submission queue doorbell

Parameters

struct nvme_sq *sq

Submission queue

Description

Write the queue doorbell if the tail pointer has changed since last written.

void nvme_sq_exec(struct nvme_sq *sq, const union nvme_cmd *sqe)

Post submission queue entry and write the doorbell

Parameters

struct nvme_sq *sq

Submission queue

const union nvme_cmd *sqe

Submission queue entry

Description

Combine the effects of nvme_sq_post() and nvme_sq_update_tail().

struct nvme_cqe *nvme_cq_head(struct nvme_cq *cq)

Get a pointer to the current completion queue head

Parameters

struct nvme_cq *cq

Completion queue

Return

Pointer to completion queue head entry

void nvme_cq_update_head(struct nvme_cq *cq)

Write the completion queue head doorbell

Parameters

struct nvme_cq *cq

Completion queue

Description

Write the completion queue head doorbell.

void nvme_cq_spin(struct nvme_cq *cq)

Continuously read the top completion queue entry until phase change

Parameters

struct nvme_cq *cq

Completion queue

Description

Keep reading the current head of the completion queue cq until the phase changes.

struct nvme_cqe *nvme_cq_get_cqe(struct nvme_cq *cq)

Get a pointer to the current completion queue head and advance it

Parameters

struct nvme_cq *cq

Completion queue

Description

If the current completion queue head entry is valid (has the right phase), advance the head and return a pointer to it. Otherwise, return NULL and leave the head as-is.

Note

Does NOT update the cq head doorbell. See nvme_cq_update_head().

Return

If the current completion queue head entry is valid (correct phase), return a pointer to it. Otherwise, return NULL.

void nvme_cq_get_cqes(struct nvme_cq *cq, struct nvme_cqe *cqes, int n)

Get an exact number of cqes from a completion queue

Parameters

struct nvme_cq *cq

Completion queue

struct nvme_cqe *cqes

Pointer to array of struct cqe to place cqes into

int n

number of cqes to reap

Description

Continuously spin on cq and copy n cqes into cqes if not NULL.

Note

Does NOT update the cq head pointer. See nvme_cq_update_head().

int nvme_cq_wait_cqes(struct nvme_cq *cq, struct nvme_cqe *cqes, int n, struct timespec *ts)

Get an exact number of cqes from a completion queue with timeout

Parameters

struct nvme_cq *cq

Completion queue

struct nvme_cqe *cqes

Pointer to array of struct cqe to place cqes into

int n

Number of cqes to reap

struct timespec *ts

Maximum time to wait for CQEs

Description

Continuously poll cq and copy n cqes into cqes if not NULL.

Note

Does NOT update the cq head pointer. See nvme_cq_update_head().

Return

n on success. On timeout, returns the number of cqes reaped (i.e., less than n) and sets errno.