summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2005-03-11 20:39:16 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2005-03-11 20:39:16 +0000
commitabbf9535ac9cb9f2514207382603801294d4af38 (patch)
tree2643985fad6118bca05393288f2209482b461e31
parent28b708d54f1b7067c2ad8cd72397a17d80eea05e (diff)
introduce new ral_setup_tx_desc() function so we can factor out filling
of tx descriptors.
-rw-r--r--sys/dev/ic/ral.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/sys/dev/ic/ral.c b/sys/dev/ic/ral.c
index 319b571332d..7001b6013de 100644
--- a/sys/dev/ic/ral.c
+++ b/sys/dev/ic/ral.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ral.c,v 1.29 2005/03/11 20:34:59 damien Exp $ */
+/* $OpenBSD: ral.c,v 1.30 2005/03/11 20:39:15 damien Exp $ */
/*-
* Copyright (c) 2005
@@ -102,6 +102,8 @@ void ral_wakeup_expire(struct ral_softc *);
int ral_ack_rate(int);
uint16_t ral_txtime(int, int, uint32_t);
uint8_t ral_plcp_signal(int);
+void ral_setup_tx_desc(struct ral_softc *, struct ral_tx_desc *,
+ uint32_t, int, int, int, bus_addr_t);
int ral_tx_bcn(struct ral_softc *, struct mbuf *,
struct ieee80211_node *);
int ral_tx_mgt(struct ral_softc *, struct mbuf *,
@@ -1535,6 +1537,61 @@ ral_plcp_signal(int rate)
}
}
+void
+ral_setup_tx_desc(struct ral_softc *sc, struct ral_tx_desc *desc,
+ uint32_t flags, int len, int rate, int encrypt, bus_addr_t physaddr)
+{
+ struct ieee80211com *ic = &sc->sc_ic;
+ uint16_t plcp_length;
+ int remainder;
+
+ desc->flags = htole32(flags);
+ desc->flags |= htole32(len << 16);
+ desc->flags |= encrypt ? htole32(RAL_TX_CIPHER_BUSY) :
+ htole32(RAL_TX_BUSY | RAL_TX_VALID);
+ if (RAL_RATE_IS_OFDM(rate))
+ desc->flags |= htole32(RAL_TX_OFDM);
+
+ desc->physaddr = htole32(physaddr);
+ desc->wme = htole32(
+ 8 << RAL_WME_CWMAX_BITS_SHIFT |
+ 3 << RAL_WME_CWMIN_BITS_SHIFT |
+ 2 << RAL_WME_AIFSN_BITS_SHIFT);
+
+ /*
+ * Fill PLCP fields.
+ */
+ desc->plcp_service = 4;
+
+ len += 4; /* account for FCS */
+ if (RAL_RATE_IS_OFDM(rate)) {
+ /*
+ * PLCP length field (LENGTH).
+ * From IEEE Std 802.11a-1999, pp. 14.
+ */
+ plcp_length = len & 0xfff;
+ desc->plcp_length = htole16((plcp_length >> 6) << 8 |
+ (plcp_length & 0x3f));
+ } else {
+ /*
+ * Long PLCP LENGTH field.
+ * From IEEE Std 802.11b-1999, pp. 16.
+ */
+ plcp_length = (8 * len * 2) / rate;
+ remainder = (8 * len * 2) % rate;
+ if (remainder != 0) {
+ if (rate == 22 && (rate - remainder) / 16 != 0)
+ desc->plcp_service |= RAL_PLCP_LENGEXT;
+ plcp_length++;
+ }
+ desc->plcp_length = htole16(plcp_length);
+ }
+
+ desc->plcp_signal = ral_plcp_signal(rate);
+ if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
+ desc->plcp_signal |= 0x08;
+}
+
int
ral_tx_bcn(struct ral_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
{