James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 1 | /* |
| 2 | * 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 | */ |
| 17 | |
| 18 | /* |
James Smart | 0f222cc | 2017-03-23 20:41:22 -0700 | [diff] [blame] | 19 | * This file contains definitions relative to FC-NVME r1.14 (16-020vB). |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #ifndef _NVME_FC_H |
| 23 | #define _NVME_FC_H 1 |
| 24 | |
| 25 | |
| 26 | #define NVME_CMD_SCSI_ID 0xFD |
| 27 | #define NVME_CMD_FC_ID FC_TYPE_NVME |
| 28 | |
| 29 | /* FC-NVME Cmd IU Flags */ |
| 30 | #define FCNVME_CMD_FLAGS_DIRMASK 0x03 |
| 31 | #define FCNVME_CMD_FLAGS_WRITE 0x01 |
| 32 | #define FCNVME_CMD_FLAGS_READ 0x02 |
| 33 | |
| 34 | struct nvme_fc_cmd_iu { |
| 35 | __u8 scsi_id; |
| 36 | __u8 fc_id; |
| 37 | __be16 iu_len; |
| 38 | __u8 rsvd4[3]; |
| 39 | __u8 flags; |
| 40 | __be64 connection_id; |
| 41 | __be32 csn; |
| 42 | __be32 data_len; |
| 43 | struct nvme_command sqe; |
| 44 | __be32 rsvd88[2]; |
| 45 | }; |
| 46 | |
| 47 | #define NVME_FC_SIZEOF_ZEROS_RSP 12 |
| 48 | |
James Smart | 0f222cc | 2017-03-23 20:41:22 -0700 | [diff] [blame] | 49 | enum { |
| 50 | FCNVME_SC_SUCCESS = 0, |
| 51 | FCNVME_SC_INVALID_FIELD = 1, |
| 52 | FCNVME_SC_INVALID_CONNID = 2, |
| 53 | }; |
| 54 | |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 55 | struct nvme_fc_ersp_iu { |
James Smart | 0f222cc | 2017-03-23 20:41:22 -0700 | [diff] [blame] | 56 | __u8 status_code; |
| 57 | __u8 rsvd1; |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 58 | __be16 iu_len; |
| 59 | __be32 rsn; |
| 60 | __be32 xfrd_len; |
| 61 | __be32 rsvd12; |
| 62 | struct nvme_completion cqe; |
| 63 | /* for now - no additional payload */ |
| 64 | }; |
| 65 | |
| 66 | |
James Smart | 0f222cc | 2017-03-23 20:41:22 -0700 | [diff] [blame] | 67 | /* FC-NVME Link Services */ |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 68 | enum { |
| 69 | FCNVME_LS_RSVD = 0, |
| 70 | FCNVME_LS_RJT = 1, |
| 71 | FCNVME_LS_ACC = 2, |
| 72 | FCNVME_LS_CREATE_ASSOCIATION = 3, |
| 73 | FCNVME_LS_CREATE_CONNECTION = 4, |
| 74 | FCNVME_LS_DISCONNECT = 5, |
| 75 | }; |
| 76 | |
James Smart | 0f222cc | 2017-03-23 20:41:22 -0700 | [diff] [blame] | 77 | /* FC-NVME Link Service Descriptors */ |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 78 | enum { |
| 79 | FCNVME_LSDESC_RSVD = 0x0, |
| 80 | FCNVME_LSDESC_RQST = 0x1, |
| 81 | FCNVME_LSDESC_RJT = 0x2, |
| 82 | FCNVME_LSDESC_CREATE_ASSOC_CMD = 0x3, |
| 83 | FCNVME_LSDESC_CREATE_CONN_CMD = 0x4, |
| 84 | FCNVME_LSDESC_DISCONN_CMD = 0x5, |
| 85 | FCNVME_LSDESC_CONN_ID = 0x6, |
| 86 | FCNVME_LSDESC_ASSOC_ID = 0x7, |
| 87 | }; |
| 88 | |
| 89 | |
| 90 | /* ********** start of Link Service Descriptors ********** */ |
| 91 | |
| 92 | |
| 93 | /* |
| 94 | * fills in length of a descriptor. Struture minus descriptor header |
| 95 | */ |
| 96 | static inline __be32 fcnvme_lsdesc_len(size_t sz) |
| 97 | { |
| 98 | return cpu_to_be32(sz - (2 * sizeof(u32))); |
| 99 | } |
| 100 | |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 101 | struct fcnvme_ls_rqst_w0 { |
| 102 | u8 ls_cmd; /* FCNVME_LS_xxx */ |
| 103 | u8 zeros[3]; |
| 104 | }; |
| 105 | |
| 106 | /* FCNVME_LSDESC_RQST */ |
| 107 | struct fcnvme_lsdesc_rqst { |
| 108 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 109 | __be32 desc_len; |
| 110 | struct fcnvme_ls_rqst_w0 w0; |
| 111 | __be32 rsvd12; |
| 112 | }; |
| 113 | |
James Smart | 0f222cc | 2017-03-23 20:41:22 -0700 | [diff] [blame] | 114 | /* FC-NVME LS RJT reason_code values */ |
| 115 | enum fcnvme_ls_rjt_reason { |
| 116 | FCNVME_RJT_RC_NONE = 0, |
| 117 | /* no reason - not to be sent */ |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 118 | |
James Smart | 0f222cc | 2017-03-23 20:41:22 -0700 | [diff] [blame] | 119 | FCNVME_RJT_RC_INVAL = 0x01, |
| 120 | /* invalid NVMe_LS command code */ |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 121 | |
James Smart | 0f222cc | 2017-03-23 20:41:22 -0700 | [diff] [blame] | 122 | FCNVME_RJT_RC_LOGIC = 0x03, |
| 123 | /* logical error */ |
| 124 | |
| 125 | FCNVME_RJT_RC_UNAB = 0x09, |
| 126 | /* unable to perform command request */ |
| 127 | |
| 128 | FCNVME_RJT_RC_UNSUP = 0x0b, |
| 129 | /* command not supported */ |
| 130 | |
| 131 | FCNVME_RJT_RC_INPROG = 0x0e, |
| 132 | /* command already in progress */ |
| 133 | |
| 134 | FCNVME_RJT_RC_INV_ASSOC = 0x40, |
| 135 | /* Invalid Association ID*/ |
| 136 | |
| 137 | FCNVME_RJT_RC_INV_CONN = 0x41, |
| 138 | /* Invalid Connection ID*/ |
| 139 | |
| 140 | FCNVME_RJT_RC_VENDOR = 0xff, |
| 141 | /* vendor specific error */ |
| 142 | }; |
| 143 | |
| 144 | /* FC-NVME LS RJT reason_explanation values */ |
| 145 | enum fcnvme_ls_rjt_explan { |
| 146 | FCNVME_RJT_EXP_NONE = 0x00, |
| 147 | /* No additional explanation */ |
| 148 | |
| 149 | FCNVME_RJT_EXP_OXID_RXID = 0x17, |
| 150 | /* invalid OX_ID-RX_ID combination */ |
| 151 | |
| 152 | FCNVME_RJT_EXP_INSUF_RES = 0x29, |
| 153 | /* insufficient resources */ |
| 154 | |
| 155 | FCNVME_RJT_EXP_UNAB_DATA = 0x2a, |
| 156 | /* unable to supply requested data */ |
| 157 | |
| 158 | FCNVME_RJT_EXP_INV_LEN = 0x2d, |
| 159 | /* Invalid payload length */ |
| 160 | }; |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 161 | |
| 162 | /* FCNVME_LSDESC_RJT */ |
| 163 | struct fcnvme_lsdesc_rjt { |
| 164 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 165 | __be32 desc_len; |
| 166 | u8 rsvd8; |
| 167 | |
| 168 | /* |
| 169 | * Reject reason and explanaction codes are generic |
| 170 | * to ELs's from LS-3. |
| 171 | */ |
James Smart | 0f222cc | 2017-03-23 20:41:22 -0700 | [diff] [blame] | 172 | u8 reason_code; /* fcnvme_ls_rjt_reason */ |
| 173 | u8 reason_explanation; /* fcnvme_ls_rjt_explan */ |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 174 | |
| 175 | u8 vendor; |
| 176 | __be32 rsvd12; |
| 177 | }; |
| 178 | |
| 179 | |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 180 | #define FCNVME_ASSOC_HOSTNQN_LEN 256 |
| 181 | #define FCNVME_ASSOC_SUBNQN_LEN 256 |
| 182 | |
| 183 | /* FCNVME_LSDESC_CREATE_ASSOC_CMD */ |
| 184 | struct fcnvme_lsdesc_cr_assoc_cmd { |
| 185 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 186 | __be32 desc_len; |
| 187 | __be16 ersp_ratio; |
| 188 | __be16 rsvd10; |
| 189 | __be32 rsvd12[9]; |
| 190 | __be16 cntlid; |
| 191 | __be16 sqsize; |
| 192 | __be32 rsvd52; |
Christoph Hellwig | 8e41226 | 2017-05-17 09:54:27 +0200 | [diff] [blame] | 193 | uuid_t hostid; |
James Smart | b1ad1475 | 2016-12-02 00:28:40 -0800 | [diff] [blame] | 194 | u8 hostnqn[FCNVME_ASSOC_HOSTNQN_LEN]; |
| 195 | u8 subnqn[FCNVME_ASSOC_SUBNQN_LEN]; |
| 196 | u8 rsvd632[384]; |
| 197 | }; |
| 198 | |
| 199 | /* FCNVME_LSDESC_CREATE_CONN_CMD */ |
| 200 | struct fcnvme_lsdesc_cr_conn_cmd { |
| 201 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 202 | __be32 desc_len; |
| 203 | __be16 ersp_ratio; |
| 204 | __be16 rsvd10; |
| 205 | __be32 rsvd12[9]; |
| 206 | __be16 qid; |
| 207 | __be16 sqsize; |
| 208 | __be32 rsvd52; |
| 209 | }; |
| 210 | |
| 211 | /* Disconnect Scope Values */ |
| 212 | enum { |
| 213 | FCNVME_DISCONN_ASSOCIATION = 0, |
| 214 | FCNVME_DISCONN_CONNECTION = 1, |
| 215 | }; |
| 216 | |
| 217 | /* FCNVME_LSDESC_DISCONN_CMD */ |
| 218 | struct fcnvme_lsdesc_disconn_cmd { |
| 219 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 220 | __be32 desc_len; |
| 221 | u8 rsvd8[3]; |
| 222 | /* note: scope is really a 1 bit field */ |
| 223 | u8 scope; /* FCNVME_DISCONN_xxx */ |
| 224 | __be32 rsvd12; |
| 225 | __be64 id; |
| 226 | }; |
| 227 | |
| 228 | /* FCNVME_LSDESC_CONN_ID */ |
| 229 | struct fcnvme_lsdesc_conn_id { |
| 230 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 231 | __be32 desc_len; |
| 232 | __be64 connection_id; |
| 233 | }; |
| 234 | |
| 235 | /* FCNVME_LSDESC_ASSOC_ID */ |
| 236 | struct fcnvme_lsdesc_assoc_id { |
| 237 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 238 | __be32 desc_len; |
| 239 | __be64 association_id; |
| 240 | }; |
| 241 | |
| 242 | /* r_ctl values */ |
| 243 | enum { |
| 244 | FCNVME_RS_RCTL_DATA = 1, |
| 245 | FCNVME_RS_RCTL_XFER_RDY = 5, |
| 246 | FCNVME_RS_RCTL_RSP = 8, |
| 247 | }; |
| 248 | |
| 249 | |
| 250 | /* ********** start of Link Services ********** */ |
| 251 | |
| 252 | |
| 253 | /* FCNVME_LS_RJT */ |
| 254 | struct fcnvme_ls_rjt { |
| 255 | struct fcnvme_ls_rqst_w0 w0; |
| 256 | __be32 desc_list_len; |
| 257 | struct fcnvme_lsdesc_rqst rqst; |
| 258 | struct fcnvme_lsdesc_rjt rjt; |
| 259 | }; |
| 260 | |
| 261 | /* FCNVME_LS_ACC */ |
| 262 | struct fcnvme_ls_acc_hdr { |
| 263 | struct fcnvme_ls_rqst_w0 w0; |
| 264 | __be32 desc_list_len; |
| 265 | struct fcnvme_lsdesc_rqst rqst; |
| 266 | /* Followed by cmd-specific ACC descriptors, see next definitions */ |
| 267 | }; |
| 268 | |
| 269 | /* FCNVME_LS_CREATE_ASSOCIATION */ |
| 270 | struct fcnvme_ls_cr_assoc_rqst { |
| 271 | struct fcnvme_ls_rqst_w0 w0; |
| 272 | __be32 desc_list_len; |
| 273 | struct fcnvme_lsdesc_cr_assoc_cmd assoc_cmd; |
| 274 | }; |
| 275 | |
| 276 | struct fcnvme_ls_cr_assoc_acc { |
| 277 | struct fcnvme_ls_acc_hdr hdr; |
| 278 | struct fcnvme_lsdesc_assoc_id associd; |
| 279 | struct fcnvme_lsdesc_conn_id connectid; |
| 280 | }; |
| 281 | |
| 282 | |
| 283 | /* FCNVME_LS_CREATE_CONNECTION */ |
| 284 | struct fcnvme_ls_cr_conn_rqst { |
| 285 | struct fcnvme_ls_rqst_w0 w0; |
| 286 | __be32 desc_list_len; |
| 287 | struct fcnvme_lsdesc_assoc_id associd; |
| 288 | struct fcnvme_lsdesc_cr_conn_cmd connect_cmd; |
| 289 | }; |
| 290 | |
| 291 | struct fcnvme_ls_cr_conn_acc { |
| 292 | struct fcnvme_ls_acc_hdr hdr; |
| 293 | struct fcnvme_lsdesc_conn_id connectid; |
| 294 | }; |
| 295 | |
| 296 | /* FCNVME_LS_DISCONNECT */ |
| 297 | struct fcnvme_ls_disconnect_rqst { |
| 298 | struct fcnvme_ls_rqst_w0 w0; |
| 299 | __be32 desc_list_len; |
| 300 | struct fcnvme_lsdesc_assoc_id associd; |
| 301 | struct fcnvme_lsdesc_disconn_cmd discon_cmd; |
| 302 | }; |
| 303 | |
| 304 | struct fcnvme_ls_disconnect_acc { |
| 305 | struct fcnvme_ls_acc_hdr hdr; |
| 306 | }; |
| 307 | |
| 308 | |
| 309 | /* |
| 310 | * Yet to be defined in FC-NVME: |
| 311 | */ |
| 312 | #define NVME_FC_CONNECT_TIMEOUT_SEC 2 /* 2 seconds */ |
| 313 | #define NVME_FC_LS_TIMEOUT_SEC 2 /* 2 seconds */ |
| 314 | #define NVME_FC_TGTOP_TIMEOUT_SEC 2 /* 2 seconds */ |
| 315 | |
| 316 | |
| 317 | #endif /* _NVME_FC_H */ |