1 /******************************************************************************* 2 *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved. 3 * 4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided 5 *that the following conditions are met: 6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 7 *following disclaimer. 8 *2. Redistributions in binary form must reproduce the above copyright notice, 9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided 10 *with the distribution. 11 * 12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED 13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 20 * 21 * 22 ********************************************************************************/ 23 /******************************************************************************** 24 ** 25 ** Version Control Information: 26 ** 27 ** 28 *******************************************************************************/ 29 /******************************************************************************** 30 ** 31 * tidefs.h 32 * 33 * Abstract: This module contains enum and #define definition used 34 * by Transport Independent API (TIAPI) Layer. 35 * 36 ********************************************************************************/ 37 38 #ifndef TIDEFS_H 39 40 #define TIDEFS_H 41 42 #include <dev/pms/freebsd/driver/common/osenv.h> 43 #include <dev/pms/freebsd/driver/common/ostypes.h> 44 #include <dev/pms/freebsd/driver/common/osdebug.h> 45 46 /***************************************************************************** 47 * INITIATOR/TARGET SHARED DEFINES AND ENUMS 48 *****************************************************************************/ 49 50 /* 51 * Option mask parameter for tiCOMPortStart() 52 */ 53 #define PORTAL_ADD_MASK 0x00000001 54 55 /* 56 * Maximum memory descriptor for Low-Level layer. 57 */ 58 #define MAX_LL_LAYER_MEM_DESCRIPTORS 64 59 60 61 /* 62 * TI API function return types 63 */ 64 typedef enum 65 { 66 tiSuccess, 67 tiError, 68 tiBusy, 69 tiIONoDevice, 70 tiMemoryTooLarge, 71 tiMemoryNotAvail, 72 tiInvalidHandle, 73 tiNotSupported, 74 tiReject, 75 tiIncorrectLun, 76 tiDeviceBusy, 77 } tiStatus_t; 78 79 /* 80 * Type of memory, OR-ed the bit fields. 81 */ 82 83 /* Bit 0-1, cached or dma-uncached dma-cached */ 84 85 #define TI_DMA_MEM 0x00000000 /* uncached DMA capable memory */ 86 #define TI_CACHED_MEM 0x00000001 /* cached non-DMA capable memory */ 87 #define TI_CACHED_DMA_MEM 0x00000002 /* cached DMA capable memory */ 88 #define TI_DMA_MEM_CHIP 0x00000003 /* Internal HW/chip memory */ 89 90 /* Bit2-3: location of memory */ 91 #define TI_LOC_HOST 0x00000000 /* default, allocated from host */ 92 #define TI_LOC_ON_CHIP 0x00000004 /* memory is from on-chip RAM */ 93 #define TI_LOC_ON_CARD 0x00000008 /* memory is from on-card RAM */ 94 95 /* Type of SGL list 96 * 97 */ 98 typedef enum 99 { 100 tiSgl=0, 101 tiSglList=0x80000000, 102 tiExtHdr 103 }tiSglType_t; 104 105 /* 106 * Type of mutex semaphoring/synchronization 107 */ 108 typedef enum 109 { 110 tiSingleMutexLockPerPort, 111 tiOneMutexLockPerQueue 112 }tiMutexType_t; 113 114 /* 115 * Context (interrupt or non-interrupt) 116 */ 117 typedef enum 118 { 119 tiInterruptContext, 120 tiNonInterruptContext 121 }tiIntContextType_t; 122 123 /* 124 * Port Event type. 125 */ 126 typedef enum 127 { 128 tiPortPanic, 129 tiPortResetComplete, 130 tiPortNameServerDown, 131 tiPortLinkDown, 132 tiPortLinkUp, 133 tiPortStarted, 134 tiPortStopped, 135 tiPortShutdown, 136 tiPortDiscoveryReady, 137 tiPortResetNeeded, 138 tiEncryptOperation, 139 tiModePageOperation 140 } tiPortEvent_t; 141 142 /* 143 * tiEncryptOperation Event types 144 */ 145 typedef enum 146 { 147 tiEncryptGetInfo, 148 tiEncryptSetMode, 149 tiEncryptKekAdd, 150 tiEncryptDekInvalidate, 151 tiEncryptKekStore, 152 tiEncryptKekLoad, 153 tiEncryptAttribRegUpdate, 154 tiEncryptDekAdd, 155 /* new */ 156 tiEncryptOperatorManagement, 157 tiEncryptSelfTest, 158 tiEncryptSetOperator, 159 tiEncryptGetOperator 160 } tiEncryptOp_t; 161 162 /* 163 * ostiPortEvent() status values for tiCOMOperatorManagement() 164 */ 165 typedef enum 166 { 167 tiOMNotSupported, 168 tiOMIllegalParam, 169 tiOMKENUnwrapFail, 170 tiOMNvramOpFailure, 171 } tiOperatorManagementStatus_t; 172 173 /* 174 * ostiInitiatorIOCompleted() and ostiTargetIOError() status values 175 */ 176 typedef enum 177 { 178 tiIOSuccess, 179 tiIOOverRun, 180 tiIOUnderRun, 181 tiIOFailed, 182 tiIODifError, 183 tiIOEncryptError, 184 } tiIOStatus_t; 185 186 /* 187 * ostiInitiatorIOCompleted() and ostiTargetIOError() statusDetail values 188 */ 189 typedef enum 190 { 191 tiSMPSuccess, 192 tiSMPAborted, 193 tiSMPFailed, 194 } tiSMPStatus_t; 195 196 typedef enum 197 { 198 tiDetailBusy, 199 tiDetailNotValid, 200 tiDetailNoLogin, 201 tiDetailAbortLogin, 202 tiDetailAbortReset, 203 tiDetailAborted, 204 tiDetailDifMismatch, 205 tiDetailDifAppTagMismatch, 206 tiDetailDifRefTagMismatch, 207 tiDetailDifCrcMismatch, 208 tiDetailDekKeyCacheMiss, 209 tiDetailCipherModeInvalid, 210 tiDetailDekIVMismatch, 211 tiDetailDekRamInterfaceError, 212 tiDetailDekIndexOutofBounds, 213 tiDetailOtherError, 214 tiDetailOtherErrorNoRetry, 215 } tiIOStatusDetail_t; 216 217 /* 218 * IOCTL Status Codes 219 */ 220 #define IOCTL_ERR_STATUS_OK 0x00 221 #define IOCTL_ERR_STATUS_MORE_DATA 0x01 222 #define IOCTL_ERR_STATUS_NO_MORE_DATA 0x02 223 #define IOCTL_ERR_STATUS_INVALID_CODE 0x03 224 #define IOCTL_ERR_STATUS_INVALID_DEVICE 0x04 225 #define IOCTL_ERR_STATUS_NOT_RESPONDING 0x05 226 #define IOCTL_ERR_STATUS_INTERNAL_ERROR 0x06 227 #define IOCTL_ERR_STATUS_NOT_SUPPORTED 0x07 228 #define IOCTL_ERR_FW_EVENTLOG_DISABLED 0x08 229 #define IOCTL_MJ_FATAL_ERROR_SOFT_RESET_TRIG 0x72 230 #define IOCTL_MJ_FATAL_ERR_CHK_SEND_TRUE 0x77 231 #define IOCTL_MJ_FATAL_ERR_CHK_SEND_FALSE 0x76 232 #define IOCTL_ERROR_NO_FATAL_ERROR 0x77 233 234 #define ADAPTER_WWN_START_OFFSET 0x804 235 #define ADAPTER_WWN_END_OFFSET 0x80b 236 #define ADAPTER_WWN_SPC_START_OFFSET 0x704 237 #define ADAPTER_WWN_SPC_END_OFFSET 0x70b 238 239 /* 240 * IOCTL Return Codes 241 */ 242 #define IOCTL_CALL_SUCCESS 0x00 243 #define IOCTL_CALL_FAIL 0x01 244 #define IOCTL_CALL_PENDING 0x02 245 #define IOCTL_CALL_INVALID_CODE 0x03 246 #define IOCTL_CALL_INVALID_DEVICE 0x04 247 #define IOCTL_CALL_TIMEOUT 0x08 248 249 /* 250 * DIF operation 251 */ 252 #define DIF_INSERT 0 253 #define DIF_VERIFY_FORWARD 1 254 #define DIF_VERIFY_DELETE 2 255 #define DIF_VERIFY_REPLACE 3 256 257 #define DIF_UDT_SIZE 6 258 259 /* 260 * Login state in tiDeviceInfo_t 261 */ 262 #define INI_LGN_STATE_FREE 0x00000000 263 #define INI_LGN_STATE_LOGIN 0x00000001 264 #define INI_LGN_STATE_FAIL 0x00000002 265 #define INI_LGN_STATE_OTHERS 0x0000000F 266 267 /* 268 * SecurityCipherMode in tiEncryptInfo_t and tiCOMEncryptSetMode() 269 */ 270 #define TI_ENCRYPT_SEC_MODE_FACT_INIT 0x00000000 271 #define TI_ENCRYPT_SEC_MODE_A 0x40000000 272 #define TI_ENCRYPT_SEC_MODE_B 0x80000000 273 #define TI_ENCRYPT_ATTRIB_ALLOW_SMF 0x00000200 274 #define TI_ENCRYPT_ATTRIB_AUTH_REQ 0x00000100 275 #define TI_ENCRYPT_ATTRIB_CIPHER_XTS 0x00000002 276 #define TI_ENCRYPT_ATTRIB_CIPHER_ECB 0x00000001 277 278 /* 279 * Status in tiEncryptInfo_t 280 */ 281 #define TI_ENCRYPT_STATUS_NO_NVRAM 0x00000001 282 #define TI_ENCRYPT_STATUS_NVRAM_ERROR 0x00000002 283 #define TI_ENCRYPT_STATUS_ENGINE_ERROR 0x00000004 284 285 /* 286 * EncryptMode in tiEncrypt_t 287 */ 288 #define TI_ENCRYPT_MODE_XTS_AES 0x00400000 289 #define TI_ENCRYPT_MODE_ECB_AES 0x00000000 290 291 /* 292 * Encrypt blob types 293 */ 294 #define TI_PLAINTEXT 0 295 #define TI_ENCRYPTED_KEK_PMCA 1 296 #define TI_ENCRYPTED_KEK_PMCB 2 297 298 /* 299 * Encrypt DEK table key entry sizes 300 */ 301 #define TI_DEK_TABLE_KEY_SIZE16 0 302 #define TI_DEK_TABLE_KEY_SIZE24 1 303 #define TI_DEK_TABLE_KEY_SIZE32 2 304 #define TI_DEK_TABLE_KEY_SIZE40 3 305 #define TI_DEK_TABLE_KEY_SIZE48 4 306 #define TI_DEK_TABLE_KEY_SIZE56 5 307 #define TI_DEK_TABLE_KEY_SIZE64 6 308 #define TI_DEK_TABLE_KEY_SIZE72 7 309 #define TI_DEK_TABLE_KEY_SIZE80 8 310 311 /* KEK blob size and DEK blob size and host DEK table entry number */ 312 #define TI_KEK_BLOB_SIZE 48 313 #define TI_KEK_MAX_TABLE_ENTRIES 8 314 315 #define TI_DEK_MAX_TABLES 2 316 #define TI_DEK_MAX_TABLE_ENTRIES (1024*4) 317 318 #define TI_DEK_BLOB_SIZE 80 319 320 321 /************************************************************ 322 * tiHWEventMode_t page operation definitions 323 ************************************************************/ 324 #define tiModePageGet 1 325 #define tiModePageSet 2 326 327 /* controller configuration page code */ 328 #define TI_SAS_PROTOCOL_TIMER_CONFIG_PAGE 0x04 329 #define TI_INTERRUPT_CONFIGURATION_PAGE 0x05 330 #define TI_ENCRYPTION_GENERAL_CONFIG_PAGE 0x20 331 #define TI_ENCRYPTION_DEK_CONFIG_PAGE 0x21 332 #define TI_ENCRYPTION_CONTROL_PARM_PAGE 0x22 333 #define TI_ENCRYPTION_HMAC_CONFIG_PAGE 0x23 334 335 336 /* encryption self test type */ 337 #define TI_ENCRYPTION_TEST_TYPE_BIST 0x01 338 #define TI_ENCRYPTION_TEST_TYPE_HMAC 0x02 339 340 /* SHA algorithm type */ 341 #define TI_SHA_ALG_1 0x04 342 #define TI_SHA_ALG_256 0x08 343 #define TI_SHA_ALG_224 0x10 344 #define TI_SHA_ALG_512 0x20 345 #define TI_SHA_ALG_384 0x40 346 347 #define TI_SHA_1_DIGEST_SIZE 20 348 #define TI_SHA_256_DIGEST_SIZE 32 349 #define TI_SHA_224_DIGEST_SIZE 28 350 #define TI_SHA_512_DIGEST_SIZE 64 351 #define TI_SHA_384_DIGEST_SIZE 48 352 353 354 /***************************************************************************** 355 * INITIATOR SPECIFIC DEFINES AND ENUMS 356 *****************************************************************************/ 357 358 /* 359 * ostiInitiatorIOCompleted() statusDetail contains SCSI status, 360 * when status passed in ostiInitiatorIOCompleted() is tiIOSuccess. 361 */ 362 #define SCSI_STAT_GOOD 0x00 363 #define SCSI_STAT_CHECK_CONDITION 0x02 364 #define SCSI_STAT_CONDITION_MET 0x04 365 #define SCSI_STAT_BUSY 0x08 366 #define SCSI_STAT_INTERMEDIATE 0x10 367 #define SCSI_STAT_INTER_CONDIT_MET 0x14 368 #define SCSI_STAT_RESV_CONFLICT 0x18 369 #define SCSI_STAT_COMMANDTERMINATED 0x22 370 #define SCSI_STAT_TASK_SET_FULL 0x28 371 #define SCSI_STAT_ACA_ACTIVE 0x30 372 #define SCSI_STAT_TASK_ABORTED 0x40 373 374 /* 375 01: soft error 376 02: not ready 377 03: medium error 378 04: hardware error 379 05: illegal request 380 06: unit attention 381 0b: abort command 382 */ 383 #define SCSI_SENSE_KEY_NO_SENSE 0x00 384 #define SCSI_SENSE_KEY_RECOVERED_ERROR 0x01 385 #define SCSI_SENSE_KEY_NOT_READY 0x02 386 #define SCSI_SENSE_KEY_MEDIUM_ERROR 0x03 387 #define SCSI_SENSE_KEY_HARDWARE_ERROR 0x04 388 #define SCSI_SENSE_KEY_ILLEGAL_REQUEST 0x05 389 #define SCSI_SENSE_KEY_UNIT_ATTENTION 0x06 390 #define SCSI_SENSE_KEY_DATA_PROTECT 0x07 391 #define SCSI_SENSE_KEY_BLANK_CHECK 0x08 392 #define SCSI_SENSE_KEY_UNIQUE 0x09 393 #define SCSI_SENSE_KEY_COPY_ABORTED 0x0A 394 #define SCSI_SENSE_KEY_ABORTED_COMMAND 0x0B 395 #define SCSI_SENSE_KEY_EQUAL 0x0C 396 #define SCSI_SENSE_KEY_VOL_OVERFLOW 0x0D 397 #define SCSI_SENSE_KEY_MISCOMPARE 0x0E 398 #define SCSI_SENSE_KEY_RESERVED 0x0F 399 400 401 402 403 /* 404 * Reset option in tiCOMReset() 405 */ 406 typedef enum 407 { 408 tiSoftReset, 409 tiHardReset, 410 tiAutoReset 411 } tiReset_t; 412 413 /* 414 * Bit 0 Mask for the persistent option in tiINIDiscoverTargets() 415 */ 416 #define NORMAL_ASSIGN_MASK 0x00000000 417 #define FORCE_PERSISTENT_ASSIGN_MASK 0x00000001 418 419 /* 420 * Bit 1 Mask for the auto login option in tiINIDiscoverTargets() 421 */ 422 #define AUTO_LOGIN_MASK 0x00000000 423 #define NO_AUTO_LOGIN_MASK 0x00000002 424 425 426 /* 427 * Task Management task used in tiINITaskManagement() 428 * 429 * 1 AG_ABORT TASK - aborts the task identified by the Referenced Task Tag field. 430 * 2 AG_ABORT TASK SET - aborts all Tasks issued by this initiator on the Logical Unit 431 * 3 AG_CLEAR ACA - clears the Auto Contingent Allegiance condition. 432 * 4 AG_CLEAR TASK SET - Aborts all Tasks (from all initiators) for the Logical Unit. 433 * 5 AG_LOGICAL UNIT RESET 434 * 6 AG_TARGET WARM RESET - iSCSI only 435 * 7 AG_TARGET_COLD_RESET - iSCSI only 436 * 8 AG_TASK_REASSIGN - iSCSI only 437 * 9 AG_QUERY_TASK - SAS only 438 */ 439 440 #define AG_ABORT_TASK 1 441 #define AG_ABORT_TASK_SET 2 442 #define AG_CLEAR_ACA 3 443 #define AG_CLEAR_TASK_SET 4 444 #define AG_LOGICAL_UNIT_RESET 5 445 #define AG_TARGET_WARM_RESET 6 /* iSCSI only */ 446 #define AG_TARGET_COLD_RESET 7 /* iSCSI only */ 447 #define AG_TASK_REASSIGN 8 /* iSCSI only */ 448 #define AG_QUERY_TASK 9 /* SAS only */ 449 450 451 /* 452 * Event types for ostiInitiatorEvent() 453 */ 454 typedef enum 455 { 456 tiIntrEventTypeCnxError, 457 tiIntrEventTypeDiscovery, 458 tiIntrEventTypeTransportRecovery, 459 tiIntrEventTypeTaskManagement, 460 tiIntrEventTypeDeviceChange, 461 tiIntrEventTypeLogin, 462 tiIntrEventTypeLocalAbort 463 } tiIntrEventType_t; 464 465 /* 466 * Event status for ostiInitiatorEvent() 467 */ 468 typedef enum 469 { 470 tiCnxUp, 471 tiCnxDown 472 } tiCnxEventStatus_t; 473 474 typedef enum 475 { 476 tiDiscOK, 477 tiDiscFailed 478 } tiDiscEventStatus_t; 479 480 typedef enum 481 { 482 tiLoginOK, 483 tiLoginFailed, 484 tiLogoutOK, 485 tiLogoutFailed 486 } tiLoginEventStatus_t; 487 488 typedef enum 489 { 490 tiRecOK, 491 tiRecFailed, 492 tiRecStarted 493 } tiRecEventStatus_t; 494 495 typedef enum 496 { 497 tiTMOK, 498 tiTMFailed 499 } tiTMEventStatus_t; 500 501 typedef enum 502 { 503 tiDeviceRemoval, 504 tiDeviceArrival, 505 tiDeviceLoginReceived 506 } tiDevEventStatus_t; 507 508 typedef enum 509 { 510 tiAbortOK, 511 tiAbortFailed, 512 tiAbortDelayed, 513 tiAbortInProgress 514 } tiAbortEventStatus_t; 515 516 /* 517 * SCSI SAM-2 Task Attribute 518 */ 519 #define TASK_UNTAGGED 0 /* Untagged */ 520 #define TASK_SIMPLE 1 /* Simple */ 521 #define TASK_ORDERED 2 /* Ordered */ 522 #define TASK_HEAD_OF_QUEUE 3 /* Head of Queue */ 523 #define TASK_ACA 4 /* ACA */ 524 525 /* 526 * Data direction for I/O request 527 */ 528 typedef enum 529 { 530 tiDirectionIn = 0x0000, 531 tiDirectionOut = 0x0001 532 }tiDataDirection_t; 533 534 /* 535 * NVRAM error subEvents for encryption 536 */ 537 typedef enum 538 { 539 tiNVRAMSuccess = 0x0000, 540 tiNVRAMWriteFail = 0x0001, 541 tiNVRAMReadFail = 0x0002, 542 tiNVRAMNotFound = 0x0003, 543 tiNVRAMAccessTimeout = 0x0004 544 }tiEncryptSubEvent_t; 545 546 /* Event Logging */ 547 548 /* Event Severity Codes */ 549 #define IOCTL_EVT_SEV_OFF 0x00 550 #define IOCTL_EVT_SEV_ALWAYS_ON 0x01 551 #define IOCTL_EVT_SEV_ERROR 0x02 552 #define IOCTL_EVT_SEV_WARNING 0x03 553 #define IOCTL_EVT_SEV_INFORMATIONAL 0x04 554 #define IOCTL_EVT_SEV_DEBUG_L1 0x05 555 #define IOCTL_EVT_SEV_DEBUG_L2 0x06 556 #define IOCTL_EVT_SEV_DEBUG_L3 0x07 557 558 /* Event Source */ 559 #define IOCTL_EVT_SRC_HW 0xF0000000 560 #define IOCTL_EVT_SRC_ITSDK 0x0F000000 561 #define IOCTL_EVT_SRC_FW 0x00F00000 562 #define IOCTL_EVT_SRC_TD_LAYER 0x000F0000 563 #define IOCTL_EVT_SRC_TARGET 0x0000F000 564 #define IOCTL_EVT_SRC_OSLAYER 0x00000F00 565 #define IOCTL_EVT_SRC_RESERVED 0x000000F0 566 #define IOCTL_EVT_SRC_RESERVED1 0x0000000F 567 /* Event Shifter */ 568 #define IOCTL_EVT_SRC_HW_SHIFTER 28 569 #define IOCTL_EVT_SRC_ITSDK_SHIFTER 24 570 #define IOCTL_EVT_SRC_FW_SHIFTER 20 571 #define IOCTL_EVT_SRC_COMMON_LAYER_SHIFTER 16 572 #define IOCTL_EVT_SRC_TARGET_SHIFTER 12 573 #define IOCTL_EVT_SRC_OSLAYER_SHIFTER 8 574 #define IOCTL_EVT_SRC_RESERVED_SHIFTER 4 575 #define IOCTL_EVT_SRC_RESERVED1_SHIFTER 0 576 577 #define EVENTLOG_MAX_MSG_LEN 110 578 579 #define EVENT_ID_MAX 0xffffffff 580 581 #define DISCOVERY_IN_PROGRESS 0xFFFFFFFF 582 583 #define TI_SSP_INDIRECT_CDB_SIZE 64 584 /* 585 * Flags in tiSuperScsiInitiatorRequest_t 586 */ 587 #define TI_SCSI_INITIATOR_DIF 0x00000001 588 #define TI_SCSI_INITIATOR_ENCRYPT 0x00000002 589 #define TI_SCSI_INITIATOR_INDIRECT_CDB 0x00000004 590 /***************************************************************************** 591 * TARGET SPECIFIC DEFINES AND ENUMS 592 *****************************************************************************/ 593 594 /* 595 * Event types for ostiTargetEvent() 596 */ 597 typedef enum 598 { 599 tiTgtEventTypeCnxError, 600 tiTgtEventTypeDeviceChange 601 } tiTgtEventType_t; 602 603 /* 604 * Flags in tiSuperScsiTargetRequest_t 605 */ 606 #define TI_SCSI_TARGET_DIF 0x00000001 607 #define TI_SCSI_TARGET_MIRROR 0x00000002 608 #define TI_SCSI_TARGET_ENCRYPT 0x00000004 609 #endif /* TIDEFS_H */ 610