From 2434225ec564a22427005b9a3778dc071254abf3 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 7 May 2009 10:10:06 +0000 Subject: [PATCH] madwifi: improve antenna diversity handling SVN-Revision: 15658 --- .../madwifi/patches/420-diversity_fix.patch | 58 +++++++++++++++++- .../patches/421-channel_handling.patch | 60 +++++++++---------- 2 files changed, 87 insertions(+), 31 deletions(-) diff --git a/package/madwifi/patches/420-diversity_fix.patch b/package/madwifi/patches/420-diversity_fix.patch index b7d26d976d..e12de72ded 100644 --- a/package/madwifi/patches/420-diversity_fix.patch +++ b/package/madwifi/patches/420-diversity_fix.patch @@ -1,6 +1,32 @@ --- a/ath/if_ath.c +++ b/ath/if_ath.c -@@ -5344,27 +5344,6 @@ ath_beacon_send(struct ath_softc *sc, in +@@ -797,7 +797,6 @@ ath_attach(u_int16_t devid, struct net_d + break; + } + +- sc->sc_setdefantenna = ath_setdefantenna; + sc->sc_rc = ieee80211_rate_attach(sc, ratectl); + if (sc->sc_rc == NULL) { + error = EIO; +@@ -2623,9 +2622,6 @@ ath_init(struct net_device *dev) + ath_radar_update(sc); + ath_rp_flush(sc); + +- /* Set the default RX antenna; it may get lost on reset. */ +- ath_setdefantenna(sc, sc->sc_defant); +- + /* + * Setup the hardware after reset: the key cache + * is filled as needed and the receive engine is +@@ -3010,7 +3006,6 @@ ath_reset(struct net_device *dev) + ath_setintmit(sc); + ath_update_txpow(sc); /* update tx power state */ + ath_radar_update(sc); +- ath_setdefantenna(sc, sc->sc_defant); + if (ath_startrecv(sc) != 0) /* restart recv */ + EPRINTF(sc, "Unable to start receive logic.\n"); + if (sc->sc_softled) +@@ -5344,27 +5339,6 @@ ath_beacon_send(struct ath_softc *sc, in } else if ((sc->sc_updateslot == COMMIT) && (sc->sc_slotupdate == slot)) ath_setslottime(sc); /* commit change to hardware */ @@ -28,3 +54,33 @@ if (bfaddr != 0) { /* * Stop any current DMA and put the new frame(s) on the queue. +@@ -6725,9 +6699,8 @@ ath_setdefantenna(struct ath_softc *sc, + { + struct ath_hal *ah = sc->sc_ah; + +- /* XXX block beacon interrupts */ +- ath_hal_setdiversity(ah, (sc->sc_diversity != 0)); + ath_hal_setdefantenna(ah, antenna); ++ ath_hal_setantennaswitch(ah, sc->sc_diversity ? 0 : sc->sc_defant); + if (sc->sc_defant != antenna) + sc->sc_stats.ast_ant_defswitch++; + sc->sc_defant = antenna; +@@ -11138,7 +11111,7 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl + break; + } + sc->sc_diversity = val; +- ath_hal_setdiversity(ah, val); ++ ath_setdefantenna(sc, sc->sc_defant); + break; + case ATH_TXINTRPERIOD: + /* XXX: validate? */ +--- a/ath/if_athvar.h ++++ b/ath/if_athvar.h +@@ -640,7 +640,6 @@ struct ath_softc { + spinlock_t sc_hal_lock; /* hardware access lock */ + struct ath_ratectrl *sc_rc; /* tx rate control support */ + struct ath_tx99 *sc_tx99; /* tx99 support */ +- void (*sc_setdefantenna)(struct ath_softc *, u_int); + const struct ath_hw_detect *sc_hwinfo; + + unsigned int sc_invalid:1; /* being detached */ diff --git a/package/madwifi/patches/421-channel_handling.patch b/package/madwifi/patches/421-channel_handling.patch index a9ad2bd1a6..5418f1b007 100644 --- a/package/madwifi/patches/421-channel_handling.patch +++ b/package/madwifi/patches/421-channel_handling.patch @@ -173,7 +173,7 @@ /* NB: setup here so ath_rate_update is happy */ ath_setcurmode(sc, IEEE80211_MODE_11A); -@@ -909,10 +929,6 @@ ath_attach(u_int16_t devid, struct net_d +@@ -908,10 +928,6 @@ ath_attach(u_int16_t devid, struct net_d IEEE80211_ATHC_COMP : 0); #endif @@ -184,7 +184,7 @@ #ifdef ATH_SUPERG_XR ic->ic_ath_cap |= (ath_hal_xrsupported(ah) ? IEEE80211_ATHC_XR : 0); #endif -@@ -4466,17 +4482,17 @@ ath_mode_init(struct net_device *dev) +@@ -4461,17 +4477,17 @@ ath_mode_init(struct net_device *dev) * Set the slot time based on the current setting. */ static void @@ -210,7 +210,7 @@ sc->sc_updateslot = OK; } -@@ -4498,7 +4514,7 @@ ath_updateslot(struct net_device *dev) +@@ -4493,7 +4509,7 @@ ath_updateslot(struct net_device *dev) if (ic->ic_opmode == IEEE80211_M_HOSTAP) sc->sc_updateslot = UPDATE; else if (dev->flags & IFF_RUNNING) @@ -219,7 +219,7 @@ } #ifdef ATH_SUPERG_DYNTURBO -@@ -5342,7 +5358,7 @@ ath_beacon_send(struct ath_softc *sc, in +@@ -5337,7 +5353,7 @@ ath_beacon_send(struct ath_softc *sc, in sc->sc_updateslot = COMMIT; /* commit next beacon */ sc->sc_slotupdate = slot; } else if ((sc->sc_updateslot == COMMIT) && (sc->sc_slotupdate == slot)) @@ -228,7 +228,7 @@ if (bfaddr != 0) { /* -@@ -7796,12 +7812,14 @@ ath_get_ivlen(struct ieee80211_key *k) +@@ -7790,12 +7806,14 @@ ath_get_ivlen(struct ieee80211_key *k) * Get transmit rate index using rate in Kbps */ static __inline int @@ -245,7 +245,7 @@ ndx = i; break; } -@@ -8094,7 +8112,7 @@ ath_tx_start(struct net_device *dev, str +@@ -8088,7 +8106,7 @@ ath_tx_start(struct net_device *dev, str atype = HAL_PKT_TYPE_NORMAL; /* default */ if (ismcast) { @@ -254,7 +254,7 @@ txrate = rt->info[rix].rateCode; if (shortPreamble) txrate |= rt->info[rix].shortPreamble; -@@ -9061,7 +9079,7 @@ ath_chan_change(struct ath_softc *sc, st +@@ -9055,7 +9073,7 @@ ath_chan_change(struct ath_softc *sc, st struct net_device *dev = sc->sc_dev; enum ieee80211_phymode mode; @@ -263,7 +263,7 @@ ath_rate_setup(dev, mode); ath_setcurmode(sc, mode); -@@ -10110,8 +10128,7 @@ ath_newassoc(struct ieee80211_node *ni, +@@ -10104,8 +10122,7 @@ ath_newassoc(struct ieee80211_node *ni, } static int @@ -273,7 +273,7 @@ { struct ath_softc *sc = dev->priv; struct ieee80211com *ic = &sc->sc_ic; -@@ -10125,17 +10142,31 @@ ath_getchannels(struct net_device *dev, +@@ -10119,17 +10136,31 @@ ath_getchannels(struct net_device *dev, EPRINTF(sc, "Insufficient memory for channel table!\n"); return -ENOMEM; } @@ -307,7 +307,7 @@ /* * Convert HAL channels to ieee80211 ones. */ -@@ -10379,7 +10410,7 @@ ath_xr_rate_setup(struct net_device *dev +@@ -10373,7 +10404,7 @@ ath_xr_rate_setup(struct net_device *dev struct ieee80211com *ic = &sc->sc_ic; const HAL_RATE_TABLE *rt; struct ieee80211_rateset *rs; @@ -316,7 +316,7 @@ sc->sc_xr_rates = ath_hal_getratetable(ah, HAL_MODE_XR); rt = sc->sc_xr_rates; if (rt == NULL) -@@ -10392,57 +10423,16 @@ ath_xr_rate_setup(struct net_device *dev +@@ -10386,57 +10417,16 @@ ath_xr_rate_setup(struct net_device *dev } else maxrates = rt->rateCount; rs = &ic->ic_sup_xr_rates; @@ -380,7 +380,7 @@ static int ath_rate_setup(struct net_device *dev, u_int mode) { -@@ -10451,7 +10441,7 @@ ath_rate_setup(struct net_device *dev, u +@@ -10445,7 +10435,7 @@ ath_rate_setup(struct net_device *dev, u struct ieee80211com *ic = &sc->sc_ic; const HAL_RATE_TABLE *rt; struct ieee80211_rateset *rs; @@ -389,7 +389,7 @@ switch (mode) { case IEEE80211_MODE_11A: -@@ -10469,6 +10459,12 @@ ath_rate_setup(struct net_device *dev, u +@@ -10463,6 +10453,12 @@ ath_rate_setup(struct net_device *dev, u case IEEE80211_MODE_TURBO_G: sc->sc_rates[mode] = ath_hal_getratetable(ah, HAL_MODE_108G); break; @@ -402,7 +402,7 @@ default: DPRINTF(sc, ATH_DEBUG_ANY, "Invalid mode %u\n", mode); return 0; -@@ -10483,10 +10479,16 @@ ath_rate_setup(struct net_device *dev, u +@@ -10477,10 +10473,16 @@ ath_rate_setup(struct net_device *dev, u maxrates = IEEE80211_RATE_MAXSIZE; } else maxrates = rt->rateCount; @@ -419,7 +419,7 @@ return 1; } -@@ -10515,13 +10517,18 @@ ath_setcurmode(struct ath_softc *sc, enu +@@ -10509,13 +10511,18 @@ ath_setcurmode(struct ath_softc *sc, enu { 0, 500, 130 }, }; const HAL_RATE_TABLE *rt; @@ -440,7 +440,7 @@ memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap)); for (i = 0; i < 32; i++) { u_int8_t ix = rt->rateCodeToIndex[i]; -@@ -10531,7 +10538,7 @@ ath_setcurmode(struct ath_softc *sc, enu +@@ -10525,7 +10532,7 @@ ath_setcurmode(struct ath_softc *sc, enu continue; } sc->sc_hwmap[i].ieeerate = @@ -449,7 +449,7 @@ if (rt->info[ix].shortPreamble || rt->info[ix].phy == IEEE80211_T_OFDM) sc->sc_hwmap[i].flags |= IEEE80211_RADIOTAP_F_SHORTPRE; -@@ -10932,9 +10939,106 @@ enum { +@@ -10926,9 +10933,106 @@ enum { ATH_MAXVAPS = 26, ATH_INTMIT = 27, ATH_NOISE_IMMUNITY = 28, @@ -557,7 +557,7 @@ static int ath_sysctl_set_intmit(struct ath_softc *sc, long ctl, u_int val) { -@@ -11013,6 +11117,7 @@ static int +@@ -11007,6 +11111,7 @@ static int ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl, write, filp, buffer, lenp, ppos) { struct ath_softc *sc = ctl->extra1; @@ -565,7 +565,7 @@ struct ath_hal *ah = sc->sc_ah; u_int val; u_int tab_3_val[3]; -@@ -11036,25 +11141,33 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl +@@ -11030,25 +11135,33 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl lenp, ppos); if (ret == 0) { switch ((long)ctl->extra2) { @@ -612,7 +612,7 @@ break; case ATH_SOFTLED: if (val != sc->sc_softled) { -@@ -11207,6 +11320,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl +@@ -11201,6 +11314,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl } } else { switch ((long)ctl->extra2) { @@ -622,7 +622,7 @@ case ATH_SLOTTIME: val = ath_hal_getslottime(ah); break; -@@ -11225,6 +11341,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl +@@ -11219,6 +11335,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl case ATH_COUNTRYCODE: ath_hal_getcountrycode(ah, &val); break; @@ -632,7 +632,7 @@ case ATH_MAXVAPS: val = ath_maxvaps; break; -@@ -11338,11 +11457,17 @@ static const ctl_table ath_sysctl_templa +@@ -11332,11 +11451,17 @@ static const ctl_table ath_sysctl_templa }, { .ctl_name = CTL_AUTO, .procname = "countrycode", @@ -651,7 +651,7 @@ .procname = "maxvaps", .mode = 0444, .proc_handler = ath_sysctl_halparam, -@@ -11350,7 +11475,7 @@ static const ctl_table ath_sysctl_templa +@@ -11344,7 +11469,7 @@ static const ctl_table ath_sysctl_templa }, { .ctl_name = CTL_AUTO, .procname = "regdomain", @@ -660,7 +660,7 @@ .proc_handler = ath_sysctl_halparam, .extra2 = (void *)ATH_REGDOMAIN, }, -@@ -11413,6 +11538,12 @@ static const ctl_table ath_sysctl_templa +@@ -11407,6 +11532,12 @@ static const ctl_table ath_sysctl_templa .extra2 = (void *)ATH_ACKRATE, }, { .ctl_name = CTL_AUTO, @@ -673,7 +673,7 @@ .procname = "rp", .mode = 0200, .proc_handler = ath_sysctl_halparam, -@@ -11653,13 +11784,6 @@ static ctl_table ath_static_sysctls[] = +@@ -11647,13 +11778,6 @@ static ctl_table ath_static_sysctls[] = }, #endif { .ctl_name = CTL_AUTO, @@ -687,7 +687,7 @@ .procname = "maxvaps", .mode = 0444, .data = &ath_maxvaps, -@@ -11667,13 +11791,6 @@ static ctl_table ath_static_sysctls[] = +@@ -11661,13 +11785,6 @@ static ctl_table ath_static_sysctls[] = .proc_handler = proc_dointvec }, { .ctl_name = CTL_AUTO, @@ -703,7 +703,7 @@ .data = &ath_xchanmode, --- a/ath/if_athvar.h +++ b/ath/if_athvar.h -@@ -689,16 +689,17 @@ struct ath_softc { +@@ -688,16 +688,17 @@ struct ath_softc { int8_t sc_ofdm_weak_det; /* OFDM weak frames detection, -1 == auto */ /* rate tables */ @@ -724,7 +724,7 @@ u_int8_t sc_curbssid[IEEE80211_ADDR_LEN]; u_int8_t sc_rixmap[256]; /* IEEE to h/w rate table ix */ struct { -@@ -809,6 +810,8 @@ struct ath_softc { +@@ -808,6 +809,8 @@ struct ath_softc { u_int32_t sc_dturbo_bw_turbo; /* bandwidth threshold */ #endif u_int sc_slottimeconf; /* manual override for slottime */ @@ -733,7 +733,7 @@ struct timer_list sc_dfs_excl_timer; /* mark expiration timer task */ struct timer_list sc_dfs_cac_timer; /* dfs wait timer */ -@@ -827,6 +830,7 @@ struct ath_softc { +@@ -826,6 +829,7 @@ struct ath_softc { int sc_rp_num; int sc_rp_min; HAL_BOOL (*sc_rp_analyse)(struct ath_softc *sc); @@ -741,7 +741,7 @@ struct ATH_TQ_STRUCT sc_rp_tq; int sc_rp_ignored; /* if set, we ignored all -@@ -942,6 +946,48 @@ int ar_device(int devid); +@@ -941,6 +945,48 @@ int ar_device(int devid); DEV_NAME(_v->iv_ic->ic_dev)) void ath_radar_detected(struct ath_softc *sc, const char* message); -- 2.30.2