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

Last change on this file was 6319, checked in by chunter, 5 years ago

1.8.0 release wlan-mac-se

File size: 4.8 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-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
23struct 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.
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 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
71typedef struct ltg_sched_periodic_params{
72    u32 interval_count;
73    u64 duration_count;
74} ltg_sched_periodic_params_t;
75
76typedef 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
82typedef 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
88typedef 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
95typedef struct ltg_pyld_hdr{
96    u32 type;
97} ltg_pyld_hdr_t;
98
99typedef 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;
104ASSERT_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
109typedef 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;
115ASSERT_TYPE_SIZE(ltg_pyld_ctrl_resp_t, 14);
116
117typedef 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;
121ASSERT_TYPE_SIZE(ltg_pyld_all_assoc_fixed_t, 6);
122
123typedef 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;
129ASSERT_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
137int wlan_mac_ltg_sched_init();
138void wlan_mac_ltg_sched_set_callback(void(*callback)());
139u32 ltg_sched_create(u32 type, void* params, void* callback_arg, void(*callback)());
140int ltg_sched_remove(u32 id);
141int ltg_sched_remove_all();
142int ltg_sched_start(u32 id);
143int ltg_sched_start_all();
144int ltg_sched_stop(u32 id);
145int ltg_sched_stop_all();
146int ltg_sched_get_state(u32 id, u32* type, void** state);
147int ltg_sched_get_params(u32 id, void** params);
148int ltg_sched_get_callback_arg(u32 id, void** callback_arg);
149
150int 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
157dl_entry* ltg_sched_find_tg_schedule(u32 id);
158
159#endif /* WLAN_MAC_LTG_H_ */
Note: See TracBrowser for help on using the repository browser.