00001
00013 #ifndef _STA_MGMT_H_
00014 #define _STA_MGMT_H_
00015
00025
00026
00027
00028
00029 #include "rwnx_config.h"
00030
00031
00032 #include "co_list.h"
00033
00034 #include "mac.h"
00035
00036 #include "mm_task.h"
00037
00038 #if (NX_TDLS)
00039
00040 #include "tdls_task.h"
00041
00042 #include "mm_timer.h"
00043 #endif
00044
00045 #if (NX_UMAC_PRESENT)
00046 #include "rxu_cntrl.h"
00047 #include "bam.h"
00048 #endif //(NX_UMAC_PRESENT)
00049
00050
00051
00052
00053
00054
00055 #if (NX_UMAC_PRESENT)
00056
00061
00062 #define STA_MGMT_PROT_HW_MASK (PROT_FRM_EX_RCX_MASK | MCS_INDEX_PROT_TX_RCX_MASK | BW_PROT_TX_RCX_MASK |\
00063 FORMAT_MOD_PROT_TX_RCX_MASK)
00064
00065 #endif //(NX_UMAC_PRESENT)
00066
00068 enum
00069 {
00070 #if NX_UMAC_PRESENT
00072 BROADCAST_STA_IDX_MIN = NX_REMOTE_STA_MAX,
00074 BROADCAST_STA_IDX_MAX = NX_REMOTE_STA_MAX + NX_VIRT_DEV_MAX - 1,
00076 STA_MAX,
00077 #else
00078 STA_MAX = NX_REMOTE_STA_MAX,
00079 #endif
00081 INVALID_STA_IDX = 0xFF
00082 };
00083
00085 #define VIF_TO_BCMC_IDX(idx) (BROADCAST_STA_IDX_MIN + (idx))
00086
00089 #define STA_REF_BSSID_AID ((uint8_t)-1)
00090
00091
00092
00093
00094
00095
00096 #if (NX_UMAC_PRESENT)
00098 enum sta_mgmt_key_type
00099 {
00100 STA_MGMT_KEY_TYPE_PAIRWISE = 0,
00101 STA_MGMT_KEY_TYPE_GROUP,
00102
00103 STA_MGMT_KEY_TYPE_MAX
00104 };
00105
00107 enum sta_mgmt_port_state
00108 {
00110 STA_MGMT_PORT_CLOSED = 0,
00112 STA_MGMT_PORT_CONTROLED,
00114 STA_MGMT_PORT_OPEN
00115 };
00116
00118 enum sta_mgmt_pol_upd
00119 {
00121 STA_MGMT_POL_UPD_RATE,
00123 STA_MGMT_POL_UPD_PROT,
00125 STA_MGMT_POL_UPD_PPDU_TX,
00127 STA_MGMT_POL_UPD_BW,
00129 STA_MGMT_POL_UPD_TX_POWER,
00131 STA_MGMT_POL_TRIAL_RATE,
00133 STA_MGMT_POL_UPD_BSS_COLOR,
00134
00135 STA_MGMT_POL_UPD_MAX
00136 };
00137
00139 enum sta_ps_traffic
00140 {
00142 PS_TRAFFIC_HOST = CO_BIT(0),
00144 PS_TRAFFIC_INT = CO_BIT(1),
00146 PS_TRAFFIC = (PS_TRAFFIC_HOST | PS_TRAFFIC_INT),
00147
00149 UAPSD_TRAFFIC_HOST = CO_BIT(2),
00151 UAPSD_TRAFFIC_INT = CO_BIT(3),
00153 UAPSD_TRAFFIC = (UAPSD_TRAFFIC_HOST | UAPSD_TRAFFIC_INT)
00154 };
00155
00157 enum sta_ps_sp
00158 {
00160 NO_SERVICE_PERIOD = 0,
00162 PS_SERVICE_PERIOD = CO_BIT(0),
00164 UAPSD_SERVICE_PERIOD_INT = CO_BIT(1),
00166 UAPSD_SERVICE_PERIOD_HOST = CO_BIT(2),
00168 UAPSD_SERVICE_PERIOD = (UAPSD_SERVICE_PERIOD_INT | UAPSD_SERVICE_PERIOD_HOST),
00170 ANY_SERVICE_PERIOD_INT = (PS_SERVICE_PERIOD | UAPSD_SERVICE_PERIOD_INT),
00172 BCN_SERVICE_PERIOD = CO_BIT(3),
00173 };
00174
00175 #endif //(NX_UMAC_PRESENT)
00176
00178 enum
00179 {
00181 PORT_CLOSED = 0,
00183 PORT_CONTROLED,
00185 PORT_OPEN
00186 };
00187
00188
00189
00190
00191
00192
00193 #if (NX_UMAC_PRESENT)
00194
00195 struct mm_key_add_req;
00196
00198 struct sta_capa_info
00199 {
00201 struct mac_rateset rate_set;
00203 struct mac_htcapability ht_cap;
00204 #if NX_VHT
00206 struct mac_vhtcapability vht_cap;
00207 #endif
00208 #if NX_HE
00210 struct mac_hecapability he_cap;
00211 #endif
00214 uint32_t capa_flags;
00216 uint8_t phy_bw_max;
00218 uint8_t bw_cur;
00220 uint8_t uapsd_queues;
00222 uint8_t max_sp_len;
00224 uint8_t stbc_nss;
00225 };
00226
00228 struct sta_mgmt_sec_info
00229 {
00231 struct key_info_tag key_info;
00232 #if (RW_MESH_EN)
00234 struct key_info_tag key_mfp_mesh_info[MAC_DEFAULT_MFP_KEY_COUNT - MAC_DEFAULT_KEY_COUNT];
00235 #endif //(RW_MESH_EN)
00237 struct key_info_tag *pairwise_key;
00239 struct key_info_tag **cur_key;
00240
00241 };
00242
00244 struct sta_pol_tbl_cntl
00245 {
00247 struct txl_buffer_control *buf_ctrl;
00249 struct rc_sta_stats *sta_stats;
00259 uint32_t prot_cfg;
00266 uint16_t ppdu_tx_cfg;
00268 uint8_t upd_field;
00269 };
00270
00272 struct sta_mgmt_ba_info
00273 {
00275 uint32_t last_ba_add_time;
00277 uint8_t bam_idx_rx;
00279 uint8_t bam_idx_tx;
00281 int8_t credit_oft;
00283 uint8_t tx_pkt_cnt;
00284 };
00285 #endif //(NX_UMAC_PRESENT)
00286
00287 #if (NX_AMPDU_TX)
00289 struct ba_agmt
00290 {
00292 uint16_t ssn;
00294 uint8_t bufsz;
00295 };
00296 #endif //(NX_AMPDU_TX)
00297
00298 #if (NX_TDLS)
00300 struct tdls_info_tag
00301 {
00303 bool initiator;
00305 bool chsw_allowed;
00307 bool chsw_initiator;
00309 uint8_t dialog_token;
00311 bool traffic_available;
00313 bool chsw_active;
00315 bool ka_tx_req;
00317 uint8_t ka_retries;
00320 bool pti_timer_running;
00322 struct mac_chan_op chsw;
00324 uint8_t chsw_num;
00326 uint8_t chsw_op_class;
00328 uint16_t chsw_time;
00330 uint16_t chsw_timeout;
00332 struct mm_timer_tag pti_timeout_timer;
00334 struct mm_timer_tag keep_alive_timer;
00336 struct mm_timer_tag chsw_time_timer;
00338 struct mm_timer_tag chsw_timeout_timer;
00340 struct mm_timer_tag chsw_req_timer;
00342 struct mm_timer_tag chsw_end_timer;
00343 };
00344 #endif
00345
00347 struct sta_info_tag
00348 {
00350 struct co_list_hdr list_hdr;
00355 uint32_t bcn_int;
00357 uint32_t ampdu_size_max_he;
00359 uint32_t ampdu_size_max_vht;
00361 uint16_t ampdu_size_max_ht;
00363 uint32_t paid_gid;
00365 uint8_t ampdu_spacing_min;
00366 #if (NX_POWERSAVE)
00367
00371 uint16_t drift;
00372 #endif //(NX_POWERSAVE)
00374 uint16_t aid;
00376 uint8_t inst_nbr;
00378 uint8_t staid;
00380 uint8_t ps_state;
00382 bool valid;
00384 struct mac_addr mac_addr;
00386 struct sta_info_tag *linked_sta;
00387 #if (NX_UMAC_PRESENT)
00389 uint8_t ctrl_port_state;
00391 enum sta_ps_traffic traffic_avail;
00393 enum sta_ps_sp ps_service_period;
00395 uint16_t ctrl_port_ethertype;
00397 struct sta_mgmt_sec_info sta_sec_info;
00399 struct sta_capa_info info;
00401 uint16_t seq_nbr[TID_MAX];
00403 struct sta_pol_tbl_cntl pol_tbl;
00404 #endif //(NX_UMAC_PRESENT)
00405
00406 #if (NX_AMPDU_TX)
00408 struct ba_agmt ba_agmts_tx[TID_MAX];
00409 #endif //(NX_AMPDU_TX && !NX_UMAC_PRESENT)
00410
00411 #if (NX_REORD)
00413 struct rxu_cntrl_reord *ba_agmts_rx[TID_MAX];
00414 #endif //(NX_REORD)
00415
00416 #if (NX_UMAC_PRESENT)
00418 struct sta_mgmt_ba_info ba_info[TID_MAX];
00420 uint16_t rx_nqos_last_seqcntl;
00422 uint16_t rx_qos_last_seqcntl[TID_MAX];
00423 #endif //(NX_UMAC_PRESENT)
00424
00425 #if (NX_TX_FRAME)
00427 struct co_list tx_desc_post;
00428 #endif //(NX_TX_FRAME)
00429
00430 #if (RW_MESH_EN)
00432 uint8_t mlink_idx;
00433 #endif //(RW_MESH_EN)
00434
00435 #if (NX_TDLS)
00437 struct tdls_info_tag tdls;
00439 bool is_tdls;
00440 #endif
00441 #if NX_UMAC_PRESENT && NX_MAC_HE
00443 uint32_t bsr;
00444 #endif
00445 };
00446
00448 struct sta_info_env_tag
00449 {
00451 struct co_list free_sta_list;
00452
00453 #if (RW_MESH_EN && !NX_UMAC_PRESENT)
00455 uint8_t mesh_link_idx[RW_MESH_LINK_NB];
00457 uint8_t nb_mesh_sta;
00458 #endif //(RW_MESH_EN && !NX_UMAC_PRESENT)
00459 };
00460
00461
00462
00463
00464
00466 extern struct sta_info_env_tag sta_info_env;
00467
00469 extern struct sta_info_tag sta_info_tab[STA_MAX];
00470
00479 #define STA_CAPA(sta, type) (((sta)->info.capa_flags & STA_##type##_CAPA) != 0)
00480
00488 #define STA_CAPA_SET(sta, type) ((sta)->info.capa_flags |= STA_##type##_CAPA)
00489
00497 #define STA_CAPA_CLR(sta, type) ((sta)->info.capa_flags &= ~STA_##type##_CAPA)
00498
00499
00500
00501
00502
00503
00504 #if (NX_UMAC_PRESENT)
00505
00514 __INLINE uint8_t sta_mgmt_get_port_state(uint8_t sta_idx)
00515 {
00516 return (sta_info_tab[sta_idx].ctrl_port_state);
00517 }
00518
00528 __INLINE uint16_t sta_mgmt_get_port_ethertype(uint8_t sta_idx)
00529 {
00530 return (sta_info_tab[sta_idx].ctrl_port_ethertype);
00531 }
00532
00533 #endif //(NX_UMAC_PRESENT)
00534
00540 void sta_mgmt_init(void);
00541
00553 uint8_t sta_mgmt_register(struct mm_sta_add_req const *param,
00554 uint8_t *sta_idx);
00555
00563 void sta_mgmt_unregister(uint8_t sta_idx);
00564
00565 #if (NX_UMAC_PRESENT)
00566
00574 void sta_mgmt_add_key(struct mm_key_add_req const *param, uint8_t hw_key_idx);
00575
00583 void sta_mgmt_del_key(struct sta_info_tag *sta);
00584
00595 __INLINE uint8_t sta_mgmt_get_tx_bam_idx(uint8_t sta_idx, uint8_t tid)
00596 {
00597 return (sta_info_tab[sta_idx].ba_info[tid].bam_idx_tx);
00598 }
00599
00610 __INLINE uint8_t sta_mgmt_get_rx_bam_idx(uint8_t sta_idx, uint8_t tid)
00611 {
00612 return (sta_info_tab[sta_idx].ba_info[tid].bam_idx_rx);
00613 }
00614
00625 __INLINE uint8_t sta_mgmt_ba_tx_cnt_get(uint8_t sta_idx, uint8_t tid)
00626 {
00627 return sta_info_tab[sta_idx].ba_info[tid].tx_pkt_cnt;
00628 }
00629
00639 __INLINE void sta_mgmt_ba_tx_cnt_inc(uint8_t sta_idx, uint8_t tid)
00640 {
00641 sta_info_tab[sta_idx].ba_info[tid].tx_pkt_cnt++;
00642 }
00643
00653 __INLINE void sta_mgmt_ba_tx_cnt_dec(uint8_t sta_idx, uint8_t tid)
00654 {
00655 sta_info_tab[sta_idx].ba_info[tid].tx_pkt_cnt--;
00656 }
00657
00668 __INLINE uint32_t sta_mgmt_get_add_ba_time(uint8_t sta_idx, uint8_t tid)
00669 {
00670 return (sta_info_tab[sta_idx].ba_info[tid].last_ba_add_time);
00671 }
00672
00682 __INLINE void sta_mgmt_set_add_ba_time(uint8_t sta_idx, uint8_t tid, uint32_t time)
00683 {
00684 sta_info_tab[sta_idx].ba_info[tid].last_ba_add_time = time;
00685 }
00686
00697 __INLINE uint16_t sta_mgmt_get_tx_ssn_and_inc(uint8_t sta_idx, uint8_t tid)
00698 {
00699 uint16_t sn = sta_info_tab[sta_idx].seq_nbr[tid]++;
00700
00701 sta_info_tab[sta_idx].seq_nbr[tid] &= 0xFFF;
00702
00703 return sn;
00704 }
00705
00716 __INLINE uint16_t sta_mgmt_get_tx_ssn(uint8_t sta_idx, uint8_t tid)
00717 {
00718 return sta_info_tab[sta_idx].seq_nbr[tid];
00719 }
00720
00730 __INLINE bool sta_mgmt_is_in_ps(uint8_t sta_idx)
00731 {
00732 return (sta_info_tab[sta_idx].ps_state != 0);
00733 }
00734 #endif //(NX_UMAC_PRESENT)
00735
00746 __INLINE bool sta_mgmt_is_valid(uint8_t sta_idx)
00747 {
00748 return (sta_info_tab[sta_idx].valid);
00749 }
00750
00751 #if (RW_BFMER_EN || NX_UMAC_PRESENT)
00752
00761 __INLINE struct mac_addr *sta_mgmt_get_peer_addr(uint8_t sta_idx)
00762 {
00763 return (&sta_info_tab[sta_idx].mac_addr);
00764 }
00765
00775 __INLINE uint8_t sta_mgmt_get_vif_idx(uint8_t sta_idx)
00776 {
00777 return (sta_info_tab[sta_idx].inst_nbr);
00778 }
00779 #endif //(RW_BFMER_EN || NX_UMAC_PRESENT)
00780
00781 #if (NX_AMPDU_TX || NX_UMAC_PRESENT)
00782
00791 __INLINE void sta_mgmt_set_tx_ssn(uint8_t sta_idx, uint8_t tid, uint16_t ssn)
00792 {
00793 #if (NX_UMAC_PRESENT)
00794 uint8_t bam_idx = sta_info_tab[sta_idx].ba_info[tid].bam_idx_tx;
00795
00796 bam_env[bam_idx].ssn = ssn;
00797 #elif (NX_AMPDU_TX)
00798 sta_info_tab[sta_idx].ba_agmts_tx[tid].ssn = ssn;
00799 #endif //(NX_UMAC_PRESENT)
00800 }
00801
00802 #if (NX_AMPDU_TX)
00803
00813 __INLINE uint8_t sta_mgmt_get_tx_buff_size(uint8_t sta_idx, uint8_t tid)
00814 {
00815 return (sta_info_tab[sta_idx].ba_agmts_tx[tid].bufsz);
00816 }
00817
00827 __INLINE void sta_mgmt_set_tx_buff_size(uint8_t sta_idx, uint8_t tid, uint8_t buff_size)
00828 {
00829 sta_info_tab[sta_idx].ba_agmts_tx[tid].bufsz = buff_size;
00830 }
00831 #endif //(NX_AMPDU_TX)
00832 #endif //(NX_AMPDU_TX || NX_UMAC_PRESENT)
00833
00834 #if (NX_TX_FRAME)
00835 struct vif_info_tag;
00836
00847 int sta_mgmt_send_postponed_frame(struct vif_info_tag *vif, struct sta_info_tag *sta,
00848 int limit);
00849 #endif //(NX_TX_FRAME)
00850
00852
00853 #endif // _STA_MGMT_H_