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: |
Justin P. Mattock | 6ccb5d7 | 2010-11-08 13:41:46 -0800 | [diff] [blame] | 31 | Ralink Wireless Driver timer related data structures and declarations |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 32 | |
| 33 | Revision History: |
Justin P. Mattock | 6ccb5d7 | 2010-11-08 13:41:46 -0800 | [diff] [blame] | 34 | Who When What |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 35 | -------- ---------- ---------------------------------------------- |
Justin P. Mattock | 6ccb5d7 | 2010-11-08 13:41:46 -0800 | [diff] [blame] | 36 | Name Date Modification logs |
| 37 | Shiang Tu Aug-28-2008 init version |
| 38 | Justin P. Mattock 11/07/2010 Fix a typo |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 39 | |
| 40 | */ |
| 41 | |
| 42 | #ifndef __RTMP_TIMER_H__ |
| 43 | #define __RTMP_TIMER_H__ |
| 44 | |
| 45 | #include "rtmp_os.h" |
| 46 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 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 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 53 | /* ----------------- Timer Related MARCO ---------------*/ |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 54 | /* In some os or chipset, we have a lot of timer functions and will read/write register, */ |
Justin P. Mattock | 6ccb5d7 | 2010-11-08 13:41:46 -0800 | [diff] [blame] | 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. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 57 | |
| 58 | #ifdef RTMP_TIMER_TASK_SUPPORT |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 59 | typedef void(*RTMP_TIMER_TASK_HANDLE) (void *SystemSpecific1, |
| 60 | void *FunctionContext, |
| 61 | void *SystemSpecific2, |
| 62 | void *SystemSpecific3); |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 63 | #endif /* RTMP_TIMER_TASK_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 64 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 65 | struct rt_ralink_timer { |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 66 | struct timer_list TimerObj; /* Ndis Timer object */ |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 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 */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 71 | unsigned long TimerValue; /* Timer value in milliseconds */ |
| 72 | unsigned long cookie; /* os specific object */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 73 | #ifdef RTMP_TIMER_TASK_SUPPORT |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 74 | RTMP_TIMER_TASK_HANDLE handle; |
| 75 | void *pAd; |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 76 | #endif /* RTMP_TIMER_TASK_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 77 | }; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 78 | |
| 79 | #ifdef RTMP_TIMER_TASK_SUPPORT |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 80 | struct rt_rtmp_timer_task_entry { |
| 81 | struct rt_ralink_timer *pRaTimer; |
| 82 | struct rt_rtmp_timer_task_entry *pNext; |
| 83 | }; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 84 | |
| 85 | #define TIMER_QUEUE_SIZE_MAX 128 |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 86 | struct rt_rtmp_timer_task_queue { |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 87 | unsigned int status; |
| 88 | unsigned char *pTimerQPoll; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 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 | }; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 93 | |
| 94 | #define BUILD_TIMER_FUNCTION(_func) \ |
| 95 | void rtmp_timer_##_func(unsigned long data) \ |
| 96 | { \ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 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; \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 100 | \ |
| 101 | _pTimer->handle = _func; \ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 102 | _pAd = (struct rt_rtmp_adapter *)_pTimer->pAd; \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 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 | { \ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 111 | struct rt_ralink_timer *pTimer = (struct rt_ralink_timer *)data; \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 112 | \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 113 | _func(NULL, (void *)pTimer->cookie, NULL, pTimer); \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 114 | if (pTimer->Repeat) \ |
| 115 | RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue); \ |
| 116 | } |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 117 | #endif /* RTMP_TIMER_TASK_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 118 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 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); |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 126 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 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); |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 142 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 143 | |
| 144 | #if defined(AP_LED) || defined(STA_LED) |
| 145 | DECLARE_TIMER_FUNCTION(LedCtrlMain); |
| 146 | #endif |
| 147 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 148 | #endif /* __RTMP_TIMER_H__ // */ |