00001 00012 #ifndef _TD_H_ 00013 #define _TD_H_ 00014 00024 /* 00025 * INCLUDE FILES 00026 **************************************************************************************** 00027 */ 00028 #include "rwnx_config.h" 00029 00030 /* 00031 * DEFINES 00032 **************************************************************************************** 00033 */ 00034 00036 #define TD_DEFAULT_INTV_US (100000) 00037 00041 #define TD_DEFAULT_PCK_NB_THRES (3) 00042 00043 /* 00044 * ENUMERATIONS 00045 **************************************************************************************** 00046 */ 00047 00049 enum td_status_bit 00050 { 00052 TD_STATUS_TX = 0, 00054 TD_STATUS_RX, 00056 TD_STATUS_TX_PS, 00058 TD_STATUS_RX_PS, 00059 }; 00060 00061 #if (NX_TD) 00062 00063 #include "mm_timer.h" 00064 00065 /* 00066 * TYPES DEFINITION 00067 **************************************************************************************** 00068 */ 00069 00073 struct td_env_tag 00074 { 00075 // Timer used for Traffic Detection Interval 00076 struct mm_timer_tag td_timer; 00077 00078 // Number of packets transmitted during TD interval (overall) 00079 uint32_t pck_cnt_tx; 00080 // Number of packets received during TD interval (overall) 00081 uint32_t pck_cnt_rx; 00082 00083 #if (NX_DPSM) 00084 // Number of packets transmitted during TD interval, PS filtering applied (UAPSD,...) 00085 uint32_t pck_cnt_tx_ps; 00086 // Number of packets received during TD interval, PS filtering applied (UAPSD,...) 00087 uint32_t pck_cnt_rx_ps; 00088 #endif //(NX_DPSM) 00089 00090 // VIF Index 00091 uint8_t vif_index; 00092 // Bit field indicating traffic status - see enum td_status_bit 00093 uint8_t status; 00094 // Indicate if the Traffic Detection is activated for a VIF (<=> td_timer running) 00095 bool is_on; 00096 00097 #if (NX_CHNL_CTXT) 00098 // Indicate if VIF has been present on its channel context during TD interval 00099 bool has_active_chan; 00100 #endif //(NX_CHNL_CTXT) 00101 }; 00102 00103 00104 /* 00105 * GLOBAL VARIABLES 00106 **************************************************************************************** 00107 */ 00108 00110 extern struct td_env_tag td_env_tab[NX_VIRT_DEV_MAX]; 00111 00112 /* 00113 * PUBLIC FUNCTIONS 00114 **************************************************************************************** 00115 */ 00116 00122 void td_init(void); 00123 00130 void td_reset(uint8_t vif_index); 00131 00138 void td_start(uint8_t vif_index); 00139 00149 void td_pck_ind(uint8_t vif_index, uint8_t sta_index, bool rx); 00150 00151 #if (NX_DPSM) 00152 00161 void td_pck_ps_ind(uint8_t vif_index, bool rx); 00162 #endif //(NX_DPSM) 00163 00169 __INLINE uint8_t td_get_status(uint8_t vif_index) 00170 { 00171 return (td_env_tab[vif_index].status & (CO_BIT(TD_STATUS_TX) | CO_BIT(TD_STATUS_RX))); 00172 } 00173 00179 __INLINE uint8_t td_get_ps_status(uint8_t vif_index) 00180 { 00181 return (td_env_tab[vif_index].status & (CO_BIT(TD_STATUS_TX_PS) | CO_BIT(TD_STATUS_RX_PS))); 00182 } 00183 00184 #endif //(NX_TD) 00185 00186 #if (NX_TD_STA) 00187 00190 struct td_sta_env_tag 00191 { 00192 // Status (@see enum td_status_bit) 00193 uint8_t status; 00194 // Counter allowing to monitor if number of packets transmitted during TD interval has reached the detection threshold 00195 uint8_t pck_cnt_tx; 00196 // Counter allowing to monitor if number of packets received during TD interval has reached the detection threshold 00197 uint8_t pck_cnt_rx; 00198 }; 00199 00201 extern struct td_sta_env_tag td_sta_env[NX_REMOTE_STA_MAX]; 00202 00209 void td_sta_reset(uint8_t sta_index); 00210 00219 __INLINE bool td_sta_has_tx_traffic(uint8_t sta_idx) 00220 { 00221 return (td_sta_env[sta_idx].status & CO_BIT(TD_STATUS_TX)); 00222 } 00223 00232 __INLINE bool td_sta_has_traffic(uint8_t sta_idx) 00233 { 00234 return ((td_sta_env[sta_idx].status & (CO_BIT(TD_STATUS_TX) | CO_BIT(TD_STATUS_RX))) != 0); 00235 } 00236 #endif //(NX_TD_STA) 00237 00239 00240 #endif // _TD_H_
1.6.1