1 CCA
CCA(空間信道評估)在CSMA/CA中比較非常重要,事關整機吞吐量,所以對其實現進行簡單分析。CCA好像應該有2種:CCA-CS,是屬於PLCP層的,捕獲到能量且能量值高於-82dB后,確定空間忙;CCA-ED,屬於協議層,捕獲到-62dB信號后,需要判定空間忙,並等待。
修改CCA等級,可以讓它對“弱信號”失聰,從而可以在干擾環境中提高吞吐量。
2 具體實現
ar9300_update_cca_threshold(struct ath_hal *ah, int16_t nfarray[NUM_NF_READINGS], u_int8_t rxchainmask)
nf=ah->nf_2GHz.max OR ah->nf_5GHz.max 頻段噪底
nf_max_primary = nf_max_extension = nf; 主信道噪底=輔信道噪低=頻段噪底
chainmask = rxchainmask & ahpriv->ah_caps.hal_rx_chain_mask; 天線數
for (chan = 0; chan < 2 /*ctl,ext*/; chan++) 基於nfarry[]獲得最高nf,利用nf更新 nf_max_primary 和nf_max_extension
nf_nominal = -101(HT20) OR -98(HT40) 標稱噪低(極限)
if (nf_max_primary < nf_nominal)
cca_detection_margin_pri = ahpriv->ah_config.ath_hal_cca_detection_margin + (nf_nominal - nf_max_primary);
主信道cca檢測余量值=配置檢測余量+極限噪底-當前主信道噪底
else
cca_detection_margin_pri = ahpriv->ah_config.ath_hal_cca_detection_margin;
主信道cca檢測余量值=配置檢測余量 (一般都是這里)
if (nf_max_extension < nf_nominal)
cca_detection_margin_ext = ahpriv->ah_config.ath_hal_cca_detection_margin + (nf_nominal - nf_max_extension);
輔信道cca檢測余量值=配置檢測余量+極限噪底-當前輔信道噪底
else
cca_detection_margin_ext = ahpriv->ah_config.ath_hal_cca_detection_margin;
輔信道cca檢測余量值=配置檢測余量 (一般都是這里)
derived_max_cca = (ahpriv->ah_config.ath_hal_cca_detection_level - ahpriv->ah_config.ath_hal_cca_detection_margin - (-130);
計算出的最大cca=配置的檢測等級值 – 配置的檢測余量 - (-130)
max_cca_cap = derived_max_cca < 90 ? derived_max_cca : 90;
最大cca門限=(計算出的最大cca值 與90之間的小者)
cca_threshold_primary = (ahpriv->ah_config.ath_hal_cca_detection_level - cca_detection_margin_pri - nf_max_primary);
主信道CCA門限=配置的CCA檢測余量值-計算出的主信道檢測余量值-當前主信道噪低
cca_threshold_primary = cca_threshold_primary < max_cca_cap ? (cca_threshold_primary > 0 ? cca_threshold_primary : 0) : max_cca_cap;
主信道CCA門限 =(主信道CCA門限 與最大cca門限間的小者)
主信道CCA門限 =(主信道CCA門限 與0 間的大者)
cca_threshold_extension = (ahpriv->ah_config.ath_hal_cca_detection_level - cca_detection_margin_ext - nf_max_extension);
輔信道CCA門限=配置的CCA檢測余量值-計算出的輔信道檢測余量值-當前輔信道噪低
cca_threshold_extension = cca_threshold_extension < max_cca_cap ? (cca_threshold_extension > 0 ? cca_threshold_extension : 0) : max_cca_cap;
輔信道CCA門限 =(輔信道CCA門限 與最大cca門限間的小者)
輔信道CCA門限 =(輔信道CCA門限 與0 間的大者)
更新寄存器
AR_PHY_CCA_0.AR_PHY_CCA_THRESH62= cca_threshold_primary
主信道CCA值寫入BB_cca_b0的0x0007F000位。這個寄存器應該是同時支持CCA_CS和CCA_ED的,這里所寫入的也許就是CCA_ED,因為它命名為THRESH62;如果是CS,則為THRESH80才吻合;同樣,該寄存器的0x1FF00000位好像不可改寫,也不會隨THRESH62值跳變,也許就是PLCP中的CCA_CS值,即真實的載波能量值。
AR_PHY_EXTCHN_PWRTHR1.AR_PHY_EXT_CCA0_THRESH62=cca_threshold_extension
輔信道CCA值寫入BB_ext_chan_pwr_thr_1的0x000000FF位
AR_PHY_EXT_CCA0.AR_PHY_EXT_CCA0_THRESH62_MODE=0x0
BB_cca_ctrl_2_b0的0x00040000位置0。模式0/1的具體意思不明白,也許是自動和固定。
3 引申
僅涉及到BB_cca_b0,BB_ext_chan_pwr_thr_1和BB_cca_ctrl_2_b0。因此,在需要強制提高CCA的場景下,僅需求關閉CCA自動調整功能(缺省模式),然后手工修改這3個寄存器即可。
當然,開啟CCA自動調整(CCAThEna ),也可以獲得吞吐量提升,但要預設好適合當前場景的CCADetLevel值即可。
