PERFORCE change 137840 for review
Sam Leffler
sam at FreeBSD.org
Sun Mar 16 16:28:23 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=137840
Change 137840 by sam at sam_ebb on 2008/03/16 16:28:21
o bump tx list count
o add protection
Note: untested until I can locate my awol rum card
Affected files ...
.. //depot/projects/vap/sys/dev/usb/if_rum.c#11 edit
.. //depot/projects/vap/sys/dev/usb/if_rumvar.h#7 edit
Differences ...
==== //depot/projects/vap/sys/dev/usb/if_rum.c#11 (text+ko) ====
@@ -632,7 +632,7 @@
struct rum_tx_data *data;
int i, error;
- sc->tx_queued = 0;
+ sc->tx_queued = sc->tx_cur = 0;
for (i = 0; i < RUM_TX_LIST_COUNT; i++) {
data = &sc->tx_data[i];
@@ -1126,6 +1126,71 @@
#define RUM_TX_TIMEOUT 5000
static int
+rum_sendprot(struct rum_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 rum_tx_desc *desc;
+ struct rum_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 = rum_ack_rate(ic, rate);
+
+ dur = rum_txtime(pktlen, rate, ic->ic_flags) +
+ rum_txtime(RUM_ACK_SIZE, ackrate, ic->ic_flags) +
+ 2 * sc->sifs;
+ flags = RT2573_TX_MORE_FRAG;
+ if (prot == IEEE80211_PROT_RTSCTS) {
+ dur += rum_txtime(RUM_CTS_SIZE,
+ rum_ack_rate(ic, protrate), ic->ic_flags) + sc->sifs;
+ 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 = &sc->tx_data[sc->tx_cur];
+ desc = (struct rum_tx_desc *)data->buf;
+
+ data->m = mprot;
+ data->ni = ieee80211_ref_node(ni);
+ m_copydata(mprot, 0, mprot->m_pkthdr.len, data->buf + RT2573_TX_DESC_SIZE);
+ rum_setup_tx_desc(sc, desc, flags, 0, mprot->m_pkthdr.len, protrate);
+
+ usbd_setup_xfer(data->xfer, sc->sc_tx_pipeh, data, data->buf,
+ /* NB: no roundup necessary */
+ RT2573_TX_DESC_SIZE + mprot->m_pkthdr.len,
+ USBD_FORCE_SHORT_XFER | USBD_NO_COPY, RUM_TX_TIMEOUT, rum_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) % RUM_TX_LIST_COUNT;
+
+ return 0;
+}
+
+static int
rum_tx_mgt(struct rum_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
{
struct ieee80211vap *vap = ni->ni_vap;
@@ -1212,6 +1277,7 @@
}
sc->tx_queued++;
+ sc->tx_cur = (sc->tx_cur + 1) % RUM_TX_LIST_COUNT;
return 0;
}
@@ -1233,15 +1299,26 @@
data = &sc->tx_data[0];
desc = (struct rum_tx_desc *)data->buf;
- flags = 0;
rate = params->ibp_rate0 & IEEE80211_RATE_VAL;
/* XXX validate */
if (rate == 0) {
m_freem(m0);
return EINVAL;
}
+ flags = 0;
if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0)
flags |= RT2573_TX_NEED_ACK;
+ if (params->ibp_flags & (IEEE80211_BPF_RTS|IEEE80211_BPF_CTS)) {
+ error = rum_sendprot(sc, m0, ni,
+ params->ibp_flags & IEEE80211_BPF_RTS ?
+ IEEE80211_PROT_RTSCTS : IEEE80211_PROT_CTSONLY,
+ rate);
+ if (error) {
+ m_freem(m0);
+ return error;
+ }
+ flags |= RT2573_TX_LONG_RETRY | RT2573_TX_IFS_SIFS;
+ }
if (bpf_peers_present(ifp->if_bpf)) {
struct rum_tx_radiotap_header *tap = &sc->sc_txtap;
@@ -1284,6 +1361,7 @@
return error;
sc->tx_queued++;
+ sc->tx_cur = (sc->tx_cur + 1) % RUM_TX_LIST_COUNT;
return 0;
}
@@ -1316,8 +1394,6 @@
rate = ni->ni_txrate;
}
- rate &= IEEE80211_RATE_VAL;
-
if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
k = ieee80211_crypto_encap(ni, m0);
if (k == NULL) {
@@ -1329,6 +1405,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) &&
+ RUM_RATE_IS_OFDM(rate))
+ prot = ic->ic_protmode;
+ if (prot != IEEE80211_PROT_NONE) {
+ error = rum_sendprot(sc, m0, ni, prot, rate);
+ if (error) {
+ m_freem(m0);
+ return error;
+ }
+ flags |= RT2573_TX_LONG_RETRY | RT2573_TX_IFS_SIFS;
+ }
+ }
+
data = &sc->tx_data[0];
desc = (struct rum_tx_desc *)data->buf;
@@ -1384,6 +1477,7 @@
}
sc->tx_queued++;
+ sc->tx_cur = (sc->tx_cur + 1) % RUM_TX_LIST_COUNT;
return 0;
}
@@ -1399,7 +1493,7 @@
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
if (m == NULL)
break;
- if (sc->tx_queued >= RUM_TX_LIST_COUNT) {
+ if (sc->tx_queued >= RUM_TX_LIST_COUNT-1) {
IFQ_DRV_PREPEND(&ifp->if_snd, m);
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
break;
@@ -2277,7 +2371,7 @@
ieee80211_free_node(ni);
return ENETDOWN;
}
- if (sc->tx_queued >= RUM_TX_LIST_COUNT) {
+ if (sc->tx_queued >= RUM_TX_LIST_COUNT-1) {
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
m_freem(m);
ieee80211_free_node(ni);
==== //depot/projects/vap/sys/dev/usb/if_rumvar.h#7 (text+ko) ====
@@ -18,7 +18,7 @@
*/
#define RUM_RX_LIST_COUNT 1
-#define RUM_TX_LIST_COUNT 1
+#define RUM_TX_LIST_COUNT 8
struct rum_rx_radiotap_header {
struct ieee80211_radiotap_header wr_ihdr;
@@ -118,6 +118,7 @@
struct rum_rx_data rx_data[RUM_RX_LIST_COUNT];
struct rum_tx_data tx_data[RUM_TX_LIST_COUNT];
int tx_queued;
+ int tx_cur;
struct mtx sc_mtx;
More information about the p4-projects
mailing list