Skip to content

Commit

Permalink
nvme: Live Migration plugin
Browse files Browse the repository at this point in the history
Implementation of TP 4159 PCIe Infrastructure for Live Migration plugin.
Includes command support for Track Send, Migration Receive, Migration
Send, and Controller Data Queue; Identify Controller LM related fields;
Bash and ZSH completions.

Changes are isolated to the User Data Migration subset, with Track
Memory functionality deferred to a future commit.

Signed-off-by: Nate Thornton <[email protected]>
  • Loading branch information
NateThornton committed Nov 8, 2024
1 parent 1425179 commit 3ece45c
Show file tree
Hide file tree
Showing 7 changed files with 1,219 additions and 4 deletions.
130 changes: 129 additions & 1 deletion completions/_nvme
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ _nvme () {
'solidigm:Solidigm plug-in extensions'
'micron:Micron plug-in extensions'
'dapustor:DapuStor plug-in extensions'
'lm:Live Migration plug-in extensions'
'help:print brief descriptions of all nvme commands'
'json:dump output in json format'
)
Expand Down Expand Up @@ -617,6 +618,118 @@ _nvme () {
;;
esac
;;
(lm)
case ${words[2]} in
(create-cdq)
local _create_cdq
_create_cdq=(
--cntlid':controller id'
-c':alias for --cntlid'
--size':size of cdq in dwords'
-s':alias for --size'
--queue-type':queue type'
-q':alias for --queue-type'
--consent':(optional) consent to this not working as desired'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme lm create-cdq options" _create_cdq
;;
(delete-cdq)
local _delete_cdq
_delete_cdq=(
--cdqid=':controller data queue id'
-C':alias for --cdqid'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme lm delete-cdq options" _delete_cdq
;;
(track-send)
local _track_send
_track_send=(
--cdqid=':controller data queue id'
-C':alias for --cdqid'
--select':select'
-s':alias for --select'
--mos':management operation'
-m':alias for --mos'
--start':(optional) start logging'
--stop':(optional) stop logging'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme lm track-send options" _track_send
;;
(migration-send)
local _migration_send
_migration_send=(
--cntlid=':controller id'
-c':alias for --cntlid'
--select=':select'
-s':alias for --select'
--suspend-type=':suspend type'
-t':alias for --suspend-type'
--delete=':(optional) delete cdq'
--seq-ind=':(optional) sequence index'
-S':alias for --seq-ind'
--uuid-index=':(optional) uuid index'
-U':alias for --uuid-index'
--version-index=':(optional) version index'
-V':alias for --version-index'
--offset=':(optional) offset'
-O':alias for --offset'
--numd=':number of dwords'
-n':alias for --numd'
--input-file=':input file'
-f':alias for --input-file'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme lm migration-send options" _migration_send
;;
(migration-recv)
local _migration_recv
_migration_recv=(
--cntlid=':controller id'
-c':alias for --cntlid'
--uuid-index=':(optional) uuid index'
-U':alias for --uuid-index'
--version-index=':(optional) version index'
-V':alias for --version-index'
--offset=':(optional) offset'
-o':alias for --offset'
--numd=':number of dwords'
-n':alias for --numd'
--output-file=':output file'
-f':alias for --output-file'
--human-readable=':show infos in human readable format'
-H':alias of --human-readable'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme lm migration-recv options" _migration_recv
;;
(set-cdq)
local _set_cdq
_set_cdq=(
--cdqid=':controller data queue id'
--hp=':head pointer'
-H':alias for --hp'
--tp=':(optional) tail pointer'
-T':alias for --tp'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme lm set-cdq options" _set_cdq
;;
(get-cdq)
local _get_cdq
_get_cqq=(
--cdqid=':controller data queue id'
-C':alias for --cdqid'
--output-format=':output format'
-o':alias for --output-format'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme get-cdq options" _get_cdq
;;
esac
;;
(sanitize)
case ${words[CURRENT-1]} in
(--sanact=|-a)
Expand Down Expand Up @@ -2705,6 +2818,21 @@ _nvme () {
_arguments '*:: :->subcmds'
_describe -t commands "nvme dapustor options" _dapustor
;;
(lm)
local _lm
_lm=(
create-cdq':Create Controller Data Queue'
delete-cdq':Delete Controller Data Queue'
track-send':Track Send'
migration-recv':Migration Receive'
migration-send':Migration Send'
get-cdq':Get Controller Data Queue Feature'
set-cdq':Set Controller Data Queue Feature'
version':Shows the program version'
help':Display this help'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme lm options" _lm
(help)
local _h
_h=( id-ctrl id-ns list-ns id-iocs create-ns delete-ns attach-ns detach-ns
Expand All @@ -2722,7 +2850,7 @@ _nvme () {
get-property write-zeroes write-uncor verify sanitize sanitize-log reset
subsystem-reset ns-rescan get-lba-status dsm discover connect-all connect
dim disconnect disconnect-all gen-hostnqn show-hostnqn tls-key dir-receive
dir-send virt-mgmt rpmb version ocp solidigm dapustor
dir-send virt-mgmt rpmb version ocp solidigm dapustor lm
)
_arguments '*:: :->subcmds'
_describe -t commands "help: infos on a specific nvme command, or provide no option to see a synopsis of all nvme commands" _h
Expand Down
59 changes: 59 additions & 0 deletions completions/bash-nvme-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,62 @@ plugin_ocp_opts () {
return 0
}

plugin_lm_opts() {
local opts=""
local compargs=""

local nonopt_args=0
for (( i=0; i < ${#words[@]}-1; i++ )); do
if [[ ${words[i]} != -* ]]; then
let nonopt_args+=1
fi
done

if [ $nonopt_args -eq 3 ]; then
opts="/dev/nvme* "
fi

opts+=" "

case "$1" in
"create-cdq")
opts+=" --cntlid= -c --size= -s --queue-type= -q \
--consent"
;;
"delete-cdq")
opts+=" --cdqid= -C"
;;
"track-send")
opts+=" --cdqid= -C --select= -s --mos= -m \
--start --stop"
;;
"migration-send")
opts+=" --cntlid= -c --select= -s -suspend-type= -t \
--delete --seq-ind= -S --uuid-index= -U \
--version-index= -V --offset= -o --numd= -n \
--input-file -f"
;;
"migration-recv")
opts+=" --cntlid= -c --uuid-index= -U --version-index= -V \
--offset= -o --numd= -n --output-file= \
--human-readable -H"
;;
"set-cdq")
opts+=" --cdqid= -C --hp= -H --tp= -T"
;;
"get-cq")
opts+=" --cdqid= -C --output-format= -o"
;;
"help")
opts+=$NO_OPTS
;;
esac

COMPREPLY+=( $( compgen $compargs -W "$opts" -- $cur ) )

return 0
}

_nvme_subcmds () {
local cur prev words cword
_init_completion || return
Expand Down Expand Up @@ -1616,6 +1672,8 @@ _nvme_subcmds () {
set-dssd-async-event-config get-dssd-async-event-config \
get-error-injection set-error-injection \
hardware-component-log"
[lm]="create-cdq delete-cdq track-send migration-recv migration-send \
set-cdq get-cq"
)

# Associative array mapping plugins to corresponding option completions
Expand All @@ -1640,6 +1698,7 @@ _nvme_subcmds () {
[ymtc]="plugin_ymtc_opts"
[inspur]="plugin_inspur_opts"
[ocp]="plugin_ocp_opts"
[lm]="plugin_lm_opts"
)

# Top level commands
Expand Down
10 changes: 10 additions & 0 deletions nvme-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,16 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
obj_add_uint(r, "maxcna", le32_to_cpu(ctrl->maxcna));
obj_add_uint(r, "oaqd", le32_to_cpu(ctrl->oaqd));

obj_add_uint(r, "cmmrtd", le16_to_cpu(ctrl->cmmrtd));
obj_add_uint(r, "nmmrtd", le16_to_cpu(ctrl->nmmrtd));
obj_add_uint(r, "minmrtg", ctrl->minmrtg);
obj_add_uint(r, "maxmrtg", ctrl->maxmrtg);
obj_add_uint(r, "trattr", ctrl->trattr);
obj_add_uint(r, "mcumq", le16_to_cpu(ctrl->mcudmq));
obj_add_uint(r, "mcmr", le16_to_cpu(ctrl->mcmr));
obj_add_uint(r, "nmcmr", le16_to_cpu(ctrl->nmcmr));
obj_add_uint(r, "mcdqpc", le16_to_cpu(ctrl->mcdqpc));

if (strlen(subnqn))
obj_add_str(r, "subnqn", subnqn);

Expand Down
9 changes: 6 additions & 3 deletions nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1871,8 +1871,9 @@ static void stdout_id_ctrl_mec(__u8 mec)
static void stdout_id_ctrl_oacs(__le16 ctrl_oacs)
{
__u16 oacs = le16_to_cpu(ctrl_oacs);
__u16 rsvd = (oacs & 0xF800) >> 11;
__u16 lock = (oacs >> 10) & 0x1;
__u16 rsvd = (oacs & 0xF000) >> 12;
__u16 hmlms = (oacs & 0x800) >> 11;
__u16 lock = (oacs & 0x400) >> 10;
__u16 glbas = (oacs & 0x200) >> 9;
__u16 dbc = (oacs & 0x100) >> 8;
__u16 vir = (oacs & 0x80) >> 7;
Expand All @@ -1885,7 +1886,9 @@ static void stdout_id_ctrl_oacs(__le16 ctrl_oacs)
__u16 sec = oacs & 0x1;

if (rsvd)
printf(" [15:11] : %#x\tReserved\n", rsvd);
printf(" [15:12] : %#x\tReserved\n", rsvd);
printf(" [11:11] : %#x\tHost Managed Live Migration %sSupported\n",
hmlms, hmlms ? "" : "Not ");
printf(" [10:10] : %#x\tLockdown Command and Feature %sSupported\n",
lock, lock ? "" : "Not ");
printf(" [9:9] : %#x\tGet LBA Status Capability %sSupported\n",
Expand Down
Loading

0 comments on commit 3ece45c

Please sign in to comment.