Show
Ignore:
Timestamp:
09/17/07 18:34:10 (5 years ago)
Author:
mentor
Message:

The aforementioned patch. It currently does no work, and I can no longer remember where I was going with it. I think I needed to add some logic for fiddling TX power on channel change at least.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/madwifi-ng-txpower/ath/if_ath.c

    r2632 r2711  
    115115#endif 
    116116 
     117#ifndef MIN 
     118#define MIN(a,b)        ((a) < (b) ? (a) : (b)) 
     119#endif 
     120#ifndef MAX 
     121#define MAX(a,b)        ((a) > (b) ? (a) : (b)) 
     122#endif 
     123 
    117124enum { 
    118125        ATH_LED_TX, 
     
    210217static void ath_scan_end(struct ieee80211com *); 
    211218static void ath_set_channel(struct ieee80211com *); 
     219static void ath_set_txpow(struct ieee80211com *, int); 
    212220static void ath_set_coverageclass(struct ieee80211com *); 
    213221static u_int ath_mhz2ieee(struct ieee80211com *, u_int, u_int); 
     
    908916        ic->ic_registers_mark       = ath_registers_mark; 
    909917#endif /* #ifdef ATH_REVERSE_ENGINEERING */ 
     918 
     919        ic->ic_set_txpow = ath_set_txpow; 
    910920 
    911921        ic->ic_set_coverageclass = ath_set_coverageclass; 
     
    22182228         */ 
    22192229        ATH_TXQ_LOCK_IRQ(txq); 
    2220         if (ni && ni->ni_vap && txq == &ATH_VAP(ni->ni_vap)->av_mcastq) { 
     2230        if (ni && ni->ni_vap && (txq == &ATH_VAP(ni->ni_vap)->av_mcastq)) { 
    22212231                /* 
    22222232                 * The CAB queue is started from the SWBA handler since 
     
    23362346        /* XXX check return value? */ 
    23372347        ath_hal_setuptxdesc(ah, ds, 
    2338                             pktlen,                     /* packet length */ 
    2339                             hdrlen,                     /* header length */ 
    2340                             atype,                      /* Atheros packet type */ 
    2341                             power,                      /* txpower */ 
    2342                             txrate, try0,               /* series 0 rate/tries */ 
    2343                             HAL_TXKEYIX_INVALID,        /* key cache index */ 
    2344                             antenna,                    /* antenna mode */ 
    2345                             flags,                      /* flags */ 
    2346                             0,                          /* rts/cts rate */ 
    2347                             0,                          /* rts/cts duration */ 
    2348                             0,                          /* comp icv len */ 
    2349                             0,                          /* comp iv len */ 
    2350                             ATH_COMP_PROC_NO_COMP_NO_CCS /* comp scheme */ 
     2348                            pktlen,                            /* packet length */ 
     2349                            hdrlen,                            /* header length */ 
     2350                            atype,                             /* Atheros packet type */ 
     2351                            power,                             /* txpower */ 
     2352                            txrate, try0,                      /* series 0 rate/tries */ 
     2353                            HAL_TXKEYIX_INVALID,               /* key cache index */ 
     2354                            antenna,                           /* antenna mode */ 
     2355                            flags,                             /* flags */ 
     2356                            0,                                 /* rts/cts rate */ 
     2357                            0,                                 /* rts/cts duration */ 
     2358                            0,                                 /* comp icv len */ 
     2359                            0,                                 /* comp iv len */ 
     2360                            ATH_COMP_PROC_NO_COMP_NO_CCS       /* comp scheme */ 
    23512361                           ); 
    23522362 
     
    39843994                sizeof(struct ieee80211_frame), /* header length */ 
    39853995                HAL_PKT_TYPE_BEACON,            /* Atheros packet type */ 
    3986                 ni->ni_txpower,               /* txpower XXX */ 
     3996                ni->ni_vap->iv_txpower,               /* txpower XXX */ 
    39873997                rate, 1,                        /* series 0 rate/tries */ 
    39883998                HAL_TXKEYIX_INVALID,            /* no encryption */ 
     
    66096619ath_tx_start(struct net_device *dev, struct ieee80211_node *ni, struct ath_buf *bf, struct sk_buff *skb, int nextfraglen) 
    66106620{ 
    6611 #define MIN(a,b)        ((a) < (b) ? (a) : (b)) 
    66126621        struct ath_softc *sc = dev->priv; 
    66136622        struct ieee80211com *ic = ni->ni_ic; 
     
    70767085        /* XXX check return value? */ 
    70777086        ath_hal_setuptxdesc(ah, ds, 
    7078                             pktlen,                    /* packet length */ 
    7079                             hdrlen,                    /* header length */ 
    7080                             atype,                     /* Atheros packet type */ 
    7081                             MIN(ni->ni_txpower, 60), /* txpower */ 
    7082                             txrate, try0,              /* series 0 rate/tries */ 
    7083                             keyix,                     /* key cache index */ 
    7084                             antenna,                   /* antenna mode */ 
    7085                             flags,                     /* flags */ 
    7086                             ctsrate,                   /* rts/cts rate */ 
    7087                             ctsduration,               /* rts/cts duration */ 
    7088                             icvlen,                    /* comp icv len */ 
    7089                             ivlen,                     /* comp iv len */ 
    7090                             comp                       /* comp scheme */ 
     7087                            pktlen,             /* packet length */ 
     7088                            hdrlen,             /* header length */ 
     7089                            atype,              /* Atheros packet type */ 
     7090                            vap->iv_txpower,  /* txpower */ 
     7091                            txrate, try0,       /* series 0 rate/tries */ 
     7092                            keyix,              /* key cache index */ 
     7093                            antenna,            /* antenna mode */ 
     7094                            flags,              /* flags */ 
     7095                            ctsrate,            /* rts/cts rate */ 
     7096                            ctsduration,        /* rts/cts duration */ 
     7097                            icvlen,             /* comp icv len */ 
     7098                            ivlen,              /* comp iv len */ 
     7099                            comp                /* comp scheme */ 
    70917100                ); 
    70927101        bf->bf_flags = flags;   /* record for post-processing */ 
     
    71967205        ath_tx_txqaddbuf(sc, ni, txq, bf, ds, pktlen); 
    71977206        return 0; 
    7198 #undef MIN 
    71997207} 
    72007208 
     
    77407748                htole16(chan->ic_flags); 
    77417749#endif 
    7742         if (ic->ic_curchanmaxpwr == 0) 
    7743                 ic->ic_curchanmaxpwr = chan->ic_maxregpower; 
    77447750} 
    77457751 
     
    86178623                ichan->ic_flags = c->channelFlags; 
    86188624                ichan->ic_maxregpower = c->maxRegTxPower;       /* dBm */ 
    8619                 ichan->ic_maxpower = c->maxTxPower;                /* 1/4 dBm */ 
    8620                 ichan->ic_minpower = c->minTxPower;                /* 1/4 dBm */ 
     8625                ichan->ic_maxpower = c->maxTxPower / 2;                /* dBm */ 
     8626                ichan->ic_minpower = c->minTxPower / 2;                /* dBm */ 
    86218627        } 
    86228628        ic->ic_nchans = nchan; 
     
    86868692} 
    86878693 
    8688 static void 
    8689 set_node_txpower(void *arg, struct ieee80211_node *ni) 
    8690 { 
    8691         int *value = (int *)arg; 
    8692         ni->ni_txpower = *value; 
    8693 } 
    8694  
    86958694/* XXX: this function needs some locking to avoid being called twice/interrupted */ 
    86968695static void 
    86978696ath_update_txpow(struct ath_softc *sc) 
    86988697{ 
    8699         struct ieee80211com *ic = &sc->sc_ic; 
     8698        struct ieee80211com *ic = &sc->sc_ic; 
     8699        struct ath_hal *ah = sc->sc_ah; 
     8700        u_int32_t txpow; 
     8701   
     8702        if (!sc->sc_hastpc) { 
     8703                ath_hal_settxpowlimit(ah, ic->ic_txpowlimit); 
     8704                 
     8705                (void)ath_hal_gettxpowlimit(ah, &txpow); 
     8706                ic->ic_txpowlimit = txpow; 
     8707        } 
     8708
     8709    
     8710static void 
     8711ath_set_txpow(struct ieee80211com *ic, int txpow) 
     8712
     8713        struct net_device *dev = ic->ic_dev; 
     8714        struct ath_softc *sc = dev->priv; 
    87008715        struct ieee80211vap *vap = NULL; 
    8701         struct ath_hal *ah = sc->sc_ah; 
    8702         u_int32_t txpowlimit = 0; 
    8703         u_int32_t maxtxpowlimit = 9999; 
    8704         u_int32_t clamped_txpow = 0; 
    8705  
    8706         /* 
    8707          * Find the maxtxpow of the card and regulatory constraints 
    8708          */ 
    8709         (void)ath_hal_getmaxtxpow(ah, &txpowlimit); 
    8710         ath_hal_settxpowlimit(ah, maxtxpowlimit); 
    8711         (void)ath_hal_getmaxtxpow(ah, &maxtxpowlimit); 
    8712         ic->ic_txpowlimit = maxtxpowlimit; 
    8713         ath_hal_settxpowlimit(ah, txpowlimit); 
    8714  
    8715         /* 
    8716          * Make sure the VAPs change is within limits, clamp it otherwise 
    8717          */ 
    8718         if (ic->ic_newtxpowlimit > ic->ic_txpowlimit) 
    8719                 clamped_txpow = ic->ic_txpowlimit; 
    8720         else 
    8721                 clamped_txpow = ic->ic_newtxpowlimit; 
    8722  
    8723         /* 
    8724          * Search for the VAP that needs a txpow change, if any 
    8725          */ 
    8726         TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { 
    8727                 if (!tpc || ic->ic_newtxpowlimit != vap->iv_bss->ni_txpower) { 
    8728                         vap->iv_bss->ni_txpower = clamped_txpow; 
    8729                         ieee80211_iterate_nodes(&vap->iv_ic->ic_sta, set_node_txpower, &clamped_txpow); 
    8730                 } 
    8731         } 
    8732  
    8733         sc->sc_curtxpow = clamped_txpow; 
    8734         if (clamped_txpow != txpowlimit) 
    8735                 ath_hal_settxpowlimit(ah, clamped_txpow); 
    8736 
    8737  
     8716        u_int32_t mintxpow; 
     8717   
     8718        if (!sc->sc_hastpc) { 
     8719                /* Find the minimum TX power of all VAPs and set that; 
     8720                 * i.e., we guarantee that the set TX power is the  
     8721                 * _maximum_ TX power. */ 
     8722                mintxpow = txpow; 
     8723                TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { 
     8724                        mintxpow = MIN(mintxpow, vap->iv_txpower); 
     8725                } 
     8726                ic->ic_txpowlimit = mintxpow; 
     8727        } 
     8728
    87388729 
    87398730#ifdef ATH_SUPERG_XR 
     
    89728963 
    89738964#define US_PER_4MS 4000 
    8974 #define MIN(a,b)        ((a) < (b) ? (a) : (b)) 
    89758965 
    89768966        *flushq = AH_FALSE; 
     
    90129002 
    90139003#undef US_PER_4MS 
    9014 #undef MIN 
    90159004} 
    90169005#endif