Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
mac_defines.h
00001 /* 00002 * Copyright (c) 2014-2019, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef MAC_DEFINES_H_ 00019 #define MAC_DEFINES_H_ 00020 00021 #include "eventOS_event.h" 00022 #include "mlme.h" 00023 #include "mac_data_buffer.h" 00024 #include "ns_list.h" 00025 00026 struct cca_structure_s; 00027 struct buffer; 00028 struct mac_pre_build_frame; 00029 struct mlme_key_descriptor_s; 00030 struct arm_device_driver_list; 00031 struct fhss_api; 00032 00033 typedef enum mac_event_t { 00034 MAC_STATE_IDLE = 0, 00035 MAC_TX_DONE, 00036 MAC_TX_DONE_PENDING, 00037 MAC_CCA_FAIL, 00038 MAC_TIMER_ACK, 00039 MAC_TIMER_CCA, 00040 MAC_TX_FAIL, 00041 MAC_TX_TIMEOUT, 00042 MAC_ACK_SECURITY_FAIL, 00043 MAC_UNKNOWN_DESTINATION, 00044 MAC_TX_PRECOND_FAIL 00045 } mac_event_t; 00046 00047 typedef enum mac_tx_status_type_t { 00048 MAC_TX_STATUS_LEN = 0, 00049 MAC_TX_STATUS_CCA_CNT, 00050 MAC_TX_STATUS_RETRY_CNT, 00051 } mac_tx_status_type_t; 00052 00053 00054 typedef enum mac_int_event_t { 00055 MAC_INT_IDLE = 0, 00056 MAC_INT_TX, 00057 MAC_INT_TIMER 00058 } mac_int_event_t; 00059 00060 00061 typedef enum mac_ifs_event_t { 00062 MAC_IFS_IDLE = 0, 00063 MAC_IFS_CCA, 00064 MAC_IFS_TRIG_TX, 00065 MAC_IFS_TX_ACTIVE, 00066 MAC_IFS_CCA_FAILED, 00067 MAC_IFS_ACK_TIMEOUT, 00068 } mac_ifs_event_t; 00069 00070 00071 00072 typedef enum mac_timer_event_t { 00073 MAC_INT_TIMER_IDLE = 0, 00074 MAC_INT_TIMER_ACK, 00075 MAC_INT_TIMER_CCA 00076 } mac_timer_event_t; 00077 00078 typedef enum { 00079 MAC_FRAME_BEACON = 0, 00080 MAC_FRAME_DATA = 1, 00081 MAC_FRAME_ACK = 2, 00082 MAC_FRAME_CMD = 3, 00083 MAC_ILLEGAL_LEGACY = 5, 00084 MAC_FRAME_RANGING = 14, 00085 MAC_FRAME_NONE = 15 00086 } mac_frame_e; 00087 00088 typedef enum arm_nwk_mlme_event_type { 00089 ARM_NWK_MAC_MLME_IDLE = 0, 00090 ARM_NWK_MAC_MLME_SCAN = 1, 00091 ARM_NWK_MAC_MLME_ED_ANALYZE = 2, 00092 ARM_NWK_MAC_MLME_INDIRECT_DATA_POLL = 4, 00093 ARM_NWK_MAC_MLME_INDIRECT_DATA_POLL_AFTER_DATA = 5, 00094 } arm_nwk_mlme_event_type_e; 00095 00096 #define ENHANCED_ACK_MAX_LENGTH 255 00097 00098 typedef struct dev_driver_tx_buffer { 00099 uint8_t *buf; 00100 uint8_t *enhanced_ack_buf; 00101 uint16_t ack_len; 00102 uint16_t len; 00103 unsigned priority: 2; 00104 } dev_driver_tx_buffer_s; 00105 00106 /* 00107 * Table 82-MAC command frames 00108 * 00109 * Command Command name RFD Subclause 00110 * Tx Rx */ 00111 #define MAC_ASSOC_REQ 0x01 // Association request X 7.3.1 00112 #define MAC_ASSOC_RESP 0x02 // Association response X 7.3.2 00113 #define MAC_DISASSOC_NOTIFY 0x03 // Disassociation notification X X 7.3.3 00114 #define MAC_DATA_REQ 0x04 // Data request X 7.3.4 00115 #define MAC_PAN_CONFLICT 0x05 // PAN ID conflict notification X 7.3.5 00116 #define MAC_ORPHAN 0x06 // Orphan notification X 7.3.6 00117 #define MAC_BEACON_REQ 0x07 // Beacon request 7.3.7 00118 #define MAC_COORD_REALIGN 0x08 // Coordinator realignment X 7.3.8 00119 #define MAC_GTS_REQ 0x09 // GTS request 7.3.9 00120 // 0x0a-0xff Reserved 00121 00122 #define MAC_CCA_MAX 8 00123 #define MAC_DEF_MIN_BE 3 00124 #define MAC_DEF_MAX_BE 5 00125 00126 typedef struct mac_active_scan { 00127 uint8_t pan_id[2]; 00128 uint8_t address[8]; 00129 uint8_t lqi; 00130 uint8_t beacon_scan_ok; 00131 } mac_active_scan; 00132 00133 #define MAC_EXT_ADDLIST_SIZE 8 00134 typedef struct mac_extented_address_table_t { 00135 uint8_t short_addr[2]; 00136 uint8_t addr[8]; 00137 } mac_extented_address_table_t; 00138 00139 typedef struct mac_tx_status_t { 00140 uint16_t length; 00141 uint8_t cca_cnt; 00142 uint8_t retry; 00143 } mac_tx_status_t; 00144 00145 typedef struct mac_mcps_data_conf_fail_s { 00146 uint8_t msduHandle; /**< Handle associated with MSDU */ 00147 uint8_t status; /**< Status of the failing MSDU transmission */ 00148 } mac_mcps_data_conf_fail_t; 00149 00150 typedef struct protocol_interface_rf_mac_setup { 00151 int8_t mac_interface_id; 00152 bool macUpState: 1; 00153 bool shortAdressValid: 1; //Define Dynamic src address to mac16 when it is true 00154 bool beaconSrcAddressModeLong: 1; //This force beacon src to mac64 otherwise shortAdressValid will define type 00155 bool secFrameCounterPerKey: 1; 00156 bool mac_extension_enabled: 1; 00157 bool mac_ack_tx_active: 1; 00158 bool mac_frame_pending: 1; 00159 /* MAC Capability Information */ 00160 bool macCapRxOnIdle: 1; 00161 bool macCapCordinator: 1; 00162 bool macCapAssocationPermit: 1; 00163 bool macCapBatteryPowered: 1; 00164 bool macCapSecrutityCapability: 1; 00165 bool macProminousMode: 1; 00166 bool macGTSPermit: 1; 00167 bool mac_security_enabled: 1; 00168 /* Let trough packet which is secured properly (MIC authenticated group key) and src address is 64-bit*/ 00169 bool mac_security_bypass_unknow_device: 1; 00170 /* Load balancing need this feature */ 00171 bool macAcceptAnyBeacon: 1; 00172 /* TX process Flag */ 00173 bool macTxProcessActive: 1; 00174 bool macTxRequestAck: 1; 00175 /* Data Poll state's */ 00176 bool macDataPollReq: 1; 00177 bool macWaitingData: 1; 00178 bool macRxDataAtPoll: 1; 00179 /* Radio State flags */ 00180 bool macRfRadioOn: 1; 00181 bool macRfRadioTxActive: 1; 00182 bool macBroadcastDisabled: 1; 00183 bool scan_active: 1; 00184 bool rf_csma_extension_supported: 1; 00185 bool ack_tx_possible: 1; 00186 uint16_t mac_short_address; 00187 uint16_t pan_id; 00188 uint8_t mac64[8]; 00189 uint16_t coord_short_address; 00190 uint8_t coord_long_address[8]; 00191 00192 /* CSMA Params */ 00193 unsigned macMinBE: 4; 00194 unsigned macMaxBE: 4; 00195 unsigned macCurrentBE: 4; 00196 uint8_t macMaxCSMABackoffs; 00197 uint8_t backoff_period_in_10us; // max 2550us - it's 320us for standard 250kbps 00198 uint8_t mac_frame_filters; 00199 /* MAC channel parameters */ 00200 channel_list_s mac_channel_list; 00201 uint8_t scan_duration; //Needed??? 00202 mac_scan_type_t scan_type; 00203 00204 uint8_t mac_channel; 00205 //uint8_t cca_failure; 00206 00207 /* MAC TX Queue */ 00208 uint16_t direct_queue_bytes; 00209 uint16_t unicast_queue_size; 00210 uint16_t broadcast_queue_size; 00211 struct mac_pre_build_frame *pd_data_request_queue_to_go; 00212 struct mac_pre_build_frame *pd_data_request_bc_queue_to_go; 00213 struct mac_pre_build_frame *active_pd_data_request; 00214 /* MAC Beacon info */ 00215 uint16_t max_beacon_payload_length; 00216 uint8_t *mac_beacon_payload; 00217 uint8_t mac_beacon_payload_size; 00218 uint8_t mac_bea_sequence; 00219 uint8_t mac_sequence; 00220 uint8_t mac_tx_retry; 00221 uint8_t mac_cca_retry; 00222 uint16_t mac_ack_wait_duration; 00223 uint8_t mac_mlme_retry_max; 00224 uint8_t aUnitBackoffPeriod; 00225 uint8_t number_of_csma_ca_periods; /**< Number of CSMA-CA periods */ 00226 uint16_t multi_cca_interval; /**< Length of the additional CSMA-CA period(s) in microseconds */ 00227 /* Indirect queue parameters */ 00228 struct mac_pre_build_frame *indirect_pd_data_request_queue; 00229 struct mac_pre_build_frame enhanced_ack_buffer; 00230 uint32_t enhanced_ack_handler_timestamp; 00231 arm_event_t mac_mcps_timer_event; 00232 uint16_t indirect_pending_bytes; 00233 arm_nwk_mlme_event_type_e mac_mlme_event; 00234 mac_event_t timer_mac_event; 00235 mac_event_t mac_tx_result; 00236 uint16_t active_mac_events; 00237 int8_t mac_tasklet_id; 00238 int8_t mac_mcps_timer; 00239 int8_t mac_timer_id; 00240 int8_t ifs_timer_id; 00241 int8_t mlme_timer_id; 00242 int8_t cca_timer_id; 00243 int8_t bc_timer_id; 00244 uint32_t mlme_tick_count; 00245 uint32_t symbol_rate; 00246 uint32_t symbol_time_us; 00247 uint8_t max_ED; 00248 uint16_t mlme_ED_counter; 00249 mac_tx_status_t mac_tx_status; 00250 mac_mcps_data_conf_fail_t mac_mcps_data_conf_fail; 00251 struct cca_structure_s *cca_structure; 00252 /* MAC Security components */ 00253 struct mlme_device_descriptor_s *device_description_table; 00254 uint8_t device_description_table_size; 00255 struct mlme_key_descriptor_s *key_description_table; 00256 void *key_device_frame_counter_list_buffer; 00257 uint8_t key_description_table_size; 00258 uint8_t key_lookup_list_size; 00259 uint8_t key_usage_list_size; 00260 mlme_key_device_descriptor_t *key_device_desc_buffer; 00261 mlme_key_usage_descriptor_t *key_usage_list_buffer; 00262 mlme_key_id_lookup_descriptor_t *key_lookup_buffer; 00263 struct mlme_security_level_descriptor_s *security_level_descriptor_table; 00264 uint8_t security_level_descriptor_table_size; 00265 uint32_t security_frame_counter; 00266 uint8_t mac_default_key_source[8]; 00267 mlme_security_t mac_auto_request; 00268 /* end of security part */ 00269 //Device driver and buffer 00270 struct arm_device_driver_list *dev_driver; 00271 dev_driver_tx_buffer_s dev_driver_tx_buffer; 00272 struct arm_device_driver_list *tun_extension_rf_driver; 00273 /* End of API Control */ 00274 struct mlme_scan_conf_s *mac_mlme_scan_resp; 00275 //beacon_join_priority_tx_cb *beacon_join_priority_tx_cb_ptr; 00276 struct mac_statistics_s *mac_statistics; 00277 /* FHSS API*/ 00278 struct fhss_api *fhss_api; 00279 } protocol_interface_rf_mac_setup_s; 00280 00281 00282 #define MAC_FCF_FRAME_TYPE_MASK 0x0007 00283 #define MAC_FCF_FRAME_TYPE_SHIFT 0 00284 #define MAC_FCF_SECURITY_BIT_MASK 0x0008 00285 #define MAC_FCF_SECURITY_BIT_SHIFT 3 00286 #define MAC_FCF_PENDING_BIT_MASK 0x0010 00287 #define MAC_FCF_PENDING_BIT_SHIFT 4 00288 #define MAC_FCF_ACK_REQ_BIT_MASK 0x0020 00289 #define MAC_FCF_ACK_REQ_BIT_SHIFT 5 00290 #define MAC_FCF_INTRA_PANID_MASK 0x0040 00291 #define MAC_FCF_INTRA_PANID_SHIFT 6 00292 #define MAC_FCF_SEQ_NUM_SUPPRESS_MASK 0x0100 00293 #define MAC_FCF_SEQ_NUM_SUPPRESS_SHIFT 8 00294 #define MAC_FCF_IE_PRESENTS_MASK 0x0200 00295 #define MAC_FCF_IE_PRESENTS_SHIFT 9 00296 #define MAC_FCF_DST_ADDR_MASK 0x0c00 00297 #define MAC_FCF_DST_ADDR_SHIFT 10 00298 #define MAC_FCF_VERSION_MASK 0x3000 00299 #define MAC_FCF_VERSION_SHIFT 12 00300 #define MAC_FCF_SRC_ADDR_MASK 0xc000 00301 #define MAC_FCF_SRC_ADDR_SHIFT 14 00302 00303 /* MAC supported frame types */ 00304 #define FC_BEACON_FRAME 0x00 00305 #define FC_DATA_FRAME 0x01 00306 #define FC_ACK_FRAME 0x02 00307 #define FC_CMD_FRAME 0x03 00308 00309 /* MAC virtual configuration types*/ 00310 #define MAC_BROADCAST_EVENT 0 00311 00312 #define MAC_DATA_PACKET_MIN_HEADER_LENGTH 11 00313 00314 #define MAC_DEFAULT_MAX_FRAME_RETRIES 3 00315 00316 // TODO: make this dynamic 00317 #define FHSS_SYNCH_INFO_START 20 00318 00319 #endif /* MAC_DEFINES_H_ */
Generated on Tue Jul 12 2022 13:54:31 by
