hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/nvme-fc.h
....@@ -1,48 +1,63 @@
1
+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
23 * Copyright (c) 2016 Avago Technologies. All rights reserved.
3
- *
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.
7
- *
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
15
- *
164 */
175
186 /*
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.
7
+ * This file contains definitions relative to FC-NVME-2 r1.08
8
+ * (T11-2019-00210-v004).
219 */
2210
2311 #ifndef _NVME_FC_H
2412 #define _NVME_FC_H 1
2513
14
+#include <uapi/scsi/fc/fc_fs.h>
2615
27
-#define NVME_CMD_SCSI_ID 0xFD
16
+#define NVME_CMD_FORMAT_ID 0xFD
2817 #define NVME_CMD_FC_ID FC_TYPE_NVME
2918
3019 /* 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
20
+enum {
21
+ FCNVME_CMD_FLAGS_DIRMASK = 0x03,
22
+ FCNVME_CMD_FLAGS_WRITE = (1 << 0),
23
+ FCNVME_CMD_FLAGS_READ = (1 << 1),
24
+
25
+ FCNVME_CMD_FLAGS_PICWP = (1 << 2),
26
+};
27
+
28
+enum {
29
+ FCNVME_CMD_CAT_MASK = 0x0F,
30
+ FCNVME_CMD_CAT_ADMINQ = 0x01,
31
+ FCNVME_CMD_CAT_CSSMASK = 0x07,
32
+ FCNVME_CMD_CAT_CSSFLAG = 0x08,
33
+};
34
+
35
+static inline __u8 fccmnd_set_cat_admin(__u8 rsv_cat)
36
+{
37
+ return (rsv_cat & ~FCNVME_CMD_CAT_MASK) | FCNVME_CMD_CAT_ADMINQ;
38
+}
39
+
40
+static inline __u8 fccmnd_set_cat_css(__u8 rsv_cat, __u8 css)
41
+{
42
+ return (rsv_cat & ~FCNVME_CMD_CAT_MASK) | FCNVME_CMD_CAT_CSSFLAG |
43
+ (css & FCNVME_CMD_CAT_CSSMASK);
44
+}
3445
3546 struct nvme_fc_cmd_iu {
36
- __u8 scsi_id;
47
+ __u8 format_id;
3748 __u8 fc_id;
3849 __be16 iu_len;
39
- __u8 rsvd4[3];
50
+ __u8 rsvd4[2];
51
+ __u8 rsv_cat;
4052 __u8 flags;
4153 __be64 connection_id;
4254 __be32 csn;
4355 __be32 data_len;
4456 struct nvme_command sqe;
45
- __be32 rsvd88[2];
57
+ __u8 dps;
58
+ __u8 lbads;
59
+ __be16 ms;
60
+ __be32 rsvd92;
4661 };
4762
4863 #define NVME_FC_SIZEOF_ZEROS_RSP 12
....@@ -50,11 +65,12 @@
5065 enum {
5166 FCNVME_SC_SUCCESS = 0,
5267 FCNVME_SC_INVALID_FIELD = 1,
53
- FCNVME_SC_INVALID_CONNID = 2,
68
+ /* reserved 2 */
69
+ FCNVME_SC_ILL_CONN_PARAMS = 3,
5470 };
5571
5672 struct nvme_fc_ersp_iu {
57
- __u8 status_code;
73
+ __u8 ersp_result;
5874 __u8 rsvd1;
5975 __be16 iu_len;
6076 __be32 rsn;
....@@ -65,14 +81,45 @@
6581 };
6682
6783
68
-/* FC-NVME Link Services */
84
+#define FCNVME_NVME_SR_OPCODE 0x01
85
+#define FCNVME_NVME_SR_RSP_OPCODE 0x02
86
+
87
+struct nvme_fc_nvme_sr_iu {
88
+ __u8 fc_id;
89
+ __u8 opcode;
90
+ __u8 rsvd2;
91
+ __u8 retry_rctl;
92
+ __be32 rsvd4;
93
+};
94
+
95
+
96
+enum {
97
+ FCNVME_SRSTAT_ACC = 0x0,
98
+ /* reserved 0x1 */
99
+ /* reserved 0x2 */
100
+ FCNVME_SRSTAT_LOGICAL_ERR = 0x3,
101
+ FCNVME_SRSTAT_INV_QUALIF = 0x4,
102
+ FCNVME_SRSTAT_UNABL2PERFORM = 0x9,
103
+};
104
+
105
+struct nvme_fc_nvme_sr_rsp_iu {
106
+ __u8 fc_id;
107
+ __u8 opcode;
108
+ __u8 rsvd2;
109
+ __u8 status;
110
+ __be32 rsvd4;
111
+};
112
+
113
+
114
+/* FC-NVME Link Services - LS cmd values (w0 bits 31:24) */
69115 enum {
70116 FCNVME_LS_RSVD = 0,
71117 FCNVME_LS_RJT = 1,
72118 FCNVME_LS_ACC = 2,
73
- FCNVME_LS_CREATE_ASSOCIATION = 3,
74
- FCNVME_LS_CREATE_CONNECTION = 4,
75
- FCNVME_LS_DISCONNECT = 5,
119
+ FCNVME_LS_CREATE_ASSOCIATION = 3, /* Create Association */
120
+ FCNVME_LS_CREATE_CONNECTION = 4, /* Create I/O Connection */
121
+ FCNVME_LS_DISCONNECT_ASSOC = 5, /* Disconnect Association */
122
+ FCNVME_LS_DISCONNECT_CONN = 6, /* Disconnect Connection */
76123 };
77124
78125 /* FC-NVME Link Service Descriptors */
....@@ -129,14 +176,17 @@
129176 FCNVME_RJT_RC_UNSUP = 0x0b,
130177 /* command not supported */
131178
132
- FCNVME_RJT_RC_INPROG = 0x0e,
133
- /* command already in progress */
134
-
135179 FCNVME_RJT_RC_INV_ASSOC = 0x40,
136
- /* Invalid Association ID*/
180
+ /* Invalid Association ID */
137181
138182 FCNVME_RJT_RC_INV_CONN = 0x41,
139
- /* Invalid Connection ID*/
183
+ /* Invalid Connection ID */
184
+
185
+ FCNVME_RJT_RC_INV_PARAM = 0x42,
186
+ /* Invalid Parameters */
187
+
188
+ FCNVME_RJT_RC_INSUF_RES = 0x43,
189
+ /* Insufficient Resources */
140190
141191 FCNVME_RJT_RC_VENDOR = 0xff,
142192 /* vendor specific error */
....@@ -150,14 +200,32 @@
150200 FCNVME_RJT_EXP_OXID_RXID = 0x17,
151201 /* invalid OX_ID-RX_ID combination */
152202
153
- FCNVME_RJT_EXP_INSUF_RES = 0x29,
154
- /* insufficient resources */
155
-
156203 FCNVME_RJT_EXP_UNAB_DATA = 0x2a,
157204 /* unable to supply requested data */
158205
159206 FCNVME_RJT_EXP_INV_LEN = 0x2d,
160207 /* Invalid payload length */
208
+
209
+ FCNVME_RJT_EXP_INV_ERSP_RAT = 0x40,
210
+ /* Invalid NVMe_ERSP Ratio */
211
+
212
+ FCNVME_RJT_EXP_INV_CTLR_ID = 0x41,
213
+ /* Invalid Controller ID */
214
+
215
+ FCNVME_RJT_EXP_INV_QUEUE_ID = 0x42,
216
+ /* Invalid Queue ID */
217
+
218
+ FCNVME_RJT_EXP_INV_SQSIZE = 0x43,
219
+ /* Invalid Submission Queue Size */
220
+
221
+ FCNVME_RJT_EXP_INV_HOSTID = 0x44,
222
+ /* Invalid HOST ID */
223
+
224
+ FCNVME_RJT_EXP_INV_HOSTNQN = 0x45,
225
+ /* Invalid HOSTNQN */
226
+
227
+ FCNVME_RJT_EXP_INV_SUBNQN = 0x46,
228
+ /* Invalid SUBNQN */
161229 };
162230
163231 /* FCNVME_LSDESC_RJT */
....@@ -221,21 +289,11 @@
221289 __be32 rsvd52;
222290 };
223291
224
-/* Disconnect Scope Values */
225
-enum {
226
- FCNVME_DISCONN_ASSOCIATION = 0,
227
- FCNVME_DISCONN_CONNECTION = 1,
228
-};
229
-
230292 /* FCNVME_LSDESC_DISCONN_CMD */
231293 struct fcnvme_lsdesc_disconn_cmd {
232294 __be32 desc_tag; /* FCNVME_LSDESC_xxx */
233295 __be32 desc_len;
234
- u8 rsvd8[3];
235
- /* note: scope is really a 1 bit field */
236
- u8 scope; /* FCNVME_DISCONN_xxx */
237
- __be32 rsvd12;
238
- __be64 id;
296
+ __be32 rsvd8[4];
239297 };
240298
241299 /* FCNVME_LSDESC_CONN_ID */
....@@ -254,9 +312,14 @@
254312
255313 /* r_ctl values */
256314 enum {
257
- FCNVME_RS_RCTL_DATA = 1,
258
- FCNVME_RS_RCTL_XFER_RDY = 5,
259
- FCNVME_RS_RCTL_RSP = 8,
315
+ FCNVME_RS_RCTL_CMND = 0x6,
316
+ FCNVME_RS_RCTL_DATA = 0x1,
317
+ FCNVME_RS_RCTL_CONF = 0x3,
318
+ FCNVME_RS_RCTL_SR = 0x9,
319
+ FCNVME_RS_RCTL_XFER_RDY = 0x5,
320
+ FCNVME_RS_RCTL_RSP = 0x7,
321
+ FCNVME_RS_RCTL_ERSP = 0x8,
322
+ FCNVME_RS_RCTL_SR_RSP = 0xA,
260323 };
261324
262325
....@@ -276,7 +339,10 @@
276339 struct fcnvme_ls_rqst_w0 w0;
277340 __be32 desc_list_len;
278341 struct fcnvme_lsdesc_rqst rqst;
279
- /* Followed by cmd-specific ACC descriptors, see next definitions */
342
+ /*
343
+ * Followed by cmd-specific ACCEPT descriptors, see xxx_acc
344
+ * definitions below
345
+ */
280346 };
281347
282348 /* FCNVME_LS_CREATE_ASSOCIATION */
....@@ -314,25 +380,39 @@
314380 struct fcnvme_lsdesc_conn_id connectid;
315381 };
316382
317
-/* FCNVME_LS_DISCONNECT */
318
-struct fcnvme_ls_disconnect_rqst {
383
+/* FCNVME_LS_DISCONNECT_ASSOC */
384
+struct fcnvme_ls_disconnect_assoc_rqst {
319385 struct fcnvme_ls_rqst_w0 w0;
320386 __be32 desc_list_len;
321387 struct fcnvme_lsdesc_assoc_id associd;
322388 struct fcnvme_lsdesc_disconn_cmd discon_cmd;
323389 };
324390
325
-struct fcnvme_ls_disconnect_acc {
391
+struct fcnvme_ls_disconnect_assoc_acc {
392
+ struct fcnvme_ls_acc_hdr hdr;
393
+};
394
+
395
+
396
+/* FCNVME_LS_DISCONNECT_CONN */
397
+struct fcnvme_ls_disconnect_conn_rqst {
398
+ struct fcnvme_ls_rqst_w0 w0;
399
+ __be32 desc_list_len;
400
+ struct fcnvme_lsdesc_assoc_id associd;
401
+ struct fcnvme_lsdesc_conn_id connectid;
402
+};
403
+
404
+struct fcnvme_ls_disconnect_conn_acc {
326405 struct fcnvme_ls_acc_hdr hdr;
327406 };
328407
329408
330409 /*
331
- * Yet to be defined in FC-NVME:
410
+ * Default R_A_TOV is pulled in from fc_fs.h but needs conversion
411
+ * from ms to seconds for our use.
332412 */
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 */
413
+#define FC_TWO_TIMES_R_A_TOV (2 * (FC_DEF_R_A_TOV / 1000))
414
+#define NVME_FC_LS_TIMEOUT_SEC FC_TWO_TIMES_R_A_TOV
415
+#define NVME_FC_TGTOP_TIMEOUT_SEC FC_TWO_TIMES_R_A_TOV
336416
337417 /*
338418 * TRADDR string must be of form "nn-<16hexdigits>:pn-<16hexdigits>"
....@@ -340,6 +420,7 @@
340420 * infront of the <16hexdigits>. Without is considered the "min" string
341421 * and with is considered the "max" string. The hexdigits may be upper
342422 * or lower case.
423
+ * Note: FC-NVME-2 standard requires a "0x" prefix.
343424 */
344425 #define NVME_FC_TRADDR_NNLEN 3 /* "?n-" */
345426 #define NVME_FC_TRADDR_OXNNLEN 5 /* "?n-0x" */