From: Max Gurtovoy <mgurtovoy@nvidia.com>
To: Sagi Grimberg <sagi@grimberg.me>, Daniel Wagner <dwagner@suse.de>
Cc: Keith Busch <kbusch@kernel.org>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
Christoph Hellwig <hch@lst.de>
Subject: Re: ioccsz and iorcsz check failing
Date: Wed, 20 Dec 2023 02:10:42 +0200 [thread overview]
Message-ID: <a4ec22ae-c7b7-4583-a41d-52755eb5f301@nvidia.com> (raw)
In-Reply-To: <af03a48b-1084-4049-8cf7-a48088b3e5e2@nvidia.com>
On 20/12/2023 1:55, Max Gurtovoy wrote:
>
>
> On 19/12/2023 21:59, Sagi Grimberg wrote:
>>
>>
>> On 12/19/23 19:24, Max Gurtovoy wrote:
>>>
>>>
>>> On 18/12/2023 18:04, Sagi Grimberg wrote:
>>>>
>>>>>> Is anything else in the identify wrong, or is it just these
>>>>>> fabrics fields?
>>>>>
>>>>> So what I am seeing on the wire are a few fabrics commands (connect,
>>>>> get
>>>>> property) followed by the nvme id ctrl command (opcode 0x6).
>>>>>
>>>>> nvmet: nvmet_req_init:962
>>>>> nvmet: nvmet_parse_admin_cmd:1011
>>>>> nvmet: nvmet_parse_discovery_cmd:359 opcode 6
>>>>>
>>>>> This calls then nvmet_execute_disc_identify, so adding
>>>>>
>>>>> --- a/drivers/nvme/target/discovery.c
>>>>> +++ b/drivers/nvme/target/discovery.c
>>>>> @@ -249,6 +249,7 @@ static void nvmet_execute_disc_identify(struct
>>>>> nvmet_req *req)
>>>>> {
>>>>> struct nvmet_ctrl *ctrl = req->sq->ctrl;
>>>>> struct nvme_id_ctrl *id;
>>>>> + u32 cmd_capsule_size;
>>>>> u16 status = 0;
>>>>>
>>>>> if (!nvmet_check_transfer_len(req, NVME_IDENTIFY_DATA_SIZE))
>>>>> @@ -289,6 +290,17 @@ static void nvmet_execute_disc_identify(struct
>>>>> nvmet_req *req)
>>>>> id->sgls |= cpu_to_le32(1 << 2);
>>>>> if (req->port->inline_data_size)
>>>>> id->sgls |= cpu_to_le32(1 << 20);
>>>>> + /*
>>>>> + * Max command capsule size is sqe + in-capsule data size.
>>>>> + * Disable in-capsule data for Metadata capable controllers.
>>>>> + */
>>>>> + cmd_capsule_size = sizeof(struct nvme_command);
>>>>> + if (!ctrl->pi_support)
>>>>> + cmd_capsule_size += req->port->inline_data_size;
>>>>> + id->ioccsz = cpu_to_le32(cmd_capsule_size / 16);
>>>>
>>>> Yes, this is the culprit. Nice that it exposed a bug.
>>>>
>>>> There is no in-capsule data for discovery controllers afaict.
>>>
>>> Also, the discovery controllers can't support PI AFAIK.
>>
>> Indeed, we should simply set it to sizeof(struct nvme_command) / 16.
>>
>> It is true that for tcp transport we should add additional 8192 which
>> is mandatory for nvme-tcp. But that can be done in an incremental patch.
>
> I'm not aware of additional 8k of mandatory size for nvme-tcp discovery
> controllers.
> what is this needed for ?
>
> I was re-thinking about this issue again and I think that the original
> patch that caused the problem that Daniel found is wrong from spec
> perspective and also breaks compatibility with linux target for no
> reason. And maybe with other targets as well.
>
> A discovery controller according to the spec does not implement IO
> queues or expose namespaces. So why do we even check for IOCCSZ and
> IORCSZ for these controllers ?
> It is also mentioned explicitly that these 2 fields are reserved for
> discovery controllers.
>
> SPEC:
> "
> I/O Queue Command Capsule Supported Size (IOCCSZ): This field defines
> the maximum I/O command capsule size in 16 byte units. The minimum value
> that shall be indicated is 4 corresponding to 64 bytes.
>
> I/O Queue Response Capsule Supported Size (IORCSZ): This field defines
> the maximum I/O response capsule size in 16 byte units. The minimum
> value that shall be indicated is 1 corresponding to 16 bytes.
> "
>
> I suggest the following untested code to fix *only* the host driver side:
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index ee2e4c49892d..89e01e6b5fe4 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3068,14 +3068,14 @@ static int nvme_check_ctrl_fabric_info(struct
> nvme_ctrl *ctrl, struct nvme_id_ct
> return -EINVAL;
> }
>
> - if (ctrl->ioccsz < 4) {
> + if (nvme_discovery_ctrl(ctrl) && ctrl->ioccsz < 4) {
> dev_err(ctrl->device,
> "I/O queue command capsule supported size %d <
> 4\n",
> ctrl->ioccsz);
> return -EINVAL;
> }
>
> - if (ctrl->iorcsz < 1) {
> + if (nvme_discovery_ctrl(ctrl) && ctrl->iorcsz < 1) {
> dev_err(ctrl->device,
> "I/O queue response capsule supported size %d <
> 1\n",
> ctrl->iorcsz);
>
>
> Daniel,
> can you please test the above and if it works I'll send a fix with your
> Tested-By signature. We must have it merged to next 6.7 rc.
>
> -Max.
>
Daniel,
I just saw that Caleb also noticed that it shouldn't be relevant for
discovery controllers. The mail got lost in the mailbox.
Anyway, I believe the initiator/host code should be updated for 6.7 and
must ignore these fields as the spec explicitly said it is reserved.
For the target side, I prefer to keep it 0 for reserved fields since
this is the convention in all the specifications that I'm aware of.
Sagi/Christoph,
WDYT ?
I have a small bug for above code so please use:
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ee2e4c49892d..b218ac88fcf8 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3068,14 +3068,14 @@ static int nvme_check_ctrl_fabric_info(struct
nvme_ctrl *ctrl, struct nvme_id_ct
return -EINVAL;
}
- if (ctrl->ioccsz < 4) {
+ if (!nvme_discovery_ctrl(ctrl) && ctrl->ioccsz < 4) {
dev_err(ctrl->device,
"I/O queue command capsule supported size %d <
4\n",
ctrl->ioccsz);
return -EINVAL;
}
- if (ctrl->iorcsz < 1) {
+ if (!nvme_discovery_ctrl(ctrl) && ctrl->iorcsz < 1) {
dev_err(ctrl->device,
"I/O queue response capsule supported size %d <
1\n",
ctrl->iorcsz);
next prev parent reply other threads:[~2023-12-20 0:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 14:48 ioccsz and iorcsz check failing Daniel Wagner
2023-12-15 18:08 ` Keith Busch
2023-12-18 9:59 ` Sagi Grimberg
2023-12-18 13:57 ` Daniel Wagner
2023-12-18 16:04 ` Sagi Grimberg
2023-12-19 17:24 ` Max Gurtovoy
2023-12-19 19:59 ` Sagi Grimberg
2023-12-19 23:55 ` Max Gurtovoy
2023-12-20 0:10 ` Max Gurtovoy [this message]
2023-12-20 9:02 ` Daniel Wagner
2023-12-20 9:13 ` Sagi Grimberg
2023-12-19 17:28 ` Daniel Wagner
2023-12-19 18:54 ` Caleb Sander
2023-12-19 19:58 ` Sagi Grimberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a4ec22ae-c7b7-4583-a41d-52755eb5f301@nvidia.com \
--to=mgurtovoy@nvidia.com \
--cc=dwagner@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox