- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# /space/home/slher/rel/Beken/v6_4_5/macsw/ip/lmac/src/mm/mm.h

Go to the documentation of this file.

    00001
    00012 #ifndef _MM_H_
    00013 #define _MM_H_
    00014
    00032 /*
    00033  * INCLUDE FILES
    00034  ****************************************************************************************
    00035  */
    00036 // standard includes
    00037 #include "co_int.h"
    00038 #include "co_bool.h"
    00039
    00040 #include "co_utils.h"
    00041 #include "ke_timer.h"
    00042 #include "mm_timer.h"
    00043 #include "mm_task.h"
    00044 #include "hal_desc.h"
    00045 #include "hal_machw.h"
    00046 #include "hal_dma.h"
    00047 #include "sta_mgmt.h"
    00048
    00049 /*
    00050  * DEFINES
    00051  ****************************************************************************************
    00052  */
    00054 #define MM_DEFAULT_TX_POWER 15
    00055
    00057 #define MM_DEFAULT_MAX_AMPDU_DURATION 150
    00058
    00060 #define MM_AP_CLK_ACCURACY 20
    00061
    00063 #define MM_RX_FILTER_MONITOR  (0xFFFFFFFF & ~(NXMAC_ACCEPT_ERROR_FRAMES_BIT | NXMAC_EXC_UNENCRYPTED_BIT |                      \
    00064                                               NXMAC_EN_DUPLICATE_DETECTION_BIT))
    00065
    00067 #if NX_UMAC_PRESENT
    00068 #define MM_RX_FILTER_ACTIVE (NXMAC_ACCEPT_MULTICAST_BIT | NXMAC_ACCEPT_BROADCAST_BIT | \
    00069                              NXMAC_ACCEPT_MY_UNICAST_BIT | NXMAC_ACCEPT_PROBE_REQ_BIT | \
    00070                              NXMAC_ACCEPT_BEACON_BIT | NXMAC_ACCEPT_OTHER_MGMT_FRAMES_BIT | \
    00071                              NXMAC_ACCEPT_BAR_BIT | NXMAC_ACCEPT_BA_BIT |                \
    00072                              NXMAC_ACCEPT_DATA_BIT | NXMAC_ACCEPT_Q_DATA_BIT |           \
    00073                              NXMAC_ACCEPT_QO_S_NULL_BIT | NXMAC_ACCEPT_OTHER_DATA_FRAMES_BIT)
    00074 #else
    00075 #define MM_RX_FILTER_ACTIVE (NXMAC_ACCEPT_MULTICAST_BIT | NXMAC_ACCEPT_BROADCAST_BIT | \
    00076                              NXMAC_ACCEPT_MY_UNICAST_BIT | NXMAC_ACCEPT_PROBE_REQ_BIT | \
    00077                              NXMAC_ACCEPT_BEACON_BIT | NXMAC_ACCEPT_OTHER_MGMT_FRAMES_BIT | \
    00078                              NXMAC_ACCEPT_BAR_BIT | NXMAC_ACCEPT_BA_BIT |                \
    00079                              NXMAC_ACCEPT_DATA_BIT | NXMAC_ACCEPT_Q_DATA_BIT |           \
    00080                              NXMAC_ACCEPT_QO_S_NULL_BIT | NXMAC_ACCEPT_OTHER_DATA_FRAMES_BIT | \
    00081                              NXMAC_ACCEPT_OTHER_BSSID_BIT)
    00082 #endif
    00083
    00084
    00086 #if NX_KEY_RAM_CONFIG
    00087 #define MM_SEC_MAX_KEY_NBR      (nxmac_sta_key_max_index_getf() + 1)
    00088 #else
    00089 #define MM_SEC_MAX_KEY_NBR      64
    00090 #endif
    00091
    00093 #if NX_KEY_RAM_CONFIG
    00094 #define MM_SEC_VLAN_COUNT (NX_VIRT_DEV_MAX + RW_MESH_LINK_NB)
    00095 #else
    00096 #define MM_SEC_VLAN_COUNT 6
    00097 #endif
    00098
    00100 #define MM_SEC_DEFAULT_KEY_COUNT (MAC_DEFAULT_KEY_COUNT * MM_SEC_VLAN_COUNT)
    00101 #if (RW_MESH_EN)
    00103 #define MM_SEC_DEFAULT_VIF_KEY_COUNT    (MAC_DEFAULT_KEY_COUNT * NX_VIRT_DEV_MAX)
    00104 #endif //(RW_MESH_EN)
    00105
    00107 #define MM_SEC_CTYPE_NULL        0
    00109 #define MM_SEC_CTYPE_WEP         1
    00111 #define MM_SEC_CTYPE_TKIP        2
    00113 #define MM_SEC_CTYPE_CCMP        3
    00115 #define MM_SEC_CTYPE_WPI_SMS4    4
    00116
    00118 #define MM_VIF_TO_KEY(key_idx, vif_idx)     ((key_idx) + ((vif_idx) * MAC_DEFAULT_KEY_COUNT))
    00120 #define MM_STA_TO_KEY(sta_idx)              ((sta_idx) + MM_SEC_DEFAULT_KEY_COUNT)
    00121 #if (RW_MESH_EN)
    00123 #define MM_MLINK_TO_KEY(key_idx, mlink_idx) (((NX_VIRT_DEV_MAX + mlink_idx) * MAC_DEFAULT_KEY_COUNT) + key_idx)
    00124 #endif //(RW_MESH_EN)
    00125
    00127 #define MM_KEY_TO_STA(hw_key_idx)    ((hw_key_idx) - MM_SEC_DEFAULT_KEY_COUNT)
    00129 #define MM_KEY_TO_VIF(hw_key_idx)    (((hw_key_idx) & ~(MAC_DEFAULT_KEY_COUNT - 1)) / MAC_DEFAULT_KEY_COUNT)
    00131 #define MM_KEY_TO_KEYID(hw_key_idx)  ((hw_key_idx) & (MAC_DEFAULT_KEY_COUNT - 1))
    00132 #if (RW_MESH_EN)
    00134 #define MM_KEY_TO_MLINK(hw_key_idx) (((hw_key_idx & ~(MAC_DEFAULT_KEY_COUNT - 1)) / MAC_DEFAULT_KEY_COUNT) - NX_VIRT_DEV_MAX)
    00135 #endif //(RW_MESH_EN)
    00136
    00137 #if NX_MFP
    00139 #define MM_SEC_MFP_KEY_COUNT (MAC_DEFAULT_MFP_KEY_COUNT - MAC_DEFAULT_KEY_COUNT)
    00141 #define MM_SEC_MAX_MFP_KEY_NBR MM_SEC_MAX_KEY_NBR + (MM_SEC_MFP_KEY_COUNT * MM_SEC_VLAN_COUNT)
    00142
    00144 #define MM_VIF_TO_MFP_KEY(key_idx, vif_idx) ((((key_idx) - MAC_DEFAULT_KEY_COUNT) + ((vif_idx) * MM_SEC_MFP_KEY_COUNT)) + MM_SEC_MAX_KEY_NBR)
    00146 #define MM_MFP_KEY_TO_VIF(hw_key_idx) (((hw_key_idx) - MM_SEC_MAX_KEY_NBR) / MM_SEC_MFP_KEY_COUNT)
    00148 #define MM_MFP_KEY_TO_KEYID(hw_key_idx) ((((hw_key_idx) - MM_SEC_MAX_KEY_NBR) & (MM_SEC_MFP_KEY_COUNT - 1)) + MAC_DEFAULT_KEY_COUNT)
    00149
    00150 #if (RW_UMESH_EN)
    00152 #define MM_SEC_MAX_MESH_MFP_KEY_NBR (MM_SEC_MAX_MFP_KEY_NBR + (MM_SEC_MFP_KEY_COUNT * NX_REMOTE_STA_MAX))
    00153
    00155 #define MM_STA_TO_MESH_MFP_KEY(key_idx, sta_idx) (MM_SEC_MAX_MFP_KEY_NBR + (MM_SEC_MFP_KEY_COUNT * sta_idx) + key_idx)
    00157 #define MM_MESH_MFP_KEY_TO_KEYID(hw_key_idx) ((hw_key_idx - MM_SEC_MAX_MFP_KEY_NBR) & (MM_SEC_MFP_KEY_COUNT - 1))
    00158 #endif //(RW_UMESH_EN)
    00159 #endif //(NX_MFP)
    00160
    00161 #if (NX_CHNL_CTXT || NX_P2P_GO || RW_UMESH_EN)
    00163 #define MM_PRE_AP_TBTT_DELAY_US    (1000)
    00164 #else
    00165 #define MM_PRE_AP_TBTT_DELAY_US    (0)
    00166 #endif //(NX_P2P_GO || RW_UMESH_EN)
    00167
    00168 #if (NX_ANT_DIV)
    00170 #define ANT_DIV_RSSI_THD                (20)
    00172 #define ANT_DIV_RSSI_GOLDEN_MIN         (-55)
    00174 #define ANT_DIV_RSSI_GOLDEN_MAX         (-20)
    00176 #define ANT_DIV_RSSI_STEP_CHANGE        (5)
    00178 #define ANT_DIV_BEACON_LOSS_THD         (3)
    00180 #define ANT_DIV_RSSI_RESET              (-128)
    00182 #define ANT_DIV_UPDATE_CNT_THD          (100)
    00183 #endif //(NX_ANT_DIV)
    00184
    00185 /*
    00186  * ENUMERATIONS
    00187  ****************************************************************************************
    00188  */
    00189
    00191 enum
    00192 {
    00194     BA_AGMT_TX,
    00196     BA_AGMT_RX,
    00197 };
    00198
    00199
    00201 enum
    00202 {
    00204     BA_AGMT_ESTABLISHED,
    00206     BA_AGMT_ALREADY_EXISTS,
    00208     BA_AGMT_DELETED,
    00210     BA_AGMT_DOESNT_EXIST,
    00212     BA_AGMT_NO_MORE_BA_AGMT,
    00214     BA_AGMT_NOT_SUPPORTED
    00215 };
    00216
    00218 enum mm_features
    00219 {
    00221     MM_FEAT_BCN_BIT         = 0,
    00223     MM_FEAT_AUTOBCN_BIT,
    00225     MM_FEAT_HWSCAN_BIT,
    00227     MM_FEAT_CMON_BIT,
    00229     MM_FEAT_MROLE_BIT,
    00231     MM_FEAT_RADAR_BIT,
    00233     MM_FEAT_PS_BIT,
    00235     MM_FEAT_UAPSD_BIT,
    00237     MM_FEAT_DPSM_BIT,
    00239     MM_FEAT_AMPDU_BIT,
    00241     MM_FEAT_AMSDU_BIT,
    00243     MM_FEAT_CHNL_CTXT_BIT,
    00245     MM_FEAT_REORD_BIT,
    00247     MM_FEAT_P2P_BIT,
    00249     MM_FEAT_P2P_GO_BIT,
    00251     MM_FEAT_UMAC_BIT,
    00253     MM_FEAT_VHT_BIT,
    00255     MM_FEAT_BFMEE_BIT,
    00257     MM_FEAT_BFMER_BIT,
    00259     MM_FEAT_WAPI_BIT,
    00261     MM_FEAT_MFP_BIT,
    00263     MM_FEAT_MU_MIMO_RX_BIT,
    00265     MM_FEAT_MU_MIMO_TX_BIT,
    00267     MM_FEAT_MESH_BIT,
    00269     MM_FEAT_TDLS_BIT,
    00271     MM_FEAT_ANT_DIV_BIT,
    00273     MM_FEAT_UF_BIT,
    00275     MM_AMSDU_MAX_SIZE_BIT0,
    00277     MM_AMSDU_MAX_SIZE_BIT1,
    00279     MM_FEAT_MON_DATA_BIT,
    00281     MM_FEAT_HE_BIT,
    00282 };
    00283
    00284
    00285 // Forward declaration
    00286 struct vif_info_tag;
    00287
    00288 #if (NX_ANT_DIV)
    00290 struct antenna_diversity
    00291 {
    00293     bool enable;
    00295     bool sw_enable;
    00297     int8_t rssi[2];
    00299     int8_t init_rssi[2];
    00301     uint8_t cur_ant;
    00303     bool init_rssi_upd_req;
    00305     uint32_t update_cnt;
    00307     uint8_t nvif_active;
    00308 };
    00309 #endif //(NX_ANT_DIV)
    00310
    00312 struct mm_env_tag
    00313 {
    00315     uint32_t rx_filter_umac;
    00317     uint32_t rx_filter_lmac_enable;
    00319     uint16_t ampdu_max_dur[NX_TXQ_CNT];
    00320     #if NX_BEACONING && ((NX_POWERSAVE || NX_CONNECTION_MONITOR || NX_UMAC_PRESENT) && !NX_MULTI_ROLE)
    00322     bool beaconing;
    00323     #endif
    00325     uint8_t prev_mm_state;
    00327     uint8_t prev_hw_state;
    00328     #if NX_CHNL_CTXT
    00330     uint32_t basic_rates[PHY_BAND_MAX];
    00331     #endif
    00332     #if NX_UAPSD
    00334     uint32_t uapsd_timeout;
    00335     #endif
    00336     #if NX_POWERSAVE
    00338     uint16_t lp_clk_accuracy;
    00339     #endif
    00341     uint8_t host_idle;
    00342     #if (NX_ANT_DIV)
    00344     struct antenna_diversity ant_div;
    00345     #endif //(NX_ANT_DIV)
    00346     #if NX_BEACONING
    00348     struct mm_timer_tag tbtt_move_tmr;
    00350     bool tbtt_move_ongoing;
    00351     #endif
    00352 };
    00353
    00354 /*
    00355  * GLOBAL VARIABLES
    00356  ****************************************************************************************
    00357  */
    00358 extern struct mm_env_tag mm_env;
    00359
    00360 /*
    00361  * FUNCTION PROTOTYPES
    00362  ****************************************************************************************
    00363  */
    00370 __INLINE void mm_rx_filter_set(void)
    00371 {
    00372     // Configure the filtering of the HW
    00373     nxmac_rx_cntrl_set(mm_env.rx_filter_umac | mm_env.rx_filter_lmac_enable);
    00374 }
    00375
    00383 __INLINE void mm_rx_filter_umac_set(uint32_t filter)
    00384 {
    00385     mm_env.rx_filter_umac = filter;
    00386
    00387     // Configure the filtering of the HW
    00388     mm_rx_filter_set();
    00389 }
    00390
    00398 __INLINE void mm_rx_filter_lmac_enable_set(uint32_t filter)
    00399 {
    00400     mm_env.rx_filter_lmac_enable |= filter;
    00401
    00402     // Configure the filtering of the HW
    00403     mm_rx_filter_set();
    00404 }
    00405
    00413 __INLINE void mm_rx_filter_lmac_enable_clear(uint32_t filter)
    00414 {
    00415     mm_env.rx_filter_lmac_enable &= ~filter;
    00416
    00417     // Configure the filtering of the HW
    00418     mm_rx_filter_set();
    00419 }
    00420
    00429 __INLINE void mm_ps_change_ind(uint8_t sta_idx, uint8_t ps_state)
    00430 {
    00431     struct sta_info_tag *sta = &sta_info_tab[sta_idx];
    00432
    00433     #if (NX_P2P)
    00434     if (sta->ps_state != ps_state)
    00435     #endif //(NX_P2P)
    00436     {
    00437         struct mm_ps_change_ind *ind = KE_MSG_ALLOC(MM_PS_CHANGE_IND, TASK_API,
    00438                                                         TASK_MM, mm_ps_change_ind);
    00439
    00440         // Change the local value of the PS state
    00441         sta->ps_state = ps_state;
    00442
    00443         // Fill-in the parameters
    00444         ind->sta_idx = sta_idx;
    00445         ind->ps_state = ps_state;
    00446
    00447         // Send the message
    00448         ke_msg_send(ind);
    00449     }
    00450 }
    00451
    00461 __INLINE void mm_traffic_req_ind(uint8_t sta_idx, uint8_t pkt_cnt, bool uapsd)
    00462 {
    00463     struct mm_traffic_req_ind *ind = KE_MSG_ALLOC(MM_TRAFFIC_REQ_IND, TASK_API,
    00464                                                     TASK_MM, mm_traffic_req_ind);
    00465
    00466     PROF_PS_TRAFFIC_REQ_SET();
    00467
    00468     // Fill-in the parameters
    00469     ind->sta_idx = sta_idx;
    00470     ind->pkt_cnt = pkt_cnt;
    00471     ind->uapsd = uapsd;
    00472
    00473     // Send the message
    00474     ke_msg_send(ind);
    00475
    00476     PROF_PS_TRAFFIC_REQ_CLR();
    00477 }
    00478
    00479 #if (NX_ANT_DIV)
    00480
    00489 __INLINE uint8_t mm_get_golden_range_distance(int8_t rssi)
    00490 {
    00491     uint8_t dist = 0;
    00492     if (rssi < ANT_DIV_RSSI_GOLDEN_MIN)
    00493     {
    00494         dist = ANT_DIV_RSSI_GOLDEN_MIN - rssi;
    00495     }
    00496     else if (rssi > ANT_DIV_RSSI_GOLDEN_MAX)
    00497     {
    00498         dist = rssi - ANT_DIV_RSSI_GOLDEN_MAX;
    00499     }
    00500
    00501     return dist;
    00502 }
    00503 #endif //(NX_ANT_DIV)
    00504
    00511 void mm_init(void);
    00512
    00513
    00521 void mm_reset(void);
    00522
    00528 void mm_active(void);
    00529
    00535 void mm_env_init(void);
    00536
    00537
    00543 void mm_env_max_ampdu_duration_set(void);
    00544
    00545
    00558 uint8_t mm_sec_machwaddr_wr(uint8_t sta_idx, uint8_t inst_nbr);
    00559
    00569 void mm_sec_machwaddr_del(uint8_t sta_idx);
    00570
    00583 uint8_t mm_sec_machwkey_wr(struct mm_key_add_req const *param);
    00584
    00595 void mm_sec_machwkey_del(uint8_t hw_key_idx);
    00596
    00597 #if NX_BEACONING || NX_POWERSAVE || NX_CONNECTION_MONITOR || NX_UMAC_PRESENT
    00598
    00609 void mm_tbtt_evt(int dummy);
    00610 #endif
    00611
    00612 #if NX_CONNECTION_MONITOR || NX_MULTI_ROLE
    00613
    00630 bool mm_check_beacon(struct rx_hd *rhd, struct vif_info_tag *vif,
    00631                      struct sta_info_tag *sta, uint32_t *tim);
    00632 #endif
    00633
    00644 void mm_hw_idle_evt(int dummy);
    00645
    00646 #if NX_MULTI_ROLE
    00647
    00654 void mm_hw_info_set(struct mac_addr const *mac_addr);
    00655
    00661 void mm_hw_ap_info_set(void);
    00662
    00668 void mm_hw_ap_info_reset(void);
    00669
    00684 void mm_tbtt_compute(struct bcn_frame *bcn, uint16_t len, struct rx_hd *rhd,
    00685                      struct vif_info_tag *vif,
    00686                      struct sta_info_tag *sta, uint32_t tim);
    00687 #else
    00688
    00696 void mm_hw_interface_info_set(uint8_t type, struct mac_addr const *mac_addr);
    00697 #endif
    00698
    00707 void mm_sta_tbtt(void *env);
    00708
    00717 void mm_ap_pre_tbtt(void *env);
    00718
    00732 int32_t mm_ap_tbtt_move(int32_t offset);
    00733
    00734 extern struct mm_env_tag mm_env;
    00735
    00736 #if (NX_AMPDU_TX)
    00737
    00745 bool mm_ba_agmt_tx_exists(uint8_t sta_idx, uint8_t tid);
    00746 #endif //(NX_AMPDU_TX)
    00747
    00748 #if (NX_REORD)
    00749
    00757 bool mm_ba_agmt_rx_exists(uint8_t sta_idx, uint8_t tid);
    00758 #endif //(NX_REORD)
    00759
    00765 void mm_force_idle_req(void);
    00766
    00767
    00779 uint8_t mm_sta_add(struct mm_sta_add_req const *param, uint8_t  *sta_idx,
    00780                    uint8_t *hw_sta_idx);
    00781
    00789 void mm_sta_del(uint8_t sta_idx);
    00790
    00796 void mm_back_to_host_idle(void);
    00797
    00805 void mm_no_idle_start(void);
    00806
    00813 void mm_no_idle_stop(void);
    00814
    00815 #if (NX_CONNECTION_MONITOR)
    00816
    00823 void mm_send_connection_loss_ind(struct vif_info_tag *vif);
    00824 #endif //(NX_CONNECTION_MONITOR)
    00825
    00835 void mm_check_rssi(struct vif_info_tag *vif, int8_t rssi);
    00836
    00837 #if NX_UMAC_PRESENT
    00838
    00847 void mm_send_pktloss_ind(struct vif_info_tag *vif, uint8_t sta_idx, uint32_t num_pkts);
    00848
    00858 void mm_send_csa_traffic_ind(uint8_t vif_index, bool enable);
    00859 #endif
    00860
    00861 #if (NX_ANT_DIV)
    00862
    00869 void mm_ant_div_init(bool enable);
    00870
    00877 void mm_ant_div_switch_and_stop(void);
    00878
    00887 void mm_ant_div_restore(bool active);
    00888
    00894 void mm_ant_div_update(void);
    00895
    00902 void mm_ant_div_switch_antenna(void);
    00903
    00912 void mm_ant_div_reset_rssi(uint8_t ant);
    00913
    00921 void mm_ant_div_update_rssi(int8_t *rssi);
    00922
    00944 void mm_ant_div_check(uint8_t beacon_loss_cnt);
    00945 #endif //(NX_ANT_DIV)
    00946
    00948
    00949 #endif // _MM_H_