svn commit: r300752 - head/sys/dev/ral

Andriy Voskoboinyk avos at FreeBSD.org
Thu May 26 16:05:20 UTC 2016


Author: avos
Date: Thu May 26 16:05:19 2016
New Revision: 300752
URL: https://svnweb.freebsd.org/changeset/base/300752

Log:
  ral: switch to ieee80211_add_channel_list_*()
  
  - Use device's channel list instead of default one (from
  ieee80211_init_channels()).
  - Add ic_getradiocaps() method.
  
  Added channels:
  - 2GHz (all): 12, 13, 14.
  - 5GHz:
   * rt2661: 165
   * rt2860: 38, 46, 54, 62, 102, 110, 118, 126, 134, 151, 159, 165, 167,
  169, 171, 173.
  
  Differential Revision:	https://reviews.freebsd.org/D6182

Modified:
  head/sys/dev/ral/rt2560.c
  head/sys/dev/ral/rt2661.c
  head/sys/dev/ral/rt2860.c

Modified: head/sys/dev/ral/rt2560.c
==============================================================================
--- head/sys/dev/ral/rt2560.c	Thu May 26 15:56:27 2016	(r300751)
+++ head/sys/dev/ral/rt2560.c	Thu May 26 16:05:19 2016	(r300752)
@@ -117,6 +117,8 @@ static void		rt2560_beacon_expire(struct
 static void		rt2560_wakeup_expire(struct rt2560_softc *);
 static void		rt2560_scan_start(struct ieee80211com *);
 static void		rt2560_scan_end(struct ieee80211com *);
+static void		rt2560_getradiocaps(struct ieee80211com *, int, int *,
+			    struct ieee80211_channel[]);
 static void		rt2560_set_channel(struct ieee80211com *);
 static void		rt2560_setup_tx_desc(struct rt2560_softc *,
 			    struct rt2560_tx_desc *, uint32_t, int, int, int,
@@ -187,6 +189,14 @@ static const uint32_t rt2560_rf2525e_r2[
 static const uint32_t rt2560_rf2526_r2[]    = RT2560_RF2526_R2;
 static const uint32_t rt2560_rf2526_hi_r2[] = RT2560_RF2526_HI_R2;
 
+static const uint8_t rt2560_chan_2ghz[] =
+	{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
+
+static const uint8_t rt2560_chan_5ghz[] =
+	{ 36, 40, 44, 48, 52, 56, 60, 64,
+	  100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
+	  149, 153, 157, 161 };
+
 static const struct {
 	uint8_t		chan;
 	uint32_t	r1, r2, r4;
@@ -199,7 +209,6 @@ rt2560_attach(device_t dev, int id)
 {
 	struct rt2560_softc *sc = device_get_softc(dev);
 	struct ieee80211com *ic = &sc->sc_ic;
-	uint8_t bands[IEEE80211_MODE_BYTES];
 	int error;
 
 	sc->sc_dev = dev;
@@ -278,12 +287,8 @@ rt2560_attach(device_t dev, int id)
 #endif
 		;
 
-	memset(bands, 0, sizeof(bands));
-	setbit(bands, IEEE80211_MODE_11B);
-	setbit(bands, IEEE80211_MODE_11G);
-	if (sc->rf_rev == RT2560_RF_5222)
-		setbit(bands, IEEE80211_MODE_11A);
-	ieee80211_init_channels(ic, NULL, bands);
+	rt2560_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
+	    ic->ic_channels);
 
 	ieee80211_ifattach(ic);
 	ic->ic_raw_xmit = rt2560_raw_xmit;
@@ -291,6 +296,7 @@ rt2560_attach(device_t dev, int id)
 	ic->ic_update_promisc = rt2560_update_promisc;
 	ic->ic_scan_start = rt2560_scan_start;
 	ic->ic_scan_end = rt2560_scan_end;
+	ic->ic_getradiocaps = rt2560_getradiocaps;
 	ic->ic_set_channel = rt2560_set_channel;
 
 	ic->ic_vap_create = rt2560_vap_create;
@@ -2141,6 +2147,26 @@ rt2560_set_chan(struct rt2560_softc *sc,
 }
 
 static void
+rt2560_getradiocaps(struct ieee80211com *ic,
+    int maxchans, int *nchans, struct ieee80211_channel chans[])
+{
+	struct rt2560_softc *sc = ic->ic_softc;
+	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,
+	    rt2560_chan_2ghz, nitems(rt2560_chan_2ghz), bands, 0);
+
+	if (sc->rf_rev == RT2560_RF_5222) {
+		setbit(bands, IEEE80211_MODE_11A);
+		ieee80211_add_channel_list_5ghz(chans, maxchans, nchans,
+		    rt2560_chan_5ghz, nitems(rt2560_chan_5ghz), bands, 0);
+	}
+}
+
+static void
 rt2560_set_channel(struct ieee80211com *ic)
 {
 	struct rt2560_softc *sc = ic->ic_softc;

Modified: head/sys/dev/ral/rt2661.c
==============================================================================
--- head/sys/dev/ral/rt2661.c	Thu May 26 15:56:27 2016	(r300751)
+++ head/sys/dev/ral/rt2661.c	Thu May 26 16:05:19 2016	(r300752)
@@ -113,6 +113,8 @@ static void		rt2661_mcu_wakeup(struct rt
 static void		rt2661_mcu_cmd_intr(struct rt2661_softc *);
 static void		rt2661_scan_start(struct ieee80211com *);
 static void		rt2661_scan_end(struct ieee80211com *);
+static void		rt2661_getradiocaps(struct ieee80211com *, int, int *,
+			    struct ieee80211_channel[]);
 static void		rt2661_set_channel(struct ieee80211com *);
 static void		rt2661_setup_tx_desc(struct rt2661_softc *,
 			    struct rt2661_tx_desc *, uint32_t, uint16_t, int,
@@ -193,13 +195,19 @@ static const struct rfprog {
 	RT2661_RF5225_2
 };
 
+static const uint8_t rt2661_chan_2ghz[] =
+	{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
+static const uint8_t rt2661_chan_5ghz[] =
+	{ 36, 40, 44, 48, 52, 56, 60, 64,
+	  100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
+	  149, 153, 157, 161, 165 };
+
 int
 rt2661_attach(device_t dev, int id)
 {
 	struct rt2661_softc *sc = device_get_softc(dev);
 	struct ieee80211com *ic = &sc->sc_ic;
 	uint32_t val;
-	uint8_t bands[IEEE80211_MODE_BYTES];
 	int error, ac, ntries;
 
 	sc->sc_id = id;
@@ -279,12 +287,8 @@ rt2661_attach(device_t dev, int id)
 #endif
 		;
 
-	memset(bands, 0, sizeof(bands));
-	setbit(bands, IEEE80211_MODE_11B);
-	setbit(bands, IEEE80211_MODE_11G);
-	if (sc->rf_rev == RT2661_RF_5225 || sc->rf_rev == RT2661_RF_5325) 
-		setbit(bands, IEEE80211_MODE_11A);
-	ieee80211_init_channels(ic, NULL, bands);
+	rt2661_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
+	    ic->ic_channels);
 
 	ieee80211_ifattach(ic);
 #if 0
@@ -2762,6 +2766,26 @@ rt2661_scan_end(struct ieee80211com *ic)
 }
 
 static void
+rt2661_getradiocaps(struct ieee80211com *ic,
+    int maxchans, int *nchans, struct ieee80211_channel chans[])
+{
+	struct rt2661_softc *sc = ic->ic_softc;
+	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,
+	    rt2661_chan_2ghz, nitems(rt2661_chan_2ghz), bands, 0);
+
+	if (sc->rf_rev == RT2661_RF_5225 || sc->rf_rev == RT2661_RF_5325) {
+		setbit(bands, IEEE80211_MODE_11A);
+		ieee80211_add_channel_list_5ghz(chans, maxchans, nchans,
+		    rt2661_chan_5ghz, nitems(rt2661_chan_5ghz), bands, 0);
+	}
+}
+
+static void
 rt2661_set_channel(struct ieee80211com *ic)
 {
 	struct rt2661_softc *sc = ic->ic_softc;

Modified: head/sys/dev/ral/rt2860.c
==============================================================================
--- head/sys/dev/ral/rt2860.c	Thu May 26 15:56:27 2016	(r300751)
+++ head/sys/dev/ral/rt2860.c	Thu May 26 16:05:19 2016	(r300752)
@@ -138,6 +138,8 @@ static void	rt2860_set_basicrates(struct
 		    const struct ieee80211_rateset *);
 static void	rt2860_scan_start(struct ieee80211com *);
 static void	rt2860_scan_end(struct ieee80211com *);
+static void	rt2860_getradiocaps(struct ieee80211com *, int, int *,
+		    struct ieee80211_channel[]);
 static void	rt2860_set_channel(struct ieee80211com *);
 static void	rt2860_select_chan_group(struct rt2860_softc *, int);
 static void	rt2860_set_chan(struct rt2860_softc *, u_int);
@@ -226,13 +228,19 @@ static const struct {
 	RT5392_DEF_RF
 };
 
+static const uint8_t rt2860_chan_2ghz[] =
+	{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
+static const uint8_t rt2860_chan_5ghz[] =
+	{ 36, 38, 40, 44, 46, 48, 52, 54, 56, 60, 62, 64, 100, 102, 104,
+	  108, 110, 112, 116, 118, 120, 124, 126, 128, 132, 134, 136, 140,
+	  149, 151, 153, 157, 159, 161, 165, 167, 169, 171, 173 };
+
 int
 rt2860_attach(device_t dev, int id)
 {
 	struct rt2860_softc *sc = device_get_softc(dev);
 	struct ieee80211com *ic = &sc->sc_ic;
 	uint32_t tmp;
-	uint8_t bands[IEEE80211_MODE_BYTES];
 	int error, ntries, qid;
 
 	sc->sc_dev = dev;
@@ -319,18 +327,15 @@ rt2860_attach(device_t dev, int id)
 		| IEEE80211_C_WME		/* 802.11e */
 		;
 
-	memset(bands, 0, sizeof(bands));
-	setbit(bands, IEEE80211_MODE_11B);
-	setbit(bands, IEEE80211_MODE_11G);
-	if (sc->rf_rev == RT2860_RF_2750 || sc->rf_rev == RT2860_RF_2850)
-		setbit(bands, IEEE80211_MODE_11A);
-	ieee80211_init_channels(ic, NULL, bands);
+	rt2860_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
+	    ic->ic_channels);
 
 	ieee80211_ifattach(ic);
 
 	ic->ic_wme.wme_update = rt2860_updateedca;
 	ic->ic_scan_start = rt2860_scan_start;
 	ic->ic_scan_end = rt2860_scan_end;
+	ic->ic_getradiocaps = rt2860_getradiocaps;
 	ic->ic_set_channel = rt2860_set_channel;
 	ic->ic_updateslot = rt2860_updateslot;
 	ic->ic_update_promisc = rt2860_update_promisc;
@@ -2299,6 +2304,26 @@ rt2860_scan_end(struct ieee80211com *ic)
 }
 
 static void
+rt2860_getradiocaps(struct ieee80211com *ic, int maxchans, int *nchans,
+    struct ieee80211_channel chans[])
+{
+	struct rt2860_softc *sc = ic->ic_softc;
+	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,
+	    rt2860_chan_2ghz, nitems(rt2860_chan_2ghz), bands, 0);
+
+	if (sc->rf_rev == RT2860_RF_2750 || sc->rf_rev == RT2860_RF_2850) {
+		setbit(bands, IEEE80211_MODE_11A);
+		ieee80211_add_channel_list_5ghz(chans, maxchans, nchans,
+		    rt2860_chan_5ghz, nitems(rt2860_chan_5ghz), bands, 0);
+	}
+}
+
+static void
 rt2860_set_channel(struct ieee80211com *ic)
 {
 	struct rt2860_softc *sc = ic->ic_softc;


More information about the svn-src-head mailing list