FreeBSD kernel pms device code
tdtimers.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/*******************************************************************************/
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD$");
30#include <dev/pms/config.h>
31
35
39
44
45#ifdef FDS_SM
49#endif
50
51#ifdef FDS_DM
55#endif
56
60
61#ifdef INITIATOR_DRIVER
65#endif
66
67#ifdef TARGET_DRIVER
69#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h>
71#endif
72
75
76/*****************************************************************************
77*! \brief tiCOMTimerTick
78*
79* Purpose: This function is called to every usecsPerTick interval
80*
81* \param tiRoot: Pointer to initiator specific root data structure for this
82* instance of the driver.
83*
84* \return: None
85*
86*
87*****************************************************************************/
88osGLOBAL void
91 )
92{
93 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)(tiRoot->tdData);
94 agsaRoot_t *agRoot = &tdsaRoot->tdsaAllShared.agRootNonInt;
95#ifdef FDS_DM
96 dmRoot_t *dmRoot = &tdsaRoot->tdsaAllShared.dmRoot;
97#endif
98
99#ifdef FDS_SM_NOT_YET
100 smRoot_t *smRoot = &tdsaRoot->tdsaAllShared.smRoot;
101#endif
102 /* checking the lower layer */
103 saTimerTick(agRoot);
104
105#ifdef FDS_DM
106 /* checking the DM */
107 dmTimerTick(dmRoot);
108#endif
109
110#ifdef FDS_SM_NOT_YET
111 /* checking the SM */
112 smTimerTick(smRoot);
113#endif
114
115 /*
116 timers for discovery
117 checking tdsaRoot_t timers
118 */
119
121
122}
123
124/*****************************************************************************
125*! \brief tdsaInitTimerRequest
126*
127* Purpose: This function initiallizes timer request
128*
129* \param tiRoot: Pointer to initiator specific root data structure
130* for this instance of the driver.
131* \param timerrequest Pointer to timer request
132*
133* \return: None
134*
135*
136*****************************************************************************/
137osGLOBAL void
140 tdsaTimerRequest_t *timerRequest
141 )
142{
143 timerRequest->timeout = 0;
144 timerRequest->timerCBFunc = agNULL;
145 timerRequest->timerData1 = agNULL;
146 timerRequest->timerData2 = agNULL;
147 timerRequest->timerData3 = agNULL;
148 TDLIST_INIT_ELEMENT((&timerRequest->timerLink));
149}
150
151/*****************************************************************************
152*! \brief tdsaSetTimerRequest
153*
154* Purpose: This function sets timer request
155*
156* \param tiRoot: Pointer to initiator specific root data structure
157* for this instance of the driver.
158* \param timerrequest Pointer to timer request
159* \param timeout timeout value
160* \param CBFunc timer CB function
161* \param timerData1 Data associated with the timer
162* \param timerData2 Data associated with the timer
163* \param timerData3 Data associated with the timer
164*
165* \return: None
166*
167*
168*****************************************************************************/
169osGLOBAL void
172 tdsaTimerRequest_t *timerRequest,
173 bit32 timeout,
174 tdsaTimerCBFunc_t CBFunc,
175 void *timerData1,
176 void *timerData2,
177 void *timerData3
178 )
179{
180 timerRequest->timeout = timeout;
181 timerRequest->timerCBFunc = CBFunc;
182 timerRequest->timerData1 = timerData1;
183 timerRequest->timerData2 = timerData2;
184 timerRequest->timerData3 = timerData3;
185}
186
187/*****************************************************************************
188*! \brief tdsaAddTimer
189*
190* Purpose: This function adds timer request to timer list
191*
192* \param tiRoot: Pointer to initiator specific root data structure
193* for this instance of the driver.
194* \param timerListHdr Pointer to the timer list
195* \param timerrequest Pointer to timer request
196*
197* \return: None
198*
199*
200*****************************************************************************/
201osGLOBAL void
204 tdList_t *timerListHdr,
205 tdsaTimerRequest_t *timerRequest
206 )
207{
209 TDLIST_ENQUEUE_AT_TAIL(&(timerRequest->timerLink), timerListHdr);
210 timerRequest->timerRunning = agTRUE;
212}
213
214/*****************************************************************************
215*! \brief tdsaKillTimer
216*
217* Purpose: This function kills timer request.
218*
219* \param tiRoot: Pointer to initiator specific root data structure
220* for this instance of the driver.
221* \param timerrequest Pointer to timer request
222*
223* \return: None
224*
225*
226*****************************************************************************/
227osGLOBAL void
230 tdsaTimerRequest_t *timerRequest
231 )
232{
234 timerRequest->timerRunning = agFALSE;
235 TDLIST_DEQUEUE_THIS(&(timerRequest->timerLink));
237}
238
239/*****************************************************************************
240*! \brief tdsaProcessTimers
241*
242* Purpose: This function processes timer request.
243*
244* \param tiRoot: Pointer to initiator specific root data structure
245* for this instance of the driver.
246*
247* \return: None
248*
249*
250*****************************************************************************/
251osGLOBAL void
254 )
255{
256 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)(tiRoot->tdData);
257 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
258 tdsaTimerRequest_t *timerRequest_to_process = agNULL;
259 tdList_t *timerlist_to_process, *nexttimerlist = agNULL;
260
261
262 timerlist_to_process = &tdsaAllShared->timerlist;
263
264 timerlist_to_process = timerlist_to_process->flink;
265
266 while ((timerlist_to_process != agNULL) && (timerlist_to_process != &tdsaAllShared->timerlist))
267 {
268 nexttimerlist = timerlist_to_process->flink;
269
271 timerRequest_to_process = TDLIST_OBJECT_BASE(tdsaTimerRequest_t, timerLink, timerlist_to_process);
273
274 if (timerRequest_to_process == agNULL)
275 {
276 TI_DBG1(("tdsaProcessTimers: timerRequest_to_process is NULL! Error!!!\n"));
277 return;
278 }
279
280 timerRequest_to_process->timeout--;
281
282 if (timerRequest_to_process->timeout == 0)
283 {
285 if (timerRequest_to_process->timerRunning == agTRUE)
286 {
287 timerRequest_to_process->timerRunning = agFALSE;
288 TDLIST_DEQUEUE_THIS(timerlist_to_process);
289 }
291 /* calling call back function */
292 (timerRequest_to_process->timerCBFunc)(tiRoot,
293 timerRequest_to_process->timerData1,
294 timerRequest_to_process->timerData2,
295 timerRequest_to_process->timerData3
296 );
297 }
298 timerlist_to_process = nexttimerlist;
299 }
300 return;
301}
302
osGLOBAL void dmTimerTick(dmRoot_t *dmRoot)
#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
The file defines the constants, data structure, and functions defined by LL API.
The file defines the declaration of tSDK APIs.
GLOBAL void saTimerTick(agsaRoot_t *agRoot)
TimerTick.
Definition: satimer.c:54
The file defines the declaration of OS APIs.
osGLOBAL void smTimerTick(smRoot_t *smRoot)
Definition: smtimer.c:45
data structure stores OS specific and LL specific context
Definition: sa.h:1658
Definition: dm.h:91
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
tdList_t timerlist
Definition: tdsatypes.h:237
the root data structure for TD layer
Definition: tdsatypes.h:362
tdsaContext_t tdsaAllShared
Definition: tdsatypes.h:364
data structure for timer request Timer requests are enqueued and dequeued using tdList_t and have a c...
Definition: tdtypes.h:122
void * timerData3
Definition: tdtypes.h:127
tdsaTimerCBFunc_t timerCBFunc
Definition: tdtypes.h:128
tdList_t timerLink
Definition: tdtypes.h:129
bit32 timerRunning
Definition: tdtypes.h:130
void * timerData1
Definition: tdtypes.h:125
void * timerData2
Definition: tdtypes.h:126
Definition: titypes.h:61
void * tdData
Definition: titypes.h:63
@ TD_TIMER_LOCK
Definition: tddefs.h:1159
#define TDLIST_OBJECT_BASE(baseType, fieldName, fieldPtr)
Definition: tdlist.h:161
#define TDLIST_ENQUEUE_AT_TAIL(toAddHdr, listHdr)
Definition: tdlist.h:65
#define TDLIST_INIT_ELEMENT(hdr)
Definition: tdlist.h:51
#define TDLIST_DEQUEUE_THIS(hdr)
Definition: tdlist.h:79
void tdsaSingleThreadedEnter(tiRoot_t *ptiRoot, bit32 queueId)
Definition: tdmisc.c:2862
void tdsaSingleThreadedLeave(tiRoot_t *ptiRoot, bit32 queueId)
Definition: tdmisc.c:2875
osGLOBAL void tdsaInitTimerRequest(tiRoot_t *tiRoot, tdsaTimerRequest_t *timerRequest)
Definition: tdtimers.c:138
osGLOBAL void tdsaProcessTimers(tiRoot_t *tiRoot)
Definition: tdtimers.c:252
__FBSDID("$FreeBSD$")
osGLOBAL void tiCOMTimerTick(tiRoot_t *tiRoot)
Definition: tdtimers.c:89
osGLOBAL void tdsaAddTimer(tiRoot_t *tiRoot, tdList_t *timerListHdr, tdsaTimerRequest_t *timerRequest)
Definition: tdtimers.c:202
osGLOBAL void tdsaKillTimer(tiRoot_t *tiRoot, tdsaTimerRequest_t *timerRequest)
Definition: tdtimers.c:228
osGLOBAL void tdsaSetTimerRequest(tiRoot_t *tiRoot, tdsaTimerRequest_t *timerRequest, bit32 timeout, tdsaTimerCBFunc_t CBFunc, void *timerData1, void *timerData2, void *timerData3)
Definition: tdtimers.c:170
void(* tdsaTimerCBFunc_t)(tiRoot_t *tiRoot, void *timerData1, void *timerData2, void *timerData3)
Definition: tdtypes.h:116
#define TI_DBG1(a)
Definition: tiglobal.h:48