Skip to content

Commit bd038fc

Browse files
fg-cfhcarlescufi
authored andcommitted
doc: ieee802154: l2: improved docs
Hides types used in the IEEE 802.15.4 L2 sub-API and L2-internal APIs that are of no public interest and improves documentation of the remainder. The changes are mostly minor as the API documentation had already been improved and clarified in previous changes. Also includes non-visible documentation to the subsystem-internal Frame API by adding references to the specification. Signed-off-by: Florian Grandel <[email protected]>
1 parent 9864d03 commit bd038fc

File tree

2 files changed

+198
-75
lines changed

2 files changed

+198
-75
lines changed

include/zephyr/net/ieee802154.h

Lines changed: 164 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
/**
88
* @file
9-
* @brief IEEE 802.15.4 L2 stack public header
9+
* @brief IEEE 802.15.4 native L2 stack public header
10+
*
11+
* @note All references to the standard in this file cite IEEE 802.15.4-2020.
1012
*/
1113

1214
#ifndef ZEPHYR_INCLUDE_NET_IEEE802154_H_
@@ -88,41 +90,118 @@ extern "C" {
8890
* - protocol-specific extension to the interface structure (see @ref net_if)
8991
* - protocol-specific extensions to the network packet structure
9092
* (see @ref net_pkt),
93+
*
94+
* @note All section, table and figure references are to the IEEE 802.15.4-2020
95+
* standard.
96+
*
9197
* @{
9298
*/
9399

94-
/* References are to the IEEE 802.15.4-2020 standard */
95-
#define IEEE802154_MAX_PHY_PACKET_SIZE 127 /* see section 11.3, aMaxPhyPacketSize */
96-
#define IEEE802154_FCS_LENGTH 2 /* see section 7.2.1.1 */
100+
#define IEEE802154_MAX_PHY_PACKET_SIZE 127 /**< see section 11.3, aMaxPhyPacketSize */
101+
#define IEEE802154_FCS_LENGTH 2 /**< see section 7.2.1.1 */
102+
103+
/**
104+
* @brief IEEE 802.15.4 "hardware" MTU (not to be confused with L3/IP MTU), i.e.
105+
* the actual payload available to the next higher layer.
106+
*
107+
* @details This is equivalent to the IEEE 802.15.4 MAC frame length minus
108+
* checksum bytes which is again equivalent to the PHY payload aka PSDU length
109+
* minus checksum bytes. This definition exists for compatibility with the same
110+
* concept in Linux and Zephyr's L3. It is not a concept from the IEEE 802.15.4
111+
* standard.
112+
*
113+
* @note Currently we only support the original frame size from the 2006
114+
* standard version and earlier. The 2015+ standard introduced PHYs with larger
115+
* PHY payload. These are not (yet) supported in Zephyr.
116+
*/
97117
#define IEEE802154_MTU (IEEE802154_MAX_PHY_PACKET_SIZE - IEEE802154_FCS_LENGTH)
118+
98119
/* TODO: Support flexible MTU and FCS lengths for IEEE 802.15.4-2015ff */
99120

121+
/** IEEE 802.15.4 short address length. */
100122
#define IEEE802154_SHORT_ADDR_LENGTH 2
123+
124+
/** IEEE 802.15.4 extended address length. */
101125
#define IEEE802154_EXT_ADDR_LENGTH 8
126+
127+
/** IEEE 802.15.4 maximum address length. */
102128
#define IEEE802154_MAX_ADDR_LENGTH IEEE802154_EXT_ADDR_LENGTH
103129

130+
/**
131+
* A special channel value that symbolizes "all" channels or "any" channel -
132+
* depending on context.
133+
*/
104134
#define IEEE802154_NO_CHANNEL USHRT_MAX
105135

106-
/* See IEEE 802.15.4-2020, sections 6.1 and 7.3.5 */
136+
/**
137+
* @{
138+
* See sections 6.1 and 7.3.5
139+
*/
107140
#define IEEE802154_BROADCAST_ADDRESS 0xffff
108141
#define IEEE802154_NO_SHORT_ADDRESS_ASSIGNED 0xfffe
142+
/** @} */
109143

110-
/* See IEEE 802.15.4-2020, section 6.1 */
144+
/* See section 6.1 */
111145
#define IEEE802154_BROADCAST_PAN_ID 0xffff
112146

113-
/* See IEEE 802.15.4-2020, section 7.3.5 */
147+
/* See section 7.3.5 */
114148
#define IEEE802154_SHORT_ADDRESS_NOT_ASSOCIATED IEEE802154_BROADCAST_ADDRESS
115149
#define IEEE802154_PAN_ID_NOT_ASSOCIATED IEEE802154_BROADCAST_PAN_ID
116150

151+
/** interface-level security attributes, see section 9.5. */
117152
struct ieee802154_security_ctx {
153+
/** section 9.5, secFrameCounter */
118154
uint32_t frame_counter;
155+
156+
/** @cond INTERNAL_HIDDEN */
119157
struct cipher_ctx enc;
120158
struct cipher_ctx dec;
159+
/** INTERNAL_HIDDEN @endcond */
160+
161+
/**
162+
* @brief frame-level security key material
163+
*
164+
* @details Currently native L2 only supports a single secKeySource, see
165+
* section 9.5, table 9-9, in combination with secKeyMode zero (implicit
166+
* key mode), see section 9.4.2.3, table 9-7.
167+
*
168+
* @warning This is no longer in accordance with the current version of
169+
* the standard and needs to be extended in the future for full security
170+
* procedure compliance.
171+
*/
121172
uint8_t key[16];
173+
174+
/** frame-level security key material */
122175
uint8_t key_len;
176+
177+
/**
178+
* @brief security level
179+
*
180+
* @details Currently native L2 supports a single security level for all
181+
* frame types, commands and information elements, see section 9.4.2.2,
182+
* table 9-6 and ieee802154_security_level.
183+
*
184+
* @warning This is no longer in accordance with the current version of
185+
* the standard and needs to be extended in the future for full security
186+
* procedure compliance.
187+
*/
123188
uint8_t level : 3;
189+
190+
/**
191+
* @brief key_mode
192+
*
193+
* @details Currently only implicit key mode is partially supported, see
194+
* section 9.4.2.3, table 9-7, secKeyMode.
195+
*
196+
* @warning This is no longer in accordance with the current version of
197+
* the standard and needs to be extended in the future for full security
198+
* procedure compliance.
199+
*/
124200
uint8_t key_mode : 2;
201+
202+
/** @cond INTERNAL_HIDDEN */
125203
uint8_t _unused : 3;
204+
/** INTERNAL_HIDDEN @endcond */
126205
};
127206

128207
enum ieee802154_device_role {
@@ -131,63 +210,77 @@ enum ieee802154_device_role {
131210
IEEE802154_DEVICE_ROLE_PAN_COORDINATOR,
132211
};
133212

134-
/* This not meant to be used by any code but the IEEE 802.15.4 L2 stack */
213+
/** IEEE 802.15.4 L2 context. */
135214
struct ieee802154_context {
136-
/* PAN ID
215+
/**
216+
* @brief PAN ID
137217
*
138-
* The identifier of the PAN on which the device is operating. If this
139-
* value is 0xffff, the device is not associated. See section 8.4.3.1,
140-
* table 8-94, macPanId.
218+
* @details The identifier of the PAN on which the device is operating.
219+
* If this value is 0xffff, the device is not associated. See section
220+
* 8.4.3.1, table 8-94, macPanId.
141221
*
142222
* in CPU byte order
143223
*/
144224
uint16_t pan_id;
145225

146-
/* Channel Number
226+
/**
227+
* @brief Channel Number
147228
*
148-
* The RF channel to use for all transmissions and receptions, see
149-
* section 11.3, table 11-2, phyCurrentChannel. The allowable range
229+
* @details The RF channel to use for all transmissions and receptions,
230+
* see section 11.3, table 11-2, phyCurrentChannel. The allowable range
150231
* of values is PHY dependent as defined in section 10.1.3.
151232
*
152233
* in CPU byte order
153234
*/
154235
uint16_t channel;
155236

156-
/* Short Address
237+
/**
238+
* @brief Short Address (in CPU byte order)
157239
*
158-
* Range:
240+
* @details Range:
159241
* * 0x0000–0xfffd: associated, short address was assigned
160242
* * 0xfffe: associated but no short address assigned
161243
* * 0xffff: not associated (default),
162244
*
163245
* See section 6.4.1, table 6-4 (Usage of the shart address) and
164246
* section 8.4.3.1, table 8-94, macShortAddress.
165-
*
166-
* in CPU byte order
167247
*/
168248
uint16_t short_addr;
169249

170-
/* Extended Address
250+
/**
251+
* @brief Extended Address (in little endian)
171252
*
172-
* The extended address is device specific, usually permanently stored
173-
* on the device and immutable.
253+
* @details The extended address is device specific, usually permanently
254+
* stored on the device and immutable.
174255
*
175256
* See section 8.4.3.1, table 8-94, macExtendedAddress.
176-
*
177-
* in little endian
178257
*/
179258
uint8_t ext_addr[IEEE802154_MAX_ADDR_LENGTH];
180259

181-
struct net_linkaddr_storage linkaddr; /* in big endian */
260+
/** Link layer address (in big endian) */
261+
struct net_linkaddr_storage linkaddr;
262+
182263
#ifdef CONFIG_NET_L2_IEEE802154_SECURITY
264+
/** Security context */
183265
struct ieee802154_security_ctx sec_ctx;
184266
#endif
267+
185268
#ifdef CONFIG_NET_L2_IEEE802154_MGMT
186-
struct ieee802154_req_params *scan_ctx; /* guarded by scan_ctx_lock */
269+
/** Pointer to scanning parameters and results, guarded by scan_ctx_lock */
270+
struct ieee802154_req_params *scan_ctx;
271+
272+
/**
273+
* Used to maintain integrity of data for all fields in this struct
274+
* unless otherwise documented on field level.
275+
*/
187276
struct k_sem scan_ctx_lock;
188277

189-
/* see section 8.4.3.1, table 8-94, macCoordExtendedAddress, the address
190-
* of the coordinator through which the device is associated.
278+
/**
279+
* @brief Coordinator extended address
280+
*
281+
* @details see section 8.4.3.1, table 8-94, macCoordExtendedAddress,
282+
* the address of the coordinator through which the device is
283+
* associated.
191284
*
192285
* A value of zero indicates that a coordinator extended address is
193286
* unknown (default).
@@ -196,8 +289,11 @@ struct ieee802154_context {
196289
*/
197290
uint8_t coord_ext_addr[IEEE802154_MAX_ADDR_LENGTH];
198291

199-
/* see section 8.4.3.1, table 8-94, macCoordShortAddress, the short
200-
* address assigned to the coordinator through which the device is
292+
/**
293+
* @brief Coordinator short address
294+
*
295+
* @details see section 8.4.3.1, table 8-94, macCoordShortAddress, the
296+
* short address assigned to the coordinator through which the device is
201297
* associated.
202298
*
203299
* A value of 0xfffe indicates that the coordinator is only using its
@@ -208,36 +304,64 @@ struct ieee802154_context {
208304
*/
209305
uint16_t coord_short_addr;
210306
#endif
307+
308+
/** transmission power */
211309
int16_t tx_power;
310+
311+
/** L2 flags */
212312
enum net_l2_flags flags;
213313

214-
/* The sequence number added to the transmitted Data frame or MAC
215-
* command, see section 8.4.3.1, table 8-94, macDsn.
314+
/**
315+
* @brief DSN
316+
*
317+
* @details The sequence number added to the transmitted Data frame or
318+
* MAC command, see section 8.4.3.1, table 8-94, macDsn.
216319
*/
217320
uint8_t sequence;
218321

219-
/* See section 6.1: A device may be operating as end device
220-
* (0 - default), coordinator (1), or PAN coordinator (2).
322+
/**
323+
* @brief Device Role
324+
*
325+
* @details See section 6.1: A device may be operating as end device (0
326+
* - default), coordinator (1), or PAN coordinator (2).
221327
*
222328
* A value of 3 is undefined.
223329
*
224-
* Can be read/set via enum ieee802154_device_role.
330+
* Can be read/set via @ref ieee802154_device_role.
225331
*/
226332
uint8_t device_role : 2;
227333

334+
/** @cond INTERNAL_HIDDEN */
228335
uint8_t _unused : 5;
336+
/** INTERNAL_HIDDEN @endcond */
229337

230-
uint8_t ack_requested : 1; /* guarded by ack_lock */
231-
uint8_t ack_seq; /* guarded by ack_lock */
338+
/**
339+
* ACK requested flag, guarded by ack_lock
340+
*/
341+
uint8_t ack_requested: 1;
342+
343+
/** ACK expected sequence number, guarded by ack_lock */
344+
uint8_t ack_seq;
345+
346+
/** ACK lock, guards ack_* fields */
232347
struct k_sem ack_lock;
233348

234-
struct k_sem ctx_lock; /* guards all mutable context attributes unless
235-
* otherwise mentioned on attribute level
236-
*/
349+
/**
350+
* @brief Context lock
351+
*
352+
* @details guards all mutable context attributes unless otherwise
353+
* mentioned on attribute level
354+
*/
355+
struct k_sem ctx_lock;
237356
};
238357

358+
/** @cond INTERNAL_HIDDEN */
359+
360+
/* L2 context type to be used with NET_L2_GET_CTX_TYPE */
239361
#define IEEE802154_L2_CTX_TYPE struct ieee802154_context
240362

363+
/** INTERNAL_HIDDEN @endcond */
364+
241365
#ifdef __cplusplus
242366
}
243367
#endif

0 commit comments

Comments
 (0)