From owner-freebsd-wireless@freebsd.org Tue May 19 23:07:31 2020 Return-Path: Delivered-To: freebsd-wireless@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B7F202F7B27 for ; Tue, 19 May 2020 23:07:31 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 49RWkC2dCZz4GnB for ; Tue, 19 May 2020 23:07:31 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mailman.nyi.freebsd.org (Postfix) id 59B252F7B26; Tue, 19 May 2020 23:07:31 +0000 (UTC) Delivered-To: wireless@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 597032F78DB for ; Tue, 19 May 2020 23:07:31 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49RWkB3qQ4z4GT4 for ; Tue, 19 May 2020 23:07:30 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mail-lf1-f68.google.com with SMTP id c21so953278lfb.3 for ; Tue, 19 May 2020 16:07:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=BlxV4O9962DyPg5byauB9m0t5lkDqwT+0pj0VCZ9FFU=; b=TeWp099VOq9Grx8zjI63PvbGvxPsiqOThodCM47D2EsPn8+OKxWaY6kvI/5xYLV2CG JdCFIfAmf2yIcuaV94mGawt+Mw4ThMuPEJ8by8sKHD3SVCqlqRQmb2MmZpQ3L6YbGBYd F5yxKhUi7u3yBUvuzJe+FScPGxPrh2G+rugMRaQyrRV2C9QD7OvH9OQEdf6OZE6z4tUg QUFNq0GfCosgbBEGWhrlW62yZskukkq52Df9hoBR4H3XI06tCWBhVZdOavUdnKh2NpR+ aCQHoxcHln/5FsvU8DD02pQ/Pgcggk07OcTOi0zStVdO2v8j/beUOpzLVTwaavKY1n9R bv7A== X-Gm-Message-State: AOAM530X3GB8Eo/ke6j7p7T9xhRu+pmZutULeNQv9KvYzM6BkULg9Zid 7UGe2hhWRzcIlwuzhpOW+W3zJZcj X-Google-Smtp-Source: ABdhPJwPsr37cWNlOhvXlVkonU+BbcHxqcK6QW3j9uBP/qEJjOYnomG0AO7p4Cg8QDT/MRxiw2V1dQ== X-Received: by 2002:ac2:464c:: with SMTP id s12mr702746lfo.147.1589929648453; Tue, 19 May 2020 16:07:28 -0700 (PDT) Received: from [192.168.0.88] (east.meadow.volia.net. [93.72.151.96]) by smtp.googlemail.com with ESMTPSA id z16sm462211lfq.18.2020.05.19.16.07.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 May 2020 16:07:27 -0700 (PDT) Subject: Re: iwm rfkill From: Andriy Gapon To: Adrian Chadd , "freebsd-wireless@freebsd.org" References: <15021eed-2d82-5391-0edc-8d328e3ba31d@FreeBSD.org> <9d55db0d-fe7a-2695-ac3e-6668eab43622@FreeBSD.org> Openpgp: preference=signencrypt Autocrypt: addr=avg@FreeBSD.org; prefer-encrypt=mutual; keydata= mQINBFm4LIgBEADNB/3lT7f15UKeQ52xCFQx/GqHkSxEdVyLFZTmY3KyNPQGBtyvVyBfprJ7 mAeXZWfhat6cKNRA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mRxYg/L HgZY3zfKOqcAEQEAAYkCPAQYAQgAJhYhBL4sQ7ueBCdcDgGOvnfybtNRzXKPBQJZuCyIAhsM BQkFo5qAAAoJEHfybtNRzXKPBVwQAKfFy9P7N3OsLDMB56A4Kf+ZT+d5cIx0Yiaf4n6w7m3i ImHHHk9FIetI4Xe54a2IXh4Bq5UkAGY0667eIs+Z1Ea6I2i27Sdo7DxGwq09Qnm/Y65ADvXs 3aBvokCcm7FsM1wky395m8xUos1681oV5oxgqeRI8/76qy0hD9WR65UW+HQgZRIcIjSel9vR XDaD2HLGPTTGr7u4v00UeTMs6qvPsa2PJagogrKY8RXdFtXvweQFz78NbXhluwix2Tb9ETPk LIpDrtzV73CaE2aqBG/KrboXT2C67BgFtnk7T7Y7iKq4/XvEdDWscz2wws91BOXuMMd4c/c4 OmGW9m3RBLufFrOag1q5yUS9QbFfyqL6dftJP3Zq/xe+mr7sbWbhPVCQFrH3r26mpmy841ym dwQnNcsbIGiBASBSKksOvIDYKa2Wy8htPmWFTEOPRpFXdGQ27awcjjnB42nngyCK5ukZDHi6 w0qK5DNQQCkiweevCIC6wc3p67jl1EMFY5+z+zdTPb3h7LeVnGqW0qBQl99vVFgzLxchKcl0 R/paSFgwqXCZhAKMuUHncJuynDOP7z5LirUeFI8qsBAJi1rXpQoLJTVcW72swZ42IdPiboqx NbTMiNOiE36GqMcTPfKylCbF45JNX4nF9ElM0E+Y8gi4cizJYBRr2FBJgay0b9Cp Message-ID: Date: Wed, 20 May 2020 02:07:25 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Firefox/60.0 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <9d55db0d-fe7a-2695-ac3e-6668eab43622@FreeBSD.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 49RWkB3qQ4z4GT4 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of agapon@gmail.com designates 209.85.167.68 as permitted sender) smtp.mailfrom=agapon@gmail.com X-Spamd-Result: default: False [-0.95 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.71)[-0.708]; RCPT_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[gmail.com,freebsd.org]; FORGED_SENDER(0.30)[avg@FreeBSD.org,agapon@gmail.com]; RECEIVED_SPAMHAUS_PBL(0.00)[93.72.151.96:received]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; MID_RHS_MATCH_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[avg@FreeBSD.org,agapon@gmail.com]; R_DKIM_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.24)[-0.240]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[wireless@freebsd.org]; DMARC_NA(0.00)[FreeBSD.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.167.68:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.167.68:from]; RCVD_TLS_ALL(0.00)[] X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.33 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: Tue, 19 May 2020 23:07:31 -0000 On 20/05/2020 01:40, Andriy Gapon wrote: > On 18/05/2020 18:42, Adrian Chadd wrote: >> On Mon, 18 May 2020 at 00:57, Andriy Gapon wrote: >>> >>> >>> I am trying to get my laptop fully functional and one of the things that >>> currently does not work as expected is a Wi-Fi / Radio special key. >>> It seems to be handled fully in hardware (but not 100% sure), but when I press >>> it only bluetooth is turned off, but Wi-Fi stays on. >>> >>> This is the hardware: >>> iwm0: mem 0xfe800000-0xfe801fff at device >>> 0.0 on pci3 >>> iwm0: hw rev 0x220, fw ver 22.361476.0, address xx >>> >>> When I press the key I see these messages: >>> iwm0: iwm_intr: rfkill switch, disabling interface >>> ugen0.6: at usbus0 (disconnected) >>> ubt0: at uhub1, port 4, addr 5 (disconnected) >>> ubt0: detached >>> >>> However, ifconfig still shows that wlan0 is UP and RUNNING and the traffic keeps >>> flowing. >>> >>> So, it seems that the RF KILL bit gets set and it's detected by the driver, but >>> whatever the driver does is not enough to turn off the Wi-Fi. >>> Does anyone have any patches or suggestions or pointers (documentation, etc) ? >> >> It should be pretty easy to hack in; look at what iwn does? It should >> just do a software thing to disable the interface in software. > > Adrian, thank you very much for your suggestion. > Being a complete noob in this area, this is my stab at it: > https://reviews.freebsd.org/D24923 Also, I see that there is some friction between how rfkill is handled at the driver / kernel level and how it gets (or doesn't get) known to userland. First, at least Intel wireless drivers use ieee80211_suspend_all / ieee80211_resume_all KPI when handling rfkill. Those calls end up clearing or setting IFF_DRV_RUNNING while userland mostly checks for IFF_UP. But that's not an issue actually -- I think that it's userland code that needs fixing. The issue is that the IFF_DRV_RUNNING changes become known to userland only by accident if at all. Specifically, if we consider wpa_supplicant, it listens for notifications coming via PF_ROUTE socket such as RTM_IFINFO. So, wpa_supplicant depends on (a) a notification getting generated in the first place; (b) the notification conveying correct information about an interface's state. As far as I can tell, net80211 layer does not try to do either of the above. E.g., in the case of ieee80211_stop_locked there is an RTM_IFINFO notification because of a link status change, but that notification by the state change that's performed before IFF_DRV_RUNNING is cleared. In the case of ieee80211_start_locked the situation is even worse. I wonder if ieee80211 should explicitly use rt_ifmsg() to post right notifications at right times. FWIW, I already have a patch for that and it seems to work. -- Andriy Gapon