diff options
author | avos <avos@FreeBSD.org> | 2016-05-26 16:39:11 +0000 |
---|---|---|
committer | avos <avos@FreeBSD.org> | 2016-05-26 16:39:11 +0000 |
commit | a6adaa3c235fe0f54b50a73bea13297603dbb5b7 (patch) | |
tree | 91d29e7e88244129cb6dde1ae14d6c5edb1d144c | |
parent | 930215e113f4fdc93adfeeea2dc664ed68f3bdc4 (diff) | |
download | FreeBSD-src-a6adaa3c235fe0f54b50a73bea13297603dbb5b7.zip FreeBSD-src-a6adaa3c235fe0f54b50a73bea13297603dbb5b7.tar.gz |
urtwn, rtwn, rsu: switch to ieee80211_add_channel_list_2ghz().
- Use device's channel list instead of default one (from
ieee80211_init_channels()); adds 12 - 14 2GHz channels.
- Add ic_getradiocaps() method.
-rw-r--r-- | sys/dev/rtwn/if_rtwn.c | 30 | ||||
-rw-r--r-- | sys/dev/rtwn/if_rtwnreg.h | 2 | ||||
-rw-r--r-- | sys/dev/urtwn/if_urtwn.c | 32 | ||||
-rw-r--r-- | sys/dev/urtwn/if_urtwnreg.h | 2 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_rsu.c | 33 |
5 files changed, 78 insertions, 21 deletions
diff --git a/sys/dev/rtwn/if_rtwn.c b/sys/dev/rtwn/if_rtwn.c index d800475..3ae0c1a 100644 --- a/sys/dev/rtwn/if_rtwn.c +++ b/sys/dev/rtwn/if_rtwn.c @@ -172,6 +172,8 @@ static void rtwn_set_rx_bssid_all(struct rtwn_softc *, int); static void rtwn_set_gain(struct rtwn_softc *, uint8_t); static void rtwn_scan_start(struct ieee80211com *); static void rtwn_scan_end(struct ieee80211com *); +static void rtwn_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static void rtwn_set_channel(struct ieee80211com *); static void rtwn_update_mcast(struct ieee80211com *); static void rtwn_set_chan(struct rtwn_softc *, @@ -230,6 +232,9 @@ MODULE_DEPEND(rtwn, pci, 1, 1, 1); MODULE_DEPEND(rtwn, wlan, 1, 1, 1); MODULE_DEPEND(rtwn, firmware, 1, 1, 1); +static const uint8_t rtwn_chan_2ghz[] = + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; + static int rtwn_probe(device_t dev) { @@ -251,7 +256,6 @@ rtwn_attach(device_t dev) struct rtwn_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; uint32_t lcsr; - uint8_t bands[IEEE80211_MODE_BYTES]; int i, count, error, rid; sc->sc_dev = dev; @@ -352,17 +356,18 @@ rtwn_attach(device_t dev) | IEEE80211_C_WME /* 802.11e */ ; - 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 R92C_CHANNEL_PLAN_BY_HW bit is set. */ + + rtwn_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); ieee80211_ifattach(ic); ic->ic_wme.wme_update = rtwn_updateedca; ic->ic_update_mcast = rtwn_update_mcast; - ic->ic_scan_start =rtwn_scan_start; + ic->ic_scan_start = rtwn_scan_start; ic->ic_scan_end = rtwn_scan_end; + ic->ic_getradiocaps = rtwn_getradiocaps; ic->ic_set_channel = rtwn_set_channel; ic->ic_raw_xmit = rtwn_raw_xmit; ic->ic_transmit = rtwn_transmit; @@ -2717,6 +2722,19 @@ rtwn_scan_end(struct ieee80211com *ic) } static void +rtwn_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, + rtwn_chan_2ghz, nitems(rtwn_chan_2ghz), bands, 0); +} + +static void rtwn_set_channel(struct ieee80211com *ic) { struct rtwn_softc *sc = ic->ic_softc; diff --git a/sys/dev/rtwn/if_rtwnreg.h b/sys/dev/rtwn/if_rtwnreg.h index 1992e83..6fc970c 100644 --- a/sys/dev/rtwn/if_rtwnreg.h +++ b/sys/dev/rtwn/if_rtwnreg.h @@ -1014,6 +1014,8 @@ struct r92c_rom { uint8_t rf_opt3; uint8_t rf_opt4; uint8_t channel_plan; +#define R92C_CHANNEL_PLAN_BY_HW 0x80 + uint8_t version; uint8_t curstomer_id; } __packed; diff --git a/sys/dev/urtwn/if_urtwn.c b/sys/dev/urtwn/if_urtwn.c index 221852f..d6ed4d7 100644 --- a/sys/dev/urtwn/if_urtwn.c +++ b/sys/dev/urtwn/if_urtwn.c @@ -350,6 +350,8 @@ static void urtwn_set_rx_bssid_all(struct urtwn_softc *, int); static void urtwn_set_gain(struct urtwn_softc *, uint8_t); static void urtwn_scan_start(struct ieee80211com *); static void urtwn_scan_end(struct ieee80211com *); +static void urtwn_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static void urtwn_set_channel(struct ieee80211com *); static int urtwn_wme_update(struct ieee80211com *); static void urtwn_update_slot(struct ieee80211com *); @@ -458,6 +460,9 @@ static const struct wme_to_queue { { R92C_EDCA_VO_PARAM, URTWN_BULK_TX_VO} }; +static const uint8_t urtwn_chan_2ghz[] = + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; + static int urtwn_match(device_t self) { @@ -492,7 +497,6 @@ urtwn_attach(device_t self) struct usb_attach_arg *uaa = device_get_ivars(self); struct urtwn_softc *sc = device_get_softc(self); struct ieee80211com *ic = &sc->sc_ic; - uint8_t bands[IEEE80211_MODE_BYTES]; int error; device_set_usb_desc(self); @@ -608,17 +612,16 @@ urtwn_attach(device_t self) ic->ic_rxstream = sc->nrxchains; } - memset(bands, 0, sizeof(bands)); - setbit(bands, IEEE80211_MODE_11B); - setbit(bands, IEEE80211_MODE_11G); - if (urtwn_enable_11n) - setbit(bands, IEEE80211_MODE_11NG); - ieee80211_init_channels(ic, NULL, bands); + /* XXX TODO: setup regdomain if R92C_CHANNEL_PLAN_BY_HW bit is set. */ + + urtwn_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); ieee80211_ifattach(ic); ic->ic_raw_xmit = urtwn_raw_xmit; ic->ic_scan_start = urtwn_scan_start; ic->ic_scan_end = urtwn_scan_end; + ic->ic_getradiocaps = urtwn_getradiocaps; ic->ic_set_channel = urtwn_set_channel; ic->ic_transmit = urtwn_transmit; ic->ic_parent = urtwn_parent; @@ -4744,6 +4747,21 @@ urtwn_scan_end(struct ieee80211com *ic) } static void +urtwn_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); + if (urtwn_enable_11n) + setbit(bands, IEEE80211_MODE_11NG); + ieee80211_add_channel_list_2ghz(chans, maxchans, nchans, + urtwn_chan_2ghz, nitems(urtwn_chan_2ghz), bands, 0); +} + +static void urtwn_set_channel(struct ieee80211com *ic) { struct urtwn_softc *sc = ic->ic_softc; diff --git a/sys/dev/urtwn/if_urtwnreg.h b/sys/dev/urtwn/if_urtwnreg.h index 7b618aa..e80fd07 100644 --- a/sys/dev/urtwn/if_urtwnreg.h +++ b/sys/dev/urtwn/if_urtwnreg.h @@ -1018,6 +1018,8 @@ struct r92c_rom { uint8_t rf_opt3; uint8_t rf_opt4; uint8_t channel_plan; +#define R92C_CHANNEL_PLAN_BY_HW 0x80 + uint8_t version; uint8_t customer_id; } __packed; diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c index 08740b3..c08b4af 100644 --- a/sys/dev/usb/wlan/if_rsu.c +++ b/sys/dev/usb/wlan/if_rsu.c @@ -170,6 +170,8 @@ static struct ieee80211vap * static void rsu_vap_delete(struct ieee80211vap *); static void rsu_scan_start(struct ieee80211com *); static void rsu_scan_end(struct ieee80211com *); +static void rsu_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static void rsu_set_channel(struct ieee80211com *); static void rsu_update_mcast(struct ieee80211com *); static int rsu_alloc_rx_list(struct rsu_softc *); @@ -252,6 +254,9 @@ MODULE_DEPEND(rsu, firmware, 1, 1, 1); MODULE_VERSION(rsu, 1); USB_PNP_HOST_INFO(rsu_devs); +static const uint8_t rsu_chan_2ghz[] = + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; + static uint8_t rsu_wme_ac_xfer_map[4] = { [WME_AC_BE] = RSU_BULK_TX_BE_BK, [WME_AC_BK] = RSU_BULK_TX_BE_BK, @@ -404,7 +409,6 @@ rsu_attach(device_t self) struct rsu_softc *sc = device_get_softc(self); struct ieee80211com *ic = &sc->sc_ic; int error; - uint8_t bands[IEEE80211_MODE_BYTES]; uint8_t iface_index; struct usb_interface *iface; const char *rft; @@ -534,18 +538,14 @@ rsu_attach(device_t self) ic->ic_rxstream = sc->sc_nrxstream; } - /* Set supported .11b and .11g rates. */ - memset(bands, 0, sizeof(bands)); - setbit(bands, IEEE80211_MODE_11B); - setbit(bands, IEEE80211_MODE_11G); - if (sc->sc_ht) - setbit(bands, IEEE80211_MODE_11NG); - ieee80211_init_channels(ic, NULL, bands); + rsu_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); ieee80211_ifattach(ic); ic->ic_raw_xmit = rsu_raw_xmit; ic->ic_scan_start = rsu_scan_start; ic->ic_scan_end = rsu_scan_end; + ic->ic_getradiocaps = rsu_getradiocaps; ic->ic_set_channel = rsu_set_channel; ic->ic_vap_create = rsu_vap_create; ic->ic_vap_delete = rsu_vap_delete; @@ -699,6 +699,23 @@ rsu_scan_end(struct ieee80211com *ic) } static void +rsu_getradiocaps(struct ieee80211com *ic, + int maxchans, int *nchans, struct ieee80211_channel chans[]) +{ + struct rsu_softc *sc = ic->ic_softc; + uint8_t bands[IEEE80211_MODE_BYTES]; + + /* Set supported .11b and .11g rates. */ + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + if (sc->sc_ht) + setbit(bands, IEEE80211_MODE_11NG); + ieee80211_add_channel_list_2ghz(chans, maxchans, nchans, + rsu_chan_2ghz, nitems(rsu_chan_2ghz), bands, 0); +} + +static void rsu_set_channel(struct ieee80211com *ic __unused) { /* We are unable to switch channels, yet. */ |