1*4e1bc9a0SAchim Leubner /*******************************************************************************
2*4e1bc9a0SAchim Leubner *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
3*4e1bc9a0SAchim Leubner *
4*4e1bc9a0SAchim Leubner *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5*4e1bc9a0SAchim Leubner *that the following conditions are met:
6*4e1bc9a0SAchim Leubner *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7*4e1bc9a0SAchim Leubner *following disclaimer.
8*4e1bc9a0SAchim Leubner *2. Redistributions in binary form must reproduce the above copyright notice,
9*4e1bc9a0SAchim Leubner *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10*4e1bc9a0SAchim Leubner *with the distribution.
11*4e1bc9a0SAchim Leubner *
12*4e1bc9a0SAchim Leubner *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13*4e1bc9a0SAchim Leubner *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14*4e1bc9a0SAchim Leubner *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15*4e1bc9a0SAchim Leubner *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16*4e1bc9a0SAchim Leubner *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17*4e1bc9a0SAchim Leubner *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18*4e1bc9a0SAchim Leubner *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19*4e1bc9a0SAchim Leubner *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20*4e1bc9a0SAchim Leubner
21*4e1bc9a0SAchim Leubner ********************************************************************************/
22*4e1bc9a0SAchim Leubner #include <sys/cdefs.h>
23*4e1bc9a0SAchim Leubner #include <dev/pms/config.h>
24*4e1bc9a0SAchim Leubner
25*4e1bc9a0SAchim Leubner #include <dev/pms/freebsd/driver/common/osenv.h>
26*4e1bc9a0SAchim Leubner #include <dev/pms/freebsd/driver/common/ostypes.h>
27*4e1bc9a0SAchim Leubner #include <dev/pms/freebsd/driver/common/osdebug.h>
28*4e1bc9a0SAchim Leubner
29*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/api/titypes.h>
30*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/api/ostiapi.h>
31*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/api/tiapi.h>
32*4e1bc9a0SAchim Leubner /* for TIDEBUG_MSG */
33*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/api/tiglobal.h>
34*4e1bc9a0SAchim Leubner
35*4e1bc9a0SAchim Leubner #ifdef FDS_SM
36*4e1bc9a0SAchim Leubner
37*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sat/api/sm.h>
38*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sat/api/smapi.h>
39*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sat/api/tdsmapi.h>
40*4e1bc9a0SAchim Leubner
41*4e1bc9a0SAchim Leubner #ifdef FDS_DM
42*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/discovery/api/dm.h>
43*4e1bc9a0SAchim Leubner #endif
44*4e1bc9a0SAchim Leubner
45*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER
46*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h>
47*4e1bc9a0SAchim Leubner #endif
48*4e1bc9a0SAchim Leubner
49*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h>
50*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h>
51*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h>
52*4e1bc9a0SAchim Leubner
53*4e1bc9a0SAchim Leubner #if defined(SM_DEBUG)
54*4e1bc9a0SAchim Leubner extern bit32 gSMDebugLevel;
55*4e1bc9a0SAchim Leubner #endif
56*4e1bc9a0SAchim Leubner
57*4e1bc9a0SAchim Leubner osGLOBAL void
smReportRemovalDirect(tiRoot_t * tiRoot,agsaRoot_t * agRoot,tdsaDeviceData_t * oneDeviceData)58*4e1bc9a0SAchim Leubner smReportRemovalDirect(
59*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot,
60*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
61*4e1bc9a0SAchim Leubner tdsaDeviceData_t *oneDeviceData
62*4e1bc9a0SAchim Leubner )
63*4e1bc9a0SAchim Leubner {
64*4e1bc9a0SAchim Leubner tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
65*4e1bc9a0SAchim Leubner tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
66*4e1bc9a0SAchim Leubner bit8 PhyID;
67*4e1bc9a0SAchim Leubner
68*4e1bc9a0SAchim Leubner TI_DBG2(("smReportRemovalDirect: start\n"));
69*4e1bc9a0SAchim Leubner
70*4e1bc9a0SAchim Leubner PhyID = oneDeviceData->phyID;
71*4e1bc9a0SAchim Leubner
72*4e1bc9a0SAchim Leubner tdsaAbortAll(tiRoot, agRoot, oneDeviceData);
73*4e1bc9a0SAchim Leubner oneDeviceData->valid = agFALSE;
74*4e1bc9a0SAchim Leubner oneDeviceData->valid2 = agFALSE;
75*4e1bc9a0SAchim Leubner /* put onedevicedata back to free list */
76*4e1bc9a0SAchim Leubner osti_memset(&(oneDeviceData->satDevData.satIdentifyData), 0xFF, sizeof(agsaSATAIdentifyData_t));
77*4e1bc9a0SAchim Leubner TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
78*4e1bc9a0SAchim Leubner TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList));
79*4e1bc9a0SAchim Leubner
80*4e1bc9a0SAchim Leubner /* notifying link up */
81*4e1bc9a0SAchim Leubner ostiPortEvent (
82*4e1bc9a0SAchim Leubner tiRoot,
83*4e1bc9a0SAchim Leubner tiPortLinkUp,
84*4e1bc9a0SAchim Leubner tiSuccess,
85*4e1bc9a0SAchim Leubner (void *)tdsaAllShared->Ports[PhyID].tiPortalContext
86*4e1bc9a0SAchim Leubner );
87*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER
88*4e1bc9a0SAchim Leubner /* triggers discovery */
89*4e1bc9a0SAchim Leubner ostiPortEvent(
90*4e1bc9a0SAchim Leubner tiRoot,
91*4e1bc9a0SAchim Leubner tiPortDiscoveryReady,
92*4e1bc9a0SAchim Leubner tiSuccess,
93*4e1bc9a0SAchim Leubner (void *) tdsaAllShared->Ports[PhyID].tiPortalContext
94*4e1bc9a0SAchim Leubner );
95*4e1bc9a0SAchim Leubner #endif
96*4e1bc9a0SAchim Leubner return;
97*4e1bc9a0SAchim Leubner }
98*4e1bc9a0SAchim Leubner
99*4e1bc9a0SAchim Leubner osGLOBAL void
smReportRemoval(tiRoot_t * tiRoot,agsaRoot_t * agRoot,tdsaDeviceData_t * oneDeviceData,tdsaPortContext_t * onePortContext)100*4e1bc9a0SAchim Leubner smReportRemoval(
101*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot,
102*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
103*4e1bc9a0SAchim Leubner tdsaDeviceData_t *oneDeviceData,
104*4e1bc9a0SAchim Leubner tdsaPortContext_t *onePortContext
105*4e1bc9a0SAchim Leubner )
106*4e1bc9a0SAchim Leubner {
107*4e1bc9a0SAchim Leubner TI_DBG2(("smReportRemoval: start\n"));
108*4e1bc9a0SAchim Leubner
109*4e1bc9a0SAchim Leubner if (oneDeviceData->registered == agTRUE)
110*4e1bc9a0SAchim Leubner {
111*4e1bc9a0SAchim Leubner /*
112*4e1bc9a0SAchim Leubner 1. remove this device
113*4e1bc9a0SAchim Leubner 2. device removal event
114*4e1bc9a0SAchim Leubner */
115*4e1bc9a0SAchim Leubner tdsaAbortAll(tiRoot, agRoot, oneDeviceData);
116*4e1bc9a0SAchim Leubner oneDeviceData->valid = agFALSE;
117*4e1bc9a0SAchim Leubner oneDeviceData->valid2 = agFALSE;
118*4e1bc9a0SAchim Leubner oneDeviceData->registered = agFALSE;
119*4e1bc9a0SAchim Leubner ostiInitiatorEvent(
120*4e1bc9a0SAchim Leubner tiRoot,
121*4e1bc9a0SAchim Leubner onePortContext->tiPortalContext,
122*4e1bc9a0SAchim Leubner agNULL,
123*4e1bc9a0SAchim Leubner tiIntrEventTypeDeviceChange,
124*4e1bc9a0SAchim Leubner tiDeviceRemoval,
125*4e1bc9a0SAchim Leubner agNULL
126*4e1bc9a0SAchim Leubner );
127*4e1bc9a0SAchim Leubner }
128*4e1bc9a0SAchim Leubner
129*4e1bc9a0SAchim Leubner return;
130*4e1bc9a0SAchim Leubner }
131*4e1bc9a0SAchim Leubner osGLOBAL void
smHandleDirect(tiRoot_t * tiRoot,agsaRoot_t * agRoot,tdsaDeviceData_t * oneDeviceData,void * IDdata)132*4e1bc9a0SAchim Leubner smHandleDirect(
133*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot,
134*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
135*4e1bc9a0SAchim Leubner tdsaDeviceData_t *oneDeviceData,
136*4e1bc9a0SAchim Leubner void *IDdata
137*4e1bc9a0SAchim Leubner )
138*4e1bc9a0SAchim Leubner {
139*4e1bc9a0SAchim Leubner tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
140*4e1bc9a0SAchim Leubner tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
141*4e1bc9a0SAchim Leubner agsaSATAIdentifyData_t *pSATAIdData;
142*4e1bc9a0SAchim Leubner tdList_t *DeviceListList;
143*4e1bc9a0SAchim Leubner tdsaDeviceData_t *tmpOneDeviceData = agNULL;
144*4e1bc9a0SAchim Leubner int new_device = agTRUE;
145*4e1bc9a0SAchim Leubner bit8 PhyID;
146*4e1bc9a0SAchim Leubner
147*4e1bc9a0SAchim Leubner TI_DBG2(("smHandleDirect: start\n"));
148*4e1bc9a0SAchim Leubner PhyID = oneDeviceData->phyID;
149*4e1bc9a0SAchim Leubner
150*4e1bc9a0SAchim Leubner pSATAIdData = (agsaSATAIdentifyData_t *)IDdata;
151*4e1bc9a0SAchim Leubner //tdhexdump("satAddSATAIDDevCB after", (bit8 *)pSATAIdData, sizeof(agsaSATAIdentifyData_t));
152*4e1bc9a0SAchim Leubner
153*4e1bc9a0SAchim Leubner /* compare idenitfy device data to the exiting list */
154*4e1bc9a0SAchim Leubner DeviceListList = tdsaAllShared->MainDeviceList.flink;
155*4e1bc9a0SAchim Leubner while (DeviceListList != &(tdsaAllShared->MainDeviceList))
156*4e1bc9a0SAchim Leubner {
157*4e1bc9a0SAchim Leubner tmpOneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
158*4e1bc9a0SAchim Leubner if (tmpOneDeviceData == agNULL)
159*4e1bc9a0SAchim Leubner {
160*4e1bc9a0SAchim Leubner TI_DBG1(("smHandleDirect: tmpOneDeviceData is NULL!!!\n"));
161*4e1bc9a0SAchim Leubner return;
162*4e1bc9a0SAchim Leubner }
163*4e1bc9a0SAchim Leubner TI_DBG1(("smHandleDirect: LOOP tmpOneDeviceData %p did %d\n", tmpOneDeviceData, tmpOneDeviceData->id));
164*4e1bc9a0SAchim Leubner //tdhexdump("smHandleDirect LOOP", (bit8 *)&tmpOneDeviceData->satDevData.satIdentifyData, sizeof(agsaSATAIdentifyData_t));
165*4e1bc9a0SAchim Leubner
166*4e1bc9a0SAchim Leubner /* what is unique ID for sata device -> response of identify devicedata; not really
167*4e1bc9a0SAchim Leubner Let's compare serial number, firmware version, model number
168*4e1bc9a0SAchim Leubner */
169*4e1bc9a0SAchim Leubner if ( tmpOneDeviceData->DeviceType == TD_SATA_DEVICE &&
170*4e1bc9a0SAchim Leubner (osti_memcmp (tmpOneDeviceData->satDevData.satIdentifyData.serialNumber,
171*4e1bc9a0SAchim Leubner pSATAIdData->serialNumber,
172*4e1bc9a0SAchim Leubner 20) == 0) &&
173*4e1bc9a0SAchim Leubner (osti_memcmp (tmpOneDeviceData->satDevData.satIdentifyData.firmwareVersion,
174*4e1bc9a0SAchim Leubner pSATAIdData->firmwareVersion,
175*4e1bc9a0SAchim Leubner 8) == 0) &&
176*4e1bc9a0SAchim Leubner (osti_memcmp (tmpOneDeviceData->satDevData.satIdentifyData.modelNumber,
177*4e1bc9a0SAchim Leubner pSATAIdData->modelNumber,
178*4e1bc9a0SAchim Leubner 40) == 0)
179*4e1bc9a0SAchim Leubner )
180*4e1bc9a0SAchim Leubner {
181*4e1bc9a0SAchim Leubner TI_DBG2(("smHandleDirect: did %d\n", tmpOneDeviceData->id));
182*4e1bc9a0SAchim Leubner new_device = agFALSE;
183*4e1bc9a0SAchim Leubner break;
184*4e1bc9a0SAchim Leubner }
185*4e1bc9a0SAchim Leubner DeviceListList = DeviceListList->flink;
186*4e1bc9a0SAchim Leubner }
187*4e1bc9a0SAchim Leubner
188*4e1bc9a0SAchim Leubner
189*4e1bc9a0SAchim Leubner if (new_device == agFALSE)
190*4e1bc9a0SAchim Leubner {
191*4e1bc9a0SAchim Leubner TI_DBG2(("smHandleDirect: old device data\n"));
192*4e1bc9a0SAchim Leubner tmpOneDeviceData->valid = agTRUE;
193*4e1bc9a0SAchim Leubner tmpOneDeviceData->valid2 = agTRUE;
194*4e1bc9a0SAchim Leubner /* save data field from new device data */
195*4e1bc9a0SAchim Leubner tmpOneDeviceData->agRoot = agRoot;
196*4e1bc9a0SAchim Leubner tmpOneDeviceData->agDevHandle = oneDeviceData->agDevHandle;
197*4e1bc9a0SAchim Leubner tmpOneDeviceData->agDevHandle->osData = tmpOneDeviceData; /* TD layer */
198*4e1bc9a0SAchim Leubner tmpOneDeviceData->tdPortContext = oneDeviceData->tdPortContext;
199*4e1bc9a0SAchim Leubner tmpOneDeviceData->phyID = oneDeviceData->phyID;
200*4e1bc9a0SAchim Leubner
201*4e1bc9a0SAchim Leubner /*
202*4e1bc9a0SAchim Leubner one SATA directly attached device per phy;
203*4e1bc9a0SAchim Leubner Therefore, deregister then register
204*4e1bc9a0SAchim Leubner */
205*4e1bc9a0SAchim Leubner saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData));
206*4e1bc9a0SAchim Leubner
207*4e1bc9a0SAchim Leubner if (tmpOneDeviceData->registered == agFALSE)
208*4e1bc9a0SAchim Leubner {
209*4e1bc9a0SAchim Leubner TI_DBG2(("smHandleDirect: re-registering old device data\n"));
210*4e1bc9a0SAchim Leubner /* already has old information; just register it again */
211*4e1bc9a0SAchim Leubner saRegisterNewDevice( /* smHandleDirect */
212*4e1bc9a0SAchim Leubner agRoot,
213*4e1bc9a0SAchim Leubner &tmpOneDeviceData->agContext,
214*4e1bc9a0SAchim Leubner 0,/*tdsaRotateQnumber(tiRoot, tmpOneDeviceData),*/
215*4e1bc9a0SAchim Leubner &tmpOneDeviceData->agDeviceInfo,
216*4e1bc9a0SAchim Leubner tmpOneDeviceData->tdPortContext->agPortContext,
217*4e1bc9a0SAchim Leubner 0
218*4e1bc9a0SAchim Leubner );
219*4e1bc9a0SAchim Leubner }
220*4e1bc9a0SAchim Leubner
221*4e1bc9a0SAchim Leubner // tdsaAbortAll(tiRoot, agRoot, oneDeviceData);
222*4e1bc9a0SAchim Leubner /* put tmpOneDeviceData back to free list */
223*4e1bc9a0SAchim Leubner osti_memset(&(oneDeviceData->satDevData.satIdentifyData), 0xFF, sizeof(agsaSATAIdentifyData_t));
224*4e1bc9a0SAchim Leubner TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
225*4e1bc9a0SAchim Leubner TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList));
226*4e1bc9a0SAchim Leubner
227*4e1bc9a0SAchim Leubner TI_DBG2(("smHandleDirect: pid %d\n", tdsaAllShared->Ports[PhyID].portContext->id));
228*4e1bc9a0SAchim Leubner /* notifying link up */
229*4e1bc9a0SAchim Leubner ostiPortEvent (
230*4e1bc9a0SAchim Leubner tiRoot,
231*4e1bc9a0SAchim Leubner tiPortLinkUp,
232*4e1bc9a0SAchim Leubner tiSuccess,
233*4e1bc9a0SAchim Leubner (void *)tdsaAllShared->Ports[PhyID].tiPortalContext
234*4e1bc9a0SAchim Leubner );
235*4e1bc9a0SAchim Leubner
236*4e1bc9a0SAchim Leubner
237*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER
238*4e1bc9a0SAchim Leubner /* triggers discovery */
239*4e1bc9a0SAchim Leubner ostiPortEvent(
240*4e1bc9a0SAchim Leubner tiRoot,
241*4e1bc9a0SAchim Leubner tiPortDiscoveryReady,
242*4e1bc9a0SAchim Leubner tiSuccess,
243*4e1bc9a0SAchim Leubner (void *) tdsaAllShared->Ports[PhyID].tiPortalContext
244*4e1bc9a0SAchim Leubner );
245*4e1bc9a0SAchim Leubner #endif
246*4e1bc9a0SAchim Leubner return;
247*4e1bc9a0SAchim Leubner }
248*4e1bc9a0SAchim Leubner
249*4e1bc9a0SAchim Leubner TI_DBG2(("smHandleDirect: new device data\n"));
250*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.satIdentifyData = *pSATAIdData;
251*4e1bc9a0SAchim Leubner /* notifying link up */
252*4e1bc9a0SAchim Leubner ostiPortEvent (
253*4e1bc9a0SAchim Leubner tiRoot,
254*4e1bc9a0SAchim Leubner tiPortLinkUp,
255*4e1bc9a0SAchim Leubner tiSuccess,
256*4e1bc9a0SAchim Leubner (void *)tdsaAllShared->Ports[PhyID].tiPortalContext
257*4e1bc9a0SAchim Leubner );
258*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER
259*4e1bc9a0SAchim Leubner /* triggers discovery */
260*4e1bc9a0SAchim Leubner ostiPortEvent(
261*4e1bc9a0SAchim Leubner tiRoot,
262*4e1bc9a0SAchim Leubner tiPortDiscoveryReady,
263*4e1bc9a0SAchim Leubner tiSuccess,
264*4e1bc9a0SAchim Leubner (void *) tdsaAllShared->Ports[PhyID].tiPortalContext
265*4e1bc9a0SAchim Leubner );
266*4e1bc9a0SAchim Leubner #endif
267*4e1bc9a0SAchim Leubner
268*4e1bc9a0SAchim Leubner return;
269*4e1bc9a0SAchim Leubner }
270*4e1bc9a0SAchim Leubner
271*4e1bc9a0SAchim Leubner /*
272*4e1bc9a0SAchim Leubner combine satAddSATAIDDevCB(expander) and satAddSATAIDDevCB(directly attached)
273*4e1bc9a0SAchim Leubner */
274*4e1bc9a0SAchim Leubner osGLOBAL void
tdsmIDCompletedCB(smRoot_t * smRoot,smIORequest_t * smIORequest,smDeviceHandle_t * smDeviceHandle,bit32 status,void * IDdata)275*4e1bc9a0SAchim Leubner tdsmIDCompletedCB(
276*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
277*4e1bc9a0SAchim Leubner smIORequest_t *smIORequest,
278*4e1bc9a0SAchim Leubner smDeviceHandle_t *smDeviceHandle,
279*4e1bc9a0SAchim Leubner bit32 status,
280*4e1bc9a0SAchim Leubner void *IDdata
281*4e1bc9a0SAchim Leubner )
282*4e1bc9a0SAchim Leubner {
283*4e1bc9a0SAchim Leubner tdsaRoot_t *tdsaRoot;
284*4e1bc9a0SAchim Leubner tdsaContext_t *tdsaAllShared;
285*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot;
286*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot;
287*4e1bc9a0SAchim Leubner tdIORequestBody_t *tdIORequestBody;
288*4e1bc9a0SAchim Leubner tdsaDeviceData_t *oneDeviceData;
289*4e1bc9a0SAchim Leubner tdsaPortContext_t *onePortContext;
290*4e1bc9a0SAchim Leubner tiPortalContext_t *tiPortalContext;
291*4e1bc9a0SAchim Leubner bit32 pid = 0xff;
292*4e1bc9a0SAchim Leubner bit32 IDstatus;
293*4e1bc9a0SAchim Leubner agsaSATAIdentifyData_t *pSATAIdData;
294*4e1bc9a0SAchim Leubner
295*4e1bc9a0SAchim Leubner TI_DBG2(("tdsmIDCompletedCB: start\n"));
296*4e1bc9a0SAchim Leubner
297*4e1bc9a0SAchim Leubner tdsaRoot = (tdsaRoot_t *)smRoot->tdData;
298*4e1bc9a0SAchim Leubner tdsaAllShared = &(tdsaRoot->tdsaAllShared);
299*4e1bc9a0SAchim Leubner tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
300*4e1bc9a0SAchim Leubner tdIORequestBody = (tdIORequestBody_t *)smIORequest->tdData;
301*4e1bc9a0SAchim Leubner
302*4e1bc9a0SAchim Leubner if (smDeviceHandle == agNULL)
303*4e1bc9a0SAchim Leubner {
304*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: smDeviceHandle is NULL !!!!\n"));
305*4e1bc9a0SAchim Leubner ostiFreeMemory(
306*4e1bc9a0SAchim Leubner tiRoot,
307*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
308*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
309*4e1bc9a0SAchim Leubner );
310*4e1bc9a0SAchim Leubner return;
311*4e1bc9a0SAchim Leubner }
312*4e1bc9a0SAchim Leubner
313*4e1bc9a0SAchim Leubner oneDeviceData = (tdsaDeviceData_t *)smDeviceHandle->tdData;
314*4e1bc9a0SAchim Leubner onePortContext = oneDeviceData->tdPortContext;
315*4e1bc9a0SAchim Leubner agRoot = oneDeviceData->agRoot;
316*4e1bc9a0SAchim Leubner pid = tdIORequestBody->pid;
317*4e1bc9a0SAchim Leubner
318*4e1bc9a0SAchim Leubner
319*4e1bc9a0SAchim Leubner // oneDeviceData->satDevData.IDDeviceValid = agFALSE;
320*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.IDPending = agFALSE;
321*4e1bc9a0SAchim Leubner
322*4e1bc9a0SAchim Leubner TI_DBG2(("tdsmIDCompletedCB: tdIORequestBody %p tdIORequestBody->osMemHandle %p\n", tdIORequestBody, tdIORequestBody->osMemHandle));
323*4e1bc9a0SAchim Leubner
324*4e1bc9a0SAchim Leubner tdsaSingleThreadedEnter(tiRoot, TD_TIMER_LOCK);
325*4e1bc9a0SAchim Leubner
326*4e1bc9a0SAchim Leubner if (oneDeviceData->tdIDTimer.timerRunning == agTRUE)
327*4e1bc9a0SAchim Leubner {
328*4e1bc9a0SAchim Leubner tdsaSingleThreadedLeave(tiRoot, TD_TIMER_LOCK);
329*4e1bc9a0SAchim Leubner tdsaKillTimer(
330*4e1bc9a0SAchim Leubner tiRoot,
331*4e1bc9a0SAchim Leubner &oneDeviceData->tdIDTimer
332*4e1bc9a0SAchim Leubner );
333*4e1bc9a0SAchim Leubner }
334*4e1bc9a0SAchim Leubner else
335*4e1bc9a0SAchim Leubner {
336*4e1bc9a0SAchim Leubner tdsaSingleThreadedLeave(tiRoot, TD_TIMER_LOCK);
337*4e1bc9a0SAchim Leubner }
338*4e1bc9a0SAchim Leubner
339*4e1bc9a0SAchim Leubner if (onePortContext == agNULL)
340*4e1bc9a0SAchim Leubner {
341*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: onePortContext is NULL!!!\n"));
342*4e1bc9a0SAchim Leubner ostiFreeMemory(
343*4e1bc9a0SAchim Leubner tiRoot,
344*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
345*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
346*4e1bc9a0SAchim Leubner );
347*4e1bc9a0SAchim Leubner return;
348*4e1bc9a0SAchim Leubner }
349*4e1bc9a0SAchim Leubner
350*4e1bc9a0SAchim Leubner /* check port id */
351*4e1bc9a0SAchim Leubner if (pid != onePortContext->id)
352*4e1bc9a0SAchim Leubner {
353*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: not matching pid; pid %d onePortContext->id %d!!!\n", pid, onePortContext->id));
354*4e1bc9a0SAchim Leubner if (oneDeviceData->directlyAttached == agTRUE)
355*4e1bc9a0SAchim Leubner {
356*4e1bc9a0SAchim Leubner smReportRemovalDirect(tiRoot, agRoot, oneDeviceData);
357*4e1bc9a0SAchim Leubner }
358*4e1bc9a0SAchim Leubner else
359*4e1bc9a0SAchim Leubner {
360*4e1bc9a0SAchim Leubner smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext);
361*4e1bc9a0SAchim Leubner }
362*4e1bc9a0SAchim Leubner ostiFreeMemory(
363*4e1bc9a0SAchim Leubner tiRoot,
364*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
365*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
366*4e1bc9a0SAchim Leubner );
367*4e1bc9a0SAchim Leubner return;
368*4e1bc9a0SAchim Leubner }
369*4e1bc9a0SAchim Leubner
370*4e1bc9a0SAchim Leubner tiPortalContext= onePortContext->tiPortalContext;
371*4e1bc9a0SAchim Leubner
372*4e1bc9a0SAchim Leubner if (tiPortalContext == agNULL)
373*4e1bc9a0SAchim Leubner {
374*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: tiPortalContext is NULL!!!\n"));
375*4e1bc9a0SAchim Leubner if (oneDeviceData->directlyAttached == agTRUE)
376*4e1bc9a0SAchim Leubner {
377*4e1bc9a0SAchim Leubner smReportRemovalDirect(tiRoot, agRoot, oneDeviceData);
378*4e1bc9a0SAchim Leubner }
379*4e1bc9a0SAchim Leubner else
380*4e1bc9a0SAchim Leubner {
381*4e1bc9a0SAchim Leubner smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext);
382*4e1bc9a0SAchim Leubner }
383*4e1bc9a0SAchim Leubner ostiFreeMemory(
384*4e1bc9a0SAchim Leubner tiRoot,
385*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
386*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
387*4e1bc9a0SAchim Leubner );
388*4e1bc9a0SAchim Leubner return;
389*4e1bc9a0SAchim Leubner }
390*4e1bc9a0SAchim Leubner
391*4e1bc9a0SAchim Leubner if (agRoot == agNULL)
392*4e1bc9a0SAchim Leubner {
393*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: agRoot is NULL!!!\n"));
394*4e1bc9a0SAchim Leubner ostiFreeMemory(
395*4e1bc9a0SAchim Leubner tiRoot,
396*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
397*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
398*4e1bc9a0SAchim Leubner );
399*4e1bc9a0SAchim Leubner return;
400*4e1bc9a0SAchim Leubner }
401*4e1bc9a0SAchim Leubner
402*4e1bc9a0SAchim Leubner if (status == smIOSuccess)
403*4e1bc9a0SAchim Leubner {
404*4e1bc9a0SAchim Leubner TI_DBG2(("tdsmIDCompletedCB: smIOSuccess\n"));
405*4e1bc9a0SAchim Leubner
406*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.IDDeviceValid = agTRUE;
407*4e1bc9a0SAchim Leubner if (oneDeviceData->directlyAttached == agTRUE)
408*4e1bc9a0SAchim Leubner {
409*4e1bc9a0SAchim Leubner TI_DBG2(("tdsmIDCompletedCB: directlyAttached\n"));
410*4e1bc9a0SAchim Leubner pSATAIdData = (agsaSATAIdentifyData_t *)IDdata;
411*4e1bc9a0SAchim Leubner smHandleDirect(tiRoot, agRoot, oneDeviceData, IDdata);
412*4e1bc9a0SAchim Leubner /* filling in */
413*4e1bc9a0SAchim Leubner osti_memcpy(onePortContext->remoteName, pSATAIdData->serialNumber, 20);
414*4e1bc9a0SAchim Leubner osti_memcpy(&(onePortContext->remoteName[20]), pSATAIdData->firmwareVersion, 8);
415*4e1bc9a0SAchim Leubner osti_memcpy(&(onePortContext->remoteName[28]), pSATAIdData->modelNumber, 40);
416*4e1bc9a0SAchim Leubner }
417*4e1bc9a0SAchim Leubner else /* expander attached */
418*4e1bc9a0SAchim Leubner {
419*4e1bc9a0SAchim Leubner
420*4e1bc9a0SAchim Leubner TI_DBG2(("tdsmIDCompletedCB: expander attached\n"));
421*4e1bc9a0SAchim Leubner
422*4e1bc9a0SAchim Leubner if (onePortContext->DiscoveryState == ITD_DSTATE_COMPLETED)
423*4e1bc9a0SAchim Leubner {
424*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: ID completed after discovery is done; tiDeviceArrival\n"));
425*4e1bc9a0SAchim Leubner /* ID data completed after discovery is completed */
426*4e1bc9a0SAchim Leubner ostiInitiatorEvent(
427*4e1bc9a0SAchim Leubner tiRoot,
428*4e1bc9a0SAchim Leubner tiPortalContext,
429*4e1bc9a0SAchim Leubner agNULL,
430*4e1bc9a0SAchim Leubner tiIntrEventTypeDeviceChange,
431*4e1bc9a0SAchim Leubner tiDeviceArrival,
432*4e1bc9a0SAchim Leubner agNULL
433*4e1bc9a0SAchim Leubner );
434*4e1bc9a0SAchim Leubner }
435*4e1bc9a0SAchim Leubner }
436*4e1bc9a0SAchim Leubner TI_DBG2(("tdsmIDCompletedCB: tdIORequestBody %p tdIORequestBody->osMemHandle %p\n", tdIORequestBody, tdIORequestBody->osMemHandle));
437*4e1bc9a0SAchim Leubner ostiFreeMemory(
438*4e1bc9a0SAchim Leubner tiRoot,
439*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
440*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
441*4e1bc9a0SAchim Leubner );
442*4e1bc9a0SAchim Leubner
443*4e1bc9a0SAchim Leubner }
444*4e1bc9a0SAchim Leubner else if ( status == smIORetry)
445*4e1bc9a0SAchim Leubner {
446*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: smIORetry!!!\n"));
447*4e1bc9a0SAchim Leubner if ( !(oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE &&
448*4e1bc9a0SAchim Leubner oneDeviceData->tdPortContext != agNULL)
449*4e1bc9a0SAchim Leubner )
450*4e1bc9a0SAchim Leubner {
451*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: smIORetry but device is not valid!!!\n"));
452*4e1bc9a0SAchim Leubner tdIORequestBody->reTries = 0;
453*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agTRUE;
454*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agFALSE;
455*4e1bc9a0SAchim Leubner ostiFreeMemory(
456*4e1bc9a0SAchim Leubner tiRoot,
457*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
458*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
459*4e1bc9a0SAchim Leubner );
460*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.IDDeviceValid = agFALSE;
461*4e1bc9a0SAchim Leubner return;
462*4e1bc9a0SAchim Leubner }
463*4e1bc9a0SAchim Leubner
464*4e1bc9a0SAchim Leubner if (tdIORequestBody->reTries <= SM_RETRIES)
465*4e1bc9a0SAchim Leubner {
466*4e1bc9a0SAchim Leubner tdIORequestBody->tiIORequest = agNULL; /* not in use */
467*4e1bc9a0SAchim Leubner tdIORequestBody->pid = onePortContext->id;
468*4e1bc9a0SAchim Leubner smIORequest->tdData = tdIORequestBody;
469*4e1bc9a0SAchim Leubner smIORequest->smData = &tdIORequestBody->smIORequestBody;
470*4e1bc9a0SAchim Leubner
471*4e1bc9a0SAchim Leubner smDeviceHandle->tdData = oneDeviceData;
472*4e1bc9a0SAchim Leubner
473*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.IDDeviceValid = agFALSE;
474*4e1bc9a0SAchim Leubner
475*4e1bc9a0SAchim Leubner IDstatus = smIDStart(smRoot,
476*4e1bc9a0SAchim Leubner smIORequest,
477*4e1bc9a0SAchim Leubner smDeviceHandle
478*4e1bc9a0SAchim Leubner );
479*4e1bc9a0SAchim Leubner if (IDstatus != SM_RC_SUCCESS)
480*4e1bc9a0SAchim Leubner {
481*4e1bc9a0SAchim Leubner /* identify device data is not valid */
482*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: smIDStart fail or busy %d!!!\n", IDstatus));
483*4e1bc9a0SAchim Leubner tdIORequestBody->reTries = 0;
484*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agTRUE;
485*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agFALSE;
486*4e1bc9a0SAchim Leubner ostiFreeMemory(
487*4e1bc9a0SAchim Leubner tiRoot,
488*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
489*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
490*4e1bc9a0SAchim Leubner );
491*4e1bc9a0SAchim Leubner smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext);
492*4e1bc9a0SAchim Leubner return;
493*4e1bc9a0SAchim Leubner }
494*4e1bc9a0SAchim Leubner tdIORequestBody->reTries++;
495*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agFALSE;
496*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agTRUE;
497*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.IDPending = agTRUE;
498*4e1bc9a0SAchim Leubner /* start a timer */
499*4e1bc9a0SAchim Leubner tdIDStartTimer(tiRoot, smIORequest, oneDeviceData);
500*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: being retried!!!\n"));
501*4e1bc9a0SAchim Leubner }
502*4e1bc9a0SAchim Leubner else
503*4e1bc9a0SAchim Leubner {
504*4e1bc9a0SAchim Leubner /* give up */
505*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: retries are over!!!\n"));
506*4e1bc9a0SAchim Leubner tdIORequestBody->reTries = 0;
507*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agTRUE;
508*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agFALSE;
509*4e1bc9a0SAchim Leubner ostiFreeMemory(
510*4e1bc9a0SAchim Leubner tiRoot,
511*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
512*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
513*4e1bc9a0SAchim Leubner );
514*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.IDDeviceValid = agFALSE;
515*4e1bc9a0SAchim Leubner /* SATA device is not usable; remove it */
516*4e1bc9a0SAchim Leubner smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext);
517*4e1bc9a0SAchim Leubner }
518*4e1bc9a0SAchim Leubner }
519*4e1bc9a0SAchim Leubner else if ( status == smIOSTPResourceBusy)
520*4e1bc9a0SAchim Leubner {
521*4e1bc9a0SAchim Leubner /* decides to send smp hard reset or not */
522*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: smIOSTPResourceBusy\n"));
523*4e1bc9a0SAchim Leubner ostiFreeMemory(
524*4e1bc9a0SAchim Leubner tiRoot,
525*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
526*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
527*4e1bc9a0SAchim Leubner );
528*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.IDDeviceValid = agFALSE;
529*4e1bc9a0SAchim Leubner if (tdsaAllShared->FCA)
530*4e1bc9a0SAchim Leubner {
531*4e1bc9a0SAchim Leubner if (oneDeviceData->SMNumOfFCA <= 0) /* does SMP HARD RESET only upto one time */
532*4e1bc9a0SAchim Leubner {
533*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; sending HARD_RESET\n"));
534*4e1bc9a0SAchim Leubner oneDeviceData->SMNumOfFCA++;
535*4e1bc9a0SAchim Leubner tdsaPhyControlSend(tiRoot,
536*4e1bc9a0SAchim Leubner oneDeviceData,
537*4e1bc9a0SAchim Leubner SMP_PHY_CONTROL_HARD_RESET,
538*4e1bc9a0SAchim Leubner agNULL,
539*4e1bc9a0SAchim Leubner tdsaRotateQnumber(tiRoot, oneDeviceData)
540*4e1bc9a0SAchim Leubner );
541*4e1bc9a0SAchim Leubner }
542*4e1bc9a0SAchim Leubner else
543*4e1bc9a0SAchim Leubner {
544*4e1bc9a0SAchim Leubner /* given up after one time of SMP HARD RESET; */
545*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; but giving up sending HARD_RESET!!!\n"));
546*4e1bc9a0SAchim Leubner smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext);
547*4e1bc9a0SAchim Leubner }
548*4e1bc9a0SAchim Leubner }
549*4e1bc9a0SAchim Leubner else
550*4e1bc9a0SAchim Leubner {
551*4e1bc9a0SAchim Leubner /* do nothing */
552*4e1bc9a0SAchim Leubner }
553*4e1bc9a0SAchim Leubner }
554*4e1bc9a0SAchim Leubner else
555*4e1bc9a0SAchim Leubner {
556*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: smIDStart fail, status 0x%x!!!\n", status));
557*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: did %d!!!\n", oneDeviceData->id));
558*4e1bc9a0SAchim Leubner if ( !(oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE &&
559*4e1bc9a0SAchim Leubner oneDeviceData->tdPortContext != agNULL)
560*4e1bc9a0SAchim Leubner )
561*4e1bc9a0SAchim Leubner {
562*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: fail but device is not valid!!!\n"));
563*4e1bc9a0SAchim Leubner tdIORequestBody->reTries = 0;
564*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agTRUE;
565*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agFALSE;
566*4e1bc9a0SAchim Leubner ostiFreeMemory(
567*4e1bc9a0SAchim Leubner tiRoot,
568*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
569*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
570*4e1bc9a0SAchim Leubner );
571*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.IDDeviceValid = agFALSE;
572*4e1bc9a0SAchim Leubner return;
573*4e1bc9a0SAchim Leubner }
574*4e1bc9a0SAchim Leubner tdsaAllShared->IDRetry = agTRUE;
575*4e1bc9a0SAchim Leubner if (tdsaAllShared->IDRetry)
576*4e1bc9a0SAchim Leubner {
577*4e1bc9a0SAchim Leubner if (tdIORequestBody->reTries <= SM_RETRIES)
578*4e1bc9a0SAchim Leubner {
579*4e1bc9a0SAchim Leubner tdIORequestBody->tiIORequest = agNULL; /* not in use */
580*4e1bc9a0SAchim Leubner tdIORequestBody->pid = onePortContext->id;
581*4e1bc9a0SAchim Leubner smIORequest->tdData = tdIORequestBody;
582*4e1bc9a0SAchim Leubner smIORequest->smData = &tdIORequestBody->smIORequestBody;
583*4e1bc9a0SAchim Leubner
584*4e1bc9a0SAchim Leubner smDeviceHandle->tdData = oneDeviceData;
585*4e1bc9a0SAchim Leubner IDstatus = smIDStart(smRoot,
586*4e1bc9a0SAchim Leubner smIORequest,
587*4e1bc9a0SAchim Leubner smDeviceHandle
588*4e1bc9a0SAchim Leubner );
589*4e1bc9a0SAchim Leubner if (IDstatus != SM_RC_SUCCESS)
590*4e1bc9a0SAchim Leubner {
591*4e1bc9a0SAchim Leubner /* identify device data is not valid */
592*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: smIDStart fail or busy %d!!!\n", IDstatus));
593*4e1bc9a0SAchim Leubner tdIORequestBody->reTries = 0;
594*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agTRUE;
595*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agFALSE;
596*4e1bc9a0SAchim Leubner ostiFreeMemory(
597*4e1bc9a0SAchim Leubner tiRoot,
598*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
599*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
600*4e1bc9a0SAchim Leubner );
601*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.IDDeviceValid = agFALSE;
602*4e1bc9a0SAchim Leubner if (oneDeviceData->directlyAttached == agTRUE)
603*4e1bc9a0SAchim Leubner {
604*4e1bc9a0SAchim Leubner smReportRemovalDirect(tiRoot, agRoot, oneDeviceData);
605*4e1bc9a0SAchim Leubner }
606*4e1bc9a0SAchim Leubner else
607*4e1bc9a0SAchim Leubner {
608*4e1bc9a0SAchim Leubner smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext);
609*4e1bc9a0SAchim Leubner }
610*4e1bc9a0SAchim Leubner return;
611*4e1bc9a0SAchim Leubner }
612*4e1bc9a0SAchim Leubner tdIORequestBody->reTries++;
613*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agFALSE;
614*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agTRUE;
615*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.IDPending = agTRUE;
616*4e1bc9a0SAchim Leubner /* start a timer */
617*4e1bc9a0SAchim Leubner tdIDStartTimer(tiRoot, smIORequest, oneDeviceData);
618*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: being retried!!!\n"));
619*4e1bc9a0SAchim Leubner }
620*4e1bc9a0SAchim Leubner else
621*4e1bc9a0SAchim Leubner {
622*4e1bc9a0SAchim Leubner /* give up */
623*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: retries are over; sending hard reset!!!\n"));
624*4e1bc9a0SAchim Leubner tdIORequestBody->reTries = 0;
625*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agTRUE;
626*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agFALSE;
627*4e1bc9a0SAchim Leubner ostiFreeMemory(
628*4e1bc9a0SAchim Leubner tiRoot,
629*4e1bc9a0SAchim Leubner tdIORequestBody->osMemHandle,
630*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
631*4e1bc9a0SAchim Leubner );
632*4e1bc9a0SAchim Leubner oneDeviceData->satDevData.IDDeviceValid = agFALSE;
633*4e1bc9a0SAchim Leubner
634*4e1bc9a0SAchim Leubner if (oneDeviceData->SMNumOfID <= 0) /* does SMP HARD RESET only upto one time */
635*4e1bc9a0SAchim Leubner {
636*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: fail; sending HARD_RESET\n"));
637*4e1bc9a0SAchim Leubner oneDeviceData->SMNumOfID++;
638*4e1bc9a0SAchim Leubner if (oneDeviceData->directlyAttached == agTRUE)
639*4e1bc9a0SAchim Leubner {
640*4e1bc9a0SAchim Leubner saLocalPhyControl(agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), oneDeviceData->phyID, AGSA_PHY_HARD_RESET, agNULL);
641*4e1bc9a0SAchim Leubner }
642*4e1bc9a0SAchim Leubner else
643*4e1bc9a0SAchim Leubner {
644*4e1bc9a0SAchim Leubner tdsaPhyControlSend(tiRoot,
645*4e1bc9a0SAchim Leubner oneDeviceData,
646*4e1bc9a0SAchim Leubner SMP_PHY_CONTROL_HARD_RESET,
647*4e1bc9a0SAchim Leubner agNULL,
648*4e1bc9a0SAchim Leubner tdsaRotateQnumber(tiRoot, oneDeviceData)
649*4e1bc9a0SAchim Leubner );
650*4e1bc9a0SAchim Leubner }
651*4e1bc9a0SAchim Leubner }
652*4e1bc9a0SAchim Leubner else
653*4e1bc9a0SAchim Leubner {
654*4e1bc9a0SAchim Leubner /* given up after one time of SMP HARD RESET; */
655*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIDCompletedCB: fail; but giving up sending HARD_RESET!!!\n"));
656*4e1bc9a0SAchim Leubner if (oneDeviceData->directlyAttached == agTRUE)
657*4e1bc9a0SAchim Leubner {
658*4e1bc9a0SAchim Leubner smReportRemovalDirect(tiRoot, agRoot, oneDeviceData);
659*4e1bc9a0SAchim Leubner }
660*4e1bc9a0SAchim Leubner else
661*4e1bc9a0SAchim Leubner {
662*4e1bc9a0SAchim Leubner smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext);
663*4e1bc9a0SAchim Leubner }
664*4e1bc9a0SAchim Leubner }
665*4e1bc9a0SAchim Leubner }
666*4e1bc9a0SAchim Leubner }
667*4e1bc9a0SAchim Leubner else
668*4e1bc9a0SAchim Leubner {
669*4e1bc9a0SAchim Leubner /* do nothing */
670*4e1bc9a0SAchim Leubner }
671*4e1bc9a0SAchim Leubner
672*4e1bc9a0SAchim Leubner
673*4e1bc9a0SAchim Leubner }
674*4e1bc9a0SAchim Leubner
675*4e1bc9a0SAchim Leubner
676*4e1bc9a0SAchim Leubner return;
677*4e1bc9a0SAchim Leubner }
678*4e1bc9a0SAchim Leubner
679*4e1bc9a0SAchim Leubner FORCEINLINE void
tdsmIOCompletedCB(smRoot_t * smRoot,smIORequest_t * smIORequest,bit32 status,bit32 statusDetail,smSenseData_t * senseData,bit32 interruptContext)680*4e1bc9a0SAchim Leubner tdsmIOCompletedCB(
681*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
682*4e1bc9a0SAchim Leubner smIORequest_t *smIORequest,
683*4e1bc9a0SAchim Leubner bit32 status,
684*4e1bc9a0SAchim Leubner bit32 statusDetail,
685*4e1bc9a0SAchim Leubner smSenseData_t *senseData,
686*4e1bc9a0SAchim Leubner bit32 interruptContext
687*4e1bc9a0SAchim Leubner )
688*4e1bc9a0SAchim Leubner {
689*4e1bc9a0SAchim Leubner tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)smRoot->tdData;
690*4e1bc9a0SAchim Leubner tdsaContext_t *tdsaAllShared = &(tdsaRoot->tdsaAllShared);
691*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
692*4e1bc9a0SAchim Leubner tdIORequestBody_t *tdIORequestBody = (tdIORequestBody_t *)smIORequest->tdData;
693*4e1bc9a0SAchim Leubner tiIORequest_t *tiIORequest = tdIORequestBody->tiIORequest;
694*4e1bc9a0SAchim Leubner
695*4e1bc9a0SAchim Leubner tdsaDeviceData_t *oneDeviceData;
696*4e1bc9a0SAchim Leubner tiDeviceHandle_t *tiDeviceHandle;
697*4e1bc9a0SAchim Leubner smDeviceHandle_t *smDeviceHandle;
698*4e1bc9a0SAchim Leubner smScsiInitiatorRequest_t *smSCSIRequest;
699*4e1bc9a0SAchim Leubner smSuperScsiInitiatorRequest_t *smSuperSCSIRequest;
700*4e1bc9a0SAchim Leubner
701*4e1bc9a0SAchim Leubner bit32 SMStatus = SM_RC_FAILURE;
702*4e1bc9a0SAchim Leubner
703*4e1bc9a0SAchim Leubner
704*4e1bc9a0SAchim Leubner TI_DBG5(("tdsmIOCompletedCB: start\n"));
705*4e1bc9a0SAchim Leubner
706*4e1bc9a0SAchim Leubner if (status == smIOSuccess)
707*4e1bc9a0SAchim Leubner {
708*4e1bc9a0SAchim Leubner ostiInitiatorIOCompleted( tiRoot,
709*4e1bc9a0SAchim Leubner tiIORequest,
710*4e1bc9a0SAchim Leubner status,
711*4e1bc9a0SAchim Leubner statusDetail,
712*4e1bc9a0SAchim Leubner (tiSenseData_t *)senseData,
713*4e1bc9a0SAchim Leubner interruptContext);
714*4e1bc9a0SAchim Leubner }
715*4e1bc9a0SAchim Leubner else if (status == smIORetry)
716*4e1bc9a0SAchim Leubner {
717*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIOCompletedCB: smIORetry!!!\n"));
718*4e1bc9a0SAchim Leubner smIORequest = (smIORequest_t *)&(tdIORequestBody->smIORequest);
719*4e1bc9a0SAchim Leubner tiDeviceHandle = tdIORequestBody->tiDevHandle;
720*4e1bc9a0SAchim Leubner oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
721*4e1bc9a0SAchim Leubner
722*4e1bc9a0SAchim Leubner if (! (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE &&
723*4e1bc9a0SAchim Leubner oneDeviceData->tdPortContext != agNULL)
724*4e1bc9a0SAchim Leubner )
725*4e1bc9a0SAchim Leubner {
726*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIOCompletedCB: smIORetry but device is not valid!!!\n"));
727*4e1bc9a0SAchim Leubner tdIORequestBody->reTries = 0;
728*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agTRUE;
729*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agFALSE;
730*4e1bc9a0SAchim Leubner ostiInitiatorIOCompleted( tiRoot,
731*4e1bc9a0SAchim Leubner tiIORequest,
732*4e1bc9a0SAchim Leubner status,
733*4e1bc9a0SAchim Leubner statusDetail,
734*4e1bc9a0SAchim Leubner (tiSenseData_t *)senseData,
735*4e1bc9a0SAchim Leubner interruptContext);
736*4e1bc9a0SAchim Leubner return;
737*4e1bc9a0SAchim Leubner }
738*4e1bc9a0SAchim Leubner if (tdIORequestBody->reTries <= SM_RETRIES)
739*4e1bc9a0SAchim Leubner {
740*4e1bc9a0SAchim Leubner smDeviceHandle = (smDeviceHandle_t *)&(oneDeviceData->smDeviceHandle);
741*4e1bc9a0SAchim Leubner if (tdIORequestBody->superIOFlag == agTRUE)
742*4e1bc9a0SAchim Leubner {
743*4e1bc9a0SAchim Leubner smSuperSCSIRequest = (smSuperScsiInitiatorRequest_t *)&(tdIORequestBody->SM.smSuperSCSIRequest);
744*4e1bc9a0SAchim Leubner SMStatus = smSuperIOStart(smRoot,
745*4e1bc9a0SAchim Leubner smIORequest,
746*4e1bc9a0SAchim Leubner smDeviceHandle,
747*4e1bc9a0SAchim Leubner smSuperSCSIRequest,
748*4e1bc9a0SAchim Leubner oneDeviceData->SASAddressID.sasAddressHi,
749*4e1bc9a0SAchim Leubner oneDeviceData->SASAddressID.sasAddressLo,
750*4e1bc9a0SAchim Leubner interruptContext);
751*4e1bc9a0SAchim Leubner }
752*4e1bc9a0SAchim Leubner else
753*4e1bc9a0SAchim Leubner {
754*4e1bc9a0SAchim Leubner smSCSIRequest = (smScsiInitiatorRequest_t *)&(tdIORequestBody->SM.smSCSIRequest);
755*4e1bc9a0SAchim Leubner SMStatus = smIOStart(smRoot,
756*4e1bc9a0SAchim Leubner smIORequest,
757*4e1bc9a0SAchim Leubner smDeviceHandle,
758*4e1bc9a0SAchim Leubner smSCSIRequest,
759*4e1bc9a0SAchim Leubner interruptContext);
760*4e1bc9a0SAchim Leubner }
761*4e1bc9a0SAchim Leubner
762*4e1bc9a0SAchim Leubner
763*4e1bc9a0SAchim Leubner if (SMStatus != SM_RC_SUCCESS)
764*4e1bc9a0SAchim Leubner {
765*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIOCompletedCB: smIDStart fail or busy %d!!!\n", SMStatus));
766*4e1bc9a0SAchim Leubner tdIORequestBody->reTries = 0;
767*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agTRUE;
768*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agFALSE;
769*4e1bc9a0SAchim Leubner ostiInitiatorIOCompleted( tiRoot,
770*4e1bc9a0SAchim Leubner tiIORequest,
771*4e1bc9a0SAchim Leubner status,
772*4e1bc9a0SAchim Leubner statusDetail,
773*4e1bc9a0SAchim Leubner (tiSenseData_t *)senseData,
774*4e1bc9a0SAchim Leubner interruptContext);
775*4e1bc9a0SAchim Leubner return;
776*4e1bc9a0SAchim Leubner }
777*4e1bc9a0SAchim Leubner else
778*4e1bc9a0SAchim Leubner {
779*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIOCompletedCB: being retried!!!\n"));
780*4e1bc9a0SAchim Leubner tdIORequestBody->reTries++;
781*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agFALSE;
782*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agTRUE;
783*4e1bc9a0SAchim Leubner }
784*4e1bc9a0SAchim Leubner }
785*4e1bc9a0SAchim Leubner else
786*4e1bc9a0SAchim Leubner {
787*4e1bc9a0SAchim Leubner /* give up; complete IO */
788*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIOCompletedCB: retries are over!!!\n"));
789*4e1bc9a0SAchim Leubner tdIORequestBody->reTries = 0;
790*4e1bc9a0SAchim Leubner tdIORequestBody->ioCompleted = agTRUE;
791*4e1bc9a0SAchim Leubner tdIORequestBody->ioStarted = agFALSE;
792*4e1bc9a0SAchim Leubner ostiInitiatorIOCompleted( tiRoot,
793*4e1bc9a0SAchim Leubner tiIORequest,
794*4e1bc9a0SAchim Leubner status,
795*4e1bc9a0SAchim Leubner statusDetail,
796*4e1bc9a0SAchim Leubner (tiSenseData_t *)senseData,
797*4e1bc9a0SAchim Leubner interruptContext);
798*4e1bc9a0SAchim Leubner return;
799*4e1bc9a0SAchim Leubner }
800*4e1bc9a0SAchim Leubner
801*4e1bc9a0SAchim Leubner }
802*4e1bc9a0SAchim Leubner else if ( status == smIOSTPResourceBusy)
803*4e1bc9a0SAchim Leubner {
804*4e1bc9a0SAchim Leubner /* decides to send smp hard reset or not */
805*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIOCompletedCB: smIOSTPResourceBusy\n"));
806*4e1bc9a0SAchim Leubner if (tdsaAllShared->FCA)
807*4e1bc9a0SAchim Leubner {
808*4e1bc9a0SAchim Leubner smIORequest = (smIORequest_t *)&(tdIORequestBody->smIORequest);
809*4e1bc9a0SAchim Leubner tiDeviceHandle = tdIORequestBody->tiDevHandle;
810*4e1bc9a0SAchim Leubner oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
811*4e1bc9a0SAchim Leubner if (oneDeviceData->SMNumOfFCA <= 0) /* does SMP HARD RESET only upto one time */
812*4e1bc9a0SAchim Leubner {
813*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIOCompletedCB: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; sending HARD_RESET\n"));
814*4e1bc9a0SAchim Leubner oneDeviceData->SMNumOfFCA++;
815*4e1bc9a0SAchim Leubner tdsaPhyControlSend(tiRoot,
816*4e1bc9a0SAchim Leubner oneDeviceData,
817*4e1bc9a0SAchim Leubner SMP_PHY_CONTROL_HARD_RESET,
818*4e1bc9a0SAchim Leubner agNULL,
819*4e1bc9a0SAchim Leubner tdsaRotateQnumber(tiRoot, oneDeviceData)
820*4e1bc9a0SAchim Leubner );
821*4e1bc9a0SAchim Leubner }
822*4e1bc9a0SAchim Leubner else
823*4e1bc9a0SAchim Leubner {
824*4e1bc9a0SAchim Leubner /* given up after one time of SMP HARD RESET; */
825*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIOCompletedCB: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; but giving up sending HARD_RESET!!!\n"));
826*4e1bc9a0SAchim Leubner }
827*4e1bc9a0SAchim Leubner }
828*4e1bc9a0SAchim Leubner ostiInitiatorIOCompleted( tiRoot,
829*4e1bc9a0SAchim Leubner tiIORequest,
830*4e1bc9a0SAchim Leubner status,
831*4e1bc9a0SAchim Leubner statusDetail,
832*4e1bc9a0SAchim Leubner (tiSenseData_t *)senseData,
833*4e1bc9a0SAchim Leubner interruptContext);
834*4e1bc9a0SAchim Leubner return;
835*4e1bc9a0SAchim Leubner }
836*4e1bc9a0SAchim Leubner else
837*4e1bc9a0SAchim Leubner {
838*4e1bc9a0SAchim Leubner if (statusDetail == smDetailAborted)
839*4e1bc9a0SAchim Leubner {
840*4e1bc9a0SAchim Leubner tiDeviceHandle = tdIORequestBody->tiDevHandle;
841*4e1bc9a0SAchim Leubner oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
842*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmIOCompletedCB: agIOStatus = OSSA_IO_ABORTED did %d\n", oneDeviceData->id));
843*4e1bc9a0SAchim Leubner }
844*4e1bc9a0SAchim Leubner ostiInitiatorIOCompleted( tiRoot,
845*4e1bc9a0SAchim Leubner tiIORequest,
846*4e1bc9a0SAchim Leubner status,
847*4e1bc9a0SAchim Leubner statusDetail,
848*4e1bc9a0SAchim Leubner (tiSenseData_t *)senseData,
849*4e1bc9a0SAchim Leubner interruptContext);
850*4e1bc9a0SAchim Leubner }
851*4e1bc9a0SAchim Leubner
852*4e1bc9a0SAchim Leubner return;
853*4e1bc9a0SAchim Leubner }
854*4e1bc9a0SAchim Leubner
855*4e1bc9a0SAchim Leubner /* completion of taskmanagement
856*4e1bc9a0SAchim Leubner osGLOBAL void ostiInitiatorEvent (
857*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot,
858*4e1bc9a0SAchim Leubner tiPortalContext_t *portalContext,
859*4e1bc9a0SAchim Leubner tiDeviceHandle_t *tiDeviceHandle,
860*4e1bc9a0SAchim Leubner tiIntrEventType_t eventType,
861*4e1bc9a0SAchim Leubner bit32 eventStatus,
862*4e1bc9a0SAchim Leubner void *parm
863*4e1bc9a0SAchim Leubner );
864*4e1bc9a0SAchim Leubner
865*4e1bc9a0SAchim Leubner */
866*4e1bc9a0SAchim Leubner //qqq1
867*4e1bc9a0SAchim Leubner osGLOBAL void
tdsmEventCB(smRoot_t * smRoot,smDeviceHandle_t * smDeviceHandle,smIntrEventType_t eventType,bit32 eventStatus,void * parm)868*4e1bc9a0SAchim Leubner tdsmEventCB(
869*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
870*4e1bc9a0SAchim Leubner smDeviceHandle_t *smDeviceHandle,
871*4e1bc9a0SAchim Leubner smIntrEventType_t eventType,
872*4e1bc9a0SAchim Leubner bit32 eventStatus,
873*4e1bc9a0SAchim Leubner void *parm
874*4e1bc9a0SAchim Leubner )
875*4e1bc9a0SAchim Leubner {
876*4e1bc9a0SAchim Leubner tdsaRoot_t *tdsaRoot;
877*4e1bc9a0SAchim Leubner tdsaContext_t *tdsaAllShared;
878*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot;
879*4e1bc9a0SAchim Leubner tdIORequestBody_t *tdIORequestBody;
880*4e1bc9a0SAchim Leubner smIORequest_t *SMcurrentTaskTag;
881*4e1bc9a0SAchim Leubner tiIORequest_t *currentTaskTag;
882*4e1bc9a0SAchim Leubner tdsaDeviceData_t *oneDeviceData;
883*4e1bc9a0SAchim Leubner void *osMemHandle;
884*4e1bc9a0SAchim Leubner tdsaPortContext_t *onePortContext;
885*4e1bc9a0SAchim Leubner tiPortalContext_t *tiportalContext;
886*4e1bc9a0SAchim Leubner tiDeviceHandle_t *tiDeviceHandle;
887*4e1bc9a0SAchim Leubner
888*4e1bc9a0SAchim Leubner /* be sure to free using tdIORequestBody->->IOType.InitiatorTMIO.osMemHandle but how???
889*4e1bc9a0SAchim Leubner parm = pSatDevData->satTmTaskTag (currentTaskTag in tiINITaskManagement)
890*4e1bc9a0SAchim Leubner In this case, parm is smIORequest_t
891*4e1bc9a0SAchim Leubner */
892*4e1bc9a0SAchim Leubner
893*4e1bc9a0SAchim Leubner TI_DBG2(("tdsmEventCB: start\n"));
894*4e1bc9a0SAchim Leubner
895*4e1bc9a0SAchim Leubner tdsaRoot = (tdsaRoot_t *)smRoot->tdData;
896*4e1bc9a0SAchim Leubner tdsaAllShared = &(tdsaRoot->tdsaAllShared);
897*4e1bc9a0SAchim Leubner tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
898*4e1bc9a0SAchim Leubner
899*4e1bc9a0SAchim Leubner
900*4e1bc9a0SAchim Leubner if (eventType == smIntrEventTypeLocalAbort)
901*4e1bc9a0SAchim Leubner {
902*4e1bc9a0SAchim Leubner oneDeviceData = (tdsaDeviceData_t *)smDeviceHandle->tdData;
903*4e1bc9a0SAchim Leubner if (oneDeviceData == agNULL)
904*4e1bc9a0SAchim Leubner {
905*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmEventCB: oneDeviceData is NULL\n"));
906*4e1bc9a0SAchim Leubner return;
907*4e1bc9a0SAchim Leubner }
908*4e1bc9a0SAchim Leubner else
909*4e1bc9a0SAchim Leubner {
910*4e1bc9a0SAchim Leubner tiDeviceHandle = &(oneDeviceData->tiDeviceHandle);
911*4e1bc9a0SAchim Leubner if (oneDeviceData->OSAbortAll == agTRUE)
912*4e1bc9a0SAchim Leubner {
913*4e1bc9a0SAchim Leubner oneDeviceData->OSAbortAll = agFALSE;
914*4e1bc9a0SAchim Leubner ostiInitiatorEvent( tiRoot,
915*4e1bc9a0SAchim Leubner agNULL,
916*4e1bc9a0SAchim Leubner tiDeviceHandle,
917*4e1bc9a0SAchim Leubner tiIntrEventTypeLocalAbort,
918*4e1bc9a0SAchim Leubner tiAbortOK,
919*4e1bc9a0SAchim Leubner agNULL);
920*4e1bc9a0SAchim Leubner }
921*4e1bc9a0SAchim Leubner }
922*4e1bc9a0SAchim Leubner }
923*4e1bc9a0SAchim Leubner else
924*4e1bc9a0SAchim Leubner {
925*4e1bc9a0SAchim Leubner
926*4e1bc9a0SAchim Leubner SMcurrentTaskTag = (smIORequest_t *)parm;
927*4e1bc9a0SAchim Leubner if (SMcurrentTaskTag == agNULL)
928*4e1bc9a0SAchim Leubner {
929*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmEventCB: SMcurrentTaskTag is NULL!!!\n"));
930*4e1bc9a0SAchim Leubner return;
931*4e1bc9a0SAchim Leubner }
932*4e1bc9a0SAchim Leubner
933*4e1bc9a0SAchim Leubner tdIORequestBody = (tdIORequestBody_t *)SMcurrentTaskTag->tdData;
934*4e1bc9a0SAchim Leubner if (tdIORequestBody == agNULL)
935*4e1bc9a0SAchim Leubner {
936*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmEventCB: tdIORequestBody is NULL!!!\n"));
937*4e1bc9a0SAchim Leubner return;
938*4e1bc9a0SAchim Leubner }
939*4e1bc9a0SAchim Leubner
940*4e1bc9a0SAchim Leubner osMemHandle = tdIORequestBody->IOType.InitiatorTMIO.osMemHandle;
941*4e1bc9a0SAchim Leubner currentTaskTag = tdIORequestBody->IOType.InitiatorTMIO.CurrentTaskTag;
942*4e1bc9a0SAchim Leubner
943*4e1bc9a0SAchim Leubner
944*4e1bc9a0SAchim Leubner oneDeviceData = (tdsaDeviceData_t *)smDeviceHandle->tdData;
945*4e1bc9a0SAchim Leubner if (oneDeviceData == agNULL)
946*4e1bc9a0SAchim Leubner {
947*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmEventCB: oneDeviceData is NULL!!!\n"));
948*4e1bc9a0SAchim Leubner return;
949*4e1bc9a0SAchim Leubner }
950*4e1bc9a0SAchim Leubner
951*4e1bc9a0SAchim Leubner tiDeviceHandle = &(oneDeviceData->tiDeviceHandle);
952*4e1bc9a0SAchim Leubner onePortContext = oneDeviceData->tdPortContext;
953*4e1bc9a0SAchim Leubner if (onePortContext == agNULL)
954*4e1bc9a0SAchim Leubner {
955*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmEventCB: onePortContext is NULL!!!\n"));
956*4e1bc9a0SAchim Leubner return;
957*4e1bc9a0SAchim Leubner }
958*4e1bc9a0SAchim Leubner tiportalContext = onePortContext->tiPortalContext;
959*4e1bc9a0SAchim Leubner
960*4e1bc9a0SAchim Leubner /* free tdIORequestBody */
961*4e1bc9a0SAchim Leubner ostiFreeMemory(
962*4e1bc9a0SAchim Leubner tiRoot,
963*4e1bc9a0SAchim Leubner osMemHandle,
964*4e1bc9a0SAchim Leubner sizeof(tdIORequestBody_t)
965*4e1bc9a0SAchim Leubner );
966*4e1bc9a0SAchim Leubner
967*4e1bc9a0SAchim Leubner
968*4e1bc9a0SAchim Leubner TI_DBG2(("tdsmEventCB: calling ostiInitiatorEvent\n"));
969*4e1bc9a0SAchim Leubner ostiInitiatorEvent(
970*4e1bc9a0SAchim Leubner tiRoot,
971*4e1bc9a0SAchim Leubner tiportalContext,
972*4e1bc9a0SAchim Leubner tiDeviceHandle,
973*4e1bc9a0SAchim Leubner eventType,
974*4e1bc9a0SAchim Leubner eventStatus,
975*4e1bc9a0SAchim Leubner (void *)currentTaskTag
976*4e1bc9a0SAchim Leubner );
977*4e1bc9a0SAchim Leubner
978*4e1bc9a0SAchim Leubner
979*4e1bc9a0SAchim Leubner /* completion of taskmanagement
980*4e1bc9a0SAchim Leubner osGLOBAL void ostiInitiatorEvent (
981*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot,
982*4e1bc9a0SAchim Leubner tiPortalContext_t *portalContext,
983*4e1bc9a0SAchim Leubner tiDeviceHandle_t *tiDeviceHandle,
984*4e1bc9a0SAchim Leubner tiIntrEventType_t eventType,
985*4e1bc9a0SAchim Leubner bit32 eventStatus,
986*4e1bc9a0SAchim Leubner void *parm
987*4e1bc9a0SAchim Leubner );
988*4e1bc9a0SAchim Leubner
989*4e1bc9a0SAchim Leubner
990*4e1bc9a0SAchim Leubner ostiFreeAlloc()
991*4e1bc9a0SAchim Leubner */
992*4e1bc9a0SAchim Leubner
993*4e1bc9a0SAchim Leubner }
994*4e1bc9a0SAchim Leubner
995*4e1bc9a0SAchim Leubner return;
996*4e1bc9a0SAchim Leubner }
997*4e1bc9a0SAchim Leubner
998*4e1bc9a0SAchim Leubner
999*4e1bc9a0SAchim Leubner FORCEINLINE void
tdsmSingleThreadedEnter(smRoot_t * smRoot,bit32 syncLockId)1000*4e1bc9a0SAchim Leubner tdsmSingleThreadedEnter(
1001*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1002*4e1bc9a0SAchim Leubner bit32 syncLockId
1003*4e1bc9a0SAchim Leubner )
1004*4e1bc9a0SAchim Leubner {
1005*4e1bc9a0SAchim Leubner tdsaRoot_t *tdsaRoot;
1006*4e1bc9a0SAchim Leubner tdsaContext_t *tdsaAllShared;
1007*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot;
1008*4e1bc9a0SAchim Leubner bit32 offset = 0;
1009*4e1bc9a0SAchim Leubner
1010*4e1bc9a0SAchim Leubner TI_DBG7(("tdsmSingleThreadedEnter: start\n"));
1011*4e1bc9a0SAchim Leubner
1012*4e1bc9a0SAchim Leubner tdsaRoot = (tdsaRoot_t *)smRoot->tdData;
1013*4e1bc9a0SAchim Leubner if (tdsaRoot == agNULL)
1014*4e1bc9a0SAchim Leubner {
1015*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmSingleThreadedEnter: tdsaRoot is NULL\n"));
1016*4e1bc9a0SAchim Leubner return;
1017*4e1bc9a0SAchim Leubner }
1018*4e1bc9a0SAchim Leubner
1019*4e1bc9a0SAchim Leubner tdsaAllShared = &(tdsaRoot->tdsaAllShared);
1020*4e1bc9a0SAchim Leubner if (tdsaAllShared == agNULL)
1021*4e1bc9a0SAchim Leubner {
1022*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmSingleThreadedEnter: tdsaAllShared is NULL\n"));
1023*4e1bc9a0SAchim Leubner return;
1024*4e1bc9a0SAchim Leubner }
1025*4e1bc9a0SAchim Leubner
1026*4e1bc9a0SAchim Leubner tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
1027*4e1bc9a0SAchim Leubner if (tiRoot == agNULL)
1028*4e1bc9a0SAchim Leubner {
1029*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmSingleThreadedEnter: tiRoot is NULL\n"));
1030*4e1bc9a0SAchim Leubner return;
1031*4e1bc9a0SAchim Leubner }
1032*4e1bc9a0SAchim Leubner
1033*4e1bc9a0SAchim Leubner offset = tdsaAllShared->MaxNumLLLocks + tdsaAllShared->MaxNumOSLocks + TD_MAX_LOCKS + tdsaAllShared->MaxNumDMLocks;
1034*4e1bc9a0SAchim Leubner
1035*4e1bc9a0SAchim Leubner ostiSingleThreadedEnter(tiRoot, syncLockId + offset);
1036*4e1bc9a0SAchim Leubner
1037*4e1bc9a0SAchim Leubner return;
1038*4e1bc9a0SAchim Leubner }
1039*4e1bc9a0SAchim Leubner
1040*4e1bc9a0SAchim Leubner FORCEINLINE void
tdsmSingleThreadedLeave(smRoot_t * smRoot,bit32 syncLockId)1041*4e1bc9a0SAchim Leubner tdsmSingleThreadedLeave(
1042*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1043*4e1bc9a0SAchim Leubner bit32 syncLockId
1044*4e1bc9a0SAchim Leubner )
1045*4e1bc9a0SAchim Leubner {
1046*4e1bc9a0SAchim Leubner tdsaRoot_t *tdsaRoot;
1047*4e1bc9a0SAchim Leubner tdsaContext_t *tdsaAllShared;
1048*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot;
1049*4e1bc9a0SAchim Leubner bit32 offset = 0;
1050*4e1bc9a0SAchim Leubner
1051*4e1bc9a0SAchim Leubner TI_DBG7(("tdsmSingleThreadedLeave: start\n"));
1052*4e1bc9a0SAchim Leubner
1053*4e1bc9a0SAchim Leubner tdsaRoot = (tdsaRoot_t *)smRoot->tdData;
1054*4e1bc9a0SAchim Leubner if (tdsaRoot == agNULL)
1055*4e1bc9a0SAchim Leubner {
1056*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmSingleThreadedLeave: tdsaRoot is NULL\n"));
1057*4e1bc9a0SAchim Leubner return;
1058*4e1bc9a0SAchim Leubner }
1059*4e1bc9a0SAchim Leubner
1060*4e1bc9a0SAchim Leubner tdsaAllShared = &(tdsaRoot->tdsaAllShared);
1061*4e1bc9a0SAchim Leubner if (tdsaAllShared == agNULL)
1062*4e1bc9a0SAchim Leubner {
1063*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmSingleThreadedLeave: tdsaAllShared is NULL\n"));
1064*4e1bc9a0SAchim Leubner return;
1065*4e1bc9a0SAchim Leubner }
1066*4e1bc9a0SAchim Leubner
1067*4e1bc9a0SAchim Leubner tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
1068*4e1bc9a0SAchim Leubner if (tiRoot == agNULL)
1069*4e1bc9a0SAchim Leubner {
1070*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmSingleThreadedLeave: tiRoot is NULL\n"));
1071*4e1bc9a0SAchim Leubner return;
1072*4e1bc9a0SAchim Leubner }
1073*4e1bc9a0SAchim Leubner offset = tdsaAllShared->MaxNumLLLocks + tdsaAllShared->MaxNumOSLocks + TD_MAX_LOCKS + tdsaAllShared->MaxNumDMLocks;
1074*4e1bc9a0SAchim Leubner
1075*4e1bc9a0SAchim Leubner ostiSingleThreadedLeave(tiRoot, syncLockId + offset);
1076*4e1bc9a0SAchim Leubner
1077*4e1bc9a0SAchim Leubner return;
1078*4e1bc9a0SAchim Leubner }
1079*4e1bc9a0SAchim Leubner
1080*4e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE bit8
tdsmBitScanForward(smRoot_t * smRoot,bit32 * Index,bit32 Mask)1081*4e1bc9a0SAchim Leubner tdsmBitScanForward(
1082*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1083*4e1bc9a0SAchim Leubner bit32 *Index,
1084*4e1bc9a0SAchim Leubner bit32 Mask
1085*4e1bc9a0SAchim Leubner )
1086*4e1bc9a0SAchim Leubner {
1087*4e1bc9a0SAchim Leubner return ostiBitScanForward(agNULL, Index, Mask);
1088*4e1bc9a0SAchim Leubner }
1089*4e1bc9a0SAchim Leubner
1090*4e1bc9a0SAchim Leubner #ifdef LINUX_VERSION_CODE
1091*4e1bc9a0SAchim Leubner
1092*4e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
tdsmInterlockedIncrement(smRoot_t * smRoot,sbit32 volatile * Addend)1093*4e1bc9a0SAchim Leubner tdsmInterlockedIncrement(
1094*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1095*4e1bc9a0SAchim Leubner sbit32 volatile *Addend
1096*4e1bc9a0SAchim Leubner )
1097*4e1bc9a0SAchim Leubner {
1098*4e1bc9a0SAchim Leubner return ostiAtomicIncrement(agNULL, Addend);
1099*4e1bc9a0SAchim Leubner }
1100*4e1bc9a0SAchim Leubner
1101*4e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
tdsmInterlockedDecrement(smRoot_t * smRoot,sbit32 volatile * Addend)1102*4e1bc9a0SAchim Leubner tdsmInterlockedDecrement(
1103*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1104*4e1bc9a0SAchim Leubner sbit32 volatile *Addend
1105*4e1bc9a0SAchim Leubner )
1106*4e1bc9a0SAchim Leubner {
1107*4e1bc9a0SAchim Leubner return ostiAtomicDecrement(agNULL, Addend);
1108*4e1bc9a0SAchim Leubner }
1109*4e1bc9a0SAchim Leubner
1110*4e1bc9a0SAchim Leubner
1111*4e1bc9a0SAchim Leubner
1112*4e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
tdsmAtomicBitClear(smRoot_t * smRoot,sbit32 volatile * Destination,sbit32 Value)1113*4e1bc9a0SAchim Leubner tdsmAtomicBitClear(
1114*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1115*4e1bc9a0SAchim Leubner sbit32 volatile *Destination,
1116*4e1bc9a0SAchim Leubner sbit32 Value
1117*4e1bc9a0SAchim Leubner )
1118*4e1bc9a0SAchim Leubner {
1119*4e1bc9a0SAchim Leubner return ostiAtomicBitClear(agNULL, Destination, Value);
1120*4e1bc9a0SAchim Leubner }
1121*4e1bc9a0SAchim Leubner
1122*4e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
tdsmAtomicBitSet(smRoot_t * smRoot,sbit32 volatile * Destination,sbit32 Value)1123*4e1bc9a0SAchim Leubner tdsmAtomicBitSet(
1124*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1125*4e1bc9a0SAchim Leubner sbit32 volatile *Destination,
1126*4e1bc9a0SAchim Leubner sbit32 Value
1127*4e1bc9a0SAchim Leubner )
1128*4e1bc9a0SAchim Leubner {
1129*4e1bc9a0SAchim Leubner return ostiAtomicBitSet(agNULL, Destination, Value);
1130*4e1bc9a0SAchim Leubner }
1131*4e1bc9a0SAchim Leubner
1132*4e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
tdsmAtomicExchange(smRoot_t * smRoot,sbit32 volatile * Target,sbit32 Value)1133*4e1bc9a0SAchim Leubner tdsmAtomicExchange(
1134*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1135*4e1bc9a0SAchim Leubner sbit32 volatile *Target,
1136*4e1bc9a0SAchim Leubner sbit32 Value
1137*4e1bc9a0SAchim Leubner )
1138*4e1bc9a0SAchim Leubner {
1139*4e1bc9a0SAchim Leubner return ostiAtomicExchange(agNULL, Target, Value);
1140*4e1bc9a0SAchim Leubner }
1141*4e1bc9a0SAchim Leubner
1142*4e1bc9a0SAchim Leubner #else
1143*4e1bc9a0SAchim Leubner
1144*4e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
tdsmInterlockedIncrement(smRoot_t * smRoot,sbit32 volatile * Addend)1145*4e1bc9a0SAchim Leubner tdsmInterlockedIncrement(
1146*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1147*4e1bc9a0SAchim Leubner sbit32 volatile *Addend
1148*4e1bc9a0SAchim Leubner )
1149*4e1bc9a0SAchim Leubner {
1150*4e1bc9a0SAchim Leubner return ostiInterlockedIncrement(agNULL, Addend);
1151*4e1bc9a0SAchim Leubner }
1152*4e1bc9a0SAchim Leubner
1153*4e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
tdsmInterlockedDecrement(smRoot_t * smRoot,sbit32 volatile * Addend)1154*4e1bc9a0SAchim Leubner tdsmInterlockedDecrement(
1155*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1156*4e1bc9a0SAchim Leubner sbit32 volatile *Addend
1157*4e1bc9a0SAchim Leubner )
1158*4e1bc9a0SAchim Leubner {
1159*4e1bc9a0SAchim Leubner return ostiInterlockedDecrement(agNULL, Addend);
1160*4e1bc9a0SAchim Leubner }
1161*4e1bc9a0SAchim Leubner
1162*4e1bc9a0SAchim Leubner
1163*4e1bc9a0SAchim Leubner
1164*4e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
tdsmInterlockedAnd(smRoot_t * smRoot,sbit32 volatile * Destination,sbit32 Value)1165*4e1bc9a0SAchim Leubner tdsmInterlockedAnd(
1166*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1167*4e1bc9a0SAchim Leubner sbit32 volatile *Destination,
1168*4e1bc9a0SAchim Leubner sbit32 Value
1169*4e1bc9a0SAchim Leubner )
1170*4e1bc9a0SAchim Leubner {
1171*4e1bc9a0SAchim Leubner
1172*4e1bc9a0SAchim Leubner return ostiInterlockedAnd(agNULL, Destination, Value);
1173*4e1bc9a0SAchim Leubner }
1174*4e1bc9a0SAchim Leubner
1175*4e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
tdsmInterlockedOr(smRoot_t * smRoot,sbit32 volatile * Destination,sbit32 Value)1176*4e1bc9a0SAchim Leubner tdsmInterlockedOr(
1177*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1178*4e1bc9a0SAchim Leubner sbit32 volatile *Destination,
1179*4e1bc9a0SAchim Leubner sbit32 Value
1180*4e1bc9a0SAchim Leubner )
1181*4e1bc9a0SAchim Leubner {
1182*4e1bc9a0SAchim Leubner return ostiInterlockedOr(agNULL, Destination, Value);
1183*4e1bc9a0SAchim Leubner }
1184*4e1bc9a0SAchim Leubner
1185*4e1bc9a0SAchim Leubner osGLOBAL FORCEINLINE sbit32
tdsmInterlockedExchange(smRoot_t * smRoot,sbit32 volatile * Target,sbit32 Value)1186*4e1bc9a0SAchim Leubner tdsmInterlockedExchange(
1187*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1188*4e1bc9a0SAchim Leubner sbit32 volatile *Target,
1189*4e1bc9a0SAchim Leubner sbit32 Value
1190*4e1bc9a0SAchim Leubner )
1191*4e1bc9a0SAchim Leubner {
1192*4e1bc9a0SAchim Leubner return ostiInterlockedExchange(agNULL, Target, Value);
1193*4e1bc9a0SAchim Leubner }
1194*4e1bc9a0SAchim Leubner
1195*4e1bc9a0SAchim Leubner #endif /*LINUX_VERSION_CODE*/
1196*4e1bc9a0SAchim Leubner
1197*4e1bc9a0SAchim Leubner osGLOBAL bit32
tdsmAllocMemory(smRoot_t * smRoot,void ** osMemHandle,void ** virtPtr,bit32 * physAddrUpper,bit32 * physAddrLower,bit32 alignment,bit32 allocLength,smBOOLEAN isCacheable)1198*4e1bc9a0SAchim Leubner tdsmAllocMemory(
1199*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1200*4e1bc9a0SAchim Leubner void **osMemHandle,
1201*4e1bc9a0SAchim Leubner void ** virtPtr,
1202*4e1bc9a0SAchim Leubner bit32 * physAddrUpper,
1203*4e1bc9a0SAchim Leubner bit32 * physAddrLower,
1204*4e1bc9a0SAchim Leubner bit32 alignment,
1205*4e1bc9a0SAchim Leubner bit32 allocLength,
1206*4e1bc9a0SAchim Leubner smBOOLEAN isCacheable
1207*4e1bc9a0SAchim Leubner )
1208*4e1bc9a0SAchim Leubner {
1209*4e1bc9a0SAchim Leubner tdsaRoot_t *tdsaRoot;
1210*4e1bc9a0SAchim Leubner tdsaContext_t *tdsaAllShared;
1211*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot;
1212*4e1bc9a0SAchim Leubner bit32 status;
1213*4e1bc9a0SAchim Leubner
1214*4e1bc9a0SAchim Leubner TI_DBG5(("tdsmAllocMemory: start\n"));
1215*4e1bc9a0SAchim Leubner
1216*4e1bc9a0SAchim Leubner tdsaRoot = (tdsaRoot_t *)smRoot->tdData;
1217*4e1bc9a0SAchim Leubner if (tdsaRoot == agNULL)
1218*4e1bc9a0SAchim Leubner {
1219*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmAllocMemory: tdsaRoot is NULL\n"));
1220*4e1bc9a0SAchim Leubner return SM_RC_FAILURE;
1221*4e1bc9a0SAchim Leubner }
1222*4e1bc9a0SAchim Leubner
1223*4e1bc9a0SAchim Leubner tdsaAllShared = &(tdsaRoot->tdsaAllShared);
1224*4e1bc9a0SAchim Leubner if (tdsaAllShared == agNULL)
1225*4e1bc9a0SAchim Leubner {
1226*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmAllocMemory: tdsaAllShared is NULL\n"));
1227*4e1bc9a0SAchim Leubner return SM_RC_FAILURE;
1228*4e1bc9a0SAchim Leubner }
1229*4e1bc9a0SAchim Leubner
1230*4e1bc9a0SAchim Leubner tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
1231*4e1bc9a0SAchim Leubner if (tiRoot == agNULL)
1232*4e1bc9a0SAchim Leubner {
1233*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmAllocMemory: tiRoot is NULL\n"));
1234*4e1bc9a0SAchim Leubner return SM_RC_FAILURE;
1235*4e1bc9a0SAchim Leubner }
1236*4e1bc9a0SAchim Leubner
1237*4e1bc9a0SAchim Leubner status = ostiAllocMemory(tiRoot,
1238*4e1bc9a0SAchim Leubner osMemHandle,
1239*4e1bc9a0SAchim Leubner virtPtr,
1240*4e1bc9a0SAchim Leubner physAddrUpper,
1241*4e1bc9a0SAchim Leubner physAddrLower,
1242*4e1bc9a0SAchim Leubner alignment,
1243*4e1bc9a0SAchim Leubner allocLength,
1244*4e1bc9a0SAchim Leubner isCacheable);
1245*4e1bc9a0SAchim Leubner
1246*4e1bc9a0SAchim Leubner if (status == tiSuccess)
1247*4e1bc9a0SAchim Leubner {
1248*4e1bc9a0SAchim Leubner return SM_RC_SUCCESS;
1249*4e1bc9a0SAchim Leubner }
1250*4e1bc9a0SAchim Leubner else
1251*4e1bc9a0SAchim Leubner {
1252*4e1bc9a0SAchim Leubner return SM_RC_FAILURE;
1253*4e1bc9a0SAchim Leubner }
1254*4e1bc9a0SAchim Leubner
1255*4e1bc9a0SAchim Leubner }
1256*4e1bc9a0SAchim Leubner
1257*4e1bc9a0SAchim Leubner osGLOBAL bit32
tdsmFreeMemory(smRoot_t * smRoot,void * osDMAHandle,bit32 allocLength)1258*4e1bc9a0SAchim Leubner tdsmFreeMemory(
1259*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1260*4e1bc9a0SAchim Leubner void *osDMAHandle,
1261*4e1bc9a0SAchim Leubner bit32 allocLength
1262*4e1bc9a0SAchim Leubner )
1263*4e1bc9a0SAchim Leubner {
1264*4e1bc9a0SAchim Leubner tdsaRoot_t *tdsaRoot;
1265*4e1bc9a0SAchim Leubner tdsaContext_t *tdsaAllShared;
1266*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot;
1267*4e1bc9a0SAchim Leubner bit32 status;
1268*4e1bc9a0SAchim Leubner
1269*4e1bc9a0SAchim Leubner TI_DBG5(("tdsmFreeMemory: start\n"));
1270*4e1bc9a0SAchim Leubner
1271*4e1bc9a0SAchim Leubner tdsaRoot = (tdsaRoot_t *)smRoot->tdData;
1272*4e1bc9a0SAchim Leubner if (tdsaRoot == agNULL)
1273*4e1bc9a0SAchim Leubner {
1274*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmFreeMemory: tdsaRoot is NULL\n"));
1275*4e1bc9a0SAchim Leubner return SM_RC_FAILURE;
1276*4e1bc9a0SAchim Leubner }
1277*4e1bc9a0SAchim Leubner
1278*4e1bc9a0SAchim Leubner tdsaAllShared = &(tdsaRoot->tdsaAllShared);
1279*4e1bc9a0SAchim Leubner if (tdsaAllShared == agNULL)
1280*4e1bc9a0SAchim Leubner {
1281*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmFreeMemory: tdsaAllShared is NULL\n"));
1282*4e1bc9a0SAchim Leubner return SM_RC_FAILURE;
1283*4e1bc9a0SAchim Leubner }
1284*4e1bc9a0SAchim Leubner
1285*4e1bc9a0SAchim Leubner tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
1286*4e1bc9a0SAchim Leubner if (tiRoot == agNULL)
1287*4e1bc9a0SAchim Leubner {
1288*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmFreeMemory: tiRoot is NULL\n"));
1289*4e1bc9a0SAchim Leubner return SM_RC_FAILURE;
1290*4e1bc9a0SAchim Leubner }
1291*4e1bc9a0SAchim Leubner
1292*4e1bc9a0SAchim Leubner status = ostiFreeMemory(tiRoot,
1293*4e1bc9a0SAchim Leubner osDMAHandle,
1294*4e1bc9a0SAchim Leubner allocLength);
1295*4e1bc9a0SAchim Leubner
1296*4e1bc9a0SAchim Leubner if (status == tiSuccess)
1297*4e1bc9a0SAchim Leubner {
1298*4e1bc9a0SAchim Leubner return SM_RC_SUCCESS;
1299*4e1bc9a0SAchim Leubner }
1300*4e1bc9a0SAchim Leubner else
1301*4e1bc9a0SAchim Leubner {
1302*4e1bc9a0SAchim Leubner return SM_RC_FAILURE;
1303*4e1bc9a0SAchim Leubner }
1304*4e1bc9a0SAchim Leubner }
1305*4e1bc9a0SAchim Leubner
1306*4e1bc9a0SAchim Leubner FORCEINLINE bit32
tdsmRotateQnumber(smRoot_t * smRoot,smDeviceHandle_t * smDeviceHandle)1307*4e1bc9a0SAchim Leubner tdsmRotateQnumber(smRoot_t *smRoot,
1308*4e1bc9a0SAchim Leubner smDeviceHandle_t *smDeviceHandle
1309*4e1bc9a0SAchim Leubner )
1310*4e1bc9a0SAchim Leubner {
1311*4e1bc9a0SAchim Leubner tdsaRoot_t *tdsaRoot;
1312*4e1bc9a0SAchim Leubner tdsaContext_t *tdsaAllShared;
1313*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot;
1314*4e1bc9a0SAchim Leubner tdsaDeviceData_t *oneDeviceData;
1315*4e1bc9a0SAchim Leubner bit32 ret = 0;
1316*4e1bc9a0SAchim Leubner
1317*4e1bc9a0SAchim Leubner tdsaRoot = (tdsaRoot_t *)smRoot->tdData;
1318*4e1bc9a0SAchim Leubner tdsaAllShared = &(tdsaRoot->tdsaAllShared);
1319*4e1bc9a0SAchim Leubner tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
1320*4e1bc9a0SAchim Leubner
1321*4e1bc9a0SAchim Leubner
1322*4e1bc9a0SAchim Leubner TI_DBG6(("tdsmRotateQnumber: start\n"));
1323*4e1bc9a0SAchim Leubner
1324*4e1bc9a0SAchim Leubner if (smDeviceHandle == agNULL)
1325*4e1bc9a0SAchim Leubner {
1326*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmRotateQnumber: smDeviceHandle is NULL !!!!\n"));
1327*4e1bc9a0SAchim Leubner return ret;
1328*4e1bc9a0SAchim Leubner }
1329*4e1bc9a0SAchim Leubner oneDeviceData = (tdsaDeviceData_t *)smDeviceHandle->tdData;
1330*4e1bc9a0SAchim Leubner if (oneDeviceData == agNULL)
1331*4e1bc9a0SAchim Leubner {
1332*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmRotateQnumber: oneDeviceData is NULL !!!!\n"));
1333*4e1bc9a0SAchim Leubner return ret;
1334*4e1bc9a0SAchim Leubner }
1335*4e1bc9a0SAchim Leubner return tdsaRotateQnumber(tiRoot, oneDeviceData);
1336*4e1bc9a0SAchim Leubner }
1337*4e1bc9a0SAchim Leubner
1338*4e1bc9a0SAchim Leubner osGLOBAL bit32
tdsmSetDeviceQueueDepth(smRoot_t * smRoot,smIORequest_t * smIORequest,bit32 QueueDepth)1339*4e1bc9a0SAchim Leubner tdsmSetDeviceQueueDepth(smRoot_t *smRoot,
1340*4e1bc9a0SAchim Leubner smIORequest_t *smIORequest,
1341*4e1bc9a0SAchim Leubner bit32 QueueDepth
1342*4e1bc9a0SAchim Leubner )
1343*4e1bc9a0SAchim Leubner {
1344*4e1bc9a0SAchim Leubner tdsaRoot_t *tdsaRoot = agNULL;
1345*4e1bc9a0SAchim Leubner tdsaContext_t *tdsaAllShared = agNULL;
1346*4e1bc9a0SAchim Leubner tiRoot_t *tiRoot = agNULL;
1347*4e1bc9a0SAchim Leubner tdIORequestBody_t *tdIORequestBody = (tdIORequestBody_t *)smIORequest->tdData;
1348*4e1bc9a0SAchim Leubner tiIORequest_t *tiIORequest = tdIORequestBody->tiIORequest;
1349*4e1bc9a0SAchim Leubner
1350*4e1bc9a0SAchim Leubner
1351*4e1bc9a0SAchim Leubner TI_DBG5(("tdsmSetDeviceQueueDepth: start\n"));
1352*4e1bc9a0SAchim Leubner
1353*4e1bc9a0SAchim Leubner tdsaRoot = (tdsaRoot_t *)smRoot->tdData;
1354*4e1bc9a0SAchim Leubner if (tdsaRoot == agNULL)
1355*4e1bc9a0SAchim Leubner {
1356*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmSetDeviceQueueDepth: tdsaRoot is NULL\n"));
1357*4e1bc9a0SAchim Leubner return SM_RC_FAILURE;
1358*4e1bc9a0SAchim Leubner }
1359*4e1bc9a0SAchim Leubner
1360*4e1bc9a0SAchim Leubner tdsaAllShared = &(tdsaRoot->tdsaAllShared);
1361*4e1bc9a0SAchim Leubner if (tdsaAllShared == agNULL)
1362*4e1bc9a0SAchim Leubner {
1363*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmSetDeviceQueueDepth: tdsaAllShared is NULL\n"));
1364*4e1bc9a0SAchim Leubner return SM_RC_FAILURE;
1365*4e1bc9a0SAchim Leubner }
1366*4e1bc9a0SAchim Leubner
1367*4e1bc9a0SAchim Leubner tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot;
1368*4e1bc9a0SAchim Leubner if (tiRoot == agNULL)
1369*4e1bc9a0SAchim Leubner {
1370*4e1bc9a0SAchim Leubner TI_DBG1(("tdsmFreeMemory: tiRoot is NULL\n"));
1371*4e1bc9a0SAchim Leubner return SM_RC_FAILURE;
1372*4e1bc9a0SAchim Leubner }
1373*4e1bc9a0SAchim Leubner
1374*4e1bc9a0SAchim Leubner return ostiSetDeviceQueueDepth(tiRoot, tiIORequest, QueueDepth);
1375*4e1bc9a0SAchim Leubner }
1376*4e1bc9a0SAchim Leubner
tdsmGetTransportParam(smRoot_t * smRoot,char * key,char * subkey1,char * subkey2,char * subkey3,char * subkey4,char * subkey5,char * valueName,char * buffer,bit32 bufferLen,bit32 * lenReceived)1377*4e1bc9a0SAchim Leubner osGLOBAL bit32 tdsmGetTransportParam(
1378*4e1bc9a0SAchim Leubner smRoot_t *smRoot,
1379*4e1bc9a0SAchim Leubner char *key,
1380*4e1bc9a0SAchim Leubner char *subkey1,
1381*4e1bc9a0SAchim Leubner char *subkey2,
1382*4e1bc9a0SAchim Leubner char *subkey3,
1383*4e1bc9a0SAchim Leubner char *subkey4,
1384*4e1bc9a0SAchim Leubner char *subkey5,
1385*4e1bc9a0SAchim Leubner char *valueName,
1386*4e1bc9a0SAchim Leubner char *buffer,
1387*4e1bc9a0SAchim Leubner bit32 bufferLen,
1388*4e1bc9a0SAchim Leubner bit32 *lenReceived
1389*4e1bc9a0SAchim Leubner )
1390*4e1bc9a0SAchim Leubner {
1391*4e1bc9a0SAchim Leubner bit32 ret = tiError;
1392*4e1bc9a0SAchim Leubner
1393*4e1bc9a0SAchim Leubner TI_DBG7(("tdsmGetTransportParam: start\n"));
1394*4e1bc9a0SAchim Leubner ret = ostiGetTransportParam(agNULL,
1395*4e1bc9a0SAchim Leubner key,
1396*4e1bc9a0SAchim Leubner subkey1,
1397*4e1bc9a0SAchim Leubner subkey2,
1398*4e1bc9a0SAchim Leubner subkey3,
1399*4e1bc9a0SAchim Leubner subkey4,
1400*4e1bc9a0SAchim Leubner subkey5,
1401*4e1bc9a0SAchim Leubner valueName,
1402*4e1bc9a0SAchim Leubner buffer,
1403*4e1bc9a0SAchim Leubner bufferLen,
1404*4e1bc9a0SAchim Leubner lenReceived
1405*4e1bc9a0SAchim Leubner );
1406*4e1bc9a0SAchim Leubner return ret;
1407*4e1bc9a0SAchim Leubner }
1408*4e1bc9a0SAchim Leubner #endif /* FDS_SM */
1409*4e1bc9a0SAchim Leubner
1410