GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / staging / otus / 80211core / cwm.c
blob1bd0b1ff12dcfc29e99c736bee1af8ab4487ebcd
1 /*
2 * Copyright (c) 2007-2008 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 /* */
17 /* Module Name : cwm.c */
18 /* */
19 /* Abstract */
20 /* This module contains channel width related functions. */
21 /* */
22 /* NOTES */
23 /* None */
24 /* */
25 /************************************************************************/
27 #include "cprecomp.h"
31 void zfCwmInit(zdev_t* dev) {
32 //u16_t i;
33 zmw_get_wlan_dev(dev);
35 switch (wd->wlanMode) {
36 case ZM_MODE_AP:
37 wd->cwm.cw_mode = CWM_MODE2040;
38 wd->cwm.cw_width = CWM_WIDTH40;
39 wd->cwm.cw_enable = 1;
40 break;
41 case ZM_MODE_INFRASTRUCTURE:
42 case ZM_MODE_PSEUDO:
43 case ZM_MODE_IBSS:
44 default:
45 wd->cwm.cw_mode = CWM_MODE2040;
46 wd->cwm.cw_width = CWM_WIDTH20;
47 wd->cwm.cw_enable = 1;
48 break;
53 void zfCoreCwmBusy(zdev_t* dev, u16_t busy)
56 zmw_get_wlan_dev(dev);
58 zm_msg1_mm(ZM_LV_0, "CwmBusy=", busy);
60 if(wd->cwm.cw_mode == CWM_MODE20) {
61 wd->cwm.cw_width = CWM_WIDTH20;
62 return;
65 if(wd->cwm.cw_mode == CWM_MODE40) {
66 wd->cwm.cw_width = CWM_WIDTH40;
67 return;
70 if (busy) {
71 wd->cwm.cw_width = CWM_WIDTH20;
72 return;
76 if((wd->wlanMode == ZM_MODE_INFRASTRUCTURE || wd->wlanMode == ZM_MODE_PSEUDO ||
77 wd->wlanMode == ZM_MODE_IBSS)) {
78 if ((wd->sta.ie.HtCap.HtCapInfo & HTCAP_SupChannelWidthSet) &&
79 (wd->sta.ie.HtInfo.ChannelInfo & ExtHtCap_RecomTxWidthSet) &&
80 (wd->sta.ie.HtInfo.ChannelInfo & ExtHtCap_ExtChannelOffsetAbove)) {
82 wd->cwm.cw_width = CWM_WIDTH40;
84 else {
85 wd->cwm.cw_width = CWM_WIDTH20;
88 return;
91 if(wd->wlanMode == ZM_MODE_AP) {
92 wd->cwm.cw_width = CWM_WIDTH40;
100 u16_t zfCwmIsExtChanBusy(u32_t ctlBusy, u32_t extBusy)
102 u32_t busy; /* percentage */
103 u32_t cycleTime, ctlClear;
105 cycleTime = 1280000; //1.28 seconds
107 if (cycleTime > ctlBusy) {
108 ctlClear = cycleTime - ctlBusy;
110 else
112 ctlClear = 0;
115 /* Compute ratio of extension channel busy to control channel clear
116 * as an approximation to extension channel cleanliness.
118 * According to the hardware folks, ext rxclear is undefined
119 * if the ctrl rxclear is de-asserted (i.e. busy)
121 if (ctlClear) {
122 busy = (extBusy * 100) / ctlClear;
123 } else {
124 busy = 0;
126 if (busy > ATH_CWM_EXTCH_BUSY_THRESHOLD) {
127 return TRUE;
130 return FALSE;