Index: stable/12/sys/dev/rtwn/rtl8188e/r88e_rom.c =================================================================== --- stable/12/sys/dev/rtwn/rtl8188e/r88e_rom.c (revision 342833) +++ stable/12/sys/dev/rtwn/rtl8188e/r88e_rom.c (revision 342834) @@ -1,85 +1,86 @@ /* $OpenBSD: if_urtwn.c,v 1.16 2011/02/10 17:26:40 jakemsr Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini * Copyright (c) 2014 Kevin Lo * Copyright (c) 2015-2016 Andriy Voskoboinyk * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include __FBSDID("$FreeBSD$"); #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 void r88e_parse_rom(struct rtwn_softc *sc, uint8_t *buf) { struct r92c_softc *rs = sc->sc_priv; struct rtwn_r88e_txpwr *rt = rs->rs_txpwr; struct r88e_rom *rom = (struct r88e_rom *)buf; int i; rt->bw20_tx_pwr_diff = RTWN_SIGN4TO8(MS(rom->tx_pwr_diff, HIGH_PART)); rt->ofdm_tx_pwr_diff = RTWN_SIGN4TO8(MS(rom->tx_pwr_diff, LOW_PART)); for (i = 0; i < nitems(rom->cck_tx_pwr); i++) rt->cck_tx_pwr[i] = rom->cck_tx_pwr[i]; for (i = 0; i < nitems(rom->ht40_tx_pwr); i++) rt->ht40_tx_pwr[i] = rom->ht40_tx_pwr[i]; rs->crystalcap = RTWN_GET_ROM_VAR(rom->crystalcap, R88E_ROM_CRYSTALCAP_DEF); rs->regulatory = MS(rom->rf_board_opt, R92C_ROM_RF1_REGULATORY); rs->board_type = MS(RTWN_GET_ROM_VAR(rom->rf_board_opt, R92C_BOARD_TYPE_DONGLE), R92C_ROM_RF1_BOARD_TYPE); RTWN_DPRINTF(sc, RTWN_DEBUG_ROM, "%s: regulatory type %d\n", __func__,rs->regulatory); sc->thermal_meter = rom->thermal_meter; - IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, rom->macaddr); + + rtwn_r92c_set_rom_opts(sc, buf); } Index: stable/12/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c =================================================================== --- stable/12/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c (revision 342833) +++ stable/12/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c (revision 342834) @@ -1,218 +1,227 @@ /* $OpenBSD: if_urtwn.c,v 1.16 2011/02/10 17:26:40 jakemsr Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini * Copyright (c) 2014 Kevin Lo * Copyright (c) 2015-2016 Andriy Voskoboinyk * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include __FBSDID("$FreeBSD$"); #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 /* for 'macaddr' field */ #include static struct rtwn_r88e_txpwr r88e_txpwr; void r88eu_attach(struct rtwn_usb_softc *); static void +r88eu_set_macaddr(struct rtwn_softc *sc, uint8_t *buf) +{ + struct r88e_rom *rom = (struct r88e_rom *)buf; + + IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, rom->macaddr); +} + +static void r88e_postattach(struct rtwn_softc *sc) { struct r92c_softc *rs = sc->sc_priv; struct ieee80211com *ic = &sc->sc_ic; rs->rs_scan_start = ic->ic_scan_start; ic->ic_scan_start = r92c_scan_start; rs->rs_scan_end = ic->ic_scan_end; ic->ic_scan_end = r92c_scan_end; } static void r88eu_attach_private(struct rtwn_softc *sc) { struct r92c_softc *rs; rs = malloc(sizeof(struct r92c_softc), M_RTWN_PRIV, M_WAITOK | M_ZERO); rs->rs_txpwr = &r88e_txpwr; rs->rs_txagc = NULL; rs->rs_set_bw20 = r88e_set_bw20; rs->rs_get_txpower = r88e_get_txpower; rs->rs_set_gain = r88e_set_gain; rs->rs_tx_enable_ampdu = r88e_tx_enable_ampdu; rs->rs_tx_setup_hwseq = r88e_tx_setup_hwseq; rs->rs_tx_setup_macid = r88e_tx_setup_macid; - rs->rs_set_name = rtwn_nop_softc; /* not used */ + rs->rs_set_rom_opts = r88eu_set_macaddr; rs->rf_read_delay[0] = 10; rs->rf_read_delay[1] = 100; rs->rf_read_delay[2] = 10; sc->sc_priv = rs; } static void r88eu_adj_devcaps(struct rtwn_softc *sc) { /* XXX TODO? */ } void r88eu_attach(struct rtwn_usb_softc *uc) { struct rtwn_softc *sc = &uc->uc_sc; /* USB part. */ uc->uc_align_rx = r92cu_align_rx; uc->tx_agg_desc_num = 6; /* Common part. */ sc->sc_flags = RTWN_FLAG_EXT_HDR; sc->sc_set_chan = r92c_set_chan; sc->sc_fill_tx_desc = r92c_fill_tx_desc; sc->sc_fill_tx_desc_raw = r92c_fill_tx_desc_raw; sc->sc_fill_tx_desc_null = r92c_fill_tx_desc_null; sc->sc_dump_tx_desc = r92cu_dump_tx_desc; sc->sc_tx_radiotap_flags = r92c_tx_radiotap_flags; sc->sc_rx_radiotap_flags = r92c_rx_radiotap_flags; sc->sc_get_rx_stats = r88e_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 = r88e_classify_intr; sc->sc_handle_tx_report = r88e_ratectl_tx_complete; sc->sc_handle_c2h_report = r88e_handle_c2h_report; sc->sc_check_frame = rtwn_nop_int_softc_mbuf; sc->sc_rf_read = r92c_rf_read; sc->sc_rf_write = r88e_rf_write; sc->sc_check_condition = r92c_check_condition; sc->sc_efuse_postread = rtwn_nop_softc; sc->sc_parse_rom = r88e_parse_rom; sc->sc_set_led = r88e_set_led; sc->sc_power_on = r88eu_power_on; sc->sc_power_off = r88eu_power_off; #ifndef RTWN_WITHOUT_UCODE sc->sc_fw_reset = r88e_fw_reset; sc->sc_fw_download_enable = r88e_fw_download_enable; #endif sc->sc_llt_init = r92c_llt_init; sc->sc_set_page_size = r92c_set_page_size; sc->sc_lc_calib = r92c_lc_calib; sc->sc_iq_calib = r88e_iq_calib; sc->sc_read_chipid_vendor = rtwn_nop_softc_uint32; sc->sc_adj_devcaps = r88eu_adj_devcaps; sc->sc_vap_preattach = rtwn_nop_softc_vap; sc->sc_postattach = r88e_postattach; sc->sc_detach_private = r92c_detach_private; sc->sc_set_media_status = r88e_set_media_status; #ifndef RTWN_WITHOUT_UCODE sc->sc_set_rsvd_page = r88e_set_rsvd_page; sc->sc_set_pwrmode = r88e_set_pwrmode; sc->sc_set_rssi = rtwn_nop_softc; /* XXX TODO? */ #endif sc->sc_beacon_init = r92c_beacon_init; sc->sc_beacon_enable = r88e_beacon_enable; sc->sc_beacon_set_rate = rtwn_nop_void_int; 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 = r88eu_init_rx_agg; sc->sc_init_ampdu = rtwn_nop_softc; sc->sc_init_intr = r88eu_init_intr; sc->sc_init_edca = r92c_init_edca; sc->sc_init_bb = r88eu_init_bb; sc->sc_init_rf = r92c_init_rf; sc->sc_init_antsel = rtwn_nop_softc; sc->sc_post_init = r88eu_post_init; sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc; sc->mac_prog = &rtl8188e_mac[0]; sc->mac_size = nitems(rtl8188e_mac); sc->bb_prog = &rtl8188e_bb[0]; sc->bb_size = nitems(rtl8188e_bb); sc->agc_prog = &rtl8188e_agc[0]; sc->agc_size = nitems(rtl8188e_agc); sc->rf_prog = &rtl8188e_rf[0]; sc->name = "RTL8188EU"; sc->fwname = "rtwn-rtl8188eufw"; sc->fwsig = 0x88e; sc->page_count = R88EU_TX_PAGE_COUNT; sc->pktbuf_count = R88E_TXPKTBUF_COUNT; sc->ackto = 0x40; sc->npubqpages = R88EU_PUBQ_NPAGES; sc->page_size = R92C_TX_PAGE_SIZE; sc->txdesc_len = sizeof(struct r92cu_tx_desc); sc->efuse_maxlen = R88E_EFUSE_MAX_LEN; sc->efuse_maplen = R88E_EFUSE_MAP_LEN; sc->rx_dma_size = R88E_RX_DMA_BUFFER_SIZE; sc->macid_limit = R88E_MACID_MAX + 1; sc->cam_entry_limit = R92C_CAM_ENTRY_COUNT; sc->fwsize_limit = R92C_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 = 0; sc->ntxchains = 1; sc->nrxchains = 1; r88eu_attach_private(sc); } Index: stable/12/sys/dev/rtwn/rtl8192c/pci/r92ce_attach.c =================================================================== --- stable/12/sys/dev/rtwn/rtl8192c/pci/r92ce_attach.c (revision 342833) +++ stable/12/sys/dev/rtwn/rtl8192c/pci/r92ce_attach.c (revision 342834) @@ -1,266 +1,266 @@ /* $OpenBSD: if_rtwn.c,v 1.6 2015/08/28 00:03:53 deraadt Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini * Copyright (c) 2015 Stefan Sperling * Copyright (c) 2016 Andriy Voskoboinyk * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include __FBSDID("$FreeBSD$"); #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 static struct rtwn_r92c_txpwr r92c_txpwr; void r92ce_attach(struct rtwn_pci_softc *); static void r92ce_postattach(struct rtwn_softc *sc) { struct r92c_softc *rs = sc->sc_priv; struct ieee80211com *ic = &sc->sc_ic; if (!(rs->chip & R92C_CHIP_92C) && rs->board_type == R92C_BOARD_TYPE_HIGHPA) rs->rs_txagc = &rtl8188ru_txagc[0]; else rs->rs_txagc = &rtl8192cu_txagc[0]; if ((rs->chip & (R92C_CHIP_UMC_A_CUT | R92C_CHIP_92C)) == R92C_CHIP_UMC_A_CUT) sc->fwname = "rtwn-rtl8192cfwE"; else sc->fwname = "rtwn-rtl8192cfwE_B"; sc->fwsig = 0x88c; rs->rs_scan_start = ic->ic_scan_start; ic->ic_scan_start = r92c_scan_start; rs->rs_scan_end = ic->ic_scan_end; ic->ic_scan_end = r92c_scan_end; } static void -r92ce_set_name(struct rtwn_softc *sc) +r92ce_set_name(struct rtwn_softc *sc, uint8_t *buf) { struct r92c_softc *rs = sc->sc_priv; if (rs->chip & R92C_CHIP_92C) sc->name = "RTL8192CE"; else sc->name = "RTL8188CE"; } static void r92ce_attach_private(struct rtwn_softc *sc) { struct r92c_softc *rs; rs = malloc(sizeof(struct r92c_softc), M_RTWN_PRIV, M_WAITOK | M_ZERO); rs->rs_txpwr = &r92c_txpwr; rs->rs_set_bw20 = r92c_set_bw20; rs->rs_get_txpower = r92c_get_txpower; rs->rs_set_gain = r92c_set_gain; rs->rs_tx_enable_ampdu = r92c_tx_enable_ampdu; rs->rs_tx_setup_hwseq = r92c_tx_setup_hwseq; rs->rs_tx_setup_macid = r92c_tx_setup_macid; - rs->rs_set_name = r92ce_set_name; + rs->rs_set_rom_opts = r92ce_set_name; /* XXX TODO: test with net80211 ratectl! */ #ifndef RTWN_WITHOUT_UCODE rs->rs_c2h_timeout = hz; callout_init_mtx(&rs->rs_c2h_report, &sc->sc_mtx, 0); #endif rs->rf_read_delay[0] = 1000; rs->rf_read_delay[1] = 1000; rs->rf_read_delay[2] = 1000; sc->sc_priv = rs; } static void r92ce_adj_devcaps(struct rtwn_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; /* * XXX do NOT enable PMGT until RSVD_PAGE command * will not be tested / fixed + HRPWM register must be set too. */ ic->ic_caps &= ~IEEE80211_C_PMGT; } void r92ce_attach(struct rtwn_pci_softc *pc) { struct rtwn_softc *sc = &pc->pc_sc; /* PCIe part. */ pc->pc_setup_tx_desc = r92ce_setup_tx_desc; pc->pc_tx_postsetup = r92ce_tx_postsetup; pc->pc_copy_tx_desc = r92ce_copy_tx_desc; pc->pc_enable_intr = r92ce_enable_intr; pc->pc_get_intr_status = r92ce_get_intr_status; pc->pc_qmap = 0xf771; pc->tcr = R92C_TCR_CFENDFORM | (1 << 12) | (1 << 13); /* Common part. */ /* RTL8192C* cannot use pairwise keys from first 4 slots */ sc->sc_flags = RTWN_FLAG_CAM_FIXED; sc->sc_start_xfers = r92ce_start_xfers; sc->sc_set_chan = r92c_set_chan; sc->sc_fill_tx_desc = r92c_fill_tx_desc; sc->sc_fill_tx_desc_raw = r92c_fill_tx_desc_raw; sc->sc_fill_tx_desc_null = r92c_fill_tx_desc_null; /* XXX recheck */ sc->sc_dump_tx_desc = r92ce_dump_tx_desc; sc->sc_tx_radiotap_flags = r92c_tx_radiotap_flags; sc->sc_rx_radiotap_flags = r92c_rx_radiotap_flags; sc->sc_get_rx_stats = r92c_get_rx_stats; sc->sc_get_rssi_cck = r92c_get_rssi_cck; sc->sc_get_rssi_ofdm = r92c_get_rssi_ofdm; sc->sc_classify_intr = r92c_classify_intr; sc->sc_handle_tx_report = rtwn_nop_softc_uint8_int; sc->sc_handle_c2h_report = rtwn_nop_softc_uint8_int; sc->sc_check_frame = rtwn_nop_int_softc_mbuf; sc->sc_rf_read = r92c_rf_read; sc->sc_rf_write = r92c_rf_write; sc->sc_check_condition = r92c_check_condition; sc->sc_efuse_postread = r92c_efuse_postread; sc->sc_parse_rom = r92c_parse_rom; sc->sc_set_led = r92ce_set_led; sc->sc_power_on = r92ce_power_on; sc->sc_power_off = r92ce_power_off; #ifndef RTWN_WITHOUT_UCODE sc->sc_fw_reset = r92ce_fw_reset; sc->sc_fw_download_enable = r92c_fw_download_enable; #endif sc->sc_llt_init = r92c_llt_init; sc->sc_set_page_size = r92c_set_page_size; sc->sc_lc_calib = r92c_lc_calib; sc->sc_iq_calib = r92ce_iq_calib; sc->sc_read_chipid_vendor = r92c_read_chipid_vendor; sc->sc_adj_devcaps = r92ce_adj_devcaps; sc->sc_vap_preattach = rtwn_nop_softc_vap; sc->sc_postattach = r92ce_postattach; sc->sc_detach_private = r92c_detach_private; sc->sc_set_media_status = r92c_joinbss_rpt; #ifndef RTWN_WITHOUT_UCODE sc->sc_set_rsvd_page = r92c_set_rsvd_page; sc->sc_set_pwrmode = r92c_set_pwrmode; sc->sc_set_rssi = r92c_set_rssi; #endif sc->sc_beacon_init = r92c_beacon_init; sc->sc_beacon_enable = r92c_beacon_enable; sc->sc_beacon_set_rate = rtwn_nop_void_int; sc->sc_beacon_select = rtwn_nop_softc_int; sc->sc_temp_measure = r92c_temp_measure; sc->sc_temp_read = r92c_temp_read; sc->sc_init_tx_agg = rtwn_nop_softc; sc->sc_init_rx_agg = rtwn_nop_softc; sc->sc_init_ampdu = r92ce_init_ampdu; sc->sc_init_intr = r92ce_init_intr; sc->sc_init_edca = r92ce_init_edca; sc->sc_init_bb = r92ce_init_bb; sc->sc_init_rf = r92c_init_rf; sc->sc_init_antsel = rtwn_nop_softc; sc->sc_post_init = r92ce_post_init; sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc; sc->mac_prog = &rtl8192ce_mac[0]; sc->mac_size = nitems(rtl8192ce_mac); sc->bb_prog = &rtl8192ce_bb[0]; sc->bb_size = nitems(rtl8192ce_bb); sc->agc_prog = &rtl8192ce_agc[0]; sc->agc_size = nitems(rtl8192ce_agc); sc->rf_prog = &rtl8192c_rf[0]; sc->page_count = R92CE_TX_PAGE_COUNT; sc->pktbuf_count = R92C_TXPKTBUF_COUNT; sc->ackto = 0x40; sc->npubqpages = R92CE_PUBQ_NPAGES; sc->nhqpages = R92CE_HPQ_NPAGES; sc->nnqpages = 0; sc->nlqpages = R92CE_LPQ_NPAGES; sc->page_size = R92C_TX_PAGE_SIZE; sc->txdesc_len = sizeof(struct r92ce_tx_desc); sc->efuse_maxlen = R92C_EFUSE_MAX_LEN; sc->efuse_maplen = R92C_EFUSE_MAP_LEN; sc->rx_dma_size = R92C_RX_DMA_BUFFER_SIZE; sc->macid_limit = R92C_MACID_MAX + 1; sc->cam_entry_limit = R92C_CAM_ENTRY_COUNT; sc->fwsize_limit = R92C_MAX_FW_SIZE; sc->temp_delta = R92C_CALIB_THRESHOLD; sc->bcn_status_reg[0] = R92C_TDECTRL; /* * TODO: some additional setup is required * to maintain few beacons at the same time. * * XXX BCNQ1 mechanism is not needed here; move it to the USB module. */ sc->bcn_status_reg[1] = R92C_TDECTRL; sc->rcr = 0; r92ce_attach_private(sc); } Index: stable/12/sys/dev/rtwn/rtl8192c/r92c_rom.c =================================================================== --- stable/12/sys/dev/rtwn/rtl8192c/r92c_rom.c (revision 342833) +++ stable/12/sys/dev/rtwn/rtl8192c/r92c_rom.c (revision 342834) @@ -1,139 +1,139 @@ /* $OpenBSD: if_urtwn.c,v 1.16 2011/02/10 17:26:40 jakemsr Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini * Copyright (c) 2014 Kevin Lo * Copyright (c) 2015-2016 Andriy Voskoboinyk * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include __FBSDID("$FreeBSD$"); #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 static void r92c_set_chains(struct rtwn_softc *sc) { struct r92c_softc *rs = sc->sc_priv; if (rs->chip & R92C_CHIP_92C) { sc->ntxchains = (rs->chip & R92C_CHIP_92C_1T2R) ? 1 : 2; sc->nrxchains = 2; } else { sc->ntxchains = 1; sc->nrxchains = 1; } } void r92c_efuse_postread(struct rtwn_softc *sc) { struct r92c_softc *rs = sc->sc_priv; /* XXX Weird but this is what the vendor driver does. */ sc->next_rom_addr = 0x1fa; (void) rtwn_efuse_read_next(sc, &rs->pa_setting); RTWN_DPRINTF(sc, RTWN_DEBUG_ROM, "%s: PA setting=0x%x\n", __func__, rs->pa_setting); } void r92c_parse_rom(struct rtwn_softc *sc, uint8_t *buf) { struct r92c_softc *rs = sc->sc_priv; struct rtwn_r92c_txpwr *rt = rs->rs_txpwr; struct r92c_rom *rom = (struct r92c_rom *)buf; int i, j; rs->board_type = MS(rom->rf_opt1, R92C_ROM_RF1_BOARD_TYPE); rs->regulatory = MS(rom->rf_opt1, R92C_ROM_RF1_REGULATORY); RTWN_DPRINTF(sc, RTWN_DEBUG_ROM, "%s: regulatory type=%d\n", __func__, rs->regulatory); /* Need to be set before postinit() (but after preinit()). */ - rtwn_r92c_set_name(sc); + rtwn_r92c_set_rom_opts(sc, buf); r92c_set_chains(sc); for (j = 0; j < R92C_GROUP_2G; j++) { for (i = 0; i < sc->ntxchains; i++) { rt->cck_tx_pwr[i][j] = rom->cck_tx_pwr[i][j]; rt->ht40_1s_tx_pwr[i][j] = rom->ht40_1s_tx_pwr[i][j]; } rt->ht40_2s_tx_pwr_diff[0][j] = MS(rom->ht40_2s_tx_pwr_diff[j], LOW_PART); rt->ht20_tx_pwr_diff[0][j] = RTWN_SIGN4TO8(MS(rom->ht20_tx_pwr_diff[j], LOW_PART)); rt->ofdm_tx_pwr_diff[0][j] = MS(rom->ofdm_tx_pwr_diff[j], LOW_PART); rt->ht40_max_pwr[0][j] = MS(rom->ht40_max_pwr[j], LOW_PART); rt->ht20_max_pwr[0][j] = MS(rom->ht20_max_pwr[j], LOW_PART); if (sc->ntxchains > 1) { rt->ht40_2s_tx_pwr_diff[1][j] = MS(rom->ht40_2s_tx_pwr_diff[j], HIGH_PART); rt->ht20_tx_pwr_diff[1][j] = RTWN_SIGN4TO8(MS(rom->ht20_tx_pwr_diff[j], HIGH_PART)); rt->ofdm_tx_pwr_diff[1][j] = MS(rom->ofdm_tx_pwr_diff[j], HIGH_PART); rt->ht40_max_pwr[1][j] = MS(rom->ht40_max_pwr[j], HIGH_PART); rt->ht20_max_pwr[1][j] = MS(rom->ht20_max_pwr[j], HIGH_PART); } } sc->thermal_meter = MS(rom->thermal_meter, R92C_ROM_THERMAL_METER); if (sc->thermal_meter == R92C_ROM_THERMAL_METER_M) sc->thermal_meter = 0xff; IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, rom->macaddr); } Index: stable/12/sys/dev/rtwn/rtl8192c/r92c_var.h =================================================================== --- stable/12/sys/dev/rtwn/rtl8192c/r92c_var.h (revision 342833) +++ stable/12/sys/dev/rtwn/rtl8192c/r92c_var.h (revision 342834) @@ -1,83 +1,83 @@ /*- * Copyright (c) 2010 Damien Bergamini * Copyright (c) 2015-2016 Andriy Voskoboinyk * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $ * $FreeBSD$ */ #ifndef R92C_VAR_H #define R92C_VAR_H #include struct r92c_softc { uint8_t rs_flags; #define R92C_FLAG_ASSOCIATED 0x01 uint8_t chip; #define R92C_CHIP_92C 0x01 #define R92C_CHIP_92C_1T2R 0x02 #define R92C_CHIP_UMC_A_CUT 0x04 #ifndef RTWN_WITHOUT_UCODE struct callout rs_c2h_report; int rs_c2h_timeout; int rs_c2h_pending; int rs_c2h_paused; #endif #define R92C_TX_PAUSED_THRESHOLD 20 void *rs_txpwr; const void *rs_txagc; uint8_t board_type; uint8_t regulatory; uint8_t crystalcap; uint8_t pa_setting; void (*rs_scan_start)(struct ieee80211com *); void (*rs_scan_end)(struct ieee80211com *); void (*rs_set_bw20)(struct rtwn_softc *, uint8_t); void (*rs_get_txpower)(struct rtwn_softc *, int, struct ieee80211_channel *, uint8_t[]); void (*rs_set_gain)(struct rtwn_softc *, uint8_t); void (*rs_tx_enable_ampdu)(void *, int); void (*rs_tx_setup_hwseq)(void *); void (*rs_tx_setup_macid)(void *, int); - void (*rs_set_name)(struct rtwn_softc *); + void (*rs_set_rom_opts)(struct rtwn_softc *, uint8_t *); int rf_read_delay[3]; uint32_t rf_chnlbw[R92C_MAX_CHAINS]; }; #define R92C_SOFTC(_sc) ((struct r92c_softc *)((_sc)->sc_priv)) #define rtwn_r92c_set_bw20(_sc, _chan) \ ((R92C_SOFTC(_sc)->rs_set_bw20)((_sc), (_chan))) #define rtwn_r92c_get_txpower(_sc, _chain, _c, _power) \ ((R92C_SOFTC(_sc)->rs_get_txpower)((_sc), (_chain), (_c), (_power))) #define rtwn_r92c_set_gain(_sc, _gain) \ ((R92C_SOFTC(_sc)->rs_set_gain)((_sc), (_gain))) #define rtwn_r92c_tx_enable_ampdu(_sc, _buf, _enable) \ ((R92C_SOFTC(_sc)->rs_tx_enable_ampdu)((_buf), (_enable))) #define rtwn_r92c_tx_setup_hwseq(_sc, _buf) \ ((R92C_SOFTC(_sc)->rs_tx_setup_hwseq)((_buf))) #define rtwn_r92c_tx_setup_macid(_sc, _buf, _id) \ ((R92C_SOFTC(_sc)->rs_tx_setup_macid)((_buf), (_id))) -#define rtwn_r92c_set_name(_sc) \ - ((R92C_SOFTC(_sc)->rs_set_name)((_sc))) +#define rtwn_r92c_set_rom_opts(_sc, _buf) \ + ((R92C_SOFTC(_sc)->rs_set_rom_opts)((_sc), (_buf))) #endif /* R92C_VAR_H */ Index: stable/12/sys/dev/rtwn/rtl8192c/usb/r92cu_attach.c =================================================================== --- stable/12/sys/dev/rtwn/rtl8192c/usb/r92cu_attach.c (revision 342833) +++ stable/12/sys/dev/rtwn/rtl8192c/usb/r92cu_attach.c (revision 342834) @@ -1,247 +1,247 @@ /* $OpenBSD: if_urtwn.c,v 1.16 2011/02/10 17:26:40 jakemsr Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini * Copyright (c) 2014 Kevin Lo * Copyright (c) 2016 Andriy Voskoboinyk * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include __FBSDID("$FreeBSD$"); #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 static struct rtwn_r92c_txpwr r92c_txpwr; void r92cu_attach(struct rtwn_usb_softc *); static void r92cu_postattach(struct rtwn_softc *sc) { struct r92c_softc *rs = sc->sc_priv; struct ieee80211com *ic = &sc->sc_ic; if (!(rs->chip & R92C_CHIP_92C) && rs->board_type == R92C_BOARD_TYPE_HIGHPA) { sc->agc_prog = &rtl8188ru_agc[0]; sc->agc_size = nitems(rtl8188ru_agc); rs->rs_txagc = &rtl8188ru_txagc[0]; } else { sc->agc_prog = &rtl8192ce_agc[0]; sc->agc_size = nitems(rtl8192ce_agc); rs->rs_txagc = &rtl8192cu_txagc[0]; } if ((rs->chip & (R92C_CHIP_UMC_A_CUT | R92C_CHIP_92C)) == R92C_CHIP_UMC_A_CUT) { sc->fwname = "rtwn-rtl8192cfwU"; } else { sc->fwname = "rtwn-rtl8192cfwT"; } sc->fwsig = 0x88c; rs->rs_scan_start = ic->ic_scan_start; ic->ic_scan_start = r92c_scan_start; rs->rs_scan_end = ic->ic_scan_end; ic->ic_scan_end = r92c_scan_end; } static void -r92cu_set_name(struct rtwn_softc *sc) +r92cu_set_name(struct rtwn_softc *sc, uint8_t *buf) { struct r92c_softc *rs = sc->sc_priv; if (!(rs->chip & R92C_CHIP_92C)) { if (rs->board_type == R92C_BOARD_TYPE_HIGHPA) sc->name = "RTL8188RU"; else if (rs->board_type == R92C_BOARD_TYPE_MINICARD) sc->name = "RTL8188CU-VAU"; else sc->name = "RTL8188CUS"; } else sc->name = "RTL8192CU"; } static void r92cu_attach_private(struct rtwn_softc *sc) { struct r92c_softc *rs; rs = malloc(sizeof(struct r92c_softc), M_RTWN_PRIV, M_WAITOK | M_ZERO); rs->rs_txpwr = &r92c_txpwr; rs->rs_set_bw20 = r92c_set_bw20; rs->rs_get_txpower = r92c_get_txpower; rs->rs_set_gain = r92c_set_gain; rs->rs_tx_enable_ampdu = r92c_tx_enable_ampdu; rs->rs_tx_setup_hwseq = r92c_tx_setup_hwseq; rs->rs_tx_setup_macid = r92c_tx_setup_macid; - rs->rs_set_name = r92cu_set_name; + rs->rs_set_rom_opts = r92cu_set_name; #ifndef RTWN_WITHOUT_UCODE rs->rs_c2h_timeout = hz; callout_init_mtx(&rs->rs_c2h_report, &sc->sc_mtx, 0); #endif rs->rf_read_delay[0] = 10; rs->rf_read_delay[1] = 100; rs->rf_read_delay[2] = 10; sc->sc_priv = rs; } static void r92cu_adj_devcaps(struct rtwn_softc *sc) { /* XXX Currently broken / incomplete. */ sc->sc_ic.ic_caps &= ~IEEE80211_C_PMGT; } void r92cu_attach(struct rtwn_usb_softc *uc) { struct rtwn_softc *sc = &uc->uc_sc; /* USB part. */ uc->uc_align_rx = r92cu_align_rx; uc->tx_agg_desc_num = 6; /* Common part. */ sc->sc_flags = RTWN_FLAG_CAM_FIXED; sc->sc_set_chan = r92c_set_chan; sc->sc_fill_tx_desc = r92c_fill_tx_desc; sc->sc_fill_tx_desc_raw = r92c_fill_tx_desc_raw; sc->sc_fill_tx_desc_null = r92c_fill_tx_desc_null; sc->sc_dump_tx_desc = r92cu_dump_tx_desc; sc->sc_tx_radiotap_flags = r92c_tx_radiotap_flags; sc->sc_rx_radiotap_flags = r92c_rx_radiotap_flags; sc->sc_get_rx_stats = r92c_get_rx_stats; sc->sc_get_rssi_cck = r92c_get_rssi_cck; sc->sc_get_rssi_ofdm = r92c_get_rssi_ofdm; sc->sc_classify_intr = r92c_classify_intr; sc->sc_handle_tx_report = rtwn_nop_softc_uint8_int; sc->sc_handle_c2h_report = rtwn_nop_softc_uint8_int; sc->sc_check_frame = rtwn_nop_int_softc_mbuf; sc->sc_rf_read = r92c_rf_read; sc->sc_rf_write = r92c_rf_write; sc->sc_check_condition = r92c_check_condition; sc->sc_efuse_postread = r92c_efuse_postread; sc->sc_parse_rom = r92c_parse_rom; sc->sc_set_led = r92cu_set_led; sc->sc_power_on = r92cu_power_on; sc->sc_power_off = r92cu_power_off; #ifndef RTWN_WITHOUT_UCODE sc->sc_fw_reset = r92c_fw_reset; sc->sc_fw_download_enable = r92c_fw_download_enable; #endif sc->sc_llt_init = r92c_llt_init; sc->sc_set_page_size = r92c_set_page_size; sc->sc_lc_calib = r92c_lc_calib; sc->sc_iq_calib = r92c_iq_calib; /* XXX TODO */ sc->sc_read_chipid_vendor = r92c_read_chipid_vendor; sc->sc_adj_devcaps = r92cu_adj_devcaps; sc->sc_vap_preattach = rtwn_nop_softc_vap; sc->sc_postattach = r92cu_postattach; sc->sc_detach_private = r92c_detach_private; sc->sc_set_media_status = r92c_joinbss_rpt; #ifndef RTWN_WITHOUT_UCODE sc->sc_set_rsvd_page = r92c_set_rsvd_page; sc->sc_set_pwrmode = r92c_set_pwrmode; sc->sc_set_rssi = r92c_set_rssi; #endif sc->sc_beacon_init = r92c_beacon_init; sc->sc_beacon_enable = r92c_beacon_enable; sc->sc_beacon_set_rate = rtwn_nop_void_int; sc->sc_beacon_select = rtwn_nop_softc_int; sc->sc_temp_measure = r92c_temp_measure; sc->sc_temp_read = r92c_temp_read; sc->sc_init_tx_agg = r92cu_init_tx_agg; sc->sc_init_rx_agg = r92cu_init_rx_agg; sc->sc_init_ampdu = r92c_init_ampdu; sc->sc_init_intr = r92cu_init_intr; sc->sc_init_edca = r92c_init_edca; sc->sc_init_bb = r92cu_init_bb; sc->sc_init_rf = r92c_init_rf; sc->sc_init_antsel = r92c_init_antsel; sc->sc_post_init = r92cu_post_init; sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc; sc->mac_prog = &rtl8192cu_mac[0]; sc->mac_size = nitems(rtl8192cu_mac); sc->bb_prog = &rtl8192cu_bb[0]; sc->bb_size = nitems(rtl8192cu_bb); sc->rf_prog = &rtl8192c_rf[0]; sc->page_count = R92CU_TX_PAGE_COUNT; sc->pktbuf_count = R92C_TXPKTBUF_COUNT; sc->ackto = 0x40; sc->npubqpages = R92CU_PUBQ_NPAGES; sc->page_size = R92C_TX_PAGE_SIZE; sc->txdesc_len = sizeof(struct r92cu_tx_desc); sc->efuse_maxlen = R92C_EFUSE_MAX_LEN; sc->efuse_maplen = R92C_EFUSE_MAP_LEN; sc->rx_dma_size = R92C_RX_DMA_BUFFER_SIZE; sc->macid_limit = R92C_MACID_MAX + 1; sc->cam_entry_limit = R92C_CAM_ENTRY_COUNT; sc->fwsize_limit = R92C_MAX_FW_SIZE; sc->temp_delta = R92C_CALIB_THRESHOLD; sc->bcn_status_reg[0] = R92C_TDECTRL; sc->bcn_status_reg[1] = R92C_TDECTRL; sc->rcr = 0; r92cu_attach_private(sc); } Index: stable/12 =================================================================== --- stable/12 (revision 342833) +++ stable/12 (revision 342834) Property changes on: stable/12 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r342681