nvme: add NVME_INIT_REQUEST macro

This macro will be used in an upcoming patch
that needs to construct an nvme_request structure
outside of the standard nvme_allocate() routines.

Examined x86 optimized assembly with this patch,
and there is no change.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I0f6b8500e06b56edc33f437f351536cf857d13d3
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11513
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Jim Harris 2022-02-09 19:21:04 +00:00
parent 70a6e3ac22
commit 56618eacb9

View File

@ -1245,6 +1245,17 @@ typedef int (*spdk_nvme_parse_ana_log_page_cb)(
int nvme_ctrlr_parse_ana_log_page(struct spdk_nvme_ctrlr *ctrlr,
spdk_nvme_parse_ana_log_page_cb cb_fn, void *cb_arg);
#define NVME_INIT_REQUEST(req, _cb_fn, _cb_arg, _payload, _payload_size, _md_size) \
do { \
req->cb_fn = _cb_fn; \
req->cb_arg = _cb_arg; \
req->payload = _payload; \
req->payload_size = _payload_size; \
req->md_size = _md_size; \
req->pid = g_spdk_nvme_pid; \
req->submit_tick = 0; \
} while (0);
static inline struct nvme_request *
nvme_allocate_request(struct spdk_nvme_qpair *qpair,
const struct nvme_payload *payload, uint32_t payload_size, uint32_t md_size,
@ -1272,13 +1283,7 @@ nvme_allocate_request(struct spdk_nvme_qpair *qpair,
*/
memset(req, 0, offsetof(struct nvme_request, payload_size));
req->cb_fn = cb_fn;
req->cb_arg = cb_arg;
req->payload = *payload;
req->payload_size = payload_size;
req->md_size = md_size;
req->pid = g_spdk_nvme_pid;
req->submit_tick = 0;
NVME_INIT_REQUEST(req, cb_fn, cb_arg, *payload, payload_size, md_size);
return req;
}