Backported r12989 for 8.09
[openwrt/svn-archive/archive.git] / package / madwifi / patches-testing / 307-maxrate.patch
1 --- a/ath/if_ath.c
2 +++ b/ath/if_ath.c
3 @@ -1299,6 +1299,7 @@
4 vap->iv_key_set = ath_key_set;
5 vap->iv_key_update_begin = ath_key_update_begin;
6 vap->iv_key_update_end = ath_key_update_end;
7 + vap->iv_maxrateindex = 0;
8 if (sc->sc_default_ieee80211_debug) {
9 /* User specified defaults for new VAPs were provided, so
10 * use those (only). */
11 --- a/ath_rate/sample/sample.c
12 +++ b/ath_rate/sample/sample.c
13 @@ -838,7 +838,12 @@
14 }
15 sn->static_rate_ndx = -1;
16
17 - sn->num_rates = ni->ni_rates.rs_nrates;
18 + if (vap->iv_maxrateindex == 0 || ni->ni_rates.rs_nrates <= 0
19 + || vap->iv_maxrateindex > ni->ni_rates.rs_nrates)
20 + sn->num_rates = ni->ni_rates.rs_nrates;
21 + else
22 + sn->num_rates = vap->iv_maxrateindex;
23 +
24 for (x = 0; x < ni->ni_rates.rs_nrates; x++) {
25 sn->rates[x].rate = ni->ni_rates.rs_rates[x] & IEEE80211_RATE_VAL;
26 sn->rates[x].rix = sc->sc_rixmap[sn->rates[x].rate];
27 --- a/net80211/ieee80211_var.h
28 +++ b/net80211/ieee80211_var.h
29 @@ -291,6 +291,7 @@
30 struct ieee80211_spy iv_spy; /* IWSPY support */
31 struct ieee80211_app_ie app_ie[IEEE80211_APPIE_NUM_OF_FRAME]; /* app-specified IEs by frame type */
32 u_int32_t app_filter; /* filters which management frames are forwarded to app */
33 + int iv_maxrateindex;
34 };
35
36 /* Debug functions need the defintion of struct ieee80211vap because iv_debug
37 --- a/net80211/ieee80211_wireless.c
38 +++ b/net80211/ieee80211_wireless.c
39 @@ -2873,6 +2873,12 @@
40 else
41 ic->ic_flags_ext &= ~IEEE80211_FEXT_MARKDFS;
42 break;
43 + case IEEE80211_PARAM_MAXRATE:
44 + if (value > 0)
45 + vap->iv_maxrateindex = value;
46 + else
47 + vap->iv_maxrateindex = 0;
48 + break;
49 #ifdef ATH_REVERSE_ENGINEERING
50 case IEEE80211_PARAM_DUMPREGS:
51 ieee80211_dump_registers(dev, info, w, extra);
52 @@ -3211,6 +3217,9 @@
53 else
54 param[0] = 0;
55 break;
56 + case IEEE80211_PARAM_MAXRATE:
57 + param[0] = vap->iv_maxrateindex;
58 + break;
59 default:
60 return -EOPNOTSUPP;
61 }
62 @@ -5666,6 +5675,10 @@
63 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "debug_scanbufs" },
64 { IEEE80211_PARAM_LEAKTXBUFS,
65 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "debug_leaktxbufs" },
66 + {IEEE80211_PARAM_MAXRATE,
67 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "maxrate"},
68 + {IEEE80211_PARAM_MAXRATE,
69 + 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_maxrate"},
70
71 #ifdef ATH_REVERSE_ENGINEERING
72 /*
73 --- a/net80211/ieee80211_ioctl.h
74 +++ b/net80211/ieee80211_ioctl.h
75 @@ -650,6 +650,7 @@
76 IEEE80211_PARAM_RESETTXBUFS = 80, /* Reset transmit DMA */
77 IEEE80211_PARAM_SCANBUFS = 81, /* Heap analysis for TX DMA */
78 IEEE80211_PARAM_LEAKTXBUFS = 82, /* Leak tx buffers */
79 + IEEE80211_PARAM_MAXRATE = 83, /* Maximum rate (by table index) */
80 };
81
82 #define SIOCG80211STATS (SIOCDEVPRIVATE+2)
83 --- a/ath_rate/minstrel/minstrel.c
84 +++ b/ath_rate/minstrel/minstrel.c
85 @@ -644,6 +644,11 @@
86 return;
87 }
88 sn->static_rate_ndx = -1;
89 + if (vap->iv_maxrateindex == 0 || ni->ni_rates.rs_nrates <= 0
90 + || vap->iv_maxrateindex > ni->ni_rates.rs_nrates)
91 + sn->num_rates = ni->ni_rates.rs_nrates;
92 + else
93 + sn->num_rates = vap->iv_maxrateindex;
94
95 sn->num_rates = ni->ni_rates.rs_nrates;
96 for (x = 0; x < ni->ni_rates.rs_nrates; x++) {