码迷,mamicode.com
首页 > 其他好文 > 详细

ANI功能分析

时间:2017-09-07 20:25:43      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:unity   越界   listen   mode   rate   set   信道   nat   efault   

1 ANI 

ANI(Adapt Noise Immunity)就是基于CCK错包率,和/或CCK错包率,自动调整抗扰等级,从而提高或降低灵敏度,达到提高整体性能的目标。

2 关键常量

firstep_table    = { -4, -2,  0,  2,  4,  6,  8, 10, 12};  /*FIR滤波级别表*/

cycpwr_thr1_table = { -6, -4, -2,  0,  2,  4,  6,  8 }; /*功率阈值表*/

ofdm_level_table[] = {

/*     SI  FS  WS */

     {  0,  0,  1  }, /* lvl 0 */

     {  1,  1,  1  }, /* lvl 1 */

     {  2,  2,  1  }, /* lvl 2 */

     {  3,  2,  1  }, /* lvl 3  (default) */

     {  4,  3,  1  }, /* lvl 4 */

     {  5,  4,  1  }, /* lvl 5 */

     {  6,  5,  1  }, /* lvl 6 */

     {  7,  6,  1  }, /* lvl 7 */

     {  7,  7,  1  }, /* lvl 8 */

     {  7,  8,  0  }  /* lvl 9 */

};

/*SI Spur-Immunity-level;FS=FIRStep;WS=OFDM weak sigal on */

cck_level_table[] = {

/*     FS  MRC-CCK */

     {  0,  1  },  /* lvl 0 */

     {  1,  1  },  /* lvl 1 */

     {  2,  1  },  /* lvl 2  (default) */

     {  3,  1  },  /* lvl 3 */

     {  4,  0  },  /* lvl 4 */

     {  5,  0  },  /* lvl 5 */

     {  6,  0  },  /* lvl 6 */

     {  7,  0  },  /* lvl 7 (only for high rssi) */

     {  8,  0  }   /* lvl 8 (only for high rssi) */

};

/*FS=First Step; MRC-CCK: Maximal Ratio Combining for CCK*/

3 重要函数

3.1 加载

ar9300_ani_attach(struct ath_hal *ah)

for (i = 0; i < 256; i++) {

        ahp->ah_ani[i].ofdm_trig_high = 1000;

        ahp->ah_ani[i].ofdm_trig_low = 400;

        ahp->ah_ani[i].cck_trig_high = 600;

        ahp->ah_ani[i].cck_trig_low = 300;

        ahp->ah_ani[i].rssi_thr_high = 40;

        ahp->ah_ani[i].rssi_thr_low =7;

        ahp->ah_ani[i].ofdm_noise_immunity_level =3;

        ahp->ah_ani[i].cck_noise_immunity_level =2;

        ahp->ah_ani[i].ofdm_weak_sig_detect_off = 0;

        ahp->ah_ani[i].spur_immunity_level = 3;

        ahp->ah_ani[i].firstep_level = 2;

        ahp->ah_ani[i].mrc_cck_off =0;

        ahp->ah_ani[i].ofdms_turn = true;

        ahp->ah_ani[i].must_restore = false;

}

    OS_REG_WRITE(ah, AR_PHY_ERR_1, 0); 寄存器MAC_PCU_PHY_ERR_CNT_1 归0

    OS_REG_WRITE(ah, AR_PHY_ERR_2, 0); 寄存器MAC_PCU_PHY_ERR_CNT_2归0

    ar9300_enable_mib_counters(ah);

归档ACKFAIL,RTSFAIL,FCSFAIL,RTSOK,BEACONCOUNT计数

FLT_OFDM,FLT_CCK计数归0,启动MAC_PCU_PHY_ERR_CNT_1_MASK对错误OFDM计数,启动MAC_PCU_PHY_ERR_CNT_2_MASK对错误CCK计数

ahp->ah_ani_period =1000

如果ANI使能,则ahp->ah_proc_phy_err |= HAL_PROCESS_ANI;

 3.2 初始化

    ar9300_ani_init_defaults(struct ath_hal *ah, HAL_HT_MACMODE macmode)

    index = ar9300_get_ani_channel_index(ah, chan); 基于信道存放

    ani_state = &ahp->ah_ani[index];

ahp->ah_curani = ani_state;

val = OS_REG_READ(ah, AR_PHY_SFCORR);取BB_sfcorr值,self-coordinate

利用val值,填充

ani_state->ini_def.m1_thresh,

ani_state->ini_def.m2_thresh,和

ani_state->ini_def.m2_count_thr

val = OS_REG_READ(ah, AR_PHY_SFCORR_LOW);取BB_sfcorr_low值,并填充

ani_state->ini_def.m1_thresh_low,

ani_state->ini_def.m2_thresh_low,

ani_state->ini_def.m2_count_thr_low

val = OS_REG_READ(ah, AR_PHY_SFCORR_EXT); 取BB_sfcorr_ext值,填充

ani_state->ini_def.m1_thresh_ext,

ani_state->ini_def.m2_thresh_ext,

ani_state->ini_def.m1_thresh_low_ext,

ani_state->ini_def.m2_thresh_low_ext

ani_state->ini_def.firstep 源自BB_find_signal的0x0003F000

ani_state->ini_def.firstep_low源自BB_find_signal_low的(0x3f << 6)

ani_state->ini_def.cycpwr_thr1 源自BB_timing_control_5的0x000000FE

ani_state->ini_def.cycpwr_thr1_ext源自BB_ext_chan_pwr_thr_2_b0的0x0000FE00

ani_state->spur_immunity_level=3

ani_state->firstep_level=2

ani_state->ofdm_weak_sig_detect_off=0

ani_state->mrc_cck_off=0

ani_state->cycle_count = 0;

 3.3 OFDM抗扰

ar9300_ani_set_odfm_noise_immunity_level(struct ath_hal *ah,

                                   u_int8_t ofdm_noise_immunity_level)
ani_state->rssi =当前值;

ani_state->ofdm_noise_immunity_level = ofdm_noise_immunity_level; 调整值

if (ani_state->spur_immunity_level !=

        ofdm_level_table[ofdm_noise_immunity_level].spur_immunity_level)

调用ar9300_ani_control调整SI等级

 if (ani_state->firstep_level !=

            ofdm_level_table[ofdm_noise_immunity_level].fir_step_level &&

        ofdm_level_table[ofdm_noise_immunity_level].fir_step_level >=

            cck_level_table[ani_state->cck_noise_immunity_level].fir_step_level)

调用ar9300_ani_control调整FIR阶次;FIRStep是OFDM和CCK中的小者

若ani_state->rssi <= ani_state->rssi_thr_high 且ani_state->ofdm_weak_sig_detect_off,则调用ar9300_ani_control开启HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION

若ani_state->ofdm_weak_sig_detect_off =

ofdm_level_table[ofdm_noise_immunity_level].ofdm_weak_signal_on,则基于后者的值,调用ar9300_ani_control开关HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION

 3.4 CCK抗扰

ar9300_ani_set_cck_noise_immunity_level(struct ath_hal *ah,

                                  u_int8_t cck_noise_immunity_level)

更新ani_state->rssi

ani_state->cck_noise_immunity_level = cck_noise_immunity_level;

   level = ani_state->ofdm_noise_immunity_level; OFDM抗扰等级

   if (ani_state->firstep_level !=

            cck_level_table[cck_noise_immunity_level].fir_step_level &&

        cck_level_table[cck_noise_immunity_level].fir_step_level >=

            ofdm_level_table[level].fir_step_level)

                   调用ar9300_ani_control调整FIR 阶次

                   DRAGONFLY和SCORPION型硬件,不调整MRC_CCK;否则,

若ani_state->mrc_cck_off ==

            cck_level_table[cck_noise_immunity_level].mrc_cck_on

          则调用ar9300_ani_control调整mrc_cck开关。

 3.5 ANI控制

ar9300_ani_control(struct ath_hal *ah, HAL_ANI_CMD cmd, int param)

case OFDM_WEAK_SIGNAL_DETECTION

                   基于param为0或1,为BB_sfcorr_low,BB_sfcorr,BB_sfcorr_ext寄存器分别写入关闭检测的值,或由ar9300_ani_init_defaults初始化好的值。

                   BB_self_corr_low的0x00000001基于param值复位或置位。

                   ani_state->ofdm_weak_sig_detect_off =param值取反

case FIRSTEP_LEVEL

                    value =

     firstep_table[param] - firstep_table[2] + ani_state->ini_def.firstep;

                   设置BB_find_signal中0x0003F000位为value

                    value2 =

     firstep_table[param] -firstep_table[2] + ani_state->ini_def.firstep_low;

                   设置BB_find_signal_low中(0x3f << 6)位为value2

                   ani_state->firstep_level = param;

case SI_LEVEL

                    value =

      cycpwr_thr1_table[param] - cycpwr_thr1_table[3] + ani_state->ini_def.cycpwr_thr1;

                   设置BB_ext_chan_pwr_thr_2_b0中0x0000FE00位为value

                   ani_state->spur_immunity_level = param;

          case MRC_CCK

                   若为on,则为低级别抗噪,也是缺省;否则,为高等级抗噪

                   非POSEIDON平台时,BB_mrc_cck_ctrl的bit0,bit1设置为param值。

                   ani_state->mrc_cck_off =param值取反

 3.6 OFDMERR触发器处理

ar9300_ani_ofdm_err_trigger(struct ath_hal *ah)

                   调用ar9300_ani_set_odfm_noise_immunity_level上调

ani_state->ofdm_noise_immunity_level 1个等级

CCKERR触发器处理

ar9300_ani_cck_err_trigger(struct ath_hal *ah)

                   调用ar9300_ani_set_cck_noise_immunity_level 上调

ani_state->cck_noise_immunity_level 1个等级

总之,只要OFDM/CCK错误统计越界,则上调抗噪等级,灵敏度降低。

 3.7 抗噪调低处理

ar9300_ani_lower_immunity(struct ath_hal *ah)

          优先调用ar9300_ani_set_odfm_noise_immunity_level调低ofdm_noise_immunity_level 1个等级

          或者调用ar9300_ani_set_cck_noise_immunity_level 调低cck_noise_immunity_level 1个等级

4 抗噪处理

ar9300_ani_ar_poll(struct ath_hal *ah, const HAL_NODE_STATS *stats,

                HAL_CHANNEL *chan, HAL_ANISTATS *ani_stats)

    ani_state = ahp->ah_curani;

    ahp->ah_stats.ast_nodestats = *stats;

listen_time = ar9300_ani_get_listen_time(ah, ani_stats); 返回一个0(非法)或正值

          ani_state->listen_time += listen_time;

ar9300_update_mib_mac_stats(ah);

ofdm_phy_err_cnt = OFDM错误统计值;

cck_phy_err_cnt = CCK错误统计值

ahp->ah_stats.ast_ani_ofdmerrs和ahp->ah_stats.ast_ani_cckerrs 累加本轮递增值

统计ofdm_phy_err_rate和cck_phy_err_rate 值,均为本listen_time期内的错误比率

若ani_state->listen_time >=100 则

                   old_phy_noise_spur = ani_state->phy_noise_spur;

                   若ofdm_phy_err_rate <= ani_state->ofdm_trig_low 且

                            cck_phy_err_rate <= ani_state->cck_trig_low) 则

                            若ani_state->listen_time >= 5000 则ani_state->phy_noise_spur = 0;

    否则ani_state->phy_noise_spur = 1;

 若ani_state->listen_time > 5 * ahp->ah_ani_period 则

                   若ofdm_phy_err_rate <= ani_state->ofdm_trig_low 且

                            cck_phy_err_rate <= ani_state->cck_trig_low 则

                            调用ar9300_ani_lower_immunity  调低抗噪等级

                    调用ar9300_ani_restar重启计数

否则若ani_state->listen_time > ahp->ah_ani_period 则

                      若ofdm_phy_err_rate > ani_state->ofdm_trig_high 且

                                      cck_phy_err_rate <= ani_state->cck_trig_high 或 检测odfm 则

                                      调用ar9300_ani_ofdm_err_trigger,上调抗噪等级

                                      调用ar9300_ani_restart重启计数

                                      检测ofdm标记复位

                            否则 若cck_phy_err_rate > ani_state->cck_trig_high 则

                                      调用ar9300_ani_cck_err_trigger,上调抗噪等级

                                      调用ar9300_ani_restart 重启计数

                                      检测ofdm标记置位

 

5 总结

启用了ANI(缺省)时,会基于OFDM Err和CCK Err统计值,自动调整抗噪等级,从而提高或降低接收机灵敏度(是否能调整PLCP灵敏度未知)。所以在一个需要高灵敏的场景下,需要先关闭ANI功能,然后直接手工调整:

弱信号寄存器:BB_sfcorr_low, BB_sfcorr, BB_ext_chan_scorr_thr的值,并确保BB_sfcorr_low的bit0为1(启用)或为0(关闭);

FIR阶次寄存器:BB_find_signal,BB_find_signal_low

冲激(毛刺)寄存器:BB_timing_control_5,BB_ext_chan_pwr_thr_2_b0

MRC(Maximal Ratio Combining)寄存器: BB_mrc_cck_ctrl的bit1-0,全为0或1;MRC对CCK有额外要求,如果低速下效果满意,可以取反测试一下。

ANI功能分析

标签:unity   越界   listen   mode   rate   set   信道   nat   efault   

原文地址:http://www.cnblogs.com/gierwu-wirelessIoT/p/7491547.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!