Skip to content

Commit dade0e6

Browse files
committed
ioctl: rework nvme_lm_set_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 59fc85f commit dade0e6

4 files changed

Lines changed: 23 additions & 25 deletions

File tree

libnvme/src/libnvme.map

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ LIBNVME_2_0 {
138138
nvme_io_passthru;
139139
nvme_ipaddrs_eq;
140140
nvme_lm_get_features_ctrl_data_queue;
141-
nvme_lm_set_features_ctrl_data_queue;
142141
nvme_lookup_ctrl;
143142
nvme_lookup_host;
144143
nvme_lookup_key;

libnvme/src/nvme/ioctl.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -772,19 +772,6 @@ int nvme_copy(struct nvme_transport_handle *hdl, struct nvme_copy_args *args)
772772
return nvme_submit_io_passthru(hdl, &cmd, args->result);
773773
}
774774

775-
int nvme_lm_set_features_ctrl_data_queue(struct nvme_transport_handle *hdl, __u16 cdqid, __u32 hp, __u32 tpt, bool etpt,
776-
__u32 *result)
777-
{
778-
struct nvme_passthru_cmd cmd;
779-
780-
nvme_init_set_features(&cmd, NVME_FEAT_FID_CTRL_DATA_QUEUE, false);
781-
cmd.cdw11 = cdqid | NVME_SET(etpt, LM_CTRL_DATA_QUEUE_ETPT);
782-
cmd.cdw12 = hp;
783-
cmd.cdw13 = tpt;
784-
785-
return nvme_submit_admin_passthru(hdl, &cmd, result);
786-
}
787-
788775
int nvme_lm_get_features_ctrl_data_queue(struct nvme_transport_handle *hdl, __u16 cdqid,
789776
struct nvme_lm_ctrl_data_queue_fid_data *data,
790777
__u32 *result)

libnvme/src/nvme/ioctl.h

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5307,19 +5307,29 @@ nvme_init_lm_migration_recv(struct nvme_passthru_cmd *cmd,
53075307
}
53085308

53095309
/**
5310-
* nvme_lm_set_features_ctrl_data_queue - Set Controller Datea Queue feature
5311-
* @hdl: Transport handle
5310+
* nvme_init_lm_set_features_ctrl_data_queue() - Initialize passthru command for
5311+
* Set Controller Data Queue feature
5312+
* @cmd: Passthru command to use
53125313
* @cdqid: Controller Data Queue ID (CDQID)
5313-
* @hp: Head Pointer
5314-
* @tpt: Tail Pointer Trigger
5314+
* @hp: Head Pointer (passed in cdw12)
5315+
* @tpt: Tail Pointer Trigger (passed in cdw13)
53155316
* @etpt: Enable Tail Pointer Trigger
5316-
* @result: The command completions result from CQE dword0
53175317
*
5318-
* Return: 0 on success, the nvme command status if a response was
5319-
* received (see &enum nvme_status_field) or a negative error otherwise.
5318+
* Initializes the passthru command buffer for the Set Features command with
5319+
* FID value %NVME_FEAT_FID_CTRL_DATA_QUEUE.
53205320
*/
5321-
int nvme_lm_set_features_ctrl_data_queue(struct nvme_transport_handle *hdl, __u16 cdqid, __u32 hp, __u32 tpt, bool etpt,
5322-
__u32 *result);
5321+
static inline void
5322+
nvme_init_lm_set_features_ctrl_data_queue(struct nvme_passthru_cmd *cmd,
5323+
__u16 cdqid, __u32 hp, __u32 tpt, bool etpt)
5324+
{
5325+
nvme_init_set_features(cmd, NVME_FEAT_FID_CTRL_DATA_QUEUE, false);
5326+
cmd->cdw11 = cdqid |
5327+
NVME_FIELD_ENCODE(etpt,
5328+
NVME_LM_CTRL_DATA_QUEUE_ETPT_SHIFT,
5329+
NVME_LM_CTRL_DATA_QUEUE_ETPT_MASK);
5330+
cmd->cdw12 = hp;
5331+
cmd->cdw13 = tpt;
5332+
}
53235333

53245334
/**
53255335
* nvme_lm_get_features_ctrl_data_queue - Get Controller Data Queue feature

libnvme/test/ioctl/features.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,12 +1574,14 @@ static void test_lm_set_features_ctrl_data_queue(void)
15741574
.cdw13 = tpt,
15751575
.result = TEST_RESULT,
15761576
};
1577+
struct nvme_passthru_cmd cmd;
15771578
uint32_t result = 0;
15781579
int err;
15791580

15801581
set_mock_admin_cmds(&mock_admin_cmd, 1);
1581-
err = nvme_lm_set_features_ctrl_data_queue(test_hdl,
1582-
TEST_CDQID, hp, tpt, etpt, &result);
1582+
nvme_init_lm_set_features_ctrl_data_queue(&cmd, TEST_CDQID,
1583+
hp, tpt, etpt);
1584+
err = nvme_submit_admin_passthru(test_hdl, &cmd, &result);
15831585
end_mock_cmds();
15841586
check(err == 0, "set features returned error %d, errno %m", err);
15851587
check(result == TEST_RESULT,

0 commit comments

Comments
 (0)