Skip to content

Commit 74d2cfc

Browse files
kurz-migaw
authored andcommitted
src: rework nvme_lm_cdq command
libnvme changed the API for the nvme_lm_cdq command. Update the callsite accordingly. Signed-off-by: Markus Kurz <[email protected]> [wagi: replaced nvme_ini_lm_cdq with nvme_init_lm_cdq_{create|delete}] Signed-off-by: Daniel Wagner <[email protected]>
1 parent 3e2d050 commit 74d2cfc

1 file changed

Lines changed: 13 additions & 21 deletions

File tree

plugins/lm/lm-nvme.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ static int lm_create_cdq(int argc, char **argv, struct command *acmd, struct plu
5757
"will write to invalid memory, inevitably leading to MMU faults or "
5858
"worse.";
5959

60-
_cleanup_huge_ struct nvme_mem_huge mh = { 0, };
61-
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
6260
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
61+
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
6362
struct lba_migration_queue_entry_type_0 *queue = NULL;
63+
_cleanup_huge_ struct nvme_mem_huge mh = { 0, };
64+
struct nvme_passthru_cmd cmd;
65+
__u32 result;
6466
int err = -1;
6567

6668
struct config {
@@ -105,22 +107,16 @@ static int lm_create_cdq(int argc, char **argv, struct command *acmd, struct plu
105107
return -ENOMEM;
106108
}
107109

108-
struct nvme_lm_cdq_args args = {
109-
.args_size = sizeof(args),
110-
.sel = NVME_LM_SEL_CREATE_CDQ,
111-
.mos = NVME_SET(cfg.qt, LM_QT),
112-
.cntlid = cfg.cntlid,
113-
.sz = cfg.sz,
114-
.data = queue
115-
};
116-
117-
err = nvme_lm_cdq(hdl, &args);
110+
nvme_init_lm_cdq_create(&cmd, NVME_SET(cfg.qt, LM_QT),
111+
cfg.cntlid, cfg.sz, queue);
112+
err = nvme_submit_admin_passthru(hdl, &cmd, &result);
118113
if (err < 0)
119114
nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", nvme_strerror(errno));
120115
else if (err)
121116
nvme_show_status(err);
122117
else
123-
printf("Create CDQ Successful: CDQID=0x%04x\n", args.cdqid);
118+
printf("Create CDQ Successful: CDQID=0x%04x\n",
119+
NVME_GET(result, LM_CREATE_CDQ_CDQID));
124120

125121
return err;
126122
}
@@ -130,8 +126,9 @@ static int lm_delete_cdq(int argc, char **argv, struct command *acmd, struct plu
130126
const char *desc = "Delete Controller Data Queue";
131127
const char *cdqid = "Controller Data Queue ID";
132128

133-
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
134129
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
130+
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
131+
struct nvme_passthru_cmd cmd;
135132
int err = -1;
136133

137134
struct config {
@@ -151,13 +148,8 @@ static int lm_delete_cdq(int argc, char **argv, struct command *acmd, struct plu
151148
if (err)
152149
return err;
153150

154-
struct nvme_lm_cdq_args args = {
155-
.args_size = sizeof(args),
156-
.sel = NVME_LM_SEL_DELETE_CDQ,
157-
.cdqid = cfg.cdqid,
158-
};
159-
160-
err = nvme_lm_cdq(hdl, &args);
151+
nvme_init_lm_cdq_delete(&cmd, 0, cfg.cdqid);
152+
err = nvme_submit_admin_passthru(hdl, &cmd, NULL);
161153
if (err < 0)
162154
nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", nvme_strerror(errno));
163155
else if (err > 0)

0 commit comments

Comments
 (0)