[6319] | 1 | /** @file wlan_mac_station_info.c |
---|
| 2 | * @brief Station Information Metadata Subsystem |
---|
| 3 | * |
---|
| 4 | * This contains code tracking metadata about stations. |
---|
| 5 | * |
---|
| 6 | * @copyright Copyright 2014-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 | #ifndef WLAN_MAC_STATION_INFO_H_ |
---|
| 15 | #define WLAN_MAC_STATION_INFO_H_ |
---|
| 16 | |
---|
| 17 | /***************************** Include Files *********************************/ |
---|
| 18 | |
---|
| 19 | #include "wlan_mac_high_sw_config.h" |
---|
| 20 | #include "xil_types.h" |
---|
| 21 | #include "wlan_common_types.h" |
---|
| 22 | #include "wlan_high_types.h" |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | /*************************** Constant Definitions ****************************/ |
---|
| 26 | |
---|
| 27 | //----------------------------------------------- |
---|
| 28 | // Timeout used to remove inactive BSS infos |
---|
| 29 | // - Part of bss_info_timestamp_check() |
---|
| 30 | // |
---|
| 31 | #define STATION_INFO_TIMEOUT_USEC 600000000 |
---|
| 32 | |
---|
| 33 | /******************************************************************** |
---|
| 34 | * @brief Tx/Rx Counts Sub-structure |
---|
| 35 | * |
---|
| 36 | * This struct contains counts about the communications link. It is intended to |
---|
| 37 | * be instantiated multiple times in the broader txrx_counts_t struct so that |
---|
| 38 | * different packet types can be individually tracked. |
---|
| 39 | * |
---|
| 40 | ********************************************************************/ |
---|
| 41 | typedef struct txrx_counts_sub_t{ |
---|
| 42 | u64 rx_num_bytes; ///< # of successfully received bytes (de-duplicated) |
---|
| 43 | u64 rx_num_bytes_total; ///< # of successfully received bytes (including duplicates) |
---|
| 44 | u64 tx_num_bytes_success; ///< # of successfully transmitted bytes (high-level MPDUs) |
---|
| 45 | u64 tx_num_bytes_total; ///< Total # of transmitted bytes (high-level MPDUs) |
---|
| 46 | u32 rx_num_packets; ///< # of successfully received packets (de-duplicated) |
---|
| 47 | u32 rx_num_packets_total; ///< # of successfully received packets (including duplicates) |
---|
| 48 | u32 tx_num_packets_success; ///< # of successfully transmitted packets (high-level MPDUs) |
---|
| 49 | u32 tx_num_packets_total; ///< Total # of transmitted packets (high-level MPDUs) |
---|
| 50 | u64 tx_num_attempts; ///< # of low-level attempts (including retransmissions) |
---|
| 51 | } txrx_counts_sub_t; |
---|
| 52 | CASSERT(sizeof(txrx_counts_sub_t) == 56,txrx_counts_sub_alignment_check); |
---|
| 53 | |
---|
| 54 | /******************************************************************** |
---|
| 55 | * @brief Station Counts Structure |
---|
| 56 | * |
---|
| 57 | * This struct contains counts about the communications link. Additionally, |
---|
| 58 | * counting different parameters can be decoupled from station_info structs |
---|
| 59 | * entirely to enable promiscuous counts about unassociated devices seen in |
---|
| 60 | * the network. |
---|
| 61 | * |
---|
| 62 | ********************************************************************/ |
---|
| 63 | typedef struct station_txrx_counts_t{ |
---|
| 64 | txrx_counts_sub_t data; /* Counts about data types */ |
---|
| 65 | /*----- 8-byte boundary ------*/ |
---|
| 66 | txrx_counts_sub_t mgmt; /* Counts about management types */ |
---|
| 67 | /*----- 8-byte boundary ------*/ |
---|
| 68 | } station_txrx_counts_t; |
---|
| 69 | |
---|
| 70 | ASSERT_TYPE_SIZE(station_txrx_counts_t, 112); |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | /******************************************************************** |
---|
| 74 | * @brief Rate Selection Information |
---|
| 75 | * |
---|
| 76 | * This structure contains information about the rate selection scheme. |
---|
| 77 | * |
---|
| 78 | ********************************************************************/ |
---|
| 79 | typedef struct rate_selection_info_t{ |
---|
| 80 | u16 rate_selection_scheme; |
---|
| 81 | u8 reserved[6]; |
---|
| 82 | } rate_selection_info_t; |
---|
| 83 | |
---|
| 84 | #define RATE_SELECTION_SCHEME_STATIC 0 |
---|
| 85 | |
---|
| 86 | /******************************************************************** |
---|
| 87 | * @brief Station Information Structure |
---|
| 88 | * |
---|
| 89 | * This struct contains information about associated stations (or, in the |
---|
| 90 | * case of a station, information about the associated access point). |
---|
| 91 | * |
---|
| 92 | * NOTE: The reason that the reference design uses a #define for fields in |
---|
| 93 | * two different structs is so that fields that must be in two different |
---|
| 94 | * structs stay in sync and so there is not another level of indirection |
---|
| 95 | * by using nested structs. |
---|
| 96 | * |
---|
| 97 | ********************************************************************/ |
---|
| 98 | #define STATION_INFO_HOSTNAME_MAXLEN 19 |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | typedef struct station_info_t{ |
---|
| 102 | u8 addr[MAC_ADDR_LEN]; /* HW Address */ |
---|
| 103 | s16 ID; /* Identification Index for this station */ |
---|
| 104 | char hostname[STATION_INFO_HOSTNAME_MAXLEN+1]; /* Hostname from DHCP requests */ |
---|
| 105 | u8 flags; /* 1-bit flags */ |
---|
| 106 | u8 ps_state; /* Power saving state */ |
---|
| 107 | u16 capabilities; /* Capabilities */ |
---|
| 108 | u64 latest_rx_timestamp; /* Timestamp of most recent reception */ |
---|
| 109 | u64 latest_txrx_timestamp; /* Timestamp of most recent reception or transmission */ |
---|
| 110 | u16 latest_rx_seq; /* Sequence number of the last MPDU reception */ |
---|
| 111 | s16 QID; /* Queue ID used by this station */ |
---|
| 112 | int num_linked_queue_buffer; /* Number of queue buffers linked to this station_info_t */ |
---|
| 113 | tx_params_t tx_params_data; /* Transmission Parameters Structure for Data */ |
---|
| 114 | tx_params_t tx_params_mgmt; /* Transmission Parameters Structure for Management */ |
---|
| 115 | #if WLAN_SW_CONFIG_ENABLE_TXRX_COUNTS |
---|
| 116 | station_txrx_counts_t txrx_counts; /* Tx/Rx Counts */ |
---|
| 117 | #endif |
---|
| 118 | rate_selection_info_t rate_info; |
---|
| 119 | } station_info_t; |
---|
| 120 | #if WLAN_SW_CONFIG_ENABLE_TXRX_COUNTS |
---|
| 121 | ASSERT_TYPE_SIZE(station_info_t, 192); |
---|
| 122 | |
---|
| 123 | // For wlan_exp retrieval purposes, we need to make sure that the txrx_counter field is located |
---|
| 124 | // at the end of the struct with rate_info. Here we can construct a compile time assertion that |
---|
| 125 | // will fail if that assumption is broken. |
---|
| 126 | ASSERT_FIELD_END_ALIGNMENT(station_info_t, txrx_counts, sizeof(station_txrx_counts_t) + sizeof(rate_selection_info_t)); |
---|
| 127 | |
---|
| 128 | #else |
---|
| 129 | ASSERT_TYPE_SIZE(station_info_t, 80); |
---|
| 130 | #endif |
---|
| 131 | |
---|
| 132 | // For wlan_exp retrieval purposes, we need to make sure that the rate_info field is located |
---|
| 133 | // at the end of the struct Here we can construct a compile time assertion that will fail if |
---|
| 134 | // that assumption is broken. |
---|
| 135 | ASSERT_FIELD_END_ALIGNMENT(station_info_t, rate_info, sizeof(rate_selection_info_t)); |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | #define STATION_INFO_FLAG_KEEP 0x01 ///< Prevent MAC High Framework from deleting this station_infO |
---|
| 139 | #define STATION_INFO_FLAG_DISABLE_ASSOC_CHECK 0x02 ///< Mask for flag in station_info -- disable association check |
---|
| 140 | |
---|
| 141 | #define STATION_INFO_PS_STATE_DOZE 0x01 ///< Mask to sleeping stations (if STA supports PS) |
---|
| 142 | |
---|
| 143 | #define STATION_INFO_CAPABILITIES_HT_CAPABLE 0x0001 ///< Station is capable of HT Tx and Rx |
---|
| 144 | |
---|
| 145 | #define RX_PROCESS_COUNTS_OPTION_FLAG_IS_DUPLICATE 0x00000001 |
---|
| 146 | |
---|
| 147 | #define STATION_INFO_PRINT_OPTION_FLAG_INCLUDE_COUNTS 0x00000001 |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | //Define a new type of dl_entry for pointing to station_info_t |
---|
| 151 | // structs that contains some extra fields for faster searching |
---|
| 152 | // without needing to jump to DRAM. |
---|
| 153 | typedef struct station_info_entry_t station_info_entry_t; |
---|
| 154 | struct station_info_entry_t{ |
---|
| 155 | station_info_entry_t* next; |
---|
| 156 | station_info_entry_t* prev; |
---|
| 157 | station_info_t* data; |
---|
| 158 | u8 addr[6]; |
---|
| 159 | u16 reserved; |
---|
| 160 | }; |
---|
| 161 | ASSERT_TYPE_SIZE(station_info_entry_t, 20); |
---|
| 162 | |
---|
| 163 | typedef enum default_tx_param_sel_t{ |
---|
| 164 | unicast_mgmt, |
---|
| 165 | unicast_data, |
---|
| 166 | mcast_mgmt, |
---|
| 167 | mcast_data, |
---|
| 168 | } default_tx_param_sel_t; |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | // Forward declarations -- these must be defined elsewhere |
---|
| 172 | struct dl_entry; |
---|
| 173 | struct dl_list; |
---|
| 174 | struct wlan_mac_low_tx_details_t; |
---|
| 175 | |
---|
| 176 | /*************************** Function Prototypes *****************************/ |
---|
| 177 | |
---|
| 178 | void station_info_init(); |
---|
| 179 | void station_info_init_finish(); |
---|
| 180 | |
---|
| 181 | station_info_entry_t* station_info_checkout(); |
---|
| 182 | void station_info_checkin(struct dl_entry* entry); |
---|
| 183 | |
---|
| 184 | station_info_t* station_info_posttx_process(void* pkt_buf_addr); |
---|
| 185 | station_info_t* station_info_txreport_process(void* pkt_buf_addr, struct wlan_mac_low_tx_details_t* wlan_mac_low_tx_details); |
---|
| 186 | station_info_t* station_info_postrx_process(void* pkt_buf_addr); |
---|
| 187 | void station_info_rx_process_hostname(void* pkt_buf_addr, station_info_t* station_info); |
---|
| 188 | #if WLAN_SW_CONFIG_ENABLE_TXRX_COUNTS |
---|
| 189 | void station_info_rx_process_counts(void* pkt_buf_addr, station_info_t* station_info, u32 option_flags); |
---|
| 190 | #endif |
---|
| 191 | |
---|
| 192 | void station_info_print(struct dl_list* list, u32 option_flags); |
---|
| 193 | |
---|
| 194 | #if WLAN_SW_CONFIG_ENABLE_TXRX_COUNTS |
---|
| 195 | void txrx_counts_zero_all(); |
---|
| 196 | void station_info_clear_txrx_counts(station_txrx_counts_t* txrx_counts); |
---|
| 197 | #endif |
---|
| 198 | |
---|
| 199 | void station_info_timestamp_check(); |
---|
| 200 | |
---|
| 201 | station_info_t* station_info_create(u8* addr); |
---|
| 202 | void station_info_reset_all(); |
---|
| 203 | void station_info_clear(station_info_t* station_info); |
---|
| 204 | |
---|
| 205 | struct dl_list* station_info_get_list(); |
---|
| 206 | |
---|
| 207 | station_info_entry_t* station_info_find_by_id(u32 id, struct dl_list* list); |
---|
| 208 | station_info_entry_t* station_info_find_by_addr(u8* addr, struct dl_list* list); |
---|
| 209 | |
---|
| 210 | station_info_t* station_info_add_to_list(dl_list* app_station_info_list, u8* addr); |
---|
| 211 | int station_info_remove_from_list(dl_list* app_station_info_list, u8* addr); |
---|
| 212 | |
---|
| 213 | u8 station_info_is_member(struct dl_list* app_station_info_list, station_info_t* station_info); |
---|
| 214 | |
---|
| 215 | tx_params_t wlan_mac_get_default_tx_params(default_tx_param_sel_t default_tx_param_sel); |
---|
| 216 | void wlan_mac_set_default_tx_params(default_tx_param_sel_t default_tx_param_sel, tx_params_t* tx_params); |
---|
| 217 | void wlan_mac_reapply_default_tx_params(); |
---|
| 218 | |
---|
| 219 | #endif |
---|