Zephyr Project API  3.3.0
A Scalable Open Source RTOS
ieee802154_radio.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_NET_IEEE802154_RADIO_H_
13#define ZEPHYR_INCLUDE_NET_IEEE802154_RADIO_H_
14
15#include <zephyr/device.h>
16#include <zephyr/net/net_if.h>
17#include <zephyr/net/net_pkt.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
45};
46
48 IEEE802154_HW_FCS = BIT(0), /* Frame Check-Sum supported */
49 IEEE802154_HW_PROMISC = BIT(1), /* Promiscuous mode supported */
50 IEEE802154_HW_FILTER = BIT(2), /* Filter PAN ID, long/short addr */
51 IEEE802154_HW_CSMA = BIT(3), /* CSMA-CA supported */
52 IEEE802154_HW_2_4_GHZ = BIT(4), /* 2.4Ghz radio supported */
53 IEEE802154_HW_TX_RX_ACK = BIT(5), /* Handles ACK request on TX */
54 IEEE802154_HW_SUB_GHZ = BIT(6), /* Sub-GHz radio supported */
55 IEEE802154_HW_ENERGY_SCAN = BIT(7), /* Energy scan supported */
56 IEEE802154_HW_TXTIME = BIT(8), /* TX at specified time supported */
57 IEEE802154_HW_SLEEP_TO_TX = BIT(9), /* TX directly from sleep supported */
58 IEEE802154_HW_TX_SEC = BIT(10), /* TX security handling supported */
59 IEEE802154_HW_RXTIME = BIT(11), /* RX at specified time supported */
60};
61
68};
69
71 IEEE802154_EVENT_TX_STARTED, /* Data transmission started */
72 IEEE802154_EVENT_RX_FAILED, /* Data reception failed */
73 IEEE802154_EVENT_SLEEP, /* Sleep pending */
74};
75
77 IEEE802154_RX_FAIL_NOT_RECEIVED, /* Nothing received */
78 IEEE802154_RX_FAIL_INVALID_FCS, /* Frame had invalid checksum */
79 IEEE802154_RX_FAIL_ADDR_FILTERED, /* Address did not match */
80 IEEE802154_RX_FAIL_OTHER /* General reason */
81};
82
83typedef void (*energy_scan_done_cb_t)(const struct device *dev,
84 int16_t max_ed);
85
86typedef void (*ieee802154_event_cb_t)(const struct device *dev,
87 enum ieee802154_event evt,
88 void *event_params);
89
92 union {
93 uint8_t *ieee_addr; /* in little endian */
94 uint16_t short_addr; /* in CPU byte order */
95 uint16_t pan_id; /* in CPU byte order */
96 };
97/* @endcond */
98};
99
106};
107
112
115
118
121
124};
125
131
136};
137
148
154
157
160
165
168
171
208
211
216
222};
223
227 union {
229 struct {
233
235 struct {
236 uint8_t *addr; /* in little endian for both, short and extended address */
238 bool enabled;
240
243
246
249
262
265
267 struct {
272
274 uint32_t csl_period; /* in CPU byte order */
275
277 uint32_t csl_rx_time; /* in microseconds,
278 * based on ieee802154_radio_api.get_time()
279 */
280
282 struct {
283 const uint8_t *data; /* header IEs to be added to the Enh-Ack frame in
284 * little endian byte order
285 */
287 uint16_t short_addr; /* in CPU byte order */
297 const uint8_t *ext_addr; /* in big endian */
299 };
300};
301
313 struct net_if_api iface_api;
314
316 enum ieee802154_hw_caps (*get_capabilities)(const struct device *dev);
317
319 int (*cca)(const struct device *dev);
320
322 int (*set_channel)(const struct device *dev, uint16_t channel);
323
325 int (*filter)(const struct device *dev,
326 bool set,
327 enum ieee802154_filter_type type,
328 const struct ieee802154_filter *filter);
329
331 int (*set_txpower)(const struct device *dev, int16_t dbm);
332
334 int (*tx)(const struct device *dev, enum ieee802154_tx_mode mode,
335 struct net_pkt *pkt, struct net_buf *frag);
336
338 int (*start)(const struct device *dev);
339
341 int (*stop)(const struct device *dev);
342
344 int (*configure)(const struct device *dev,
345 enum ieee802154_config_type type,
346 const struct ieee802154_config *config);
347
350
355 int (*ed_scan)(const struct device *dev,
356 uint16_t duration,
357 energy_scan_done_cb_t done_cb);
358
360 uint64_t (*get_time)(const struct device *dev);
361
367 uint8_t (*get_sch_acc)(const struct device *dev);
368};
369
370/* Make sure that the network interface API is properly setup inside
371 * IEEE 802154 radio API struct (it is the first one).
372 */
373BUILD_ASSERT(offsetof(struct ieee802154_radio_api, iface_api) == 0);
374
375#define IEEE802154_AR_FLAG_SET (0x20)
376
387static inline bool ieee802154_is_ar_flag_set(struct net_buf *frag)
388{
389 return (*frag->data & IEEE802154_AR_FLAG_SET);
390}
391
404 struct net_pkt *pkt);
405
411#ifndef CONFIG_IEEE802154_RAW_MODE
412void ieee802154_init(struct net_if *iface);
413#else
414#define ieee802154_init(_iface_)
415#endif /* CONFIG_IEEE802154_RAW_MODE */
416
417#ifdef __cplusplus
418}
419#endif
420
425#endif /* ZEPHYR_INCLUDE_NET_IEEE802154_RADIO_H_ */
ieee802154_rx_fail_reason
Definition: ieee802154_radio.h:76
ieee802154_channel
IEEE 802.15.4 Channel assignments.
Definition: ieee802154_radio.h:40
ieee802154_event
Definition: ieee802154_radio.h:70
ieee802154_config_type
Definition: ieee802154_radio.h:139
enum net_verdict ieee802154_radio_handle_ack(struct net_if *iface, struct net_pkt *pkt)
Radio driver ACK handling function that hw drivers should use.
void(* ieee802154_event_cb_t)(const struct device *dev, enum ieee802154_event evt, void *event_params)
Definition: ieee802154_radio.h:86
#define IEEE802154_AR_FLAG_SET
Definition: ieee802154_radio.h:375
void(* energy_scan_done_cb_t)(const struct device *dev, int16_t max_ed)
Definition: ieee802154_radio.h:83
ieee802154_filter_type
Definition: ieee802154_radio.h:62
ieee802154_tx_mode
Definition: ieee802154_radio.h:109
ieee802154_fpb_mode
Definition: ieee802154_radio.h:127
void ieee802154_init(struct net_if *iface)
Initialize L2 stack for a given interface.
static bool ieee802154_is_ar_flag_set(struct net_buf *frag)
Check if AR flag is set on the frame inside given net_pkt.
Definition: ieee802154_radio.h:387
ieee802154_hw_caps
Definition: ieee802154_radio.h:47
@ IEEE802154_RX_FAIL_INVALID_FCS
Definition: ieee802154_radio.h:78
@ IEEE802154_RX_FAIL_OTHER
Definition: ieee802154_radio.h:80
@ IEEE802154_RX_FAIL_ADDR_FILTERED
Definition: ieee802154_radio.h:79
@ IEEE802154_RX_FAIL_NOT_RECEIVED
Definition: ieee802154_radio.h:77
@ IEEE802154_2_4_GHZ_CHANNEL_MAX
Definition: ieee802154_radio.h:44
@ IEEE802154_SUB_GHZ_CHANNEL_MIN
Definition: ieee802154_radio.h:41
@ IEEE802154_2_4_GHZ_CHANNEL_MIN
Definition: ieee802154_radio.h:43
@ IEEE802154_SUB_GHZ_CHANNEL_MAX
Definition: ieee802154_radio.h:42
@ IEEE802154_EVENT_TX_STARTED
Definition: ieee802154_radio.h:71
@ IEEE802154_EVENT_RX_FAILED
Definition: ieee802154_radio.h:72
@ IEEE802154_EVENT_SLEEP
Definition: ieee802154_radio.h:73
@ IEEE802154_CONFIG_AUTO_ACK_FPB
Definition: ieee802154_radio.h:147
@ IEEE802154_CONFIG_PROMISCUOUS
Definition: ieee802154_radio.h:159
@ IEEE802154_CONFIG_ENH_ACK_HEADER_IE
Definition: ieee802154_radio.h:221
@ IEEE802154_CONFIG_MAC_KEYS
Definition: ieee802154_radio.h:167
@ IEEE802154_CONFIG_EVENT_HANDLER
Definition: ieee802154_radio.h:164
@ IEEE802154_CONFIG_CSL_PERIOD
Definition: ieee802154_radio.h:210
@ IEEE802154_CONFIG_CSL_RX_TIME
Definition: ieee802154_radio.h:215
@ IEEE802154_CONFIG_FRAME_COUNTER
Definition: ieee802154_radio.h:170
@ IEEE802154_CONFIG_PAN_COORDINATOR
Definition: ieee802154_radio.h:156
@ IEEE802154_CONFIG_ACK_FPB
Definition: ieee802154_radio.h:153
@ IEEE802154_CONFIG_RX_SLOT
Definition: ieee802154_radio.h:207
@ IEEE802154_FILTER_TYPE_SHORT_ADDR
Definition: ieee802154_radio.h:64
@ IEEE802154_FILTER_TYPE_IEEE_ADDR
Definition: ieee802154_radio.h:63
@ IEEE802154_FILTER_TYPE_PAN_ID
Definition: ieee802154_radio.h:65
@ IEEE802154_FILTER_TYPE_SRC_SHORT_ADDR
Definition: ieee802154_radio.h:67
@ IEEE802154_FILTER_TYPE_SRC_IEEE_ADDR
Definition: ieee802154_radio.h:66
@ IEEE802154_TX_MODE_CCA
Definition: ieee802154_radio.h:114
@ IEEE802154_TX_MODE_TXTIME_CCA
Definition: ieee802154_radio.h:123
@ IEEE802154_TX_MODE_CSMA_CA
Definition: ieee802154_radio.h:117
@ IEEE802154_TX_MODE_DIRECT
Definition: ieee802154_radio.h:111
@ IEEE802154_TX_MODE_TXTIME
Definition: ieee802154_radio.h:120
@ IEEE802154_FPB_ADDR_MATCH_THREAD
Definition: ieee802154_radio.h:130
@ IEEE802154_FPB_ADDR_MATCH_ZIGBEE
Definition: ieee802154_radio.h:135
@ IEEE802154_HW_FCS
Definition: ieee802154_radio.h:48
@ IEEE802154_HW_ENERGY_SCAN
Definition: ieee802154_radio.h:55
@ IEEE802154_HW_CSMA
Definition: ieee802154_radio.h:51
@ IEEE802154_HW_SLEEP_TO_TX
Definition: ieee802154_radio.h:57
@ IEEE802154_HW_TXTIME
Definition: ieee802154_radio.h:56
@ IEEE802154_HW_PROMISC
Definition: ieee802154_radio.h:49
@ IEEE802154_HW_RXTIME
Definition: ieee802154_radio.h:59
@ IEEE802154_HW_TX_SEC
Definition: ieee802154_radio.h:58
@ IEEE802154_HW_SUB_GHZ
Definition: ieee802154_radio.h:54
@ IEEE802154_HW_TX_RX_ACK
Definition: ieee802154_radio.h:53
@ IEEE802154_HW_2_4_GHZ
Definition: ieee802154_radio.h:52
@ IEEE802154_HW_FILTER
Definition: ieee802154_radio.h:50
net_verdict
Net Verdict.
Definition: net_core.h:97
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
IEEE 802.15.4 L2 stack public header.
Public API for network interface.
Network packet buffer descriptor API.
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
__INT16_TYPE__ int16_t
Definition: stdint.h:73
Runtime device structure (in ROM) per driver instance.
Definition: device.h:378
Definition: ieee802154_radio.h:225
const uint8_t * ext_addr
Definition: ieee802154_radio.h:297
bool pan_coordinator
Definition: ieee802154_radio.h:242
uint32_t csl_rx_time
Definition: ieee802154_radio.h:277
ieee802154_event_cb_t event_handler
Definition: ieee802154_radio.h:248
uint32_t frame_counter
Definition: ieee802154_radio.h:264
struct ieee802154_config::@221::@223 auto_ack_fpb
const uint8_t * data
Definition: ieee802154_radio.h:283
uint32_t duration
Definition: ieee802154_radio.h:270
uint32_t csl_period
Definition: ieee802154_radio.h:274
bool extended
Definition: ieee802154_radio.h:237
uint8_t * addr
Definition: ieee802154_radio.h:236
struct ieee802154_config::@221::@224 ack_fpb
uint8_t channel
Definition: ieee802154_radio.h:268
struct ieee802154_config::@221::@225 rx_slot
struct ieee802154_key * mac_keys
Definition: ieee802154_radio.h:261
uint16_t short_addr
Definition: ieee802154_radio.h:287
uint16_t data_len
Definition: ieee802154_radio.h:286
bool promiscuous
Definition: ieee802154_radio.h:245
enum ieee802154_fpb_mode mode
Definition: ieee802154_radio.h:231
uint32_t start
Definition: ieee802154_radio.h:269
struct ieee802154_config::@221::@226 ack_ie
bool enabled
Definition: ieee802154_radio.h:230
Definition: ieee802154_radio.h:90
Definition: ieee802154_radio.h:100
uint8_t * key_value
Definition: ieee802154_radio.h:101
uint32_t key_frame_counter
Definition: ieee802154_radio.h:102
bool frame_counter_per_key
Definition: ieee802154_radio.h:103
uint8_t key_id_mode
Definition: ieee802154_radio.h:104
uint8_t key_index
Definition: ieee802154_radio.h:105
IEEE 802.15.4 radio interface API.
Definition: ieee802154_radio.h:306
int(* ed_scan)(const struct device *dev, uint16_t duration, energy_scan_done_cb_t done_cb)
Definition: ieee802154_radio.h:355
enum ieee802154_hw_caps(* get_capabilities)(const struct device *dev)
Definition: ieee802154_radio.h:316
int(* start)(const struct device *dev)
Definition: ieee802154_radio.h:338
int(* cca)(const struct device *dev)
Definition: ieee802154_radio.h:319
int(* tx)(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag)
Definition: ieee802154_radio.h:334
int(* stop)(const struct device *dev)
Definition: ieee802154_radio.h:341
int(* configure)(const struct device *dev, enum ieee802154_config_type type, const struct ieee802154_config *config)
Definition: ieee802154_radio.h:344
int(* set_channel)(const struct device *dev, uint16_t channel)
Definition: ieee802154_radio.h:322
int(* filter)(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter)
Definition: ieee802154_radio.h:325
struct net_if_api iface_api
Definition: ieee802154_radio.h:313
uint16_t(* get_subg_channel_count)(const struct device *dev)
Definition: ieee802154_radio.h:349
uint8_t(* get_sch_acc)(const struct device *dev)
Definition: ieee802154_radio.h:367
int(* set_txpower)(const struct device *dev, int16_t dbm)
Definition: ieee802154_radio.h:331
uint64_t(* get_time)(const struct device *dev)
Definition: ieee802154_radio.h:360
Network buffer representation.
Definition: buf.h:905
uint8_t * data
Definition: buf.h:931
Network Interface structure.
Definition: net_if.h:510
Network packet.
Definition: net_pkt.h:62