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 typedef enum {
52 
56 #define GNRC_MAC_TX_FEEDBACK_INIT { TX_FEEDBACK_UNDEF }
57 
58 #if ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN)
59 
66 typedef struct {
67 #if (GNRC_MAC_RX_QUEUE_SIZE != 0) || defined(DOXYGEN)
70 #endif /* (GNRC_MAC_RX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
71 
72 #if (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0) || defined(DOXYGEN)
74 #endif /* (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0) || defined(DOXYGEN) */
75 
76 #ifdef MODULE_GNRC_LWMAC
77  gnrc_lwmac_l2_addr_t l2_addr;
78  gnrc_lwmac_rx_state_t state;
79  uint8_t rx_bad_exten_count;
80 #endif
81 
82 #ifdef MODULE_GNRC_GOMACH
83  gnrc_gomach_listen_state_t listen_state;
85  gnrc_gomach_vtdma_manag_t vtdma_manag;
86  gnrc_gomach_dupchk_t check_dup_pkt;
87 #endif
89 
93 #if ((GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN)
94 #define GNRC_MAC_RX_INIT { \
95  PRIORITY_PKTQUEUE_INIT, \
96  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
97  { NULL }, \
98 }
99 #elif (GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE == 0) || defined(DOXYGEN)
100 #define GNRC_MAC_RX_INIT { \
101  PRIORITY_PKTQUEUE_INIT, \
102  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
103 }
104 #elif (GNRC_MAC_RX_QUEUE_SIZE == 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0) || defined(DOXYGEN)
105 #define GNRC_MAC_RX_INIT { \
106  { NULL }, \
107 }
108 #endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
109 #endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
110 
111 #if (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
112 
115 typedef struct {
116  uint8_t l2_addr[IEEE802154_LONG_ADDRESS_LEN];
117  uint8_t l2_addr_len;
118  uint32_t phase;
120 #if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
122 #endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
123 
124 #ifdef MODULE_GNRC_GOMACH
125  uint16_t pub_chanseq;
126  uint32_t cp_phase;
127  uint8_t mac_type;
128 #endif
130 
134 #define GNRC_MAC_PHASE_UNINITIALIZED (0)
135 
139 #define GNRC_MAC_PHASE_MAX (-1)
140 
144 #if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
145 #define GNRC_MAC_TX_NEIGHBOR_INIT { \
146  { 0 }, \
147  0, \
148  GNRC_MAC_PHASE_UNINITIALIZED, \
149  PRIORITY_PKTQUEUE_INIT, \
150 }
151 #else
152 #define GNRC_MAC_TX_NEIGHBOR_INIT { \
153  { 0 }, \
154  0, \
155  GNRC_MAC_PHASE_UNINITIALIZED, \
156 }
157 #endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
158 #endif /* (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
159 
160 #if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
161 
168 typedef struct {
169 #if (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
174 #endif /* (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
175 
176 #if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
177 #if (GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN)
180 #endif /* (GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN) */
181 
184 #endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
185 
186 #ifdef MODULE_GNRC_LWMAC
187  gnrc_lwmac_tx_state_t state;
188  uint32_t wr_sent;
189  uint32_t timestamp;
190  uint8_t bcast_seqnr;
191  uint8_t tx_burst_count;
192  uint8_t tx_retry_count;
193 #endif
194 
195 #ifdef MODULE_GNRC_GOMACH
196  gnrc_gomach_transmit_state_t transmit_state;
197  gnrc_gomach_bcast_state_t bcast_state;
198  gnrc_gomach_t2k_state_t t2k_state;
199  gnrc_gomach_t2u_state_t t2u_state;
200  uint8_t preamble_sent;
201  uint8_t broadcast_seq;
202  uint8_t tx_seq;
203  gnrc_gomach_vtdma_t vtdma_para;
204  uint8_t no_ack_counter;
205  uint8_t t2u_retry_counter;
206  uint8_t last_tx_neighbor_id;
207  uint8_t tx_busy_count;
208  uint8_t t2u_fail_count;
209 #endif
210 } gnrc_mac_tx_t;
211 
215 #if ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
216 #define GNRC_MAC_TX_INIT { \
217  { GNRC_MAC_TX_NEIGHBOR_INIT }, \
218  NULL, \
219  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
220  NULL, \
221 }
222 #elif ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT == 0)) || defined(DOXYGEN)
223 #define GNRC_MAC_TX_INIT { \
224  PRIORITY_PKTQUEUE_INIT, \
225  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
226  NULL, \
227 }
228 #elif ((GNRC_MAC_TX_QUEUE_SIZE == 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
229 #define GNRC_MAC_TX_INIT { \
230  { GNRC_MAC_TX_NEIGHBOR_INIT }, \
231  NULL, \
232 }
233 #endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
234 #endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif /* NET_GNRC_MAC_TYPES_H */
241 
gnrc_mac_tx_feedback_t
definition for device transmission feedback types
Definition: mac/types.h:46
Types used by the kernel.
Transmission just start, no Tx feedback yet.
Definition: mac/types.h:47
GoMacH&#39;s slot-schedule-unit.
Definition: gomach/types.h:216
gnrc_priority_pktqueue_t queue
If neighbor queues is not used, define a single queue for managing TX packets.
Definition: mac/types.h:178
#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:117
data type for priority queues
uint32_t phase
Neighbor&#39;s wake-up Phase.
Definition: mac/types.h:118
gnrc_gomach_listen_state_t
State-machine states of duty-cycled listening procedure of GoMacH.
Definition: gomach/types.h:160
GoMacH&#39;s vTDMA (dynamic slots allocation) management unit.
Definition: gomach/types.h:224
gnrc_gomach_t2u_state_t
State-machine states of Transmission-to-phase-unknown (t2u) procedure of GoMacH.
Definition: gomach/types.h:127
#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:49
found medium busy when doing transmission
Definition: mac/types.h:50
Definitions of GNRC_MAC.
gnrc_priority_pktqueue_t queue
TX queue for this particular Neighbor.
Definition: mac/types.h:121
type for storing states of TX neighbor node.
Definition: mac/types.h:115
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:262
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:183
#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:68
gnrc priority packet queue API
GoMacH&#39;s data structure for recording TX information for avoiding receiving duplicate packets...
Definition: gomach/types.h:242
MAC internal type for storing reception state parameters and state machines.
Definition: mac/types.h:66
LWMAC internal L2 address structure.
gnrc_gomach_bcast_state_t
State-machine states of Broadcast procedure of GoMacH.
Definition: gomach/types.h:99
Type to represent parts (either headers or payload) of a packet, called snips.
Transmission succeeded.
Definition: mac/types.h:48
#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:111
gnrc_gomach_transmit_state_t
State-machine states of basic transmission management procedure of GoMacH.
Definition: gomach/types.h:177
MAC internal type for storing transmission state parameters and state machines.
Definition: mac/types.h:168
#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:172