Skip to content

Commit 1e95aad

Browse files
committed
nvme: Add support for get-reg and set-reg commands
The get-reg command is to output single register. The set-reg command is to write nvme register. Add below to stop the checkpatch "does MAINTAINERS need updating?" message. MAINTAINERS | Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent 461db32 commit 1e95aad

17 files changed

+1321
-226
lines changed

Documentation/nvme-id-ns-granularity.txt

100755100644
File mode changed.

Documentation/nvme-id-uuid.txt

100755100644
File mode changed.

Documentation/nvme-list-secondary.txt

100755100644
File mode changed.

Documentation/nvme-nvme-mi-recv.txt

100755100644
File mode changed.

Documentation/nvme-nvme-mi-send.txt

100755100644
File mode changed.

Documentation/nvme-set-property.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ OPTIONS
2323
--offset::
2424
The offset of the property.
2525

26-
-V::
27-
--value:
26+
-V <val>::
27+
--value=<val>::
2828
The value of the property to be set.
2929

3030
-o <fmt>::

Documentation/nvme-virt-mgmt.txt

100755100644
File mode changed.

common.h

+21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _COMMON_H
44

55
#include <string.h>
6+
#include <stdbool.h>
67

78
#include "ccan/endian/endian.h"
89

@@ -35,4 +36,24 @@ static inline uint64_t mmio_read64(void *addr)
3536
return ((uint64_t)high << 32) | low;
3637
}
3738

39+
static inline void mmio_write32(void *addr, uint32_t value)
40+
{
41+
leint32_t *p = addr;
42+
43+
*p = cpu_to_le32(value);
44+
}
45+
46+
/* Access 64-bit registers as 2 32-bit if write32 flag set; Some devices fail 64-bit MMIO. */
47+
static inline void mmio_write64(void *addr, uint64_t value, bool write32)
48+
{
49+
uint64_t *p = addr;
50+
51+
if (write32) {
52+
mmio_write32(addr, value);
53+
mmio_write32((uint32_t *)addr + 1, value >> 32);
54+
return;
55+
}
56+
57+
*p = cpu_to_le64(value);
58+
}
3859
#endif

completions/_nvme

+120
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ _nvme () {
104104
'show-topology:show subsystem topology'
105105
'nvme-mi-recv:send a NVMe-MI receive command'
106106
'nvme-mi-send:send a NVMe-MI send command'
107+
'get-reg:read and show the defined NVMe controller register'
108+
'set-seg:write and show the defined NVMe controller register'
107109
'version:show the program version'
108110
'ocp:OCP cloud SSD extensions'
109111
'solidigm:Solidigm plug-in extensions'
@@ -2234,6 +2236,124 @@ _nvme () {
22342236
_arguments '*:: :->subcmds'
22352237
_describe -t commands "nvme nvme-mi-send options" _nvme_mi_send
22362238
;;
2239+
(get-reg)
2240+
local _get_reg
2241+
_get_reg=(
2242+
--offset=':offset of the requested register'
2243+
-O':alias for --offset'
2244+
--human-readable':show register in readable format'
2245+
-H':alias for --human-readable'
2246+
--cap':CAP=0x0 register offset'
2247+
-c':alias for --cap'
2248+
--vs':VS=0x8 register offset'
2249+
-V':alias for --vs'
2250+
--cmbloc':CMBLOC=0x38 register offset'
2251+
-m':alias for --cmbloc'
2252+
--cmbsz':CMBSZ=0x3c register offset'
2253+
-M':alias for --cmbsz'
2254+
--bpinfo':BPINFO=0x40 register offset'
2255+
-b':alias for --bpinfo'
2256+
--cmbsts':CMBSTS=0x58 register offset'
2257+
-S':alias for --cmbsts'
2258+
--cmbebs':CMBEBS=0x5c register offset'
2259+
-E':alias for --cmbebs'
2260+
--cmbswtp':CMBSWTP=0x60 register offset'
2261+
-W':alias for --cmbswtp'
2262+
--crto':CRTO=0x68 register offset'
2263+
-r':alias for --crto'
2264+
--pmrcap':PMRCAP=0xe00 register offset'
2265+
-P':alias for --pmrcap'
2266+
--pmrsts':PMRSTS=0xe08 register offset'
2267+
-t':alias for --pmrsts'
2268+
--pmrebs':PMREBS=0xe0c register offset'
2269+
-e':alias for --pmrebs'
2270+
--pmrswtp':PMRSWTP=0xe10 register offset'
2271+
-w':alias for --pmrswtp'
2272+
--intms':INTMS=0xc register offset'
2273+
-i':alias for --intms'
2274+
--intmc':INTMC=0x10 register offset'
2275+
-I':alias for --intmc'
2276+
--cc':CC=0x14 register offset'
2277+
-C':alias for --cc'
2278+
--csts':CSTS=0x1c register offset'
2279+
-T':alias for --csts'
2280+
--nssr':NSSR=0x20 register offset'
2281+
-n':alias for --nssr'
2282+
--aqa':AQA=0x24 register offset'
2283+
-a':alias for --aqa'
2284+
--asq':ASQ=0x28 register offset'
2285+
-A':alias for --asq'
2286+
--acq':ACQ=0x30 register offset'
2287+
-q':alias for --acq'
2288+
--bprsel':BPRSEL=0x44 register offset'
2289+
-B':alias for --bprsel'
2290+
--bpmbl':BPMBL=0x48 register offset'
2291+
-p':alias for --bpmbl'
2292+
--cmbmsc':CMBMSC=0x50 register offset'
2293+
-s':alias for --cmbmsc'
2294+
--nssd':NSSD=0x64 register offset'
2295+
-N':alias for --nssd'
2296+
--pmrctl':PMRCTL=0xe04 register offset'
2297+
-R':alias for --pmrctl'
2298+
--pmrmscl':PMRMSCL=0xe14 register offset'
2299+
-l':alias for --pmrmscl'
2300+
--pmrmscu':PMRMSCU=0xe18 register offset'
2301+
-u':alias for --pmrmscu'
2302+
--output-format=':Output format: normal|json|binary'
2303+
-o ':alias for --output-format'
2304+
--verbose':Increase the information detail in the output.'
2305+
-v':alias for --verbose'
2306+
)
2307+
_arguments '*:: :->subcmds'
2308+
_describe -t commands "nvme get-reg options" _get_reg
2309+
;;
2310+
(set-reg)
2311+
local _set_reg
2312+
_set_reg=(
2313+
--offset=':offset of the requested register'
2314+
-O':alias for --offset'
2315+
--value=':the value of the register to be set'
2316+
-V':alias for --value'
2317+
--mmio32':Access 64-bit registers as 2 32-bit'
2318+
-M':alias for --mmio32'
2319+
--intms=':INTMS=0xc register offset'
2320+
-i':alias for --intms'
2321+
--intmc=':INTMC=0x10 register offset'
2322+
-I':alias for --intmc'
2323+
--cc=':CC=0x14 register offset'
2324+
-C':alias for --cc'
2325+
--csts=':CSTS=0x1c register offset'
2326+
-T':alias for --csts'
2327+
--nssr=':NSSR=0x20 register offset'
2328+
-n':alias for --nssr'
2329+
--aqa=':AQA=0x24 register offset'
2330+
-a':alias for --aqa'
2331+
--asq=':ASQ=0x28 register offset'
2332+
-A':alias for --asq'
2333+
--acq=':ACQ=0x30 register offset'
2334+
-q':alias for --acq'
2335+
--bprsel=':BPRSEL=0x44 register offset'
2336+
-B':alias for --bprsel'
2337+
--bpmbl=':BPMBL=0x48 register offset'
2338+
-p':alias for --bpmbl'
2339+
--cmbmsc=':CMBMSC=0x50 register offset'
2340+
-s':alias for --cmbmsc'
2341+
--nssd=':NSSD=0x64 register offset'
2342+
-N':alias for --nssd'
2343+
--pmrctl=':PMRCTL=0xe04 register offset'
2344+
-R':alias for --pmrctl'
2345+
--pmrmscl=':PMRMSCL=0xe14 register offset'
2346+
-l':alias for --pmrmscl'
2347+
--pmrmscu=':PMRMSCU=0xe18 register offset'
2348+
-u':alias for --pmrmscu'
2349+
--output-format=':Output format: normal|json|binary'
2350+
-o ':alias for --output-format'
2351+
--verbose':Increase the information detail in the output.'
2352+
-v':alias for --verbose'
2353+
)
2354+
_arguments '*:: :->subcmds'
2355+
_describe -t commands "nvme set-reg options" _set_reg
2356+
;;
22372357
(version)
22382358
local _version
22392359
_version=(

completions/bash-nvme-completion.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,23 @@ nvme_list_opts () {
453453
opts+=" --opcode= -O --namespace-id= -n --data-len= -l \
454454
--nmimt= -m --nmd0= -0 --nmd1= -1 --input-file= -i"
455455
;;
456+
"get-reg")
457+
opts+=" --offset, -O --human-readable -H --cap -c --vs -V \
458+
--cmbloc -m --cmbsz -M --bpinfo -b --cmbsts -S \
459+
--cmbebs -E --cmbswtp -W --crto -r --pmrcap -P \
460+
--pmrsts -t --pmrebs -e --pmrswtp -w --intms -i \
461+
--intmc -I --cc -C --csts -T --nssr -n --aqa -a \
462+
--asq -A --acq -q --bprsel -B --bpmbl -p --cmbmsc -s \
463+
--nssd -N --pmrctl -R --pmrmscl -l --pmrmscu -u \
464+
--output-format -o --verbose -v"
465+
;;
466+
"set-reg")
467+
opts+=" --offset, -O --value= -V --mmio32 -M --intms= -i \
468+
--intmc= -I --cc= -C --csts= -T --nssr= -n --aqa= -a \
469+
--asq= -A --acq= -q --bprsel= -B --bpmbl= -p \
470+
--cmbmsc= -s --nssd= -N --pmrctl= -R --pmrmscl= -l \
471+
--pmrmscu= -u --output-format= -o --verbose= -v"
472+
;;
456473
"version")
457474
opts+=$NO_OPTS
458475
;;
@@ -1571,7 +1588,7 @@ _nvme_subcmds () {
15711588
rpmb boot-part-log fid-support-effects-log \
15721589
supported-log-pages lockdown media-unit-stat-log \
15731590
supported-cap-config-log dim show-topology list-endgrp \
1574-
nvme-mi-recv nvme-mi-send"
1591+
nvme-mi-recv nvme-mi-send get-reg set-reg"
15751592

15761593
# Add plugins:
15771594
for plugin in "${!_plugin_subcmds[@]}"; do

nvme-builtin.h

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ COMMAND_LIST(
8989
ENTRY("subsystem-reset", "Resets the subsystem", subsystem_reset)
9090
ENTRY("ns-rescan", "Rescans the NVME namespaces", ns_rescan)
9191
ENTRY("show-regs", "Shows the controller registers or properties. Requires character device", show_registers)
92+
ENTRY("set-reg", "Set a register and show the resulting value", set_register)
93+
ENTRY("get-reg", "Get a register and show the resulting value", get_register)
9294
ENTRY("discover", "Discover NVMeoF subsystems", discover_cmd)
9395
ENTRY("connect-all", "Discover and Connect to NVMeoF subsystems", connect_all_cmd)
9496
ENTRY("connect", "Connect to NVMeoF subsystem", connect_cmd)

0 commit comments

Comments
 (0)