Skip to content

Commit 8e376cb

Browse files
hreineckedwsuse
authored andcommitted
Use argument structure for nvme_lockdown()
Use an argument structure instead of passing all arguments one by one. This allows for a future expansion of the argument list without having to change the library ABI. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 353d689 commit 8e376cb

2 files changed

Lines changed: 35 additions & 13 deletions

File tree

src/nvme/ioctl.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,18 +1398,23 @@ int nvme_capacity_mgmt(struct nvme_capacity_mgmt_args *args)
13981398
return nvme_submit_admin_passthru(args->fd, &cmd, args->result);
13991399
}
14001400

1401-
int nvme_lockdown(int fd, __u8 scp, __u8 prhbt, __u8 ifc, __u8 ofi,
1402-
__u8 uuid)
1401+
int nvme_lockdown(struct nvme_lockdown_args *args)
14031402
{
1404-
__u32 cdw10 = ofi << 8 | (ifc & 0x3) << 5 | (prhbt & 0x1) << 4 | (scp & 0xF);
1403+
__u32 cdw10 = args->ofi << 8 |
1404+
(args->ifc & 0x3) << 5 |
1405+
(args->prhbt & 0x1) << 4 |
1406+
(args->scp & 0xF);
14051407

14061408
struct nvme_passthru_cmd cmd = {
14071409
.opcode = nvme_admin_lockdown,
14081410
.cdw10 = cdw10,
1409-
.cdw14 = uuid & 0x3F,
1411+
.cdw14 = args->uuidx & 0x3F,
1412+
.timeout_ms = args->timeout,
14101413
};
14111414

1412-
return nvme_submit_admin_passthru(fd, &cmd, NULL);
1415+
if (args->args_size < sizeof(*args))
1416+
return -EINVAL;
1417+
return nvme_submit_admin_passthru(args->fd, &cmd, args->result);
14131418
}
14141419

14151420
int nvme_set_property(int fd, int offset, __u64 value,

src/nvme/ioctl.h

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3349,19 +3349,36 @@ struct nvme_capacity_mgmt_args {
33493349
int nvme_capacity_mgmt(struct nvme_capacity_mgmt_args *args);
33503350

33513351
/**
3352-
* nvme_lockdown() - Issue lockdown command
3352+
* nvme_lockdown_args - Arguments for the NVME Lockdown command
33533353
* @fd: File descriptor of nvme device
3354-
* @scp:
3355-
* @prhbt:
3356-
* @ifc:
3357-
* @ofi:
3358-
* @uuid:
3354+
* @scp: Scope of the command
3355+
* @prhbt: Prohibit or allow the command opcode or Set Features command
3356+
* @ifc: Affected interface
3357+
* @ofi: Opcode or Feature Identifier
3358+
* @uuid: UUID Index if controller supports this id selection method
3359+
* @timeout: Timeout in ms (0 for default timeout)
3360+
* @result: The command completion result from CQE dword0
3361+
*/
3362+
struct nvme_lockdown_args {
3363+
int args_size;
3364+
int fd;
3365+
__u8 scp;
3366+
__u8 prhbt;
3367+
__u8 ifc;
3368+
__u8 ofi;
3369+
__u8 uuidx;
3370+
__u32 timeout;
3371+
__u32 *result;
3372+
};
3373+
3374+
/**
3375+
* nvme_lockdown() - Issue lockdown command
3376+
* @args: &struct nvme_lockdown_args argument structure
33593377
*
33603378
* Return: The nvme command status if a response was received (see
33613379
* &enum nvme_status_field) or -1 with errno set otherwise.
33623380
*/
3363-
int nvme_lockdown(int fd, __u8 scp, __u8 prhbt, __u8 ifc, __u8 ofi,
3364-
__u8 uuid);
3381+
int nvme_lockdown(struct nvme_lockdown_args *args);
33653382

33663383
/**
33673384
* nvme_set_property() - Set controller property

0 commit comments

Comments
 (0)