Skip to content

Commit 5f9db44

Browse files
committed
ioctl: rework nvme_lm_get_features_data_queue command
Replace the struct args approach by providing init function for initializing the passthru commands. This reduces the dependency between callside and library. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 7f9af12 commit 5f9db44

4 files changed

Lines changed: 23 additions & 27 deletions

File tree

libnvme/src/libnvme.map

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ LIBNVME_2_0 {
137137
nvme_io_passthru64;
138138
nvme_io_passthru;
139139
nvme_ipaddrs_eq;
140-
nvme_lm_get_features_ctrl_data_queue;
141140
nvme_lookup_ctrl;
142141
nvme_lookup_host;
143142
nvme_lookup_key;

libnvme/src/nvme/ioctl.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -771,17 +771,3 @@ int nvme_copy(struct nvme_transport_handle *hdl, struct nvme_copy_args *args)
771771

772772
return nvme_submit_io_passthru(hdl, &cmd, args->result);
773773
}
774-
775-
int nvme_lm_get_features_ctrl_data_queue(struct nvme_transport_handle *hdl, __u16 cdqid,
776-
struct nvme_lm_ctrl_data_queue_fid_data *data,
777-
__u32 *result)
778-
{
779-
struct nvme_passthru_cmd cmd;
780-
781-
nvme_init_get_features(&cmd, NVME_FEAT_FID_CTRL_DATA_QUEUE, 0);
782-
cmd.cdw11 = cdqid;
783-
cmd.data_len = sizeof(*data);
784-
cmd.addr = (__u64)(uintptr_t)data;
785-
786-
return nvme_submit_admin_passthru(hdl, &cmd, result);
787-
}

libnvme/src/nvme/ioctl.h

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5332,18 +5332,27 @@ nvme_init_lm_set_features_ctrl_data_queue(struct nvme_passthru_cmd *cmd,
53325332
}
53335333

53345334
/**
5335-
* nvme_lm_get_features_ctrl_data_queue - Get Controller Data Queue feature
5336-
* @hdl: Transport handle
5335+
* nvme_init_lm_get_features_ctrl_data_queue() - Initialize passthru command for
5336+
* Get Controller Data Queue feature
5337+
* @cmd: Passthru command to use
5338+
* @sel: Select which type of attribute to return,
5339+
* see &enum nvme_get_features_sel
53375340
* @cdqid: Controller Data Queue ID (CDQID)
5338-
* @data: Get Controller Data Queue feature data
5339-
* @result: The command completions result from CQE dword0
5341+
* @qfd: Get Controller Data Queue feature data buffer
53405342
*
5341-
* Return: 0 on success, the nvme command status if a response was
5342-
* received (see &enum nvme_status_field) or a negative error otherwise.
5343+
* Initializes the passthru command buffer for the Get Features command with
5344+
* FID value %NVME_FEAT_FID_CTRL_DATA_QUEUE.
53435345
*/
5344-
int nvme_lm_get_features_ctrl_data_queue(struct nvme_transport_handle *hdl, __u16 cdqid,
5345-
struct nvme_lm_ctrl_data_queue_fid_data *data,
5346-
__u32 *result);
5346+
static inline void
5347+
nvme_init_lm_get_features_ctrl_data_queue(struct nvme_passthru_cmd *cmd,
5348+
enum nvme_get_features_sel sel, __u16 cdqid,
5349+
struct nvme_lm_ctrl_data_queue_fid_data *qfd)
5350+
{
5351+
nvme_init_get_features(cmd, NVME_FEAT_FID_CTRL_DATA_QUEUE, sel);
5352+
cmd->data_len = sizeof(*qfd);
5353+
cmd->addr = (__u64)(uintptr_t)qfd;
5354+
cmd->cdw11 = cdqid;
5355+
}
53475356

53485357
/**
53495358
* nvme_identify() - Submit a generic Identify command

libnvme/test/ioctl/features.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,19 +1594,21 @@ static void test_lm_get_features_ctrl_data_queue(void)
15941594
struct mock_cmd mock_admin_cmd = {
15951595
.opcode = nvme_admin_get_features,
15961596
.nsid = NVME_NSID_NONE,
1597-
.cdw10 = NVME_FEAT_FID_CTRL_DATA_QUEUE,
1597+
.cdw10 = TEST_SEL << 8 | NVME_FEAT_FID_CTRL_DATA_QUEUE,
15981598
.cdw11 = TEST_CDQID,
15991599
.data_len = sizeof(expected_data),
16001600
.out_data = &expected_data,
16011601
.result = TEST_RESULT,
16021602
};
1603+
struct nvme_passthru_cmd cmd;
16031604
uint32_t result = 0;
16041605
int err;
16051606

16061607
arbitrary(&expected_data, sizeof(expected_data));
16071608
set_mock_admin_cmds(&mock_admin_cmd, 1);
1608-
err = nvme_lm_get_features_ctrl_data_queue(test_hdl, TEST_CDQID, &data,
1609-
&result);
1609+
nvme_init_lm_get_features_ctrl_data_queue(&cmd, TEST_SEL,
1610+
TEST_CDQID, &data);
1611+
err = nvme_submit_admin_passthru(test_hdl, &cmd, &result);
16101612
end_mock_cmds();
16111613
check(err == 0, "get features returned error %d, errno %m", err);
16121614
check(result == TEST_RESULT,

0 commit comments

Comments
 (0)