Changeset 3619

Show
Ignore:
Timestamp:
05/07/08 00:18:43 (8 months ago)
Author:
mentor
Message:

Fold descriptor link address byte-swapping for hardware into a common function

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • madwifi/trunk/ath/if_ath.c

    r3616 r3619  
    165165static int ath_desc_alloc(struct ath_softc *); 
    166166static void ath_desc_free(struct ath_softc *); 
    167 static void ath_desc_swap(struct ath_desc *); 
     167static __inline void ath_desc_swap(struct ath_desc *); 
     168static __inline u_int32_t ath_ds_link_swap(u_int32_t); 
    168169 
    169170#ifdef IEEE80211_DEBUG_REFCNT 
     
    21192120 
    21202121                                        if (uapsd_xmit_q->axq_link) { 
    2121 #ifdef AH_NEED_DESC_SWAP 
    21222122                                                *uapsd_xmit_q->axq_link = 
    2123                                                         cpu_to_le32(STAILQ_FIRST(&an->an_uapsd_q)->bf_daddr); 
    2124 #else 
    2125                                                 *uapsd_xmit_q->axq_link = 
    2126                                                         STAILQ_FIRST(&an->an_uapsd_q)->bf_daddr; 
    2127 #endif 
     2123                                                        ath_ds_link_swap(STAILQ_FIRST(&an->an_uapsd_q)->bf_daddr); 
    21282124                                        } 
    21292125                                        /* below leaves an_uapsd_q NULL */ 
     
    29052901} 
    29062902 
     2903/* Swap transmit descriptor pointer for HW. */ 
     2904static __inline u_int32_t 
     2905ath_ds_link_swap(u_int32_t dp) { 
     2906#ifdef AH_NEED_DESC_SWAP 
     2907        return swab32(dp); 
     2908#else 
     2909        return (dp); 
     2910#endif 
     2911} 
     2912 
    29072913static void 
    29082914ath_txq_dump(struct ath_softc *sc, struct ath_txq *txq) 
     
    29912997                                txq->axq_qnum, txq->axq_depth); 
    29922998                if (txq->axq_link != NULL) { 
    2993 #ifdef AH_NEED_DESC_SWAP 
    2994                         *txq->axq_link = cpu_to_le32(bf->bf_daddr); 
    2995 #else 
    2996                         *txq->axq_link = bf->bf_daddr; 
    2997 #endif 
     2999                        *txq->axq_link = ath_ds_link_swap(bf->bf_daddr); 
    29983000                        DPRINTF(sc, ATH_DEBUG_XMIT, "link[%u](%p)=%08llx (%p)\n", 
    29993001                                txq->axq_qnum, txq->axq_link, 
     
    30223024                        } 
    30233025                } else { 
    3024 #ifdef AH_NEED_DESC_SWAP 
    3025                         *txq->axq_link = cpu_to_le32(bf->bf_daddr); 
    3026 #else 
    3027                         *txq->axq_link = bf->bf_daddr; 
    3028 #endif 
     3026                        *txq->axq_link = ath_ds_link_swap(bf->bf_daddr); 
    30293027                        DPRINTF(sc, ATH_DEBUG_XMIT, "link[%u] (%p)=%08llx (%p)\n", 
    30303028                                txq->axq_qnum, txq->axq_link, 
     
    51635161                                                 bfmcast->bf_daddr); 
    51645162                        } else { 
    5165 #ifdef AH_NEED_DESC_SWAP 
    5166                                 *cabq->axq_link = cpu_to_le32(bfmcast->bf_daddr); 
    5167 #else 
    5168                                 *cabq->axq_link = bfmcast->bf_daddr; 
    5169 #endif 
     5163                                *cabq->axq_link = ath_ds_link_swap(bfmcast->bf_daddr); 
    51705164                        } 
    51715165                        /* Set the MORE_DATA bit for each packet except the last one */ 
     
    52925286                                                needmark)) != NULL) { 
    52935287                                        if (bflink != NULL) 
    5294 #ifdef AH_NEED_DESC_SWAP 
    5295                                                 *bflink = cpu_to_le32(bf->bf_daddr); 
    5296 #else 
    5297                                                 *bflink = bf->bf_daddr; 
    5298 #endif 
     5288                                                *bflink = ath_ds_link_swap(bf->bf_daddr); 
    52995289                                        else /* For the first bf, save bf_addr for later */ 
    53005290                                                bfaddr = bf->bf_daddr; 
     
    60486038                                                ds = prev->bf_desc; 
    60496039#endif 
    6050 #ifdef AH_NEED_DESC_SWAP 
    6051                                                 ds->ds_link = cpu_to_le32(bf->bf_daddr); 
    6052 #else 
    6053                                                 ds->ds_link = bf->bf_daddr; 
    6054 #endif 
     6040                                                ds->ds_link = ath_ds_link_swap(bf->bf_daddr); 
    60556041                                        } 
    60566042                                } else { 
     
    62026188                                 */ 
    62036189                                if (wmeq->axq_link != NULL) { 
    6204 #ifdef AH_NEED_DESC_SWAP 
    62056190                                        *wmeq->axq_link =  
    6206                                                 cpu_to_le32(bf_tmp->bf_daddr); 
    6207 #else 
    6208                                         *wmeq->axq_link = bf_tmp->bf_daddr; 
    6209 #endif 
     6191                                                ath_ds_link_swap(bf_tmp->bf_daddr); 
    62106192                                        DPRINTF(sc, ATH_DEBUG_XMIT,  
    62116193                                                        "link[%u](%p)=%08llx (%p)\n", 
     
    62836265                                        ATH_TXQ_MOVE_Q(wmeq, txq); 
    62846266                                        if (txq->axq_link != NULL) { 
    6285 #ifdef AH_NEED_DESC_SWAP 
    62866267                                                *(txq->axq_link) =  
    6287                                                         cpu_to_le32(bf->bf_daddr); 
    6288 #else 
    6289                                                 *(txq->axq_link) = bf->bf_daddr; 
    6290 #endif 
     6268                                                        ath_ds_link_swap(bf->bf_daddr); 
    62916269                                        } 
    62926270                                } 
     
    72717249                        ath_desc_swap(ds); 
    72727250                        if (txq->axq_link) { 
    7273 #ifdef AH_NEED_DESC_SWAP 
    7274                                 *txq->axq_link = cpu_to_le32(bf->bf_daddr); 
    7275 #else 
    7276                                 *txq->axq_link = bf->bf_daddr; 
    7277 #endif 
     7251                                *txq->axq_link = ath_ds_link_swap(bf->bf_daddr); 
    72787252                        } 
    72797253                        txq->axq_link = &ds->ds_link; 
     
    72867260        } 
    72877261        /* make it circular */ 
    7288 #ifdef AH_NEED_DESC_SWAP 
    7289         ds->ds_link = cpu_to_le32(head->bf_daddr); 
    7290 #else 
    7291         ds->ds_link = head->bf_daddr; 
    7292 #endif 
     7262        ds->ds_link = ath_ds_link_swap(head->bf_daddr); 
    72937263        /* start the queue */ 
    72947264        ath_hal_puttxbuf(ah, txq->axq_qnum, head->bf_daddr); 
     
    76637633                /* add to delivery q */ 
    76647634                if ((lastbuf = STAILQ_LAST(&an->an_uapsd_q, ath_buf, bf_list))) { 
    7665 #ifdef AH_NEED_DESC_SWAP 
    7666                         lastbuf->bf_desc->ds_link = cpu_to_le32(bf->bf_daddr); 
    7667 #else 
    7668                         lastbuf->bf_desc->ds_link = bf->bf_daddr; 
    7669 #endif 
     7635                        lastbuf->bf_desc->ds_link = ath_ds_link_swap(bf->bf_daddr); 
    76707636                } 
    76717637                STAILQ_INSERT_TAIL(&an->an_uapsd_q, bf, bf_list); 
     
    77007666        /* add to overflow q */ 
    77017667        if ((lastbuf = STAILQ_LAST(&an->an_uapsd_overflowq, ath_buf, bf_list))) { 
    7702 #ifdef AH_NEED_DESC_SWAP 
    7703                 lastbuf->bf_desc->ds_link = cpu_to_le32(bf->bf_daddr); 
    7704 #else 
    7705                 lastbuf->bf_desc->ds_link = bf->bf_daddr; 
    7706 #endif 
     7668                lastbuf->bf_desc->ds_link = ath_ds_link_swap(bf->bf_daddr); 
    77077669        } 
    77087670        STAILQ_INSERT_TAIL(&an->an_uapsd_overflowq, bf, bf_list);