1 /* 2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 #ifndef _SYS_SCSI_ADAPTERS_MPAPI_IMPL_H 7 #define _SYS_SCSI_ADAPTERS_MPAPI_IMPL_H 8 9 #pragma ident "%Z%%M% %I% %E% SMI" 10 11 #include <sys/sunmdi.h> 12 #include <sys/sunddi.h> 13 #include <sys/mdi_impldefs.h> 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL) 20 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 21 #endif /* _BIT_FIELDS_LTOH */ 22 23 /* 24 * All the structures (except mp_iocdata_t) are 64-bit aligned (padded, 25 * where necessary) to facilitate the use of the same structure for 26 * handling ioctl calls made by both 32-bit and 64-bit applications. 27 * There are no pointers to other structures inside these structures 28 * as copyout to user land may not produce desired result. 29 * The caddr_t structure is kept at the end due to the undeterminstic 30 * size it could accrue to its parent structure. 31 */ 32 33 /* Structure for MP_PLUGIN_PROPERTIES */ 34 35 typedef struct mp_driver_prop { 36 char driverVersion[256]; 37 uint32_t supportedLoadBalanceTypes; 38 boolean_t canSetTPGAccess; 39 boolean_t canOverridePaths; 40 boolean_t exposesPathDeviceFiles; 41 char deviceFileNamespace[256]; 42 uint32_t onlySupportsSpecifiedProducts; 43 uint32_t maximumWeight; 44 uint32_t failbackPollingRateMax; 45 uint32_t currentFailbackPollingRate; 46 uint32_t autoFailbackSupport; 47 uint32_t autoFailbackEnabled; 48 uint32_t defaultLoadBalanceType; 49 uint32_t probingPollingRateMax; 50 uint32_t currentProbingPollingRate; 51 uint32_t autoProbingSupport; 52 uint32_t autoProbingEnabled; 53 uint32_t proprietaryPropSize; 54 caddr_t proprietaryProp; 55 } mp_driver_prop_t; 56 57 58 /* Size of "proprietaryProp" field */ 59 60 #define MP_MAX_PROP_BUF_SIZE 1024 61 62 63 /* Constants for autoFailbackSupport */ 64 65 /* 66 * Both MP_DRVR_AUTO_FAILBACK_SUPPORT and 67 * MP_DRVR_AUTO_FAILBACK_SUPPORT_LU 68 * can be supported at the same time. 69 */ 70 71 #define MP_DRVR_AUTO_FAILBACK_SUPPORT_NONE 0 72 #define MP_DRVR_AUTO_FAILBACK_SUPPORT (1<<0) 73 #define MP_DRVR_AUTO_FAILBACK_SUPPORT_LU (1<<1) 74 75 76 /* Constants for defaultLoadBalanceType */ 77 78 #define MP_DRVR_LOAD_BALANCE_TYPE_UNKNOWN 0 79 #define MP_DRVR_LOAD_BALANCE_TYPE_ROUNDROBIN (1<<0) 80 #define MP_DRVR_LOAD_BALANCE_TYPE_LEASTBLOCKS (1<<1) 81 #define MP_DRVR_LOAD_BALANCE_TYPE_LEASTIO (1<<2) 82 #define MP_DRVR_LOAD_BALANCE_TYPE_DEVICE_PRODUCT (1<<3) 83 #define MP_DRVR_LOAD_BALANCE_TYPE_LBA_REGION (1<<4) 84 #define MP_DRVR_LOAD_BALANCE_TYPE_PROPRIETARY1 (1<<16) 85 #define MP_DRVR_LOAD_BALANCE_TYPE_PROPRIETARY2 (1<<17) 86 87 88 /* Constants for autoProbingSupport */ 89 90 /* 91 * Both MP_DRVR_AUTO_PROBING_SUPPORT and 92 * MP_DRVR_AUTO_PROBING_SUPPORT_LU 93 * can be supported at the same time. 94 */ 95 96 #define MP_DRVR_AUTO_PROBING_SUPPORT_NONE 0 97 #define MP_DRVR_AUTO_PROBING_SUPPORT (1<<0) 98 #define MP_DRVR_AUTO_PROBING_SUPPORT_LU (1<<1) 99 100 101 /* Structures for MP_DEVICE_PRODUCT_PROPERTIES */ 102 103 typedef struct mp_vendor_prod_info { 104 char vendor[8]; 105 char product[16]; 106 char revision[4]; 107 char reserved[4]; /* padding for 64bit alignment */ 108 } mp_vendor_prod_info_t; 109 110 typedef struct mp_dev_prod_prop { 111 struct mp_vendor_prod_info prodInfo; 112 uint32_t supportedLoadBalanceTypes; 113 uint32_t reserved; /* 64bit alignment padding */ 114 uint64_t id; 115 } mp_dev_prod_prop_t; 116 117 118 /* Structure for MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES */ 119 120 typedef struct mp_logical_unit_prop { 121 struct mp_vendor_prod_info prodInfo; 122 char name[256]; /* guid */ 123 uint32_t nameType; 124 uint32_t luGroupID; 125 char deviceFileName[256]; 126 uint64_t id; 127 boolean_t asymmetric; 128 uint32_t currentLoadBalanceType; 129 boolean_t autoFailbackEnabled; 130 uint32_t failbackPollingRateMax; 131 uint32_t currentFailBackPollingRate; 132 uint32_t autoProbingEnabled; 133 uint32_t probingPollingRateMax; 134 uint32_t currentProbingPollingRate; 135 uint64_t overridePathID; 136 boolean_t overridePathInUse; 137 uint32_t proprietaryPropSize; 138 caddr_t proprietaryProp; 139 } mp_logical_unit_prop_t; 140 141 142 /* Constants for nameType */ 143 144 #define MP_DRVR_NAME_TYPE_UNKNOWN 0 145 #define MP_DRVR_NAME_TYPE_VPD83_TYPE1 1 146 #define MP_DRVR_NAME_TYPE_VPD83_TYPE2 2 147 #define MP_DRVR_NAME_TYPE_VPD83_TYPE3 3 148 #define MP_DRVR_NAME_TYPE_DEVICE_SPECIFIC 4 149 150 151 /* Structure for MP_INITIATOR_PORT_PROPERTIES */ 152 153 typedef struct mp_init_port_prop { 154 char portID[256]; 155 char osDeviceFile[256]; 156 uint32_t portType; 157 uint32_t reserved; /* padding for 64bit alignment */ 158 uint64_t id; 159 } mp_init_port_prop_t; 160 161 162 /* Constants for portType */ 163 164 #define MP_DRVR_TRANSPORT_TYPE_UNKNOWN 0 165 #define MP_DRVR_TRANSPORT_TYPE_FC 2 166 #define MP_DRVR_TRANSPORT_TYPE_SPI 3 167 #define MP_DRVR_TRANSPORT_TYPE_ISCSI 4 168 #define MP_DRVR_TRANSPORT_TYPE_IFB 5 169 170 171 /* Structure for MP_TARGET_PORT_PROPERTIES */ 172 173 typedef struct mp_target_port_prop { 174 char portName[256]; 175 uint32_t relativePortID; 176 uint32_t reserved; /* padding for 64bit alignment */ 177 uint64_t id; 178 } mp_target_port_prop_t; 179 180 181 /* Structure for MP_TARGET_PORT_GROUP_PROPERTIES */ 182 183 typedef struct mp_tpg_prop { 184 uint32_t accessState; 185 boolean_t explicitFailover; 186 uint32_t tpgId; /* T10 defined id in report/set TPG */ 187 boolean_t preferredLuPath; 188 boolean_t supportsLuAssignment; 189 uint32_t reserved; /* padding for 64bit alignment */ 190 uint64_t id; 191 } mp_tpg_prop_t; 192 193 194 /* Constants for accessState */ 195 196 #define MP_DRVR_ACCESS_STATE_ACTIVE_OPTIMIZED 0 197 #define MP_DRVR_ACCESS_STATE_ACTIVE_NONOPTIMIZED 0x1 198 #define MP_DRVR_ACCESS_STATE_STANDBY 0x2 199 #define MP_DRVR_ACCESS_STATE_UNAVAILABLE 0x3 200 #define MP_DRVR_ACCESS_STATE_TRANSITIONING 0xf 201 #define MP_DRVR_ACCESS_STATE_ACTIVE 0x10 202 203 204 /* Structure for MP_PATH_LOGICAL_UNIT_PROPERTIES */ 205 206 typedef struct mp_path_prop { 207 uint32_t weight; 208 uint32_t pathState; 209 boolean_t disabled; 210 uint32_t reserved; /* 64bit alignment padding */ 211 uint64_t id; 212 struct mp_init_port_prop initPort; 213 struct mp_target_port_prop targetPort; 214 struct mp_logical_unit_prop logicalUnit; 215 } mp_path_prop_t; 216 217 218 /* Constants for pathState */ 219 220 #define MP_DRVR_PATH_STATE_ACTIVE 0 221 #define MP_DRVR_PATH_STATE_PASSIVE 1 222 #define MP_DRVR_PATH_STATE_PATH_ERR 2 223 #define MP_DRVR_PATH_STATE_LU_ERR 3 224 #define MP_DRVR_PATH_STATE_RESERVED 4 225 #define MP_DRVR_PATH_STATE_REMOVED 5 226 #define MP_DRVR_PATH_STATE_TRANSITIONING 6 227 #define MP_DRVR_PATH_STATE_UNKNOWN 7 228 229 230 /* Structure for MP_PROPRIETARY_LOAD_BALANCE_PROPERTIES */ 231 232 typedef struct mp_proprietary_loadbalance_prop { 233 char name[256]; 234 char vendorName[256]; 235 uint64_t id; 236 uint32_t typeIndex; 237 uint32_t proprietaryPropSize; 238 caddr_t proprietaryProp; 239 } mp_proprietary_loadbalance_prop_t; 240 241 242 /* 243 * Structure used as input to 244 * MP_ASSIGN_LU_TO_TPG subcmd. 245 */ 246 247 typedef struct mp_lu_tpg_pair { 248 uint64_t luId; 249 uint64_t tpgId; 250 } mp_lu_tpg_pair_t; 251 252 253 /* 254 * Structure used as input to 255 * MP_SET_TPG_ACCESS_STATE subcmd. 256 */ 257 258 typedef struct mp_set_tpg_state_req { 259 struct mp_lu_tpg_pair luTpgPair; 260 uint32_t desiredState; 261 uint32_t reserved; /* padding for 64bit boundary */ 262 } mp_set_tpg_state_req_t; 263 264 265 /* 266 * Structure for ioctl data 267 */ 268 typedef struct mp_iocdata { 269 uint16_t mp_xfer; /* direction */ 270 uint16_t mp_cmd; /* sub command */ 271 uint16_t mp_flags; /* flags */ 272 uint16_t mp_cmd_flags; /* command specific flags */ 273 size_t mp_ilen; /* Input buffer length */ 274 caddr_t mp_ibuf; /* Input buffer */ 275 size_t mp_olen; /* Output buffer length */ 276 caddr_t mp_obuf; /* Output buffer */ 277 size_t mp_alen; /* Auxiliary buffer length */ 278 caddr_t mp_abuf; /* Auxiliary buffer */ 279 int mp_errno; /* MPAPI driver internal error code */ 280 } mp_iocdata_t; 281 282 283 #ifdef _KERNEL 284 285 #if defined(_SYSCALL32) 286 287 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 288 #pragma pack(4) 289 #endif 290 291 /* 292 * Structure for 32-bit ioctl data 293 */ 294 295 typedef struct mp_iocdata32 { 296 uint16_t mp_xfer; /* direction */ 297 uint16_t mp_cmd; /* sub command */ 298 uint16_t mp_flags; /* flags */ 299 uint16_t mp_cmd_flags; /* command specific flags */ 300 uint32_t mp_ilen; /* Input buffer length */ 301 caddr32_t mp_ibuf; /* Input buffer */ 302 uint32_t mp_olen; /* Output buffer length */ 303 caddr32_t mp_obuf; /* Output buffer */ 304 uint32_t mp_alen; /* Auxiliary buffer length */ 305 caddr32_t mp_abuf; /* Auxiliary buffer */ 306 int32_t mp_errno; /* MPAPI driver internal error code */ 307 } mp_iocdata32_t; 308 309 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 310 #pragma pack() 311 #endif 312 313 #endif /* _SYSCALL32 */ 314 315 #endif /* _KERNEL */ 316 317 318 /* Constants for MP_XFER */ 319 320 #define MP_XFER_NONE 0x00 321 #define MP_XFER_READ 0x01 322 #define MP_XFER_WRITE 0x02 323 #define MP_XFER_RW (MP_XFER_READ | MP_XFER_WRITE) 324 325 326 /* Constants for MP_OBJECT_TYPE */ 327 328 #define MP_OBJECT_TYPE_UNKNOWN 0 329 #define MP_OBJECT_TYPE_PLUGIN 1 330 #define MP_OBJECT_TYPE_INITIATOR_PORT 2 331 #define MP_OBJECT_TYPE_TARGET_PORT 3 332 #define MP_OBJECT_TYPE_MULTIPATH_LU 4 333 #define MP_OBJECT_TYPE_PATH_LU 5 334 #define MP_OBJECT_TYPE_DEVICE_PRODUCT 6 335 #define MP_OBJECT_TYPE_TARGET_PORT_GROUP 7 336 #define MP_OBJECT_TYPE_PROPRIETARY_LOAD_BALANCE 8 337 #define MP_OBJECT_TYPE_LAST_ENTRY MP_OBJECT_TYPE_PROPRIETARY_LOAD_BALANCE 338 #define MP_MAX_OBJECT_TYPE (MP_OBJECT_TYPE_LAST_ENTRY + 1) 339 340 341 /* Constants for MP_CMD */ 342 343 #define MPAPI_CTL ('m'<<8) 344 #define MP_CMD (MPAPI_CTL | 2005) 345 #define MP_SUB_CMD ('M'<<8) 346 347 #define MP_API_SUBCMD_MIN (MP_SUB_CMD + 0x01) 348 #define MP_GET_DRIVER_PROP (MP_SUB_CMD + 0x01) 349 #define MP_GET_DEV_PROD_LIST (MP_SUB_CMD + 0x02) 350 #define MP_GET_DEV_PROD_PROP (MP_SUB_CMD + 0x03) 351 #define MP_GET_LU_LIST (MP_SUB_CMD + 0x04) 352 #define MP_GET_LU_LIST_FROM_TPG (MP_SUB_CMD + 0x05) 353 #define MP_GET_LU_PROP (MP_SUB_CMD + 0x06) 354 #define MP_GET_PATH_LIST_FOR_MP_LU (MP_SUB_CMD + 0x07) 355 #define MP_GET_PATH_LIST_FOR_INIT_PORT (MP_SUB_CMD + 0x08) 356 #define MP_GET_PATH_LIST_FOR_TARGET_PORT (MP_SUB_CMD + 0x09) 357 #define MP_GET_PATH_PROP (MP_SUB_CMD + 0x0a) 358 #define MP_GET_INIT_PORT_LIST (MP_SUB_CMD + 0x0b) 359 #define MP_GET_INIT_PORT_PROP (MP_SUB_CMD + 0x0c) 360 #define MP_GET_TARGET_PORT_PROP (MP_SUB_CMD + 0x0d) 361 #define MP_GET_TPG_LIST (MP_SUB_CMD + 0x0e) 362 #define MP_GET_TPG_PROP (MP_SUB_CMD + 0x0f) 363 #define MP_GET_TPG_LIST_FOR_LU (MP_SUB_CMD + 0x10) 364 #define MP_GET_TARGET_PORT_LIST_FOR_TPG (MP_SUB_CMD + 0x11) 365 #define MP_SET_TPG_ACCESS_STATE (MP_SUB_CMD + 0x12) 366 #define MP_ENABLE_AUTO_FAILBACK (MP_SUB_CMD + 0x13) 367 #define MP_DISABLE_AUTO_FAILBACK (MP_SUB_CMD + 0x14) 368 #define MP_ENABLE_PATH (MP_SUB_CMD + 0x15) 369 #define MP_DISABLE_PATH (MP_SUB_CMD + 0x16) 370 #define MP_GET_PROPRIETARY_LOADBALANCE_LIST (MP_SUB_CMD + 0x17) 371 #define MP_GET_PROPRIETARY_LOADBALANCE_PROP (MP_SUB_CMD + 0x18) 372 #define MP_ASSIGN_LU_TO_TPG (MP_SUB_CMD + 0x19) 373 #define MP_API_SUBCMD_MAX (MP_ASSIGN_LU_TO_TPG) 374 375 376 /* 377 * Typical MP API ioctl interface specific Return Values 378 */ 379 380 #define MP_IOCTL_ERROR_START 0x5533 381 #define MP_MORE_DATA (MP_IOCTL_ERROR_START + 1) 382 #define MP_DRVR_INVALID_ID (MP_IOCTL_ERROR_START + 2) 383 #define MP_DRVR_ID_OBSOLETE (MP_IOCTL_ERROR_START + 3) 384 #define MP_DRVR_ACCESS_SYMMETRIC (MP_IOCTL_ERROR_START + 4) 385 #define MP_DRVR_PATH_UNAVAILABLE (MP_IOCTL_ERROR_START + 5) 386 #define MP_DRVR_IDS_NOT_ASSOCIATED (MP_IOCTL_ERROR_START + 6) 387 #define MP_DRVR_ILLEGAL_ACCESS_STATE_REQUEST (MP_IOCTL_ERROR_START + 7) 388 389 /* 390 * Macros for OID operations 391 */ 392 #define MP_ID_SHIFT4MAJOR 32 393 #define MP_GET_MAJOR_FROM_ID(id) ((id) >> MP_ID_SHIFT4MAJOR) 394 #define MP_GET_INST_FROM_ID(id) ((id) & 0x00000000ffffffff) 395 #define MP_STORE_INST_TO_ID(inst, id) (((uint64_t)(inst)) | id) 396 #define MP_STORE_MAJOR_TO_ID(major, id) \ 397 ((((uint64_t)(major)) << MP_ID_SHIFT4MAJOR) | id) 398 399 /* 400 * Event Class and Sub-Class definitions 401 */ 402 #define EC_SUN_MP "EC_sun_mp" 403 404 #define ESC_SUN_MP_LU_CHANGE "ESC_sun_mp_lu_change" 405 406 #define ESC_SUN_MP_PATH_CHANGE "ESC_sun_mp_path_change" 407 #define ESC_SUN_MP_PATH_ADD "ESC_sun_mp_path_add" 408 #define ESC_SUN_MP_PATH_REMOVE "ESC_sun_mp_path_remove" 409 410 #define ESC_SUN_MP_INIT_PORT_CHANGE "ESC_sun_mp_init_port_change" 411 412 #define ESC_SUN_MP_TPG_CHANGE "ESC_sun_mp_tpg_change" 413 #define ESC_SUN_MP_TPG_ADD "ESC_sun_mp_tpg_add" 414 #define ESC_SUN_MP_TPG_REMOVE "ESC_sun_mp_tpg_remove" 415 416 #define ESC_SUN_MP_TARGET_PORT_CHANGE "ESC_sun_mp_target_port_change" 417 #define ESC_SUN_MP_TARGET_PORT_ADD "ESC_sun_mp_target_port_add" 418 #define ESC_SUN_MP_TARGET_PORT_REMOVE "ESC_sun_mp_target_port_remove" 419 420 #define ESC_SUN_MP_DEV_PROD_CHANGE "ESC_sun_mp_dev_prod_change" 421 #define ESC_SUN_MP_DEV_PROD_ADD "ESC_sun_mp_dev_prod_add" 422 #define ESC_SUN_MP_DEV_PROD_REMOVE "ESC_sun_mp_dev_prod_remove" 423 424 #ifdef __cplusplus 425 } 426 #endif 427 428 #endif /* _SYS_SCSI_ADAPTERS_MPAPI_IMPL_H */ 429