broadcom43xx: Sync with FreeBSD 11.1.

And with that, the driver upgrades to FreeBSD 11.1 are complete!
This commit is contained in:
Augustin Cavalier
2018-07-18 19:47:06 -04:00
parent 3c42c902d9
commit fd893db8b1
15 changed files with 390 additions and 443 deletions
@@ -1,11 +1,9 @@
SubDir HAIKU_TOP src add-ons kernel drivers network wlan ;
# FreeBSD 9.3 drivers
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan broadcom43xx ;
# FreeBSD 11.1 drivers
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan aironetwifi ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan atheroswifi ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan broadcom43xx ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi2100 ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi3945 ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi4965 ;
@@ -1,19 +1,19 @@
SubDir HAIKU_TOP src add-ons kernel drivers network wlan broadcom43xx ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ]
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_network compat ]
: true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_wlan ] : true ;
UsePrivateHeaders net system ;
UsePrivateKernelHeaders ;
# Enabling C++ structures in C only code
Includes [ FGristFiles kernel_c++_structs.h ]
: <src!system!kernel>kernel_c++_struct_sizes.h ;
SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ]
-Wno-format
-Wno-unused
-Wno-uninitialized
SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ]
-Wno-format
-Wno-unused
-Wno-uninitialized
;
UseHeaders [ FDirName $(SUBDIR) ] : true ;
@@ -28,6 +28,6 @@ KernelAddon broadcom43xx :
bwirf.c
glue.c
:
libfreebsd_wlan.a
libfreebsd_network.a
libfreebsd11_wlan.a
libfreebsd11_network.a
;
@@ -29,7 +29,7 @@
* OF SUCH DAMAGE.
*
* $DragonFly: src/sys/dev/netif/bwi/bitops.h,v 1.1 2007/09/08 06:15:54 sephe Exp $
* $FreeBSD$
* $FreeBSD: releng/11.1/sys/dev/bwi/bitops.h 191762 2009-05-03 04:01:43Z imp $
*/
#ifndef _BITOPS_H
@@ -35,10 +35,11 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
__FBSDID("$FreeBSD: releng/11.1/sys/dev/bwi/bwimac.c 288087 2015-09-22 02:44:59Z adrian $");
#include "opt_inet.h"
#include "opt_bwi.h"
#include "opt_wlan.h"
#include <sys/param.h>
#include <sys/endian.h>
@@ -56,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <sys/firmware.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
@@ -99,7 +101,6 @@ static void bwi_mac_opmode_init(struct bwi_mac *);
static void bwi_mac_hostflags_init(struct bwi_mac *);
static void bwi_mac_bss_param_init(struct bwi_mac *);
static int bwi_mac_fw_alloc(struct bwi_mac *);
static void bwi_mac_fw_free(struct bwi_mac *);
static int bwi_mac_fw_load(struct bwi_mac *);
static int bwi_mac_fw_init(struct bwi_mac *);
@@ -323,10 +324,6 @@ bwi_mac_init(struct bwi_mac *mac)
/*
* Load and initialize firmwares
*/
error = bwi_mac_fw_alloc(mac);
if (error)
return error;
error = bwi_mac_fw_load(mac);
if (error)
return error;
@@ -835,11 +832,11 @@ bwi_fwimage_is_valid(struct bwi_softc *sc, const struct firmware *fw,
uint8_t fw_type)
{
const struct bwi_fwhdr *hdr;
struct ifnet *ifp = sc->sc_ifp;
if (fw->datasize < sizeof(*hdr)) {
if_printf(ifp, "invalid firmware (%s): invalid size %zu\n",
fw->name, fw->datasize);
device_printf(sc->sc_dev,
"invalid firmware (%s): invalid size %zu\n",
fw->name, fw->datasize);
return 0;
}
@@ -850,25 +847,26 @@ bwi_fwimage_is_valid(struct bwi_softc *sc, const struct firmware *fw,
* Don't verify IV's size, it has different meaning
*/
if (be32toh(hdr->fw_size) != fw->datasize - sizeof(*hdr)) {
if_printf(ifp, "invalid firmware (%s): size mismatch, "
"fw %u, real %zu\n", fw->name,
be32toh(hdr->fw_size),
fw->datasize - sizeof(*hdr));
device_printf(sc->sc_dev,
"invalid firmware (%s): size mismatch, "
"fw %u, real %zu\n", fw->name,
be32toh(hdr->fw_size), fw->datasize - sizeof(*hdr));
return 0;
}
}
if (hdr->fw_type != fw_type) {
if_printf(ifp, "invalid firmware (%s): type mismatch, "
"fw \'%c\', target \'%c\'\n", fw->name,
hdr->fw_type, fw_type);
device_printf(sc->sc_dev,
"invalid firmware (%s): type mismatch, "
"fw \'%c\', target \'%c\'\n", fw->name,
hdr->fw_type, fw_type);
return 0;
}
if (hdr->fw_gen != BWI_FW_GEN_1) {
if_printf(ifp, "invalid firmware (%s): wrong generation, "
"fw %d, target %d\n", fw->name,
hdr->fw_gen, BWI_FW_GEN_1);
device_printf(sc->sc_dev,
"invalid firmware (%s): wrong generation, "
"fw %d, target %d\n", fw->name, hdr->fw_gen, BWI_FW_GEN_1);
return 0;
}
return 1;
@@ -877,11 +875,10 @@ bwi_fwimage_is_valid(struct bwi_softc *sc, const struct firmware *fw,
/*
* XXX Error cleanup
*/
static int
int
bwi_mac_fw_alloc(struct bwi_mac *mac)
{
struct bwi_softc *sc = mac->mac_sc;
struct ifnet *ifp = sc->sc_ifp;
char fwname[64];
int idx;
@@ -893,10 +890,8 @@ bwi_mac_fw_alloc(struct bwi_mac *mac)
snprintf(fwname, sizeof(fwname), BWI_FW_STUB_PATH,
sc->sc_fw_version);
mac->mac_stub = firmware_get(fwname);
if (mac->mac_stub == NULL) {
if_printf(ifp, "request firmware %s failed\n", fwname);
return ENOMEM;
}
if (mac->mac_stub == NULL)
goto no_firmware;
}
if (mac->mac_ucode == NULL) {
@@ -905,11 +900,8 @@ bwi_mac_fw_alloc(struct bwi_mac *mac)
mac->mac_rev >= 5 ? 5 : mac->mac_rev);
mac->mac_ucode = firmware_get(fwname);
if (mac->mac_ucode == NULL) {
if_printf(ifp, "request firmware %s failed\n", fwname);
return ENOMEM;
}
if (mac->mac_ucode == NULL)
goto no_firmware;
if (!bwi_fwimage_is_valid(sc, mac->mac_ucode, BWI_FW_T_UCODE))
return EINVAL;
}
@@ -920,11 +912,8 @@ bwi_mac_fw_alloc(struct bwi_mac *mac)
mac->mac_rev < 5 ? 4 : 5);
mac->mac_pcm = firmware_get(fwname);
if (mac->mac_pcm == NULL) {
if_printf(ifp, "request firmware %s failed\n", fwname);
return ENOMEM;
}
if (mac->mac_pcm == NULL)
goto no_firmware;
if (!bwi_fwimage_is_valid(sc, mac->mac_pcm, BWI_FW_T_PCM))
return EINVAL;
}
@@ -936,8 +925,8 @@ bwi_mac_fw_alloc(struct bwi_mac *mac)
} else if (mac->mac_rev >= 5 && mac->mac_rev <= 10) {
idx = 5;
} else {
if_printf(ifp, "no suitible IV for MAC rev %d\n",
mac->mac_rev);
device_printf(sc->sc_dev,
"no suitible IV for MAC rev %d\n", mac->mac_rev);
return ENODEV;
}
@@ -945,10 +934,8 @@ bwi_mac_fw_alloc(struct bwi_mac *mac)
sc->sc_fw_version, idx);
mac->mac_iv = firmware_get(fwname);
if (mac->mac_iv == NULL) {
if_printf(ifp, "request firmware %s failed\n", fwname);
return ENOMEM;
}
if (mac->mac_iv == NULL)
goto no_firmware;
if (!bwi_fwimage_is_valid(sc, mac->mac_iv, BWI_FW_T_IV))
return EINVAL;
}
@@ -958,12 +945,12 @@ bwi_mac_fw_alloc(struct bwi_mac *mac)
if (mac->mac_rev == 2 || mac->mac_rev == 4 ||
mac->mac_rev >= 11) {
/* No extended IV */
goto back;
return (0);
} else if (mac->mac_rev >= 5 && mac->mac_rev <= 10) {
idx = 5;
} else {
if_printf(ifp, "no suitible ExtIV for MAC rev %d\n",
mac->mac_rev);
device_printf(sc->sc_dev,
"no suitible ExtIV for MAC rev %d\n", mac->mac_rev);
return ENODEV;
}
@@ -971,15 +958,16 @@ bwi_mac_fw_alloc(struct bwi_mac *mac)
sc->sc_fw_version, idx);
mac->mac_iv_ext = firmware_get(fwname);
if (mac->mac_iv_ext == NULL) {
if_printf(ifp, "request firmware %s failed\n", fwname);
return ENOMEM;
}
if (mac->mac_iv_ext == NULL)
goto no_firmware;
if (!bwi_fwimage_is_valid(sc, mac->mac_iv_ext, BWI_FW_T_IV))
return EINVAL;
}
back:
return 0;
return (0);
no_firmware:
device_printf(sc->sc_dev, "request firmware %s failed\n", fwname);
return (ENOENT);
}
static void
@@ -1015,7 +1003,6 @@ static int
bwi_mac_fw_load(struct bwi_mac *mac)
{
struct bwi_softc *sc = mac->mac_sc;
struct ifnet *ifp = sc->sc_ifp;
const uint32_t *fw;
uint16_t fw_rev;
int fw_len, i;
@@ -1070,7 +1057,8 @@ bwi_mac_fw_load(struct bwi_mac *mac)
DELAY(10);
}
if (i == NRETRY) {
if_printf(ifp, "firmware (ucode&pcm) loading timed out\n");
device_printf(sc->sc_dev,
"firmware (ucode&pcm) loading timed out\n");
return ETIMEDOUT;
}
@@ -1080,12 +1068,14 @@ bwi_mac_fw_load(struct bwi_mac *mac)
fw_rev = MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_FWREV);
if (fw_rev > BWI_FW_VERSION3_REVMAX) {
if_printf(ifp, "firmware version 4 is not supported yet\n");
device_printf(sc->sc_dev,
"firmware version 4 is not supported yet\n");
return ENODEV;
}
if_printf(ifp, "firmware rev 0x%04x, patch level 0x%04x\n", fw_rev,
MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_FWPATCHLV));
device_printf(sc->sc_dev,
"firmware rev 0x%04x, patch level 0x%04x\n", fw_rev,
MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_FWPATCHLV));
return 0;
}
@@ -1145,7 +1135,6 @@ static int
bwi_mac_fw_load_iv(struct bwi_mac *mac, const struct firmware *fw)
{
struct bwi_softc *sc = mac->mac_sc;
struct ifnet *ifp = sc->sc_ifp;
const struct bwi_fwhdr *hdr;
const struct bwi_fw_iv *iv;
int n, i, iv_img_size;
@@ -1168,7 +1157,7 @@ bwi_mac_fw_load_iv(struct bwi_mac *mac, const struct firmware *fw)
int sz = 0;
if (iv_img_size < sizeof(iv->iv_ofs)) {
if_printf(ifp, "invalid IV image, ofs\n");
device_printf(sc->sc_dev, "invalid IV image, ofs\n");
return EINVAL;
}
iv_img_size -= sizeof(iv->iv_ofs);
@@ -1178,7 +1167,7 @@ bwi_mac_fw_load_iv(struct bwi_mac *mac, const struct firmware *fw)
ofs = __SHIFTOUT(iv_ofs, BWI_FW_IV_OFS_MASK);
if (ofs >= 0x1000) {
if_printf(ifp, "invalid ofs (0x%04x) "
device_printf(sc->sc_dev, "invalid ofs (0x%04x) "
"for %dth iv\n", ofs, i);
return EINVAL;
}
@@ -1187,7 +1176,8 @@ bwi_mac_fw_load_iv(struct bwi_mac *mac, const struct firmware *fw)
uint32_t val32;
if (iv_img_size < sizeof(iv->iv_val.val32)) {
if_printf(ifp, "invalid IV image, val32\n");
device_printf(sc->sc_dev,
"invalid IV image, val32\n");
return EINVAL;
}
iv_img_size -= sizeof(iv->iv_val.val32);
@@ -1199,7 +1189,8 @@ bwi_mac_fw_load_iv(struct bwi_mac *mac, const struct firmware *fw)
uint16_t val16;
if (iv_img_size < sizeof(iv->iv_val.val16)) {
if_printf(ifp, "invalid IV image, val16\n");
device_printf(sc->sc_dev,
"invalid IV image, val16\n");
return EINVAL;
}
iv_img_size -= sizeof(iv->iv_val.val16);
@@ -1213,7 +1204,8 @@ bwi_mac_fw_load_iv(struct bwi_mac *mac, const struct firmware *fw)
}
if (iv_img_size != 0) {
if_printf(ifp, "invalid IV image, size left %d\n", iv_img_size);
device_printf(sc->sc_dev, "invalid IV image, size left %d\n",
iv_img_size);
return EINVAL;
}
return 0;
@@ -1222,19 +1214,19 @@ bwi_mac_fw_load_iv(struct bwi_mac *mac, const struct firmware *fw)
static int
bwi_mac_fw_init(struct bwi_mac *mac)
{
struct ifnet *ifp = mac->mac_sc->sc_ifp;
device_t dev = mac->mac_sc->sc_dev;
int error;
error = bwi_mac_fw_load_iv(mac, mac->mac_iv);
if (error) {
if_printf(ifp, "load IV failed\n");
device_printf(dev, "load IV failed\n");
return error;
}
if (mac->mac_iv_ext != NULL) {
error = bwi_mac_fw_load_iv(mac, mac->mac_iv_ext);
if (error)
if_printf(ifp, "load ExtIV failed\n");
device_printf(dev, "load ExtIV failed\n");
}
return error;
}
@@ -1243,8 +1235,7 @@ static void
bwi_mac_opmode_init(struct bwi_mac *mac)
{
struct bwi_softc *sc = mac->mac_sc;
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211com *ic = &sc->sc_ic;
uint32_t mac_status;
uint16_t pre_tbtt;
@@ -1293,7 +1284,7 @@ bwi_mac_opmode_init(struct bwi_mac *mac)
break;
}
if (ic->ic_ifp->if_flags & IFF_PROMISC)
if (ic->ic_promisc > 0)
mac_status |= BWI_MAC_STATUS_PROMISC;
CSR_WRITE_4(sc, BWI_MAC_STATUS, mac_status);
@@ -1344,8 +1335,7 @@ bwi_mac_bss_param_init(struct bwi_mac *mac)
{
struct bwi_softc *sc = mac->mac_sc;
struct bwi_phy *phy = &mac->mac_phy;
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211com *ic = &sc->sc_ic;
const struct ieee80211_rate_table *rt;
struct bwi_retry_lim lim;
uint16_t cw_min;
@@ -1426,7 +1416,8 @@ bwi_mac_set_ackrates(struct bwi_mac *mac, const struct ieee80211_rate_table *rt,
enum ieee80211_phytype modtype;
uint16_t ofs;
modtype = ieee80211_rate2phytype(rt, rs->rs_rates[i]);
modtype = ieee80211_rate2phytype(rt,
rs->rs_rates[i] & IEEE80211_RATE_VAL);
switch (modtype) {
case IEEE80211_T_DS:
ofs = 0x4c0;
@@ -1437,7 +1428,9 @@ bwi_mac_set_ackrates(struct bwi_mac *mac, const struct ieee80211_rate_table *rt,
default:
panic("unsupported modtype %u\n", modtype);
}
ofs += 2*(ieee80211_rate2plcp(rs->rs_rates[i], modtype) & 0xf);
ofs += 2*(ieee80211_rate2plcp(
rs->rs_rates[i] & IEEE80211_RATE_VAL,
modtype) & 0xf);
MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, ofs + 0x20,
MOBJ_READ_2(mac, BWI_COMM_MOBJ, ofs));
@@ -1664,17 +1657,15 @@ bwi_mac_attach(struct bwi_softc *sc, int id, uint8_t rev)
/*
* Test whether the revision of this MAC is supported
*/
#define N(arr) (int)(sizeof(arr) / sizeof(arr[0]))
for (i = 0; i < N(bwi_sup_macrev); ++i) {
for (i = 0; i < nitems(bwi_sup_macrev); ++i) {
if (bwi_sup_macrev[i] == rev)
break;
}
if (i == N(bwi_sup_macrev)) {
if (i == nitems(bwi_sup_macrev)) {
device_printf(sc->sc_dev, "MAC rev %u is "
"not supported\n", rev);
return ENXIO;
}
#undef N
BWI_CREATE_MAC(mac, sc, id, rev);
sc->sc_nmac++;
@@ -1925,8 +1916,7 @@ static void
bwi_mac_lock(struct bwi_mac *mac)
{
struct bwi_softc *sc = mac->mac_sc;
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211com *ic = &sc->sc_ic;
KASSERT((mac->mac_flags & BWI_MAC_F_LOCKED) == 0,
("mac_flags 0x%x", mac->mac_flags));
@@ -1949,8 +1939,7 @@ static void
bwi_mac_unlock(struct bwi_mac *mac)
{
struct bwi_softc *sc = mac->mac_sc;
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211com *ic = &sc->sc_ic;
KASSERT(mac->mac_flags & BWI_MAC_F_LOCKED,
("mac_flags 0x%x", mac->mac_flags));
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* $DragonFly: src/sys/dev/netif/bwi/bwimac.h,v 1.2 2008/02/15 11:15:38 sephe Exp $
* $FreeBSD$
* $FreeBSD: releng/11.1/sys/dev/bwi/bwimac.h 283639 2015-05-27 22:30:21Z glebius $
*/
#ifndef _BWI_MAC_H
@@ -57,6 +57,7 @@ void bwi_mac_init_tpctl_11bg(struct bwi_mac *);
void bwi_mac_dummy_xmit(struct bwi_mac *);
void bwi_mac_reset_hwkeys(struct bwi_mac *);
int bwi_mac_config_ps(struct bwi_mac *);
int bwi_mac_fw_alloc(struct bwi_mac *);
uint16_t bwi_memobj_read_2(struct bwi_mac *, uint16_t, uint16_t);
uint32_t bwi_memobj_read_4(struct bwi_mac *, uint16_t, uint16_t);
@@ -35,9 +35,10 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
__FBSDID("$FreeBSD: releng/11.1/sys/dev/bwi/bwiphy.c 288087 2015-09-22 02:44:59Z adrian $");
#include "opt_inet.h"
#include "opt_wlan.h"
#include <sys/param.h>
#include <sys/endian.h>
@@ -52,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
@@ -183,19 +185,17 @@ bwi_phy_attach(struct bwi_mac *mac)
phy->phy_tbl_data_hi = BWI_PHYR_TBL_DATA_HI_11A;
break;
case BWI_PHYINFO_TYPE_11B:
#define N(arr) (int)(sizeof(arr) / sizeof(arr[0]))
for (i = 0; i < N(bwi_sup_bphy); ++i) {
for (i = 0; i < nitems(bwi_sup_bphy); ++i) {
if (phyrev == bwi_sup_bphy[i].rev) {
phy->phy_init = bwi_sup_bphy[i].init;
break;
}
}
if (i == N(bwi_sup_bphy)) {
if (i == nitems(bwi_sup_bphy)) {
device_printf(sc->sc_dev, "unsupported 11B PHY, "
"rev %u\n", phyrev);
return ENXIO;
}
#undef N
phy->phy_mode = IEEE80211_MODE_11B;
break;
case BWI_PHYINFO_TYPE_11G:
@@ -427,7 +427,7 @@ static void
bwi_phy_init_11b_rev2(struct bwi_mac *mac)
{
/* TODO:11B */
if_printf(mac->mac_sc->sc_ifp,
device_printf(mac->mac_sc->sc_dev,
"%s is not implemented yet\n", __func__);
}
@@ -743,8 +743,6 @@ bwi_phy_init_11b_rev6(struct bwi_mac *mac)
}
}
#define N(arr) (int)(sizeof(arr) / sizeof(arr[0]))
static void
bwi_phy_config_11g(struct bwi_mac *mac)
{
@@ -761,19 +759,19 @@ bwi_phy_config_11g(struct bwi_mac *mac)
PHY_WRITE(mac, 0x427, 0x1a);
/* Fill frequency table */
for (i = 0; i < N(bwi_phy_freq_11g_rev1); ++i) {
for (i = 0; i < nitems(bwi_phy_freq_11g_rev1); ++i) {
bwi_tbl_write_2(mac, BWI_PHYTBL_FREQ + i,
bwi_phy_freq_11g_rev1[i]);
}
/* Fill noise table */
for (i = 0; i < N(bwi_phy_noise_11g_rev1); ++i) {
for (i = 0; i < nitems(bwi_phy_noise_11g_rev1); ++i) {
bwi_tbl_write_2(mac, BWI_PHYTBL_NOISE + i,
bwi_phy_noise_11g_rev1[i]);
}
/* Fill rotor table */
for (i = 0; i < N(bwi_phy_rotor_11g_rev1); ++i) {
for (i = 0; i < nitems(bwi_phy_rotor_11g_rev1); ++i) {
/* NB: data length is 4 bytes */
bwi_tbl_write_4(mac, BWI_PHYTBL_ROTOR + i,
bwi_phy_rotor_11g_rev1[i]);
@@ -796,7 +794,7 @@ bwi_phy_config_11g(struct bwi_mac *mac)
bwi_tbl_write_2(mac, BWI_PHYTBL_RSSI + i, i);
/* Fill noise table */
for (i = 0; i < N(bwi_phy_noise_11g); ++i) {
for (i = 0; i < nitems(bwi_phy_noise_11g); ++i) {
bwi_tbl_write_2(mac, BWI_PHYTBL_NOISE + i,
bwi_phy_noise_11g[i]);
}
@@ -807,13 +805,13 @@ bwi_phy_config_11g(struct bwi_mac *mac)
*/
if (phy->phy_rev <= 2) {
tbl = bwi_phy_noise_scale_11g_rev2;
n = N(bwi_phy_noise_scale_11g_rev2);
n = nitems(bwi_phy_noise_scale_11g_rev2);
} else if (phy->phy_rev >= 7 && (PHY_READ(mac, 0x449) & 0x200)) {
tbl = bwi_phy_noise_scale_11g_rev7;
n = N(bwi_phy_noise_scale_11g_rev7);
n = nitems(bwi_phy_noise_scale_11g_rev7);
} else {
tbl = bwi_phy_noise_scale_11g;
n = N(bwi_phy_noise_scale_11g);
n = nitems(bwi_phy_noise_scale_11g);
}
for (i = 0; i < n; ++i)
bwi_tbl_write_2(mac, BWI_PHYTBL_NOISE_SCALE + i, tbl[i]);
@@ -823,10 +821,10 @@ bwi_phy_config_11g(struct bwi_mac *mac)
*/
if (phy->phy_rev == 2) {
tbl = bwi_phy_sigma_sq_11g_rev2;
n = N(bwi_phy_sigma_sq_11g_rev2);
n = nitems(bwi_phy_sigma_sq_11g_rev2);
} else if (phy->phy_rev > 2 && phy->phy_rev <= 8) {
tbl = bwi_phy_sigma_sq_11g_rev7;
n = N(bwi_phy_sigma_sq_11g_rev7);
n = nitems(bwi_phy_sigma_sq_11g_rev7);
} else {
tbl = NULL;
n = 0;
@@ -836,7 +834,7 @@ bwi_phy_config_11g(struct bwi_mac *mac)
if (phy->phy_rev == 1) {
/* Fill delay table */
for (i = 0; i < N(bwi_phy_delay_11g_rev1); ++i) {
for (i = 0; i < nitems(bwi_phy_delay_11g_rev1); ++i) {
bwi_tbl_write_4(mac, BWI_PHYTBL_DELAY + i,
bwi_phy_delay_11g_rev1[i]);
}
@@ -875,8 +873,6 @@ bwi_phy_config_11g(struct bwi_mac *mac)
PHY_WRITE(mac, 0x46e, 0x3cf);
}
#undef N
/*
* Configure Automatic Gain Controller
*/
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* $DragonFly: src/sys/dev/netif/bwi/bwiphy.h,v 1.1 2007/09/08 06:15:54 sephe Exp $
* $FreeBSD$
* $FreeBSD: releng/11.1/sys/dev/bwi/bwiphy.h 191762 2009-05-03 04:01:43Z imp $
*/
#ifndef _BWI_PHY_H
@@ -35,10 +35,11 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
__FBSDID("$FreeBSD: releng/11.1/sys/dev/bwi/bwirf.c 298307 2016-04-19 23:37:24Z pfg $");
#include "opt_inet.h"
#include "opt_bwi.h"
#include "opt_wlan.h"
#include <sys/param.h>
#include <sys/endian.h>
@@ -53,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
@@ -1016,8 +1018,7 @@ bwi_rf_calibval(struct bwi_mac *mac)
val = RF_READ(mac, BWI_RFR_BBP_ATTEN);
idx = __SHIFTOUT(val, BWI_RFR_BBP_ATTEN_CALIB_IDX);
KASSERT(idx < (int)(sizeof(rf_calibvals) / sizeof(rf_calibvals[0])),
("idx %d", idx));
KASSERT(idx < (int)nitems(rf_calibvals), ("idx %d", idx));
calib = rf_calibvals[idx] << 1;
if (val & BWI_RFR_BBP_ATTEN_CALIB_BIT)
@@ -1153,7 +1154,6 @@ bwi_rf_map_txpower(struct bwi_mac *mac)
}
#define IS_VALID_PA_PARAM(p) ((p) != 0 && (p) != -1)
#define N(arr) (int)(sizeof(arr) / sizeof(arr[0]))
/*
* Extract PA parameters
@@ -1162,10 +1162,10 @@ bwi_rf_map_txpower(struct bwi_mac *mac)
sprom_ofs = BWI_SPROM_PA_PARAM_11A;
else
sprom_ofs = BWI_SPROM_PA_PARAM_11BG;
for (i = 0; i < N(pa_params); ++i)
for (i = 0; i < nitems(pa_params); ++i)
pa_params[i] = (int16_t)bwi_read_sprom(sc, sprom_ofs + (i * 2));
for (i = 0; i < N(pa_params); ++i) {
for (i = 0; i < nitems(pa_params); ++i) {
/*
* If one of the PA parameters from SPROM is not valid,
* fall back to the default values, if there are any.
@@ -1198,8 +1198,6 @@ bwi_rf_map_txpower(struct bwi_mac *mac)
}
}
#undef N
/*
* All of the PA parameters from SPROM are valid.
*/
@@ -1258,7 +1256,6 @@ static void
bwi_rf_lo_update_11g(struct bwi_mac *mac)
{
struct bwi_softc *sc = mac->mac_sc;
struct ifnet *ifp = sc->sc_ifp;
struct bwi_rf *rf = &mac->mac_rf;
struct bwi_phy *phy = &mac->mac_phy;
struct bwi_tpctl *tpctl = &mac->mac_tpctl;
@@ -1327,7 +1324,7 @@ bwi_rf_lo_update_11g(struct bwi_mac *mac)
PHY_WRITE(mac, 0x812, 0xb2);
}
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
if ((sc->sc_flags & BWI_F_RUNNING) == 0)
tpctl->tp_ctrl2 = bwi_rf_get_tp_ctrl2(mac);
PHY_WRITE(mac, 0x80f, 0x8078);
@@ -1350,7 +1347,7 @@ bwi_rf_lo_update_11g(struct bwi_mac *mac)
PHY_WRITE(mac, 0x15, devi_ctrl | 0xefa0);
}
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
if ((sc->sc_flags & BWI_F_RUNNING) == 0)
tpctl = NULL;
bwi_rf_lo_adjust(mac, tpctl);
@@ -1460,7 +1457,7 @@ _bwi_rf_lo_update_11g(struct bwi_mac *mac, uint16_t orig_rf7a)
static const int rf_lo_measure_order[RF_ATTEN_LISTSZ] =
{ 3, 1, 5, 7, 9, 2, 0, 4, 6, 8, 10, 11, 12, 13 };
struct ifnet *ifp = mac->mac_sc->sc_ifp;
struct bwi_softc *sc = mac->mac_sc;
struct bwi_rf_lo lo_save, *lo;
uint8_t devi_ctrl = 0;
int idx, adj_rf7a = 0;
@@ -1474,7 +1471,7 @@ _bwi_rf_lo_update_11g(struct bwi_mac *mac, uint16_t orig_rf7a)
for (bbp_atten = 0; bbp_atten < BBP_ATTEN_MAX; ++bbp_atten) {
uint16_t tp_ctrl2, rf7a;
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
if ((sc->sc_flags & BWI_F_RUNNING) == 0) {
if (idx == 0) {
bzero(&lo_save, sizeof(lo_save));
} else if (init_rf_atten < 0) {
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* $DragonFly: src/sys/dev/netif/bwi/bwirf.h,v 1.3 2007/10/03 04:53:19 sephe Exp $
* $FreeBSD$
* $FreeBSD: releng/11.1/sys/dev/bwi/bwirf.h 191762 2009-05-03 04:01:43Z imp $
*/
#ifndef _BWI_RF_H
File diff suppressed because it is too large Load Diff
@@ -28,17 +28,20 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
__FBSDID("$FreeBSD: releng/11.1/sys/dev/bwi/if_bwi_pci.c 283637 2015-05-27 22:27:15Z glebius $");
/*
* PCI/Cardbus front-end for the Broadcom Wireless LAN controller driver.
*/
#include "opt_wlan.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/errno.h>
@@ -50,8 +53,10 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_media.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
@@ -156,12 +161,6 @@ bwi_pci_attach(device_t dev)
device_printf(dev, "could not map interrupt\n");
goto bad1;
}
if (bus_setup_intr(dev, sc->sc_irq_res,
INTR_TYPE_NET | INTR_MPSAFE,
NULL, bwi_intr, sc, &sc->sc_irq_handle)) {
device_printf(dev, "could not establish interrupt\n");
goto bad2;
}
/* Get more PCI information */
sc->sc_pci_did = pci_get_device(dev);
@@ -169,11 +168,17 @@ bwi_pci_attach(device_t dev)
sc->sc_pci_subvid = pci_get_subvendor(dev);
sc->sc_pci_subdid = pci_get_subdevice(dev);
error = bwi_attach(sc);
if (error == 0) /* success */
return 0;
if ((error = bwi_attach(sc)) != 0)
goto bad2;
if (bus_setup_intr(dev, sc->sc_irq_res,
INTR_TYPE_NET | INTR_MPSAFE,
NULL, bwi_intr, sc, &sc->sc_irq_handle)) {
device_printf(dev, "could not establish interrupt\n");
goto bad2;
}
return (0);
bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_irq_handle);
bad2:
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res);
bad1:
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* $DragonFly: src/sys/dev/netif/bwi/if_bwireg.h,v 1.4 2007/10/19 14:27:04 sephe Exp $
* $FreeBSD$
* $FreeBSD: releng/11.1/sys/dev/bwi/if_bwireg.h 192279 2009-05-18 01:07:38Z imp $
*/
#ifndef _IF_BWIREG_H
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2007 The DragonFly Project. All rights reserved.
*
*
* This code is derived from software contributed to The DragonFly Project
* by Sepherosa Ziehau <sepherosa@gmail.com>
*
*
* 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
@@ -17,7 +17,7 @@
* 3. Neither the name of The DragonFly Project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific, prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -30,9 +30,9 @@
* 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.
*
*
* $DragonFly: src/sys/dev/netif/bwi/if_bwivar.h,v 1.14 2008/02/15 11:15:38 sephe Exp $
* $FreeBSD$
* $FreeBSD: releng/11.1/sys/dev/bwi/if_bwivar.h 287197 2015-08-27 08:56:39Z glebius $
*/
#ifndef _IF_BWIVAR_H
@@ -541,10 +541,11 @@ struct bwi_vap {
#define BWI_VAP(vap) ((struct bwi_vap *)(vap))
struct bwi_softc {
struct ifnet *sc_ifp;
uint32_t sc_flags; /* BWI_F_ */
device_t sc_dev;
struct mtx sc_mtx;
struct ieee80211com sc_ic;
struct mbufq sc_snd;
int sc_invalid;
uint32_t sc_cap; /* BWI_CAP_ */
@@ -651,6 +652,7 @@ struct bwi_softc {
#define BWI_F_BUS_INITED 0x1
#define BWI_F_PROMISC 0x2
#define BWI_F_STOP 0x4
#define BWI_F_RUNNING 0x8
#define BWI_DBG_MAC 0x00000001
#define BWI_DBG_RF 0x00000002
@@ -0,0 +1 @@
/* nothing here */
@@ -32,10 +32,9 @@ int
HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
{
struct bwi_softc* sc = (struct bwi_softc*)device_get_softc(dev);
struct ifnet* ifp = sc->sc_ifp;
uint32 intr_status;
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0
if ((sc->sc_flags & BWI_F_RUNNING) == 0
|| (sc->sc_flags & BWI_F_STOP))
return 0;