[6319] | 1 | /** @file wlan_mac_ltg.h |
---|
| 2 | * @brief Local Traffic Generator |
---|
| 3 | * |
---|
| 4 | * This contains code for scheduling local traffic directly from the |
---|
| 5 | * board. |
---|
| 6 | * |
---|
| 7 | * @copyright Copyright 2013-2019, Mango Communications. All rights reserved. |
---|
| 8 | * Distributed under the Mango Communications Reference Design License |
---|
| 9 | * See LICENSE.txt included in the design archive or |
---|
| 10 | * at http://mangocomm.com/802.11/license |
---|
| 11 | * |
---|
| 12 | * This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11) |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #ifndef WLAN_MAC_LTG_H_ |
---|
| 16 | #define WLAN_MAC_LTG_H_ |
---|
| 17 | |
---|
| 18 | #include "wlan_mac_high_sw_config.h" |
---|
| 19 | #include "xil_types.h" |
---|
| 20 | #include "wlan_common_types.h" |
---|
| 21 | |
---|
| 22 | //Forward declarations |
---|
| 23 | struct mac_header_80211_common; |
---|
| 24 | |
---|
| 25 | //LTG Schedules define the times when LTG event callbacks are called. |
---|
| 26 | #define LTG_SCHED_TYPE_PERIODIC 1 |
---|
| 27 | #define LTG_SCHED_TYPE_UNIFORM_RAND 2 |
---|
| 28 | |
---|
| 29 | //LTG Payloads define how payloads are constructed once the LTG event callbacks |
---|
| 30 | //are called. For example, the LTG_SCHED_TYPE_PERIODIC schedule that employs the |
---|
| 31 | //LTG_PYLD_TYPE_FIXED would result in a constant bit rate (CBR) traffic |
---|
| 32 | //profile |
---|
| 33 | #define LTG_PYLD_TYPE_FIXED 1 |
---|
| 34 | #define LTG_PYLD_TYPE_UNIFORM_RAND 2 |
---|
| 35 | #define LTG_PYLD_TYPE_ALL_ASSOC_FIXED 3 |
---|
| 36 | #define LTG_PYLD_TYPE_CTRL_RESP 4 |
---|
| 37 | |
---|
| 38 | #define LTG_REMOVE_ALL 0xFFFFFFFF |
---|
| 39 | #define LTG_START_ALL 0xFFFFFFFF |
---|
| 40 | #define LTG_STOP_ALL 0xFFFFFFFF |
---|
| 41 | |
---|
| 42 | //In spirit, tg_schedule is derived from dl_entry. Since C |
---|
| 43 | //lacks a formal notion of inheritance, we adopt a popular |
---|
| 44 | //alternative idiom for inheritance where the dl_entry |
---|
| 45 | //is the first entry in the new structure. Since structures |
---|
| 46 | //will never be padded before their first entry, it is safe |
---|
| 47 | //to cast back and forth between the tg_schedule and dl_entry. |
---|
| 48 | typedef struct tg_schedule tg_schedule; |
---|
| 49 | struct tg_schedule{ |
---|
| 50 | u32 id; |
---|
| 51 | u32 type; |
---|
| 52 | u64 target; |
---|
| 53 | u64 stop_target; |
---|
| 54 | void* params; |
---|
| 55 | void* callback_arg; |
---|
| 56 | function_ptr_t cleanup_callback; |
---|
| 57 | void* state; |
---|
| 58 | }; |
---|
| 59 | |
---|
| 60 | //LTG Schedules |
---|
| 61 | |
---|
| 62 | #define LTG_DURATION_FOREVER 0 |
---|
| 63 | |
---|
| 64 | typedef struct ltg_sched_state_hdr{ |
---|
| 65 | u8 enabled; |
---|
| 66 | u8 reserved[3]; |
---|
| 67 | u64 start_timestamp; |
---|
| 68 | u64 stop_timestamp; |
---|
| 69 | } ltg_sched_state_hdr_t; |
---|
| 70 | |
---|
| 71 | typedef struct ltg_sched_periodic_params{ |
---|
| 72 | u32 interval_count; |
---|
| 73 | u64 duration_count; |
---|
| 74 | } ltg_sched_periodic_params_t; |
---|
| 75 | |
---|
| 76 | typedef struct ltg_sched_periodic_state{ |
---|
| 77 | ltg_sched_state_hdr_t hdr; |
---|
| 78 | u32 time_to_next_count; |
---|
| 79 | } ltg_sched_periodic_state_t; |
---|
| 80 | |
---|
| 81 | // Note: count variables are in units of FAST_TIMER_DUR_US |
---|
| 82 | typedef struct ltg_sched_uniform_rand_params{ |
---|
| 83 | u32 min_interval_count; |
---|
| 84 | u32 max_interval_count; |
---|
| 85 | u64 duration_count; |
---|
| 86 | } ltg_sched_uniform_rand_params_t; |
---|
| 87 | |
---|
| 88 | typedef struct ltg_sched_uniform_rand_state{ |
---|
| 89 | ltg_sched_state_hdr_t hdr; |
---|
| 90 | u32 time_to_next_count; |
---|
| 91 | } ltg_sched_uniform_rand_state_t; |
---|
| 92 | |
---|
| 93 | //LTG Payload Profiles |
---|
| 94 | |
---|
| 95 | typedef struct ltg_pyld_hdr{ |
---|
| 96 | u32 type; |
---|
| 97 | } ltg_pyld_hdr_t; |
---|
| 98 | |
---|
| 99 | typedef struct ltg_pyld_fixed{ |
---|
| 100 | ltg_pyld_hdr_t hdr; |
---|
| 101 | u8 addr_da[MAC_ADDR_LEN]; |
---|
| 102 | u16 length; |
---|
| 103 | } __attribute__((__packed__)) ltg_pyld_fixed_t; |
---|
| 104 | ASSERT_TYPE_SIZE(ltg_pyld_fixed_t, 12); |
---|
| 105 | |
---|
| 106 | #define LTG_PYLD_CTRL_RESP_SUBTYPE_CTS 0 |
---|
| 107 | #define LTG_PYLD_CTRL_RESP_SUBTYPE_ACK 1 |
---|
| 108 | |
---|
| 109 | typedef struct ltg_pyld_ctrl_resp_t{ |
---|
| 110 | ltg_pyld_hdr_t hdr; |
---|
| 111 | u8 addr_ra[MAC_ADDR_LEN]; |
---|
| 112 | u16 subtype; |
---|
| 113 | u16 duration; |
---|
| 114 | } __attribute__((__packed__)) ltg_pyld_ctrl_resp_t; |
---|
| 115 | ASSERT_TYPE_SIZE(ltg_pyld_ctrl_resp_t, 14); |
---|
| 116 | |
---|
| 117 | typedef struct ltg_pyld_all_assoc_fixed_t{ |
---|
| 118 | ltg_pyld_hdr_t hdr; |
---|
| 119 | u16 length; |
---|
| 120 | } __attribute__((__packed__)) ltg_pyld_all_assoc_fixed_t; |
---|
| 121 | ASSERT_TYPE_SIZE(ltg_pyld_all_assoc_fixed_t, 6); |
---|
| 122 | |
---|
| 123 | typedef struct ltg_pyld_uniform_rand_t{ |
---|
| 124 | ltg_pyld_hdr_t hdr; |
---|
| 125 | u8 addr_da[MAC_ADDR_LEN]; |
---|
| 126 | u16 min_length; |
---|
| 127 | u16 max_length; |
---|
| 128 | } __attribute__((__packed__)) ltg_pyld_uniform_rand_t; |
---|
| 129 | ASSERT_TYPE_SIZE(ltg_pyld_uniform_rand_t, 14); |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | //Note: This definition simply reflects the use of the fast timer for LTG polling. To increase LTG |
---|
| 133 | //polling rate at the cost of more overhead in checking LTGs, increase the speed of the fast timer. |
---|
| 134 | #define LTG_ID_INVALID 0xFFFFFFFF |
---|
| 135 | |
---|
| 136 | //External function to LTG -- user code interacts with the LTG via these functions |
---|
| 137 | int wlan_mac_ltg_sched_init(); |
---|
| 138 | void wlan_mac_ltg_sched_set_callback(void(*callback)()); |
---|
| 139 | u32 ltg_sched_create(u32 type, void* params, void* callback_arg, void(*callback)()); |
---|
| 140 | int ltg_sched_remove(u32 id); |
---|
| 141 | int ltg_sched_remove_all(); |
---|
| 142 | int ltg_sched_start(u32 id); |
---|
| 143 | int ltg_sched_start_all(); |
---|
| 144 | int ltg_sched_stop(u32 id); |
---|
| 145 | int ltg_sched_stop_all(); |
---|
| 146 | int ltg_sched_get_state(u32 id, u32* type, void** state); |
---|
| 147 | int ltg_sched_get_params(u32 id, void** params); |
---|
| 148 | int ltg_sched_get_callback_arg(u32 id, void** callback_arg); |
---|
| 149 | |
---|
| 150 | int wlan_create_ltg_frame(u8* pkt, |
---|
| 151 | u8* addr1, |
---|
| 152 | u8* addr2, |
---|
| 153 | u8* addr3, |
---|
| 154 | u8 frame_control_2, |
---|
| 155 | u32 ltg_id); |
---|
| 156 | |
---|
| 157 | dl_entry* ltg_sched_find_tg_schedule(u32 id); |
---|
| 158 | |
---|
| 159 | #endif /* WLAN_MAC_LTG_H_ */ |
---|