From owner-svn-src-all@FreeBSD.ORG Tue Jun 23 14:37:07 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E783D1065672; Tue, 23 Jun 2009 14:37:07 +0000 (UTC) (envelope-from cokane@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D59698FC28; Tue, 23 Jun 2009 14:37:07 +0000 (UTC) (envelope-from cokane@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5NEb7fT078874; Tue, 23 Jun 2009 14:37:07 GMT (envelope-from cokane@svn.freebsd.org) Received: (from cokane@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5NEb7tO078872; Tue, 23 Jun 2009 14:37:07 GMT (envelope-from cokane@svn.freebsd.org) Message-Id: <200906231437.n5NEb7tO078872@svn.freebsd.org> From: Coleman Kane Date: Tue, 23 Jun 2009 14:37:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194706 - head/sys/dev/if_ndis X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jun 2009 14:37:08 -0000 Author: cokane Date: Tue Jun 23 14:37:07 2009 New Revision: 194706 URL: http://svn.freebsd.org/changeset/base/194706 Log: Code cleanup by moving some repetitive code into an ndis_get_bssid_list helper function. Also, add ieee80211_announce() call for bootverbose case. Submitted by: Paul B. Mahol Modified: head/sys/dev/if_ndis/if_ndis.c Modified: head/sys/dev/if_ndis/if_ndis.c ============================================================================== --- head/sys/dev/if_ndis/if_ndis.c Tue Jun 23 14:12:49 2009 (r194705) +++ head/sys/dev/if_ndis/if_ndis.c Tue Jun 23 14:37:07 2009 (r194706) @@ -183,6 +183,8 @@ static void ndis_init (void *); static void ndis_stop (struct ndis_softc *); static int ndis_ifmedia_upd (struct ifnet *); static void ndis_ifmedia_sts (struct ifnet *, struct ifmediareq *); +static int ndis_get_bssid_list (struct ndis_softc *, + ndis_80211_bssid_list_ex **); static int ndis_get_assoc (struct ndis_softc *, ndis_wlan_bssid_ex **); static int ndis_probe_offload (struct ndis_softc *); static int ndis_set_offload (struct ndis_softc *); @@ -943,6 +945,9 @@ got_crypto: ic->ic_update_mcast = ndis_update_mcast; ic->ic_update_promisc = ndis_update_promisc; + if (bootverbose) + ieee80211_announce(ic); + } else { ifmedia_init(&sc->ifmedia, IFM_IMASK, ndis_ifmedia_upd, ndis_ifmedia_sts); @@ -2621,6 +2626,36 @@ ndis_auth_and_assoc(sc, vap) } static int +ndis_get_bssid_list(sc, bl) + struct ndis_softc *sc; + ndis_80211_bssid_list_ex **bl; +{ + int len, error; + + len = sizeof(uint32_t) + (sizeof(ndis_wlan_bssid_ex) * 16); + *bl = malloc(len, M_DEVBUF, M_NOWAIT | M_ZERO); + if (*bl == NULL) + return (ENOMEM); + + error = ndis_get_info(sc, OID_802_11_BSSID_LIST, *bl, &len); + if (error == ENOSPC) { + free(*bl, M_DEVBUF); + *bl = malloc(len, M_DEVBUF, M_NOWAIT | M_ZERO); + if (*bl == NULL) + return (ENOMEM); + + error = ndis_get_info(sc, OID_802_11_BSSID_LIST, *bl, &len); + } + if (error) { + DPRINTF(("%s: failed to read\n", __func__)); + free(*bl, M_DEVBUF); + return (error); + } + + return (0); +} + +static int ndis_get_assoc(sc, assoc) struct ndis_softc *sc; ndis_wlan_bssid_ex **assoc; @@ -2647,25 +2682,9 @@ ndis_get_assoc(sc, assoc) vap = TAILQ_FIRST(&ic->ic_vaps); ni = vap->iv_bss; - len = sizeof(uint32_t) + (sizeof(ndis_wlan_bssid_ex) * 16); - bl = malloc(len, M_TEMP, M_NOWAIT | M_ZERO); - if (bl == NULL) - return (ENOMEM); - - error = ndis_get_info(sc, OID_802_11_BSSID_LIST, bl, &len); - if (error == ENOSPC) { - free(bl, M_TEMP); - bl = malloc(len, M_TEMP, M_NOWAIT | M_ZERO); - if (bl == NULL) - return (ENOMEM); - - error = ndis_get_info(sc, OID_802_11_BSSID_LIST, bl, &len); - } - if (error) { - free(bl, M_TEMP); - device_printf(sc->ndis_dev, "bssid_list failed\n"); + error = ndis_get_bssid_list(sc, &bl); + if (error) return (error); - } bs = (ndis_wlan_bssid_ex *)&bl->nblx_bssid[0]; for (i = 0; i < bl->nblx_items; i++) { @@ -3281,7 +3300,7 @@ ndis_scan_results(struct ndis_softc *sc) struct ieee80211_frame wh; struct ieee80211_channel *saved_chan; int i, j; - int error, len, rssi, noise, freq, chanflag; + int rssi, noise, freq, chanflag; uint8_t ssid[2+IEEE80211_NWID_LEN]; uint8_t rates[2+IEEE80211_RATE_MAXSIZE]; uint8_t *frm, *efrm; @@ -3291,26 +3310,9 @@ ndis_scan_results(struct ndis_softc *sc) saved_chan = ic->ic_curchan; noise = -96; - len = sizeof(uint32_t) + (sizeof(ndis_wlan_bssid_ex) * 16); - bl = malloc(len, M_DEVBUF, M_NOWAIT | M_ZERO); - if (bl == NULL) + if (ndis_get_bssid_list(sc, &bl)) return; - error = ndis_get_info(sc, OID_802_11_BSSID_LIST, bl, &len); - if (error == ENOSPC) { - free(bl, M_DEVBUF); - bl = malloc(len, M_DEVBUF, M_NOWAIT | M_ZERO); - if (bl == NULL) - return; - - error = ndis_get_info(sc, OID_802_11_BSSID_LIST, bl, &len); - } - if (error) { - DPRINTF(("%s: failed to read\n", __func__)); - free(bl, M_DEVBUF); - return;; - } - DPRINTF(("%s: %d results\n", __func__, bl->nblx_items)); wb = &bl->nblx_bssid[0]; for (i = 0; i < bl->nblx_items; i++) {