X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=target_firmware%2Fwlan%2Fif_ath.c;h=91376c5848689939fe59f2fb51580b25e2b5910c;hb=facb4cd0538a5c8de03389895c8226c11d5282ef;hp=789725baa21d98239856f0aacbe6bbf16886288d;hpb=8804cc94e3b66550797279f540b960d18a78421f;p=open-ath9k-htc-firmware.git diff --git a/target_firmware/wlan/if_ath.c b/target_firmware/wlan/if_ath.c index 789725b..91376c5 100755 --- a/target_firmware/wlan/if_ath.c +++ b/target_firmware/wlan/if_ath.c @@ -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 #include #include @@ -15,13 +50,12 @@ #include #include -#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" +#include "ah.h" static a_int32_t ath_numrxbufs = -1; static a_int32_t ath_numrxdescs = -1; @@ -35,12 +69,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); @@ -88,10 +120,10 @@ static a_int32_t ath_rate_setup(struct ath_softc_tgt *sc, a_uint32_t mode) switch (mode) { case IEEE80211_MODE_11NA: - sc->sc_rates[mode] = ath_hal_getratetable(ah, HAL_MODE_11NA); + sc->sc_rates[mode] = ah->ah_getRateTable(ah, HAL_MODE_11NA); break; case IEEE80211_MODE_11NG: - sc->sc_rates[mode] = ath_hal_getratetable(ah, HAL_MODE_11NG); + sc->sc_rates[mode] = ah->ah_getRateTable(ah, HAL_MODE_11NG); break; default: return 0; @@ -125,7 +157,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 +179,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 +377,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 +443,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 +482,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 +515,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 +533,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 +602,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 +878,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 +923,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 +932,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 +960,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 +1000,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 +1015,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) @@ -1038,7 +1067,7 @@ adf_os_irq_resp_t ath_intr(adf_drv_handle_t hdl) if (status & HAL_INT_TXURN) { sc->sc_int_stats.ast_txurn++; - ath_hal_updatetxtriglevel(ah, AH_TRUE); + ah->ah_updateTxTrigLevel(ah, AH_TRUE); } ATH_SCHEDULE_TQUEUE(sc->sc_dev, &sc->sc_txtq); @@ -1106,7 +1135,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 +1145,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 +1523,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 +1628,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,14 +1637,14 @@ 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; struct ath_hal *ah = sc->sc_ah; ath_desc_free(sc); - ath_hal_detach(ah); + ah->ah_detach(ah); wmi_cmd_rsp(sc->tgt_wmi_handle, Command, SeqNo, NULL, 0); adf_os_mem_free(sc); } @@ -1854,8 +1874,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 +1896,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; @@ -1917,7 +1936,7 @@ bad: bad2: ath_desc_free(sc); if (ah) - ath_hal_detach(ah); + ah->ah_detach(ah); } static void tgt_hif_htc_wmi_shutdown(struct ath_softc_tgt *sc)