From: Hannes Reinecke <hare@suse.de>
To: Maurizio Lombardi <mlombard@redhat.com>, kbusch@kernel.org
Cc: axboe@kernel.dk, hch@lst.de, sagi@grimberg.me,
linux-nvme@lists.infradead.org, hare@kernel.org,
mlombard@bsdbackstore.eu
Subject: Re: [PATCH] nvme-tcp: add basic support for the C2HTermReq PDU
Date: Mon, 17 Feb 2025 11:56:14 +0100 [thread overview]
Message-ID: <91041933-6a18-490c-8090-4e03d15d3cf3@suse.de> (raw)
In-Reply-To: <20250214190012.311960-1-mlombard@redhat.com>
On 2/14/25 20:00, Maurizio Lombardi wrote:
> Previously, the NVMe/TCP host driver did not handle the C2HTermReq PDU,
> instead printing "unsupported pdu type (3)" when received. This patch adds
> support for processing the C2HTermReq PDU, allowing the driver
> to print the Fatal Error Status field.
>
> Example of output:
> nvme nvme4: Received C2HTermReq (FES = Invalid PDU Header Field)
>
> Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
> ---
> drivers/nvme/host/tcp.c | 37 +++++++++++++++++++++++++++++++++++++
> include/linux/nvme-tcp.h | 2 ++
> 2 files changed, 39 insertions(+)
>
> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index 841238f38fdd..8f783185575d 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
> @@ -763,6 +763,40 @@ static int nvme_tcp_handle_r2t(struct nvme_tcp_queue *queue,
> return 0;
> }
>
> +static void nvme_tcp_handle_c2h_term(struct nvme_tcp_queue *queue,
> + struct nvme_tcp_term_pdu *pdu)
> +{
> + u16 fes;
> + const char *msg;
> + u32 plen = le32_to_cpu(pdu->hdr.plen);
> +
> + static const char * const msg_table[] = {
> + [NVME_TCP_FES_INVALID_PDU_HDR] = "Invalid PDU Header Field",
> + [NVME_TCP_FES_PDU_SEQ_ERR] = "PDU Sequence Error",
> + [NVME_TCP_FES_HDR_DIGEST_ERR] = "Header Digest Error",
> + [NVME_TCP_FES_DATA_OUT_OF_RANGE] = "Data Transfer Out Of Range",
> + [NVME_TCP_FES_R2T_LIMIT_EXCEEDED] = "R2T Limit Exceeded",
> + [NVME_TCP_FES_UNSUPPORTED_PARAM] = "Unsupported Parameter",
> + };
> +
> + if (plen < NVME_TCP_MIN_C2HTERM_PLEN ||
> + plen > NVME_TCP_MAX_C2HTERM_PLEN) {
> + dev_err(queue->ctrl->ctrl.device,
> + "Received a malformed C2HTermReq PDU (plen = %u)\n",
> + plen);
> + return;
> + }
> +
> + fes = le16_to_cpu(pdu->fes);
> + if (fes && fes < ARRAY_SIZE(msg_table))
> + msg = msg_table[fes];
> + else
> + msg = "N/A";
> +
> + dev_err(queue->ctrl->ctrl.device,
> + "Received C2HTermReq (FES = %s)\n", msg);
> +}
> +
> static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb,
> unsigned int *offset, size_t *len)
> {
> @@ -806,6 +840,9 @@ static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb,
> case nvme_tcp_r2t:
> nvme_tcp_init_recv_ctx(queue);
> return nvme_tcp_handle_r2t(queue, (void *)queue->pdu);
> + case nvme_tcp_c2h_term:
> + nvme_tcp_handle_c2h_term(queue, (void *)queue->pdu);
> + return -EINVAL;
> default:
> dev_err(queue->ctrl->ctrl.device,
> "unsupported pdu type (%d)\n", hdr->type);
> diff --git a/include/linux/nvme-tcp.h b/include/linux/nvme-tcp.h
> index e07e8978d691..e435250fcb4d 100644
> --- a/include/linux/nvme-tcp.h
> +++ b/include/linux/nvme-tcp.h
> @@ -13,6 +13,8 @@
> #define NVME_TCP_ADMIN_CCSZ SZ_8K
> #define NVME_TCP_DIGEST_LENGTH 4
> #define NVME_TCP_MIN_MAXH2CDATA 4096
> +#define NVME_TCP_MIN_C2HTERM_PLEN 24
> +#define NVME_TCP_MAX_C2HTERM_PLEN 152
>
> enum nvme_tcp_pfv {
> NVME_TCP_PFV_1_0 = 0x0,
Can you add support for nvmet, too, such that we can test the patch?
(And maybe even a blktest script for it?)
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
next prev parent reply other threads:[~2025-02-17 12:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 19:00 [PATCH] nvme-tcp: add basic support for the C2HTermReq PDU Maurizio Lombardi
2025-02-17 8:14 ` Sagi Grimberg
2025-02-17 13:26 ` Maurizio Lombardi
2025-02-17 10:56 ` Hannes Reinecke [this message]
2025-02-17 13:29 ` Maurizio Lombardi
2025-02-24 14:38 ` Maurizio Lombardi
2025-02-24 16:04 ` Hannes Reinecke
2025-02-24 16:48 ` Maurizio Lombardi
2025-02-24 17:03 ` Hannes Reinecke
2025-02-25 7:41 ` 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=91041933-6a18-490c-8090-4e03d15d3cf3@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--cc=hare@kernel.org \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=mlombard@bsdbackstore.eu \
--cc=mlombard@redhat.com \
--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