blob: 441571dbaff42fbb70d04f23ba22555f48f08a5a [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:
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 Zolnierkiewiczca97b832009-09-22 20:44:07 +020046#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 Zolnierkiewiczca97b832009-09-22 20:44:07 +020052/* ----------------- Timer Related MARCO ---------------*/
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -080053/* 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. */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020056
57#ifdef RTMP_TIMER_TASK_SUPPORT
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -080058typedef void(*RTMP_TIMER_TASK_HANDLE) (void *SystemSpecific1,
59 void *FunctionContext,
60 void *SystemSpecific2,
61 void *SystemSpecific3);
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -080062#endif /* RTMP_TIMER_TASK_SUPPORT // */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020063
Bartlomiej Zolnierkiewicz52b81c82009-12-11 12:23:14 -080064typedef struct _RALINK_TIMER_STRUCT {
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -080065 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 */
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -080070 unsigned long TimerValue; /* Timer value in milliseconds */
71 unsigned long cookie; /* os specific object */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020072#ifdef RTMP_TIMER_TASK_SUPPORT
Bartlomiej Zolnierkiewicz52b81c82009-12-11 12:23:14 -080073 RTMP_TIMER_TASK_HANDLE handle;
74 void *pAd;
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -080075#endif /* RTMP_TIMER_TASK_SUPPORT // */
Bartlomiej Zolnierkiewicz52b81c82009-12-11 12:23:14 -080076} RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020077
78#ifdef RTMP_TIMER_TASK_SUPPORT
Bartlomiej Zolnierkiewicz52b81c82009-12-11 12:23:14 -080079typedef struct _RTMP_TIMER_TASK_ENTRY_ {
80 RALINK_TIMER_STRUCT *pRaTimer;
81 struct _RTMP_TIMER_TASK_ENTRY_ *pNext;
82} RTMP_TIMER_TASK_ENTRY;
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +020083
84#define TIMER_QUEUE_SIZE_MAX 128
Bartlomiej Zolnierkiewicz52b81c82009-12-11 12:23:14 -080085typedef 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 Zolnierkiewiczca97b832009-09-22 20:44:07 +020092
93#define BUILD_TIMER_FUNCTION(_func) \
94void 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) \
108void rtmp_timer_##_func(unsigned long data) \
109{ \
110 PRALINK_TIMER_STRUCT pTimer = (PRALINK_TIMER_STRUCT) data; \
111 \
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800112 _func(NULL, (void *)pTimer->cookie, NULL, pTimer); \
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200113 if (pTimer->Repeat) \
114 RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue); \
115}
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -0800116#endif /* RTMP_TIMER_TASK_SUPPORT // */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200117
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200118DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
119DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
120DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
121DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
122DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
123#ifdef RTMP_MAC_USB
124DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -0800125#endif /* RTMP_MAC_USB // */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200126
127DECLARE_TIMER_FUNCTION(BeaconTimeout);
128DECLARE_TIMER_FUNCTION(ScanTimeout);
129DECLARE_TIMER_FUNCTION(AuthTimeout);
130DECLARE_TIMER_FUNCTION(AssocTimeout);
131DECLARE_TIMER_FUNCTION(ReassocTimeout);
132DECLARE_TIMER_FUNCTION(DisassocTimeout);
133DECLARE_TIMER_FUNCTION(LinkDownExec);
134DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
135DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
136DECLARE_TIMER_FUNCTION(PsPollWakeExec);
137DECLARE_TIMER_FUNCTION(RadioOnExec);
138
139#ifdef RTMP_MAC_USB
140DECLARE_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout);
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -0800141#endif /* RTMP_MAC_USB // */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200142
143#if defined(AP_LED) || defined(STA_LED)
144DECLARE_TIMER_FUNCTION(LedCtrlMain);
145#endif
146
Bartlomiej Zolnierkiewiczcc277062009-12-11 12:23:15 -0800147#endif /* __RTMP_TIMER_H__ // */