From owner-p4-projects@FreeBSD.ORG Sun Mar 16 01:29:19 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 278631065670; Sun, 16 Mar 2008 01:29:19 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0CD0106564A for ; Sun, 16 Mar 2008 01:29:18 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id BC2688FC19 for ; Sun, 16 Mar 2008 01:29:18 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m2G1TIBi008391 for ; Sun, 16 Mar 2008 01:29:18 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m2G1TIlk008389 for perforce@freebsd.org; Sun, 16 Mar 2008 01:29:18 GMT (envelope-from sam@freebsd.org) Date: Sun, 16 Mar 2008 01:29:18 GMT Message-Id: <200803160129.m2G1TIlk008389@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 137816 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Mar 2008 01:29:19 -0000 http://perforce.freebsd.org/chv.cgi?CH=137816 Change 137816 by sam@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;