mac/types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Daniel Krebs
3  * 2016 INRIA
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
21 #ifndef NET_GNRC_MAC_TYPES_H
22 #define NET_GNRC_MAC_TYPES_H
23 
24 #include <stdint.h>
25 #include <stdbool.h>
26 
27 #include "kernel_types.h"
28 #include "net/gnrc.h"
30 #include "net/ieee802154.h"
31 #include "net/gnrc/mac/mac.h"
32 #ifdef MODULE_GNRC_LWMAC
33 #include "net/gnrc/lwmac/types.h"
34 #endif
35 #ifdef MODULE_GNRC_GOMACH
36 #include "net/gnrc/gomach/types.h"
37 #endif
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
46 #ifndef GNRC_MAC_TYPE_GET_DUTYCYCLE
47 #define GNRC_MAC_TYPE_GET_DUTYCYCLE (0x4401)
48 #endif
49 
53 typedef enum {
59 
63 #define GNRC_MAC_TX_FEEDBACK_INIT { TX_FEEDBACK_UNDEF }
64 
65 #if ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN)
66 
73 typedef struct {
74 #if (GNRC_MAC_RX_QUEUE_SIZE != 0) || defined(DOXYGEN)
77 #endif /* (GNRC_MAC_RX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
78 
79 #if (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0) || defined(DOXYGEN)
81 #endif /* (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0) || defined(DOXYGEN) */
82 
83 #ifdef MODULE_GNRC_LWMAC
84  gnrc_lwmac_l2_addr_t l2_addr;
85  gnrc_lwmac_rx_state_t state;
86  uint8_t rx_bad_exten_count;
87 #endif
88 
89 #ifdef MODULE_GNRC_GOMACH
90  gnrc_gomach_listen_state_t listen_state;
92  gnrc_gomach_vtdma_manag_t vtdma_manag;
93  gnrc_gomach_dupchk_t check_dup_pkt;
94 #endif
96 
100 #if ((GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN)
101 #define GNRC_MAC_RX_INIT { \
102  PRIORITY_PKTQUEUE_INIT, \
103  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
104  { NULL }, \
105 }
106 #elif (GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE == 0) || defined(DOXYGEN)
107 #define GNRC_MAC_RX_INIT { \
108  PRIORITY_PKTQUEUE_INIT, \
109  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
110 }
111 #elif (GNRC_MAC_RX_QUEUE_SIZE == 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0) || defined(DOXYGEN)
112 #define GNRC_MAC_RX_INIT { \
113  { NULL }, \
114 }
115 #endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
116 #endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
117 
118 #if (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
119 
122 typedef struct {
123  uint8_t l2_addr[IEEE802154_LONG_ADDRESS_LEN];
124  uint8_t l2_addr_len;
125  uint32_t phase;
127 #if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
129 #endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
130 
131 #ifdef MODULE_GNRC_GOMACH
132  uint16_t pub_chanseq;
133  uint32_t cp_phase;
134  uint8_t mac_type;
135 #endif
137 
141 #define GNRC_MAC_PHASE_UNINITIALIZED (0)
142 
146 #define GNRC_MAC_PHASE_MAX (-1)
147 
151 #if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
152 #define GNRC_MAC_TX_NEIGHBOR_INIT { \
153  { 0 }, \
154  0, \
155  GNRC_MAC_PHASE_UNINITIALIZED, \
156  PRIORITY_PKTQUEUE_INIT, \
157 }
158 #else
159 #define GNRC_MAC_TX_NEIGHBOR_INIT { \
160  { 0 }, \
161  0, \
162  GNRC_MAC_PHASE_UNINITIALIZED, \
163 }
164 #endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
165 #endif /* (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
166 
167 #if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
168 
175 typedef struct {
176 #if (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
181 #endif /* (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
182 
183 #if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
184 #if (GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN)
187 #endif /* (GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN) */
188 
191 #endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
192 
193 #ifdef MODULE_GNRC_LWMAC
194  gnrc_lwmac_tx_state_t state;
195  uint32_t wr_sent;
196  uint32_t timestamp;
197  uint8_t bcast_seqnr;
198  uint8_t tx_burst_count;
199  uint8_t tx_retry_count;
200 #endif
201 
202 #ifdef MODULE_GNRC_GOMACH
203  gnrc_gomach_transmit_state_t transmit_state;
204  gnrc_gomach_bcast_state_t bcast_state;
205  gnrc_gomach_t2k_state_t t2k_state;
206  gnrc_gomach_t2u_state_t t2u_state;
207  uint8_t preamble_sent;
208  uint8_t broadcast_seq;
209  uint8_t tx_seq;
210  gnrc_gomach_vtdma_t vtdma_para;
211  uint8_t no_ack_counter;
212  uint8_t t2u_retry_counter;
213  uint8_t last_tx_neighbor_id;
214  uint8_t tx_busy_count;
215  uint8_t t2u_fail_count;
216 #endif
217 } gnrc_mac_tx_t;
218 
222 #if ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
223 #define GNRC_MAC_TX_INIT { \
224  { GNRC_MAC_TX_NEIGHBOR_INIT }, \
225  NULL, \
226  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
227  NULL, \
228 }
229 #elif ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT == 0)) || defined(DOXYGEN)
230 #define GNRC_MAC_TX_INIT { \
231  PRIORITY_PKTQUEUE_INIT, \
232  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
233  NULL, \
234 }
235 #elif ((GNRC_MAC_TX_QUEUE_SIZE == 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
236 #define GNRC_MAC_TX_INIT { \
237  { GNRC_MAC_TX_NEIGHBOR_INIT }, \
238  NULL, \
239 }
240 #endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
241 #endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
242 
243 #ifdef __cplusplus
244 }
245 #endif
246 
247 #endif /* NET_GNRC_MAC_TYPES_H */
248 
gnrc_mac_tx_feedback_t
definition for device transmission feedback types
Definition: mac/types.h:53
Types used by the kernel.
Transmission just start, no Tx feedback yet.
Definition: mac/types.h:54
GoMacH&#39;s slot-schedule-unit.
Definition: gomach/types.h:207
gnrc_priority_pktqueue_t queue
If neighbor queues is not used, define a single queue for managing TX packets.
Definition: mac/types.h:185
#define GNRC_MAC_TX_QUEUE_SIZE
The default queue size for transmission packets coming from higher layers.
Definition: mac/mac.h:56
uint8_t l2_addr_len
Neighbor address length.
Definition: mac/types.h:124
data type for priority queues
uint32_t phase
Neighbor&#39;s wake-up Phase.
Definition: mac/types.h:125
gnrc_gomach_listen_state_t
State-machine states of duty-cycled listening procedure of GoMacH.
Definition: gomach/types.h:151
GoMacH&#39;s vTDMA (dynamic slots allocation) management unit.
Definition: gomach/types.h:215
gnrc_gomach_t2u_state_t
State-machine states of Transmission-to-phase-unknown (t2u) procedure of GoMacH.
Definition: gomach/types.h:118
#define GNRC_MAC_DISPATCH_BUFFER_SIZE
The default buffer size for storing dispatching packets.
Definition: mac/mac.h:42
IEEE 802.15.4 header definitions.
No ACK for the transmitted packet.
Definition: mac/types.h:56
found medium busy when doing transmission
Definition: mac/types.h:57
Definitions of GNRC_MAC.
gnrc_priority_pktqueue_t queue
TX queue for this particular Neighbor.
Definition: mac/types.h:128
type for storing states of TX neighbor node.
Definition: mac/types.h:122
Includes all essential GNRC network stack base modules.
#define GNRC_MAC_NEIGHBOR_COUNT
Count of neighbor nodes in one-hop distance.
Definition: mac/mac.h:49
Internal used types of GoMacH.
Sender&#39;s vTDMA (dynamic slots allocation) management unit.
Definition: gomach/types.h:253
gnrc_lwmac_rx_state_t
RX states of LWMAC.
Definition: lwmac/types.h:148
gnrc_lwmac_tx_state_t
TX states of LWMAC.
Definition: lwmac/types.h:127
Definition of internal types used by LWMAC.
gnrc_pktsnip_t * packet
currently scheduled packet for sending
Definition: mac/types.h:190
#define GNRC_MAC_RX_QUEUE_SIZE
The default rx queue size for incoming packets.
Definition: mac/mac.h:35
gnrc_priority_pktqueue_t queue
RX packet queue.
Definition: mac/types.h:75
gnrc priority packet queue API
GoMacH&#39;s data structure for recording TX information for avoiding receiving duplicate packets...
Definition: gomach/types.h:233
MAC internal type for storing reception state parameters and state machines.
Definition: mac/types.h:73
LWMAC internal L2 address structure.
gnrc_gomach_bcast_state_t
State-machine states of Broadcast procedure of GoMacH.
Definition: gomach/types.h:90
Type to represent parts (either headers or payload) of a packet, called snips.
Transmission succeeded.
Definition: mac/types.h:55
#define GNRC_GOMACH_SLOSCH_UNIT_COUNT
The default number of slot-schedule-unit gnrc_gomach_slosch_unit_t in GoMacH.
Definition: gomach/types.h:73
data type for gnrc priority packet queue nodes
gnrc_gomach_t2k_state_t
State-machine states of Transmission-to-phase-known (t2k) procedure of GoMacH.
Definition: gomach/types.h:102
gnrc_gomach_transmit_state_t
State-machine states of basic transmission management procedure of GoMacH.
Definition: gomach/types.h:168
MAC internal type for storing transmission state parameters and state machines.
Definition: mac/types.h:175
#define IEEE802154_LONG_ADDRESS_LEN
long address (EUI-64)
gnrc_mac_tx_neighbor_t * current_neighbor
Neighbor information unit of destination node to which the current packet will be sent...
Definition: mac/types.h:179