Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[cascardo/linux.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 declarations 
32
33     Revision History:
34         Who                     When                 What
35         --------    ----------      ----------------------------------------------
36         Name                    Date                 Modification logs
37         Shiang Tu               Aug-28-2008          init version
38         Justin P. Mattock       11/07/2010           Fix a typo
39
40 */
41
42 #ifndef __RTMP_TIMER_H__
43 #define  __RTMP_TIMER_H__
44
45 #include "rtmp_os.h"
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 /* ----------------- Timer Related MARCO ---------------*/
54 /* In some os or chipset, we have a lot of timer functions and will read/write register, */
55 /* it's not allowed in Linux USB sub-system to do it ( because of sleep issue when */
56 /* submit to ctrl pipe). So we need a wrapper function to take care it. */
57
58 #ifdef RTMP_TIMER_TASK_SUPPORT
59 typedef void(*RTMP_TIMER_TASK_HANDLE) (void *SystemSpecific1,
60                                        void *FunctionContext,
61                                        void *SystemSpecific2,
62                                        void *SystemSpecific3);
63 #endif /* RTMP_TIMER_TASK_SUPPORT // */
64
65 struct rt_ralink_timer {
66         struct timer_list TimerObj;     /* Ndis Timer object */
67         BOOLEAN Valid;          /* Set to True when call RTMPInitTimer */
68         BOOLEAN State;          /* True if timer cancelled */
69         BOOLEAN PeriodicType;   /* True if timer is periodic timer */
70         BOOLEAN Repeat;         /* True if periodic timer */
71         unsigned long TimerValue;       /* Timer value in milliseconds */
72         unsigned long cookie;           /* os specific object */
73 #ifdef RTMP_TIMER_TASK_SUPPORT
74         RTMP_TIMER_TASK_HANDLE handle;
75         void *pAd;
76 #endif                          /* RTMP_TIMER_TASK_SUPPORT // */
77 };
78
79 #ifdef RTMP_TIMER_TASK_SUPPORT
80 struct rt_rtmp_timer_task_entry {
81         struct rt_ralink_timer *pRaTimer;
82         struct rt_rtmp_timer_task_entry *pNext;
83 };
84
85 #define TIMER_QUEUE_SIZE_MAX    128
86 struct rt_rtmp_timer_task_queue {
87         unsigned int status;
88         unsigned char *pTimerQPoll;
89         struct rt_rtmp_timer_task_entry *pQPollFreeList;
90         struct rt_rtmp_timer_task_entry *pQHead;
91         struct rt_rtmp_timer_task_entry *pQTail;
92 };
93
94 #define BUILD_TIMER_FUNCTION(_func)                                                                             \
95 void rtmp_timer_##_func(unsigned long data)                                                                             \
96 {                                                                                                                                                       \
97         struct rt_ralink_timer *_pTimer = (struct rt_ralink_timer *)data;                               \
98         struct rt_rtmp_timer_task_entry *_pQNode;                                                                               \
99         struct rt_rtmp_adapter *_pAd;                                                                                   \
100                                                                                                                                                         \
101         _pTimer->handle = _func;                                                                                                        \
102         _pAd = (struct rt_rtmp_adapter *)_pTimer->pAd;                                                                          \
103         _pQNode = RtmpTimerQInsert(_pAd, _pTimer);                                                              \
104         if ((_pQNode == NULL) && (_pAd->TimerQ.status & RTMP_TASK_CAN_DO_INSERT))       \
105                 RTMP_OS_Add_Timer(&_pTimer->TimerObj, OS_HZ);                                                   \
106 }
107 #else
108 #define BUILD_TIMER_FUNCTION(_func)                                                                             \
109 void rtmp_timer_##_func(unsigned long data)                                                                             \
110 {                                                                                                                                                       \
111         struct rt_ralink_timer *pTimer = (struct rt_ralink_timer *)data;                                \
112                                                                                                                                                         \
113         _func(NULL, (void *)pTimer->cookie, NULL, pTimer);                                                      \
114         if (pTimer->Repeat)                                                                                                             \
115                 RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue);                       \
116 }
117 #endif /* RTMP_TIMER_TASK_SUPPORT // */
118
119 DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
120 DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
121 DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
122 DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
123 DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
124 #ifdef RTMP_MAC_USB
125 DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
126 #endif /* RTMP_MAC_USB // */
127
128 DECLARE_TIMER_FUNCTION(BeaconTimeout);
129 DECLARE_TIMER_FUNCTION(ScanTimeout);
130 DECLARE_TIMER_FUNCTION(AuthTimeout);
131 DECLARE_TIMER_FUNCTION(AssocTimeout);
132 DECLARE_TIMER_FUNCTION(ReassocTimeout);
133 DECLARE_TIMER_FUNCTION(DisassocTimeout);
134 DECLARE_TIMER_FUNCTION(LinkDownExec);
135 DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
136 DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
137 DECLARE_TIMER_FUNCTION(PsPollWakeExec);
138 DECLARE_TIMER_FUNCTION(RadioOnExec);
139
140 #ifdef RTMP_MAC_USB
141 DECLARE_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout);
142 #endif /* RTMP_MAC_USB // */
143
144 #if defined(AP_LED) || defined(STA_LED)
145 DECLARE_TIMER_FUNCTION(LedCtrlMain);
146 #endif
147
148 #endif /* __RTMP_TIMER_H__ // */