Skip to content

Commit ab5b923

Browse files
committed
ioctl: rework nvme_lm_track_send 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 2151fdf commit ab5b923

5 files changed

Lines changed: 32 additions & 55 deletions

File tree

libnvme/src/libnvme.map

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ LIBNVME_2_0 {
141141
nvme_lm_migration_recv;
142142
nvme_lm_migration_send;
143143
nvme_lm_set_features_ctrl_data_queue;
144-
nvme_lm_track_send;
145144
nvme_lookup_ctrl;
146145
nvme_lookup_host;
147146
nvme_lookup_key;

libnvme/src/nvme/api-types.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,6 @@ struct nvme_copy_args {
143143
__u64 ilbrt_u64;
144144
};
145145

146-
/**
147-
* struct nvme_lm_track_send_args - Arguments for the Track Send command
148-
* @result: Set on completion to the command's CQE DWORD 0 controller response
149-
* @args_size: Length of structure
150-
* @timeout: Timeout in ms
151-
* @mos: Management Operation Specific (MOS): This field is specific to the SEL type
152-
* @cdqid: Controller Data Queue ID (CDQID)
153-
* @sel: Select (SEL): This field specifies the type of management operation to perform
154-
*/
155-
struct nvme_lm_track_send_args {
156-
__u32 *result;
157-
int args_size;
158-
__u32 timeout;
159-
__u16 mos;
160-
__u16 cdqid;
161-
__u8 sel;
162-
};
163-
164146
/**
165147
* struct nvme_lm_migration_send_args - Arguments for the Migration Send command
166148
* @offset: Offset: This field specifies the offset, in bytes, within the data available to be

libnvme/src/nvme/ioctl.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -772,24 +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_track_send(struct nvme_transport_handle *hdl, struct nvme_lm_track_send_args *args)
776-
{
777-
__u32 cdw10 = NVME_SET(args->sel, LM_TRACK_SEND_SEL) |
778-
NVME_SET(args->mos, LM_TRACK_SEND_MOS);
779-
780-
struct nvme_passthru_cmd cmd = {
781-
.opcode = nvme_admin_track_send,
782-
.cdw10 = cdw10,
783-
.cdw11 = args->cdqid,
784-
.timeout_ms = args->timeout,
785-
};
786-
787-
if (args->args_size < sizeof(*args))
788-
return -EINVAL;
789-
790-
return nvme_submit_admin_passthru(hdl, &cmd, args->result);
791-
}
792-
793775
int nvme_lm_migration_send(struct nvme_transport_handle *hdl, struct nvme_lm_migration_send_args *args)
794776
{
795777
__u32 cdw10 = NVME_SET(args->sel, LM_MIGRATION_SEND_SEL) |

libnvme/src/nvme/ioctl.h

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5138,14 +5138,32 @@ nvme_init_lm_cdq_delete(struct nvme_passthru_cmd *cmd,
51385138
}
51395139

51405140
/**
5141-
* nvme_lm_track_send() - Track Send command
5142-
* @hdl: Transport handle
5143-
* @args: &struct nvme_lm_track_send_args argument structure
5141+
* nvme_init_lm_track_send() - Initialize passthru command for
5142+
* Track Send command
5143+
* @cmd: Passthru command to use
5144+
* @sel: Select (SEL): This field specifies the type of
5145+
* management operation to perform
5146+
* @mos: Management Operation Specific (MOS): This field
5147+
* is specific to the SEL type
5148+
* @cdqid: Controller Data Queue ID (CDQID)
51445149
*
5145-
* Return: 0 on success, the nvme command status if a response was
5146-
* received (see &enum nvme_status_field) or a negative error otherwise.
5150+
* Initializes the passthru command buffer for the Track Send command.
51475151
*/
5148-
int nvme_lm_track_send(struct nvme_transport_handle *hdl, struct nvme_lm_track_send_args *args);
5152+
static inline void
5153+
nvme_init_lm_track_send(struct nvme_passthru_cmd *cmd,
5154+
__u8 sel, __u16 mos, __u16 cdqid)
5155+
{
5156+
5157+
memset(cmd, 0, sizeof(*cmd));
5158+
cmd->opcode = nvme_admin_track_send;
5159+
cmd->cdw10 = NVME_FIELD_ENCODE(sel,
5160+
NVME_LM_TRACK_SEND_SEL_SHIFT,
5161+
NVME_LM_TRACK_SEND_SEL_MASK) |
5162+
NVME_FIELD_ENCODE(mos,
5163+
NVME_LM_TRACK_SEND_MOS_SHIFT,
5164+
NVME_LM_TRACK_SEND_MOS_MASK);
5165+
cmd->cdw11 = cdqid;
5166+
}
51495167

51505168
/**
51515169
* nvme_lm_migration_send() - Migration Send command

libnvme/test/ioctl/misc.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,25 +1377,21 @@ static void test_lm_cdq_delete(void)
13771377

13781378
static void test_lm_track_send(void)
13791379
{
1380+
__u8 sel = NVME_LM_SEL_DELETE_CDQ;
1381+
__u16 cdqid = 0x3;
13801382
__u32 result = 0;
1381-
struct nvme_lm_track_send_args args = {
1382-
.result = 0,
1383-
.args_size = sizeof(args),
1384-
.mos = 0x1,
1385-
.cdqid = 0x3,
1386-
.sel = NVME_LM_SEL_DELETE_CDQ,
1387-
};
1388-
1383+
__u16 mos = 0x1;
13891384
struct mock_cmd mock_admin_cmd = {
13901385
.opcode = nvme_admin_track_send,
1391-
.cdw10 = args.sel | (args.mos << 16),
1392-
.cdw11 = args.cdqid,
1386+
.cdw10 = sel | (mos << 16),
1387+
.cdw11 = cdqid,
13931388
};
1394-
1389+
struct nvme_passthru_cmd cmd;
13951390
int err;
13961391

13971392
set_mock_admin_cmds(&mock_admin_cmd, 1);
1398-
err = nvme_lm_track_send(test_hdl, &args);
1393+
nvme_init_lm_track_send(&cmd, sel, mos, cdqid);
1394+
err = nvme_submit_admin_passthru(test_hdl, &cmd, &result);
13991395
end_mock_cmds();
14001396
check(err == 0, "returned error %d", err);
14011397
check(result == 0, "returned result %u", result);

0 commit comments

Comments
 (0)