diff options
author | avos <avos@FreeBSD.org> | 2016-05-26 16:15:10 +0000 |
---|---|---|
committer | avos <avos@FreeBSD.org> | 2016-05-26 16:15:10 +0000 |
commit | 930215e113f4fdc93adfeeea2dc664ed68f3bdc4 (patch) | |
tree | af583966dccc12044489f71ae59417c38b1036f9 | |
parent | 202dc345c7198baa603bd80a7c0f10a5c19114d7 (diff) | |
download | FreeBSD-src-930215e113f4fdc93adfeeea2dc664ed68f3bdc4.zip FreeBSD-src-930215e113f4fdc93adfeeea2dc664ed68f3bdc4.tar.gz |
urtw: switch to ieee80211_add_channel_list_2ghz().
- Use device's channel list instead of default one (from
ieee80211_init_channels()).
- Add ic_getradiocaps() method.
-rw-r--r-- | sys/dev/usb/wlan/if_urtw.c | 28 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_urtwreg.h | 1 |
2 files changed, 24 insertions, 5 deletions
diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index 4c6bc76..9d91281 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -206,6 +206,9 @@ static uint8_t urtw_8225z2_agc[] = { 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31 }; +static const uint8_t urtw_chan_2ghz[] = + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; + static uint32_t urtw_8225_channel[] = { 0x0000, /* dummy channel 0 */ 0x085c, /* 1 */ @@ -662,6 +665,8 @@ static int urtw_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); static void urtw_scan_start(struct ieee80211com *); static void urtw_scan_end(struct ieee80211com *); +static void urtw_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static void urtw_set_channel(struct ieee80211com *); static void urtw_update_mcast(struct ieee80211com *); static int urtw_tx_start(struct urtw_softc *, @@ -785,7 +790,6 @@ urtw_attach(device_t dev) struct urtw_softc *sc = device_get_softc(dev); struct usb_attach_arg *uaa = device_get_ivars(dev); struct ieee80211com *ic = &sc->sc_ic; - uint8_t bands[IEEE80211_MODE_BYTES]; uint8_t iface_index = URTW_IFACE_INDEX; /* XXX */ uint16_t n_setup; uint32_t data; @@ -877,15 +881,16 @@ urtw_attach(device_t dev) IEEE80211_C_BGSCAN | /* capable of bg scanning */ IEEE80211_C_WPA; /* 802.11i */ - memset(bands, 0, sizeof(bands)); - setbit(bands, IEEE80211_MODE_11B); - setbit(bands, IEEE80211_MODE_11G); - ieee80211_init_channels(ic, NULL, bands); + /* XXX TODO: setup regdomain if URTW_EPROM_CHANPLAN_BY_HW bit is set.*/ + + urtw_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); ieee80211_ifattach(ic); ic->ic_raw_xmit = urtw_raw_xmit; ic->ic_scan_start = urtw_scan_start; ic->ic_scan_end = urtw_scan_end; + ic->ic_getradiocaps = urtw_getradiocaps; ic->ic_set_channel = urtw_set_channel; ic->ic_updateslot = urtw_updateslot; ic->ic_vap_create = urtw_vap_create; @@ -1564,6 +1569,19 @@ urtw_scan_end(struct ieee80211com *ic) } static void +urtw_getradiocaps(struct ieee80211com *ic, + int maxchans, int *nchans, struct ieee80211_channel chans[]) +{ + uint8_t bands[IEEE80211_MODE_BYTES]; + + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + ieee80211_add_channel_list_2ghz(chans, maxchans, nchans, + urtw_chan_2ghz, nitems(urtw_chan_2ghz), bands, 0); +} + +static void urtw_set_channel(struct ieee80211com *ic) { struct urtw_softc *sc = ic->ic_softc; diff --git a/sys/dev/usb/wlan/if_urtwreg.h b/sys/dev/usb/wlan/if_urtwreg.h index 09dd597..5021e5a 100644 --- a/sys/dev/usb/wlan/if_urtwreg.h +++ b/sys/dev/usb/wlan/if_urtwreg.h @@ -253,6 +253,7 @@ /* for EEPROM */ #define URTW_EPROM_CHANPLAN 0x03 +#define URTW_EPROM_CHANPLAN_BY_HW (0x80) #define URTW_EPROM_TXPW_BASE 0x05 #define URTW_EPROM_RFCHIPID 0x06 #define URTW_EPROM_RFCHIPID_RTL8225U (5) |