From owner-svn-src-all@freebsd.org Wed Nov 11 21:48:08 2015 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 0A2B7A2C679; Wed, 11 Nov 2015 21:48:08 +0000 (UTC) (envelope-from andriyvos@gmail.com) Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8F9A11FAC; Wed, 11 Nov 2015 21:48:07 +0000 (UTC) (envelope-from andriyvos@gmail.com) Received: by wmww144 with SMTP id w144so176779906wmw.1; Wed, 11 Nov 2015 13:48:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=content-type:to:subject:references:date:cc:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=JfASOosc6hbAjFtZcW4KyBzzFGdkAfYkL1nMgXzXftk=; b=YDz/HMyRYeIix50uPxv4NOzRTf1icMUFydDFvQbY6FZ4VK2h0DZ1KzOwPQlbDzXRLX cIdZqidiTPJboYnbSjmRql9woIleFngBm6ZLeDCwGvexdk1kIX/26tj232I5jHXko5EE Ts5e+UPPtUKhaPRSMz3c+cWrY14ZOZWMJiZVsnqKeNAmqKtw7LwN7qyq5cv62gqRD4Tc Smv69B0VulcpHXczVj+HFZWbnN4LgFwNZWpYxXa1IUCUwjaWfBcM9sQZIxYNa82sCEWY 9ZCtBZwZAh092CjXy2EjdZyEpXkHbqyLqEXCApqtbMvIF6kHkxOV7d6urdAAonL+B65a xRzg== X-Received: by 10.28.6.12 with SMTP id 12mr38633177wmg.99.1447278020762; Wed, 11 Nov 2015 13:40:20 -0800 (PST) Received: from localhost (host-176-37-109-22.la.net.ua. [176.37.109.22]) by smtp.gmail.com with ESMTPSA id y77sm27280843wme.15.2015.11.11.13.40.19 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 11 Nov 2015 13:40:20 -0800 (PST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Renato Botelho" Subject: Re: svn commit: r290651 - head/sys/dev/usb/wlan References: <201511101252.tAACqQrE033782@repo.freebsd.org> <2D6627A5-D455-424C-8A9E-0A18754CFE11@FreeBSD.org> Date: Wed, 11 Nov 2015 23:40:16 +0200 Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable From: "Andriy Voskoboinyk" Message-ID: In-Reply-To: User-Agent: Opera Mail/12.16 (FreeBSD) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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: Wed, 11 Nov 2015 21:48:08 -0000 Wed, 11 Nov 2015 11:54:58 +0200 =D0=B1=D1=83=D0=BB=D0=BE =D0=BD=D0=B0=D0= =BF=D0=B8=D1=81=D0=B0=D0=BD=D0=BE Renato Botelho = : >> On Nov 10, 2015, at 18:19, Renato Botelho wrote: >> >>> On Nov 10, 2015, at 10:52, Andriy Voskoboinyk wro= te: >>> >>> Author: avos >>> Date: Tue Nov 10 12:52:26 2015 >>> New Revision: 290651 >>> URL: https://svnweb.freebsd.org/changeset/base/290651 >>> >>> Log: >>> urtwn(4): add IBSS mode support >>> >>> Tested with RTL8188EU, IBSS and STA modes. >>> >>> Reviewed by: kevlo >>> Approved by: adrian (mentor) >>> Differential Revision: https://reviews.freebsd.org/D4038 >>> >>> Modified: >>> head/sys/dev/usb/wlan/if_urtwn.c >>> head/sys/dev/usb/wlan/if_urtwnvar.h >>> >>> Modified: head/sys/dev/usb/wlan/if_urtwn.c >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D >>> --- head/sys/dev/usb/wlan/if_urtwn.c Tue Nov 10 12:20:22 2015 (r2906= 50) >>> +++ head/sys/dev/usb/wlan/if_urtwn.c Tue Nov 10 12:52:26 2015 (r2906= 51) >>> @@ -228,10 +228,14 @@ static int urtwn_setup_beacon(struct ur >>> static void urtwn_update_beacon(struct ieee80211vap *, int); >>> static int urtwn_tx_beacon(struct urtwn_softc *sc, >>> struct urtwn_vap *); >>> +static void urtwn_tsf_task_adhoc(void *, int); >>> static void urtwn_tsf_sync_enable(struct urtwn_softc *, >>> struct ieee80211vap *); >>> static void urtwn_set_led(struct urtwn_softc *, int, int); >>> static void urtwn_set_mode(struct urtwn_softc *, uint8_t); >>> +static void urtwn_ibss_recv_mgmt(struct ieee80211_node *, >>> + struct mbuf *, int, >>> + const struct ieee80211_rx_stats *, int, int); >>> static int urtwn_newstate(struct ieee80211vap *, >>> enum ieee80211_state, int); >>> static void urtwn_watchdog(void *); >>> @@ -449,6 +453,7 @@ urtwn_attach(device_t self) >>> ic->ic_caps =3D >>> IEEE80211_C_STA /* station mode */ >>> | IEEE80211_C_MONITOR /* monitor mode */ >>> + | IEEE80211_C_IBSS /* adhoc mode */ >>> | IEEE80211_C_HOSTAP /* hostap mode */ >>> | IEEE80211_C_SHPREAMBLE /* short preamble supported */ >>> | IEEE80211_C_SHSLOT /* short slot time supported */ >>> @@ -592,13 +597,18 @@ urtwn_vap_create(struct ieee80211com *ic >>> return (NULL); >>> } >>> >>> - if (opmode =3D=3D IEEE80211_M_HOSTAP) >>> + if (opmode =3D=3D IEEE80211_M_HOSTAP || opmode =3D=3D IEEE80211_M_= IBSS) >>> urtwn_init_beacon(sc, uvp); >>> >>> /* override state transition machine */ >>> uvp->newstate =3D vap->iv_newstate; >>> vap->iv_newstate =3D urtwn_newstate; >>> vap->iv_update_beacon =3D urtwn_update_beacon; >>> + if (opmode =3D=3D IEEE80211_M_IBSS) { >>> + uvp->recv_mgmt =3D vap->iv_recv_mgmt; >>> + vap->iv_recv_mgmt =3D urtwn_ibss_recv_mgmt; >>> + TASK_INIT(&uvp->tsf_task_adhoc, 0, urtwn_tsf_task_adhoc, vap); >>> + } >>> >>> /* complete setup */ >>> ieee80211_vap_attach(vap, ieee80211_media_change, >>> @@ -610,13 +620,13 @@ urtwn_vap_create(struct ieee80211com *ic >>> static void >>> urtwn_vap_delete(struct ieee80211vap *vap) >>> { >>> + struct ieee80211com *ic =3D vap->iv_ic; >>> struct urtwn_vap *uvp =3D URTWN_VAP(vap); >>> - enum ieee80211_opmode opmode =3D vap->iv_opmode; >>> >>> - if (opmode =3D=3D IEEE80211_M_HOSTAP) { >>> - if (uvp->bcn_mbuf !=3D NULL) >>> - m_freem(uvp->bcn_mbuf); >>> - } >>> + if (uvp->bcn_mbuf !=3D NULL) >>> + m_freem(uvp->bcn_mbuf); >>> + if (vap->iv_opmode =3D=3D IEEE80211_M_IBSS) >>> + ieee80211_draintask(ic, &uvp->tsf_task_adhoc); >>> ieee80211_vap_detach(vap); >>> free(uvp, M_80211_VAP); >>> } >>> @@ -1611,8 +1621,50 @@ urtwn_tx_beacon(struct urtwn_softc *sc, >>> } >>> >>> static void >>> +urtwn_tsf_task_adhoc(void *arg, int pending) >>> +{ >>> + struct ieee80211vap *vap =3D arg; >>> + struct urtwn_softc *sc =3D vap->iv_ic->ic_softc; >>> + struct ieee80211_node *ni; >>> + uint32_t reg; >>> + >>> + URTWN_LOCK(sc); >>> + ni =3D ieee80211_ref_node(vap->iv_bss); >>> + reg =3D urtwn_read_1(sc, R92C_BCN_CTRL); >>> + >>> + /* Accept beacons with the same BSSID. */ >>> + urtwn_set_rx_bssid_all(sc, 0); >>> + >>> + /* Enable synchronization. */ >>> + reg &=3D ~R92C_BCN_CTRL_DIS_TSF_UDT0; >>> + urtwn_write_1(sc, R92C_BCN_CTRL, reg); >>> + >>> + /* Synchronize. */ >>> + usb_pause_mtx(&sc->sc_mtx, hz * ni->ni_intval * 5 / 1000); >>> + >>> + /* Disable synchronization. */ >>> + reg |=3D R92C_BCN_CTRL_DIS_TSF_UDT0; >>> + urtwn_write_1(sc, R92C_BCN_CTRL, reg); >>> + >>> + /* Remove beacon filter. */ >>> + urtwn_set_rx_bssid_all(sc, 1); >>> + >>> + /* Enable beaconing. */ >>> + urtwn_write_1(sc, R92C_MBID_NUM, >>> + urtwn_read_1(sc, R92C_MBID_NUM) | R92C_MBID_TXBCN_RPT0); >>> + reg |=3D R92C_BCN_CTRL_EN_BCN; >>> + >>> + urtwn_write_1(sc, R92C_BCN_CTRL, reg); >>> + ieee80211_free_node(ni); >>> + URTWN_UNLOCK(sc); >>> +} >>> + >>> +static void >>> urtwn_tsf_sync_enable(struct urtwn_softc *sc, struct ieee80211vap *v= ap) >>> { >>> + struct ieee80211com *ic =3D &sc->sc_ic; >>> + struct urtwn_vap *uvp =3D URTWN_VAP(vap); >>> + >>> /* Reset TSF. */ >>> urtwn_write_1(sc, R92C_DUAL_TSF_RST, R92C_DUAL_TSF_RST0); >>> >>> @@ -1623,6 +1675,9 @@ urtwn_tsf_sync_enable(struct urtwn_softc >>> urtwn_read_1(sc, R92C_BCN_CTRL) & >>> ~R92C_BCN_CTRL_DIS_TSF_UDT0); >>> break; >>> + case IEEE80211_M_IBSS: >>> + ieee80211_runtask(ic, &uvp->tsf_task_adhoc); >>> + break; >>> case IEEE80211_M_HOSTAP: >>> /* Enable beaconing. */ >>> urtwn_write_1(sc, R92C_MBID_NUM, >>> @@ -1674,6 +1729,37 @@ urtwn_set_mode(struct urtwn_softc *sc, u >>> urtwn_write_1(sc, R92C_MSR, reg); >>> } >>> >>> +static void >>> +urtwn_ibss_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m, int= = >>> subtype, >>> + const struct ieee80211_rx_stats *rxs, >>> + int rssi, int nf) >>> +{ >>> + struct ieee80211vap *vap =3D ni->ni_vap; >>> + struct urtwn_softc *sc =3D vap->iv_ic->ic_softc; >>> + struct urtwn_vap *uvp =3D URTWN_VAP(vap); >>> + uint64_t ni_tstamp, curr_tstamp; >>> + >>> + uvp->recv_mgmt(ni, m, subtype, rxs, rssi, nf); >>> + >>> + if (vap->iv_state =3D=3D IEEE80211_S_RUN && >>> + (subtype =3D=3D IEEE80211_FC0_SUBTYPE_BEACON || >>> + subtype =3D=3D IEEE80211_FC0_SUBTYPE_PROBE_RESP)) { >>> + ni_tstamp =3D le64toh(ni->ni_tstamp.tsf); >>> +#ifdef D3831 >>> + URTWN_LOCK(sc); >>> + urtwn_get_tsf(sc, &curr_tstamp); >>> + URTWN_UNLOCK(sc); >>> + curr_tstamp =3D le64toh(curr_tstamp); >>> + >>> + if (ni_tstamp >=3D curr_tstamp) >>> + (void) ieee80211_ibss_merge(ni); >>> +#else >>> + (void) sc; >>> + (void) curr_tstamp; >>> +#endif >>> + } >>> +} >>> + >>> static int >>> urtwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate= , = >>> int arg) >>> { >>> @@ -1757,6 +1843,9 @@ urtwn_newstate(struct ieee80211vap *vap, >>> case IEEE80211_M_STA: >>> mode =3D R92C_MSR_INFRA; >>> break; >>> + case IEEE80211_M_IBSS: >>> + mode =3D R92C_MSR_ADHOC; >>> + break; >>> case IEEE80211_M_HOSTAP: >>> mode =3D R92C_MSR_AP; >>> break; >>> @@ -1794,13 +1883,14 @@ urtwn_newstate(struct ieee80211vap *vap, >>> >>> if (vap->iv_opmode !=3D IEEE80211_M_HOSTAP) >>> reg |=3D R92C_RCR_CBSSID_DATA; >>> - >>> - reg |=3D R92C_RCR_CBSSID_BCN; >>> + if (vap->iv_opmode !=3D IEEE80211_M_IBSS) >>> + reg |=3D R92C_RCR_CBSSID_BCN; >>> >>> urtwn_write_4(sc, R92C_RCR, reg); >>> } >>> >>> - if (vap->iv_opmode =3D=3D IEEE80211_M_HOSTAP) { >>> + if (vap->iv_opmode =3D=3D IEEE80211_M_HOSTAP || >>> + vap->iv_opmode =3D=3D IEEE80211_M_IBSS) { >>> error =3D urtwn_setup_beacon(sc, ni); >>> if (error !=3D 0) { >>> device_printf(sc->sc_dev, >>> @@ -3007,6 +3097,7 @@ urtwn_rxfilter_init(struct urtwn_softc * >>> R92C_RXFLTMAP_SUBTYPE(IEEE80211_FC0_SUBTYPE_BEACON)); >>> break; >>> case IEEE80211_M_MONITOR: >>> + case IEEE80211_M_IBSS: >>> break; >>> default: >>> device_printf(sc->sc_dev, "%s: undefined opmode %d\n", >>> @@ -3335,7 +3426,9 @@ urtwn_scan_start(struct ieee80211com *ic >>> >>> URTWN_LOCK(sc); >>> /* Receive beacons / probe responses from any BSSID. */ >>> - urtwn_set_rx_bssid_all(sc, 1); >>> + if (ic->ic_opmode !=3D IEEE80211_M_IBSS) >>> + urtwn_set_rx_bssid_all(sc, 1); >>> + >>> /* Set gain for scanning. */ >>> urtwn_set_gain(sc, 0x20); >>> URTWN_UNLOCK(sc); >>> @@ -3348,8 +3441,9 @@ urtwn_scan_end(struct ieee80211com *ic) >>> >>> URTWN_LOCK(sc); >>> /* Restore limitations. */ >>> - if (ic->ic_promisc =3D=3D 0) >>> + if (ic->ic_promisc =3D=3D 0 && ic->ic_opmode !=3D IEEE80211_M_IBSS= ) >>> urtwn_set_rx_bssid_all(sc, 0); >>> + >>> /* Set gain under link. */ >>> urtwn_set_gain(sc, 0x32); >>> URTWN_UNLOCK(sc); >>> @@ -3393,6 +3487,9 @@ urtwn_set_promisc(struct urtwn_softc *sc >>> case IEEE80211_M_HOSTAP: >>> mask2 |=3D R92C_RCR_CBSSID_BCN; >>> break; >>> + case IEEE80211_M_IBSS: >>> + mask2 |=3D R92C_RCR_CBSSID_DATA; >>> + break; >>> default: >>> device_printf(sc->sc_dev, "%s: undefined opmode %d\n", >>> __func__, vap->iv_opmode); >>> >>> Modified: head/sys/dev/usb/wlan/if_urtwnvar.h >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D >>> --- head/sys/dev/usb/wlan/if_urtwnvar.h Tue Nov 10 12:20:22 = >>> 2015 (r290650) >>> +++ head/sys/dev/usb/wlan/if_urtwnvar.h Tue Nov 10 12:52:26 = >>> 2015 (r290651) >>> @@ -87,13 +87,18 @@ struct urtwn_fw_info { >>> }; >>> >>> struct urtwn_vap { >>> - struct ieee80211vap vap; >>> + struct ieee80211vap vap; >>> >>> - struct r92c_tx_desc bcn_desc; >>> - struct mbuf *bcn_mbuf; >>> - >>> - int (*newstate)(struct ieee80211vap *, >>> - enum ieee80211_state, int); >>> + struct r92c_tx_desc bcn_desc; >>> + struct mbuf *bcn_mbuf; >>> + struct task tsf_task_adhoc; >>> + >>> + int (*newstate)(struct ieee80211vap *, >>> + enum ieee80211_state, int); >>> + void (*recv_mgmt)(struct ieee80211_node *, >>> + struct mbuf *, int, >>> + const struct ieee80211_rx_stats *, >>> + int, int); >>> }; >>> #define URTWN_VAP(vap) ((struct urtwn_vap *)(vap)) >>> >> >> After this revision, every time I insert my urtwn card into USB port = I = >> get this panic [1]. Moving back to 290650 fixed the problem. >> >> [1] http://imgur.com/6p78GIT > > FYI, after talk with adrian, I updated src to latest rev (r290668) and= = > manually reverted this commit and also 290663 (that broke the build) a= nd = > system is still working as expected. This is the hardware I=E2=80=99m = using: > > urtwn0: = > on usbus1 > urtwn0: MAC/BB RTL8188CUS, RF 6052 1T1R > > -- > Renato Botelho > Resolved via IRC (not reproducible).