1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-11-26 07:04:12 +00:00
rtl8812au/hal/phydm/phydm_primary_cca.c

174 lines
4.7 KiB
C
Raw Normal View History

2018-06-22 16:48:32 +00:00
/******************************************************************************
*
2018-08-24 20:52:34 +00:00
* Copyright(c) 2007 - 2017 Realtek Corporation.
2018-06-22 16:48:32 +00:00
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2018-08-24 20:52:34 +00:00
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
2018-06-22 16:48:32 +00:00
* more details.
*
2018-08-24 20:52:34 +00:00
* The full GNU General Public License is included in this distribution in the
* file called LICENSE.
*
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
* Hsinchu 300, Taiwan.
*
* Larry Finger <Larry.Finger@lwfinger.net>
*
2018-06-22 16:48:32 +00:00
*****************************************************************************/
2019-05-24 19:43:57 +00:00
/*************************************************************
2018-06-22 16:48:32 +00:00
* include files
2019-05-24 19:43:57 +00:00
************************************************************/
2018-06-22 16:48:32 +00:00
#include "mp_precomp.h"
#include "phydm_precomp.h"
#ifdef PHYDM_PRIMARY_CCA
2019-05-24 19:43:57 +00:00
void phydm_write_dynamic_cca(
void *dm_void,
u8 curr_mf_state
)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct phydm_pricca_struct *pri_cca = &dm->dm_pri_cca;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
if (pri_cca->mf_state == curr_mf_state)
2018-08-24 20:52:34 +00:00
return;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type & ODM_IC_11N_SERIES) {
if (curr_mf_state == MF_USC_LSC) {
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0xc6c, 0x180, MF_USC_LSC);
/*@40M OFDM MF CCA threshold*/
odm_set_bb_reg(dm, R_0xc84, 0xf0000000,
pri_cca->cca_th_40m_bkp);
2018-08-24 20:52:34 +00:00
} else {
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0xc6c, 0x180, curr_mf_state);
/*@40M OFDM MF CCA threshold*/
odm_set_bb_reg(dm, R_0xc84, 0xf0000000, 0);
2018-06-22 16:48:32 +00:00
}
}
2018-08-24 20:52:34 +00:00
2019-05-24 19:43:57 +00:00
pri_cca->mf_state = curr_mf_state;
PHYDM_DBG(dm, DBG_PRI_CCA, "Set CCA at ((%s SB)), 0xc6c[8:7]=((%d))\n",
((curr_mf_state == MF_USC_LSC) ? "D" :
((curr_mf_state == MF_LSC) ? "L" : "U")), curr_mf_state);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void phydm_primary_cca_reset(
void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct phydm_pricca_struct *pri_cca = &dm->dm_pri_cca;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_PRI_CCA, "[PriCCA] Reset\n");
2019-05-24 19:43:57 +00:00
pri_cca->mf_state = 0xff;
pri_cca->pre_bw = (enum channel_width)0xff;
2018-08-24 20:52:34 +00:00
phydm_write_dynamic_cca(dm, MF_USC_LSC);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void phydm_primary_cca_11n(
void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct phydm_pricca_struct *pri_cca = &dm->dm_pri_cca;
enum channel_width curr_bw = (enum channel_width)*dm->band_width;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (!(dm->support_ability & ODM_BB_PRIMARY_CCA))
2018-06-22 16:48:32 +00:00
return;
2019-05-24 19:43:57 +00:00
if (!dm->is_linked) {
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_PRI_CCA, "[PriCCA][No Link!!!]\n");
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
if (pri_cca->pri_cca_is_become_linked) {
2018-08-24 20:52:34 +00:00
phydm_primary_cca_reset(dm);
2019-05-24 19:43:57 +00:00
pri_cca->pri_cca_is_become_linked = dm->is_linked;
2018-06-22 16:48:32 +00:00
}
return;
} else {
2019-05-24 19:43:57 +00:00
if (!pri_cca->pri_cca_is_become_linked) {
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_PRI_CCA, "[PriCCA][Linked !!!]\n");
2019-05-24 19:43:57 +00:00
pri_cca->pri_cca_is_become_linked = dm->is_linked;
2018-06-22 16:48:32 +00:00
}
}
2019-05-24 19:43:57 +00:00
if (curr_bw != pri_cca->pre_bw) {
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_PRI_CCA, "[Primary CCA] start ==>\n");
2019-05-24 19:43:57 +00:00
pri_cca->pre_bw = curr_bw;
2018-06-22 16:48:32 +00:00
if (curr_bw == CHANNEL_WIDTH_40) {
2019-05-24 19:43:57 +00:00
if (*dm->sec_ch_offset == SECOND_CH_AT_LSB) {
/* Primary CH @ upper sideband*/
PHYDM_DBG(dm, DBG_PRI_CCA,
"BW40M, Primary CH at USB\n");
2018-08-24 20:52:34 +00:00
phydm_write_dynamic_cca(dm, MF_USC);
2019-05-24 19:43:57 +00:00
} else {
/*Primary CH @ lower sideband*/
PHYDM_DBG(dm, DBG_PRI_CCA,
"BW40M, Primary CH at LSB\n");
2018-08-24 20:52:34 +00:00
phydm_write_dynamic_cca(dm, MF_LSC);
2018-06-22 16:48:32 +00:00
}
} else {
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_PRI_CCA, "Not BW40M, USB + LSB\n");
phydm_primary_cca_reset(dm);
2018-06-22 16:48:32 +00:00
}
}
}
2019-05-24 19:43:57 +00:00
boolean
odm_dynamic_primary_cca_dup_rts(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct phydm_pricca_struct *pri_cca = &dm->dm_pri_cca;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
return pri_cca->dup_rts_flag;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void phydm_primary_cca_init(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct phydm_pricca_struct *pri_cca = &dm->dm_pri_cca;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (!(dm->support_ability & ODM_BB_PRIMARY_CCA))
2018-06-22 16:48:32 +00:00
return;
2019-05-24 19:43:57 +00:00
if (!(dm->support_ic_type & ODM_IC_11N_SERIES))
2018-06-22 16:48:32 +00:00
return;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_PRI_CCA, "[PriCCA] Init ==>\n");
2019-05-24 19:43:57 +00:00
#if (RTL8188E_SUPPORT == 1) || (RTL8192E_SUPPORT == 1)
pri_cca->dup_rts_flag = 0;
pri_cca->intf_flag = 0;
pri_cca->intf_type = 0;
pri_cca->monitor_flag = 0;
pri_cca->pri_cca_flag = 0;
pri_cca->ch_offset = 0;
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
pri_cca->mf_state = 0xff;
pri_cca->pre_bw = (enum channel_width)0xff;
pri_cca->cca_th_40m_bkp = (u8)odm_get_bb_reg(dm, R_0xc84, 0xf0000000);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void phydm_primary_cca(void *dm_void)
2018-06-22 16:48:32 +00:00
{
#ifdef PHYDM_PRIMARY_CCA
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (!(dm->support_ic_type & ODM_IC_11N_SERIES))
2018-06-22 16:48:32 +00:00
return;
2018-08-24 20:52:34 +00:00
if (!(dm->support_ability & ODM_BB_PRIMARY_CCA))
2018-06-22 16:48:32 +00:00
return;
2018-08-24 20:52:34 +00:00
phydm_primary_cca_11n(dm);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
#endif