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 | /* |
| 19 | * This file contains definitions relative to FC-NVME r1.11 and a few |
| 20 | * newer items |
| 21 | */ |
| 22 | |
| 23 | #ifndef _NVME_FC_H |
| 24 | #define _NVME_FC_H 1 |
| 25 | |
| 26 | |
| 27 | #define NVME_CMD_SCSI_ID 0xFD |
| 28 | #define NVME_CMD_FC_ID FC_TYPE_NVME |
| 29 | |
| 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 |
| 34 | |
| 35 | struct nvme_fc_cmd_iu { |
| 36 | __u8 scsi_id; |
| 37 | __u8 fc_id; |
| 38 | __be16 iu_len; |
| 39 | __u8 rsvd4[3]; |
| 40 | __u8 flags; |
| 41 | __be64 connection_id; |
| 42 | __be32 csn; |
| 43 | __be32 data_len; |
| 44 | struct nvme_command sqe; |
| 45 | __be32 rsvd88[2]; |
| 46 | }; |
| 47 | |
| 48 | #define NVME_FC_SIZEOF_ZEROS_RSP 12 |
| 49 | |
| 50 | struct nvme_fc_ersp_iu { |
| 51 | __u8 rsvd0[2]; |
| 52 | __be16 iu_len; |
| 53 | __be32 rsn; |
| 54 | __be32 xfrd_len; |
| 55 | __be32 rsvd12; |
| 56 | struct nvme_completion cqe; |
| 57 | /* for now - no additional payload */ |
| 58 | }; |
| 59 | |
| 60 | |
| 61 | /* FC-NVME r1.03/16-119v0 NVME Link Services */ |
| 62 | enum { |
| 63 | FCNVME_LS_RSVD = 0, |
| 64 | FCNVME_LS_RJT = 1, |
| 65 | FCNVME_LS_ACC = 2, |
| 66 | FCNVME_LS_CREATE_ASSOCIATION = 3, |
| 67 | FCNVME_LS_CREATE_CONNECTION = 4, |
| 68 | FCNVME_LS_DISCONNECT = 5, |
| 69 | }; |
| 70 | |
| 71 | /* FC-NVME r1.03/16-119v0 NVME Link Service Descriptors */ |
| 72 | enum { |
| 73 | FCNVME_LSDESC_RSVD = 0x0, |
| 74 | FCNVME_LSDESC_RQST = 0x1, |
| 75 | FCNVME_LSDESC_RJT = 0x2, |
| 76 | FCNVME_LSDESC_CREATE_ASSOC_CMD = 0x3, |
| 77 | FCNVME_LSDESC_CREATE_CONN_CMD = 0x4, |
| 78 | FCNVME_LSDESC_DISCONN_CMD = 0x5, |
| 79 | FCNVME_LSDESC_CONN_ID = 0x6, |
| 80 | FCNVME_LSDESC_ASSOC_ID = 0x7, |
| 81 | }; |
| 82 | |
| 83 | |
| 84 | /* ********** start of Link Service Descriptors ********** */ |
| 85 | |
| 86 | |
| 87 | /* |
| 88 | * fills in length of a descriptor. Struture minus descriptor header |
| 89 | */ |
| 90 | static inline __be32 fcnvme_lsdesc_len(size_t sz) |
| 91 | { |
| 92 | return cpu_to_be32(sz - (2 * sizeof(u32))); |
| 93 | } |
| 94 | |
| 95 | |
| 96 | struct fcnvme_ls_rqst_w0 { |
| 97 | u8 ls_cmd; /* FCNVME_LS_xxx */ |
| 98 | u8 zeros[3]; |
| 99 | }; |
| 100 | |
| 101 | /* FCNVME_LSDESC_RQST */ |
| 102 | struct fcnvme_lsdesc_rqst { |
| 103 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 104 | __be32 desc_len; |
| 105 | struct fcnvme_ls_rqst_w0 w0; |
| 106 | __be32 rsvd12; |
| 107 | }; |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | /* FCNVME_LSDESC_RJT */ |
| 113 | struct fcnvme_lsdesc_rjt { |
| 114 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 115 | __be32 desc_len; |
| 116 | u8 rsvd8; |
| 117 | |
| 118 | /* |
| 119 | * Reject reason and explanaction codes are generic |
| 120 | * to ELs's from LS-3. |
| 121 | */ |
| 122 | u8 reason_code; |
| 123 | u8 reason_explanation; |
| 124 | |
| 125 | u8 vendor; |
| 126 | __be32 rsvd12; |
| 127 | }; |
| 128 | |
| 129 | |
| 130 | #define FCNVME_ASSOC_HOSTID_LEN 64 |
| 131 | #define FCNVME_ASSOC_HOSTNQN_LEN 256 |
| 132 | #define FCNVME_ASSOC_SUBNQN_LEN 256 |
| 133 | |
| 134 | /* FCNVME_LSDESC_CREATE_ASSOC_CMD */ |
| 135 | struct fcnvme_lsdesc_cr_assoc_cmd { |
| 136 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 137 | __be32 desc_len; |
| 138 | __be16 ersp_ratio; |
| 139 | __be16 rsvd10; |
| 140 | __be32 rsvd12[9]; |
| 141 | __be16 cntlid; |
| 142 | __be16 sqsize; |
| 143 | __be32 rsvd52; |
| 144 | u8 hostid[FCNVME_ASSOC_HOSTID_LEN]; |
| 145 | u8 hostnqn[FCNVME_ASSOC_HOSTNQN_LEN]; |
| 146 | u8 subnqn[FCNVME_ASSOC_SUBNQN_LEN]; |
| 147 | u8 rsvd632[384]; |
| 148 | }; |
| 149 | |
| 150 | /* FCNVME_LSDESC_CREATE_CONN_CMD */ |
| 151 | struct fcnvme_lsdesc_cr_conn_cmd { |
| 152 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 153 | __be32 desc_len; |
| 154 | __be16 ersp_ratio; |
| 155 | __be16 rsvd10; |
| 156 | __be32 rsvd12[9]; |
| 157 | __be16 qid; |
| 158 | __be16 sqsize; |
| 159 | __be32 rsvd52; |
| 160 | }; |
| 161 | |
| 162 | /* Disconnect Scope Values */ |
| 163 | enum { |
| 164 | FCNVME_DISCONN_ASSOCIATION = 0, |
| 165 | FCNVME_DISCONN_CONNECTION = 1, |
| 166 | }; |
| 167 | |
| 168 | /* FCNVME_LSDESC_DISCONN_CMD */ |
| 169 | struct fcnvme_lsdesc_disconn_cmd { |
| 170 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 171 | __be32 desc_len; |
| 172 | u8 rsvd8[3]; |
| 173 | /* note: scope is really a 1 bit field */ |
| 174 | u8 scope; /* FCNVME_DISCONN_xxx */ |
| 175 | __be32 rsvd12; |
| 176 | __be64 id; |
| 177 | }; |
| 178 | |
| 179 | /* FCNVME_LSDESC_CONN_ID */ |
| 180 | struct fcnvme_lsdesc_conn_id { |
| 181 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 182 | __be32 desc_len; |
| 183 | __be64 connection_id; |
| 184 | }; |
| 185 | |
| 186 | /* FCNVME_LSDESC_ASSOC_ID */ |
| 187 | struct fcnvme_lsdesc_assoc_id { |
| 188 | __be32 desc_tag; /* FCNVME_LSDESC_xxx */ |
| 189 | __be32 desc_len; |
| 190 | __be64 association_id; |
| 191 | }; |
| 192 | |
| 193 | /* r_ctl values */ |
| 194 | enum { |
| 195 | FCNVME_RS_RCTL_DATA = 1, |
| 196 | FCNVME_RS_RCTL_XFER_RDY = 5, |
| 197 | FCNVME_RS_RCTL_RSP = 8, |
| 198 | }; |
| 199 | |
| 200 | |
| 201 | /* ********** start of Link Services ********** */ |
| 202 | |
| 203 | |
| 204 | /* FCNVME_LS_RJT */ |
| 205 | struct fcnvme_ls_rjt { |
| 206 | struct fcnvme_ls_rqst_w0 w0; |
| 207 | __be32 desc_list_len; |
| 208 | struct fcnvme_lsdesc_rqst rqst; |
| 209 | struct fcnvme_lsdesc_rjt rjt; |
| 210 | }; |
| 211 | |
| 212 | /* FCNVME_LS_ACC */ |
| 213 | struct fcnvme_ls_acc_hdr { |
| 214 | struct fcnvme_ls_rqst_w0 w0; |
| 215 | __be32 desc_list_len; |
| 216 | struct fcnvme_lsdesc_rqst rqst; |
| 217 | /* Followed by cmd-specific ACC descriptors, see next definitions */ |
| 218 | }; |
| 219 | |
| 220 | /* FCNVME_LS_CREATE_ASSOCIATION */ |
| 221 | struct fcnvme_ls_cr_assoc_rqst { |
| 222 | struct fcnvme_ls_rqst_w0 w0; |
| 223 | __be32 desc_list_len; |
| 224 | struct fcnvme_lsdesc_cr_assoc_cmd assoc_cmd; |
| 225 | }; |
| 226 | |
| 227 | struct fcnvme_ls_cr_assoc_acc { |
| 228 | struct fcnvme_ls_acc_hdr hdr; |
| 229 | struct fcnvme_lsdesc_assoc_id associd; |
| 230 | struct fcnvme_lsdesc_conn_id connectid; |
| 231 | }; |
| 232 | |
| 233 | |
| 234 | /* FCNVME_LS_CREATE_CONNECTION */ |
| 235 | struct fcnvme_ls_cr_conn_rqst { |
| 236 | struct fcnvme_ls_rqst_w0 w0; |
| 237 | __be32 desc_list_len; |
| 238 | struct fcnvme_lsdesc_assoc_id associd; |
| 239 | struct fcnvme_lsdesc_cr_conn_cmd connect_cmd; |
| 240 | }; |
| 241 | |
| 242 | struct fcnvme_ls_cr_conn_acc { |
| 243 | struct fcnvme_ls_acc_hdr hdr; |
| 244 | struct fcnvme_lsdesc_conn_id connectid; |
| 245 | }; |
| 246 | |
| 247 | /* FCNVME_LS_DISCONNECT */ |
| 248 | struct fcnvme_ls_disconnect_rqst { |
| 249 | struct fcnvme_ls_rqst_w0 w0; |
| 250 | __be32 desc_list_len; |
| 251 | struct fcnvme_lsdesc_assoc_id associd; |
| 252 | struct fcnvme_lsdesc_disconn_cmd discon_cmd; |
| 253 | }; |
| 254 | |
| 255 | struct fcnvme_ls_disconnect_acc { |
| 256 | struct fcnvme_ls_acc_hdr hdr; |
| 257 | }; |
| 258 | |
| 259 | |
| 260 | /* |
| 261 | * Yet to be defined in FC-NVME: |
| 262 | */ |
| 263 | #define NVME_FC_CONNECT_TIMEOUT_SEC 2 /* 2 seconds */ |
| 264 | #define NVME_FC_LS_TIMEOUT_SEC 2 /* 2 seconds */ |
| 265 | #define NVME_FC_TGTOP_TIMEOUT_SEC 2 /* 2 seconds */ |
| 266 | |
| 267 | |
| 268 | #endif /* _NVME_FC_H */ |