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
22 ********************************************************************************/
23 #include <sys/cdefs.h>
24 __FBSDID("$FreeBSD$");
25 #include <dev/pms/config.h>
27 #include <dev/pms/freebsd/driver/common/osenv.h>
28 #include <dev/pms/freebsd/driver/common/ostypes.h>
29 #include <dev/pms/freebsd/driver/common/osdebug.h>
31 #include <dev/pms/RefTisa/sallsdk/api/sa.h>
32 #include <dev/pms/RefTisa/sallsdk/api/saapi.h>
33 #include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
36 #include <dev/pms/RefTisa/discovery/api/dm.h>
37 #include <dev/pms/RefTisa/discovery/api/dmapi.h>
38 #include <dev/pms/RefTisa/discovery/api/tddmapi.h>
40 #include <dev/pms/RefTisa/discovery/dm/dmdefs.h>
41 #include <dev/pms/RefTisa/discovery/dm/dmtypes.h>
42 #include <dev/pms/RefTisa/discovery/dm/dmproto.h>
48 dmDeviceData_t *oneDeviceData,
55 dmIntRoot_t *dmIntRoot = (dmIntRoot_t *)dmRoot->dmData;
56 dmIntContext_t *dmAllShared = (dmIntContext_t *)&dmIntRoot->dmAllShared;
57 dmIntPortContext_t *onePortContext = agNULL;
58 dmSMPRequestBody_t *dmSMPRequestBody = agNULL;
60 dmSMPRequestBody_t *dmSMPResponseBody = agNULL;
62 agsaSASRequestBody_t *agSASRequestBody;
64 agsaDevHandle_t *agDevHandle;
65 agsaIORequest_t *agIORequest;
66 agsaSMPFrame_t *agSMPFrame;
67 bit32 expectedRspLen = 0;
68 dmSMPFrameHeader_t dmSMPFrameHeader;
69 dmExpander_t *oneExpander = agNULL;
72 DM_DBG5(("dmSMPStart: start\n"));
73 DM_DBG5(("dmSMPStart: 2nd sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
74 DM_DBG5(("dmSMPStart: 2nd sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
76 dm_memset(&dmSMPFrameHeader, 0, sizeof(dmSMPFrameHeader_t));
78 onePortContext = oneDeviceData->dmPortContext;
80 if (dmDiscoverCheck(dmRoot, onePortContext) == agTRUE)
82 DM_DBG1(("dmSMPStart: invalid port or aborted discovery!!!\n"));
86 oneExpander = oneDeviceData->dmExpander;
87 if (oneExpander == agNULL)
89 DM_DBG1(("dmSMPStart: Wrong!!! oneExpander is NULL!!!\n"));
93 if (onePortContext != agNULL)
95 DM_DBG5(("dmSMPStart: pid %d\n", onePortContext->id));
96 /* increment the number of pending SMP */
97 onePortContext->discovery.pendingSMP++;
101 DM_DBG1(("dmSMPStart: Wrong, onePortContext is NULL!!!\n"));
102 return DM_RC_FAILURE;
105 /* get an smp REQUEST from the free list */
106 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
107 if (DMLIST_EMPTY(&(dmAllShared->freeSMPList)))
109 DM_DBG1(("dmSMPStart: no free SMP!!!\n"));
110 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
111 /* undo increment the number of pending SMP */
112 onePortContext->discovery.pendingSMP--;
113 return DM_RC_FAILURE;
117 DMLIST_DEQUEUE_FROM_HEAD(&SMPList, &(dmAllShared->freeSMPList));
118 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
119 dmSMPRequestBody = DMLIST_OBJECT_BASE(dmSMPRequestBody_t, Link, SMPList);
122 if (dmSMPRequestBody == agNULL)
124 DM_DBG1(("dmSMPStart: dmSMPRequestBody is NULL, wrong!!!\n"));
125 return DM_RC_FAILURE;
127 DM_DBG5(("dmSMPStart: SMP id %d\n", dmSMPRequestBody->id));
129 dmSMPRequestBody->dmRoot = dmRoot;
130 dmSMPRequestBody->dmDevice = oneDeviceData;
131 dmSMPRequestBody->dmPortContext = onePortContext;
133 agDevHandle = oneExpander->agDevHandle;
135 /* save the callback funtion */
136 dmSMPRequestBody->SMPCompletionFunc = dmSMPCompleted; /* in dmsmp.c */
138 dmSMPRequestBody->retries = 0;
140 agIORequest = &(dmSMPRequestBody->agIORequest);
141 agIORequest->osData = (void *) dmSMPRequestBody;
142 agIORequest->sdkData = agNULL; /* SALL takes care of this */
144 agSASRequestBody = &(dmSMPRequestBody->agSASRequestBody);
145 agSMPFrame = &(agSASRequestBody->smpFrame);
147 /* sets dmSMPFrameHeader values */
148 if (oneExpander->SAS2 == 0)
150 DM_DBG5(("dmSMPStart: SAS 1.1\n"));
151 switch (functionCode)
153 case SMP_REPORT_GENERAL:
154 expectedRspLen = sizeof(smpRespReportGeneral_t) + 4;
156 case SMP_REPORT_MANUFACTURE_INFORMATION:
157 expectedRspLen = sizeof(smpRespReportManufactureInfo_t) + 4;
160 expectedRspLen = sizeof(smpRespDiscover_t) + 4;
162 case SMP_REPORT_PHY_ERROR_LOG:
163 expectedRspLen = 32 - 4;
165 case SMP_REPORT_PHY_SATA:
166 expectedRspLen = sizeof(smpRespReportPhySata_t) + 4;
168 case SMP_REPORT_ROUTING_INFORMATION:
169 expectedRspLen = sizeof(smpRespReportRouteTable_t) + 4;
171 case SMP_CONFIGURE_ROUTING_INFORMATION:
174 case SMP_PHY_CONTROL:
177 case SMP_PHY_TEST_FUNCTION:
180 case SMP_PMC_SPECIFIC:
185 DM_DBG1(("dmSMPStart: SAS 1.1 error, undefined or unused smp function code 0x%x !!!\n", functionCode));
186 return DM_RC_FAILURE;
189 dmSMPFrameHeader.smpFrameType = SMP_REQUEST; /* SMP request */
190 dmSMPFrameHeader.smpFunction = (bit8)functionCode;
191 dmSMPFrameHeader.smpFunctionResult = 0;
192 dmSMPFrameHeader.smpReserved = 0;
196 DM_DBG2(("dmSMPStart: SAS 2\n"));
197 switch (functionCode)
199 case SMP_REPORT_GENERAL:
200 expectedRspLen = sizeof(smpRespReportGeneral2_t) + 4;
202 dmSMPFrameHeader.smpFrameType = SMP_REQUEST; /* SMP request */
203 dmSMPFrameHeader.smpFunction = (bit8)functionCode;
204 dmSMPFrameHeader.smpFunctionResult = 0x11;
205 dmSMPFrameHeader.smpReserved = 0;
207 case SMP_REPORT_MANUFACTURE_INFORMATION:
208 expectedRspLen = sizeof(smpRespReportManufactureInfo2_t) + 4;
211 expectedRspLen = sizeof(smpRespDiscover2_t) + 4;
213 dmSMPFrameHeader.smpFrameType = SMP_REQUEST; /* SMP request */
214 dmSMPFrameHeader.smpFunction = (bit8)functionCode;
215 // dmSMPFrameHeader.smpFunctionResult = 0x6c;
216 dmSMPFrameHeader.smpFunctionResult = 0x1b;
217 dmSMPFrameHeader.smpReserved = 0x02;
219 case SMP_REPORT_PHY_ERROR_LOG:
220 expectedRspLen = 32 - 4;
222 case SMP_REPORT_PHY_SATA:
224 dmSMPFrameHeader.smpFrameType = SMP_REQUEST; /* SMP request */
225 dmSMPFrameHeader.smpFunction = (bit8)functionCode;
226 dmSMPFrameHeader.smpFunctionResult = 0x10;
227 dmSMPFrameHeader.smpReserved = 0x02;
228 expectedRspLen = sizeof(smpRespReportPhySata2_t) + 4;
230 case SMP_REPORT_ROUTING_INFORMATION:
231 expectedRspLen = sizeof(smpRespReportRouteTable2_t) + 4;
233 case SMP_CONFIGURE_ROUTING_INFORMATION:
236 dmSMPFrameHeader.smpFrameType = SMP_REQUEST; /* SMP request */
237 dmSMPFrameHeader.smpFunction = (bit8)functionCode;
238 dmSMPFrameHeader.smpFunctionResult = 0;
239 dmSMPFrameHeader.smpReserved = 0x09;
241 case SMP_PHY_CONTROL:
244 dmSMPFrameHeader.smpFrameType = SMP_REQUEST; /* SMP request */
245 dmSMPFrameHeader.smpFunction = (bit8)functionCode;
246 dmSMPFrameHeader.smpFunctionResult = 0;
247 dmSMPFrameHeader.smpReserved = 0x09;
249 case SMP_PHY_TEST_FUNCTION:
252 case SMP_DISCOVER_LIST:
253 expectedRspLen = SMP_MAXIMUM_PAYLOAD; /* 1024 without CRC */
255 dmSMPFrameHeader.smpFrameType = SMP_REQUEST; /* SMP request */
256 dmSMPFrameHeader.smpFunction = (bit8)functionCode;
257 dmSMPFrameHeader.smpFunctionResult = 0xFF;
258 dmSMPFrameHeader.smpReserved = 0x06;
260 case SMP_PMC_SPECIFIC:
265 DM_DBG1(("dmSMPStart: SAS 2 error!!! undefined or unused smp function code 0x%x!!!\n", functionCode));
266 return DM_RC_FAILURE;
272 #ifdef DIRECT_SMP /* direct SMP with 48 or less payload */
273 if ( (smpBodySize + 4) <= SMP_DIRECT_PAYLOAD_LIMIT) /* 48 */
275 DM_DBG5(("dmSMPStart: DIRECT smp payload\n"));
276 dm_memset(dmSMPRequestBody->smpPayload, 0, SMP_DIRECT_PAYLOAD_LIMIT);
277 dm_memcpy(dmSMPRequestBody->smpPayload, &dmSMPFrameHeader, 4);
278 dm_memcpy((dmSMPRequestBody->smpPayload)+4, pSmpBody, smpBodySize);
280 /* direct SMP payload eg) REPORT_GENERAL, DISCOVER etc */
281 agSMPFrame->outFrameBuf = dmSMPRequestBody->smpPayload;
282 agSMPFrame->outFrameLen = smpBodySize + 4; /* without last 4 byte crc */
283 /* to specify DIRECT SMP response */
284 agSMPFrame->inFrameLen = 0;
286 /* temporary solution for T2D Combo*/
287 #if defined (INITIATOR_DRIVER) && defined (TARGET_DRIVER)
288 /* force smp repsonse to be direct */
289 agSMPFrame->expectedRespLen = 0;
291 agSMPFrame->expectedRespLen = expectedRspLen;
296 DM_DBG5(("dmSMPStart: INDIRECT smp payload, TBD\n"));
302 dmSMPRequestBody is SMP request
303 dmSMPResponsebody is SMP response
306 /* get an smp RESPONSE from the free list */
307 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
308 if (DMLIST_EMPTY(&(dmAllShared->freeSMPList)))
310 DM_DBG1(("dmSMPStart: no free SMP!!!\n"));
311 /* puy back dmSMPRequestBody to the freelist ???*/
312 // DMLIST_DEQUEUE_THIS(&(dmSMPRequestBody->Link));
313 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
314 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
316 /* undo increment the number of pending SMP */
317 onePortContext->discovery.pendingSMP--;
318 return DM_RC_FAILURE;
322 DMLIST_DEQUEUE_FROM_HEAD(&SMPList, &(dmAllShared->freeSMPList));
323 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
324 dmSMPResponseBody = DMLIST_OBJECT_BASE(dmSMPRequestBody_t, Link, SMPList);
325 DM_DBG5(("dmSMPStart: SMP id %d\n", dmSMPResponseBody->id));
328 if (dmSMPResponseBody == agNULL)
330 DM_DBG1(("dmSMPStart: dmSMPResponseBody is NULL, wrong!!!\n"));
331 return DM_RC_FAILURE;
334 /* fill in indirect SMP request fields */
335 DM_DBG5(("dmSMPStart: INDIRECT smp payload\n"));
337 /* save the pointer to SMP response in SMP request */
338 dmSMPRequestBody->IndirectSMPResponse = dmSMPResponseBody;
339 /* SMP request and response initialization */
340 dm_memset(dmSMPRequestBody->IndirectSMP, 0, smpBodySize + 4);
341 dm_memset(dmSMPResponseBody->IndirectSMP, 0, expectedRspLen);
343 dm_memcpy(dmSMPRequestBody->IndirectSMP, &dmSMPFrameHeader, 4);
344 dm_memcpy(dmSMPRequestBody->IndirectSMP+4, pSmpBody, smpBodySize);
346 /* Indirect SMP request */
347 agSMPFrame->outFrameBuf = agNULL;
348 agSMPFrame->outFrameAddrUpper32 = dmSMPRequestBody->IndirectSMPUpper32;
349 agSMPFrame->outFrameAddrLower32 = dmSMPRequestBody->IndirectSMPLower32;
350 agSMPFrame->outFrameLen = smpBodySize + 4; /* without last 4 byte crc */
352 /* Indirect SMP response */
353 agSMPFrame->expectedRespLen = expectedRspLen;
354 agSMPFrame->inFrameAddrUpper32 = dmSMPResponseBody->IndirectSMPUpper32;
355 agSMPFrame->inFrameAddrLower32 = dmSMPResponseBody->IndirectSMPLower32;
356 agSMPFrame->inFrameLen = expectedRspLen; /* without last 4 byte crc */
360 else /* SPCv controller */
362 /* only direct mode for both request and response */
363 DM_DBG5(("dmSMPStart: DIRECT smp payload\n"));
364 agSMPFrame->flag = 0;
365 dm_memset(dmSMPRequestBody->smpPayload, 0, SMP_DIRECT_PAYLOAD_LIMIT);
366 dm_memcpy(dmSMPRequestBody->smpPayload, &dmSMPFrameHeader, 4);
367 dm_memcpy((dmSMPRequestBody->smpPayload)+4, pSmpBody, smpBodySize);
369 /* direct SMP payload eg) REPORT_GENERAL, DISCOVER etc */
370 agSMPFrame->outFrameBuf = dmSMPRequestBody->smpPayload;
371 agSMPFrame->outFrameLen = smpBodySize + 4; /* without last 4 byte crc */
372 /* to specify DIRECT SMP response */
373 agSMPFrame->inFrameLen = 0;
375 /* temporary solution for T2D Combo*/
376 #if defined (INITIATOR_DRIVER) && defined (TARGET_DRIVER)
377 /* force smp repsonse to be direct */
378 agSMPFrame->expectedRespLen = 0;
380 agSMPFrame->expectedRespLen = expectedRspLen;
382 // tdhexdump("tdSMPStart", (bit8*)agSMPFrame->outFrameBuf, agSMPFrame->outFrameLen);
383 // tdhexdump("tdSMPStart new", (bit8*)tdSMPRequestBody->smpPayload, agSMPFrame->outFrameLen);
384 // tdhexdump("tdSMPStart - tdSMPRequestBody", (bit8*)tdSMPRequestBody, sizeof(tdssSMPRequestBody_t));
387 if (agDevHandle == agNULL)
389 DM_DBG1(("dmSMPStart: !!! agDevHandle is NULL !!! \n"));
403 if (status == AGSA_RC_SUCCESS)
405 /* start SMP timer */
406 if (functionCode == SMP_REPORT_GENERAL || functionCode == SMP_DISCOVER ||
407 functionCode == SMP_REPORT_PHY_SATA || functionCode == SMP_CONFIGURE_ROUTING_INFORMATION
410 dmDiscoverySMPTimer(dmRoot, onePortContext, functionCode, dmSMPRequestBody);
412 return DM_RC_SUCCESS;
414 else if (status == AGSA_RC_BUSY)
417 if (functionCode == SMP_REPORT_GENERAL || functionCode == SMP_DISCOVER ||
418 functionCode == SMP_REPORT_PHY_SATA || functionCode == SMP_CONFIGURE_ROUTING_INFORMATION)
420 /* only for discovery related SMPs*/
421 dmSMPBusyTimer(dmRoot, onePortContext, oneDeviceData, dmSMPRequestBody);
422 return DM_RC_SUCCESS;
426 DM_DBG1(("dmSMPStart: return DM_RC_BUSY!!! \n"));
428 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
429 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
430 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
432 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
433 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
434 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
435 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
440 else /* AGSA_RC_FAILURE */
442 DM_DBG1(("dmSMPStart: return DM_RC_FAILURE!!! \n"));
443 /* discovery failure or task management failure */
444 if (functionCode == SMP_REPORT_GENERAL || functionCode == SMP_DISCOVER ||
445 functionCode == SMP_REPORT_PHY_SATA || functionCode == SMP_CONFIGURE_ROUTING_INFORMATION)
447 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
450 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
451 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
452 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
454 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
455 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
456 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
457 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
460 return DM_RC_FAILURE;
463 return DM_RC_SUCCESS;
469 agsaIORequest_t *agIORequest,
472 agsaFrameHandle_t agFrameHandle
475 dmSMPRequestBody_t *pSMPRequestBody = (dmSMPRequestBody_t *) agIORequest->osData;
477 /* SPC can't be SMP target */
479 DM_DBG5(("dmsaSMPCompleted: start\n"));
481 if (pSMPRequestBody == agNULL)
483 DM_DBG1(("dmsaSMPCompleted: pSMPRequestBody is NULL!!! \n"));
487 if (pSMPRequestBody->SMPCompletionFunc == agNULL)
489 DM_DBG1(("dmsaSMPCompleted: pSMPRequestBody->SMPCompletionFunc is NULL!!!\n"));
493 #ifdef DM_INTERNAL_DEBUG /* debugging */
494 DM_DBG3(("dmsaSMPCompleted: agIOrequest %p\n", agIORequest->osData));
495 DM_DBG3(("dmsaSMPCompleted: sizeof(tdIORequestBody_t) %d 0x%x\n", sizeof(tdIORequestBody_t),
496 sizeof(tdIORequestBody_t)));
497 DM_DBG3(("dmsaSMPCompleted: SMPRequestbody %p\n", pSMPRequestBody));
498 DM_DBG3(("dmsaSMPCompleted: calling callback fn\n"));
499 DM_DBG3(("dmsaSMPCompleted: callback fn %p\n",pSMPRequestBody->SMPCompletionFunc));
500 #endif /* TD_INTERNAL_DEBUG */
502 if initiator, calling dmSMPCompleted() in dmsmp.c
504 pSMPRequestBody->SMPCompletionFunc(
519 // dmDeviceData_t *oneDeviceData, /* taget disk */
520 dmDeviceData_t *oneExpDeviceData, /* taget disk */
525 dmIntRoot_t *dmIntRoot = (dmIntRoot_t *)dmRoot->dmData;
526 dmIntContext_t *dmAllShared = (dmIntContext_t *)&dmIntRoot->dmAllShared;
527 agsaRoot_t *agRoot = dmAllShared->agRoot;
529 // dmDeviceData_t *oneExpDeviceData;
530 smpReqPhyControl_t smpPhyControlReq;
534 DM_DBG3(("dmPhyControlSend: start\n"));
538 osti_memset(&smpPhyControlReq, 0, sizeof(smpReqPhyControl_t));
540 /* fill in SMP payload */
541 smpPhyControlReq.phyIdentifier = phyID;
542 smpPhyControlReq.phyOperation = phyOp;
549 (bit8 *)&smpPhyControlReq,
550 sizeof(smpReqPhyControl_t),
559 dmDeviceData_t *oneDeviceData
562 dmIntRoot_t *dmIntRoot = (dmIntRoot_t *)dmRoot->dmData;
563 dmIntContext_t *dmAllShared = (dmIntContext_t *)&dmIntRoot->dmAllShared;
564 agsaRoot_t *agRoot = dmAllShared->agRoot;
566 DM_DBG3(("dmReportGeneralSend: start\n"));
567 DM_DBG3(("dmReportGeneralSend: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
568 DM_DBG3(("dmReportGeneralSend: oneExpander %p did %d\n", oneDeviceData->dmExpander, oneDeviceData->dmExpander->id));
570 if (agRoot == agNULL)
572 DM_DBG1(("dmReportGeneralSend: agRoot is NULL!!!\n"));
588 dmReportGeneralRespRcvd(
591 agsaIORequest_t *agIORequest,
592 dmDeviceData_t *oneDeviceData,
593 dmSMPFrameHeader_t *frameHeader,
594 agsaFrameHandle_t frameHandle
597 smpRespReportGeneral_t dmSMPReportGeneralResp;
598 smpRespReportGeneral_t *pdmSMPReportGeneralResp;
599 dmIntPortContext_t *onePortContext = agNULL;
600 dmDiscovery_t *discovery;
601 dmExpander_t *oneExpander = agNULL;
603 dmSMPRequestBody_t *dmSMPRequestBody;
604 dmSMPRequestBody_t *dmSMPResponseBody = agNULL;
606 dmIntRoot_t *dmIntRoot = (dmIntRoot_t *)dmRoot->dmData;
607 dmIntContext_t *dmAllShared = (dmIntContext_t *)&dmIntRoot->dmAllShared;
609 DM_DBG3(("dmReportGeneralRespRcvd: start\n"));
610 DM_DBG3(("dmReportGeneralRespRcvd: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
611 DM_DBG3(("dmReportGeneralRespRcvd: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
614 dmSMPRequestBody = (dmSMPRequestBody_t *)agIORequest->osData;
616 pdmSMPReportGeneralResp = &dmSMPReportGeneralResp;
618 dm_memset(&dmSMPReportGeneralResp, 0, sizeof(smpRespReportGeneral_t));
621 saFrameReadBlock(agRoot, frameHandle, 4, pdmSMPReportGeneralResp, sizeof(smpRespReportGeneral_t));
623 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
624 saFrameReadBlock(agRoot, dmSMPResponseBody->IndirectSMP, 4, pdmSMPReportGeneralResp, sizeof(smpRespReportGeneral_t));
627 onePortContext = oneDeviceData->dmPortContext;
628 discovery = &(onePortContext->discovery);
630 if (dmDiscoverCheck(dmRoot, onePortContext) == agTRUE)
632 DM_DBG1(("dmReportGeneralRespRcvd: invalid port or aborted discovery!!!\n"));
636 if (frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
638 oneDeviceData->numOfPhys = (bit8) pdmSMPReportGeneralResp->numOfPhys;
639 oneExpander = oneDeviceData->dmExpander;
640 oneExpander->routingIndex = (bit16) REPORT_GENERAL_GET_ROUTEINDEXES(pdmSMPReportGeneralResp);
641 oneExpander->configReserved = 0;
642 oneExpander->configRouteTable = REPORT_GENERAL_IS_CONFIGURABLE(pdmSMPReportGeneralResp) ? 1 : 0;
643 oneExpander->configuring = REPORT_GENERAL_IS_CONFIGURING(pdmSMPReportGeneralResp) ? 1 : 0;
644 DM_DBG2(("dmReportGeneralRespRcvd: SAS 2 is %d\n", oneExpander->SAS2));
645 DM_DBG3(("dmReportGeneralRespRcvd: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
646 DM_DBG3(("dmReportGeneralRespRcvd: oneExpander %p did %d\n", oneExpander, oneExpander->id));
648 if ( oneExpander->SAS2 == 0 && REPORT_GENERAL_IS_LONG_RESPONSE(pdmSMPReportGeneralResp) == 1)
650 oneExpander->SAS2 = REPORT_GENERAL_IS_LONG_RESPONSE(pdmSMPReportGeneralResp);
651 DM_DBG2(("dmReportGeneralRespRcvd: SAS 2 Long Response=%d\n", REPORT_GENERAL_IS_LONG_RESPONSE(pdmSMPReportGeneralResp)));
652 dmReportGeneralSend(dmRoot, oneDeviceData);
656 DM_DBG3(("dmReportGeneralRespRcvd: oneExpander=%p numberofPhys=0x%x RoutingIndex=0x%x\n",
657 oneExpander, oneDeviceData->numOfPhys, oneExpander->routingIndex));
658 DM_DBG3(("dmReportGeneralRespRcvd: configRouteTable=%d configuring=%d\n",
659 oneExpander->configRouteTable, oneExpander->configuring));
661 if (oneExpander->configuring == 1)
663 discovery->retries++;
664 if (discovery->retries >= dmAllShared->MaxRetryDiscovery)
666 DM_DBG1(("dmReportGeneralRespRcvd: retries are over!!!\n"));
667 DM_DBG1(("dmReportGeneralRespRcvd: sasAddressHi 0x%08x sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
668 discovery->retries = 0;
669 /* failed the discovery */
670 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
674 DM_DBG3(("dmReportGeneralRespRcvd: keep retrying\n"));
675 DM_DBG1(("dmReportGeneralRespRcvd: Prep222389 RETRY at %d Maximum Retry is %d\n", discovery->retries, dmAllShared->MaxRetryDiscovery));
676 DM_DBG1(("dmReportGeneralRespRcvd: sasAddressHi 0x%08x sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
677 // start timer for sending ReportGeneral
678 dmDiscoveryConfiguringTimer(dmRoot, onePortContext, oneDeviceData);
683 discovery->retries = 0;
684 dmDiscoverSend(dmRoot, oneDeviceData);
689 DM_DBG1(("dmReportGeneralRespRcvd: SMP failed; fn result 0x%x; stopping discovery !!!\n", frameHeader->smpFunctionResult));
690 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
696 dmReportGeneral2RespRcvd(
699 agsaIORequest_t *agIORequest,
700 dmDeviceData_t *oneDeviceData,
701 dmSMPFrameHeader_t *frameHeader,
702 agsaFrameHandle_t frameHandle
705 smpRespReportGeneral2_t dmSMPReportGeneral2Resp;
706 smpRespReportGeneral2_t *pdmSMPReportGeneral2Resp;
707 dmExpander_t *oneExpander = agNULL;
708 dmIntPortContext_t *onePortContext = agNULL;
709 dmDiscovery_t *discovery;
711 dmSMPRequestBody_t *dmSMPRequestBody;
712 dmSMPRequestBody_t *dmSMPResponseBody = agNULL;
714 bit32 ConfiguresOthers = agFALSE;
715 dmIntRoot_t *dmIntRoot = (dmIntRoot_t *)dmRoot->dmData;
716 dmIntContext_t *dmAllShared = (dmIntContext_t *)&dmIntRoot->dmAllShared;
719 DM_DBG2(("dmReportGeneral2RespRcvd: start\n"));
720 DM_DBG2(("dmReportGeneral2RespRcvd: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
721 DM_DBG2(("dmReportGeneral2RespRcvd: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
724 dmSMPRequestBody = (dmSMPRequestBody_t *)agIORequest->osData;
726 pdmSMPReportGeneral2Resp = &dmSMPReportGeneral2Resp;
728 dm_memset(&dmSMPReportGeneral2Resp, 0, sizeof(smpRespReportGeneral2_t));
731 saFrameReadBlock(agRoot, frameHandle, 4, pdmSMPReportGeneral2Resp, sizeof(smpRespReportGeneral2_t));
733 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
734 saFrameReadBlock(agRoot, dmSMPResponseBody->IndirectSMP, 4, pdmSMPReportGeneral2Resp, sizeof(smpRespReportGeneral2_t));
737 onePortContext = oneDeviceData->dmPortContext;
738 discovery = &(onePortContext->discovery);
739 if (dmDiscoverCheck(dmRoot, onePortContext) == agTRUE)
741 DM_DBG1(("dmReportGeneral2RespRcvd: invalid port or aborted discovery!!!\n"));
746 if (frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
748 oneDeviceData->numOfPhys = (bit8) pdmSMPReportGeneral2Resp->numOfPhys;
749 oneExpander = oneDeviceData->dmExpander;
750 oneExpander->routingIndex = (bit16) SAS2_REPORT_GENERAL_GET_ROUTEINDEXES(pdmSMPReportGeneral2Resp);
751 oneExpander->configReserved = 0;
752 oneExpander->configRouteTable = SAS2_REPORT_GENERAL_IS_CONFIGURABLE(pdmSMPReportGeneral2Resp) ? 1 : 0;
753 oneExpander->configuring = SAS2_REPORT_GENERAL_IS_CONFIGURING(pdmSMPReportGeneral2Resp) ? 1 : 0;
754 oneExpander->TTTSupported = SAS2_REPORT_GENERAL_IS_TABLE_TO_TABLE_SUPPORTED(pdmSMPReportGeneral2Resp) ? 1 : 0;
755 ConfiguresOthers = SAS2_REPORT_GENERAL_IS_CONFIGURES_OTHERS(pdmSMPReportGeneral2Resp) ? 1 : 0;
757 DM_DBG2(("dmReportGeneral2RespRcvd: SAS 2 is %d\n", oneExpander->SAS2));
758 DM_DBG3(("dmReportGeneral2RespRcvd: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
759 DM_DBG3(("dmReportGeneral2RespRcvd: oneExpander %p did %d\n", oneExpander, oneExpander->id));
762 DM_DBG2(("dmReportGeneral2RespRcvd: oneExpander=%p numberofPhys=0x%x RoutingIndex=0x%x\n",
763 oneExpander, oneDeviceData->numOfPhys, oneExpander->routingIndex));
764 DM_DBG2(("dmReportGeneral2RespRcvd: configRouteTable=%d configuring=%d\n",
765 oneExpander->configRouteTable, oneExpander->configuring));
766 if (ConfiguresOthers)
768 DM_DBG2(("dmReportGeneral2RespRcvd: ConfiguresOthers is true\n"));
769 discovery->ConfiguresOthers = agTRUE;
771 if (oneExpander->configuring == 1)
773 discovery->retries++;
774 if (discovery->retries >= dmAllShared->MaxRetryDiscovery)
776 DM_DBG1(("dmReportGeneral2RespRcvd: retries are over!!!\n"));
777 DM_DBG1(("dmReportGeneral2RespRcvd: sasAddressHi 0x%08x sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
779 discovery->retries = 0;
780 /* failed the discovery */
781 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
785 DM_DBG2(("dmReportGeneral2RespRcvd: keep retrying\n"));
786 DM_DBG1(("dmReportGeneral2RespRcvd: Prep222389 RETRY at %d Maximum Retry is %d\n", discovery->retries, dmAllShared->MaxRetryDiscovery));
787 DM_DBG1(("dmReportGeneral2RespRcvd: sasAddressHi 0x%08x sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
788 // start timer for sending ReportGeneral
789 dmDiscoveryConfiguringTimer(dmRoot, onePortContext, oneDeviceData);
794 discovery->retries = 0;
795 dmDiscoverSend(dmRoot, oneDeviceData);
800 DM_DBG2(("dmReportGeneral2RespRcvd: SMP failed, stopping discovery\n"));
801 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
811 dmDeviceData_t *oneDeviceData
814 dmIntRoot_t *dmIntRoot = (dmIntRoot_t *)dmRoot->dmData;
815 dmIntContext_t *dmAllShared = (dmIntContext_t *)&dmIntRoot->dmAllShared;
816 agsaRoot_t *agRoot = dmAllShared->agRoot;
817 smpReqDiscover_t smpDiscoverReq;
818 dmExpander_t *oneExpander;
820 DM_DBG3(("dmDiscoverSend: start\n"));
821 DM_DBG3(("dmDiscoverSend: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
822 oneExpander = oneDeviceData->dmExpander;
823 DM_DBG3(("dmDiscoverSend: oneExpander %p did %d\n", oneExpander, oneExpander->id));
824 DM_DBG3(("dmDiscoverSend: phyID 0x%x\n", oneExpander->discoveringPhyId));
826 dm_memset(&smpDiscoverReq, 0, sizeof(smpReqDiscover_t));
828 smpDiscoverReq.reserved1 = 0;
829 smpDiscoverReq.reserved2 = 0;
830 smpDiscoverReq.phyIdentifier = oneExpander->discoveringPhyId;
831 smpDiscoverReq.reserved3 = 0;
838 (bit8 *)&smpDiscoverReq,
839 sizeof(smpReqDiscover_t),
849 agsaIORequest_t *agIORequest,
850 dmDeviceData_t *oneDeviceData,
851 dmSMPFrameHeader_t *frameHeader,
852 agsaFrameHandle_t frameHandle
855 dmIntPortContext_t *onePortContext = agNULL;
856 dmDiscovery_t *discovery;
857 smpRespDiscover_t *pdmSMPDiscoverResp;
859 dmSMPRequestBody_t *dmSMPRequestBody;
860 dmSMPRequestBody_t *dmSMPResponseBody = agNULL;
862 dmExpander_t *oneExpander = agNULL;
864 DM_DBG3(("dmDiscoverRespRcvd: start\n"));
865 DM_DBG3(("dmDiscoverRespRcvd: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
866 DM_DBG3(("dmDiscoverRespRcvd: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
868 onePortContext = oneDeviceData->dmPortContext;
869 oneExpander = oneDeviceData->dmExpander;
870 discovery = &(onePortContext->discovery);
872 dmSMPRequestBody = (dmSMPRequestBody_t *)agIORequest->osData;
874 DM_DBG3(("dmDiscoverRespRcvd: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
875 DM_DBG3(("dmDiscoverRespRcvd: oneExpander %p did %d\n", oneExpander, oneExpander->id));
877 if (dmDiscoverCheck(dmRoot, onePortContext) == agTRUE)
879 DM_DBG1(("dmDiscoverRespRcvd: invalid port or aborted discovery!!!\n"));
883 pdmSMPDiscoverResp = &(discovery->SMPDiscoverResp);
886 saFrameReadBlock(agRoot, frameHandle, 4, pdmSMPDiscoverResp, sizeof(smpRespDiscover_t));
888 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
889 saFrameReadBlock(agRoot, dmSMPResponseBody->IndirectSMP, 4, pdmSMPDiscoverResp, sizeof(smpRespDiscover_t));
892 if ( frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
894 if ( onePortContext->discovery.status == DISCOVERY_UP_STREAM)
896 dmUpStreamDiscoverExpanderPhy(dmRoot, onePortContext, oneExpander, pdmSMPDiscoverResp);
898 else if ( onePortContext->discovery.status == DISCOVERY_DOWN_STREAM)
900 dmDownStreamDiscoverExpanderPhy(dmRoot, onePortContext, oneExpander, pdmSMPDiscoverResp);
902 else if (onePortContext->discovery.status == DISCOVERY_CONFIG_ROUTING)
904 /* not done with configuring routing
906 2. on timer expiration, call tdsaSASDownStreamDiscoverExpanderPhy()
908 DM_DBG3(("dmDiscoverRespRcvd: still configuring routing; setting timer\n"));
909 DM_DBG3(("dmDiscoverRespRcvd: onePortContext %p oneDeviceData %p pdmSMPDiscoverResp %p\n", onePortContext, oneDeviceData, pdmSMPDiscoverResp));
910 dmhexdump("dmDiscoverRespRcvd", (bit8*)pdmSMPDiscoverResp, sizeof(smpRespDiscover_t));
912 dmConfigureRouteTimer(dmRoot, onePortContext, oneExpander, pdmSMPDiscoverResp, agNULL);
919 else if (frameHeader->smpFunctionResult == PHY_VACANT)
921 DM_DBG3(("dmDiscoverRespRcvd: smpFunctionResult is PHY_VACANT, phyid %d\n", oneExpander->discoveringPhyId));
922 if ( onePortContext->discovery.status == DISCOVERY_UP_STREAM)
924 dmUpStreamDiscoverExpanderPhySkip(dmRoot, onePortContext, oneExpander);
926 else if ( onePortContext->discovery.status == DISCOVERY_DOWN_STREAM)
928 dmDownStreamDiscoverExpanderPhySkip(dmRoot, onePortContext, oneExpander);
930 else if (onePortContext->discovery.status == DISCOVERY_CONFIG_ROUTING)
932 /* not done with configuring routing
934 2. on timer expiration, call tdsaSASDownStreamDiscoverExpanderPhy()
936 DM_DBG3(("dmDiscoverRespRcvd: still configuring routing; setting timer\n"));
937 DM_DBG3(("dmDiscoverRespRcvd: onePortContext %p oneDeviceData %p pdmSMPDiscoverResp %p\n", onePortContext, oneDeviceData, pdmSMPDiscoverResp));
938 dmhexdump("dmDiscoverRespRcvd", (bit8*)pdmSMPDiscoverResp, sizeof(smpRespDiscover_t));
940 dmConfigureRouteTimer(dmRoot, onePortContext, oneExpander, pdmSMPDiscoverResp, agNULL);
945 DM_DBG1(("dmDiscoverRespRcvd: Discovery Error SMP function return result error=0x%x !!!\n",
946 frameHeader->smpFunctionResult));
947 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
959 agsaIORequest_t *agIORequest,
960 dmDeviceData_t *oneDeviceData,
961 dmSMPFrameHeader_t *frameHeader,
962 agsaFrameHandle_t frameHandle
965 dmIntPortContext_t *onePortContext = agNULL;
966 dmDiscovery_t *discovery;
967 smpRespDiscover2_t *pdmSMPDiscover2Resp;
969 dmSMPRequestBody_t *dmSMPRequestBody;
970 dmSMPRequestBody_t *dmSMPResponseBody = agNULL;
972 dmExpander_t *oneExpander = agNULL;
974 DM_DBG2(("dmDiscover2RespRcvd: start\n"));
975 DM_DBG2(("dmDiscover2RespRcvd: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
976 DM_DBG2(("dmDiscover2RespRcvd: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
978 onePortContext = oneDeviceData->dmPortContext;
979 oneExpander = oneDeviceData->dmExpander;
980 discovery = &(onePortContext->discovery);
982 dmSMPRequestBody = (dmSMPRequestBody_t *)agIORequest->osData;
984 DM_DBG3(("dmDiscoverRespRcvd: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
985 DM_DBG3(("dmDiscoverRespRcvd: oneExpander %p did %d\n", oneExpander, oneExpander->id));
987 if (dmDiscoverCheck(dmRoot, onePortContext) == agTRUE)
989 DM_DBG1(("dmDiscover2RespRcvd: invalid port or aborted discovery!!!\n"));
993 pdmSMPDiscover2Resp = &(discovery->SMPDiscover2Resp);
996 saFrameReadBlock(agRoot, frameHandle, 4, pdmSMPDiscover2Resp, sizeof(smpRespDiscover2_t));
998 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
999 saFrameReadBlock(agRoot, dmSMPResponseBody->IndirectSMP, 4, pdmSMPDiscover2Resp, sizeof(smpRespDiscover2_t));
1002 if ( frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED )
1004 DM_DBG2(("dmDiscover2RespRcvd: phyIdentifier %d\n", pdmSMPDiscover2Resp->phyIdentifier));
1005 DM_DBG2(("dmDiscover2RespRcvd: NegotiatedSSCHWMuxingSupported %d\n", pdmSMPDiscover2Resp->NegotiatedSSCHWMuxingSupported));
1006 DM_DBG2(("dmDiscover2RespRcvd: SAS2_MUXING_SUPPORTED %d\n", SAS2_DISCRSP_IS_MUXING_SUPPORTED(pdmSMPDiscover2Resp)));
1007 DM_DBG2(("dmDiscover2RespRcvd: NegotiatedLogicalLinkRate %d\n", pdmSMPDiscover2Resp->NegotiatedLogicalLinkRate));
1008 DM_DBG2(("dmDiscover2RespRcvd: ReasonNegotiatedPhysicalLinkRate %d\n", pdmSMPDiscover2Resp->ReasonNegotiatedPhysicalLinkRate));
1009 DM_DBG2(("dmDiscover2RespRcvd: SAS2_DISCRSP_GET_LOGICAL_LINKRATE %d\n", SAS2_DISCRSP_GET_LOGICAL_LINKRATE(pdmSMPDiscover2Resp)));
1010 DM_DBG2(("dmDiscover2RespRcvd: SAS2_DISCRSP_GET_LINKRATE %d\n", SAS2_DISCRSP_GET_LINKRATE(pdmSMPDiscover2Resp)));
1012 //NegotiatedLogicalLinkRate 13
1013 //ReasonNegotiatedPhysicalLinkRate 94
1014 if ( onePortContext->discovery.status == DISCOVERY_UP_STREAM)
1016 dmUpStreamDiscover2ExpanderPhy(dmRoot, onePortContext, oneExpander, pdmSMPDiscover2Resp);
1018 else if ( onePortContext->discovery.status == DISCOVERY_DOWN_STREAM)
1020 dmDownStreamDiscover2ExpanderPhy(dmRoot, onePortContext, oneExpander, pdmSMPDiscover2Resp);
1022 else if (onePortContext->discovery.status == DISCOVERY_CONFIG_ROUTING)
1024 /* not done with configuring routing
1026 2. on timer expiration, call tdsaSASDownStreamDiscoverExpanderPhy()
1028 DM_DBG2(("dmDiscover2RespRcvd: still configuring routing; setting timer\n"));
1029 DM_DBG2(("dmDiscover2RespRcvd: onePortContext %p oneDeviceData %p pdmSMPDiscover2Resp %p\n", onePortContext, oneDeviceData, pdmSMPDiscover2Resp));
1030 dmhexdump("dmDiscover2RespRcvd", (bit8*)pdmSMPDiscover2Resp, sizeof(smpRespDiscover2_t));
1031 dmConfigureRouteTimer(dmRoot, onePortContext, oneExpander, agNULL, pdmSMPDiscover2Resp);
1038 else if (frameHeader->smpFunctionResult == PHY_VACANT)
1040 DM_DBG2(("dmDiscover2RespRcvd: smpFunctionResult is PHY_VACANT, phyid %d\n", oneExpander->discoveringPhyId));
1041 if ( onePortContext->discovery.status == DISCOVERY_UP_STREAM)
1043 dmUpStreamDiscover2ExpanderPhySkip(dmRoot, onePortContext, oneExpander);
1045 else if ( onePortContext->discovery.status == DISCOVERY_DOWN_STREAM)
1047 dmDownStreamDiscover2ExpanderPhySkip(dmRoot, onePortContext, oneExpander);
1049 else if (onePortContext->discovery.status == DISCOVERY_CONFIG_ROUTING)
1051 /* not done with configuring routing
1053 2. on timer expiration, call tdsaSASDownStreamDiscoverExpanderPhy()
1055 DM_DBG2(("dmDiscover2RespRcvd: still configuring routing; setting timer\n"));
1056 DM_DBG2(("dmDiscover2RespRcvd: onePortContext %p oneDeviceData %p pdmSMPDiscover2Resp %p\n", onePortContext, oneDeviceData, pdmSMPDiscover2Resp));
1057 dmhexdump("dmDiscover2RespRcvd", (bit8*)pdmSMPDiscover2Resp, sizeof(smpRespDiscover2_t));
1058 dmConfigureRouteTimer(dmRoot, onePortContext, oneExpander, agNULL, pdmSMPDiscover2Resp);
1067 DM_DBG1(("dmDiscover2RespRcvd: Discovery Error SMP function return result error=0x%x\n",
1068 frameHeader->smpFunctionResult));
1069 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
1076 tdsaDiscoverList2Send(
1078 tdsaDeviceData_t *oneDeviceData
1082 tdsaExpander_t *oneExpander;
1083 smpReqDiscoverList2_t smpDiscoverListReq;
1085 DM_DBG1(("tdsaDiscoverList2Send: start\n"));
1086 DM_DBG1(("tdsaDiscoverList2Send: device %p did %d\n", oneDeviceData, oneDeviceData->id));
1087 agRoot = oneDeviceData->agRoot;
1088 oneExpander = oneDeviceData->dmExpander;
1089 DM_DBG1(("tdsaDiscoverList2Send: phyID 0x%x\n", oneExpander->discoveringPhyId));
1092 osti_memset(&smpDiscoverListReq, 0, sizeof(smpReqDiscoverList2_t));
1094 smpDiscoverListReq.reserved1 = 0;
1095 smpDiscoverListReq.StartingPhyID = 0;
1096 smpDiscoverListReq.MaxNumDiscoverDesc = 40; /* 40 for SHORT FORMAT; 8 for Long Format; SAS2 p630 */
1097 smpDiscoverListReq.byte10 = 0x2; /* phy filter; all but "no device attached" */
1098 smpDiscoverListReq.byte11 = 0x1; /* descriptor type; SHORT FORMAT */
1106 (bit8 *)&smpDiscoverListReq,
1107 sizeof(smpReqDiscoverList2_t),
1115 tdsaDiscoverList2RespRcvd(
1118 tdsaDeviceData_t *oneDeviceData,
1119 tdssSMPFrameHeader_t *frameHeader,
1120 agsaFrameHandle_t frameHandle
1125 #endif /* not yet */
1127 /*****************************************************************************
1128 *! \brief dmReportPhySataSend
1130 * Purpose: This function sends Report Phy SATA to a device.
1132 * \param dmRoot: Pointer to the OS Specific module allocated dmRoot_t
1134 * \param oneDeviceData: Pointer to the device data.
1135 * \param phyId: Phy Identifier.
1142 *****************************************************************************/
1144 dmReportPhySataSend(
1146 dmDeviceData_t *oneDeviceData,
1150 dmIntRoot_t *dmIntRoot = (dmIntRoot_t *)dmRoot->dmData;
1151 dmIntContext_t *dmAllShared = (dmIntContext_t *)&dmIntRoot->dmAllShared;
1152 agsaRoot_t *agRoot = dmAllShared->agRoot;
1153 dmExpander_t *oneExpander;
1154 smpReqReportPhySata_t smpReportPhySataReq;
1156 DM_DBG3(("dmReportPhySataSend: start\n"));
1157 DM_DBG3(("dmReportPhySataSend: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
1158 DM_DBG3(("dmReportPhySataSend: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
1159 DM_DBG3(("dmReportPhySataSend: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
1161 oneExpander = oneDeviceData->dmExpander;
1163 if (oneExpander == agNULL)
1165 DM_DBG1(("dmReportPhySataSend: Error!!! expander is NULL\n"));
1168 DM_DBG3(("dmReportPhySataSend: device %p did %d\n", oneDeviceData, oneDeviceData->id));
1169 DM_DBG3(("dmReportPhySataSend: phyid %d\n", phyId));
1171 dm_memset(&smpReportPhySataReq, 0, sizeof(smpReqReportPhySata_t));
1173 smpReportPhySataReq.phyIdentifier = phyId;
1178 oneExpander->dmDevice,
1179 SMP_REPORT_PHY_SATA,
1180 (bit8 *)&smpReportPhySataReq,
1181 sizeof(smpReqReportPhySata_t),
1187 /*****************************************************************************
1188 *! \brief dmReportPhySataRcvd
1190 * Purpose: This function processes Report Phy SATA response.
1192 * \param dmRoot_t: Pointer to the OS Specific module allocated dmRoot_t
1194 * \param agRoot: Pointer to chip/driver Instance.
1195 * \param oneDeviceData: Pointer to the device data.
1196 * \param frameHeader: Pointer to SMP frame header.
1197 * \param frameHandle: A Handle used to refer to the response frame
1204 *****************************************************************************/
1207 dmReportPhySataRcvd(
1210 agsaIORequest_t *agIORequest,
1211 dmDeviceData_t *oneDeviceData,
1212 dmSMPFrameHeader_t *frameHeader,
1213 agsaFrameHandle_t frameHandle
1216 smpRespReportPhySata_t SMPreportPhySataResp;
1217 smpRespReportPhySata_t *pSMPReportPhySataResp;
1218 dmExpander_t *oneExpander = oneDeviceData->dmExpander;
1219 dmIntPortContext_t *onePortContext = agNULL;
1220 agsaFisRegDeviceToHost_t *fis;
1221 dmDeviceData_t *SataDevice = agNULL;
1223 dmSMPRequestBody_t *tdSMPRequestBody;
1225 bit8 sataDeviceType;
1229 bit8 bit8fisarray[20];
1231 DM_DBG3(("dmReportPhySataRcvd: start\n"));
1232 DM_DBG3(("dmReportPhySataRcvd: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
1233 DM_DBG3(("dmReportPhySataRcvd: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
1236 tdSMPRequestBody = (dmSMPRequestBody_t *)agIORequest->osData;
1238 /* get the current sata device hanlde stored in the expander structure */
1239 if (oneExpander != agNULL)
1241 SataDevice = oneExpander->dmDeviceToProcess;
1244 if (SataDevice != agNULL)
1246 DM_DBG3(("dmReportPhySataRcvd: sasAddressHi 0x%08x\n", SataDevice->SASAddressID.sasAddressHi));
1247 DM_DBG3(("dmReportPhySataRcvd: sasAddressLo 0x%08x\n", SataDevice->SASAddressID.sasAddressLo));
1251 DM_DBG3(("dmReportPhySataRcvd: SataDevice is NULL\n"));
1254 pSMPReportPhySataResp = &SMPreportPhySataResp;
1257 saFrameReadBlock(agRoot, frameHandle, 4, pSMPReportPhySataResp, sizeof(smpRespReportPhySata_t));
1259 saFrameReadBlock(agRoot, tdSMPRequestBody->IndirectSMPResp, 4, pSMPReportPhySataResp, sizeof(smpRespReportPhySata_t));
1262 /* tdhexdump("dmReportPhySataRcvd", (bit8 *)pSMPReportPhySataResp, sizeof(smpRespReportPhySata_t));*/
1267 tdSMPRequestBody->IndirectSMPReqosMemHandle,
1268 tdSMPRequestBody->IndirectSMPReqLen
1272 tdSMPRequestBody->IndirectSMPResposMemHandle,
1273 tdSMPRequestBody->IndirectSMPRespLen
1277 onePortContext = oneDeviceData->dmPortContext;
1279 if (dmDiscoverCheck(dmRoot, onePortContext) == agTRUE)
1281 DM_DBG1(("dmReportPhySataRcvd: invalid port or aborted discovery!!!\n"));
1285 if (SataDevice == agNULL)
1287 DM_DBG1(("dmReportPhySataRcvd: SataDevice is NULL, wrong\n"));
1288 dmDiscoverAbort(dmRoot, onePortContext);
1292 if (frameHeader->smpFunctionResult == PHY_VACANT )
1294 DM_DBG1(("dmReportPhySataRcvd: smpFunctionResult == PHY_VACANT, wrong\n"));
1298 if ( frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED )
1300 fis = (agsaFisRegDeviceToHost_t*) &SMPreportPhySataResp.regDevToHostFis;
1301 if (fis->h.fisType == REG_DEV_TO_HOST_FIS)
1303 /* save signature */
1304 DM_DBG3(("dmReportPhySataRcvd: saves the signature\n"));
1305 /* saves signature */
1306 SataDevice->satSignature[0] = fis->d.sectorCount;
1307 SataDevice->satSignature[1] = fis->d.lbaLow;
1308 SataDevice->satSignature[2] = fis->d.lbaMid;
1309 SataDevice->satSignature[3] = fis->d.lbaHigh;
1310 SataDevice->satSignature[4] = fis->d.device;
1311 SataDevice->satSignature[5] = 0;
1312 SataDevice->satSignature[6] = 0;
1313 SataDevice->satSignature[7] = 0;
1315 DM_DBG3(("dmReportPhySataRcvd: SATA Signature = %02x %02x %02x %02x %02x\n",
1316 SataDevice->satSignature[0],
1317 SataDevice->satSignature[1],
1318 SataDevice->satSignature[2],
1319 SataDevice->satSignature[3],
1320 SataDevice->satSignature[4]));
1322 sataDeviceType = tddmSATADeviceTypeDecode(SataDevice->satSignature);
1323 if( sataDeviceType == SATA_ATAPI_DEVICE)
1325 SataDevice->agDeviceInfo.flag |= ATAPI_DEVICE_FLAG;
1327 SataDevice->dmDeviceInfo.sataDeviceType = sataDeviceType;
1329 /* Handling DataDomain buggy FIS */
1330 else if (fis->h.error == REG_DEV_TO_HOST_FIS)
1332 /* needs to flip fis to host order */
1333 bit8fis = (bit8*)fis;
1336 a = DMA_LEBIT32_TO_BIT32(*(bit32*)bit8fis);
1337 DM_DBG3(("dmReportPhySataRcvd: a 0x%8x\n", a));
1338 bit8fisarray[4*i] = (a & 0xFF000000) >> 24;
1339 bit8fisarray[4*i+1] = (a & 0x00FF0000) >> 16;
1340 bit8fisarray[4*i+2] = (a & 0x0000FF00) >> 8;
1341 bit8fisarray[4*i+3] = (a & 0x000000FF);
1342 bit8fis = bit8fis + 4;
1344 fis = (agsaFisRegDeviceToHost_t*) bit8fisarray;
1345 /* save signature */
1346 DM_DBG3(("dmReportPhySataRcvd: DataDomain ATAPI saves the signature\n"));
1347 /* saves signature */
1348 SataDevice->satSignature[0] = fis->d.sectorCount;
1349 SataDevice->satSignature[1] = fis->d.lbaLow;
1350 SataDevice->satSignature[2] = fis->d.lbaMid;
1351 SataDevice->satSignature[3] = fis->d.lbaHigh;
1352 SataDevice->satSignature[4] = fis->d.device;
1353 SataDevice->satSignature[5] = 0;
1354 SataDevice->satSignature[6] = 0;
1355 SataDevice->satSignature[7] = 0;
1357 DM_DBG3(("dmReportPhySataRcvd: SATA Signature = %02x %02x %02x %02x %02x\n",
1358 SataDevice->satSignature[0],
1359 SataDevice->satSignature[1],
1360 SataDevice->satSignature[2],
1361 SataDevice->satSignature[3],
1362 SataDevice->satSignature[4]));
1364 sataDeviceType = tddmSATADeviceTypeDecode(SataDevice->satSignature);
1365 if( sataDeviceType == SATA_ATAPI_DEVICE)
1367 SataDevice->agDeviceInfo.flag |= ATAPI_DEVICE_FLAG;
1369 SataDevice->dmDeviceInfo.sataDeviceType = sataDeviceType;
1373 DM_DBG3(("dmReportPhySataRcvd: getting next stp bride\n"));
1376 /* Continure to report this STP device to TD*/
1377 if (SataDevice->ExpDevice != agNULL)
1379 tddmReportDevice(dmRoot, onePortContext->dmPortContext, &SataDevice->dmDeviceInfo, &SataDevice->ExpDevice->dmDeviceInfo, dmDeviceArrival);
1383 tddmReportDevice(dmRoot, onePortContext->dmPortContext, &SataDevice->dmDeviceInfo, agNULL, dmDeviceArrival);
1388 DM_DBG3(("dmReportPhySataRcvd: siReportPhySataRcvd SMP function return result %x\n",
1389 frameHeader->smpFunctionResult));
1390 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
1396 /*****************************************************************************
1397 *! \brief dmReportPhySata2Rcvd
1399 * Purpose: This function processes SAS2.0 Report Phy SATA response.
1401 * \param dmRoot_t: Pointer to the OS Specific module allocated dmRoot_t
1403 * \param agRoot: Pointer to chip/driver Instance.
1404 * \param oneDeviceData: Pointer to the device data.
1405 * \param frameHeader: Pointer to SMP frame header.
1406 * \param frameHandle: A Handle used to refer to the response frame
1413 *****************************************************************************/
1415 dmReportPhySata2Rcvd(
1418 agsaIORequest_t *agIORequest,
1419 dmDeviceData_t *oneDeviceData,
1420 dmSMPFrameHeader_t *frameHeader,
1421 agsaFrameHandle_t frameHandle
1424 smpRespReportPhySata2_t SMPreportPhySataResp;
1425 smpRespReportPhySata2_t *pSMPReportPhySataResp;
1426 dmExpander_t *oneExpander = oneDeviceData->dmExpander;
1427 dmIntPortContext_t *onePortContext = agNULL;
1428 agsaFisRegDeviceToHost_t *fis;
1429 dmDeviceData_t *SataDevice = agNULL;
1431 dmSMPRequestBody_t *tdSMPRequestBody;
1433 bit8 sataDeviceType = 0;
1437 bit8 bit8fisarray[20];
1439 DM_DBG3(("dmReportPhySata2Rcvd: start\n"));
1440 DM_DBG3(("dmReportPhySata2Rcvd: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
1441 DM_DBG3(("dmReportPhySata2Rcvd: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
1444 tdSMPRequestBody = (dmSMPRequestBody_t *)agIORequest->osData;
1446 /* get the current sata device hanlde stored in the expander structure */
1447 if (oneExpander != agNULL)
1449 SataDevice = oneExpander->dmDeviceToProcess;
1452 if (SataDevice != agNULL)
1454 DM_DBG3(("dmReportPhySata2Rcvd: sasAddressHi 0x%08x\n", SataDevice->SASAddressID.sasAddressHi));
1455 DM_DBG3(("dmReportPhySata2Rcvd: sasAddressLo 0x%08x\n", SataDevice->SASAddressID.sasAddressLo));
1459 DM_DBG3(("dmReportPhySataRcvd: SataDevice is NULL\n"));
1462 pSMPReportPhySataResp = &SMPreportPhySataResp;
1465 saFrameReadBlock(agRoot, frameHandle, 4, pSMPReportPhySataResp, sizeof(smpRespReportPhySata_t));
1467 saFrameReadBlock(agRoot, tdSMPRequestBody->IndirectSMPResp, 4, pSMPReportPhySataResp, sizeof(smpRespReportPhySata_t));
1470 /* tdhexdump("dmReportPhySataRcvd", (bit8 *)pSMPReportPhySataResp, sizeof(smpRespReportPhySata_t));*/
1475 tdSMPRequestBody->IndirectSMPReqosMemHandle,
1476 tdSMPRequestBody->IndirectSMPReqLen
1480 tdSMPRequestBody->IndirectSMPResposMemHandle,
1481 tdSMPRequestBody->IndirectSMPRespLen
1485 onePortContext = oneDeviceData->dmPortContext;
1487 if (dmDiscoverCheck(dmRoot, onePortContext) == agTRUE)
1489 DM_DBG1(("dmReportPhySata2Rcvd: invalid port or aborted discovery!!!\n"));
1493 if (SataDevice == agNULL)
1495 DM_DBG1(("dmReportPhySata2Rcvd: SataDevice is NULL, wrong\n"));
1496 dmDiscoverAbort(dmRoot, onePortContext);
1500 if ( frameHeader->smpFunctionResult == PHY_VACANT )
1502 DM_DBG1(("dmReportPhySata2Rcvd: smpFunctionResult == PHY_VACANT, wrong\n"));
1506 if ( frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED )
1508 fis = (agsaFisRegDeviceToHost_t*) &SMPreportPhySataResp.regDevToHostFis;
1509 if (fis->h.fisType == REG_DEV_TO_HOST_FIS)
1511 /* save signature */
1512 DM_DBG3(("dmReportPhySata2Rcvd: saves the signature\n"));
1513 /* saves signature */
1514 SataDevice->satSignature[0] = fis->d.sectorCount;
1515 SataDevice->satSignature[1] = fis->d.lbaLow;
1516 SataDevice->satSignature[2] = fis->d.lbaMid;
1517 SataDevice->satSignature[3] = fis->d.lbaHigh;
1518 SataDevice->satSignature[4] = fis->d.device;
1519 SataDevice->satSignature[5] = 0;
1520 SataDevice->satSignature[6] = 0;
1521 SataDevice->satSignature[7] = 0;
1522 DM_DBG3(("dmReportPhySata2Rcvd: SATA Signature = %02x %02x %02x %02x %02x\n",
1523 SataDevice->satSignature[0],
1524 SataDevice->satSignature[1],
1525 SataDevice->satSignature[2],
1526 SataDevice->satSignature[3],
1527 SataDevice->satSignature[4]));
1528 sataDeviceType = tddmSATADeviceTypeDecode(SataDevice->satSignature);
1529 if( sataDeviceType == SATA_ATAPI_DEVICE)
1531 SataDevice->agDeviceInfo.flag |= ATAPI_DEVICE_FLAG;
1533 SataDevice->dmDeviceInfo.sataDeviceType = sataDeviceType;
1535 /* Handling DataDomain buggy FIS */
1536 else if (fis->h.error == REG_DEV_TO_HOST_FIS)
1538 /* needs to flip fis to host order */
1539 bit8fis = (bit8*)fis;
1542 a = DMA_LEBIT32_TO_BIT32(*(bit32*)bit8fis);
1543 DM_DBG3(("dmReportPhySata2Rcvd: a 0x%8x\n", a));
1544 bit8fisarray[4*i] = (a & 0xFF000000) >> 24;
1545 bit8fisarray[4*i+1] = (a & 0x00FF0000) >> 16;
1546 bit8fisarray[4*i+2] = (a & 0x0000FF00) >> 8;
1547 bit8fisarray[4*i+3] = (a & 0x000000FF);
1548 bit8fis = bit8fis + 4;
1550 fis = (agsaFisRegDeviceToHost_t*) bit8fisarray;
1551 /* save signature */
1552 DM_DBG3(("dmReportPhySata2Rcvd: DataDomain ATAPI saves the signature\n"));
1553 /* saves signature */
1554 SataDevice->satSignature[0] = fis->d.sectorCount;
1555 SataDevice->satSignature[1] = fis->d.lbaLow;
1556 SataDevice->satSignature[2] = fis->d.lbaMid;
1557 SataDevice->satSignature[3] = fis->d.lbaHigh;
1558 SataDevice->satSignature[4] = fis->d.device;
1559 SataDevice->satSignature[5] = 0;
1560 SataDevice->satSignature[6] = 0;
1561 SataDevice->satSignature[7] = 0;
1562 DM_DBG3(("dmReportPhySata2Rcvd: SATA Signature = %02x %02x %02x %02x %02x\n",
1563 SataDevice->satSignature[0],
1564 SataDevice->satSignature[1],
1565 SataDevice->satSignature[2],
1566 SataDevice->satSignature[3],
1567 SataDevice->satSignature[4]));
1569 sataDeviceType = tddmSATADeviceTypeDecode(SataDevice->satSignature);
1570 if( sataDeviceType == SATA_ATAPI_DEVICE)
1572 SataDevice->agDeviceInfo.flag |= ATAPI_DEVICE_FLAG;
1574 SataDevice->dmDeviceInfo.sataDeviceType = sataDeviceType;
1578 DM_DBG3(("dmReportPhySata2Rcvd: getting next stp bride\n"));
1581 /* Continue to report this STP device to TD*/
1582 if (SataDevice->ExpDevice != agNULL)
1584 tddmReportDevice(dmRoot, onePortContext->dmPortContext, &SataDevice->dmDeviceInfo, &SataDevice->ExpDevice->dmDeviceInfo, dmDeviceArrival);
1588 tddmReportDevice(dmRoot, onePortContext->dmPortContext, &SataDevice->dmDeviceInfo, agNULL, dmDeviceArrival);
1594 DM_DBG3(("dmReportPhySata2Rcvd: siReportPhySataRcvd SMP function return result %x\n",
1595 frameHeader->smpFunctionResult));
1596 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
1607 dmExpander_t *oneExpander,
1609 bit32 configSASAddressHi,
1610 bit32 configSASAddressLo
1613 dmIntRoot_t *dmIntRoot = (dmIntRoot_t *)dmRoot->dmData;
1614 dmIntContext_t *dmAllShared = (dmIntContext_t *)&dmIntRoot->dmAllShared;
1615 agsaRoot_t *agRoot = dmAllShared->agRoot;
1617 dmIntPortContext_t *onePortContext;
1618 smpReqConfigureRouteInformation_t confRoutingInfo;
1621 DM_DBG3(("dmRoutingEntryAdd: start\n"));
1622 DM_DBG3(("dmRoutingEntryAdd: exp addrHi 0x%08x\n", oneExpander->dmDevice->SASAddressID.sasAddressHi));
1623 DM_DBG3(("dmRoutingEntryAdd: exp addrLo 0x%08x\n", oneExpander->dmDevice->SASAddressID.sasAddressLo));
1624 DM_DBG3(("dmRoutingEntryAdd: phyid %d\n", phyId));
1626 if (oneExpander->dmDevice->SASAddressID.sasAddressHi == configSASAddressHi &&
1627 oneExpander->dmDevice->SASAddressID.sasAddressLo == configSASAddressLo
1630 DM_DBG3(("dmRoutingEntryAdd: unnecessary\n"));
1633 if (oneExpander->routingAttribute[phyId] != SAS_ROUTING_TABLE)
1635 DM_DBG3(("dmRoutingEntryAdd: not table routing, routing is %d\n", oneExpander->routingAttribute[phyId]));
1639 onePortContext = oneExpander->dmDevice->dmPortContext;
1641 onePortContext->discovery.status = DISCOVERY_CONFIG_ROUTING;
1643 /* reset smpReqConfigureRouteInformation_t */
1644 dm_memset(&confRoutingInfo, 0, sizeof(smpReqConfigureRouteInformation_t));
1645 if ( oneExpander->currentIndex[phyId] < oneExpander->routingIndex )
1647 DM_DBG3(("dmRoutingEntryAdd: adding sasAddressHi 0x%08x\n", configSASAddressHi));
1648 DM_DBG3(("dmRoutingEntryAdd: adding sasAddressLo 0x%08x\n", configSASAddressLo));
1649 DM_DBG3(("dmRoutingEntryAdd: phyid %d currentIndex[phyid] %d\n", phyId, oneExpander->currentIndex[phyId]));
1651 oneExpander->configSASAddressHi = configSASAddressHi;
1652 oneExpander->configSASAddressLo = configSASAddressLo;
1653 confRoutingInfo.reserved1[0] = 0;
1654 confRoutingInfo.reserved1[1] = 0;
1655 OSSA_WRITE_BE_16(agRoot, confRoutingInfo.expanderRouteIndex, 0, (oneExpander->currentIndex[phyId]));
1656 confRoutingInfo.reserved2 = 0;
1657 confRoutingInfo.phyIdentifier = (bit8)phyId;
1658 confRoutingInfo.reserved3[0] = 0;
1659 confRoutingInfo.reserved3[1] = 0;
1660 confRoutingInfo.disabledBit_reserved4 = 0;
1661 confRoutingInfo.reserved5[0] = 0;
1662 confRoutingInfo.reserved5[1] = 0;
1663 confRoutingInfo.reserved5[2] = 0;
1664 OSSA_WRITE_BE_32(agRoot, confRoutingInfo.routedSasAddressHi, 0, configSASAddressHi);
1665 OSSA_WRITE_BE_32(agRoot, confRoutingInfo.routedSasAddressLo, 0, configSASAddressLo);
1666 for ( i = 0; i < 16; i ++ )
1668 confRoutingInfo.reserved6[i] = 0;
1670 dmSMPStart(dmRoot, agRoot, oneExpander->dmDevice, SMP_CONFIGURE_ROUTING_INFORMATION, (bit8 *)&confRoutingInfo, sizeof(smpReqConfigureRouteInformation_t), AGSA_SMP_INIT_REQ);
1672 oneExpander->currentIndex[phyId] ++;
1676 DM_DBG3(("dmRoutingEntryAdd: Discovery Error routing index overflow for currentIndex=%d, routingIndex=%d\n", oneExpander->currentIndex[phyId], oneExpander->routingIndex));
1677 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
1686 dmConfigRoutingInfoRespRcvd(
1689 agsaIORequest_t *agIORequest,
1690 dmDeviceData_t *oneDeviceData,
1691 dmSMPFrameHeader_t *frameHeader,
1692 agsaFrameHandle_t frameHandle
1695 dmIntPortContext_t *onePortContext;
1696 dmExpander_t *oneExpander = oneDeviceData->dmExpander;
1697 dmExpander_t *UpStreamExpander;
1698 dmExpander_t *DownStreamExpander;
1699 dmExpander_t *ReturningExpander;
1700 dmExpander_t *ConfigurableExpander;
1701 dmDeviceData_t *ReturningExpanderDeviceData = agNULL;
1702 bit32 dupConfigSASAddr = agFALSE;
1705 DM_DBG3(("dmConfigRoutingInfoRespRcvd: start\n"));
1706 DM_DBG3(("dmConfigRoutingInfoRespRcvd: exp addrHi 0x%08x\n", oneExpander->dmDevice->SASAddressID.sasAddressHi));
1707 DM_DBG3(("dmConfigRoutingInfoRespRcvd: exp addrLo 0x%08x\n", oneExpander->dmDevice->SASAddressID.sasAddressLo));
1709 onePortContext = oneDeviceData->dmPortContext;
1711 if (dmDiscoverCheck(dmRoot, onePortContext) == agTRUE)
1713 DM_DBG1(("dmConfigRoutingInfoRespRcvd: invalid port or aborted discovery!!!\n"));
1717 if ( frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED ||
1718 frameHeader->smpFunctionResult == PHY_VACANT
1721 DownStreamExpander = oneExpander->dmCurrentDownStreamExpander;
1722 if (DownStreamExpander != agNULL)
1724 DownStreamExpander->currentUpStreamPhyIndex ++;
1725 DM_DBG3(("dmConfigRoutingInfoRespRcvd: DownStreamExpander->currentUpStreamPhyIndex %d\n", DownStreamExpander->currentUpStreamPhyIndex));
1726 DM_DBG3(("dmConfigRoutingInfoRespRcvd: DownStreamExpander->numOfUpStreamPhys %d\n", DownStreamExpander->numOfUpStreamPhys));
1727 DM_DBG3(("dmConfigRoutingInfoRespRcvd: DownStreamExpander addrHi 0x%08x\n", DownStreamExpander->dmDevice->SASAddressID.sasAddressHi));
1728 DM_DBG3(("dmConfigRoutingInfoRespRcvd: DownStreamExpander addrLo 0x%08x\n", DownStreamExpander->dmDevice->SASAddressID.sasAddressLo));
1732 oneExpander->currentDownStreamPhyIndex++;
1733 DM_DBG3(("dmConfigRoutingInfoRespRcvd: oneExpander->currentDownStreamPhyIndex %d oneExpander->numOfDownStreamPhys %d\n", oneExpander->currentDownStreamPhyIndex, oneExpander->numOfDownStreamPhys));
1735 if ( (DownStreamExpander != agNULL) &&
1736 (DownStreamExpander->currentUpStreamPhyIndex < DownStreamExpander->numOfUpStreamPhys)
1739 DM_DBG3(("dmConfigRoutingInfoRespRcvd: first if\n"));
1740 DM_DBG3(("dmConfigRoutingInfoRespRcvd: DownStreamExpander->currentUpStreamPhyIndex %d\n", DownStreamExpander->currentUpStreamPhyIndex));
1742 DM_DBG3(("dmConfigRoutingInfoRespRcvd: DownStreamExpander->upStreamPhys[] %d\n", DownStreamExpander->upStreamPhys[DownStreamExpander->currentUpStreamPhyIndex]));
1744 dmRoutingEntryAdd(dmRoot,
1746 DownStreamExpander->upStreamPhys[DownStreamExpander->currentUpStreamPhyIndex],
1747 oneExpander->configSASAddressHi,
1748 oneExpander->configSASAddressLo
1753 /* traversing up till discovery Root onePortContext->discovery.RootExp */
1754 DM_DBG3(("dmConfigRoutingInfoRespRcvd: else\n"));
1756 UpStreamExpander = oneExpander->dmUpStreamExpander;
1757 ConfigurableExpander = dmFindConfigurableExp(dmRoot, onePortContext, oneExpander);
1758 if (UpStreamExpander != agNULL)
1760 DM_DBG3(("dmConfigRoutingInfoRespRcvd: UpStreamExpander addrHi 0x%08x\n", UpStreamExpander->dmDevice->SASAddressID.sasAddressHi));
1761 DM_DBG3(("dmConfigRoutingInfoRespRcvd: UpStreamExpander addrLo 0x%08x\n", UpStreamExpander->dmDevice->SASAddressID.sasAddressLo));
1765 DM_DBG3(("dmConfigRoutingInfoRespRcvd: UpStreamExpander is NULL\n"));
1767 dupConfigSASAddr = dmDuplicateConfigSASAddr(dmRoot,
1768 ConfigurableExpander,
1769 oneExpander->configSASAddressHi,
1770 oneExpander->configSASAddressLo
1773 if ( ConfigurableExpander != agNULL && dupConfigSASAddr == agFALSE)
1775 DM_DBG3(("dmConfigRoutingInfoRespRcvd: else if\n"));
1777 DM_DBG3(("dmConfigRoutingInfoRespRcvd: ConfigurableExpander addrHi 0x%08x\n", ConfigurableExpander->dmDevice->SASAddressID.sasAddressHi));
1778 DM_DBG3(("dmConfigRoutingInfoRespRcvd: ConfigurableExpander addrLo 0x%08x\n", ConfigurableExpander->dmDevice->SASAddressID.sasAddressLo));
1780 if ( UpStreamExpander != agNULL)
1782 UpStreamExpander->dmCurrentDownStreamExpander = oneExpander;
1784 ConfigurableExpander->currentDownStreamPhyIndex =
1785 dmFindCurrentDownStreamPhyIndex(dmRoot, ConfigurableExpander);
1786 ConfigurableExpander->dmReturnginExpander = oneExpander->dmReturnginExpander;
1787 if ( DownStreamExpander != agNULL)
1789 DownStreamExpander->currentUpStreamPhyIndex = 0;
1791 DM_DBG3(("dmConfigRoutingInfoRespRcvd: ConfigurableExpander->currentDownStreamPhyIndex %d\n", ConfigurableExpander->currentDownStreamPhyIndex));
1793 DM_DBG3(("dmConfigRoutingInfoRespRcvd: ConfigurableExpander->downStreamPhys[] %d\n", ConfigurableExpander->downStreamPhys[ConfigurableExpander->currentDownStreamPhyIndex]));
1794 dmRoutingEntryAdd(dmRoot,
1795 ConfigurableExpander,
1796 ConfigurableExpander->downStreamPhys[ConfigurableExpander->currentDownStreamPhyIndex],
1797 oneExpander->configSASAddressHi,
1798 oneExpander->configSASAddressLo
1803 /* going back to where it was */
1804 /* ConfigRoutingInfo is done for a target */
1805 DM_DBG3(("dmConfigRoutingInfoRespRcvd: $$$$$$ my change $$$$$ \n"));
1806 ReturningExpander = oneExpander->dmReturnginExpander;
1807 if ( DownStreamExpander != agNULL)
1809 DownStreamExpander->currentUpStreamPhyIndex = 0;
1812 if (ReturningExpander != agNULL)
1814 DM_DBG3(("dmConfigRoutingInfoRespRcvd: ReturningExpander addrHi 0x%08x\n", ReturningExpander->dmDevice->SASAddressID.sasAddressHi));
1815 DM_DBG3(("dmConfigRoutingInfoRespRcvd: ReturningExpander addrLo 0x%08x\n", ReturningExpander->dmDevice->SASAddressID.sasAddressLo));
1816 ReturningExpanderDeviceData = ReturningExpander->dmDevice;
1819 /* No longer in DISCOVERY_CONFIG_ROUTING */
1820 onePortContext->discovery.status = DISCOVERY_DOWN_STREAM;
1822 if (ReturningExpander != agNULL && ReturningExpanderDeviceData != agNULL)
1824 /* If not the last phy */
1825 if ( ReturningExpander->discoveringPhyId < ReturningExpanderDeviceData->numOfPhys )
1827 DM_DBG3(("dmConfigRoutingInfoRespRcvd: More Phys to discover\n"));
1828 /* continue discovery for the next phy */
1829 /* needs to send only one Discovery not multiple times */
1830 if (ReturningExpander->discoverSMPAllowed == agTRUE)
1832 dmDiscoverSend(dmRoot, ReturningExpanderDeviceData);
1834 if (ReturningExpander != agNULL)
1836 ReturningExpander->discoverSMPAllowed = agFALSE;
1839 /* If the last phy */
1842 DM_DBG3(("dmConfigRoutingInfoRespRcvd: No More Phys\n"));
1843 ReturningExpander->discoverSMPAllowed = agTRUE;
1845 /* remove the expander from the discovering list */
1846 dmDiscoveringExpanderRemove(dmRoot, onePortContext, ReturningExpander);
1847 /* continue downstream discovering */
1848 dmDownStreamDiscovering(dmRoot, onePortContext, ReturningExpanderDeviceData);
1850 //DownStreamExpander
1858 DM_DBG1(("dmConfigRoutingInfoRespRcvd: Discovery Error SMP function return result error=0x%x !!!\n", frameHeader->smpFunctionResult));
1859 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
1865 dmConfigRoutingInfo2RespRcvd(
1868 agsaIORequest_t *agIORequest,
1869 dmDeviceData_t *oneDeviceData,
1870 dmSMPFrameHeader_t *frameHeader,
1871 agsaFrameHandle_t frameHandle
1874 dmExpander_t *oneExpander = oneDeviceData->dmExpander;
1875 dmExpander_t *UpStreamExpander;
1876 dmExpander_t *DownStreamExpander;
1877 dmExpander_t *ReturningExpander;
1878 dmExpander_t *ConfigurableExpander;
1880 dmIntPortContext_t *onePortContext;
1881 dmDeviceData_t *ReturningExpanderDeviceData = agNULL;
1882 bit32 dupConfigSASAddr = agFALSE;
1884 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: start\n"));
1885 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: exp addrHi 0x%08x\n", oneExpander->dmDevice->SASAddressID.sasAddressHi));
1886 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: exp addrLo 0x%08x\n", oneExpander->dmDevice->SASAddressID.sasAddressLo));
1888 onePortContext = oneDeviceData->dmPortContext;
1890 if (dmDiscoverCheck(dmRoot, onePortContext) == agTRUE)
1892 DM_DBG1(("dmConfigRoutingInfo2RespRcvd: invalid port or aborted discovery!!!\n"));
1896 if (frameHeader->smpFunctionResult == PHY_VACANT)
1898 DM_DBG1(("dmConfigRoutingInfo2RespRcvd: smpFunctionResult is PHY_VACANT\n"));
1901 if ( frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED ||
1902 frameHeader->smpFunctionResult == PHY_VACANT
1905 DownStreamExpander = oneExpander->dmCurrentDownStreamExpander;
1906 if (DownStreamExpander != agNULL)
1908 DownStreamExpander->currentUpStreamPhyIndex ++;
1909 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: DownStreamExpander->currentUpStreamPhyIndex %d\n", DownStreamExpander->currentUpStreamPhyIndex));
1910 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: DownStreamExpander->numOfUpStreamPhys %d\n", DownStreamExpander->numOfUpStreamPhys));
1911 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: DownStreamExpander addrHi 0x%08x\n", DownStreamExpander->dmDevice->SASAddressID.sasAddressHi));
1912 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: DownStreamExpander addrLo 0x%08x\n", DownStreamExpander->dmDevice->SASAddressID.sasAddressLo));
1916 oneExpander->currentDownStreamPhyIndex++;
1917 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: oneExpander->currentDownStreamPhyIndex %d oneExpander->numOfDownStreamPhys %d\n", oneExpander->currentDownStreamPhyIndex, oneExpander->numOfDownStreamPhys));
1919 if ( (DownStreamExpander != agNULL) &&
1920 (DownStreamExpander->currentUpStreamPhyIndex < DownStreamExpander->numOfUpStreamPhys)
1923 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: first if\n"));
1924 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: DownStreamExpander->currentUpStreamPhyIndex %d\n", DownStreamExpander->currentUpStreamPhyIndex));
1926 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: DownStreamExpander->upStreamPhys[] %d\n", DownStreamExpander->upStreamPhys[DownStreamExpander->currentUpStreamPhyIndex]));
1928 dmRoutingEntryAdd(dmRoot,
1930 DownStreamExpander->upStreamPhys[DownStreamExpander->currentUpStreamPhyIndex],
1931 oneExpander->configSASAddressHi,
1932 oneExpander->configSASAddressLo
1937 /* traversing up till discovery Root onePortContext->discovery.RootExp */
1938 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: else\n"));
1940 UpStreamExpander = oneExpander->dmUpStreamExpander;
1941 ConfigurableExpander = dmFindConfigurableExp(dmRoot, onePortContext, oneExpander);
1942 if (UpStreamExpander != agNULL)
1944 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: UpStreamExpander addrHi 0x%08x\n", UpStreamExpander->dmDevice->SASAddressID.sasAddressHi));
1945 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: UpStreamExpander addrLo 0x%08x\n", UpStreamExpander->dmDevice->SASAddressID.sasAddressLo));
1949 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: UpStreamExpander is NULL\n"));
1951 dupConfigSASAddr = dmDuplicateConfigSASAddr(dmRoot,
1952 ConfigurableExpander,
1953 oneExpander->configSASAddressHi,
1954 oneExpander->configSASAddressLo
1957 if ( ConfigurableExpander != agNULL && dupConfigSASAddr == agFALSE)
1959 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: else if\n"));
1961 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: ConfigurableExpander addrHi 0x%08x\n", ConfigurableExpander->dmDevice->SASAddressID.sasAddressHi));
1962 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: ConfigurableExpander addrLo 0x%08x\n", ConfigurableExpander->dmDevice->SASAddressID.sasAddressLo));
1964 if ( UpStreamExpander != agNULL)
1966 UpStreamExpander->dmCurrentDownStreamExpander = oneExpander;
1968 ConfigurableExpander->currentDownStreamPhyIndex =
1969 dmFindCurrentDownStreamPhyIndex(dmRoot, ConfigurableExpander);
1970 ConfigurableExpander->dmReturnginExpander = oneExpander->dmReturnginExpander;
1971 if ( DownStreamExpander != agNULL)
1973 DownStreamExpander->currentUpStreamPhyIndex = 0;
1975 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: ConfigurableExpander->currentDownStreamPhyIndex %d\n", ConfigurableExpander->currentDownStreamPhyIndex));
1977 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: ConfigurableExpander->downStreamPhys[] %d\n", ConfigurableExpander->downStreamPhys[ConfigurableExpander->currentDownStreamPhyIndex]));
1978 dmRoutingEntryAdd(dmRoot,
1979 ConfigurableExpander,
1980 ConfigurableExpander->downStreamPhys[ConfigurableExpander->currentDownStreamPhyIndex],
1981 oneExpander->configSASAddressHi,
1982 oneExpander->configSASAddressLo
1987 /* going back to where it was */
1988 /* ConfigRoutingInfo is done for a target */
1989 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: $$$$$$ my change $$$$$ \n"));
1990 ReturningExpander = oneExpander->dmReturnginExpander;
1991 if ( DownStreamExpander != agNULL)
1993 DownStreamExpander->currentUpStreamPhyIndex = 0;
1996 if (ReturningExpander != agNULL)
1998 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: ReturningExpander addrHi 0x%08x\n", ReturningExpander->dmDevice->SASAddressID.sasAddressHi));
1999 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: ReturningExpander addrLo 0x%08x\n", ReturningExpander->dmDevice->SASAddressID.sasAddressLo));
2000 ReturningExpanderDeviceData = ReturningExpander->dmDevice;
2003 /* No longer in DISCOVERY_CONFIG_ROUTING */
2004 onePortContext->discovery.status = DISCOVERY_DOWN_STREAM;
2006 if (ReturningExpander != agNULL && ReturningExpanderDeviceData != agNULL)
2008 /* If not the last phy */
2009 if ( ReturningExpander->discoveringPhyId < ReturningExpanderDeviceData->numOfPhys )
2011 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: More Phys to discover\n"));
2012 /* continue discovery for the next phy */
2013 /* needs to send only one Discovery not multiple times */
2014 if (ReturningExpander->discoverSMPAllowed == agTRUE)
2016 dmDiscoverSend(dmRoot, ReturningExpanderDeviceData);
2018 if (ReturningExpander != agNULL)
2020 ReturningExpander->discoverSMPAllowed = agFALSE;
2023 /* If the last phy */
2026 DM_DBG2(("dmConfigRoutingInfo2RespRcvd: No More Phys\n"));
2027 ReturningExpander->discoverSMPAllowed = agTRUE;
2029 /* remove the expander from the discovering list */
2030 dmDiscoveringExpanderRemove(dmRoot, onePortContext, ReturningExpander);
2031 /* continue downstream discovering */
2032 dmDownStreamDiscovering(dmRoot, onePortContext, ReturningExpanderDeviceData);
2034 //DownStreamExpander
2042 DM_DBG1(("dmConfigRoutingInfo2RespRcvd: Discovery Error SMP function return result error=0x%x!!!\n", frameHeader->smpFunctionResult));
2043 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
2049 /* no task management case here for phyControl*/
2051 /* no task management case here for phyControl*/
2053 dmPhyControlRespRcvd(
2056 agsaIORequest_t *agIORequest,
2057 dmDeviceData_t *oneDeviceData,
2058 dmSMPFrameHeader_t *frameHeader,
2059 agsaFrameHandle_t frameHandle
2062 DM_DBG3(("dmPhyControlRespRcvd: start\n"));
2063 DM_DBG3(("dmPhyControlRespRcvd: expander device AddrHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
2064 DM_DBG3(("dmPhyControlRespRcvd: expander device AddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
2066 if (frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
2068 DM_DBG3(("dmPhyControlRespRcvd: SMP success\n"));
2072 DM_DBG1(("dmPhyControlRespRcvd: SMP failure; result 0x%x !!!\n", frameHeader->smpFunctionResult));
2078 /* no task management case here for phyControl*/
2080 dmPhyControl2RespRcvd(
2083 agsaIORequest_t *agIORequest,
2084 dmDeviceData_t *oneDeviceData,
2085 dmSMPFrameHeader_t *frameHeader,
2086 agsaFrameHandle_t frameHandle
2089 DM_DBG2(("dmPhyControl2RespRcvd: start\n"));
2090 DM_DBG2(("dmPhyControl2RespRcvd: expander device AddrHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
2091 DM_DBG2(("dmPhyControl2RespRcvd: expander device AddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
2093 if (frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
2095 DM_DBG2(("dmPhyControl2RespRcvd: SMP success\n"));
2099 DM_DBG1(("dmPhyControl2RespRcvd: SMP failure; result 0x%x !!!\n", frameHeader->smpFunctionResult));
2106 dmPhyControlFailureRespRcvd(
2109 dmDeviceData_t *oneDeviceData,
2110 dmSMPFrameHeader_t *frameHeader,
2111 agsaFrameHandle_t frameHandle
2114 DM_DBG1(("dmPhyControlFailureRespRcvd: start\n"));
2118 GLOBAL void dmSetDeviceInfoCB(
2120 agsaContext_t *agContext,
2121 agsaDevHandle_t *agDevHandle,
2127 dmRoot_t *dmRoot = agNULL;
2128 agsaIORequest_t *agIORequest;
2130 agsaSASRequestBody_t *agSASRequestBody;
2131 dmSMPRequestBody_t *dmSMPRequestBody = agNULL;
2132 dmIntPortContext_t *onePortContext = agNULL;
2133 dmDeviceData_t *oneDeviceData;
2134 bit8 SMPRequestFunction;
2135 bit8 devType_S_Rate;
2136 DM_DBG1(("dmSetDeviceInfoCB: start\n"));
2137 DM_DBG4(("dmSetDeviceInfoCB: status 0x%x\n", status));
2138 DM_DBG4(("dmSetDeviceInfoCB: option 0x%x\n", option));
2139 DM_DBG4(("dmSetDeviceInfoCB: param 0x%x\n", param));
2140 if (status != OSSA_SUCCESS)
2142 DM_DBG1(("dmSetDeviceInfoCB: status %d\n", status));
2143 DM_DBG1(("dmSetDeviceInfoCB: option 0x%x\n", option));
2144 DM_DBG1(("dmSetDeviceInfoCB: param 0x%x\n", param));
2145 if (option == 32) /* set connection rate */
2147 DM_DBG1(("dmSetDeviceInfoCB: IO failure\n"));
2148 agIORequest = (agsaIORequest_t *)agContext->osData;
2149 dmSMPRequestBody = (dmSMPRequestBody_t *)agIORequest->osData;
2150 dmRoot = dmSMPRequestBody->dmRoot;
2151 oneDeviceData = dmSMPRequestBody->dmDevice;
2152 onePortContext = oneDeviceData->dmPortContext;
2153 SMPRequestFunction = dmSMPRequestBody->smpPayload[1];
2154 if (SMPRequestFunction == SMP_REPORT_GENERAL ||
2155 SMPRequestFunction == SMP_DISCOVER ||
2156 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
2157 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
2160 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
2162 else if (SMPRequestFunction == SMP_PHY_CONTROL)
2164 /* task management failure */
2165 dmPhyControlFailureRespRcvd(
2175 if (agDevHandle == agNULL)
2177 DM_DBG1(("dmSetDeviceInfoCB: agDevHandle is NULL\n"));
2182 if (option == 32) /* set connection rate */
2184 DM_DBG1(("dmSetDeviceInfoCB: set connection rate option\n"));
2185 agIORequest = (agsaIORequest_t *)agContext->osData;
2186 dmSMPRequestBody = (dmSMPRequestBody_t *)agIORequest->osData;
2187 dmRoot = dmSMPRequestBody->dmRoot;
2188 agSASRequestBody = &(dmSMPRequestBody->agSASRequestBody);
2189 oneDeviceData = dmSMPRequestBody->dmDevice;
2190 onePortContext = oneDeviceData->dmPortContext;
2191 devType_S_Rate = oneDeviceData->agDeviceInfo.devType_S_Rate;
2192 devType_S_Rate = (devType_S_Rate & 0xF0) | (param >> 28);
2193 oneDeviceData->agDeviceInfo.devType_S_Rate = devType_S_Rate;
2194 SMPRequestFunction = dmSMPRequestBody->smpPayload[1];
2195 DM_DBG1(("dmSetDeviceInfoCB: SMPRequestFunction 0x%x\n", SMPRequestFunction));
2196 DM_DBG1(("dmSetDeviceInfoCB: new rate is 0x%x\n", DEVINFO_GET_LINKRATE(&oneDeviceData->agDeviceInfo)));
2197 smstatus = saSMPStart(
2206 if (status == AGSA_RC_SUCCESS)
2208 /* increment the number of pending SMP */
2209 onePortContext->discovery.pendingSMP++;
2210 // dmSMPRequestBody->retries++;
2211 if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
2212 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
2213 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
2216 /* start discovery-related SMP timer */
2217 dmDiscoverySMPTimer(dmRoot, onePortContext, (bit32)SMPRequestFunction, dmSMPRequestBody);
2221 else if (status == AGSA_RC_BUSY)
2223 onePortContext->discovery.pendingSMP++;
2224 // dmSMPRequestBody->retries++;
2225 if (SMPRequestFunction == SMP_REPORT_GENERAL ||
2226 SMPRequestFunction == SMP_DISCOVER ||
2227 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
2228 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
2231 dmSMPBusyTimer(dmRoot, onePortContext, oneDeviceData, dmSMPRequestBody);
2233 else if (SMPRequestFunction == SMP_PHY_CONTROL)
2235 /* For taskmanagement SMP, let's fail task management failure */
2236 dmPhyControlFailureRespRcvd(
2248 else /* AGSA_RC_FAILURE */
2250 if (SMPRequestFunction == SMP_REPORT_GENERAL ||
2251 SMPRequestFunction == SMP_DISCOVER ||
2252 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
2253 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
2256 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
2258 else if (SMPRequestFunction == SMP_PHY_CONTROL)
2260 /* task management failure */
2261 dmPhyControlFailureRespRcvd(
2276 /* smp completion */
2280 agsaIORequest_t *agIORequest,
2283 agsaFrameHandle_t agFrameHandle
2286 dmIntRoot_t *dmIntRoot = agNULL;
2287 dmIntContext_t *dmAllShared = agNULL;
2288 dmSMPRequestBody_t *dmSMPRequestBody = agNULL;
2289 agsaSMPFrame_t *agSMPFrame;
2290 dmRoot_t *dmRoot = agNULL;
2291 dmIntPortContext_t *onePortContext = agNULL;
2292 dmIntPortContext_t *oldonePortContext;
2293 dmExpander_t *oneExpander = agNULL;
2294 dmDeviceData_t *oneDeviceData;
2295 agsaDevHandle_t *agDevHandle = agNULL;
2296 agsaSASRequestBody_t *agSASRequestBody;
2298 bit8 SMPRequestFunction;
2299 dmSMPFrameHeader_t *dmResponseSMPFrameHeader;
2300 dmSMPFrameHeader_t *dmSMPFrameHeader;
2302 smpReqPhyControl_t *smpPhyControlReq;
2303 smpReqPhyControl2_t *smpPhyControl2Req;
2305 dmSMPRequestBody_t *dmSMPResponseBody = agNULL;
2306 dmSMPFrameHeader_t *dmRequestSMPFrameHeader;
2307 bit8 smpRequestHeader[4];
2310 bit32 ConnRate = SAS_CONNECTION_RATE_12_0G;
2311 agsaContext_t *agContext = agNULL;
2313 DM_DBG3(("dmSMPCompleted: start\n"));
2315 dmSMPRequestBody = (dmSMPRequestBody_t *)agIORequest->osData;
2317 dmRoot = dmSMPRequestBody->dmRoot;
2318 dmIntRoot = (dmIntRoot_t *)dmRoot->dmData;
2319 dmAllShared = (dmIntContext_t *)&dmIntRoot->dmAllShared;
2321 oneDeviceData = dmSMPRequestBody->dmDevice;
2322 agSASRequestBody = &(dmSMPRequestBody->agSASRequestBody);
2323 agSMPFrame = &(agSASRequestBody->smpFrame);
2325 if (oneDeviceData->valid == agFALSE &&
2326 oneDeviceData->valid2 == agFALSE &&
2327 oneDeviceData->dmPortContext == agNULL &&
2328 dmSMPRequestBody->dmPortContext->valid == agFALSE
2331 DM_DBG3(("dmSMPCompleted: port has been destroyed\n"));
2332 /* all device, port information have been reset
2333 just put smp to freeList
2336 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2337 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
2338 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2342 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
2343 if (dmSMPResponseBody == agNULL)
2345 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
2348 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2349 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
2350 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2355 onePortContext = oneDeviceData->dmPortContext;
2356 oneExpander = oneDeviceData->dmExpander;
2357 agDevHandle = oneExpander->agDevHandle;
2361 SMPRequestFunction = dmSMPRequestBody->smpPayload[1];
2363 saFrameReadBlock(agRoot, dmSMPRequestBody->IndirectSMP, 0, smpRequestHeader, 4);
2364 dmRequestSMPFrameHeader = (dmSMPFrameHeader_t *)smpRequestHeader;
2365 SMPRequestFunction = dmRequestSMPFrameHeader->smpFunction;
2369 /* for debugging; dump SMP request payload */
2370 dmhexdump("smp payload",
2371 (bit8 *)agSASRequestBody->smpFrame.outFrameBuf,
2372 agSASRequestBody->smpFrame.outFrameLen
2374 dmhexdump("smp payload new",
2375 (bit8 *)dmSMPRequestBody->smpPayload,
2376 agSASRequestBody->smpFrame.outFrameLen
2381 if (onePortContext != agNULL)
2383 DM_DBG5(("dmSMPCompleted: pid %d\n", onePortContext->id));
2387 DM_DBG1(("dmSMPCompleted: Wrong, onePortContext is NULL!!!\n"));
2389 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2390 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
2391 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2395 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
2396 if (dmSMPResponseBody == agNULL)
2398 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
2401 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2402 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
2403 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2408 oldonePortContext = dmSMPRequestBody->dmPortContext;
2409 if (oldonePortContext != agNULL)
2411 DM_DBG5(("dmSMPCompleted: old pid %d\n", oldonePortContext->id));
2415 DM_DBG1(("dmSMPCompleted: Wrong, oldonePortContext is NULL!!!\n"));
2417 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2418 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
2419 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2423 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
2424 if (dmSMPResponseBody == agNULL)
2426 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
2429 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2430 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
2431 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2436 /* decrement the number of pending SMP */
2437 onePortContext->discovery.pendingSMP--;
2440 /* for port invalid case;
2441 full discovery -> full discovery; incremental discovery -> full discovery
2443 if (onePortContext != oldonePortContext)
2445 DM_DBG1(("dmSMPCompleted: portcontext has changed!!!\n"));
2446 if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
2447 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
2448 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
2451 /* stop SMP timer */
2452 tddmSingleThreadedEnter(dmRoot, DM_TIMER_LOCK);
2453 if (onePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
2455 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2458 &(onePortContext->discovery.DiscoverySMPTimer)
2463 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2466 tddmSingleThreadedEnter(dmRoot, DM_TIMER_LOCK);
2467 if (oldonePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
2469 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2472 &(oldonePortContext->discovery.DiscoverySMPTimer)
2477 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2480 /* clean up expanders data strucures; move to free exp when device is cleaned */
2481 dmCleanAllExp(dmRoot, oldonePortContext);
2482 /* remove devices */
2483 dmInternalRemovals(dmRoot, oldonePortContext);
2486 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2487 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
2488 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2492 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
2493 if (dmSMPResponseBody == agNULL)
2495 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
2498 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2499 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
2500 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2507 if (onePortContext->valid == agFALSE ||
2508 onePortContext->DiscoveryState == DM_DSTATE_COMPLETED ||
2509 onePortContext->discovery.status == DISCOVERY_SAS_DONE ||
2510 onePortContext->DiscoveryAbortInProgress == agTRUE
2513 if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
2514 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
2515 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
2518 /* stop SMP timer */
2519 tddmSingleThreadedEnter(dmRoot, DM_TIMER_LOCK);
2520 if (onePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
2522 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2525 &(onePortContext->discovery.DiscoverySMPTimer)
2530 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2535 tddmSingleThreadedEnter(dmRoot, DM_TIMER_LOCK);
2536 if (oldonePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
2538 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2541 &(oldonePortContext->discovery.DiscoverySMPTimer)
2546 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2551 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2552 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
2553 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2557 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
2558 if (dmSMPResponseBody == agNULL)
2560 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
2563 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2564 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
2565 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2568 if (onePortContext->discovery.pendingSMP == 0)
2570 DM_DBG1(("dmSMPCompleted: aborting discovery\n"));
2571 if (onePortContext->DiscoveryState == DM_DSTATE_COMPLETED ||
2572 onePortContext->discovery.status == DISCOVERY_SAS_DONE ||
2573 onePortContext->DiscoveryAbortInProgress == agTRUE
2576 onePortContext->DiscoveryAbortInProgress = agFALSE;
2577 onePortContext->DiscoveryState = DM_DSTATE_COMPLETED;
2578 onePortContext->discovery.status = DISCOVERY_SAS_DONE;
2579 dmCleanAllExp(dmRoot, onePortContext);
2580 if ( onePortContext->DiscoveryAbortInProgress == agTRUE)
2584 onePortContext->dmPortContext,
2592 DM_DBG3(("dmSMPCompleted: not yet abort; non zero pendingSMP %d\n", onePortContext->discovery.pendingSMP));
2597 if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
2598 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
2599 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
2602 /* stop SMP timer */
2603 tddmSingleThreadedEnter(dmRoot, DM_TIMER_LOCK);
2604 if (onePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
2606 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2609 &(onePortContext->discovery.DiscoverySMPTimer)
2614 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2618 tddmSingleThreadedEnter(dmRoot, DM_TIMER_LOCK);
2619 if (oldonePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
2621 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2624 &(oldonePortContext->discovery.DiscoverySMPTimer)
2629 tddmSingleThreadedLeave(dmRoot, DM_TIMER_LOCK);
2633 if (oneExpander->SAS2 == 0)
2635 DM_DBG3(("dmSMPCompleted: SAS 1.1\n"));
2636 if (agIOStatus == OSSA_IO_SUCCESS)
2638 //tdhexdump("dmSMPCompleted", (bit8*)agFrameHandle, agIOInfoLen);
2639 /* parsing SMP payload */
2641 saFrameReadBlock(agRoot, agFrameHandle, 0, smpHeader, 4);
2643 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
2644 saFrameReadBlock(agRoot, dmSMPResponseBody->IndirectSMP, 0, smpHeader, 4);
2646 dmResponseSMPFrameHeader = (dmSMPFrameHeader_t *)smpHeader;
2648 /* SMP function dependent payload */
2649 switch (dmResponseSMPFrameHeader->smpFunction)
2651 case SMP_REPORT_GENERAL:
2652 DM_DBG3(("dmSMPCompleted: report general\n"));
2653 if (agIOInfoLen != sizeof(smpRespReportGeneral_t) + 4 &&
2654 dmResponseSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
2656 DM_DBG3(("dmSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, (unsigned int)sizeof(smpRespReportGeneral_t) + 4));
2657 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
2660 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2661 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
2662 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2666 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
2667 if (dmSMPResponseBody == agNULL)
2669 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
2672 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2673 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
2674 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2679 dmReportGeneralRespRcvd(
2684 dmResponseSMPFrameHeader,
2689 DM_DBG3(("dmSMPCompleted: discover\n"));
2690 if (agIOInfoLen != sizeof(smpRespDiscover_t) + 4 &&
2691 dmResponseSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
2693 DM_DBG3(("dmSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, (unsigned int)sizeof(smpRespDiscover_t) + 4));
2694 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
2696 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2697 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
2698 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2702 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
2703 if (dmSMPResponseBody == agNULL)
2705 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
2708 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2709 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
2710 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2719 dmResponseSMPFrameHeader,
2723 case SMP_REPORT_PHY_SATA:
2724 DM_DBG3(("dmSMPCompleted: report phy sata\n"));
2725 if (agIOInfoLen != sizeof(smpRespReportPhySata_t) + 4 &&
2726 dmResponseSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
2728 DM_DBG3(("dmSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, (unsigned int)sizeof(smpRespReportPhySata_t) + 4));
2729 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
2731 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2732 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
2733 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2737 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
2738 if (dmSMPResponseBody == agNULL)
2740 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
2743 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2744 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
2745 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2749 dmReportPhySataRcvd(
2754 dmResponseSMPFrameHeader,
2758 case SMP_CONFIGURE_ROUTING_INFORMATION:
2759 DM_DBG3(("dmSMPCompleted: configure routing information\n"));
2760 if (agIOInfoLen != 4 &&
2761 dmResponseSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
2763 DM_DBG3(("dmSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, 4));
2764 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
2766 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2767 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
2768 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2772 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
2773 if (dmSMPResponseBody == agNULL)
2775 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
2778 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2779 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
2780 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2784 dmConfigRoutingInfoRespRcvd(
2789 dmResponseSMPFrameHeader,
2794 case SMP_PHY_CONTROL:
2795 DM_DBG3(("dmSMPCompleted: phy control\n"));
2796 if (agIOInfoLen != 4 &&
2797 dmResponseSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED) /*zero length is expected */
2799 DM_DBG3(("dmSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, 4));
2800 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
2803 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2804 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
2805 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2809 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
2810 if (dmSMPResponseBody == agNULL)
2812 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
2815 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
2816 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
2817 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
2821 dmPhyControlRespRcvd(
2826 dmResponseSMPFrameHeader,
2830 case SMP_REPORT_ROUTING_INFORMATION: /* fall through */
2831 case SMP_REPORT_PHY_ERROR_LOG: /* fall through */
2832 case SMP_PHY_TEST_FUNCTION: /* fall through */
2833 case SMP_REPORT_MANUFACTURE_INFORMATION: /* fall through */
2834 case SMP_READ_GPIO_REGISTER: /* fall through */
2835 case SMP_WRITE_GPIO_REGISTER: /* fall through */
2837 DM_DBG1(("dmSMPCompleted: wrong SMP function 0x%x !!!\n", dmResponseSMPFrameHeader->smpFunction));
2838 DM_DBG1(("dmSMPCompleted: smpFrameType 0x%x !!!\n", dmResponseSMPFrameHeader->smpFrameType));
2839 DM_DBG1(("dmSMPCompleted: smpFunctionResult 0x%x !!!\n", dmResponseSMPFrameHeader->smpFunctionResult));
2840 DM_DBG1(("dmSMPCompleted: smpReserved 0x%x !!!\n", dmResponseSMPFrameHeader->smpReserved));
2841 dmhexdump("dmSMPCompleted: SMP payload !!!", (bit8 *)agFrameHandle, agIOInfoLen);
2844 } /* OSSA_IO_SUCCESS */
2845 else if (agIOStatus == OSSA_IO_ABORTED || agIOStatus == OSSA_IO_INVALID_LENGTH)
2847 /* no retry this case */
2848 DM_DBG1(("dmSMPCompleted: OSSA_IO_ABORTED or OSSA_IO_INVALID_LENGTH, status 0x%x\n", agIOStatus));
2850 else if (agIOStatus == OSSA_IO_ERROR_INTERNAL_SMP_RESOURCE)
2852 DM_DBG3(("dmSMPCompleted: OSSA_IO_ERROR_INTERNAL_SMP_RESOURCE\n"));
2853 saFrameReadBlock(agRoot, agFrameHandle, 0, smpHeader, 4);
2854 dmResponseSMPFrameHeader = (dmSMPFrameHeader_t *)smpHeader;
2856 status = saSMPStart(
2866 if (status == AGSA_RC_SUCCESS)
2868 /* increment the number of pending SMP */
2869 onePortContext->discovery.pendingSMP++;
2870 if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
2871 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
2872 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
2875 /* start discovery-related SMP timer */
2876 dmDiscoverySMPTimer(dmRoot, onePortContext, (bit32)(dmResponseSMPFrameHeader->smpFunction), dmSMPRequestBody);
2880 else if (status == AGSA_RC_BUSY)
2882 if (dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
2883 dmResponseSMPFrameHeader->smpFunction == SMP_DISCOVER ||
2884 dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
2885 dmResponseSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION
2888 dmSMPBusyTimer(dmRoot, onePortContext, oneDeviceData, dmSMPRequestBody);
2890 else if (dmResponseSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
2892 /* For taskmanagement SMP, let's fail task management failure */
2893 dmPhyControlFailureRespRcvd(
2897 dmResponseSMPFrameHeader,
2905 else /* AGSA_RC_FAILURE */
2907 if (dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
2908 dmResponseSMPFrameHeader->smpFunction == SMP_DISCOVER ||
2909 dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
2910 dmResponseSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION
2913 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
2915 else if (dmResponseSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
2917 /* task management failure */
2918 dmPhyControlFailureRespRcvd(
2922 dmResponseSMPFrameHeader,
2930 } /* OSSA_IO_ERROR_INTERNAL_SMP_RESOURCE*/
2933 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS ||
2934 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED ||
2935 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO ||
2936 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST ||
2937 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE ||
2938 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED ||
2939 agIOStatus == OSSA_IO_DS_NON_OPERATIONAL )
2941 DM_DBG1(("dmSMPCompleted: setting back to operational\n"));
2942 saSetDeviceState(agRoot, agNULL, 0, agDevHandle, SA_DS_OPERATIONAL);
2944 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED && dmAllShared->RateAdjust)
2946 DM_DBG1(("dmSMPCompleted: OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n"));
2947 DM_DBG1(("dmSMPCompleted: SMPRequestFunction 0x%x\n", SMPRequestFunction));
2948 ConnRate = DEVINFO_GET_LINKRATE(&oneDeviceData->agDeviceInfo);
2949 if (ConnRate == SAS_CONNECTION_RATE_1_5G)
2951 /* no retry; failure ??? */
2952 if (SMPRequestFunction == SMP_REPORT_GENERAL ||
2953 SMPRequestFunction == SMP_DISCOVER ||
2954 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
2955 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
2958 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
2960 else if (SMPRequestFunction == SMP_PHY_CONTROL)
2962 /* task management failure */
2963 dmPhyControlFailureRespRcvd(
2977 ConnRate = ConnRate - 1;
2979 agContext = &(dmSMPRequestBody->agContext);
2980 agContext->osData = agIORequest;
2981 saSetDeviceInfo(agRoot, agContext, 0, agDevHandle, 32, ConnRate << 28, dmSetDeviceInfoCB);
2985 if (dmSMPRequestBody->retries < SMP_RETRIES) /* 5 */
2987 /* retry the SMP again */
2988 DM_DBG1(("dmSMPCompleted: failed, but retries %d agIOStatus 0x%x %d agIOInfoLen %d !!!\n",
2989 dmSMPRequestBody->retries, agIOStatus, agIOStatus, agIOInfoLen));
2990 saFrameReadBlock(agRoot, agFrameHandle, 0, smpHeader, 4);
2991 dmResponseSMPFrameHeader = (dmSMPFrameHeader_t *)smpHeader;
2992 status = saSMPStart(
3001 if (status == AGSA_RC_SUCCESS)
3003 /* increment the number of pending SMP */
3004 onePortContext->discovery.pendingSMP++;
3005 dmSMPRequestBody->retries++;
3006 if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
3007 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
3008 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3011 /* start discovery-related SMP timer */
3012 dmDiscoverySMPTimer(dmRoot, onePortContext, (bit32)(dmResponseSMPFrameHeader->smpFunction), dmSMPRequestBody);
3016 else if (status == AGSA_RC_BUSY)
3018 onePortContext->discovery.pendingSMP++;
3019 dmSMPRequestBody->retries++;
3020 if (dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
3021 dmResponseSMPFrameHeader->smpFunction == SMP_DISCOVER ||
3022 dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
3023 dmResponseSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3026 dmSMPBusyTimer(dmRoot, onePortContext, oneDeviceData, dmSMPRequestBody);
3029 else if (dmResponseSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
3031 /* For taskmanagement SMP, let's fail task management failure */
3032 dmPhyControlFailureRespRcvd(
3036 dmResponseSMPFrameHeader,
3044 else /* AGSA_RC_FAILURE */
3046 if (dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
3047 dmResponseSMPFrameHeader->smpFunction == SMP_DISCOVER ||
3048 dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
3049 dmResponseSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3052 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3054 else if (dmResponseSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
3056 /* task management failure */
3057 dmPhyControlFailureRespRcvd(
3061 dmResponseSMPFrameHeader,
3072 dmSMPFrameHeader = (dmSMPFrameHeader_t *)agSMPFrame->outFrameBuf;
3073 dmSMPPayload = (bit8 *)agSMPFrame->outFrameBuf + 4;
3074 DM_DBG1(("dmSMPCompleted: failed. no more retry. agIOStatus 0x%x %d !!!\n", agIOStatus, agIOStatus));
3075 if (agIOStatus == OSSA_IO_DS_NON_OPERATIONAL)
3077 DM_DBG1(("dmSMPCompleted: failed, agIOStatus is OSSA_IO_DS_NON_OPERATIONAL!!!\n"));
3079 if (agIOStatus == OSSA_IO_DS_IN_RECOVERY)
3081 DM_DBG1(("dmSMPCompleted: failed, agIOStatus is OSSA_IO_DS_IN_RECOVERY!!!\n"));
3083 if (dmSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
3084 dmSMPFrameHeader->smpFunction == SMP_DISCOVER ||
3085 dmSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
3086 dmSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3089 /* discovery failure */
3090 DM_DBG1(("dmSMPCompleted: SMP function 0x%x\n", dmSMPFrameHeader->smpFunction));
3091 DM_DBG1(("dmSMPCompleted: discover done with error\n"));
3092 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3094 else if (dmSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
3096 DM_DBG3(("dmSMPCompleted: SMP_PHY_CONTROL\n"));
3097 smpPhyControlReq = (smpReqPhyControl_t *)dmSMPPayload;
3098 if (smpPhyControlReq->phyOperation == SMP_PHY_CONTROL_CLEAR_AFFILIATION)
3100 DM_DBG3(("dmSMPCompleted: discover done with error\n"));
3101 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3105 DM_DBG3(("dmSMPCompleted: unknown phy operation 0x%x\n", smpPhyControlReq->phyOperation));
3107 } /* SMP_PHY_CONTROL */
3110 DM_DBG3(("dmSMPCompleted: SMP function 0x%x\n", dmSMPFrameHeader->smpFunction));
3113 } /* for RateAdjust */
3116 /************************************ SAS 2 ***********************************************/
3119 DM_DBG2(("dmSMPCompleted: SAS 2\n"));
3120 if (agIOStatus == OSSA_IO_SUCCESS)
3122 //tdhexdump("dmSMPCompleted", (bit8*)agFrameHandle, agIOInfoLen);
3123 /* parsing SMP payload */
3125 saFrameReadBlock(agRoot, agFrameHandle, 0, smpHeader, 4);
3127 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
3128 saFrameReadBlock(agRoot, dmSMPResponseBody->IndirectSMP, 0, smpHeader, 4);
3130 dmResponseSMPFrameHeader = (dmSMPFrameHeader_t *)smpHeader;
3132 /* SMP function dependent payload */
3133 switch (dmResponseSMPFrameHeader->smpFunction)
3135 case SMP_REPORT_GENERAL:
3136 DM_DBG2(("dmSMPCompleted: report general\n"));
3137 if ((agIOInfoLen != sizeof(smpRespReportGeneral2_t) + 4) &&
3138 dmResponseSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED
3141 DM_DBG1(("dmSMPCompleted: report general mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, (int)sizeof(smpRespReportGeneral2_t) + 4));
3142 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3145 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3146 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
3147 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3151 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
3152 if (dmSMPResponseBody == agNULL)
3154 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
3157 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3158 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
3159 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3165 dmReportGeneral2RespRcvd(
3170 dmResponseSMPFrameHeader,
3175 DM_DBG2(("dmSMPCompleted: discover\n"));
3176 if ((agIOInfoLen != sizeof(smpRespDiscover2_t) + 4) &&
3177 dmResponseSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED
3180 DM_DBG1(("dmSMPCompleted: discover mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, (int)sizeof(smpRespDiscover2_t) + 4));
3181 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3184 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3185 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
3186 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3190 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
3191 if (dmSMPResponseBody == agNULL)
3193 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
3196 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3197 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
3198 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3203 dmDiscover2RespRcvd(
3208 dmResponseSMPFrameHeader,
3212 case SMP_REPORT_PHY_SATA:
3213 DM_DBG2(("dmSMPCompleted: report phy sata\n"));
3214 if ((agIOInfoLen != sizeof(smpRespReportPhySata2_t) + 4) &&
3215 dmResponseSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED
3218 DM_DBG1(("dmSMPCompleted: report phy sata mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, (int)sizeof(smpRespReportPhySata2_t) + 4));
3219 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3222 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3223 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
3224 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3228 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
3229 if (dmSMPResponseBody == agNULL)
3231 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
3234 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3235 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
3236 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3241 dmReportPhySata2Rcvd(
3246 dmResponseSMPFrameHeader,
3250 case SMP_CONFIGURE_ROUTING_INFORMATION:
3251 DM_DBG2(("dmSMPCompleted: configure routing information\n"));
3252 if (agIOInfoLen != 4 &&
3253 dmResponseSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED
3256 DM_DBG1(("dmSMPCompleted: configure routing information mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, 4));
3257 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3260 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3261 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
3262 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3266 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
3267 if (dmSMPResponseBody == agNULL)
3269 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
3272 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3273 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
3274 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3279 dmConfigRoutingInfo2RespRcvd(
3284 dmResponseSMPFrameHeader,
3289 case SMP_PHY_CONTROL:
3290 DM_DBG2(("dmSMPCompleted: phy control\n"));
3291 if (agIOInfoLen != 4 &&
3292 dmResponseSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED
3293 ) /*zero length is expected */
3295 DM_DBG1(("dmSMPCompleted: phy control mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, 4));
3296 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3299 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3300 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
3301 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3305 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
3306 if (dmSMPResponseBody == agNULL)
3308 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
3311 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3312 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
3313 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3318 dmPhyControl2RespRcvd(
3323 dmResponseSMPFrameHeader,
3330 case SMP_DISCOVER_LIST:
3331 DM_DBG1(("dmSMPCompleted: SMP_DISCOVER_LIST\n"));
3332 DM_DBG1(("dmSMPCompleted: agIOInfoLen 0x%x \n", agIOInfoLen));
3333 tdhexdump("dmSMPCompleted", (bit8*)agFrameHandle, agIOInfoLen);
3334 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3337 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3338 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
3339 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3343 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
3344 if (dmSMPResponseBody == agNULL)
3346 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
3349 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3350 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
3351 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3357 case SMP_REPORT_ROUTING_INFORMATION: /* fall through */
3358 case SMP_REPORT_PHY_ERROR_LOG: /* fall through */
3359 case SMP_PHY_TEST_FUNCTION: /* fall through */
3360 case SMP_REPORT_MANUFACTURE_INFORMATION: /* fall through */
3361 case SMP_READ_GPIO_REGISTER: /* fall through */
3362 case SMP_WRITE_GPIO_REGISTER: /* fall through */
3364 DM_DBG1(("dmSMPCompleted: wrong SMP function 0x%x\n", dmResponseSMPFrameHeader->smpFunction));
3365 DM_DBG1(("dmSMPCompleted: smpFrameType 0x%x\n", dmResponseSMPFrameHeader->smpFrameType));
3366 DM_DBG1(("dmSMPCompleted: smpFunctionResult 0x%x\n", dmResponseSMPFrameHeader->smpFunctionResult));
3367 DM_DBG1(("dmSMPCompleted: smpReserved 0x%x\n", dmResponseSMPFrameHeader->smpReserved));
3368 dmhexdump("dmSMPCompleted: SMP payload", (bit8 *)agFrameHandle, agIOInfoLen);
3371 } /* agIOStatus == OSSA_IO_SUCCESS */
3372 else if (agIOStatus == OSSA_IO_ABORTED || agIOStatus == OSSA_IO_INVALID_LENGTH)
3374 /* no retry this case */
3375 DM_DBG1(("dmSMPCompleted: OSSA_IO_ABORTED or OSSA_IO_INVALID_LENGTH, status 0x%x\n", agIOStatus));
3377 else if (agIOStatus == OSSA_IO_ERROR_INTERNAL_SMP_RESOURCE)
3379 DM_DBG1(("dmSMPCompleted: OSSA_IO_ERROR_INTERNAL_SMP_RESOURCE\n"));
3380 saFrameReadBlock(agRoot, agFrameHandle, 0, smpHeader, 4);
3381 dmResponseSMPFrameHeader = (dmSMPFrameHeader_t *)smpHeader;
3383 status = saSMPStart(
3394 if (status == AGSA_RC_SUCCESS)
3396 /* increment the number of pending SMP */
3397 onePortContext->discovery.pendingSMP++;
3398 if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
3399 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
3400 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3403 /* start discovery-related SMP timer */
3404 dmDiscoverySMPTimer(dmRoot, onePortContext, (bit32)(dmResponseSMPFrameHeader->smpFunction), dmSMPRequestBody);
3408 else if (status == AGSA_RC_BUSY)
3410 if (dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
3411 dmResponseSMPFrameHeader->smpFunction == SMP_DISCOVER ||
3412 dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
3413 dmResponseSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3416 dmSMPBusyTimer(dmRoot, onePortContext, oneDeviceData, dmSMPRequestBody);
3418 else if (dmResponseSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
3420 /* For taskmanagement SMP, let's fail task management failure */
3421 dmPhyControlFailureRespRcvd(
3425 dmResponseSMPFrameHeader,
3433 else /* AGSA_RC_FAILURE */
3435 if (dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
3436 dmResponseSMPFrameHeader->smpFunction == SMP_DISCOVER ||
3437 dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
3438 dmResponseSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3441 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3443 else if (dmResponseSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
3445 /* task management failure */
3446 dmPhyControlFailureRespRcvd(
3450 dmResponseSMPFrameHeader,
3459 else if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION)
3461 DM_DBG1(("dmSMPCompleted: OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION\n"));
3463 skip to the next expander
3465 dmHandleZoneViolation(
3476 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS ||
3477 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED ||
3478 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO ||
3479 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST ||
3480 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE ||
3481 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED ||
3482 agIOStatus == OSSA_IO_DS_NON_OPERATIONAL )
3484 DM_DBG1(("dmSMPCompleted: setting back to operational\n"));
3485 saSetDeviceState(agRoot, agNULL, 0, agDevHandle, SA_DS_OPERATIONAL);
3487 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED && dmAllShared->RateAdjust)
3489 DM_DBG1(("dmSMPCompleted: OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n"));
3490 DM_DBG1(("dmSMPCompleted: SMPRequestFunction 0x%x\n", SMPRequestFunction));
3491 ConnRate = DEVINFO_GET_LINKRATE(&oneDeviceData->agDeviceInfo);
3492 if (ConnRate == SAS_CONNECTION_RATE_1_5G)
3494 /* no retry; failure ??? */
3495 if (SMPRequestFunction == SMP_REPORT_GENERAL ||
3496 SMPRequestFunction == SMP_DISCOVER ||
3497 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
3498 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3501 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3503 else if (SMPRequestFunction == SMP_PHY_CONTROL)
3505 /* task management failure */
3506 dmPhyControlFailureRespRcvd(
3520 ConnRate = ConnRate - 1;
3522 agContext = &(dmSMPRequestBody->agContext);
3523 agContext->osData = agIORequest;
3524 saSetDeviceInfo(agRoot, agContext, 0, agDevHandle, 32, ConnRate << 28, dmSetDeviceInfoCB);
3528 if (dmSMPRequestBody->retries < SMP_RETRIES) /* 5 */
3530 /* retry the SMP again */
3531 DM_DBG1(("dmSMPCompleted: failed! but retries %d agIOStatus 0x%x %d agIOInfoLen %d\n",
3532 dmSMPRequestBody->retries, agIOStatus, agIOStatus, agIOInfoLen));
3533 saFrameReadBlock(agRoot, agFrameHandle, 0, smpHeader, 4);
3534 dmResponseSMPFrameHeader = (dmSMPFrameHeader_t *)smpHeader;
3535 status = saSMPStart(
3545 if (status == AGSA_RC_SUCCESS)
3547 /* increment the number of pending SMP */
3548 onePortContext->discovery.pendingSMP++;
3549 dmSMPRequestBody->retries++;
3550 if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
3551 SMPRequestFunction == SMP_REPORT_PHY_SATA ||
3552 SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3555 /* start discovery-related SMP timer */
3556 dmDiscoverySMPTimer(dmRoot, onePortContext, (bit32)(dmResponseSMPFrameHeader->smpFunction), dmSMPRequestBody);
3560 else if (status == AGSA_RC_BUSY)
3562 onePortContext->discovery.pendingSMP++;
3563 dmSMPRequestBody->retries++;
3564 if (dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
3565 dmResponseSMPFrameHeader->smpFunction == SMP_DISCOVER ||
3566 dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
3567 dmResponseSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3570 dmSMPBusyTimer(dmRoot, onePortContext, oneDeviceData, dmSMPRequestBody);
3573 else if (dmResponseSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
3575 /* For taskmanagement SMP, let's fail task management failure */
3576 dmPhyControlFailureRespRcvd(
3580 dmResponseSMPFrameHeader,
3588 else /* AGSA_RC_FAILURE */
3590 if (dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
3591 dmResponseSMPFrameHeader->smpFunction == SMP_DISCOVER ||
3592 dmResponseSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
3593 dmResponseSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3596 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3598 else if (dmResponseSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
3600 /* task management failure */
3601 dmPhyControlFailureRespRcvd(
3605 dmResponseSMPFrameHeader,
3616 dmSMPFrameHeader = (dmSMPFrameHeader_t *)agSMPFrame->outFrameBuf;
3617 dmSMPPayload = (bit8 *)agSMPFrame->outFrameBuf + 4;
3618 DM_DBG1(("dmSMPCompleted: failed! no more retry! agIOStatus 0x%x %d\n", agIOStatus, agIOStatus));
3619 if (agIOStatus == OSSA_IO_DS_NON_OPERATIONAL)
3621 DM_DBG1(("dmSMPCompleted: failed! agIOStatus is OSSA_IO_DS_NON_OPERATIONAL\n"));
3623 if (agIOStatus == OSSA_IO_DS_IN_RECOVERY)
3625 DM_DBG1(("dmSMPCompleted: failed! agIOStatus is OSSA_IO_DS_IN_RECOVERY\n"));
3627 if (dmSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
3628 dmSMPFrameHeader->smpFunction == SMP_DISCOVER ||
3629 dmSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
3630 dmSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION
3633 /* discovery failure */
3634 DM_DBG1(("dmSMPCompleted: SMP function 0x%x\n", dmSMPFrameHeader->smpFunction));
3635 DM_DBG1(("dmSMPCompleted: discover done with error\n"));
3636 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3638 else if (dmSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
3640 DM_DBG1(("dmSMPCompleted: SMP_PHY_CONTROL\n"));
3641 smpPhyControl2Req = (smpReqPhyControl2_t *)dmSMPPayload;
3642 if (smpPhyControl2Req->phyOperation == SMP_PHY_CONTROL_CLEAR_AFFILIATION)
3644 DM_DBG1(("dmSMPCompleted: discover done with error\n"));
3645 dmDiscoverDone(dmRoot, onePortContext, DM_RC_FAILURE);
3649 DM_DBG1(("dmSMPCompleted: unknown phy operation 0x%x\n", smpPhyControl2Req->phyOperation));
3651 } /* SMP_PHY_CONTROL */
3654 DM_DBG1(("dmSMPCompleted: SMP function 0x%x\n", dmSMPFrameHeader->smpFunction));
3657 } /* for RateAdjust */
3662 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3663 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
3664 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3668 dmSMPResponseBody = (dmSMPRequestBody_t *)dmSMPRequestBody->IndirectSMPResponse;
3669 if (dmSMPResponseBody == agNULL)
3671 DM_DBG1(("dmSMPCompleted: Wrong, dmSMPResponseBody is NULL!!!\n"));
3674 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3675 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPResponseBody->Link), &(dmAllShared->freeSMPList));
3676 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3685 agsaIORequest_t *agIORequest,
3689 dmRoot_t *dmRoot = agNULL;
3690 dmIntRoot_t *dmIntRoot = agNULL;
3691 dmIntContext_t *dmAllShared = agNULL;
3692 dmSMPRequestBody_t *dmSMPRequestBody = (dmSMPRequestBody_t *) agIORequest->osData;
3694 DM_DBG5(("dmSMPAbortCB: start\n"));
3696 if (dmSMPRequestBody == agNULL)
3698 DM_DBG1(("dmSMPAbortCB: pSMPRequestBody is NULL!!! \n"));
3702 dmRoot = dmSMPRequestBody->dmRoot;
3703 dmIntRoot = (dmIntRoot_t *)dmRoot->dmData;
3704 dmAllShared = (dmIntContext_t *)&dmIntRoot->dmAllShared;
3707 /* put back into free smplist */
3708 tddmSingleThreadedEnter(dmRoot, DM_SMP_LOCK);
3709 DMLIST_ENQUEUE_AT_TAIL(&(dmSMPRequestBody->Link), &(dmAllShared->freeSMPList));
3710 tddmSingleThreadedLeave(dmRoot, DM_SMP_LOCK);
3715 /* abort all per port */
3716 DM_DBG1(("dmSMPAbortCB: abort per port; not used!!!\n"));
3721 DM_DBG1(("dmSMPAbortCB: abort all; not used!!!\n"));
3726 DM_DBG1(("ossaSMPAbortCB: abort one\n"));
3727 if (status != OSSA_IO_SUCCESS)
3729 DM_DBG1(("dmSMPAbortCB: abort one, status 0x%x\n", status));
3734 DM_DBG1(("dmSMPAbortCB: not allowed case, flag 0x%x!!!\n", flag));