Skip to content

Commit d7590f2

Browse files
ikegami-tigaw
authored andcommitted
ioctl: nvme_zns_mgmt_recv use nvme_passthru_cmd directly
Drop struct nvme_zns_mgmt_recv_args. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent d6f2a3f commit d7590f2

File tree

5 files changed

+48
-106
lines changed

5 files changed

+48
-106
lines changed

src/libnvme.map

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ LIBNVME_2_0 {
357357
nvme_uuid_to_string;
358358
nvme_virtual_mgmt;
359359
nvme_zns_append;
360-
nvme_zns_mgmt_recv;
361360
nvmf_add_ctrl;
362361
nvmf_adrfam_str;
363362
nvmf_cms_str;

src/nvme/api-types.h

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

321-
/**
322-
* struct nvme_zns_mgmt_recv_args - Arguments for the NVMe ZNS Management Receive command
323-
* @slba: Starting logical block address
324-
* @result: The command completion result from CQE dword0
325-
* @data: Userspace address of the data
326-
* @args_size: Size of &struct nvme_zns_mgmt_recv_args
327-
* @timeout: timeout in ms
328-
* @nsid: Namespace ID
329-
* @zra: zone receive action
330-
* @data_len: Length of @data
331-
* @zrasf: Zone receive action specific field
332-
* @zras_feat: Zone receive action specific features
333-
*/
334-
struct nvme_zns_mgmt_recv_args {
335-
__u64 slba;
336-
__u32 *result;
337-
void *data;
338-
int args_size;
339-
__u32 timeout;
340-
__u32 nsid;
341-
enum nvme_zns_recv_action zra;
342-
__u32 data_len;
343-
__u16 zrasf;
344-
bool zras_feat;
345-
};
346-
347321
/**
348322
* struct nvme_zns_append_args - Arguments for the NVMe ZNS Append command
349323
* @zslba: Zone start logical block address

src/nvme/ioctl.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,33 +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_zns_mgmt_recv(nvme_link_t l, struct nvme_zns_mgmt_recv_args *args)
1348-
{
1349-
__u32 cdw10 = args->slba & 0xffffffff;
1350-
__u32 cdw11 = args->slba >> 32;
1351-
__u32 cdw12 = (args->data_len >> 2) - 1;
1352-
__u32 cdw13 = NVME_SET(args->zra, ZNS_MGMT_RECV_ZRA) |
1353-
NVME_SET(args->zrasf, ZNS_MGMT_RECV_ZRASF) |
1354-
NVME_SET(args->zras_feat, ZNS_MGMT_RECV_ZRAS_FEAT);
1355-
1356-
struct nvme_passthru_cmd cmd = {
1357-
.opcode = nvme_zns_cmd_mgmt_recv,
1358-
.nsid = args->nsid,
1359-
.cdw10 = cdw10,
1360-
.cdw11 = cdw11,
1361-
.cdw12 = cdw12,
1362-
.cdw13 = cdw13,
1363-
.addr = (__u64)(uintptr_t)args->data,
1364-
.data_len = args->data_len,
1365-
.timeout_ms = args->timeout,
1366-
};
1367-
1368-
if (args->args_size < sizeof(*args))
1369-
return -EINVAL;
1370-
1371-
return nvme_submit_io_passthru(l, &cmd, args->result);
1372-
}
1373-
13741347
int nvme_zns_append(nvme_link_t l, struct nvme_zns_append_args *args)
13751348
{
13761349
const size_t size_v1 = sizeof_args(struct nvme_zns_append_args, lbatm, __u64);

src/nvme/ioctl.h

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4847,12 +4847,41 @@ static inline int nvme_zns_mgmt_send(nvme_link_t l, __u32 nsid, __u64 slba,
48474847
/**
48484848
* nvme_zns_mgmt_recv() - ZNS management receive command
48494849
* @l: Link handle
4850-
* @args: &struct nvme_zns_mgmt_recv_args argument structure
4850+
* @nsid: Namespace ID
4851+
* @slba: Starting logical block address
4852+
* @zra: zone receive action
4853+
* @zrasf: Zone receive action specific field
4854+
* @zras_feat: Zone receive action specific features
4855+
* @data: Userspace address of the data
4856+
* @data_len: Length of @data
4857+
* @result: The command completion result from CQE dword0
48514858
*
48524859
* Return: 0 on success, the nvme command status if a response was
48534860
* received (see &enum nvme_status_field) or a negative error otherwise.
48544861
*/
4855-
int nvme_zns_mgmt_recv(nvme_link_t l, struct nvme_zns_mgmt_recv_args *args);
4862+
static inline int nvme_zns_mgmt_recv(nvme_link_t l, __u32 nsid, __u64 slba,
4863+
enum nvme_zns_recv_action zra, __u16 zrasf, bool zras_feat,
4864+
void *data, __u32 data_len, __u32 *result)
4865+
{
4866+
__u32 cdw10 = slba & 0xffffffff;
4867+
__u32 cdw11 = slba >> 32;
4868+
__u32 cdw12 = (data_len >> 2) - 1;
4869+
__u32 cdw13 = NVME_SET(zra, ZNS_MGMT_RECV_ZRA) | NVME_SET(zrasf, ZNS_MGMT_RECV_ZRASF) |
4870+
NVME_SET(zras_feat, ZNS_MGMT_RECV_ZRAS_FEAT);
4871+
4872+
struct nvme_passthru_cmd cmd = {
4873+
.opcode = nvme_zns_cmd_mgmt_recv,
4874+
.nsid = nsid,
4875+
.addr = (__u64)(uintptr_t)data,
4876+
.data_len = data_len,
4877+
.cdw10 = cdw10,
4878+
.cdw11 = cdw11,
4879+
.cdw12 = cdw12,
4880+
.cdw13 = cdw13,
4881+
};
4882+
4883+
return nvme_submit_io_passthru(l, &cmd, result);
4884+
}
48564885

48574886
/**
48584887
* nvme_zns_report_zones() - Return the list of zones
@@ -4864,33 +4893,18 @@ int nvme_zns_mgmt_recv(nvme_link_t l, struct nvme_zns_mgmt_recv_args *args);
48644893
* @partial: Partial report requested
48654894
* @data_len: Length of the data buffer
48664895
* @data: Userspace address of the report zones data
4867-
* @timeout: timeout in ms
48684896
* @result: The command completion result from CQE dword0
48694897
*
48704898
* Return: 0 on success, the nvme command status if a response was
48714899
* received (see &enum nvme_status_field) or a negative error otherwise.
48724900
*/
48734901
static inline int nvme_zns_report_zones(nvme_link_t l, __u32 nsid, __u64 slba,
4874-
enum nvme_zns_report_options opts,
4875-
bool extended, bool partial,
4876-
__u32 data_len, void *data,
4877-
__u32 timeout, __u32 *result)
4902+
enum nvme_zns_report_options opts, bool extended,
4903+
bool partial, __u32 data_len, void *data, __u32 *result)
48784904
{
4879-
struct nvme_zns_mgmt_recv_args args = {
4880-
.slba = slba,
4881-
.result = result,
4882-
.data = data,
4883-
.args_size = sizeof(args),
4884-
.timeout = timeout,
4885-
.nsid = nsid,
4886-
.zra = extended ? NVME_ZNS_ZRA_EXTENDED_REPORT_ZONES :
4887-
NVME_ZNS_ZRA_REPORT_ZONES,
4888-
.data_len = data_len,
4889-
.zrasf = (__u16)opts,
4890-
.zras_feat = partial,
4891-
};
4892-
4893-
return nvme_zns_mgmt_recv(l, &args);
4905+
return nvme_zns_mgmt_recv(l, nsid, slba, extended ? NVME_ZNS_ZRA_EXTENDED_REPORT_ZONES :
4906+
NVME_ZNS_ZRA_REPORT_ZONES, (__u16)opts, partial, data, data_len,
4907+
result);
48944908
}
48954909

48964910
/**

test/ioctl/zns.c

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ static void test_zns_append(void)
5858

5959
static void test_zns_report_zones(void)
6060
{
61+
enum nvme_zns_report_options opts = NVME_ZNS_ZRAS_REPORT_CLOSED;
6162
__u8 expected_data[8], data[8] = {};
62-
__u32 result = 0;
63-
uint32_t timeout = 1234;
6463
bool extended = true;
6564
bool partial = true;
66-
enum nvme_zns_report_options opts = NVME_ZNS_ZRAS_REPORT_CLOSED;
65+
__u32 result = 0;
66+
int err;
6767

6868
struct mock_cmd mock_io_cmd = {
6969
.opcode = nvme_zns_cmd_mgmt_recv,
@@ -75,16 +75,12 @@ static void test_zns_report_zones(void)
7575
(!!partial << 16),
7676
.data_len = sizeof(expected_data),
7777
.out_data = &expected_data,
78-
.timeout_ms = timeout,
7978
};
8079

81-
int err;
82-
8380
arbitrary(&expected_data, sizeof(expected_data));
8481
set_mock_io_cmds(&mock_io_cmd, 1);
85-
err = nvme_zns_report_zones(test_link, TEST_NSID, TEST_SLBA, opts,
86-
extended, partial, sizeof(data), &data,
87-
timeout, &result);
82+
err = nvme_zns_report_zones(test_link, TEST_NSID, TEST_SLBA, opts, extended, partial,
83+
sizeof(data), &data, &result);
8884
end_mock_cmds();
8985
check(err == 0, "returned error %d", err);
9086
check(result == 0, "returned result %u", result);
@@ -123,40 +119,26 @@ static void test_zns_mgmt_send(void)
123119

124120
static void test_zns_mgmt_recv(void)
125121
{
122+
enum nvme_zns_recv_action zra = NVME_ZNS_ZRA_REPORT_ZONES;
126123
__u8 expected_data[8], data[8] = {};
124+
__u16 zrasf = (__u16)NVME_ZNS_ZRAS_REPORT_ALL;
125+
bool zras_feat = false;
127126
__u32 result = 0;
128-
uint32_t timeout = 1234;
129-
bool partial = false;
130-
131-
struct nvme_zns_mgmt_recv_args args = {
132-
.slba = 0,
133-
.result = &result,
134-
.data = data,
135-
.args_size = sizeof(args),
136-
.timeout = timeout,
137-
.nsid = TEST_NSID,
138-
.zra = NVME_ZNS_ZRA_REPORT_ZONES,
139-
.data_len = sizeof(data),
140-
.zrasf = (__u16)NVME_ZNS_ZRAS_REPORT_ALL,
141-
.zras_feat = partial,
142-
};
127+
int err;
143128

144129
struct mock_cmd mock_io_cmd = {
145130
.opcode = nvme_zns_cmd_mgmt_recv,
146131
.nsid = TEST_NSID,
147132
.cdw12 = (sizeof(expected_data) >> 2) - 1,
148-
.cdw13 = (!!args.zra << 0) | ((__u16)args.zrasf << 8) |
149-
(!!args.zras_feat << 16),
133+
.cdw13 = (!!zra << 0) | ((__u16)zrasf << 8) | (!!zras_feat << 16),
150134
.data_len = sizeof(expected_data),
151135
.out_data = &expected_data,
152-
.timeout_ms = timeout,
153136
};
154137

155-
int err;
156-
157138
arbitrary(&expected_data, sizeof(expected_data));
158139
set_mock_io_cmds(&mock_io_cmd, 1);
159-
err = nvme_zns_mgmt_recv(test_link, &args);
140+
err = nvme_zns_mgmt_recv(test_link, TEST_NSID, 0, zra, zrasf, zras_feat, data, sizeof(data),
141+
&result);
160142
end_mock_cmds();
161143
check(err == 0, "returned error %d", err);
162144
check(result == 0, "returned result %u", result);

0 commit comments

Comments
 (0)