Skip to content

Commit c2fd66f

Browse files
committed
nvme: Live Migration plugin
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]>
1 parent cbfd136 commit c2fd66f

File tree

8 files changed

+1129
-5
lines changed

8 files changed

+1129
-5
lines changed

completions/_nvme

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ _nvme () {
114114
'solidigm:Solidigm plug-in extensions'
115115
'micron:Micron plug-in extensions'
116116
'dapustor:DapuStor plug-in extensions'
117+
'lm:Live Migration plug-in extensions'
117118
'help:print brief descriptions of all nvme commands'
118119
'json:dump output in json format'
119120
)
@@ -617,6 +618,118 @@ _nvme () {
617618
;;
618619
esac
619620
;;
621+
(lm)
622+
case ${words[2]} in
623+
(create-cdq)
624+
local _create_cdq
625+
_create_cdq=(
626+
--cntlid':controller id'
627+
-c':alias for --cntlid'
628+
--size':size of cdq in dwords'
629+
-s':alias for --size'
630+
--queue-type':queue type'
631+
-q':alias for --queue-type'
632+
--consent':(optional) consent to this not working as desired'
633+
)
634+
_arguments '*:: :->subcmds'
635+
_describe -t commands "nvme lm create-cdq options" _create_cdq
636+
;;
637+
(delete-cdq)
638+
local _delete_cdq
639+
_delete_cdq=(
640+
--cdqid=':controller data queue id'
641+
-C':alias for --cdqid'
642+
)
643+
_arguments '*:: :->subcmds'
644+
_describe -t commands "nvme lm delete-cdq options" _delete_cdq
645+
;;
646+
(track-send)
647+
local _track_send
648+
_track_send=(
649+
--cdqid=':controller data queue id'
650+
-C':alias for --cdqid'
651+
--select':select'
652+
-s':alias for --select'
653+
--mos':management operation'
654+
-m':alias for --mos'
655+
--start':(optional) start logging'
656+
--stop':(optional) stop logging'
657+
)
658+
_arguments '*:: :->subcmds'
659+
_describe -t commands "nvme lm track-send options" _track_send
660+
;;
661+
(migration-send)
662+
local _migration_send
663+
_migration_send=(
664+
--cntlid=':controller id'
665+
-c':alias for --cntlid'
666+
--select=':select'
667+
-s':alias for --select'
668+
--suspend-type=':suspend type'
669+
-t':alias for --suspend-type'
670+
--delete=':(optional) delete cdq'
671+
--seq-ind=':(optional) sequence index'
672+
-S':alias for --seq-ind'
673+
--uuid-index=':(optional) uuid index'
674+
-U':alias for --uuid-index'
675+
--version-index=':(optional) version index'
676+
-V':alias for --version-index'
677+
--offset=':(optional) offset'
678+
-O':alias for --offset'
679+
--numd=':number of dwords'
680+
-n':alias for --numd'
681+
--input-file=':input file'
682+
-f':alias for --input-file'
683+
)
684+
_arguments '*:: :->subcmds'
685+
_describe -t commands "nvme lm migration-send options" _migration_send
686+
;;
687+
(migration-recv)
688+
local _migration_recv
689+
_migration_recv=(
690+
--cntlid=':controller id'
691+
-c':alias for --cntlid'
692+
--uuid-index=':(optional) uuid index'
693+
-U':alias for --uuid-index'
694+
--version-index=':(optional) version index'
695+
-V':alias for --version-index'
696+
--offset=':(optional) offset'
697+
-o':alias for --offset'
698+
--numd=':number of dwords'
699+
-n':alias for --numd'
700+
--output-file=':output file'
701+
-f':alias for --output-file'
702+
--human-readable=':show infos in human readable format'
703+
-H':alias of --human-readable'
704+
)
705+
_arguments '*:: :->subcmds'
706+
_describe -t commands "nvme lm migration-recv options" _migration_recv
707+
;;
708+
(set-cdq)
709+
local _set_cdq
710+
_set_cdq=(
711+
--cdqid=':controller data queue id'
712+
--hp=':head pointer'
713+
-H':alias for --hp'
714+
--tp=':(optional) tail pointer'
715+
-T':alias for --tp'
716+
)
717+
_arguments '*:: :->subcmds'
718+
_describe -t commands "nvme lm set-cdq options" _set_cdq
719+
;;
720+
(get-cdq)
721+
local _get_cdq
722+
_get_cqq=(
723+
--cdqid=':controller data queue id'
724+
-C':alias for --cdqid'
725+
--output-format=':output format'
726+
-o':alias for --output-format'
727+
)
728+
_arguments '*:: :->subcmds'
729+
_describe -t commands "nvme get-cdq options" _get_cdq
730+
;;
731+
esac
732+
;;
620733
(sanitize)
621734
case ${words[CURRENT-1]} in
622735
(--sanact=|-a)
@@ -2705,6 +2818,21 @@ _nvme () {
27052818
_arguments '*:: :->subcmds'
27062819
_describe -t commands "nvme dapustor options" _dapustor
27072820
;;
2821+
(lm)
2822+
local _lm
2823+
_lm=(
2824+
create-cdq':Create Controller Data Queue'
2825+
delete-cdq':Delete Controller Data Queue'
2826+
track-send':Track Send'
2827+
migration-recv':Migration Receive'
2828+
migration-send':Migration Send'
2829+
get-cdq':Get Controller Data Queue Feature'
2830+
set-cdq':Set Controller Data Queue Feature'
2831+
version':Shows the program version'
2832+
help':Display this help'
2833+
)
2834+
_arguments '*:: :->subcmds'
2835+
_describe -t commands "nvme lm options" _lm
27082836
(help)
27092837
local _h
27102838
_h=( id-ctrl id-ns list-ns id-iocs create-ns delete-ns attach-ns detach-ns
@@ -2722,7 +2850,7 @@ _nvme () {
27222850
get-property write-zeroes write-uncor verify sanitize sanitize-log reset
27232851
subsystem-reset ns-rescan get-lba-status dsm discover connect-all connect
27242852
dim disconnect disconnect-all gen-hostnqn show-hostnqn tls-key dir-receive
2725-
dir-send virt-mgmt rpmb version ocp solidigm dapustor
2853+
dir-send virt-mgmt rpmb version ocp solidigm dapustor lm
27262854
)
27272855
_arguments '*:: :->subcmds'
27282856
_describe -t commands "help: infos on a specific nvme command, or provide no option to see a synopsis of all nvme commands" _h

completions/bash-nvme-completion.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,62 @@ plugin_ocp_opts () {
15451545
return 0
15461546
}
15471547

1548+
plugin_lm_opts() {
1549+
local opts=""
1550+
local compargs=""
1551+
1552+
local nonopt_args=0
1553+
for (( i=0; i < ${#words[@]}-1; i++ )); do
1554+
if [[ ${words[i]} != -* ]]; then
1555+
let nonopt_args+=1
1556+
fi
1557+
done
1558+
1559+
if [ $nonopt_args -eq 3 ]; then
1560+
opts="/dev/nvme* "
1561+
fi
1562+
1563+
opts+=" "
1564+
1565+
case "$1" in
1566+
"create-cdq")
1567+
opts+=" --cntlid= -c --size= -s --queue-type= -q \
1568+
--consent"
1569+
;;
1570+
"delete-cdq")
1571+
opts+=" --cdqid= -C"
1572+
;;
1573+
"track-send")
1574+
opts+=" --cdqid= -C --sel= -s --mos= -m \
1575+
--start --stop"
1576+
;;
1577+
"migration-send")
1578+
opts+=" --cntlid= -c --sel= -s -stype= -t \
1579+
--dudmq --seq-ind= -S --csuuidi= -U \
1580+
--csvi= -V --uidx= -u --offset= -o --numd= -n \
1581+
--input-file -f"
1582+
;;
1583+
"migration-recv")
1584+
opts+=" --cntlid= -c --csuuidi= -U --csvi= -V \
1585+
--offset= -o --numd= -n --output-file= \
1586+
--human-readable -H"
1587+
;;
1588+
"set-cdq")
1589+
opts+=" --cdqid= -C --hp= -H --tpt= -T"
1590+
;;
1591+
"get-cq")
1592+
opts+=" --cdqid= -C --output-format= -o"
1593+
;;
1594+
"help")
1595+
opts+=$NO_OPTS
1596+
;;
1597+
esac
1598+
1599+
COMPREPLY+=( $( compgen $compargs -W "$opts" -- $cur ) )
1600+
1601+
return 0
1602+
}
1603+
15481604
_nvme_subcmds () {
15491605
local cur prev words cword
15501606
_init_completion || return
@@ -1616,6 +1672,8 @@ _nvme_subcmds () {
16161672
set-dssd-async-event-config get-dssd-async-event-config \
16171673
get-error-injection set-error-injection \
16181674
hardware-component-log"
1675+
[lm]="create-cdq delete-cdq track-send migration-recv migration-send \
1676+
set-cdq get-cq"
16191677
)
16201678

16211679
# Associative array mapping plugins to corresponding option completions
@@ -1640,6 +1698,7 @@ _nvme_subcmds () {
16401698
[ymtc]="plugin_ymtc_opts"
16411699
[inspur]="plugin_inspur_opts"
16421700
[ocp]="plugin_ocp_opts"
1701+
[lm]="plugin_lm_opts"
16431702
)
16441703

16451704
# Top level commands

nvme-print-json.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,16 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
434434
obj_add_int(r, "nmcmr", le16_to_cpu(ctrl->nmcmr));
435435
obj_add_int(r, "mcdqpc", le16_to_cpu(ctrl->mcdqpc));
436436

437+
obj_add_uint(r, "cmmrtd", le16_to_cpu(ctrl->cmmrtd));
438+
obj_add_uint(r, "nmmrtd", le16_to_cpu(ctrl->nmmrtd));
439+
obj_add_uint(r, "minmrtg", ctrl->minmrtg);
440+
obj_add_uint(r, "maxmrtg", ctrl->maxmrtg);
441+
obj_add_uint(r, "trattr", ctrl->trattr);
442+
obj_add_uint(r, "mcumq", le16_to_cpu(ctrl->mcudmq));
443+
obj_add_uint(r, "mcmr", le16_to_cpu(ctrl->mcmr));
444+
obj_add_uint(r, "nmcmr", le16_to_cpu(ctrl->nmcmr));
445+
obj_add_uint(r, "mcdqpc", le16_to_cpu(ctrl->mcdqpc));
446+
437447
if (strlen(subnqn))
438448
obj_add_str(r, "subnqn", subnqn);
439449

nvme-print-stdout.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,8 +1933,9 @@ static void stdout_id_ctrl_mec(__u8 mec)
19331933
static void stdout_id_ctrl_oacs(__le16 ctrl_oacs)
19341934
{
19351935
__u16 oacs = le16_to_cpu(ctrl_oacs);
1936-
__u16 rsvd = (oacs & 0xF800) >> 11;
1937-
__u16 lock = (oacs >> 10) & 0x1;
1936+
__u16 rsvd = (oacs & 0xF000) >> 12;
1937+
__u16 hmlms = (oacs & 0x800) >> 11;
1938+
__u16 lock = (oacs & 0x400) >> 10;
19381939
__u16 glbas = (oacs & 0x200) >> 9;
19391940
__u16 dbc = (oacs & 0x100) >> 8;
19401941
__u16 vir = (oacs & 0x80) >> 7;
@@ -1947,7 +1948,9 @@ static void stdout_id_ctrl_oacs(__le16 ctrl_oacs)
19471948
__u16 sec = oacs & 0x1;
19481949

19491950
if (rsvd)
1950-
printf(" [15:11] : %#x\tReserved\n", rsvd);
1951+
printf(" [15:12] : %#x\tReserved\n", rsvd);
1952+
printf(" [11:11] : %#x\tHost Managed Live Migration %sSupported\n",
1953+
hmlms, hmlms ? "" : "Not ");
19511954
printf(" [10:10] : %#x\tLockdown Command and Feature %sSupported\n",
19521955
lock, lock ? "" : "Not ");
19531956
printf(" [9:9] : %#x\tGet LBA Status Capability %sSupported\n",

0 commit comments

Comments
 (0)