2 * Copyright (c) 2009-2010 Weongyo Jeong <weongyo@freebsd.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 * redistribution must be conditioned upon including a substantially
14 * similar Disclaimer requirement for further binary redistribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
35 struct siba_dev_softc;
39 #define N(a) (sizeof(a) / sizeof(a[0]))
40 #define BWN_ALIGN 0x1000
41 #define BWN_BUS_SPACE_MAXADDR_30BIT 0x3fffffff
42 #define BWN_RETRY_SHORT 7
43 #define BWN_RETRY_LONG 4
44 #define BWN_STAID_MAX 64
45 #define BWN_TXPWR_IGNORE_TIME (1 << 0)
46 #define BWN_TXPWR_IGNORE_TSSI (1 << 1)
47 #define BWN_HAS_TXMAG(phy) \
48 (((phy)->rev >= 2) && ((phy)->rf_ver == 0x2050) && \
50 #define BWN_HAS_LOOPBACK(phy) \
51 (((phy)->rev > 1) || ((phy)->gmode))
52 #define BWN_TXERROR_MAX 1000
53 #define BWN_GETTIME(v) do { \
56 (v) = ts.tv_nsec / 1000000 + ts.tv_sec * 1000; \
58 #define BWN_ISOLDFMT(mac) ((mac)->mac_fw.rev <= 351)
59 #define BWN_TSSI2DBM(num, den) \
60 ((int32_t)((num < 0) ? num / den : (num + den / 2) / den))
61 #define BWN_HDRSIZE(mac) bwn_tx_hdrsize(mac)
62 #define BWN_MAXTXHDRSIZE (112 + (sizeof(struct bwn_plcp6)))
64 #define BWN_PIO_COOKIE(tq, tp) \
65 ((uint16_t)((((uint16_t)tq->tq_index + 1) << 12) | tp->tp_index))
66 #define BWN_DMA_COOKIE(dr, slot) \
67 ((uint16_t)(((uint16_t)dr->dr_index + 1) << 12) | (uint16_t)slot)
68 #define BWN_READ_2(mac, o) (siba_read_2(mac->mac_sc->sc_dev, o))
69 #define BWN_READ_4(mac, o) (siba_read_4(mac->mac_sc->sc_dev, o))
70 #define BWN_WRITE_2(mac, o, v) \
71 (siba_write_2(mac->mac_sc->sc_dev, o, v))
72 #define BWN_WRITE_2_F(mac, o, v) do { \
73 (BWN_WRITE_2(mac, o, v)); \
76 #define BWN_WRITE_SETMASK2(mac, offset, mask, set) \
77 BWN_WRITE_2(mac, offset, (BWN_READ_2(mac, offset) & mask) | set)
78 #define BWN_WRITE_4(mac, o, v) \
79 (siba_write_4(mac->mac_sc->sc_dev, o, v))
80 #define BWN_WRITE_SETMASK4(mac, offset, mask, set) \
81 BWN_WRITE_4(mac, offset, (BWN_READ_4(mac, offset) & mask) | set)
82 #define BWN_PIO_TXQOFFSET(mac) \
83 ((siba_get_revid(mac->mac_sc->sc_dev) >= 11) ? 0x18 : 0)
84 #define BWN_PIO_RXQOFFSET(mac) \
85 ((siba_get_revid(mac->mac_sc->sc_dev) >= 11) ? 0x38 : 8)
86 #define BWN_SEC_NEWAPI(mac) (mac->mac_fw.rev >= 351)
87 #define BWN_SEC_KEY2FW(mac, idx) \
88 (BWN_SEC_NEWAPI(mac) ? idx : ((idx >= 4) ? idx - 4 : idx))
89 #define BWN_RF_READ(mac, r) (mac->mac_phy.rf_read(mac, r))
90 #define BWN_RF_WRITE(mac, r, v) (mac->mac_phy.rf_write(mac, r, v))
91 #define BWN_RF_MASK(mac, o, m) \
92 BWN_RF_WRITE(mac, o, BWN_RF_READ(mac, o) & m)
93 #define BWN_RF_SETMASK(mac, offset, mask, set) \
94 BWN_RF_WRITE(mac, offset, (BWN_RF_READ(mac, offset) & mask) | set)
95 #define BWN_RF_SET(mac, offset, set) \
96 BWN_RF_WRITE(mac, offset, BWN_RF_READ(mac, offset) | set)
97 #define BWN_PHY_READ(mac, r) (mac->mac_phy.phy_read(mac, r))
98 #define BWN_PHY_WRITE(mac, r, v) \
99 (mac->mac_phy.phy_write(mac, r, v))
100 #define BWN_PHY_SET(mac, offset, set) do { \
101 if (mac->mac_phy.phy_maskset != NULL) { \
102 KASSERT(mac->mac_status < BWN_MAC_STATUS_INITED || \
103 mac->mac_suspended > 0, \
104 ("dont access PHY or RF registers after turning on MAC")); \
105 mac->mac_phy.phy_maskset(mac, offset, 0xffff, set); \
107 BWN_PHY_WRITE(mac, offset, \
108 BWN_PHY_READ(mac, offset) | (set)); \
110 #define BWN_PHY_SETMASK(mac, offset, mask, set) do { \
111 if (mac->mac_phy.phy_maskset != NULL) { \
112 KASSERT(mac->mac_status < BWN_MAC_STATUS_INITED || \
113 mac->mac_suspended > 0, \
114 ("dont access PHY or RF registers after turning on MAC")); \
115 mac->mac_phy.phy_maskset(mac, offset, mask, set); \
117 BWN_PHY_WRITE(mac, offset, \
118 (BWN_PHY_READ(mac, offset) & (mask)) | (set)); \
120 #define BWN_PHY_MASK(mac, offset, mask) do { \
121 if (mac->mac_phy.phy_maskset != NULL) { \
122 KASSERT(mac->mac_status < BWN_MAC_STATUS_INITED || \
123 mac->mac_suspended > 0, \
124 ("dont access PHY or RF registers after turning on MAC")); \
125 mac->mac_phy.phy_maskset(mac, offset, mask, 0); \
127 BWN_PHY_WRITE(mac, offset, \
128 BWN_PHY_READ(mac, offset) & mask); \
130 #define BWN_PHY_COPY(mac, dst, src) do { \
131 KASSERT(mac->mac_status < BWN_MAC_STATUS_INITED || \
132 mac->mac_suspended > 0, \
133 ("dont access PHY or RF registers after turning on MAC")); \
134 BWN_PHY_WRITE(mac, dst, BWN_PHY_READ(mac, src)); \
136 #define BWN_LO_CALIB_EXPIRE (1000 * (30 - 2))
137 #define BWN_LO_PWRVEC_EXPIRE (1000 * (30 - 2))
138 #define BWN_LO_TXCTL_EXPIRE (1000 * (180 - 4))
139 #define BWN_DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
140 #define BWN_LPD(L, P, D) (((L) << 2) | ((P) << 1) | ((D) << 0))
141 #define BWN_BITREV4(tmp) (BWN_BITREV8(tmp) >> 4)
142 #define BWN_BITREV8(byte) (bwn_bitrev_table[byte])
143 #define BWN_BBATTCMP(a, b) ((a)->att == (b)->att)
144 #define BWN_RFATTCMP(a, b) \
145 (((a)->att == (b)->att) && ((a)->padmix == (b)->padmix))
146 #define BWN_PIO_WRITE_2(mac, tq, offset, value) \
147 BWN_WRITE_2(mac, (tq)->tq_base + offset, value)
148 #define BWN_PIO_READ_4(mac, tq, offset) \
149 BWN_READ_4(mac, tq->tq_base + offset)
150 #define BWN_ISCCKRATE(rate) \
151 (rate == BWN_CCK_RATE_1MB || rate == BWN_CCK_RATE_2MB || \
152 rate == BWN_CCK_RATE_5MB || rate == BWN_CCK_RATE_11MB)
153 #define BWN_ISOFDMRATE(rate) (!BWN_ISCCKRATE(rate))
154 #define BWN_BARRIER(mac, flags) siba_barrier(mac->mac_sc->sc_dev, flags)
155 #define BWN_DMA_READ(dr, offset) \
156 (BWN_READ_4(dr->dr_mac, dr->dr_base + offset))
157 #define BWN_DMA_WRITE(dr, offset, value) \
158 (BWN_WRITE_4(dr->dr_mac, dr->dr_base + offset, value))
163 BWN_PHY_BAND_5G_LO = 1,
164 BWN_PHY_BAND_5G_MI = 2,
165 BWN_PHY_BAND_5G_HI = 3
176 BWN_CHAN_TYPE_40_HT_U,
177 BWN_CHAN_TYPE_40_HT_D,
187 #define BWN_ANTAUTO0 2
188 #define BWN_ANTAUTO1 3
191 #define BWN_ANTAUTO BWN_ANTAUTO0
192 #define BWN_ANT_DEFAULT BWN_ANTAUTO
193 #define BWN_TX_SLOTS_PER_FRAME 2
201 struct bwn_channelinfo {
202 struct bwn_channel channels[IEEE80211_CHAN_MAX];
210 struct bwn_bbatt_list {
211 const struct bwn_bbatt *array;
222 struct bwn_rfatt_list {
223 const struct bwn_rfatt *array;
229 #define BWN_DC_LT_SIZE 32
237 BWN_TXPWR_RES_NEED_ADJUST,
239 } bwn_txpwr_result_t;
241 struct bwn_lo_calib {
242 struct bwn_bbatt bbatt;
243 struct bwn_rfatt rfatt;
244 struct bwn_loctl ctl;
245 unsigned long calib_time;
246 TAILQ_ENTRY(bwn_lo_calib) list;
252 uint16_t phy_status0;
272 uint16_t phy_status2;
276 uint16_t phy_status3;
279 int8_t phy_ht_power1;
280 int8_t phy_ht_power2;
290 uint16_t phy_status4;
291 uint16_t phy_status5;
299 struct bwn_txstatus {
312 #define BWN_TXCTL_PA3DB 0x40
313 #define BWN_TXCTL_PA2DB 0x20
314 #define BWN_TXCTL_TXMIX 0x10
316 struct bwn_txpwr_loctl {
317 struct bwn_rfatt_list rfatt;
318 struct bwn_bbatt_list bbatt;
319 uint16_t dc_lt[BWN_DC_LT_SIZE];
320 TAILQ_HEAD(, bwn_lo_calib) calib_list;
321 unsigned long pwr_vec_read_time;
322 unsigned long txctl_measured_time;
325 uint64_t power_vector;
328 #define BWN_OFDMTAB_DIR_UNKNOWN 0
329 #define BWN_OFDMTAB_DIR_READ 1
330 #define BWN_OFDMTAB_DIR_WRITE 2
334 #define BWN_PHY_G_FLAG_TSSITABLE_ALLOC (1 << 0)
335 #define BWN_PHY_G_FLAG_RADIOCTX_VALID (1 << 1)
337 int pg_aci_wlan_automatic;
340 uint16_t pg_radioctx_over;
341 uint16_t pg_radioctx_overval;
342 uint16_t pg_minlowsig[2];
343 uint16_t pg_minlowsigpos[2];
348 struct bwn_bbatt pg_bbatt;
349 struct bwn_rfatt pg_rfatt;
354 struct bwn_txpwr_loctl pg_loctl;
355 int16_t pg_max_lb_gain;
356 int16_t pg_trsw_rx_gain;
357 int16_t pg_lna_lod_gain;
361 #define BWN_INTERFSTACK_SIZE 26
362 uint32_t pg_interfstack[BWN_INTERFSTACK_SIZE];
365 int32_t pg_nrssi_slope;
366 int8_t pg_nrssi_lt[64];
371 uint16_t pg_ofdmtab_addr;
372 unsigned pg_ofdmtab_dir;
375 #define BWN_IMMODE_NONE 0
376 #define BWN_IMMODE_NONWLAN 1
377 #define BWN_IMMODE_MANUAL 2
378 #define BWN_IMMODE_AUTO 3
380 #define BWN_PHYLP_TXPCTL_UNKNOWN 0
381 #define BWN_PHYLP_TXPCTL_OFF 1
382 #define BWN_PHYLP_TXPCTL_ON_SW 2
383 #define BWN_PHYLP_TXPCTL_ON_HW 3
387 uint8_t plp_chanfullcal;
389 uint8_t plp_txpctlmode;
390 uint8_t plp_txisoband_h;
391 uint8_t plp_txisoband_m;
392 uint8_t plp_txisoband_l;
393 uint8_t plp_rxpwroffset;
395 uint16_t plp_tssiidx;
396 uint16_t plp_tssinpt;
402 uint8_t plp_crsusr_off;
403 uint8_t plp_crssys_off;
405 int32_t plp_tonefreq;
406 uint16_t plp_digfilt[9];
417 struct bwn_rxcompco {
423 struct bwn_phy_lp_iq_est {
429 struct bwn_txgain_entry {
437 /* only for LP PHY */
438 struct bwn_stxtable {
439 uint16_t st_phyoffset;
440 uint16_t st_physhift;
446 struct bwn_b206x_chan {
449 const uint8_t *bc_data;
452 struct bwn_b206x_rfinit_entry {
470 struct bwn_phy_g phy_g;
471 struct bwn_phy_lp phy_lp;
474 * I'd like the newer PHY code to not hide in the top-level
477 struct bwn_phy_n *phy_n;
483 int phy_do_full_init;
487 unsigned long nexttime;
491 int (*attach)(struct bwn_mac *);
492 void (*detach)(struct bwn_mac *);
493 int (*prepare_hw)(struct bwn_mac *);
494 void (*init_pre)(struct bwn_mac *);
495 int (*init)(struct bwn_mac *);
496 void (*exit)(struct bwn_mac *);
497 uint16_t (*phy_read)(struct bwn_mac *, uint16_t);
498 void (*phy_write)(struct bwn_mac *, uint16_t,
500 void (*phy_maskset)(struct bwn_mac *,
501 uint16_t, uint16_t, uint16_t);
502 uint16_t (*rf_read)(struct bwn_mac *, uint16_t);
503 void (*rf_write)(struct bwn_mac *, uint16_t,
505 int (*use_hwpctl)(struct bwn_mac *);
506 void (*rf_onoff)(struct bwn_mac *, int);
507 void (*switch_analog)(struct bwn_mac *, int);
508 int (*switch_channel)(struct bwn_mac *,
510 uint32_t (*get_default_chan)(struct bwn_mac *);
511 void (*set_antenna)(struct bwn_mac *, int);
512 int (*set_im)(struct bwn_mac *, int);
513 bwn_txpwr_result_t (*recalc_txpwr)(struct bwn_mac *, int);
514 void (*set_txpwr)(struct bwn_mac *);
515 void (*task_15s)(struct bwn_mac *);
516 void (*task_60s)(struct bwn_mac *);
519 struct bwn_chan_band {
522 #define BWN_MAX_CHAN_PER_BAND 14
523 uint8_t chan[BWN_MAX_CHAN_PER_BAND];
526 #define BWN_NR_WMEPARAMS 16
528 BWN_WMEPARAM_TXOP = 0,
538 #define BWN_WME_PARAMS(queue) \
539 (BWN_SHARED_EDCFQ + (BWN_NR_WMEPARAMS * sizeof(uint16_t) * (queue)))
540 #define BWN_WME_BACKGROUND BWN_WME_PARAMS(0)
541 #define BWN_WME_BESTEFFORT BWN_WME_PARAMS(1)
542 #define BWN_WME_VIDEO BWN_WME_PARAMS(2)
543 #define BWN_WME_VOICE BWN_WME_PARAMS(3)
546 * Radio capture format.
548 #define BWN_RX_RADIOTAP_PRESENT ( \
549 (1 << IEEE80211_RADIOTAP_TSFT) | \
550 (1 << IEEE80211_RADIOTAP_FLAGS) | \
551 (1 << IEEE80211_RADIOTAP_RATE) | \
552 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
553 (1 << IEEE80211_RADIOTAP_ANTENNA) | \
554 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
555 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \
558 struct bwn_rx_radiotap_header {
559 struct ieee80211_radiotap_header wr_ihdr;
563 u_int16_t wr_chan_freq;
564 u_int16_t wr_chan_flags;
568 } __packed __aligned(8);
570 #define BWN_TX_RADIOTAP_PRESENT ( \
571 (1 << IEEE80211_RADIOTAP_FLAGS) | \
572 (1 << IEEE80211_RADIOTAP_RATE) | \
573 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
574 (1 << IEEE80211_RADIOTAP_DBM_TX_POWER) | \
575 (1 << IEEE80211_RADIOTAP_ANTENNA) | \
578 struct bwn_tx_radiotap_header {
579 struct ieee80211_radiotap_header wt_ihdr;
582 u_int16_t wt_chan_freq;
583 u_int16_t wt_chan_flags;
594 /* Noise Calculation (Link Quality) */
597 uint8_t noi_nsamples;
598 int8_t noi_samples[8][4];
601 #define BWN_DMA_30BIT 30
602 #define BWN_DMA_32BIT 32
603 #define BWN_DMA_64BIT 64
605 struct bwn_dmadesc_meta {
606 bus_dmamap_t mt_dmap;
609 struct ieee80211_node *mt_ni;
611 #define BWN_DMADESC_METATYPE_HEADER 0
612 #define BWN_DMADESC_METATYPE_BODY 1
616 #define BWN_DMAINTR_FATALMASK \
617 ((1 << 10) | (1 << 11) | (1 << 12) | (1 << 14) | (1 << 15))
618 #define BWN_DMAINTR_NONFATALMASK (1 << 13)
619 #define BWN_DMAINTR_RX_DONE (1 << 16)
621 #define BWN_DMA32_DCTL_BYTECNT 0x00001fff
622 #define BWN_DMA32_DCTL_ADDREXT_MASK 0x00030000
623 #define BWN_DMA32_DCTL_ADDREXT_SHIFT 16
624 #define BWN_DMA32_DCTL_DTABLEEND 0x10000000
625 #define BWN_DMA32_DCTL_IRQ 0x20000000
626 #define BWN_DMA32_DCTL_FRAMEEND 0x40000000
627 #define BWN_DMA32_DCTL_FRAMESTART 0x80000000
628 struct bwn_dmadesc32 {
633 #define BWN_DMA64_DCTL0_DTABLEEND 0x10000000
634 #define BWN_DMA64_DCTL0_IRQ 0x20000000
635 #define BWN_DMA64_DCTL0_FRAMEEND 0x40000000
636 #define BWN_DMA64_DCTL0_FRAMESTART 0x80000000
637 #define BWN_DMA64_DCTL1_BYTECNT 0x00001fff
638 #define BWN_DMA64_DCTL1_ADDREXT_MASK 0x00030000
639 #define BWN_DMA64_DCTL1_ADDREXT_SHIFT 16
640 struct bwn_dmadesc64 {
643 uint32_t address_low;
644 uint32_t address_high;
647 struct bwn_dmadesc_generic {
649 struct bwn_dmadesc32 dma32;
650 struct bwn_dmadesc64 dma64;
656 struct bwn_dma_ring {
657 struct bwn_mac *dr_mac;
658 const struct bwn_dma_ops *dr_ops;
659 struct bwn_dmadesc_meta *dr_meta;
660 void *dr_txhdr_cache;
661 bus_dma_tag_t dr_ring_dtag;
662 bus_dma_tag_t dr_txring_dtag;
663 bus_dmamap_t dr_spare_dmap; /* only for RX */
664 bus_dmamap_t dr_ring_dmap;
665 bus_addr_t dr_txring_paddr;
666 void *dr_ring_descbase;
667 bus_addr_t dr_ring_dmabase;
671 uint32_t dr_frameoffset;
672 uint16_t dr_rx_bufsize;
679 void (*getdesc)(struct bwn_dma_ring *,
680 int, struct bwn_dmadesc_generic **,
681 struct bwn_dmadesc_meta **);
682 void (*setdesc)(struct bwn_dma_ring *,
683 struct bwn_dmadesc_generic *,
684 bus_addr_t, uint16_t, int, int,
686 void (*start_transfer)(struct bwn_dma_ring *,
688 void (*suspend)(struct bwn_dma_ring *);
689 void (*resume)(struct bwn_dma_ring *);
690 int (*get_curslot)(struct bwn_dma_ring *);
691 void (*set_curslot)(struct bwn_dma_ring *,
697 bus_dma_tag_t parent_dtag;
698 bus_dma_tag_t rxbuf_dtag;
699 bus_dma_tag_t txbuf_dtag;
701 struct bwn_dma_ring *wme[5];
702 struct bwn_dma_ring *mcast;
703 struct bwn_dma_ring *rx;
704 uint64_t lastseq; /* XXX FIXME */
707 struct bwn_pio_rxqueue {
708 struct bwn_mac *prq_mac;
713 struct bwn_pio_txqueue;
714 struct bwn_pio_txpkt {
715 struct bwn_pio_txqueue *tp_queue;
716 struct ieee80211_node *tp_ni;
719 TAILQ_ENTRY(bwn_pio_txpkt) tp_list;
722 #define BWN_PIO_MAX_TXPACKETS 32
723 struct bwn_pio_txqueue {
729 struct bwn_pio_txpkt tq_pkts[BWN_PIO_MAX_TXPACKETS];
730 TAILQ_HEAD(, bwn_pio_txpkt) tq_pktlist;
734 struct bwn_pio_txqueue wme[5];
735 struct bwn_pio_txqueue mcast;
736 struct bwn_pio_rxqueue rx;
760 uint16_t phyctl_1rts;
761 uint16_t phyctl_1rtsfb;
764 uint8_t eftypes; /* extra frame types */
767 uint8_t addr1[IEEE80211_ADDR_LEN];
768 uint16_t tx_festime_fb;
769 struct bwn_plcp6 rts_plcp_fb;
771 struct bwn_plcp6 plcp_fb;
773 uint16_t mimo_modelen;
774 uint16_t mimo_ratelen_fb;
783 struct bwn_plcp6 rts_plcp;
784 uint8_t rts_frame[16];
786 struct bwn_plcp6 plcp;
788 /* format > r410 < r598 */
790 uint16_t mimo_antenna;
791 uint16_t preload_size;
795 struct bwn_plcp6 rts_plcp;
796 uint8_t rts_frame[16];
798 struct bwn_plcp6 plcp;
801 uint16_t mimo_antenna;
802 uint16_t preload_size;
806 uint16_t max_n_mpdus;
807 uint16_t max_a_bytes_mrt;
808 uint16_t max_a_bytes_fbr;
809 uint16_t min_m_bytes;
810 struct bwn_plcp6 rts_plcp;
811 uint8_t rts_frame[16];
813 struct bwn_plcp6 plcp;
818 #define BWN_FWTYPE_UCODE 'u'
819 #define BWN_FWTYPE_PCM 'p'
820 #define BWN_FWTYPE_IV 'i'
828 #define BWN_FWINITVALS_OFFSET_MASK 0x7fff
829 #define BWN_FWINITVALS_32BIT 0x8000
830 struct bwn_fwinitvals {
831 uint16_t offset_size;
838 enum bwn_fw_hdr_format {
846 BWN_FWTYPE_OPENSOURCE,
851 const char *filename;
852 const struct firmware *fw;
853 enum bwn_fwtype type;
862 struct bwn_fwfile ucode;
863 struct bwn_fwfile pcm;
864 struct bwn_fwfile initvals;
865 struct bwn_fwfile initvals_band;
866 enum bwn_fw_hdr_format fw_hdr_format;
879 struct bwn_loctl loctl;
882 struct bwn_lo_g_value {
886 uint16_t phy_dacctl_hwpctl;
888 uint16_t phy_hpwr_tssictl;
889 uint16_t phy_analogover;
890 uint16_t phy_analogoverval;
892 uint16_t phy_rfoverval;
893 uint16_t phy_classctl;
896 uint16_t phy_syncctl;
909 #define BWN_LED_MAX 4
911 #define BWN_LED_EVENT_NONE -1
912 #define BWN_LED_EVENT_POLL 0
913 #define BWN_LED_EVENT_TX 1
914 #define BWN_LED_EVENT_RX 2
915 #define BWN_LED_SLOWDOWN(dur) (dur) = (((dur) * 3) / 2)
918 uint8_t led_flags; /* BWN_LED_F_ */
919 uint8_t led_act; /* BWN_LED_ACT_ */
923 #define BWN_LED_F_ACTLOW 0x1
924 #define BWN_LED_F_BLINK 0x2
925 #define BWN_LED_F_POLLABLE 0x4
926 #define BWN_LED_F_SLOW 0x8
929 struct bwn_softc *mac_sc;
931 #define BWN_MAC_STATUS_UNINIT 0
932 #define BWN_MAC_STATUS_INITED 1
933 #define BWN_MAC_STATUS_STARTED 2
935 /* use "Bad Frames Preemption" */
936 #define BWN_MAC_FLAG_BADFRAME_PREEMP (1 << 0)
937 #define BWN_MAC_FLAG_DFQVALID (1 << 1)
938 #define BWN_MAC_FLAG_RADIO_ON (1 << 2)
939 #define BWN_MAC_FLAG_DMA (1 << 3)
940 #define BWN_MAC_FLAG_WME (1 << 4)
941 #define BWN_MAC_FLAG_HWCRYPTO (1 << 5)
943 struct resource_spec *mac_intr_spec;
944 #define BWN_MSI_MESSAGES 1
945 struct resource *mac_res_irq[BWN_MSI_MESSAGES];
946 void *mac_intrhand[BWN_MSI_MESSAGES];
949 struct bwn_noise mac_noise;
950 struct bwn_phy mac_phy;
951 struct bwn_stats mac_stats;
952 uint32_t mac_reason_intr;
953 uint32_t mac_reason[6];
954 uint32_t mac_intr_mask;
957 struct bwn_fw mac_fw;
964 uint16_t mac_ktp; /* Key table pointer */
965 uint8_t mac_max_nr_keys;
966 struct bwn_key mac_key[58];
968 unsigned int mac_task_state;
969 struct task mac_intrtask;
970 struct task mac_hwreset;
971 struct task mac_txpower;
973 TAILQ_ENTRY(bwn_mac) mac_list;
977 bwn_tx_hdrsize(struct bwn_mac *mac)
979 switch (mac->mac_fw.fw_hdr_format) {
981 return (112 + (sizeof(struct bwn_plcp6)));
983 return (104 + (sizeof(struct bwn_plcp6)));
985 return (100 + (sizeof(struct bwn_plcp6)));
987 printf("%s: unknown header format (%d)\n", __func__,
988 mac->mac_fw.fw_hdr_format);
989 return (112 + (sizeof(struct bwn_plcp6)));
994 * Driver-specific vap state.
997 struct ieee80211vap bv_vap; /* base class */
998 int (*bv_newstate)(struct ieee80211vap *,
999 enum ieee80211_state, int);
1001 #define BWN_VAP(vap) ((struct bwn_vap *)(vap))
1002 #define BWN_VAP_CONST(vap) ((const struct mwl_vap *)(vap))
1007 struct ieee80211com sc_ic;
1008 struct mbufq sc_snd;
1010 #define BWN_FLAG_ATTACHED (1 << 0)
1011 #define BWN_FLAG_INVALID (1 << 1)
1012 #define BWN_FLAG_NEED_BEACON_TP (1 << 2)
1013 #define BWN_FLAG_RUNNING (1 << 3)
1016 struct bwn_mac *sc_curmac;
1017 TAILQ_HEAD(, bwn_mac) sc_maclist;
1019 uint8_t sc_bssid[IEEE80211_ADDR_LEN];
1020 unsigned int sc_filters;
1021 uint8_t sc_beacons[2];
1022 uint8_t sc_rf_enabled;
1024 struct wmeParams sc_wmeParams[4];
1026 struct callout sc_rfswitch_ch; /* for laptop */
1027 struct callout sc_task_ch;
1028 struct callout sc_watchdog_ch;
1029 int sc_watchdog_timer;
1030 struct taskqueue *sc_tq; /* private task queue */
1031 int (*sc_newstate)(struct ieee80211com *,
1032 enum ieee80211_state, int);
1033 void (*sc_node_cleanup)(
1034 struct ieee80211_node *);
1039 int sc_led_blinking;
1041 struct bwn_led *sc_blink_led;
1042 struct callout sc_led_blink_ch;
1043 int sc_led_blink_offdur;
1044 struct bwn_led sc_leds[BWN_LED_MAX];
1048 struct bwn_tx_radiotap_header sc_tx_th;
1049 struct bwn_rx_radiotap_header sc_rx_th;
1052 #define BWN_LOCK_INIT(sc) \
1053 mtx_init(&(sc)->sc_mtx, device_get_nameunit((sc)->sc_dev), \
1054 MTX_NETWORK_LOCK, MTX_DEF)
1055 #define BWN_LOCK_DESTROY(sc) mtx_destroy(&(sc)->sc_mtx)
1056 #define BWN_LOCK(sc) mtx_lock(&(sc)->sc_mtx)
1057 #define BWN_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx)
1058 #define BWN_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED)
1060 static inline bwn_band_t
1061 bwn_channel_band(struct bwn_mac *mac, struct ieee80211_channel *c)
1063 if (IEEE80211_IS_CHAN_5GHZ(c))
1065 /* XXX check 2g, log error if not 2g or 5g? */
1069 static inline bwn_band_t
1070 bwn_current_band(struct bwn_mac *mac)
1072 struct ieee80211com *ic = &mac->mac_sc->sc_ic;
1073 if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan))
1075 /* XXX check 2g, log error if not 2g or 5g? */
1080 bwn_is_40mhz(struct bwn_mac *mac)
1082 struct ieee80211com *ic = &mac->mac_sc->sc_ic;
1084 return !! (IEEE80211_IS_CHAN_HT40(ic->ic_curchan));
1088 bwn_get_centre_freq(struct bwn_mac *mac)
1091 struct ieee80211com *ic = &mac->mac_sc->sc_ic;
1092 /* XXX TODO: calculate correctly for HT40 mode */
1093 return ic->ic_curchan->ic_freq;
1097 bwn_get_chan_centre_freq(struct bwn_mac *mac, struct ieee80211_channel *chan)
1100 /* XXX TODO: calculate correctly for HT40 mode */
1101 return chan->ic_freq;
1105 bwn_get_chan(struct bwn_mac *mac)
1108 struct ieee80211com *ic = &mac->mac_sc->sc_ic;
1109 /* XXX TODO: calculate correctly for HT40 mode */
1110 return ic->ic_curchan->ic_ieee;
1113 static inline struct ieee80211_channel *
1114 bwn_get_channel(struct bwn_mac *mac)
1117 struct ieee80211com *ic = &mac->mac_sc->sc_ic;
1118 return ic->ic_curchan;
1122 bwn_is_chan_passive(struct bwn_mac *mac)
1125 struct ieee80211com *ic = &mac->mac_sc->sc_ic;
1126 return !! IEEE80211_IS_CHAN_PASSIVE(ic->ic_curchan);
1129 static inline bwn_chan_type_t
1130 bwn_get_chan_type(struct bwn_mac *mac, struct ieee80211_channel *c)
1132 struct ieee80211com *ic = &mac->mac_sc->sc_ic;
1135 if (IEEE80211_IS_CHAN_HT40U(c))
1136 return BWN_CHAN_TYPE_40_HT_U;
1137 else if (IEEE80211_IS_CHAN_HT40D(c))
1138 return BWN_CHAN_TYPE_40_HT_D;
1139 else if (IEEE80211_IS_CHAN_HT20(c))
1140 return BWN_CHAN_TYPE_20_HT;
1142 return BWN_CHAN_TYPE_20;
1146 bwn_get_chan_power(struct bwn_mac *mac, struct ieee80211_channel *c)
1150 return c->ic_maxpower / 2;
1154 * For now there's no bhnd bus support. Places where it matters
1155 * should call this routine so we can start logging things.
1158 bwn_is_bus_siba(struct bwn_mac *mac)
1163 #endif /* !_IF_BWNVAR_H */