685 lines
21 KiB
C
685 lines
21 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
#include "iot_config.h"
|
|
|
|
#include "hw_tonemap.h"
|
|
#include "rf_hw_tonemap.h"
|
|
#include "phy_rf_chn.h"
|
|
#include "iot_errno.h"
|
|
#include "plc_utils.h"
|
|
#include "iot_io.h"
|
|
#include "iot_utils_api.h"
|
|
|
|
#if HPLC_RF_DEV_SUPPORT
|
|
|
|
#define RF_MCS_RA_TBL_GET(_TBL, _IDX, _ITEM) (_TBL[_IDX]._ITEM)
|
|
#define RF_MCS_RA_TBL_SZ() IOT_ARRAY_CNT(g_rf_mcs_ra_tbl)
|
|
#define RF_MCS_RA_PHR(_IDX) \
|
|
RF_MCS_RA_TBL_GET(g_rf_mcs_ra_tbl, _IDX, phr_mcs)
|
|
#define RF_MCS_RA_PSDU(_IDX) \
|
|
RF_MCS_RA_TBL_GET(g_rf_mcs_ra_tbl, _IDX, psdu_mcs)
|
|
#define RF_MCS_RA_ENA(_OPT, _IDX) \
|
|
(!!(RF_MCS_RA_TBL_GET(g_rf_mcs_ra_tbl, _IDX, ena_opt_bm) \
|
|
& (1 << ((_OPT) - 1))))
|
|
|
|
typedef struct _rf_mcs_rate_tbl {
|
|
uint8_t phr_mcs;
|
|
uint8_t psdu_mcs;
|
|
/* option enable bitmap. bit0:option1, bit1:option2 ... */
|
|
uint8_t ena_opt_bm;
|
|
} rf_mcs_rate_tbl_t;
|
|
|
|
/* phr fl, unit us */
|
|
static uint32_t g_stf_ltf_fl = 0;
|
|
/* phr fl, unit us */
|
|
static uint32_t g_sig_fl = 0;
|
|
/* phr fl, unit us */
|
|
static uint32_t g_phr_fl[MCS_ID_MAX] = { 0 };
|
|
/* psdu fl, unit us */
|
|
static uint32_t g_psdu_fl[MCS_ID_MAX][BLOCK_SIZE_MAX] = { 0 };
|
|
/* psdu fl, unit ntb */
|
|
static uint32_t g_psdu_fl_ntb[MCS_ID_MAX][BLOCK_SIZE_MAX] = { 0 };
|
|
/* tx sack mcs */
|
|
static uint32_t g_tx_sack_mcs = 0;
|
|
|
|
/* stf + ltf + sig fl, unit ntb */
|
|
static uint32_t g_stf_ltf_sig_ntb[PHY_RF_OPTION_MAX] = { 0 };
|
|
|
|
static const rf_option_info_entry_t rf_option_tonemap[] = {
|
|
{PHY_RF_OPTION1_1M, 1, 96},
|
|
{PHY_RF_OPTION2_500K, 2, 48},
|
|
{PHY_RF_OPTION3_200K, 2, 18},
|
|
};
|
|
|
|
static const rf_tonemap_table_entry rf_phr_tonemap_table[] = {
|
|
/* robo_cnt, modulation, resv0, coding_rate_idx */
|
|
{ROBO_COPY_6, MODULATION_BPSK, 0, CODING_RATE_1_2}, // phrmcs 0
|
|
{ROBO_COPY_4, MODULATION_BPSK, 0, CODING_RATE_1_2}, // phrmcs 1
|
|
{ROBO_COPY_3, MODULATION_BPSK, 0, CODING_RATE_1_2}, // phrmcs 2
|
|
{ROBO_COPY_2, MODULATION_BPSK, 0, CODING_RATE_1_2}, // phrmcs 3
|
|
{ROBO_COPY_2, MODULATION_QPSK, 0, CODING_RATE_1_2}, // phrmcs 4
|
|
{ROBO_COPY_1, MODULATION_QPSK, 0, CODING_RATE_1_2}, // phrmcs 5
|
|
{ROBO_COPY_1, MODULATION_QPSK, 0, CODING_RATE_4_5}, // phrmcs 6
|
|
};
|
|
|
|
static const rf_tonemap_table_entry rf_psdu_tonemap_table[] = {
|
|
/* robo_cnt, modulation, resv0, coding_rate_idx */
|
|
{ROBO_COPY_4, MODULATION_BPSK, 0, CODING_RATE_1_2}, // psdumcs 0
|
|
{ROBO_COPY_2, MODULATION_BPSK, 0, CODING_RATE_1_2}, // psdumcs 1
|
|
{ROBO_COPY_2, MODULATION_QPSK, 0, CODING_RATE_1_2}, // psdumcs 2
|
|
{ROBO_COPY_1, MODULATION_QPSK, 0, CODING_RATE_1_2}, // psdumcs 3
|
|
{ROBO_COPY_1, MODULATION_QPSK, 0, CODING_RATE_4_5}, // psdumcs 4
|
|
{ROBO_COPY_1, MODULATION_16QAM, 0, CODING_RATE_1_2}, // psdumcs 5
|
|
{ROBO_COPY_1, MODULATION_16QAM, 0, CODING_RATE_4_5}, // psdumcs 6
|
|
};
|
|
|
|
static const robo_inter_table_entry rf_option1_2_robo_inter_table[] = {
|
|
{ROBO_COPY_1, INTER_1}, // id 0
|
|
{ROBO_COPY_2, INTER_4}, // id 1
|
|
{ROBO_COPY_3, INTER_6}, // id 2
|
|
{ROBO_COPY_4, INTER_4}, // id 3
|
|
{ROBO_COPY_6, INTER_6}, // id 4
|
|
};
|
|
|
|
static const robo_inter_table_entry rf_option3_robo_inter_table[] = {
|
|
{ROBO_COPY_1, INTER_1}, // id 0
|
|
{ROBO_COPY_2, INTER_2}, // id 1
|
|
{ROBO_COPY_3, INTER_6}, // id 2
|
|
{ROBO_COPY_4, INTER_4}, // id 3
|
|
{ROBO_COPY_6, INTER_6}, // id 4
|
|
};
|
|
|
|
/* NOTE: option3 phrmcs need start with 2 for rf certification test */
|
|
/* NOTE: option3 pldmcs need start with 1 for rf certification test */
|
|
static const rf_mcs_rate_tbl_t g_rf_mcs_ra_tbl[] = {
|
|
/* phr_mcs, psdu_mcs, option enable bitmap */
|
|
/*00*/ { 0, 0, 0x03 }, /* snr: -6.78, -5.02 */
|
|
/*01*/ { 0, 1, 0x03 }, /* snr: -6.78, -2.01 */
|
|
/*02*/ { 1, 0, 0x03 }, /* snr: -5.02, -5.02 */
|
|
/*03*/ { 2, 1, 0x07 }, /* snr: -3.77, -2.01 */
|
|
/*04*/ { 2, 2, 0x07 }, /* snr: -3.77, 0.99 */
|
|
/*05*/ { 3, 1, 0x07 }, /* snr: -2.01, -2.01 */
|
|
/*06*/ { 4, 2, 0x07 }, /* snr: 0.99, 0.99 */
|
|
/*07*/ { 5, 3, 0x07 }, /* snr: 4, 4 */
|
|
/*08*/ { 6, 4, 0x07 }, /* snr: 6.50, 6.50 */
|
|
/*09*/ { 6, 5, 0x07 }, /* snr: 6.50, 10 */
|
|
/*10*/ { 6, 6, 0x07 }, /* snr: 6.50, 12.50 */
|
|
};
|
|
|
|
static const rf_mcs_table_t g_rf_bcn_fix_mcs_tlb[][BLOCK_SIZE_MAX] = {
|
|
/* option 1 */
|
|
{
|
|
/* phr_mcs , psdu_mcs ******************* phr_mcs , psdu_mcs fl/ms */
|
|
{ 0 , 1 }, // bcn 16byte snr: -6.78 -2.01 4.46
|
|
{ 0 , 1 }, // bcn 40byte snr: -6.78 -2.01 5.69
|
|
{ 0 , 1 }, // bcn 72byte snr: -6.78 -2.01 7.23
|
|
{ 0 , 1 }, // bcn 136byte snr: -6.78 -2.01 10.61
|
|
{ 0 , 1 }, // bcn 264byte snr: -6.78 -2.01 17.06
|
|
{ 0 , 1 }, // bcn 520byte snr: -6.78 -2.01 30.27
|
|
},
|
|
/* option 2 */
|
|
{
|
|
/* phr_mcs , psdu_mcs ******************* phr_mcs , psdu_mcs fl/ms */
|
|
{ 0 , 1 }, // bcn 16byte snr: -6.78 -2.01 7.84
|
|
{ 0 , 1 }, // bcn 40byte snr: -6.78 -2.01 10.30
|
|
{ 0 , 1 }, // bcn 72byte snr: -6.78 -2.01 13.52
|
|
{ 0 , 1 }, // bcn 136byte snr: -6.78 -2.01 20.13
|
|
{ 0 , 1 }, // bcn 264byte snr: -6.78 -2.01 33.19
|
|
{ 0 , 2 }, // bcn 520byte snr: -6.78 0.99 32.88
|
|
},
|
|
/* option 3 */
|
|
{
|
|
/* NOTE: option3 phrmcs need start with 2 for rf certification test */
|
|
/* NOTE: option3 pldmcs need start with 1 for rf certification test */
|
|
/* phr_mcs , psdu_mcs ******************* phr_mcs , psdu_mcs fl/ms */
|
|
{ 2 , 2 }, // bcn 16byte snr: -3.77 0.99 10.15
|
|
{ 2 , 2 }, // bcn 40byte snr: -3.77 0.99 13.38
|
|
{ 2 , 2 }, // bcn 72byte snr: -3.77 0.99 17.68
|
|
{ 2 , 2 }, // bcn 136byte snr: -3.77 0.99 26.43
|
|
{ 3 , 2 }, // bcn 264byte snr: -2.01 0.99 41.76
|
|
{ 3 , 3 }, // bcn 520byte snr: -2.01 4 41.33
|
|
},
|
|
};
|
|
|
|
static const rf_mcs_table_t g_rf_sof_fix_mcs_tlb[][BLOCK_SIZE_MAX] = {
|
|
/* option 1 */
|
|
{
|
|
/* phr_mcs , psdu_mcs ******************* phr_mcs , psdu_mcs fl/ms */
|
|
{ 0 , 1 }, // sof 16byte snr: -6.78 -2.01 4.46
|
|
{ 0 , 1 }, // sof 40byte snr: -6.78 -2.01 5.69
|
|
{ 0 , 1 }, // sof 72byte snr: -6.78 -2.01 7.23
|
|
{ 0 , 1 }, // sof 136byte snr: -6.78 -2.01 10.61
|
|
{ 0 , 1 }, // sof 264byte snr: -6.78 -2.01 17.06
|
|
{ 0 , 1 }, // sof 520byte snr: -6.78 -2.01 30.27
|
|
},
|
|
/* option 2 */
|
|
{
|
|
/* phr_mcs , psdu_mcs ******************* phr_mcs , psdu_mcs fl/ms */
|
|
{ 0 , 1 }, // sof 16byte snr: -6.78 -2.01 7.84
|
|
{ 0 , 1 }, // sof 40byte snr: -6.78 -2.01 10.30
|
|
{ 0 , 1 }, // sof 72byte snr: -6.78 -2.01 13.52
|
|
{ 0 , 1 }, // sof 136byte snr: -6.78 -2.01 20.13
|
|
{ 0 , 1 }, // sof 264byte snr: -6.78 -2.01 33.19
|
|
{ 0 , 2 }, // sof 520byte snr: -6.78 0.99 32.88
|
|
},
|
|
/* option 3 */
|
|
{
|
|
/* NOTE: option3 phrmcs need start with 2 for rf certification test */
|
|
/* NOTE: option3 pldmcs need start with 1 for rf certification test */
|
|
/* phr_mcs , psdu_mcs ******************* phr_mcs , psdu_mcs fl/ms */
|
|
{ 2 , 2 }, // sof 16byte snr: -3.77 0.99 10.15
|
|
{ 2 , 2 }, // sof 40byte snr: -3.77 0.99 13.38
|
|
{ 2 , 2 }, // sof 72byte snr: -3.77 0.99 17.68
|
|
{ 2 , 2 }, // sof 136byte snr: -3.77 0.99 26.43
|
|
{ 2 , 2 }, // sof 264byte snr: -3.77 0.99 43.94
|
|
{ 2 , 3 }, // sof 520byte snr: -3.77 4 43.48
|
|
},
|
|
};
|
|
|
|
/* get fix mcs */
|
|
#define PHY_RF_GET_BCN_FIX_MCS(option, idx) (&g_rf_bcn_fix_mcs_tlb[option][idx])
|
|
#define PHY_RF_GET_SOF_FIX_MCS(option, idx) (&g_rf_sof_fix_mcs_tlb[option][idx])
|
|
|
|
/* get phr param by phr mcs */
|
|
#define PHY_RF_GET_PHR_MCS_PARAM(phr_mcs) (&rf_phr_tonemap_table[phr_mcs])
|
|
|
|
/* get psdu param by psdu mcs */
|
|
#define PHY_RF_GET_PSDU_MCS_PARAM(psdu_mcs) (&rf_psdu_tonemap_table[psdu_mcs])
|
|
|
|
static uint32_t phy_rf_get_robo_inter(uint32_t option, uint32_t robo_cnt,
|
|
uint32_t *robo_inter)
|
|
{
|
|
uint32_t i, ret = ERR_OK;
|
|
if (option == PHY_RF_OPTION1_1M || option == PHY_RF_OPTION2_500K) {
|
|
for (i = 0; i < sizeof(rf_option1_2_robo_inter_table); i++) {
|
|
if(rf_option1_2_robo_inter_table[i].robo_cpy == robo_cnt) {
|
|
*robo_inter = rf_option1_2_robo_inter_table[i].inter_num;
|
|
break;
|
|
}
|
|
}
|
|
if (sizeof(rf_option1_2_robo_inter_table) == i) {
|
|
IOT_ASSERT(0);
|
|
ret = ERR_FAIL;
|
|
} else {
|
|
ret = ERR_OK;
|
|
}
|
|
} else if (option == PHY_RF_OPTION3_200K) {
|
|
for (i = 0; i < sizeof(rf_option3_robo_inter_table); i++) {
|
|
if(rf_option3_robo_inter_table[i].robo_cpy == robo_cnt) {
|
|
*robo_inter = rf_option3_robo_inter_table[i].inter_num;
|
|
break;
|
|
}
|
|
}
|
|
if (sizeof(rf_option3_robo_inter_table) == i) {
|
|
IOT_ASSERT(0);
|
|
ret = ERR_FAIL;
|
|
} else {
|
|
ret = ERR_OK;
|
|
}
|
|
} else {
|
|
IOT_ASSERT(0);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static uint32_t phy_rf_get_vld_tone_num(uint32_t option)
|
|
{
|
|
uint32_t i;
|
|
IOT_ASSERT(option < PHY_RF_OPTION_MAX);
|
|
for (i = 0; i < sizeof(rf_option_tonemap); i++) {
|
|
if (rf_option_tonemap[i].option == option) {
|
|
return rf_option_tonemap[i].vld_tone_num;
|
|
}
|
|
}
|
|
|
|
if (sizeof(rf_option_tonemap) == i) {
|
|
IOT_ASSERT(0);
|
|
}
|
|
|
|
return ERR_FAIL;
|
|
}
|
|
|
|
static uint32_t phy_rf_get_sig_num(uint32_t option)
|
|
{
|
|
uint32_t i;
|
|
IOT_ASSERT(option < PHY_RF_OPTION_MAX);
|
|
for (i = 0; i < sizeof(rf_option_tonemap); i++) {
|
|
if (rf_option_tonemap[i].option == option) {
|
|
return rf_option_tonemap[i].sig_symbol_num;
|
|
}
|
|
}
|
|
|
|
if (sizeof(rf_option_tonemap) == i) {
|
|
IOT_ASSERT(0);
|
|
}
|
|
|
|
return ERR_FAIL;
|
|
}
|
|
|
|
static uint32_t phy_rf_get_phr_sym(uint32_t option, uint32_t phr_mcs)
|
|
{
|
|
uint32_t pbsz = RF_PHR_LEN;
|
|
uint32_t robo_inter = 0;
|
|
float coding_rate = 0;
|
|
uint32_t vld_tone_num = 0;
|
|
uint32_t sym_ppb;
|
|
const rf_tonemap_table_entry *phr_param = PHY_RF_GET_PHR_MCS_PARAM(phr_mcs);
|
|
|
|
phy_rf_get_robo_inter(option, phr_param->robo_cnt, &robo_inter);
|
|
|
|
if(phr_param->coding_rate_idx == CODING_RATE_1_2){
|
|
coding_rate = 0.5;
|
|
} else if(phr_param->coding_rate_idx == CODING_RATE_4_5){
|
|
coding_rate = (float)(4.0/5.0);
|
|
} else {
|
|
IOT_ASSERT(0);
|
|
}
|
|
|
|
/* get vaild tone */
|
|
vld_tone_num = phy_rf_get_vld_tone_num(option);
|
|
|
|
sym_ppb = (uint32_t)OFDM_SYMBOL_PER_PB(pbsz,
|
|
phr_param->robo_cnt,
|
|
coding_rate,
|
|
phr_param->modulation,
|
|
vld_tone_num,
|
|
robo_inter);
|
|
|
|
return sym_ppb;
|
|
}
|
|
|
|
static uint32_t phy_rf_get_psdu_sym(uint32_t option, uint32_t psdu_mcs,
|
|
uint32_t pb_idx)
|
|
{
|
|
uint32_t pbsz;
|
|
uint32_t robo_inter = 0;
|
|
float coding_rate = 0;
|
|
uint32_t vld_tone_num = 0;
|
|
uint32_t sym_ppb;
|
|
const rf_tonemap_table_entry *psdu_param = PHY_RF_GET_PSDU_MCS_PARAM(psdu_mcs);
|
|
|
|
phy_rf_get_robo_inter(option, psdu_param->robo_cnt, &robo_inter);
|
|
|
|
if(psdu_param->coding_rate_idx == CODING_RATE_1_2){
|
|
coding_rate = 0.5;
|
|
} else if(psdu_param->coding_rate_idx == CODING_RATE_4_5){
|
|
coding_rate = (float)(4.0/5.0);
|
|
} else {
|
|
IOT_ASSERT(0);
|
|
}
|
|
pbsz = phy_rf_get_pbsz((uint8_t)pb_idx);
|
|
/* get vaild tone */
|
|
vld_tone_num = phy_rf_get_vld_tone_num(option);
|
|
|
|
sym_ppb = (uint32_t)OFDM_SYMBOL_PER_PB(pbsz,
|
|
psdu_param->robo_cnt,
|
|
coding_rate,
|
|
psdu_param->modulation,
|
|
vld_tone_num,
|
|
robo_inter);
|
|
|
|
return sym_ppb;
|
|
}
|
|
|
|
static uint32_t phy_rf_get_stf_ltf_frame_len(uint32_t option)
|
|
{
|
|
IOT_ASSERT(option < PHY_RF_OPTION_MAX);
|
|
if (option == PHY_RF_OPTION1_1M || option == PHY_RF_OPTION2_500K) {
|
|
return STF_LTF_OPTION1_2_LEN;
|
|
} else if (option == PHY_RF_OPTION3_200K) {
|
|
return STF_LTF_OPTION3_LEN;
|
|
}
|
|
|
|
return ERR_FAIL;
|
|
}
|
|
|
|
static uint32_t phy_rf_get_sig_frame_len(uint32_t option)
|
|
{
|
|
uint32_t sig_num;
|
|
uint32_t sig_fl = 0;
|
|
|
|
IOT_ASSERT(option < PHY_RF_OPTION_MAX);
|
|
|
|
sig_num = phy_rf_get_sig_num(option);
|
|
|
|
sig_fl = sig_num * PER_SIG_LEN;
|
|
|
|
return sig_fl;
|
|
}
|
|
|
|
static uint32_t phy_rf_get_phr_frame_len(uint32_t option, uint32_t phr_mcs)
|
|
{
|
|
uint32_t sym_num = 0;
|
|
uint32_t phr_len = 0;
|
|
|
|
sym_num = phy_rf_get_phr_sym(option, phr_mcs);
|
|
phr_len = sym_num * PER_SIG_LEN;
|
|
|
|
/* unit us */
|
|
return phr_len;
|
|
}
|
|
|
|
static uint32_t phy_rf_get_psdu_frame_len(uint32_t option, uint32_t psdu_mcs,
|
|
uint32_t pb_idx)
|
|
{
|
|
uint32_t sym_num = 0;
|
|
uint32_t psdu_len = 0;
|
|
|
|
sym_num = phy_rf_get_psdu_sym(option, psdu_mcs, pb_idx);
|
|
psdu_len = sym_num * PSDU_SYMBOL_LEN;
|
|
|
|
/* unit ntb */
|
|
return psdu_len;
|
|
}
|
|
|
|
static uint32_t phy_rf_get_tx_sack_phr_mcs(uint32_t option)
|
|
{
|
|
uint32_t phr_mcs = MCS_ID_0;
|
|
IOT_ASSERT(option < PHY_RF_OPTION_MAX);
|
|
/* NOTE: option3 phrmcs need start with 2 for rf certification test */
|
|
if (PHY_RF_OPTION3_200K == option) {
|
|
phr_mcs = MCS_ID_2;
|
|
}
|
|
return phr_mcs;
|
|
}
|
|
|
|
static void phy_rf_stf_ltf_sig_fl_init()
|
|
{
|
|
uint32_t option = 0;
|
|
for (option = PHY_RF_OPTION1_1M; option < PHY_RF_OPTION_MAX; option++) {
|
|
g_stf_ltf_sig_ntb[option] = phy_rf_get_stf_ltf_frame_len(option) +
|
|
phy_rf_get_sig_frame_len(option);
|
|
}
|
|
}
|
|
|
|
uint32_t fl_debug()
|
|
{
|
|
uint32_t stf_ltf_fl = 0;
|
|
uint32_t sig_fl = 0;
|
|
uint32_t fl = 0;
|
|
uint32_t option = 0, phr_mcs, phr_sym, psdu_mcs, psdu_sym, pb_idx;
|
|
uint32_t phr_fl, psdu_fl;
|
|
for (option = PHY_RF_OPTION1_1M; option < PHY_RF_OPTION_MAX; option++) {
|
|
stf_ltf_fl = phy_rf_get_stf_ltf_frame_len(option);
|
|
sig_fl = phy_rf_get_sig_frame_len(option);
|
|
for (pb_idx = BLOCK_SIZE_0; pb_idx < BLOCK_SIZE_MAX; pb_idx++) {
|
|
for (phr_mcs = MCS_ID_0; phr_mcs < MCS_ID_MAX; phr_mcs++) {
|
|
phr_sym = phy_rf_get_phr_sym(option, phr_mcs);
|
|
for (psdu_mcs = MCS_ID_0; psdu_mcs < MCS_ID_MAX; psdu_mcs++) {
|
|
psdu_sym = phy_rf_get_psdu_sym(option, psdu_mcs, pb_idx);
|
|
phr_fl = phy_rf_get_phr_frame_len(option, phr_mcs);
|
|
psdu_fl = phy_rf_get_psdu_frame_len(option,
|
|
psdu_mcs, pb_idx);
|
|
fl = (stf_ltf_fl + sig_fl + phr_fl + psdu_fl) / 25;
|
|
iot_printf("option:%d, phr_mcs:%d, psdu_mcs:%d, pb_idx:%d, "
|
|
"phr_sym:%d, psdu_sym:%d, phr_fl:%d, psdu_fl:%d, fl:%d\n",
|
|
option, phr_mcs, psdu_mcs, pb_idx, phr_sym, psdu_sym,
|
|
phr_fl, psdu_fl, fl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
uint32_t phy_rf_fl_init(uint32_t option)
|
|
{
|
|
float tmp = 0;
|
|
/* stf ltf init */
|
|
tmp = (float)phy_rf_get_stf_ltf_frame_len(option) / 25;
|
|
g_stf_ltf_fl = iot_float_ceil(tmp);
|
|
/* sig init */
|
|
tmp = (float)phy_rf_get_sig_frame_len(option) / 25;
|
|
g_sig_fl = iot_float_ceil(tmp);
|
|
/* phy header init */
|
|
for (uint32_t phr_mcs = 0; phr_mcs < MCS_ID_MAX; phr_mcs++) {
|
|
tmp = (float)phy_rf_get_phr_frame_len(option, phr_mcs) / 25;
|
|
g_phr_fl[phr_mcs] = iot_float_ceil(tmp);
|
|
}
|
|
|
|
/* psdu init */
|
|
for (uint32_t psdu_mcs = 0; psdu_mcs < MCS_ID_MAX; psdu_mcs++) {
|
|
for (uint32_t pbidx = BLOCK_SIZE_0; pbidx < BLOCK_SIZE_MAX; pbidx++) {
|
|
g_psdu_fl_ntb[psdu_mcs][pbidx] = phy_rf_get_psdu_frame_len(option,
|
|
psdu_mcs, pbidx);
|
|
tmp = (float)g_psdu_fl_ntb[psdu_mcs][pbidx] / 25;
|
|
g_psdu_fl[psdu_mcs][pbidx] = iot_float_ceil(tmp);
|
|
}
|
|
}
|
|
|
|
/* init stf ltf sig fl, uint ntb */
|
|
phy_rf_stf_ltf_sig_fl_init();
|
|
|
|
/* init tx sack mcs */
|
|
g_tx_sack_mcs = phy_rf_get_tx_sack_phr_mcs(option);
|
|
|
|
/* fl debug */
|
|
//fl_debug();
|
|
|
|
return ERR_OK;
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_stf_ltf_fl()
|
|
{
|
|
return g_stf_ltf_fl;
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_sig_fl()
|
|
{
|
|
return g_sig_fl;
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_phr_fl(uint32_t phr_mcs)
|
|
{
|
|
IOT_ASSERT(phr_mcs < MCS_ID_MAX);
|
|
return g_phr_fl[phr_mcs];
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_psdu_fl(uint32_t psdu_mcs, uint32_t pb_idx)
|
|
{
|
|
IOT_ASSERT(psdu_mcs < MCS_ID_MAX && pb_idx < BLOCK_SIZE_MAX);
|
|
return g_psdu_fl[psdu_mcs][pb_idx];
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_psdu_fl_ntb(uint32_t psdu_mcs, uint32_t pb_idx)
|
|
{
|
|
IOT_ASSERT(psdu_mcs < MCS_ID_MAX && pb_idx < BLOCK_SIZE_MAX);
|
|
return g_psdu_fl_ntb[psdu_mcs][pb_idx];
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_stf_ltf_sig_fl(uint32_t option)
|
|
{
|
|
return g_stf_ltf_sig_ntb[option];
|
|
}
|
|
|
|
const rf_mcs_table_t *phy_rf_get_bcn_fix_mcs(uint32_t option,
|
|
uint32_t pb_sz_idx)
|
|
{
|
|
IOT_ASSERT(option < PHY_RF_OPTION_MAX && pb_sz_idx < BLOCK_SIZE_MAX);
|
|
return PHY_RF_GET_BCN_FIX_MCS((option - 1), pb_sz_idx);
|
|
}
|
|
|
|
const rf_mcs_table_t *phy_rf_get_sof_fix_mcs(uint32_t option,
|
|
uint32_t pb_sz_idx)
|
|
{
|
|
IOT_ASSERT(option < PHY_RF_OPTION_MAX && pb_sz_idx < BLOCK_SIZE_MAX);
|
|
return PHY_RF_GET_SOF_FIX_MCS((option - 1), pb_sz_idx);
|
|
}
|
|
|
|
void phy_rf_get_ra_idx_range(uint8_t option, uint8_t *start, uint8_t *end)
|
|
{
|
|
if (RF_OPTION_3 == option) {
|
|
*start = 3;
|
|
} else {
|
|
*start = 0;
|
|
}
|
|
|
|
*end = RF_MCS_RA_TBL_SZ();
|
|
}
|
|
|
|
uint32_t phy_rf_get_ra_idx_mcs(uint8_t option, uint8_t idx, uint8_t *phr_mcs,
|
|
uint8_t *psdu_mcs)
|
|
{
|
|
if (RF_MCS_RA_ENA(option, idx)) {
|
|
*phr_mcs = RF_MCS_RA_PHR(idx);
|
|
*psdu_mcs = RF_MCS_RA_PSDU(idx);
|
|
return ERR_OK;
|
|
} else {
|
|
return ERR_NOSUPP;
|
|
}
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_tx_sack_mcs()
|
|
{
|
|
return g_tx_sack_mcs;
|
|
}
|
|
|
|
#else /* !HPLC_RF_DEV_SUPPORT */
|
|
|
|
uint32_t phy_rf_fl_init(uint32_t option)
|
|
{
|
|
(void)option;
|
|
return ERR_OK;
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_stf_ltf_fl()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_sig_fl()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_phr_fl(uint32_t phr_mcs)
|
|
{
|
|
(void)phr_mcs;
|
|
return 0;
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_psdu_fl(uint32_t psdu_mcs, uint32_t pb_idx)
|
|
{
|
|
(void)psdu_mcs;
|
|
(void)pb_idx;
|
|
return 0;
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_psdu_fl_ntb(uint32_t psdu_mcs, uint32_t pb_idx)
|
|
{
|
|
(void)psdu_mcs;
|
|
(void)pb_idx;
|
|
return 0;
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_stf_ltf_sig_fl(uint32_t option)
|
|
{
|
|
(void)option;
|
|
return 0;
|
|
}
|
|
|
|
const rf_mcs_table_t *phy_rf_get_bcn_fix_mcs(uint32_t option,
|
|
uint32_t pb_sz_idx)
|
|
{
|
|
(void)option;
|
|
(void)pb_sz_idx;
|
|
return NULL;
|
|
}
|
|
|
|
const rf_mcs_table_t *phy_rf_get_sof_fix_mcs(uint32_t option,
|
|
uint32_t pb_sz_idx)
|
|
{
|
|
(void)option;
|
|
(void)pb_sz_idx;
|
|
return NULL;
|
|
}
|
|
|
|
void phy_rf_get_ra_idx_range(uint8_t option, uint8_t *start, uint8_t *end)
|
|
{
|
|
(void)option;
|
|
(void)start;
|
|
(void)end;
|
|
}
|
|
|
|
uint32_t phy_rf_get_ra_idx_mcs(uint8_t option, uint8_t idx, uint8_t *phr_mcs,
|
|
uint8_t *psdu_mcs)
|
|
{
|
|
(void)option;
|
|
(void)idx;
|
|
(void)phr_mcs;
|
|
(void)psdu_mcs;
|
|
return ERR_NOSUPP;
|
|
}
|
|
|
|
uint32_t phy_rf_get_g_tx_sack_mcs()
|
|
{
|
|
return MCS_ID_MAX;
|
|
}
|
|
|
|
#endif /* HPLC_RF_DEV_SUPPORT */
|
|
|
|
uint8_t phy_rf_get_blkz(uint32_t pbsz)
|
|
{
|
|
uint8_t blkz = BLOCK_SIZE_MAX;
|
|
switch (pbsz) {
|
|
case PB_SIZE_16:
|
|
blkz = BLOCK_SIZE_0;
|
|
break;
|
|
case PB_SIZE_40:
|
|
blkz = BLOCK_SIZE_1;
|
|
break;
|
|
case PB_SIZE_72:
|
|
blkz = BLOCK_SIZE_2;
|
|
break;
|
|
case PB_SIZE_136:
|
|
blkz = BLOCK_SIZE_3;
|
|
break;
|
|
case PB_SIZE_264:
|
|
blkz = BLOCK_SIZE_4;
|
|
break;
|
|
case PB_SIZE_520:
|
|
blkz = BLOCK_SIZE_5;
|
|
break;
|
|
default:
|
|
IOT_ASSERT(0);
|
|
break;
|
|
}
|
|
return blkz;
|
|
}
|
|
|
|
uint32_t phy_rf_get_pbsz(uint8_t blkz)
|
|
{
|
|
switch (blkz) {
|
|
case BLOCK_SIZE_0:
|
|
return PB_SIZE_16;
|
|
case BLOCK_SIZE_1:
|
|
return PB_SIZE_40;
|
|
case BLOCK_SIZE_2:
|
|
return PB_SIZE_72;
|
|
case BLOCK_SIZE_3:
|
|
return PB_SIZE_136;
|
|
case BLOCK_SIZE_4:
|
|
return PB_SIZE_264;
|
|
case BLOCK_SIZE_5:
|
|
return PB_SIZE_520;
|
|
default:
|
|
IOT_ASSERT(0);
|
|
break;
|
|
}
|
|
return PB_SIZE_INV;
|
|
}
|
|
|