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