Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 May 2016 16:15:10 +0000 (UTC)
From:      Andriy Voskoboinyk <avos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300753 - head/sys/dev/usb/wlan
Message-ID:  <201605261615.u4QGFAfA014609@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avos
Date: Thu May 26 16:15:10 2016
New Revision: 300753
URL: https://svnweb.freebsd.org/changeset/base/300753

Log:
  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.

Modified:
  head/sys/dev/usb/wlan/if_urtw.c
  head/sys/dev/usb/wlan/if_urtwreg.h

Modified: head/sys/dev/usb/wlan/if_urtw.c
==============================================================================
--- head/sys/dev/usb/wlan/if_urtw.c	Thu May 26 16:05:19 2016	(r300752)
+++ head/sys/dev/usb/wlan/if_urtw.c	Thu May 26 16:15:10 2016	(r300753)
@@ -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 ieee802
 			    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;

Modified: head/sys/dev/usb/wlan/if_urtwreg.h
==============================================================================
--- head/sys/dev/usb/wlan/if_urtwreg.h	Thu May 26 16:05:19 2016	(r300752)
+++ head/sys/dev/usb/wlan/if_urtwreg.h	Thu May 26 16:15:10 2016	(r300753)
@@ -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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605261615.u4QGFAfA014609>