diff options
-rw-r--r-- | Documentation/networking/ieee802154.rst (renamed from Documentation/networking/ieee802154.txt) | 193 | ||||
-rw-r--r-- | Documentation/networking/index.rst | 1 |
2 files changed, 99 insertions, 95 deletions
diff --git a/Documentation/networking/ieee802154.txt b/Documentation/networking/ieee802154.rst index e74d8e1da0e2..36ca823a1122 100644 --- a/Documentation/networking/ieee802154.txt +++ b/Documentation/networking/ieee802154.rst | |||
@@ -1,54 +1,79 @@ | |||
1 | 1 | =============================== | |
2 | Linux IEEE 802.15.4 implementation | 2 | IEEE 802.15.4 Developer's Guide |
3 | 3 | =============================== | |
4 | 4 | ||
5 | Introduction | 5 | Introduction |
6 | ============ | 6 | ============ |
7 | The IEEE 802.15.4 working group focuses on standardization of the bottom | 7 | The IEEE 802.15.4 working group focuses on standardization of the bottom |
8 | two layers: Medium Access Control (MAC) and Physical access (PHY). And there | 8 | two layers: Medium Access Control (MAC) and Physical access (PHY). And there |
9 | are mainly two options available for upper layers: | 9 | are mainly two options available for upper layers: |
10 | - ZigBee - proprietary protocol from the ZigBee Alliance | 10 | |
11 | - 6LoWPAN - IPv6 networking over low rate personal area networks | 11 | - ZigBee - proprietary protocol from the ZigBee Alliance |
12 | - 6LoWPAN - IPv6 networking over low rate personal area networks | ||
12 | 13 | ||
13 | The goal of the Linux-wpan is to provide a complete implementation | 14 | The goal of the Linux-wpan is to provide a complete implementation |
14 | of the IEEE 802.15.4 and 6LoWPAN protocols. IEEE 802.15.4 is a stack | 15 | of the IEEE 802.15.4 and 6LoWPAN protocols. IEEE 802.15.4 is a stack |
15 | of protocols for organizing Low-Rate Wireless Personal Area Networks. | 16 | of protocols for organizing Low-Rate Wireless Personal Area Networks. |
16 | 17 | ||
17 | The stack is composed of three main parts: | 18 | The stack is composed of three main parts: |
18 | - IEEE 802.15.4 layer; We have chosen to use plain Berkeley socket API, | ||
19 | the generic Linux networking stack to transfer IEEE 802.15.4 data | ||
20 | messages and a special protocol over netlink for configuration/management | ||
21 | - MAC - provides access to shared channel and reliable data delivery | ||
22 | - PHY - represents device drivers | ||
23 | 19 | ||
20 | - IEEE 802.15.4 layer; We have chosen to use plain Berkeley socket API, | ||
21 | the generic Linux networking stack to transfer IEEE 802.15.4 data | ||
22 | messages and a special protocol over netlink for configuration/management | ||
23 | - MAC - provides access to shared channel and reliable data delivery | ||
24 | - PHY - represents device drivers | ||
24 | 25 | ||
25 | Socket API | 26 | Socket API |
26 | ========== | 27 | ========== |
27 | 28 | ||
28 | int sd = socket(PF_IEEE802154, SOCK_DGRAM, 0); | 29 | .. c:function:: int sd = socket(PF_IEEE802154, SOCK_DGRAM, 0); |
29 | ..... | ||
30 | 30 | ||
31 | The address family, socket addresses etc. are defined in the | 31 | The address family, socket addresses etc. are defined in the |
32 | include/net/af_ieee802154.h header or in the special header | 32 | include/net/af_ieee802154.h header or in the special header |
33 | in the userspace package (see either http://wpan.cakelab.org/ or the | 33 | in the userspace package (see either http://wpan.cakelab.org/ or the |
34 | git tree at https://github.com/linux-wpan/wpan-tools). | 34 | git tree at https://github.com/linux-wpan/wpan-tools). |
35 | 35 | ||
36 | 6LoWPAN Linux implementation | ||
37 | ============================ | ||
38 | |||
39 | The IEEE 802.15.4 standard specifies an MTU of 127 bytes, yielding about 80 | ||
40 | octets of actual MAC payload once security is turned on, on a wireless link | ||
41 | with a link throughput of 250 kbps or less. The 6LoWPAN adaptation format | ||
42 | [RFC4944] was specified to carry IPv6 datagrams over such constrained links, | ||
43 | taking into account limited bandwidth, memory, or energy resources that are | ||
44 | expected in applications such as wireless Sensor Networks. [RFC4944] defines | ||
45 | a Mesh Addressing header to support sub-IP forwarding, a Fragmentation header | ||
46 | to support the IPv6 minimum MTU requirement [RFC2460], and stateless header | ||
47 | compression for IPv6 datagrams (LOWPAN_HC1 and LOWPAN_HC2) to reduce the | ||
48 | relatively large IPv6 and UDP headers down to (in the best case) several bytes. | ||
49 | |||
50 | In September 2011 the standard update was published - [RFC6282]. | ||
51 | It deprecates HC1 and HC2 compression and defines IPHC encoding format which is | ||
52 | used in this Linux implementation. | ||
53 | |||
54 | All the code related to 6lowpan you may find in files: net/6lowpan/* | ||
55 | and net/ieee802154/6lowpan/* | ||
56 | |||
57 | To setup a 6LoWPAN interface you need: | ||
58 | 1. Add IEEE802.15.4 interface and set channel and PAN ID; | ||
59 | 2. Add 6lowpan interface by command like: | ||
60 | # ip link add link wpan0 name lowpan0 type lowpan | ||
61 | 3. Bring up 'lowpan0' interface | ||
36 | 62 | ||
37 | Kernel side | 63 | Drivers |
38 | ============= | 64 | ======= |
39 | 65 | ||
40 | Like with WiFi, there are several types of devices implementing IEEE 802.15.4. | 66 | Like with WiFi, there are several types of devices implementing IEEE 802.15.4. |
41 | 1) 'HardMAC'. The MAC layer is implemented in the device itself, the device | 67 | 1) 'HardMAC'. The MAC layer is implemented in the device itself, the device |
42 | exports a management (e.g. MLME) and data API. | 68 | exports a management (e.g. MLME) and data API. |
43 | 2) 'SoftMAC' or just radio. These types of devices are just radio transceivers | 69 | 2) 'SoftMAC' or just radio. These types of devices are just radio transceivers |
44 | possibly with some kinds of acceleration like automatic CRC computation and | 70 | possibly with some kinds of acceleration like automatic CRC computation and |
45 | comparation, automagic ACK handling, address matching, etc. | 71 | comparation, automagic ACK handling, address matching, etc. |
46 | 72 | ||
47 | Those types of devices require different approach to be hooked into Linux kernel. | 73 | Those types of devices require different approach to be hooked into Linux kernel. |
48 | 74 | ||
49 | |||
50 | HardMAC | 75 | HardMAC |
51 | ======= | 76 | ------- |
52 | 77 | ||
53 | See the header include/net/ieee802154_netdev.h. You have to implement Linux | 78 | See the header include/net/ieee802154_netdev.h. You have to implement Linux |
54 | net_device, with .type = ARPHRD_IEEE802154. Data is exchanged with socket family | 79 | net_device, with .type = ARPHRD_IEEE802154. Data is exchanged with socket family |
@@ -64,9 +89,8 @@ net_device with a pointer to struct ieee802154_mlme_ops instance. The fields | |||
64 | assoc_req, assoc_resp, disassoc_req, start_req, and scan_req are optional. | 89 | assoc_req, assoc_resp, disassoc_req, start_req, and scan_req are optional. |
65 | All other fields are required. | 90 | All other fields are required. |
66 | 91 | ||
67 | |||
68 | SoftMAC | 92 | SoftMAC |
69 | ======= | 93 | ------- |
70 | 94 | ||
71 | The MAC is the middle layer in the IEEE 802.15.4 Linux stack. This moment it | 95 | The MAC is the middle layer in the IEEE 802.15.4 Linux stack. This moment it |
72 | provides interface for drivers registration and management of slave interfaces. | 96 | provides interface for drivers registration and management of slave interfaces. |
@@ -79,99 +103,78 @@ This layer is going to be extended soon. | |||
79 | See header include/net/mac802154.h and several drivers in | 103 | See header include/net/mac802154.h and several drivers in |
80 | drivers/net/ieee802154/. | 104 | drivers/net/ieee802154/. |
81 | 105 | ||
106 | Fake drivers | ||
107 | ------------ | ||
108 | |||
109 | In addition there is a driver available which simulates a real device with | ||
110 | SoftMAC (fakelb - IEEE 802.15.4 loopback driver) interface. This option | ||
111 | provides a possibility to test and debug the stack without usage of real hardware. | ||
82 | 112 | ||
83 | Device drivers API | 113 | Device drivers API |
84 | ================== | 114 | ================== |
85 | 115 | ||
86 | The include/net/mac802154.h defines following functions: | 116 | The include/net/mac802154.h defines following functions: |
87 | - struct ieee802154_hw * | ||
88 | ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops): | ||
89 | allocation of IEEE 802.15.4 compatible hardware device | ||
90 | 117 | ||
91 | - void ieee802154_free_hw(struct ieee802154_hw *hw): | 118 | .. c:function:: struct ieee802154_dev *ieee802154_alloc_device (size_t priv_size, struct ieee802154_ops *ops) |
92 | freeing allocated hardware device | ||
93 | 119 | ||
94 | - int ieee802154_register_hw(struct ieee802154_hw *hw): | 120 | Allocation of IEEE 802.15.4 compatible device. |
95 | register PHY which is the allocated hardware device, in the system | ||
96 | 121 | ||
97 | - void ieee802154_unregister_hw(struct ieee802154_hw *hw): | 122 | .. c:function:: void ieee802154_free_device(struct ieee802154_dev *dev) |
98 | freeing registered PHY | ||
99 | 123 | ||
100 | - void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, | 124 | Freeing allocated device. |
101 | u8 lqi): | ||
102 | telling 802.15.4 module there is a new received frame in the skb with | ||
103 | the RF Link Quality Indicator (LQI) from the hardware device | ||
104 | 125 | ||
105 | - void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb, | 126 | .. c:function:: int ieee802154_register_device(struct ieee802154_dev *dev) |
106 | bool ifs_handling): | 127 | |
107 | telling 802.15.4 module the frame in the skb is or going to be | 128 | Register PHY in the system. |
108 | transmitted through the hardware device | 129 | |
130 | .. c:function:: void ieee802154_unregister_device(struct ieee802154_dev *dev) | ||
131 | |||
132 | Freeing registered PHY. | ||
133 | |||
134 | .. c:function:: void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi): | ||
135 | |||
136 | Telling 802.15.4 module there is a new received frame in the skb with | ||
137 | the RF Link Quality Indicator (LQI) from the hardware device. | ||
138 | |||
139 | .. c:function:: void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb, bool ifs_handling): | ||
140 | |||
141 | Telling 802.15.4 module the frame in the skb is or going to be | ||
142 | transmitted through the hardware device | ||
109 | 143 | ||
110 | The device driver must implement the following callbacks in the IEEE 802.15.4 | 144 | The device driver must implement the following callbacks in the IEEE 802.15.4 |
111 | operations structure at least: | 145 | operations structure at least:: |
112 | struct ieee802154_ops { | ||
113 | ... | ||
114 | int (*start)(struct ieee802154_hw *hw); | ||
115 | void (*stop)(struct ieee802154_hw *hw); | ||
116 | ... | ||
117 | int (*xmit_async)(struct ieee802154_hw *hw, struct sk_buff *skb); | ||
118 | int (*ed)(struct ieee802154_hw *hw, u8 *level); | ||
119 | int (*set_channel)(struct ieee802154_hw *hw, u8 page, u8 channel); | ||
120 | ... | ||
121 | }; | ||
122 | |||
123 | - int start(struct ieee802154_hw *hw): | ||
124 | handler that 802.15.4 module calls for the hardware device initialization. | ||
125 | |||
126 | - void stop(struct ieee802154_hw *hw): | ||
127 | handler that 802.15.4 module calls for the hardware device cleanup. | ||
128 | |||
129 | - int xmit_async(struct ieee802154_hw *hw, struct sk_buff *skb): | ||
130 | handler that 802.15.4 module calls for each frame in the skb going to be | ||
131 | transmitted through the hardware device. | ||
132 | |||
133 | - int ed(struct ieee802154_hw *hw, u8 *level): | ||
134 | handler that 802.15.4 module calls for Energy Detection from the hardware | ||
135 | device. | ||
136 | |||
137 | - int set_channel(struct ieee802154_hw *hw, u8 page, u8 channel): | ||
138 | set radio for listening on specific channel of the hardware device. | ||
139 | 146 | ||
140 | Moreover IEEE 802.15.4 device operations structure should be filled. | 147 | struct ieee802154_ops { |
148 | ... | ||
149 | int (*start)(struct ieee802154_hw *hw); | ||
150 | void (*stop)(struct ieee802154_hw *hw); | ||
151 | ... | ||
152 | int (*xmit_async)(struct ieee802154_hw *hw, struct sk_buff *skb); | ||
153 | int (*ed)(struct ieee802154_hw *hw, u8 *level); | ||
154 | int (*set_channel)(struct ieee802154_hw *hw, u8 page, u8 channel); | ||
155 | ... | ||
156 | }; | ||
141 | 157 | ||
142 | Fake drivers | 158 | .. c:function:: int start(struct ieee802154_hw *hw): |
143 | ============ | ||
144 | 159 | ||
145 | In addition there is a driver available which simulates a real device with | 160 | Handler that 802.15.4 module calls for the hardware device initialization. |
146 | SoftMAC (fakelb - IEEE 802.15.4 loopback driver) interface. This option | ||
147 | provides a possibility to test and debug the stack without usage of real hardware. | ||
148 | 161 | ||
149 | See sources in drivers/net/ieee802154 folder for more details. | 162 | .. c:function:: void stop(struct ieee802154_hw *hw): |
150 | 163 | ||
164 | Handler that 802.15.4 module calls for the hardware device cleanup. | ||
151 | 165 | ||
152 | 6LoWPAN Linux implementation | 166 | .. c:function:: int xmit_async(struct ieee802154_hw *hw, struct sk_buff *skb): |
153 | ============================ | ||
154 | 167 | ||
155 | The IEEE 802.15.4 standard specifies an MTU of 127 bytes, yielding about 80 | 168 | Handler that 802.15.4 module calls for each frame in the skb going to be |
156 | octets of actual MAC payload once security is turned on, on a wireless link | 169 | transmitted through the hardware device. |
157 | with a link throughput of 250 kbps or less. The 6LoWPAN adaptation format | ||
158 | [RFC4944] was specified to carry IPv6 datagrams over such constrained links, | ||
159 | taking into account limited bandwidth, memory, or energy resources that are | ||
160 | expected in applications such as wireless Sensor Networks. [RFC4944] defines | ||
161 | a Mesh Addressing header to support sub-IP forwarding, a Fragmentation header | ||
162 | to support the IPv6 minimum MTU requirement [RFC2460], and stateless header | ||
163 | compression for IPv6 datagrams (LOWPAN_HC1 and LOWPAN_HC2) to reduce the | ||
164 | relatively large IPv6 and UDP headers down to (in the best case) several bytes. | ||
165 | 170 | ||
166 | In September 2011 the standard update was published - [RFC6282]. | 171 | .. c:function:: int ed(struct ieee802154_hw *hw, u8 *level): |
167 | It deprecates HC1 and HC2 compression and defines IPHC encoding format which is | ||
168 | used in this Linux implementation. | ||
169 | 172 | ||
170 | All the code related to 6lowpan you may find in files: net/6lowpan/* | 173 | Handler that 802.15.4 module calls for Energy Detection from the hardware |
171 | and net/ieee802154/6lowpan/* | 174 | device. |
172 | 175 | ||
173 | To setup a 6LoWPAN interface you need: | 176 | .. c:function:: int set_channel(struct ieee802154_hw *hw, u8 page, u8 channel): |
174 | 1. Add IEEE802.15.4 interface and set channel and PAN ID; | 177 | |
175 | 2. Add 6lowpan interface by command like: | 178 | Set radio for listening on specific channel of the hardware device. |
176 | # ip link add link wpan0 name lowpan0 type lowpan | 179 | |
177 | 3. Bring up 'lowpan0' interface | 180 | Moreover IEEE 802.15.4 device operations structure should be filled. |
diff --git a/Documentation/networking/index.rst b/Documentation/networking/index.rst index b08cf145d5eb..f0da1b001514 100644 --- a/Documentation/networking/index.rst +++ b/Documentation/networking/index.rst | |||
@@ -25,6 +25,7 @@ Contents: | |||
25 | device_drivers/intel/iavf | 25 | device_drivers/intel/iavf |
26 | device_drivers/intel/ice | 26 | device_drivers/intel/ice |
27 | devlink-info-versions | 27 | devlink-info-versions |
28 | ieee802154 | ||
28 | kapi | 29 | kapi |
29 | z8530book | 30 | z8530book |
30 | msg_zerocopy | 31 | msg_zerocopy |