Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 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 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 46 | #define DECLARE_TIMER_FUNCTION(_func) \ |
| 47 | void rtmp_timer_##_func(unsigned long data) |
| 48 | |
| 49 | #define GET_TIMER_FUNCTION(_func) \ |
| 50 | rtmp_timer_##_func |
| 51 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 52 | /* ----------------- Timer Related MARCO ---------------*/ |
| 53 | // In some os or chipset, we have a lot of timer functions and will read/write register, |
| 54 | // it's not allowed in Linux USB sub-system to do it ( because of sleep issue when |
| 55 | // submit to ctrl pipe). So we need a wrapper function to take care it. |
| 56 | |
| 57 | #ifdef RTMP_TIMER_TASK_SUPPORT |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 58 | typedef VOID(*RTMP_TIMER_TASK_HANDLE) (IN PVOID SystemSpecific1, |
| 59 | IN PVOID FunctionContext, |
| 60 | IN PVOID SystemSpecific2, |
| 61 | IN PVOID SystemSpecific3); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 62 | #endif // RTMP_TIMER_TASK_SUPPORT // |
| 63 | |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 64 | typedef struct _RALINK_TIMER_STRUCT { |
| 65 | RTMP_OS_TIMER TimerObj; // Ndis Timer object |
| 66 | BOOLEAN Valid; // Set to True when call RTMPInitTimer |
| 67 | BOOLEAN State; // True if timer cancelled |
| 68 | BOOLEAN PeriodicType; // True if timer is periodic timer |
| 69 | BOOLEAN Repeat; // True if periodic timer |
| 70 | ULONG TimerValue; // Timer value in milliseconds |
| 71 | ULONG cookie; // os specific object |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 72 | #ifdef RTMP_TIMER_TASK_SUPPORT |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 73 | RTMP_TIMER_TASK_HANDLE handle; |
| 74 | void *pAd; |
| 75 | #endif // RTMP_TIMER_TASK_SUPPORT // |
| 76 | } RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 77 | |
| 78 | #ifdef RTMP_TIMER_TASK_SUPPORT |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 79 | typedef struct _RTMP_TIMER_TASK_ENTRY_ { |
| 80 | RALINK_TIMER_STRUCT *pRaTimer; |
| 81 | struct _RTMP_TIMER_TASK_ENTRY_ *pNext; |
| 82 | } RTMP_TIMER_TASK_ENTRY; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 83 | |
| 84 | #define TIMER_QUEUE_SIZE_MAX 128 |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 85 | typedef struct _RTMP_TIMER_TASK_QUEUE_ { |
| 86 | unsigned int status; |
| 87 | unsigned char *pTimerQPoll; |
| 88 | RTMP_TIMER_TASK_ENTRY *pQPollFreeList; |
| 89 | RTMP_TIMER_TASK_ENTRY *pQHead; |
| 90 | RTMP_TIMER_TASK_ENTRY *pQTail; |
| 91 | } RTMP_TIMER_TASK_QUEUE; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 92 | |
| 93 | #define BUILD_TIMER_FUNCTION(_func) \ |
| 94 | void rtmp_timer_##_func(unsigned long data) \ |
| 95 | { \ |
| 96 | PRALINK_TIMER_STRUCT _pTimer = (PRALINK_TIMER_STRUCT)data; \ |
| 97 | RTMP_TIMER_TASK_ENTRY *_pQNode; \ |
| 98 | RTMP_ADAPTER *_pAd; \ |
| 99 | \ |
| 100 | _pTimer->handle = _func; \ |
| 101 | _pAd = (RTMP_ADAPTER *)_pTimer->pAd; \ |
| 102 | _pQNode = RtmpTimerQInsert(_pAd, _pTimer); \ |
| 103 | if ((_pQNode == NULL) && (_pAd->TimerQ.status & RTMP_TASK_CAN_DO_INSERT)) \ |
| 104 | RTMP_OS_Add_Timer(&_pTimer->TimerObj, OS_HZ); \ |
| 105 | } |
| 106 | #else |
| 107 | #define BUILD_TIMER_FUNCTION(_func) \ |
| 108 | void rtmp_timer_##_func(unsigned long data) \ |
| 109 | { \ |
| 110 | PRALINK_TIMER_STRUCT pTimer = (PRALINK_TIMER_STRUCT) data; \ |
| 111 | \ |
| 112 | _func(NULL, (PVOID) pTimer->cookie, NULL, pTimer); \ |
| 113 | if (pTimer->Repeat) \ |
| 114 | RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue); \ |
| 115 | } |
| 116 | #endif // RTMP_TIMER_TASK_SUPPORT // |
| 117 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 118 | DECLARE_TIMER_FUNCTION(MlmePeriodicExec); |
| 119 | DECLARE_TIMER_FUNCTION(MlmeRssiReportExec); |
| 120 | DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout); |
| 121 | DECLARE_TIMER_FUNCTION(APSDPeriodicExec); |
| 122 | DECLARE_TIMER_FUNCTION(AsicRfTuningExec); |
| 123 | #ifdef RTMP_MAC_USB |
| 124 | DECLARE_TIMER_FUNCTION(BeaconUpdateExec); |
| 125 | #endif // RTMP_MAC_USB // |
| 126 | |
| 127 | DECLARE_TIMER_FUNCTION(BeaconTimeout); |
| 128 | DECLARE_TIMER_FUNCTION(ScanTimeout); |
| 129 | DECLARE_TIMER_FUNCTION(AuthTimeout); |
| 130 | DECLARE_TIMER_FUNCTION(AssocTimeout); |
| 131 | DECLARE_TIMER_FUNCTION(ReassocTimeout); |
| 132 | DECLARE_TIMER_FUNCTION(DisassocTimeout); |
| 133 | DECLARE_TIMER_FUNCTION(LinkDownExec); |
| 134 | DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec); |
| 135 | DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc); |
| 136 | DECLARE_TIMER_FUNCTION(PsPollWakeExec); |
| 137 | DECLARE_TIMER_FUNCTION(RadioOnExec); |
| 138 | |
| 139 | #ifdef RTMP_MAC_USB |
| 140 | DECLARE_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout); |
| 141 | #endif // RTMP_MAC_USB // |
| 142 | |
| 143 | #if defined(AP_LED) || defined(STA_LED) |
| 144 | DECLARE_TIMER_FUNCTION(LedCtrlMain); |
| 145 | #endif |
| 146 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 147 | #endif // __RTMP_TIMER_H__ // |