source: ReferenceDesigns/w3_802.11/c/wlan_mac_low_dcf/include/wlan_mac_dcf.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_dcf.h
2 *  @brief Distributed Coordination Function
3 *
4 *  This contains code to implement the 802.11 DCF.
5 *
6 *  @copyright Copyright 2013-2019, Mango Communications. All rights reserved.
7 *          Distributed under the Mango Communications Reference Design License
8 *              See LICENSE.txt included in the design archive or
9 *              at http://mangocomm.com/802.11/license
10 *
11 *  This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11)
12 */
13
14
15/*************************** Constant Definitions ****************************/
16#ifndef WLAN_MAC_DCF_H_
17#define WLAN_MAC_DCF_H_
18
19#include "xil_types.h"
20
21//Forward declarations
22struct phy_rx_details_t;
23enum phy_samp_rate_t;
24struct beacon_txrx_configure_t;
25
26#define PKT_BUF_INVALID                                   0xFF
27#define MAX_NUM_PENDING_TX_PKT_BUFS                       5
28
29
30//-----------------------------------------------
31// MAC Timing Structure
32typedef struct mac_timing{
33    u16 t_slot;
34    u16 t_sifs;
35    u16 t_difs;
36    u16 t_eifs;
37    u16 t_phy_rx_start_dly;
38    u16 t_timeout;
39} mac_timing;
40
41//-----------------------------------------------
42// CW Update Reasons
43#define DCF_CW_UPDATE_MPDU_TX_ERR                          0
44#define DCF_CW_UPDATE_MPDU_RX_ACK                          1
45#define DCF_CW_UPDATE_BCAST_TX                             2
46
47
48//-----------------------------------------------
49// Reason codes for generating a random number of slots
50//     See:  rand_num_slots()
51//
52#define RAND_SLOT_REASON_STANDARD_ACCESS                   0
53#define RAND_SLOT_REASON_IBSS_BEACON                       1
54
55//-----------------------------------------------
56// According to 10.21.1 of 802.11-2012, the timestamp value of
57// transmitted beacons and probe responses shall be set to the
58// time of the data symbol containing the first bit of the timestamp
59// This is a rate-specific value. For this release, we will hardcode
60// the value for the default MCS 0, NONHT (aka 6 Mbps) rate. This
61// needs to be changed for beacons & probe responses sent at a different
62// rate
63#define T_TIMESTAMP_FIELD_OFFSET                           52
64
65
66//-----------------------------------------------
67// WLAN Exp low parameter defines (DCF)
68//     NOTE:  Need to make sure that these values do not conflict with any of the LOW PARAM
69//     callback defines
70//
71#define LOW_PARAM_DCF_RTS_THRESH                           0x10000001
72#define LOW_PARAM_DCF_DOT11SHORTRETRY                      0x10000002
73#define LOW_PARAM_DCF_DOT11LONGRETRY                       0x10000003
74#define LOW_PARAM_DCF_CW_EXP_MIN                           0x10000005
75#define LOW_PARAM_DCF_CW_EXP_MAX                           0x10000006
76
77
78
79/*********************** Global Structure Definitions ************************/
80
81typedef enum rx_finish_state_t{
82    RX_FINISH_SEND_NONE,
83    RX_FINISH_SEND_A,
84    RX_FINISH_SEND_B
85} rx_finish_state_t;
86
87
88typedef enum tx_pending_state_t{
89    TX_PENDING_NONE,
90    TX_PENDING_A,
91    TX_PENDING_B
92} tx_pending_state_t;
93
94
95typedef enum tx_wait_state_t{
96    TX_WAIT_NONE,
97    TX_WAIT_ACK,
98    TX_WAIT_CTS
99} tx_wait_state_t;
100
101
102typedef enum tx_mode_t{
103    TX_MODE_SHORT,
104    TX_MODE_LONG
105} tx_mode_t;
106
107/*************************** Function Prototypes *****************************/
108int                main();
109
110u32                frame_receive(u8 rx_pkt_buf, struct phy_rx_details_t* phy_details);
111void               handle_mcast_buffer_enable(u32 enable);
112void               update_tx_pkt_buf_lists();
113void               handle_sample_rate_change(enum phy_samp_rate_t phy_samp_rate);
114void               update_dtim_count();
115void               update_tu_target(u8 recompute);
116void               handle_mactime_change(s64 time_delta_usec);
117void               configure_beacon_txrx(struct beacon_txrx_configure_t* beacon_txrx_configure);
118void               frame_transmit_general(u8 pkt_buf);
119
120#define            DTIM_MCAST_RETURN_PAUSED         0x00000001
121u32                frame_transmit_dtim_mcast(u8 pkt_buf, u8 resume);
122int                handle_tx_pkt_buf_ready(u8 pkt_buf);
123
124#define            POLL_TX_PKT_BUF_LIST_RETURN_ERROR            0x80000000
125#define            POLL_TX_PKT_BUF_LIST_RETURN_TRANSMITTED      0x00000001
126#define            POLL_TX_PKT_BUF_LIST_RETURN_PAUSED           0x00000002
127#define            POLL_TX_PKT_BUF_LIST_RETURN_MORE_DATA        0x00000004
128u32                poll_tx_pkt_buf_list(pkt_buf_group_t pkt_buf_group);
129
130void               increment_src(u16* src_ptr);
131void               increment_lrc(u16* lrc_ptr);
132
133void               poll_tbtt_and_send_beacon();
134
135#define            SEND_BEACON_RETURN_DTIM          0x00000001
136#define            SEND_BEACON_RETURN_CANCELLED     0x00000002
137u32                send_beacon(u8 tx_pkt_buf);
138
139void               reset_cw();
140void               reset_ssrc();
141void               reset_slrc();
142
143u32                rand_num_slots(u8 reason);
144
145void               wlan_mac_dcf_hw_start_backoff(u16 num_slots);
146
147#endif /* WLAN_MAC_DCF_H_ */
Note: See TracBrowser for help on using the repository browser.