aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/brcm80211/brcmsmac/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/brcm80211/brcmsmac/main.c')
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/main.c1261
1 files changed, 394 insertions, 867 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index 75086b37c817..17594de4199e 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -34,12 +34,9 @@
34#include "ucode_loader.h" 34#include "ucode_loader.h"
35#include "main.h" 35#include "main.h"
36#include "soc.h" 36#include "soc.h"
37 37#include "dma.h"
38/* 38#include "debug.h"
39 * Indication for txflowcontrol that all priority bits in 39#include "brcms_trace_events.h"
40 * TXQ_STOP_FOR_PRIOFC_MASK are to be considered.
41 */
42#define ALLPRIO -1
43 40
44/* watchdog timer, in unit of ms */ 41/* watchdog timer, in unit of ms */
45#define TIMER_INTERVAL_WATCHDOG 1000 42#define TIMER_INTERVAL_WATCHDOG 1000
@@ -126,21 +123,6 @@
126 123
127#define BRCMS_TEMPSENSE_PERIOD 10 /* 10 second timeout */ 124#define BRCMS_TEMPSENSE_PERIOD 10 /* 10 second timeout */
128 125
129/* precedences numbers for wlc queues. These are twice as may levels as
130 * 802.1D priorities.
131 * Odd numbers are used for HI priority traffic at same precedence levels
132 * These constants are used ONLY by wlc_prio2prec_map. Do not use them
133 * elsewhere.
134 */
135#define _BRCMS_PREC_NONE 0 /* None = - */
136#define _BRCMS_PREC_BK 2 /* BK - Background */
137#define _BRCMS_PREC_BE 4 /* BE - Best-effort */
138#define _BRCMS_PREC_EE 6 /* EE - Excellent-effort */
139#define _BRCMS_PREC_CL 8 /* CL - Controlled Load */
140#define _BRCMS_PREC_VI 10 /* Vi - Video */
141#define _BRCMS_PREC_VO 12 /* Vo - Voice */
142#define _BRCMS_PREC_NC 14 /* NC - Network Control */
143
144/* synthpu_dly times in us */ 126/* synthpu_dly times in us */
145#define SYNTHPU_DLY_APHY_US 3700 127#define SYNTHPU_DLY_APHY_US 3700
146#define SYNTHPU_DLY_BPHY_US 1050 128#define SYNTHPU_DLY_BPHY_US 1050
@@ -237,17 +219,17 @@
237 219
238#define MAX_DMA_SEGS 4 220#define MAX_DMA_SEGS 4
239 221
240/* Max # of entries in Tx FIFO based on 4kb page size */ 222/* # of entries in Tx FIFO */
241#define NTXD 256 223#define NTXD 64
242/* Max # of entries in Rx FIFO based on 4kb page size */ 224/* Max # of entries in Rx FIFO based on 4kb page size */
243#define NRXD 256 225#define NRXD 256
244 226
227/* Amount of headroom to leave in Tx FIFO */
228#define TX_HEADROOM 4
229
245/* try to keep this # rbufs posted to the chip */ 230/* try to keep this # rbufs posted to the chip */
246#define NRXBUFPOST 32 231#define NRXBUFPOST 32
247 232
248/* data msg txq hiwat mark */
249#define BRCMS_DATAHIWAT 50
250
251/* max # frames to process in brcms_c_recv() */ 233/* max # frames to process in brcms_c_recv() */
252#define RXBND 8 234#define RXBND 8
253/* max # tx status to process in wlc_txstatus() */ 235/* max # tx status to process in wlc_txstatus() */
@@ -283,24 +265,8 @@ struct edcf_acparam {
283 u16 TXOP; 265 u16 TXOP;
284} __packed; 266} __packed;
285 267
286const u8 prio2fifo[NUMPRIO] = {
287 TX_AC_BE_FIFO, /* 0 BE AC_BE Best Effort */
288 TX_AC_BK_FIFO, /* 1 BK AC_BK Background */
289 TX_AC_BK_FIFO, /* 2 -- AC_BK Background */
290 TX_AC_BE_FIFO, /* 3 EE AC_BE Best Effort */
291 TX_AC_VI_FIFO, /* 4 CL AC_VI Video */
292 TX_AC_VI_FIFO, /* 5 VI AC_VI Video */
293 TX_AC_VO_FIFO, /* 6 VO AC_VO Voice */
294 TX_AC_VO_FIFO /* 7 NC AC_VO Voice */
295};
296
297/* debug/trace */ 268/* debug/trace */
298uint brcm_msg_level = 269uint brcm_msg_level;
299#if defined(DEBUG)
300 LOG_ERROR_VAL;
301#else
302 0;
303#endif /* DEBUG */
304 270
305/* TX FIFO number to WME/802.1E Access Category */ 271/* TX FIFO number to WME/802.1E Access Category */
306static const u8 wme_fifo2ac[] = { 272static const u8 wme_fifo2ac[] = {
@@ -320,18 +286,6 @@ static const u8 wme_ac2fifo[] = {
320 TX_AC_BK_FIFO 286 TX_AC_BK_FIFO
321}; 287};
322 288
323/* 802.1D Priority to precedence queue mapping */
324const u8 wlc_prio2prec_map[] = {
325 _BRCMS_PREC_BE, /* 0 BE - Best-effort */
326 _BRCMS_PREC_BK, /* 1 BK - Background */
327 _BRCMS_PREC_NONE, /* 2 None = - */
328 _BRCMS_PREC_EE, /* 3 EE - Excellent-effort */
329 _BRCMS_PREC_CL, /* 4 CL - Controlled Load */
330 _BRCMS_PREC_VI, /* 5 Vi - Video */
331 _BRCMS_PREC_VO, /* 6 Vo - Voice */
332 _BRCMS_PREC_NC, /* 7 NC - Network Control */
333};
334
335static const u16 xmtfifo_sz[][NFIFO] = { 289static const u16 xmtfifo_sz[][NFIFO] = {
336 /* corerev 17: 5120, 49152, 49152, 5376, 4352, 1280 */ 290 /* corerev 17: 5120, 49152, 49152, 5376, 4352, 1280 */
337 {20, 192, 192, 21, 17, 5}, 291 {20, 192, 192, 21, 17, 5},
@@ -371,6 +325,36 @@ static const char fifo_names[6][0];
371static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); 325static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL);
372#endif 326#endif
373 327
328/* Mapping of ieee80211 AC numbers to tx fifos */
329static const u8 ac_to_fifo_mapping[IEEE80211_NUM_ACS] = {
330 [IEEE80211_AC_VO] = TX_AC_VO_FIFO,
331 [IEEE80211_AC_VI] = TX_AC_VI_FIFO,
332 [IEEE80211_AC_BE] = TX_AC_BE_FIFO,
333 [IEEE80211_AC_BK] = TX_AC_BK_FIFO,
334};
335
336/* Mapping of tx fifos to ieee80211 AC numbers */
337static const u8 fifo_to_ac_mapping[IEEE80211_NUM_ACS] = {
338 [TX_AC_BK_FIFO] = IEEE80211_AC_BK,
339 [TX_AC_BE_FIFO] = IEEE80211_AC_BE,
340 [TX_AC_VI_FIFO] = IEEE80211_AC_VI,
341 [TX_AC_VO_FIFO] = IEEE80211_AC_VO,
342};
343
344static u8 brcms_ac_to_fifo(u8 ac)
345{
346 if (ac >= ARRAY_SIZE(ac_to_fifo_mapping))
347 return TX_AC_BE_FIFO;
348 return ac_to_fifo_mapping[ac];
349}
350
351static u8 brcms_fifo_to_ac(u8 fifo)
352{
353 if (fifo >= ARRAY_SIZE(fifo_to_ac_mapping))
354 return IEEE80211_AC_BE;
355 return fifo_to_ac_mapping[fifo];
356}
357
374/* Find basic rate for a given rate */ 358/* Find basic rate for a given rate */
375static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) 359static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec)
376{ 360{
@@ -415,10 +399,15 @@ static bool brcms_deviceremoved(struct brcms_c_info *wlc)
415} 399}
416 400
417/* sum the individual fifo tx pending packet counts */ 401/* sum the individual fifo tx pending packet counts */
418static s16 brcms_txpktpendtot(struct brcms_c_info *wlc) 402static int brcms_txpktpendtot(struct brcms_c_info *wlc)
419{ 403{
420 return wlc->core->txpktpend[0] + wlc->core->txpktpend[1] + 404 int i;
421 wlc->core->txpktpend[2] + wlc->core->txpktpend[3]; 405 int pending = 0;
406
407 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++)
408 if (wlc->hw->di[i])
409 pending += dma_txpending(wlc->hw->di[i]);
410 return pending;
422} 411}
423 412
424static bool brcms_is_mband_unlocked(struct brcms_c_info *wlc) 413static bool brcms_is_mband_unlocked(struct brcms_c_info *wlc)
@@ -626,14 +615,11 @@ static uint brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec,
626 uint rate = rspec2rate(ratespec); 615 uint rate = rspec2rate(ratespec);
627 616
628 if (rate == 0) { 617 if (rate == 0) {
629 wiphy_err(wlc->wiphy, "wl%d: WAR: using rate of 1 mbps\n", 618 brcms_err(wlc->hw->d11core, "wl%d: WAR: using rate of 1 mbps\n",
630 wlc->pub->unit); 619 wlc->pub->unit);
631 rate = BRCM_RATE_1M; 620 rate = BRCM_RATE_1M;
632 } 621 }
633 622
634 BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d, len%d\n",
635 wlc->pub->unit, ratespec, preamble_type, mac_len);
636
637 if (is_mcs_rate(ratespec)) { 623 if (is_mcs_rate(ratespec)) {
638 uint mcs = ratespec & RSPEC_RATE_MASK; 624 uint mcs = ratespec & RSPEC_RATE_MASK;
639 int tot_streams = mcs_2_txstreams(mcs) + rspec_stc(ratespec); 625 int tot_streams = mcs_2_txstreams(mcs) + rspec_stc(ratespec);
@@ -696,7 +682,7 @@ static void brcms_c_write_inits(struct brcms_hardware *wlc_hw,
696 u16 size; 682 u16 size;
697 u32 value; 683 u32 value;
698 684
699 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 685 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit);
700 686
701 for (i = 0; inits[i].addr != cpu_to_le16(0xffff); i++) { 687 for (i = 0; inits[i].addr != cpu_to_le16(0xffff); i++) {
702 size = le16_to_cpu(inits[i].size); 688 size = le16_to_cpu(inits[i].size);
@@ -725,19 +711,19 @@ static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs)
725 711
726static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) 712static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw)
727{ 713{
728 struct wiphy *wiphy = wlc_hw->wlc->wiphy;
729 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; 714 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode;
730 715
731 /* init microcode host flags */ 716 /* init microcode host flags */
732 brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs); 717 brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs);
733 718
734 /* do band-specific ucode IHR, SHM, and SCR inits */ 719 /* do band-specific ucode IHR, SHM, and SCR inits */
735 if (D11REV_IS(wlc_hw->corerev, 23)) { 720 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) {
736 if (BRCMS_ISNPHY(wlc_hw->band)) 721 if (BRCMS_ISNPHY(wlc_hw->band))
737 brcms_c_write_inits(wlc_hw, ucode->d11n0bsinitvals16); 722 brcms_c_write_inits(wlc_hw, ucode->d11n0bsinitvals16);
738 else 723 else
739 wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" 724 brcms_err(wlc_hw->d11core,
740 " %d\n", __func__, wlc_hw->unit, 725 "%s: wl%d: unsupported phy in corerev %d\n",
726 __func__, wlc_hw->unit,
741 wlc_hw->corerev); 727 wlc_hw->corerev);
742 } else { 728 } else {
743 if (D11REV_IS(wlc_hw->corerev, 24)) { 729 if (D11REV_IS(wlc_hw->corerev, 24)) {
@@ -745,12 +731,14 @@ static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw)
745 brcms_c_write_inits(wlc_hw, 731 brcms_c_write_inits(wlc_hw,
746 ucode->d11lcn0bsinitvals24); 732 ucode->d11lcn0bsinitvals24);
747 else 733 else
748 wiphy_err(wiphy, "%s: wl%d: unsupported phy in" 734 brcms_err(wlc_hw->d11core,
749 " core rev %d\n", __func__, 735 "%s: wl%d: unsupported phy in core rev %d\n",
750 wlc_hw->unit, wlc_hw->corerev); 736 __func__, wlc_hw->unit,
737 wlc_hw->corerev);
751 } else { 738 } else {
752 wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n", 739 brcms_err(wlc_hw->d11core,
753 __func__, wlc_hw->unit, wlc_hw->corerev); 740 "%s: wl%d: unsupported corerev %d\n",
741 __func__, wlc_hw->unit, wlc_hw->corerev);
754 } 742 }
755 } 743 }
756} 744}
@@ -765,7 +753,7 @@ static void brcms_b_core_ioctl(struct brcms_hardware *wlc_hw, u32 m, u32 v)
765 753
766static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk) 754static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk)
767{ 755{
768 BCMMSG(wlc_hw->wlc->wiphy, "wl%d: clk %d\n", wlc_hw->unit, clk); 756 brcms_dbg_info(wlc_hw->d11core, "wl%d: clk %d\n", wlc_hw->unit, clk);
769 757
770 wlc_hw->phyclk = clk; 758 wlc_hw->phyclk = clk;
771 759
@@ -790,8 +778,8 @@ static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk)
790/* low-level band switch utility routine */ 778/* low-level band switch utility routine */
791static void brcms_c_setxband(struct brcms_hardware *wlc_hw, uint bandunit) 779static void brcms_c_setxband(struct brcms_hardware *wlc_hw, uint bandunit)
792{ 780{
793 BCMMSG(wlc_hw->wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, 781 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: bandunit %d\n", wlc_hw->unit,
794 bandunit); 782 bandunit);
795 783
796 wlc_hw->band = wlc_hw->bandstate[bandunit]; 784 wlc_hw->band = wlc_hw->bandstate[bandunit];
797 785
@@ -819,7 +807,7 @@ static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit)
819 u32 macintmask; 807 u32 macintmask;
820 u32 macctrl; 808 u32 macctrl;
821 809
822 BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); 810 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d\n", wlc_hw->unit);
823 macctrl = bcma_read32(wlc_hw->d11core, 811 macctrl = bcma_read32(wlc_hw->d11core,
824 D11REGOFFS(maccontrol)); 812 D11REGOFFS(maccontrol));
825 WARN_ON((macctrl & MCTL_EN_MAC) != 0); 813 WARN_ON((macctrl & MCTL_EN_MAC) != 0);
@@ -841,9 +829,10 @@ static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit)
841static bool 829static bool
842brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) 830brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
843{ 831{
844 struct sk_buff *p; 832 struct sk_buff *p = NULL;
845 uint queue; 833 uint queue = NFIFO;
846 struct d11txh *txh; 834 struct dma_pub *dma = NULL;
835 struct d11txh *txh = NULL;
847 struct scb *scb = NULL; 836 struct scb *scb = NULL;
848 bool free_pdu; 837 bool free_pdu;
849 int tx_rts, tx_frame_count, tx_rts_count; 838 int tx_rts, tx_frame_count, tx_rts_count;
@@ -854,6 +843,11 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
854 struct ieee80211_tx_info *tx_info; 843 struct ieee80211_tx_info *tx_info;
855 struct ieee80211_tx_rate *txrate; 844 struct ieee80211_tx_rate *txrate;
856 int i; 845 int i;
846 bool fatal = true;
847
848 trace_brcms_txstatus(&wlc->hw->d11core->dev, txs->framelen,
849 txs->frameid, txs->status, txs->lasttxtime,
850 txs->sequence, txs->phyerr, txs->ackphyrxsh);
857 851
858 /* discard intermediate indications for ucode with one legitimate case: 852 /* discard intermediate indications for ucode with one legitimate case:
859 * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange, 853 * e.g. if "useRTS" is set. ucode did a successful rts/cts exchange,
@@ -862,34 +856,36 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
862 */ 856 */
863 if (!(txs->status & TX_STATUS_AMPDU) 857 if (!(txs->status & TX_STATUS_AMPDU)
864 && (txs->status & TX_STATUS_INTERMEDIATE)) { 858 && (txs->status & TX_STATUS_INTERMEDIATE)) {
865 BCMMSG(wlc->wiphy, "INTERMEDIATE but not AMPDU\n"); 859 brcms_dbg_tx(wlc->hw->d11core, "INTERMEDIATE but not AMPDU\n");
866 return false; 860 fatal = false;
861 goto out;
867 } 862 }
868 863
869 queue = txs->frameid & TXFID_QUEUE_MASK; 864 queue = txs->frameid & TXFID_QUEUE_MASK;
870 if (queue >= NFIFO) { 865 if (queue >= NFIFO) {
871 p = NULL; 866 brcms_err(wlc->hw->d11core, "queue %u >= NFIFO\n", queue);
872 goto fatal; 867 goto out;
873 } 868 }
874 869
870 dma = wlc->hw->di[queue];
871
875 p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); 872 p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED);
876 if (p == NULL) 873 if (p == NULL) {
877 goto fatal; 874 brcms_err(wlc->hw->d11core, "dma_getnexttxp returned null!\n");
875 goto out;
876 }
878 877
879 txh = (struct d11txh *) (p->data); 878 txh = (struct d11txh *) (p->data);
880 mcl = le16_to_cpu(txh->MacTxControlLow); 879 mcl = le16_to_cpu(txh->MacTxControlLow);
881 880
882 if (txs->phyerr) { 881 if (txs->phyerr)
883 if (brcm_msg_level & LOG_ERROR_VAL) { 882 brcms_err(wlc->hw->d11core, "phyerr 0x%x, rate 0x%x\n",
884 wiphy_err(wlc->wiphy, "phyerr 0x%x, rate 0x%x\n", 883 txs->phyerr, txh->MainRates);
885 txs->phyerr, txh->MainRates);
886 brcms_c_print_txdesc(txh);
887 }
888 brcms_c_print_txstatus(txs);
889 }
890 884
891 if (txs->frameid != le16_to_cpu(txh->TxFrameID)) 885 if (txs->frameid != le16_to_cpu(txh->TxFrameID)) {
892 goto fatal; 886 brcms_err(wlc->hw->d11core, "frameid != txh->TxFrameID\n");
887 goto out;
888 }
893 tx_info = IEEE80211_SKB_CB(p); 889 tx_info = IEEE80211_SKB_CB(p);
894 h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); 890 h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
895 891
@@ -898,14 +894,24 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
898 894
899 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { 895 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
900 brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); 896 brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs);
901 return false; 897 fatal = false;
898 goto out;
902 } 899 }
903 900
901 /*
902 * brcms_c_ampdu_dotxstatus() will trace tx descriptors for AMPDU
903 * frames; this traces them for the rest.
904 */
905 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, sizeof(*txh));
906
904 supr_status = txs->status & TX_STATUS_SUPR_MASK; 907 supr_status = txs->status & TX_STATUS_SUPR_MASK;
905 if (supr_status == TX_STATUS_SUPR_BADCH) 908 if (supr_status == TX_STATUS_SUPR_BADCH) {
906 BCMMSG(wlc->wiphy, 909 unsigned xfts = le16_to_cpu(txh->XtraFrameTypes);
907 "%s: Pkt tx suppressed, possibly channel %d\n", 910 brcms_dbg_tx(wlc->hw->d11core,
908 __func__, CHSPEC_CHANNEL(wlc->default_bss->chanspec)); 911 "Pkt tx suppressed, dest chan %u, current %d\n",
912 (xfts >> XFTS_CHANNEL_SHIFT) & 0xff,
913 CHSPEC_CHANNEL(wlc->default_bss->chanspec));
914 }
909 915
910 tx_rts = le16_to_cpu(txh->MacTxControlLow) & TXC_SENDRTS; 916 tx_rts = le16_to_cpu(txh->MacTxControlLow) & TXC_SENDRTS;
911 tx_frame_count = 917 tx_frame_count =
@@ -916,7 +922,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
916 lastframe = !ieee80211_has_morefrags(h->frame_control); 922 lastframe = !ieee80211_has_morefrags(h->frame_control);
917 923
918 if (!lastframe) { 924 if (!lastframe) {
919 wiphy_err(wlc->wiphy, "Not last frame!\n"); 925 brcms_err(wlc->hw->d11core, "Not last frame!\n");
920 } else { 926 } else {
921 /* 927 /*
922 * Set information to be consumed by Minstrel ht. 928 * Set information to be consumed by Minstrel ht.
@@ -982,26 +988,37 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
982 totlen = p->len; 988 totlen = p->len;
983 free_pdu = true; 989 free_pdu = true;
984 990
985 brcms_c_txfifo_complete(wlc, queue, 1);
986
987 if (lastframe) { 991 if (lastframe) {
988 /* remove PLCP & Broadcom tx descriptor header */ 992 /* remove PLCP & Broadcom tx descriptor header */
989 skb_pull(p, D11_PHY_HDR_LEN); 993 skb_pull(p, D11_PHY_HDR_LEN);
990 skb_pull(p, D11_TXH_LEN); 994 skb_pull(p, D11_TXH_LEN);
991 ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); 995 ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p);
992 } else { 996 } else {
993 wiphy_err(wlc->wiphy, "%s: Not last frame => not calling " 997 brcms_err(wlc->hw->d11core,
994 "tx_status\n", __func__); 998 "%s: Not last frame => not calling tx_status\n",
999 __func__);
995 } 1000 }
996 1001
997 return false; 1002 fatal = false;
998 1003
999 fatal: 1004 out:
1000 if (p) 1005 if (fatal) {
1001 brcmu_pkt_buf_free_skb(p); 1006 if (txh)
1007 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
1008 sizeof(*txh));
1009 if (p)
1010 brcmu_pkt_buf_free_skb(p);
1011 }
1002 1012
1003 return true; 1013 if (dma && queue < NFIFO) {
1014 u16 ac_queue = brcms_fifo_to_ac(queue);
1015 if (dma->txavail > TX_HEADROOM && queue < TX_BCMC_FIFO &&
1016 ieee80211_queue_stopped(wlc->pub->ieee_hw, ac_queue))
1017 ieee80211_wake_queue(wlc->pub->ieee_hw, ac_queue);
1018 dma_kick_tx(dma);
1019 }
1004 1020
1021 return fatal;
1005} 1022}
1006 1023
1007/* process tx completion events in BMAC 1024/* process tx completion events in BMAC
@@ -1011,7 +1028,6 @@ static bool
1011brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) 1028brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal)
1012{ 1029{
1013 bool morepending = false; 1030 bool morepending = false;
1014 struct brcms_c_info *wlc = wlc_hw->wlc;
1015 struct bcma_device *core; 1031 struct bcma_device *core;
1016 struct tx_status txstatus, *txs; 1032 struct tx_status txstatus, *txs;
1017 u32 s1, s2; 1033 u32 s1, s2;
@@ -1022,19 +1038,23 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal)
1022 */ 1038 */
1023 uint max_tx_num = bound ? TXSBND : -1; 1039 uint max_tx_num = bound ? TXSBND : -1;
1024 1040
1025 BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit);
1026
1027 txs = &txstatus; 1041 txs = &txstatus;
1028 core = wlc_hw->d11core; 1042 core = wlc_hw->d11core;
1029 *fatal = false; 1043 *fatal = false;
1030 s1 = bcma_read32(core, D11REGOFFS(frmtxstatus)); 1044 s1 = bcma_read32(core, D11REGOFFS(frmtxstatus));
1031 while (!(*fatal) 1045 while (!(*fatal)
1032 && (s1 & TXS_V)) { 1046 && (s1 & TXS_V)) {
1047 /* !give others some time to run! */
1048 if (n >= max_tx_num) {
1049 morepending = true;
1050 break;
1051 }
1033 1052
1034 if (s1 == 0xffffffff) { 1053 if (s1 == 0xffffffff) {
1035 wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", 1054 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit,
1036 wlc_hw->unit, __func__); 1055 __func__);
1037 return morepending; 1056 *fatal = true;
1057 return false;
1038 } 1058 }
1039 s2 = bcma_read32(core, D11REGOFFS(frmtxstatus2)); 1059 s2 = bcma_read32(core, D11REGOFFS(frmtxstatus2));
1040 1060
@@ -1046,20 +1066,12 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal)
1046 1066
1047 *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs); 1067 *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs);
1048 1068
1049 /* !give others some time to run! */
1050 if (++n >= max_tx_num)
1051 break;
1052 s1 = bcma_read32(core, D11REGOFFS(frmtxstatus)); 1069 s1 = bcma_read32(core, D11REGOFFS(frmtxstatus));
1070 n++;
1053 } 1071 }
1054 1072
1055 if (*fatal) 1073 if (*fatal)
1056 return 0; 1074 return false;
1057
1058 if (n >= max_tx_num)
1059 morepending = true;
1060
1061 if (!pktq_empty(&wlc->pkt_queue->q))
1062 brcms_c_send_q(wlc);
1063 1075
1064 return morepending; 1076 return morepending;
1065} 1077}
@@ -1112,7 +1124,6 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme)
1112 u16 pio_mhf2 = 0; 1124 u16 pio_mhf2 = 0;
1113 struct brcms_hardware *wlc_hw = wlc->hw; 1125 struct brcms_hardware *wlc_hw = wlc->hw;
1114 uint unit = wlc_hw->unit; 1126 uint unit = wlc_hw->unit;
1115 struct wiphy *wiphy = wlc->wiphy;
1116 1127
1117 /* name and offsets for dma_attach */ 1128 /* name and offsets for dma_attach */
1118 snprintf(name, sizeof(name), "wl%d", unit); 1129 snprintf(name, sizeof(name), "wl%d", unit);
@@ -1125,12 +1136,12 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme)
1125 * TX: TX_AC_BK_FIFO (TX AC Background data packets) 1136 * TX: TX_AC_BK_FIFO (TX AC Background data packets)
1126 * RX: RX_FIFO (RX data packets) 1137 * RX: RX_FIFO (RX data packets)
1127 */ 1138 */
1128 wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, 1139 wlc_hw->di[0] = dma_attach(name, wlc,
1129 (wme ? dmareg(DMA_TX, 0) : 0), 1140 (wme ? dmareg(DMA_TX, 0) : 0),
1130 dmareg(DMA_RX, 0), 1141 dmareg(DMA_RX, 0),
1131 (wme ? NTXD : 0), NRXD, 1142 (wme ? NTXD : 0), NRXD,
1132 RXBUFSZ, -1, NRXBUFPOST, 1143 RXBUFSZ, -1, NRXBUFPOST,
1133 BRCMS_HWRXOFF, &brcm_msg_level); 1144 BRCMS_HWRXOFF);
1134 dma_attach_err |= (NULL == wlc_hw->di[0]); 1145 dma_attach_err |= (NULL == wlc_hw->di[0]);
1135 1146
1136 /* 1147 /*
@@ -1139,10 +1150,9 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme)
1139 * (legacy) TX_DATA_FIFO (TX data packets) 1150 * (legacy) TX_DATA_FIFO (TX data packets)
1140 * RX: UNUSED 1151 * RX: UNUSED
1141 */ 1152 */
1142 wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, 1153 wlc_hw->di[1] = dma_attach(name, wlc,
1143 dmareg(DMA_TX, 1), 0, 1154 dmareg(DMA_TX, 1), 0,
1144 NTXD, 0, 0, -1, 0, 0, 1155 NTXD, 0, 0, -1, 0, 0);
1145 &brcm_msg_level);
1146 dma_attach_err |= (NULL == wlc_hw->di[1]); 1156 dma_attach_err |= (NULL == wlc_hw->di[1]);
1147 1157
1148 /* 1158 /*
@@ -1150,26 +1160,26 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme)
1150 * TX: TX_AC_VI_FIFO (TX AC Video data packets) 1160 * TX: TX_AC_VI_FIFO (TX AC Video data packets)
1151 * RX: UNUSED 1161 * RX: UNUSED
1152 */ 1162 */
1153 wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, 1163 wlc_hw->di[2] = dma_attach(name, wlc,
1154 dmareg(DMA_TX, 2), 0, 1164 dmareg(DMA_TX, 2), 0,
1155 NTXD, 0, 0, -1, 0, 0, 1165 NTXD, 0, 0, -1, 0, 0);
1156 &brcm_msg_level);
1157 dma_attach_err |= (NULL == wlc_hw->di[2]); 1166 dma_attach_err |= (NULL == wlc_hw->di[2]);
1158 /* 1167 /*
1159 * FIFO 3 1168 * FIFO 3
1160 * TX: TX_AC_VO_FIFO (TX AC Voice data packets) 1169 * TX: TX_AC_VO_FIFO (TX AC Voice data packets)
1161 * (legacy) TX_CTL_FIFO (TX control & mgmt packets) 1170 * (legacy) TX_CTL_FIFO (TX control & mgmt packets)
1162 */ 1171 */
1163 wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, 1172 wlc_hw->di[3] = dma_attach(name, wlc,
1164 dmareg(DMA_TX, 3), 1173 dmareg(DMA_TX, 3),
1165 0, NTXD, 0, 0, -1, 1174 0, NTXD, 0, 0, -1,
1166 0, 0, &brcm_msg_level); 1175 0, 0);
1167 dma_attach_err |= (NULL == wlc_hw->di[3]); 1176 dma_attach_err |= (NULL == wlc_hw->di[3]);
1168/* Cleaner to leave this as if with AP defined */ 1177/* Cleaner to leave this as if with AP defined */
1169 1178
1170 if (dma_attach_err) { 1179 if (dma_attach_err) {
1171 wiphy_err(wiphy, "wl%d: wlc_attach: dma_attach failed" 1180 brcms_err(wlc_hw->d11core,
1172 "\n", unit); 1181 "wl%d: wlc_attach: dma_attach failed\n",
1182 unit);
1173 return false; 1183 return false;
1174 } 1184 }
1175 1185
@@ -1503,8 +1513,7 @@ brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset,
1503 u16 mac_m; 1513 u16 mac_m;
1504 u16 mac_h; 1514 u16 mac_h;
1505 1515
1506 BCMMSG(wlc_hw->wlc->wiphy, "wl%d: brcms_b_set_addrmatch\n", 1516 brcms_dbg_rx(core, "wl%d: brcms_b_set_addrmatch\n", wlc_hw->unit);
1507 wlc_hw->unit);
1508 1517
1509 mac_l = addr[0] | (addr[1] << 8); 1518 mac_l = addr[0] | (addr[1] << 8);
1510 mac_m = addr[2] | (addr[3] << 8); 1519 mac_m = addr[2] | (addr[3] << 8);
@@ -1527,7 +1536,7 @@ brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len,
1527 __le32 word_le; 1536 __le32 word_le;
1528 __be32 word_be; 1537 __be32 word_be;
1529 bool be_bit; 1538 bool be_bit;
1530 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 1539 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit);
1531 1540
1532 bcma_write32(core, D11REGOFFS(tplatewrptr), offset); 1541 bcma_write32(core, D11REGOFFS(tplatewrptr), offset);
1533 1542
@@ -1700,8 +1709,8 @@ static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec)
1700{ 1709{
1701 struct brcms_hardware *wlc_hw = wlc->hw; 1710 struct brcms_hardware *wlc_hw = wlc->hw;
1702 1711
1703 BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, 1712 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: bandunit %d\n", wlc_hw->unit,
1704 wlc_hw->band->bandunit); 1713 wlc_hw->band->bandunit);
1705 1714
1706 brcms_c_ucode_bsinit(wlc_hw); 1715 brcms_c_ucode_bsinit(wlc_hw);
1707 1716
@@ -1736,8 +1745,6 @@ static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec)
1736/* Perform a soft reset of the PHY PLL */ 1745/* Perform a soft reset of the PHY PLL */
1737void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw) 1746void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw)
1738{ 1747{
1739 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
1740
1741 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_addr), 1748 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_addr),
1742 ~0, 0); 1749 ~0, 0);
1743 udelay(1); 1750 udelay(1);
@@ -1782,7 +1789,7 @@ void brcms_b_phy_reset(struct brcms_hardware *wlc_hw)
1782 u32 phy_bw_clkbits; 1789 u32 phy_bw_clkbits;
1783 bool phy_in_reset = false; 1790 bool phy_in_reset = false;
1784 1791
1785 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 1792 brcms_dbg_info(wlc_hw->d11core, "wl%d: reset phy\n", wlc_hw->unit);
1786 1793
1787 if (pih == NULL) 1794 if (pih == NULL)
1788 return; 1795 return;
@@ -1916,7 +1923,7 @@ static void brcms_c_get_macaddr(struct brcms_hardware *wlc_hw, u8 etheraddr[ETH_
1916/* power both the pll and external oscillator on/off */ 1923/* power both the pll and external oscillator on/off */
1917static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want) 1924static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want)
1918{ 1925{
1919 BCMMSG(wlc_hw->wlc->wiphy, "wl%d: want %d\n", wlc_hw->unit, want); 1926 brcms_dbg_info(wlc_hw->d11core, "wl%d: want %d\n", wlc_hw->unit, want);
1920 1927
1921 /* 1928 /*
1922 * dont power down if plldown is false or 1929 * dont power down if plldown is false or
@@ -2005,7 +2012,7 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags)
2005 if (flags == BRCMS_USE_COREFLAGS) 2012 if (flags == BRCMS_USE_COREFLAGS)
2006 flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0); 2013 flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0);
2007 2014
2008 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 2015 brcms_dbg_info(wlc_hw->d11core, "wl%d: core reset\n", wlc_hw->unit);
2009 2016
2010 /* request FAST clock if not on */ 2017 /* request FAST clock if not on */
2011 fastclk = wlc_hw->forcefastclk; 2018 fastclk = wlc_hw->forcefastclk;
@@ -2016,13 +2023,13 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags)
2016 if (bcma_core_is_enabled(wlc_hw->d11core)) { 2023 if (bcma_core_is_enabled(wlc_hw->d11core)) {
2017 for (i = 0; i < NFIFO; i++) 2024 for (i = 0; i < NFIFO; i++)
2018 if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) 2025 if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i])))
2019 wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: " 2026 brcms_err(wlc_hw->d11core, "wl%d: %s: "
2020 "dma_txreset[%d]: cannot stop dma\n", 2027 "dma_txreset[%d]: cannot stop dma\n",
2021 wlc_hw->unit, __func__, i); 2028 wlc_hw->unit, __func__, i);
2022 2029
2023 if ((wlc_hw->di[RX_FIFO]) 2030 if ((wlc_hw->di[RX_FIFO])
2024 && (!wlc_dma_rxreset(wlc_hw, RX_FIFO))) 2031 && (!wlc_dma_rxreset(wlc_hw, RX_FIFO)))
2025 wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: dma_rxreset" 2032 brcms_err(wlc_hw->d11core, "wl%d: %s: dma_rxreset"
2026 "[%d]: cannot stop dma\n", 2033 "[%d]: cannot stop dma\n",
2027 wlc_hw->unit, __func__, RX_FIFO); 2034 wlc_hw->unit, __func__, RX_FIFO);
2028 } 2035 }
@@ -2235,7 +2242,7 @@ static void brcms_ucode_write(struct brcms_hardware *wlc_hw,
2235 uint i; 2242 uint i;
2236 uint count; 2243 uint count;
2237 2244
2238 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 2245 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit);
2239 2246
2240 count = (nbytes / sizeof(u32)); 2247 count = (nbytes / sizeof(u32));
2241 2248
@@ -2257,14 +2264,14 @@ static void brcms_ucode_download(struct brcms_hardware *wlc_hw)
2257 if (wlc_hw->ucode_loaded) 2264 if (wlc_hw->ucode_loaded)
2258 return; 2265 return;
2259 2266
2260 if (D11REV_IS(wlc_hw->corerev, 23)) { 2267 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) {
2261 if (BRCMS_ISNPHY(wlc_hw->band)) { 2268 if (BRCMS_ISNPHY(wlc_hw->band)) {
2262 brcms_ucode_write(wlc_hw, ucode->bcm43xx_16_mimo, 2269 brcms_ucode_write(wlc_hw, ucode->bcm43xx_16_mimo,
2263 ucode->bcm43xx_16_mimosz); 2270 ucode->bcm43xx_16_mimosz);
2264 wlc_hw->ucode_loaded = true; 2271 wlc_hw->ucode_loaded = true;
2265 } else 2272 } else
2266 wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in " 2273 brcms_err(wlc_hw->d11core,
2267 "corerev %d\n", 2274 "%s: wl%d: unsupported phy in corerev %d\n",
2268 __func__, wlc_hw->unit, wlc_hw->corerev); 2275 __func__, wlc_hw->unit, wlc_hw->corerev);
2269 } else if (D11REV_IS(wlc_hw->corerev, 24)) { 2276 } else if (D11REV_IS(wlc_hw->corerev, 24)) {
2270 if (BRCMS_ISLCNPHY(wlc_hw->band)) { 2277 if (BRCMS_ISLCNPHY(wlc_hw->band)) {
@@ -2272,8 +2279,8 @@ static void brcms_ucode_download(struct brcms_hardware *wlc_hw)
2272 ucode->bcm43xx_24_lcnsz); 2279 ucode->bcm43xx_24_lcnsz);
2273 wlc_hw->ucode_loaded = true; 2280 wlc_hw->ucode_loaded = true;
2274 } else { 2281 } else {
2275 wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in " 2282 brcms_err(wlc_hw->d11core,
2276 "corerev %d\n", 2283 "%s: wl%d: unsupported phy in corerev %d\n",
2277 __func__, wlc_hw->unit, wlc_hw->corerev); 2284 __func__, wlc_hw->unit, wlc_hw->corerev);
2278 } 2285 }
2279 } 2286 }
@@ -2310,7 +2317,6 @@ static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw)
2310 uint unit; 2317 uint unit;
2311 uint intstatus, idx; 2318 uint intstatus, idx;
2312 struct bcma_device *core = wlc_hw->d11core; 2319 struct bcma_device *core = wlc_hw->d11core;
2313 struct wiphy *wiphy = wlc_hw->wlc->wiphy;
2314 2320
2315 unit = wlc_hw->unit; 2321 unit = wlc_hw->unit;
2316 2322
@@ -2323,39 +2329,39 @@ static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw)
2323 if (!intstatus) 2329 if (!intstatus)
2324 continue; 2330 continue;
2325 2331
2326 BCMMSG(wlc_hw->wlc->wiphy, "wl%d: intstatus%d 0x%x\n", 2332 brcms_dbg_int(core, "wl%d: intstatus%d 0x%x\n",
2327 unit, idx, intstatus); 2333 unit, idx, intstatus);
2328 2334
2329 if (intstatus & I_RO) { 2335 if (intstatus & I_RO) {
2330 wiphy_err(wiphy, "wl%d: fifo %d: receive fifo " 2336 brcms_err(core, "wl%d: fifo %d: receive fifo "
2331 "overflow\n", unit, idx); 2337 "overflow\n", unit, idx);
2332 fatal = true; 2338 fatal = true;
2333 } 2339 }
2334 2340
2335 if (intstatus & I_PC) { 2341 if (intstatus & I_PC) {
2336 wiphy_err(wiphy, "wl%d: fifo %d: descriptor error\n", 2342 brcms_err(core, "wl%d: fifo %d: descriptor error\n",
2337 unit, idx); 2343 unit, idx);
2338 fatal = true; 2344 fatal = true;
2339 } 2345 }
2340 2346
2341 if (intstatus & I_PD) { 2347 if (intstatus & I_PD) {
2342 wiphy_err(wiphy, "wl%d: fifo %d: data error\n", unit, 2348 brcms_err(core, "wl%d: fifo %d: data error\n", unit,
2343 idx); 2349 idx);
2344 fatal = true; 2350 fatal = true;
2345 } 2351 }
2346 2352
2347 if (intstatus & I_DE) { 2353 if (intstatus & I_DE) {
2348 wiphy_err(wiphy, "wl%d: fifo %d: descriptor protocol " 2354 brcms_err(core, "wl%d: fifo %d: descriptor protocol "
2349 "error\n", unit, idx); 2355 "error\n", unit, idx);
2350 fatal = true; 2356 fatal = true;
2351 } 2357 }
2352 2358
2353 if (intstatus & I_RU) 2359 if (intstatus & I_RU)
2354 wiphy_err(wiphy, "wl%d: fifo %d: receive descriptor " 2360 brcms_err(core, "wl%d: fifo %d: receive descriptor "
2355 "underflow\n", idx, unit); 2361 "underflow\n", idx, unit);
2356 2362
2357 if (intstatus & I_XU) { 2363 if (intstatus & I_XU) {
2358 wiphy_err(wiphy, "wl%d: fifo %d: transmit fifo " 2364 brcms_err(core, "wl%d: fifo %d: transmit fifo "
2359 "underflow\n", idx, unit); 2365 "underflow\n", idx, unit);
2360 fatal = true; 2366 fatal = true;
2361 } 2367 }
@@ -2516,13 +2522,13 @@ static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr)
2516{ 2522{
2517 struct brcms_hardware *wlc_hw = wlc->hw; 2523 struct brcms_hardware *wlc_hw = wlc->hw;
2518 struct bcma_device *core = wlc_hw->d11core; 2524 struct bcma_device *core = wlc_hw->d11core;
2519 u32 macintstatus; 2525 u32 macintstatus, mask;
2520 2526
2521 /* macintstatus includes a DMA interrupt summary bit */ 2527 /* macintstatus includes a DMA interrupt summary bit */
2522 macintstatus = bcma_read32(core, D11REGOFFS(macintstatus)); 2528 macintstatus = bcma_read32(core, D11REGOFFS(macintstatus));
2529 mask = in_isr ? wlc->macintmask : wlc->defmacintmask;
2523 2530
2524 BCMMSG(wlc->wiphy, "wl%d: macintstatus: 0x%x\n", wlc_hw->unit, 2531 trace_brcms_macintstatus(&core->dev, in_isr, macintstatus, mask);
2525 macintstatus);
2526 2532
2527 /* detect cardbus removed, in power down(suspend) and in reset */ 2533 /* detect cardbus removed, in power down(suspend) and in reset */
2528 if (brcms_deviceremoved(wlc)) 2534 if (brcms_deviceremoved(wlc))
@@ -2535,16 +2541,12 @@ static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr)
2535 return 0; 2541 return 0;
2536 2542
2537 /* defer unsolicited interrupts */ 2543 /* defer unsolicited interrupts */
2538 macintstatus &= (in_isr ? wlc->macintmask : wlc->defmacintmask); 2544 macintstatus &= mask;
2539 2545
2540 /* if not for us */ 2546 /* if not for us */
2541 if (macintstatus == 0) 2547 if (macintstatus == 0)
2542 return 0; 2548 return 0;
2543 2549
2544 /* interrupts are already turned off for CFE build
2545 * Caution: For CFE Turning off the interrupts again has some undesired
2546 * consequences
2547 */
2548 /* turn off the interrupts */ 2550 /* turn off the interrupts */
2549 bcma_write32(core, D11REGOFFS(macintmask), 0); 2551 bcma_write32(core, D11REGOFFS(macintmask), 0);
2550 (void)bcma_read32(core, D11REGOFFS(macintmask)); 2552 (void)bcma_read32(core, D11REGOFFS(macintmask));
@@ -2587,33 +2589,31 @@ bool brcms_c_intrsupd(struct brcms_c_info *wlc)
2587 2589
2588/* 2590/*
2589 * First-level interrupt processing. 2591 * First-level interrupt processing.
2590 * Return true if this was our interrupt, false otherwise. 2592 * Return true if this was our interrupt
2591 * *wantdpc will be set to true if further brcms_c_dpc() processing is required, 2593 * and if further brcms_c_dpc() processing is required,
2592 * false otherwise. 2594 * false otherwise.
2593 */ 2595 */
2594bool brcms_c_isr(struct brcms_c_info *wlc, bool *wantdpc) 2596bool brcms_c_isr(struct brcms_c_info *wlc)
2595{ 2597{
2596 struct brcms_hardware *wlc_hw = wlc->hw; 2598 struct brcms_hardware *wlc_hw = wlc->hw;
2597 u32 macintstatus; 2599 u32 macintstatus;
2598 2600
2599 *wantdpc = false;
2600
2601 if (!wlc_hw->up || !wlc->macintmask) 2601 if (!wlc_hw->up || !wlc->macintmask)
2602 return false; 2602 return false;
2603 2603
2604 /* read and clear macintstatus and intstatus registers */ 2604 /* read and clear macintstatus and intstatus registers */
2605 macintstatus = wlc_intstatus(wlc, true); 2605 macintstatus = wlc_intstatus(wlc, true);
2606 2606
2607 if (macintstatus == 0xffffffff) 2607 if (macintstatus == 0xffffffff) {
2608 wiphy_err(wlc->wiphy, "DEVICEREMOVED detected in the ISR code" 2608 brcms_err(wlc_hw->d11core,
2609 " path\n"); 2609 "DEVICEREMOVED detected in the ISR code path\n");
2610 return false;
2611 }
2610 2612
2611 /* it is not for us */ 2613 /* it is not for us */
2612 if (macintstatus == 0) 2614 if (macintstatus == 0)
2613 return false; 2615 return false;
2614 2616
2615 *wantdpc = true;
2616
2617 /* save interrupt status bits */ 2617 /* save interrupt status bits */
2618 wlc->macintstatus = macintstatus; 2618 wlc->macintstatus = macintstatus;
2619 2619
@@ -2626,10 +2626,9 @@ void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc)
2626 struct brcms_hardware *wlc_hw = wlc->hw; 2626 struct brcms_hardware *wlc_hw = wlc->hw;
2627 struct bcma_device *core = wlc_hw->d11core; 2627 struct bcma_device *core = wlc_hw->d11core;
2628 u32 mc, mi; 2628 u32 mc, mi;
2629 struct wiphy *wiphy = wlc->wiphy;
2630 2629
2631 BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, 2630 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit,
2632 wlc_hw->band->bandunit); 2631 wlc_hw->band->bandunit);
2633 2632
2634 /* 2633 /*
2635 * Track overlapping suspend requests 2634 * Track overlapping suspend requests
@@ -2644,7 +2643,7 @@ void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc)
2644 mc = bcma_read32(core, D11REGOFFS(maccontrol)); 2643 mc = bcma_read32(core, D11REGOFFS(maccontrol));
2645 2644
2646 if (mc == 0xffffffff) { 2645 if (mc == 0xffffffff) {
2647 wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, 2646 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit,
2648 __func__); 2647 __func__);
2649 brcms_down(wlc->wl); 2648 brcms_down(wlc->wl);
2650 return; 2649 return;
@@ -2655,7 +2654,7 @@ void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc)
2655 2654
2656 mi = bcma_read32(core, D11REGOFFS(macintstatus)); 2655 mi = bcma_read32(core, D11REGOFFS(macintstatus));
2657 if (mi == 0xffffffff) { 2656 if (mi == 0xffffffff) {
2658 wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, 2657 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit,
2659 __func__); 2658 __func__);
2660 brcms_down(wlc->wl); 2659 brcms_down(wlc->wl);
2661 return; 2660 return;
@@ -2668,10 +2667,10 @@ void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc)
2668 BRCMS_MAX_MAC_SUSPEND); 2667 BRCMS_MAX_MAC_SUSPEND);
2669 2668
2670 if (!(bcma_read32(core, D11REGOFFS(macintstatus)) & MI_MACSSPNDD)) { 2669 if (!(bcma_read32(core, D11REGOFFS(macintstatus)) & MI_MACSSPNDD)) {
2671 wiphy_err(wiphy, "wl%d: wlc_suspend_mac_and_wait: waited %d uS" 2670 brcms_err(core, "wl%d: wlc_suspend_mac_and_wait: waited %d uS"
2672 " and MI_MACSSPNDD is still not on.\n", 2671 " and MI_MACSSPNDD is still not on.\n",
2673 wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND); 2672 wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND);
2674 wiphy_err(wiphy, "wl%d: psmdebug 0x%08x, phydebug 0x%08x, " 2673 brcms_err(core, "wl%d: psmdebug 0x%08x, phydebug 0x%08x, "
2675 "psm_brc 0x%04x\n", wlc_hw->unit, 2674 "psm_brc 0x%04x\n", wlc_hw->unit,
2676 bcma_read32(core, D11REGOFFS(psmdebug)), 2675 bcma_read32(core, D11REGOFFS(psmdebug)),
2677 bcma_read32(core, D11REGOFFS(phydebug)), 2676 bcma_read32(core, D11REGOFFS(phydebug)),
@@ -2680,7 +2679,7 @@ void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc)
2680 2679
2681 mc = bcma_read32(core, D11REGOFFS(maccontrol)); 2680 mc = bcma_read32(core, D11REGOFFS(maccontrol));
2682 if (mc == 0xffffffff) { 2681 if (mc == 0xffffffff) {
2683 wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, 2682 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit,
2684 __func__); 2683 __func__);
2685 brcms_down(wlc->wl); 2684 brcms_down(wlc->wl);
2686 return; 2685 return;
@@ -2696,8 +2695,8 @@ void brcms_c_enable_mac(struct brcms_c_info *wlc)
2696 struct bcma_device *core = wlc_hw->d11core; 2695 struct bcma_device *core = wlc_hw->d11core;
2697 u32 mc, mi; 2696 u32 mc, mi;
2698 2697
2699 BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, 2698 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit,
2700 wlc->band->bandunit); 2699 wlc->band->bandunit);
2701 2700
2702 /* 2701 /*
2703 * Track overlapping suspend requests 2702 * Track overlapping suspend requests
@@ -2740,8 +2739,6 @@ static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw)
2740 u32 w, val; 2739 u32 w, val;
2741 struct wiphy *wiphy = wlc_hw->wlc->wiphy; 2740 struct wiphy *wiphy = wlc_hw->wlc->wiphy;
2742 2741
2743 BCMMSG(wiphy, "wl%d\n", wlc_hw->unit);
2744
2745 /* Validate dchip register access */ 2742 /* Validate dchip register access */
2746 2743
2747 bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); 2744 bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0);
@@ -2802,7 +2799,7 @@ void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on)
2802 struct bcma_device *core = wlc_hw->d11core; 2799 struct bcma_device *core = wlc_hw->d11core;
2803 u32 tmp; 2800 u32 tmp;
2804 2801
2805 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 2802 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit);
2806 2803
2807 tmp = 0; 2804 tmp = 0;
2808 2805
@@ -2818,8 +2815,8 @@ void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on)
2818 2815
2819 tmp = bcma_read32(core, D11REGOFFS(clk_ctl_st)); 2816 tmp = bcma_read32(core, D11REGOFFS(clk_ctl_st));
2820 if ((tmp & CCS_ERSRC_AVAIL_HT) != CCS_ERSRC_AVAIL_HT) 2817 if ((tmp & CCS_ERSRC_AVAIL_HT) != CCS_ERSRC_AVAIL_HT)
2821 wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on PHY" 2818 brcms_err(core, "%s: turn on PHY PLL failed\n",
2822 " PLL failed\n", __func__); 2819 __func__);
2823 } else { 2820 } else {
2824 bcma_set32(core, D11REGOFFS(clk_ctl_st), 2821 bcma_set32(core, D11REGOFFS(clk_ctl_st),
2825 tmp | CCS_ERSRC_REQ_D11PLL | 2822 tmp | CCS_ERSRC_REQ_D11PLL |
@@ -2835,8 +2832,8 @@ void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on)
2835 (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) 2832 (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL))
2836 != 2833 !=
2837 (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) 2834 (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL))
2838 wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on " 2835 brcms_err(core, "%s: turn on PHY PLL failed\n",
2839 "PHY PLL failed\n", __func__); 2836 __func__);
2840 } 2837 }
2841 } else { 2838 } else {
2842 /* 2839 /*
@@ -2854,7 +2851,7 @@ static void brcms_c_coredisable(struct brcms_hardware *wlc_hw)
2854{ 2851{
2855 bool dev_gone; 2852 bool dev_gone;
2856 2853
2857 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 2854 brcms_dbg_info(wlc_hw->d11core, "wl%d: disable core\n", wlc_hw->unit);
2858 2855
2859 dev_gone = brcms_deviceremoved(wlc_hw->wlc); 2856 dev_gone = brcms_deviceremoved(wlc_hw->wlc);
2860 2857
@@ -2884,12 +2881,14 @@ static void brcms_c_flushqueues(struct brcms_c_info *wlc)
2884 uint i; 2881 uint i;
2885 2882
2886 /* free any posted tx packets */ 2883 /* free any posted tx packets */
2887 for (i = 0; i < NFIFO; i++) 2884 for (i = 0; i < NFIFO; i++) {
2888 if (wlc_hw->di[i]) { 2885 if (wlc_hw->di[i]) {
2889 dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL); 2886 dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL);
2890 wlc->core->txpktpend[i] = 0; 2887 if (i < TX_BCMC_FIFO)
2891 BCMMSG(wlc->wiphy, "pktpend fifo %d clrd\n", i); 2888 ieee80211_wake_queue(wlc->pub->ieee_hw,
2889 brcms_fifo_to_ac(i));
2892 } 2890 }
2891 }
2893 2892
2894 /* free any posted rx packets */ 2893 /* free any posted rx packets */
2895 dma_rxreclaim(wlc_hw->di[RX_FIFO]); 2894 dma_rxreclaim(wlc_hw->di[RX_FIFO]);
@@ -2921,7 +2920,7 @@ brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v,
2921 if (offset & 2) 2920 if (offset & 2)
2922 objoff += 2; 2921 objoff += 2;
2923 2922
2924 bcma_write16(core, objoff, v); 2923 bcma_wflush16(core, objoff, v);
2925} 2924}
2926 2925
2927/* 2926/*
@@ -3109,7 +3108,7 @@ static void brcms_c_statsupd(struct brcms_c_info *wlc)
3109 /* check for rx fifo 0 overflow */ 3108 /* check for rx fifo 0 overflow */
3110 delta = (u16) (wlc->core->macstat_snapshot->rxf0ovfl - rxf0ovfl); 3109 delta = (u16) (wlc->core->macstat_snapshot->rxf0ovfl - rxf0ovfl);
3111 if (delta) 3110 if (delta)
3112 wiphy_err(wlc->wiphy, "wl%d: %u rx fifo 0 overflows!\n", 3111 brcms_err(wlc->hw->d11core, "wl%d: %u rx fifo 0 overflows!\n",
3113 wlc->pub->unit, delta); 3112 wlc->pub->unit, delta);
3114 3113
3115 /* check for tx fifo underflows */ 3114 /* check for tx fifo underflows */
@@ -3118,8 +3117,9 @@ static void brcms_c_statsupd(struct brcms_c_info *wlc)
3118 (u16) (wlc->core->macstat_snapshot->txfunfl[i] - 3117 (u16) (wlc->core->macstat_snapshot->txfunfl[i] -
3119 txfunfl[i]); 3118 txfunfl[i]);
3120 if (delta) 3119 if (delta)
3121 wiphy_err(wlc->wiphy, "wl%d: %u tx fifo %d underflows!" 3120 brcms_err(wlc->hw->d11core,
3122 "\n", wlc->pub->unit, delta, i); 3121 "wl%d: %u tx fifo %d underflows!\n",
3122 wlc->pub->unit, delta, i);
3123 } 3123 }
3124#endif /* DEBUG */ 3124#endif /* DEBUG */
3125 3125
@@ -3132,8 +3132,6 @@ static void brcms_c_statsupd(struct brcms_c_info *wlc)
3132 3132
3133static void brcms_b_reset(struct brcms_hardware *wlc_hw) 3133static void brcms_b_reset(struct brcms_hardware *wlc_hw)
3134{ 3134{
3135 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
3136
3137 /* reset the core */ 3135 /* reset the core */
3138 if (!brcms_deviceremoved(wlc_hw->wlc)) 3136 if (!brcms_deviceremoved(wlc_hw->wlc))
3139 brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); 3137 brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS);
@@ -3144,7 +3142,7 @@ static void brcms_b_reset(struct brcms_hardware *wlc_hw)
3144 3142
3145void brcms_c_reset(struct brcms_c_info *wlc) 3143void brcms_c_reset(struct brcms_c_info *wlc)
3146{ 3144{
3147 BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); 3145 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit);
3148 3146
3149 /* slurp up hw mac counters before core reset */ 3147 /* slurp up hw mac counters before core reset */
3150 brcms_c_statsupd(wlc); 3148 brcms_c_statsupd(wlc);
@@ -3189,10 +3187,9 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc)
3189 bool fifosz_fixup = false; 3187 bool fifosz_fixup = false;
3190 int err = 0; 3188 int err = 0;
3191 u16 buf[NFIFO]; 3189 u16 buf[NFIFO];
3192 struct wiphy *wiphy = wlc->wiphy;
3193 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; 3190 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode;
3194 3191
3195 BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); 3192 brcms_dbg_info(core, "wl%d: core init\n", wlc_hw->unit);
3196 3193
3197 /* reset PSM */ 3194 /* reset PSM */
3198 brcms_b_mctrl(wlc_hw, ~0, (MCTL_IHR_EN | MCTL_PSM_JMP_0 | MCTL_WAKE)); 3195 brcms_b_mctrl(wlc_hw, ~0, (MCTL_IHR_EN | MCTL_PSM_JMP_0 | MCTL_WAKE));
@@ -3212,29 +3209,29 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc)
3212 SPINWAIT(((bcma_read32(core, D11REGOFFS(macintstatus)) & 3209 SPINWAIT(((bcma_read32(core, D11REGOFFS(macintstatus)) &
3213 MI_MACSSPNDD) == 0), 1000 * 1000); 3210 MI_MACSSPNDD) == 0), 1000 * 1000);
3214 if ((bcma_read32(core, D11REGOFFS(macintstatus)) & MI_MACSSPNDD) == 0) 3211 if ((bcma_read32(core, D11REGOFFS(macintstatus)) & MI_MACSSPNDD) == 0)
3215 wiphy_err(wiphy, "wl%d: wlc_coreinit: ucode did not self-" 3212 brcms_err(core, "wl%d: wlc_coreinit: ucode did not self-"
3216 "suspend!\n", wlc_hw->unit); 3213 "suspend!\n", wlc_hw->unit);
3217 3214
3218 brcms_c_gpio_init(wlc); 3215 brcms_c_gpio_init(wlc);
3219 3216
3220 sflags = bcma_aread32(core, BCMA_IOST); 3217 sflags = bcma_aread32(core, BCMA_IOST);
3221 3218
3222 if (D11REV_IS(wlc_hw->corerev, 23)) { 3219 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) {
3223 if (BRCMS_ISNPHY(wlc_hw->band)) 3220 if (BRCMS_ISNPHY(wlc_hw->band))
3224 brcms_c_write_inits(wlc_hw, ucode->d11n0initvals16); 3221 brcms_c_write_inits(wlc_hw, ucode->d11n0initvals16);
3225 else 3222 else
3226 wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" 3223 brcms_err(core, "%s: wl%d: unsupported phy in corerev"
3227 " %d\n", __func__, wlc_hw->unit, 3224 " %d\n", __func__, wlc_hw->unit,
3228 wlc_hw->corerev); 3225 wlc_hw->corerev);
3229 } else if (D11REV_IS(wlc_hw->corerev, 24)) { 3226 } else if (D11REV_IS(wlc_hw->corerev, 24)) {
3230 if (BRCMS_ISLCNPHY(wlc_hw->band)) 3227 if (BRCMS_ISLCNPHY(wlc_hw->band))
3231 brcms_c_write_inits(wlc_hw, ucode->d11lcn0initvals24); 3228 brcms_c_write_inits(wlc_hw, ucode->d11lcn0initvals24);
3232 else 3229 else
3233 wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev" 3230 brcms_err(core, "%s: wl%d: unsupported phy in corerev"
3234 " %d\n", __func__, wlc_hw->unit, 3231 " %d\n", __func__, wlc_hw->unit,
3235 wlc_hw->corerev); 3232 wlc_hw->corerev);
3236 } else { 3233 } else {
3237 wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n", 3234 brcms_err(core, "%s: wl%d: unsupported corerev %d\n",
3238 __func__, wlc_hw->unit, wlc_hw->corerev); 3235 __func__, wlc_hw->unit, wlc_hw->corerev);
3239 } 3236 }
3240 3237
@@ -3276,7 +3273,7 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc)
3276 err = -1; 3273 err = -1;
3277 } 3274 }
3278 if (err != 0) 3275 if (err != 0)
3279 wiphy_err(wiphy, "wlc_coreinit: txfifo mismatch: ucode size %d" 3276 brcms_err(core, "wlc_coreinit: txfifo mismatch: ucode size %d"
3280 " driver size %d index %d\n", buf[i], 3277 " driver size %d index %d\n", buf[i],
3281 wlc_hw->xmtfifo_sz[i], i); 3278 wlc_hw->xmtfifo_sz[i], i);
3282 3279
@@ -3359,8 +3356,6 @@ static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec) {
3359 bool fastclk; 3356 bool fastclk;
3360 struct brcms_c_info *wlc = wlc_hw->wlc; 3357 struct brcms_c_info *wlc = wlc_hw->wlc;
3361 3358
3362 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
3363
3364 /* request FAST clock if not on */ 3359 /* request FAST clock if not on */
3365 fastclk = wlc_hw->forcefastclk; 3360 fastclk = wlc_hw->forcefastclk;
3366 if (!fastclk) 3361 if (!fastclk)
@@ -3453,7 +3448,7 @@ static void brcms_c_rate_lookup_init(struct brcms_c_info *wlc,
3453 rate = (rateset->rates[i] & BRCMS_RATE_MASK); 3448 rate = (rateset->rates[i] & BRCMS_RATE_MASK);
3454 3449
3455 if (rate > BRCM_MAXRATE) { 3450 if (rate > BRCM_MAXRATE) {
3456 wiphy_err(wlc->wiphy, "brcms_c_rate_lookup_init: " 3451 brcms_err(wlc->hw->d11core, "brcms_c_rate_lookup_init: "
3457 "invalid rate 0x%X in rate set\n", 3452 "invalid rate 0x%X in rate set\n",
3458 rateset->rates[i]); 3453 rateset->rates[i]);
3459 continue; 3454 continue;
@@ -3529,7 +3524,6 @@ static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc,
3529 uint parkband; 3524 uint parkband;
3530 uint i, band_order[2]; 3525 uint i, band_order[2];
3531 3526
3532 BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
3533 /* 3527 /*
3534 * We might have been bandlocked during down and the chip 3528 * We might have been bandlocked during down and the chip
3535 * power-cycled (hibernate). Figure out the right band to park on 3529 * power-cycled (hibernate). Figure out the right band to park on
@@ -3710,8 +3704,8 @@ static void brcms_c_set_ratetable(struct brcms_c_info *wlc)
3710/* band-specific init */ 3704/* band-specific init */
3711static void brcms_c_bsinit(struct brcms_c_info *wlc) 3705static void brcms_c_bsinit(struct brcms_c_info *wlc)
3712{ 3706{
3713 BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", 3707 brcms_dbg_info(wlc->hw->d11core, "wl%d: bandunit %d\n",
3714 wlc->pub->unit, wlc->band->bandunit); 3708 wlc->pub->unit, wlc->band->bandunit);
3715 3709
3716 /* write ucode ACK/CTS rate table */ 3710 /* write ucode ACK/CTS rate table */
3717 brcms_c_set_ratetable(wlc); 3711 brcms_c_set_ratetable(wlc);
@@ -3734,7 +3728,8 @@ brcms_c_duty_cycle_set(struct brcms_c_info *wlc, int duty_cycle, bool isOFDM,
3734 isOFDM ? M_TX_IDLE_BUSY_RATIO_X_16_OFDM : 3728 isOFDM ? M_TX_IDLE_BUSY_RATIO_X_16_OFDM :
3735 M_TX_IDLE_BUSY_RATIO_X_16_CCK; 3729 M_TX_IDLE_BUSY_RATIO_X_16_CCK;
3736 if (duty_cycle > 100 || duty_cycle < 0) { 3730 if (duty_cycle > 100 || duty_cycle < 0) {
3737 wiphy_err(wlc->wiphy, "wl%d: duty cycle value off limit\n", 3731 brcms_err(wlc->hw->d11core,
3732 "wl%d: duty cycle value off limit\n",
3738 wlc->pub->unit); 3733 wlc->pub->unit);
3739 return -EINVAL; 3734 return -EINVAL;
3740 } 3735 }
@@ -3752,40 +3747,6 @@ brcms_c_duty_cycle_set(struct brcms_c_info *wlc, int duty_cycle, bool isOFDM,
3752 return 0; 3747 return 0;
3753} 3748}
3754 3749
3755/*
3756 * Initialize the base precedence map for dequeueing
3757 * from txq based on WME settings
3758 */
3759static void brcms_c_tx_prec_map_init(struct brcms_c_info *wlc)
3760{
3761 wlc->tx_prec_map = BRCMS_PREC_BMP_ALL;
3762 memset(wlc->fifo2prec_map, 0, NFIFO * sizeof(u16));
3763
3764 wlc->fifo2prec_map[TX_AC_BK_FIFO] = BRCMS_PREC_BMP_AC_BK;
3765 wlc->fifo2prec_map[TX_AC_BE_FIFO] = BRCMS_PREC_BMP_AC_BE;
3766 wlc->fifo2prec_map[TX_AC_VI_FIFO] = BRCMS_PREC_BMP_AC_VI;
3767 wlc->fifo2prec_map[TX_AC_VO_FIFO] = BRCMS_PREC_BMP_AC_VO;
3768}
3769
3770static void
3771brcms_c_txflowcontrol_signal(struct brcms_c_info *wlc,
3772 struct brcms_txq_info *qi, bool on, int prio)
3773{
3774 /* transmit flowcontrol is not yet implemented */
3775}
3776
3777static void brcms_c_txflowcontrol_reset(struct brcms_c_info *wlc)
3778{
3779 struct brcms_txq_info *qi;
3780
3781 for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) {
3782 if (qi->stopped) {
3783 brcms_c_txflowcontrol_signal(wlc, qi, OFF, ALLPRIO);
3784 qi->stopped = 0;
3785 }
3786 }
3787}
3788
3789/* push sw hps and wake state through hardware */ 3750/* push sw hps and wake state through hardware */
3790static void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc) 3751static void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc)
3791{ 3752{
@@ -3795,7 +3756,8 @@ static void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc)
3795 3756
3796 hps = brcms_c_ps_allowed(wlc); 3757 hps = brcms_c_ps_allowed(wlc);
3797 3758
3798 BCMMSG(wlc->wiphy, "wl%d: hps %d\n", wlc->pub->unit, hps); 3759 brcms_dbg_mac80211(wlc->hw->d11core, "wl%d: hps %d\n", wlc->pub->unit,
3760 hps);
3799 3761
3800 v1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); 3762 v1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol));
3801 v2 = MCTL_WAKE; 3763 v2 = MCTL_WAKE;
@@ -3881,7 +3843,8 @@ brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec,
3881{ 3843{
3882 uint bandunit; 3844 uint bandunit;
3883 3845
3884 BCMMSG(wlc_hw->wlc->wiphy, "wl%d: 0x%x\n", wlc_hw->unit, chanspec); 3846 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: 0x%x\n", wlc_hw->unit,
3847 chanspec);
3885 3848
3886 wlc_hw->chanspec = chanspec; 3849 wlc_hw->chanspec = chanspec;
3887 3850
@@ -3942,7 +3905,7 @@ static void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec)
3942 u16 old_chanspec = wlc->chanspec; 3905 u16 old_chanspec = wlc->chanspec;
3943 3906
3944 if (!brcms_c_valid_chanspec_db(wlc->cmi, chanspec)) { 3907 if (!brcms_c_valid_chanspec_db(wlc->cmi, chanspec)) {
3945 wiphy_err(wlc->wiphy, "wl%d: %s: Bad channel %d\n", 3908 brcms_err(wlc->hw->d11core, "wl%d: %s: Bad channel %d\n",
3946 wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec)); 3909 wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec));
3947 return; 3910 return;
3948 } 3911 }
@@ -3953,8 +3916,8 @@ static void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec)
3953 if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) { 3916 if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) {
3954 switchband = true; 3917 switchband = true;
3955 if (wlc->bandlocked) { 3918 if (wlc->bandlocked) {
3956 wiphy_err(wlc->wiphy, "wl%d: %s: chspec %d " 3919 brcms_err(wlc->hw->d11core,
3957 "band is locked!\n", 3920 "wl%d: %s: chspec %d band is locked!\n",
3958 wlc->pub->unit, __func__, 3921 wlc->pub->unit, __func__,
3959 CHSPEC_CHANNEL(chanspec)); 3922 CHSPEC_CHANNEL(chanspec));
3960 return; 3923 return;
@@ -4018,6 +3981,10 @@ void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc,
4018 */ 3981 */
4019void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val) 3982void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val)
4020{ 3983{
3984 /*
3985 * Cannot use brcms_dbg_* here because this function is called
3986 * before wlc is sufficiently initialized.
3987 */
4021 BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val); 3988 BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val);
4022 3989
4023 switch (idx) { 3990 switch (idx) {
@@ -4090,8 +4057,8 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci,
4090 4057
4091 /* Only apply params if the core is out of reset and has clocks */ 4058 /* Only apply params if the core is out of reset and has clocks */
4092 if (!wlc->clk) { 4059 if (!wlc->clk) {
4093 wiphy_err(wlc->wiphy, "wl%d: %s : no-clock\n", wlc->pub->unit, 4060 brcms_err(wlc->hw->d11core, "wl%d: %s : no-clock\n",
4094 __func__); 4061 wlc->pub->unit, __func__);
4095 return; 4062 return;
4096 } 4063 }
4097 4064
@@ -4109,7 +4076,7 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci,
4109 4076
4110 if (acp_shm.aifs < EDCF_AIFSN_MIN 4077 if (acp_shm.aifs < EDCF_AIFSN_MIN
4111 || acp_shm.aifs > EDCF_AIFSN_MAX) { 4078 || acp_shm.aifs > EDCF_AIFSN_MAX) {
4112 wiphy_err(wlc->wiphy, "wl%d: edcf_setparams: bad " 4079 brcms_err(wlc->hw->d11core, "wl%d: edcf_setparams: bad "
4113 "aifs %d\n", wlc->pub->unit, acp_shm.aifs); 4080 "aifs %d\n", wlc->pub->unit, acp_shm.aifs);
4114 } else { 4081 } else {
4115 acp_shm.cwmin = params->cw_min; 4082 acp_shm.cwmin = params->cw_min;
@@ -4224,8 +4191,8 @@ static void brcms_c_radio_timer(void *arg)
4224 struct brcms_c_info *wlc = (struct brcms_c_info *) arg; 4191 struct brcms_c_info *wlc = (struct brcms_c_info *) arg;
4225 4192
4226 if (brcms_deviceremoved(wlc)) { 4193 if (brcms_deviceremoved(wlc)) {
4227 wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, 4194 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n",
4228 __func__); 4195 wlc->pub->unit, __func__);
4229 brcms_down(wlc->wl); 4196 brcms_down(wlc->wl);
4230 return; 4197 return;
4231 } 4198 }
@@ -4238,8 +4205,6 @@ static void brcms_b_watchdog(struct brcms_c_info *wlc)
4238{ 4205{
4239 struct brcms_hardware *wlc_hw = wlc->hw; 4206 struct brcms_hardware *wlc_hw = wlc->hw;
4240 4207
4241 BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit);
4242
4243 if (!wlc_hw->up) 4208 if (!wlc_hw->up)
4244 return; 4209 return;
4245 4210
@@ -4258,14 +4223,14 @@ static void brcms_b_watchdog(struct brcms_c_info *wlc)
4258/* common watchdog code */ 4223/* common watchdog code */
4259static void brcms_c_watchdog(struct brcms_c_info *wlc) 4224static void brcms_c_watchdog(struct brcms_c_info *wlc)
4260{ 4225{
4261 BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); 4226 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit);
4262 4227
4263 if (!wlc->pub->up) 4228 if (!wlc->pub->up)
4264 return; 4229 return;
4265 4230
4266 if (brcms_deviceremoved(wlc)) { 4231 if (brcms_deviceremoved(wlc)) {
4267 wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, 4232 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n",
4268 __func__); 4233 wlc->pub->unit, __func__);
4269 brcms_down(wlc->wl); 4234 brcms_down(wlc->wl);
4270 return; 4235 return;
4271 } 4236 }
@@ -4437,13 +4402,13 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core,
4437 struct ssb_sprom *sprom = &core->bus->sprom; 4402 struct ssb_sprom *sprom = &core->bus->sprom;
4438 4403
4439 if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) 4404 if (core->bus->hosttype == BCMA_HOSTTYPE_PCI)
4440 BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, 4405 brcms_dbg_info(core, "wl%d: vendor 0x%x device 0x%x\n", unit,
4441 pcidev->vendor, 4406 pcidev->vendor,
4442 pcidev->device); 4407 pcidev->device);
4443 else 4408 else
4444 BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, 4409 brcms_dbg_info(core, "wl%d: vendor 0x%x device 0x%x\n", unit,
4445 core->bus->boardinfo.vendor, 4410 core->bus->boardinfo.vendor,
4446 core->bus->boardinfo.type); 4411 core->bus->boardinfo.type);
4447 4412
4448 wme = true; 4413 wme = true;
4449 4414
@@ -4535,7 +4500,8 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core,
4535 4500
4536 /* check device id(srom, nvram etc.) to set bands */ 4501 /* check device id(srom, nvram etc.) to set bands */
4537 if (wlc_hw->deviceid == BCM43224_D11N_ID || 4502 if (wlc_hw->deviceid == BCM43224_D11N_ID ||
4538 wlc_hw->deviceid == BCM43224_D11N_ID_VEN1) 4503 wlc_hw->deviceid == BCM43224_D11N_ID_VEN1 ||
4504 wlc_hw->deviceid == BCM43224_CHIP_ID)
4539 /* Dualband boards */ 4505 /* Dualband boards */
4540 wlc_hw->_nbands = 2; 4506 wlc_hw->_nbands = 2;
4541 else 4507 else
@@ -4715,8 +4681,9 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core,
4715 goto fail; 4681 goto fail;
4716 } 4682 }
4717 4683
4718 BCMMSG(wlc->wiphy, "deviceid 0x%x nbands %d board 0x%x\n", 4684 brcms_dbg_info(wlc_hw->d11core, "deviceid 0x%x nbands %d board 0x%x\n",
4719 wlc_hw->deviceid, wlc_hw->_nbands, ai_get_boardtype(wlc_hw->sih)); 4685 wlc_hw->deviceid, wlc_hw->_nbands,
4686 ai_get_boardtype(wlc_hw->sih));
4720 4687
4721 return err; 4688 return err;
4722 4689
@@ -4836,56 +4803,6 @@ static void brcms_c_bss_default_init(struct brcms_c_info *wlc)
4836 bi->flags |= BRCMS_BSS_HT; 4803 bi->flags |= BRCMS_BSS_HT;
4837} 4804}
4838 4805
4839static struct brcms_txq_info *brcms_c_txq_alloc(struct brcms_c_info *wlc)
4840{
4841 struct brcms_txq_info *qi, *p;
4842
4843 qi = kzalloc(sizeof(struct brcms_txq_info), GFP_ATOMIC);
4844 if (qi != NULL) {
4845 /*
4846 * Have enough room for control packets along with HI watermark
4847 * Also, add room to txq for total psq packets if all the SCBs
4848 * leave PS mode. The watermark for flowcontrol to OS packets
4849 * will remain the same
4850 */
4851 brcmu_pktq_init(&qi->q, BRCMS_PREC_COUNT,
4852 2 * BRCMS_DATAHIWAT + PKTQ_LEN_DEFAULT);
4853
4854 /* add this queue to the the global list */
4855 p = wlc->tx_queues;
4856 if (p == NULL) {
4857 wlc->tx_queues = qi;
4858 } else {
4859 while (p->next != NULL)
4860 p = p->next;
4861 p->next = qi;
4862 }
4863 }
4864 return qi;
4865}
4866
4867static void brcms_c_txq_free(struct brcms_c_info *wlc,
4868 struct brcms_txq_info *qi)
4869{
4870 struct brcms_txq_info *p;
4871
4872 if (qi == NULL)
4873 return;
4874
4875 /* remove the queue from the linked list */
4876 p = wlc->tx_queues;
4877 if (p == qi)
4878 wlc->tx_queues = p->next;
4879 else {
4880 while (p != NULL && p->next != qi)
4881 p = p->next;
4882 if (p != NULL)
4883 p->next = p->next->next;
4884 }
4885
4886 kfree(qi);
4887}
4888
4889static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap) 4806static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap)
4890{ 4807{
4891 uint i; 4808 uint i;
@@ -4991,8 +4908,6 @@ uint brcms_c_detach(struct brcms_c_info *wlc)
4991 if (wlc == NULL) 4908 if (wlc == NULL)
4992 return 0; 4909 return 0;
4993 4910
4994 BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
4995
4996 callbacks += brcms_b_detach(wlc); 4911 callbacks += brcms_b_detach(wlc);
4997 4912
4998 /* delete software timers */ 4913 /* delete software timers */
@@ -5005,10 +4920,6 @@ uint brcms_c_detach(struct brcms_c_info *wlc)
5005 4920
5006 brcms_c_detach_module(wlc); 4921 brcms_c_detach_module(wlc);
5007 4922
5008
5009 while (wlc->tx_queues != NULL)
5010 brcms_c_txq_free(wlc, wlc->tx_queues);
5011
5012 brcms_c_detach_mfree(wlc); 4923 brcms_c_detach_mfree(wlc);
5013 return callbacks; 4924 return callbacks;
5014} 4925}
@@ -5026,7 +4937,7 @@ static void brcms_b_hw_up(struct brcms_hardware *wlc_hw)
5026 if (wlc_hw->wlc->pub->hw_up) 4937 if (wlc_hw->wlc->pub->hw_up)
5027 return; 4938 return;
5028 4939
5029 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 4940 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit);
5030 4941
5031 /* 4942 /*
5032 * Enable pll and xtal, initialize the power control registers, 4943 * Enable pll and xtal, initialize the power control registers,
@@ -5063,7 +4974,7 @@ static void brcms_b_hw_up(struct brcms_hardware *wlc_hw)
5063 4974
5064static int brcms_b_up_prep(struct brcms_hardware *wlc_hw) 4975static int brcms_b_up_prep(struct brcms_hardware *wlc_hw)
5065{ 4976{
5066 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 4977 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit);
5067 4978
5068 /* 4979 /*
5069 * Enable pll and xtal, initialize the power control registers, 4980 * Enable pll and xtal, initialize the power control registers,
@@ -5077,7 +4988,7 @@ static int brcms_b_up_prep(struct brcms_hardware *wlc_hw)
5077 * Configure pci/pcmcia here instead of in brcms_c_attach() 4988 * Configure pci/pcmcia here instead of in brcms_c_attach()
5078 * to allow mfg hotswap: down, hotswap (chip power cycle), up. 4989 * to allow mfg hotswap: down, hotswap (chip power cycle), up.
5079 */ 4990 */
5080 bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci, wlc_hw->d11core, 4991 bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci[0], wlc_hw->d11core,
5081 true); 4992 true);
5082 4993
5083 /* 4994 /*
@@ -5102,8 +5013,6 @@ static int brcms_b_up_prep(struct brcms_hardware *wlc_hw)
5102 5013
5103static int brcms_b_up_finish(struct brcms_hardware *wlc_hw) 5014static int brcms_b_up_finish(struct brcms_hardware *wlc_hw)
5104{ 5015{
5105 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
5106
5107 wlc_hw->up = true; 5016 wlc_hw->up = true;
5108 wlc_phy_hw_state_upd(wlc_hw->band->pi, true); 5017 wlc_phy_hw_state_upd(wlc_hw->band->pi, true);
5109 5018
@@ -5135,7 +5044,7 @@ int brcms_c_up(struct brcms_c_info *wlc)
5135{ 5044{
5136 struct ieee80211_channel *ch; 5045 struct ieee80211_channel *ch;
5137 5046
5138 BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); 5047 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit);
5139 5048
5140 /* HW is turned off so don't try to access it */ 5049 /* HW is turned off so don't try to access it */
5141 if (wlc->pub->hw_off || brcms_deviceremoved(wlc)) 5050 if (wlc->pub->hw_off || brcms_deviceremoved(wlc))
@@ -5176,8 +5085,8 @@ int brcms_c_up(struct brcms_c_info *wlc)
5176 WL_RADIO_HW_DISABLE); 5085 WL_RADIO_HW_DISABLE);
5177 5086
5178 if (bsscfg->enable && bsscfg->BSS) 5087 if (bsscfg->enable && bsscfg->BSS)
5179 wiphy_err(wlc->wiphy, "wl%d: up" 5088 brcms_err(wlc->hw->d11core,
5180 ": rfdisable -> " 5089 "wl%d: up: rfdisable -> "
5181 "bsscfg_disable()\n", 5090 "bsscfg_disable()\n",
5182 wlc->pub->unit); 5091 wlc->pub->unit);
5183 } 5092 }
@@ -5237,8 +5146,6 @@ static int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw)
5237 bool dev_gone; 5146 bool dev_gone;
5238 uint callbacks = 0; 5147 uint callbacks = 0;
5239 5148
5240 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
5241
5242 if (!wlc_hw->up) 5149 if (!wlc_hw->up)
5243 return callbacks; 5150 return callbacks;
5244 5151
@@ -5265,8 +5172,6 @@ static int brcms_b_down_finish(struct brcms_hardware *wlc_hw)
5265 uint callbacks = 0; 5172 uint callbacks = 0;
5266 bool dev_gone; 5173 bool dev_gone;
5267 5174
5268 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
5269
5270 if (!wlc_hw->up) 5175 if (!wlc_hw->up)
5271 return callbacks; 5176 return callbacks;
5272 5177
@@ -5314,14 +5219,14 @@ uint brcms_c_down(struct brcms_c_info *wlc)
5314 uint callbacks = 0; 5219 uint callbacks = 0;
5315 int i; 5220 int i;
5316 bool dev_gone = false; 5221 bool dev_gone = false;
5317 struct brcms_txq_info *qi;
5318 5222
5319 BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); 5223 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit);
5320 5224
5321 /* check if we are already in the going down path */ 5225 /* check if we are already in the going down path */
5322 if (wlc->going_down) { 5226 if (wlc->going_down) {
5323 wiphy_err(wlc->wiphy, "wl%d: %s: Driver going down so return" 5227 brcms_err(wlc->hw->d11core,
5324 "\n", wlc->pub->unit, __func__); 5228 "wl%d: %s: Driver going down so return\n",
5229 wlc->pub->unit, __func__);
5325 return 0; 5230 return 0;
5326 } 5231 }
5327 if (!wlc->pub->up) 5232 if (!wlc->pub->up)
@@ -5353,13 +5258,6 @@ uint brcms_c_down(struct brcms_c_info *wlc)
5353 5258
5354 wlc_phy_mute_upd(wlc->band->pi, false, PHY_MUTE_ALL); 5259 wlc_phy_mute_upd(wlc->band->pi, false, PHY_MUTE_ALL);
5355 5260
5356 /* clear txq flow control */
5357 brcms_c_txflowcontrol_reset(wlc);
5358
5359 /* flush tx queues */
5360 for (qi = wlc->tx_queues; qi != NULL; qi = qi->next)
5361 brcmu_pktq_flush(&qi->q, true, NULL, NULL);
5362
5363 callbacks += brcms_b_down_finish(wlc->hw); 5261 callbacks += brcms_b_down_finish(wlc->hw);
5364 5262
5365 /* brcms_b_down_finish has done brcms_c_coredisable(). so clk is off */ 5263 /* brcms_b_down_finish has done brcms_c_coredisable(). so clk is off */
@@ -5441,7 +5339,7 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config)
5441 5339
5442 default: 5340 default:
5443 /* Error */ 5341 /* Error */
5444 wiphy_err(wlc->wiphy, "wl%d: %s: invalid gmode %d\n", 5342 brcms_err(wlc->hw->d11core, "wl%d: %s: invalid gmode %d\n",
5445 wlc->pub->unit, __func__, gmode); 5343 wlc->pub->unit, __func__, gmode);
5446 return -ENOTSUPP; 5344 return -ENOTSUPP;
5447 } 5345 }
@@ -5745,45 +5643,6 @@ int brcms_c_module_unregister(struct brcms_pub *pub, const char *name,
5745 return -ENODATA; 5643 return -ENODATA;
5746} 5644}
5747 5645
5748void brcms_c_print_txstatus(struct tx_status *txs)
5749{
5750 pr_debug("\ntxpkt (MPDU) Complete\n");
5751
5752 pr_debug("FrameID: %04x TxStatus: %04x\n", txs->frameid, txs->status);
5753
5754 pr_debug("[15:12] %d frame attempts\n",
5755 (txs->status & TX_STATUS_FRM_RTX_MASK) >>
5756 TX_STATUS_FRM_RTX_SHIFT);
5757 pr_debug(" [11:8] %d rts attempts\n",
5758 (txs->status & TX_STATUS_RTS_RTX_MASK) >>
5759 TX_STATUS_RTS_RTX_SHIFT);
5760 pr_debug(" [7] %d PM mode indicated\n",
5761 txs->status & TX_STATUS_PMINDCTD ? 1 : 0);
5762 pr_debug(" [6] %d intermediate status\n",
5763 txs->status & TX_STATUS_INTERMEDIATE ? 1 : 0);
5764 pr_debug(" [5] %d AMPDU\n",
5765 txs->status & TX_STATUS_AMPDU ? 1 : 0);
5766 pr_debug(" [4:2] %d Frame Suppressed Reason (%s)\n",
5767 (txs->status & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT,
5768 (const char *[]) {
5769 "None",
5770 "PMQ Entry",
5771 "Flush request",
5772 "Previous frag failure",
5773 "Channel mismatch",
5774 "Lifetime Expiry",
5775 "Underflow"
5776 } [(txs->status & TX_STATUS_SUPR_MASK) >>
5777 TX_STATUS_SUPR_SHIFT]);
5778 pr_debug(" [1] %d acked\n",
5779 txs->status & TX_STATUS_ACK_RCV ? 1 : 0);
5780
5781 pr_debug("LastTxTime: %04x Seq: %04x PHYTxStatus: %04x RxAckRSSI: %04x RxAckSQ: %04x\n",
5782 txs->lasttxtime, txs->sequence, txs->phyerr,
5783 (txs->ackphyrxsh & PRXS1_JSSI_MASK) >> PRXS1_JSSI_SHIFT,
5784 (txs->ackphyrxsh & PRXS1_SQ_MASK) >> PRXS1_SQ_SHIFT);
5785}
5786
5787static bool brcms_c_chipmatch_pci(struct bcma_device *core) 5646static bool brcms_c_chipmatch_pci(struct bcma_device *core)
5788{ 5647{
5789 struct pci_dev *pcidev = core->bus->host_pci; 5648 struct pci_dev *pcidev = core->bus->host_pci;
@@ -5795,7 +5654,7 @@ static bool brcms_c_chipmatch_pci(struct bcma_device *core)
5795 return false; 5654 return false;
5796 } 5655 }
5797 5656
5798 if (device == BCM43224_D11N_ID_VEN1) 5657 if (device == BCM43224_D11N_ID_VEN1 || device == BCM43224_CHIP_ID)
5799 return true; 5658 return true;
5800 if ((device == BCM43224_D11N_ID) || (device == BCM43225_D11N2G_ID)) 5659 if ((device == BCM43224_D11N_ID) || (device == BCM43225_D11N2G_ID))
5801 return true; 5660 return true;
@@ -5832,184 +5691,6 @@ bool brcms_c_chipmatch(struct bcma_device *core)
5832 } 5691 }
5833} 5692}
5834 5693
5835#if defined(DEBUG)
5836void brcms_c_print_txdesc(struct d11txh *txh)
5837{
5838 u16 mtcl = le16_to_cpu(txh->MacTxControlLow);
5839 u16 mtch = le16_to_cpu(txh->MacTxControlHigh);
5840 u16 mfc = le16_to_cpu(txh->MacFrameControl);
5841 u16 tfest = le16_to_cpu(txh->TxFesTimeNormal);
5842 u16 ptcw = le16_to_cpu(txh->PhyTxControlWord);
5843 u16 ptcw_1 = le16_to_cpu(txh->PhyTxControlWord_1);
5844 u16 ptcw_1_Fbr = le16_to_cpu(txh->PhyTxControlWord_1_Fbr);
5845 u16 ptcw_1_Rts = le16_to_cpu(txh->PhyTxControlWord_1_Rts);
5846 u16 ptcw_1_FbrRts = le16_to_cpu(txh->PhyTxControlWord_1_FbrRts);
5847 u16 mainrates = le16_to_cpu(txh->MainRates);
5848 u16 xtraft = le16_to_cpu(txh->XtraFrameTypes);
5849 u8 *iv = txh->IV;
5850 u8 *ra = txh->TxFrameRA;
5851 u16 tfestfb = le16_to_cpu(txh->TxFesTimeFallback);
5852 u8 *rtspfb = txh->RTSPLCPFallback;
5853 u16 rtsdfb = le16_to_cpu(txh->RTSDurFallback);
5854 u8 *fragpfb = txh->FragPLCPFallback;
5855 u16 fragdfb = le16_to_cpu(txh->FragDurFallback);
5856 u16 mmodelen = le16_to_cpu(txh->MModeLen);
5857 u16 mmodefbrlen = le16_to_cpu(txh->MModeFbrLen);
5858 u16 tfid = le16_to_cpu(txh->TxFrameID);
5859 u16 txs = le16_to_cpu(txh->TxStatus);
5860 u16 mnmpdu = le16_to_cpu(txh->MaxNMpdus);
5861 u16 mabyte = le16_to_cpu(txh->MaxABytes_MRT);
5862 u16 mabyte_f = le16_to_cpu(txh->MaxABytes_FBR);
5863 u16 mmbyte = le16_to_cpu(txh->MinMBytes);
5864
5865 u8 *rtsph = txh->RTSPhyHeader;
5866 struct ieee80211_rts rts = txh->rts_frame;
5867
5868 /* add plcp header along with txh descriptor */
5869 brcmu_dbg_hex_dump(txh, sizeof(struct d11txh) + 48,
5870 "Raw TxDesc + plcp header:\n");
5871
5872 pr_debug("TxCtlLow: %04x ", mtcl);
5873 pr_debug("TxCtlHigh: %04x ", mtch);
5874 pr_debug("FC: %04x ", mfc);
5875 pr_debug("FES Time: %04x\n", tfest);
5876 pr_debug("PhyCtl: %04x%s ", ptcw,
5877 (ptcw & PHY_TXC_SHORT_HDR) ? " short" : "");
5878 pr_debug("PhyCtl_1: %04x ", ptcw_1);
5879 pr_debug("PhyCtl_1_Fbr: %04x\n", ptcw_1_Fbr);
5880 pr_debug("PhyCtl_1_Rts: %04x ", ptcw_1_Rts);
5881 pr_debug("PhyCtl_1_Fbr_Rts: %04x\n", ptcw_1_FbrRts);
5882 pr_debug("MainRates: %04x ", mainrates);
5883 pr_debug("XtraFrameTypes: %04x ", xtraft);
5884 pr_debug("\n");
5885
5886 print_hex_dump_bytes("SecIV:", DUMP_PREFIX_OFFSET, iv, sizeof(txh->IV));
5887 print_hex_dump_bytes("RA:", DUMP_PREFIX_OFFSET,
5888 ra, sizeof(txh->TxFrameRA));
5889
5890 pr_debug("Fb FES Time: %04x ", tfestfb);
5891 print_hex_dump_bytes("Fb RTS PLCP:", DUMP_PREFIX_OFFSET,
5892 rtspfb, sizeof(txh->RTSPLCPFallback));
5893 pr_debug("RTS DUR: %04x ", rtsdfb);
5894 print_hex_dump_bytes("PLCP:", DUMP_PREFIX_OFFSET,
5895 fragpfb, sizeof(txh->FragPLCPFallback));
5896 pr_debug("DUR: %04x", fragdfb);
5897 pr_debug("\n");
5898
5899 pr_debug("MModeLen: %04x ", mmodelen);
5900 pr_debug("MModeFbrLen: %04x\n", mmodefbrlen);
5901
5902 pr_debug("FrameID: %04x\n", tfid);
5903 pr_debug("TxStatus: %04x\n", txs);
5904
5905 pr_debug("MaxNumMpdu: %04x\n", mnmpdu);
5906 pr_debug("MaxAggbyte: %04x\n", mabyte);
5907 pr_debug("MaxAggbyte_fb: %04x\n", mabyte_f);
5908 pr_debug("MinByte: %04x\n", mmbyte);
5909
5910 print_hex_dump_bytes("RTS PLCP:", DUMP_PREFIX_OFFSET,
5911 rtsph, sizeof(txh->RTSPhyHeader));
5912 print_hex_dump_bytes("RTS Frame:", DUMP_PREFIX_OFFSET,
5913 (u8 *)&rts, sizeof(txh->rts_frame));
5914 pr_debug("\n");
5915}
5916#endif /* defined(DEBUG) */
5917
5918#if defined(DEBUG)
5919static int
5920brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf,
5921 int len)
5922{
5923 int i;
5924 char *p = buf;
5925 char hexstr[16];
5926 int slen = 0, nlen = 0;
5927 u32 bit;
5928 const char *name;
5929
5930 if (len < 2 || !buf)
5931 return 0;
5932
5933 buf[0] = '\0';
5934
5935 for (i = 0; flags != 0; i++) {
5936 bit = bd[i].bit;
5937 name = bd[i].name;
5938 if (bit == 0 && flags != 0) {
5939 /* print any unnamed bits */
5940 snprintf(hexstr, 16, "0x%X", flags);
5941 name = hexstr;
5942 flags = 0; /* exit loop */
5943 } else if ((flags & bit) == 0)
5944 continue;
5945 flags &= ~bit;
5946 nlen = strlen(name);
5947 slen += nlen;
5948 /* count btwn flag space */
5949 if (flags != 0)
5950 slen += 1;
5951 /* need NULL char as well */
5952 if (len <= slen)
5953 break;
5954 /* copy NULL char but don't count it */
5955 strncpy(p, name, nlen + 1);
5956 p += nlen;
5957 /* copy btwn flag space and NULL char */
5958 if (flags != 0)
5959 p += snprintf(p, 2, " ");
5960 len -= slen;
5961 }
5962
5963 /* indicate the str was too short */
5964 if (flags != 0) {
5965 if (len < 2)
5966 p -= 2 - len; /* overwrite last char */
5967 p += snprintf(p, 2, ">");
5968 }
5969
5970 return (int)(p - buf);
5971}
5972#endif /* defined(DEBUG) */
5973
5974#if defined(DEBUG)
5975void brcms_c_print_rxh(struct d11rxhdr *rxh)
5976{
5977 u16 len = rxh->RxFrameSize;
5978 u16 phystatus_0 = rxh->PhyRxStatus_0;
5979 u16 phystatus_1 = rxh->PhyRxStatus_1;
5980 u16 phystatus_2 = rxh->PhyRxStatus_2;
5981 u16 phystatus_3 = rxh->PhyRxStatus_3;
5982 u16 macstatus1 = rxh->RxStatus1;
5983 u16 macstatus2 = rxh->RxStatus2;
5984 char flagstr[64];
5985 char lenbuf[20];
5986 static const struct brcms_c_bit_desc macstat_flags[] = {
5987 {RXS_FCSERR, "FCSErr"},
5988 {RXS_RESPFRAMETX, "Reply"},
5989 {RXS_PBPRES, "PADDING"},
5990 {RXS_DECATMPT, "DeCr"},
5991 {RXS_DECERR, "DeCrErr"},
5992 {RXS_BCNSENT, "Bcn"},
5993 {0, NULL}
5994 };
5995
5996 brcmu_dbg_hex_dump(rxh, sizeof(struct d11rxhdr), "Raw RxDesc:\n");
5997
5998 brcms_c_format_flags(macstat_flags, macstatus1, flagstr, 64);
5999
6000 snprintf(lenbuf, sizeof(lenbuf), "0x%x", len);
6001
6002 pr_debug("RxFrameSize: %6s (%d)%s\n", lenbuf, len,
6003 (rxh->PhyRxStatus_0 & PRXS0_SHORTH) ? " short preamble" : "");
6004 pr_debug("RxPHYStatus: %04x %04x %04x %04x\n",
6005 phystatus_0, phystatus_1, phystatus_2, phystatus_3);
6006 pr_debug("RxMACStatus: %x %s\n", macstatus1, flagstr);
6007 pr_debug("RXMACaggtype: %x\n",
6008 (macstatus2 & RXS_AGGTYPE_MASK));
6009 pr_debug("RxTSFTime: %04x\n", rxh->RxTSFTime);
6010}
6011#endif /* defined(DEBUG) */
6012
6013u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate) 5694u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate)
6014{ 5695{
6015 u16 table_ptr; 5696 u16 table_ptr;
@@ -6033,86 +5714,6 @@ u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate)
6033 return 2 * brcms_b_read_shm(wlc_hw, table_ptr + (index * 2)); 5714 return 2 * brcms_b_read_shm(wlc_hw, table_ptr + (index * 2));
6034} 5715}
6035 5716
6036static bool
6037brcms_c_prec_enq_head(struct brcms_c_info *wlc, struct pktq *q,
6038 struct sk_buff *pkt, int prec, bool head)
6039{
6040 struct sk_buff *p;
6041 int eprec = -1; /* precedence to evict from */
6042
6043 /* Determine precedence from which to evict packet, if any */
6044 if (pktq_pfull(q, prec))
6045 eprec = prec;
6046 else if (pktq_full(q)) {
6047 p = brcmu_pktq_peek_tail(q, &eprec);
6048 if (eprec > prec) {
6049 wiphy_err(wlc->wiphy, "%s: Failing: eprec %d > prec %d"
6050 "\n", __func__, eprec, prec);
6051 return false;
6052 }
6053 }
6054
6055 /* Evict if needed */
6056 if (eprec >= 0) {
6057 bool discard_oldest;
6058
6059 discard_oldest = ac_bitmap_tst(0, eprec);
6060
6061 /* Refuse newer packet unless configured to discard oldest */
6062 if (eprec == prec && !discard_oldest) {
6063 wiphy_err(wlc->wiphy, "%s: No where to go, prec == %d"
6064 "\n", __func__, prec);
6065 return false;
6066 }
6067
6068 /* Evict packet according to discard policy */
6069 p = discard_oldest ? brcmu_pktq_pdeq(q, eprec) :
6070 brcmu_pktq_pdeq_tail(q, eprec);
6071 brcmu_pkt_buf_free_skb(p);
6072 }
6073
6074 /* Enqueue */
6075 if (head)
6076 p = brcmu_pktq_penq_head(q, prec, pkt);
6077 else
6078 p = brcmu_pktq_penq(q, prec, pkt);
6079
6080 return true;
6081}
6082
6083/*
6084 * Attempts to queue a packet onto a multiple-precedence queue,
6085 * if necessary evicting a lower precedence packet from the queue.
6086 *
6087 * 'prec' is the precedence number that has already been mapped
6088 * from the packet priority.
6089 *
6090 * Returns true if packet consumed (queued), false if not.
6091 */
6092static bool brcms_c_prec_enq(struct brcms_c_info *wlc, struct pktq *q,
6093 struct sk_buff *pkt, int prec)
6094{
6095 return brcms_c_prec_enq_head(wlc, q, pkt, prec, false);
6096}
6097
6098void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb,
6099 struct sk_buff *sdu, uint prec)
6100{
6101 struct brcms_txq_info *qi = wlc->pkt_queue; /* Check me */
6102 struct pktq *q = &qi->q;
6103 int prio;
6104
6105 prio = sdu->priority;
6106
6107 if (!brcms_c_prec_enq(wlc, q, sdu, prec)) {
6108 /*
6109 * we might hit this condtion in case
6110 * packet flooding from mac80211 stack
6111 */
6112 brcmu_pkt_buf_free_skb(sdu);
6113 }
6114}
6115
6116/* 5717/*
6117 * bcmc_fid_generate: 5718 * bcmc_fid_generate:
6118 * Generate frame ID for a BCMC packet. The frag field is not used 5719 * Generate frame ID for a BCMC packet. The frag field is not used
@@ -6140,8 +5741,6 @@ brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec,
6140{ 5741{
6141 uint dur = 0; 5742 uint dur = 0;
6142 5743
6143 BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d\n",
6144 wlc->pub->unit, rspec, preamble_type);
6145 /* 5744 /*
6146 * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that 5745 * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that
6147 * is less than or equal to the rate of the immediately previous 5746 * is less than or equal to the rate of the immediately previous
@@ -6159,8 +5758,6 @@ static uint
6159brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rspec, 5758brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rspec,
6160 u8 preamble_type) 5759 u8 preamble_type)
6161{ 5760{
6162 BCMMSG(wlc->wiphy, "wl%d: ratespec 0x%x, preamble_type %d\n",
6163 wlc->pub->unit, rspec, preamble_type);
6164 return brcms_c_calc_ack_time(wlc, rspec, preamble_type); 5761 return brcms_c_calc_ack_time(wlc, rspec, preamble_type);
6165} 5762}
6166 5763
@@ -6168,8 +5765,6 @@ static uint
6168brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec, 5765brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec,
6169 u8 preamble_type) 5766 u8 preamble_type)
6170{ 5767{
6171 BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, "
6172 "preamble_type %d\n", wlc->pub->unit, rspec, preamble_type);
6173 /* 5768 /*
6174 * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that 5769 * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that
6175 * is less than or equal to the rate of the immediately previous 5770 * is less than or equal to the rate of the immediately previous
@@ -6223,9 +5818,6 @@ brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 ratespec,
6223 uint nsyms, mac_len, Ndps, kNdps; 5818 uint nsyms, mac_len, Ndps, kNdps;
6224 uint rate = rspec2rate(ratespec); 5819 uint rate = rspec2rate(ratespec);
6225 5820
6226 BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d, dur %d\n",
6227 wlc->pub->unit, ratespec, preamble_type, dur);
6228
6229 if (is_mcs_rate(ratespec)) { 5821 if (is_mcs_rate(ratespec)) {
6230 uint mcs = ratespec & RSPEC_RATE_MASK; 5822 uint mcs = ratespec & RSPEC_RATE_MASK;
6231 int tot_streams = mcs_2_txstreams(mcs) + rspec_stc(ratespec); 5823 int tot_streams = mcs_2_txstreams(mcs) + rspec_stc(ratespec);
@@ -6292,7 +5884,7 @@ static bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band,
6292 return true; 5884 return true;
6293 error: 5885 error:
6294 if (verbose) 5886 if (verbose)
6295 wiphy_err(wlc->wiphy, "wl%d: valid_rate: rate spec 0x%x " 5887 brcms_err(wlc->hw->d11core, "wl%d: valid_rate: rate spec 0x%x "
6296 "not in hw_rateset\n", wlc->pub->unit, rspec); 5888 "not in hw_rateset\n", wlc->pub->unit, rspec);
6297 5889
6298 return false; 5890 return false;
@@ -6302,6 +5894,7 @@ static u32
6302mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, 5894mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band,
6303 u32 int_val) 5895 u32 int_val)
6304{ 5896{
5897 struct bcma_device *core = wlc->hw->d11core;
6305 u8 stf = (int_val & NRATE_STF_MASK) >> NRATE_STF_SHIFT; 5898 u8 stf = (int_val & NRATE_STF_MASK) >> NRATE_STF_SHIFT;
6306 u8 rate = int_val & NRATE_RATE_MASK; 5899 u8 rate = int_val & NRATE_RATE_MASK;
6307 u32 rspec; 5900 u32 rspec;
@@ -6318,7 +5911,7 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band,
6318 if ((wlc->pub->_n_enab & SUPPORT_11N) && ismcs) { 5911 if ((wlc->pub->_n_enab & SUPPORT_11N) && ismcs) {
6319 /* mcs only allowed when nmode */ 5912 /* mcs only allowed when nmode */
6320 if (stf > PHY_TXC1_MODE_SDM) { 5913 if (stf > PHY_TXC1_MODE_SDM) {
6321 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid stf\n", 5914 brcms_err(core, "wl%d: %s: Invalid stf\n",
6322 wlc->pub->unit, __func__); 5915 wlc->pub->unit, __func__);
6323 bcmerror = -EINVAL; 5916 bcmerror = -EINVAL;
6324 goto done; 5917 goto done;
@@ -6329,8 +5922,8 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band,
6329 if (!CHSPEC_IS40(wlc->home_chanspec) || 5922 if (!CHSPEC_IS40(wlc->home_chanspec) ||
6330 ((stf != PHY_TXC1_MODE_SISO) 5923 ((stf != PHY_TXC1_MODE_SISO)
6331 && (stf != PHY_TXC1_MODE_CDD))) { 5924 && (stf != PHY_TXC1_MODE_CDD))) {
6332 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid mcs " 5925 brcms_err(core, "wl%d: %s: Invalid mcs 32\n",
6333 "32\n", wlc->pub->unit, __func__); 5926 wlc->pub->unit, __func__);
6334 bcmerror = -EINVAL; 5927 bcmerror = -EINVAL;
6335 goto done; 5928 goto done;
6336 } 5929 }
@@ -6338,9 +5931,9 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band,
6338 } else if (rate > HIGHEST_SINGLE_STREAM_MCS) { 5931 } else if (rate > HIGHEST_SINGLE_STREAM_MCS) {
6339 /* mcs > 7 must use stf SDM */ 5932 /* mcs > 7 must use stf SDM */
6340 if (stf != PHY_TXC1_MODE_SDM) { 5933 if (stf != PHY_TXC1_MODE_SDM) {
6341 BCMMSG(wlc->wiphy, "wl%d: enabling " 5934 brcms_dbg_mac80211(core, "wl%d: enabling "
6342 "SDM mode for mcs %d\n", 5935 "SDM mode for mcs %d\n",
6343 wlc->pub->unit, rate); 5936 wlc->pub->unit, rate);
6344 stf = PHY_TXC1_MODE_SDM; 5937 stf = PHY_TXC1_MODE_SDM;
6345 } 5938 }
6346 } else { 5939 } else {
@@ -6351,15 +5944,15 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band,
6351 if ((stf > PHY_TXC1_MODE_STBC) || 5944 if ((stf > PHY_TXC1_MODE_STBC) ||
6352 (!BRCMS_STBC_CAP_PHY(wlc) 5945 (!BRCMS_STBC_CAP_PHY(wlc)
6353 && (stf == PHY_TXC1_MODE_STBC))) { 5946 && (stf == PHY_TXC1_MODE_STBC))) {
6354 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid STBC" 5947 brcms_err(core, "wl%d: %s: Invalid STBC\n",
6355 "\n", wlc->pub->unit, __func__); 5948 wlc->pub->unit, __func__);
6356 bcmerror = -EINVAL; 5949 bcmerror = -EINVAL;
6357 goto done; 5950 goto done;
6358 } 5951 }
6359 } 5952 }
6360 } else if (is_ofdm_rate(rate)) { 5953 } else if (is_ofdm_rate(rate)) {
6361 if ((stf != PHY_TXC1_MODE_CDD) && (stf != PHY_TXC1_MODE_SISO)) { 5954 if ((stf != PHY_TXC1_MODE_CDD) && (stf != PHY_TXC1_MODE_SISO)) {
6362 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid OFDM\n", 5955 brcms_err(core, "wl%d: %s: Invalid OFDM\n",
6363 wlc->pub->unit, __func__); 5956 wlc->pub->unit, __func__);
6364 bcmerror = -EINVAL; 5957 bcmerror = -EINVAL;
6365 goto done; 5958 goto done;
@@ -6367,20 +5960,20 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band,
6367 } else if (is_cck_rate(rate)) { 5960 } else if (is_cck_rate(rate)) {
6368 if ((cur_band->bandtype != BRCM_BAND_2G) 5961 if ((cur_band->bandtype != BRCM_BAND_2G)
6369 || (stf != PHY_TXC1_MODE_SISO)) { 5962 || (stf != PHY_TXC1_MODE_SISO)) {
6370 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid CCK\n", 5963 brcms_err(core, "wl%d: %s: Invalid CCK\n",
6371 wlc->pub->unit, __func__); 5964 wlc->pub->unit, __func__);
6372 bcmerror = -EINVAL; 5965 bcmerror = -EINVAL;
6373 goto done; 5966 goto done;
6374 } 5967 }
6375 } else { 5968 } else {
6376 wiphy_err(wlc->wiphy, "wl%d: %s: Unknown rate type\n", 5969 brcms_err(core, "wl%d: %s: Unknown rate type\n",
6377 wlc->pub->unit, __func__); 5970 wlc->pub->unit, __func__);
6378 bcmerror = -EINVAL; 5971 bcmerror = -EINVAL;
6379 goto done; 5972 goto done;
6380 } 5973 }
6381 /* make sure multiple antennae are available for non-siso rates */ 5974 /* make sure multiple antennae are available for non-siso rates */
6382 if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { 5975 if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) {
6383 wiphy_err(wlc->wiphy, "wl%d: %s: SISO antenna but !SISO " 5976 brcms_err(core, "wl%d: %s: SISO antenna but !SISO "
6384 "request\n", wlc->pub->unit, __func__); 5977 "request\n", wlc->pub->unit, __func__);
6385 bcmerror = -EINVAL; 5978 bcmerror = -EINVAL;
6386 goto done; 5979 goto done;
@@ -6449,7 +6042,7 @@ static void brcms_c_cck_plcp_set(struct brcms_c_info *wlc, int rate_500,
6449 break; 6042 break;
6450 6043
6451 default: 6044 default:
6452 wiphy_err(wlc->wiphy, 6045 brcms_err(wlc->hw->d11core,
6453 "brcms_c_cck_plcp_set: unsupported rate %d\n", 6046 "brcms_c_cck_plcp_set: unsupported rate %d\n",
6454 rate_500); 6047 rate_500);
6455 rate_500 = BRCM_RATE_1M; 6048 rate_500 = BRCM_RATE_1M;
@@ -6582,7 +6175,7 @@ static u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec)
6582 bw = rspec_get_bw(rspec); 6175 bw = rspec_get_bw(rspec);
6583 /* 10Mhz is not supported yet */ 6176 /* 10Mhz is not supported yet */
6584 if (bw < PHY_TXC1_BW_20MHZ) { 6177 if (bw < PHY_TXC1_BW_20MHZ) {
6585 wiphy_err(wlc->wiphy, "phytxctl1_calc: bw %d is " 6178 brcms_err(wlc->hw->d11core, "phytxctl1_calc: bw %d is "
6586 "not supported yet, set to 20L\n", bw); 6179 "not supported yet, set to 20L\n", bw);
6587 bw = PHY_TXC1_BW_20MHZ; 6180 bw = PHY_TXC1_BW_20MHZ;
6588 } 6181 }
@@ -6609,7 +6202,7 @@ static u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec)
6609 /* get the phyctl byte from rate phycfg table */ 6202 /* get the phyctl byte from rate phycfg table */
6610 phycfg = brcms_c_rate_legacy_phyctl(rspec2rate(rspec)); 6203 phycfg = brcms_c_rate_legacy_phyctl(rspec2rate(rspec));
6611 if (phycfg == -1) { 6204 if (phycfg == -1) {
6612 wiphy_err(wlc->wiphy, "phytxctl1_calc: wrong " 6205 brcms_err(wlc->hw->d11core, "phytxctl1_calc: wrong "
6613 "legacy OFDM/CCK rate\n"); 6206 "legacy OFDM/CCK rate\n");
6614 phycfg = 0; 6207 phycfg = 0;
6615 } 6208 }
@@ -6689,8 +6282,9 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw,
6689 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { 6282 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
6690 /* non-AP STA should never use BCMC queue */ 6283 /* non-AP STA should never use BCMC queue */
6691 if (queue == TX_BCMC_FIFO) { 6284 if (queue == TX_BCMC_FIFO) {
6692 wiphy_err(wlc->wiphy, "wl%d: %s: ASSERT queue == " 6285 brcms_err(wlc->hw->d11core,
6693 "TX_BCMC!\n", wlc->pub->unit, __func__); 6286 "wl%d: %s: ASSERT queue == TX_BCMC!\n",
6287 wlc->pub->unit, __func__);
6694 frameid = bcmc_fid_generate(wlc, NULL, txh); 6288 frameid = bcmc_fid_generate(wlc, NULL, txh);
6695 } else { 6289 } else {
6696 /* Increment the counter for first fragment */ 6290 /* Increment the counter for first fragment */
@@ -6860,7 +6454,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw,
6860 6454
6861 if ((txrate[k]->flags & IEEE80211_TX_RC_MCS) 6455 if ((txrate[k]->flags & IEEE80211_TX_RC_MCS)
6862 && (!is_mcs_rate(rspec[k]))) { 6456 && (!is_mcs_rate(rspec[k]))) {
6863 wiphy_err(wlc->wiphy, "wl%d: %s: IEEE80211_TX_" 6457 brcms_err(wlc->hw->d11core,
6458 "wl%d: %s: IEEE80211_TX_"
6864 "RC_MCS != is_mcs_rate(rspec)\n", 6459 "RC_MCS != is_mcs_rate(rspec)\n",
6865 wlc->pub->unit, __func__); 6460 wlc->pub->unit, __func__);
6866 } 6461 }
@@ -7254,14 +6849,16 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw,
7254 wlc->fragthresh[queue] = 6849 wlc->fragthresh[queue] =
7255 (u16) newfragthresh; 6850 (u16) newfragthresh;
7256 } else { 6851 } else {
7257 wiphy_err(wlc->wiphy, "wl%d: %s txop invalid " 6852 brcms_err(wlc->hw->d11core,
6853 "wl%d: %s txop invalid "
7258 "for rate %d\n", 6854 "for rate %d\n",
7259 wlc->pub->unit, fifo_names[queue], 6855 wlc->pub->unit, fifo_names[queue],
7260 rspec2rate(rspec[0])); 6856 rspec2rate(rspec[0]));
7261 } 6857 }
7262 6858
7263 if (dur > wlc->edcf_txop[ac]) 6859 if (dur > wlc->edcf_txop[ac])
7264 wiphy_err(wlc->wiphy, "wl%d: %s: %s txop " 6860 brcms_err(wlc->hw->d11core,
6861 "wl%d: %s: %s txop "
7265 "exceeded phylen %d/%d dur %d/%d\n", 6862 "exceeded phylen %d/%d dur %d/%d\n",
7266 wlc->pub->unit, __func__, 6863 wlc->pub->unit, __func__,
7267 fifo_names[queue], 6864 fifo_names[queue],
@@ -7273,79 +6870,33 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw,
7273 return 0; 6870 return 0;
7274} 6871}
7275 6872
7276void brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, 6873static int brcms_c_tx(struct brcms_c_info *wlc, struct sk_buff *skb)
7277 struct ieee80211_hw *hw)
7278{ 6874{
7279 u8 prio; 6875 struct dma_pub *dma;
7280 uint fifo; 6876 int fifo, ret = -ENOSPC;
7281 struct scb *scb = &wlc->pri_scb; 6877 struct d11txh *txh;
7282 struct ieee80211_hdr *d11_header = (struct ieee80211_hdr *)(sdu->data); 6878 u16 frameid = INVALIDFID;
7283
7284 /*
7285 * 802.11 standard requires management traffic
7286 * to go at highest priority
7287 */
7288 prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority :
7289 MAXPRIO;
7290 fifo = prio2fifo[prio];
7291 if (brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0))
7292 return;
7293 brcms_c_txq_enq(wlc, scb, sdu, BRCMS_PRIO_TO_PREC(prio));
7294 brcms_c_send_q(wlc);
7295}
7296
7297void brcms_c_send_q(struct brcms_c_info *wlc)
7298{
7299 struct sk_buff *pkt[DOT11_MAXNUMFRAGS];
7300 int prec;
7301 u16 prec_map;
7302 int err = 0, i, count;
7303 uint fifo;
7304 struct brcms_txq_info *qi = wlc->pkt_queue;
7305 struct pktq *q = &qi->q;
7306 struct ieee80211_tx_info *tx_info;
7307 6879
7308 prec_map = wlc->tx_prec_map; 6880 fifo = brcms_ac_to_fifo(skb_get_queue_mapping(skb));
6881 dma = wlc->hw->di[fifo];
6882 txh = (struct d11txh *)(skb->data);
7309 6883
7310 /* Send all the enq'd pkts that we can. 6884 if (dma->txavail == 0) {
7311 * Dequeue packets with precedence with empty HW fifo only 6885 /*
7312 */ 6886 * We sometimes get a frame from mac80211 after stopping
7313 while (prec_map && (pkt[0] = brcmu_pktq_mdeq(q, prec_map, &prec))) { 6887 * the queues. This only ever seems to be a single frame
7314 tx_info = IEEE80211_SKB_CB(pkt[0]); 6888 * and is seems likely to be a race. TX_HEADROOM should
7315 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { 6889 * ensure that we have enough space to handle these stray
7316 err = brcms_c_sendampdu(wlc->ampdu, qi, pkt, prec); 6890 * packets, so warn if there isn't. If we're out of space
7317 } else { 6891 * in the tx ring and the tx queue isn't stopped then
7318 count = 1; 6892 * we've really got a bug; warn loudly if that happens.
7319 err = brcms_c_prep_pdu(wlc, pkt[0], &fifo); 6893 */
7320 if (!err) { 6894 brcms_warn(wlc->hw->d11core,
7321 for (i = 0; i < count; i++) 6895 "Received frame for tx with no space in DMA ring\n");
7322 brcms_c_txfifo(wlc, fifo, pkt[i], true, 6896 WARN_ON(!ieee80211_queue_stopped(wlc->pub->ieee_hw,
7323 1); 6897 skb_get_queue_mapping(skb)));
7324 } 6898 return -ENOSPC;
7325 }
7326
7327 if (err == -EBUSY) {
7328 brcmu_pktq_penq_head(q, prec, pkt[0]);
7329 /*
7330 * If send failed due to any other reason than a
7331 * change in HW FIFO condition, quit. Otherwise,
7332 * read the new prec_map!
7333 */
7334 if (prec_map == wlc->tx_prec_map)
7335 break;
7336 prec_map = wlc->tx_prec_map;
7337 }
7338 } 6899 }
7339}
7340
7341void
7342brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p,
7343 bool commit, s8 txpktpend)
7344{
7345 u16 frameid = INVALIDFID;
7346 struct d11txh *txh;
7347
7348 txh = (struct d11txh *) (p->data);
7349 6900
7350 /* When a BC/MC frame is being committed to the BCMC fifo 6901 /* When a BC/MC frame is being committed to the BCMC fifo
7351 * via DMA (NOT PIO), update ucode or BSS info as appropriate. 6902 * via DMA (NOT PIO), update ucode or BSS info as appropriate.
@@ -7353,16 +6904,6 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p,
7353 if (fifo == TX_BCMC_FIFO) 6904 if (fifo == TX_BCMC_FIFO)
7354 frameid = le16_to_cpu(txh->TxFrameID); 6905 frameid = le16_to_cpu(txh->TxFrameID);
7355 6906
7356 /*
7357 * Bump up pending count for if not using rpc. If rpc is
7358 * used, this will be handled in brcms_b_txfifo()
7359 */
7360 if (commit) {
7361 wlc->core->txpktpend[fifo] += txpktpend;
7362 BCMMSG(wlc->wiphy, "pktpend inc %d to %d\n",
7363 txpktpend, wlc->core->txpktpend[fifo]);
7364 }
7365
7366 /* Commit BCMC sequence number in the SHM frame ID location */ 6907 /* Commit BCMC sequence number in the SHM frame ID location */
7367 if (frameid != INVALIDFID) { 6908 if (frameid != INVALIDFID) {
7368 /* 6909 /*
@@ -7372,8 +6913,55 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p,
7372 brcms_b_write_shm(wlc->hw, M_BCMC_FID, frameid); 6913 brcms_b_write_shm(wlc->hw, M_BCMC_FID, frameid);
7373 } 6914 }
7374 6915
7375 if (dma_txfast(wlc->hw->di[fifo], p, commit) < 0) 6916 ret = brcms_c_txfifo(wlc, fifo, skb);
6917 /*
6918 * The only reason for brcms_c_txfifo to fail is because
6919 * there weren't any DMA descriptors, but we've already
6920 * checked for that. So if it does fail yell loudly.
6921 */
6922 WARN_ON_ONCE(ret);
6923
6924 return ret;
6925}
6926
6927bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu,
6928 struct ieee80211_hw *hw)
6929{
6930 uint fifo;
6931 struct scb *scb = &wlc->pri_scb;
6932
6933 fifo = brcms_ac_to_fifo(skb_get_queue_mapping(sdu));
6934 brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0);
6935 if (!brcms_c_tx(wlc, sdu))
6936 return true;
6937
6938 /* packet discarded */
6939 dev_kfree_skb_any(sdu);
6940 return false;
6941}
6942
6943int
6944brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p)
6945{
6946 struct dma_pub *dma = wlc->hw->di[fifo];
6947 int ret;
6948 u16 queue;
6949
6950 ret = dma_txfast(wlc, dma, p);
6951 if (ret < 0)
7376 wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); 6952 wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n");
6953
6954 /*
6955 * Stop queue if DMA ring is full. Reserve some free descriptors,
6956 * as we sometimes receive a frame from mac80211 after the queues
6957 * are stopped.
6958 */
6959 queue = skb_get_queue_mapping(p);
6960 if (dma->txavail <= TX_HEADROOM && fifo < TX_BCMC_FIFO &&
6961 !ieee80211_queue_stopped(wlc->pub->ieee_hw, queue))
6962 ieee80211_stop_queue(wlc->pub->ieee_hw, queue);
6963
6964 return ret;
7377} 6965}
7378 6966
7379u32 6967u32
@@ -7423,19 +7011,6 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec,
7423 return rts_rspec; 7011 return rts_rspec;
7424} 7012}
7425 7013
7426void
7427brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo, s8 txpktpend)
7428{
7429 wlc->core->txpktpend[fifo] -= txpktpend;
7430 BCMMSG(wlc->wiphy, "pktpend dec %d to %d\n", txpktpend,
7431 wlc->core->txpktpend[fifo]);
7432
7433 /* There is more room; mark precedences related to this FIFO sendable */
7434 wlc->tx_prec_map |= wlc->fifo2prec_map[fifo];
7435
7436 /* figure out which bsscfg is being worked on... */
7437}
7438
7439/* Update beacon listen interval in shared memory */ 7014/* Update beacon listen interval in shared memory */
7440static void brcms_c_bcn_li_upd(struct brcms_c_info *wlc) 7015static void brcms_c_bcn_li_upd(struct brcms_c_info *wlc)
7441{ 7016{
@@ -7508,7 +7083,7 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh,
7508 7083
7509 /* fill in TSF and flag its presence */ 7084 /* fill in TSF and flag its presence */
7510 rx_status->mactime = brcms_c_recover_tsf64(wlc, rxh); 7085 rx_status->mactime = brcms_c_recover_tsf64(wlc, rxh);
7511 rx_status->flag |= RX_FLAG_MACTIME_MPDU; 7086 rx_status->flag |= RX_FLAG_MACTIME_START;
7512 7087
7513 channel = BRCMS_CHAN_CHANNEL(rxh->RxChan); 7088 channel = BRCMS_CHAN_CHANNEL(rxh->RxChan);
7514 7089
@@ -7571,7 +7146,8 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh,
7571 rx_status->rate_idx = 11; 7146 rx_status->rate_idx = 11;
7572 break; 7147 break;
7573 default: 7148 default:
7574 wiphy_err(wlc->wiphy, "%s: Unknown rate\n", __func__); 7149 brcms_err(wlc->hw->d11core,
7150 "%s: Unknown rate\n", __func__);
7575 } 7151 }
7576 7152
7577 /* 7153 /*
@@ -7590,7 +7166,7 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh,
7590 } else if (is_ofdm_rate(rspec)) { 7166 } else if (is_ofdm_rate(rspec)) {
7591 rx_status->flag |= RX_FLAG_SHORTPRE; 7167 rx_status->flag |= RX_FLAG_SHORTPRE;
7592 } else { 7168 } else {
7593 wiphy_err(wlc->wiphy, "%s: Unknown modulation\n", 7169 brcms_err(wlc->hw->d11core, "%s: Unknown modulation\n",
7594 __func__); 7170 __func__);
7595 } 7171 }
7596 } 7172 }
@@ -7600,12 +7176,12 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh,
7600 7176
7601 if (rxh->RxStatus1 & RXS_DECERR) { 7177 if (rxh->RxStatus1 & RXS_DECERR) {
7602 rx_status->flag |= RX_FLAG_FAILED_PLCP_CRC; 7178 rx_status->flag |= RX_FLAG_FAILED_PLCP_CRC;
7603 wiphy_err(wlc->wiphy, "%s: RX_FLAG_FAILED_PLCP_CRC\n", 7179 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_PLCP_CRC\n",
7604 __func__); 7180 __func__);
7605 } 7181 }
7606 if (rxh->RxStatus1 & RXS_FCSERR) { 7182 if (rxh->RxStatus1 & RXS_FCSERR) {
7607 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; 7183 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
7608 wiphy_err(wlc->wiphy, "%s: RX_FLAG_FAILED_FCS_CRC\n", 7184 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_FCS_CRC\n",
7609 __func__); 7185 __func__);
7610 } 7186 }
7611} 7187}
@@ -7649,9 +7225,6 @@ brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec,
7649{ 7225{
7650 uint nsyms, len = 0, kNdps; 7226 uint nsyms, len = 0, kNdps;
7651 7227
7652 BCMMSG(wlc->wiphy, "wl%d: rate %d, len%d\n",
7653 wlc->pub->unit, rspec2rate(ratespec), mac_len);
7654
7655 if (is_mcs_rate(ratespec)) { 7228 if (is_mcs_rate(ratespec)) {
7656 uint mcs = ratespec & RSPEC_RATE_MASK; 7229 uint mcs = ratespec & RSPEC_RATE_MASK;
7657 int tot_streams = (mcs_2_txstreams(mcs) + 1) + 7230 int tot_streams = (mcs_2_txstreams(mcs) + 1) +
@@ -7883,35 +7456,6 @@ void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend)
7883 brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend); 7456 brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend);
7884} 7457}
7885 7458
7886/* prepares pdu for transmission. returns BCM error codes */
7887int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu, uint *fifop)
7888{
7889 uint fifo;
7890 struct d11txh *txh;
7891 struct ieee80211_hdr *h;
7892 struct scb *scb;
7893
7894 txh = (struct d11txh *) (pdu->data);
7895 h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
7896
7897 /* get the pkt queue info. This was put at brcms_c_sendctl or
7898 * brcms_c_send for PDU */
7899 fifo = le16_to_cpu(txh->TxFrameID) & TXFID_QUEUE_MASK;
7900
7901 scb = NULL;
7902
7903 *fifop = fifo;
7904
7905 /* return if insufficient dma resources */
7906 if (*wlc->core->txavail[fifo] < MAX_DMA_SEGS) {
7907 /* Mark precedences related to this FIFO, unsendable */
7908 /* A fifo is full. Clear precedences related to that FIFO */
7909 wlc->tx_prec_map &= ~(wlc->fifo2prec_map[fifo]);
7910 return -EBUSY;
7911 }
7912 return 0;
7913}
7914
7915int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, 7459int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
7916 uint *blocks) 7460 uint *blocks)
7917{ 7461{
@@ -7977,13 +7521,15 @@ int brcms_c_get_curband(struct brcms_c_info *wlc)
7977void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, bool drop) 7521void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, bool drop)
7978{ 7522{
7979 int timeout = 20; 7523 int timeout = 20;
7524 int i;
7980 7525
7981 /* flush packet queue when requested */ 7526 /* Kick DMA to send any pending AMPDU */
7982 if (drop) 7527 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++)
7983 brcmu_pktq_flush(&wlc->pkt_queue->q, false, NULL, NULL); 7528 if (wlc->hw->di[i])
7529 dma_txflush(wlc->hw->di[i]);
7984 7530
7985 /* wait for queue and DMA fifos to run dry */ 7531 /* wait for queue and DMA fifos to run dry */
7986 while (!pktq_empty(&wlc->pkt_queue->q) || brcms_txpktpendtot(wlc) > 0) { 7532 while (brcms_txpktpendtot(wlc) > 0) {
7987 brcms_msleep(wlc->wl, 1); 7533 brcms_msleep(wlc->wl, 1);
7988 7534
7989 if (--timeout == 0) 7535 if (--timeout == 0)
@@ -8032,8 +7578,6 @@ static void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p)
8032 uint len; 7578 uint len;
8033 bool is_amsdu; 7579 bool is_amsdu;
8034 7580
8035 BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
8036
8037 /* frame starts with rxhdr */ 7581 /* frame starts with rxhdr */
8038 rxh = (struct d11rxhdr *) (p->data); 7582 rxh = (struct d11rxhdr *) (p->data);
8039 7583
@@ -8043,8 +7587,9 @@ static void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p)
8043 /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU subframes */ 7587 /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU subframes */
8044 if (rxh->RxStatus1 & RXS_PBPRES) { 7588 if (rxh->RxStatus1 & RXS_PBPRES) {
8045 if (p->len < 2) { 7589 if (p->len < 2) {
8046 wiphy_err(wlc->wiphy, "wl%d: recv: rcvd runt of " 7590 brcms_err(wlc->hw->d11core,
8047 "len %d\n", wlc->pub->unit, p->len); 7591 "wl%d: recv: rcvd runt of len %d\n",
7592 wlc->pub->unit, p->len);
8048 goto toss; 7593 goto toss;
8049 } 7594 }
8050 skb_pull(p, 2); 7595 skb_pull(p, 2);
@@ -8088,17 +7633,19 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound)
8088 7633
8089 uint n = 0; 7634 uint n = 0;
8090 uint bound_limit = bound ? RXBND : -1; 7635 uint bound_limit = bound ? RXBND : -1;
7636 bool morepending;
8091 7637
8092 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
8093 skb_queue_head_init(&recv_frames); 7638 skb_queue_head_init(&recv_frames);
8094 7639
8095 /* gather received frames */ 7640 /* gather received frames */
8096 while (dma_rx(wlc_hw->di[fifo], &recv_frames)) { 7641 do {
8097
8098 /* !give others some time to run! */ 7642 /* !give others some time to run! */
8099 if (++n >= bound_limit) 7643 if (n >= bound_limit)
8100 break; 7644 break;
8101 } 7645
7646 morepending = dma_rx(wlc_hw->di[fifo], &recv_frames);
7647 n++;
7648 } while (morepending);
8102 7649
8103 /* post more rbufs */ 7650 /* post more rbufs */
8104 dma_rxfill(wlc_hw->di[fifo]); 7651 dma_rxfill(wlc_hw->di[fifo]);
@@ -8128,7 +7675,7 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound)
8128 brcms_c_recv(wlc_hw->wlc, p); 7675 brcms_c_recv(wlc_hw->wlc, p);
8129 } 7676 }
8130 7677
8131 return n >= bound_limit; 7678 return morepending;
8132} 7679}
8133 7680
8134/* second-level interrupt processing 7681/* second-level interrupt processing
@@ -8140,10 +7687,9 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded)
8140 u32 macintstatus; 7687 u32 macintstatus;
8141 struct brcms_hardware *wlc_hw = wlc->hw; 7688 struct brcms_hardware *wlc_hw = wlc->hw;
8142 struct bcma_device *core = wlc_hw->d11core; 7689 struct bcma_device *core = wlc_hw->d11core;
8143 struct wiphy *wiphy = wlc->wiphy;
8144 7690
8145 if (brcms_deviceremoved(wlc)) { 7691 if (brcms_deviceremoved(wlc)) {
8146 wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, 7692 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit,
8147 __func__); 7693 __func__);
8148 brcms_down(wlc->wl); 7694 brcms_down(wlc->wl);
8149 return false; 7695 return false;
@@ -8153,8 +7699,8 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded)
8153 macintstatus = wlc->macintstatus; 7699 macintstatus = wlc->macintstatus;
8154 wlc->macintstatus = 0; 7700 wlc->macintstatus = 0;
8155 7701
8156 BCMMSG(wlc->wiphy, "wl%d: macintstatus 0x%x\n", 7702 brcms_dbg_int(core, "wl%d: macintstatus 0x%x\n",
8157 wlc_hw->unit, macintstatus); 7703 wlc_hw->unit, macintstatus);
8158 7704
8159 WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */ 7705 WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */
8160 7706
@@ -8164,7 +7710,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded)
8164 if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) 7710 if (brcms_b_txstatus(wlc->hw, bounded, &fatal))
8165 wlc->macintstatus |= MI_TFS; 7711 wlc->macintstatus |= MI_TFS;
8166 if (fatal) { 7712 if (fatal) {
8167 wiphy_err(wiphy, "MI_TFS: fatal\n"); 7713 brcms_err(core, "MI_TFS: fatal\n");
8168 goto fatal; 7714 goto fatal;
8169 } 7715 }
8170 } 7716 }
@@ -8174,7 +7720,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded)
8174 7720
8175 /* ATIM window end */ 7721 /* ATIM window end */
8176 if (macintstatus & MI_ATIMWINEND) { 7722 if (macintstatus & MI_ATIMWINEND) {
8177 BCMMSG(wlc->wiphy, "end of ATIM window\n"); 7723 brcms_dbg_info(core, "end of ATIM window\n");
8178 bcma_set32(core, D11REGOFFS(maccommand), wlc->qvalid); 7724 bcma_set32(core, D11REGOFFS(maccommand), wlc->qvalid);
8179 wlc->qvalid = 0; 7725 wlc->qvalid = 0;
8180 } 7726 }
@@ -8192,7 +7738,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded)
8192 wlc_phy_noise_sample_intr(wlc_hw->band->pi); 7738 wlc_phy_noise_sample_intr(wlc_hw->band->pi);
8193 7739
8194 if (macintstatus & MI_GP0) { 7740 if (macintstatus & MI_GP0) {
8195 wiphy_err(wiphy, "wl%d: PSM microcode watchdog fired at %d " 7741 brcms_err(core, "wl%d: PSM microcode watchdog fired at %d "
8196 "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now); 7742 "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now);
8197 7743
8198 printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n", 7744 printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n",
@@ -8206,15 +7752,11 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded)
8206 bcma_write32(core, D11REGOFFS(gptimer), 0); 7752 bcma_write32(core, D11REGOFFS(gptimer), 0);
8207 7753
8208 if (macintstatus & MI_RFDISABLE) { 7754 if (macintstatus & MI_RFDISABLE) {
8209 BCMMSG(wlc->wiphy, "wl%d: BMAC Detected a change on the" 7755 brcms_dbg_info(core, "wl%d: BMAC Detected a change on the"
8210 " RF Disable Input\n", wlc_hw->unit); 7756 " RF Disable Input\n", wlc_hw->unit);
8211 brcms_rfkill_set_hw_state(wlc->wl); 7757 brcms_rfkill_set_hw_state(wlc->wl);
8212 } 7758 }
8213 7759
8214 /* send any enq'd tx packets. Just makes sure to jump start tx */
8215 if (!pktq_empty(&wlc->pkt_queue->q))
8216 brcms_c_send_q(wlc);
8217
8218 /* it isn't done and needs to be resched if macintstatus is non-zero */ 7760 /* it isn't done and needs to be resched if macintstatus is non-zero */
8219 return wlc->macintstatus != 0; 7761 return wlc->macintstatus != 0;
8220 7762
@@ -8229,7 +7771,7 @@ void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx)
8229 struct ieee80211_channel *ch = wlc->pub->ieee_hw->conf.channel; 7771 struct ieee80211_channel *ch = wlc->pub->ieee_hw->conf.channel;
8230 u16 chanspec; 7772 u16 chanspec;
8231 7773
8232 BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); 7774 brcms_dbg_info(core, "wl%d\n", wlc->pub->unit);
8233 7775
8234 chanspec = ch20mhz_chspec(ch->hw_value); 7776 chanspec = ch20mhz_chspec(ch->hw_value);
8235 7777
@@ -8286,9 +7828,6 @@ void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx)
8286 bcma_set16(core, D11REGOFFS(ifs_ctl), IFS_USEEDCF); 7828 bcma_set16(core, D11REGOFFS(ifs_ctl), IFS_USEEDCF);
8287 brcms_c_edcf_setparams(wlc, false); 7829 brcms_c_edcf_setparams(wlc, false);
8288 7830
8289 /* Init precedence maps for empty FIFOs */
8290 brcms_c_tx_prec_map_init(wlc);
8291
8292 /* read the ucode version if we have not yet done so */ 7831 /* read the ucode version if we have not yet done so */
8293 if (wlc->ucode_rev == 0) { 7832 if (wlc->ucode_rev == 0) {
8294 wlc->ucode_rev = 7833 wlc->ucode_rev =
@@ -8303,9 +7842,6 @@ void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx)
8303 if (mute_tx) 7842 if (mute_tx)
8304 brcms_b_mute(wlc->hw, true); 7843 brcms_b_mute(wlc->hw, true);
8305 7844
8306 /* clear tx flow control */
8307 brcms_c_txflowcontrol_reset(wlc);
8308
8309 /* enable the RF Disable Delay timer */ 7845 /* enable the RF Disable Delay timer */
8310 bcma_write32(core, D11REGOFFS(rfdisabledly), RFDISABLE_DEFAULT); 7846 bcma_write32(core, D11REGOFFS(rfdisabledly), RFDISABLE_DEFAULT);
8311 7847
@@ -8464,15 +8000,6 @@ brcms_c_attach(struct brcms_info *wl, struct bcma_device *core, uint unit,
8464 * Complete the wlc default state initializations.. 8000 * Complete the wlc default state initializations..
8465 */ 8001 */
8466 8002
8467 /* allocate our initial queue */
8468 wlc->pkt_queue = brcms_c_txq_alloc(wlc);
8469 if (wlc->pkt_queue == NULL) {
8470 wiphy_err(wl->wiphy, "wl%d: %s: failed to malloc tx queue\n",
8471 unit, __func__);
8472 err = 100;
8473 goto fail;
8474 }
8475
8476 wlc->bsscfg->wlc = wlc; 8003 wlc->bsscfg->wlc = wlc;
8477 8004
8478 wlc->mimoft = FT_HT; 8005 wlc->mimoft = FT_HT;