diff --git a/sys/dev/rtwn/rtl8812a/r12a_var.h b/sys/dev/rtwn/rtl8812a/r12a_var.h index 182e6b902758..0a76e013b6a7 100644 --- a/sys/dev/rtwn/rtl8812a/r12a_var.h +++ b/sys/dev/rtwn/rtl8812a/r12a_var.h @@ -1,124 +1,125 @@ /*- * Copyright (c) 2016 Andriy Voskoboinyk * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef R12A_VAR_H #define R12A_VAR_H #include struct r12a_softc { uint8_t chip; #define R12A_CHIP_C_CUT 0x01 uint8_t rs_flags; #define R12A_RXCKSUM_EN 0x01 #define R12A_RXCKSUM6_EN 0x02 #define R12A_IQK_RUNNING 0x04 #define R12A_RADAR_ENABLED 0x08 int rs_radar; struct timeout_task rs_chan_check; /* ROM variables */ int ext_pa_2g:1, ext_pa_5g:1, ext_lna_2g:1, ext_lna_5g:1, type_pa_2g:4, type_pa_5g:4, type_lna_2g:4, type_lna_5g:4, bt_coex:1, bt_ant_num:1; uint8_t board_type; uint8_t regulatory; uint8_t crystalcap; uint8_t rfe_type; uint8_t tx_bbswing_2g; uint8_t tx_bbswing_5g; uint8_t cck_tx_pwr[R12A_MAX_RF_PATH][R12A_GROUP_2G]; uint8_t ht40_tx_pwr_2g[R12A_MAX_RF_PATH][R12A_GROUP_2G]; uint8_t ht40_tx_pwr_5g[R12A_MAX_RF_PATH][R12A_GROUP_5G]; int8_t cck_tx_pwr_diff_2g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT]; int8_t ofdm_tx_pwr_diff_2g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT]; int8_t bw20_tx_pwr_diff_2g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT]; int8_t bw40_tx_pwr_diff_2g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT]; int8_t ofdm_tx_pwr_diff_5g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT]; int8_t bw20_tx_pwr_diff_5g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT]; int8_t bw40_tx_pwr_diff_5g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT]; int8_t bw80_tx_pwr_diff_5g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT]; int8_t bw160_tx_pwr_diff_5g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT]; int sc_ant; int (*rs_newstate[RTWN_PORT_COUNT])(struct ieee80211vap *, enum ieee80211_state, int); void (*rs_scan_start)(struct ieee80211com *); void (*rs_scan_end)(struct ieee80211com *); void (*rs_crystalcap_write)(struct rtwn_softc *); void (*rs_fix_spur)(struct rtwn_softc *, struct ieee80211_channel *); void (*rs_set_band_2ghz)(struct rtwn_softc *, uint32_t); void (*rs_set_band_5ghz)(struct rtwn_softc *, uint32_t); void (*rs_init_burstlen)(struct rtwn_softc *); void (*rs_init_ampdu_fwhw)(struct rtwn_softc *); #ifndef RTWN_WITHOUT_UCODE int (*rs_iq_calib_fw_supported)(struct rtwn_softc *); #endif void (*rs_iq_calib_sw)(struct rtwn_softc *); int ac_usb_dma_size; int ac_usb_dma_time; int ampdu_max_time; + int ampdu_max_size; }; #define R12A_SOFTC(_sc) ((struct r12a_softc *)((_sc)->sc_priv)) #define rtwn_r12a_fix_spur(_sc, _c) \ ((R12A_SOFTC(_sc)->rs_fix_spur)((_sc), (_c))) #define rtwn_r12a_set_band_2ghz(_sc, _rates) \ ((R12A_SOFTC(_sc)->rs_set_band_2ghz)((_sc), (_rates))) #define rtwn_r12a_set_band_5ghz(_sc, _rates) \ ((R12A_SOFTC(_sc)->rs_set_band_5ghz)((_sc), (_rates))) #define rtwn_r12a_init_burstlen(_sc) \ ((R12A_SOFTC(_sc)->rs_init_burstlen)((_sc))) #define rtwn_r12a_init_ampdu_fwhw(_sc) \ ((R12A_SOFTC(_sc)->rs_init_ampdu_fwhw)((_sc))) #define rtwn_r12a_crystalcap_write(_sc) \ ((R12A_SOFTC(_sc)->rs_crystalcap_write)((_sc))) #ifndef RTWN_WITHOUT_UCODE #define rtwn_r12a_iq_calib_fw_supported(_sc) \ ((R12A_SOFTC(_sc)->rs_iq_calib_fw_supported)((_sc))) #endif #define rtwn_r12a_iq_calib_sw(_sc) \ ((R12A_SOFTC(_sc)->rs_iq_calib_sw)((_sc))) #endif /* R12A_VAR_H */ diff --git a/sys/dev/rtwn/rtl8812a/usb/r12au_attach.c b/sys/dev/rtwn/rtl8812a/usb/r12au_attach.c index 84bfcfbda0e8..c87bffb4db19 100644 --- a/sys/dev/rtwn/rtl8812a/usb/r12au_attach.c +++ b/sys/dev/rtwn/rtl8812a/usb/r12au_attach.c @@ -1,305 +1,306 @@ /*- * Copyright (c) 2016 Andriy Voskoboinyk * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include "opt_wlan.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void r12au_attach(struct rtwn_usb_softc *); static void r12au_postattach(struct rtwn_softc *sc) { struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); struct r12a_softc *rs = sc->sc_priv; if (usbd_get_speed(uc->uc_udev) == USB_SPEED_SUPER) { rs->ac_usb_dma_size = 0x07; rs->ac_usb_dma_time = 0x1a; } else { rs->ac_usb_dma_size = 0x01; rs->ac_usb_dma_time = 0x10; } if (rs->chip & R12A_CHIP_C_CUT) sc->sc_rf_read = r12a_c_cut_rf_read; else sc->sc_rf_read = r12a_rf_read; if (rs->board_type == R92C_BOARD_TYPE_MINICARD || rs->board_type == R92C_BOARD_TYPE_SOLO || rs->board_type == R92C_BOARD_TYPE_COMBO) sc->sc_set_led = r88e_set_led; else sc->sc_set_led = r12a_set_led; if (!(rs->ext_pa_2g || rs->ext_lna_2g || rs->ext_pa_5g || rs->ext_lna_5g)) sc->mac_prog = &rtl8812au_mac_no_ext_pa_lna[0]; sc->sc_ic.ic_ioctl = r12a_ioctl_net; } void r12a_vap_preattach(struct rtwn_softc *sc, struct ieee80211vap *vap) { struct r12a_softc *rs = sc->sc_priv; if_t ifp = vap->iv_ifp; if_setcapabilities(ifp, IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6); RTWN_LOCK(sc); if (rs->rs_flags & R12A_RXCKSUM_EN) if_setcapenablebit(ifp, IFCAP_RXCSUM, 0); if (rs->rs_flags & R12A_RXCKSUM6_EN) if_setcapenablebit(ifp, IFCAP_RXCSUM_IPV6, 0); RTWN_UNLOCK(sc); } static void r12a_attach_private(struct rtwn_softc *sc) { struct r12a_softc *rs; rs = malloc(sizeof(struct r12a_softc), M_RTWN_PRIV, M_WAITOK | M_ZERO); rs->rs_flags = R12A_RXCKSUM_EN | R12A_RXCKSUM6_EN; rs->rs_fix_spur = r12a_fix_spur; rs->rs_set_band_2ghz = r12a_set_band_2ghz; rs->rs_set_band_5ghz = r12a_set_band_5ghz; rs->rs_init_burstlen = r12au_init_burstlen; rs->rs_init_ampdu_fwhw = r12au_init_ampdu_fwhw; rs->rs_crystalcap_write = r12a_crystalcap_write; #ifndef RTWN_WITHOUT_UCODE rs->rs_iq_calib_fw_supported = r12a_iq_calib_fw_supported; #endif rs->rs_iq_calib_sw = r12a_iq_calib_sw; rs->ampdu_max_time = 0x70; + rs->ampdu_max_size = 0x1ffff; /* 128k */ sc->sc_priv = rs; } void r12a_detach_private(struct rtwn_softc *sc) { struct r12a_softc *rs = sc->sc_priv; free(rs, M_RTWN_PRIV); } static void r12a_read_chipid_vendor(struct rtwn_softc *sc, uint32_t reg_sys_cfg) { struct r12a_softc *rs = sc->sc_priv; if (MS(reg_sys_cfg, R92C_SYS_CFG_CHIP_VER_RTL) == 1) rs->chip |= R12A_CHIP_C_CUT; } static void r12au_adj_devcaps(struct rtwn_softc *sc) { struct r12a_softc *rs = sc->sc_priv; struct ieee80211com *ic = &sc->sc_ic; if (rs->chip & R12A_CHIP_C_CUT) { ic->ic_htcaps |= IEEE80211_HTCAP_LDPC | IEEE80211_HTC_TXLDPC; } ic->ic_htcaps |= IEEE80211_HTCAP_CHWIDTH40 /* 40 MHz channel width */ | IEEE80211_HTCAP_SHORTGI40 /* short GI in 40MHz */ ; /* TODO: STBC, VHT etc */ } void r12au_attach(struct rtwn_usb_softc *uc) { struct rtwn_softc *sc = &uc->uc_sc; /* USB part. */ uc->uc_align_rx = r12au_align_rx; uc->tx_agg_desc_num = 1; /* Common part. */ sc->sc_flags = RTWN_FLAG_EXT_HDR; sc->sc_set_chan = r12a_set_chan; sc->sc_fill_tx_desc = r12a_fill_tx_desc; sc->sc_fill_tx_desc_raw = r12a_fill_tx_desc_raw; sc->sc_fill_tx_desc_null = r12a_fill_tx_desc_null; sc->sc_dump_tx_desc = r12au_dump_tx_desc; sc->sc_tx_radiotap_flags = r12a_tx_radiotap_flags; sc->sc_rx_radiotap_flags = r12a_rx_radiotap_flags; sc->sc_get_rx_stats = r12a_get_rx_stats; sc->sc_get_rssi_cck = r88e_get_rssi_cck; sc->sc_get_rssi_ofdm = r88e_get_rssi_ofdm; sc->sc_classify_intr = r12au_classify_intr; sc->sc_handle_tx_report = r12a_ratectl_tx_complete; sc->sc_handle_tx_report2 = rtwn_nop_softc_uint8_int; sc->sc_handle_c2h_report = r12a_handle_c2h_report; sc->sc_check_frame = r12a_check_frame_checksum; sc->sc_rf_write = r12a_rf_write; sc->sc_check_condition = r12a_check_condition; sc->sc_efuse_postread = rtwn_nop_softc; sc->sc_parse_rom = r12a_parse_rom; sc->sc_power_on = r12a_power_on; sc->sc_power_off = r12a_power_off; #ifndef RTWN_WITHOUT_UCODE sc->sc_fw_reset = r12a_fw_reset; sc->sc_fw_download_enable = r12a_fw_download_enable; #endif sc->sc_llt_init = r92c_llt_init; sc->sc_set_page_size = r12a_set_page_size; sc->sc_lc_calib = r12a_lc_calib; sc->sc_iq_calib = r12a_iq_calib; sc->sc_read_chipid_vendor = r12a_read_chipid_vendor; sc->sc_adj_devcaps = r12au_adj_devcaps; sc->sc_vap_preattach = r12a_vap_preattach; sc->sc_postattach = r12au_postattach; sc->sc_detach_private = r12a_detach_private; #ifndef RTWN_WITHOUT_UCODE sc->sc_set_media_status = r12a_set_media_status; sc->sc_set_rsvd_page = r88e_set_rsvd_page; sc->sc_set_pwrmode = r12a_set_pwrmode; sc->sc_set_rssi = rtwn_nop_softc; /* XXX TODO */ #else sc->sc_set_media_status = rtwn_nop_softc_int; #endif sc->sc_beacon_init = r12a_beacon_init; sc->sc_beacon_enable = r92c_beacon_enable; sc->sc_sta_beacon_enable = r12a_sta_beacon_enable; sc->sc_beacon_set_rate = r12a_beacon_set_rate; sc->sc_beacon_select = rtwn_nop_softc_int; sc->sc_temp_measure = r88e_temp_measure; sc->sc_temp_read = r88e_temp_read; sc->sc_init_tx_agg = r92cu_init_tx_agg; sc->sc_init_rx_agg = r12au_init_rx_agg; sc->sc_init_ampdu = r12au_init_ampdu; sc->sc_init_intr = r12a_init_intr; sc->sc_init_edca = r12a_init_edca; sc->sc_init_bb = r12a_init_bb; sc->sc_init_rf = r12a_init_rf; sc->sc_init_antsel = r12a_init_antsel; sc->sc_post_init = r12au_post_init; sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc; sc->sc_set_tx_power = rtwn_nop_int_softc_vap; sc->chan_list_5ghz[0] = r12a_chan_5ghz_0; sc->chan_list_5ghz[1] = r12a_chan_5ghz_1; sc->chan_list_5ghz[2] = r12a_chan_5ghz_2; sc->chan_num_5ghz[0] = nitems(r12a_chan_5ghz_0); sc->chan_num_5ghz[1] = nitems(r12a_chan_5ghz_1); sc->chan_num_5ghz[2] = nitems(r12a_chan_5ghz_2); sc->mac_prog = &rtl8812au_mac[0]; sc->mac_size = nitems(rtl8812au_mac); sc->bb_prog = &rtl8812au_bb[0]; sc->bb_size = nitems(rtl8812au_bb); sc->agc_prog = &rtl8812au_agc[0]; sc->agc_size = nitems(rtl8812au_agc); sc->rf_prog = &rtl8812au_rf[0]; sc->name = "RTL8812AU"; sc->fwname = "rtwn-rtl8812aufw"; sc->fwsig = 0x950; sc->page_count = R12A_TX_PAGE_COUNT; sc->pktbuf_count = R12A_TXPKTBUF_COUNT; sc->ackto = 0x80; sc->npubqpages = R12A_PUBQ_NPAGES; sc->page_size = R12A_TX_PAGE_SIZE; sc->txdesc_len = sizeof(struct r12au_tx_desc); sc->efuse_maxlen = R12A_EFUSE_MAX_LEN; sc->efuse_maplen = R12A_EFUSE_MAP_LEN; sc->rx_dma_size = R12A_RX_DMA_BUFFER_SIZE; sc->macid_limit = R12A_MACID_MAX + 1; sc->cam_entry_limit = R12A_CAM_ENTRY_COUNT; sc->fwsize_limit = R12A_MAX_FW_SIZE; sc->temp_delta = R88E_CALIB_THRESHOLD; sc->bcn_status_reg[0] = R92C_TDECTRL; sc->bcn_status_reg[1] = R92C_TDECTRL; sc->rcr = R12A_RCR_DIS_CHK_14 | R12A_RCR_VHT_ACK | R12A_RCR_TCP_OFFLD_EN; sc->ntxchains = 2; sc->nrxchains = 2; sc->sc_ht40 = 1; r12a_attach_private(sc); } diff --git a/sys/dev/rtwn/rtl8812a/usb/r12au_init.c b/sys/dev/rtwn/rtl8812a/usb/r12au_init.c index ac6a599895ac..1bee2c665657 100644 --- a/sys/dev/rtwn/rtl8812a/usb/r12au_init.c +++ b/sys/dev/rtwn/rtl8812a/usb/r12au_init.c @@ -1,197 +1,207 @@ /*- * Copyright (c) 2016 Andriy Voskoboinyk * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include "opt_wlan.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void r12au_init_rx_agg(struct rtwn_softc *sc) { struct r12a_softc *rs = sc->sc_priv; /* Rx aggregation (USB). */ rtwn_write_2(sc, R92C_RXDMA_AGG_PG_TH, rs->ac_usb_dma_size | (rs->ac_usb_dma_time << 8)); rtwn_setbits_1(sc, R92C_TRXDMA_CTRL, 0, R92C_TRXDMA_CTRL_RXDMA_AGG_EN); } void r12au_init_burstlen_usb2(struct rtwn_softc *sc) { const uint8_t dma_count = R12A_DMA_MODE | SM(R12A_BURST_CNT, 3); if ((rtwn_read_1(sc, R92C_USB_INFO) & 0x30) == 0) { /* Set burst packet length to 512 B. */ rtwn_setbits_1(sc, R12A_RXDMA_PRO, R12A_BURST_SZ_M, dma_count | SM(R12A_BURST_SZ, R12A_BURST_SZ_USB2)); } else { /* Set burst packet length to 64 B. */ rtwn_setbits_1(sc, R12A_RXDMA_PRO, R12A_BURST_SZ_M, dma_count | SM(R12A_BURST_SZ, R12A_BURST_SZ_USB1)); } } void r12au_init_burstlen(struct rtwn_softc *sc) { const uint8_t dma_count = R12A_DMA_MODE | SM(R12A_BURST_CNT, 3); if (rtwn_read_1(sc, R92C_TYPE_ID + 3) & 0x80) r12au_init_burstlen_usb2(sc); else { /* USB 3.0 */ /* Set burst packet length to 1 KB. */ rtwn_setbits_1(sc, R12A_RXDMA_PRO, R12A_BURST_SZ_M, dma_count | SM(R12A_BURST_SZ, R12A_BURST_SZ_USB3)); rtwn_setbits_1(sc, 0xf008, 0x18, 0); } } static void r12au_arfb_init(struct rtwn_softc *sc) { /* ARFB table 9 for 11ac 5G 2SS. */ rtwn_write_4(sc, R12A_ARFR_5G(0), 0x00000010); rtwn_write_4(sc, R12A_ARFR_5G(0) + 4, 0xfffff000); /* ARFB table 10 for 11ac 5G 1SS. */ rtwn_write_4(sc, R12A_ARFR_5G(1), 0x00000010); rtwn_write_4(sc, R12A_ARFR_5G(1) + 4, 0x003ff000); /* ARFB table 11 for 11ac 2G 1SS. */ rtwn_write_4(sc, R12A_ARFR_2G(0), 0x00000015); rtwn_write_4(sc, R12A_ARFR_2G(0) + 4, 0x003ff000); /* ARFB table 12 for 11ac 2G 2SS. */ rtwn_write_4(sc, R12A_ARFR_2G(1), 0x00000015); rtwn_write_4(sc, R12A_ARFR_2G(1) + 4, 0xffcff000); } void r12au_init_ampdu_fwhw(struct rtwn_softc *sc) { rtwn_setbits_1(sc, R92C_FWHW_TXQ_CTRL, R92C_FWHW_TXQ_CTRL_AMPDU_RTY_NEW, 0); } void r12au_init_ampdu(struct rtwn_softc *sc) { struct r12a_softc *rs = sc->sc_priv; /* Rx interval (USB3). */ rtwn_write_1(sc, 0xf050, 0x01); /* burst length = 4 */ rtwn_write_2(sc, R92C_RXDMA_STATUS, 0x7400); rtwn_write_1(sc, R92C_RXDMA_STATUS + 1, 0xf5); /* Setup AMPDU aggregation. */ rtwn_write_1(sc, R12A_AMPDU_MAX_TIME, rs->ampdu_max_time); - rtwn_write_4(sc, R12A_AMPDU_MAX_LENGTH, 0xffffffff); + /* + * Note: The vendor driver (hal/rtl8812a_hal_init.c:SetHwReg8812A()) + * also sets bit 31. + */ + /* + * TODO: this should be limited to the peer in STA mode, + * and perhaps the minimum A-MPDU of all VAPs/peers in + * multi-STA / other operating modes. + */ + rtwn_write_4(sc, R12A_AMPDU_MAX_LENGTH, + rs->ampdu_max_size | (1<<31)); /* 80 MHz clock (again?) */ rtwn_write_1(sc, R92C_USTIME_TSF, 0x50); rtwn_write_1(sc, R92C_USTIME_EDCA, 0x50); rtwn_r12a_init_burstlen(sc); /* Enable single packet AMPDU. */ rtwn_setbits_1(sc, R12A_HT_SINGLE_AMPDU, 0, R12A_HT_SINGLE_AMPDU_PKT_ENA); /* 11K packet length for VHT. */ rtwn_write_1(sc, R92C_RX_PKT_LIMIT, 0x18); rtwn_write_1(sc, R92C_PIFS, 0); rtwn_write_2(sc, R92C_MAX_AGGR_NUM, 0x1f1f); rtwn_r12a_init_ampdu_fwhw(sc); /* Do not reset MAC. */ rtwn_setbits_1(sc, R92C_RSV_CTRL, 0, 0x60); r12au_arfb_init(sc); } void r12au_post_init(struct rtwn_softc *sc) { /* Setup RTS BW (equal to data BW). */ rtwn_setbits_1(sc, R92C_QUEUE_CTRL, 0x08, 0); rtwn_write_1(sc, R12A_EARLY_MODE_CONTROL + 3, 0x01); /* Reset USB mode switch setting. */ rtwn_write_1(sc, R12A_SDIO_CTRL, 0); rtwn_write_1(sc, R92C_ACLK_MON, 0); rtwn_write_1(sc, R92C_USB_HRPWM, 0); #ifndef RTWN_WITHOUT_UCODE if (sc->sc_flags & RTWN_FW_LOADED) { if (sc->sc_ratectl_sysctl == RTWN_RATECTL_FW) { /* TODO: implement */ sc->sc_ratectl = RTWN_RATECTL_NET80211; } else sc->sc_ratectl = sc->sc_ratectl_sysctl; } else #endif sc->sc_ratectl = RTWN_RATECTL_NONE; } diff --git a/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c b/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c index 9f0e2c950a1e..175bac8f6fc9 100644 --- a/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c +++ b/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c @@ -1,291 +1,292 @@ /*- * Copyright (c) 2016 Andriy Voskoboinyk * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include "opt_wlan.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void r21au_attach(struct rtwn_usb_softc *); static void r21a_postattach(struct rtwn_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; struct r12a_softc *rs = sc->sc_priv; if (rs->board_type == R92C_BOARD_TYPE_MINICARD || rs->board_type == R92C_BOARD_TYPE_SOLO || rs->board_type == R92C_BOARD_TYPE_COMBO) sc->sc_set_led = r88e_set_led; else sc->sc_set_led = r21a_set_led; TIMEOUT_TASK_INIT(taskqueue_thread, &rs->rs_chan_check, 0, r21au_chan_check, sc); /* RXCKSUM */ ic->ic_ioctl = r12a_ioctl_net; /* DFS */ rs->rs_scan_start = ic->ic_scan_start; ic->ic_scan_start = r21au_scan_start; rs->rs_scan_end = ic->ic_scan_end; ic->ic_scan_end = r21au_scan_end; } static void r21au_vap_preattach(struct rtwn_softc *sc, struct ieee80211vap *vap) { struct rtwn_vap *rvp = RTWN_VAP(vap); struct r12a_softc *rs = sc->sc_priv; r12a_vap_preattach(sc, vap); /* Install DFS newstate handler (non-monitor vaps only). */ if (rvp->id != RTWN_VAP_ID_INVALID) { KASSERT(rvp->id >= 0 && rvp->id <= nitems(rs->rs_newstate), ("%s: wrong vap id %d\n", __func__, rvp->id)); rs->rs_newstate[rvp->id] = vap->iv_newstate; vap->iv_newstate = r21au_newstate; } } static void r21a_attach_private(struct rtwn_softc *sc) { struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); struct r12a_softc *rs; rs = malloc(sizeof(struct r12a_softc), M_RTWN_PRIV, M_WAITOK | M_ZERO); rs->rs_flags = R12A_RXCKSUM_EN | R12A_RXCKSUM6_EN; rs->rs_radar = 0; SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "radar_detection", CTLFLAG_RDTUN, &rs->rs_radar, rs->rs_radar, "Enable radar detection (untested)"); rs->rs_fix_spur = rtwn_nop_softc_chan; rs->rs_set_band_2ghz = r21a_set_band_2ghz; rs->rs_set_band_5ghz = r21a_set_band_5ghz; rs->rs_init_burstlen = r12au_init_burstlen_usb2; rs->rs_init_ampdu_fwhw = r21a_init_ampdu_fwhw; rs->rs_crystalcap_write = r21a_crystalcap_write; #ifndef RTWN_WITHOUT_UCODE rs->rs_iq_calib_fw_supported = r21a_iq_calib_fw_supported; #endif rs->rs_iq_calib_sw = r21a_iq_calib_sw; rs->ampdu_max_time = 0x5e; + rs->ampdu_max_size = 0xffff; /* 64k */ rs->ac_usb_dma_size = 0x01; rs->ac_usb_dma_time = 0x10; sc->sc_priv = rs; } static void r21au_adj_devcaps(struct rtwn_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; struct r12a_softc *rs = sc->sc_priv; ic->ic_htcaps |= IEEE80211_HTC_TXLDPC; if (rs->rs_radar != 0) ic->ic_caps |= IEEE80211_C_DFS; ic->ic_htcaps |= IEEE80211_HTCAP_CHWIDTH40 /* 40 MHz channel width */ | IEEE80211_HTCAP_SHORTGI40 /* short GI in 40MHz */ ; /* TODO: VHT */ } void r21au_attach(struct rtwn_usb_softc *uc) { struct rtwn_softc *sc = &uc->uc_sc; /* USB part. */ uc->uc_align_rx = r12au_align_rx; uc->tx_agg_desc_num = 6; /* Common part. */ sc->sc_flags = RTWN_FLAG_EXT_HDR; sc->sc_set_chan = r12a_set_chan; sc->sc_fill_tx_desc = r12a_fill_tx_desc; sc->sc_fill_tx_desc_raw = r12a_fill_tx_desc_raw; sc->sc_fill_tx_desc_null = r12a_fill_tx_desc_null; sc->sc_dump_tx_desc = r12au_dump_tx_desc; sc->sc_tx_radiotap_flags = r12a_tx_radiotap_flags; sc->sc_rx_radiotap_flags = r12a_rx_radiotap_flags; sc->sc_get_rx_stats = r12a_get_rx_stats; sc->sc_get_rssi_cck = r21a_get_rssi_cck; sc->sc_get_rssi_ofdm = r88e_get_rssi_ofdm; sc->sc_classify_intr = r12au_classify_intr; sc->sc_handle_tx_report = r12a_ratectl_tx_complete; sc->sc_handle_tx_report2 = rtwn_nop_softc_uint8_int; sc->sc_handle_c2h_report = r12a_handle_c2h_report; sc->sc_check_frame = r12a_check_frame_checksum; sc->sc_rf_read = r12a_c_cut_rf_read; sc->sc_rf_write = r12a_rf_write; sc->sc_check_condition = r21a_check_condition; sc->sc_efuse_postread = rtwn_nop_softc; sc->sc_parse_rom = r21a_parse_rom; sc->sc_power_on = r21a_power_on; sc->sc_power_off = r21a_power_off; #ifndef RTWN_WITHOUT_UCODE sc->sc_fw_reset = r21a_fw_reset; sc->sc_fw_download_enable = r12a_fw_download_enable; #endif sc->sc_llt_init = r92c_llt_init; sc->sc_set_page_size = rtwn_nop_int_softc; sc->sc_lc_calib = rtwn_nop_softc; /* XXX not used */ sc->sc_iq_calib = r12a_iq_calib; sc->sc_read_chipid_vendor = rtwn_nop_softc_uint32; sc->sc_adj_devcaps = r21au_adj_devcaps; sc->sc_vap_preattach = r21au_vap_preattach; sc->sc_postattach = r21a_postattach; sc->sc_detach_private = r12a_detach_private; #ifndef RTWN_WITHOUT_UCODE sc->sc_set_media_status = r12a_set_media_status; sc->sc_set_rsvd_page = r88e_set_rsvd_page; sc->sc_set_pwrmode = r12a_set_pwrmode; sc->sc_set_rssi = rtwn_nop_softc; /* XXX TODO */ #else sc->sc_set_media_status = rtwn_nop_softc_int; #endif sc->sc_beacon_init = r21a_beacon_init; sc->sc_beacon_enable = r92c_beacon_enable; sc->sc_sta_beacon_enable = r12a_sta_beacon_enable; sc->sc_beacon_set_rate = r12a_beacon_set_rate; sc->sc_beacon_select = r21a_beacon_select; sc->sc_temp_measure = r88e_temp_measure; sc->sc_temp_read = r88e_temp_read; sc->sc_init_tx_agg = r21au_init_tx_agg; sc->sc_init_rx_agg = r12au_init_rx_agg; sc->sc_init_ampdu = r12au_init_ampdu; sc->sc_init_intr = r12a_init_intr; sc->sc_init_edca = r12a_init_edca; sc->sc_init_bb = r12a_init_bb; sc->sc_init_rf = r12a_init_rf; sc->sc_init_antsel = r12a_init_antsel; sc->sc_post_init = r12au_post_init; sc->sc_init_bcnq1_boundary = r21a_init_bcnq1_boundary; sc->sc_set_tx_power = rtwn_nop_int_softc_vap; sc->chan_list_5ghz[0] = r12a_chan_5ghz_0; sc->chan_list_5ghz[1] = r12a_chan_5ghz_1; sc->chan_list_5ghz[2] = r12a_chan_5ghz_2; sc->chan_num_5ghz[0] = nitems(r12a_chan_5ghz_0); sc->chan_num_5ghz[1] = nitems(r12a_chan_5ghz_1); sc->chan_num_5ghz[2] = nitems(r12a_chan_5ghz_2); sc->mac_prog = &rtl8821au_mac[0]; sc->mac_size = nitems(rtl8821au_mac); sc->bb_prog = &rtl8821au_bb[0]; sc->bb_size = nitems(rtl8821au_bb); sc->agc_prog = &rtl8821au_agc[0]; sc->agc_size = nitems(rtl8821au_agc); sc->rf_prog = &rtl8821au_rf[0]; sc->name = "RTL8821AU"; sc->fwname = "rtwn-rtl8821aufw"; sc->fwsig = 0x210; sc->page_count = R21A_TX_PAGE_COUNT; sc->pktbuf_count = R12A_TXPKTBUF_COUNT; sc->ackto = 0x80; sc->npubqpages = R12A_PUBQ_NPAGES; sc->page_size = R21A_TX_PAGE_SIZE; sc->txdesc_len = sizeof(struct r12au_tx_desc); sc->efuse_maxlen = R12A_EFUSE_MAX_LEN; sc->efuse_maplen = R12A_EFUSE_MAP_LEN; sc->rx_dma_size = R12A_RX_DMA_BUFFER_SIZE; sc->macid_limit = R12A_MACID_MAX + 1; sc->cam_entry_limit = R12A_CAM_ENTRY_COUNT; sc->fwsize_limit = R12A_MAX_FW_SIZE; sc->temp_delta = R88E_CALIB_THRESHOLD; sc->bcn_status_reg[0] = R92C_TDECTRL; sc->bcn_status_reg[1] = R21A_DWBCN1_CTRL; sc->rcr = R12A_RCR_DIS_CHK_14 | R12A_RCR_VHT_ACK | R12A_RCR_TCP_OFFLD_EN; sc->ntxchains = 1; sc->nrxchains = 1; sc->sc_ht40 = 1; r21a_attach_private(sc); }