source: ReferenceDesigns/w3_802.11/c/wlan_mac_common_framework/include/wlan_common_types.h

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

1.8.0 release wlan-mac-se

File size: 6.1 KB
Line 
1#ifndef WLAN_COMMON_TYPES_H_
2#define WLAN_COMMON_TYPES_H_
3
4#include "xil_types.h"
5#include "xil_io.h"
6#include "stddef.h"
7
8#define WLAN_SUCCESS 0
9#define WLAN_FAILURE -1
10
11// Define a compile-time  macros that act like assert
12//  We use these primarily to check that struct sizes match corresponding sizes expected by wlan_exp
13//  This check catches cases where unexpected packing/padding change alignment of struct fields
14//  Inspired by https://stackoverflow.com/a/809465
15#define CASSERT(test_cond, failure_msg) \
16    typedef char CASSERT_FAILED_##failure_msg[2*!!(test_cond)-1];
17
18#define ASSERT_TYPE_SIZE(check_type, req_size) \
19    typedef char ASSERT_TYPE_SIZE_FAILED_##check_type##_neq_##req_size[2*!!(req_size == sizeof(check_type))-1]
20
21#define ASSERT_FIELD_ALIGNMENT(type, field, alignment) \
22    typedef char ASSERT_FIELD_ALIGNMENT_FAILED_##type##_##member##_neq_##alignment[2*!!((offsetof(type,field) % alignment) == 0)-1]
23
24#define ASSERT_FIELD_OVERLAP_ALIGNMENT(type1, field1, type2, field2) \
25    CASSERT(offsetof(type1,field1)==offsetof(type2,field2),OVERLAP_ALIGNMENT_ERROR);
26
27#define ASSERT_FIELD_END_ALIGNMENT(type, field, size) \
28    CASSERT((offsetof(type,field)+size) == sizeof(type), END_ALIGNMENT_ERROR);
29
30#define ASSERT_U32_ALIGNED(type) \
31    CASSERT((sizeof(type) & 0x3) == 0, U32_ALIGNMENT_ERROR);
32
33
34//-----------------------------------------------
35// Compilation Details
36//
37typedef struct {
38    char    compilation_date[12]; // Must be at least 12 bytes.
39    char    compilation_time[12]; // Must be at least 9 bytes. Unfortunately, wlan_exp places an additional requirement that each field in
40                                  // wlan_exp_node_info_t must be u32 aligned, so we increase the size to 12 bytes.
41} __attribute__((__packed__)) compilation_details_t;
42ASSERT_TYPE_SIZE(compilation_details_t, 24);
43// This type is sent as an IPC payload, which deals with u32 words
44ASSERT_U32_ALIGNED(compilation_details_t);
45
46
47//-----------------------------------------------
48// Generic function pointer
49//
50typedef int (*function_ptr_t)();
51
52//-----------------------------------------------
53// Interrupt Connection Parameters
54//
55typedef struct intr_conn_params_t {
56    function_ptr_t intr_handler0;
57    void*          intr_handler_arg0;
58    function_ptr_t intr_handler1;
59    void*          intr_handler_arg1;
60} intr_conn_params_t ;
61
62typedef struct peripheral_args_t {
63    void*   driver_instance;
64    function_ptr_t callback0;
65    function_ptr_t callback1;
66} peripheral_args_t;
67
68//-----------------------------------------------
69// Field size defines
70//
71#define MAC_ADDR_LEN 6  ///< MAC Address Length (in bytes)
72#define IP_ADDR_LEN 4 ///< Length of IP address (in bytes)
73#define SSID_LEN_MAX 32 ///< Maximum SSID length
74
75#define MAX_PKT_SIZE_KB 2
76#define MAX_PKT_SIZE_B (MAX_PKT_SIZE_KB << 10)
77
78// Helper macro to swap byte order for 64-bit values
79//  Xil_ header only provides 16-bit and 32-bit macros
80#define wlan_htonll(x) ((((u64)Xil_Htonl(x)) << 32) + Xil_Htonl((x) >> 32))
81
82//-----------------------------------------------
83// TX parameters
84//     - Be careful when modifying these structures, there are alignment concerns
85//       for many of the structures that contain these structures.  In general,
86//       tx_params_t should be 8-byte aligned.
87//
88//  phy_tx_params_t is also used as a field in Tx log entries, so the struct
89//   must be packed to match the log entry definition in Python
90typedef struct phy_tx_params_t{
91    u8                       mcs;                          ///< MCS index
92    u8                       phy_mode;                     ///< PHY mode selection and flags
93    u8                       antenna_mode;                 ///< Tx antenna selection
94    s8                       power;                        ///< Tx power (in dBm)
95} __attribute__((__packed__)) phy_tx_params_t;
96ASSERT_TYPE_SIZE(phy_tx_params_t, 4);
97
98typedef struct mac_tx_params_t{
99    u8                       flags;                        ///< Flags affecting waveform construction
100    u8                       reserved[3];                  ///< Reserved for 32-bit alignment
101} mac_tx_params_t;
102
103typedef struct tx_params_t{
104    phy_tx_params_t          phy;                          ///< PHY Tx params
105    mac_tx_params_t          mac;                          ///< Lower-level MAC Tx params
106} tx_params_t;
107
108//-----------------------------------------------
109// TX queue information
110//     - Information about the TX queue that contained the packet while in CPU High.
111//     - This structure must be 32-bit aligned.
112//
113typedef enum __attribute__ ((__packed__)){
114    PKT_BUF_GROUP_GENERAL       = 0,
115    PKT_BUF_GROUP_DTIM_MCAST    = 1,
116    PKT_BUF_GROUP_OTHER         = 0xFF,
117} pkt_buf_group_t;
118ASSERT_TYPE_SIZE(pkt_buf_group_t, 1);
119
120typedef struct __attribute__ ((__packed__)) tx_queue_details_t{
121    u64                     enqueue_timestamp;
122    u8                      id;                           ///< ID of the Queue
123    pkt_buf_group_t         pkt_buf_group;                ///< Packet Buffer Group
124    u16                     occupancy;                    ///< Number of elements in the queue when the packet was enqueued (including itself)
125} tx_queue_details_t;
126ASSERT_TYPE_SIZE(tx_queue_details_t, 12);
127
128//-----------------------------------------------
129// LLC Header
130//
131typedef struct llc_header_t{
132    u8   dsap;
133    u8   ssap;
134    u8   control_field;
135    u8   org_code[3];
136    u16  type;
137} llc_header_t;
138
139//-----------------------------------------------
140// LTG Payload Contents
141//
142typedef struct ltg_packet_id_t{
143    llc_header_t   llc_hdr;
144    u64            unique_seq;
145    u32            ltg_id;
146} ltg_packet_id_t;
147
148//-----------------------------------------------
149// Doubly-Linked List
150//
151
152typedef struct dl_entry dl_entry;
153
154struct dl_entry{
155    dl_entry* next;
156    dl_entry* prev;
157    void*     data;
158};
159
160//Forward declaration of dl_entry
161typedef struct dl_list{
162    dl_entry* first;
163    dl_entry* last;
164    u32       length;
165} dl_list;
166
167//-----------------------------------------------
168// PHY Bandwidth Configuration
169//
170typedef enum phy_samp_rate_t{
171    PHY_10M   = 10,
172    PHY_20M   = 20,
173    PHY_40M   = 40
174} phy_samp_rate_t;
175
176
177#endif /* WLAN_COMMON_TYPES_H_ */
Note: See TracBrowser for help on using the repository browser.