.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
---|
1 | 2 | /* |
---|
2 | 3 | * 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 | | - * |
---|
16 | 4 | */ |
---|
17 | 5 | |
---|
18 | 6 | /* |
---|
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). |
---|
21 | 9 | */ |
---|
22 | 10 | |
---|
23 | 11 | #ifndef _NVME_FC_H |
---|
24 | 12 | #define _NVME_FC_H 1 |
---|
25 | 13 | |
---|
| 14 | +#include <uapi/scsi/fc/fc_fs.h> |
---|
26 | 15 | |
---|
27 | | -#define NVME_CMD_SCSI_ID 0xFD |
---|
| 16 | +#define NVME_CMD_FORMAT_ID 0xFD |
---|
28 | 17 | #define NVME_CMD_FC_ID FC_TYPE_NVME |
---|
29 | 18 | |
---|
30 | 19 | /* 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 | +} |
---|
34 | 45 | |
---|
35 | 46 | struct nvme_fc_cmd_iu { |
---|
36 | | - __u8 scsi_id; |
---|
| 47 | + __u8 format_id; |
---|
37 | 48 | __u8 fc_id; |
---|
38 | 49 | __be16 iu_len; |
---|
39 | | - __u8 rsvd4[3]; |
---|
| 50 | + __u8 rsvd4[2]; |
---|
| 51 | + __u8 rsv_cat; |
---|
40 | 52 | __u8 flags; |
---|
41 | 53 | __be64 connection_id; |
---|
42 | 54 | __be32 csn; |
---|
43 | 55 | __be32 data_len; |
---|
44 | 56 | struct nvme_command sqe; |
---|
45 | | - __be32 rsvd88[2]; |
---|
| 57 | + __u8 dps; |
---|
| 58 | + __u8 lbads; |
---|
| 59 | + __be16 ms; |
---|
| 60 | + __be32 rsvd92; |
---|
46 | 61 | }; |
---|
47 | 62 | |
---|
48 | 63 | #define NVME_FC_SIZEOF_ZEROS_RSP 12 |
---|
.. | .. |
---|
50 | 65 | enum { |
---|
51 | 66 | FCNVME_SC_SUCCESS = 0, |
---|
52 | 67 | FCNVME_SC_INVALID_FIELD = 1, |
---|
53 | | - FCNVME_SC_INVALID_CONNID = 2, |
---|
| 68 | + /* reserved 2 */ |
---|
| 69 | + FCNVME_SC_ILL_CONN_PARAMS = 3, |
---|
54 | 70 | }; |
---|
55 | 71 | |
---|
56 | 72 | struct nvme_fc_ersp_iu { |
---|
57 | | - __u8 status_code; |
---|
| 73 | + __u8 ersp_result; |
---|
58 | 74 | __u8 rsvd1; |
---|
59 | 75 | __be16 iu_len; |
---|
60 | 76 | __be32 rsn; |
---|
.. | .. |
---|
65 | 81 | }; |
---|
66 | 82 | |
---|
67 | 83 | |
---|
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) */ |
---|
69 | 115 | enum { |
---|
70 | 116 | FCNVME_LS_RSVD = 0, |
---|
71 | 117 | FCNVME_LS_RJT = 1, |
---|
72 | 118 | 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 */ |
---|
76 | 123 | }; |
---|
77 | 124 | |
---|
78 | 125 | /* FC-NVME Link Service Descriptors */ |
---|
.. | .. |
---|
129 | 176 | FCNVME_RJT_RC_UNSUP = 0x0b, |
---|
130 | 177 | /* command not supported */ |
---|
131 | 178 | |
---|
132 | | - FCNVME_RJT_RC_INPROG = 0x0e, |
---|
133 | | - /* command already in progress */ |
---|
134 | | - |
---|
135 | 179 | FCNVME_RJT_RC_INV_ASSOC = 0x40, |
---|
136 | | - /* Invalid Association ID*/ |
---|
| 180 | + /* Invalid Association ID */ |
---|
137 | 181 | |
---|
138 | 182 | 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 */ |
---|
140 | 190 | |
---|
141 | 191 | FCNVME_RJT_RC_VENDOR = 0xff, |
---|
142 | 192 | /* vendor specific error */ |
---|
.. | .. |
---|
150 | 200 | FCNVME_RJT_EXP_OXID_RXID = 0x17, |
---|
151 | 201 | /* invalid OX_ID-RX_ID combination */ |
---|
152 | 202 | |
---|
153 | | - FCNVME_RJT_EXP_INSUF_RES = 0x29, |
---|
154 | | - /* insufficient resources */ |
---|
155 | | - |
---|
156 | 203 | FCNVME_RJT_EXP_UNAB_DATA = 0x2a, |
---|
157 | 204 | /* unable to supply requested data */ |
---|
158 | 205 | |
---|
159 | 206 | FCNVME_RJT_EXP_INV_LEN = 0x2d, |
---|
160 | 207 | /* 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 */ |
---|
161 | 229 | }; |
---|
162 | 230 | |
---|
163 | 231 | /* FCNVME_LSDESC_RJT */ |
---|
.. | .. |
---|
221 | 289 | __be32 rsvd52; |
---|
222 | 290 | }; |
---|
223 | 291 | |
---|
224 | | -/* Disconnect Scope Values */ |
---|
225 | | -enum { |
---|
226 | | - FCNVME_DISCONN_ASSOCIATION = 0, |
---|
227 | | - FCNVME_DISCONN_CONNECTION = 1, |
---|
228 | | -}; |
---|
229 | | - |
---|
230 | 292 | /* FCNVME_LSDESC_DISCONN_CMD */ |
---|
231 | 293 | struct fcnvme_lsdesc_disconn_cmd { |
---|
232 | 294 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
---|
233 | 295 | __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]; |
---|
239 | 297 | }; |
---|
240 | 298 | |
---|
241 | 299 | /* FCNVME_LSDESC_CONN_ID */ |
---|
.. | .. |
---|
254 | 312 | |
---|
255 | 313 | /* r_ctl values */ |
---|
256 | 314 | 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, |
---|
260 | 323 | }; |
---|
261 | 324 | |
---|
262 | 325 | |
---|
.. | .. |
---|
276 | 339 | struct fcnvme_ls_rqst_w0 w0; |
---|
277 | 340 | __be32 desc_list_len; |
---|
278 | 341 | 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 | + */ |
---|
280 | 346 | }; |
---|
281 | 347 | |
---|
282 | 348 | /* FCNVME_LS_CREATE_ASSOCIATION */ |
---|
.. | .. |
---|
314 | 380 | struct fcnvme_lsdesc_conn_id connectid; |
---|
315 | 381 | }; |
---|
316 | 382 | |
---|
317 | | -/* FCNVME_LS_DISCONNECT */ |
---|
318 | | -struct fcnvme_ls_disconnect_rqst { |
---|
| 383 | +/* FCNVME_LS_DISCONNECT_ASSOC */ |
---|
| 384 | +struct fcnvme_ls_disconnect_assoc_rqst { |
---|
319 | 385 | struct fcnvme_ls_rqst_w0 w0; |
---|
320 | 386 | __be32 desc_list_len; |
---|
321 | 387 | struct fcnvme_lsdesc_assoc_id associd; |
---|
322 | 388 | struct fcnvme_lsdesc_disconn_cmd discon_cmd; |
---|
323 | 389 | }; |
---|
324 | 390 | |
---|
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 { |
---|
326 | 405 | struct fcnvme_ls_acc_hdr hdr; |
---|
327 | 406 | }; |
---|
328 | 407 | |
---|
329 | 408 | |
---|
330 | 409 | /* |
---|
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. |
---|
332 | 412 | */ |
---|
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 |
---|
336 | 416 | |
---|
337 | 417 | /* |
---|
338 | 418 | * TRADDR string must be of form "nn-<16hexdigits>:pn-<16hexdigits>" |
---|
.. | .. |
---|
340 | 420 | * infront of the <16hexdigits>. Without is considered the "min" string |
---|
341 | 421 | * and with is considered the "max" string. The hexdigits may be upper |
---|
342 | 422 | * or lower case. |
---|
| 423 | + * Note: FC-NVME-2 standard requires a "0x" prefix. |
---|
343 | 424 | */ |
---|
344 | 425 | #define NVME_FC_TRADDR_NNLEN 3 /* "?n-" */ |
---|
345 | 426 | #define NVME_FC_TRADDR_OXNNLEN 5 /* "?n-0x" */ |
---|