1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _FCIO_H 27 #define _FCIO_H 28 29 30 #include <sys/note.h> 31 #include <sys/fibre-channel/fc_types.h> 32 #include <sys/fibre-channel/fc_appif.h> 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 /* 39 * ioctl definitions 40 */ 41 #define FCTIO ('F'<< 8) 42 43 /* 44 * New ioctl definitions 45 */ 46 #define FCIO_CMD (FCTIO | 1998) 47 #define FCIO_SUB_CMD ('Z' << 8) 48 #define FCIO_GET_NUM_DEVS (FCIO_SUB_CMD + 0x01) 49 #define FCIO_GET_DEV_LIST (FCIO_SUB_CMD + 0x02) 50 #define FCIO_GET_SYM_PNAME (FCIO_SUB_CMD + 0x03) 51 #define FCIO_GET_SYM_NNAME (FCIO_SUB_CMD + 0x04) 52 #define FCIO_SET_SYM_PNAME (FCIO_SUB_CMD + 0x05) 53 #define FCIO_SET_SYM_NNAME (FCIO_SUB_CMD + 0x06) 54 #define FCIO_GET_LOGI_PARAMS (FCIO_SUB_CMD + 0x07) 55 #define FCIO_DEV_LOGIN (FCIO_SUB_CMD + 0x08) 56 #define FCIO_DEV_LOGOUT (FCIO_SUB_CMD + 0x09) 57 #define FCIO_GET_STATE (FCIO_SUB_CMD + 0x0A) 58 #define FCIO_DEV_REMOVE (FCIO_SUB_CMD + 0x0B) 59 #define FCIO_GET_FCODE_REV (FCIO_SUB_CMD + 0x0C) 60 #define FCIO_GET_FW_REV (FCIO_SUB_CMD + 0x0D) 61 #define FCIO_GET_DUMP_SIZE (FCIO_SUB_CMD + 0x0E) 62 #define FCIO_FORCE_DUMP (FCIO_SUB_CMD + 0x0F) 63 #define FCIO_GET_DUMP (FCIO_SUB_CMD + 0x10) 64 #define FCIO_GET_TOPOLOGY (FCIO_SUB_CMD + 0x11) 65 #define FCIO_RESET_LINK (FCIO_SUB_CMD + 0x12) 66 #define FCIO_RESET_HARD (FCIO_SUB_CMD + 0x13) 67 #define FCIO_RESET_HARD_CORE (FCIO_SUB_CMD + 0x14) 68 #define FCIO_DIAG (FCIO_SUB_CMD + 0x15) 69 #define FCIO_NS (FCIO_SUB_CMD + 0x16) 70 #define FCIO_DOWNLOAD_FW (FCIO_SUB_CMD + 0x17) 71 #define FCIO_GET_HOST_PARAMS (FCIO_SUB_CMD + 0x18) 72 #define FCIO_LINK_STATUS (FCIO_SUB_CMD + 0x19) 73 #define FCIO_DOWNLOAD_FCODE (FCIO_SUB_CMD + 0x1A) 74 #define FCIO_GET_NODE_ID (FCIO_SUB_CMD + 0x1B) 75 #define FCIO_SET_NODE_ID (FCIO_SUB_CMD + 0x1C) 76 #define FCIO_SEND_NODE_ID (FCIO_SUB_CMD + 0x1D) 77 78 /* 79 * IOCTLs to handle T11's FC-HBA library 80 */ 81 #define FCIO_GET_ADAPTER_ATTRIBUTES (FCIO_SUB_CMD + 0x1E) 82 #define FCIO_GET_OTHER_ADAPTER_PORTS (FCIO_SUB_CMD + 0x1F) 83 #define FCIO_GET_ADAPTER_PORT_ATTRIBUTES (FCIO_SUB_CMD + 0x20) 84 #define FCIO_GET_DISCOVERED_PORT_ATTRIBUTES (FCIO_SUB_CMD + 0x21) 85 #define FCIO_GET_PORT_ATTRIBUTES (FCIO_SUB_CMD + 0x22) 86 #define FCIO_GET_ADAPTER_PORT_STATS (FCIO_SUB_CMD + 0x23) 87 #define FCIO_GET_ADAPTER_PORT_NPIV_ATTRIBUTES (FCIO_SUB_CMD + 0x24) 88 #define FCIO_CREATE_NPIV_PORT (FCIO_SUB_CMD + 0x25) 89 #define FCIO_GET_NPIV_ATTRIBUTES (FCIO_SUB_CMD + 0x26) 90 #define FCIO_GET_DISCOVERED_NPIV_ATTRIBUTES (FCIO_SUB_CMD + 0x27) 91 #define FCIO_GET_NPIV_PORT_LIST (FCIO_SUB_CMD + 0x28) 92 #define FCIO_DELETE_NPIV_PORT (FCIO_SUB_CMD + 0x29) 93 #define FCIO_NPIV_GET_ADAPTER_ATTRIBUTES (FCIO_SUB_CMD + 0x2a) 94 95 96 /* 97 * Fixed diag_codes for FCIO_DIAG. These is supported by all FCAs. 98 * No FCA should define ioctls in this range. 99 */ 100 #define FCIO_DIAG_PORT_DISABLE (FCIO_SUB_CMD + 0x80) 101 #define FCIO_DIAG_PORT_ENABLE (FCIO_SUB_CMD + 0x81) 102 103 /* cmd_flags for FCIO_LINK_STATUS ioctl */ 104 #define FCIO_CFLAGS_RLS_DEST_NPORT 0x0000 105 #define FCIO_CFLAGS_RLS_DEST_FPORT 0x0001 106 107 /* 108 * Note about fc_port_dev_t structure : The dev_did.priv_lilp_posit field will 109 * return the lilp map position of the port for diagnostics to use. 110 * It is important to note that dev_did.priv_lilp_posit field will only have 111 * valid loop position for Private Loop devices ONLY and the value 112 * contained in this field for other topologies will be undetermined. 113 */ 114 typedef struct fc_port_dev { 115 uchar_t dev_dtype; /* SCSI device type */ 116 uint32_t dev_type[8]; /* protocol specific */ 117 uint32_t dev_state; /* port state */ 118 fc_portid_t dev_did; /* Destination Identifier */ 119 fc_hardaddr_t dev_hard_addr; /* Hard address */ 120 la_wwn_t dev_pwwn; /* port WWN */ 121 la_wwn_t dev_nwwn; /* node WWN */ 122 } fc_port_dev_t; 123 124 #if defined(_SYSCALL32) 125 126 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 127 #pragma pack(4) 128 #endif 129 130 typedef struct fc_port_dev32 { 131 uchar_t dev_dtype; /* SCSI device type */ 132 uint32_t dev_type[8]; /* protocol specific */ 133 uint32_t dev_state; /* port state */ 134 fc_portid_t dev_did; /* Destination Identifier */ 135 fc_hardaddr_t dev_hard_addr; /* Hard address */ 136 la_wwn_t dev_pwwn; /* port WWN */ 137 la_wwn_t dev_nwwn; /* node WWN */ 138 } fc_port_dev32_t; 139 140 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 141 #pragma pack() 142 #endif 143 144 #endif /* _SYSCALL32 */ 145 146 typedef struct fc_port_dev fc_ns_map_entry_t; 147 148 /* 149 * fcio_xfer definitions 150 */ 151 #define FCIO_XFER_NONE 0x00 152 #define FCIO_XFER_READ 0x01 153 #define FCIO_XFER_WRITE 0x02 154 #define FCIO_XFER_RW (FCIO_XFER_READ | FCIO_XFER_WRITE) 155 156 typedef struct fcio { 157 uint16_t fcio_xfer; /* direction */ 158 uint16_t fcio_cmd; /* sub command */ 159 uint16_t fcio_flags; /* flags */ 160 uint16_t fcio_cmd_flags; /* command specific flags */ 161 size_t fcio_ilen; /* Input buffer length */ 162 caddr_t fcio_ibuf; /* Input buffer */ 163 size_t fcio_olen; /* Output buffer length */ 164 caddr_t fcio_obuf; /* Output buffer */ 165 size_t fcio_alen; /* Auxillary buffer length */ 166 caddr_t fcio_abuf; /* Auxillary buffer */ 167 int fcio_errno; /* FC internal error code */ 168 } fcio_t; 169 170 /* 171 * T11 FC-HBA exchange structures 172 */ 173 #define FC_HBA_LIST_VERSION 1 174 typedef struct fc_hba_list { 175 uint32_t version; /* Set to FC_HBA_LIST_VERSION */ 176 uint32_t numAdapters; 177 uint64_t reserved; 178 char hbaPaths[1][MAXPATHLEN]; /* numAdapters long */ 179 } fc_hba_list_t; 180 181 #define FC_HBA_NPIV_PORT_LIST_VERSION 1 182 typedef struct fc_hba_npiv_port_list { 183 uint32_t version; 184 uint32_t numAdapters; 185 uint64_t reserved; 186 char hbaPaths[1][MAXPATHLEN]; 187 } fc_hba_npiv_port_list_t; 188 189 #define FC_HBA_NPIV_ATTRIBUTES_VERSION 1 190 typedef struct fc_hba_npiv_attributes { 191 uint32_t version; 192 la_wwn_t NodeWWN; 193 la_wwn_t PortWWN; 194 fc_hba_state_change_t lastChange; 195 } fc_hba_npiv_attributes_t; 196 197 #define FC_HBA_PORT_NPIV_ATTRIBUTES_VERSION 1 198 typedef struct fc_hba_port_npiv_attributes { 199 uint32_t version; 200 int npivflag; 201 fc_hba_state_change_t lastChange; 202 la_wwn_t NodeWWN; 203 la_wwn_t PortWWN; 204 uint32_t MaxNumberOfNPIVPorts; 205 uint32_t NumberOfNPIVPorts; 206 } fc_hba_port_npiv_attributes_t; 207 208 #define FC_HBA_SINGLE_VERSION 1 209 typedef struct fc_hba_single { 210 uint32_t version; /* Set to FC_HBA_SINGLE_VERSION */ 211 uint64_t reserved; 212 char hbaPath[MAXPATHLEN]; 213 } fc_hba_single_t; 214 215 #define FC_HBA_ADAPTER_ATTRIBUTES_VERSION 1 216 typedef struct fc_hba_adapter_attributes { 217 uint32_t version; /* Set to FC_HBA_ADAPTER_ATTRIBUTES_VERSION */ 218 char Manufacturer[64]; 219 char SerialNumber[64]; 220 char Model[256]; 221 char ModelDescription[256]; 222 la_wwn_t NodeWWN; 223 char NodeSymbolicName[256]; 224 char HardwareVersion[256]; 225 char DriverVersion[256]; 226 char OptionROMVersion[256]; 227 char FirmwareVersion[256]; 228 uint32_t VendorSpecificID; 229 uint32_t NumberOfPorts; 230 char DriverName[256]; 231 uint64_t reserved; 232 } fc_hba_adapter_attributes_t; 233 234 #if defined(_SYSCALL32) 235 236 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 237 #pragma pack(4) 238 #endif 239 240 typedef struct fc_hba_adapter_attributes32 { 241 uint32_t version; /* Set to FC_HBA_ADAPTER_ATTRIBUTES_VERSION */ 242 char Manufacturer[64]; 243 char SerialNumber[64]; 244 char Model[256]; 245 char ModelDescription[256]; 246 la_wwn_t NodeWWN; 247 char NodeSymbolicName[256]; 248 char HardwareVersion[256]; 249 char DriverVersion[256]; 250 char OptionROMVersion[256]; 251 char FirmwareVersion[256]; 252 uint32_t VendorSpecificID; 253 uint32_t NumberOfPorts; 254 char DriverName[256]; 255 uint64_t reserved; 256 } fc_hba_adapter_attributes32_t; 257 258 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 259 #pragma pack() 260 #endif 261 262 #endif /* defined(_SYSCALL32) */ 263 264 #define FC_HBA_PORT_ATTRIBUTES_VERSION 1 265 typedef struct fc_hba_port_attributes { 266 uint32_t version; /* FC_HBA_PORT_ATTRIBUTES_VERSION */ 267 fc_hba_state_change_t lastChange; 268 minor_t fp_minor; 269 la_wwn_t NodeWWN; 270 la_wwn_t PortWWN; 271 uint32_t PortFcId; 272 uint32_t PortType; 273 uint32_t PortState; 274 uint32_t PortSupportedClassofService; 275 uint8_t PortSupportedFc4Types[32]; 276 uint8_t PortActiveFc4Types[32]; 277 char PortSymbolicName[256]; 278 uint32_t PortSupportedSpeed; 279 uint32_t PortSpeed; 280 uint32_t PortMaxFrameSize; 281 la_wwn_t FabricName; 282 uint32_t NumberofDiscoveredPorts; 283 uint64_t reserved; 284 } fc_hba_port_attributes_t; 285 286 #if defined(_SYSCALL32) 287 288 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 289 #pragma pack(4) 290 #endif 291 292 typedef struct fc_hba_port_attributes32 { 293 uint32_t version; /* FC_HBA_PORT_ATTRIBUTES_VERSION */ 294 fc_hba_state_change_t lastChange; 295 minor_t fp_minor; 296 la_wwn_t NodeWWN; 297 la_wwn_t PortWWN; 298 uint32_t PortFcId; 299 uint32_t PortType; 300 uint32_t PortState; 301 uint32_t PortSupportedClassofService; 302 uint8_t PortSupportedFc4Types[32]; 303 uint8_t PortActiveFc4Types[32]; 304 char PortSymbolicName[256]; 305 uint32_t PortSupportedSpeed; 306 uint32_t PortSpeed; 307 uint32_t PortMaxFrameSize; 308 la_wwn_t FabricName; 309 uint32_t NumberofDiscoveredPorts; 310 uint64_t reserved; 311 } fc_hba_port_attributes32_t; 312 313 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 314 #pragma pack() 315 #endif 316 317 #endif /* defined(_SYSCALL32) */ 318 319 #define FC_HBA_ADAPTER_PORT_STATS_VERSION 1 320 typedef struct fc_hba_adapter_port_stats { 321 uint32_t version; /* FC_HBA_ADAPTER_PORT_STATS_VERSION */ 322 uint64_t SecondsSinceLastReset; 323 uint64_t TxFrames; 324 uint64_t TxWords; 325 uint64_t RxFrames; 326 uint64_t RxWords; 327 uint64_t LIPCount; 328 uint64_t NOSCount; 329 uint64_t ErrorFrames; 330 uint64_t DumpedFrames; 331 uint64_t LinkFailureCount; 332 uint64_t LossOfSyncCount; 333 uint64_t LossOfSignalCount; 334 uint64_t PrimitiveSeqProtocolErrCount; 335 uint64_t InvalidTxWordCount; 336 uint64_t InvalidCRCCount; 337 uint64_t reserved; 338 } fc_hba_adapter_port_stats_t; 339 340 341 /* 342 * Constant values derived from T11 FC-HBA 343 */ 344 #define FC_HBA_PORTTYPE_UNKNOWN 1 /* Unknown */ 345 #define FC_HBA_PORTTYPE_OTHER 2 /* Other */ 346 #define FC_HBA_PORTTYPE_NOTPRESENT 3 /* Not present */ 347 #define FC_HBA_PORTTYPE_NPORT 5 /* Fabric */ 348 #define FC_HBA_PORTTYPE_NLPORT 6 /* Public Loop */ 349 #define FC_HBA_PORTTYPE_FLPORT 7 350 #define FC_HBA_PORTTYPE_FPORT 8 /* Fabric Port */ 351 #define FC_HBA_PORTTYPE_EPORT 9 /* Fabric expansion port */ 352 #define FC_HBA_PORTTYPE_GPORT 10 /* Generic Fabric Port */ 353 #define FC_HBA_PORTTYPE_LPORT 20 /* Private Loop */ 354 #define FC_HBA_PORTTYPE_PTP 21 /* Point to Point */ 355 356 #define FC_HBA_PORTSTATE_UNKNOWN 1 /* Unknown */ 357 #define FC_HBA_PORTSTATE_ONLINE 2 /* Operational */ 358 #define FC_HBA_PORTSTATE_OFFLINE 3 /* User Offline */ 359 #define FC_HBA_PORTSTATE_BYPASSED 4 /* Bypassed */ 360 #define FC_HBA_PORTSTATE_DIAGNOSTICS 5 /* In diagnostics mode */ 361 #define FC_HBA_PORTSTATE_LINKDOWN 6 /* Link Down */ 362 #define FC_HBA_PORTSTATE_ERROR 7 /* Port Error */ 363 #define FC_HBA_PORTSTATE_LOOPBACK 8 /* Loopback */ 364 365 366 367 #if defined(_SYSCALL32) 368 /* 369 * 32 bit varient of fcio_t; to be used 370 * only in the driver and NOT applications 371 */ 372 struct fcio32 { 373 uint16_t fcio_xfer; /* direction */ 374 uint16_t fcio_cmd; /* sub command */ 375 uint16_t fcio_flags; /* flags */ 376 uint16_t fcio_cmd_flags; /* command specific flags */ 377 size32_t fcio_ilen; /* Input buffer length */ 378 caddr32_t fcio_ibuf; /* Input buffer */ 379 size32_t fcio_olen; /* Output buffer length */ 380 caddr32_t fcio_obuf; /* Output buffer */ 381 size32_t fcio_alen; /* Auxillary buffer length */ 382 caddr32_t fcio_abuf; /* Auxillary buffer */ 383 int fcio_errno; /* FC internal error code */ 384 }; 385 386 #if !defined(__lint) 387 _NOTE(SCHEME_PROTECTS_DATA("unique per request", fcio32)) 388 #endif /* __lint */ 389 390 #endif /* _SYSCALL32 */ 391 392 #if !defined(__lint) 393 _NOTE(SCHEME_PROTECTS_DATA("unique per request", fcio fc_port_dev)) 394 #endif /* __lint */ 395 396 #ifdef __cplusplus 397 } 398 #endif 399 400 #endif /* _FCIO_H */ 401