From owner-freebsd-wireless@freebsd.org Sun Aug 6 02:44:07 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 D8856DD9AAB for ; Sun, 6 Aug 2017 02:44:07 +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 AD00D6CCDC for ; Sun, 6 Aug 2017 02:44:07 +0000 (UTC) (envelope-from khanzf@gmail.com) Received: by mail-pg0-x244.google.com with SMTP id u185so5496331pgb.0 for ; Sat, 05 Aug 2017 19:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=9OXSU49Hmqg4knPDwU7qj1i+hGWUHa2AZ3REN/N7UE0=; b=DwIKjPs2CVmzp3kw6ZaebolQCWfG9qex1rj8y23wm8VSUU1xvUwsIQBWgdhsnBB7ln gjnZPioSvE0/EB8k182zvtgcE19srOKL3lrr3fhjGackelrncc0DDlW0VX62/P9+UP5u pofTf2/fqJCZv01PaMXs+0XcHIPyGxpXH4kBQ+hiXJOwLFFPKqRJYxYv3/CVEy0eRb1w fCoLl1Gh5zQq4jdgi8W/4HuJE4DhhTSP5NG5lzosxJ7mB1BztUPhQZH4ll+Xg6FQgkHu 1v73O1DMpgycPflyK//k9o7F7pduux8uwyf94N6jPoaHLBf/ZlCx/ozAEpmFzCOtSao5 6yPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=9OXSU49Hmqg4knPDwU7qj1i+hGWUHa2AZ3REN/N7UE0=; b=cI8RSTCma1hdLala7/p2b3hoSXim7QlEfNDZgjAHlZwwUyh2lw8dpaUDKvudzpzmoq fSFw0zPuYAtEjXEGGd3cMNMYG7YFmG14kZSIPL646yc4Sg9TLuy4uQ89XE1twyY8a2Ne wNxa4UNSvShRn4JT7pWWovtHtdfCPYFxQ0fNn4ex1oVXc8qUH3J9l/juNPgDZkqmR6pR XRydCFgQCY+TIMGUqZzS9dgsckinu9++rhFlUFVKpLS9LN2kzoHdH1cjzdjTjsuNtixW N3jspm+w7AMhTxt69sg5iCUL+EFMrjlDYxSsgCQiMd+Pt8o3dNd7XzqGAyiLMPjXb4ZL FtzA== X-Gm-Message-State: AIVw11381RQaQOSfMdKPs+G0E2bRuvGusBUX4PqeeTgty+g84olCMNJb cisnlmPQqgHX/NM4RrNJyftY5vWMD8OC6yA= X-Received: by 10.98.60.220 with SMTP id b89mr7613325pfk.170.1501987446796; Sat, 05 Aug 2017 19:44:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.183.208 with HTTP; Sat, 5 Aug 2017 19:43:46 -0700 (PDT) From: Farhan Khan Date: Sat, 5 Aug 2017 22:43:46 -0400 Message-ID: Subject: Why is rtwn module detaching? To: 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, 06 Aug 2017 02:44:07 -0000 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