Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/bwn/if_bwn.c
Show First 20 Lines • Show All 6,395 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
bwn_set_txhdr(struct bwn_mac *mac, struct ieee80211_node *ni, | bwn_set_txhdr(struct bwn_mac *mac, struct ieee80211_node *ni, | ||||
struct mbuf *m, struct bwn_txhdr *txhdr, uint16_t cookie) | struct mbuf *m, struct bwn_txhdr *txhdr, uint16_t cookie) | ||||
{ | { | ||||
const struct bwn_phy *phy = &mac->mac_phy; | const struct bwn_phy *phy = &mac->mac_phy; | ||||
struct bwn_softc *sc = mac->mac_sc; | struct bwn_softc *sc = mac->mac_sc; | ||||
struct ieee80211_frame *wh; | struct ieee80211_frame *wh; | ||||
struct ieee80211_frame *protwh; | struct ieee80211_frame *protwh; | ||||
struct ieee80211_frame_cts *cts; | |||||
struct ieee80211_frame_rts *rts; | |||||
const struct ieee80211_txparam *tp = ni->ni_txparms; | const struct ieee80211_txparam *tp = ni->ni_txparms; | ||||
struct ieee80211vap *vap = ni->ni_vap; | struct ieee80211vap *vap = ni->ni_vap; | ||||
struct ieee80211com *ic = &sc->sc_ic; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct mbuf *mprot; | struct mbuf *mprot; | ||||
uint8_t *prot_ptr; | |||||
unsigned int len; | unsigned int len; | ||||
uint32_t macctl = 0; | uint32_t macctl = 0; | ||||
int protdur, rts_rate, rts_rate_fb, ismcast, isshort, rix, type; | int rts_rate, rts_rate_fb, ismcast, isshort, rix, type; | ||||
uint16_t phyctl = 0; | uint16_t phyctl = 0; | ||||
uint8_t rate, rate_fb; | uint8_t rate, rate_fb; | ||||
int fill_phy_ctl1 = 0; | int fill_phy_ctl1 = 0; | ||||
wh = mtod(m, struct ieee80211_frame *); | wh = mtod(m, struct ieee80211_frame *); | ||||
memset(txhdr, 0, sizeof(*txhdr)); | memset(txhdr, 0, sizeof(*txhdr)); | ||||
type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; | type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | bwn_set_txhdr(struct bwn_mac *mac, struct ieee80211_node *ni, | ||||
if (!ismcast) | if (!ismcast) | ||||
macctl |= BWN_TX_MAC_ACK; | macctl |= BWN_TX_MAC_ACK; | ||||
macctl |= (BWN_TX_MAC_HWSEQ | BWN_TX_MAC_START_MSDU); | macctl |= (BWN_TX_MAC_HWSEQ | BWN_TX_MAC_START_MSDU); | ||||
if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && | if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && | ||||
m->m_pkthdr.len + IEEE80211_CRC_LEN > vap->iv_rtsthreshold) | m->m_pkthdr.len + IEEE80211_CRC_LEN > vap->iv_rtsthreshold) | ||||
macctl |= BWN_TX_MAC_LONGFRAME; | macctl |= BWN_TX_MAC_LONGFRAME; | ||||
if (ic->ic_flags & IEEE80211_F_USEPROT) { | if ((ic->ic_flags & IEEE80211_F_USEPROT) && | ||||
ic->ic_protmode != IEEE80211_PROT_NONE) { | |||||
/* Note: don't fall back to CCK rates for 5G */ | /* Note: don't fall back to CCK rates for 5G */ | ||||
if (phy->gmode) | if (phy->gmode) | ||||
rts_rate = BWN_CCK_RATE_1MB; | rts_rate = BWN_CCK_RATE_1MB; | ||||
else | else | ||||
rts_rate = BWN_OFDM_RATE_6MB; | rts_rate = BWN_OFDM_RATE_6MB; | ||||
rts_rate_fb = bwn_get_fbrate(rts_rate); | rts_rate_fb = bwn_get_fbrate(rts_rate); | ||||
/* XXX 'rate' here is hardware rate now, not the net80211 rate */ | /* XXX 'rate' here is hardware rate now, not the net80211 rate */ | ||||
protdur = ieee80211_compute_duration(ic->ic_rt, | mprot = ieee80211_alloc_prot(ni, m, rate, ic->ic_protmode); | ||||
m->m_pkthdr.len, rate, isshort) + | if (mprot == NULL) { | ||||
+ ieee80211_ack_duration(ic->ic_rt, rate, isshort); | if_inc_counter(vap->iv_ifp, IFCOUNTER_OERRORS, 1); | ||||
device_printf(sc->sc_dev, | |||||
"could not allocate mbuf for protection mode %d\n", | |||||
ic->ic_protmode); | |||||
return (ENOBUFS); | |||||
} | |||||
if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) { | |||||
switch (mac->mac_fw.fw_hdr_format) { | switch (mac->mac_fw.fw_hdr_format) { | ||||
case BWN_FW_HDR_351: | case BWN_FW_HDR_351: | ||||
cts = (struct ieee80211_frame_cts *) | prot_ptr = txhdr->body.r351.rts_frame; | ||||
txhdr->body.r351.rts_frame; | |||||
break; | break; | ||||
case BWN_FW_HDR_410: | case BWN_FW_HDR_410: | ||||
cts = (struct ieee80211_frame_cts *) | prot_ptr = txhdr->body.r410.rts_frame; | ||||
txhdr->body.r410.rts_frame; | |||||
break; | break; | ||||
case BWN_FW_HDR_598: | case BWN_FW_HDR_598: | ||||
cts = (struct ieee80211_frame_cts *) | prot_ptr = txhdr->body.r598.rts_frame; | ||||
txhdr->body.r598.rts_frame; | |||||
break; | break; | ||||
} | } | ||||
mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, | bcopy(mtod(mprot, uint8_t *), prot_ptr, mprot->m_pkthdr.len); | ||||
protdur); | |||||
KASSERT(mprot != NULL, ("failed to alloc mbuf\n")); | |||||
bcopy(mtod(mprot, uint8_t *), (uint8_t *)cts, | |||||
mprot->m_pkthdr.len); | |||||
m_freem(mprot); | m_freem(mprot); | ||||
if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) { | |||||
macctl |= BWN_TX_MAC_SEND_CTSTOSELF; | macctl |= BWN_TX_MAC_SEND_CTSTOSELF; | ||||
len = sizeof(struct ieee80211_frame_cts); | len = sizeof(struct ieee80211_frame_cts); | ||||
} else { | } else { | ||||
switch (mac->mac_fw.fw_hdr_format) { | |||||
case BWN_FW_HDR_351: | |||||
rts = (struct ieee80211_frame_rts *) | |||||
txhdr->body.r351.rts_frame; | |||||
break; | |||||
case BWN_FW_HDR_410: | |||||
rts = (struct ieee80211_frame_rts *) | |||||
txhdr->body.r410.rts_frame; | |||||
break; | |||||
case BWN_FW_HDR_598: | |||||
rts = (struct ieee80211_frame_rts *) | |||||
txhdr->body.r598.rts_frame; | |||||
break; | |||||
} | |||||
/* XXX rate/rate_fb is the hardware rate */ | |||||
protdur += ieee80211_ack_duration(ic->ic_rt, rate, | |||||
isshort); | |||||
mprot = ieee80211_alloc_rts(ic, wh->i_addr1, | |||||
wh->i_addr2, protdur); | |||||
KASSERT(mprot != NULL, ("failed to alloc mbuf\n")); | |||||
bcopy(mtod(mprot, uint8_t *), (uint8_t *)rts, | |||||
mprot->m_pkthdr.len); | |||||
m_freem(mprot); | |||||
macctl |= BWN_TX_MAC_SEND_RTSCTS; | macctl |= BWN_TX_MAC_SEND_RTSCTS; | ||||
len = sizeof(struct ieee80211_frame_rts); | len = sizeof(struct ieee80211_frame_rts); | ||||
} | } | ||||
len += IEEE80211_CRC_LEN; | len += IEEE80211_CRC_LEN; | ||||
switch (mac->mac_fw.fw_hdr_format) { | switch (mac->mac_fw.fw_hdr_format) { | ||||
case BWN_FW_HDR_351: | case BWN_FW_HDR_351: | ||||
bwn_plcp_genhdr((struct bwn_plcp4 *) | bwn_plcp_genhdr((struct bwn_plcp4 *) | ||||
▲ Show 20 Lines • Show All 1,178 Lines • Show Last 20 Lines |