1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2016 Avago Technologies. All rights reserved.
7 * This file contains definitions relative to FC-NVME r1.14 (16-020vB).
8 * The fcnvme_lsdesc_cr_assoc_cmd struct reflects expected r1.16 content.
15 #define NVME_CMD_SCSI_ID 0xFD
16 #define NVME_CMD_FC_ID FC_TYPE_NVME
18 /* FC-NVME Cmd IU Flags */
19 #define FCNVME_CMD_FLAGS_DIRMASK 0x03
20 #define FCNVME_CMD_FLAGS_WRITE 0x01
21 #define FCNVME_CMD_FLAGS_READ 0x02
23 struct nvme_fc_cmd_iu
{
32 struct nvme_command sqe
;
36 #define NVME_FC_SIZEOF_ZEROS_RSP 12
39 FCNVME_SC_SUCCESS
= 0,
40 FCNVME_SC_INVALID_FIELD
= 1,
41 FCNVME_SC_INVALID_CONNID
= 2,
44 struct nvme_fc_ersp_iu
{
51 struct nvme_completion cqe
;
52 /* for now - no additional payload */
56 /* FC-NVME Link Services */
61 FCNVME_LS_CREATE_ASSOCIATION
= 3,
62 FCNVME_LS_CREATE_CONNECTION
= 4,
63 FCNVME_LS_DISCONNECT
= 5,
66 /* FC-NVME Link Service Descriptors */
68 FCNVME_LSDESC_RSVD
= 0x0,
69 FCNVME_LSDESC_RQST
= 0x1,
70 FCNVME_LSDESC_RJT
= 0x2,
71 FCNVME_LSDESC_CREATE_ASSOC_CMD
= 0x3,
72 FCNVME_LSDESC_CREATE_CONN_CMD
= 0x4,
73 FCNVME_LSDESC_DISCONN_CMD
= 0x5,
74 FCNVME_LSDESC_CONN_ID
= 0x6,
75 FCNVME_LSDESC_ASSOC_ID
= 0x7,
79 /* ********** start of Link Service Descriptors ********** */
83 * fills in length of a descriptor. Struture minus descriptor header
85 static inline __be32
fcnvme_lsdesc_len(size_t sz
)
87 return cpu_to_be32(sz
- (2 * sizeof(u32
)));
90 struct fcnvme_ls_rqst_w0
{
91 u8 ls_cmd
; /* FCNVME_LS_xxx */
95 /* FCNVME_LSDESC_RQST */
96 struct fcnvme_lsdesc_rqst
{
97 __be32 desc_tag
; /* FCNVME_LSDESC_xxx */
99 struct fcnvme_ls_rqst_w0 w0
;
103 /* FC-NVME LS RJT reason_code values */
104 enum fcnvme_ls_rjt_reason
{
105 FCNVME_RJT_RC_NONE
= 0,
106 /* no reason - not to be sent */
108 FCNVME_RJT_RC_INVAL
= 0x01,
109 /* invalid NVMe_LS command code */
111 FCNVME_RJT_RC_LOGIC
= 0x03,
114 FCNVME_RJT_RC_UNAB
= 0x09,
115 /* unable to perform command request */
117 FCNVME_RJT_RC_UNSUP
= 0x0b,
118 /* command not supported */
120 FCNVME_RJT_RC_INPROG
= 0x0e,
121 /* command already in progress */
123 FCNVME_RJT_RC_INV_ASSOC
= 0x40,
124 /* Invalid Association ID*/
126 FCNVME_RJT_RC_INV_CONN
= 0x41,
127 /* Invalid Connection ID*/
129 FCNVME_RJT_RC_VENDOR
= 0xff,
130 /* vendor specific error */
133 /* FC-NVME LS RJT reason_explanation values */
134 enum fcnvme_ls_rjt_explan
{
135 FCNVME_RJT_EXP_NONE
= 0x00,
136 /* No additional explanation */
138 FCNVME_RJT_EXP_OXID_RXID
= 0x17,
139 /* invalid OX_ID-RX_ID combination */
141 FCNVME_RJT_EXP_INSUF_RES
= 0x29,
142 /* insufficient resources */
144 FCNVME_RJT_EXP_UNAB_DATA
= 0x2a,
145 /* unable to supply requested data */
147 FCNVME_RJT_EXP_INV_LEN
= 0x2d,
148 /* Invalid payload length */
151 /* FCNVME_LSDESC_RJT */
152 struct fcnvme_lsdesc_rjt
{
153 __be32 desc_tag
; /* FCNVME_LSDESC_xxx */
158 * Reject reason and explanaction codes are generic
159 * to ELs's from LS-3.
161 u8 reason_code
; /* fcnvme_ls_rjt_reason */
162 u8 reason_explanation
; /* fcnvme_ls_rjt_explan */
169 #define FCNVME_ASSOC_HOSTNQN_LEN 256
170 #define FCNVME_ASSOC_SUBNQN_LEN 256
172 /* FCNVME_LSDESC_CREATE_ASSOC_CMD */
173 struct fcnvme_lsdesc_cr_assoc_cmd
{
174 __be32 desc_tag
; /* FCNVME_LSDESC_xxx */
183 u8 hostnqn
[FCNVME_ASSOC_HOSTNQN_LEN
];
184 u8 subnqn
[FCNVME_ASSOC_SUBNQN_LEN
];
185 __be32 rsvd584
[108]; /* pad to 1016 bytes,
186 * which makes overall LS rqst
191 #define FCNVME_LSDESC_CRA_CMD_DESC_MINLEN \
192 offsetof(struct fcnvme_lsdesc_cr_assoc_cmd, rsvd584)
194 #define FCNVME_LSDESC_CRA_CMD_DESC_MIN_DESCLEN \
195 (FCNVME_LSDESC_CRA_CMD_DESC_MINLEN - \
196 offsetof(struct fcnvme_lsdesc_cr_assoc_cmd, ersp_ratio))
200 /* FCNVME_LSDESC_CREATE_CONN_CMD */
201 struct fcnvme_lsdesc_cr_conn_cmd
{
202 __be32 desc_tag
; /* FCNVME_LSDESC_xxx */
212 /* Disconnect Scope Values */
214 FCNVME_DISCONN_ASSOCIATION
= 0,
215 FCNVME_DISCONN_CONNECTION
= 1,
218 /* FCNVME_LSDESC_DISCONN_CMD */
219 struct fcnvme_lsdesc_disconn_cmd
{
220 __be32 desc_tag
; /* FCNVME_LSDESC_xxx */
223 /* note: scope is really a 1 bit field */
224 u8 scope
; /* FCNVME_DISCONN_xxx */
229 /* FCNVME_LSDESC_CONN_ID */
230 struct fcnvme_lsdesc_conn_id
{
231 __be32 desc_tag
; /* FCNVME_LSDESC_xxx */
233 __be64 connection_id
;
236 /* FCNVME_LSDESC_ASSOC_ID */
237 struct fcnvme_lsdesc_assoc_id
{
238 __be32 desc_tag
; /* FCNVME_LSDESC_xxx */
240 __be64 association_id
;
245 FCNVME_RS_RCTL_DATA
= 1,
246 FCNVME_RS_RCTL_XFER_RDY
= 5,
247 FCNVME_RS_RCTL_RSP
= 8,
251 /* ********** start of Link Services ********** */
255 struct fcnvme_ls_rjt
{
256 struct fcnvme_ls_rqst_w0 w0
;
257 __be32 desc_list_len
;
258 struct fcnvme_lsdesc_rqst rqst
;
259 struct fcnvme_lsdesc_rjt rjt
;
263 struct fcnvme_ls_acc_hdr
{
264 struct fcnvme_ls_rqst_w0 w0
;
265 __be32 desc_list_len
;
266 struct fcnvme_lsdesc_rqst rqst
;
267 /* Followed by cmd-specific ACC descriptors, see next definitions */
270 /* FCNVME_LS_CREATE_ASSOCIATION */
271 struct fcnvme_ls_cr_assoc_rqst
{
272 struct fcnvme_ls_rqst_w0 w0
;
273 __be32 desc_list_len
;
274 struct fcnvme_lsdesc_cr_assoc_cmd assoc_cmd
;
277 #define FCNVME_LSDESC_CRA_RQST_MINLEN \
278 (offsetof(struct fcnvme_ls_cr_assoc_rqst, assoc_cmd) + \
279 FCNVME_LSDESC_CRA_CMD_DESC_MINLEN)
281 #define FCNVME_LSDESC_CRA_RQST_MIN_LISTLEN \
282 FCNVME_LSDESC_CRA_CMD_DESC_MINLEN
285 struct fcnvme_ls_cr_assoc_acc
{
286 struct fcnvme_ls_acc_hdr hdr
;
287 struct fcnvme_lsdesc_assoc_id associd
;
288 struct fcnvme_lsdesc_conn_id connectid
;
292 /* FCNVME_LS_CREATE_CONNECTION */
293 struct fcnvme_ls_cr_conn_rqst
{
294 struct fcnvme_ls_rqst_w0 w0
;
295 __be32 desc_list_len
;
296 struct fcnvme_lsdesc_assoc_id associd
;
297 struct fcnvme_lsdesc_cr_conn_cmd connect_cmd
;
300 struct fcnvme_ls_cr_conn_acc
{
301 struct fcnvme_ls_acc_hdr hdr
;
302 struct fcnvme_lsdesc_conn_id connectid
;
305 /* FCNVME_LS_DISCONNECT */
306 struct fcnvme_ls_disconnect_rqst
{
307 struct fcnvme_ls_rqst_w0 w0
;
308 __be32 desc_list_len
;
309 struct fcnvme_lsdesc_assoc_id associd
;
310 struct fcnvme_lsdesc_disconn_cmd discon_cmd
;
313 struct fcnvme_ls_disconnect_acc
{
314 struct fcnvme_ls_acc_hdr hdr
;
319 * Yet to be defined in FC-NVME:
321 #define NVME_FC_CONNECT_TIMEOUT_SEC 2 /* 2 seconds */
322 #define NVME_FC_LS_TIMEOUT_SEC 2 /* 2 seconds */
323 #define NVME_FC_TGTOP_TIMEOUT_SEC 2 /* 2 seconds */
326 * TRADDR string must be of form "nn-<16hexdigits>:pn-<16hexdigits>"
327 * the string is allowed to be specified with or without a "0x" prefix
328 * infront of the <16hexdigits>. Without is considered the "min" string
329 * and with is considered the "max" string. The hexdigits may be upper
332 #define NVME_FC_TRADDR_NNLEN 3 /* "?n-" */
333 #define NVME_FC_TRADDR_OXNNLEN 5 /* "?n-0x" */
334 #define NVME_FC_TRADDR_HEXNAMELEN 16
335 #define NVME_FC_TRADDR_MINLENGTH \
336 (2 * (NVME_FC_TRADDR_NNLEN + NVME_FC_TRADDR_HEXNAMELEN) + 1)
337 #define NVME_FC_TRADDR_MAXLENGTH \
338 (2 * (NVME_FC_TRADDR_OXNNLEN + NVME_FC_TRADDR_HEXNAMELEN) + 1)
339 #define NVME_FC_TRADDR_MIN_PN_OFFSET \
340 (NVME_FC_TRADDR_NNLEN + NVME_FC_TRADDR_HEXNAMELEN + 1)
341 #define NVME_FC_TRADDR_MAX_PN_OFFSET \
342 (NVME_FC_TRADDR_OXNNLEN + NVME_FC_TRADDR_HEXNAMELEN + 1)
345 #endif /* _NVME_FC_H */