blob: 15b62874350033d18fb411c2eac6ffb5fb695c12 [file] [log] [blame]
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +02001/*
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. Mattock6ccb5d72010-11-08 13:41:46 -080031 Ralink Wireless Driver timer related data structures and declarations
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020032
33 Revision History:
Justin P. Mattock6ccb5d72010-11-08 13:41:46 -080034 Who When What
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020035 -------- ---------- ----------------------------------------------
Justin P. Mattock6ccb5d72010-11-08 13:41:46 -080036 Name Date Modification logs
37 Shiang Tu Aug-28-2008 init version
38 Justin P. Mattock 11/07/2010 Fix a typo
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020039
40*/
41
42#ifndef __RTMP_TIMER_H__
43#define __RTMP_TIMER_H__
44
45#include "rtmp_os.h"
46
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020047#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 Zolnierkiewiczca97b832009-09-22 20:44:07 +020053/* ----------------- Timer Related MARCO ---------------*/
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -080054/* In some os or chipset, we have a lot of timer functions and will read/write register, */
Justin P. Mattock6ccb5d72010-11-08 13:41:46 -080055/* 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 Zolnierkiewiczca97b832009-09-22 20:44:07 +020057
58#ifdef RTMP_TIMER_TASK_SUPPORT
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -080059typedef void(*RTMP_TIMER_TASK_HANDLE) (void *SystemSpecific1,
60 void *FunctionContext,
61 void *SystemSpecific2,
62 void *SystemSpecific3);
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -080063#endif /* RTMP_TIMER_TASK_SUPPORT // */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020064
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -080065struct rt_ralink_timer {
Bartlomiej Zolnierkiewicz8a10a542009-12-11 12:23:15 -080066 struct timer_list TimerObj; /* Ndis Timer object */
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -080067 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 Zolnierkiewicz51126de2009-12-11 12:23:15 -080071 unsigned long TimerValue; /* Timer value in milliseconds */
72 unsigned long cookie; /* os specific object */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020073#ifdef RTMP_TIMER_TASK_SUPPORT
Bartlomiej Zolnierkiewicz52b81c82009-12-11 12:23:14 -080074 RTMP_TIMER_TASK_HANDLE handle;
75 void *pAd;
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -080076#endif /* RTMP_TIMER_TASK_SUPPORT // */
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -080077};
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020078
79#ifdef RTMP_TIMER_TASK_SUPPORT
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -080080struct rt_rtmp_timer_task_entry {
81 struct rt_ralink_timer *pRaTimer;
82 struct rt_rtmp_timer_task_entry *pNext;
83};
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020084
85#define TIMER_QUEUE_SIZE_MAX 128
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -080086struct rt_rtmp_timer_task_queue {
Bartlomiej Zolnierkiewicz52b81c82009-12-11 12:23:14 -080087 unsigned int status;
88 unsigned char *pTimerQPoll;
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -080089 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 Zolnierkiewiczca97b832009-09-22 20:44:07 +020093
94#define BUILD_TIMER_FUNCTION(_func) \
95void rtmp_timer_##_func(unsigned long data) \
96{ \
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -080097 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 Zolnierkiewiczca97b832009-09-22 20:44:07 +0200100 \
101 _pTimer->handle = _func; \
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800102 _pAd = (struct rt_rtmp_adapter *)_pTimer->pAd; \
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200103 _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) \
109void rtmp_timer_##_func(unsigned long data) \
110{ \
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800111 struct rt_ralink_timer *pTimer = (struct rt_ralink_timer *)data; \
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200112 \
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800113 _func(NULL, (void *)pTimer->cookie, NULL, pTimer); \
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200114 if (pTimer->Repeat) \
115 RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue); \
116}
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -0800117#endif /* RTMP_TIMER_TASK_SUPPORT // */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200118
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200119DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
120DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
121DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
122DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
123DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
124#ifdef RTMP_MAC_USB
125DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -0800126#endif /* RTMP_MAC_USB // */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200127
128DECLARE_TIMER_FUNCTION(BeaconTimeout);
129DECLARE_TIMER_FUNCTION(ScanTimeout);
130DECLARE_TIMER_FUNCTION(AuthTimeout);
131DECLARE_TIMER_FUNCTION(AssocTimeout);
132DECLARE_TIMER_FUNCTION(ReassocTimeout);
133DECLARE_TIMER_FUNCTION(DisassocTimeout);
134DECLARE_TIMER_FUNCTION(LinkDownExec);
135DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
136DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
137DECLARE_TIMER_FUNCTION(PsPollWakeExec);
138DECLARE_TIMER_FUNCTION(RadioOnExec);
139
140#ifdef RTMP_MAC_USB
141DECLARE_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout);
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -0800142#endif /* RTMP_MAC_USB // */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200143
144#if defined(AP_LED) || defined(STA_LED)
145DECLARE_TIMER_FUNCTION(LedCtrlMain);
146#endif
147
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -0800148#endif /* __RTMP_TIMER_H__ // */