rfkill.txt 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. rfkill - RF switch subsystem support
  2. ====================================
  3. 1 Introduction
  4. 2 Implementation details
  5. 3 Kernel driver guidelines
  6. 3.1 wireless device drivers
  7. 3.2 platform/switch drivers
  8. 3.3 input device drivers
  9. 4 Kernel API
  10. 5 Userspace support
  11. 1. Introduction:
  12. The rfkill switch subsystem exists to add a generic interface to circuitry that
  13. can enable or disable the signal output of a wireless *transmitter* of any
  14. type. By far, the most common use is to disable radio-frequency transmitters.
  15. Note that disabling the signal output means that the the transmitter is to be
  16. made to not emit any energy when "blocked". rfkill is not about blocking data
  17. transmissions, it is about blocking energy emission.
  18. The rfkill subsystem offers support for keys and switches often found on
  19. laptops to enable wireless devices like WiFi and Bluetooth, so that these keys
  20. and switches actually perform an action in all wireless devices of a given type
  21. attached to the system.
  22. The buttons to enable and disable the wireless transmitters are important in
  23. situations where the user is for example using his laptop on a location where
  24. radio-frequency transmitters _must_ be disabled (e.g. airplanes).
  25. Because of this requirement, userspace support for the keys should not be made
  26. mandatory. Because userspace might want to perform some additional smarter
  27. tasks when the key is pressed, rfkill provides userspace the possibility to
  28. take over the task to handle the key events.
  29. ===============================================================================
  30. 2: Implementation details
  31. The rfkill subsystem is composed of various components: the rfkill class, the
  32. rfkill-input module (an input layer handler), and some specific input layer
  33. events.
  34. The rfkill class provides kernel drivers with an interface that allows them to
  35. know when they should enable or disable a wireless network device transmitter.
  36. This is enabled by the CONFIG_RFKILL Kconfig option.
  37. The rfkill class support makes sure userspace will be notified of all state
  38. changes on rfkill devices through uevents. It provides a notification chain
  39. for interested parties in the kernel to also get notified of rfkill state
  40. changes in other drivers. It creates several sysfs entries which can be used
  41. by userspace. See section "Userspace support".
  42. The rfkill-input module provides the kernel with the ability to implement a
  43. basic response when the user presses a key or button (or toggles a switch)
  44. related to rfkill functionality. It is an in-kernel implementation of default
  45. policy of reacting to rfkill-related input events and neither mandatory nor
  46. required for wireless drivers to operate. It is enabled by the
  47. CONFIG_RFKILL_INPUT Kconfig option.
  48. rfkill-input is a rfkill-related events input layer handler. This handler will
  49. listen to all rfkill key events and will change the rfkill state of the
  50. wireless devices accordingly. With this option enabled userspace could either
  51. do nothing or simply perform monitoring tasks.
  52. The rfkill-input module also provides EPO (emergency power-off) functionality
  53. for all wireless transmitters. This function cannot be overridden, and it is
  54. always active. rfkill EPO is related to *_RFKILL_ALL input layer events.
  55. Important terms for the rfkill subsystem:
  56. In order to avoid confusion, we avoid the term "switch" in rfkill when it is
  57. referring to an electronic control circuit that enables or disables a
  58. transmitter. We reserve it for the physical device a human manipulates
  59. (which is an input device, by the way):
  60. rfkill switch:
  61. A physical device a human manipulates. Its state can be perceived by
  62. the kernel either directly (through a GPIO pin, ACPI GPE) or by its
  63. effect on a rfkill line of a wireless device.
  64. rfkill controller:
  65. A hardware circuit that controls the state of a rfkill line, which a
  66. kernel driver can interact with *to modify* that state (i.e. it has
  67. either write-only or read/write access).
  68. rfkill line:
  69. An input channel (hardware or software) of a wireless device, which
  70. causes a wireless transmitter to stop emitting energy (BLOCK) when it
  71. is active. Point of view is extremely important here: rfkill lines are
  72. always seen from the PoV of a wireless device (and its driver).
  73. soft rfkill line/software rfkill line:
  74. A rfkill line the wireless device driver can directly change the state
  75. of. Related to rfkill_state RFKILL_STATE_SOFT_BLOCKED.
  76. hard rfkill line/hardware rfkill line:
  77. A rfkill line that works fully in hardware or firmware, and that cannot
  78. be overridden by the kernel driver. The hardware device or the
  79. firmware just exports its status to the driver, but it is read-only.
  80. Related to rfkill_state RFKILL_STATE_HARD_BLOCKED.
  81. The enum rfkill_state describes the rfkill state of a transmitter:
  82. When a rfkill line or rfkill controller is in the RFKILL_STATE_UNBLOCKED state,
  83. the wireless transmitter (radio TX circuit for example) is *enabled*. When the
  84. it is in the RFKILL_STATE_SOFT_BLOCKED or RFKILL_STATE_HARD_BLOCKED, the
  85. wireless transmitter is to be *blocked* from operating.
  86. RFKILL_STATE_SOFT_BLOCKED indicates that a call to toggle_radio() can change
  87. that state. RFKILL_STATE_HARD_BLOCKED indicates that a call to toggle_radio()
  88. will not be able to change the state and will return with a suitable error if
  89. attempts are made to set the state to RFKILL_STATE_UNBLOCKED.
  90. RFKILL_STATE_HARD_BLOCKED is used by drivers to signal that the device is
  91. locked in the BLOCKED state by a hardwire rfkill line (typically an input pin
  92. that, when active, forces the transmitter to be disabled) which the driver
  93. CANNOT override.
  94. Full rfkill functionality requires two different subsystems to cooperate: the
  95. input layer and the rfkill class. The input layer issues *commands* to the
  96. entire system requesting that devices registered to the rfkill class change
  97. state. The way this interaction happens is not complex, but it is not obvious
  98. either:
  99. Kernel Input layer:
  100. * Generates KEY_WWAN, KEY_WLAN, KEY_BLUETOOTH, SW_RFKILL_ALL, and
  101. other such events when the user presses certain keys, buttons, or
  102. toggles certain physical switches.
  103. THE INPUT LAYER IS NEVER USED TO PROPAGATE STATUS, NOTIFICATIONS OR THE
  104. KIND OF STUFF AN ON-SCREEN-DISPLAY APPLICATION WOULD REPORT. It is
  105. used to issue *commands* for the system to change behaviour, and these
  106. commands may or may not be carried out by some kernel driver or
  107. userspace application. It follows that doing user feedback based only
  108. on input events is broken, as there is no guarantee that an input event
  109. will be acted upon.
  110. Most wireless communication device drivers implementing rfkill
  111. functionality MUST NOT generate these events, and have no reason to
  112. register themselves with the input layer. Doing otherwise is a common
  113. misconception. There is an API to propagate rfkill status change
  114. information, and it is NOT the input layer.
  115. rfkill class:
  116. * Calls a hook in a driver to effectively change the wireless
  117. transmitter state;
  118. * Keeps track of the wireless transmitter state (with help from
  119. the driver);
  120. * Generates userspace notifications (uevents) and a call to a
  121. notification chain (kernel) when there is a wireless transmitter
  122. state change;
  123. * Connects a wireless communications driver with the common rfkill
  124. control system, which, for example, allows actions such as
  125. "switch all bluetooth devices offline" to be carried out by
  126. userspace or by rfkill-input.
  127. THE RFKILL CLASS NEVER ISSUES INPUT EVENTS. THE RFKILL CLASS DOES
  128. NOT LISTEN TO INPUT EVENTS. NO DRIVER USING THE RFKILL CLASS SHALL
  129. EVER LISTEN TO, OR ACT ON RFKILL INPUT EVENTS. Doing otherwise is
  130. a layering violation.
  131. Most wireless data communication drivers in the kernel have just to
  132. implement the rfkill class API to work properly. Interfacing to the
  133. input layer is not often required (and is very often a *bug*) on
  134. wireless drivers.
  135. Platform drivers often have to attach to the input layer to *issue*
  136. (but never to listen to) rfkill events for rfkill switches, and also to
  137. the rfkill class to export a control interface for the platform rfkill
  138. controllers to the rfkill subsystem. This does NOT mean the rfkill
  139. switch is attached to a rfkill class (doing so is almost always wrong).
  140. It just means the same kernel module is the driver for different
  141. devices (rfkill switches and rfkill controllers).
  142. Userspace input handlers (uevents) or kernel input handlers (rfkill-input):
  143. * Implements the policy of what should happen when one of the input
  144. layer events related to rfkill operation is received.
  145. * Uses the sysfs interface (userspace) or private rfkill API calls
  146. to tell the devices registered with the rfkill class to change
  147. their state (i.e. translates the input layer event into real
  148. action).
  149. * rfkill-input implements EPO by handling EV_SW SW_RFKILL_ALL 0
  150. (power off all transmitters) in a special way: it ignores any
  151. overrides and local state cache and forces all transmitters to the
  152. RFKILL_STATE_SOFT_BLOCKED state (including those which are already
  153. supposed to be BLOCKED). Note that the opposite event (power on all
  154. transmitters) is handled normally.
  155. Userspace uevent handler or kernel platform-specific drivers hooked to the
  156. rfkill notifier chain:
  157. * Taps into the rfkill notifier chain or to KOBJ_CHANGE uevents,
  158. in order to know when a device that is registered with the rfkill
  159. class changes state;
  160. * Issues feedback notifications to the user;
  161. * In the rare platforms where this is required, synthesizes an input
  162. event to command all *OTHER* rfkill devices to also change their
  163. statues when a specific rfkill device changes state.
  164. ===============================================================================
  165. 3: Kernel driver guidelines
  166. Remember: point-of-view is everything for a driver that connects to the rfkill
  167. subsystem. All the details below must be measured/perceived from the point of
  168. view of the specific driver being modified.
  169. The first thing one needs to know is whether his driver should be talking to
  170. the rfkill class or to the input layer. In rare cases (platform drivers), it
  171. could happen that you need to do both, as platform drivers often handle a
  172. variety of devices in the same driver.
  173. Do not mistake input devices for rfkill controllers. The only type of "rfkill
  174. switch" device that is to be registered with the rfkill class are those
  175. directly controlling the circuits that cause a wireless transmitter to stop
  176. working (or the software equivalent of them), i.e. what we call a rfkill
  177. controller. Every other kind of "rfkill switch" is just an input device and
  178. MUST NOT be registered with the rfkill class.
  179. A driver should register a device with the rfkill class when ALL of the
  180. following conditions are met (they define a rfkill controller):
  181. 1. The device is/controls a data communications wireless transmitter;
  182. 2. The kernel can interact with the hardware/firmware to CHANGE the wireless
  183. transmitter state (block/unblock TX operation);
  184. 3. The transmitter can be made to not emit any energy when "blocked":
  185. rfkill is not about blocking data transmissions, it is about blocking
  186. energy emission;
  187. A driver should register a device with the input subsystem to issue
  188. rfkill-related events (KEY_WLAN, KEY_BLUETOOTH, KEY_WWAN, KEY_WIMAX,
  189. SW_RFKILL_ALL, etc) when ALL of the folowing conditions are met:
  190. 1. It is directly related to some physical device the user interacts with, to
  191. command the O.S./firmware/hardware to enable/disable a data communications
  192. wireless transmitter.
  193. Examples of the physical device are: buttons, keys and switches the user
  194. will press/touch/slide/switch to enable or disable the wireless
  195. communication device.
  196. 2. It is NOT slaved to another device, i.e. there is no other device that
  197. issues rfkill-related input events in preference to this one.
  198. Please refer to the corner cases and examples section for more details.
  199. When in doubt, do not issue input events. For drivers that should generate
  200. input events in some platforms, but not in others (e.g. b43), the best solution
  201. is to NEVER generate input events in the first place. That work should be
  202. deferred to a platform-specific kernel module (which will know when to generate
  203. events through the rfkill notifier chain) or to userspace. This avoids the
  204. usual maintenance problems with DMI whitelisting.
  205. Corner cases and examples:
  206. ====================================
  207. 1. If the device is an input device that, because of hardware or firmware,
  208. causes wireless transmitters to be blocked regardless of the kernel's will, it
  209. is still just an input device, and NOT to be registered with the rfkill class.
  210. 2. If the wireless transmitter switch control is read-only, it is an input
  211. device and not to be registered with the rfkill class (and maybe not to be made
  212. an input layer event source either, see below).
  213. 3. If there is some other device driver *closer* to the actual hardware the
  214. user interacted with (the button/switch/key) to issue an input event, THAT is
  215. the device driver that should be issuing input events.
  216. E.g:
  217. [RFKILL slider switch] -- [GPIO hardware] -- [WLAN card rf-kill input]
  218. (platform driver) (wireless card driver)
  219. The user is closer to the RFKILL slide switch plaform driver, so the driver
  220. which must issue input events is the platform driver looking at the GPIO
  221. hardware, and NEVER the wireless card driver (which is just a slave). It is
  222. very likely that there are other leaves than just the WLAN card rf-kill input
  223. (e.g. a bluetooth card, etc)...
  224. On the other hand, some embedded devices do this:
  225. [RFKILL slider switch] -- [WLAN card rf-kill input]
  226. (wireless card driver)
  227. In this situation, the wireless card driver *could* register itself as an input
  228. device and issue rf-kill related input events... but in order to AVOID the need
  229. for DMI whitelisting, the wireless card driver does NOT do it. Userspace (HAL)
  230. or a platform driver (that exists only on these embedded devices) will do the
  231. dirty job of issuing the input events.
  232. COMMON MISTAKES in kernel drivers, related to rfkill:
  233. ====================================
  234. 1. NEVER confuse input device keys and buttons with input device switches.
  235. 1a. Switches are always set or reset. They report the current state
  236. (on position or off position).
  237. 1b. Keys and buttons are either in the pressed or not-pressed state, and
  238. that's it. A "button" that latches down when you press it, and
  239. unlatches when you press it again is in fact a switch as far as input
  240. devices go.
  241. Add the SW_* events you need for switches, do NOT try to emulate a button using
  242. KEY_* events just because there is no such SW_* event yet. Do NOT try to use,
  243. for example, KEY_BLUETOOTH when you should be using SW_BLUETOOTH instead.
  244. 2. Input device switches (sources of EV_SW events) DO store their current state
  245. (so you *must* initialize it by issuing a gratuitous input layer event on
  246. driver start-up and also when resuming from sleep), and that state CAN be
  247. queried from userspace through IOCTLs. There is no sysfs interface for this,
  248. but that doesn't mean you should break things trying to hook it to the rfkill
  249. class to get a sysfs interface :-)
  250. 3. Do not issue *_RFKILL_ALL events by default, unless you are sure it is the
  251. correct event for your switch/button. These events are emergency power-off
  252. events when they are trying to turn the transmitters off. An example of an
  253. input device which SHOULD generate *_RFKILL_ALL events is the wireless-kill
  254. switch in a laptop which is NOT a hotkey, but a real switch that kills radios
  255. in hardware, even if the O.S. has gone to lunch. An example of an input device
  256. which SHOULD NOT generate *_RFKILL_ALL events by default, is any sort of hot
  257. key that does nothing by itself, as well as any hot key that is type-specific
  258. (e.g. the one for WLAN).
  259. 3.1 Guidelines for wireless device drivers
  260. ------------------------------------------
  261. (in this text, rfkill->foo means the foo field of struct rfkill).
  262. 1. Each independent transmitter in a wireless device (usually there is only one
  263. transmitter per device) should have a SINGLE rfkill class attached to it.
  264. 2. If the device does not have any sort of hardware assistance to allow the
  265. driver to rfkill the device, the driver should emulate it by taking all actions
  266. required to silence the transmitter.
  267. 3. If it is impossible to silence the transmitter (i.e. it still emits energy,
  268. even if it is just in brief pulses, when there is no data to transmit and there
  269. is no hardware support to turn it off) do NOT lie to the users. Do not attach
  270. it to a rfkill class. The rfkill subsystem does not deal with data
  271. transmission, it deals with energy emission. If the transmitter is emitting
  272. energy, it is not blocked in rfkill terms.
  273. 4. It doesn't matter if the device has multiple rfkill input lines affecting
  274. the same transmitter, their combined state is to be exported as a single state
  275. per transmitter (see rule 1).
  276. This rule exists because users of the rfkill subsystem expect to get (and set,
  277. when possible) the overall transmitter rfkill state, not of a particular rfkill
  278. line.
  279. 5. The wireless device driver MUST NOT leave the transmitter enabled during
  280. suspend and hibernation unless:
  281. 5.1. The transmitter has to be enabled for some sort of functionality
  282. like wake-on-wireless-packet or autonomous packed forwarding in a mesh
  283. network, and that functionality is enabled for this suspend/hibernation
  284. cycle.
  285. AND
  286. 5.2. The device was not on a user-requested BLOCKED state before
  287. the suspend (i.e. the driver must NOT unblock a device, not even
  288. to support wake-on-wireless-packet or remain in the mesh).
  289. In other words, there is absolutely no allowed scenario where a driver can
  290. automatically take action to unblock a rfkill controller (obviously, this deals
  291. with scenarios where soft-blocking or both soft and hard blocking is happening.
  292. Scenarios where hardware rfkill lines are the only ones blocking the
  293. transmitter are outside of this rule, since the wireless device driver does not
  294. control its input hardware rfkill lines in the first place).
  295. 6. During resume, rfkill will try to restore its previous state.
  296. 7. After a rfkill class is suspended, it will *not* call rfkill->toggle_radio
  297. until it is resumed.
  298. Example of a WLAN wireless driver connected to the rfkill subsystem:
  299. --------------------------------------------------------------------
  300. A certain WLAN card has one input pin that causes it to block the transmitter
  301. and makes the status of that input pin available (only for reading!) to the
  302. kernel driver. This is a hard rfkill input line (it cannot be overridden by
  303. the kernel driver).
  304. The card also has one PCI register that, if manipulated by the driver, causes
  305. it to block the transmitter. This is a soft rfkill input line.
  306. It has also a thermal protection circuitry that shuts down its transmitter if
  307. the card overheats, and makes the status of that protection available (only for
  308. reading!) to the kernel driver. This is also a hard rfkill input line.
  309. If either one of these rfkill lines are active, the transmitter is blocked by
  310. the hardware and forced offline.
  311. The driver should allocate and attach to its struct device *ONE* instance of
  312. the rfkill class (there is only one transmitter).
  313. It can implement the get_state() hook, and return RFKILL_STATE_HARD_BLOCKED if
  314. either one of its two hard rfkill input lines are active. If the two hard
  315. rfkill lines are inactive, it must return RFKILL_STATE_SOFT_BLOCKED if its soft
  316. rfkill input line is active. Only if none of the rfkill input lines are
  317. active, will it return RFKILL_STATE_UNBLOCKED.
  318. Since the device has a hardware rfkill line, it IS subject to state changes
  319. external to rfkill. Therefore, the driver must make sure that it calls
  320. rfkill_force_state() to keep the status always up-to-date, and it must do a
  321. rfkill_force_state() on resume from sleep.
  322. Every time the driver gets a notification from the card that one of its rfkill
  323. lines changed state (polling might be needed on badly designed cards that don't
  324. generate interrupts for such events), it recomputes the rfkill state as per
  325. above, and calls rfkill_force_state() to update it.
  326. The driver should implement the toggle_radio() hook, that:
  327. 1. Returns an error if one of the hardware rfkill lines are active, and the
  328. caller asked for RFKILL_STATE_UNBLOCKED.
  329. 2. Activates the soft rfkill line if the caller asked for state
  330. RFKILL_STATE_SOFT_BLOCKED. It should do this even if one of the hard rfkill
  331. lines are active, effectively double-blocking the transmitter.
  332. 3. Deactivates the soft rfkill line if none of the hardware rfkill lines are
  333. active and the caller asked for RFKILL_STATE_UNBLOCKED.
  334. ===============================================================================
  335. 4: Kernel API
  336. To build a driver with rfkill subsystem support, the driver should depend on
  337. (or select) the Kconfig symbol RFKILL; it should _not_ depend on RKFILL_INPUT.
  338. The hardware the driver talks to may be write-only (where the current state
  339. of the hardware is unknown), or read-write (where the hardware can be queried
  340. about its current state).
  341. The rfkill class will call the get_state hook of a device every time it needs
  342. to know the *real* current state of the hardware. This can happen often, but
  343. it does not do any polling, so it is not enough on hardware that is subject
  344. to state changes outside of the rfkill subsystem.
  345. Therefore, calling rfkill_force_state() when a state change happens is
  346. mandatory when the device has a hardware rfkill line, or when something else
  347. like the firmware could cause its state to be changed without going through the
  348. rfkill class.
  349. Some hardware provides events when its status changes. In these cases, it is
  350. best for the driver to not provide a get_state hook, and instead register the
  351. rfkill class *already* with the correct status, and keep it updated using
  352. rfkill_force_state() when it gets an event from the hardware.
  353. rfkill_force_state() must be used on the device resume handlers to update the
  354. rfkill status, should there be any chance of the device status changing during
  355. the sleep.
  356. There is no provision for a statically-allocated rfkill struct. You must
  357. use rfkill_allocate() to allocate one.
  358. You should:
  359. - rfkill_allocate()
  360. - modify rfkill fields (flags, name)
  361. - modify state to the current hardware state (THIS IS THE ONLY TIME
  362. YOU CAN ACCESS state DIRECTLY)
  363. - rfkill_register()
  364. The only way to set a device to the RFKILL_STATE_HARD_BLOCKED state is through
  365. a suitable return of get_state() or through rfkill_force_state().
  366. When a device is in the RFKILL_STATE_HARD_BLOCKED state, the only way to switch
  367. it to a different state is through a suitable return of get_state() or through
  368. rfkill_force_state().
  369. If toggle_radio() is called to set a device to state RFKILL_STATE_SOFT_BLOCKED
  370. when that device is already at the RFKILL_STATE_HARD_BLOCKED state, it should
  371. not return an error. Instead, it should try to double-block the transmitter,
  372. so that its state will change from RFKILL_STATE_HARD_BLOCKED to
  373. RFKILL_STATE_SOFT_BLOCKED should the hardware blocking cease.
  374. Please refer to the source for more documentation.
  375. ===============================================================================
  376. 5: Userspace support
  377. rfkill devices issue uevents (with an action of "change"), with the following
  378. environment variables set:
  379. RFKILL_NAME
  380. RFKILL_STATE
  381. RFKILL_TYPE
  382. The ABI for these variables is defined by the sysfs attributes. It is best
  383. to take a quick look at the source to make sure of the possible values.
  384. It is expected that HAL will trap those, and bridge them to DBUS, etc. These
  385. events CAN and SHOULD be used to give feedback to the user about the rfkill
  386. status of the system.
  387. Input devices may issue events that are related to rfkill. These are the
  388. various KEY_* events and SW_* events supported by rfkill-input.c.
  389. ******IMPORTANT******
  390. When rfkill-input is ACTIVE, userspace is NOT TO CHANGE THE STATE OF AN RFKILL
  391. SWITCH IN RESPONSE TO AN INPUT EVENT also handled by rfkill-input, unless it
  392. has set to true the user_claim attribute for that particular switch. This rule
  393. is *absolute*; do NOT violate it.
  394. ******IMPORTANT******
  395. Userspace must not assume it is the only source of control for rfkill switches.
  396. Their state CAN and WILL change due to firmware actions, direct user actions,
  397. and the rfkill-input EPO override for *_RFKILL_ALL.
  398. When rfkill-input is not active, userspace must initiate a rfkill status
  399. change by writing to the "state" attribute in order for anything to happen.
  400. Take particular care to implement EV_SW SW_RFKILL_ALL properly. When that
  401. switch is set to OFF, *every* rfkill device *MUST* be immediately put into the
  402. RFKILL_STATE_SOFT_BLOCKED state, no questions asked.
  403. The following sysfs entries will be created:
  404. name: Name assigned by driver to this key (interface or driver name).
  405. type: Name of the key type ("wlan", "bluetooth", etc).
  406. state: Current state of the transmitter
  407. 0: RFKILL_STATE_SOFT_BLOCKED
  408. transmitter is forced off, but one can override it
  409. by a write to the state attribute;
  410. 1: RFKILL_STATE_UNBLOCKED
  411. transmiter is NOT forced off, and may operate if
  412. all other conditions for such operation are met
  413. (such as interface is up and configured, etc);
  414. 2: RFKILL_STATE_HARD_BLOCKED
  415. transmitter is forced off by something outside of
  416. the driver's control. One cannot set a device to
  417. this state through writes to the state attribute;
  418. claim: 1: Userspace handles events, 0: Kernel handles events
  419. Both the "state" and "claim" entries are also writable. For the "state" entry
  420. this means that when 1 or 0 is written, the device rfkill state (if not yet in
  421. the requested state), will be will be toggled accordingly.
  422. For the "claim" entry writing 1 to it means that the kernel no longer handles
  423. key events even though RFKILL_INPUT input was enabled. When "claim" has been
  424. set to 0, userspace should make sure that it listens for the input events or
  425. check the sysfs "state" entry regularly to correctly perform the required tasks
  426. when the rkfill key is pressed.
  427. A note about input devices and EV_SW events:
  428. In order to know the current state of an input device switch (like
  429. SW_RFKILL_ALL), you will need to use an IOCTL. That information is not
  430. available through sysfs in a generic way at this time, and it is not available
  431. through the rfkill class AT ALL.