rfkill: add a reason to the HW rfkill state
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Wed, 4 Nov 2020 13:46:41 +0000 (15:46 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 11 Dec 2020 11:47:17 +0000 (12:47 +0100)
commit14486c82612a177cb910980c70ba900827ca0894
treebce8d66f6a6159acbf7b7fe45b1d609fe4d99ba8
parent91163f82143630a9629a8bf0227d49173697c69c
rfkill: add a reason to the HW rfkill state

The WLAN device may exist yet not be usable. This can happen
when the WLAN device is controllable by both the host and
some platform internal component.
We need some arbritration that is vendor specific, but when
the device is not available for the host, we need to reflect
this state towards the user space.

Add a reason field to the rfkill object (and event) so that
userspace can know why the device is in rfkill: because some
other platform component currently owns the device, or
because the actual hw rfkill signal is asserted.

Capable userspace can now determine the reason for the rfkill
and possibly do some negotiation on a side band channel using
a proprietary protocol to gain ownership on the device in case
the device is owned by some other component. When the host
gains ownership on the device, the kernel can remove the
RFKILL_HARD_BLOCK_NOT_OWNER reason and the hw rfkill state
will be off. Then, the userspace can bring the device up and
start normal operation.

The rfkill_event structure is enlarged to include the additional
byte, it is now 9 bytes long. Old user space will ask to read
only 8 bytes so that the kernel can know not to feed them with
more data. When the user space writes 8 bytes, new kernels will
just read what is present in the file descriptor. This new byte
is read only from the userspace standpoint anyway.

If a new user space uses an old kernel, it'll ask to read 9 bytes
but will get only 8, and it'll know that it didn't get the new
state. When it'll write 9 bytes, the kernel will again ignore
this new byte which is read only from the userspace standpoint.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Link: https://lore.kernel.org/r/20201104134641.28816-1-emmanuel.grumbach@intel.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/linux/rfkill.h
include/uapi/linux/rfkill.h
net/rfkill/core.c