From owner-freebsd-wireless@freebsd.org Mon Aug 7 23:15:25 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 69837DCF588 for ; Mon, 7 Aug 2017 23:15:25 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-yw0-x242.google.com (mail-yw0-x242.google.com [IPv6:2607:f8b0:4002:c05::242]) (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 22CC03A3E for ; Mon, 7 Aug 2017 23:15:25 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-yw0-x242.google.com with SMTP id u207so1219882ywc.0 for ; Mon, 07 Aug 2017 16:15:25 -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=vKg591rWB1y/oxMlUKhqI1pYiqviWt3tyjousOG/5sw=; b=p0X5Uf1VoND5tTkSmAVIui/Um7Di769BsDU3w9vZhVXGRdY87KVGL15tOX1taFXf+i +LjU7TQYxAnRBkKiXFx51RZ8aLnmP95AHa5gJBxVyCwZFNHLbEHqKplNdGZL3aluV43L tYLFnXgU+NFciycqc3fAHB67Q1tKu9d98iKKkTKUHjQO2fd3b0MYDFn62oy2/d0eLFhP JqOeJv7cznM8ZNNeNfU0m40NILMmfWzH1/3yGOC07SskzNkqBTrdVuj072bG8u5flTjH kye7fj7zRg3ImEfPVhW//VYaKyNagIBNdKuEWkzRLeL1g/LUnqp33xXpVanOo64j5/jg E5Ag== 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=vKg591rWB1y/oxMlUKhqI1pYiqviWt3tyjousOG/5sw=; b=ty/Km09VK5D2qh4uivNqCxxbMkvys1NZ4Kz0G7uUZMLLb2RN0xawA9HoJf9VhyrCtf htZ2PW5LdL4bobK3Fac2jTjhUVpjX9v6rcmXOUuQFlCkMrK1awUZJo8fxolLHerpDKbj k5MUqS0/CZiq5bKk3G5/CZ2P1BPAzJQXfta+wcKrIqB9/fDycUbWDpzYW8BpHPSMLS99 J7thfqqvUPPsOh/IS0Amv0EZ+ZRf9zkiMNZzeuHxQypzsWeOl8YbFuYrfmUVG8cnwU5o KrY+ObMxYI7SD8J0vwGI1GFuLzRlNpwpVIq0nsewloSPcH1EFRy9/IkwoEPgCdNlJ5fW HY5w== X-Gm-Message-State: AHYfb5hdhKN6j9WQ6P1pAKPZX8q+Os+J2d4Fpds+pTh6Cs5SCczERpkt T6h0YCeEzPSlgSdKwQe9ikPFzqWx4LKT X-Received: by 10.37.208.69 with SMTP id h66mr1928029ybg.272.1502147724228; Mon, 07 Aug 2017 16:15:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.13.203.145 with HTTP; Mon, 7 Aug 2017 16:15:23 -0700 (PDT) In-Reply-To: References: From: Adrian Chadd Date: Mon, 7 Aug 2017 16:15:23 -0700 Message-ID: Subject: Re: Why is rtwn module detaching? To: Farhan Khan Cc: "freebsd-wireless@freebsd.org" Content-Type: text/plain; charset="UTF-8" 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: Mon, 07 Aug 2017 23:15:25 -0000 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"