FreeBSD kernel pms device code
sadisc.c
Go to the documentation of this file.
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/*******************************************************************************/
27/******************************************************************************/
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD$");
31#include <dev/pms/config.h>
32
34#ifdef SA_ENABLE_TRACE_FUNCTIONS
35#ifdef siTraceFileID
36#undef siTraceFileID
37#endif
38#define siTraceFileID 'C'
39#endif
40
41/******************************************************************************/
56/*******************************************************************************/
58 agsaRoot_t *agRoot,
59 agsaPortContext_t *agPortContext,
60 bit32 type,
61 bit32 option
62 )
63{
64 /* Currently not supported */
65 return AGSA_RC_FAILURE;
66}
67
68/******************************************************************************/
82/*******************************************************************************/
84 agsaRoot_t *agRoot,
85 agsaContext_t *agContext,
86 agsaDevHandle_t *agDevHandle,
87 bit32 queueNum
88 )
89{
90 agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
91 agsaDeviceDesc_t *pDevice;
92 agsaPort_t *pPort;
94 bit32 deviceid, portid;
95 bit32 deviceIdx;
96
97 OS_ASSERT(agDevHandle != agNULL, "saDeregisterDeviceHandle agDevHandle is NULL");
98
100
101 if(agNULL == agDevHandle)
102 {
104 return AGSA_RC_FAILURE;
105 }
106
107 pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
108
109 OS_ASSERT(pDevice != agNULL, "saDeregisterDeviceHandle pDevice is NULL");
110 if(pDevice == agNULL)
111 {
113 return AGSA_RC_FAILURE;
114 }
115
116 /* find device id */
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;
121 /* find port id */
122 portid = pPort->portId;
123
124 SA_DBG3(("saDeregisterDeviceHandle: start DeviceHandle %p\n", agDevHandle));
125 SA_DBG1(("saDeregisterDeviceHandle: deviceId 0x%x Device Context %p\n", deviceid, pDevice));
126
127 if ((deviceid != saRoot->DeviceMap[deviceIdx].DeviceIdFromFW) ||
128 (pDevice != saRoot->DeviceMap[deviceIdx].DeviceHandle))
129 {
130 SA_DBG1(("saDeregisterDeviceHandle: Not match failure\n"));
131 ret = AGSA_RC_FAILURE;
133 return ret;
134 }
135
136 /* Build IOMB and send it to SPC */
137 ret = mpiDeregDevHandleCmd(agRoot, agContext, pDevice, deviceid, portid, queueNum);
138
140 return ret;
141}
142
143/******************************************************************************/
157/*******************************************************************************/
159 agsaRoot_t *agRoot,
160 agsaDevHandle_t *agDevHandle
161 )
162{
163 agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
164 agsaPort_t *pPort;
166
167 OS_ASSERT(pDevice != agNULL, "siRemoveDevHandle is NULL");
169
170 if (pDevice == agNULL)
171 {
172 SA_DBG1(("siRemoveDevHandle: pDevice is NULL \n"));
174 return AGSA_RC_FAILURE;
175 }
176
177 /* If it's to remove an initiator device handle */
178 if ( &(pDevice->initiatorDevHandle) == agDevHandle )
179 {
180 (pDevice->initiatorDevHandle).sdkData = agNULL;
181 }
182 /* If it's to remove an target device handle */
183 else if ( &(pDevice->targetDevHandle) == agDevHandle )
184 {
185 (pDevice->targetDevHandle).sdkData = agNULL;
186 }
187 else
188 {
189 SA_ASSERT(agFALSE, "");
190 }
191
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) )
195 {
196 /* Find the port of the device */
197 pPort = pDevice->pPort;
198
199 /* remove the device descriptor free discover list */
200 switch ( pDevice->deviceType )
201 {
202 case STP_DEVICE: /* fall through */
203 case SSP_SMP_DEVICE:
205 {
206 SA_DBG3(("siRemoveDevHandle: remove device context %p\n", pDevice));
207 siPortDeviceRemove(agRoot, pPort, pDevice, agTRUE);
208 break;
209 }
210 default:
211 {
212 SA_DBG1(("siRemoveDevHandle: switch. Not calling siPortDeviceRemove %d\n", pDevice->deviceType));
213 break;
214 }
215 }
216 }
217 else
218 {
219 SA_DBG1(("siRemoveDevHandle: else. Not caling siPortDeviceRemove\n"));
220 }
222 return ret;
223}
224
225/******************************************************************************/
242/*******************************************************************************/
244 agsaRoot_t *agRoot,
245 agsaContext_t *agContext,
246 bit32 queueNum,
247 agsaPortContext_t *agPortContext,
248 bit32 flags,
249 agsaDevHandle_t *agDev[],
250 bit32 skipCount,
251 bit32 MaxDevs
252 )
253{
254 agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
255 agsaPort_t *pPort = (agsaPort_t *) (agPortContext->sdkData);
256 bit32 portIndex, i;
258
259 OS_ASSERT(pPort != agNULL, "saGetDeviceHandles is NULL");
261
262 if (pPort == agNULL)
263 {
264 SA_DBG1(("saGetDeviceHandles: pPort is NULL \n"));
266 return AGSA_RC_FAILURE;
267 }
268
269 SA_DBG1(("saGetDeviceHandles: start portId %d\n", pPort->portId));
270
271 /* save the device handles arrary pointer */
272 for (i = 0; i < MaxDevs; i ++)
273 {
274 saRoot->DeviceHandle[i] = agDev[i];
275 }
276
277 /* send GET_DEVICE_HANDLE IOMB to SPC */
278 portIndex = pPort->portId;
279 mpiGetDeviceHandleCmd(agRoot, agContext, portIndex, flags, MaxDevs, queueNum, skipCount);
280
281 /* return */
283 return ret;
284}
285
286/******************************************************************************/
301/*******************************************************************************/
303 agsaRoot_t *agRoot,
304 agsaContext_t *agContext,
305 bit32 queueNum,
306 agsaDeviceInfo_t *agDeviceInfo,
307 agsaPortContext_t *agPortContext,
308 bit16 hostAssignedDeviceId
309 )
310{
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;
319
320 OS_ASSERT(pPort != agNULL, "saRegisterNewDevice is NULL");
321 OS_ASSERT(saRoot != agNULL, "saRoot is NULL");
323
324 if(saRoot == agNULL)
325 {
326 SA_DBG1(("saRegisterNewDevice: saRoot == agNULL\n"));
328 return(AGSA_RC_FAILURE);
329 }
330
331 if (pPort == agNULL)
332 {
333 SA_DBG1(("saRegisterNewDevice: pPort is NULL \n"));
335 return AGSA_RC_FAILURE;
336 }
337
338 SA_DBG2(("saRegisterNewDevice: start portId %d Port Context %p\n", pPort->portId, agPortContext));
339
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] ));
349
350 agDeviceInfo->devType_S_Rate &= DEV_LINK_RATE;
351
352 /*
353 Using agsaDeviceInfo_t, fill in only sas address and device type
354 of identify address frame
355 */
356 si_memset(&remoteIdentify, 0, sizeof(agsaSASIdentify_t));
357 for (i=0;i<4;i++)
358 {
359 remoteIdentify.sasAddressHi[i] = agDeviceInfo->sasAddressHi[i];
360 remoteIdentify.sasAddressLo[i] = agDeviceInfo->sasAddressLo[i];
361 }
362 remoteIdentify.deviceType_addressFrameType = (bit8)(agDeviceInfo->devType_S_Rate & 0xC0);
363
364 /* Get request from free IORequests */
366 pRequest = (agsaIORequestDesc_t *)saLlistIOGetHead(&(saRoot->freeIORequests));
367
368 /* If no LL Control request entry available */
369 if ( agNULL == pRequest )
370 {
372 if(agNULL != pRequest)
373 {
374 saLlistIORemove(&(saRoot->freeReservedRequests), &(pRequest->linkNode));
375 SA_DBG1(("saRegisterNewDevice, using saRoot->freeReservedRequests\n"));
376 }
377 else
378 {
379 SA_DBG1(("saRegisterNewDevice, No request from free list Not using saRoot->freeReservedRequests\n"));
382 return AGSA_RC_BUSY;
383 }
384 }
385 else
386 {
387 /* If LL Control request entry avaliable */
388 saLlistIORemove(&(saRoot->freeIORequests), &(pRequest->linkNode));
389 }
390
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;
395
397 /* checking bit5 for SATA direct device */
398 if (!(agDeviceInfo->devType_S_Rate & 0x20))
399 {
400 /* SAS device */
401 /* Add SAS device to the device list */
402 pDevice = siPortSASDeviceAdd(agRoot,
403 pPort,
404 remoteIdentify,
405 agFALSE,
406 agDeviceInfo->smpTimeout,
407 agDeviceInfo->it_NexusTimeout,
408 agDeviceInfo->firstBurstSize,
409 agDeviceInfo->devType_S_Rate,
410 (agDeviceInfo->flag & DEV_INFO_MASK));
411 }
412 else
413 {
414 /* SATA device */
415 /* Add SATA device to the device list */
416 pDevice = siPortSATADeviceAdd(agRoot,
417 pPort,
418 agNULL,
419 agNULL, /* no signature */
420 agFALSE,
421 0,
422 agDeviceInfo->smpTimeout,
423 agDeviceInfo->it_NexusTimeout,
424 agDeviceInfo->firstBurstSize,
425 agDeviceInfo->devType_S_Rate,
426 (agDeviceInfo->flag & DEV_INFO_MASK));
427 }
428
429 SA_DBG1(("saRegisterNewDevice: Device Context %p, TypeRate 0x%x\n", pDevice, agDeviceInfo->devType_S_Rate));
430
431 pRequest->pDevice = pDevice;
432
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);
436 /* set AWT flag */
437 sDTypeRate |= (agDeviceInfo->flag & 0x02) << 1;
438
439 /* If the host assigned device ID is used, then set the HA bit. */
440 if ( hostAssignedDeviceId != 0 )
441 {
442 sDTypeRate |= 2;
443 SA_DBG3(("saRegisterNewDevice:hostAssignedDeviceId 0x%x sDTypeRate 0x%x\n",hostAssignedDeviceId,sDTypeRate ));
444 }
445
446 /* Add the MCN field */
447
448 sDTypeRate |= ((agDeviceInfo->flag >> DEV_INFO_MCN_SHIFT) & 0xf) << 4;
449
450 /* Add the IR field */
451 sDTypeRate |= ((agDeviceInfo->flag >> DEV_INFO_IR_SHIFT) & 0x1) << 3;
452
453 /* Add the ATAPI protocol flag */
454 sDTypeRate |= ((agDeviceInfo->flag & ATAPI_DEVICE_FLAG) << SHIFT9 );
455
456 /* Add the AWT flag */
457 sDTypeRate |= (agDeviceInfo->flag & AWT_DEVICE_FLAG) ? (1 << SHIFT2) : 0;
458
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)
462 {
463 SA_DBG1(("saRegisterNewDevice: sflag XFER_RDY_PRIORTY_DEVICE_FLAG sDTypeRate 0x%x\n",sDTypeRate ));
464 }
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 */
469
470 /* create payload for IOMB */
471 si_memset(&payload, 0, sizeof(agsaRegDevCmd_t));
472
473 SA_DBG2(("saRegisterNewDevice,flag 0x%08X\n",agDeviceInfo->flag));
474 if ((agDeviceInfo->devType_S_Rate & 0x30) == 0x20)
475 {
476 if(smIS_SPC(agRoot))
477 {
478 /* direct SATA device */
479 phyId = (agDeviceInfo->flag & 0xF0);
480 }
481 else
482 {
483 phyId = (agDeviceInfo->flag & 0xF0) << SHIFT4;
484 }
485 }
486 else
487 {
488 phyId = 0;
489 }
490
491 smTrace(hpDBG_VERY_LOUD,"QQ",phyId);
492 /* TP:QQ phyId */
493 smTrace(hpDBG_VERY_LOUD,"QR",pPort->portId);
494 /* TP:QR 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 */
499
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));
503
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;
509
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);
512
513 if(smIS_SPC(agRoot))
514 {
515 ret = mpiBuildCmd(agRoot, (bit32 *)&payload, MPI_CATEGORY_SAS_SATA, OPC_INB_SPC_REG_DEV, IOMB_SIZE64, queueNum);
516 }
517 else
518 {
519 ret = mpiBuildCmd(agRoot, (bit32 *)&payload, MPI_CATEGORY_SAS_SATA, OPC_INB_REG_DEV, IOMB_SIZE64, queueNum);
520 }
521
522 if (AGSA_RC_SUCCESS != ret)
523 {
524 /* return the request to free pool */
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;
531
533 {
534 SA_DBG1(("saRegisterNewDevice: saving pRequest (%p) for later use\n", pRequest));
535 saLlistIOAdd(&(saRoot->freeReservedRequests), &(pRequest->linkNode));
536 }
537 else
538 {
539 /* return the request to free pool */
540 saLlistIOAdd(&(saRoot->freeIORequests), &(pRequest->linkNode));
541 }
543 SA_DBG1(("saRegisterNewDevice, sending IOMB failed\n" ));
544 }
545 SA_DBG3(("saRegisterNewDevice: end\n"));
546
548 return ret;
549}
550
551/******************************************************************************/
565/*******************************************************************************/
567 agsaRoot_t *agRoot,
568 bit32 eventSourceType,
569 ossaGenericCB_t callbackPtr
570 )
571{
572 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
574
575 SA_DBG3(("saRegisterEventCallback: start\n"));
576 switch (eventSourceType)
577 {
580 ret = AGSA_RC_SUCCESS;
581 break;
584 ret = AGSA_RC_SUCCESS;
585 break;
586 default:
587 SA_DBG1(("saRegisterEventCallback: not allowed case %d\n", eventSourceType));
588 ret = AGSA_RC_FAILURE;
589 break;
590 }
591 return ret;
592}
593
594/******************************************************************************/
608/*******************************************************************************/
610 agsaRoot_t *agRoot,
611 agsaContext_t *agContext,
612 bit32 option,
613 bit32 queueNum,
614 agsaDevHandle_t *agDevHandle
615 )
616{
617 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
618 agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
619 bit32 deviceid;
621
622 OS_ASSERT(pDevice != agNULL, "saGetDeviceInfo is NULL");
624
625 if (pDevice == agNULL)
626 {
627 SA_DBG1(("saGetDeviceInfo: pDevice is NULL \n"));
629 return AGSA_RC_FAILURE;
630 }
631
632 /* Get deviceid */
633 deviceid = pDevice->DeviceMapIndex;
634 SA_DBG3(("saGetDeviceInfo: start pDevice %p, deviceId %d\n", pDevice, deviceid));
635
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))
639 {
640 SA_DBG1(("saGetDeviceInfo: Not match failure or device not exist\n"));
641 ret = AGSA_RC_FAILURE;
643 return ret;
644 }
645
646 /* send IOMB to the SPC */
647 ret = mpiGetDeviceInfoCmd(agRoot, agContext, deviceid, option, queueNum);
648
649 SA_DBG3(("saGetDeviceInfo: end\n"));
651 return ret;
652}
653
654/******************************************************************************/
671/*******************************************************************************/
673 agsaRoot_t *agRoot,
674 agsaContext_t *agContext,
675 bit32 queueNum,
676 agsaDevHandle_t *agDevHandle,
677 bit32 option,
678 bit32 param,
680 )
681{
682 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
683 agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
684 bit32 deviceid;
686
687 OS_ASSERT(pDevice != agNULL, "saSetDeviceInfo is NULL");
689
690 SA_DBG2(("saSetDeviceInfo: start pDevice %p, option=0x%x param=0x0%x\n", pDevice, option, param));
691 if(agNULL == pDevice )
692 {
694 return ret;
695 }
696
697
698 /* Get deviceid */
699 deviceid = pDevice->DeviceMapIndex;
700 pDevice->option = option;
701 pDevice->param = param;
702
703 SA_DBG3(("saSetDeviceInfo: deviceId %d\n", deviceid));
704
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))
708 {
709 SA_DBG1(("saSetDeviceInfo: Not match failure or device not exist\n"));
710 ret = AGSA_RC_FAILURE;
712 return ret;
713 }
714
715 /* send IOMB to the SPC */
716 ret = mpiSetDeviceInfoCmd(agRoot, agContext, deviceid, option, queueNum, param, agCB);
717
718 SA_DBG3(("saSetDeviceInfo: end\n"));
720 return ret;
721}
722
723/******************************************************************************/
738/*******************************************************************************/
740 agsaRoot_t *agRoot,
741 agsaContext_t *agContext,
742 bit32 queueNum,
743 agsaDevHandle_t *agDevHandle
744 )
745{
746 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
747 agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
748 bit32 deviceid;
750
751 OS_ASSERT(pDevice != agNULL, "saGetDeviceState is NULL");
753
754 if (pDevice == agNULL)
755 {
756 SA_DBG1(("saGetDeviceState: pDevice is NULL \n"));
758 return AGSA_RC_FAILURE;
759 }
760
761 SA_DBG3(("saGetDeviceState: start pDevice %p\n", pDevice));
762
763 /* Get deviceid */
764 deviceid = pDevice->DeviceMapIndex;
765
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))
769 {
770 SA_DBG1(("saGetDeviceState: Not match failure or device not exist\n"));
771 ret = AGSA_RC_FAILURE;
773 return ret;
774 }
775
776 /* send IOMB to the SPC */
777 ret = mpiGetDeviceStateCmd(agRoot, agContext, deviceid, queueNum);
778
779 SA_DBG3(("saGetDeviceState: end\n"));
781 return ret;
782}
783
784/******************************************************************************/
800/*******************************************************************************/
802 agsaRoot_t *agRoot,
803 agsaContext_t *agContext,
804 bit32 queueNum,
805 agsaDevHandle_t *agDevHandle,
806 bit32 newDeviceState
807 )
808{
809 agsaLLRoot_t *saRoot;
810 agsaDeviceDesc_t *pDevice;
811 bit32 deviceid;
813
814 saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
815 OS_ASSERT(saRoot != agNULL, "saSetDeviceState saRoot");
816
817 if(saRoot == agNULL )
818 {
819 SA_DBG1(("saSetDeviceState: saRoot is NULL\n"));
820 return ret;
821 }
822
823 OS_ASSERT(agDevHandle != agNULL, "saSetDeviceState agDevHandle is NULL");
824
826
827 if(agDevHandle == agNULL )
828 {
829 SA_DBG1(("saSetDeviceState: agDevHandle is NULL\n"));
831 return ret;
832 }
833
834 pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
835
836 OS_ASSERT(pDevice != agNULL, "saSetDeviceState pDevice is NULL");
837
838 SA_DBG3(("saSetDeviceState: start pDevice %p\n", pDevice));
839
840 if(pDevice == agNULL )
841 {
842 SA_DBG1(("saSetDeviceState: pDevice is NULL\n"));
844 return ret;
845 }
846 /* Get deviceid */
847 deviceid = pDevice->DeviceMapIndex;
848
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))
852 {
853 SA_DBG1(("saSetDeviceState: Not match failure or device not exist\n"));
855 return ret;
856 }
857
858 /* send IOMB to the SPC */
859 ret = mpiSetDeviceStateCmd(agRoot, agContext, deviceid, newDeviceState, queueNum);
860
861 SA_DBG3(("saSetDeviceState: end\n"));
863 return ret;
864}
#define ATAPI_DEVICE_FLAG
Definition: dmdefs.h:1097
bit32 flags
Definition: encrypt_ioctl.h:2
@ MPI_CATEGORY_SAS_SATA
Definition: mpi.h:80
#define smTraceFuncEnter(L, I)
Definition: mpidebug.h:238
#define smTraceFuncExit(L, S, I)
Definition: mpidebug.h:239
#define smTrace(L, I, V)
Definition: mpidebug.h:244
#define hpDBG_VERY_LOUD
Definition: mpidebug.h:100
#define OS_ASSERT(expr, message)
Definition: osdebug.h:56
unsigned short bit16
Definition: ostypes.h:98
#define agNULL
Definition: ostypes.h:151
#define GLOBAL
Definition: ostypes.h:131
unsigned int bit32
Definition: ostypes.h:99
#define agFALSE
Definition: ostypes.h:150
#define agTRUE
Definition: ostypes.h:149
unsigned char bit8
Definition: ostypes.h:97
#define DEV_INFO_IR_SHIFT
Definition: sa.h:2616
#define XFER_RDY_PRIORTY_DEVICE_FLAG
Definition: sa.h:2622
#define SA_RESERVED_REQUEST_COUNT
Definition: sa.h:3597
#define AGSA_RC_BUSY
Definition: sa.h:782
#define OSSA_OFFSET_OF(STRUCT_TYPE, FEILD)
Definition: sa.h:39
void(* ossaDeviceRegistrationCB_t)(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 status, agsaDevHandle_t *agDevHandle, bit32 deviceID)
Callback definition for .ossaDeviceRegistration.
Definition: sa.h:3469
void(* ossaDeregisterDeviceHandleCB_t)(agsaRoot_t *agRoot, agsaContext_t *agContext, agsaDevHandle_t *agDevHandle, bit32 status)
Callback definition for.
Definition: sa.h:3480
#define OSSA_EVENT_SOURCE_DEVICE_HANDLE_ADDED
Definition: sa.h:1399
void(* ossaGenericCB_t)(void)
Callback definition for.
Definition: sa.h:3490
#define DEV_INFO_MASK
Definition: sa.h:2614
#define DEV_LINK_RATE
Definition: sa.h:2625
#define OSSA_EVENT_SOURCE_DEVICE_HANDLE_REMOVED
Definition: sa.h:1400
#define AWT_DEVICE_FLAG
Definition: sa.h:2619
#define MAX_IO_DEVICE_ENTRIES
Definition: sa.h:3791
#define DEV_INFO_MCN_SHIFT
Definition: sa.h:2615
#define AGSA_RC_FAILURE
Definition: sa.h:781
void(* ossaSetDeviceInfoCB_t)(agsaRoot_t *agRoot, agsaContext_t *agContext, agsaDevHandle_t *agDevHandle, bit32 status, bit32 option, bit32 param)
Callback definition for.
Definition: sa.h:3555
#define AGSA_RC_SUCCESS
Definition: sa.h:780
#define SHIFT4
Definition: sadefs.h:205
#define IOMB_SIZE64
Definition: sadefs.h:60
#define LL_IOREQ_LOCKEQ_LOCK
Definition: sadefs.h:130
#define SHIFT2
Definition: sadefs.h:203
#define DIRECT_SATA_DEVICE
Definition: sadefs.h:179
#define MARK_OFF
Definition: sadefs.h:185
#define STP_DEVICE
Definition: sadefs.h:177
#define PORTID_MASK
Definition: sadefs.h:75
#define SSP_SMP_DEVICE
Definition: sadefs.h:178
#define SHIFT24
Definition: sadefs.h:225
#define SHIFT31
Definition: sadefs.h:232
#define SHIFT9
Definition: sadefs.h:210
GLOBAL bit32 siRemoveDevHandle(agsaRoot_t *agRoot, agsaDevHandle_t *agDevHandle)
Function for target to remove stale initiator device handle.
Definition: sadisc.c:158
GLOBAL bit32 saRegisterEventCallback(agsaRoot_t *agRoot, bit32 eventSourceType, ossaGenericCB_t callbackPtr)
Register a callback for a specific event.
Definition: sadisc.c:566
GLOBAL bit32 saSetDeviceInfo(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 queueNum, agsaDevHandle_t *agDevHandle, bit32 option, bit32 param, ossaSetDeviceInfoCB_t agCB)
Set Device Information.
Definition: sadisc.c:672
__FBSDID("$FreeBSD$")
GLOBAL bit32 saGetDeviceInfo(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 option, bit32 queueNum, agsaDevHandle_t *agDevHandle)
Get Device Information.
Definition: sadisc.c:609
GLOBAL bit32 saSetDeviceState(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 queueNum, agsaDevHandle_t *agDevHandle, bit32 newDeviceState)
Set Device State.
Definition: sadisc.c:801
GLOBAL bit32 saDeregisterDeviceHandle(agsaRoot_t *agRoot, agsaContext_t *agContext, agsaDevHandle_t *agDevHandle, bit32 queueNum)
Function for target to remove stale initiator device handle.
Definition: sadisc.c:83
GLOBAL bit32 saRegisterNewDevice(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 queueNum, agsaDeviceInfo_t *agDeviceInfo, agsaPortContext_t *agPortContext, bit16 hostAssignedDeviceId)
Register New Device from a specific local port.
Definition: sadisc.c:302
GLOBAL bit32 saDiscover(agsaRoot_t *agRoot, agsaPortContext_t *agPortContext, bit32 type, bit32 option)
Start/Abort SAS/SATA discovery.
Definition: sadisc.c:57
GLOBAL bit32 saGetDeviceState(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 queueNum, agsaDevHandle_t *agDevHandle)
Get Device State.
Definition: sadisc.c:739
GLOBAL bit32 saGetDeviceHandles(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 queueNum, agsaPortContext_t *agPortContext, bit32 flags, agsaDevHandle_t *agDev[], bit32 skipCount, bit32 MaxDevs)
Get Device Handles from a specific local port.
Definition: sadisc.c:243
This file defines global types.
#define saLlistIOAdd(pList, pLink)
Definition: sallist.h:185
#define saLlistIORemove(pList, pLink)
Definition: sallist.h:275
#define saLlistIOGetHead(pList)
Definition: sallist.h:307
#define saLlistIOGetCount(pList)
Definition: sallist.h:361
#define SA_DBG1(format)
Definition: samacro.h:200
#define SA_DBG2(format)
Definition: samacro.h:201
#define SA_ASSERT
Definition: samacro.h:209
#define SA_DBG3(format)
Definition: samacro.h:202
GLOBAL bit32 mpiSetDeviceStateCmd(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 deviceId, bit32 nds, bit32 queueNum)
Set Device State command.
Definition: sampicmd.c:1800
GLOBAL bit32 mpiGetDeviceInfoCmd(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 deviceid, bit32 option, bit32 queueNum)
Get Device Information Command.
Definition: sampicmd.c:541
GLOBAL bit32 mpiGetDeviceHandleCmd(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 portId, bit32 flags, bit32 maxDevs, bit32 queueNum, bit32 skipCount)
SPC MPI Get Device Handle Command.
Definition: sampicmd.c:1058
GLOBAL bit32 mpiSetDeviceInfoCmd(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 deviceid, bit32 option, bit32 queueNum, bit32 param, ossaSetDeviceInfoCB_t agCB)
Set Device Information Command.
Definition: sampicmd.c:642
GLOBAL bit32 mpiGetDeviceStateCmd(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 deviceId, bit32 queueNum)
Get Device State command.
Definition: sampicmd.c:1890
GLOBAL bit32 mpiDeregDevHandleCmd(agsaRoot_t *agRoot, agsaContext_t *agContext, agsaDeviceDesc_t *pDevice, bit32 deviceId, bit32 portId, bit32 queueNum)
SPC MPI Deregister Device Handle Command.
Definition: sampicmd.c:965
GLOBAL bit32 mpiBuildCmd(agsaRoot_t *agRoot, bit32 *payload, mpiMsgCategory_t category, bit16 opcode, bit16 size, bit32 queueNum)
Build a IOMB command and send to SPC.
Definition: sampicmd.c:94
#define OPC_INB_SPC_REG_DEV
Definition: sampidefs.h:54
#define DEVICE_ID_BITS
Definition: sampidefs.h:1086
#define OPC_INB_REG_DEV
Definition: sampidefs.h:80
GLOBAL FORCEINLINE void ossaSingleThreadedEnter(agsaRoot_t *agRoot, bit32 syncLockId)
ossaSingleThreadedEnter
Definition: ossacmnapi.c:3786
GLOBAL FORCEINLINE void ossaSingleThreadedLeave(agsaRoot_t *agRoot, bit32 syncLockId)
ossaSingleThreadedLeave
Definition: ossacmnapi.c:3827
GLOBAL void siPortDeviceRemove(agsaRoot_t *agRoot, agsaPort_t *pPort, agsaDeviceDesc_t *pDevice, bit32 unmap)
The function to remove a device descriptor.
Definition: saport.c:169
GLOBAL agsaDeviceDesc_t * siPortSATADeviceAdd(agsaRoot_t *agRoot, agsaPort_t *pPort, agsaDeviceDesc_t *pSTPBridge, bit8 *pSignature, bit8 pm, bit8 pmField, bit32 smpReqTimeout, bit32 itNexusTimeout, bit32 firstBurstSize, bit8 dTypeSRate, bit32 flag)
Add a SATA device to the discovery list of the port.
Definition: saport.c:238
GLOBAL agsaDeviceDesc_t * siPortSASDeviceAdd(agsaRoot_t *agRoot, agsaPort_t *pPort, agsaSASIdentify_t sasIdentify, bit32 sasInitiator, bit32 smpTimeout, bit32 itNexusTimeout, bit32 firstBurstSize, bit8 dTypeSRate, bit32 flag)
Add a SAS device to the discovery list of the port.
Definition: saport.c:60
GLOBAL bit32 smIS_SPC(agsaRoot_t *agRoot)
Definition: sautil.c:437
GLOBAL FORCEINLINE void * si_memset(void *s, int c, bit32 n)
memset
Definition: sautil.c:104
data structure stores OS specific and LL specific context
Definition: sa.h:1658
void * sdkData
Definition: sa.h:1660
the LL defined device descriptor
Definition: satypes.h:112
agsaDevHandle_t targetDevHandle
Definition: satypes.h:115
agsaDevHandle_t initiatorDevHandle
Definition: satypes.h:114
agsaPort_t * pPort
Definition: satypes.h:117
bit32 DeviceMapIndex
Definition: satypes.h:123
data structure provides some information about a SATA device
Definition: sa.h:2561
bit8 sasAddressHi[4]
Definition: sa.h:2580
bit8 devType_S_Rate
Definition: sa.h:2567
bit16 firstBurstSize
Definition: sa.h:2564
bit16 smpTimeout
Definition: sa.h:2562
bit8 sasAddressLo[4]
Definition: sa.h:2581
bit32 flag
Definition: sa.h:2582
bit16 it_NexusTimeout
Definition: sa.h:2563
void * DeviceHandle
Definition: satypes.h:195
bit32 DeviceIdFromFW
Definition: satypes.h:194
agsaIORequestDesc_t * IORequest
Definition: satypes.h:171
bit32 Tag
Definition: satypes.h:170
agsaContext_t * agContext
Definition: satypes.h:172
the LL defined IO request descriptor
Definition: satypes.h:132
agsaDeviceDesc_t * pDevice
Definition: satypes.h:135
the LLRoot
Definition: satypes.h:209
agsaDeviceMap_t DeviceMap[MAX_IO_DEVICE_ENTRIES]
Definition: satypes.h:245
SALINK_LIST freeIORequests
Definition: satypes.h:214
SALINK_LIST freeReservedRequests
Definition: satypes.h:215
agsaIOMap_t IOMap[MAX_ACTIVE_IO_REQUESTS]
Definition: satypes.h:246
ossaDeviceRegistrationCB_t DeviceRegistrationCB
Definition: satypes.h:261
ossaDeregisterDeviceHandleCB_t DeviceDeregistrationCB
Definition: satypes.h:262
agsaDevHandle_t * DeviceHandle[MAX_IO_DEVICE_ENTRIES]
Definition: satypes.h:247
the port
Definition: satypes.h:64
bit32 portId
Definition: satypes.h:71
the data structure of Register Device Command
Definition: sampidefs.h:335
describe SAS IDENTIFY address frame
Definition: sa_spec.h:448
bit8 sasAddressLo[4]
Definition: sa_spec.h:471
bit8 deviceType_addressFrameType
Definition: sa_spec.h:449
bit8 sasAddressHi[4]
Definition: sa_spec.h:470