summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2007-07-24 16:07:48 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2007-07-24 16:07:48 +0000
commit602f606c42169c42a600ffcf8e57607e9294f515 (patch)
tree5037c00702e568b9d13c6e32c8cb4c1f221a2cdb /sys
parenta6bb4a402d2f7ebe0f8ddb967d6b9df527861e11 (diff)
hardware WEP in the TX path.
make sure to clear the SCAN lock in case the scan is interrupted.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/if_wpi.c33
-rw-r--r--sys/dev/pci/if_wpireg.h16
2 files changed, 32 insertions, 17 deletions
diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c
index fd64a82b603..0a8261e75fb 100644
--- a/sys/dev/pci/if_wpi.c
+++ b/sys/dev/pci/if_wpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wpi.c,v 1.48 2007/07/11 16:50:12 damien Exp $ */
+/* $OpenBSD: if_wpi.c,v 1.49 2007/07/24 16:07:47 damien Exp $ */
/*-
* Copyright (c) 2006, 2007
@@ -783,6 +783,9 @@ wpi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
timeout_del(&sc->calib_to);
+ if (ic->ic_state == IEEE80211_S_SCAN)
+ ic->ic_scan_lock = IEEE80211_SCAN_UNLOCKED;
+
switch (nstate) {
case IEEE80211_S_SCAN:
/* make the link LED blink while we're scanning */
@@ -1554,7 +1557,6 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m0, struct ieee80211_node *ni,
int ac)
{
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &ic->ic_if;
struct wpi_tx_ring *ring = &sc->txq[ac];
struct wpi_tx_desc *desc;
struct wpi_tx_data *data;
@@ -1562,22 +1564,13 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m0, struct ieee80211_node *ni,
struct wpi_cmd_data *tx;
struct ieee80211_frame *wh;
struct mbuf *mnew;
- int i, rate, error;
+ int i, rate, error, ovhd = 0;
desc = &ring->desc[ring->cur];
data = &ring->data[ring->cur];
wh = mtod(m0, struct ieee80211_frame *);
- if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
- m0 = ieee80211_wep_crypt(ifp, m0, 1);
- if (m0 == NULL)
- return ENOBUFS;
-
- /* packet header may have moved, reset our local pointer */
- wh = mtod(m0, struct ieee80211_frame *);
- }
-
/* pickup a rate */
if (IEEE80211_IS_MULTICAST(wh->i_addr1) ||
((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
@@ -1624,6 +1617,20 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m0, struct ieee80211_node *ni,
/* no need to zero tx, all fields are reinitialized here */
tx->flags = 0;
+ if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
+ const struct ieee80211_key *key =
+ &ic->ic_nw_keys[ic->ic_wep_txkey];
+ if (key->k_cipher == IEEE80211_CIPHER_WEP40)
+ tx->security = WPI_CIPHER_WEP40;
+ else
+ tx->security = WPI_CIPHER_WEP104;
+ tx->security |= ic->ic_wep_txkey << 6;
+ memcpy(&tx->key[3], key->k_key, key->k_len);
+ /* compute crypto overhead */
+ ovhd = IEEE80211_WEP_TOTLEN;
+ } else
+ tx->security = 0;
+
if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
tx->id = WPI_ID_BSS;
tx->flags |= htole32(WPI_TX_NEED_ACK);
@@ -1633,7 +1640,7 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m0, struct ieee80211_node *ni,
/* check if RTS/CTS or CTS-to-self protection must be used */
if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
/* multicast frames are not sent at OFDM rates in 802.11b/g */
- if (m0->m_pkthdr.len + IEEE80211_CRC_LEN >
+ if (m0->m_pkthdr.len + ovhd + IEEE80211_CRC_LEN >
ic->ic_rtsthreshold) {
tx->flags |= htole32(WPI_TX_NEED_RTS |
WPI_TX_FULL_TXOP);
diff --git a/sys/dev/pci/if_wpireg.h b/sys/dev/pci/if_wpireg.h
index 110bac8c735..b989feb635b 100644
--- a/sys/dev/pci/if_wpireg.h
+++ b/sys/dev/pci/if_wpireg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wpireg.h,v 1.16 2007/07/10 18:29:38 damien Exp $ */
+/* $OpenBSD: if_wpireg.h,v 1.17 2007/07/24 16:07:47 damien Exp $ */
/*-
* Copyright (c) 2006, 2007
@@ -198,6 +198,7 @@ struct wpi_rx_desc {
uint32_t len;
uint8_t type;
#define WPI_UC_READY 1
+#define WPI_ADD_NODE_DONE 24
#define WPI_RX_DONE 27
#define WPI_TX_DONE 28
#define WPI_START_SCAN 130
@@ -323,7 +324,7 @@ struct wpi_cmd_tsf {
/* structure for WPI_CMD_ADD_NODE */
struct wpi_node_info {
uint8_t control;
-#define WPI_NODE_UPDATE (1 << 0)
+#define WPI_NODE_UPDATE (1 << 0)
uint8_t reserved1[3];
uint8_t bssid[IEEE80211_ADDR_LEN];
@@ -333,15 +334,17 @@ struct wpi_node_info {
#define WPI_ID_BROADCAST 24
uint8_t flags;
+#define WPI_FLAG_SET_KEY (1 << 0)
+
uint16_t reserved3;
- uint16_t key_flags;
+ uint16_t security;
uint8_t tkip;
uint8_t reserved4;
uint16_t ttak[5];
uint16_t reserved5;
uint8_t key[IEEE80211_KEYBUF_SIZE];
uint32_t action;
-#define WPI_ACTION_SET_RATE 4
+#define WPI_ACTION_SET_RATE (1 << 2)
uint32_t mask;
uint16_t tid;
@@ -373,6 +376,11 @@ struct wpi_cmd_data {
uint8_t id;
uint8_t tid;
uint8_t security;
+#define WPI_CIPHER_WEP40 1
+#define WPI_CIPHER_CCMP 2
+#define WPI_CIPHER_TKIP 3
+#define WPI_CIPHER_WEP104 9
+
uint8_t key[IEEE80211_KEYBUF_SIZE];
uint8_t tkip[IEEE80211_WEP_MICLEN];
uint32_t fnext;