Fri Aug 7 06:48:10 2009 UTC ()
Pull up following revision(s) (requested by jmcneill in ticket #775):
	sys/dev/ic/ath.c: revision 1.106
	sys/dev/ic/athvar.h: revision 1.28
- fix TKIP, changes adapted from FreeBSD
- reduce diffs between FreeBSD and NetBSD athvar.h


(snj)
diff -r1.102.4.1 -r1.102.4.2 src/sys/dev/ic/ath.c
diff -r1.25.4.1 -r1.25.4.2 src/sys/dev/ic/athvar.h

cvs diff -r1.102.4.1 -r1.102.4.2 src/sys/dev/ic/ath.c (expand / switch to unified diff)

--- src/sys/dev/ic/ath.c 2009/08/07 06:43:27 1.102.4.1
+++ src/sys/dev/ic/ath.c 2009/08/07 06:48:09 1.102.4.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ath.c,v 1.102.4.1 2009/08/07 06:43:27 snj Exp $ */ 1/* $NetBSD: ath.c,v 1.102.4.2 2009/08/07 06:48:09 snj Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting 4 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer, 11 * notice, this list of conditions and the following disclaimer,
12 * without modification. 12 * without modification.
13 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 13 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 14 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
@@ -31,27 +31,27 @@ @@ -31,27 +31,27 @@
31 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
34 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
36 * THE POSSIBILITY OF SUCH DAMAGES. 36 * THE POSSIBILITY OF SUCH DAMAGES.
37 */ 37 */
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40#ifdef __FreeBSD__ 40#ifdef __FreeBSD__
41__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.104 2005/09/16 10:09:23 ru Exp $"); 41__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.104 2005/09/16 10:09:23 ru Exp $");
42#endif 42#endif
43#ifdef __NetBSD__ 43#ifdef __NetBSD__
44__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.102.4.1 2009/08/07 06:43:27 snj Exp $"); 44__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.102.4.2 2009/08/07 06:48:09 snj Exp $");
45#endif 45#endif
46 46
47/* 47/*
48 * Driver for the Atheros Wireless LAN controller. 48 * Driver for the Atheros Wireless LAN controller.
49 * 49 *
50 * This software is derived from work of Atsushi Onoe; his contribution 50 * This software is derived from work of Atsushi Onoe; his contribution
51 * is greatly appreciated. 51 * is greatly appreciated.
52 */ 52 */
53 53
54#include "opt_inet.h" 54#include "opt_inet.h"
55 55
56#ifdef __NetBSD__ 56#ifdef __NetBSD__
57#include "bpfilter.h" 57#include "bpfilter.h"
@@ -510,48 +510,60 @@ ath_attach(u_int16_t devid, struct ath_s @@ -510,48 +510,60 @@ ath_attach(u_int16_t devid, struct ath_s
510 if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_OCB)) 510 if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_OCB))
511 ic->ic_caps |= IEEE80211_C_AES; 511 ic->ic_caps |= IEEE80211_C_AES;
512 if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_CCM)) 512 if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_CCM))
513 ic->ic_caps |= IEEE80211_C_AES_CCM; 513 ic->ic_caps |= IEEE80211_C_AES_CCM;
514 if (ath_hal_ciphersupported(ah, HAL_CIPHER_CKIP)) 514 if (ath_hal_ciphersupported(ah, HAL_CIPHER_CKIP))
515 ic->ic_caps |= IEEE80211_C_CKIP; 515 ic->ic_caps |= IEEE80211_C_CKIP;
516 if (ath_hal_ciphersupported(ah, HAL_CIPHER_TKIP)) { 516 if (ath_hal_ciphersupported(ah, HAL_CIPHER_TKIP)) {
517 ic->ic_caps |= IEEE80211_C_TKIP; 517 ic->ic_caps |= IEEE80211_C_TKIP;
518 /* 518 /*
519 * Check if h/w does the MIC and/or whether the 519 * Check if h/w does the MIC and/or whether the
520 * separate key cache entries are required to 520 * separate key cache entries are required to
521 * handle both tx+rx MIC keys. 521 * handle both tx+rx MIC keys.
522 */ 522 */
523 if (ath_hal_ciphersupported(ah, HAL_CIPHER_MIC)) { 523 if (ath_hal_ciphersupported(ah, HAL_CIPHER_MIC))
524 ic->ic_caps |= IEEE80211_C_TKIPMIC; 524 ic->ic_caps |= IEEE80211_C_TKIPMIC;
525 /* 
526 * Check if h/w does MIC correctly when 
527 * WMM is turned on. 
528 */ 
529 if (ath_hal_wmetkipmic(ah)) 
530 ic->ic_caps |= IEEE80211_C_WME_TKIPMIC; 
531 } 
532 525
533 /* 526 /*
534 * If the h/w supports storing tx+rx MIC keys 527 * If the h/w supports storing tx+rx MIC keys
535 * in one cache slot automatically enable use. 528 * in one cache slot automatically enable use.
536 */ 529 */
537 if (ath_hal_tkipsplit(ah) || 530 if (ath_hal_hastkipsplit(ah) ||
538 !ath_hal_settkipsplit(ah, AH_FALSE)) 531 !ath_hal_settkipsplit(ah, AH_FALSE))
539 sc->sc_splitmic = 1; 532 sc->sc_splitmic = 1;
 533
 534 /*
 535 * If the h/w can do TKIP MIC together with WME then
 536 * we use it; otherwise we force the MIC to be done
 537 * in software by the net80211 layer.
 538 */
 539 if (ath_hal_haswmetkipmic(ah))
 540 ic->ic_caps |= IEEE80211_C_WME_TKIPMIC;
540 } 541 }
541 sc->sc_hasclrkey = ath_hal_ciphersupported(ah, HAL_CIPHER_CLR); 542 sc->sc_hasclrkey = ath_hal_ciphersupported(ah, HAL_CIPHER_CLR);
542#if 0 
543 sc->sc_mcastkey = ath_hal_getmcastkeysearch(ah); 543 sc->sc_mcastkey = ath_hal_getmcastkeysearch(ah);
544#endif 544 /*
 545 * Mark key cache slots associated with global keys
 546 * as in use. If we knew TKIP was not to be used we
 547 * could leave the +32, +64, and +32+64 slots free.
 548 */
 549 for (i = 0; i < IEEE80211_WEP_NKID; i++) {
 550 setbit(sc->sc_keymap, i);
 551 setbit(sc->sc_keymap, i+64);
 552 if (sc->sc_splitmic) {
 553 setbit(sc->sc_keymap, i+32);
 554 setbit(sc->sc_keymap, i+32+64);
 555 }
 556 }
545 /* 557 /*
546 * TPC support can be done either with a global cap or 558 * TPC support can be done either with a global cap or
547 * per-packet support. The latter is not available on 559 * per-packet support. The latter is not available on
548 * all parts. We're a bit pedantic here as all parts 560 * all parts. We're a bit pedantic here as all parts
549 * support a global cap. 561 * support a global cap.
550 */ 562 */
551 if (ath_hal_hastpc(ah) || ath_hal_hastxpowlimit(ah)) 563 if (ath_hal_hastpc(ah) || ath_hal_hastxpowlimit(ah))
552 ic->ic_caps |= IEEE80211_C_TXPMGT; 564 ic->ic_caps |= IEEE80211_C_TXPMGT;
553 565
554 /* 566 /*
555 * Mark WME capability only if we have sufficient 567 * Mark WME capability only if we have sufficient
556 * hardware queues to do proper priority scheduling. 568 * hardware queues to do proper priority scheduling.
557 */ 569 */
@@ -938,69 +950,77 @@ ath_chan2flags(struct ieee80211com *ic,  @@ -938,69 +950,77 @@ ath_chan2flags(struct ieee80211com *ic,
938 KASSERT(modeflags[mode] != 0, ("mode %u undefined", mode)); 950 KASSERT(modeflags[mode] != 0, ("mode %u undefined", mode));
939 return modeflags[mode]; 951 return modeflags[mode];
940#undef N 952#undef N
941} 953}
942 954
943static int 955static int
944ath_ifinit(struct ifnet *ifp) 956ath_ifinit(struct ifnet *ifp)
945{ 957{
946 struct ath_softc *sc = (struct ath_softc *)ifp->if_softc; 958 struct ath_softc *sc = (struct ath_softc *)ifp->if_softc;
947 959
948 return ath_init(sc); 960 return ath_init(sc);
949} 961}
950 962
 963static void
 964ath_settkipmic(struct ath_softc *sc)
 965{
 966 struct ieee80211com *ic = &sc->sc_ic;
 967 struct ath_hal *ah = sc->sc_ah;
 968
 969 if ((ic->ic_caps & IEEE80211_C_TKIP) &&
 970 !(ic->ic_caps & IEEE80211_C_WME_TKIPMIC)) {
 971 if (ic->ic_flags & IEEE80211_F_WME) {
 972 (void)ath_hal_settkipmic(ah, AH_FALSE);
 973 ic->ic_caps &= ~IEEE80211_C_TKIPMIC;
 974 } else {
 975 (void)ath_hal_settkipmic(ah, AH_TRUE);
 976 ic->ic_caps |= IEEE80211_C_TKIPMIC;
 977 }
 978 }
 979}
 980
951static int 981static int
952ath_init(struct ath_softc *sc) 982ath_init(struct ath_softc *sc)
953{ 983{
954 struct ifnet *ifp = &sc->sc_if; 984 struct ifnet *ifp = &sc->sc_if;
955 struct ieee80211com *ic = &sc->sc_ic; 985 struct ieee80211com *ic = &sc->sc_ic;
956 struct ath_hal *ah = sc->sc_ah; 986 struct ath_hal *ah = sc->sc_ah;
957 HAL_STATUS status; 987 HAL_STATUS status;
958 int error = 0; 988 int error = 0;
959 989
960 DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags 0x%x\n", 990 DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags 0x%x\n",
961 __func__, ifp->if_flags); 991 __func__, ifp->if_flags);
962 992
963 if (device_is_active(sc->sc_dev)) { 993 if (device_is_active(sc->sc_dev)) {
964 ATH_LOCK(sc); 994 ATH_LOCK(sc);
965 } else if (!pmf_device_resume_self(sc->sc_dev)) 995 } else if (!pmf_device_resume_self(sc->sc_dev))
966 return ENXIO; 996 return ENXIO;
967 else 997 else
968 ATH_LOCK(sc); 998 ATH_LOCK(sc);
969 999
970 /* 1000 /*
971 * Stop anything previously setup. This is safe 1001 * Stop anything previously setup. This is safe
972 * whether this is the first time through or not. 1002 * whether this is the first time through or not.
973 */ 1003 */
974 ath_stop_locked(ifp, 0); 1004 ath_stop_locked(ifp, 0);
975 1005
976 int dummy; /* XXX: gcc */ 
977 /* Whether we should enable h/w TKIP MIC */ 
978 if ((ic->ic_caps & IEEE80211_C_WME) && 
979 ((ic->ic_caps & IEEE80211_C_WME_TKIPMIC) || 
980 !(ic->ic_flags & IEEE80211_F_WME))) { 
981 dummy = ath_hal_settkipmic(ah, AH_TRUE); 
982 } else { 
983 dummy = ath_hal_settkipmic(ah, AH_FALSE); 
984 } 
985 
986 
987 /* 1006 /*
988 * The basic interface to setting the hardware in a good 1007 * The basic interface to setting the hardware in a good
989 * state is ``reset''. On return the hardware is known to 1008 * state is ``reset''. On return the hardware is known to
990 * be powered up and with interrupts disabled. This must 1009 * be powered up and with interrupts disabled. This must
991 * be followed by initialization of the appropriate bits 1010 * be followed by initialization of the appropriate bits
992 * and then setup of the interrupt mask. 1011 * and then setup of the interrupt mask.
993 */ 1012 */
 1013 ath_settkipmic(sc);
994 sc->sc_curchan.channel = ic->ic_curchan->ic_freq; 1014 sc->sc_curchan.channel = ic->ic_curchan->ic_freq;
995 sc->sc_curchan.channelFlags = ath_chan2flags(ic, ic->ic_curchan); 1015 sc->sc_curchan.channelFlags = ath_chan2flags(ic, ic->ic_curchan);
996 if (!ath_hal_reset(ah, ic->ic_opmode, &sc->sc_curchan, AH_FALSE, &status)) { 1016 if (!ath_hal_reset(ah, ic->ic_opmode, &sc->sc_curchan, AH_FALSE, &status)) {
997 if_printf(ifp, "unable to reset hardware; hal status %u\n", 1017 if_printf(ifp, "unable to reset hardware; hal status %u\n",
998 status); 1018 status);
999 error = EIO; 1019 error = EIO;
1000 goto done; 1020 goto done;
1001 } 1021 }
1002 1022
1003 /* 1023 /*
1004 * This is needed only to setup initial state 1024 * This is needed only to setup initial state
1005 * but it's best done after a reset. 1025 * but it's best done after a reset.
1006 */ 1026 */
@@ -1160,26 +1180,27 @@ ath_reset(struct ifnet *ifp) @@ -1160,26 +1180,27 @@ ath_reset(struct ifnet *ifp)
1160 HAL_STATUS status; 1180 HAL_STATUS status;
1161 1181
1162 /* 1182 /*
1163 * Convert to a HAL channel description with the flags 1183 * Convert to a HAL channel description with the flags
1164 * constrained to reflect the current operating mode. 1184 * constrained to reflect the current operating mode.
1165 */ 1185 */
1166 c = ic->ic_curchan; 1186 c = ic->ic_curchan;
1167 sc->sc_curchan.channel = c->ic_freq; 1187 sc->sc_curchan.channel = c->ic_freq;
1168 sc->sc_curchan.channelFlags = ath_chan2flags(ic, c); 1188 sc->sc_curchan.channelFlags = ath_chan2flags(ic, c);
1169 1189
1170 ath_hal_intrset(ah, 0); /* disable interrupts */ 1190 ath_hal_intrset(ah, 0); /* disable interrupts */
1171 ath_draintxq(sc); /* stop xmit side */ 1191 ath_draintxq(sc); /* stop xmit side */
1172 ath_stoprecv(sc); /* stop recv side */ 1192 ath_stoprecv(sc); /* stop recv side */
 1193 ath_settkipmic(sc); /* configure TKIP MIC handling */
1173 /* NB: indicate channel change so we do a full reset */ 1194 /* NB: indicate channel change so we do a full reset */
1174 if (!ath_hal_reset(ah, ic->ic_opmode, &sc->sc_curchan, AH_TRUE, &status)) 1195 if (!ath_hal_reset(ah, ic->ic_opmode, &sc->sc_curchan, AH_TRUE, &status))
1175 if_printf(ifp, "%s: unable to reset hardware; hal status %u\n", 1196 if_printf(ifp, "%s: unable to reset hardware; hal status %u\n",
1176 __func__, status); 1197 __func__, status);
1177 ath_update_txpow(sc); /* update tx power state */ 1198 ath_update_txpow(sc); /* update tx power state */
1178 ath_restore_diversity(sc); 1199 ath_restore_diversity(sc);
1179 sc->sc_calinterval = 1; 1200 sc->sc_calinterval = 1;
1180 sc->sc_caltries = 0; 1201 sc->sc_caltries = 0;
1181 if (ath_startrecv(sc) != 0) /* restart recv */ 1202 if (ath_startrecv(sc) != 0) /* restart recv */
1182 if_printf(ifp, "%s: unable to start recv logic\n", __func__); 1203 if_printf(ifp, "%s: unable to start recv logic\n", __func__);
1183 /* 1204 /*
1184 * We may be doing a reset in response to an ioctl 1205 * We may be doing a reset in response to an ioctl
1185 * that changes the channel so update any state that 1206 * that changes the channel so update any state that
@@ -1502,41 +1523,45 @@ ath_keyset_tkip(struct ath_softc *sc, co @@ -1502,41 +1523,45 @@ ath_keyset_tkip(struct ath_softc *sc, co
1502 1523
1503 memcpy(hk->kv_mic, k->wk_rxmic, sizeof(hk->kv_mic)); 1524 memcpy(hk->kv_mic, k->wk_rxmic, sizeof(hk->kv_mic));
1504 KEYPRINTF(sc, k->wk_keyix+32, hk, mac); 1525 KEYPRINTF(sc, k->wk_keyix+32, hk, mac);
1505 /* XXX delete tx key on failure? */ 1526 /* XXX delete tx key on failure? */
1506 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix+32), 1527 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix+32),
1507 hk, mac); 1528 hk, mac);
1508 } else { 1529 } else {
1509 /* 1530 /*
1510 * Room for both TX+RX MIC keys in one key cache 1531 * Room for both TX+RX MIC keys in one key cache
1511 * slot, just set key at the first index; the HAL 1532 * slot, just set key at the first index; the HAL
1512 * will handle the reset. 1533 * will handle the reset.
1513 */ 1534 */
1514 memcpy(hk->kv_mic, k->wk_rxmic, sizeof(hk->kv_mic)); 1535 memcpy(hk->kv_mic, k->wk_rxmic, sizeof(hk->kv_mic));
1515#if HAL_ABI_VERSION > 0x06052200 
1516 memcpy(hk->kv_txmic, k->wk_txmic, sizeof(hk->kv_txmic)); 1536 memcpy(hk->kv_txmic, k->wk_txmic, sizeof(hk->kv_txmic));
1517#endif 
1518 KEYPRINTF(sc, k->wk_keyix, hk, mac); 1537 KEYPRINTF(sc, k->wk_keyix, hk, mac);
1519 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix), hk, mac); 1538 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix), hk, mac);
1520 } 1539 }
1521 } else if (k->wk_flags & IEEE80211_KEY_XR) { 1540 } else if (k->wk_flags & IEEE80211_KEY_XMIT) {
1522 /* 1541 if (sc->sc_splitmic) {
1523 * TX/RX key goes at first index. 1542 /*
1524 * The hal handles the MIC keys are index+64. 1543 * NB: must pass MIC key in expected location when
1525 */ 1544 * the keycache only holds one MIC key per entry.
1526 memcpy(hk->kv_mic, k->wk_flags & IEEE80211_KEY_XMIT ? 1545 */
1527 k->wk_txmic : k->wk_rxmic, sizeof(hk->kv_mic)); 1546 memcpy(hk->kv_mic, k->wk_txmic, sizeof(hk->kv_txmic));
 1547 } else
 1548 memcpy(hk->kv_txmic, k->wk_txmic, sizeof(hk->kv_txmic));
1528 KEYPRINTF(sc, k->wk_keyix, hk, mac); 1549 KEYPRINTF(sc, k->wk_keyix, hk, mac);
1529 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix), hk, mac); 1550 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix), hk, mac);
 1551 } else if (k->wk_flags & IEEE80211_KEY_RECV) {
 1552 memcpy(hk->kv_mic, k->wk_rxmic, sizeof(hk->kv_mic));
 1553 KEYPRINTF(sc, k->wk_keyix, hk, mac);
 1554 return ath_hal_keyset(ah, k->wk_keyix, hk, mac);
1530 } 1555 }
1531 return 0; 1556 return 0;
1532#undef IEEE80211_KEY_XR 1557#undef IEEE80211_KEY_XR
1533} 1558}
1534 1559
1535/* 1560/*
1536 * Set a net80211 key into the hardware. This handles the 1561 * Set a net80211 key into the hardware. This handles the
1537 * potential distribution of key state to multiple key 1562 * potential distribution of key state to multiple key
1538 * cache slots for TKIP with hardware MIC support. 1563 * cache slots for TKIP with hardware MIC support.
1539 */ 1564 */
1540static int 1565static int
1541ath_keyset(struct ath_softc *sc, const struct ieee80211_key *k, 1566ath_keyset(struct ath_softc *sc, const struct ieee80211_key *k,
1542 const u_int8_t mac0[IEEE80211_ADDR_LEN], 1567 const u_int8_t mac0[IEEE80211_ADDR_LEN],
@@ -1576,27 +1601,27 @@ ath_keyset(struct ath_softc *sc, const s @@ -1576,27 +1601,27 @@ ath_keyset(struct ath_softc *sc, const s
1576 if ((k->wk_flags & IEEE80211_KEY_GROUP) && sc->sc_mcastkey) { 1601 if ((k->wk_flags & IEEE80211_KEY_GROUP) && sc->sc_mcastkey) {
1577 /* 1602 /*
1578 * Group keys on hardware that supports multicast frame 1603 * Group keys on hardware that supports multicast frame
1579 * key search use a mac that is the sender's address with 1604 * key search use a mac that is the sender's address with
1580 * the high bit set instead of the app-specified address. 1605 * the high bit set instead of the app-specified address.
1581 */ 1606 */
1582 IEEE80211_ADDR_COPY(gmac, bss->ni_macaddr); 1607 IEEE80211_ADDR_COPY(gmac, bss->ni_macaddr);
1583 gmac[0] |= 0x80; 1608 gmac[0] |= 0x80;
1584 mac = gmac; 1609 mac = gmac;
1585 } else 1610 } else
1586 mac = mac0; 1611 mac = mac0;
1587 1612
1588 if ((hk.kv_type == HAL_CIPHER_TKIP && 1613 if ((hk.kv_type == HAL_CIPHER_TKIP &&
1589 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0) && sc->sc_splitmic) { 1614 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0)) {
1590 return ath_keyset_tkip(sc, k, &hk, mac); 1615 return ath_keyset_tkip(sc, k, &hk, mac);
1591 } else { 1616 } else {
1592 KEYPRINTF(sc, k->wk_keyix, &hk, mac); 1617 KEYPRINTF(sc, k->wk_keyix, &hk, mac);
1593 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix), &hk, mac); 1618 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix), &hk, mac);
1594 } 1619 }
1595#undef N 1620#undef N
1596} 1621}
1597 1622
1598/* 1623/*
1599 * Allocate tx/rx key slots for TKIP. We allocate two slots for 1624 * Allocate tx/rx key slots for TKIP. We allocate two slots for
1600 * each key, one for decrypt/encrypt and the other for the MIC. 1625 * each key, one for decrypt/encrypt and the other for the MIC.
1601 */ 1626 */
1602static u_int16_t 1627static u_int16_t
@@ -1641,26 +1666,74 @@ key_alloc_2pair(struct ath_softc *sc, @@ -1641,26 +1666,74 @@ key_alloc_2pair(struct ath_softc *sc,
1641 __func__, keyix, keyix+64, 1666 __func__, keyix, keyix+64,
1642 keyix+32, keyix+32+64); 1667 keyix+32, keyix+32+64);
1643 *txkeyix = keyix; 1668 *txkeyix = keyix;
1644 *rxkeyix = keyix+32; 1669 *rxkeyix = keyix+32;
1645 return keyix; 1670 return keyix;
1646 } 1671 }
1647 } 1672 }
1648 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s: out of pair space\n", __func__); 1673 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s: out of pair space\n", __func__);
1649 return IEEE80211_KEYIX_NONE; 1674 return IEEE80211_KEYIX_NONE;
1650#undef N 1675#undef N
1651} 1676}
1652 1677
1653/* 1678/*
 1679 * Allocate tx/rx key slots for TKIP. We allocate two slots for
 1680 * each key, one for decrypt/encrypt and the other for the MIC.
 1681 */
 1682static int
 1683key_alloc_pair(struct ath_softc *sc, ieee80211_keyix *txkeyix,
 1684 ieee80211_keyix *rxkeyix)
 1685{
 1686#define N(a) (sizeof(a)/sizeof(a[0]))
 1687 u_int i, keyix;
 1688
 1689 KASSERT(!sc->sc_splitmic, ("key cache split"));
 1690 /* XXX could optimize */
 1691 for (i = 0; i < N(sc->sc_keymap)/4; i++) {
 1692 uint8_t b = sc->sc_keymap[i];
 1693 if (b != 0xff) {
 1694 /*
 1695 * One or more slots in this byte are free.
 1696 */
 1697 keyix = i*NBBY;
 1698 while (b & 1) {
 1699 again:
 1700 keyix++;
 1701 b >>= 1;
 1702 }
 1703 if (isset(sc->sc_keymap, keyix+64)) {
 1704 /* full pair unavailable */
 1705 /* XXX statistic */
 1706 if (keyix == (i+1)*NBBY) {
 1707 /* no slots were appropriate, advance */
 1708 continue;
 1709 }
 1710 goto again;
 1711 }
 1712 setbit(sc->sc_keymap, keyix);
 1713 setbit(sc->sc_keymap, keyix+64);
 1714 DPRINTF(sc, ATH_DEBUG_KEYCACHE,
 1715 "%s: key pair %u,%u\n",
 1716 __func__, keyix, keyix+64);
 1717 *txkeyix = *rxkeyix = keyix;
 1718 return 1;
 1719 }
 1720 }
 1721 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s: out of pair space\n", __func__);
 1722 return 0;
 1723#undef N
 1724}
 1725
 1726/*
1654 * Allocate a single key cache slot. 1727 * Allocate a single key cache slot.
1655 */ 1728 */
1656static int 1729static int
1657key_alloc_single(struct ath_softc *sc, 1730key_alloc_single(struct ath_softc *sc,
1658 ieee80211_keyix *txkeyix, ieee80211_keyix *rxkeyix) 1731 ieee80211_keyix *txkeyix, ieee80211_keyix *rxkeyix)
1659{ 1732{
1660#define N(a) (sizeof(a)/sizeof(a[0])) 1733#define N(a) (sizeof(a)/sizeof(a[0]))
1661 u_int i, keyix; 1734 u_int i, keyix;
1662 1735
1663 /* XXX try i,i+32,i+64,i+32+64 to minimize key pair conflicts */ 1736 /* XXX try i,i+32,i+64,i+32+64 to minimize key pair conflicts */
1664 for (i = 0; i < N(sc->sc_keymap); i++) { 1737 for (i = 0; i < N(sc->sc_keymap); i++) {
1665 u_int8_t b = sc->sc_keymap[i]; 1738 u_int8_t b = sc->sc_keymap[i];
1666 if (b != 0xff) { 1739 if (b != 0xff) {
@@ -1725,28 +1798,31 @@ ath_key_alloc(struct ieee80211com *ic, c @@ -1725,28 +1798,31 @@ ath_key_alloc(struct ieee80211com *ic, c
1725 } 1798 }
1726 1799
1727 /* 1800 /*
1728 * We allocate two pair for TKIP when using the h/w to do 1801 * We allocate two pair for TKIP when using the h/w to do
1729 * the MIC. For everything else, including software crypto, 1802 * the MIC. For everything else, including software crypto,
1730 * we allocate a single entry. Note that s/w crypto requires 1803 * we allocate a single entry. Note that s/w crypto requires
1731 * a pass-through slot on the 5211 and 5212. The 5210 does 1804 * a pass-through slot on the 5211 and 5212. The 5210 does
1732 * not support pass-through cache entries and we map all 1805 * not support pass-through cache entries and we map all
1733 * those requests to slot 0. 1806 * those requests to slot 0.
1734 */ 1807 */
1735 if (k->wk_flags & IEEE80211_KEY_SWCRYPT) { 1808 if (k->wk_flags & IEEE80211_KEY_SWCRYPT) {
1736 return key_alloc_single(sc, keyix, rxkeyix); 1809 return key_alloc_single(sc, keyix, rxkeyix);
1737 } else if (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP && 1810 } else if (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP &&
1738 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0 && sc->sc_splitmic) { 1811 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0) {
1739 return key_alloc_2pair(sc, keyix, rxkeyix); 1812 if (sc->sc_splitmic)
 1813 return key_alloc_2pair(sc, keyix, rxkeyix);
 1814 else
 1815 return key_alloc_pair(sc, keyix, rxkeyix);
1740 } else { 1816 } else {
1741 return key_alloc_single(sc, keyix, rxkeyix); 1817 return key_alloc_single(sc, keyix, rxkeyix);
1742 } 1818 }
1743} 1819}
1744 1820
1745/* 1821/*
1746 * Delete an entry in the key cache allocated by ath_key_alloc. 1822 * Delete an entry in the key cache allocated by ath_key_alloc.
1747 */ 1823 */
1748static int 1824static int
1749ath_key_delete(struct ieee80211com *ic, const struct ieee80211_key *k) 1825ath_key_delete(struct ieee80211com *ic, const struct ieee80211_key *k)
1750{ 1826{
1751 struct ath_softc *sc = ic->ic_ifp->if_softc; 1827 struct ath_softc *sc = ic->ic_ifp->if_softc;
1752 struct ath_hal *ah = sc->sc_ah; 1828 struct ath_hal *ah = sc->sc_ah;
@@ -1764,31 +1840,33 @@ ath_key_delete(struct ieee80211com *ic,  @@ -1764,31 +1840,33 @@ ath_key_delete(struct ieee80211com *ic,
1764 /* 1840 /*
1765 * Handle split tx/rx keying required for TKIP with h/w MIC. 1841 * Handle split tx/rx keying required for TKIP with h/w MIC.
1766 */ 1842 */
1767 if (cip->ic_cipher == IEEE80211_CIPHER_TKIP && 1843 if (cip->ic_cipher == IEEE80211_CIPHER_TKIP &&
1768 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0 && sc->sc_splitmic) 1844 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0 && sc->sc_splitmic)
1769 ath_hal_keyreset(ah, keyix+32); /* RX key */ 1845 ath_hal_keyreset(ah, keyix+32); /* RX key */
1770 if (keyix >= IEEE80211_WEP_NKID) { 1846 if (keyix >= IEEE80211_WEP_NKID) {
1771 /* 1847 /*
1772 * Don't touch keymap entries for global keys so 1848 * Don't touch keymap entries for global keys so
1773 * they are never considered for dynamic allocation. 1849 * they are never considered for dynamic allocation.
1774 */ 1850 */
1775 clrbit(sc->sc_keymap, keyix); 1851 clrbit(sc->sc_keymap, keyix);
1776 if (cip->ic_cipher == IEEE80211_CIPHER_TKIP && 1852 if (cip->ic_cipher == IEEE80211_CIPHER_TKIP &&
1777 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0 && 1853 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0) {
1778 sc->sc_splitmic) { 
1779 clrbit(sc->sc_keymap, keyix+64); /* TX key MIC */ 1854 clrbit(sc->sc_keymap, keyix+64); /* TX key MIC */
1780 clrbit(sc->sc_keymap, keyix+32); /* RX key */ 1855 if (sc->sc_splitmic) {
1781 clrbit(sc->sc_keymap, keyix+32+64); /* RX key MIC */ 1856 /* +32 for RX key, +32+64 for RX key MIC */
 1857 clrbit(sc->sc_keymap, keyix+32);
 1858 clrbit(sc->sc_keymap, keyix+32+64);
 1859 }
1782 } 1860 }
1783 } 1861 }
1784 return 1; 1862 return 1;
1785} 1863}
1786 1864
1787/* 1865/*
1788 * Set the key cache contents for the specified key. Key cache 1866 * Set the key cache contents for the specified key. Key cache
1789 * slot(s) must already have been allocated by ath_key_alloc. 1867 * slot(s) must already have been allocated by ath_key_alloc.
1790 */ 1868 */
1791static int 1869static int
1792ath_key_set(struct ieee80211com *ic, const struct ieee80211_key *k, 1870ath_key_set(struct ieee80211com *ic, const struct ieee80211_key *k,
1793 const u_int8_t mac[IEEE80211_ADDR_LEN]) 1871 const u_int8_t mac[IEEE80211_ADDR_LEN])
1794{ 1872{
@@ -2972,27 +3050,27 @@ ath_rx_proc(void *arg, int npending) @@ -2972,27 +3050,27 @@ ath_rx_proc(void *arg, int npending)
2972 /* 3050 /*
2973 * Must provide the virtual address of the current 3051 * Must provide the virtual address of the current
2974 * descriptor, the physical address, and the virtual 3052 * descriptor, the physical address, and the virtual
2975 * address of the next descriptor in the h/w chain. 3053 * address of the next descriptor in the h/w chain.
2976 * This allows the HAL to look ahead to see if the 3054 * This allows the HAL to look ahead to see if the
2977 * hardware is done with a descriptor by checking the 3055 * hardware is done with a descriptor by checking the
2978 * done bit in the following descriptor and the address 3056 * done bit in the following descriptor and the address
2979 * of the current descriptor the DMA engine is working 3057 * of the current descriptor the DMA engine is working
2980 * on. All this is necessary because of our use of 3058 * on. All this is necessary because of our use of
2981 * a self-linked list to avoid rx overruns. 3059 * a self-linked list to avoid rx overruns.
2982 */ 3060 */
2983 status = ath_hal_rxprocdesc(ah, ds, 3061 status = ath_hal_rxprocdesc(ah, ds,
2984 bf->bf_daddr, PA2DESC(sc, ds->ds_link), 3062 bf->bf_daddr, PA2DESC(sc, ds->ds_link),
2985 tsf, &ds->ds_rxstat); 3063 &ds->ds_rxstat);
2986#ifdef AR_DEBUG 3064#ifdef AR_DEBUG
2987 if (sc->sc_debug & ATH_DEBUG_RECV_DESC) 3065 if (sc->sc_debug & ATH_DEBUG_RECV_DESC)
2988 ath_printrxbuf(bf, status == HAL_OK); 3066 ath_printrxbuf(bf, status == HAL_OK);
2989#endif 3067#endif
2990 if (status == HAL_EINPROGRESS) 3068 if (status == HAL_EINPROGRESS)
2991 break; 3069 break;
2992 STAILQ_REMOVE_HEAD(&sc->sc_rxbuf, bf_list); 3070 STAILQ_REMOVE_HEAD(&sc->sc_rxbuf, bf_list);
2993 if (ds->ds_rxstat.rs_more) { 3071 if (ds->ds_rxstat.rs_more) {
2994 /* 3072 /*
2995 * Frame spans multiple descriptors; this 3073 * Frame spans multiple descriptors; this
2996 * cannot happen yet as we don't support 3074 * cannot happen yet as we don't support
2997 * jumbograms. If not in monitor mode, 3075 * jumbograms. If not in monitor mode,
2998 * discard the frame. 3076 * discard the frame.
@@ -4291,27 +4369,27 @@ ath_stoprecv(struct ath_softc *sc) @@ -4291,27 +4369,27 @@ ath_stoprecv(struct ath_softc *sc)
4291 ath_hal_setrxfilter(ah, 0); /* clear recv filter */ 4369 ath_hal_setrxfilter(ah, 0); /* clear recv filter */
4292 ath_hal_stopdmarecv(ah); /* disable DMA engine */ 4370 ath_hal_stopdmarecv(ah); /* disable DMA engine */
4293 DELAY(3000); /* 3ms is long enough for 1 frame */ 4371 DELAY(3000); /* 3ms is long enough for 1 frame */
4294 if (sc->sc_debug & (ATH_DEBUG_RESET | ATH_DEBUG_FATAL)) { 4372 if (sc->sc_debug & (ATH_DEBUG_RESET | ATH_DEBUG_FATAL)) {
4295 struct ath_buf *bf; 4373 struct ath_buf *bf;
4296 4374
4297 printf("%s: rx queue %p, link %p\n", __func__, 4375 printf("%s: rx queue %p, link %p\n", __func__,
4298 (void *)(uintptr_t) ath_hal_getrxbuf(ah), sc->sc_rxlink); 4376 (void *)(uintptr_t) ath_hal_getrxbuf(ah), sc->sc_rxlink);
4299 STAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) { 4377 STAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) {
4300 struct ath_desc *ds = bf->bf_desc; 4378 struct ath_desc *ds = bf->bf_desc;
4301 tsf = ath_hal_gettsf64(sc->sc_ah); 4379 tsf = ath_hal_gettsf64(sc->sc_ah);
4302 HAL_STATUS status = ath_hal_rxprocdesc(ah, ds, 4380 HAL_STATUS status = ath_hal_rxprocdesc(ah, ds,
4303 bf->bf_daddr, PA2DESC(sc, ds->ds_link), 4381 bf->bf_daddr, PA2DESC(sc, ds->ds_link),
4304 tsf, &ds->ds_rxstat); 4382 &ds->ds_rxstat);
4305 if (status == HAL_OK || (sc->sc_debug & ATH_DEBUG_FATAL)) 4383 if (status == HAL_OK || (sc->sc_debug & ATH_DEBUG_FATAL))
4306 ath_printrxbuf(bf, status == HAL_OK); 4384 ath_printrxbuf(bf, status == HAL_OK);
4307 } 4385 }
4308 } 4386 }
4309 sc->sc_rxlink = NULL; /* just in case */ 4387 sc->sc_rxlink = NULL; /* just in case */
4310#undef PA2DESC 4388#undef PA2DESC
4311} 4389}
4312 4390
4313/* 4391/*
4314 * Enable the receive h/w following a reset. 4392 * Enable the receive h/w following a reset.
4315 */ 4393 */
4316static int 4394static int
4317ath_startrecv(struct ath_softc *sc) 4395ath_startrecv(struct ath_softc *sc)

cvs diff -r1.25.4.1 -r1.25.4.2 src/sys/dev/ic/athvar.h (expand / switch to unified diff)

--- src/sys/dev/ic/athvar.h 2009/08/07 06:43:28 1.25.4.1
+++ src/sys/dev/ic/athvar.h 2009/08/07 06:48:09 1.25.4.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: athvar.h,v 1.25.4.1 2009/08/07 06:43:28 snj Exp $ */ 1/* $NetBSD: athvar.h,v 1.25.4.2 2009/08/07 06:48:09 snj Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting 4 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer, 11 * notice, this list of conditions and the following disclaimer,
12 * without modification. 12 * without modification.
13 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 13 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 14 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
@@ -48,27 +48,27 @@ @@ -48,27 +48,27 @@
48 48
49#include <external/isc/atheros_hal/dist/ah.h> 49#include <external/isc/atheros_hal/dist/ah.h>
50 50
51#include <dev/ic/ath_netbsd.h> 51#include <dev/ic/ath_netbsd.h>
52#include <dev/ic/athioctl.h> 52#include <dev/ic/athioctl.h>
53#include <dev/ic/athrate.h> 53#include <dev/ic/athrate.h>
54 54
55#define ATH_TIMEOUT 1000 55#define ATH_TIMEOUT 1000
56 56
57#ifndef ATH_RXBUF 57#ifndef ATH_RXBUF
58#define ATH_RXBUF 40 /* number of RX buffers */ 58#define ATH_RXBUF 40 /* number of RX buffers */
59#endif 59#endif
60#ifndef ATH_TXBUF 60#ifndef ATH_TXBUF
61#define ATH_TXBUF 100 /* number of TX buffers */ 61#define ATH_TXBUF 200 /* number of TX buffers */
62#endif 62#endif
63#define ATH_TXDESC 10 /* number of descriptors per buffer */ 63#define ATH_TXDESC 10 /* number of descriptors per buffer */
64#define ATH_TXMAXTRY 11 /* max number of transmit attempts */ 64#define ATH_TXMAXTRY 11 /* max number of transmit attempts */
65#define ATH_TXMGTTRY 4 /* xmit attempts for mgt/ctl frames */ 65#define ATH_TXMGTTRY 4 /* xmit attempts for mgt/ctl frames */
66#define ATH_TXINTR_PERIOD 5 /* max number of batched tx descriptors */ 66#define ATH_TXINTR_PERIOD 5 /* max number of batched tx descriptors */
67 67
68#define ATH_BEACON_AIFS_DEFAULT 0 /* default aifs for ap beacon q */ 68#define ATH_BEACON_AIFS_DEFAULT 0 /* default aifs for ap beacon q */
69#define ATH_BEACON_CWMIN_DEFAULT 0 /* default cwmin for ap beacon q */ 69#define ATH_BEACON_CWMIN_DEFAULT 0 /* default cwmin for ap beacon q */
70#define ATH_BEACON_CWMAX_DEFAULT 0 /* default cwmax for ap beacon q */ 70#define ATH_BEACON_CWMAX_DEFAULT 0 /* default cwmax for ap beacon q */
71 71
72/* 72/*
73 * The key cache is used for h/w cipher state and also for 73 * The key cache is used for h/w cipher state and also for
74 * tracking station state such as the current tx antenna. 74 * tracking station state such as the current tx antenna.
@@ -118,27 +118,27 @@ struct ath_buf { @@ -118,27 +118,27 @@ struct ath_buf {
118#define bf_mapsize bf_dmamap->dm_mapsize 118#define bf_mapsize bf_dmamap->dm_mapsize
119#define ATH_MAX_SCATTER ATH_TXDESC /* max(tx,rx,beacon) desc's */ 119#define ATH_MAX_SCATTER ATH_TXDESC /* max(tx,rx,beacon) desc's */
120#define bf_segs bf_dmamap->dm_segs 120#define bf_segs bf_dmamap->dm_segs
121}; 121};
122typedef STAILQ_HEAD(, ath_buf) ath_bufhead; 122typedef STAILQ_HEAD(, ath_buf) ath_bufhead;
123 123
124/* 124/*
125 * DMA state for tx/rx descriptors. 125 * DMA state for tx/rx descriptors.
126 */ 126 */
127struct ath_descdma { 127struct ath_descdma {
128 const char* dd_name; 128 const char* dd_name;
129 struct ath_desc *dd_desc; /* descriptors */ 129 struct ath_desc *dd_desc; /* descriptors */
130 bus_addr_t dd_desc_paddr; /* physical addr of dd_desc */ 130 bus_addr_t dd_desc_paddr; /* physical addr of dd_desc */
131 bus_addr_t dd_desc_len; /* size of dd_desc */ 131 bus_size_t dd_desc_len; /* size of dd_desc */
132 bus_dma_segment_t dd_dseg; 132 bus_dma_segment_t dd_dseg;
133 int dd_dnseg; /* number of segments */ 133 int dd_dnseg; /* number of segments */
134 bus_dma_tag_t dd_dmat; /* bus DMA tag */ 134 bus_dma_tag_t dd_dmat; /* bus DMA tag */
135 bus_dmamap_t dd_dmamap; /* DMA map for descriptors */ 135 bus_dmamap_t dd_dmamap; /* DMA map for descriptors */
136 struct ath_buf *dd_bufptr; /* associated buffers */ 136 struct ath_buf *dd_bufptr; /* associated buffers */
137}; 137};
138 138
139/* 139/*
140 * Data transmit queue state. One of these exists for each 140 * Data transmit queue state. One of these exists for each
141 * hardware transmit queue. Packets sent to us from above 141 * hardware transmit queue. Packets sent to us from above
142 * are assigned to queues based on their priority. Not all 142 * are assigned to queues based on their priority. Not all
143 * devices support a complete set of hardware transmit queues. 143 * devices support a complete set of hardware transmit queues.
144 * For those devices the array sc_ac2q will map multiple 144 * For those devices the array sc_ac2q will map multiple
@@ -447,36 +447,40 @@ extern int ath_txbuf; @@ -447,36 +447,40 @@ extern int ath_txbuf;
447#define ath_hal_setctstimeout(_ah, _us) \ 447#define ath_hal_setctstimeout(_ah, _us) \
448 ((*(_ah)->ah_setCTSTimeout)((_ah), (_us))) 448 ((*(_ah)->ah_setCTSTimeout)((_ah), (_us)))
449#define ath_hal_getctstimeout(_ah) \ 449#define ath_hal_getctstimeout(_ah) \
450 ((*(_ah)->ah_getCTSTimeout)((_ah))) 450 ((*(_ah)->ah_getCTSTimeout)((_ah)))
451#define ath_hal_getcapability(_ah, _cap, _param, _result) \ 451#define ath_hal_getcapability(_ah, _cap, _param, _result) \
452 ((*(_ah)->ah_getCapability)((_ah), (_cap), (_param), (_result))) 452 ((*(_ah)->ah_getCapability)((_ah), (_cap), (_param), (_result)))
453#define ath_hal_setcapability(_ah, _cap, _param, _v, _status) \ 453#define ath_hal_setcapability(_ah, _cap, _param, _v, _status) \
454 ((*(_ah)->ah_setCapability)((_ah), (_cap), (_param), (_v), (_status))) 454 ((*(_ah)->ah_setCapability)((_ah), (_cap), (_param), (_v), (_status)))
455#define ath_hal_ciphersupported(_ah, _cipher) \ 455#define ath_hal_ciphersupported(_ah, _cipher) \
456 (ath_hal_getcapability(_ah, HAL_CAP_CIPHER, _cipher, NULL) == HAL_OK) 456 (ath_hal_getcapability(_ah, HAL_CAP_CIPHER, _cipher, NULL) == HAL_OK)
457#define ath_hal_getregdomain(_ah, _prd) \ 457#define ath_hal_getregdomain(_ah, _prd) \
458 (ath_hal_getcapability(_ah, HAL_CAP_REG_DMN, 0, (_prd)) == HAL_OK) 458 (ath_hal_getcapability(_ah, HAL_CAP_REG_DMN, 0, (_prd)) == HAL_OK)
459#define ath_hal_setregdomain(_ah, _rd) \ 459#define ath_hal_setregdomain(_ah, _rd) \
460 ((*(_ah)->ah_setRegulatoryDomain)((_ah), (_rd), NULL)) 460 ath_hal_setcapability(_ah, HAL_CAP_REG_DMN, 0, _rd, NULL)
461#define ath_hal_getcountrycode(_ah, _pcc) \ 461#define ath_hal_getcountrycode(_ah, _pcc) \
462 (*(_pcc) = (_ah)->ah_countryCode) 462 (*(_pcc) = (_ah)->ah_countryCode)
463#define ath_hal_tkipsplit(_ah) \ 463#define ath_hal_gettkipmic(_ah) \
 464 (ath_hal_getcapability(_ah, HAL_CAP_TKIP_MIC, 1, NULL) == HAL_OK)
 465#define ath_hal_settkipmic(_ah, _v) \
 466 ath_hal_setcapability(_ah, HAL_CAP_TKIP_MIC, 1, _v, NULL)
 467#define ath_hal_hastkipsplit(_ah) \
464 (ath_hal_getcapability(_ah, HAL_CAP_TKIP_SPLIT, 0, NULL) == HAL_OK) 468 (ath_hal_getcapability(_ah, HAL_CAP_TKIP_SPLIT, 0, NULL) == HAL_OK)
465#define ath_hal_settkipmic(_ah, _v) \ 469#define ath_hal_gettkipsplit(_ah) \
466 (ath_hal_setcapability(_ah, HAL_CAP_TKIP_MIC, 1, _v, NULL) == HAL_OK) 470 (ath_hal_getcapability(_ah, HAL_CAP_TKIP_SPLIT, 1, NULL) == HAL_OK)
467#define ath_hal_settkipsplit(_ah, _v) \ 471#define ath_hal_settkipsplit(_ah, _v) \
468 (ath_hal_setcapability(_ah, HAL_CAP_TKIP_SPLIT, 1, _v, NULL) == HAL_OK) 472 ath_hal_setcapability(_ah, HAL_CAP_TKIP_SPLIT, 1, _v, NULL)
469#define ath_hal_wmetkipmic(_ah) \ 473#define ath_hal_haswmetkipmic(_ah) \
470 (ath_hal_getcapability(_ah, HAL_CAP_WME_TKIPMIC, 0, NULL) == HAL_OK) 474 (ath_hal_getcapability(_ah, HAL_CAP_WME_TKIPMIC, 0, NULL) == HAL_OK)
471#define ath_hal_hwphycounters(_ah) \ 475#define ath_hal_hwphycounters(_ah) \
472 (ath_hal_getcapability(_ah, HAL_CAP_PHYCOUNTERS, 0, NULL) == HAL_OK) 476 (ath_hal_getcapability(_ah, HAL_CAP_PHYCOUNTERS, 0, NULL) == HAL_OK)
473#define ath_hal_hasdiversity(_ah) \ 477#define ath_hal_hasdiversity(_ah) \
474 (ath_hal_getcapability(_ah, HAL_CAP_DIVERSITY, 0, NULL) == HAL_OK) 478 (ath_hal_getcapability(_ah, HAL_CAP_DIVERSITY, 0, NULL) == HAL_OK)
475#define ath_hal_getdiversity(_ah) \ 479#define ath_hal_getdiversity(_ah) \
476 (ath_hal_getcapability(_ah, HAL_CAP_DIVERSITY, 1, NULL) == HAL_OK) 480 (ath_hal_getcapability(_ah, HAL_CAP_DIVERSITY, 1, NULL) == HAL_OK)
477#define ath_hal_setdiversity(_ah, _v) \ 481#define ath_hal_setdiversity(_ah, _v) \
478 ath_hal_setcapability(_ah, HAL_CAP_DIVERSITY, 1, _v, NULL) 482 ath_hal_setcapability(_ah, HAL_CAP_DIVERSITY, 1, _v, NULL)
479#define ath_hal_getdiag(_ah, _pv) \ 483#define ath_hal_getdiag(_ah, _pv) \
480 (ath_hal_getcapability(_ah, HAL_CAP_DIAG, 0, _pv) == HAL_OK) 484 (ath_hal_getcapability(_ah, HAL_CAP_DIAG, 0, _pv) == HAL_OK)
481#define ath_hal_setdiag(_ah, _v) \ 485#define ath_hal_setdiag(_ah, _v) \
482 ath_hal_setcapability(_ah, HAL_CAP_DIAG, 0, _v, NULL) 486 ath_hal_setcapability(_ah, HAL_CAP_DIAG, 0, _v, NULL)
@@ -520,54 +524,52 @@ extern int ath_txbuf; @@ -520,54 +524,52 @@ extern int ath_txbuf;
520 ath_hal_setcapability(_ah, HAL_CAP_RFSILENT, 1, _onoff, NULL) 524 ath_hal_setcapability(_ah, HAL_CAP_RFSILENT, 1, _onoff, NULL)
521#define ath_hal_getrfsilent(_ah, _prfsilent) \ 525#define ath_hal_getrfsilent(_ah, _prfsilent) \
522 (ath_hal_getcapability(_ah, HAL_CAP_RFSILENT, 2, _prfsilent) == HAL_OK) 526 (ath_hal_getcapability(_ah, HAL_CAP_RFSILENT, 2, _prfsilent) == HAL_OK)
523#define ath_hal_setrfsilent(_ah, _rfsilent) \ 527#define ath_hal_setrfsilent(_ah, _rfsilent) \
524 ath_hal_setcapability(_ah, HAL_CAP_RFSILENT, 2, _rfsilent, NULL) 528 ath_hal_setcapability(_ah, HAL_CAP_RFSILENT, 2, _rfsilent, NULL)
525#define ath_hal_gettpack(_ah, _ptpack) \ 529#define ath_hal_gettpack(_ah, _ptpack) \
526 (ath_hal_getcapability(_ah, HAL_CAP_TPC_ACK, 0, _ptpack) == HAL_OK) 530 (ath_hal_getcapability(_ah, HAL_CAP_TPC_ACK, 0, _ptpack) == HAL_OK)
527#define ath_hal_settpack(_ah, _tpack) \ 531#define ath_hal_settpack(_ah, _tpack) \
528 ath_hal_setcapability(_ah, HAL_CAP_TPC_ACK, 0, _tpack, NULL) 532 ath_hal_setcapability(_ah, HAL_CAP_TPC_ACK, 0, _tpack, NULL)
529#define ath_hal_gettpcts(_ah, _ptpcts) \ 533#define ath_hal_gettpcts(_ah, _ptpcts) \
530 (ath_hal_getcapability(_ah, HAL_CAP_TPC_CTS, 0, _ptpcts) == HAL_OK) 534 (ath_hal_getcapability(_ah, HAL_CAP_TPC_CTS, 0, _ptpcts) == HAL_OK)
531#define ath_hal_settpcts(_ah, _tpcts) \ 535#define ath_hal_settpcts(_ah, _tpcts) \
532 ath_hal_setcapability(_ah, HAL_CAP_TPC_CTS, 0, _tpcts, NULL) 536 ath_hal_setcapability(_ah, HAL_CAP_TPC_CTS, 0, _tpcts, NULL)
533#if HAL_ABI_VERSION < 0x05120700 
534#define ath_hal_process_noisefloor(_ah) 
535#define ath_hal_getchannoise(_ah, _c) (-96) 
536#define HAL_CAP_TPC_ACK 99 
537#define HAL_CAP_TPC_CTS 100 
538#else 
539#define ath_hal_getchannoise(_ah, _c) \ 537#define ath_hal_getchannoise(_ah, _c) \
540 ((*(_ah)->ah_getChanNoise)((_ah), (_c))) 538 ((*(_ah)->ah_getChanNoise)((_ah), (_c)))
541#endif 
542 539
543#define ath_hal_setuprxdesc(_ah, _ds, _size, _intreq) \ 540#define ath_hal_setuprxdesc(_ah, _ds, _size, _intreq) \
544 ((*(_ah)->ah_setupRxDesc)((_ah), (_ds), (_size), (_intreq))) 541 ((*(_ah)->ah_setupRxDesc)((_ah), (_ds), (_size), (_intreq)))
 542#if 0
545#define ath_hal_rxprocdesc(_ah, _ds, _dspa, _dsnext, tsf, a5) \ 543#define ath_hal_rxprocdesc(_ah, _ds, _dspa, _dsnext, tsf, a5) \
546 ((*(_ah)->ah_procRxDesc)((_ah), (_ds), (_dspa), (_dsnext), (tsf), (a5))) 544 ((*(_ah)->ah_procRxDesc)((_ah), (_ds), (_dspa), (_dsnext), (tsf), (a5)))
 545#else
 546#define ath_hal_rxprocdesc(_ah, _ds, _dspa, _dsnext, _rs) \
 547 ((*(_ah)->ah_procRxDesc)((_ah), (_ds), (_dspa), (_dsnext), 0, (_rs)))
 548#endif
547#define ath_hal_setuptxdesc(_ah, _ds, _plen, _hlen, _atype, _txpow, \ 549#define ath_hal_setuptxdesc(_ah, _ds, _plen, _hlen, _atype, _txpow, \
548 _txr0, _txtr0, _keyix, _ant, _flags, \ 550 _txr0, _txtr0, _keyix, _ant, _flags, \
549 _rtsrate, _rtsdura) \ 551 _rtsrate, _rtsdura) \
550 ((*(_ah)->ah_setupTxDesc)((_ah), (_ds), (_plen), (_hlen), (_atype), \ 552 ((*(_ah)->ah_setupTxDesc)((_ah), (_ds), (_plen), (_hlen), (_atype), \
551 (_txpow), (_txr0), (_txtr0), (_keyix), (_ant), \ 553 (_txpow), (_txr0), (_txtr0), (_keyix), (_ant), \
552 (_flags), (_rtsrate), (_rtsdura), 0, 0, 0)) 554 (_flags), (_rtsrate), (_rtsdura), 0, 0, 0))
553#define ath_hal_setupxtxdesc(_ah, _ds, \ 555#define ath_hal_setupxtxdesc(_ah, _ds, \
554 _txr1, _txtr1, _txr2, _txtr2, _txr3, _txtr3) \ 556 _txr1, _txtr1, _txr2, _txtr2, _txr3, _txtr3) \
555 ((*(_ah)->ah_setupXTxDesc)((_ah), (_ds), \ 557 ((*(_ah)->ah_setupXTxDesc)((_ah), (_ds), \
556 (_txr1), (_txtr1), (_txr2), (_txtr2), (_txr3), (_txtr3))) 558 (_txr1), (_txtr1), (_txr2), (_txtr2), (_txr3), (_txtr3)))
557#define ath_hal_filltxdesc(_ah, _ds, _l, _first, _last, _ds0) \ 559#define ath_hal_filltxdesc(_ah, _ds, _l, _first, _last, _ds0) \
558 ((*(_ah)->ah_fillTxDesc)((_ah), (_ds), (_l), (_first), (_last), (_ds0))) 560 ((*(_ah)->ah_fillTxDesc)((_ah), (_ds), (_l), (_first), (_last), (_ds0)))
559#define ath_hal_txprocdesc(_ah, _ds, _a2) \ 561#define ath_hal_txprocdesc(_ah, _ds, _ts) \
560 ((*(_ah)->ah_procTxDesc)((_ah), (_ds), (_a2))) 562 ((*(_ah)->ah_procTxDesc)((_ah), (_ds), (_ts)))
561#define ath_hal_gettxintrtxqs(_ah, _txqs) \ 563#define ath_hal_gettxintrtxqs(_ah, _txqs) \
562 ((*(_ah)->ah_getTxIntrQueue)((_ah), (_txqs))) 564 ((*(_ah)->ah_getTxIntrQueue)((_ah), (_txqs)))
563 565
564#define ath_hal_gpioCfgOutput(_ah, _gpio) \ 566#define ath_hal_gpioCfgOutput(_ah, _gpio) \
565 ((*(_ah)->ah_gpioCfgOutput)((_ah), (_gpio))) 567 ((*(_ah)->ah_gpioCfgOutput)((_ah), (_gpio)))
566#define ath_hal_gpioset(_ah, _gpio, _b) \ 568#define ath_hal_gpioset(_ah, _gpio, _b) \
567 ((*(_ah)->ah_gpioSet)((_ah), (_gpio), (_b))) 569 ((*(_ah)->ah_gpioSet)((_ah), (_gpio), (_b)))
568 570
569#define ath_hal_radar_event(_ah) \ 571#define ath_hal_radar_event(_ah) \
570 ((*(_ah)->ah_radarHaveEvent)((_ah))) 572 ((*(_ah)->ah_radarHaveEvent)((_ah)))
571#define ath_hal_procdfs(_ah, _chan) \ 573#define ath_hal_procdfs(_ah, _chan) \
572 ((*(_ah)->ah_processDfs)((_ah), (_chan))) 574 ((*(_ah)->ah_processDfs)((_ah), (_chan)))
573#define ath_hal_checknol(_ah, _chan, _nchans) \ 575#define ath_hal_checknol(_ah, _chan, _nchans) \