14e1bc9a0SAchim Leubner /*******************************************************************************
24e1bc9a0SAchim Leubner *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
34e1bc9a0SAchim Leubner *
44e1bc9a0SAchim Leubner *Redistribution and use in source and binary forms, with or without modification, are permitted provided
54e1bc9a0SAchim Leubner *that the following conditions are met:
64e1bc9a0SAchim Leubner *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
74e1bc9a0SAchim Leubner *following disclaimer.
84e1bc9a0SAchim Leubner *2. Redistributions in binary form must reproduce the above copyright notice,
94e1bc9a0SAchim Leubner *this list of conditions and the following disclaimer in the documentation and/or other materials provided
104e1bc9a0SAchim Leubner *with the distribution.
114e1bc9a0SAchim Leubner *
124e1bc9a0SAchim Leubner *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
134e1bc9a0SAchim Leubner *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
144e1bc9a0SAchim Leubner *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
154e1bc9a0SAchim Leubner *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
164e1bc9a0SAchim Leubner *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
174e1bc9a0SAchim Leubner *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
184e1bc9a0SAchim Leubner *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
194e1bc9a0SAchim Leubner *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
204e1bc9a0SAchim Leubner *
214e1bc9a0SAchim Leubner *
224e1bc9a0SAchim Leubner *******************************************************************************/
234e1bc9a0SAchim Leubner /******************************************************************************
244e1bc9a0SAchim Leubner PMC-Sierra TISA Initiator Device Driver for Linux 2.x.x.
254e1bc9a0SAchim Leubner
264e1bc9a0SAchim Leubner Module Name:
274e1bc9a0SAchim Leubner osapi.c
284e1bc9a0SAchim Leubner Abstract:
294e1bc9a0SAchim Leubner Linux iSCSI/FC Initiator driver module itsdk required OS functions
304e1bc9a0SAchim Leubner Environment:
314e1bc9a0SAchim Leubner Part of oslayer module, Kernel or loadable module
324e1bc9a0SAchim Leubner
334e1bc9a0SAchim Leubner *******************************************************************************
344e1bc9a0SAchim Leubner ostiInitiatorEvent()
354e1bc9a0SAchim Leubner
364e1bc9a0SAchim Leubner Purpose:
374e1bc9a0SAchim Leubner TI layer call back to OSlayer to inform events
384e1bc9a0SAchim Leubner Parameters:
394e1bc9a0SAchim Leubner tiRoot_t *ptiRoot (IN) Pointer to HBA data structure
404e1bc9a0SAchim Leubner tiDeviceHandle_t *ptiDevHandle (IN) Pointer to device handle
414e1bc9a0SAchim Leubner tiIntrEvenType_t evenType (IN) Event type
424e1bc9a0SAchim Leubner tiIntrEventStatus_t evetStatus (IN) Event status
434e1bc9a0SAchim Leubner void *parm (IN) pointer to even specific data
444e1bc9a0SAchim Leubner Return:
454e1bc9a0SAchim Leubner Note:
464e1bc9a0SAchim Leubner TBD, further event process required.
474e1bc9a0SAchim Leubner ******************************************************************************/
ostiInitiatorEvent(tiRoot_t * ptiRoot,tiPortalContext_t * ptiPortalContext,tiDeviceHandle_t * ptiDevHandle,tiIntrEventType_t eventType,U32 eventStatus,void * parm)484e1bc9a0SAchim Leubner void ostiInitiatorEvent( tiRoot_t *ptiRoot,
494e1bc9a0SAchim Leubner tiPortalContext_t *ptiPortalContext,
504e1bc9a0SAchim Leubner tiDeviceHandle_t *ptiDevHandle,
514e1bc9a0SAchim Leubner tiIntrEventType_t eventType,
524e1bc9a0SAchim Leubner U32 eventStatus,
534e1bc9a0SAchim Leubner void *parm )
544e1bc9a0SAchim Leubner {
554e1bc9a0SAchim Leubner ag_portal_data_t *pPortalData;
564e1bc9a0SAchim Leubner ag_portal_info_t *pPortalInfo;
574e1bc9a0SAchim Leubner struct agtiapi_softc *pCard = TIROOT_TO_CARD( ptiRoot );
584e1bc9a0SAchim Leubner ccb_t *pccb;
594e1bc9a0SAchim Leubner ccb_t *pTMccb;
604e1bc9a0SAchim Leubner ccb_t *ccbIO;
614e1bc9a0SAchim Leubner
624e1bc9a0SAchim Leubner #ifdef AGTIAPI_EVENT_LOG
634e1bc9a0SAchim Leubner AGTIAPI_PRINTK("Initiator Event:\n");
644e1bc9a0SAchim Leubner AGTIAPI_PRINTK("DevHandle %p, eventType 0x%x, eventStatus 0x%x\n",
654e1bc9a0SAchim Leubner ptiDevHandle, eventType, eventStatus);
664e1bc9a0SAchim Leubner AGTIAPI_PRINTK("Parameter: %s\n", (char *)parm);
674e1bc9a0SAchim Leubner #endif
684e1bc9a0SAchim Leubner
694e1bc9a0SAchim Leubner AGTIAPI_PRINTK("ostiInitiatorEvent: eventType 0x%x eventStatus 0x%x\n", eventType, eventStatus);
704e1bc9a0SAchim Leubner
714e1bc9a0SAchim Leubner switch (eventType)
724e1bc9a0SAchim Leubner {
734e1bc9a0SAchim Leubner case tiIntrEventTypeCnxError:
744e1bc9a0SAchim Leubner if (eventStatus == tiCnxUp)
754e1bc9a0SAchim Leubner {
764e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeCnxError - tiCnxUp!\n");
774e1bc9a0SAchim Leubner }
784e1bc9a0SAchim Leubner if (eventStatus == tiCnxDown)
794e1bc9a0SAchim Leubner {
804e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeCnxError - tiCnxDown!\n");
814e1bc9a0SAchim Leubner }
824e1bc9a0SAchim Leubner break;
834e1bc9a0SAchim Leubner case tiIntrEventTypeDiscovery:
844e1bc9a0SAchim Leubner pPortalData = PORTAL_CONTEXT_TO_PORTALDATA(ptiPortalContext);
854e1bc9a0SAchim Leubner pCard->flags |= AGTIAPI_CB_DONE;
864e1bc9a0SAchim Leubner if (eventStatus == tiDiscOK)
874e1bc9a0SAchim Leubner {
884e1bc9a0SAchim Leubner AGTIAPI_PRINTK("eventStatus - tiDiscOK\n");
894e1bc9a0SAchim Leubner AGTIAPI_PRINTK("ostiInitiatorEvent: pcard %d eventStatus - tiDiscOK\n", pCard->cardNo );
904e1bc9a0SAchim Leubner PORTAL_STATUS(pPortalData) |= AGTIAPI_DISC_COMPLETE;
914e1bc9a0SAchim Leubner #ifndef HOTPLUG_SUPPORT
924e1bc9a0SAchim Leubner if (!(pCard->flags & AGTIAPI_INIT_TIME))
934e1bc9a0SAchim Leubner #else
944e1bc9a0SAchim Leubner if (TRUE)
954e1bc9a0SAchim Leubner #endif
964e1bc9a0SAchim Leubner {
974e1bc9a0SAchim Leubner
984e1bc9a0SAchim Leubner agtiapi_GetDevHandle(pCard, &pPortalData->portalInfo,
994e1bc9a0SAchim Leubner tiIntrEventTypeDiscovery, tiDiscOK);
1004e1bc9a0SAchim Leubner PORTAL_STATUS(pPortalData) |=
1014e1bc9a0SAchim Leubner (AGTIAPI_DISC_DONE | AGTIAPI_PORT_LINK_UP);
1024e1bc9a0SAchim Leubner }
1034e1bc9a0SAchim Leubner /* Trigger CheckIOTimeout */
1044e1bc9a0SAchim Leubner callout_reset(&pCard->IO_timer, 20*hz, agtiapi_CheckIOTimeout, pCard);
1054e1bc9a0SAchim Leubner }
1064e1bc9a0SAchim Leubner else if (eventStatus == tiDiscFailed)
1074e1bc9a0SAchim Leubner {
1084e1bc9a0SAchim Leubner AGTIAPI_PRINTK("eventStatus - tiDiscFailed\n");
1094e1bc9a0SAchim Leubner agtiapi_GetDevHandle(pCard, &pPortalData->portalInfo,
1104e1bc9a0SAchim Leubner tiIntrEventTypeDiscovery, tiDiscFailed);
1114e1bc9a0SAchim Leubner PORTAL_STATUS(pPortalData) &= ~AGTIAPI_DISC_DONE;
1124e1bc9a0SAchim Leubner }
1134e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeDiscovery - portal %p, status 0x%x\n",
1144e1bc9a0SAchim Leubner pPortalData,
1154e1bc9a0SAchim Leubner PORTAL_STATUS(pPortalData));
1164e1bc9a0SAchim Leubner break;
1174e1bc9a0SAchim Leubner case tiIntrEventTypeDeviceChange:
1184e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeDeviceChange - portal %p es %d\n",
1194e1bc9a0SAchim Leubner ptiPortalContext->osData, eventStatus);
1204e1bc9a0SAchim Leubner pPortalData = PORTAL_CONTEXT_TO_PORTALDATA(ptiPortalContext);
1214e1bc9a0SAchim Leubner pPortalInfo = &pPortalData->portalInfo;
1224e1bc9a0SAchim Leubner #ifndef HOTPLUG_SUPPORT
1234e1bc9a0SAchim Leubner if (!(pCard->flags & AGTIAPI_INIT_TIME))
1244e1bc9a0SAchim Leubner #else
1254e1bc9a0SAchim Leubner if (TRUE)
1264e1bc9a0SAchim Leubner #endif
1274e1bc9a0SAchim Leubner {
1284e1bc9a0SAchim Leubner agtiapi_GetDevHandle(pCard, pPortalInfo, tiIntrEventTypeDeviceChange,
1294e1bc9a0SAchim Leubner eventStatus);
1304e1bc9a0SAchim Leubner // agtiapi_StartIO(pCard);
1314e1bc9a0SAchim Leubner }
1324e1bc9a0SAchim Leubner break;
1334e1bc9a0SAchim Leubner case tiIntrEventTypeTransportRecovery:
1344e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeTransportRecovery!\n");
1354e1bc9a0SAchim Leubner break;
1364e1bc9a0SAchim Leubner case tiIntrEventTypeTaskManagement:
1374e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeTaskManagement!\n");
1384e1bc9a0SAchim Leubner pccb = (pccb_t)((tiIORequest_t *)parm)->osData;
1394e1bc9a0SAchim Leubner if (pccb->flags & TASK_TIMEOUT)
1404e1bc9a0SAchim Leubner {
1414e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeTaskManagement: TM timeout!\n");
1424e1bc9a0SAchim Leubner agtiapi_FreeTMCCB(pCard, pccb);
1434e1bc9a0SAchim Leubner }
1444e1bc9a0SAchim Leubner else
1454e1bc9a0SAchim Leubner {
1464e1bc9a0SAchim Leubner pccb->flags |= AGTIAPI_CB_DONE;
1474e1bc9a0SAchim Leubner if (eventStatus == tiTMOK)
1484e1bc9a0SAchim Leubner {
1494e1bc9a0SAchim Leubner pccb->flags |= TASK_SUCCESS;
1504e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeTaskManagement: pTMccb %p flag %x \n",
1514e1bc9a0SAchim Leubner pccb, pccb->flags);
1524e1bc9a0SAchim Leubner
1534e1bc9a0SAchim Leubner /* Incase of TM_DEV_RESET, issue LocalAbort to abort pending IO */
1544e1bc9a0SAchim Leubner if (pccb->flags & DEV_RESET)
1554e1bc9a0SAchim Leubner {
1564e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeTaskManagement: Target Reset\n");
1574e1bc9a0SAchim Leubner ccbIO = pccb->pccbIO;
1584e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeTaskManagement: IO to be aborted locally %p flag %x \n",
1594e1bc9a0SAchim Leubner ccbIO, ccbIO->flags);
1604e1bc9a0SAchim Leubner if (ccbIO->startTime == 0) /* IO has been completed. No local abort */
1614e1bc9a0SAchim Leubner {
1624e1bc9a0SAchim Leubner }
1634e1bc9a0SAchim Leubner else if (tiINIIOAbort(&pCard->tiRoot, &ccbIO->tiIORequest) != tiSuccess)
1644e1bc9a0SAchim Leubner {
1654e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeTaskManagement: Local Abort failed\n");
1664e1bc9a0SAchim Leubner /* TODO: call Soft reset here */
1674e1bc9a0SAchim Leubner }
1684e1bc9a0SAchim Leubner }
1694e1bc9a0SAchim Leubner else if (eventStatus == tiTMFailed)
1704e1bc9a0SAchim Leubner {
1714e1bc9a0SAchim Leubner ccbIO = pccb->pccbIO;
1724e1bc9a0SAchim Leubner if (ccbIO->startTime == 0) /* IO has been completed. */
1734e1bc9a0SAchim Leubner {
174*4a00a651SPedro F. Giffuni AGTIAPI_PRINTK("tiIntrEventTypeTaskManagement: TM failed because IO has been completed! pTMccb %p flag %x \n",
1754e1bc9a0SAchim Leubner pccb, pccb->flags);
1764e1bc9a0SAchim Leubner }
1774e1bc9a0SAchim Leubner else
1784e1bc9a0SAchim Leubner {
1794e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeTaskManagement: TM failed! pTMccb %p flag %x \n",
1804e1bc9a0SAchim Leubner pccb, pccb->flags);
1814e1bc9a0SAchim Leubner /* TODO:*/
1824e1bc9a0SAchim Leubner /* if TM_ABORT_TASK, call TM_TARGET_RESET */
1834e1bc9a0SAchim Leubner /* if TM_TARGET_RESET, call Soft_Reset */
1844e1bc9a0SAchim Leubner }
1854e1bc9a0SAchim Leubner }
1864e1bc9a0SAchim Leubner /* Free TM_DEV_RESET ccb */
1874e1bc9a0SAchim Leubner agtiapi_FreeTMCCB(pCard, pccb);
1884e1bc9a0SAchim Leubner }
1894e1bc9a0SAchim Leubner }
1904e1bc9a0SAchim Leubner break;
1914e1bc9a0SAchim Leubner case tiIntrEventTypeLocalAbort:
1924e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeLocalAbort!\n");
1934e1bc9a0SAchim Leubner pccb = (pccb_t)((tiIORequest_t *)parm)->osData;
1944e1bc9a0SAchim Leubner pccb->flags |= AGTIAPI_CB_DONE;
1954e1bc9a0SAchim Leubner if (eventStatus == tiAbortOK)
1964e1bc9a0SAchim Leubner {
1974e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeLocalAbort: taskTag pccb %p flag %x \n",
1984e1bc9a0SAchim Leubner pccb, pccb->flags);
1994e1bc9a0SAchim Leubner /* If this was LocalAbort for TM ABORT_TASK, issue TM_DEV_RESET */
2004e1bc9a0SAchim Leubner if (pccb->flags & TASK_MANAGEMENT)
2014e1bc9a0SAchim Leubner {
2024e1bc9a0SAchim Leubner if ((pTMccb = agtiapi_GetCCB(pCard)) == NULL)
2034e1bc9a0SAchim Leubner {
2044e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeLocalAbort: TM resource unavailable!\n");
2054e1bc9a0SAchim Leubner /* TODO: SoftReset here? */
2064e1bc9a0SAchim Leubner }
2074e1bc9a0SAchim Leubner pTMccb->pmcsc = pCard;
2084e1bc9a0SAchim Leubner pTMccb->targetId = pccb->targetId;
2094e1bc9a0SAchim Leubner pTMccb->devHandle = pccb->devHandle;
2104e1bc9a0SAchim Leubner
2114e1bc9a0SAchim Leubner /* save pending io to issue local abort at Task mgmt CB */
2124e1bc9a0SAchim Leubner pTMccb->pccbIO = pccb->pccbIO;
2134e1bc9a0SAchim Leubner pTMccb->flags &= ~(TASK_SUCCESS | ACTIVE);
2144e1bc9a0SAchim Leubner pTMccb->flags |= DEV_RESET;
2154e1bc9a0SAchim Leubner if (tiINITaskManagement(&pCard->tiRoot,
2164e1bc9a0SAchim Leubner pccb->devHandle,
2174e1bc9a0SAchim Leubner AG_TARGET_WARM_RESET,
2184e1bc9a0SAchim Leubner &pccb->tiSuperScsiRequest.scsiCmnd.lun,
2194e1bc9a0SAchim Leubner &pccb->tiIORequest,
2204e1bc9a0SAchim Leubner &pTMccb->tiIORequest)
2214e1bc9a0SAchim Leubner == tiSuccess)
2224e1bc9a0SAchim Leubner {
2234e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeLocalAbort: TM_TARGET_RESET request success ccb %p, pTMccb %p\n",
2244e1bc9a0SAchim Leubner pccb, pTMccb);
2254e1bc9a0SAchim Leubner pTMccb->startTime = ticks;
2264e1bc9a0SAchim Leubner }
2274e1bc9a0SAchim Leubner else
2284e1bc9a0SAchim Leubner {
2294e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeLocalAbort: TM_TARGET_RESET request failed ccb %p, pTMccb %p\n",
2304e1bc9a0SAchim Leubner pccb, pTMccb);
2314e1bc9a0SAchim Leubner agtiapi_FreeTMCCB(pCard, pTMccb);
2324e1bc9a0SAchim Leubner /* TODO: SoftReset here? */
2334e1bc9a0SAchim Leubner }
2344e1bc9a0SAchim Leubner /* Free ABORT_TASK TM ccb */
2354e1bc9a0SAchim Leubner agtiapi_FreeTMCCB(pCard, pccb);
2364e1bc9a0SAchim Leubner }
2374e1bc9a0SAchim Leubner }
2384e1bc9a0SAchim Leubner else if (eventStatus == tiAbortFailed)
2394e1bc9a0SAchim Leubner {
2404e1bc9a0SAchim Leubner /* TODO: */
2414e1bc9a0SAchim Leubner /* If TM_ABORT_TASK fails, issue TM_DEV_RESET */
2424e1bc9a0SAchim Leubner /* if TM_DEV_RESET fails, issue Soft_Reset */
2434e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventTypeLocalAbort: Abort Failed pccb %p\n", pccb);
2444e1bc9a0SAchim Leubner }
2454e1bc9a0SAchim Leubner break;
2464e1bc9a0SAchim Leubner default:
2474e1bc9a0SAchim Leubner AGTIAPI_PRINTK("tiIntrEventType default!\n");
2484e1bc9a0SAchim Leubner break;
2494e1bc9a0SAchim Leubner }
2504e1bc9a0SAchim Leubner }
2514e1bc9a0SAchim Leubner
2524e1bc9a0SAchim Leubner
2534e1bc9a0SAchim Leubner /******************************************************************************
2544e1bc9a0SAchim Leubner ostiInitiatorIOCompleted()
2554e1bc9a0SAchim Leubner
2564e1bc9a0SAchim Leubner Purpose:
2574e1bc9a0SAchim Leubner IO request completion call back
2584e1bc9a0SAchim Leubner Parameters:
2594e1bc9a0SAchim Leubner tiRoot_t *ptiRoot (IN) Pointer to the HBA tiRoot
2604e1bc9a0SAchim Leubner tiIORequest_t *ptiIORequest (IN) Pointer to the tiIORequest structure
2614e1bc9a0SAchim Leubner tiIOStatus_t IOStatus (IN) I/O complated status
2624e1bc9a0SAchim Leubner U32 statusDetail (IN) Additional information on status
2634e1bc9a0SAchim Leubner tiSenseData_t *pSensedata (IN) Sense data buffer pointer
2644e1bc9a0SAchim Leubner U32 context (IN) Interrupt dealing context
2654e1bc9a0SAchim Leubner Returns:
2664e1bc9a0SAchim Leubner Note:
2674e1bc9a0SAchim Leubner ******************************************************************************/
2684e1bc9a0SAchim Leubner void
ostiInitiatorIOCompleted(tiRoot_t * ptiRoot,tiIORequest_t * ptiIORequest,tiIOStatus_t IOStatus,U32 statusDetail,tiSenseData_t * pSenseData,U32 context)2694e1bc9a0SAchim Leubner ostiInitiatorIOCompleted(tiRoot_t *ptiRoot,
2704e1bc9a0SAchim Leubner tiIORequest_t *ptiIORequest,
2714e1bc9a0SAchim Leubner tiIOStatus_t IOStatus,
2724e1bc9a0SAchim Leubner U32 statusDetail,
2734e1bc9a0SAchim Leubner tiSenseData_t *pSenseData,
2744e1bc9a0SAchim Leubner U32 context )
2754e1bc9a0SAchim Leubner {
2764e1bc9a0SAchim Leubner struct agtiapi_softc *pCard;
2774e1bc9a0SAchim Leubner ccb_t *pccb;
2784e1bc9a0SAchim Leubner
2794e1bc9a0SAchim Leubner pCard = TIROOT_TO_CARD(ptiRoot);
2804e1bc9a0SAchim Leubner pccb = (ccb_t *)ptiIORequest->osData;
2814e1bc9a0SAchim Leubner
2824e1bc9a0SAchim Leubner AGTIAPI_IO( "ostiInitiatorIOCompleted: start\n" );
2834e1bc9a0SAchim Leubner
2844e1bc9a0SAchim Leubner if (IOStatus == tiIODifError)
2854e1bc9a0SAchim Leubner {
2864e1bc9a0SAchim Leubner return;
2874e1bc9a0SAchim Leubner }
2884e1bc9a0SAchim Leubner OSTI_OUT_ENTER(ptiRoot);
2894e1bc9a0SAchim Leubner
2904e1bc9a0SAchim Leubner pccb->ccbStatus = (U16)IOStatus;
2914e1bc9a0SAchim Leubner pccb->scsiStatus = statusDetail;
2924e1bc9a0SAchim Leubner
2934e1bc9a0SAchim Leubner if ((IOStatus == tiIOSuccess) && (statusDetail == SCSI_CHECK_CONDITION))
2944e1bc9a0SAchim Leubner {
2954e1bc9a0SAchim Leubner if (pSenseData == (tiSenseData_t *)agNULL)
2964e1bc9a0SAchim Leubner {
2974e1bc9a0SAchim Leubner AGTIAPI_PRINTK( "ostiInitiatorIOCompleted: "
2984e1bc9a0SAchim Leubner "check condition without sense data!\n" );
2994e1bc9a0SAchim Leubner }
3004e1bc9a0SAchim Leubner else
3014e1bc9a0SAchim Leubner {
3024e1bc9a0SAchim Leubner union ccb *ccb = pccb->ccb;
3034e1bc9a0SAchim Leubner struct ccb_scsiio *csio = &ccb->csio;
3044e1bc9a0SAchim Leubner int sense_len = 0;
3054e1bc9a0SAchim Leubner if (pccb->senseLen > pSenseData->senseLen)
3064e1bc9a0SAchim Leubner {
3074e1bc9a0SAchim Leubner csio->sense_resid = pccb->senseLen - pSenseData->senseLen;
3084e1bc9a0SAchim Leubner }
3094e1bc9a0SAchim Leubner else
3104e1bc9a0SAchim Leubner {
3114e1bc9a0SAchim Leubner csio->sense_resid = 0;
3124e1bc9a0SAchim Leubner }
3134e1bc9a0SAchim Leubner sense_len = MIN( pSenseData->senseLen,
3144e1bc9a0SAchim Leubner pccb->senseLen - csio->sense_resid );
31599c006f9SPedro F. Giffuni bzero(&csio->sense_data, sizeof(csio->sense_data));
3164e1bc9a0SAchim Leubner AGTIAPI_PRINTK("ostiInitiatorIOCompleted: check condition copying\n");
3174e1bc9a0SAchim Leubner memcpy( (void *)pccb->pSenseData,
3184e1bc9a0SAchim Leubner pSenseData->senseData,
3194e1bc9a0SAchim Leubner sense_len );
3204e1bc9a0SAchim Leubner agtiapi_hexdump( "ostiInitiatorIOCompleted check condition",
3214e1bc9a0SAchim Leubner (bit8 *)&csio->sense_data, sense_len );
3224e1bc9a0SAchim Leubner }
3234e1bc9a0SAchim Leubner }
3244e1bc9a0SAchim Leubner if ((IOStatus == tiIOFailed) && (statusDetail == tiDetailAborted))
3254e1bc9a0SAchim Leubner {
3264e1bc9a0SAchim Leubner AGTIAPI_PRINTK("ostiInitiatorIOCompleted - aborted ccb %p, flag %x\n",
3274e1bc9a0SAchim Leubner pccb, pccb->flags);
3284e1bc9a0SAchim Leubner /* indicate aborted IO completion */
3294e1bc9a0SAchim Leubner pccb->startTime = 0;
3304e1bc9a0SAchim Leubner agtiapi_Done(pCard, pccb);
3314e1bc9a0SAchim Leubner }
3324e1bc9a0SAchim Leubner else
3334e1bc9a0SAchim Leubner {
3344e1bc9a0SAchim Leubner #ifdef AGTIAPI_SA
3354e1bc9a0SAchim Leubner /*
3364e1bc9a0SAchim Leubner * SAS no data command does not trigger interrupt.
3374e1bc9a0SAchim Leubner * Command is completed in tdlayer and IO completion is called directly.
3384e1bc9a0SAchim Leubner * The completed IO therefore is not post processed.
3394e1bc9a0SAchim Leubner * Flag is raised and TDTimer will check and process IO for SAS.
3404e1bc9a0SAchim Leubner * This is a temporary solution. - Eddie, 07-17-2006
3414e1bc9a0SAchim Leubner */
3424e1bc9a0SAchim Leubner pCard->flags |= AGTIAPI_FLAG_UP;
3434e1bc9a0SAchim Leubner #endif
3444e1bc9a0SAchim Leubner pccb->flags |= REQ_DONE;
3454e1bc9a0SAchim Leubner agtiapi_QueueCCB(pCard, &pCard->ccbDoneHead, &pCard->ccbDoneTail
3464e1bc9a0SAchim Leubner AG_CARD_LOCAL_LOCK(&pCard->doneLock), pccb);
3474e1bc9a0SAchim Leubner }
3484e1bc9a0SAchim Leubner OSTI_OUT_LEAVE(ptiRoot);
3494e1bc9a0SAchim Leubner return;
3504e1bc9a0SAchim Leubner }
3514e1bc9a0SAchim Leubner #ifdef HIALEAH_ENCRYPTION
3524e1bc9a0SAchim Leubner osGLOBAL void
ostidisableEncryption(tiRoot_t * ptiRoot)3534e1bc9a0SAchim Leubner ostidisableEncryption(tiRoot_t *ptiRoot)
3544e1bc9a0SAchim Leubner {
3554e1bc9a0SAchim Leubner struct agtiapi_softc *pCard;
3564e1bc9a0SAchim Leubner pCard = TIROOT_TO_CARD(ptiRoot);
3574e1bc9a0SAchim Leubner pCard->encrypt=agFALSE;
3584e1bc9a0SAchim Leubner }
3594e1bc9a0SAchim Leubner #endif
3604e1bc9a0SAchim Leubner /* device Handle */
3614e1bc9a0SAchim Leubner osGLOBAL //FORCEINLINE
3624e1bc9a0SAchim Leubner tiDeviceHandle_t*
ostiGetDevHandleFromSasAddr(tiRoot_t * root,unsigned char * sas_addr)3634e1bc9a0SAchim Leubner ostiGetDevHandleFromSasAddr(
3644e1bc9a0SAchim Leubner tiRoot_t *root,
3654e1bc9a0SAchim Leubner unsigned char *sas_addr
3664e1bc9a0SAchim Leubner )
3674e1bc9a0SAchim Leubner {
3684e1bc9a0SAchim Leubner int i;
3694e1bc9a0SAchim Leubner unsigned long x;
3704e1bc9a0SAchim Leubner
3714e1bc9a0SAchim Leubner ag_portal_data_t *pPortal = NULL;
3724e1bc9a0SAchim Leubner tiDeviceHandle_t *devHandle = NULL;
3734e1bc9a0SAchim Leubner struct agtiapi_softc *pCard = TIROOT_TO_CARD(root);
3744e1bc9a0SAchim Leubner bit8 sas_addr_hi[4], sas_addr_lo[4];
3754e1bc9a0SAchim Leubner
3764e1bc9a0SAchim Leubner
3774e1bc9a0SAchim Leubner for(i=0; i<4; i++)
3784e1bc9a0SAchim Leubner {
3794e1bc9a0SAchim Leubner sas_addr_hi[i] = sas_addr[3-i];
3804e1bc9a0SAchim Leubner }
3814e1bc9a0SAchim Leubner
3824e1bc9a0SAchim Leubner for(i=0; i<4; i++)
3834e1bc9a0SAchim Leubner {
3844e1bc9a0SAchim Leubner sas_addr_lo[i] = sas_addr[7-i];
3854e1bc9a0SAchim Leubner }
3864e1bc9a0SAchim Leubner
3874e1bc9a0SAchim Leubner /* Retrieve the handles for each portal */
3884e1bc9a0SAchim Leubner for (x=0; x < pCard->portCount; x++)
3894e1bc9a0SAchim Leubner {
3904e1bc9a0SAchim Leubner pPortal = &pCard->pPortalData[x];
3914e1bc9a0SAchim Leubner devHandle = tiINIGetExpDeviceHandleBySasAddress(&pCard->tiRoot,
3924e1bc9a0SAchim Leubner &pPortal->portalInfo.tiPortalContext,
3934e1bc9a0SAchim Leubner *(bit32*)sas_addr_hi,
3944e1bc9a0SAchim Leubner *(bit32*)sas_addr_lo,
3954e1bc9a0SAchim Leubner (bit32)1024/*gMaxTargets*/);
3964e1bc9a0SAchim Leubner if(devHandle != NULL)
3974e1bc9a0SAchim Leubner break;
3984e1bc9a0SAchim Leubner }
3994e1bc9a0SAchim Leubner return devHandle;
4004e1bc9a0SAchim Leubner
4014e1bc9a0SAchim Leubner return NULL;
4024e1bc9a0SAchim Leubner }
4034e1bc9a0SAchim Leubner /******************************************************************************
4044e1bc9a0SAchim Leubner ostiInitiatorSMPCompleted()
4054e1bc9a0SAchim Leubner
4064e1bc9a0SAchim Leubner Purpose:
4074e1bc9a0SAchim Leubner IO request completion call back
4084e1bc9a0SAchim Leubner Parameters:
4094e1bc9a0SAchim Leubner tiRoot_t *ptiRoot (IN) Pointer to the HBA tiRoot
4104e1bc9a0SAchim Leubner tiIORequest_t *ptiSMPRequest (IN) Pointer to the SMP request structure
4114e1bc9a0SAchim Leubner tiIOStatus_t IOStatus (IN) I/O complated status
4124e1bc9a0SAchim Leubner U32 tiSMPInfoLen (IN) Number of bytes of response frame len
4134e1bc9a0SAchim Leubner tiFrameHandle (IN) Handle that referes to response frame
4144e1bc9a0SAchim Leubner U32 context (IN) Interrupt dealing context
4154e1bc9a0SAchim Leubner Returns:
4164e1bc9a0SAchim Leubner Note:
4174e1bc9a0SAchim Leubner ******************************************************************************/
4184e1bc9a0SAchim Leubner void
ostiInitiatorSMPCompleted(tiRoot_t * ptiRoot,tiIORequest_t * ptiSMPRequest,tiSMPStatus_t smpStatus,bit32 tiSMPInfoLen,void * tiFrameHandle,bit32 context)4194e1bc9a0SAchim Leubner ostiInitiatorSMPCompleted(tiRoot_t *ptiRoot,
4204e1bc9a0SAchim Leubner tiIORequest_t *ptiSMPRequest,
4214e1bc9a0SAchim Leubner tiSMPStatus_t smpStatus,
4224e1bc9a0SAchim Leubner bit32 tiSMPInfoLen,
4234e1bc9a0SAchim Leubner void *tiFrameHandle,
4244e1bc9a0SAchim Leubner bit32 context)
4254e1bc9a0SAchim Leubner {
4264e1bc9a0SAchim Leubner struct agtiapi_softc *pCard;
4274e1bc9a0SAchim Leubner ccb_t *pccb;
4284e1bc9a0SAchim Leubner pCard = TIROOT_TO_CARD(ptiRoot);
4294e1bc9a0SAchim Leubner pccb = (ccb_t *)ptiSMPRequest->osData;
4304e1bc9a0SAchim Leubner
4314e1bc9a0SAchim Leubner AGTIAPI_PRINTK("ostiInitiatorSMPCompleted: start\n");
4324e1bc9a0SAchim Leubner
4334e1bc9a0SAchim Leubner OSTI_OUT_ENTER(ptiRoot);
4344e1bc9a0SAchim Leubner pccb->ccbStatus = (U16)smpStatus;
4354e1bc9a0SAchim Leubner if(smpStatus != tiSMPSuccess)
4364e1bc9a0SAchim Leubner {
4374e1bc9a0SAchim Leubner AGTIAPI_PRINTK("ostiInitiatorSMPCompleted: SMP Error\n");
4384e1bc9a0SAchim Leubner }
4394e1bc9a0SAchim Leubner else
4404e1bc9a0SAchim Leubner {
4414e1bc9a0SAchim Leubner union ccb *ccb = pccb->ccb;
4424e1bc9a0SAchim Leubner struct ccb_smpio *csmpio = &ccb->smpio;
4434e1bc9a0SAchim Leubner memcpy(csmpio->smp_response, tiFrameHandle, tiSMPInfoLen);
4444e1bc9a0SAchim Leubner csmpio->smp_response_len = tiSMPInfoLen;
445*4a00a651SPedro F. Giffuni agtiapi_hexdump("ostiInitiatorSMPCompleted: Response Payload in CAM", (bit8 *)csmpio->smp_response, csmpio->smp_response_len);
4464e1bc9a0SAchim Leubner }
4474e1bc9a0SAchim Leubner pccb->flags |= REQ_DONE;
4484e1bc9a0SAchim Leubner agtiapi_QueueCCB(pCard, &pCard->smpDoneHead, &pCard->smpDoneTail
4494e1bc9a0SAchim Leubner AG_CARD_LOCAL_LOCK(&pCard->doneSMPLock), pccb);
4504e1bc9a0SAchim Leubner AGTIAPI_PRINTK("ostiInitiatorSMPCompleted: Done\n");
4514e1bc9a0SAchim Leubner OSTI_OUT_LEAVE(ptiRoot);
4524e1bc9a0SAchim Leubner
4534e1bc9a0SAchim Leubner return;
4544e1bc9a0SAchim Leubner }
4554e1bc9a0SAchim Leubner
4564e1bc9a0SAchim Leubner #ifdef FAST_IO_TEST
4574e1bc9a0SAchim Leubner void
osti_FastIOCb(tiRoot_t * ptiRoot,void * arg,tiIOStatus_t IOStatus,U32 statusDetail)4584e1bc9a0SAchim Leubner osti_FastIOCb(tiRoot_t *ptiRoot,
4594e1bc9a0SAchim Leubner void *arg,
4604e1bc9a0SAchim Leubner tiIOStatus_t IOStatus,
4614e1bc9a0SAchim Leubner U32 statusDetail)
4624e1bc9a0SAchim Leubner {
4634e1bc9a0SAchim Leubner ccb_t *pccb = (ccb_t*)arg;
4644e1bc9a0SAchim Leubner ag_card_t *pCard;
4654e1bc9a0SAchim Leubner
4664e1bc9a0SAchim Leubner static int callNum = 0;
4674e1bc9a0SAchim Leubner
4684e1bc9a0SAchim Leubner callNum++;
4694e1bc9a0SAchim Leubner
4704e1bc9a0SAchim Leubner BUG_ON(!pccb);
4714e1bc9a0SAchim Leubner
4724e1bc9a0SAchim Leubner if ((callNum % CMDS_PER_IO_DUP) != 0)
4734e1bc9a0SAchim Leubner {
4744e1bc9a0SAchim Leubner goto err;
4754e1bc9a0SAchim Leubner }
4764e1bc9a0SAchim Leubner
4774e1bc9a0SAchim Leubner pccb->ccbStatus = IOStatus;
4784e1bc9a0SAchim Leubner pccb->scsiStatus = statusDetail;
4794e1bc9a0SAchim Leubner
4804e1bc9a0SAchim Leubner /* pccb->pSenseData is copied already */
4814e1bc9a0SAchim Leubner
4824e1bc9a0SAchim Leubner if (pccb->flags & AGTIAPI_ABORT)
4834e1bc9a0SAchim Leubner {
4844e1bc9a0SAchim Leubner AGTIAPI_PRINTK("agtiapi_SuperIOCb: aborted ccb %p, flag %x\n",
4854e1bc9a0SAchim Leubner pccb, pccb->flags);
4864e1bc9a0SAchim Leubner pccb->startTime = 0; /* indicate aborted IO completion */
4874e1bc9a0SAchim Leubner BUG_ON(1);
4884e1bc9a0SAchim Leubner goto err;
4894e1bc9a0SAchim Leubner }
4904e1bc9a0SAchim Leubner pCard = TIROOT_TO_CARD(ptiRoot);
4914e1bc9a0SAchim Leubner pccb->flags |= REQ_DONE;
4924e1bc9a0SAchim Leubner agtiapi_QueueCCB(pCard, &pCard->ccbDoneHead, &pCard->ccbDoneTail
4934e1bc9a0SAchim Leubner AG_CARD_LOCAL_LOCK(&pCard->doneLock), pccb);
4944e1bc9a0SAchim Leubner err:
4954e1bc9a0SAchim Leubner return;
4964e1bc9a0SAchim Leubner } /* osti_FastIOCb */
4974e1bc9a0SAchim Leubner #endif
4984e1bc9a0SAchim Leubner
4994e1bc9a0SAchim Leubner
5004e1bc9a0SAchim Leubner /******************************************************************************
5014e1bc9a0SAchim Leubner ostiSingleThreadedEnter()
5024e1bc9a0SAchim Leubner
5034e1bc9a0SAchim Leubner Purpose:
5044e1bc9a0SAchim Leubner Critical region code excution protection.
5054e1bc9a0SAchim Leubner Parameters:
5064e1bc9a0SAchim Leubner tiRoot_t *ptiRoot (IN) Pointer to tiRoot data structure
5074e1bc9a0SAchim Leubner U32 queueId (IN) spinlock Id
5084e1bc9a0SAchim Leubner Returns:
5094e1bc9a0SAchim Leubner Note:
5104e1bc9a0SAchim Leubner Lock is held by oslayer.
5114e1bc9a0SAchim Leubner ******************************************************************************/
5124e1bc9a0SAchim Leubner void
ostiSingleThreadedEnter(tiRoot_t * ptiRoot,U32 queueId)5134e1bc9a0SAchim Leubner ostiSingleThreadedEnter(tiRoot_t *ptiRoot, U32 queueId)
5144e1bc9a0SAchim Leubner {
5154e1bc9a0SAchim Leubner struct agtiapi_softc *pCard = TIROOT_TO_CARD(ptiRoot);
5164e1bc9a0SAchim Leubner mtx_lock( &pCard->STLock[queueId] ); // review: need irq save? ##
5174e1bc9a0SAchim Leubner }
5184e1bc9a0SAchim Leubner
5194e1bc9a0SAchim Leubner
5204e1bc9a0SAchim Leubner /******************************************************************************
5214e1bc9a0SAchim Leubner ostiSingleThreadedLeave()
5224e1bc9a0SAchim Leubner
5234e1bc9a0SAchim Leubner Purpose:
5244e1bc9a0SAchim Leubner Restore multi-threading environment.
5254e1bc9a0SAchim Leubner Parameters:
5264e1bc9a0SAchim Leubner tiRoot_t *ptiRoot (IN) Pointer to the tiRoot data structure
5274e1bc9a0SAchim Leubner U32 queueId (IN) spinlock Id
5284e1bc9a0SAchim Leubner Returns:
5294e1bc9a0SAchim Leubner Note:
5304e1bc9a0SAchim Leubner Lock is held by oslayer.
5314e1bc9a0SAchim Leubner ******************************************************************************/
5324e1bc9a0SAchim Leubner void
ostiSingleThreadedLeave(tiRoot_t * ptiRoot,U32 queueId)5334e1bc9a0SAchim Leubner ostiSingleThreadedLeave(tiRoot_t *ptiRoot, U32 queueId)
5344e1bc9a0SAchim Leubner {
5354e1bc9a0SAchim Leubner struct agtiapi_softc *pCard = TIROOT_TO_CARD(ptiRoot);
5364e1bc9a0SAchim Leubner mtx_unlock( &pCard->STLock[queueId] ); // review: need irq restore? ##
5374e1bc9a0SAchim Leubner }
5384e1bc9a0SAchim Leubner
5394e1bc9a0SAchim Leubner
5404e1bc9a0SAchim Leubner osGLOBAL tiDeviceHandle_t*
ostiMapToDevHandle(tiRoot_t * root,bit8 pathId,bit8 targetId,bit8 LUN)5414e1bc9a0SAchim Leubner ostiMapToDevHandle(tiRoot_t *root,
5424e1bc9a0SAchim Leubner bit8 pathId,
5434e1bc9a0SAchim Leubner bit8 targetId,
5444e1bc9a0SAchim Leubner bit8 LUN
5454e1bc9a0SAchim Leubner )
5464e1bc9a0SAchim Leubner {
5474e1bc9a0SAchim Leubner tiDeviceHandle_t *dev = NULL;
5484e1bc9a0SAchim Leubner struct agtiapi_softc *pCard;
5494e1bc9a0SAchim Leubner bit32 offset;
5504e1bc9a0SAchim Leubner
5514e1bc9a0SAchim Leubner pCard = TIROOT_TO_CARD(root);
5524e1bc9a0SAchim Leubner
5534e1bc9a0SAchim Leubner offset = pathId * pCard->tgtCount + targetId;
5544e1bc9a0SAchim Leubner
5554e1bc9a0SAchim Leubner if (offset > (pCard->tgtCount - 1) )
5564e1bc9a0SAchim Leubner {
5574e1bc9a0SAchim Leubner dev = NULL;
5584e1bc9a0SAchim Leubner }
5594e1bc9a0SAchim Leubner else
5604e1bc9a0SAchim Leubner {
5614e1bc9a0SAchim Leubner dev = pCard->pDevList[offset].pDevHandle;
5624e1bc9a0SAchim Leubner }
5634e1bc9a0SAchim Leubner
5644e1bc9a0SAchim Leubner return dev;
5654e1bc9a0SAchim Leubner }
5664e1bc9a0SAchim Leubner
5674e1bc9a0SAchim Leubner
5684e1bc9a0SAchim Leubner
5694e1bc9a0SAchim Leubner #ifdef PERF_COUNT
5704e1bc9a0SAchim Leubner
5714e1bc9a0SAchim Leubner #ifdef AGTIAPI_LOCAL_LOCK
5724e1bc9a0SAchim Leubner #define OSTI_SPIN_LOCK(lock) spin_lock(lock)
5734e1bc9a0SAchim Leubner #define OSTI_SPIN_UNLOCK(lock) spin_unlock(lock)
5744e1bc9a0SAchim Leubner #else
5754e1bc9a0SAchim Leubner #define OSTI_SPIN_LOCK(lock)
5764e1bc9a0SAchim Leubner #define OSTI_SPIN_UNLOCK(lock)
5774e1bc9a0SAchim Leubner #endif
5784e1bc9a0SAchim Leubner
5794e1bc9a0SAchim Leubner
5804e1bc9a0SAchim Leubner void
ostiEnter(tiRoot_t * ptiRoot,U32 layer,int io)5814e1bc9a0SAchim Leubner ostiEnter(tiRoot_t *ptiRoot, U32 layer, int io)
5824e1bc9a0SAchim Leubner {
5834e1bc9a0SAchim Leubner ag_card_t *pCard = ((ag_card_info_t*)ptiRoot->osData)->pCard;
5844e1bc9a0SAchim Leubner int ini = ((pCard->flags & AGTIAPI_INIT_TIME) == AGTIAPI_INIT_TIME);
5854e1bc9a0SAchim Leubner
5864e1bc9a0SAchim Leubner BUG_ON((io != 0 && io != 1) || (layer != 0 && layer != 1 && layer != 2));
5874e1bc9a0SAchim Leubner if (!ini)
5884e1bc9a0SAchim Leubner {
5894e1bc9a0SAchim Leubner unsigned long long cycles = get_cycles();
5904e1bc9a0SAchim Leubner
5914e1bc9a0SAchim Leubner OSTI_SPIN_LOCK(&pCard->latLock);
5924e1bc9a0SAchim Leubner BUG_ON(pCard->callLevel[io] >= sizeof(pCard->layer[0]) /
5934e1bc9a0SAchim Leubner sizeof(pCard->layer[0][0]));
5944e1bc9a0SAchim Leubner if (pCard->callLevel[io] > 0)
5954e1bc9a0SAchim Leubner {
5964e1bc9a0SAchim Leubner unsigned int prev_layer = pCard->layer[io][pCard->callLevel[io] - 1];
5974e1bc9a0SAchim Leubner
5984e1bc9a0SAchim Leubner pCard->totalCycles[io][prev_layer] += cycles -
5994e1bc9a0SAchim Leubner pCard->enterCycles[io][prev_layer];
6004e1bc9a0SAchim Leubner }
6014e1bc9a0SAchim Leubner pCard->enterCycles[io][layer] = cycles;
6024e1bc9a0SAchim Leubner pCard->layer[io][pCard->callLevel[io]] = layer;
6034e1bc9a0SAchim Leubner pCard->callLevel[io]++;
6044e1bc9a0SAchim Leubner OSTI_SPIN_UNLOCK(&pCard->latLock);
6054e1bc9a0SAchim Leubner }
6064e1bc9a0SAchim Leubner }
6074e1bc9a0SAchim Leubner
6084e1bc9a0SAchim Leubner void
ostiLeave(tiRoot_t * ptiRoot,U32 layer,int io)6094e1bc9a0SAchim Leubner ostiLeave(tiRoot_t *ptiRoot, U32 layer, int io)
6104e1bc9a0SAchim Leubner {
6114e1bc9a0SAchim Leubner ag_card_t *pCard = ((ag_card_info_t*)ptiRoot->osData)->pCard;
6124e1bc9a0SAchim Leubner int ini = ((pCard->flags & AGTIAPI_INIT_TIME) == AGTIAPI_INIT_TIME);
6134e1bc9a0SAchim Leubner
6144e1bc9a0SAchim Leubner BUG_ON((io != 0 && io != 1) || (layer != 0 && layer != 1 && layer != 2));
6154e1bc9a0SAchim Leubner if (!ini)
6164e1bc9a0SAchim Leubner {
6174e1bc9a0SAchim Leubner unsigned long long cycles = get_cycles();
6184e1bc9a0SAchim Leubner
6194e1bc9a0SAchim Leubner OSTI_SPIN_LOCK(&pCard->latLock);
6204e1bc9a0SAchim Leubner pCard->callLevel[io]--;
6214e1bc9a0SAchim Leubner
6224e1bc9a0SAchim Leubner BUG_ON(pCard->callLevel[io] < 0);
6234e1bc9a0SAchim Leubner BUG_ON(pCard->layer[io][pCard->callLevel[io]] != layer);
6244e1bc9a0SAchim Leubner
6254e1bc9a0SAchim Leubner pCard->totalCycles[io][layer] += cycles - pCard->enterCycles[io][layer];
6264e1bc9a0SAchim Leubner if (pCard->callLevel[io] > 0)
6274e1bc9a0SAchim Leubner pCard->enterCycles[io][pCard->layer[io][pCard->callLevel[io] - 1]] =
6284e1bc9a0SAchim Leubner cycles;
6294e1bc9a0SAchim Leubner OSTI_SPIN_UNLOCK(&pCard->latLock);
6304e1bc9a0SAchim Leubner }
6314e1bc9a0SAchim Leubner }
6324e1bc9a0SAchim Leubner #endif
6334e1bc9a0SAchim Leubner
6344e1bc9a0SAchim Leubner
6354e1bc9a0SAchim Leubner
6364e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE bit8
ostiBitScanForward(tiRoot_t * root,bit32 * Index,bit32 Mask)6374e1bc9a0SAchim Leubner ostiBitScanForward(
6384e1bc9a0SAchim Leubner tiRoot_t *root,
6394e1bc9a0SAchim Leubner bit32 *Index,
6404e1bc9a0SAchim Leubner bit32 Mask
6414e1bc9a0SAchim Leubner )
6424e1bc9a0SAchim Leubner {
6434e1bc9a0SAchim Leubner return 1;
6444e1bc9a0SAchim Leubner
6454e1bc9a0SAchim Leubner }
6464e1bc9a0SAchim Leubner
6474e1bc9a0SAchim Leubner #ifdef REMOVED
6484e1bc9a0SAchim Leubner osGLOBAL sbit32
ostiAtomicIncrement(tiRoot_t * root,sbit32 volatile * Addend)6494e1bc9a0SAchim Leubner ostiAtomicIncrement(
6504e1bc9a0SAchim Leubner tiRoot_t *root,
6514e1bc9a0SAchim Leubner sbit32 volatile *Addend
6524e1bc9a0SAchim Leubner )
6534e1bc9a0SAchim Leubner {
6544e1bc9a0SAchim Leubner return 1;
6554e1bc9a0SAchim Leubner
6564e1bc9a0SAchim Leubner }
6574e1bc9a0SAchim Leubner
6584e1bc9a0SAchim Leubner osGLOBAL sbit32
ostiAtomicDecrement(tiRoot_t * root,sbit32 volatile * Addend)6594e1bc9a0SAchim Leubner ostiAtomicDecrement(
6604e1bc9a0SAchim Leubner tiRoot_t *root,
6614e1bc9a0SAchim Leubner sbit32 volatile *Addend
6624e1bc9a0SAchim Leubner )
6634e1bc9a0SAchim Leubner {
6644e1bc9a0SAchim Leubner
6654e1bc9a0SAchim Leubner return 1;
6664e1bc9a0SAchim Leubner
6674e1bc9a0SAchim Leubner }
6684e1bc9a0SAchim Leubner
6694e1bc9a0SAchim Leubner osGLOBAL sbit32
ostiAtomicBitClear(tiRoot_t * root,sbit32 volatile * Destination,sbit32 Value)6704e1bc9a0SAchim Leubner ostiAtomicBitClear(
6714e1bc9a0SAchim Leubner tiRoot_t *root,
6724e1bc9a0SAchim Leubner sbit32 volatile *Destination,
6734e1bc9a0SAchim Leubner sbit32 Value
6744e1bc9a0SAchim Leubner )
6754e1bc9a0SAchim Leubner {
6764e1bc9a0SAchim Leubner
6774e1bc9a0SAchim Leubner return 0;
6784e1bc9a0SAchim Leubner
6794e1bc9a0SAchim Leubner }
6804e1bc9a0SAchim Leubner
6814e1bc9a0SAchim Leubner osGLOBAL sbit32
ostiAtomicBitSet(tiRoot_t * root,sbit32 volatile * Destination,sbit32 Value)6824e1bc9a0SAchim Leubner ostiAtomicBitSet(
6834e1bc9a0SAchim Leubner tiRoot_t *root,
6844e1bc9a0SAchim Leubner sbit32 volatile *Destination,
6854e1bc9a0SAchim Leubner sbit32 Value
6864e1bc9a0SAchim Leubner )
6874e1bc9a0SAchim Leubner {
6884e1bc9a0SAchim Leubner return 0;
6894e1bc9a0SAchim Leubner
6904e1bc9a0SAchim Leubner /*
6914e1bc9a0SAchim Leubner set_bit(Value, (volatile unsigned long *)Destination);
6924e1bc9a0SAchim Leubner return 0;
6934e1bc9a0SAchim Leubner */
6944e1bc9a0SAchim Leubner }
6954e1bc9a0SAchim Leubner
6964e1bc9a0SAchim Leubner osGLOBAL sbit32
ostiAtomicExchange(tiRoot_t * root,sbit32 volatile * Target,sbit32 Value)6974e1bc9a0SAchim Leubner ostiAtomicExchange(
6984e1bc9a0SAchim Leubner tiRoot_t *root,
6994e1bc9a0SAchim Leubner sbit32 volatile *Target,
7004e1bc9a0SAchim Leubner sbit32 Value
7014e1bc9a0SAchim Leubner )
7024e1bc9a0SAchim Leubner {
7034e1bc9a0SAchim Leubner return 0;
7044e1bc9a0SAchim Leubner
7054e1bc9a0SAchim Leubner }
7064e1bc9a0SAchim Leubner #endif
7074e1bc9a0SAchim Leubner
7084e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
ostiInterlockedExchange(tiRoot_t * root,sbit32 volatile * Target,sbit32 Value)7094e1bc9a0SAchim Leubner ostiInterlockedExchange(
7104e1bc9a0SAchim Leubner tiRoot_t *root,
7114e1bc9a0SAchim Leubner sbit32 volatile *Target,
7124e1bc9a0SAchim Leubner sbit32 Value
7134e1bc9a0SAchim Leubner )
7144e1bc9a0SAchim Leubner {
7154e1bc9a0SAchim Leubner return 0;
7164e1bc9a0SAchim Leubner }
7174e1bc9a0SAchim Leubner
7184e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
ostiInterlockedIncrement(tiRoot_t * root,sbit32 volatile * Addend)7194e1bc9a0SAchim Leubner ostiInterlockedIncrement(
7204e1bc9a0SAchim Leubner tiRoot_t *root,
7214e1bc9a0SAchim Leubner sbit32 volatile *Addend
7224e1bc9a0SAchim Leubner )
7234e1bc9a0SAchim Leubner {
7244e1bc9a0SAchim Leubner return 0;
7254e1bc9a0SAchim Leubner }
7264e1bc9a0SAchim Leubner
7274e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
ostiInterlockedDecrement(tiRoot_t * root,sbit32 volatile * Addend)7284e1bc9a0SAchim Leubner ostiInterlockedDecrement(
7294e1bc9a0SAchim Leubner tiRoot_t *root,
7304e1bc9a0SAchim Leubner sbit32 volatile *Addend
7314e1bc9a0SAchim Leubner )
7324e1bc9a0SAchim Leubner {
7334e1bc9a0SAchim Leubner return 0;
7344e1bc9a0SAchim Leubner }
7354e1bc9a0SAchim Leubner
7364e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
ostiInterlockedAnd(tiRoot_t * root,sbit32 volatile * Destination,sbit32 Value)7374e1bc9a0SAchim Leubner ostiInterlockedAnd(
7384e1bc9a0SAchim Leubner tiRoot_t *root,
7394e1bc9a0SAchim Leubner sbit32 volatile *Destination,
7404e1bc9a0SAchim Leubner sbit32 Value
7414e1bc9a0SAchim Leubner )
7424e1bc9a0SAchim Leubner {
7434e1bc9a0SAchim Leubner return 0;
7444e1bc9a0SAchim Leubner }
7454e1bc9a0SAchim Leubner
7464e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
ostiInterlockedOr(tiRoot_t * root,sbit32 volatile * Destination,sbit32 Value)7474e1bc9a0SAchim Leubner ostiInterlockedOr(
7484e1bc9a0SAchim Leubner tiRoot_t *root,
7494e1bc9a0SAchim Leubner sbit32 volatile *Destination,
7504e1bc9a0SAchim Leubner sbit32 Value
7514e1bc9a0SAchim Leubner )
7524e1bc9a0SAchim Leubner {
7534e1bc9a0SAchim Leubner return 0;
7544e1bc9a0SAchim Leubner }
7554e1bc9a0SAchim Leubner
7564e1bc9a0SAchim Leubner // this is just stub code to allow compile and use of the module ...
7574e1bc9a0SAchim Leubner // now that a call to this function has been added with windows specific
7584e1bc9a0SAchim Leubner // intentions.
7594e1bc9a0SAchim Leubner osGLOBAL bit32
ostiSetDeviceQueueDepth(tiRoot_t * tiRoot,tiIORequest_t * tiIORequest,bit32 QueueDepth)7604e1bc9a0SAchim Leubner ostiSetDeviceQueueDepth( tiRoot_t *tiRoot,
7614e1bc9a0SAchim Leubner tiIORequest_t *tiIORequest,
7624e1bc9a0SAchim Leubner bit32 QueueDepth
7634e1bc9a0SAchim Leubner )
7644e1bc9a0SAchim Leubner {
7654e1bc9a0SAchim Leubner bit32 retVal = 0;
7664e1bc9a0SAchim Leubner ccb_t *pccb = (ccb_t *) tiIORequest->osData;
7674e1bc9a0SAchim Leubner tiDeviceHandle_t *tiDeviceHandle = pccb->devHandle;
7684e1bc9a0SAchim Leubner ag_device_t *pDevice = (ag_device_t *)tiDeviceHandle->osData;
7694e1bc9a0SAchim Leubner AGTIAPI_PRINTK( "ostiSetDeviceQueueDepth stub only: root%p, req%p, qdeep%d\n",
7704e1bc9a0SAchim Leubner tiRoot, tiIORequest, QueueDepth );
7714e1bc9a0SAchim Leubner pDevice->qdepth = QueueDepth;
7724e1bc9a0SAchim Leubner return retVal;
7734e1bc9a0SAchim Leubner }
7744e1bc9a0SAchim Leubner
7754e1bc9a0SAchim Leubner
7764e1bc9a0SAchim Leubner // this is just stub code to allow compile and use of the module ...
7774e1bc9a0SAchim Leubner // now that a call to this function has been added with windows specific
7784e1bc9a0SAchim Leubner // intentions.
7794e1bc9a0SAchim Leubner osGLOBAL void
ostiGetSenseKeyCount(tiRoot_t * root,bit32 fIsClear,void * SenseKeyCount,bit32 length)7804e1bc9a0SAchim Leubner ostiGetSenseKeyCount(tiRoot_t *root,
7814e1bc9a0SAchim Leubner bit32 fIsClear,
7824e1bc9a0SAchim Leubner void *SenseKeyCount,
7834e1bc9a0SAchim Leubner bit32 length
7844e1bc9a0SAchim Leubner )
7854e1bc9a0SAchim Leubner {
7864e1bc9a0SAchim Leubner AGTIAPI_PRINTK( "ostiGetSenseKeyCount stub only: rt%p, fcl%d, kyCt%p, ln%d\n",
7874e1bc9a0SAchim Leubner root, fIsClear, SenseKeyCount, length );
7884e1bc9a0SAchim Leubner }
7894e1bc9a0SAchim Leubner
7904e1bc9a0SAchim Leubner osGLOBAL void
ostiGetSCSIStatusCount(tiRoot_t * root,bit32 fIsClear,void * ScsiStatusCount,bit32 length)7914e1bc9a0SAchim Leubner ostiGetSCSIStatusCount(tiRoot_t *root,
7924e1bc9a0SAchim Leubner bit32 fIsClear,
7934e1bc9a0SAchim Leubner void *ScsiStatusCount,
7944e1bc9a0SAchim Leubner bit32 length
7954e1bc9a0SAchim Leubner )
7964e1bc9a0SAchim Leubner {
7974e1bc9a0SAchim Leubner AGTIAPI_PRINTK( "ostiGetSCSIStatusCount: stub only rt%p, fcl%d, kyCt%p, ln%d\n",
7984e1bc9a0SAchim Leubner root, fIsClear, ScsiStatusCount, length );
7994e1bc9a0SAchim Leubner
8004e1bc9a0SAchim Leubner }
8014e1bc9a0SAchim Leubner
ostiPCI_TRIGGER(tiRoot_t * tiRoot)8024e1bc9a0SAchim Leubner osGLOBAL void ostiPCI_TRIGGER( tiRoot_t *tiRoot )
8034e1bc9a0SAchim Leubner {
8044e1bc9a0SAchim Leubner ostiChipReadBit32Ext(tiRoot, 0, 0x5C);
8054e1bc9a0SAchim Leubner
8064e1bc9a0SAchim Leubner }
8074e1bc9a0SAchim Leubner
8084e1bc9a0SAchim Leubner osGLOBAL bit32
ostiNumOfLUNIOCTLreq(tiRoot_t * root,void * param1,void * param2,void ** tiRequestBody,tiIORequest_t ** tiIORequest)8094e1bc9a0SAchim Leubner ostiNumOfLUNIOCTLreq( tiRoot_t *root,
8104e1bc9a0SAchim Leubner void *param1,
8114e1bc9a0SAchim Leubner void *param2,
8124e1bc9a0SAchim Leubner void **tiRequestBody,
8134e1bc9a0SAchim Leubner tiIORequest_t **tiIORequest
8144e1bc9a0SAchim Leubner )
8154e1bc9a0SAchim Leubner {
8164e1bc9a0SAchim Leubner bit32 status = IOCTL_CALL_SUCCESS;
8174e1bc9a0SAchim Leubner pccb_t pccb;
8184e1bc9a0SAchim Leubner AGTIAPI_PRINTK("ostiNumOfLUNIOCTLreq: start\n");
8194e1bc9a0SAchim Leubner struct agtiapi_softc *pCard = TIROOT_TO_CARD(root);
8204e1bc9a0SAchim Leubner /* get a ccb */
8214e1bc9a0SAchim Leubner if ((pccb = agtiapi_GetCCB(pCard)) == NULL)
8224e1bc9a0SAchim Leubner {
8234e1bc9a0SAchim Leubner printf("ostiNumOfLUNIOCTLreq - GetCCB ERROR\n");
8244e1bc9a0SAchim Leubner status = IOCTL_CALL_FAIL;
8254e1bc9a0SAchim Leubner //BUG_ON(1);
8264e1bc9a0SAchim Leubner }
8274e1bc9a0SAchim Leubner
8284e1bc9a0SAchim Leubner *tiIORequest = (tiIORequest_t*)&pccb->tiIORequest;
8294e1bc9a0SAchim Leubner *tiRequestBody = &pccb->tdIOReqBody;
8304e1bc9a0SAchim Leubner AGTIAPI_PRINTK("ostiNumOfLUNIOCTLreq:end\n");
8314e1bc9a0SAchim Leubner return status;
8324e1bc9a0SAchim Leubner }
8334e1bc9a0SAchim Leubner
834