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 * tiapi.h 25 * 26 * Abstract: This module contains function prototype of the Transport 27 * Independent API (TIAPI) Layer for both initiator and target. 28 ** Version Control Information: 29 ** 30 ** 31 *******************************************************************************/ 32 33 34 #ifndef TIAPI_H 35 #define TIAPI_H 36 37 #include <dev/pms/RefTisa/tisa/api/tiglobal.h> 38 #include <dev/pms/RefTisa/tisa/api/titypes.h> 39 40 /***************************************************************************** 41 * INITIATOR/TARGET SHARED APIs 42 *****************************************************************************/ 43 44 osGLOBAL void tiCOMGetResource ( 45 tiRoot_t *tiRoot, 46 tiLoLevelResource_t *loResource, 47 tiInitiatorResource_t *initiatorResource, 48 tiTargetResource_t *targetResource, 49 tiTdSharedMem_t *tdSharedMem 50 ); 51 52 osGLOBAL bit32 tiCOMInit( 53 tiRoot_t *tiRoot, 54 tiLoLevelResource_t *loResource, 55 tiInitiatorResource_t *initiatorResource, 56 tiTargetResource_t *targetResource, 57 tiTdSharedMem_t *tdSharedMem 58 ); 59 60 osGLOBAL bit32 tiCOMPortInit( 61 tiRoot_t *tiRoot, 62 bit32 sysIntsActive 63 ); 64 65 osGLOBAL bit32 tiCOMPortStart( 66 tiRoot_t *tiRoot, 67 bit32 portID, 68 tiPortalContext_t *portalContext, 69 bit32 option 70 ); 71 72 osGLOBAL void tiCOMShutDown( tiRoot_t *tiRoot); 73 74 osGLOBAL bit32 tiCOMPortStop( 75 tiRoot_t *tiRoot, 76 tiPortalContext_t *portalContext 77 ); 78 79 osGLOBAL void tiCOMReset ( 80 tiRoot_t *tiRoot, 81 bit32 option 82 ); 83 84 osGLOBAL bit32 85 tdsaGetNumOfLUNIOCTL( 86 tiRoot_t *tiRoot, 87 tiIOCTLPayload_t *agIOCTLPayload, 88 void *agParam1, 89 void *agParam2, 90 void *agParam3 91 ); 92 93 osGLOBAL void ostiNumOfLUNIOCTLRsp( 94 tiRoot_t *tiRoot, 95 bit32 status 96 ); 97 osGLOBAL bit32 98 tiNumOfLunIOCTLreq( 99 tiRoot_t *tiRoot, 100 tiIORequest_t *tiIORequest, 101 tiDeviceHandle_t *tiDeviceHandle, 102 void *tiRequestBody, 103 tiIOCTLPayload_t *agIOCTLPayload, 104 void *agParam1, 105 void *agParam2 106 ); 107 108 109 osGLOBAL FORCEINLINE bit32 tiCOMInterruptHandler( 110 tiRoot_t *tiRoot, 111 bit32 channelNum 112 ); 113 114 osGLOBAL FORCEINLINE bit32 tiCOMDelayedInterruptHandler ( 115 tiRoot_t *tiRoot, 116 bit32 channelNum, 117 bit32 count, 118 bit32 context 119 ); 120 121 osGLOBAL bit32 tiCOMLegacyInterruptHandler( 122 tiRoot_t *tiRoot, 123 bit32 channelNum 124 ); 125 126 127 osGLOBAL void tiCOMLegacyDelayedInterruptHandler( 128 tiRoot_t *tiRoot, 129 bit32 channelNum, 130 bit32 count, 131 bit32 context 132 ); 133 osGLOBAL void tiCOMTimerTick( tiRoot_t *tiRoot ); 134 135 osGLOBAL void tiCOMSystemInterruptsActive ( 136 tiRoot_t *tiRoot , 137 bit32 sysIntsActive 138 ); 139 140 141 osGLOBAL FORCEINLINE void 142 tiCOMInterruptEnable( 143 tiRoot_t * tiRoot, 144 bit32 channelNum); 145 146 osGLOBAL void tiCOMFrameReadBlock( 147 tiRoot_t *tiRoot, 148 void *agFrame, 149 bit32 FrameOffset, 150 void *FrameBuffer, 151 bit32 FrameBufLen ); 152 osGLOBAL bit32 tiCOMEncryptGetInfo( 153 tiRoot_t *tiRoot); 154 155 osGLOBAL bit32 tiCOMEncryptSetMode( 156 tiRoot_t *tiRoot, 157 bit32 securityCipherMode 158 ); 159 160 osGLOBAL bit32 tiCOMSetControllerConfig ( 161 tiRoot_t *tiRoot, 162 bit32 modePage, 163 bit32 length, 164 void *buffer, 165 void *context 166 ); 167 168 osGLOBAL bit32 tiCOMGetControllerConfig( 169 tiRoot_t *tiRoot, 170 bit32 modePage, 171 bit32 flag, 172 void *context 173 ); 174 175 176 osGLOBAL bit32 tiCOMEncryptDekAdd( 177 tiRoot_t *tiRoot, 178 bit32 kekIndex, 179 bit32 dekTableSelect, 180 bit32 dekAddrHi, 181 bit32 dekAddrLo, 182 bit32 dekIndex, 183 bit32 dekNumberOfEntries, 184 bit32 dekBlobFormat, 185 bit32 dekTableKeyEntrySize 186 ); 187 188 osGLOBAL bit32 tiCOMEncryptDekInvalidate( 189 tiRoot_t *tiRoot, 190 bit32 dekTable, 191 bit32 dekIndex 192 ); 193 194 195 osGLOBAL bit32 tiCOMEncryptKekAdd( 196 tiRoot_t *tiRoot, 197 bit32 kekIndex, 198 bit32 wrapperKekIndex, 199 bit32 blobFormat, 200 tiEncryptKekBlob_t *encryptKekBlob 201 ); 202 203 osGLOBAL tiDeviceHandle_t * 204 tiINIGetExpDeviceHandleBySasAddress( 205 tiRoot_t * tiRoot, 206 tiPortalContext_t * tiPortalContext, 207 bit32 sas_addr_hi, 208 bit32 sas_addr_lo, 209 bit32 maxDevs 210 ); 211 212 213 #ifdef HIALEAH_ENCRYPTION 214 osGLOBAL bit32 tiCOMEncryptHilSet(tiRoot_t *tiRoot ); 215 #endif /* HIALEAH_ENCRYPTION */ 216 217 osGLOBAL bit32 tiCOMEncryptKekStore( 218 tiRoot_t *tiRoot, 219 bit32 kekIndex 220 ); 221 222 osGLOBAL bit32 tiCOMEncryptKekLoad( 223 tiRoot_t *tiRoot, 224 bit32 kekIndex 225 ); 226 227 osGLOBAL bit32 tiCOMEncryptSelfTest( 228 tiRoot_t *tiRoot, 229 bit32 type, 230 bit32 length, 231 void *TestDescriptor 232 ); 233 234 osGLOBAL bit32 tiCOMSetOperator( 235 tiRoot_t *tiRoot, 236 bit32 flag, 237 void *cert 238 ); 239 240 osGLOBAL bit32 tiCOMGetOperator( 241 tiRoot_t *tiRoot, 242 bit32 option, 243 bit32 AddrHi, 244 bit32 AddrLo 245 ); 246 247 osGLOBAL bit32 tiCOMOperatorManagement( 248 tiRoot_t *tiRoot, 249 bit32 flag, 250 bit8 role, 251 tiID_t *idString, 252 tiEncryptKekBlob_t *kekBlob 253 ); 254 255 /* 256 * PMC-Sierra Management IOCTL module 257 */ 258 osGLOBAL bit32 tiCOMMgntIOCTL( 259 tiRoot_t *tiRoot, 260 tiIOCTLPayload_t *agIOCTLPayload, 261 void *agParam1, 262 void *agParam2, 263 void *agParam3 264 ); 265 266 osGLOBAL void ostiCOMMgntIOCTLRsp( 267 tiRoot_t *tiRoot, 268 bit32 status 269 ); 270 271 osGLOBAL void ostiRegDumpIOCTLRsp( 272 tiRoot_t *tiRoot, 273 bit32 status 274 ); 275 276 osGLOBAL void ostiSetNVMDIOCTLRsp( 277 tiRoot_t *tiRoot, 278 bit32 status 279 ); 280 281 osGLOBAL void ostiGetPhyProfileIOCTLRsp( 282 tiRoot_t *tiRoot, 283 bit32 status 284 ); 285 286 osGLOBAL void ostiGetNVMDIOCTLRsp( 287 tiRoot_t *tiRoot, 288 bit32 status 289 ); 290 osGLOBAL bit32 tiCOMGetPortInfo( 291 tiRoot_t *tiRoot, 292 tiPortalContext_t *portalContext, 293 tiPortInfo_t *tiPortInfo 294 ); 295 296 osGLOBAL void ostiSendSMPIOCTLRsp( 297 tiRoot_t *tiRoot, 298 bit32 status 299 ); 300 301 osGLOBAL void ostiGenEventIOCTLRsp( 302 tiRoot_t *tiRoot, 303 bit32 status 304 ); 305 306 osGLOBAL void 307 ostiGetDeviceInfoIOCTLRsp( 308 tiRoot_t *tiRoot, 309 bit32 status, 310 void *param 311 ); 312 313 osGLOBAL void 314 ostiGetIoErrorStatsIOCTLRsp( 315 tiRoot_t *tiRoot, 316 bit32 status, 317 void *param 318 ); 319 320 osGLOBAL void 321 ostiGetIoEventStatsIOCTLRsp( 322 tiRoot_t *tiRoot, 323 bit32 status, 324 void *param 325 ); 326 327 osGLOBAL void 328 ostiGetForensicDataIOCTLRsp( 329 tiRoot_t *tiRoot, 330 bit32 status, 331 void *param 332 ); 333 334 335 #ifdef SPC_ENABLE_PROFILE 336 osGLOBAL void ostiFWProfileIOCTLRsp( 337 tiRoot_t *tiRoot, 338 bit32 status, 339 bit32 len 340 ); 341 #endif 342 343 /***************************************************************************** 344 * INITIATOR SPECIFIC APIs 345 *****************************************************************************/ 346 347 /* 348 * Session management module. 349 */ 350 osGLOBAL bit32 tiINIGetExpander( 351 tiRoot_t * tiRoot, 352 tiPortalContext_t * tiPortalContext, 353 tiDeviceHandle_t * tiDev, 354 tiDeviceHandle_t ** tiExp 355 ); 356 osGLOBAL bit32 tiINIGetDeviceHandles( 357 tiRoot_t *tiRoot, 358 tiPortalContext_t *portalContext, 359 tiDeviceHandle_t *agDev[], 360 bit32 maxDevs 361 ); 362 363 osGLOBAL bit32 tiINIGetDeviceHandlesForWinIOCTL( 364 tiRoot_t *tiRoot, 365 tiPortalContext_t *portalContext, 366 tiDeviceHandle_t *agDev[], 367 bit32 maxDevs 368 ); 369 370 osGLOBAL void tiIniGetDirectSataSasAddr(tiRoot_t * tiRoot, bit32 phyId, bit8 **sasAddressHi, bit8 **sasAddressLo); 371 osGLOBAL bit32 tiINIDiscoverTargets( 372 tiRoot_t *tiRoot, 373 tiPortalContext_t *portalContext, 374 bit32 option 375 ); 376 377 osGLOBAL bit32 tiINILogin( 378 tiRoot_t *tiRoot, 379 tiDeviceHandle_t *tiDeviceHandle 380 ); 381 382 osGLOBAL bit32 tiINILogout( 383 tiRoot_t *tiRoot, 384 tiDeviceHandle_t *tiDeviceHandle 385 ); 386 387 osGLOBAL bit32 tiINIGetDeviceInfo( 388 tiRoot_t *tiRoot, 389 tiDeviceHandle_t *tiDeviceHandle, 390 tiDeviceInfo_t *tiDeviceInfo); 391 392 /* 393 * Transport recovery module. 394 */ 395 osGLOBAL void tiINITransportRecovery( 396 tiRoot_t *tiRoot, 397 tiDeviceHandle_t *tiDeviceHandle 398 ); 399 400 osGLOBAL bit32 tiINITaskManagement ( 401 tiRoot_t *tiRoot, 402 tiDeviceHandle_t *tiDeviceHandle, 403 bit32 task, 404 tiLUN_t *lun, 405 tiIORequest_t *taskTag, 406 tiIORequest_t *currentTaskTag 407 ); 408 osGLOBAL bit32 tiINISMPStart( 409 tiRoot_t *tiRoot, 410 tiIORequest_t *tiIORequest, 411 tiDeviceHandle_t *tiDeviceHandle, 412 tiSMPFrame_t *tiScsiRequest, 413 void *tiSMPBody, 414 bit32 interruptContext 415 ); 416 /* 417 * I/O module. 418 */ 419 osGLOBAL bit32 tiINIIOStart( 420 tiRoot_t *tiRoot, 421 tiIORequest_t *tiIORequest, 422 tiDeviceHandle_t *tiDeviceHandle, 423 tiScsiInitiatorRequest_t *tiScsiRequest, 424 void *tiRequestBody, 425 bit32 interruptContext 426 ); 427 428 osGLOBAL void tiINIDebugDumpIO( 429 tiRoot_t *tiRoot, 430 tiIORequest_t *tiIORequest 431 ); 432 433 osGLOBAL bit32 tiINIIOStartDif( 434 tiRoot_t *tiRoot, 435 tiIORequest_t *tiIORequest, 436 tiDeviceHandle_t *tiDeviceHandle, 437 tiScsiInitiatorRequest_t *tiScsiRequest, 438 void *tiRequestBody, 439 bit32 interruptContext, 440 tiDif_t *difOption 441 ); 442 osGLOBAL bit32 tiINISuperIOStart ( 443 tiRoot_t *tiRoot, 444 tiIORequest_t *tiIORequest, 445 tiDeviceHandle_t *tiDeviceHandle, 446 tiSuperScsiInitiatorRequest_t *tiScsiRequest, 447 void *tiRequestBody, 448 bit32 interruptContext 449 ); 450 451 #ifdef FAST_IO_TEST 452 osGLOBAL void *tiINIFastIOPrepare( 453 tiRoot_t *tiRoot, 454 void *ioHandle, 455 agsaFastCommand_t *fc); 456 457 osGLOBAL void* 458 tiINIFastIOPrepare2( 459 tiRoot_t *tiRoot, 460 void *ioHandle, 461 agsaFastCommand_t *fc, 462 void *pMessage, 463 void *pRequest); 464 465 osGLOBAL bit32 tiINIFastIOSend(void *ioHandle); 466 osGLOBAL bit32 tiINIFastIOCancel(void *ioHandle); 467 #endif 468 469 osGLOBAL bit32 tiCOMEncryptGetMode(tiRoot_t *tiRoot); 470 osGLOBAL bit32 tiCOMEncryptSetOn_Off(tiRoot_t *tiRoot, bit32 On); 471 472 osGLOBAL bit32 tiInitDevEncrypt( 473 tiRoot_t *tiRoot, 474 void *tideviceptr ); 475 476 osGLOBAL bit32 tiTGTSuperIOStart ( 477 tiRoot_t *tiRoot, 478 tiIORequest_t *tiIORequest, 479 tiSuperScsiTargetRequest_t *tiScsiRequest 480 ); 481 482 osGLOBAL void tiINITimerTick( 483 tiRoot_t *tiRoot 484 ); 485 486 487 osGLOBAL bit32 tiINIIOAbort( 488 tiRoot_t *tiRoot, 489 tiIORequest_t *taskTag 490 ); 491 492 osGLOBAL bit32 tiINIIOAbortAll( 493 tiRoot_t *tiRoot, 494 tiDeviceHandle_t *tiDeviceHandle 495 ); 496 /* 497 * Event Logging module 498 */ 499 osGLOBAL bit32 tiINIReportErrorToEventLog( 500 tiRoot_t *tiRoot, 501 tiEVTData_t *agEventData 502 ); 503 504 505 /***************************************************************************** 506 * TARGET SPECIFIC APIs 507 *****************************************************************************/ 508 509 osGLOBAL void tiTGTTimerTick( 510 tiRoot_t *tiRoot 511 ); 512 513 osGLOBAL void *tiTGTSenseBufferGet( 514 tiRoot_t *tiRoot, 515 tiIORequest_t *tiIORequest, 516 bit32 length 517 ); 518 519 osGLOBAL void tiTGTSetResp( 520 tiRoot_t *tiRoot, 521 tiIORequest_t *tiIORequest, 522 bit32 dataSentLength, 523 bit8 ScsiStatus, 524 bit32 senseLength 525 ); 526 527 osGLOBAL bit32 tiTGTIOStart ( 528 tiRoot_t *tiRoot, 529 tiIORequest_t *tiIORequest, 530 bit32 dataOffset, 531 bit32 dataLength, 532 tiSgl_t *dataSGL, 533 void *sglVirtualAddr 534 ); 535 536 osGLOBAL bit32 tiTGTIOStartMirror ( 537 tiRoot_t *tiRoot, 538 tiIORequest_t *tiIORequest, 539 bit32 dataOffset, 540 bit32 dataLength, 541 tiSgl_t *dataSGL, 542 void *sglVirtualAddr, 543 tiSgl_t *dataSGLMirror, 544 void *sglVirtualAddrMirror 545 ); 546 547 osGLOBAL bit32 tiTGTIOStartDif ( 548 tiRoot_t *tiRoot, 549 tiIORequest_t *tiIORequest, 550 bit32 dataOffset, 551 bit32 dataLength, 552 tiSgl_t *dataSGL, 553 void *sglVirtualAddr, 554 tiDif_t *difOption 555 ); 556 557 558 osGLOBAL bit32 tiTGTGetDeviceHandles( 559 tiRoot_t *tiRoot, 560 tiPortalContext_t *portalContext, 561 tiDeviceHandle_t *agDev[], 562 bit32 maxDevs 563 ); 564 565 osGLOBAL bit32 tiTGTGetDeviceInfo( 566 tiRoot_t *tiRoot, 567 tiDeviceHandle_t *tiDeviceHandle, 568 tiDeviceInfo_t *tiDeviceInfo); 569 570 osGLOBAL bit32 tiTGTIOAbort( 571 tiRoot_t *tiRoot, 572 tiIORequest_t *taskTag 573 ); 574 575 osGLOBAL bit32 tiTGTSendTmResp ( 576 tiRoot_t *tiRoot, 577 tiIORequest_t *tiTMRequest, 578 bit32 status 579 ); 580 581 void tiPCI_TRIGGER( tiRoot_t *tiRoot); 582 583 void tiComCountActiveIORequests( tiRoot_t *tiRoot); 584 585 #endif /* TIAPI_H */ 586