Skip to content

Commit a71ec94

Browse files
ikegami-tigaw
authored andcommitted
ioctl: nvme_dim_send use nvme_passthru_cmd directly
Drop struct nvme_dim_args. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent dd099d4 commit a71ec94

File tree

6 files changed

+25
-63
lines changed

6 files changed

+25
-63
lines changed

src/libnvme.map

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ LIBNVME_2_0 {
6161
nvme_default_host;
6262
nvme_describe_key_serial;
6363
nvme_dev_self_test;
64-
nvme_dim_send;
6564
nvme_directive_recv;
6665
nvme_directive_send;
6766
nvme_directive_send_id_endir;

src/nvme/api-types.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -318,24 +318,6 @@ struct nvme_virtual_mgmt_args {
318318
__u16 nr;
319319
};
320320

321-
/**
322-
* struct nvme_dim_args - Arguments for the Discovery Information Management (DIM) command
323-
* @result: Set on completion to the command's CQE DWORD 0 controller response.
324-
* @data: Pointer to the DIM data
325-
* @args_size: Length of the structure
326-
* @timeout: Timeout in ms
327-
* @data_len: Length of @data
328-
* @tas: Task field of the Command Dword 10 (cdw10)
329-
*/
330-
struct nvme_dim_args {
331-
__u32 *result;
332-
void *data;
333-
int args_size;
334-
__u32 timeout;
335-
__u32 data_len;
336-
__u8 tas;
337-
};
338-
339321
/**
340322
* struct nvme_lm_cdq_args - Arguments for Controller Data Queue (CDQ) command
341323
* @result: Set on completion to the command's CQE DWORD 0 controller response

src/nvme/fabrics.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,13 +1601,6 @@ static int nvmf_dim(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype,
16011601
__u32 tel;
16021602
int ret;
16031603

1604-
struct nvme_dim_args args = {
1605-
.args_size = sizeof(args),
1606-
.result = result,
1607-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1608-
.tas = tas
1609-
};
1610-
16111604
if (!c->s) {
16121605
nvme_msg(r, LOG_ERR,
16131606
"%s: failed to perform DIM. subsystem undefined.\n",
@@ -1673,9 +1666,7 @@ static int nvmf_dim(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype,
16731666
die = &dim->die->extended;
16741667
nvmf_fill_die(die, c->s->h, tel, trtype, adrfam, reg_addr, tsas);
16751668

1676-
args.data_len = tdl;
1677-
args.data = dim;
1678-
return nvme_dim_send(nvme_ctrl_get_link(c), &args);
1669+
return nvme_dim_send(nvme_ctrl_get_link(c), tas, dim, tdl, result);
16791670
}
16801671

16811672
/**

src/nvme/ioctl.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,25 +1344,6 @@ int nvme_io_passthru(nvme_link_t l, __u8 opcode, __u8 flags, __u16 rsvd,
13441344
timeout_ms, result);
13451345
}
13461346

1347-
int nvme_dim_send(nvme_link_t l, struct nvme_dim_args *args)
1348-
{
1349-
__u32 cdw10 = NVME_SET(args->tas, DIM_TAS);
1350-
1351-
struct nvme_passthru_cmd cmd = {
1352-
.opcode = nvme_admin_discovery_info_mgmt,
1353-
.cdw10 = cdw10,
1354-
.addr = (__u64)(uintptr_t)args->data,
1355-
.data_len = args->data_len,
1356-
.timeout_ms = args->timeout,
1357-
};
1358-
1359-
if (args->args_size < sizeof(*args))
1360-
return -EINVAL;
1361-
1362-
return nvme_submit_admin_passthru(l, &cmd, args->result);
1363-
}
1364-
1365-
13661347
int nvme_lm_cdq(nvme_link_t l, struct nvme_lm_cdq_args *args)
13671348
{
13681349
const size_t size_v1 = sizeof_args(struct nvme_lm_cdq_args, sz_u8, __u64);

src/nvme/ioctl.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4959,12 +4959,27 @@ static inline int nvme_zns_append(nvme_link_t l, __u32 nsid, __u64 zslba, __u16
49594959
/**
49604960
* nvme_dim_send - Send a Discovery Information Management (DIM) command
49614961
* @l: Link handle
4962-
* @args: &struct nvme_dim_args argument structure
4962+
* @tas: Task field of the Command Dword 10 (cdw10)
4963+
* @data: Pointer to the DIM data
4964+
* @data_len: Length of @data
4965+
* @result: Set on completion to the command's CQE DWORD 0 controller response.
49634966
*
49644967
* Return: 0 on success, the nvme command status if a response was
49654968
* received (see &enum nvme_status_field) or a negative error otherwise.
49664969
*/
4967-
int nvme_dim_send(nvme_link_t l, struct nvme_dim_args *args);
4970+
static inline int nvme_dim_send(nvme_link_t l, __u8 tas, void *data, __u32 data_len, __u32 *result)
4971+
{
4972+
__u32 cdw10 = NVME_SET(tas, DIM_TAS);
4973+
4974+
struct nvme_passthru_cmd cmd = {
4975+
.opcode = nvme_admin_discovery_info_mgmt,
4976+
.addr = (__u64)(uintptr_t)data,
4977+
.data_len = data_len,
4978+
.cdw10 = cdw10,
4979+
};
4980+
4981+
return nvme_submit_admin_passthru(l, &cmd, result);
4982+
}
49684983

49694984
/**
49704985
* nvme_lm_cdq() - Controller Data Queue - Controller Data Queue command

test/ioctl/misc.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,29 +1313,23 @@ static void test_fdp_reclaim_unit_handle_update(void)
13131313

13141314
static void test_dim_send(void)
13151315
{
1316-
__u32 result = 0;
13171316
__u8 expected_data[8], data[8] = {};
1318-
struct nvme_dim_args args = {
1319-
.result = 0,
1320-
.data = &data,
1321-
.args_size = sizeof(args),
1322-
.data_len = sizeof(data),
1323-
.tas = 0xf,
1324-
};
1317+
__u32 data_len = sizeof(data);
1318+
__u32 result = 0;
1319+
__u8 tas = 0xf;
1320+
int err;
13251321

13261322
struct mock_cmd mock_admin_cmd = {
13271323
.opcode = nvme_admin_discovery_info_mgmt,
1328-
.cdw10 = args.tas,
1329-
.data_len = args.data_len,
1324+
.cdw10 = tas,
1325+
.data_len = data_len,
13301326
.in_data = &expected_data,
13311327
};
13321328

1333-
int err;
1334-
13351329
arbitrary(&expected_data, sizeof(expected_data));
13361330
memcpy(&data, &expected_data, sizeof(expected_data));
13371331
set_mock_admin_cmds(&mock_admin_cmd, 1);
1338-
err = nvme_dim_send(test_link, &args);
1332+
err = nvme_dim_send(test_link, tas, &data, data_len, NULL);
13391333
end_mock_cmds();
13401334
check(err == 0, "returned error %d", err);
13411335
check(result == 0, "returned result %u", result);

0 commit comments

Comments
 (0)