Deleted Added
full compact
if_ath.c (140759) if_ath.c (140761)
1/*-
2 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 21 unchanged lines hidden (view full) ---

30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
32 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 * THE POSSIBILITY OF SUCH DAMAGES.
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 21 unchanged lines hidden (view full) ---

30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
32 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 * THE POSSIBILITY OF SUCH DAMAGES.
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 140759 2005-01-24 20:05:03Z sam $");
38__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 140761 2005-01-24 20:31:24Z sam $");
39
40/*
41 * Driver for the Atheros Wireless LAN controller.
42 *
43 * This software is derived from work of Atsushi Onoe; his contribution
44 * is greatly appreciated.
45 */
46

--- 2574 unchanged lines hidden (view full) ---

2621
2622 m->m_pkthdr.rcvif = ifp;
2623 len = ds->ds_rxstat.rs_datalen;
2624 m->m_pkthdr.len = m->m_len = len;
2625
2626 sc->sc_stats.ast_ant_rx[ds->ds_rxstat.rs_antenna]++;
2627
2628 if (sc->sc_drvbpf) {
39
40/*
41 * Driver for the Atheros Wireless LAN controller.
42 *
43 * This software is derived from work of Atsushi Onoe; his contribution
44 * is greatly appreciated.
45 */
46

--- 2574 unchanged lines hidden (view full) ---

2621
2622 m->m_pkthdr.rcvif = ifp;
2623 len = ds->ds_rxstat.rs_datalen;
2624 m->m_pkthdr.len = m->m_len = len;
2625
2626 sc->sc_stats.ast_ant_rx[ds->ds_rxstat.rs_antenna]++;
2627
2628 if (sc->sc_drvbpf) {
2629 const void *data;
2630 int hdrsize, hdrspace;
2631 u_int8_t rix;
2632
2633 /*
2634 * Discard anything shorter than an ack or cts.
2635 */
2636 if (len < IEEE80211_ACK_LEN) {
2637 DPRINTF(sc, ATH_DEBUG_RECV,
2638 "%s: runt packet %d\n",
2639 __func__, len);
2640 sc->sc_stats.ast_rx_tooshort++;
2641 m_freem(m);
2642 goto rx_next;
2643 }
2644 rix = ds->ds_rxstat.rs_rate;
2629 u_int8_t rix;
2630
2631 /*
2632 * Discard anything shorter than an ack or cts.
2633 */
2634 if (len < IEEE80211_ACK_LEN) {
2635 DPRINTF(sc, ATH_DEBUG_RECV,
2636 "%s: runt packet %d\n",
2637 __func__, len);
2638 sc->sc_stats.ast_rx_tooshort++;
2639 m_freem(m);
2640 goto rx_next;
2641 }
2642 rix = ds->ds_rxstat.rs_rate;
2645 sc->sc_rx_th.wr_flags = sc->sc_hwmap[rix].flags;
2643 sc->sc_rx_th.wr_flags = sc->sc_hwmap[rix].rxflags;
2646 sc->sc_rx_th.wr_rate = sc->sc_hwmap[rix].ieeerate;
2647 sc->sc_rx_th.wr_antsignal = ds->ds_rxstat.rs_rssi;
2648 sc->sc_rx_th.wr_antenna = ds->ds_rxstat.rs_antenna;
2649 /* XXX TSF */
2650
2644 sc->sc_rx_th.wr_rate = sc->sc_hwmap[rix].ieeerate;
2645 sc->sc_rx_th.wr_antsignal = ds->ds_rxstat.rs_rssi;
2646 sc->sc_rx_th.wr_antenna = ds->ds_rxstat.rs_antenna;
2647 /* XXX TSF */
2648
2651 /*
2652 * Gag, deal with hardware padding of headers. This
2653 * only happens for QoS frames. We copy the 802.11
2654 * header out-of-line and supply it separately, then
2655 * adjust the mbuf chain. It would be better if we
2656 * could just flag the packet in the radiotap header
2657 * and have applications DTRT.
2658 */
2659 if (len > sizeof(struct ieee80211_qosframe)) {
2660 data = mtod(m, const void *);
2661 hdrsize = ieee80211_anyhdrsize(data);
2662 if (hdrsize & 3) {
2663 bcopy(data, &sc->sc_rx_wh, hdrsize);
2664 hdrspace = roundup(hdrsize,
2665 sizeof(u_int32_t));
2666 m->m_data += hdrspace;
2667 m->m_len -= hdrspace;
2668 bpf_mtap2(sc->sc_drvbpf, &sc->sc_rx,
2669 sc->sc_rx_rt_len + hdrsize, m);
2670 m->m_data -= hdrspace;
2671 m->m_len += hdrspace;
2672 } else
2673 bpf_mtap2(sc->sc_drvbpf,
2674 &sc->sc_rx, sc->sc_rx_rt_len, m);
2675 } else
2676 bpf_mtap2(sc->sc_drvbpf,
2677 &sc->sc_rx, sc->sc_rx_rt_len, m);
2649 bpf_mtap2(sc->sc_drvbpf,
2650 &sc->sc_rx_th, sc->sc_rx_th_len, m);
2678 }
2679
2680 /*
2681 * From this point on we assume the frame is at least
2682 * as large as ieee80211_frame_min; verify that.
2683 */
2684 if (len < IEEE80211_MIN_LEN) {
2685 DPRINTF(sc, ATH_DEBUG_RECV, "%s: short packet %d\n",

--- 550 unchanged lines hidden (view full) ---

3236
3237 if (IFF_DUMPPKTS(sc, ATH_DEBUG_XMIT))
3238 ieee80211_dump_pkt(mtod(m0, caddr_t), m0->m_len,
3239 sc->sc_hwmap[txrate].ieeerate, -1);
3240
3241 if (ic->ic_rawbpf)
3242 bpf_mtap(ic->ic_rawbpf, m0);
3243 if (sc->sc_drvbpf) {
2651 }
2652
2653 /*
2654 * From this point on we assume the frame is at least
2655 * as large as ieee80211_frame_min; verify that.
2656 */
2657 if (len < IEEE80211_MIN_LEN) {
2658 DPRINTF(sc, ATH_DEBUG_RECV, "%s: short packet %d\n",

--- 550 unchanged lines hidden (view full) ---

3209
3210 if (IFF_DUMPPKTS(sc, ATH_DEBUG_XMIT))
3211 ieee80211_dump_pkt(mtod(m0, caddr_t), m0->m_len,
3212 sc->sc_hwmap[txrate].ieeerate, -1);
3213
3214 if (ic->ic_rawbpf)
3215 bpf_mtap(ic->ic_rawbpf, m0);
3216 if (sc->sc_drvbpf) {
3244 sc->sc_tx_th.wt_flags = sc->sc_hwmap[txrate].flags;
3217 sc->sc_tx_th.wt_flags = sc->sc_hwmap[txrate].txflags;
3245 if (iswep)
3246 sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP;
3247 sc->sc_tx_th.wt_rate = sc->sc_hwmap[txrate].ieeerate;
3248 sc->sc_tx_th.wt_txpower = ni->ni_txpower;
3249 sc->sc_tx_th.wt_antenna = sc->sc_txantenna;
3250
3251 bpf_mtap2(sc->sc_drvbpf,
3252 &sc->sc_tx_th, sc->sc_tx_th_len, m0);

--- 947 unchanged lines hidden (view full) ---

4200 u_int8_t ix = rt->rateCodeToIndex[i];
4201 if (ix == 0xff) {
4202 sc->sc_hwmap[i].ledon = (500 * hz) / 1000;
4203 sc->sc_hwmap[i].ledoff = (130 * hz) / 1000;
4204 continue;
4205 }
4206 sc->sc_hwmap[i].ieeerate =
4207 rt->info[ix].dot11Rate & IEEE80211_RATE_VAL;
3218 if (iswep)
3219 sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP;
3220 sc->sc_tx_th.wt_rate = sc->sc_hwmap[txrate].ieeerate;
3221 sc->sc_tx_th.wt_txpower = ni->ni_txpower;
3222 sc->sc_tx_th.wt_antenna = sc->sc_txantenna;
3223
3224 bpf_mtap2(sc->sc_drvbpf,
3225 &sc->sc_tx_th, sc->sc_tx_th_len, m0);

--- 947 unchanged lines hidden (view full) ---

4173 u_int8_t ix = rt->rateCodeToIndex[i];
4174 if (ix == 0xff) {
4175 sc->sc_hwmap[i].ledon = (500 * hz) / 1000;
4176 sc->sc_hwmap[i].ledoff = (130 * hz) / 1000;
4177 continue;
4178 }
4179 sc->sc_hwmap[i].ieeerate =
4180 rt->info[ix].dot11Rate & IEEE80211_RATE_VAL;
4181 sc->sc_hwmap[i].txflags = IEEE80211_RADIOTAP_F_DATAPAD;
4208 if (rt->info[ix].shortPreamble ||
4209 rt->info[ix].phy == IEEE80211_T_OFDM)
4182 if (rt->info[ix].shortPreamble ||
4183 rt->info[ix].phy == IEEE80211_T_OFDM)
4210 sc->sc_hwmap[i].flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
4184 sc->sc_hwmap[i].txflags |= IEEE80211_RADIOTAP_F_SHORTPRE;
4185 /* NB: receive frames include FCS */
4186 sc->sc_hwmap[i].rxflags = sc->sc_hwmap[i].txflags |
4187 IEEE80211_RADIOTAP_F_FCS;
4211 /* setup blink rate table to avoid per-packet lookup */
4212 for (j = 0; j < N(blinkrates)-1; j++)
4213 if (blinkrates[j].rate == sc->sc_hwmap[i].ieeerate)
4214 break;
4215 /* NB: this uses the last entry if the rate isn't found */
4216 /* XXX beware of overlow */
4217 sc->sc_hwmap[i].ledon = (blinkrates[j].timeOn * hz) / 1000;
4218 sc->sc_hwmap[i].ledoff = (blinkrates[j].timeOff * hz) / 1000;

--- 419 unchanged lines hidden (view full) ---

4638 *
4639 * NB: the channel is setup each time we transition to the
4640 * RUN state to avoid filling it in for each frame.
4641 */
4642 sc->sc_tx_th_len = roundup(sizeof(sc->sc_tx_th), sizeof(u_int32_t));
4643 sc->sc_tx_th.wt_ihdr.it_len = htole16(sc->sc_tx_th_len);
4644 sc->sc_tx_th.wt_ihdr.it_present = htole32(ATH_TX_RADIOTAP_PRESENT);
4645
4188 /* setup blink rate table to avoid per-packet lookup */
4189 for (j = 0; j < N(blinkrates)-1; j++)
4190 if (blinkrates[j].rate == sc->sc_hwmap[i].ieeerate)
4191 break;
4192 /* NB: this uses the last entry if the rate isn't found */
4193 /* XXX beware of overlow */
4194 sc->sc_hwmap[i].ledon = (blinkrates[j].timeOn * hz) / 1000;
4195 sc->sc_hwmap[i].ledoff = (blinkrates[j].timeOff * hz) / 1000;

--- 419 unchanged lines hidden (view full) ---

4615 *
4616 * NB: the channel is setup each time we transition to the
4617 * RUN state to avoid filling it in for each frame.
4618 */
4619 sc->sc_tx_th_len = roundup(sizeof(sc->sc_tx_th), sizeof(u_int32_t));
4620 sc->sc_tx_th.wt_ihdr.it_len = htole16(sc->sc_tx_th_len);
4621 sc->sc_tx_th.wt_ihdr.it_present = htole32(ATH_TX_RADIOTAP_PRESENT);
4622
4646 sc->sc_rx_rt_len = roundup(sizeof(sc->sc_rx_th), sizeof(u_int32_t));
4647 sc->sc_rx_th.wr_ihdr.it_len = htole16(sc->sc_rx_rt_len);
4623 sc->sc_rx_th_len = roundup(sizeof(sc->sc_rx_th), sizeof(u_int32_t));
4624 sc->sc_rx_th.wr_ihdr.it_len = htole16(sc->sc_rx_th_len);
4648 sc->sc_rx_th.wr_ihdr.it_present = htole32(ATH_RX_RADIOTAP_PRESENT);
4649}
4650
4651/*
4652 * Announce various information on device/driver attach.
4653 */
4654static void
4655ath_announce(struct ath_softc *sc)

--- 43 unchanged lines hidden ---
4625 sc->sc_rx_th.wr_ihdr.it_present = htole32(ATH_RX_RADIOTAP_PRESENT);
4626}
4627
4628/*
4629 * Announce various information on device/driver attach.
4630 */
4631static void
4632ath_announce(struct ath_softc *sc)

--- 43 unchanged lines hidden ---