Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/usb/wlan/if_rum.c
Show First 20 Lines • Show All 1,413 Lines • ▼ Show 20 Lines | desc->wme = htole16(RT2573_QID(qid) | | ||||
RT2573_LOGCWMAX(wmep->wmep_logcwmax)); | RT2573_LOGCWMAX(wmep->wmep_logcwmax)); | ||||
} | } | ||||
static int | static int | ||||
rum_sendprot(struct rum_softc *sc, | rum_sendprot(struct rum_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 rum_tx_data *data; | struct rum_tx_data *data; | ||||
struct mbuf *mprot; | struct mbuf *mprot; | ||||
int protrate, pktlen, flags, isshort; | int protrate, flags; | ||||
uint16_t dur; | |||||
RUM_LOCK_ASSERT(sc); | RUM_LOCK_ASSERT(sc); | ||||
KASSERT(prot == IEEE80211_PROT_RTSCTS || prot == IEEE80211_PROT_CTSONLY, | |||||
("protection %d", prot)); | |||||
wh = mtod(m, const struct ieee80211_frame *); | mprot = ieee80211_alloc_prot(ni, m, rate, prot); | ||||
pktlen = m->m_pkthdr.len + IEEE80211_CRC_LEN; | 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); | |||||
} | |||||
protrate = ieee80211_ctl_rate(ic->ic_rt, rate); | protrate = ieee80211_ctl_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 = 0; | flags = 0; | ||||
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 |= RT2573_TX_NEED_ACK; | flags |= RT2573_TX_NEED_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; | ||||
rum_setup_tx_desc(sc, &data->desc, NULL, flags, 0, 0, 0, | rum_setup_tx_desc(sc, &data->desc, NULL, flags, 0, 0, 0, | ||||
▲ Show 20 Lines • Show All 1,857 Lines • Show Last 20 Lines |