Skip to content
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

Would you please provide a usage example of the IOCTL_STORAGE_PROTOCOL_COMMAND by the DeviceIoControl? #9

Closed
sirosiro opened this issue Aug 7, 2015 · 14 comments
Labels

Comments

@sirosiro
Copy link

sirosiro commented Aug 7, 2015

I have been looking for it but I couldn't find it anywhere, and I was tried to make it myself but it was not work correctly.

@jmrossy
Copy link

jmrossy commented Aug 19, 2015

Kouichi, thanks for bringing this to our attention. We're preparing a new doc page to describe the correct usage of this IOCTL. We'll share a link to that when it's live.

@sirosiro
Copy link
Author

I found already those documents when I opened this issue. Even if it was updated, I think it is not enough information to use this IOCTL.
I found out an important comment on the "ntddstor.h" file. (simler souce exist at "http://pastebin.com/VHxcWAbp".) according to that:

//
// Parameter for IOCTL_STORAGE_PROTOCOL_COMMAND
// Buffer layout: <STORAGE_PROTOCOL_COMMAND> [Error Info Buffer] [Data-to-Device Buffer] [Data-from-Device Buffer]
//

//
// Additional notes when STORAGE_PROTOCOL_TYPE is ProtocolTypeNvme:
// 1. When flag STORAGE_PROTOCOL_COMMAND_FLAG_ADAPTER_REQUEST is set, or the request is sent through adapter, namespace Id from "Command" field is used;
// otherwise, the underneath driver should determine namespace Id from the device that receives the command.
// 2. When a command fails, the "ErrorCode" field contains value from NVMe Completion Queue Entry - DW3 - Status Field.
// 3. "CommandLength" field must have value of 64. e.g. STORAGE_PROTOCOL_COMMAND_LENGTH_NVME.
// 4. "CommandSpecific" field must have value of either STORAGE_PROTOCOL_SPECIFIC_NVME_ADMIN_COMMAND, or STORAGE_PROTOCOL_SPECIFIC_NVME_NVM_COMMAND.
// 5. When a command succeeds, field "FixedProtocolReturnData" may contain value from NVMe Completion Queue Entry - DW0.
//

And I tried to make a sample program with these information but it was not working correctly.
I can't find out more detailed description than the MSDN except the "ntddstor.h" file yet.
I need a usage example, or more detail document.

@sirosiro
Copy link
Author

Any update on this?

Does a new doc explained relations between the IOCTL_STORAGE_PROTOCOL_COMMAND and the Common Effect Log of NVMe v1.2 spec?
I think the document should explain a relation to NVMe v1.2 spec by the inbox driver (stornvme.sys). please refer below the link.

https://social.msdn.microsoft.com/Forums/windowshardware/en-US/5a2cda6f-83de-43d3-91c7-3fdc02c4971c/how-to-send-nvme-admin-command-in-windows-10?forum=wdk

And, Dose the document explain how to use extended buffers([Data-to-Device Buffer] [Data-from-Device Buffer]) with vender command?

@psycholliu
Copy link

Hi, sirosiro
I am facing the same problem about IOCTL_STORAGE_PROTOCOL_COMMAND,have you solved this problem? and How? if you give me a usage of this ioctl, will help a lot. thanks.

@sirosiro
Copy link
Author

Hi, psycholliu,
Unfortunately, I don't resolve it yet. but I found out an information recently. that is below:

https://msdn.microsoft.com/en-us/library/windows/desktop/mt718131(v=vs.85).aspx

This page explaining to how to sending a vendor-specific command, but I don't tried it yet.
I hope it'll be helpful for you. :)

@psycholliu
Copy link

Hi sirosiro,
Thanks for your reply. I have gone though https://msdn.microsoft.com/en-us/library/windows/desktop/mt718131(v=vs.85).aspx, and I have tried to send nvme IO Command(read command) with IOCTL_STORAGE_PROTOCOL_COMMAND, but failed with errorcode 87(parameter error)。thanks again!

@side1out
Copy link

I too am stuck on the 0x87 error. The bug whether it be documentation or otherwise has been reported to Microsoft. It has just moved into the active state. I too tried many variations of the sample code with no luck. I get the 87 result with about anything I do which leads me to believe this command does not work at all meaning it is not coming down to command registers or buffers.

@markg1
Copy link

markg1 commented Dec 1, 2016

IOCTL_STORAGE_PROTOCOL_COMMAND is intended for sending vendor-specific commands only.
•Vendor Specific Admin Commands (C0h – FFh)
•Vendor Specific NVMe Commands (80h – FFh)
Sending an NVMe read command (Opcode 02h) will generate an error from this IOCTL.

Also your NVMe drive must support CEL.

@wm1
Copy link
Contributor

wm1 commented Mar 16, 2017

markg1 highlighted the problem in your experiments. And they are documented at https://msdn.microsoft.com/en-us/library/windows/desktop/mt718131(v=vs.85).aspx

@wm1 wm1 closed this as completed Mar 16, 2017
@erikhugintech
Copy link

IOCTL_STORAGE_PROTOCOL_COMMAND is intended for sending vendor-specific commands only.
•Vendor Specific Admin Commands (C0h – FFh)
•Vendor Specific NVMe Commands (80h – FFh)

How can I get a namespace list? You block pass-through Identify, and you don't support Identify CNS 02 with IOCTL_STORAGE_QUERY_PROPERTY.

Have you considered not blocking commands that don't do any damage, or do you actually have a rationale behind forcing the use of incomplete and needlessly complicated abstraction layers for completely harmless commands?

@markg1
Copy link

markg1 commented Apr 3, 2017

I have not tried this, but based on nvme.h and provided info, I would suggest you try
following the Example: NVMe Identify query at https://msdn.microsoft.com/en-us/library/windows/desktop/mt718131(v=vs.85).aspx. But replace the line:

protocolData->ProtocolDataRequestValue = NVME_IDENTIFY_CNS_CONTROLLER;
with
protocolData->ProtocolDataRequestValue = NVME_IDENTIFY_CNS_ACTIVE_NAMESPACES;

Good luck.

@RealCool1983
Copy link

I have not tried this, but based on nvme.h and provided info, I would suggest you try
following the Example: NVMe Identify query at https://msdn.microsoft.com/en-us/library/windows/desktop/mt718131(v=vs.85).aspx. But replace the line:

protocolData->ProtocolDataRequestValue = NVME_IDENTIFY_CNS_CONTROLLER;
with
protocolData->ProtocolDataRequestValue = NVME_IDENTIFY_CNS_ACTIVE_NAMESPACES;

Good luck.

I try, but it can't work @@

@mannanal
Copy link

Please refer to https://docs.microsoft.com/en-us/windows-hardware/drivers/storage/nvme-features-supported-by-stornvme for any clarifications on command supported

Currently, IOCTL_STORAGE_QUERY_PROPERTY with identify option NVME_IDENTIFY_CNS_ACTIVE_NAMESPACES is not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants