Zephyr Project API  3.4.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
177
182
218
223
229};
230
234 union {
236 struct {
240
242 struct {
243 uint8_t *addr; /* in little endian for both, short and extended address */
245 bool enabled;
247
250
253
256
269
272
274 struct {
279
281 uint32_t csl_period; /* in CPU byte order */
282
284 uint32_t csl_rx_time; /* in microseconds,
285 * based on ieee802154_radio_api.get_time()
286 */
287
289 struct {
290 const uint8_t *data; /* header IEs to be added to the Enh-Ack frame in
291 * little endian byte order
292 */
294 uint16_t short_addr; /* in CPU byte order */
304 const uint8_t *ext_addr; /* in big endian */
306 };
307};
308
320 struct net_if_api iface_api;
321
323 enum ieee802154_hw_caps (*get_capabilities)(const struct device *dev);
324
326 int (*cca)(const struct device *dev);
327
329 int (*set_channel)(const struct device *dev, uint16_t channel);
330
332 int (*filter)(const struct device *dev,
333 bool set,
334 enum ieee802154_filter_type type,
335 const struct ieee802154_filter *filter);
336
338 int (*set_txpower)(const struct device *dev, int16_t dbm);
339
341 int (*tx)(const struct device *dev, enum ieee802154_tx_mode mode,
342 struct net_pkt *pkt, struct net_buf *frag);
343
345 int (*start)(const struct device *dev);
346
348 int (*stop)(const struct device *dev);
349
354 int (*continuous_carrier)(const struct device *dev);
355
357 int (*configure)(const struct device *dev,
358 enum ieee802154_config_type type,
359 const struct ieee802154_config *config);
360
363
368 int (*ed_scan)(const struct device *dev,
369 uint16_t duration,
370 energy_scan_done_cb_t done_cb);
371
373 uint64_t (*get_time)(const struct device *dev);
374
380 uint8_t (*get_sch_acc)(const struct device *dev);
381};
382
383/* Make sure that the network interface API is properly setup inside
384 * IEEE 802154 radio API struct (it is the first one).
385 */
386BUILD_ASSERT(offsetof(struct ieee802154_radio_api, iface_api) == 0);
387
388#define IEEE802154_AR_FLAG_SET (0x20)
389
400static inline bool ieee802154_is_ar_flag_set(struct net_buf *frag)
401{
402 return (*frag->data & IEEE802154_AR_FLAG_SET);
403}
404
417 struct net_pkt *pkt);
418
424#ifndef CONFIG_IEEE802154_RAW_MODE
425void ieee802154_init(struct net_if *iface);
426#else
427#define ieee802154_init(_iface_)
428#endif /* CONFIG_IEEE802154_RAW_MODE */
429
430#ifdef __cplusplus
431}
432#endif
433
438#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:388
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:400
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:228
@ 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:217
@ IEEE802154_CONFIG_FRAME_COUNTER_IF_LARGER
Definition: ieee802154_radio.h:176
@ IEEE802154_CONFIG_CSL_RX_TIME
Definition: ieee802154_radio.h:222
@ 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:181
@ 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:98
#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:380
Definition: ieee802154_radio.h:232
const uint8_t * ext_addr
Definition: ieee802154_radio.h:304
bool pan_coordinator
Definition: ieee802154_radio.h:249
uint32_t csl_rx_time
Definition: ieee802154_radio.h:284
ieee802154_event_cb_t event_handler
Definition: ieee802154_radio.h:255
uint32_t frame_counter
Definition: ieee802154_radio.h:271
const uint8_t * data
Definition: ieee802154_radio.h:290
uint32_t duration
Definition: ieee802154_radio.h:277
uint32_t csl_period
Definition: ieee802154_radio.h:281
bool extended
Definition: ieee802154_radio.h:244
uint8_t * addr
Definition: ieee802154_radio.h:243
struct ieee802154_config::@262::@267 ack_ie
struct ieee802154_config::@262::@264 auto_ack_fpb
uint8_t channel
Definition: ieee802154_radio.h:275
struct ieee802154_config::@262::@266 rx_slot
struct ieee802154_key * mac_keys
Definition: ieee802154_radio.h:268
uint16_t short_addr
Definition: ieee802154_radio.h:294
uint16_t data_len
Definition: ieee802154_radio.h:293
bool promiscuous
Definition: ieee802154_radio.h:252
struct ieee802154_config::@262::@265 ack_fpb
enum ieee802154_fpb_mode mode
Definition: ieee802154_radio.h:238
uint32_t start
Definition: ieee802154_radio.h:276
bool enabled
Definition: ieee802154_radio.h:237
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:313
int(* ed_scan)(const struct device *dev, uint16_t duration, energy_scan_done_cb_t done_cb)
Definition: ieee802154_radio.h:368
enum ieee802154_hw_caps(* get_capabilities)(const struct device *dev)
Definition: ieee802154_radio.h:323
int(* start)(const struct device *dev)
Definition: ieee802154_radio.h:345
int(* cca)(const struct device *dev)
Definition: ieee802154_radio.h:326
int(* continuous_carrier)(const struct device *dev)
Definition: ieee802154_radio.h:354
int(* tx)(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag)
Definition: ieee802154_radio.h:341
int(* stop)(const struct device *dev)
Definition: ieee802154_radio.h:348
int(* configure)(const struct device *dev, enum ieee802154_config_type type, const struct ieee802154_config *config)
Definition: ieee802154_radio.h:357
int(* set_channel)(const struct device *dev, uint16_t channel)
Definition: ieee802154_radio.h:329
int(* filter)(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter)
Definition: ieee802154_radio.h:332
struct net_if_api iface_api
Definition: ieee802154_radio.h:320
uint16_t(* get_subg_channel_count)(const struct device *dev)
Definition: ieee802154_radio.h:362
uint8_t(* get_sch_acc)(const struct device *dev)
Definition: ieee802154_radio.h:380
int(* set_txpower)(const struct device *dev, int16_t dbm)
Definition: ieee802154_radio.h:338
uint64_t(* get_time)(const struct device *dev)
Definition: ieee802154_radio.h:373
Network buffer representation.
Definition: buf.h:906
uint8_t * data
Definition: buf.h:932
Network Interface structure.
Definition: net_if.h:516
Network packet.
Definition: net_pkt.h:62