--- /dev/null
+Index: madwifi-trunk-r3776/ath/if_ath.c
+===================================================================
+--- madwifi-trunk-r3776.orig/ath/if_ath.c 2008-07-17 02:20:52.000000000 +0200
++++ madwifi-trunk-r3776/ath/if_ath.c 2008-07-17 02:20:53.000000000 +0200
+@@ -1299,6 +1299,7 @@
+ vap->iv_key_set = ath_key_set;
+ vap->iv_key_update_begin = ath_key_update_begin;
+ vap->iv_key_update_end = ath_key_update_end;
++ vap->iv_maxrateindex = 0;
+ if (sc->sc_default_ieee80211_debug) {
+ /* User specified defaults for new VAPs were provided, so
+ * use those (only). */
+Index: madwifi-trunk-r3776/ath_rate/sample/sample.c
+===================================================================
+--- madwifi-trunk-r3776.orig/ath_rate/sample/sample.c 2008-07-17 02:20:26.000000000 +0200
++++ madwifi-trunk-r3776/ath_rate/sample/sample.c 2008-07-17 02:20:53.000000000 +0200
+@@ -838,7 +838,12 @@
+ }
+ sn->static_rate_ndx = -1;
+
+- sn->num_rates = ni->ni_rates.rs_nrates;
++ if (vap->iv_maxrateindex == 0 || ni->ni_rates.rs_nrates <= 0
++ || vap->iv_maxrateindex > ni->ni_rates.rs_nrates)
++ sn->num_rates = ni->ni_rates.rs_nrates;
++ else
++ sn->num_rates = vap->iv_maxrateindex;
++
+ for (x = 0; x < ni->ni_rates.rs_nrates; x++) {
+ sn->rates[x].rate = ni->ni_rates.rs_rates[x] & IEEE80211_RATE_VAL;
+ sn->rates[x].rix = sc->sc_rixmap[sn->rates[x].rate];
+Index: madwifi-trunk-r3776/net80211/ieee80211_var.h
+===================================================================
+--- madwifi-trunk-r3776.orig/net80211/ieee80211_var.h 2008-07-17 02:20:51.000000000 +0200
++++ madwifi-trunk-r3776/net80211/ieee80211_var.h 2008-07-17 02:20:53.000000000 +0200
+@@ -291,6 +291,7 @@
+ struct ieee80211_spy iv_spy; /* IWSPY support */
+ struct ieee80211_app_ie app_ie[IEEE80211_APPIE_NUM_OF_FRAME]; /* app-specified IEs by frame type */
+ u_int32_t app_filter; /* filters which management frames are forwarded to app */
++ int iv_maxrateindex;
+ };
+
+ /* Debug functions need the defintion of struct ieee80211vap because iv_debug
+Index: madwifi-trunk-r3776/net80211/ieee80211_wireless.c
+===================================================================
+--- madwifi-trunk-r3776.orig/net80211/ieee80211_wireless.c 2008-07-17 02:20:51.000000000 +0200
++++ madwifi-trunk-r3776/net80211/ieee80211_wireless.c 2008-07-17 02:20:53.000000000 +0200
+@@ -2873,6 +2873,12 @@
+ else
+ ic->ic_flags_ext &= ~IEEE80211_FEXT_MARKDFS;
+ break;
++ case IEEE80211_PARAM_MAXRATE:
++ if (value > 0)
++ vap->iv_maxrateindex = value;
++ else
++ vap->iv_maxrateindex = 0;
++ break;
+ #ifdef ATH_REVERSE_ENGINEERING
+ case IEEE80211_PARAM_DUMPREGS:
+ ieee80211_dump_registers(dev, info, w, extra);
+@@ -3211,6 +3217,9 @@
+ else
+ param[0] = 0;
+ break;
++ case IEEE80211_PARAM_MAXRATE:
++ param[0] = vap->iv_maxrateindex;
++ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+@@ -5666,6 +5675,10 @@
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "debug_scanbufs" },
+ { IEEE80211_PARAM_LEAKTXBUFS,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "debug_leaktxbufs" },
++ {IEEE80211_PARAM_MAXRATE,
++ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "maxrate"},
++ {IEEE80211_PARAM_MAXRATE,
++ 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_maxrate"},
+
+ #ifdef ATH_REVERSE_ENGINEERING
+ /*
+Index: madwifi-trunk-r3776/net80211/ieee80211_ioctl.h
+===================================================================
+--- madwifi-trunk-r3776.orig/net80211/ieee80211_ioctl.h 2008-07-17 02:20:51.000000000 +0200
++++ madwifi-trunk-r3776/net80211/ieee80211_ioctl.h 2008-07-17 02:20:53.000000000 +0200
+@@ -650,6 +650,7 @@
+ IEEE80211_PARAM_RESETTXBUFS = 80, /* Reset transmit DMA */
+ IEEE80211_PARAM_SCANBUFS = 81, /* Heap analysis for TX DMA */
+ IEEE80211_PARAM_LEAKTXBUFS = 82, /* Leak tx buffers */
++ IEEE80211_PARAM_MAXRATE = 83, /* Maximum rate (by table index) */
+ };
+
+ #define SIOCG80211STATS (SIOCDEVPRIVATE+2)
+Index: madwifi-trunk-r3776/ath_rate/minstrel/minstrel.c
+===================================================================
+--- madwifi-trunk-r3776.orig/ath_rate/minstrel/minstrel.c 2008-07-17 02:22:27.000000000 +0200
++++ madwifi-trunk-r3776/ath_rate/minstrel/minstrel.c 2008-07-17 02:22:33.000000000 +0200
+@@ -644,6 +644,11 @@
+ return;
+ }
+ sn->static_rate_ndx = -1;
++ if (vap->iv_maxrateindex == 0 || ni->ni_rates.rs_nrates <= 0
++ || vap->iv_maxrateindex > ni->ni_rates.rs_nrates)
++ sn->num_rates = ni->ni_rates.rs_nrates;
++ else
++ sn->num_rates = vap->iv_maxrateindex;
+
+ sn->num_rates = ni->ni_rates.rs_nrates;
+ for (x = 0; x < ni->ni_rates.rs_nrates; x++) {