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.
This commit is contained in:
Andriy Voskoboinyk 2016-05-26 16:39:11 +00:00
parent 2a06b6b33f
commit a7c31fe1e9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=300754
5 changed files with 78 additions and 21 deletions

View File

@ -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;
@ -2716,6 +2721,19 @@ rtwn_scan_end(struct ieee80211com *ic)
RTWN_UNLOCK(sc);
}
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)
{

View File

@ -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;

View File

@ -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;
@ -4743,6 +4746,21 @@ urtwn_scan_end(struct ieee80211com *ic)
URTWN_UNLOCK(sc);
}
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)
{

View File

@ -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;

View File

@ -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;
@ -698,6 +698,23 @@ rsu_scan_end(struct ieee80211com *ic)
/* Nothing to do here. */
}
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)
{