use ah_set11nRateScenario directly
[open-ath9k-htc-firmware.git] / target_firmware / wlan / if_owl.c
index 1df92a27de14c46ba3274a984d24a3b51344dc38..657c89b296eecda28deaa718862ee1ecd08c0c82 100755 (executable)
@@ -47,7 +47,6 @@
 #include <adf_net.h>
 #include <adf_net_wcmd.h>
 
-#include "if_ethersubr.h"
 #include "if_llc.h"
 
 #ifdef USE_HEADERLEN_RESV
@@ -58,7 +57,6 @@
 #include "if_athrate.h"
 #include "if_athvar.h"
 #include "ah_desc.h"
-#include "if_ath_pci.h"
 
 #define ath_tgt_free_skb  adf_nbuf_free
 
@@ -133,7 +131,7 @@ static void
 ath_tx_update_baw(ath_atx_tid_t *tid, int seqno);
 static  void
 ath_tx_retry_subframe(struct ath_softc_tgt *sc, struct ath_tx_buf *bf,
-                     ath_bufhead *bf_q, struct ath_tx_buf **bar);
+                     ath_tx_bufhead *bf_q, struct ath_tx_buf **bar);
 
 static void
 ath_tx_comp_aggr_error(struct ath_softc_tgt *sc, struct ath_tx_buf *bf, ath_atx_tid_t *tid);
@@ -264,7 +262,8 @@ static void ath_filltxdesc(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
 
 static void ath_tx_tgt_setds(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
 {
-       struct ath_desc *ds = bf->bf_desc;
+       struct ath_tx_desc *ds = bf->bf_desc;
+       struct ath_hal *ah = sc->sc_ah;
 
        switch (bf->bf_protmode) {
        case IEEE80211_PROT_RTSCTS:
@@ -277,7 +276,7 @@ static void ath_tx_tgt_setds(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
                break;
        }
 
-       ath_hal_set11n_txdesc(sc->sc_ah, ds
+       ah->ah_set11nTxDesc(ah, ds
                              , bf->bf_pktlen
                              , bf->bf_atype
                              , 60
@@ -368,7 +367,7 @@ static void ath_buf_set_rate(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
 {
     struct ath_hal *ah = sc->sc_ah;
     const HAL_RATE_TABLE *rt;
-    struct ath_desc *ds = bf->bf_desc;
+    struct ath_tx_desc *ds = bf->bf_desc;
     HAL_11N_RATE_SERIES series[4];
     a_int32_t i, flags;
     a_uint8_t rix, cix, rtsctsrate;
@@ -444,7 +443,7 @@ static void ath_buf_set_rate(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
     rtsctsrate = rt->info[cix].rateCode |
            (bf->bf_shpream ? rt->info[cix].shortPreamble : 0);
 
-    ath_hal_set11n_ratescenario(ah, ds, 1,
+    ah->ah_set11nRateScenario(ah, ds, 1,
                                rtsctsrate, ctsduration,
                                series, 4,
                                flags);
@@ -618,9 +617,10 @@ void ath_tx_status_send(struct ath_softc_tgt *sc)
 
 static void owltgt_tx_process_cabq(struct ath_softc_tgt *sc, struct ath_txq *txq)
 {
-       ath_hal_intrset(sc->sc_ah, sc->sc_imask & ~HAL_INT_SWBA);
+       struct ath_hal *ah = sc->sc_ah;
+       ah->ah_setInterrupts(ah, sc->sc_imask & ~HAL_INT_SWBA);
        owltgt_tx_processq(sc, txq, OWL_TXQ_ACTIVE);
-       ath_hal_intrset(sc->sc_ah, sc->sc_imask);
+       ah->ah_setInterrupts(ah, sc->sc_imask);
 }
 
 void owl_tgt_tx_tasklet(TQUEUE_ARG data)
@@ -890,17 +890,17 @@ static void ath_tgt_txq_add_ucast(struct ath_softc_tgt *sc, struct ath_tx_buf *b
        ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
 
        if (txq->axq_link == NULL) {
-               ath_hal_puttxbuf(ah, txq->axq_qnum, ATH_BUF_GET_DESC_PHY_ADDR(bf));
+               ah->ah_setTxDP(ah, txq->axq_qnum, ATH_BUF_GET_DESC_PHY_ADDR(bf));
        } else {
                *txq->axq_link = ATH_BUF_GET_DESC_PHY_ADDR(bf);
 
                txe_val = OS_REG_READ(ah, 0x840);
                if (!(txe_val & (1<< txq->axq_qnum)))
-                       ath_hal_puttxbuf(ah, txq->axq_qnum, ATH_BUF_GET_DESC_PHY_ADDR(bf));
+                       ah->ah_setTxDP(ah, txq->axq_qnum, ATH_BUF_GET_DESC_PHY_ADDR(bf));
        }
 
        txq->axq_link = &bf->bf_lastds->ds_link;
-       ath_hal_txstart(ah, txq->axq_qnum);
+       ah->ah_startTxDma(ah, txq->axq_qnum);
 }
 
 static a_int32_t ath_tgt_txbuf_setup(struct ath_softc_tgt *sc,
@@ -908,12 +908,8 @@ static a_int32_t ath_tgt_txbuf_setup(struct ath_softc_tgt *sc,
                                     ath_data_hdr_t *dh)
 
 {
-       struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
        struct ieee80211_frame *wh = ATH_SKB2_WH(bf->bf_skb);
-       struct ieee80211_node_target *ni = (struct ieee80211_node_target *)an;
-       struct ieee80211vap_target *vap = ni->ni_vap;
-       struct ieee80211com_target *ic = &sc->sc_ic;
-       a_int32_t retval, fragno = 0;
+       a_int32_t retval;
        a_uint32_t flags = adf_os_ntohl(dh->flags);
 
        ath_tgt_tx_seqno_normal(bf);
@@ -955,7 +951,7 @@ ath_get_pktlen(struct ath_tx_buf *bf, a_int32_t hdrlen)
 void
 ath_tgt_tx_send_normal(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
 {
-       struct ath_node_target *an = bf->bf_node;
+       struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
        struct ath_rc_series rcs[4];
        struct ath_rc_series mrcs[4];
        a_int32_t shortPreamble = 0;
@@ -986,7 +982,7 @@ static void
 ath_tx_freebuf(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
 {
        a_int32_t i ;
-       struct ath_desc *bfd = NULL;
+       struct ath_tx_desc *bfd = NULL;
 
        for (bfd = bf->bf_desc, i = 0; i < bf->bf_dmamap_info.nsegs; bfd++, i++) {
                ath_hal_clr11n_aggr(sc->sc_ah, bfd);
@@ -1055,7 +1051,7 @@ ath_tgt_send_mgt(struct ath_softc_tgt *sc,adf_nbuf_t hdr_buf, adf_nbuf_t skb,
        a_uint8_t rix, txrate, ctsrate, cix = 0xff, *data;
        a_uint32_t ivlen = 0, icvlen = 0, subtype, flags, ctsduration;
        a_int32_t i, iswep, ismcast, hdrlen, pktlen, try0, len;
-       struct ath_desc *ds=NULL;
+       struct ath_tx_desc *ds=NULL;
        struct ath_txq *txq=NULL;
        struct ath_tx_buf *bf;
        HAL_PKT_TYPE atype;
@@ -1235,7 +1231,7 @@ ath_tgt_send_mgt(struct ath_softc_tgt *sc,adf_nbuf_t hdr_buf, adf_nbuf_t skb,
                series[i].ChSel = sc->sc_ic.ic_tx_chainmask;
                series[i].RateFlags = 0;
        }
-       ath_hal_set11n_ratescenario(ah, ds, 0, ctsrate, ctsduration, series, 4, 0);
+       ah->ah_set11nRateScenario(ah, ds, 0, ctsrate, ctsduration, series, 4, 0);
        ath_tgt_txqaddbuf(sc, txq, bf, bf->bf_lastds);
 
        return;
@@ -1254,13 +1250,13 @@ ath_tgt_txqaddbuf(struct ath_softc_tgt *sc,
        ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
 
        if (txq->axq_link == NULL) {
-               ath_hal_puttxbuf(ah, txq->axq_qnum, ATH_BUF_GET_DESC_PHY_ADDR(bf));
+               ah->ah_setTxDP(ah, txq->axq_qnum, ATH_BUF_GET_DESC_PHY_ADDR(bf));
        } else {
                *txq->axq_link = ATH_BUF_GET_DESC_PHY_ADDR(bf);
        }
 
        txq->axq_link = &lastds->ds_link;
-       ath_hal_txstart(ah, txq->axq_qnum);
+       ah->ah_startTxDma(ah, txq->axq_qnum);
 }
 
 void ath_tgt_handle_normal(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
@@ -1361,7 +1357,7 @@ ath_tgt_handle_aggr(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
 static void
 ath_tgt_tx_sched_normal(struct ath_softc_tgt *sc, ath_atx_tid_t *tid)
 {
-       struct ath_buf *bf;
+       struct ath_tx_buf *bf;
        struct ath_txq *txq =TID_TO_ACTXQ(tid->tidno);;
 
        do {
@@ -1380,9 +1376,9 @@ ath_tgt_tx_sched_aggr(struct ath_softc_tgt *sc, ath_atx_tid_t *tid)
 {
        struct ath_tx_buf  *bf, *bf_last;
        ATH_AGGR_STATUS status;
-       ath_bufhead bf_q;
+       ath_tx_bufhead bf_q;
        struct ath_txq *txq = TID_TO_ACTXQ(tid->tidno);
-       struct ath_desc *ds = NULL;
+       struct ath_tx_desc *ds = NULL;
        int i;
 
 
@@ -1401,7 +1397,7 @@ ath_tgt_tx_sched_aggr(struct ath_softc_tgt *sc, ath_atx_tid_t *tid)
                        break;
 
                bf = asf_tailq_first(&bf_q);
-               bf_last = asf_tailq_last(&bf_q, ath_bufhead_s);
+               bf_last = asf_tailq_last(&bf_q, ath_tx_bufhead_s);
 
                if (bf->bf_nframes == 1) {
 
@@ -1494,11 +1490,11 @@ static u_int32_t ath_lookup_rate(struct ath_softc_tgt *sc,
 }
 
 int ath_tgt_tx_form_aggr(struct ath_softc_tgt *sc, ath_atx_tid_t *tid,
-                        ath_bufhead *bf_q)
+                        ath_tx_bufhead *bf_q)
 {
        struct ath_tx_buf *bf_first ,*bf_prev = NULL;
        int nframes = 0, rl = 0;;
-       struct ath_desc *ds = NULL;
+       struct ath_tx_desc *ds = NULL;
        struct ath_tx_buf *bf;
        u_int16_t aggr_limit =  (64*1024 -1), al = 0, bpad = 0, al_delta;
        u_int16_t h_baw = tid->baw_size/2, prev_al = 0, prev_frames = 0;
@@ -1617,10 +1613,10 @@ void ath_tgt_tx_comp_aggr(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
        int ba_index;
        int nbad = 0;
        int nframes = bf->bf_nframes;
-       struct ath_buf *bf_next;
-       ath_bufhead bf_q;
+       struct ath_tx_buf *bf_next;
+       ath_tx_bufhead bf_q;
        int tx_ok = 1;
-       struct ath_buf *bar = NULL;
+       struct ath_tx_buf *bar = NULL;
        struct ath_txq *txq;
 
        txq = bf->bf_txq;
@@ -1700,12 +1696,12 @@ ath_tx_comp_aggr_error(struct ath_softc_tgt *sc, struct ath_tx_buf *bf,
 
 
        struct ath_tx_desc lastds;
-       struct ath_desc *ds = &lastds;
+       struct ath_tx_desc *ds = &lastds;
        struct ath_rc_series rcs[4];
-       struct ath_buf *bar = NULL;
-       struct ath_buf *bf_next;
+       struct ath_tx_buf *bar = NULL;
+       struct ath_tx_buf *bf_next;
        int nframes = bf->bf_nframes;
-       ath_bufhead bf_q;
+       ath_tx_bufhead bf_q;
        struct ath_txq *txq;
 
        asf_tailq_init(&bf_q);
@@ -1748,7 +1744,7 @@ ath_tx_comp_cleanup(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
        int ba_index;
        int nbad = 0;
        int nframes = bf->bf_nframes;
-       struct ath_buf *bf_next;
+       struct ath_tx_buf *bf_next;
        int tx_ok = 1;
 
        adf_os_mem_copy(ds, bf->bf_lastds, sizeof (struct ath_tx_desc));
@@ -1799,12 +1795,12 @@ ath_tx_comp_cleanup(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
 
 static void
 ath_tx_retry_subframe(struct ath_softc_tgt *sc, struct ath_tx_buf *bf,
-                     ath_bufhead *bf_q, struct ath_tx_buf **bar)
+                     ath_tx_bufhead *bf_q, struct ath_tx_buf **bar)
 {
 
        struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
        ath_atx_tid_t *tid = ATH_AN_2_TID(an, bf->bf_tidno);
-       struct ath_desc *ds = NULL;
+       struct ath_tx_desc *ds = NULL;
        int i = 0;
 
        __stats(sc, txaggr_compretries);
@@ -1883,7 +1879,7 @@ ath_tx_comp_unaggr(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
 {
        struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
        ath_atx_tid_t *tid = ATH_AN_2_TID(an, bf->bf_tidno);
-       struct ath_desc *ds  = bf->bf_lastds;
+       struct ath_tx_desc *ds  = bf->bf_lastds;
 
        ath_update_stats(sc, bf);
        ath_rate_tx_complete(sc, an, ds, bf->bf_rcs, 1, 0);
@@ -2058,7 +2054,7 @@ static void ath_bar_retry(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
 
 static void ath_bar_tx_comp(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
 {
-       struct ath_desc *ds = bf->bf_lastds;
+       struct ath_tx_desc *ds = bf->bf_lastds;
        struct ath_node_target *an;
        ath_atx_tid_t *tid;
        struct ath_txq *txq;
@@ -2084,7 +2080,8 @@ static void ath_bar_tx(struct ath_softc_tgt *sc,
        adf_nbuf_t skb;
        struct ieee80211_frame_bar *bar;
        u_int8_t min_rate;
-       struct ath_desc *ds, *ds0;
+       struct ath_tx_desc *ds, *ds0;
+       struct ath_hal *ah = sc->sc_ah;
        HAL_11N_RATE_SERIES series[4];
        int i = 0;
        adf_nbuf_queue_t skbhead;
@@ -2093,7 +2090,7 @@ static void ath_bar_tx(struct ath_softc_tgt *sc,
 
        __stats(sc, tx_bars);
 
-       memset(&series, 0, sizeof(series));
+       adf_os_mem_set(&series, 0, sizeof(series));
 
        ath_aggr_pause_tid(sc, tid);
 
@@ -2156,6 +2153,6 @@ static void ath_bar_tx(struct ath_softc_tgt *sc,
                series[i].ChSel = sc->sc_ic.ic_tx_chainmask;
        }
 
-       ath_hal_set11n_ratescenario(sc->sc_ah, bf->bf_desc, 0, 0, 0, series, 4, 4);
+       ah->ah_set11nRateScenario(ah, bf->bf_desc, 0, 0, 0, series, 4, 4);
        ath_tgt_txq_add_ucast(sc, bf);
 }