From owner-svn-src-head@freebsd.org Tue Nov 10 20:20:04 2015 Return-Path: Delivered-To: svn-src-head@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 168C0A2B2E0; Tue, 10 Nov 2015 20:20:04 +0000 (UTC) (envelope-from garga.bsd@gmail.com) Received: from mail-qg0-x236.google.com (mail-qg0-x236.google.com [IPv6:2607:f8b0:400d:c04::236]) (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 BD6A01455; Tue, 10 Nov 2015 20:20:03 +0000 (UTC) (envelope-from garga.bsd@gmail.com) Received: by qgea14 with SMTP id a14so7963933qge.0; Tue, 10 Nov 2015 12:20:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=C8Eg/GCFH34a6qF+tirgG7Bo4UIGcT04SM+k654mKhw=; b=oYrLlrqYIAfjUj8txzPVciIc+z7E6n6qGUtj8xYI6h7EhdY2qc8ahRQrlrzONlAeiY +FnwhlNhDTL442TsLSrVr3DcziPyZ8WQP+VYcmJTn0CHpODsnJC8Wd0yS1QjZ+hKrv3Z AXKtbc7He0557dgQvJim3rq3YJK7JyvtwRHtFPYbFlV2qOThkqnBzLVFDbs+TPADJcZa MfOMLinY1W9vUA4EiBSVX5sncMZEN3Q8vnd2kqtbPbP1StWTI5o59NP/w708kIAxrjUI JoJ4M9ZID632Nns0Bff8PLPzMzC0fcVY76H+ZbEVXdSUt1RZL1ORmiRTha9vt6tGGPkq PA6Q== X-Received: by 10.140.235.143 with SMTP id g137mr7441189qhc.11.1447186802730; Tue, 10 Nov 2015 12:20:02 -0800 (PST) Received: from mbp.home (179-125-138-101.desktop.com.br. [179.125.138.101]) by smtp.gmail.com with ESMTPSA id 22sm1947244qhq.39.2015.11.10.12.20.01 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Nov 2015 12:20:02 -0800 (PST) Sender: Renato Botelho Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 9.1 \(3096.5\)) Subject: Re: svn commit: r290651 - head/sys/dev/usb/wlan From: Renato Botelho In-Reply-To: <201511101252.tAACqQrE033782@repo.freebsd.org> Date: Tue, 10 Nov 2015 18:19:59 -0200 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <2D6627A5-D455-424C-8A9E-0A18754CFE11@FreeBSD.org> References: <201511101252.tAACqQrE033782@repo.freebsd.org> To: Andriy Voskoboinyk X-Mailer: Apple Mail (2.3096.5) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2015 20:20:04 -0000 > On Nov 10, 2015, at 10:52, Andriy Voskoboinyk = wrote: >=20 > Author: avos > Date: Tue Nov 10 12:52:26 2015 > New Revision: 290651 > URL: https://svnweb.freebsd.org/changeset/base/290651 >=20 > Log: > urtwn(4): add IBSS mode support >=20 > Tested with RTL8188EU, IBSS and STA modes. >=20 > Reviewed by: kevlo > Approved by: adrian (mentor) > Differential Revision: https://reviews.freebsd.org/D4038 >=20 > Modified: > head/sys/dev/usb/wlan/if_urtwn.c > head/sys/dev/usb/wlan/if_urtwnvar.h >=20 > 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 = (r290650) > +++ head/sys/dev/usb/wlan/if_urtwn.c Tue Nov 10 12:52:26 2015 = (r290651) > @@ -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); > } >=20 > - 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); >=20 > /* 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); > + } >=20 > /* 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; >=20 > - 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,=20 > } >=20 > 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 = *vap) > { > + 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); >=20 > @@ -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); > } >=20 > +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, >=20 > 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; >=20 > urtwn_write_4(sc, R92C_RCR, reg); > } >=20 > - 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 >=20 > 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) >=20 > 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); >=20 > 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 { > }; >=20 > struct urtwn_vap { > - struct ieee80211vap vap; > + struct ieee80211vap vap; >=20 > - 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)) >=20 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 -- Renato Botelho