[PATCH] nvme-tcp: add basic support for the C2HTermReq PDU
Sagi Grimberg
sagi at grimberg.me
Mon Feb 17 00:14:47 PST 2025
On 14/02/2025 21: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 at 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";
msg = "unknown" ? we shouldn't suggest N/A because it should be very
much applicable.
> +
> + dev_err(queue->ctrl->ctrl.device,
> + "Received C2HTermReq (FES = %s)\n", msg);
> +}
> +
AFAIR, the goal with C2HTerm was to also log the offending PDU itself.
However I don't think
its really necessary looking back.
Can you test this also with header digest enabled?
Conditioned that the above passes just fine, plus one minor nit,
Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
More information about the Linux-nvme
mailing list