wlan/if_ath.c: remove unused includes
[open-ath9k-htc-firmware.git] / target_firmware / wlan / if_ath.c
index 789725baa21d98239856f0aacbe6bbf16886288d..25d41ff7c6d0f852b74cb2a1691a92afb5e59a9d 100755 (executable)
@@ -1,3 +1,38 @@
+/*
+ * Copyright (c) 2013 Qualcomm Atheros, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the
+ *    distribution.
+ *
+ *  * Neither the name of Qualcomm Atheros nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #include <adf_os_types.h>
 #include <adf_os_pci.h>
 #include <adf_os_dma.h>
 #include <adf_os_irq.h>
 
 #include <if_ath_pci.h>
-#include "if_ethersubr.h"
 #include "if_llc.h"
 #include "ieee80211_var.h"
-#include "ieee80211_proto.h"
 #include "if_athrate.h"
 #include "if_athvar.h"
 #include "ah_desc.h"
@@ -35,12 +68,10 @@ uint32_t *init_htc_handle = 0;
 #define UAPSDQ_NUM   9
 #define CABQ_NUM     8
 
-void wmi_event(wmi_handle_t handle, WMI_EVENT_ID evt_id, A_UINT8 *buffer, a_int32_t Length);
 void owl_tgt_tx_tasklet(TQUEUE_ARG data);
 static void ath_tgt_send_beacon(struct ath_softc_tgt *sc,adf_nbuf_t bc_hdr,adf_nbuf_t nbuf,HTC_ENDPOINT_ID EndPt);
-void wmi_cmd_rsp(void *pContext, WMI_COMMAND_ID cmd_id, A_UINT16 SeqNo, A_UINT8 *buffer, a_int32_t Length);
 static void ath_hal_reg_write_tgt(void *Context, A_UINT16 Command, A_UINT16 SeqNo, A_UINT8 *data, a_int32_t datalen);
-extern struct ath_buf * ath_tgt_tx_prepare(struct ath_softc_tgt *sc, adf_nbuf_t skb, ath_data_hdr_t *dh);
+extern struct ath_tx_buf* ath_tgt_tx_prepare(struct ath_softc_tgt *sc, adf_nbuf_t skb, ath_data_hdr_t *dh);
 extern void  ath_tgt_send_mgt(struct ath_softc_tgt *sc,adf_nbuf_t mgt_hdr, adf_nbuf_t skb,HTC_ENDPOINT_ID EndPt);
 extern HAL_BOOL ath_hal_wait(struct ath_hal *ah, a_uint32_t reg, a_uint32_t mask, a_uint32_t val);
 extern void owltgt_tx_processq(struct ath_softc_tgt *sc, struct ath_txq *txq,  owl_txq_state_t txqstate);
@@ -125,7 +156,7 @@ static void ath_setcurmode(struct ath_softc_tgt *sc,
 }
 
 void wmi_event(wmi_handle_t handle, WMI_EVENT_ID evt_id,
-              A_UINT8 *buffer, a_int32_t Length)
+              void *buffer, a_int32_t Length)
 {
        adf_nbuf_t netbuf = ADF_NBUF_NULL;
        a_uint8_t *pData;
@@ -147,7 +178,7 @@ void wmi_event(wmi_handle_t handle, WMI_EVENT_ID evt_id,
 }
 
 void wmi_cmd_rsp(void *pContext, WMI_COMMAND_ID cmd_id, A_UINT16 SeqNo,
-                A_UINT8 *buffer, a_int32_t Length)
+                void *buffer, a_int32_t Length)
 {
        adf_nbuf_t netbuf = ADF_NBUF_NULL;
        A_UINT8 *pData;
@@ -345,7 +376,7 @@ static void ath_uapsd_processtriggers(struct ath_softc_tgt *sc)
                        break;
                }
 
-               if (ds->ds_link == NULL) {
+               if (ds->ds_link == 0) {
                        break;
                }
 
@@ -411,7 +442,7 @@ static void ath_uapsd_processtriggers(struct ath_softc_tgt *sc)
 
                        bf->bf_status |= ATH_BUFSTATUS_DONE;
 
-                       bf = asf_tailq_next(bf, bf_list);
+                       bf = (struct ath_rx_buf *)asf_tailq_next(bf, bf_list);
                }
                else {
                        ds = asf_tailq_next(ds, ds_list);
@@ -450,7 +481,6 @@ static void ath_tgt_rx_tasklet(TQUEUE_ARG data)
        struct ath_rx_buf *bf = NULL;
        struct ath_hal *ah = sc->sc_ah;
        struct rx_frame_header *rxhdr;
-       struct ieee80211_frame *wh;
        struct ath_rx_status *rxstats;
        adf_nbuf_t skb = ADF_NBUF_NULL;
 
@@ -484,7 +514,6 @@ static void ath_tgt_rx_tasklet(TQUEUE_ARG data)
                HTC_SendMsg(sc->tgt_htc_handle, RX_ENDPOINT_ID, skb);
                sc->sc_rx_stats.ast_rx_send++;
 
-       next_buf:
                bf->bf_status &= ~ATH_BUFSTATUS_DONE;
                asf_tailq_insert_tail(&sc->sc_rxbuf, bf, bf_list);
 
@@ -503,13 +532,13 @@ static void ath_tgt_rx_tasklet(TQUEUE_ARG data)
  * FIXME: Short Preamble.
  */
 static void ath_beacon_setup(struct ath_softc_tgt *sc,
-                            struct ath_buf *bf,
+                            struct ath_tx_buf *bf,
                             struct ath_vap_target *avp)
 {
        adf_nbuf_t skb = bf->bf_skb;
        struct ath_hal *ah = sc->sc_ah;
-       struct ath_desc *ds;
-       a_int32_t flags, antenna;
+       struct ath_tx_desc *ds;
+       a_int32_t flags;
        const HAL_RATE_TABLE *rt;
        a_uint8_t rix, rate;
        HAL_11N_RATE_SERIES series[4] = {{ 0 }};
@@ -572,7 +601,7 @@ static void ath_tgt_send_beacon(struct ath_softc_tgt *sc, adf_nbuf_t bc_hdr,
 
        vap_index = bhdr->vap_index;
        adf_os_assert(vap_index < TARGET_VAP_MAX);
-       vap = &sc->sc_vap[vap_index];
+       vap = &sc->sc_vap[vap_index].av_vap;
 
        wh = (struct ieee80211_frame *)adf_nbuf_pull_head(nbuf,
                                                  sizeof(ath_beacon_hdr_t));
@@ -848,8 +877,8 @@ static void ath_descdma_cleanup(struct ath_softc_tgt *sc,
                                struct ath_descdma *dd,
                                ath_bufhead *head, a_int32_t dir)
 {
-       struct ath_tx_buf *bf;
-       struct ieee80211_node *ni;
+       struct ath_buf *bf;
+       struct ieee80211_node_target *ni;
 
        asf_tailq_foreach(bf, head, bf_list) {
                if (adf_nbuf_queue_len(&bf->bf_skbhead) != 0) {
@@ -893,7 +922,7 @@ static a_int32_t ath_desc_alloc(struct ath_softc_tgt *sc)
        if (ath_numrxdescs == -1)
                ath_numrxdescs = ATH_RXDESC;
 
-       error = ath_descdma_setup(sc, &sc->sc_rxdma, &sc->sc_rxbuf,
+       error = ath_descdma_setup(sc, &sc->sc_rxdma, (ath_bufhead *)&sc->sc_rxbuf,
                                  "rx", ath_numrxdescs, 1,
                                  sizeof(struct ath_rx_buf),
                                  sizeof(struct ath_rx_desc));
@@ -902,7 +931,7 @@ static a_int32_t ath_desc_alloc(struct ath_softc_tgt *sc)
 
        a_uint32_t i;
        struct ath_descdma *dd = &sc->sc_rxdma;
-       struct ath_rx_desc *ds = dd->dd_desc;
+       struct ath_rx_desc *ds = (struct ath_rx_desc *)dd->dd_desc;
        struct ath_rx_desc *ds_prev = NULL;
 
        asf_tailq_init(&sc->sc_rxdesc);
@@ -930,24 +959,24 @@ static a_int32_t ath_desc_alloc(struct ath_softc_tgt *sc)
                asf_tailq_insert_tail(&sc->sc_rxdesc, ds, ds_list);
        }
 
-       error = ath_descdma_setup(sc, &sc->sc_txdma, &sc->sc_txbuf,
+       error = ath_descdma_setup(sc, &sc->sc_txdma, (ath_bufhead *)&sc->sc_txbuf,
                                  "tx", ATH_TXBUF + 1, ATH_TXDESC,
                                  sizeof(struct ath_tx_buf),
                                  sizeof(struct ath_tx_desc));
        if (error != 0) {
-               ath_descdma_cleanup(sc, &sc->sc_rxdma, &sc->sc_rxbuf,
+               ath_descdma_cleanup(sc, &sc->sc_rxdma, (ath_bufhead *)&sc->sc_rxbuf,
                                    ADF_OS_DMA_FROM_DEVICE);
                return error;
        }
 
-       error = ath_descdma_setup(sc, &sc->sc_bdma, &sc->sc_bbuf,
+       error = ath_descdma_setup(sc, &sc->sc_bdma, (ath_bufhead *)&sc->sc_bbuf,
                                  "beacon", ATH_BCBUF, 1,
                                  sizeof(struct ath_tx_buf),
                                  sizeof(struct ath_tx_desc));
        if (error != 0) {
-               ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf,
+               ath_descdma_cleanup(sc, &sc->sc_txdma, (ath_bufhead *)&sc->sc_txbuf,
                                    ADF_OS_DMA_TO_DEVICE);
-               ath_descdma_cleanup(sc, &sc->sc_rxdma, &sc->sc_rxbuf,
+               ath_descdma_cleanup(sc, &sc->sc_rxdma, (ath_bufhead *)&sc->sc_rxbuf,
                                    ADF_OS_DMA_FROM_DEVICE);
                return error;
        }
@@ -970,10 +999,10 @@ static void ath_desc_free(struct ath_softc_tgt *sc)
        sc->sc_txbuf_held = NULL;
 
        if (sc->sc_txdma.dd_desc_len != 0)
-               ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf,
+               ath_descdma_cleanup(sc, &sc->sc_txdma, (ath_bufhead *)&sc->sc_txbuf,
                                    ADF_OS_DMA_TO_DEVICE);
        if (sc->sc_rxdma.dd_desc_len != 0)
-               ath_descdma_cleanup(sc, &sc->sc_rxdma, &sc->sc_rxbuf,
+               ath_descdma_cleanup(sc, &sc->sc_rxdma, (ath_bufhead *)&sc->sc_rxbuf,
                                    ADF_OS_DMA_FROM_DEVICE);
 }
 
@@ -985,7 +1014,6 @@ adf_os_irq_resp_t ath_intr(adf_drv_handle_t hdl)
 {
        struct ath_softc_tgt *sc = (struct ath_softc_tgt *)hdl;
        struct ath_hal *ah = sc->sc_ah;
-       struct ieee80211com_target *ic = &sc->sc_ic;
        HAL_INT status;
 
        if (sc->sc_invalid)
@@ -1106,7 +1134,6 @@ static void ath_init_tgt(void *Context, A_UINT16 Command,
 {
        struct ath_softc_tgt *sc = (struct ath_softc_tgt *)Context;
        struct ath_hal *ah = sc->sc_ah;
-       a_uint32_t stbcsupport;
 
        sc->sc_imask = HAL_INT_RX | HAL_INT_TX
                | HAL_INT_RXEOL | HAL_INT_RXORN
@@ -1117,13 +1144,6 @@ static void ath_init_tgt(void *Context, A_UINT16 Command,
        if (ath_hal_htsupported(ah))
                sc->sc_imask |= HAL_INT_CST;
 
-#ifdef MAGPIE_MERLIN
-       if (ath_hal_txstbcsupport(ah, &stbcsupport))
-               sc->sc_txstbcsupport = stbcsupport;
-
-       if (ath_hal_rxstbcsupport(ah, &stbcsupport))
-               sc->sc_rxstbcsupport = stbcsupport;
-#endif
        adf_os_setup_intr(sc->sc_dev, ath_intr);
        ath_hal_intrset(ah, sc->sc_imask);
 
@@ -1502,7 +1522,7 @@ static void ath_flushrecv_tgt(void *Context, A_UINT16 Command,
                              A_UINT16 SeqNo, A_UINT8 *data, a_int32_t datalen)
 {
        struct ath_softc_tgt *sc = (struct ath_softc_tgt *)Context;
-       struct ath_buf *bf;
+       struct ath_rx_buf *bf;
 
        asf_tailq_foreach(bf, &sc->sc_rxbuf, bf_list)
                if (bf->bf_skb != NULL) {
@@ -1607,7 +1627,6 @@ static void ath_setcurmode_tgt(void *Context, A_UINT16 Command,
 {
        struct ath_softc_tgt *sc = (struct ath_softc_tgt *)Context;
        a_uint16_t mode;
-       struct ath_hal *ah = sc->sc_ah;
 
        mode= *((a_uint16_t *)data);
        mode = adf_os_ntohs(mode);
@@ -1617,7 +1636,7 @@ static void ath_setcurmode_tgt(void *Context, A_UINT16 Command,
        wmi_cmd_rsp(sc->tgt_wmi_handle, Command, SeqNo, NULL, 0);
 }
 
-static a_uint32_t ath_detach_tgt(void *Context, A_UINT16 Command, A_UINT16 SeqNo,
+static void ath_detach_tgt(void *Context, A_UINT16 Command, A_UINT16 SeqNo,
                                 A_UINT8 *data, a_int32_t datalen)
 {
        struct ath_softc_tgt *sc = (struct ath_softc_tgt *)Context;
@@ -1854,8 +1873,7 @@ static void tgt_hif_htc_wmi_init(struct ath_softc_tgt *sc)
        HTC_Ready(sc->tgt_htc_handle);
 }
 
-a_int32_t ath_tgt_attach(a_uint32_t devid,a_uint32_t mem_start,
-                        struct ath_softc_tgt *sc, adf_os_device_t osdev)
+a_int32_t ath_tgt_attach(a_uint32_t devid, struct ath_softc_tgt *sc, adf_os_device_t osdev)
 {
        struct ath_hal *ah;
        HAL_STATUS status;
@@ -1877,7 +1895,7 @@ a_int32_t ath_tgt_attach(a_uint32_t devid,a_uint32_t mem_start,
        ATH_INIT_TQUEUE(sc->sc_dev, &sc->sc_fataltq, ath_fatal_tasklet, sc);
 
        flags |= AH_USE_EEPROM;
-       ah = _ath_hal_attach_tgt(devid,sc,sc->sc_dev,mem_start, flags, &status);
+       ah = _ath_hal_attach_tgt(devid, sc, sc->sc_dev, flags, &status);
        if (ah == NULL) {
                error = ENXIO;
                goto bad;