Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bwi/bwimac.c
Context not available. | |||||
uint8_t fw_type) | uint8_t fw_type) | ||||
{ | { | ||||
const struct bwi_fwhdr *hdr; | const struct bwi_fwhdr *hdr; | ||||
struct ifnet *ifp = sc->sc_ifp; | |||||
if (fw->datasize < sizeof(*hdr)) { | if (fw->datasize < sizeof(*hdr)) { | ||||
if_printf(ifp, "invalid firmware (%s): invalid size %zu\n", | device_printf(sc->sc_dev, | ||||
fw->name, fw->datasize); | "invalid firmware (%s): invalid size %zu\n", | ||||
fw->name, fw->datasize); | |||||
return 0; | return 0; | ||||
} | } | ||||
Context not available. | |||||
* Don't verify IV's size, it has different meaning | * Don't verify IV's size, it has different meaning | ||||
*/ | */ | ||||
if (be32toh(hdr->fw_size) != fw->datasize - sizeof(*hdr)) { | if (be32toh(hdr->fw_size) != fw->datasize - sizeof(*hdr)) { | ||||
if_printf(ifp, "invalid firmware (%s): size mismatch, " | device_printf(sc->sc_dev, | ||||
"fw %u, real %zu\n", fw->name, | "invalid firmware (%s): size mismatch, " | ||||
be32toh(hdr->fw_size), | "fw %u, real %zu\n", fw->name, | ||||
fw->datasize - sizeof(*hdr)); | be32toh(hdr->fw_size), fw->datasize - sizeof(*hdr)); | ||||
return 0; | return 0; | ||||
} | } | ||||
} | } | ||||
if (hdr->fw_type != fw_type) { | if (hdr->fw_type != fw_type) { | ||||
if_printf(ifp, "invalid firmware (%s): type mismatch, " | device_printf(sc->sc_dev, | ||||
"fw \'%c\', target \'%c\'\n", fw->name, | "invalid firmware (%s): type mismatch, " | ||||
hdr->fw_type, fw_type); | "fw \'%c\', target \'%c\'\n", fw->name, | ||||
hdr->fw_type, fw_type); | |||||
return 0; | return 0; | ||||
} | } | ||||
if (hdr->fw_gen != BWI_FW_GEN_1) { | if (hdr->fw_gen != BWI_FW_GEN_1) { | ||||
if_printf(ifp, "invalid firmware (%s): wrong generation, " | device_printf(sc->sc_dev, | ||||
"fw %d, target %d\n", fw->name, | "invalid firmware (%s): wrong generation, " | ||||
hdr->fw_gen, BWI_FW_GEN_1); | "fw %d, target %d\n", fw->name, hdr->fw_gen, BWI_FW_GEN_1); | ||||
return 0; | return 0; | ||||
} | } | ||||
return 1; | return 1; | ||||
Context not available. | |||||
bwi_mac_fw_load(struct bwi_mac *mac) | bwi_mac_fw_load(struct bwi_mac *mac) | ||||
{ | { | ||||
struct bwi_softc *sc = mac->mac_sc; | struct bwi_softc *sc = mac->mac_sc; | ||||
struct ifnet *ifp = sc->sc_ifp; | |||||
const uint32_t *fw; | const uint32_t *fw; | ||||
uint16_t fw_rev; | uint16_t fw_rev; | ||||
int fw_len, i; | int fw_len, i; | ||||
Context not available. | |||||
DELAY(10); | DELAY(10); | ||||
} | } | ||||
if (i == NRETRY) { | 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; | return ETIMEDOUT; | ||||
} | } | ||||
Context not available. | |||||
fw_rev = MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_FWREV); | fw_rev = MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_FWREV); | ||||
if (fw_rev > BWI_FW_VERSION3_REVMAX) { | 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; | return ENODEV; | ||||
} | } | ||||
if_printf(ifp, "firmware rev 0x%04x, patch level 0x%04x\n", fw_rev, | device_printf(sc->sc_dev, | ||||
MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_FWPATCHLV)); | "firmware rev 0x%04x, patch level 0x%04x\n", fw_rev, | ||||
MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_FWPATCHLV)); | |||||
return 0; | return 0; | ||||
} | } | ||||
Context not available. | |||||
bwi_mac_fw_load_iv(struct bwi_mac *mac, const struct firmware *fw) | bwi_mac_fw_load_iv(struct bwi_mac *mac, const struct firmware *fw) | ||||
{ | { | ||||
struct bwi_softc *sc = mac->mac_sc; | struct bwi_softc *sc = mac->mac_sc; | ||||
struct ifnet *ifp = sc->sc_ifp; | |||||
const struct bwi_fwhdr *hdr; | const struct bwi_fwhdr *hdr; | ||||
const struct bwi_fw_iv *iv; | const struct bwi_fw_iv *iv; | ||||
int n, i, iv_img_size; | int n, i, iv_img_size; | ||||
Context not available. | |||||
int sz = 0; | int sz = 0; | ||||
if (iv_img_size < sizeof(iv->iv_ofs)) { | 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; | return EINVAL; | ||||
} | } | ||||
iv_img_size -= sizeof(iv->iv_ofs); | iv_img_size -= sizeof(iv->iv_ofs); | ||||
Context not available. | |||||
ofs = __SHIFTOUT(iv_ofs, BWI_FW_IV_OFS_MASK); | ofs = __SHIFTOUT(iv_ofs, BWI_FW_IV_OFS_MASK); | ||||
if (ofs >= 0x1000) { | 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); | "for %dth iv\n", ofs, i); | ||||
return EINVAL; | return EINVAL; | ||||
} | } | ||||
Context not available. | |||||
uint32_t val32; | uint32_t val32; | ||||
if (iv_img_size < sizeof(iv->iv_val.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; | return EINVAL; | ||||
} | } | ||||
iv_img_size -= sizeof(iv->iv_val.val32); | iv_img_size -= sizeof(iv->iv_val.val32); | ||||
Context not available. | |||||
uint16_t val16; | uint16_t val16; | ||||
if (iv_img_size < sizeof(iv->iv_val.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; | return EINVAL; | ||||
} | } | ||||
iv_img_size -= sizeof(iv->iv_val.val16); | iv_img_size -= sizeof(iv->iv_val.val16); | ||||
Context not available. | |||||
} | } | ||||
if (iv_img_size != 0) { | 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 EINVAL; | ||||
} | } | ||||
return 0; | return 0; | ||||
Context not available. | |||||
static int | static int | ||||
bwi_mac_fw_init(struct bwi_mac *mac) | 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; | int error; | ||||
error = bwi_mac_fw_load_iv(mac, mac->mac_iv); | error = bwi_mac_fw_load_iv(mac, mac->mac_iv); | ||||
if (error) { | if (error) { | ||||
if_printf(ifp, "load IV failed\n"); | device_printf(dev, "load IV failed\n"); | ||||
return error; | return error; | ||||
} | } | ||||
Context not available. | |||||
if (mac->mac_iv_ext != NULL) { | if (mac->mac_iv_ext != NULL) { | ||||
error = bwi_mac_fw_load_iv(mac, mac->mac_iv_ext); | error = bwi_mac_fw_load_iv(mac, mac->mac_iv_ext); | ||||
if (error) | if (error) | ||||
if_printf(ifp, "load ExtIV failed\n"); | device_printf(dev, "load ExtIV failed\n"); | ||||
} | } | ||||
return error; | return error; | ||||
} | } | ||||
Context not available. | |||||
bwi_mac_opmode_init(struct bwi_mac *mac) | bwi_mac_opmode_init(struct bwi_mac *mac) | ||||
{ | { | ||||
struct bwi_softc *sc = mac->mac_sc; | struct bwi_softc *sc = mac->mac_sc; | ||||
struct ifnet *ifp = sc->sc_ifp; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211com *ic = ifp->if_l2com; | |||||
uint32_t mac_status; | uint32_t mac_status; | ||||
uint16_t pre_tbtt; | uint16_t pre_tbtt; | ||||
Context not available. | |||||
break; | break; | ||||
} | } | ||||
if (ic->ic_ifp->if_flags & IFF_PROMISC) | if (ic->ic_promisc > 0) | ||||
mac_status |= BWI_MAC_STATUS_PROMISC; | mac_status |= BWI_MAC_STATUS_PROMISC; | ||||
CSR_WRITE_4(sc, BWI_MAC_STATUS, mac_status); | CSR_WRITE_4(sc, BWI_MAC_STATUS, mac_status); | ||||
Context not available. | |||||
{ | { | ||||
struct bwi_softc *sc = mac->mac_sc; | struct bwi_softc *sc = mac->mac_sc; | ||||
struct bwi_phy *phy = &mac->mac_phy; | struct bwi_phy *phy = &mac->mac_phy; | ||||
struct ifnet *ifp = sc->sc_ifp; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211com *ic = ifp->if_l2com; | |||||
const struct ieee80211_rate_table *rt; | const struct ieee80211_rate_table *rt; | ||||
struct bwi_retry_lim lim; | struct bwi_retry_lim lim; | ||||
uint16_t cw_min; | uint16_t cw_min; | ||||
Context not available. | |||||
bwi_mac_lock(struct bwi_mac *mac) | bwi_mac_lock(struct bwi_mac *mac) | ||||
{ | { | ||||
struct bwi_softc *sc = mac->mac_sc; | struct bwi_softc *sc = mac->mac_sc; | ||||
struct ifnet *ifp = sc->sc_ifp; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211com *ic = ifp->if_l2com; | |||||
KASSERT((mac->mac_flags & BWI_MAC_F_LOCKED) == 0, | KASSERT((mac->mac_flags & BWI_MAC_F_LOCKED) == 0, | ||||
("mac_flags 0x%x", mac->mac_flags)); | ("mac_flags 0x%x", mac->mac_flags)); | ||||
Context not available. | |||||
bwi_mac_unlock(struct bwi_mac *mac) | bwi_mac_unlock(struct bwi_mac *mac) | ||||
{ | { | ||||
struct bwi_softc *sc = mac->mac_sc; | struct bwi_softc *sc = mac->mac_sc; | ||||
struct ifnet *ifp = sc->sc_ifp; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211com *ic = ifp->if_l2com; | |||||
KASSERT(mac->mac_flags & BWI_MAC_F_LOCKED, | KASSERT(mac->mac_flags & BWI_MAC_F_LOCKED, | ||||
("mac_flags 0x%x", mac->mac_flags)); | ("mac_flags 0x%x", mac->mac_flags)); | ||||
Context not available. |