Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/usb/wlan/if_ural.c
Show First 20 Lines • Show All 1,124 Lines • ▼ Show 20 Lines | ural_tx_mgt(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) | ||||
return 0; | return 0; | ||||
} | } | ||||
static int | static int | ||||
ural_sendprot(struct ural_softc *sc, | ural_sendprot(struct ural_softc *sc, | ||||
const struct mbuf *m, struct ieee80211_node *ni, int prot, int rate) | const struct mbuf *m, struct ieee80211_node *ni, int prot, int rate) | ||||
{ | { | ||||
struct ieee80211com *ic = ni->ni_ic; | struct ieee80211com *ic = ni->ni_ic; | ||||
const struct ieee80211_frame *wh; | |||||
struct ural_tx_data *data; | struct ural_tx_data *data; | ||||
struct mbuf *mprot; | struct mbuf *mprot; | ||||
int protrate, ackrate, pktlen, flags, isshort; | int protrate, flags; | ||||
uint16_t dur; | |||||
KASSERT(prot == IEEE80211_PROT_RTSCTS || prot == IEEE80211_PROT_CTSONLY, | mprot = ieee80211_alloc_prot(ni, m, rate, prot); | ||||
("protection %d", prot)); | if (mprot == NULL) { | ||||
if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); | |||||
device_printf(sc->sc_dev, | |||||
"could not allocate mbuf for protection mode %d\n", prot); | |||||
return ENOBUFS; | |||||
} | |||||
wh = mtod(m, const struct ieee80211_frame *); | |||||
pktlen = m->m_pkthdr.len + IEEE80211_CRC_LEN; | |||||
protrate = ieee80211_ctl_rate(ic->ic_rt, rate); | protrate = ieee80211_ctl_rate(ic->ic_rt, rate); | ||||
ackrate = ieee80211_ack_rate(ic->ic_rt, rate); | |||||
isshort = (ic->ic_flags & IEEE80211_F_SHPREAMBLE) != 0; | |||||
dur = ieee80211_compute_duration(ic->ic_rt, pktlen, rate, isshort) | |||||
+ ieee80211_ack_duration(ic->ic_rt, rate, isshort); | |||||
flags = RAL_TX_RETRY(7); | flags = RAL_TX_RETRY(7); | ||||
if (prot == IEEE80211_PROT_RTSCTS) { | if (prot == IEEE80211_PROT_RTSCTS) | ||||
/* NB: CTS is the same size as an ACK */ | |||||
dur += ieee80211_ack_duration(ic->ic_rt, rate, isshort); | |||||
flags |= RAL_TX_ACK; | flags |= RAL_TX_ACK; | ||||
mprot = ieee80211_alloc_rts(ic, wh->i_addr1, wh->i_addr2, dur); | |||||
} else { | |||||
mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, dur); | |||||
} | |||||
if (mprot == NULL) { | |||||
/* XXX stat + msg */ | |||||
return ENOBUFS; | |||||
} | |||||
data = STAILQ_FIRST(&sc->tx_free); | data = STAILQ_FIRST(&sc->tx_free); | ||||
STAILQ_REMOVE_HEAD(&sc->tx_free, next); | STAILQ_REMOVE_HEAD(&sc->tx_free, next); | ||||
sc->tx_nfree--; | sc->tx_nfree--; | ||||
data->m = mprot; | data->m = mprot; | ||||
data->ni = ieee80211_ref_node(ni); | data->ni = ieee80211_ref_node(ni); | ||||
data->rate = protrate; | data->rate = protrate; | ||||
ural_setup_tx_desc(sc, &data->desc, flags, mprot->m_pkthdr.len, protrate); | ural_setup_tx_desc(sc, &data->desc, flags, mprot->m_pkthdr.len, protrate); | ||||
▲ Show 20 Lines • Show All 1,071 Lines • Show Last 20 Lines |