nvme-fabrics: Add FC transport FC-NVME definitions:
- Formats for Cmd, Data, Rsp IUs
- Formats FC-4 LS definitions
Signed-off-by: James Smart
---
include/linux/nvme-fc.h | 296
1 file changed, 296 insertions(+)
create mode 100644 include/linux/nvme-fc.h
diff --git a/include/linux/nvme-fc.h b/include/linux/nvme-fc.h
new file mode 100644
index 000..99e9200
--- /dev/null
+++ b/include/linux/nvme-fc.h
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2016 Avago Technologies. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful.
+ * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO
+ * THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
+ * See the GNU General Public License for more details, a copy of which
+ * can be found in the file COPYING included with this package
+ *
+ */
+
+/*
+ * This file contains definitions relative to FC-NVME r1.05
+ */
+
+#ifndef _NVME_FC_H
+#define _NVME_FC_H 1
+
+#define NVME_FC4_TYPE 0x28
+
+#define NVME_CMD_SCSI_ID 0xFD
+#define NVME_CMD_FC_ID NVME_FC4_TYPE
+
+/* FC-NVME Cmd IU Flags */
+#define FCNVME_CMD_FLAGS_DIRMASK 0x03
+#define FCNVME_CMD_FLAGS_WRITE 0x01
+#define FCNVME_CMD_FLAGS_READ 0x02
+
+struct nvme_fc_cmd_iu {
+ __u8scsi_id;
+ __u8fc_id;
+ __be16 iu_len;
+ __u8rsvd4[3];
+ __u8flags;
+ __be32 rsvd8[2];
+ __be64 connection_id;
+ __be32 csn;
+ __be32 data_len;
+ struct nvme_command sqe;
+};
+
+#define NVME_FC_SIZEOF_ZEROS_RSP 12
+
+struct nvme_fc_ersp_iu {
+ __u8rsvd0[2];
+ __be16 iu_len;
+ __be32 rsn;
+ __be32 rsvd8[2];
+ struct nvme_completion cqe;
+ /* for now - no additional payload */
+};
+
+
+/* FC-NVME r1.03/16-119v0 NVME Link Services */
+enum {
+ FCNVME_LS_RSVD = 0,
+ FCNVME_LS_RJT = 1,
+ FCNVME_LS_ACC = 2,
+ FCNVME_LS_CREATE_ASSOCIATION= 3,
+ FCNVME_LS_CREATE_CONNECTION = 4,
+ FCNVME_LS_DISCONNECT= 5,
+};
+
+/* FC-NVME r1.03/16-119v0 NVME Link Service Descriptors */
+enum {
+ FCNVME_LSDESC_RSVD = 0x0,
+ FCNVME_LSDESC_RQST = 0x1,
+ FCNVME_LSDESC_RJT = 0x2,
+ FCNVME_LSDESC_CREATE_ASSOC_CMD = 0x3,
+ FCNVME_LSDESC_CREATE_CONN_CMD = 0x4,
+ FCNVME_LSDESC_DISCONN_CMD = 0x5,
+ FCNVME_LSDESC_CONN_ID = 0x6,
+ FCNVME_LSDESC_ASSOC_ID = 0x7,
+};
+
+
+/* ** start of Link Service Descriptors ** */
+
+
+/* fills in length of a descriptor. Struture minus descriptor header */
+#define FCNVME_LSDESC_LEN(lsdesc) \
+ cpu_to_be32(sizeof(lsdesc) - (2*(sizeof(u32
+
+struct fcnvme_ls_rqst_w0 {
+ u8 ls_cmd; /* FCNVME_LS_xxx */
+ u8 zeros[3];
+};
+
+/* FCNVME_LSDESC_RQST */
+struct fcnvme_lsdesc_rqst {
+ __be32 desc_tag; /* FCNVME_LSDESC_xxx */
+ __be32 desc_len;
+ struct fcnvme_ls_rqst_w0w0;
+ __be32 rsvd12;
+};
+
+/* From LS-3 */
+enum {
+ LSRJT_REASON_INVALID_ELS_CODE = 0x1,
+ LSRJT_REASON_LOGICAL_ERROR = 0x3,
+ LSRJT_REASON_LOGICAL_BUSY = 0x5,
+ LSRJT_REASON_PROTOCOL_ERROR = 0x7,
+ LSRJT_REASON_UNABLE_TO_PERFORM_CMD = 0x9,
+ LSRJT_REASON_CMD_NOT_SUPPORTED = 0xB,
+ LSRJT_REASON_CMD_ALREADY_IN_PROGRESS= 0xE,
+ LSRJT_REASON_FIP_ERROR = 0x20,
+ /* Add others later */
+};
+
+enum {
+ LSRJT_EXPL_NO_EXPLANATION = 0x0,
+ /* Add others later */
+};
+
+
+/* FCNVME_LSDESC_RJT */
+struct fcnvme_lsdesc_rjt {
+ __be32 desc_tag; /* FCNVME_LSDESC_xxx */
+ __be32 desc_len;
+ u8 rsvd8;
+ u8 reason_code;
+ u8 reason_explanation;
+ u8 vendor;
+ __be32 rsvd12;
+};
+
+
+#define FCNVME_ASSOC_HOSTID_LEN64
+#define FCNVME_ASSOC_HOSTNQN_LEN 256
+#define FCNVME_ASSOC_SUBNQN_LEN256
+
+/* FCNVME_LSDESC_CREATE_ASSOC_CMD */
+struct fcnvme_lsdesc_cr_assoc_cmd {
+ __be32 desc_tag; /* FCNVME_LSDESC_xxx */
+ __be32 d