Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 May 2016 16:48:20 +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: r300755 - head/sys/dev/bwi
Message-ID:  <201605261648.u4QGmKZ2026149@repo.freebsd.org>

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

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

Modified:
  head/sys/dev/bwi/if_bwi.c

Modified: head/sys/dev/bwi/if_bwi.c
==============================================================================
--- head/sys/dev/bwi/if_bwi.c	Thu May 26 16:39:11 2016	(r300754)
+++ head/sys/dev/bwi/if_bwi.c	Thu May 26 16:48:20 2016	(r300755)
@@ -110,6 +110,8 @@ static int	bwi_raw_xmit(struct ieee80211
 			const struct ieee80211_bpf_params *);
 static void	bwi_watchdog(void *);
 static void	bwi_scan_start(struct ieee80211com *);
+static void	bwi_getradiocaps(struct ieee80211com *, int, int *,
+		    struct ieee80211_channel[]);
 static void	bwi_set_channel(struct ieee80211com *);
 static void	bwi_scan_end(struct ieee80211com *);
 static int	bwi_newstate(struct ieee80211vap *, enum ieee80211_state, int);
@@ -303,6 +305,9 @@ static const struct {
 	[108]	= { 7, 3 }
 };
 
+static const uint8_t bwi_chan_2ghz[] =
+	{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
+
 #ifdef BWI_DEBUG
 #ifdef BWI_DEBUG_VERBOSE
 static uint32_t bwi_debug = BWI_DBG_ATTACH | BWI_DBG_INIT | BWI_DBG_TXPOWER;
@@ -356,7 +361,6 @@ bwi_attach(struct bwi_softc *sc)
 	device_t dev = sc->sc_dev;
 	struct bwi_mac *mac;
 	struct bwi_phy *phy;
-	uint8_t bands[IEEE80211_MODE_BYTES];
 	int i, error;
 
 	BWI_LOCK_INIT(sc);
@@ -453,15 +457,12 @@ bwi_attach(struct bwi_softc *sc)
 	/*
 	 * Setup ratesets, phytype, channels and get MAC address
 	 */
-	memset(bands, 0, sizeof(bands));
 	if (phy->phy_mode == IEEE80211_MODE_11B ||
 	    phy->phy_mode == IEEE80211_MODE_11G) {
-		setbit(bands, IEEE80211_MODE_11B);
 		if (phy->phy_mode == IEEE80211_MODE_11B) {
 			ic->ic_phytype = IEEE80211_T_DS;
 		} else {
 			ic->ic_phytype = IEEE80211_T_OFDM;
-			setbit(bands, IEEE80211_MODE_11G);
 		}
 
 		bwi_get_eaddr(sc, BWI_SPROM_11BG_EADDR, ic->ic_macaddr);
@@ -475,7 +476,6 @@ bwi_attach(struct bwi_softc *sc)
 		}
 	} else if (phy->phy_mode == IEEE80211_MODE_11A) {
 		/* TODO:11A */
-		setbit(bands, IEEE80211_MODE_11A);
 		error = ENXIO;
 		goto fail;
 	} else {
@@ -487,7 +487,8 @@ bwi_attach(struct bwi_softc *sc)
 				   BWI_SPROM_CARD_INFO_LOCALE);
 	DPRINTF(sc, BWI_DBG_ATTACH, "locale: %d\n", sc->sc_locale);
 	/* XXX use locale */
-	ieee80211_init_channels(ic, NULL, bands);
+	bwi_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
+	    ic->ic_channels);
 
 	ic->ic_softc = sc;
 	ic->ic_name = device_get_nameunit(dev);
@@ -509,6 +510,7 @@ bwi_attach(struct bwi_softc *sc)
 	ic->ic_updateslot = bwi_updateslot;
 	ic->ic_scan_start = bwi_scan_start;
 	ic->ic_scan_end = bwi_scan_end;
+	ic->ic_getradiocaps = bwi_getradiocaps;
 	ic->ic_set_channel = bwi_set_channel;
 	ic->ic_transmit = bwi_transmit;
 	ic->ic_parent = bwi_parent;
@@ -1676,6 +1678,43 @@ bwi_scan_start(struct ieee80211com *ic)
 }
 
 static void
+bwi_getradiocaps(struct ieee80211com *ic,
+    int maxchans, int *nchans, struct ieee80211_channel chans[])
+{
+	struct bwi_softc *sc = ic->ic_softc;
+	struct bwi_mac *mac;
+	struct bwi_phy *phy;
+	uint8_t bands[IEEE80211_MODE_BYTES];
+
+	/*
+	 * XXX First MAC is known to exist
+	 * TODO2
+	 */
+	mac = &sc->sc_mac[0];
+	phy = &mac->mac_phy;
+
+	memset(bands, 0, sizeof(bands));
+	switch (phy->phy_mode) {
+	case IEEE80211_MODE_11G:
+		setbit(bands, IEEE80211_MODE_11G);
+		/* FALLTHROUGH */
+	case IEEE80211_MODE_11B:
+		setbit(bands, IEEE80211_MODE_11B);
+		break;
+	case IEEE80211_MODE_11A:
+		/* TODO:11A */
+		setbit(bands, IEEE80211_MODE_11A);
+		device_printf(sc->sc_dev, "no 11a support\n");
+		return;
+	default:
+		panic("unknown phymode %d\n", phy->phy_mode);
+	}
+
+	ieee80211_add_channel_list_2ghz(chans, maxchans, nchans,
+	    bwi_chan_2ghz, nitems(bwi_chan_2ghz), bands, 0);
+}
+
+static void
 bwi_set_channel(struct ieee80211com *ic)
 {
 	struct bwi_softc *sc = ic->ic_softc;



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