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