Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Fix alignment and endian bugs observed on sparc64.



details:   https://anonhg.NetBSD.org/src/rev/a42b632e187a
branches:  trunk
changeset: 779005:a42b632e187a
user:      nakayama <nakayama%NetBSD.org@localhost>
date:      Wed Apr 25 05:14:05 2012 +0000

description:
Fix alignment and endian bugs observed on sparc64.
Also apply some minor fix from FreeBSD.

Tested with Buffalo WLI-CB-G54 (BCM4306) and WLI3-CB-G54L (BCM4318)
on i386 and sparc64.

diffstat:

 sys/dev/ic/bwi.c |  26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diffs (93 lines):

diff -r 57b4049738af -r a42b632e187a sys/dev/ic/bwi.c
--- a/sys/dev/ic/bwi.c  Wed Apr 25 04:49:46 2012 +0000
+++ b/sys/dev/ic/bwi.c  Wed Apr 25 05:14:05 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bwi.c,v 1.21 2012/04/14 02:15:01 nakayama Exp $        */
+/*     $NetBSD: bwi.c,v 1.22 2012/04/25 05:14:05 nakayama Exp $        */
 /*     $OpenBSD: bwi.c,v 1.74 2008/02/25 21:13:30 mglocker Exp $       */
 
 /*
@@ -48,7 +48,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bwi.c,v 1.21 2012/04/14 02:15:01 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bwi.c,v 1.22 2012/04/25 05:14:05 nakayama Exp $");
 
 #include <sys/param.h>
 #include <sys/callout.h>
@@ -361,7 +361,7 @@
 static uint8_t  bwi_ieee80211_plcp2rate(uint8_t rate, enum ieee80211_phymode);
 static enum bwi_ieee80211_modtype
                 bwi_ieee80211_rate2modtype(uint8_t rate);
-static uint8_t  bwi_ofdm_plcp2rate(const uint32_t *);
+static uint8_t  bwi_ofdm_plcp2rate(const void *);
 static uint8_t  bwi_ds_plcp2rate(const struct ieee80211_ds_plcp_hdr *);
 static void     bwi_ofdm_plcp_header(uint32_t *, int, uint8_t);
 static void     bwi_ds_plcp_header(struct ieee80211_ds_plcp_hdr *, int,
@@ -3178,7 +3178,7 @@
                        RF_WRITE(mac, 0x52,
                            (tpctl->tp_ctrl1 << 4) | tpctl->tp_ctrl2);
                } else {
-                       RF_FILT_SETBITS(mac, 0x52, 0xfff0, tpctl->tp_ctrl1);
+                       RF_FILT_SETBITS(mac, 0x52, 0xfff0, tpctl->tp_ctrl2);
                }
 
                if (phy->phy_rev >= 6) {
@@ -8768,12 +8768,13 @@
 }
 
 static uint8_t
-bwi_ofdm_plcp2rate(const uint32_t *plcp0)
+bwi_ofdm_plcp2rate(const void *plcp0)
 {
        uint32_t plcp;
        uint8_t plcp_rate;
 
-       plcp = le32toh(*plcp0);
+       /* plcp0 may not be 32-bit aligned. */
+       plcp = le32dec(plcp0);
        plcp_rate = __SHIFTOUT(plcp, IEEE80211_OFDM_PLCP_RATE_MASK);
 
        return (bwi_ieee80211_plcp2rate(plcp_rate, IEEE80211_MODE_11G));
@@ -9105,8 +9106,9 @@
                hdr->txh_fb_duration = htole16(dur);
        }
 
-       hdr->txh_id = __SHIFTIN(BWI_TX_DATA_RING, BWI_TXH_ID_RING_MASK) |
-           __SHIFTIN(idx, BWI_TXH_ID_IDX_MASK);
+       hdr->txh_id = htole16(
+           __SHIFTIN(BWI_TX_DATA_RING, BWI_TXH_ID_RING_MASK) |
+           __SHIFTIN(idx, BWI_TXH_ID_IDX_MASK));
 
        bwi_plcp_header(hdr->txh_plcp, pkt_len, rate);
        /* [TRC: XXX Use fallback rate.] */
@@ -9324,9 +9326,7 @@
        while (idx != end_idx) {
                /* [TRC: XXX Filter this out if it is not pending; see
                   DragonFlyBSD's revision 1.5. */
-               /* [TRC: XXX be16toh is wrong, probably due to the
-                  build environment] */
-               _bwi_txeof(sc, be16toh(st->stats[idx].txs_id));
+               _bwi_txeof(sc, le16toh(st->stats[idx].txs_id));
                idx = (idx + 1) % BWI_TXSTATS_NDESC;
        }
        st->stats_idx = idx;
@@ -9342,7 +9342,7 @@
                uint16_t tx_id, tx_info;
 
                tx_status0 = CSR_READ_4(sc, BWI_TXSTATUS_0);
-               if (tx_status0 == 0)
+               if ((tx_status0 & BWI_TXSTATUS_0_MORE) == 0)
                        break;
                tx_status1 = CSR_READ_4(sc, BWI_TXSTATUS_1);
 
@@ -9352,7 +9352,7 @@
                if (tx_info & 0x30) /* XXX */
                        continue;
 
-               _bwi_txeof(sc, le16toh(tx_id));
+               _bwi_txeof(sc, tx_id);
 
                ifp->if_opackets++;
        }



Home | Main Index | Thread Index | Old Index