[2503] | 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 | * |
---|
[5402] | 7 | * @copyright Copyright 2013-2016, Mango Communications. All rights reserved. |
---|
[2503] | 8 | * Distributed under the Mango Communications Reference Design License |
---|
[5402] | 9 | * See LICENSE.txt included in the design archive or |
---|
| 10 | * at http://mangocomm.com/802.11/license |
---|
[2503] | 11 | * |
---|
[5525] | 12 | * This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11) |
---|
[2503] | 13 | */ |
---|
[2093] | 14 | |
---|
[2220] | 15 | #ifndef WLAN_MAC_LTG_H_ |
---|
| 16 | #define WLAN_MAC_LTG_H_ |
---|
[2093] | 17 | |
---|
[5525] | 18 | #include "wlan_mac_high_sw_config.h" |
---|
| 19 | |
---|
[2435] | 20 | #include "wlan_mac_dl_list.h" |
---|
[3697] | 21 | #include "wlan_mac_high.h" |
---|
| 22 | #include "wlan_mac_eth_util.h" |
---|
[2435] | 23 | |
---|
[2273] | 24 | //LTG Schedules define the times when LTG event callbacks are called. |
---|
| 25 | #define LTG_SCHED_TYPE_PERIODIC 1 |
---|
| 26 | #define LTG_SCHED_TYPE_UNIFORM_RAND 2 |
---|
[2122] | 27 | |
---|
[2273] | 28 | //LTG Payloads define how payloads are constructed once the LTG event callbacks |
---|
| 29 | //are called. For example, the LTG_SCHED_TYPE_PERIODIC schedule that employs the |
---|
| 30 | //LTG_PYLD_TYPE_FIXED would result in a constant bit rate (CBR) traffic |
---|
| 31 | //profile |
---|
| 32 | #define LTG_PYLD_TYPE_FIXED 1 |
---|
| 33 | #define LTG_PYLD_TYPE_UNIFORM_RAND 2 |
---|
[3237] | 34 | #define LTG_PYLD_TYPE_ALL_ASSOC_FIXED 3 |
---|
[2220] | 35 | |
---|
[2273] | 36 | |
---|
[2724] | 37 | #define LTG_REMOVE_ALL 0xFFFFFFFF |
---|
| 38 | #define LTG_START_ALL 0xFFFFFFFF |
---|
| 39 | #define LTG_STOP_ALL 0xFFFFFFFF |
---|
[2437] | 40 | |
---|
[2724] | 41 | |
---|
[2862] | 42 | //In spirit, tg_schedule is derived from dl_entry. Since C |
---|
[2437] | 43 | //lacks a formal notion of inheritance, we adopt a popular |
---|
[2862] | 44 | //alternative idiom for inheritance where the dl_entry |
---|
[2437] | 45 | //is the first entry in the new structure. Since structures |
---|
| 46 | //will never be padded before their first entry, it is safe |
---|
[2862] | 47 | //to cast back and forth between the tg_schedule and dl_entry. |
---|
[2273] | 48 | typedef struct tg_schedule tg_schedule; |
---|
| 49 | struct tg_schedule{ |
---|
[2220] | 50 | u32 id; |
---|
| 51 | u32 type; |
---|
[3226] | 52 | u64 target; |
---|
[3232] | 53 | u64 stop_target; |
---|
[2220] | 54 | void* params; |
---|
[2273] | 55 | void* callback_arg; |
---|
| 56 | function_ptr_t cleanup_callback; |
---|
| 57 | void* state; |
---|
[2122] | 58 | }; |
---|
| 59 | |
---|
[2273] | 60 | //LTG Schedules |
---|
| 61 | |
---|
[3232] | 62 | #define LTG_DURATION_FOREVER 0 |
---|
| 63 | |
---|
[2220] | 64 | typedef struct { |
---|
[3592] | 65 | u8 enabled; |
---|
| 66 | u8 reserved[3]; |
---|
| 67 | u64 start_timestamp; |
---|
| 68 | u64 stop_timestamp; |
---|
[2273] | 69 | } ltg_sched_state_hdr; |
---|
| 70 | |
---|
| 71 | typedef struct { |
---|
[3226] | 72 | u32 interval_count; |
---|
[3232] | 73 | u64 duration_count; |
---|
[2273] | 74 | } ltg_sched_periodic_params; |
---|
[2122] | 75 | |
---|
[2273] | 76 | typedef struct { |
---|
| 77 | ltg_sched_state_hdr hdr; |
---|
[3226] | 78 | u32 time_to_next_count; |
---|
[2273] | 79 | } ltg_sched_periodic_state; |
---|
[2122] | 80 | |
---|
[2273] | 81 | typedef struct { |
---|
[3226] | 82 | u32 min_interval_count; |
---|
| 83 | u32 max_interval_count; |
---|
[3232] | 84 | u64 duration_count; |
---|
[2273] | 85 | } ltg_sched_uniform_rand_params; |
---|
[2122] | 86 | |
---|
[2273] | 87 | typedef struct { |
---|
| 88 | ltg_sched_state_hdr hdr; |
---|
[3232] | 89 | u32 time_to_next_count; |
---|
[2273] | 90 | } ltg_sched_uniform_rand_state; |
---|
[2122] | 91 | |
---|
[2273] | 92 | //LTG Payload Profiles |
---|
[2122] | 93 | |
---|
[2273] | 94 | typedef struct { |
---|
| 95 | u32 type; |
---|
| 96 | } ltg_pyld_hdr; |
---|
[2122] | 97 | |
---|
[2273] | 98 | typedef struct { |
---|
| 99 | ltg_pyld_hdr hdr; |
---|
[5402] | 100 | u8 addr_da[MAC_ADDR_LEN]; |
---|
[2273] | 101 | u16 length; |
---|
| 102 | } ltg_pyld_fixed; |
---|
[2122] | 103 | |
---|
[2273] | 104 | typedef struct { |
---|
| 105 | ltg_pyld_hdr hdr; |
---|
[3237] | 106 | u16 length; |
---|
| 107 | u16 padding; |
---|
| 108 | } ltg_pyld_all_assoc_fixed; |
---|
| 109 | |
---|
| 110 | typedef struct { |
---|
| 111 | ltg_pyld_hdr hdr; |
---|
[5402] | 112 | u8 addr_da[MAC_ADDR_LEN]; |
---|
[2273] | 113 | u16 min_length; |
---|
| 114 | u16 max_length; |
---|
[3232] | 115 | u16 padding; |
---|
[2273] | 116 | } ltg_pyld_uniform_rand; |
---|
| 117 | |
---|
[3226] | 118 | |
---|
[3592] | 119 | |
---|
[3226] | 120 | //Note: This definition simply reflects the use of the fast timer for LTG polling. To increase LTG |
---|
| 121 | //polling rate at the cost of more overhead in checking LTGs, increase the speed of the fast timer. |
---|
[3264] | 122 | #define LTG_POLL_INTERVAL FAST_TIMER_DUR_US |
---|
[3226] | 123 | |
---|
[3264] | 124 | #define LTG_ID_INVALID 0xFFFFFFFF |
---|
[3237] | 125 | |
---|
[2273] | 126 | //External function to LTG -- user code interacts with the LTG via these functions |
---|
| 127 | int wlan_mac_ltg_sched_init(); |
---|
| 128 | void wlan_mac_ltg_sched_set_callback(void(*callback)()); |
---|
[3237] | 129 | u32 ltg_sched_create(u32 type, void* params, void* callback_arg, void(*callback)()); |
---|
[2273] | 130 | int ltg_sched_remove(u32 id); |
---|
[3450] | 131 | int ltg_sched_remove_all(); |
---|
[2273] | 132 | int ltg_sched_start(u32 id); |
---|
[2724] | 133 | int ltg_sched_start_all(); |
---|
[2273] | 134 | int ltg_sched_stop(u32 id); |
---|
[2724] | 135 | int ltg_sched_stop_all(); |
---|
[3180] | 136 | int ltg_sched_start_l(dl_entry* curr_tg_dl_entry); |
---|
| 137 | int ltg_sched_stop_l(dl_entry* curr_tg_dl_entry); |
---|
[2273] | 138 | int ltg_sched_get_state(u32 id, u32* type, void** state); |
---|
[3180] | 139 | int ltg_sched_get_params(u32 id, void** params); |
---|
[2273] | 140 | int ltg_sched_get_callback_arg(u32 id, void** callback_arg); |
---|
[3803] | 141 | int wlan_create_ltg_frame(void* pkt_buf, mac_header_80211_common* common, u8 tx_flags, u32 ltg_id); |
---|
[2273] | 142 | |
---|
[2724] | 143 | // WLAN Exp function to LTG -- users may call these directly or modify if needed |
---|
| 144 | void * ltg_sched_deserialize(u32 * src, u32 * ret_type, u32 * ret_size); |
---|
| 145 | void * ltg_payload_deserialize(u32 * src, u32 * ret_type, u32 * ret_size); |
---|
| 146 | |
---|
[2273] | 147 | //Internal functions to LTG -- users should not need to call these directly |
---|
| 148 | void ltg_sched_check(); |
---|
[3237] | 149 | dl_entry* ltg_sched_create_l(); |
---|
| 150 | void ltg_sched_destroy_l(dl_entry* tg_dl_entry); |
---|
[2454] | 151 | void ltg_sched_destroy_params(tg_schedule *tg); |
---|
[3180] | 152 | dl_entry* ltg_sched_find_tg_schedule(u32 id); |
---|
[2273] | 153 | |
---|
[2220] | 154 | #endif /* WLAN_MAC_LTG_H_ */ |
---|