From owner-svn-src-all@freebsd.org Tue Mar 7 07:49:27 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D791CFBF5C; Tue, 7 Mar 2017 07:49:27 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0554D1870; Tue, 7 Mar 2017 07:49:26 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v277nQPY024888; Tue, 7 Mar 2017 07:49:26 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v277nQnu024887; Tue, 7 Mar 2017 07:49:26 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201703070749.v277nQnu024887@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Tue, 7 Mar 2017 07:49:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314839 - head/sys/dev/iwn X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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, 07 Mar 2017 07:49:27 -0000 Author: avos Date: Tue Mar 7 07:49:25 2017 New Revision: 314839 URL: https://svnweb.freebsd.org/changeset/base/314839 Log: iwn: deduplicate (RXON + txpower + broadcast node) command sequence. Was previously applied to wpi(4) as a part of r278366. Tested with Intel 6205, STA / MONITOR modes. Modified: head/sys/dev/iwn/if_iwn.c Modified: head/sys/dev/iwn/if_iwn.c ============================================================================== --- head/sys/dev/iwn/if_iwn.c Tue Mar 7 06:46:38 2017 (r314838) +++ head/sys/dev/iwn/if_iwn.c Tue Mar 7 07:49:25 2017 (r314839) @@ -278,6 +278,7 @@ static int iwn_set_pslevel(struct iwn_so static int iwn_send_btcoex(struct iwn_softc *); static int iwn_send_advanced_btcoex(struct iwn_softc *); static int iwn5000_runtime_calib(struct iwn_softc *); +static int iwn_send_rxon(struct iwn_softc *, int, int); static int iwn_config(struct iwn_softc *); static int iwn_scan(struct iwn_softc *, struct ieee80211vap *, struct ieee80211_scan_state *, struct ieee80211_channel *); @@ -6534,9 +6535,49 @@ iwn_get_rxon_ht_flags(struct iwn_softc * } static int -iwn_config(struct iwn_softc *sc) +iwn_send_rxon(struct iwn_softc *sc, int assoc, int async) { struct iwn_ops *ops = &sc->ops; + int error; + + IWN_LOCK_ASSERT(sc); + + if (sc->sc_is_scanning) + device_printf(sc->sc_dev, + "%s: is_scanning set, before RXON\n", + __func__); + error = iwn_cmd(sc, IWN_CMD_RXON, sc->rxon, sc->rxonsz, async); + if (error != 0) { + device_printf(sc->sc_dev, "%s: RXON command failed\n", + __func__); + return (error); + } + + /* + * Reconfiguring RXON clears the firmware nodes table so we must + * add the broadcast node again. + */ + if ((sc->rxon->filter & htole32(IWN_FILTER_BSS)) == 0) { + if ((error = iwn_add_broadcast_node(sc, async)) != 0) { + device_printf(sc->sc_dev, + "%s: could not add broadcast node\n", __func__); + return (error); + } + } + + /* Configuration has changed, set TX power accordingly. */ + if ((error = ops->set_txpower(sc, async)) != 0) { + device_printf(sc->sc_dev, "%s: could not set TX power\n", + __func__); + return (error); + } + + return (0); +} + +static int +iwn_config(struct iwn_softc *sc) +{ struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); const uint8_t *macaddr; @@ -6671,26 +6712,8 @@ iwn_config(struct iwn_softc *sc) DPRINTF(sc, IWN_DEBUG_RESET, "%s: setting configuration; flags=0x%08x\n", __func__, le32toh(sc->rxon->flags)); - if (sc->sc_is_scanning) - device_printf(sc->sc_dev, - "%s: is_scanning set, before RXON\n", - __func__); - error = iwn_cmd(sc, IWN_CMD_RXON, sc->rxon, sc->rxonsz, 0); - if (error != 0) { - device_printf(sc->sc_dev, "%s: RXON command failed\n", - __func__); - return error; - } - - if ((error = iwn_add_broadcast_node(sc, 0)) != 0) { - device_printf(sc->sc_dev, "%s: could not add broadcast node\n", - __func__); - return error; - } - - /* Configuration has changed, set TX power accordingly. */ - if ((error = ops->set_txpower(sc, 0)) != 0) { - device_printf(sc->sc_dev, "%s: could not set TX power\n", + if ((error = iwn_send_rxon(sc, 0, 0)) != 0) { + device_printf(sc->sc_dev, "%s: could not send RXON\n", __func__); return error; } @@ -7044,7 +7067,6 @@ iwn_scan(struct iwn_softc *sc, struct ie static int iwn_auth(struct iwn_softc *sc, struct ieee80211vap *vap) { - struct iwn_ops *ops = &sc->ops; struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_node *ni = vap->iv_bss; int error; @@ -7080,37 +7102,16 @@ iwn_auth(struct iwn_softc *sc, struct ie DPRINTF(sc, IWN_DEBUG_STATE, "rxon chan %d flags %x cck %x ofdm %x\n", sc->rxon->chan, sc->rxon->flags, sc->rxon->cck_mask, sc->rxon->ofdm_mask); - if (sc->sc_is_scanning) - device_printf(sc->sc_dev, - "%s: is_scanning set, before RXON\n", - __func__); - error = iwn_cmd(sc, IWN_CMD_RXON, sc->rxon, sc->rxonsz, 1); - if (error != 0) { - device_printf(sc->sc_dev, "%s: RXON command failed, error %d\n", - __func__, error); - return error; - } - /* Configuration has changed, set TX power accordingly. */ - if ((error = ops->set_txpower(sc, 1)) != 0) { - device_printf(sc->sc_dev, - "%s: could not set TX power, error %d\n", __func__, error); - return error; - } - /* - * Reconfiguring RXON clears the firmware nodes table so we must - * add the broadcast node again. - */ - if ((error = iwn_add_broadcast_node(sc, 1)) != 0) { - device_printf(sc->sc_dev, - "%s: could not add broadcast node, error %d\n", __func__, - error); - return error; + if ((error = iwn_send_rxon(sc, 0, 1)) != 0) { + device_printf(sc->sc_dev, "%s: could not send RXON\n", + __func__); + return (error); } DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); - return 0; + return (0); } static int @@ -7163,22 +7164,10 @@ iwn_run(struct iwn_softc *sc, struct iee sc->rxon->filter |= htole32(IWN_FILTER_BSS); DPRINTF(sc, IWN_DEBUG_STATE, "rxon chan %d flags %x, curhtprotmode=%d\n", sc->rxon->chan, le32toh(sc->rxon->flags), ic->ic_curhtprotmode); - if (sc->sc_is_scanning) - device_printf(sc->sc_dev, - "%s: is_scanning set, before RXON\n", - __func__); - error = iwn_cmd(sc, IWN_CMD_RXON, sc->rxon, sc->rxonsz, 1); - if (error != 0) { - device_printf(sc->sc_dev, - "%s: could not update configuration, error %d\n", __func__, - error); - return error; - } - /* Configuration has changed, set TX power accordingly. */ - if ((error = ops->set_txpower(sc, 1)) != 0) { - device_printf(sc->sc_dev, - "%s: could not set TX power, error %d\n", __func__, error); + if ((error = iwn_send_rxon(sc, 0, 1)) != 0) { + device_printf(sc->sc_dev, "%s: could not send RXON\n", + __func__); return error; }