PERFORCE change 137816 for review
Sam Leffler
sam at FreeBSD.org
Sun Mar 16 01:29:19 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=137816
Change 137816 by sam at sam_ebb on 2008/03/16 01:29:06
implement protection (need to add raw xmit path still)
Obtained from: openbsd (loosely)
MFP4 after: 2 weeks
Affected files ...
.. //depot/projects/vap/sys/dev/usb/if_ural.c#14 edit
Differences ...
==== //depot/projects/vap/sys/dev/usb/if_ural.c#14 (text+ko) ====
@@ -1316,6 +1316,71 @@
}
static int
+ural_sendprot(struct ural_softc *sc,
+ const struct mbuf *m, struct ieee80211_node *ni, int prot, int rate)
+{
+ struct ieee80211com *ic = ni->ni_ic;
+ const struct ieee80211_frame *wh;
+ struct ural_tx_desc *desc;
+ struct ural_tx_data *data;
+ struct mbuf *mprot;
+ int protrate, ackrate, pktlen, flags;
+ uint16_t dur;
+ usbd_status error;
+
+ KASSERT(prot == IEEE80211_PROT_RTSCTS || prot == IEEE80211_PROT_CTSONLY,
+ ("protection %d", prot));
+
+ wh = mtod(m, const struct ieee80211_frame *);
+ pktlen = m->m_pkthdr.len + IEEE80211_CRC_LEN;
+
+ /* XXX use phy support */
+ protrate = 2;
+ ackrate = ural_ack_rate(ic, rate);
+
+ dur = ural_txtime(pktlen, rate, ic->ic_flags) +
+ ural_txtime(RAL_ACK_SIZE, ackrate, ic->ic_flags) +
+ 2 * RAL_SIFS;
+ flags = RAL_TX_RETRY(7);
+ if (prot == IEEE80211_PROT_RTSCTS) {
+ dur += ural_txtime(RAL_CTS_SIZE,
+ ural_ack_rate(ic, protrate), ic->ic_flags) + RAL_SIFS;
+ 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 = &sc->tx_data[sc->tx_cur];
+ desc = (struct ural_tx_desc *)data->buf;
+
+ data->m = mprot;
+ data->ni = ieee80211_ref_node(ni);
+ m_copydata(mprot, 0, mprot->m_pkthdr.len, data->buf + RAL_TX_DESC_SIZE);
+ ural_setup_tx_desc(sc, desc, flags, mprot->m_pkthdr.len, protrate);
+
+ usbd_setup_xfer(data->xfer, sc->sc_tx_pipeh, data, data->buf,
+ /* NB: no roundup necessary */
+ RAL_TX_DESC_SIZE + mprot->m_pkthdr.len,
+ USBD_FORCE_SHORT_XFER | USBD_NO_COPY, RAL_TX_TIMEOUT, ural_txeof);
+
+ error = usbd_transfer(data->xfer);
+ if (error != USBD_NORMAL_COMPLETION && error != USBD_IN_PROGRESS) {
+ data->m = NULL;
+ data->ni = NULL;
+ return error;
+ }
+
+ sc->tx_queued++;
+ sc->tx_cur = (sc->tx_cur + 1) % RAL_TX_LIST_COUNT;
+
+ return 0;
+}
+
+static int
ural_tx_raw(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni,
const struct ieee80211_bpf_params *params)
{
@@ -1338,6 +1403,7 @@
m_freem(m0);
return EINVAL;
}
+ /* XXX honor protection */
if (bpf_peers_present(ifp->if_bpf)) {
struct ural_tx_radiotap_header *tap = &sc->sc_txtap;
@@ -1429,6 +1495,23 @@
wh = mtod(m0, struct ieee80211_frame *);
}
+ if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
+ int prot = IEEE80211_PROT_NONE;
+ if (m0->m_pkthdr.len + IEEE80211_CRC_LEN > vap->iv_rtsthreshold)
+ prot = IEEE80211_PROT_RTSCTS;
+ else if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
+ RAL_RATE_IS_OFDM(rate))
+ prot = ic->ic_protmode;
+ if (prot != IEEE80211_PROT_NONE) {
+ error = ural_sendprot(sc, m0, ni, prot, rate);
+ if (error) {
+ m_freem(m0);
+ return error;
+ }
+ flags |= RAL_TX_IFS_SIFS;
+ }
+ }
+
data = &sc->tx_data[sc->tx_cur];
desc = (struct ural_tx_desc *)data->buf;
More information about the p4-projects
mailing list