2 * Copyright (c) 2016 Avago Technologies. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful.
9 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
10 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
11 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO
12 * THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
13 * See the GNU General Public License for more details, a copy of which
14 * can be found in the file COPYING included with this package
19 * This file contains definitions relative to FC-NVME r1.14 (16-020vB).
20 * The fcnvme_lsdesc_cr_assoc_cmd struct reflects expected r1.16 content.
27 #define NVME_CMD_SCSI_ID 0xFD
28 #define NVME_CMD_FC_ID FC_TYPE_NVME
30 /* FC-NVME Cmd IU Flags */
31 #define FCNVME_CMD_FLAGS_DIRMASK 0x03
32 #define FCNVME_CMD_FLAGS_WRITE 0x01
33 #define FCNVME_CMD_FLAGS_READ 0x02
35 struct nvme_fc_cmd_iu {
44 struct nvme_command sqe;
48 #define NVME_FC_SIZEOF_ZEROS_RSP 12
51 FCNVME_SC_SUCCESS = 0,
52 FCNVME_SC_INVALID_FIELD = 1,
53 FCNVME_SC_INVALID_CONNID = 2,
56 struct nvme_fc_ersp_iu {
63 struct nvme_completion cqe;
64 /* for now - no additional payload */
68 /* FC-NVME Link Services */
73 FCNVME_LS_CREATE_ASSOCIATION = 3,
74 FCNVME_LS_CREATE_CONNECTION = 4,
75 FCNVME_LS_DISCONNECT = 5,
78 /* FC-NVME Link Service Descriptors */
80 FCNVME_LSDESC_RSVD = 0x0,
81 FCNVME_LSDESC_RQST = 0x1,
82 FCNVME_LSDESC_RJT = 0x2,
83 FCNVME_LSDESC_CREATE_ASSOC_CMD = 0x3,
84 FCNVME_LSDESC_CREATE_CONN_CMD = 0x4,
85 FCNVME_LSDESC_DISCONN_CMD = 0x5,
86 FCNVME_LSDESC_CONN_ID = 0x6,
87 FCNVME_LSDESC_ASSOC_ID = 0x7,
91 /* ********** start of Link Service Descriptors ********** */
95 * fills in length of a descriptor. Struture minus descriptor header
97 static inline __be32 fcnvme_lsdesc_len(size_t sz)
99 return cpu_to_be32(sz - (2 * sizeof(u32)));
102 struct fcnvme_ls_rqst_w0 {
103 u8 ls_cmd; /* FCNVME_LS_xxx */
107 /* FCNVME_LSDESC_RQST */
108 struct fcnvme_lsdesc_rqst {
109 __be32 desc_tag; /* FCNVME_LSDESC_xxx */
111 struct fcnvme_ls_rqst_w0 w0;
115 /* FC-NVME LS RJT reason_code values */
116 enum fcnvme_ls_rjt_reason {
117 FCNVME_RJT_RC_NONE = 0,
118 /* no reason - not to be sent */
120 FCNVME_RJT_RC_INVAL = 0x01,
121 /* invalid NVMe_LS command code */
123 FCNVME_RJT_RC_LOGIC = 0x03,
126 FCNVME_RJT_RC_UNAB = 0x09,
127 /* unable to perform command request */
129 FCNVME_RJT_RC_UNSUP = 0x0b,
130 /* command not supported */
132 FCNVME_RJT_RC_INPROG = 0x0e,
133 /* command already in progress */
135 FCNVME_RJT_RC_INV_ASSOC = 0x40,
136 /* Invalid Association ID*/
138 FCNVME_RJT_RC_INV_CONN = 0x41,
139 /* Invalid Connection ID*/
141 FCNVME_RJT_RC_VENDOR = 0xff,
142 /* vendor specific error */
145 /* FC-NVME LS RJT reason_explanation values */
146 enum fcnvme_ls_rjt_explan {
147 FCNVME_RJT_EXP_NONE = 0x00,
148 /* No additional explanation */
150 FCNVME_RJT_EXP_OXID_RXID = 0x17,
151 /* invalid OX_ID-RX_ID combination */
153 FCNVME_RJT_EXP_INSUF_RES = 0x29,
154 /* insufficient resources */
156 FCNVME_RJT_EXP_UNAB_DATA = 0x2a,
157 /* unable to supply requested data */
159 FCNVME_RJT_EXP_INV_LEN = 0x2d,
160 /* Invalid payload length */
163 /* FCNVME_LSDESC_RJT */
164 struct fcnvme_lsdesc_rjt {
165 __be32 desc_tag; /* FCNVME_LSDESC_xxx */
170 * Reject reason and explanaction codes are generic
171 * to ELs's from LS-3.
173 u8 reason_code; /* fcnvme_ls_rjt_reason */
174 u8 reason_explanation; /* fcnvme_ls_rjt_explan */
181 #define FCNVME_ASSOC_HOSTNQN_LEN 256
182 #define FCNVME_ASSOC_SUBNQN_LEN 256
184 /* FCNVME_LSDESC_CREATE_ASSOC_CMD */
185 struct fcnvme_lsdesc_cr_assoc_cmd {
186 __be32 desc_tag; /* FCNVME_LSDESC_xxx */
195 u8 hostnqn[FCNVME_ASSOC_HOSTNQN_LEN];
196 u8 subnqn[FCNVME_ASSOC_SUBNQN_LEN];
197 __be32 rsvd584[108]; /* pad to 1016 bytes,
198 * which makes overall LS rqst
203 #define FCNVME_LSDESC_CRA_CMD_DESC_MINLEN \
204 offsetof(struct fcnvme_lsdesc_cr_assoc_cmd, rsvd584)
206 #define FCNVME_LSDESC_CRA_CMD_DESC_MIN_DESCLEN \
207 (FCNVME_LSDESC_CRA_CMD_DESC_MINLEN - \
208 offsetof(struct fcnvme_lsdesc_cr_assoc_cmd, ersp_ratio))
212 /* FCNVME_LSDESC_CREATE_CONN_CMD */
213 struct fcnvme_lsdesc_cr_conn_cmd {
214 __be32 desc_tag; /* FCNVME_LSDESC_xxx */
224 /* Disconnect Scope Values */
226 FCNVME_DISCONN_ASSOCIATION = 0,
227 FCNVME_DISCONN_CONNECTION = 1,
230 /* FCNVME_LSDESC_DISCONN_CMD */
231 struct fcnvme_lsdesc_disconn_cmd {
232 __be32 desc_tag; /* FCNVME_LSDESC_xxx */
235 /* note: scope is really a 1 bit field */
236 u8 scope; /* FCNVME_DISCONN_xxx */
241 /* FCNVME_LSDESC_CONN_ID */
242 struct fcnvme_lsdesc_conn_id {
243 __be32 desc_tag; /* FCNVME_LSDESC_xxx */
245 __be64 connection_id;
248 /* FCNVME_LSDESC_ASSOC_ID */
249 struct fcnvme_lsdesc_assoc_id {
250 __be32 desc_tag; /* FCNVME_LSDESC_xxx */
252 __be64 association_id;
257 FCNVME_RS_RCTL_DATA = 1,
258 FCNVME_RS_RCTL_XFER_RDY = 5,
259 FCNVME_RS_RCTL_RSP = 8,
263 /* ********** start of Link Services ********** */
267 struct fcnvme_ls_rjt {
268 struct fcnvme_ls_rqst_w0 w0;
269 __be32 desc_list_len;
270 struct fcnvme_lsdesc_rqst rqst;
271 struct fcnvme_lsdesc_rjt rjt;
275 struct fcnvme_ls_acc_hdr {
276 struct fcnvme_ls_rqst_w0 w0;
277 __be32 desc_list_len;
278 struct fcnvme_lsdesc_rqst rqst;
279 /* Followed by cmd-specific ACC descriptors, see next definitions */
282 /* FCNVME_LS_CREATE_ASSOCIATION */
283 struct fcnvme_ls_cr_assoc_rqst {
284 struct fcnvme_ls_rqst_w0 w0;
285 __be32 desc_list_len;
286 struct fcnvme_lsdesc_cr_assoc_cmd assoc_cmd;
289 #define FCNVME_LSDESC_CRA_RQST_MINLEN \
290 (offsetof(struct fcnvme_ls_cr_assoc_rqst, assoc_cmd) + \
291 FCNVME_LSDESC_CRA_CMD_DESC_MINLEN)
293 #define FCNVME_LSDESC_CRA_RQST_MIN_LISTLEN \
294 FCNVME_LSDESC_CRA_CMD_DESC_MINLEN
297 struct fcnvme_ls_cr_assoc_acc {
298 struct fcnvme_ls_acc_hdr hdr;
299 struct fcnvme_lsdesc_assoc_id associd;
300 struct fcnvme_lsdesc_conn_id connectid;
304 /* FCNVME_LS_CREATE_CONNECTION */
305 struct fcnvme_ls_cr_conn_rqst {
306 struct fcnvme_ls_rqst_w0 w0;
307 __be32 desc_list_len;
308 struct fcnvme_lsdesc_assoc_id associd;
309 struct fcnvme_lsdesc_cr_conn_cmd connect_cmd;
312 struct fcnvme_ls_cr_conn_acc {
313 struct fcnvme_ls_acc_hdr hdr;
314 struct fcnvme_lsdesc_conn_id connectid;
317 /* FCNVME_LS_DISCONNECT */
318 struct fcnvme_ls_disconnect_rqst {
319 struct fcnvme_ls_rqst_w0 w0;
320 __be32 desc_list_len;
321 struct fcnvme_lsdesc_assoc_id associd;
322 struct fcnvme_lsdesc_disconn_cmd discon_cmd;
325 struct fcnvme_ls_disconnect_acc {
326 struct fcnvme_ls_acc_hdr hdr;
331 * Yet to be defined in FC-NVME:
333 #define NVME_FC_CONNECT_TIMEOUT_SEC 2 /* 2 seconds */
334 #define NVME_FC_LS_TIMEOUT_SEC 2 /* 2 seconds */
335 #define NVME_FC_TGTOP_TIMEOUT_SEC 2 /* 2 seconds */
338 * TRADDR string must be of form "nn-<16hexdigits>:pn-<16hexdigits>"
339 * the string is allowed to be specified with or without a "0x" prefix
340 * infront of the <16hexdigits>. Without is considered the "min" string
341 * and with is considered the "max" string. The hexdigits may be upper
344 #define NVME_FC_TRADDR_NNLEN 3 /* "?n-" */
345 #define NVME_FC_TRADDR_OXNNLEN 5 /* "?n-0x" */
346 #define NVME_FC_TRADDR_HEXNAMELEN 16
347 #define NVME_FC_TRADDR_MINLENGTH \
348 (2 * (NVME_FC_TRADDR_NNLEN + NVME_FC_TRADDR_HEXNAMELEN) + 1)
349 #define NVME_FC_TRADDR_MAXLENGTH \
350 (2 * (NVME_FC_TRADDR_OXNNLEN + NVME_FC_TRADDR_HEXNAMELEN) + 1)
351 #define NVME_FC_TRADDR_MIN_PN_OFFSET \
352 (NVME_FC_TRADDR_NNLEN + NVME_FC_TRADDR_HEXNAMELEN + 1)
353 #define NVME_FC_TRADDR_MAX_PN_OFFSET \
354 (NVME_FC_TRADDR_OXNNLEN + NVME_FC_TRADDR_HEXNAMELEN + 1)
357 #endif /* _NVME_FC_H */