source: ReferenceDesigns/w3_802.11/c/wlan_mac_high_framework/include/wlan_mac_ltg.h @ 5562

Last change on this file since 5562 was 5525, checked in by chunter, 8 years ago

1) Moved compilation options out of wlan_mac_high.h and into a new top-level header file: wlan_mac_high_sw_config.h
2) Design now successfully compiles without the WARP_ip_udp library provided that WLAN_SW_CONFIG_ENABLE_WLAN_EXP is set to 0.

File size: 4.6 KB
Line 
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-2016, 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
20#include "wlan_mac_dl_list.h"
21#include "wlan_mac_high.h"
22#include "wlan_mac_eth_util.h"
23
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
27
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
34#define LTG_PYLD_TYPE_ALL_ASSOC_FIXED   3
35
36
37#define LTG_REMOVE_ALL                  0xFFFFFFFF
38#define LTG_START_ALL                   0xFFFFFFFF
39#define LTG_STOP_ALL                    0xFFFFFFFF
40
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.
48typedef struct tg_schedule tg_schedule;
49struct 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
64typedef struct {
65    u8  enabled;
66    u8  reserved[3];
67    u64 start_timestamp;
68    u64 stop_timestamp;
69} ltg_sched_state_hdr;
70
71typedef struct {
72    u32 interval_count;
73    u64 duration_count;
74} ltg_sched_periodic_params;
75
76typedef struct {
77    ltg_sched_state_hdr hdr;
78    u32 time_to_next_count;
79} ltg_sched_periodic_state;
80
81typedef struct {
82    u32 min_interval_count;
83    u32 max_interval_count;
84    u64 duration_count;
85} ltg_sched_uniform_rand_params;
86
87typedef struct {
88    ltg_sched_state_hdr hdr;
89    u32 time_to_next_count;
90} ltg_sched_uniform_rand_state;
91
92//LTG Payload Profiles
93
94typedef struct {
95    u32 type;
96} ltg_pyld_hdr;
97
98typedef struct {
99    ltg_pyld_hdr hdr;
100    u8  addr_da[MAC_ADDR_LEN];
101    u16 length;
102} ltg_pyld_fixed;
103
104typedef struct {
105    ltg_pyld_hdr hdr;
106    u16 length;
107    u16 padding;
108} ltg_pyld_all_assoc_fixed;
109
110typedef struct {
111    ltg_pyld_hdr hdr;
112    u8  addr_da[MAC_ADDR_LEN];
113    u16 min_length;
114    u16 max_length;
115    u16 padding;
116} ltg_pyld_uniform_rand;
117
118
119
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.
122#define LTG_POLL_INTERVAL              FAST_TIMER_DUR_US
123
124#define LTG_ID_INVALID                 0xFFFFFFFF
125
126//External function to LTG -- user code interacts with the LTG via these functions
127int wlan_mac_ltg_sched_init();
128void wlan_mac_ltg_sched_set_callback(void(*callback)());
129u32 ltg_sched_create(u32 type, void* params, void* callback_arg, void(*callback)());
130int ltg_sched_remove(u32 id);
131int ltg_sched_remove_all();
132int ltg_sched_start(u32 id);
133int ltg_sched_start_all();
134int ltg_sched_stop(u32 id);
135int ltg_sched_stop_all();
136int ltg_sched_start_l(dl_entry* curr_tg_dl_entry);
137int ltg_sched_stop_l(dl_entry* curr_tg_dl_entry);
138int ltg_sched_get_state(u32 id, u32* type, void** state);
139int ltg_sched_get_params(u32 id, void** params);
140int ltg_sched_get_callback_arg(u32 id, void** callback_arg);
141int wlan_create_ltg_frame(void* pkt_buf, mac_header_80211_common* common, u8 tx_flags, u32 ltg_id);
142
143// WLAN Exp function to LTG -- users may call these directly or modify if needed
144void * ltg_sched_deserialize(u32 * src, u32 * ret_type, u32 * ret_size);
145void * ltg_payload_deserialize(u32 * src, u32 * ret_type, u32 * ret_size);
146
147//Internal functions to LTG -- users should not need to call these directly
148void ltg_sched_check();
149dl_entry* ltg_sched_create_l();
150void ltg_sched_destroy_l(dl_entry* tg_dl_entry);
151void ltg_sched_destroy_params(tg_schedule *tg);
152dl_entry* ltg_sched_find_tg_schedule(u32 id);
153
154#endif /* WLAN_MAC_LTG_H_ */
Note: See TracBrowser for help on using the repository browser.