Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions Documentation/nvme-fw-commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ OPTIONS
[]
|=================
|Value|Definition
|0|Downloaded image replaces the image indicated by the Firmware Slot
field. This image is not activated.
|1|Downloaded image replaces the image indicated by the Firmware Slot
field. This image is activated at the next reset.
|2|The image indicated by the Firmware Slot field is activated at the
|0 \| 'replace'| Downloaded image replaces the image indicated by the
Firmware Slot field. This image is not activated.
|1 \| 'replace-and-activate'| Downloaded image replaces the image
indicated by the Firmware Slot field. This image is activated at the
next reset.
|3|The image specified by the Firmware Slot field is requested to be
activated immediately without reset.
|6|Downloaded image replaces the Boot Partition specified by the Boot Partition
ID field.
|7|Mark the Boot Partition specified in the BPID field as active and update
BPINFO.ABPID.
|2 \| 'set-active'| The image indicated by the Firmware Slot field is
activated at the next reset.
|3 \| 'replace-and-activate-immediate'| The image specified by the
Firmware Slot field is requested to be activated immediately without
reset.
|6 \| 'replace-boot-partition'| Downloaded image replaces the Boot
Partition specified by the Boot Partition ID field.
|7 \| 'activate-boot-partition'| Mark the Boot Partition specified in
the BPID field as active and update BPINFO.ABPID.
|=================

-s <slot>::
Expand Down
10 changes: 10 additions & 0 deletions completions/_nvme
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,16 @@ _nvme () {
;;
esac
;;
(fw-commit)
case ${words[CURRENT-1]} in
(--action=|-a)
_values '' 'replace' 'replace-and-activate' 'set-active' 'replace-and-activate-immediate' 'replace-boot-partition' 'activate-boot-partition'
;;
(*)
_files
;;
esac
;;
(*)
_files
;;
Expand Down
7 changes: 7 additions & 0 deletions completions/bash-nvme-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ nvme_list_opts () {
;;
"fw-commit")
opts+=" --slot= -s --action= -a --bpid= -b --timeout= -t"
case $opt in
--action|-a)
vals+=" replace replace-and-activate set-active \
replace-and-activate-immediate
replace-boot-partition activate-boot-partition"
;;
esac
;;
"fw-download")
opts+=" --fw= -f --xfer= -x --offset= -O --timeout= -t"
Expand Down
33 changes: 30 additions & 3 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -5269,7 +5269,11 @@
"with an 'echo 1 > /sys/class/nvme/nvmeX/reset_controller'. "
"Ensure nvmeX is the device you just activated before reset.";
const char *slot = "[0-7]: firmware slot for commit action";
const char *action = "[0-7]: commit action";
const char *action = "[0-7]: commit action: 0 = replace, "
"1 = replace and activate, 2 = set active, "

Check failure on line 5273 in nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: quoted string split across lines
"3 = replace and activate immediate, "

Check failure on line 5274 in nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: quoted string split across lines
"6 = replace boot partition, "

Check failure on line 5275 in nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: quoted string split across lines
"7 = activate boot partition";

Check failure on line 5276 in nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: quoted string split across lines
const char *bpid = "[0,1]: boot partition identifier, if applicable (default: 0)";

_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
Expand All @@ -5290,9 +5294,23 @@
.bpid = 0,
};

OPT_VALS(ca) = {
VAL_BYTE("replace", NVME_FW_COMMIT_CA_REPLACE),
VAL_BYTE("replace-and-activate",
NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE),
VAL_BYTE("set-active", NVME_FW_COMMIT_CA_SET_ACTIVE),
VAL_BYTE("replace-and-activate-immediate",
NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE_IMMEDIATE),
VAL_BYTE("replace-boot-partition",
NVME_FW_COMMIT_CA_REPLACE_BOOT_PARTITION),
VAL_BYTE("activate-boot-partition",
NVME_FW_COMMIT_CA_ACTIVATE_BOOT_PARTITION),
VAL_END()
};

NVME_ARGS(opts,
OPT_BYTE("slot", 's', &cfg.slot, slot),
OPT_BYTE("action", 'a', &cfg.action, action),
OPT_BYTE("action", 'a', &cfg.action, action, ca),
OPT_BYTE("bpid", 'b', &cfg.bpid, bpid));

err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
Expand All @@ -5309,10 +5327,19 @@
nvme_show_error("invalid slot:%d", cfg.slot);
return -EINVAL;
}
if (cfg.action > 7 || cfg.action == 4 || cfg.action == 5) {

switch (cfg.action) {
case NVME_FW_COMMIT_CA_REPLACE:
case NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE:
case NVME_FW_COMMIT_CA_SET_ACTIVE:
case NVME_FW_COMMIT_CA_REPLACE_BOOT_PARTITION:
case NVME_FW_COMMIT_CA_ACTIVATE_BOOT_PARTITION:
break;
default:
nvme_show_error("invalid action:%d", cfg.action);
return -EINVAL;
}

if (cfg.bpid > 1) {
nvme_show_error("invalid boot partition id:%d", cfg.bpid);
return -EINVAL;
Expand Down
3 changes: 3 additions & 0 deletions util/argconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ argconfig_match_val(struct argconfig_opt_val *v, const char *str)
if (strncasecmp(str, v->str, len))
continue;

if (len == strlen(v->str))
return v;

if (match)
return NULL; /* multiple matches; input is ambiguous */

Expand Down