00001
00013 #ifndef _BFR_H_
00014 #define _BFR_H_
00015
00025
00026
00027
00028
00029
00030
00031 #include "rwnx_config.h"
00032
00033 #if (RW_BFMER_EN)
00034
00035
00036 #include "co_list.h"
00037
00038 #include "mac_frame.h"
00039
00040 #include "dma.h"
00041
00042 #include "tx_swdesc.h"
00043
00044 #include "vif_mgmt.h"
00045
00046
00047
00048
00049
00050
00058 #define BFR_MEM_REP_NB_MAX (6)
00060 #define BFR_MEM_BASE_ADDR (0x60C05000)
00061
00063 #define BFM_MEM_PTR_SIZE (BFR_MEM_REP_NB_MAX * 2)
00065 #define BFR_MEM_START_ADDR (BFM_MEM_PTR_SIZE)
00067 #define BFR_MEM_NODE_NB (BFR_MEM_REP_NB_MAX)
00068
00076 #define BFR_NDPA_SU_LEN (MAC_LONG_CTRLFRAME_LEN + 3)
00078 #define BFR_NDPA_STA_INFO_LEN (2)
00080 #define BFR_NDPA_TOKEN_MAX (0x3F)
00082 #define BFR_NPDA_TOKEN_POS (2)
00084 #define BFR_NDPA_TOKEN_MASK (BFR_NDPA_TOKEN_MAX << BFR_NPDA_TOKEN_POS)
00086 #define BFR_NPDA_AID12_POS (0)
00088 #define BFR_NDPA_AID12_MASK (0xFFF)
00090 #define BFR_NPDA_FBACK_POS (12)
00092 #define BFR_NDPA_FBACK_MASK (0x1000)
00094 #define BFR_NPDA_NC_IDX_POS (13)
00096 #define BFR_NDPA_NC_IDX_MASK (0xFE00)
00097
00100 #define BFR_NDPA_DIALOG_TOKEN_OFFSET (16)
00102 #define BFR_NDPA_STA_INFO_OFFSET (17)
00104 #define BFR_NDPA_STA_INFO_LENGTH (2)
00105
00113 #define BFR_BRP_LEN (MAC_LONG_CTRLFRAME_LEN + 1)
00114
00117 #define BFR_BRP_RETX_BITMAP_OFFSET (16)
00118
00122
00123 #define BFR_MIMO_CTRL_NC_OFFSET (0)
00125 #define BFR_MIMO_CTRL_NR_OFFSET (3)
00127 #define BFR_MIMO_CTRL_CHAN_WIDTH_OFFSET (6)
00129 #define BFR_MIMO_CTRL_GROUPING_OFFSET (8)
00131 #define BFR_MIMO_CTRL_CODEBOOK_OFFSET (10)
00133 #define BFR_MIMO_CTRL_FEEDBACK_OFFSET (11)
00135 #define BFR_MIMO_CTRL_REM_SEGM_OFFSET (12)
00137 #define BFR_MIMO_CTRL_FIRST_SEGM_OFFSET (15)
00139 #define BFR_MIMO_CTRL_RESERVED_OFFSET (16)
00141 #define BFR_MIMO_CTRL_TOKEN_OFFSET (18)
00142
00144 #define BFR_MIMO_CTRL_NC_MASK (0x7)
00146 #define BFR_MIMO_CTRL_NR_MASK (0x7)
00148 #define BFR_MIMO_CTRL_CHAN_WIDTH_MASK (0x3)
00150 #define BFR_MIMO_CTRL_GROUPING_MASK (0x3)
00152 #define BFR_MIMO_CTRL_CODEBOOK_MASK (0x1)
00154 #define BFR_MIMO_CTRL_FEEDBACK_MASK (0x1)
00156 #define BFR_MIMO_CTRL_REM_SEGM_MASK (0x7)
00158 #define BFR_MIMO_CTRL_FIRST_SEGM_MASK (0x1)
00160 #define BFR_MIMO_CTRL_TOKEN_MASK (0x3F)
00161
00165
00166 #define BFR_CALIB_TMR_DFLT_DUR (50000)
00168 #define BFR_CALIB_MAX_DELAY (500000)
00170 #define BFR_INVALID_SMM_INDEX (0xFF)
00171
00174 #define BFR_VHT_BFR_CATEGORY_OFFSET (24)
00176 #define BFR_VHT_BFR_VHT_ACTION_OFFSET (25)
00178 #define BFR_VHT_BFR_VHT_MIMO_CTRL_OFFSET (26)
00180 #define BFR_VHT_REPORT_OFFSET (29)
00182 #define BFR_INVALID_NC (0xFF)
00184
00185
00186
00187
00188
00189
00190
00192 enum bfr_rx_status
00193 {
00195 BFR_RX_STATUS_NOT_VALID = 0,
00197 BFR_RX_STATUS_VALID,
00199 BFR_RX_STATUS_ERROR,
00200 };
00201
00203 enum bfr_fback_type_val
00204 {
00206 BFR_SU_TYPE = 0,
00208 BFR_MU_TYPE,
00209 };
00210
00212 enum bfr_status
00213 {
00215 BFR_STATUS_IDLE = 0,
00217 BFR_STATUS_SU_CALIB,
00219 BFR_STATUS_MU_CALIB,
00220 };
00221
00223 enum bfr_sta_info_status
00224 {
00226 BFR_STA_MU_CAPABLE = 0,
00228 BFR_STA_HAS_VALID_REPORT,
00230 BFR_STA_DOWNLOAD,
00232 BFR_STA_CALIBRATE,
00234 BFR_STA_REPORT_UPDATED,
00235 };
00236
00237
00238
00239
00240
00241
00243 struct bfr_mem_node
00244 {
00246 struct co_list_hdr hdr;
00248 uint16_t start_addr;
00250 uint16_t length;
00252 uint8_t idx;
00254 uint8_t nb_frames;
00256 uint8_t smm_index;
00258 uint8_t sta_idx;
00259 };
00260
00262 struct bfr_env_tag
00263 {
00265 struct co_list free_nodes;
00267 struct co_list nodes;
00269 struct co_list bfee_sta_list;
00271 struct co_list calib_sched;
00273 struct mm_timer_tag calib_tmr;
00275 uint32_t calib_tmr_dur;
00277 uint16_t bfr_mem_eaddr;
00279 uint8_t nb_reports;
00281 uint8_t status;
00283 uint8_t token;
00285 uint8_t bfer_nss;
00287 uint8_t nb_used_nodes;
00289 uint8_t calib_bw;
00291 bool bfr_enabled;
00292 };
00293
00295 struct bfr_info_sta
00296 {
00298 struct co_list_hdr hdr;
00300 struct bfr_mem_node *node;
00302 uint32_t last_calib_time;
00304 uint32_t host_report_addr[2];
00306 uint16_t host_report_len[2];
00308 uint16_t host_max_report_len;
00310 uint16_t sta_info;
00312 uint8_t last_token;
00314 uint8_t status;
00316 uint8_t nb_segments;
00318 uint8_t sta_idx;
00320 uint8_t vif_idx;
00322 uint8_t bfee_nss;
00324 uint8_t last_rx_nc;
00326 uint8_t host_report_idx;
00327 };
00328
00329
00330
00331
00332
00333
00335 extern struct bfr_env_tag bfr_env;
00336
00338 extern struct bfr_info_sta bfr_sta_infos[NX_REMOTE_STA_MAX];
00339
00340
00341
00342
00343
00344
00345
00352 __INLINE bool bfr_is_enabled(void)
00353 {
00354 return (bfr_env.bfr_enabled);
00355 }
00356
00362 __INLINE bool bfr_is_calibrated(uint8_t sta_idx)
00363 {
00364
00365 struct bfr_info_sta *bfr = &bfr_sta_infos[sta_idx];
00366
00367
00368 return ((bfr->status & CO_BIT(BFR_STA_HAS_VALID_REPORT)) != 0);
00369 }
00370
00382 __INLINE bool bfr_is_bfmed_sglt_allowed(struct txdesc *txdesc)
00383 {
00384 #if NX_UMAC_PRESENT
00385
00386 if (txdesc->host.flags & TXU_CNTRL_RC_TRIAL)
00387 {
00388 return ((txdesc->umac.buf_control->tx_flags & TX_SWDESC_UMAC_TRIAL_BEAMFORM_BIT) != 0);
00389 }
00390 else
00391 {
00392 return ((txdesc->umac.buf_control->tx_flags & TX_SWDESC_UMAC_BEAMFORM_BIT) != 0);
00393 }
00394 #else
00395 return ((txdesc->umac.tx_flags & TX_SWDESC_UMAC_BEAMFORM_BIT) != 0);
00396 #endif
00397 }
00398
00399
00400
00401
00402
00403
00409 void bfr_init(void);
00410
00426 void bfr_add_sta_ind(uint8_t sta_idx, bool mu_capable, uint16_t aid, uint32_t host_addr,
00427 uint16_t host_length, uint8_t nss);
00428
00436 void bfr_del_sta_ind(uint8_t sta_idx);
00437
00462 uint8_t bfr_rx_frame_ind(uint8_t sta_idx, struct rxdesc *rxdesc, uint8_t *frame);
00463
00479 bool bfr_tx_frame_ind(struct txdesc *txdesc, struct dma_desc *dma_desc_bfr);
00480
00491 void bfr_tx_cfm(struct txdesc *txdesc);
00492
00493 #if (NX_UMAC_PRESENT)
00494
00502 uint8_t bfr_get_last_nc(uint8_t sta_idx);
00503 #endif //(NX_UMAC_PRESENT)
00504
00505 #if RW_MUMIMO_TX_EN
00506
00513 void bfr_group_update_req(struct mm_mu_group_update_req const *param);
00514 #endif //RW_MUMIMO_TX_EN
00515
00516 #endif //(RW_BFMER_EN)
00517
00519
00520 #endif // _BFR_H_