nvme-fc: Create Association corrections
Subsystems (3)
cover nvme-fc: Create Association corrections
The FC-NVME spec changed between 1.14 and 1.15 and will again in 1.16 to adjust the Create Association LS. The main change was to reduce the HostID field from 64bytes to 16bytes. This change was picked up in a linux by checkin in march. However, the 1.15 spec added pad that the checkin didn't have and added additional pad it shouldn't have, causing it to exceed the desired 1Kbytes max payload size for FC-NVME LS's. 1.16 will revise the pad such that the overall LS is 1024 bytes in length.
This patch updates the headers for the spec mod and also modifies the target such that it will accept a variable amount of pad. This allows older initiators to still connect.
James Smart (2):
nvme_fc/nvmet_fc: revise Create Association descriptor length
nvmet_fc: Accept variable pad lengths on Create Association LS
drivers/nvme/target/fc.c | 20 +++++++++++++------- include/linux/nvme-fc.h | 23 ++++++++++++++++++++++- 2 files changed, 35 insertions(+), 8 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/2 nvme_fc/nvmet_fc: revise Create Association descriptor length
Revises the Create Association LS for the amount of pad expected in 1.16.
Add defines for the minimum lengths that a target can accept (e.g. variable pad lengths)
--- include/linux/nvme-fc.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
include/linux/nvme-fc.h +22 -1
@@ -17,6 +17,7 @@/* * This file contains definitions relative to FC-NVME r1.14 (16-020vB). +* The fcnvme_lsdesc_cr_assoc_cmd struct reflects expected r1.16 content. */ #ifndef _NVME_FC_H
@@ -193,9 +194,21 @@ struct fcnvme_lsdesc_cr_assoc_cmd {uuid_t hostid;u8 hostnqn[FCNVME_ASSOC_HOSTNQN_LEN ];u8 subnqn[FCNVME_ASSOC_SUBNQN_LEN ]; -u8 rsvd632[384 ]; +__be32 rsvd584[108 ];/* pad to 1016 bytes, +* which makes overall LS rqst +* payload 1024 bytes +*/ }; +#define FCNVME_LSDESC_CRA_CMD_DESC_MINLEN \ + offsetof(struct fcnvme_lsdesc_cr_assoc_cmd, rsvd584) + +#define FCNVME_LSDESC_CRA_CMD_DESC_MIN_DESCLEN \ + (FCNVME_LSDESC_CRA_CMD_DESC_MINLEN - \ + offsetof(struct fcnvme_lsdesc_cr_assoc_cmd, ersp_ratio)) + + +/* FCNVME_LSDESC_CREATE_CONN_CMD */ struct fcnvme_lsdesc_cr_conn_cmd {__be32 desc_tag;/* FCNVME_LSDESC_xxx */
@@ -273,6 +286,14 @@ struct fcnvme_ls_cr_assoc_rqst {struct fcnvme_lsdesc_cr_assoc_cmd assoc_cmd; }; +#define FCNVME_LSDESC_CRA_RQST_MINLEN \ + (offsetof(struct fcnvme_ls_cr_assoc_rqst, assoc_cmd) + \ + FCNVME_LSDESC_CRA_CMD_DESC_MINLEN) + +#define FCNVME_LSDESC_CRA_RQST_MIN_LISTLEN \ + FCNVME_LSDESC_CRA_CMD_DESC_MINLEN + +struct fcnvme_ls_cr_assoc_acc {struct fcnvme_ls_acc_hdr hdr;struct fcnvme_lsdesc_assoc_id associd;
Signature · 1 line
2.11.0
Sagi Grimberg
maintainerPATCH 1/2 nvme_fc/nvmet_fc: revise Create Association descriptor length
Looks good,
PATCH 2/2 nvmet_fc: Accept variable pad lengths on Create Association LS
In reply to James SmartTarget validation of the Create Association LS revised to accept any LS as long as all non-pad data has been received. This allows a (newer) target to accept the LS from older initiators with varying pad lengths.
--- drivers/nvme/target/fc.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/nvme/target/fc.c +13 -7
@@ -1164,18 +1164,24 @@ nvmet_fc_ls_create_association(struct nvmet_fc_tgtport *tgtport,memset (acc,0 ,sizeof (*acc)); -if (iod->rqstdatalen <sizeof (struct fcnvme_ls_cr_assoc_rqst )) +/* +* FC-NVME spec changes. There are initiators sending different +* lengths as padding sizes for Create Association Cmd descriptor +* was incorrect. +* Accept anything of "minimum" length. Assume format per 1.15 +* spec (with HOSTID reduced to 16 bytes), ignore how long the +* trailing pad length is. +*/ +if (iod->rqstdatalen <FCNVME_LSDESC_CRA_RQST_MINLEN ) ret =VERR_CR_ASSOC_LEN ; -else if (rqst->desc_list_len != -fcnvme_lsdesc_len ( -sizeof (struct fcnvme_ls_cr_assoc_rqst ))) +else if (rqst->desc_list_len < +cpu_to_be32 (FCNVME_LSDESC_CRA_RQST_MIN_LISTLEN )) ret =VERR_CR_ASSOC_RQST_LEN ;else if (rqst->assoc_cmd.desc_tag !=cpu_to_be32 (FCNVME_LSDESC_CREATE_ASSOC_CMD )) ret =VERR_CR_ASSOC_CMD ; -else if (rqst->assoc_cmd.desc_len != -fcnvme_lsdesc_len ( -sizeof (struct fcnvme_lsdesc_cr_assoc_cmd ))) +else if (rqst->assoc_cmd.desc_len < +cpu_to_be32 (FCNVME_LSDESC_CRA_CMD_DESC_MIN_DESCLEN )) ret =VERR_CR_ASSOC_CMD_LEN ; else if (!rqst->assoc_cmd.ersp_ratio || (be16_to_cpu(rqst->assoc_cmd.ersp_ratio) >=
Signature · 1 line
2.11.0
Sagi Grimberg
maintainerPATCH 2/2 nvmet_fc: Accept variable pad lengths on Create Association LS
Looks good,