From owner-freebsd-wireless@freebsd.org Sun Aug 13 01:10:06 2017 Return-Path: Delivered-To: freebsd-wireless@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 9A3B5DD7F41 for ; Sun, 13 Aug 2017 01:10:06 +0000 (UTC) (envelope-from khanzf@gmail.com) Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (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 69ACF7D8CD for ; Sun, 13 Aug 2017 01:10:06 +0000 (UTC) (envelope-from khanzf@gmail.com) Received: by mail-pg0-x244.google.com with SMTP id l64so5952931pge.2 for ; Sat, 12 Aug 2017 18:10:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=WiSg58YMXEjVJnAf9sPYyTTCGw28HWlEzHFKL41B3D0=; b=G5lMVGFcov7ZM2RyGalDyYMOm82Yxcdf9uL8PYY25KkRwhhdiuUp9CBM0Q+g+/n/oE xuCd3Ct/WPMXDjxSFIMMHgbUEhjrGhQ0dV5DtxomwZj/V+/PCUKJL6j6gslDfvQJZhvf 9QY+5Iu3+E+S0NyyfgNWqTfai2y58J/lgmD1bFdIdjj0Z6T+Aboj5TU4MCeLKNBMaord Pv/dfVx+JdqR5C83UV8N1bQQ40kchQXTSil1ijf7+lw2JlUpRHrJ4IdG0DYY4hvgb+24 aiB9rQrvepKHZXXYblBj+4TXmMUw+W+9t682x5t711cHHh8j8RQX2NGZSVPTMP7udOar AiMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=WiSg58YMXEjVJnAf9sPYyTTCGw28HWlEzHFKL41B3D0=; b=PBva3rcOISBB2MTMrPXuVaLRWLnlKY6NoA7dHn/ScTaCorRZmPN45EsiBazgooDPbO JMp8NKXU6itxtmfmDQacjzAf7oW3lDrIYV/qCDzOX+4Vs85in+hassU5gTOXCAvJL636 g7r1TYZR4Hhy3c83KDIDkFqmEPcUZ7KQL+suqlDmooxmAV25/yuSY5cx/BXmUNUZVf7C 6gPdLR9h3Cb80MiRmCcZPoH1vxdBsgbkA9scJF67po4uvHPLKi3O6xr14FcA3/PFxTEh Aw51BJW9EkuNd3/CHCBDzfeyAgQAmyuNblK4HjRRqSq0xLV/8tIqUdZ9cRHx6HOUe8C+ OfVg== X-Gm-Message-State: AHYfb5iwzeElUQt6xpr978LoANFccCgZARsKEk5Pa8iDbTfNJiJeTvMy vej3/Mmo5AaIM+IAgftzb4vKYo4rYLpEFHM= X-Received: by 10.84.132.73 with SMTP id 67mr22278174ple.53.1502586605940; Sat, 12 Aug 2017 18:10:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.183.208 with HTTP; Sat, 12 Aug 2017 18:09:45 -0700 (PDT) In-Reply-To: References: From: Farhan Khan Date: Sat, 12 Aug 2017 21:09:45 -0400 Message-ID: Subject: Re: Why is rtwn module detaching? To: Adrian Chadd Cc: "freebsd-wireless@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Aug 2017 01:10:06 -0000 Following up on this from earlier: I am trying to extend the sys/dev/rtwn/rtl8188e driver to support PCI. Linux calls this rtl8188ee. Right now, my code loads, reads the ROM, and will create an interface with: ifconfig wlan0 create wlandev rtwn0 But when I assign an IP address, it immediately detaches. I have not been able to figure out why this is happening and I cannot continue developing this driver, despite a few weeks of tracing the code. Some clues: I found that rtwn_parent() will trigger rtwn_stop() if ic->ic_nrunning is less than 0. That value is incremented in ieee80211_start_locked() and decremented in ieee80211_stop_locked(). I used stack_print(9), which show that ieee80211_stop_locked() is executed at least 4 times, but the trace's originate with a device_detach() in the first place. What is causing that in the first place? So, why is my driver unloading? Because ic->ic_nrunning is less than 0. Why is ic->ic_nrunning less than 0? Because something is calling ieee80211_stop_locked(). I have no direction on what the issue may be and have been just searching for an extended period now. Any assistance would be highly appreciated. Thank you, -- Farhan Khan PGP Fingerprint: 782F 342B 5B08 0D2F F4E8 82C3 FFA1 CAE1 6536 51CA On Mon, Aug 7, 2017 at 7:15 PM, Adrian Chadd wrote: > For reference, we chatted on IRC. > > I think it's the NIC disappearing because giving it an iP brings it > link 'up' and something in the 'up' path is causing the firmware to > crash and the NIC to disappear. > > which bus is it on btw? eg, you could try 'devctl rescan pcib3' if > it's on pcib3.. > > -adrian > > On 5 August 2017 at 19:43, Farhan Khan wrote: > > Hi all, > > > > I am slowly struggling through writing my Wifi first driver, which is an > > extension to the current rtwn driver. I have reached another hurdle that > > I'm stuck on. > > > > I bring up my wifi driver as follows: > > > > # kldload rtwn && kldload rtwn_pci > > # sudo ifconfig wlan0 create wlandev rtwn0 > > # sudo ifconfig wlan0 1.1.1.1 > > > > The third line causes the rtwn0 device to detach (and pci0 device, which > > requires a reboot and is quite frustrating). > > > > I traced through the code to find why it is detaching and found that in > > rtwn_parent() (sys/dev/rtwn/if_rtwn.c), it checks the ic->ic_nrunning > (from > > struct ieee80211com). If that value is less than or equal to 0, it will > > cause the rtwn driver to stop. This appears to be a common control > > structure used by other drivers as well. > > > > Unfortunately, I have not been able to determine where ic->ic_nrunning is > > modified anywhere in the kernel. In fact, the only references I found > from > > my searches was checking the ic_nrunning value, not setting it. > > > > Does anyone know where this is being set? Without determining this, I > > cannot why my driver is unloading. I suspect that I failed to set the > > appropriate 802.11 values in my own code, causing the base 802.11 code to > > mark it as "off" or malfunctioning but I am not certain. > > > > Please advise. > > Thank you, > > -- > > Farhan Khan > > PGP Fingerprint: 782F 342B 5B08 0D2F F4E8 82C3 FFA1 CAE1 6536 51CA > > _______________________________________________ > > freebsd-wireless@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/freebsd-wireless > > To unsubscribe, send any mail to "freebsd-wireless-unsubscribe@ > freebsd.org" >