FreeBSD kernel pms device code
tddmcmnapi.c
Go to the documentation of this file.
1/*******************************************************************************
2*Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
3*
4*Redistribution and use in source and binary forms, with or without modification, are permitted provided
5*that the following conditions are met:
6*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7*following disclaimer.
8*2. Redistributions in binary form must reproduce the above copyright notice,
9*this list of conditions and the following disclaimer in the documentation and/or other materials provided
10*with the distribution.
11*
12*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20
21********************************************************************************/
22#include <sys/cdefs.h>
23__FBSDID("$FreeBSD$");
24#include <dev/pms/config.h>
25
29
33/* for TIDEBUG_MSG */
35
36#ifdef FDS_DM
37
41
42#ifdef FDS_SM
45#endif
46
47#ifdef INITIATOR_DRIVER
49#endif
50
54
55#if defined(DM_DEBUG)
56extern bit32 gDMDebugLevel;
57#endif
58
61 dmRoot_t *dmRoot,
62 agsaDevHandle_t *agDevHandle
63 )
64{
65 tdsaRoot_t *tdsaRoot;
66 tdsaContext_t *tdsaAllShared;
68 tdsaDeviceData_t *oneDeviceData = agNULL;
69 TI_DBG1(("tddmRotateQnumber: start\n"));
70 if (agDevHandle == agNULL)
71 {
72 TI_DBG1(("tddmRotateQnumber: agDevHandle is NULL!!!\n"));
73 return 0;
74 }
75 oneDeviceData = (tdsaDeviceData_t *)agDevHandle->osData;
76 if (oneDeviceData == agNULL)
77 {
78 TI_DBG1(("tddmRotateQnumber: oneDeviceData is NULL!!!\n"));
79 return 0;
80 }
81 tdsaRoot = (tdsaRoot_t *)dmRoot->tdData;
82 if (tdsaRoot == agNULL)
83 {
84 TI_DBG1(("tddmRotateQnumber: tdsaRoot is NULL\n"));
85 return 0;
86 }
87 tdsaAllShared = &(tdsaRoot->tdsaAllShared);
88 if (tdsaAllShared == agNULL)
89 {
90 TI_DBG1(("tddmRotateQnumber: tdsaAllShared is NULL\n"));
91 return 0;
92 }
93 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
94 if (tiRoot == agNULL)
95 {
96 TI_DBG1(("tddmRotateQnumber: tiRoot is NULL\n"));
97 return 0;
98 }
99 return tdsaRotateQnumber(tiRoot, oneDeviceData);
100}
104 tdsaPortContext_t *onePortContext
105 )
106{
107 bit32 i, localMCN = 0;
108
109 TI_DBG2(("tdsaFindLocalMCN: start\n"));
110
111 if (onePortContext->valid == agFALSE)
112 {
113 TI_DBG1(("tdsaFindLocalMCN: invalid portcontext id %d\n", onePortContext->id));
114 return 0;
115 }
116
117 for(i=0;i<TD_MAX_NUM_PHYS;i++)
118 {
119 if (onePortContext->PhyIDList[i] == agTRUE)
120 {
121 localMCN++;
122 }
123 }
124
125 return localMCN;
126}
127
128
129/*
130 on success,
131 ostiInitiatorEvent(
132 tiRoot,
133 onePortContext->tiPortalContext,
134 agNULL,
135 tiIntrEventTypeDiscovery,
136 tiDiscOK,
137 agNULL
138 );
139else
140 remove(de-register) all devices
141 ostiInitiatorEvent(
142 tiRoot,
143 onePortContext->tiPortalContext,
144 agNULL,
145 tiIntrEventTypeDiscovery,
146 tiDiscFailed,
147 agNULL
148 );
149
150
151 dmRoot->tdData is tdsaRoot_t (just like current TD layer)
152 dmPortContext->tdData is tdsaPortContext_t
153
154*/
155osGLOBAL void
157 dmRoot_t *dmRoot,
158 dmPortContext_t *dmPortContext,
159 bit32 eventStatus
160 )
161{
162 tdsaRoot_t *tdsaRoot;
163 tdsaContext_t *tdsaAllShared;
165 tdsaPortContext_t *onePortContext;
166 agsaRoot_t *agRoot;
167 agsaPortContext_t *agPortContext;
168
169 TI_DBG1(("tddmDiscoverCB: start\n"));
170 tdsaRoot = (tdsaRoot_t *)dmRoot->tdData;
171 if (tdsaRoot == agNULL)
172 {
173 TI_DBG1(("tddmDiscoverCB: tdsaRoot is NULL\n"));
174 return;
175 }
176
177 tdsaAllShared = &(tdsaRoot->tdsaAllShared);
178 if (tdsaAllShared == agNULL)
179 {
180 TI_DBG1(("tddmDiscoverCB: tdsaAllShared is NULL\n"));
181 return;
182 }
183
184 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
185 if (tiRoot == agNULL)
186 {
187 TI_DBG1(("tddmDiscoverCB: tiRoot is NULL\n"));
188 return;
189 }
190
191 onePortContext = (tdsaPortContext_t *)dmPortContext->tdData;
192 if (onePortContext == agNULL)
193 {
194 TI_DBG1(("tddmDiscoverCB: onePortContext is NULL\n"));
195 return;
196 }
197
198 TI_DBG2(("tddmDiscoverCB: localMCN 0x%x\n", tdsaFindLocalMCN(tiRoot, onePortContext)));
199
200 if (eventStatus == dmDiscCompleted)
201 {
202 TI_DBG1(("tddmDiscoverCB: dmDiscCompleted\n"));
203 onePortContext->DiscoveryState = ITD_DSTATE_COMPLETED;
204 onePortContext->DMDiscoveryState = dmDiscCompleted;
205 TI_DBG1(("tddmDiscoverCB: pid %d tiPortalContext %p\n", onePortContext->id, onePortContext->tiPortalContext));
206
207 /* update onePortContext->UpdateMCN = agFALSE */
208 if ( onePortContext->UpdateMCN == agTRUE)
209 {
210 TI_DBG2(("tddmDiscoverCB: calling tdsaUpdateMCN\n"));
211 onePortContext->UpdateMCN = agFALSE;
212 tdsaUpdateMCN(dmRoot, onePortContext);
213 }
214
216 tiRoot,
217 onePortContext->tiPortalContext,
218 agNULL,
220 tiDiscOK,
221 agNULL
222 );
223 }
224 else if (eventStatus == dmDiscFailed )
225 {
226 TI_DBG1(("tddmDiscoverCB: dmDiscFailed \n"));
227 onePortContext->DiscoveryState = ITD_DSTATE_COMPLETED;
228 onePortContext->DMDiscoveryState = dmDiscFailed;
229 TI_DBG1(("tddmDiscoverCB: pid %d tiPortalContext %p\n", onePortContext->id, onePortContext->tiPortalContext));
230 agRoot = &(tdsaAllShared->agRootNonInt);
231 if (agRoot == agNULL)
232 {
233 TI_DBG1(("tddmDiscoverCB: agRoot is NULL\n"));
234 return;
235 }
236 agPortContext = onePortContext->agPortContext;
237 if (agPortContext == agNULL)
238 {
239 TI_DBG1(("tddmDiscoverCB: agPortContext is NULL\n"));
240 return;
241 }
242 /*
243 invalidate all devices in this port
244 */
245 tddmInvalidateDevicesInPort(tiRoot, onePortContext);
246
247 saPortControl(agRoot,
248 agNULL,
249 0,
250 agPortContext,
252 0 /*quarantine */,
253 0 /* unused */);
254
255
257 tiRoot,
258 onePortContext->tiPortalContext,
259 agNULL,
262 agNULL
263 );
264 }
265 else if (eventStatus == dmDiscAborted )
266 {
267 TI_DBG1(("tddmDiscoverCB: dmDiscAborted \n"));
268 onePortContext->DMDiscoveryState = dmDiscAborted;
269 }
270 else if (eventStatus == dmDiscAbortFailed )
271 {
272 TI_DBG1(("tddmDiscoverCB: dmDiscAbortFailed \n"));
273 onePortContext->DMDiscoveryState = dmDiscAbortFailed;
274 }
275 else if (eventStatus == dmDiscAbortInvalid )
276 {
277 TI_DBG1(("tddmDiscoverCB: dmDiscAbortInvalid \n"));
278 onePortContext->DMDiscoveryState = dmDiscAbortInvalid;
279 }
280 else if (eventStatus == dmDiscAbortInProgress )
281 {
282 TI_DBG1(("tddmDiscoverCB: dmDiscAbortInProgress \n"));
283 onePortContext->DMDiscoveryState = dmDiscAbortInProgress;
284 }
285 else
286 {
287 TI_DBG1(("tddmDiscoverCB: undefined eventStatus 0x%x\n", eventStatus));
288 onePortContext->DMDiscoveryState = dmDiscFailed;
289 }
290
291 return;
292}
293
294
295osGLOBAL void
297 dmRoot_t *dmRoot,
298 dmPortContext_t *dmPortContext,
299 bit32 discType,
300 bit32 discState
301 )
302{
303 tdsaPortContext_t *onePortContext = agNULL;
304
305 TI_DBG2(("tddmQueryDiscoveryCB: start\n"));
306 onePortContext = (tdsaPortContext_t *)dmPortContext->tdData;
307 if (onePortContext == agNULL)
308 {
309 TI_DBG1(("tddmQueryDiscoveryCB: onePortContext is NULL\n"));
310 return;
311 }
312 TI_DBG2(("tddmQueryDiscoveryCB: discType %d discState %d\n", discType, discState));
313
314 onePortContext->DMDiscoveryState = discState;
315 return;
316}
317
318osGLOBAL void
319tddmInvalidateDevicesInPort(
321 tdsaPortContext_t *onePortContext
322 )
323{
324 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
325 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
326 tdsaDeviceData_t *oneDeviceData = agNULL;
327 tdList_t *DeviceListList;
328
329 TI_DBG1(("tddmInvalidateDevicesInPort: start\n"));
330
331 /* find a device's existence */
332 DeviceListList = tdsaAllShared->MainDeviceList.flink;
333 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
334 {
335 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
336 if (oneDeviceData == agNULL)
337 {
338 TI_DBG1(("tddmInvalidateDevicesInPort: oneDeviceData is NULL!!!\n"));
339 return;
340 }
341 if ((oneDeviceData->registered == agTRUE) &&
342 (oneDeviceData->tdPortContext == onePortContext)
343 )
344 {
345
346 TI_DBG3(("tddmInvalidateDevicesInPort: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
347 if (oneDeviceData->SASAddressID.sasAddressHi == onePortContext->sasRemoteAddressHi &&
348 oneDeviceData->SASAddressID.sasAddressLo == onePortContext->sasRemoteAddressLo
349 )
350 {
351 TI_DBG1(("tddmInvalidateDevicesInPort: keeping\n"));
352 oneDeviceData->valid = agTRUE;
353 oneDeviceData->valid2 = agFALSE;
354 }
355 else if (oneDeviceData->valid == agTRUE)
356 {
357 oneDeviceData->valid = agFALSE;
358 oneDeviceData->valid2 = agFALSE;
359 oneDeviceData->registered = agFALSE;
360 }
361 }
362 DeviceListList = DeviceListList->flink;
363 }
364
365 TI_DBG3(("tddmInvalidateDevicesInPort: end\n"));
366
367 return;
368}
369
371tddmNewSASorNot(
373 tdsaPortContext_t *onePortContext,
374 tdsaSASSubID_t *agSASSubID
375 )
376{
377 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
378 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
379 tdsaDeviceData_t *oneDeviceData = agNULL;
380 tdList_t *DeviceListList;
381 bit32 ret = agTRUE;
382
383 TI_DBG3(("tddmNewSASorNot: start\n"));
384
385 /* find a device's existence */
386 DeviceListList = tdsaAllShared->MainDeviceList.flink;
387 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
388 {
389 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
390 if (oneDeviceData == agNULL)
391 {
392 TI_DBG1(("tddmNewSASorNot: oneDeviceData is NULL!!!\n"));
393 return agFALSE;
394 }
395 if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
396 (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
397 (oneDeviceData->registered == agTRUE) &&
398 (oneDeviceData->tdPortContext == onePortContext)
399 )
400 {
401 TI_DBG3(("tddmNewSASorNot: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
402 ret = agFALSE;
403 break;
404 }
405 DeviceListList = DeviceListList->flink;
406 }
407
408
409
410 TI_DBG3(("tddmNewSASorNot: end\n"));
411
412 return ret;
413}
414
416tddmPortSASDeviceFind(
418 tdsaPortContext_t *onePortContext,
419 bit32 sasAddrLo,
420 bit32 sasAddrHi
421 )
422{
423 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
424 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
425 tdsaDeviceData_t *oneDeviceData, *RetDeviceData=agNULL;
426 tdList_t *DeviceListList;
427
428 TI_DBG2(("tddmPortSASDeviceFind: start\n"));
429
430 TD_ASSERT((agNULL != tiRoot), "");
431 TD_ASSERT((agNULL != onePortContext), "");
432
434
435 /* find a device's existence */
436 DeviceListList = tdsaAllShared->MainDeviceList.flink;
437 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
438 {
439 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
440 if (oneDeviceData == agNULL)
441 {
442 TI_DBG1(("tddmPortSASDeviceFind: oneDeviceData is NULL!!!\n"));
443 return agNULL;
444 }
445 if ((oneDeviceData->SASAddressID.sasAddressHi == sasAddrHi) &&
446 (oneDeviceData->SASAddressID.sasAddressLo == sasAddrLo) &&
447 (oneDeviceData->valid == agTRUE) &&
448 (oneDeviceData->tdPortContext == onePortContext)
449 )
450 {
451 TI_DBG2(("tddmPortSASDeviceFind: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
452 TI_DBG2(("tddmPortSASDeviceFind: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
453 TI_DBG2(("tddmPortSASDeviceFind: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
454 RetDeviceData = oneDeviceData;
455 break;
456 }
457 DeviceListList = DeviceListList->flink;
458 }
459
461
462 return RetDeviceData;
463}
464
465/* not in use yet */
467tddmAddToSharedcontext(
468 agsaRoot_t *agRoot,
469 tdsaPortContext_t *onePortContext,
470 tdsaSASSubID_t *agSASSubID,
471 tdsaDeviceData_t *oneExpDeviceData,
472 bit8 phyID
473 )
474{
475 tdsaDeviceData_t *oneDeviceData = agNULL;
476 tdList_t *DeviceListList;
477 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
478 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
479 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
480 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
481 bit32 new_device = agTRUE;
482
483 TI_DBG1(("tddmAddToSharedcontext: start\n"));
484
485 TI_DBG1(("tddmAddToSharedcontext: oneportContext ID %d\n", onePortContext->id));
486 /* find a device's existence */
487 DeviceListList = tdsaAllShared->MainDeviceList.flink;
488 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
489 {
490 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
491 if (oneDeviceData == agNULL)
492 {
493 TI_DBG1(("tddmAddToSharedcontext: oneDeviceData is NULL!!!\n"));
494 return agNULL;
495 }
496 if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
497 (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
498 (oneDeviceData->tdPortContext == onePortContext)
499 )
500 {
501 TI_DBG1(("tddmAddToSharedcontext: pid %dtddmAddToSharedcontext did %d\n", onePortContext->id, oneDeviceData->id));
502 new_device = agFALSE;
503 break;
504 }
505 DeviceListList = DeviceListList->flink;
506 }
507
508 /* new device */
509 if (new_device == agTRUE)
510 {
511 TI_DBG1(("tddmAddToSharedcontext: new device\n"));
513 if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
514 {
516 TI_DBG1(("tddmAddToSharedcontext: empty DeviceData FreeLink\n"));
517 return agNULL;
518 }
519
520 TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
522 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
523
524 TI_DBG1(("tddmAddToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
525
526 onePortContext->Count++;
527 oneDeviceData->agRoot = agRoot;
528 /* saving sas address */
529 oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
530 oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
531 oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
532 oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
533 oneDeviceData->tdPortContext = onePortContext;
534 /* handles both SAS target and STP-target, SATA-device */
535 if (!DEVICE_IS_SATA_DEVICE(oneDeviceData) && !DEVICE_IS_STP_TARGET(oneDeviceData))
536 {
537 oneDeviceData->DeviceType = TD_SAS_DEVICE;
538 }
539 else
540 {
541 oneDeviceData->DeviceType = TD_SATA_DEVICE;
542 }
543
544 oneDeviceData->ExpDevice = oneExpDeviceData;
545 /* set phyID only when it has initial value of 0xFF */
546 if (oneDeviceData->phyID == 0xFF)
547 {
548 oneDeviceData->phyID = phyID;
549 }
550
551 oneDeviceData->valid = agTRUE;
552
553 /* add the devicedata to the portcontext */
555 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
557 TI_DBG1(("tddmAddToSharedcontext: one case pid %d did %d \n", onePortContext->id, oneDeviceData->id));
558 TI_DBG1(("tddmAddToSharedcontext: new case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
559 }
560 else /* old device */
561 {
562 TI_DBG1(("tddmAddToSharedcontext: old device\n"));
563 TI_DBG1(("tddmAddToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
564
565 oneDeviceData->agRoot = agRoot;
566 /* saving sas address */
567 oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
568 oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
569 oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
570 oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
571 oneDeviceData->tdPortContext = onePortContext;
572 /* handles both SAS target and STP-target, SATA-device */
573 if (!DEVICE_IS_SATA_DEVICE(oneDeviceData) && !DEVICE_IS_STP_TARGET(oneDeviceData))
574 {
575 oneDeviceData->DeviceType = TD_SAS_DEVICE;
576 }
577 else
578 {
579 oneDeviceData->DeviceType = TD_SATA_DEVICE;
580 }
581
582 oneDeviceData->ExpDevice = oneExpDeviceData;
583 /* set phyID only when it has initial value of 0xFF */
584 if (oneDeviceData->phyID == 0xFF)
585 {
586 oneDeviceData->phyID = phyID;
587 }
588
589 oneDeviceData->valid = agTRUE;
590 TI_DBG1(("tddmAddToSharedcontext: old case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
591
592 }
593 return oneDeviceData;
594
595}
596
597
598/*
599 calls saRegisterNewDevice()
600 in ossaDeviceRegistrationCB(), if an expander, register to DM
601#define DEVICE_IS_SMP_TARGET(DeviceData) \
602 (((DeviceData)->target_ssp_stp_smp & DEVICE_SMP_BIT) == DEVICE_SMP_BIT)
603*/
605tddmPortDeviceAdd(
607 tdsaPortContext_t *onePortContext,
608 dmDeviceInfo_t *dmDeviceInfo,
609 tdsaDeviceData_t *oneExpDeviceData
610 )
611{
612 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
613 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
614 tdsaDeviceData_t *oneDeviceData = agNULL;
615 tdsaSASSubID_t agSASSubID;
616 bit8 phyID;
617
618 TI_DBG2(("tddmPortDeviceAdd: start\n"));
619
620
621 agSASSubID.sasAddressHi = TD_GET_SAS_ADDRESSHI(dmDeviceInfo->sasAddressHi);
622 agSASSubID.sasAddressLo = TD_GET_SAS_ADDRESSLO(dmDeviceInfo->sasAddressLo);
623 agSASSubID.initiator_ssp_stp_smp = dmDeviceInfo->initiator_ssp_stp_smp;
624 agSASSubID.target_ssp_stp_smp = dmDeviceInfo->target_ssp_stp_smp;
625 phyID = (dmDeviceInfo->ext) & 0xFF;
626
627 /* old device and already registered to LL; added by link-up event */
628 if ( agFALSE == tdssNewSASorNot(
629 onePortContext->agRoot,
630 onePortContext,
631 &agSASSubID
632 )
633 )
634 {
635 /* old device and already registered to LL; added by link-up event */
636 TI_DBG2(("tddmPortDeviceAdd: OLD qqqq initiator_ssp_stp_smp %d target_ssp_stp_smp %d\n", agSASSubID.initiator_ssp_stp_smp, agSASSubID.target_ssp_stp_smp));
637 /* find the old device */
638 oneDeviceData = tdssNewAddSASToSharedcontext(
639 onePortContext->agRoot,
640 onePortContext,
641 &agSASSubID,
642 oneExpDeviceData,
643 phyID
644 );
645
646 if (oneDeviceData == agNULL)
647 {
648 TI_DBG1(("tddmPortDeviceAdd: no more device!!! oneDeviceData is null\n"));
649 }
650
651 /* If a device is allocated */
652 if ( oneDeviceData != agNULL )
653 {
654
655 TI_DBG2(("tddmPortDeviceAdd: sasAddressHi 0x%08x\n", agSASSubID.sasAddressHi));
656 TI_DBG2(("tddmPortDeviceAdd: sasAddressLo 0x%08x\n", agSASSubID.sasAddressLo));
657 TI_DBG2(("tddmPortDeviceAdd: phyID 0x%x\n", phyID));
658
659 /* copy dmDeviceInfo to oneDeviceData->agDeviceInfo except ext field */
660 oneDeviceData->agDeviceInfo.smpTimeout = dmDeviceInfo->smpTimeout;
661 oneDeviceData->agDeviceInfo.it_NexusTimeout = dmDeviceInfo->it_NexusTimeout;
662 oneDeviceData->agDeviceInfo.firstBurstSize = dmDeviceInfo->firstBurstSize;
663 oneDeviceData->agDeviceInfo.devType_S_Rate = dmDeviceInfo->devType_S_Rate;
664 osti_memcpy(&(oneDeviceData->agDeviceInfo.sasAddressHi), &(dmDeviceInfo->sasAddressHi), 4);
665 osti_memcpy(&(oneDeviceData->agDeviceInfo.sasAddressLo), &(dmDeviceInfo->sasAddressLo), 4);
666 if (dmDeviceInfo->sataDeviceType == SATA_ATAPI_DEVICE)
667 {
668 oneDeviceData->agDeviceInfo.flag |= ATAPI_DEVICE_FLAG;
669 }
670
671 oneDeviceData->satDevData.satDeviceType = dmDeviceInfo->sataDeviceType;
672
673
674
675 oneDeviceData->agContext.osData = oneDeviceData;
676 oneDeviceData->agContext.sdkData = agNULL;
677
678 }
679 return oneDeviceData;
680 } /* old device */
681
682 /* new device */
683
684 TI_DBG2(("tddmPortDeviceAdd: NEW qqqq initiator_ssp_stp_smp %d target_ssp_stp_smp %d\n", agSASSubID.initiator_ssp_stp_smp, agSASSubID.target_ssp_stp_smp));
685
686 /* allocate a new device and set the valid bit */
687 oneDeviceData = tdssNewAddSASToSharedcontext(
688 onePortContext->agRoot,
689 onePortContext,
690 &agSASSubID,
691 oneExpDeviceData,
692 phyID
693 );
694
695 if (oneDeviceData == agNULL)
696 {
697 TI_DBG1(("tddmPortDeviceAdd: no more device!!! oneDeviceData is null\n"));
698 }
699
700 /* If a device is allocated */
701 if ( oneDeviceData != agNULL )
702 {
703
704 TI_DBG2(("tddmPortDeviceAdd: sasAddressHi 0x%08x\n", agSASSubID.sasAddressHi));
705 TI_DBG2(("tddmPortDeviceAdd: sasAddressLo 0x%08x\n", agSASSubID.sasAddressLo));
706 TI_DBG2(("tddmPortDeviceAdd: phyID 0x%x\n", phyID));
707
708 /* copy dmDeviceInfo to oneDeviceData->agDeviceInfo except ext field */
709 oneDeviceData->agDeviceInfo.smpTimeout = dmDeviceInfo->smpTimeout;
710 oneDeviceData->agDeviceInfo.it_NexusTimeout = dmDeviceInfo->it_NexusTimeout;
711 oneDeviceData->agDeviceInfo.firstBurstSize = dmDeviceInfo->firstBurstSize;
712 oneDeviceData->agDeviceInfo.devType_S_Rate = dmDeviceInfo->devType_S_Rate;
713 osti_memcpy(&(oneDeviceData->agDeviceInfo.sasAddressHi), &(dmDeviceInfo->sasAddressHi), 4);
714 osti_memcpy(&(oneDeviceData->agDeviceInfo.sasAddressLo), &(dmDeviceInfo->sasAddressLo), 4);
715
716 oneDeviceData->satDevData.satDeviceType = dmDeviceInfo->sataDeviceType;
717 if (dmDeviceInfo->sataDeviceType == SATA_ATAPI_DEVICE)
718 {
719 oneDeviceData->agDeviceInfo.flag |= ATAPI_DEVICE_FLAG;
720 }
721
722 oneDeviceData->agContext.osData = oneDeviceData;
723 oneDeviceData->agContext.sdkData = agNULL;
724
725 TI_DBG2(("tddmPortDeviceAdd: did %d\n", oneDeviceData->id));
726
727 /* don't add and register initiator for T2D */
728 if ( (((oneDeviceData->initiator_ssp_stp_smp & DEVICE_SSP_BIT) == DEVICE_SSP_BIT) &&
729 ((oneDeviceData->target_ssp_stp_smp & DEVICE_SSP_BIT) != DEVICE_SSP_BIT))
730 ||
731 (((oneDeviceData->initiator_ssp_stp_smp & DEVICE_STP_BIT) == DEVICE_STP_BIT) &&
732 ((oneDeviceData->target_ssp_stp_smp & DEVICE_SSP_BIT) != DEVICE_SSP_BIT))
733 )
734 {
735 TI_DBG1(("tddmPortDeviceAdd: initiator. no add and registration\n"));
736 TI_DBG1(("tddmPortDeviceAdd: sasAddressHi 0x%08x\n", agSASSubID.sasAddressHi));
737 TI_DBG1(("tddmPortDeviceAdd: sasAddressLo 0x%08x\n", agSASSubID.sasAddressLo));
738
739 }
740 else
741 {
742 if (oneDeviceData->registered == agFALSE)
743 {
744#ifdef REMOVED
745 //temp; setting MCN to tdsaAllShared->MCN
746 oneDeviceData->agDeviceInfo.flag = oneDeviceData->agDeviceInfo.flag | (tdsaAllShared->MCN << 16);
747 //end temp
748#endif
749 if( tdsaAllShared->sflag )
750 {
751 if( ! DEVICE_IS_SMP_TARGET(oneDeviceData))
752 {
753 TI_DBG1(("tddmPortDeviceAdd: saRegisterNewDevice sflag %d\n", tdsaAllShared->sflag));
754 oneDeviceData->agDeviceInfo.flag = oneDeviceData->agDeviceInfo.flag | TD_XFER_RDY_PRIORTY_DEVICE_FLAG;
755 }
756 }
757 saRegisterNewDevice( /* tddmPortDeviceAdd */
758 onePortContext->agRoot,
759 &oneDeviceData->agContext,
760 0,
761 &oneDeviceData->agDeviceInfo,
762 onePortContext->agPortContext,
763 0
764 );
765 }
766 }
767 }
768
769 return oneDeviceData;
770}
771
772
773/*
774 each call, add the device to the device list
775 typedef struct{
776 bit16 smpTimeout;
777 bit16 it_NexusTimeout;
778 bit16 firstBurstSize;
779 bit8 flag;
780 bit8 devType_S_Rate;
781 bit8 sasAddressHi[4];
782 bit8 sasAddressLo[4];
783} dmDeviceInfo_t;
784
785 find oneExpDeviceData (expander device data) from dmExpDeviceInfo and
786 pass it to tddmPortDeviceAdd()
787 start here - change spec from bit32 to void
788
789 phyID = ((dmDeviceInfo->flag) & 0xFC) >> 2;
790 Initiators are not registered
791*/
792//start here
793osGLOBAL void
795 dmRoot_t *dmRoot,
796 dmPortContext_t *dmPortContext,
797 dmDeviceInfo_t *dmDeviceInfo, /* device */
798 dmDeviceInfo_t *dmExpDeviceInfo, /* expander the device is attached to */
799 bit32 flag
800
801 )
802{
803 agsaRoot_t *agRoot;
804 tdsaRoot_t *tdsaRoot;
805 tdsaContext_t *tdsaAllShared;
807 tdsaDeviceData_t *oneExpDeviceData = agNULL;
808 bit32 sasAddressHi, sasAddressLo;
809 tdsaPortContext_t *onePortContext;
810 tdsaDeviceData_t *oneDeviceData = agNULL;
811 bit32 localMCN = 0, finalMCN = 0;
812 bit32 devMCN = 1;
813 bit32 DLR = 0xA;
814 bit32 option;
815 bit32 param;
816
817#ifdef FDS_SM
818 smRoot_t *smRoot;
819#endif
820
821 TI_DBG2(("tddmReportDevice: start\n"));
822 tdsaRoot = (tdsaRoot_t *)dmRoot->tdData;
823 if (tdsaRoot == agNULL)
824 {
825 TI_DBG1(("tddmReportDevice: tdsaRoot is NULL\n"));
826 return;
827 }
828
829 tdsaAllShared = &(tdsaRoot->tdsaAllShared);
830 if (tdsaAllShared == agNULL)
831 {
832 TI_DBG1(("tddmReportDevice: tdsaAllShared is NULL\n"));
833 return;
834 }
835
836 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
837 if (tiRoot == agNULL)
838 {
839 TI_DBG1(("tddmReportDevice: tiRoot is NULL\n"));
840 return;
841 }
842
843 onePortContext = (tdsaPortContext_t *)dmPortContext->tdData;
844 if (onePortContext == agNULL)
845 {
846 TI_DBG1(("tddmReportDevice: onePortContext is NULL\n"));
847 return;
848 }
849
850#ifdef FDS_SM
851 smRoot = &(tdsaAllShared->smRoot);
852#endif
853
854 TI_DBG2(("tddmReportDevice: device addrHi 0x%08x addrLo 0x%08x\n",
856
857 if (dmExpDeviceInfo != agNULL)
858 {
859 TI_DBG2(("tddmReportDevice: attached expander addrHi 0x%08x addrLo 0x%08x\n",
860 TD_GET_SAS_ADDRESSHI(dmExpDeviceInfo->sasAddressHi), TD_GET_SAS_ADDRESSLO(dmExpDeviceInfo->sasAddressLo)));
861 }
862 else
863 {
864 TI_DBG2(("tddmReportDevice: No attached expander\n"));
865 }
866
867 /* initiators only (e.g. SPC or SPCv) are discarded */
868 if ( (dmDeviceInfo->target_ssp_stp_smp == 0) &&
869 ( DEVICE_IS_SSP_INITIATOR(dmDeviceInfo) || DEVICE_IS_STP_INITIATOR(dmDeviceInfo) || DEVICE_IS_SMP_INITIATOR(dmDeviceInfo))
870 )
871 {
872 TI_DBG3(("tddmReportDevice: Initiators are not added\n"));
873 TI_DBG3(("tddmReportDevice: device addrHi 0x%08x addrLo 0x%08x\n",
875 return;
876 }
877
878 if (flag == dmDeviceArrival)
879 {
880 TI_DBG2(("tddmReportDevice: arrival\n"));
881 if (dmExpDeviceInfo != agNULL)
882 {
883 sasAddressHi = TD_GET_SAS_ADDRESSHI(dmExpDeviceInfo->sasAddressHi);
884 sasAddressLo = TD_GET_SAS_ADDRESSLO(dmExpDeviceInfo->sasAddressLo);
885
886 oneExpDeviceData = tddmPortSASDeviceFind(tiRoot, onePortContext, sasAddressLo, sasAddressHi);
887 }
888
889 tddmPortDeviceAdd(tiRoot, onePortContext, dmDeviceInfo, oneExpDeviceData);
890
891 }
892 else if (flag == dmDeviceRemoval)
893 {
894 TI_DBG2(("tddmReportDevice: removal\n"));
895 sasAddressHi = TD_GET_SAS_ADDRESSHI(dmDeviceInfo->sasAddressHi);
896 sasAddressLo = TD_GET_SAS_ADDRESSLO(dmDeviceInfo->sasAddressLo);
897 oneDeviceData = tddmPortSASDeviceFind(tiRoot, onePortContext, sasAddressLo, sasAddressHi);
898 if (oneDeviceData == agNULL)
899 {
900 TI_DBG2(("tddmReportDevice: oneDeviceData is NULL!!!\n"));
901 }
902 else
903 {
904 /* invalidate device */
905 TI_DBG2(("tddmReportDevice: invalidating\n"));
906 TI_DBG2(("tddmReportDevice: agDevHandle %p\n", oneDeviceData->agDevHandle));
907 if ( oneDeviceData->agDevHandle != agNULL)
908 {
909 TI_DBG2(("tddmReportDevice: agDevHandle->sdkData %p\n", oneDeviceData->agDevHandle->sdkData));
910 }
911 else
912 {
913 TI_DBG2(("tddmReportDevice: agDevHandle->sdkData is NULL\n"));
914 }
915 oneDeviceData->valid = agFALSE;
916//to do; to be tested
917 agRoot = oneDeviceData->agRoot;
918 if ( (oneDeviceData->registered == agTRUE) &&
919 ( DEVICE_IS_SSP_TARGET(oneDeviceData) || DEVICE_IS_STP_TARGET(oneDeviceData)
920 || DEVICE_IS_SATA_DEVICE(oneDeviceData) || DEVICE_IS_SMP_TARGET(oneDeviceData) )
921 )
922 {
923 if ( !( DEVICE_IS_SMP_TARGET(oneDeviceData) && oneDeviceData->directlyAttached == agTRUE))
924 {
925 tdsaAbortAll(tiRoot, agRoot, oneDeviceData);
926 oneDeviceData->registered = agFALSE;
927 }
928 else
929 {
930 TI_DBG2(("tddmReportDevice: keeping\n"));
931 oneDeviceData->registered = agTRUE;
932 }
933 }
934 else if (oneDeviceData->registered == agTRUE)
935 {
936 if ( oneDeviceData->agDevHandle == agNULL)
937 {
938 TI_DBG1(("tddmReportDevice: agDevHandle->sdkData is NULL. Error!!! \n"));
939 }
940 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData));
941 oneDeviceData->registered = agFALSE;
942 }
943//to do remove
944#ifdef FDS_SM_WRONG
945 if (DEVICE_IS_SATA_DEVICE(oneDeviceData))
946 {
947 TI_DBG2(("tddmReportDevice: smDeregisterDevice\n"));
948 smDeregisterDevice(smRoot, agNULL, oneDeviceData->agDevHandle, &(oneDeviceData->smDeviceHandle));
949 oneDeviceData->satDevData.IDDeviceValid = agFALSE;
950 }
951#endif
952 }
953 }
954 else if (flag == dmDeviceNoChange)
955 {
956 TI_DBG2(("tddmReportDevice: no change; do nothing \n"));
957#ifdef FDS_SM
958 sasAddressHi = TD_GET_SAS_ADDRESSHI(dmDeviceInfo->sasAddressHi);
959 sasAddressLo = TD_GET_SAS_ADDRESSLO(dmDeviceInfo->sasAddressLo);
960 oneDeviceData = tddmPortSASDeviceFind(tiRoot, onePortContext, sasAddressLo, sasAddressHi);
961 if (oneDeviceData == agNULL)
962 {
963 TI_DBG2(("tddmReportDevice: oneDeviceData is NULL!!!\n"));
964 }
965 else
966 {
967 agRoot = oneDeviceData->agRoot;
968 if ( (DEVICE_IS_SATA_DEVICE(oneDeviceData) || DEVICE_IS_STP_TARGET(oneDeviceData))
969 &&
970 oneDeviceData->satDevData.IDDeviceValid == agFALSE)
971 {
972 tdIDStart(tiRoot, agRoot, smRoot, oneDeviceData, onePortContext);
973 }
974 }
975#endif
976 }
977 else if (flag == dmDeviceMCNChange)
978 {
979 TI_DBG2(("tddmReportDevice: dmDeviceMCNChange \n"));
980 localMCN = tdsaFindLocalMCN(tiRoot, onePortContext);
981 devMCN = DEVINFO_GET_EXT_MCN(dmDeviceInfo);
982 TI_DBG2(("tddmReportDevice: devMCN 0x%08x localMCN 0x%08x\n", devMCN, localMCN));
983
984 sasAddressHi = TD_GET_SAS_ADDRESSHI(dmDeviceInfo->sasAddressHi);
985 sasAddressLo = TD_GET_SAS_ADDRESSLO(dmDeviceInfo->sasAddressLo);
986 oneDeviceData = tddmPortSASDeviceFind(tiRoot, onePortContext, sasAddressLo, sasAddressHi);
987 if (oneDeviceData == agNULL)
988 {
989 TI_DBG1(("tddmReportDevice: oneDeviceData is NULL!!!\n"));
990 }
991 else
992 {
993 agRoot = oneDeviceData->agRoot;
994 oneDeviceData->devMCN = devMCN;
995 TI_DBG2(("tddmReportDevice: sasAddrHi 0x%08x sasAddrLo 0x%08x\n", sasAddressHi, sasAddressLo));
996 if (oneDeviceData->directlyAttached == agTRUE)
997 {
998 finalMCN = localMCN;
999 TI_DBG2(("tddmReportDevice: directlyAttached, Final MCN 0x%08x\n", finalMCN));
1000 }
1001 else
1002 {
1003 finalMCN = MIN(devMCN, localMCN);
1004 TI_DBG2(("tddmReportDevice: Not directlyAttached, Final MCN 0x%08x\n", finalMCN));
1005 }
1006 if ( oneDeviceData->registered == agTRUE)
1007 {
1008 /* saSetDeviceInfo to change MCN, using finalMCN */
1009 option = 8; /* setting only MCN 1000b */
1010 param = finalMCN << 24;
1011 TI_DBG2(("tddmReportDevice: option 0x%x param 0x%x MCN 0x%x\n", option, param, finalMCN));
1012 saSetDeviceInfo(agRoot, agNULL, 0, oneDeviceData->agDevHandle, option, param, ossaSetDeviceInfoCB);
1013 }
1014 else
1015 {
1016 TI_DBG1(("tddmReportDevice: oneDeviceData is not yet registered !!!\n"));
1017 }
1018 oneDeviceData->finalMCN = finalMCN;
1019 }
1020 }
1021 else if (flag == dmDeviceRateChange)
1022 {
1023 TI_DBG1(("tddmReportDevice: dmDeviceRateChange \n"));
1024 sasAddressHi = TD_GET_SAS_ADDRESSHI(dmDeviceInfo->sasAddressHi);
1025 sasAddressLo = TD_GET_SAS_ADDRESSLO(dmDeviceInfo->sasAddressLo);
1026 oneDeviceData = tddmPortSASDeviceFind(tiRoot, onePortContext, sasAddressLo, sasAddressHi);
1027 if (oneDeviceData == agNULL)
1028 {
1029 TI_DBG1(("tddmReportDevice: oneDeviceData is NULL!!!\n"));
1030 }
1031 else
1032 {
1033 agRoot = oneDeviceData->agRoot;
1034 if ( oneDeviceData->registered == agTRUE)
1035 {
1036 option = 0x20; /* bit 5 */
1037 DLR = DEVINFO_GET_LINKRATE(dmDeviceInfo);
1038 param = DLR << 28;
1039 TI_DBG1(("tddmReportDevice: option 0x%x param 0x%x DLR 0x%x\n", option, param, DLR));
1040 saSetDeviceInfo(agRoot, agNULL, 0, oneDeviceData->agDevHandle, option, param, ossaSetDeviceInfoCB);
1041
1042 }
1043 else
1044 {
1045 TI_DBG1(("tddmReportDevice: oneDeviceData is not yet registered !!!\n"));
1046 }
1047
1048 }
1049 }
1050 else
1051 {
1052 TI_DBG1(("tddmReportDevice: unknown flag 0x%x, wrong\n", flag));
1053 }
1054
1055 return;
1056}
1057
1058osGLOBAL void
1059tdsaUpdateMCN(
1060 dmRoot_t *dmRoot,
1061 tdsaPortContext_t *onePortContext
1062 )
1063{
1064 tdsaRoot_t *tdsaRoot;
1065 tdsaContext_t *tdsaAllShared;
1067 tdsaDeviceData_t *oneDeviceData = agNULL;
1068 tdList_t *DeviceListList;
1069 bit32 localMCN = 0, finalMCN = 0;
1070 bit32 devMCN = 1;
1071 bit32 option;
1072 bit32 param;
1073
1074 TI_DBG3(("tdsaUpdateMCN: start\n"));
1075 tdsaRoot = (tdsaRoot_t *)dmRoot->tdData;
1076 if (tdsaRoot == agNULL)
1077 {
1078 TI_DBG1(("tdsaUpdateMCN: tdsaRoot is NULL\n"));
1079 return;
1080 }
1081
1082 tdsaAllShared = &(tdsaRoot->tdsaAllShared);
1083 if (tdsaAllShared == agNULL)
1084 {
1085 TI_DBG1(("tdsaUpdateMCN: tdsaAllShared is NULL\n"));
1086 return;
1087 }
1088
1089 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
1090 if (tiRoot == agNULL)
1091 {
1092 TI_DBG1(("tdsaUpdateMCN: tiRoot is NULL\n"));
1093 return;
1094 }
1095
1096 if (onePortContext->valid == agFALSE)
1097 {
1098 TI_DBG1(("tdsaUpdateMCN: onePortContext is invalid\n"));
1099 return;
1100 }
1101
1102 TI_DBG3(("tdsaUpdateMCN: pid %d\n", onePortContext->id));
1103
1104 localMCN = tdsaFindLocalMCN(tiRoot, onePortContext);
1105
1106 if (TDLIST_EMPTY(&(tdsaAllShared->MainDeviceList)))
1107 {
1108 TI_DBG1(("tdsaUpdateMCN: empty device list\n"));
1109 return;
1110 }
1111
1112 /* update directly and behind expander device */
1113 DeviceListList = tdsaAllShared->MainDeviceList.flink;
1114 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
1115 {
1116 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
1117 if (oneDeviceData == agNULL)
1118 {
1119 TI_DBG1(("tdsaUpdateMCN: oneDeviceData is NULL!!!\n"));
1120 return;
1121 }
1122 TI_DBG3(("tdsaUpdateMCN: loop did %d\n", oneDeviceData->id));
1123 TI_DBG3(("tdsaUpdateMCN: sasAddrHi 0x%08x sasAddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
1124 devMCN = oneDeviceData->devMCN;
1125 if ( oneDeviceData->tdPortContext == onePortContext)
1126 {
1127 if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE && oneDeviceData->directlyAttached == agTRUE)
1128 {
1129 TI_DBG3(("tdsaUpdateMCN: found directly attached\n"));
1130 finalMCN = localMCN;
1131 TI_DBG3(("tdsaUpdateMCN: devMCN 0x%08x localMCN 0x%08x\n", devMCN, localMCN));
1132 TI_DBG3(("tdsaUpdateMCN: finalMCN 0x%08x\n", finalMCN));
1133 if (oneDeviceData->finalMCN != finalMCN)
1134 {
1135 /* saSetDeviceInfo using finalMCN */
1136 option = 8; /* setting only MCN 1000b */
1137 param = finalMCN << 24;
1138 TI_DBG3(("tdsaUpdateMCN: option 0x%x param 0x%x MCN 0x%x\n", option, param, finalMCN));
1139 saSetDeviceInfo(oneDeviceData->agRoot, agNULL, 0, oneDeviceData->agDevHandle, option, param, ossaSetDeviceInfoCB);
1140 oneDeviceData->finalMCN = finalMCN;
1141 }
1142
1143 }
1144 else if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE && oneDeviceData->directlyAttached == agFALSE)
1145 {
1146 TI_DBG3(("tdsaUpdateMCN: found behind expander device\n"));
1147 finalMCN = MIN(localMCN, devMCN);
1148 TI_DBG3(("tdsaUpdateMCN: devMCN 0x%08x localMCN 0x%08x\n", devMCN, localMCN));
1149 TI_DBG3(("tdsaUpdateMCN: finalMCN 0x%08x\n", finalMCN));
1150 if (oneDeviceData->finalMCN != finalMCN)
1151 {
1152 /* saSetDeviceInfo using finalMCN */
1153 option = 8; /* setting only MCN 1000b */
1154 param = finalMCN << 24;
1155 TI_DBG3(("tdsaUpdateMCN: option 0x%x param 0x%x MCN 0x%x\n", option, param, finalMCN));
1156 saSetDeviceInfo(oneDeviceData->agRoot, agNULL, 0, oneDeviceData->agDevHandle, option, param, ossaSetDeviceInfoCB);
1157 oneDeviceData->finalMCN = finalMCN;
1158 }
1159
1160 }
1161 DeviceListList = DeviceListList->flink;
1162 }
1163 else
1164 {
1165 if (oneDeviceData->tdPortContext != agNULL)
1166 {
1167 TI_DBG3(("tdsaUpdateMCN: different portcontext; oneDeviceData->tdPortContext pid %d oneportcontext pid %d\n", oneDeviceData->tdPortContext->id, onePortContext->id));
1168 }
1169 else
1170 {
1171 TI_DBG3(("tdsaUpdateMCN: different portcontext; oneDeviceData->tdPortContext pid NULL oneportcontext pid %d\n", onePortContext->id));
1172 }
1173 DeviceListList = DeviceListList->flink;
1174 }
1175 } /* while */
1176
1177 return;
1178}
1179
1181tddmSATADeviceTypeDecode(bit8 * pSignature)
1182{
1183 return (bit8)tdssSATADeviceTypeDecode(pSignature);
1184}
1185
1186
1187osGLOBAL void
1189 dmRoot_t *dmRoot,
1190 bit32 syncLockId
1191 )
1192{
1193 tdsaRoot_t *tdsaRoot;
1194 tdsaContext_t *tdsaAllShared;
1196 bit32 offset = 0;
1197
1198 TI_DBG7(("tddmSingleThreadedEnter: start\n"));
1199
1200 tdsaRoot = (tdsaRoot_t *)dmRoot->tdData;
1201 if (tdsaRoot == agNULL)
1202 {
1203 TI_DBG1(("tddmSingleThreadedEnter: tdsaRoot is NULL\n"));
1204 return;
1205 }
1206
1207 tdsaAllShared = &(tdsaRoot->tdsaAllShared);
1208 if (tdsaAllShared == agNULL)
1209 {
1210 TI_DBG1(("tddmSingleThreadedEnter: tdsaAllShared is NULL\n"));
1211 return;
1212 }
1213
1214 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
1215 if (tiRoot == agNULL)
1216 {
1217 TI_DBG1(("tddmSingleThreadedEnter: tiRoot is NULL\n"));
1218 return;
1219 }
1220 offset = tdsaAllShared->MaxNumLLLocks + tdsaAllShared->MaxNumOSLocks + TD_MAX_LOCKS;
1221
1222 ostiSingleThreadedEnter(tiRoot, syncLockId + offset);
1223 return;
1224}
1225
1226osGLOBAL void
1228 dmRoot_t *dmRoot,
1229 bit32 syncLockId
1230 )
1231{
1232 tdsaRoot_t *tdsaRoot;
1233 tdsaContext_t *tdsaAllShared;
1235 bit32 offset = 0;
1236
1237 TI_DBG7(("tddmSingleThreadedLeave: start\n"));
1238
1239 tdsaRoot = (tdsaRoot_t *)dmRoot->tdData;
1240 if (tdsaRoot == agNULL)
1241 {
1242 TI_DBG1(("tddmSingleThreadedLeave: tdsaRoot is NULL\n"));
1243 return;
1244 }
1245
1246 tdsaAllShared = &(tdsaRoot->tdsaAllShared);
1247 if (tdsaAllShared == agNULL)
1248 {
1249 TI_DBG1(("tddmSingleThreadedLeave: tdsaAllShared is NULL\n"));
1250 return;
1251 }
1252
1253 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
1254 if (tiRoot == agNULL)
1255 {
1256 TI_DBG1(("tddmSingleThreadedLeave: tiRoot is NULL\n"));
1257 return;
1258 }
1259 offset = tdsaAllShared->MaxNumLLLocks + tdsaAllShared->MaxNumOSLocks + TD_MAX_LOCKS;
1260
1261 ostiSingleThreadedLeave(tiRoot, syncLockId + offset);
1262
1263 return;
1264}
1265
1267 dmRoot_t *dmRoot,
1268 char *key,
1269 char *subkey1,
1270 char *subkey2,
1271 char *subkey3,
1272 char *subkey4,
1273 char *subkey5,
1274 char *valueName,
1275 char *buffer,
1276 bit32 bufferLen,
1277 bit32 *lenReceived
1278 )
1279{
1280 bit32 ret = tiError;
1281
1282 TI_DBG7(("tddmGetTransportParam: start\n"));
1284 key,
1285 subkey1,
1286 subkey2,
1287 subkey3,
1288 subkey4,
1289 subkey5,
1290 valueName,
1291 buffer,
1292 bufferLen,
1293 lenReceived
1294 );
1295
1296 return ret;
1297}
1298
1299#endif /* FDS_DM */
1300
@ dmDeviceArrival
Definition: dm.h:85
@ dmDeviceNoChange
Definition: dm.h:84
@ dmDeviceRateChange
Definition: dm.h:88
@ dmDeviceRemoval
Definition: dm.h:86
@ dmDeviceMCNChange
Definition: dm.h:87
@ dmDiscCompleted
Definition: dm.h:69
@ dmDiscAborted
Definition: dm.h:71
@ dmDiscAbortInvalid
Definition: dm.h:74
@ dmDiscFailed
Definition: dm.h:70
@ dmDiscAbortInProgress
Definition: dm.h:75
@ dmDiscAbortFailed
Definition: dm.h:72
#define DEVICE_IS_SATA_DEVICE(DeviceData)
Definition: dmdefs.h:1172
#define DEVICE_IS_STP_INITIATOR(DeviceData)
Definition: dmdefs.h:1157
#define DEVINFO_GET_EXT_MCN(devInfo)
Definition: dmdefs.h:1196
#define DEVICE_IS_STP_TARGET(DeviceData)
Definition: dmdefs.h:1166
#define MIN(a, b)
MIN macro.
Definition: dmdefs.h:88
#define DEVICE_IS_SSP_INITIATOR(DeviceData)
Definition: dmdefs.h:1154
#define SATA_ATAPI_DEVICE
Definition: dmdefs.h:1102
#define DEVICE_IS_SMP_TARGET(DeviceData)
Definition: dmdefs.h:1169
#define DEVICE_IS_SMP_INITIATOR(DeviceData)
Definition: dmdefs.h:1160
#define DEVINFO_GET_LINKRATE(devInfo)
Definition: dmdefs.h:1186
#define DEVICE_STP_BIT
Definition: dmdefs.h:1150
#define DEVICE_SSP_BIT
Definition: dmdefs.h:1149
#define DEVICE_IS_SSP_TARGET(DeviceData)
Definition: dmdefs.h:1163
#define ATAPI_DEVICE_FLAG
Definition: dmdefs.h:1097
#define ITD_DSTATE_COMPLETED
Definition: itddefs.h:39
U32 ostiGetTransportParam(tiRoot_t *ptiRoot, S08 *key, S08 *subkey1, S08 *subkey2, S08 *subkey3, S08 *subkey4, S08 *subkey5, S08 *valueName, S08 *buffer, U32 bufferLen, U32 *lenReceived)
Definition: lxosapi.c:464
void ostiSingleThreadedLeave(tiRoot_t *ptiRoot, U32 queueId)
Definition: osapi.c:534
void ostiInitiatorEvent(tiRoot_t *ptiRoot, tiPortalContext_t *ptiPortalContext, tiDeviceHandle_t *ptiDevHandle, tiIntrEventType_t eventType, U32 eventStatus, void *parm)
Definition: osapi.c:49
void ostiSingleThreadedEnter(tiRoot_t *ptiRoot, U32 queueId)
Definition: osapi.c:514
#define osti_memcpy(des, src, n)
Definition: osstring.h:64
#define osGLOBAL
Definition: ostypes.h:147
#define agNULL
Definition: ostypes.h:151
unsigned int bit32
Definition: ostypes.h:99
#define agFALSE
Definition: ostypes.h:150
#define agTRUE
Definition: ostypes.h:149
unsigned char bit8
Definition: ostypes.h:97
#define AGSA_PORT_IO_ABORT
Definition: sa.h:1172
GLOBAL bit32 saSetDeviceInfo(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 queueNum, agsaDevHandle_t *agDevHandle, bit32 option, bit32 param, ossaSetDeviceInfoCB_t agCB)
Set Device Information.
Definition: sadisc.c:672
GLOBAL bit32 saDeregisterDeviceHandle(agsaRoot_t *agRoot, agsaContext_t *agContext, agsaDevHandle_t *agDevHandle, bit32 queueNum)
Function for target to remove stale initiator device handle.
Definition: sadisc.c:83
GLOBAL bit32 saPortControl(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 queueNum, agsaPortContext_t *agPortContext, bit32 portOperation, bit32 param0, bit32 param1)
Initiate a Port COntrol IOMB command.
Definition: saport.c:422
GLOBAL bit32 saRegisterNewDevice(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 queueNum, agsaDeviceInfo_t *agDeviceInfo, agsaPortContext_t *agPortContext, bit16 hostAssignedDeviceId)
Register New Device from a specific local port.
Definition: sadisc.c:302
GLOBAL void ossaSetDeviceInfoCB(agsaRoot_t *agRoot, agsaContext_t *agContext, agsaDevHandle_t *agDevHandle, bit32 status, bit32 option, bit32 param)
ossaSetDeviceInfoCB
Definition: ossacmnapi.c:8174
osGLOBAL bit32 smDeregisterDevice(smRoot_t *smRoot, agsaDevHandle_t *agDevHandle, smDeviceHandle_t *smDeviceHandle)
Definition: smsat.c:85
bit32 sasAddressHi
Definition: tdtypes.h:229
bit32 sasAddressLo
Definition: tdtypes.h:228
data structure stores OS specific and LL specific context
Definition: sa.h:1658
void * osData
Definition: sa.h:1659
void * sdkData
Definition: sa.h:1660
bit8 sasAddressHi[4]
Definition: sa.h:2580
bit8 devType_S_Rate
Definition: sa.h:2567
bit16 firstBurstSize
Definition: sa.h:2564
bit16 smpTimeout
Definition: sa.h:2562
bit8 sasAddressLo[4]
Definition: sa.h:2581
bit32 flag
Definition: sa.h:2582
bit16 it_NexusTimeout
Definition: sa.h:2563
Definition: dm.h:91
void * tdData
Definition: dm.h:92
bit16 it_NexusTimeout
Definition: dm.h:98
bit8 sasAddressLo[4]
Definition: dm.h:103
bit8 initiator_ssp_stp_smp
Definition: dm.h:104
bit16 ext
Definition: dm.h:114
bit8 sataDeviceType
Definition: dm.h:115
bit8 devType_S_Rate
Definition: dm.h:101
bit16 firstBurstSize
Definition: dm.h:99
bit16 smpTimeout
Definition: dm.h:97
bit8 sasAddressHi[4]
Definition: dm.h:102
bit8 target_ssp_stp_smp
Definition: dm.h:105
bit32 satDeviceType
Definition: tdtypes.h:302
bit32 IDDeviceValid
Definition: tdtypes.h:305
tdList_t * flink
Definition: tdlist.h:38
data structure for SAS/SATA context at TD layer
Definition: tdsatypes.h:199
agsaRoot_t agRootNonInt
Definition: tdsatypes.h:207
struct tdsaRootOsData_s agRootOsDataForInt
Definition: tdsatypes.h:203
tdList_t MainDeviceList
Definition: tdsatypes.h:250
tdList_t FreeDeviceList
Definition: tdsatypes.h:249
bit32 MaxNumLLLocks
Definition: tdsatypes.h:310
bit32 MaxNumOSLocks
Definition: tdsatypes.h:309
data structure for SAS device list This structure maintains the device as a list and information abou...
Definition: tdtypes.h:322
agsaRoot_t * agRoot
Definition: tdtypes.h:335
bit8 target_ssp_stp_smp
Definition: tdtypes.h:343
tdList_t MainLink
Definition: tdtypes.h:328
agsaDevHandle_t * agDevHandle
Definition: tdtypes.h:336
bit8 initiator_ssp_stp_smp
Definition: tdtypes.h:342
bit8 directlyAttached
Definition: tdtypes.h:367
struct tdsaPortContext_s * tdPortContext
Definition: tdtypes.h:349
TDSASAddressID_t SASAddressID
Definition: tdtypes.h:341
satDeviceData_t satDevData
Definition: tdtypes.h:346
agsaDeviceInfo_t agDeviceInfo
Definition: tdtypes.h:357
struct tdsaDeviceData_s * ExpDevice
Definition: tdtypes.h:361
agsaContext_t agContext
Definition: tdtypes.h:358
data structure for TD port context This structure maintains information about the port such as ID add...
Definition: tdtypes.h:412
bit32 sasRemoteAddressLo
Definition: tdtypes.h:433
bit32 DiscoveryState
Definition: tdtypes.h:416
bit32 sasRemoteAddressHi
Definition: tdtypes.h:432
bit8 PhyIDList[TD_MAX_NUM_PHYS]
Definition: tdtypes.h:442
agsaPortContext_t * agPortContext
Definition: tdtypes.h:446
agsaRoot_t * agRoot
Definition: tdtypes.h:445
tiPortalContext_t * tiPortalContext
Definition: tdtypes.h:443
data structure OS root from the view of lower layer. TD Layer interrupt/non-interrupt context support...
Definition: tdtypes.h:151
tiRoot_t * tiRoot
Definition: tdtypes.h:152
the root data structure for TD layer
Definition: tdsatypes.h:362
tdsaContext_t tdsaAllShared
Definition: tdsatypes.h:364
bit8 initiator_ssp_stp_smp
Definition: tdtypes.h:396
bit32 sasAddressLo
Definition: tdtypes.h:395
bit8 target_ssp_stp_smp
Definition: tdtypes.h:397
bit32 sasAddressHi
Definition: tdtypes.h:394
Definition: titypes.h:61
void * tdData
Definition: titypes.h:63
#define TD_GET_SAS_ADDRESSHI(sasAddressHi)
Definition: tddefs.h:1193
#define TD_GET_SAS_ADDRESSLO(sasAddressLo)
Definition: tddefs.h:1190
#define TD_ASSERT
Definition: tddefs.h:1055
#define TD_MAX_NUM_PHYS
Definition: tddefs.h:108
@ TD_DEVICE_LOCK
Definition: tddefs.h:1146
@ TD_MAX_LOCKS
Definition: tddefs.h:1187
#define TD_XFER_RDY_PRIORTY_DEVICE_FLAG
Definition: tddefs.h:1196
osGLOBAL void tddmReportDevice(dmRoot_t *dmRoot, dmPortContext_t *dmPortContext, dmDeviceInfo_t *dmDeviceInfo, dmDeviceInfo_t *dmExpDeviceInfo, bit32 flag)
osGLOBAL bit8 tddmSATADeviceTypeDecode(bit8 *pSignature)
osGLOBAL void tddmSingleThreadedLeave(dmRoot_t *dmRoot, bit32 syncLockId)
osGLOBAL void tddmDiscoverCB(dmRoot_t *dmRoot, dmPortContext_t *dmPortContext, bit32 eventStatus)
osGLOBAL bit32 tddmGetTransportParam(dmRoot_t *dmRoot, char *key, char *subkey1, char *subkey2, char *subkey3, char *subkey4, char *subkey5, char *valueName, char *buffer, bit32 bufferLen, bit32 *lenReceived)
osGLOBAL void tddmQueryDiscoveryCB(dmRoot_t *dmRoot, dmPortContext_t *dmPortContext, bit32 discType, bit32 discState)
osGLOBAL bit32 tddmRotateQnumber(dmRoot_t *dmRoot, agsaDevHandle_t *agDevHandle)
osGLOBAL void tddmSingleThreadedEnter(dmRoot_t *dmRoot, bit32 syncLockId)
__FBSDID("$FreeBSD$")
#define TDLIST_OBJECT_BASE(baseType, fieldName, fieldPtr)
Definition: tdlist.h:161
#define TDLIST_NOT_EMPTY(listHdr)
Definition: tdlist.h:76
#define TDLIST_ENQUEUE_AT_TAIL(toAddHdr, listHdr)
Definition: tdlist.h:65
#define TDLIST_EMPTY(listHdr)
Definition: tdlist.h:73
#define TDLIST_DEQUEUE_FROM_HEAD(atHeadHdr, listHdr)
Definition: tdlist.h:93
void tdsaSingleThreadedEnter(tiRoot_t *ptiRoot, bit32 queueId)
Definition: tdmisc.c:2862
void tdsaSingleThreadedLeave(tiRoot_t *ptiRoot, bit32 queueId)
Definition: tdmisc.c:2875
osGLOBAL bit32 tdsaAbortAll(tiRoot_t *tiRoot, agsaRoot_t *agRoot, tdsaDeviceData_t *oneDeviceData)
Definition: tdmisc.c:354
FORCEINLINE bit32 tdsaRotateQnumber(tiRoot_t *tiRoot, tdsaDeviceData_t *oneDeviceData)
Definition: tdport.c:7956
osGLOBAL bit32 tdsaFindLocalMCN(tiRoot_t *tiRoot, tdsaPortContext_t *onePortContext)
#define TD_SATA_DEVICE
Definition: tdsatypes.h:42
#define TD_SAS_DEVICE
Definition: tdsatypes.h:41
@ tiError
Definition: tidefs.h:68
@ tiDiscFailed
Definition: tidefs.h:478
@ tiDiscOK
Definition: tidefs.h:477
@ tiIntrEventTypeDiscovery
Definition: tidefs.h:458
#define TI_DBG3(a)
Definition: tiglobal.h:50
#define TI_DBG1(a)
Definition: tiglobal.h:48
#define TI_DBG7(a)
Definition: tiglobal.h:54
#define TI_DBG2(a)
Definition: tiglobal.h:49