-
Notifications
You must be signed in to change notification settings - Fork 668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nvme: Add support for get-reg command to output single register #2188
Conversation
80db8ea
to
d176ec3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please avoid mixing white space cleanup patches with feature patches
- Documentation is missing
How does the kernel figure out that some of the register values have changes?
Fixed for some comments but still remaining comments to fix so will update later. |
nvme-print-stdout.c
Outdated
if (human) | ||
printf("%s: ", nvme_register_to_string(offset)); | ||
else | ||
printf("register: 0x%02x (%s), value: ", offset, nvme_register_to_string(offset)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The verbose output is less verbose?
Also why use %02x
? There are already some offsets that take 3 hex digits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output example is below also the human-readable option is for readable format output but not for verbose output.
tokunori@tokunori-desktop:~/nvme-cli$ sudo .build/nvme get-reg /dev/nvme0 -c
register: 0x00 (Controller Capabilities), value: 3028033fff
tokunori@tokunori-desktop:~/nvme-cli$ sudo .build/nvme get-reg /dev/nvme0 -c -H
Controller Capabilities: 3028033fff
Controller Ready With Media Support (CRWMS): Not Supported
Controller Ready Independent of Media Support (CRIMS): Not Supported
NVM Subsystem Shutdown Supported (NSSS): Not Supported
Controller Memory Buffer Supported (CMBS): The Controller Memory Buffer is Not Supported
Persistent Memory Region Supported (PMRS): The Persistent Memory Region is Not Supported
Memory Page Size Maximum (MPSMAX): 4096 bytes
Memory Page Size Minimum (MPSMIN): 4096 bytes
Controller Power Scope (CPS): Not Reported
Boot Partition Support (BPS): No
Command Sets Supported (CSS): NVM command set is Supported
One or more I/O Command Sets are Not Supported
I/O Command Set is Supported
NVM Subsystem Reset Supported (NSSRS): Yes
Doorbell Stride (DSTRD): 4 bytes
Timeout (TO): 20000 ms
Arbitration Mechanism Supported (AMS): Weighted Round Robin with Urgent Priority Class is Not supported
Contiguous Queues Required (CQR): Yes
Maximum Queue Entries Supported (MQES): 16384
tokunori@tokunori-desktop:~/nvme-cli$ sudo .build/nvme get-reg /dev/nvme0 -c -h
Usage: nvme get-reg <device> [OPTIONS]
Reads and shows the defined NVMe controller register.
Register offset must be one of:
CAP=0x0, VS=0x8, INTMS=0xc, INTMC=0x10, CC=0x14, CSTS=0x1c,
NSSR=0x20, AQA=0x24, ASQ=0x28, ACQ=0x30, CMBLOC=0x38,
CMBSZ=0x3c, BPINFO=0x40, BPRSEL=0x44, BPMBL=0x48, CMBMSC=0x50,
CMBSTS=0x58, CRTO=0x68, PMRCAP=0xe00, PMRCTL=0xe04,
PMRSTS=0xe08, PMREBS=0xe0c, PMRSWTP=0xe10, PMRMSCL=0xe14, PMRMSCU=0xe18
Options:
[ --verbose, -v ] --- Increase output verbosity
[ --output-format=<FMT>, -o <FMT> ] --- Output format: normal|json|binary
[ --offset=<NUM>, -O <NUM> ] --- offset of the requested register
[ --human-readable, -H ] --- show register in readable format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also why use
%02x
? There are already some offsets that take 3 hex digits.
Fixed by the commit 24f79e3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in this specific line (register: 0x00 (Controller Capabilities), value: 3028033fff
vs. Controller Capabilities: 3028033fff
), the verbose output doesn't have the register number. It seems like "verbose" should at least contain all the information that "not verbose" does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure let me reconfirm as the "verbose" mentioned is not actually set by the command verbose option but set by the human-readable so not necessary to contain the register number for the option output.
static int get_register(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
...
bool human = stdout_print_ops.flags & VERBOSE;
...
static void stdout_ctrl_register(int offset, uint64_t value64)
{
if (cfg.human_readable)
flags |= VERBOSE;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think stdout_ctrl_register_common
still has this issue.
+static void stdout_ctrl_register_common(int offset, uint64_t value, bool fabrics)
+{
+ bool human = !!(stdout_print_ops.flags & VERBOSE);
+ const char *name = nvme_register_to_string(offset);
+ const char *type = fabrics ? "property" : "register";
+
+ if (human) {
+ printf("%s: %#"PRIx64"\n", name, value);
+ stdout_ctrl_register_human(offset, value, true);
+ return;
+ }
+
+ printf("%s: %#04x (%s), value: %#"PRIx64"\n", type, offset,
+ name, value);
+}
While stdout_ctrl_register_support
handle the verbose flag differently, that is it prints the normal output and then the verbose. This is what I would expect from the previous output as well
+static void stdout_ctrl_register_support(void *bar, bool fabrics, int offset, bool human,
+ bool support)
+{
+ uint64_t value = nvme_is_64bit_reg(offset) ? mmio_read64(bar + offset) :
+ mmio_read32(bar + offset);
+
+ if (fabrics && value == -1)
+ return;
+
+ printf("%-8s: ", nvme_register_symbol_to_string(offset));
+
+ printf("%#"PRIx64"\n", value);
+
+ if (human)
+ stdout_ctrl_register_human(offset, value, support);
+}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No stdout_ctrl_register_common()
returns after the verbose output and before it outputs also the normal output. So the order itself same with the stdout_ctrl_register_support()
.
Note: The normal outputs below are different since depended on the current show-regs
command outputs.
stdout_ctrl_register_support
static void stdout_ctrl_register_common(int offset, uint64_t value, bool fabrics)
{
...
if (human) {
printf("%s: %#"PRIx64"\n", name, value);
...
printf("%s: %#04x (%s), value: %#"PRIx64"\n", type, offset,
name, value);
}
nvme-print-stdout.c
Outdated
printf("unknown register: 0x%02x (%s), value: %"PRIx64"\n", | ||
offset, nvme_register_to_string(offset), value64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
offset
and nvme_register_to_string(offset)
have already been printed. Is it necessary to do it again here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those only printed if the human-readable option not set but this output is only for the option so not duplicated to output actually. By the way fixed the offset output to take 4 hex digits by the commit 227ce4e.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The human
flag should only annotate information. If the flag is actually influence the control flow, than this doesn't sound right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the human
flag flow not changed as same with the current show-regs
command and the new get-reg
command follows the output I think.
Just rebased with the linux-nvme:master. |
Still to do belows.
|
Please squash your fixes for new code into the new code. There is no need to see the development history in the final version. |
Just squashed the changes. |
fec85e7
to
a830385
Compare
The review comments almost fixed so could you please review again? Still the following items to do but will do separately if you okay.
|
b306922
to
1e95aad
Compare
bcd89a7
to
3561329
Compare
Just confirmed as the access issue by CC.EN zero caused by the nvme identify namespace to scan NVMe topology sysfs ns nuse attribute and this can be avoided by stopping nvme identify namespace since the attirute not necesary for the PCI register access.
|
Move the mmio_read up the call chain. Signed-off-by: Tokunori Ikegami <[email protected]>
To use the function by other registers print functions. Signed-off-by: Tokunori Ikegami <[email protected]>
To prepare the stage for the set register feature. Signed-off-by: Tokunori Ikegami <[email protected]>
To prepare the state for the get register feature. Signed-off-by: Tokunori Ikegami <[email protected]>
To prepare the state for the get register feature. Signed-off-by: Tokunori Ikegami <[email protected]>
To prepare the state for the get register feature. Signed-off-by: Tokunori Ikegami <[email protected]>
The get-reg command is to output register(s), it's possible to show several registers when register name are used as command line option. The set-reg command is to write nvme register(s). Again, the command is able to set several registers when the register name are used. Signed-off-by: Tokunori Ikegami <[email protected]>
Thanks! |
Note: Currently only stdout print supported.