]> bbs.cooldavid.org Git - net-next-2.6.git/blob - drivers/staging/rt2860/rtmp_timer.h
5f6e3ce368a0b7966f0b625414455d4a56269373
[net-next-2.6.git] / drivers / staging / rt2860 / rtmp_timer.h
1 /*
2  *************************************************************************
3  * Ralink Tech Inc.
4  * 5F., No.36, Taiyuan St., Jhubei City,
5  * Hsinchu County 302,
6  * Taiwan, R.O.C.
7  *
8  * (c) Copyright 2002-2007, Ralink Technology, Inc.
9  *
10  * This program is free software; you can redistribute it and/or modify  *
11  * it under the terms of the GNU General Public License as published by  *
12  * the Free Software Foundation; either version 2 of the License, or     *
13  * (at your option) any later version.                                   *
14  *                                                                       *
15  * This program is distributed in the hope that it will be useful,       *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
18  * GNU General Public License for more details.                          *
19  *                                                                       *
20  * You should have received a copy of the GNU General Public License     *
21  * along with this program; if not, write to the                         *
22  * Free Software Foundation, Inc.,                                       *
23  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
24  *                                                                       *
25  *************************************************************************
26
27     Module Name:
28         rtmp_timer.h
29
30     Abstract:
31         Ralink Wireless Driver timer related data structures and delcarations
32
33     Revision History:
34         Who           When                What
35         --------    ----------      ----------------------------------------------
36         Name          Date                 Modification logs
37         Shiang Tu    Aug-28-2008        init version
38
39 */
40
41 #ifndef __RTMP_TIMER_H__
42 #define  __RTMP_TIMER_H__
43
44 #include "rtmp_os.h"
45
46
47 #define DECLARE_TIMER_FUNCTION(_func)                   \
48         void rtmp_timer_##_func(unsigned long data)
49
50 #define GET_TIMER_FUNCTION(_func)                               \
51         rtmp_timer_##_func
52
53
54 /* ----------------- Timer Related MARCO ---------------*/
55 // In some os or chipset, we have a lot of timer functions and will read/write register,
56 //   it's not allowed in Linux USB sub-system to do it ( because of sleep issue when
57 //  submit to ctrl pipe). So we need a wrapper function to take care it.
58
59 #ifdef RTMP_TIMER_TASK_SUPPORT
60 typedef VOID (*RTMP_TIMER_TASK_HANDLE)(
61         IN  PVOID   SystemSpecific1,
62         IN  PVOID   FunctionContext,
63         IN  PVOID   SystemSpecific2,
64         IN  PVOID   SystemSpecific3);
65 #endif // RTMP_TIMER_TASK_SUPPORT //
66
67 typedef struct  _RALINK_TIMER_STRUCT    {
68         RTMP_OS_TIMER           TimerObj;       // Ndis Timer object
69         BOOLEAN                         Valid;                  // Set to True when call RTMPInitTimer
70         BOOLEAN                         State;          // True if timer cancelled
71         BOOLEAN                         PeriodicType;   // True if timer is periodic timer
72         BOOLEAN                         Repeat;         // True if periodic timer
73         ULONG                           TimerValue;     // Timer value in milliseconds
74         ULONG                           cookie;                 // os specific object
75 #ifdef RTMP_TIMER_TASK_SUPPORT
76         RTMP_TIMER_TASK_HANDLE  handle;
77         void                                    *pAd;
78 #endif // RTMP_TIMER_TASK_SUPPORT //
79 }RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;
80
81
82 #ifdef RTMP_TIMER_TASK_SUPPORT
83 typedef struct _RTMP_TIMER_TASK_ENTRY_
84 {
85         RALINK_TIMER_STRUCT                     *pRaTimer;
86         struct _RTMP_TIMER_TASK_ENTRY_  *pNext;
87 }RTMP_TIMER_TASK_ENTRY;
88
89
90 #define TIMER_QUEUE_SIZE_MAX    128
91 typedef struct _RTMP_TIMER_TASK_QUEUE_
92 {
93         unsigned int                            status;
94         unsigned char                           *pTimerQPoll;
95         RTMP_TIMER_TASK_ENTRY   *pQPollFreeList;
96         RTMP_TIMER_TASK_ENTRY   *pQHead;
97         RTMP_TIMER_TASK_ENTRY   *pQTail;
98 }RTMP_TIMER_TASK_QUEUE;
99
100 #define BUILD_TIMER_FUNCTION(_func)                                                                             \
101 void rtmp_timer_##_func(unsigned long data)                                                                             \
102 {                                                                                                                                                       \
103         PRALINK_TIMER_STRUCT    _pTimer = (PRALINK_TIMER_STRUCT)data;                           \
104         RTMP_TIMER_TASK_ENTRY   *_pQNode;                                                                               \
105         RTMP_ADAPTER                    *_pAd;                                                                                  \
106                                                                                                                                                         \
107         _pTimer->handle = _func;                                                                                                        \
108         _pAd = (RTMP_ADAPTER *)_pTimer->pAd;                                                                            \
109         _pQNode = RtmpTimerQInsert(_pAd, _pTimer);                                                              \
110         if ((_pQNode == NULL) && (_pAd->TimerQ.status & RTMP_TASK_CAN_DO_INSERT))       \
111                 RTMP_OS_Add_Timer(&_pTimer->TimerObj, OS_HZ);                                                   \
112 }
113 #else
114 #define BUILD_TIMER_FUNCTION(_func)                                                                             \
115 void rtmp_timer_##_func(unsigned long data)                                                                             \
116 {                                                                                                                                                       \
117         PRALINK_TIMER_STRUCT    pTimer = (PRALINK_TIMER_STRUCT) data;                           \
118                                                                                                                                                         \
119         _func(NULL, (PVOID) pTimer->cookie, NULL, pTimer);                                                      \
120         if (pTimer->Repeat)                                                                                                             \
121                 RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue);                       \
122 }
123 #endif // RTMP_TIMER_TASK_SUPPORT //
124
125
126 DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
127 DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
128 DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
129 DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
130 DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
131 #ifdef RTMP_MAC_USB
132 DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
133 #endif // RTMP_MAC_USB //
134
135 DECLARE_TIMER_FUNCTION(BeaconTimeout);
136 DECLARE_TIMER_FUNCTION(ScanTimeout);
137 DECLARE_TIMER_FUNCTION(AuthTimeout);
138 DECLARE_TIMER_FUNCTION(AssocTimeout);
139 DECLARE_TIMER_FUNCTION(ReassocTimeout);
140 DECLARE_TIMER_FUNCTION(DisassocTimeout);
141 DECLARE_TIMER_FUNCTION(LinkDownExec);
142 DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
143 DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
144 DECLARE_TIMER_FUNCTION(PsPollWakeExec);
145 DECLARE_TIMER_FUNCTION(RadioOnExec);
146
147 #ifdef RTMP_MAC_USB
148 DECLARE_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout);
149 #endif // RTMP_MAC_USB //
150
151 #if defined(AP_LED) || defined(STA_LED)
152 DECLARE_TIMER_FUNCTION(LedCtrlMain);
153 #endif
154
155
156 #endif // __RTMP_TIMER_H__ //