1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
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
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.
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
21 ********************************************************************************/
22 /*******************************************************************************/
24 * \brief The file implements the functions to do SAS/SATA discovery
27 /******************************************************************************/
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31 #include <dev/pms/config.h>
33 #include <dev/pms/RefTisa/sallsdk/spc/saglobal.h>
34 #ifdef SA_ENABLE_TRACE_FUNCTIONS
38 #define siTraceFileID 'C'
41 /******************************************************************************/
42 /*! \brief Start/Abort SAS/SATA discovery
44 * Start/Abort SAS/SATA discovery
46 * \param agRoot Handles for this instance of SAS/SATA hardware
47 * \param agPortContext Pointer to this instance of port context
48 * \param type Specifies the type(s) of discovery operation to start or cancel
49 * \param option Specified the discovery option
51 * \return If discovery is started/aborted successfully
52 * - \e AGSA_RC_SUCCESS discovery is started/aborted successfully
53 * - \e AGSA_RC_FAILURE discovery is not started/aborted successfully
56 /*******************************************************************************/
57 GLOBAL bit32 saDiscover(
59 agsaPortContext_t *agPortContext,
64 /* Currently not supported */
65 return AGSA_RC_FAILURE;
68 /******************************************************************************/
69 /*! \brief Function for target to remove stale initiator device handle
71 * function is called to ask the LL layer to remove all LL layer and SPC firmware
72 * internal resources associated with a device handle
74 * \param agRoot Handles for this instance of SAS/SATA hardware
75 * \param agDevHandle Handle of the device that this I/O request will be made on
77 * \return If the device handle is removed successfully
78 * - \e AGSA_RC_SUCCESS the device handle is removed successfully
79 * - \e AGSA_RC_BUSY the device is busy, cannot be removed now
82 /*******************************************************************************/
83 GLOBAL bit32 saDeregisterDeviceHandle(
85 agsaContext_t *agContext,
86 agsaDevHandle_t *agDevHandle,
90 agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
91 agsaDeviceDesc_t *pDevice;
93 bit32 ret = AGSA_RC_SUCCESS;
94 bit32 deviceid, portid;
97 OS_ASSERT(agDevHandle != agNULL, "saDeregisterDeviceHandle agDevHandle is NULL");
99 smTraceFuncEnter(hpDBG_VERY_LOUD, "za");
101 if(agNULL == agDevHandle)
103 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "za");
104 return AGSA_RC_FAILURE;
107 pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
109 OS_ASSERT(pDevice != agNULL, "saDeregisterDeviceHandle pDevice is NULL");
110 if(pDevice == agNULL)
112 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "za");
113 return AGSA_RC_FAILURE;
117 deviceid = pDevice->DeviceMapIndex;
118 deviceIdx = deviceid & DEVICE_ID_BITS;
119 OS_ASSERT(deviceIdx < MAX_IO_DEVICE_ENTRIES, "deviceIdx MAX_IO_DEVICE_ENTRIES");
120 pPort = pDevice->pPort;
122 portid = pPort->portId;
124 SA_DBG3(("saDeregisterDeviceHandle: start DeviceHandle %p\n", agDevHandle));
125 SA_DBG1(("saDeregisterDeviceHandle: deviceId 0x%x Device Context %p\n", deviceid, pDevice));
127 if ((deviceid != saRoot->DeviceMap[deviceIdx].DeviceIdFromFW) ||
128 (pDevice != saRoot->DeviceMap[deviceIdx].DeviceHandle))
130 SA_DBG1(("saDeregisterDeviceHandle: Not match failure\n"));
131 ret = AGSA_RC_FAILURE;
132 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "za");
136 /* Build IOMB and send it to SPC */
137 ret = mpiDeregDevHandleCmd(agRoot, agContext, pDevice, deviceid, portid, queueNum);
139 smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "za");
143 /******************************************************************************/
144 /*! \brief Function for target to remove stale initiator device handle
146 * function is called to ask the LL layer to remove all LL layer internal resources
147 * associated with a device handle
149 * \param agRoot Handles for this instance of SAS/SATA hardware
150 * \param agDevHandle Handle of the device that this I/O request will be made on
152 * \return If the device handle is removed successfully
153 * - \e AGSA_RC_SUCCESS the device handle is removed successfully
154 * - \e AGSA_RC_BUSY the device is busy, cannot be removed now
157 /*******************************************************************************/
158 GLOBAL bit32 siRemoveDevHandle(
160 agsaDevHandle_t *agDevHandle
163 agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
165 bit32 ret = AGSA_RC_SUCCESS;
167 OS_ASSERT(pDevice != agNULL, "siRemoveDevHandle is NULL");
168 smTraceFuncEnter(hpDBG_VERY_LOUD,"zb");
170 if (pDevice == agNULL)
172 SA_DBG1(("siRemoveDevHandle: pDevice is NULL \n"));
173 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zb");
174 return AGSA_RC_FAILURE;
177 /* If it's to remove an initiator device handle */
178 if ( &(pDevice->initiatorDevHandle) == agDevHandle )
180 (pDevice->initiatorDevHandle).sdkData = agNULL;
182 /* If it's to remove an target device handle */
183 else if ( &(pDevice->targetDevHandle) == agDevHandle )
185 (pDevice->targetDevHandle).sdkData = agNULL;
189 SA_ASSERT(agFALSE, "");
192 /* remove the device descriptor if it doesn't have either initiator handle and target handle */
193 if ( (agNULL == (pDevice->initiatorDevHandle).sdkData)
194 && (agNULL == (pDevice->targetDevHandle).sdkData) )
196 /* Find the port of the device */
197 pPort = pDevice->pPort;
199 /* remove the device descriptor free discover list */
200 switch ( pDevice->deviceType )
202 case STP_DEVICE: /* fall through */
204 case DIRECT_SATA_DEVICE:
206 SA_DBG3(("siRemoveDevHandle: remove device context %p\n", pDevice));
207 siPortDeviceRemove(agRoot, pPort, pDevice, agTRUE);
212 SA_DBG1(("siRemoveDevHandle: switch. Not calling siPortDeviceRemove %d\n", pDevice->deviceType));
219 SA_DBG1(("siRemoveDevHandle: else. Not caling siPortDeviceRemove\n"));
221 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zb");
225 /******************************************************************************/
226 /*! \brief Get Device Handles from a specific local port
228 * Get a Device Handles
230 * \param agRoot Handles for this instance of SAS/SATA hardware
231 * \param agsaContext Pointer to this API context
232 * \param agPortContext Pointer to this instance of port context
233 * \param flags Device flags
234 * \param agDev[] Pointer of array of device handles
235 * \param MaxDevs Specified Maximum number of Device Handles
237 * \return If GetDeviceHandles is successfully or failure
238 * - \e AGSA_RC_SUCCESS GetDeviceHandles is successfully
239 * - \e AGSA_RC_FAILURE GetDeviceHandles is not successfully
242 /*******************************************************************************/
243 GLOBAL bit32 saGetDeviceHandles(
245 agsaContext_t *agContext,
247 agsaPortContext_t *agPortContext,
249 agsaDevHandle_t *agDev[],
254 agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
255 agsaPort_t *pPort = (agsaPort_t *) (agPortContext->sdkData);
257 bit32 ret = AGSA_RC_SUCCESS;
259 OS_ASSERT(pPort != agNULL, "saGetDeviceHandles is NULL");
260 smTraceFuncEnter(hpDBG_VERY_LOUD,"zc");
264 SA_DBG1(("saGetDeviceHandles: pPort is NULL \n"));
265 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zc");
266 return AGSA_RC_FAILURE;
269 SA_DBG1(("saGetDeviceHandles: start portId %d\n", pPort->portId));
271 /* save the device handles arrary pointer */
272 for (i = 0; i < MaxDevs; i ++)
274 saRoot->DeviceHandle[i] = agDev[i];
277 /* send GET_DEVICE_HANDLE IOMB to SPC */
278 portIndex = pPort->portId;
279 mpiGetDeviceHandleCmd(agRoot, agContext, portIndex, flags, MaxDevs, queueNum, skipCount);
282 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zc");
286 /******************************************************************************/
287 /*! \brief Register New Device from a specific local port
289 * Register New Device API
291 * \param agRoot Handles for this instance of SAS/SATA hardware
292 * \param agContext Pointer to this API context
293 * \param agDeviceInfo Pointer to this instance of device info
294 * \param agPortContext Pointer to this instance of port context
296 * \return If discovery is started/aborted successfully
297 * - \e AGSA_RC_SUCCESS discovery is started/aborted successfully
298 * - \e AGSA_RC_FAILURE discovery is not started/aborted successfully
301 /*******************************************************************************/
302 GLOBAL bit32 saRegisterNewDevice(
304 agsaContext_t *agContext,
306 agsaDeviceInfo_t *agDeviceInfo,
307 agsaPortContext_t *agPortContext,
308 bit16 hostAssignedDeviceId
311 bit32 ret = AGSA_RC_SUCCESS;
312 agsaRegDevCmd_t payload;
313 agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
314 agsaIORequestDesc_t *pRequest;
315 agsaPort_t *pPort = (agsaPort_t *) (agPortContext->sdkData);
316 agsaSASIdentify_t remoteIdentify;
317 bit32 i, phyId, sDTypeRate;
318 agsaDeviceDesc_t *pDevice = agNULL;
320 OS_ASSERT(pPort != agNULL, "saRegisterNewDevice is NULL");
321 OS_ASSERT(saRoot != agNULL, "saRoot is NULL");
322 smTraceFuncEnter(hpDBG_VERY_LOUD,"zd");
326 SA_DBG1(("saRegisterNewDevice: saRoot == agNULL\n"));
327 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zd");
328 return(AGSA_RC_FAILURE);
333 SA_DBG1(("saRegisterNewDevice: pPort is NULL \n"));
334 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zd");
335 return AGSA_RC_FAILURE;
338 SA_DBG2(("saRegisterNewDevice: start portId %d Port Context %p\n", pPort->portId, agPortContext));
340 SA_DBG2(("saRegisterNewDevice: smpTimeout 0x%x\n", agDeviceInfo->smpTimeout));
341 SA_DBG2(("saRegisterNewDevice: it_NexusTimeout 0x%x\n", agDeviceInfo->it_NexusTimeout));
342 SA_DBG2(("saRegisterNewDevice: firstBurstSize 0x%x\n", agDeviceInfo->firstBurstSize));
343 SA_DBG2(("saRegisterNewDevice: devType_S_Rate 0x%x\n", agDeviceInfo->devType_S_Rate));
344 SA_DBG2(("saRegisterNewDevice: flag 0x%x\n", agDeviceInfo->flag));
345 SA_DBG2(("saRegisterNewDevice: hostAssignedDeviceId 0x%x\n",hostAssignedDeviceId ));
346 SA_DBG2(("saRegisterNewDevice: Addr 0x%02x%02x%02x%02x 0x%02x%02x%02x%02x\n",
347 agDeviceInfo->sasAddressHi[0],agDeviceInfo->sasAddressHi[1],agDeviceInfo->sasAddressHi[2],agDeviceInfo->sasAddressHi[3],
348 agDeviceInfo->sasAddressLo[0],agDeviceInfo->sasAddressLo[1],agDeviceInfo->sasAddressLo[2],agDeviceInfo->sasAddressLo[3] ));
350 agDeviceInfo->devType_S_Rate &= DEV_LINK_RATE;
353 Using agsaDeviceInfo_t, fill in only sas address and device type
354 of identify address frame
356 si_memset(&remoteIdentify, 0, sizeof(agsaSASIdentify_t));
359 remoteIdentify.sasAddressHi[i] = agDeviceInfo->sasAddressHi[i];
360 remoteIdentify.sasAddressLo[i] = agDeviceInfo->sasAddressLo[i];
362 remoteIdentify.deviceType_addressFrameType = (bit8)(agDeviceInfo->devType_S_Rate & 0xC0);
364 /* Get request from free IORequests */
365 ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
366 pRequest = (agsaIORequestDesc_t *)saLlistIOGetHead(&(saRoot->freeIORequests));
368 /* If no LL Control request entry available */
369 if ( agNULL == pRequest )
371 pRequest = (agsaIORequestDesc_t *)saLlistIOGetHead(&(saRoot->freeReservedRequests)); /**/
372 if(agNULL != pRequest)
374 saLlistIORemove(&(saRoot->freeReservedRequests), &(pRequest->linkNode));
375 SA_DBG1(("saRegisterNewDevice, using saRoot->freeReservedRequests\n"));
379 SA_DBG1(("saRegisterNewDevice, No request from free list Not using saRoot->freeReservedRequests\n"));
380 ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
381 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "zd");
387 /* If LL Control request entry avaliable */
388 saLlistIORemove(&(saRoot->freeIORequests), &(pRequest->linkNode));
391 saRoot->IOMap[pRequest->HTag].Tag = pRequest->HTag;
392 saRoot->IOMap[pRequest->HTag].IORequest = (void *)pRequest;
393 saRoot->IOMap[pRequest->HTag].agContext = agContext;
394 pRequest->valid = agTRUE;
396 ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
397 /* checking bit5 for SATA direct device */
398 if (!(agDeviceInfo->devType_S_Rate & 0x20))
401 /* Add SAS device to the device list */
402 pDevice = siPortSASDeviceAdd(agRoot,
406 agDeviceInfo->smpTimeout,
407 agDeviceInfo->it_NexusTimeout,
408 agDeviceInfo->firstBurstSize,
409 agDeviceInfo->devType_S_Rate,
410 (agDeviceInfo->flag & DEV_INFO_MASK));
415 /* Add SATA device to the device list */
416 pDevice = siPortSATADeviceAdd(agRoot,
419 agNULL, /* no signature */
422 agDeviceInfo->smpTimeout,
423 agDeviceInfo->it_NexusTimeout,
424 agDeviceInfo->firstBurstSize,
425 agDeviceInfo->devType_S_Rate,
426 (agDeviceInfo->flag & DEV_INFO_MASK));
429 SA_DBG1(("saRegisterNewDevice: Device Context %p, TypeRate 0x%x\n", pDevice, agDeviceInfo->devType_S_Rate));
431 pRequest->pDevice = pDevice;
433 /* adjust the flag bit to build the IOMB; use only bit0 and 1 */
434 sDTypeRate = agDeviceInfo->devType_S_Rate << SHIFT24;
435 sDTypeRate |= (agDeviceInfo->flag & 0x01);
437 sDTypeRate |= (agDeviceInfo->flag & 0x02) << 1;
439 /* If the host assigned device ID is used, then set the HA bit. */
440 if ( hostAssignedDeviceId != 0 )
443 SA_DBG3(("saRegisterNewDevice:hostAssignedDeviceId 0x%x sDTypeRate 0x%x\n",hostAssignedDeviceId,sDTypeRate ));
446 /* Add the MCN field */
448 sDTypeRate |= ((agDeviceInfo->flag >> DEV_INFO_MCN_SHIFT) & 0xf) << 4;
450 /* Add the IR field */
451 sDTypeRate |= ((agDeviceInfo->flag >> DEV_INFO_IR_SHIFT) & 0x1) << 3;
453 /* Add the ATAPI protocol flag */
454 sDTypeRate |= ((agDeviceInfo->flag & ATAPI_DEVICE_FLAG) << SHIFT9 );
456 /* Add the AWT flag */
457 sDTypeRate |= (agDeviceInfo->flag & AWT_DEVICE_FLAG) ? (1 << SHIFT2) : 0;
459 /* Add the XFER_READY flag */
460 sDTypeRate |= (agDeviceInfo->flag & XFER_RDY_PRIORTY_DEVICE_FLAG) ? (1 << SHIFT31) : 0;
461 if(agDeviceInfo->flag & XFER_RDY_PRIORTY_DEVICE_FLAG)
463 SA_DBG1(("saRegisterNewDevice: sflag XFER_RDY_PRIORTY_DEVICE_FLAG sDTypeRate 0x%x\n",sDTypeRate ));
465 #ifdef CCFLAG_FORCE_AWT_ON
466 sDTypeRate |= (1 << SHIFT2);
467 SA_DBG1(("saRegisterNewDevice: Force AWT_DEVICE_FLAG sDTypeRate 0x%x\n",sDTypeRate ));
468 #endif /* CCFLAG_FORCE_AWT_ON */
470 /* create payload for IOMB */
471 si_memset(&payload, 0, sizeof(agsaRegDevCmd_t));
473 SA_DBG2(("saRegisterNewDevice,flag 0x%08X\n",agDeviceInfo->flag));
474 if ((agDeviceInfo->devType_S_Rate & 0x30) == 0x20)
478 /* direct SATA device */
479 phyId = (agDeviceInfo->flag & 0xF0);
483 phyId = (agDeviceInfo->flag & 0xF0) << SHIFT4;
491 smTrace(hpDBG_VERY_LOUD,"QQ",phyId);
493 smTrace(hpDBG_VERY_LOUD,"QR",pPort->portId);
495 smTrace(hpDBG_VERY_LOUD,"QS",sDTypeRate);
496 /* TP:QS sDTypeRate */
497 smTrace(hpDBG_VERY_LOUD,"QT",agDeviceInfo->it_NexusTimeout);
498 /* TP:QT agDeviceInfo->it_NexusTimeout */
500 OSSA_WRITE_LE_32(agRoot, &payload, OSSA_OFFSET_OF(agsaRegDevCmd_t, phyIdportId), (bit32)(pPort->portId & PORTID_MASK) | phyId);
501 OSSA_WRITE_LE_32(agRoot, &payload, OSSA_OFFSET_OF(agsaRegDevCmd_t, dTypeLRateAwtHa), sDTypeRate);
502 OSSA_WRITE_LE_32(agRoot, &payload, OSSA_OFFSET_OF(agsaRegDevCmd_t, ITNexusTimeOut), (agDeviceInfo->it_NexusTimeout));
504 smTrace(hpDBG_VERY_LOUD,"QT",(bit32)(pPort->portId & PORTID_MASK) | phyId);
505 /* TP:QT phyIdportId */
506 /* no conversion is needed since SAS address is in BE format */
507 payload.sasAddrHi = *(bit32*)agDeviceInfo->sasAddressHi;
508 payload.sasAddrLo = *(bit32*)agDeviceInfo->sasAddressLo;
510 OSSA_WRITE_LE_32(agRoot, &payload, OSSA_OFFSET_OF(agsaRegDevCmd_t, tag), pRequest->HTag);
511 OSSA_WRITE_LE_32(agRoot, &payload, OSSA_OFFSET_OF(agsaRegDevCmd_t, DeviceId), ((bit32)hostAssignedDeviceId) << 16);
515 ret = mpiBuildCmd(agRoot, (bit32 *)&payload, MPI_CATEGORY_SAS_SATA, OPC_INB_SPC_REG_DEV, IOMB_SIZE64, queueNum);
519 ret = mpiBuildCmd(agRoot, (bit32 *)&payload, MPI_CATEGORY_SAS_SATA, OPC_INB_REG_DEV, IOMB_SIZE64, queueNum);
522 if (AGSA_RC_SUCCESS != ret)
524 /* return the request to free pool */
525 ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
526 /* remove the request from IOMap */
527 saRoot->IOMap[pRequest->HTag].Tag = MARK_OFF;
528 saRoot->IOMap[pRequest->HTag].IORequest = agNULL;
529 saRoot->IOMap[pRequest->HTag].agContext = agNULL;
530 pRequest->valid = agFALSE;
532 if(saLlistIOGetCount(&(saRoot->freeReservedRequests)) < SA_RESERVED_REQUEST_COUNT)
534 SA_DBG1(("saRegisterNewDevice: saving pRequest (%p) for later use\n", pRequest));
535 saLlistIOAdd(&(saRoot->freeReservedRequests), &(pRequest->linkNode));
539 /* return the request to free pool */
540 saLlistIOAdd(&(saRoot->freeIORequests), &(pRequest->linkNode));
542 ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
543 SA_DBG1(("saRegisterNewDevice, sending IOMB failed\n" ));
545 SA_DBG3(("saRegisterNewDevice: end\n"));
547 smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "zd");
551 /******************************************************************************/
552 /*! \brief Register a callback for a specific event
554 * Register a callback for a Event API
556 * \param agRoot Handles for this instance of SAS/SATA hardware
557 * \param eventSourceType Event Type
558 * \param callbackPtr Function pointer to OS layer
561 * - \e AGSA_RC_SUCCESS
562 * - \e AGSA_RC_FAILURE
565 /*******************************************************************************/
566 GLOBAL bit32 saRegisterEventCallback(
568 bit32 eventSourceType,
569 ossaGenericCB_t callbackPtr
572 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
573 bit32 ret = AGSA_RC_FAILURE;
575 SA_DBG3(("saRegisterEventCallback: start\n"));
576 switch (eventSourceType)
578 case OSSA_EVENT_SOURCE_DEVICE_HANDLE_ADDED:
579 saRoot->DeviceRegistrationCB = (ossaDeviceRegistrationCB_t)callbackPtr;
580 ret = AGSA_RC_SUCCESS;
582 case OSSA_EVENT_SOURCE_DEVICE_HANDLE_REMOVED:
583 saRoot->DeviceDeregistrationCB = (ossaDeregisterDeviceHandleCB_t) callbackPtr;
584 ret = AGSA_RC_SUCCESS;
587 SA_DBG1(("saRegisterEventCallback: not allowed case %d\n", eventSourceType));
588 ret = AGSA_RC_FAILURE;
594 /******************************************************************************/
595 /*! \brief Get Device Information
597 * Get SAS/SATA device information API
599 * \param agRoot Handles for this instance of SAS/SATA hardware
600 * \param option device general information or extended information
601 * \param agDevHandle Pointer of device handle
604 * - \e AGSA_RC_SUCCESS
605 * - \e AGSA_RC_FAILURE
608 /*******************************************************************************/
609 GLOBAL bit32 saGetDeviceInfo(
611 agsaContext_t *agContext,
614 agsaDevHandle_t *agDevHandle
617 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
618 agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
620 bit32 ret = AGSA_RC_FAILURE;
622 OS_ASSERT(pDevice != agNULL, "saGetDeviceInfo is NULL");
623 smTraceFuncEnter(hpDBG_VERY_LOUD,"ze");
625 if (pDevice == agNULL)
627 SA_DBG1(("saGetDeviceInfo: pDevice is NULL \n"));
628 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "ze");
629 return AGSA_RC_FAILURE;
633 deviceid = pDevice->DeviceMapIndex;
634 SA_DBG3(("saGetDeviceInfo: start pDevice %p, deviceId %d\n", pDevice, deviceid));
636 /* verify the agDeviceHandle with the one in the deviceMap */
637 if ((deviceid != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceIdFromFW) ||
638 (pDevice != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceHandle))
640 SA_DBG1(("saGetDeviceInfo: Not match failure or device not exist\n"));
641 ret = AGSA_RC_FAILURE;
642 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "ze");
646 /* send IOMB to the SPC */
647 ret = mpiGetDeviceInfoCmd(agRoot, agContext, deviceid, option, queueNum);
649 SA_DBG3(("saGetDeviceInfo: end\n"));
650 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "ze");
654 /******************************************************************************/
655 /*! \brief Set Device Information
657 * Set SAS/SATA device information API
659 * \param agRoot Handles for this instance of SAS/SATA hardware
660 * \param agContext Pointer to this API context
661 * \param queueNum IQ/OQ number
662 * \param agDevHandle Pointer of device handle
663 * \param option device general information or extended information
664 * \param param Parameter of Set Device Infomation
667 * - \e AGSA_RC_SUCCESS
668 * - \e AGSA_RC_FAILURE
671 /*******************************************************************************/
672 GLOBAL bit32 saSetDeviceInfo(
674 agsaContext_t *agContext,
676 agsaDevHandle_t *agDevHandle,
679 ossaSetDeviceInfoCB_t agCB
682 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
683 agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
685 bit32 ret = AGSA_RC_FAILURE;
687 OS_ASSERT(pDevice != agNULL, "saSetDeviceInfo is NULL");
688 smTraceFuncEnter(hpDBG_VERY_LOUD,"zf");
690 SA_DBG2(("saSetDeviceInfo: start pDevice %p, option=0x%x param=0x0%x\n", pDevice, option, param));
691 if(agNULL == pDevice )
693 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zf");
699 deviceid = pDevice->DeviceMapIndex;
700 pDevice->option = option;
701 pDevice->param = param;
703 SA_DBG3(("saSetDeviceInfo: deviceId %d\n", deviceid));
705 /* verify the agDeviceHandle with the one in the deviceMap */
706 if ((deviceid != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceIdFromFW) ||
707 (pDevice != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceHandle))
709 SA_DBG1(("saSetDeviceInfo: Not match failure or device not exist\n"));
710 ret = AGSA_RC_FAILURE;
711 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zf");
715 /* send IOMB to the SPC */
716 ret = mpiSetDeviceInfoCmd(agRoot, agContext, deviceid, option, queueNum, param, agCB);
718 SA_DBG3(("saSetDeviceInfo: end\n"));
719 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "zf");
723 /******************************************************************************/
724 /*! \brief Get Device State
726 * Get SAS/SATA device state API
728 * \param agRoot Handles for this instance of SAS/SATA hardware
729 * \param agContext Pointer to this API context
730 * \param queueNum IQ/OQ number
731 * \param agDevHandle Pointer of device handler
734 * - \e AGSA_RC_SUCCESS
735 * - \e AGSA_RC_FAILURE
738 /*******************************************************************************/
739 GLOBAL bit32 saGetDeviceState(
741 agsaContext_t *agContext,
743 agsaDevHandle_t *agDevHandle
746 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
747 agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
749 bit32 ret = AGSA_RC_FAILURE;
751 OS_ASSERT(pDevice != agNULL, "saGetDeviceState is NULL");
752 smTraceFuncEnter(hpDBG_VERY_LOUD,"zg");
754 if (pDevice == agNULL)
756 SA_DBG1(("saGetDeviceState: pDevice is NULL \n"));
757 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zg");
758 return AGSA_RC_FAILURE;
761 SA_DBG3(("saGetDeviceState: start pDevice %p\n", pDevice));
764 deviceid = pDevice->DeviceMapIndex;
766 /* verify the agDeviceHandle with the one in the deviceMap */
767 if ((deviceid != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceIdFromFW) ||
768 (pDevice != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceHandle))
770 SA_DBG1(("saGetDeviceState: Not match failure or device not exist\n"));
771 ret = AGSA_RC_FAILURE;
772 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zg");
776 /* send IOMB to the SPC */
777 ret = mpiGetDeviceStateCmd(agRoot, agContext, deviceid, queueNum);
779 SA_DBG3(("saGetDeviceState: end\n"));
780 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "zg");
784 /******************************************************************************/
785 /*! \brief Set Device State
787 * Set SAS/SATA device state API
789 * \param agRoot Handles for this instance of SAS/SATA hardware
790 * \param agContext Pointer to this API context
791 * \param queueNum IQ/OQ number
792 * \param agDevHandle Pointer of device handler
793 * \param newDeviceState new device state
796 * - \e AGSA_RC_SUCCESS
797 * - \e AGSA_RC_FAILURE
800 /*******************************************************************************/
801 GLOBAL bit32 saSetDeviceState(
803 agsaContext_t *agContext,
805 agsaDevHandle_t *agDevHandle,
809 agsaLLRoot_t *saRoot;
810 agsaDeviceDesc_t *pDevice;
812 bit32 ret = AGSA_RC_FAILURE;
814 saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
815 OS_ASSERT(saRoot != agNULL, "saSetDeviceState saRoot");
817 if(saRoot == agNULL )
819 SA_DBG1(("saSetDeviceState: saRoot is NULL\n"));
823 OS_ASSERT(agDevHandle != agNULL, "saSetDeviceState agDevHandle is NULL");
825 smTraceFuncEnter(hpDBG_VERY_LOUD,"zh");
827 if(agDevHandle == agNULL )
829 SA_DBG1(("saSetDeviceState: agDevHandle is NULL\n"));
830 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zh");
834 pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
836 OS_ASSERT(pDevice != agNULL, "saSetDeviceState pDevice is NULL");
838 SA_DBG3(("saSetDeviceState: start pDevice %p\n", pDevice));
840 if(pDevice == agNULL )
842 SA_DBG1(("saSetDeviceState: pDevice is NULL\n"));
843 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zh");
847 deviceid = pDevice->DeviceMapIndex;
849 /* verify the agDeviceHandle with the one in the deviceMap */
850 if ((deviceid != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceIdFromFW) ||
851 (pDevice != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceHandle))
853 SA_DBG1(("saSetDeviceState: Not match failure or device not exist\n"));
854 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "zh");
858 /* send IOMB to the SPC */
859 ret = mpiSetDeviceStateCmd(agRoot, agContext, deviceid, newDeviceState, queueNum);
861 SA_DBG3(("saSetDeviceState: end\n"));
862 smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "zh");