From owner-svn-src-stable-8@FreeBSD.ORG Fri Nov 19 01:28:22 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7CFB1106566C; Fri, 19 Nov 2010 01:28:22 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5644B8FC1E; Fri, 19 Nov 2010 01:28:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oAJ1SMkO051618; Fri, 19 Nov 2010 01:28:22 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oAJ1SMIK051615; Fri, 19 Nov 2010 01:28:22 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <201011190128.oAJ1SMIK051615@svn.freebsd.org> From: Andrew Thompson Date: Fri, 19 Nov 2010 01:28:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r215481 - stable/8/sys/dev/usb/wlan X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2010 01:28:22 -0000 Author: thompsa Date: Fri Nov 19 01:28:22 2010 New Revision: 215481 URL: http://svn.freebsd.org/changeset/base/215481 Log: MFC r209144 - Because hostapd calls iv_key_set() before if_init(), make sure key_set callback function will be executed, and that the key won't be deleted during the init process. - txmic and rxmic are written into the chip the same place regardless of opmode. - Make the hardware generate 802.11 sequence numbers. Submitted by: Akinori Furukoshi Modified: stable/8/sys/dev/usb/wlan/if_run.c stable/8/sys/dev/usb/wlan/if_runvar.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/usb/wlan/if_run.c ============================================================================== --- stable/8/sys/dev/usb/wlan/if_run.c Fri Nov 19 01:27:21 2010 (r215480) +++ stable/8/sys/dev/usb/wlan/if_run.c Fri Nov 19 01:28:22 2010 (r215481) @@ -718,6 +718,10 @@ run_detach(device_t self) usbd_transfer_unsetup(sc->sc_xfer, RUN_N_XFER); RUN_LOCK(sc); + + sc->ratectl_run = RUN_RATECTL_OFF; + sc->cmdq_run = sc->cmdq_key_set = RUN_CMDQ_ABORT; + /* free TX list, if any */ for (i = 0; i != RUN_EP_QUEUES; i++) run_unsetup_tx_list(sc, &sc->sc_epq[i]); @@ -827,6 +831,9 @@ run_vap_create(struct ieee80211com *ic, if(sc->rvp_cnt++ == 0) ic->ic_opmode = opmode; + if(opmode == IEEE80211_M_HOSTAP) + sc->cmdq_run = RUN_CMDQ_GO; + DPRINTF("rvp_id=%d bmap=%x rvp_cnt=%d\n", rvp->rvp_id, sc->rvp_bmap, sc->rvp_cnt); @@ -1952,19 +1959,14 @@ run_key_set_cb(void *arg) struct ieee80211_node *ni; uint32_t attr; uint16_t base, associd; - uint8_t mode, wcid, txmic, rxmic, iv[8]; + uint8_t mode, wcid, iv[8]; RUN_LOCK_ASSERT(sc, MA_OWNED); - if(vap->iv_opmode == IEEE80211_M_HOSTAP){ + if(vap->iv_opmode == IEEE80211_M_HOSTAP) ni = ieee80211_find_vap_node(&ic->ic_sta, vap, cmdq->mac); - txmic = 24; - rxmic = 16; - } else { + else ni = vap->iv_bss; - txmic = 16; - rxmic = 24; - } associd = (ni != NULL) ? ni->ni_associd : 0; /* map net80211 cipher to RT2860 security mode */ @@ -2003,9 +2005,9 @@ run_key_set_cb(void *arg) if (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP) { if(run_write_region_1(sc, base, k->wk_key, 16)) return; - if(run_write_region_1(sc, base + 16, &k->wk_key[txmic], 8)) /* wk_txmic */ + if(run_write_region_1(sc, base + 16, &k->wk_key[16], 8)) /* wk_txmic */ return; - if(run_write_region_1(sc, base + 24, &k->wk_key[rxmic], 8)) /* wk_rxmic */ + if(run_write_region_1(sc, base + 24, &k->wk_key[24], 8)) /* wk_rxmic */ return; } else { /* roundup len to 16-bit: XXX fix write_region_1() instead */ @@ -2086,6 +2088,16 @@ run_key_set(struct ieee80211vap *vap, st IEEE80211_ADDR_COPY(sc->cmdq[i].mac, mac); ieee80211_runtask(ic, &sc->cmdq_task); + /* + * To make sure key will be set when hostapd + * calls iv_key_set() before if_init(). + */ + if(vap->iv_opmode == IEEE80211_M_HOSTAP){ + RUN_LOCK(sc); + sc->cmdq_key_set = RUN_CMDQ_GO; + RUN_UNLOCK(sc); + } + return(1); } @@ -2896,6 +2908,9 @@ run_set_tx_desc(struct run_softc *sc, st txwi->txop |= RT2860_TX_TXOP_HT; else txwi->txop |= RT2860_TX_TXOP_BACKOFF; + + if(vap->iv_opmode != IEEE80211_M_STA && !IEEE80211_QOS_HAS_SEQ(wh)) + txwi->xflags |= RT2860_TX_NSEQ; } /* This function must be called locked */ @@ -2975,7 +2990,7 @@ run_tx(struct run_softc *sc, struct mbuf if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && (!hasqos || (qos & IEEE80211_QOS_ACKPOLICY) != IEEE80211_QOS_ACKPOLICY_NOACK)) { - xflags = RT2860_TX_ACK; + xflags |= RT2860_TX_ACK; if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) dur = rt2860_rates[ctl_ridx].sp_ack_dur; else @@ -2997,8 +3012,8 @@ run_tx(struct run_softc *sc, struct mbuf txd->flags = qflags; txwi = (struct rt2860_txwi *)(txd + 1); txwi->xflags = xflags; - txwi->wcid = (type == IEEE80211_FC0_TYPE_DATA) ? - RUN_AID2WCID(ni->ni_associd) : 0xff; + txwi->wcid = IEEE80211_IS_MULTICAST(wh->i_addr1) ? + 0 : RUN_AID2WCID(ni->ni_associd); /* clear leftover garbage bits */ txwi->flags = 0; txwi->txop = 0; @@ -3921,6 +3936,7 @@ run_update_beacon_cb(void *arg) txwi.phy |= htole16(RT2860_PHY_OFDM); txwi.txop = RT2860_TX_TXOP_HT; txwi.flags = RT2860_TX_TS; + txwi.xflags = RT2860_TX_NSEQ; run_write_region_1(sc, RT2860_BCN_BASE(RUN_VAP(vap)->rvp_id), (uint8_t *)&txwi, sizeof txwi); @@ -4668,10 +4684,14 @@ run_init_locked(struct run_softc *sc) run_set_region_4(sc, RT2860_WCID_ENTRY(0), 0, 512); /* clear WCID attribute table */ run_set_region_4(sc, RT2860_WCID_ATTR(0), 0, 8 * 32); - /* clear shared key table */ - run_set_region_4(sc, RT2860_SKEY(0, 0), 0, 8 * 32); - /* clear shared key mode */ - run_set_region_4(sc, RT2860_SKEY_MODE_0_7, 0, 4); + + /* hostapd sets a key before init. So, don't clear it. */ + if(sc->cmdq_key_set != RUN_CMDQ_GO){ + /* clear shared key table */ + run_set_region_4(sc, RT2860_SKEY(0, 0), 0, 8 * 32); + /* clear shared key mode */ + run_set_region_4(sc, RT2860_SKEY_MODE_0_7, 0, 4); + } run_read(sc, RT2860_US_CYC_CNT, &tmp); tmp = (tmp & ~0xff) | 0x1e; @@ -4779,7 +4799,7 @@ run_stop(void *arg) ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); sc->ratectl_run = RUN_RATECTL_OFF; - sc->cmdq_run = RUN_CMDQ_ABORT; + sc->cmdq_run = sc->cmdq_key_set; RUN_UNLOCK(sc); Modified: stable/8/sys/dev/usb/wlan/if_runvar.h ============================================================================== --- stable/8/sys/dev/usb/wlan/if_runvar.h Fri Nov 19 01:27:21 2010 (r215480) +++ stable/8/sys/dev/usb/wlan/if_runvar.h Fri Nov 19 01:28:22 2010 (r215481) @@ -218,6 +218,7 @@ struct run_softc { uint32_t cmdq_store; uint8_t cmdq_exec; uint8_t cmdq_run; + uint8_t cmdq_key_set; #define RUN_CMDQ_ABORT 0 #define RUN_CMDQ_GO 1