Path: blob/master/ALFA-W1F1/RTL8814AU/core/rtw_rm_util.c
1307 views
/******************************************************************************1*2* Copyright(c) 2007 - 2019 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13*****************************************************************************/1415#include <drv_types.h>16#include <hal_data.h>17#ifdef CONFIG_RTW_80211K18#include "rtw_rm_fsm.h"19#include "rtw_rm_util.h"2021/* 802.11-2012 Table E-1 Operationg classes in United States */22static RT_OPERATING_CLASS RTW_OP_CLASS_US[] = {23/* 0, OP_CLASS_NULL */ { 0, 0, {}},24/* 1, OP_CLASS_1 */ {115, 4, {36, 40, 44, 48}},25/* 2, OP_CLASS_2 */ {118, 4, {52, 56, 60, 64}},26/* 3, OP_CLASS_3 */ {124, 4, {149, 153, 157, 161}},27/* 4, OP_CLASS_4 */ {121, 11, {100, 104, 108, 112, 116, 120, 124,28128, 132, 136, 140}},29/* 5, OP_CLASS_5 */ {125, 5, {149, 153, 157, 161, 165}},30/* 6, OP_CLASS_12 */ { 81, 11, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}31};3233u8 rm_get_ch_set(34struct rtw_ieee80211_channel *pch_set, u8 op_class, u8 ch_num)35{36int i,j,sz;37u8 ch_amount = 0;383940sz = sizeof(RTW_OP_CLASS_US)/sizeof(struct _RT_OPERATING_CLASS);4142if (ch_num != 0) {43pch_set[0].hw_value = ch_num;44ch_amount = 1;45RTW_INFO("RM: meas_ch->hw_value = %u\n", pch_set->hw_value);46goto done;47}4849for (i = 0; i < sz; i++) {5051if (RTW_OP_CLASS_US[i].global_op_class == op_class) {5253for (j = 0; j < RTW_OP_CLASS_US[i].Len; j++) {54pch_set[j].hw_value =55RTW_OP_CLASS_US[i].Channel[j];56RTW_INFO("RM: meas_ch[%d].hw_value = %u\n",57j, pch_set[j].hw_value);58}59ch_amount = RTW_OP_CLASS_US[i].Len;60break;61}62}63done:64return ch_amount;65}6667u8 rm_get_oper_class_via_ch(u8 ch)68{69int i,j,sz;707172sz = sizeof(RTW_OP_CLASS_US)/sizeof(struct _RT_OPERATING_CLASS);7374for (i = 0; i < sz; i++) {75for (j = 0; j < RTW_OP_CLASS_US[i].Len; j++) {76if ( ch == RTW_OP_CLASS_US[i].Channel[j]) {77RTW_INFO("RM: ch %u in oper_calss %u\n",78ch, RTW_OP_CLASS_US[i].global_op_class);79return RTW_OP_CLASS_US[i].global_op_class;80break;81}82}83}84return 0;85}8687int is_wildcard_bssid(u8 *bssid)88{89int i;90u8 val8 = 0xff;919293for (i=0;i<6;i++)94val8 &= bssid[i];9596if (val8 == 0xff)97return _SUCCESS;98return _FALSE;99}100101u8 translate_dbm_to_rcpi(s8 SignalPower)102{103/* RCPI = Int{(Power in dBm + 110)*2} for 0dBm > Power > -110dBm104* 0 : power <= -110.0 dBm105* 1 : power = -109.5 dBm106* 2 : power = -109.0 dBm107*/108return (SignalPower + 110)*2;109}110111u8 translate_percentage_to_rcpi(u32 SignalStrengthIndex)112{113/* Translate to dBm (x=y-100) */114return translate_dbm_to_rcpi(SignalStrengthIndex - 100);115}116117u8 rm_get_bcn_rcpi(struct rm_obj *prm, struct wlan_network *pnetwork)118{119return translate_percentage_to_rcpi(120pnetwork->network.PhyInfo.SignalStrength);121}122123u8 rm_get_frame_rsni(struct rm_obj *prm, union recv_frame *pframe)124{125int i;126u8 val8, snr;127HAL_DATA_TYPE *pHalData = GET_HAL_DATA(prm->psta->padapter);128129if (IS_CCK_RATE((hw_rate_to_m_rate(pframe->u.hdr.attrib.data_rate))))130val8 = 255;131else {132snr = 0;133for (i = 0; i < pHalData->NumTotalRFPath; i++)134snr += pframe->u.hdr.attrib.phy_info.rx_snr[i];135snr = snr / pHalData->NumTotalRFPath;136val8 = (u8)(snr + 10)*2;137}138return val8;139}140141u8 rm_get_bcn_rsni(struct rm_obj *prm, struct wlan_network *pnetwork)142{143int i;144u8 val8, snr;145HAL_DATA_TYPE *pHalData = GET_HAL_DATA(prm->psta->padapter);146147148if (pnetwork->network.PhyInfo.is_cck_rate) {149/* current HW doesn't have CCK RSNI */150/* 255 indicates RSNI is unavailable */151val8 = 255;152} else {153snr = 0;154for (i = 0; i < pHalData->NumTotalRFPath; i++) {155snr += pnetwork->network.PhyInfo.rx_snr[i];156}157snr = snr / pHalData->NumTotalRFPath;158val8 = (u8)(snr + 10)*2;159}160return val8;161}162163char *get_rate_name(enum MGN_RATE rate)164{165switch(rate) {166case MGN_1M:167return "CCK_1M";168break;169case MGN_2M:170return "CCK_2M";171break;172case MGN_5_5M:173return "CCK_5.5M";174break;175case MGN_11M:176return "CCK_11M";177break;178case MGN_6M:179return "OFDM_6M";180break;181case MGN_9M:182return "OFDM_9M";183break;184case MGN_12M:185return "OFDM_12M";186break;187case MGN_18M:188return "OFDM_18M";189break;190case MGN_24M:191return "OFDM_24M";192break;193case MGN_36M:194return "OFDM_36M";195break;196case MGN_48M:197return "OFDM_48M";198break;199case MGN_54M:200return "OFDM_54M";201break;202case MGN_MCS0:203return "HT_MCS0";204break;205case MGN_MCS8:206return "HT_MCS8";207break;208case MGN_MCS16:209return "HT_MCS16";210break;211case MGN_MCS24:212return "HT_MCS24";213break;214case MGN_MCS32:215return "HT_MCS32";216break;217case MGN_MCS1:218return "HT_MCS1";219break;220case MGN_MCS9:221return "HT_MCS9";222break;223case MGN_MCS17:224return "HT_MCS17";225break;226case MGN_MCS25:227return "HT_MCS25";228break;229case MGN_MCS2:230return "HT_MCS2";231break;232case MGN_MCS10:233return "HT_MCS10";234break;235case MGN_MCS18:236return "HT_MCS18";237break;238case MGN_MCS26:239return "HT_MCS26";240break;241case MGN_MCS3:242return "HT_MCS3";243break;244case MGN_MCS11:245return "HT_MCS11";246break;247case MGN_MCS19:248return "HT_MCS19";249break;250case MGN_MCS27:251return "HT_MCS27";252break;253case MGN_MCS4:254return "HT_MCS4";255break;256case MGN_MCS12:257return "HT_MCS12";258break;259case MGN_MCS20:260return "HT_MCS20";261break;262case MGN_MCS28:263return "HT_MCS28";264break;265case MGN_MCS5:266return "HT_MCS5";267break;268case MGN_MCS13:269return "HT_MCS13";270break;271case MGN_MCS21:272return "HT_MCS21";273break;274case MGN_MCS29:275return "HT_MCS29";276break;277case MGN_MCS6:278return "HT_MCS6";279break;280case MGN_MCS14:281return "HT_MCS14";282break;283case MGN_MCS22:284return "HT_MCS22";285break;286case MGN_MCS30:287return "HT_MCS30";288break;289case MGN_MCS7:290return "HT_MCS7";291break;292case MGN_MCS15:293return "HT_MCS15";294break;295case MGN_MCS23:296return "HT_MCS23";297break;298case MGN_MCS31:299return "HT_MCS31";300break;301case MGN_VHT1SS_MCS0:302return "VHT1SS_MCS0";303break;304case MGN_VHT2SS_MCS0:305return "VHT2SS_MCS0";306break;307case MGN_VHT3SS_MCS0:308return "VHT3SS_MCS0";309break;310case MGN_VHT4SS_MCS0:311return "VHT4SS_MCS0";312break;313case MGN_VHT1SS_MCS1:314return "VHT1SS_MCS1";315break;316case MGN_VHT2SS_MCS1:317return "VHT2SS_MCS1";318break;319case MGN_VHT3SS_MCS1:320return "VHT3SS_MCS1";321break;322case MGN_VHT4SS_MCS1:323return "VHT4SS_MCS1";324break;325case MGN_VHT1SS_MCS2:326return "VHT1SS_MCS2";327break;328case MGN_VHT2SS_MCS2:329return "VHT2SS_MCS2";330break;331case MGN_VHT3SS_MCS2:332return "VHT3SS_MCS2";333break;334case MGN_VHT4SS_MCS2:335return "VHT4SS_MCS2";336break;337case MGN_VHT1SS_MCS3:338return "VHT1SS_MCS3";339break;340case MGN_VHT2SS_MCS3:341return "VHT2SS_MCS3";342break;343case MGN_VHT3SS_MCS3:344return "VHT3SS_MCS3";345break;346case MGN_VHT4SS_MCS3:347return "VHT4SS_MCS3";348break;349case MGN_VHT1SS_MCS4:350return "VHT1SS_MCS4";351break;352case MGN_VHT2SS_MCS4:353return "VHT2SS_MCS4";354break;355case MGN_VHT3SS_MCS4:356return "VHT3SS_MCS4";357break;358case MGN_VHT4SS_MCS4:359return "VHT4SS_MCS4";360break;361case MGN_VHT1SS_MCS5:362return "VHT1SS_MCS5";363break;364case MGN_VHT2SS_MCS5:365return "VHT2SS_MCS5";366break;367case MGN_VHT3SS_MCS5:368return "VHT3SS_MCS5";369break;370case MGN_VHT4SS_MCS5:371return "VHT4SS_MCS5";372break;373case MGN_VHT1SS_MCS6:374return "VHT1SS_MCS6";375break;376case MGN_VHT2SS_MCS6:377return "VHT2SS_MCS6";378break;379case MGN_VHT3SS_MCS6:380return "VHT3SS_MCS6";381break;382case MGN_VHT4SS_MCS6:383return "VHT4SS_MCS6";384break;385case MGN_VHT1SS_MCS7:386return "VHT1SS_MCS7";387break;388case MGN_VHT2SS_MCS7:389return "VHT2SS_MCS7";390break;391case MGN_VHT3SS_MCS7:392return "VHT3SS_MCS7";393break;394case MGN_VHT4SS_MCS7:395return "VHT4SS_MCS7";396break;397case MGN_VHT1SS_MCS8:398return "VHT1SS_MCS8";399break;400case MGN_VHT2SS_MCS8:401return "VHT2SS_MCS8";402break;403case MGN_VHT3SS_MCS8:404return "VHT3SS_MCS8";405break;406case MGN_VHT4SS_MCS8:407return "VHT4SS_MCS8";408break;409case MGN_VHT1SS_MCS9:410return "VHT1SS_MCS9";411break;412case MGN_VHT2SS_MCS9:413return "VHT2SS_MCS9";414break;415case MGN_VHT3SS_MCS9:416return "VHT3SS_MCS9";417break;418case MGN_VHT4SS_MCS9:419return "VHT4SS_MCS9";420break;421default:422break;423424}425return "UNKNOWN";426}427428static int get_rate_index(enum MGN_RATE rate)429{430int rate_num = -1;431432switch(rate) {433case MGN_1M:434rate_num = 0;435break;436case MGN_2M:437rate_num = 1;438break;439case MGN_5_5M:440rate_num = 2;441break;442case MGN_11M:443rate_num = 3;444break;445case MGN_6M:446rate_num = 0;447break;448case MGN_9M:449rate_num = 1;450break;451case MGN_12M:452rate_num = 2;453break;454case MGN_18M:455rate_num = 3;456break;457case MGN_24M:458rate_num = 4;459break;460case MGN_36M:461rate_num = 5;462break;463case MGN_48M:464rate_num = 6;465break;466case MGN_54M:467rate_num = 7;468break;469case MGN_MCS0:470case MGN_MCS8:471case MGN_MCS16:472case MGN_MCS24:473case MGN_MCS32:474rate_num = 0;475break;476case MGN_MCS1:477case MGN_MCS9:478case MGN_MCS17:479case MGN_MCS25:480rate_num = 1;481break;482case MGN_MCS2:483case MGN_MCS10:484case MGN_MCS18:485case MGN_MCS26:486rate_num = 2;487break;488case MGN_MCS3:489case MGN_MCS11:490case MGN_MCS19:491case MGN_MCS27:492rate_num = 3;493break;494case MGN_MCS4:495case MGN_MCS12:496case MGN_MCS20:497case MGN_MCS28:498rate_num = 4;499break;500case MGN_MCS5:501case MGN_MCS13:502case MGN_MCS21:503case MGN_MCS29:504rate_num = 5;505break;506case MGN_MCS6:507case MGN_MCS14:508case MGN_MCS22:509case MGN_MCS30:510rate_num = 6;511break;512case MGN_MCS7:513case MGN_MCS15:514case MGN_MCS23:515case MGN_MCS31:516rate_num = 7;517break;518case MGN_VHT1SS_MCS0:519case MGN_VHT2SS_MCS0:520case MGN_VHT3SS_MCS0:521case MGN_VHT4SS_MCS0:522rate_num = 0;523break;524case MGN_VHT1SS_MCS1:525case MGN_VHT2SS_MCS1:526case MGN_VHT3SS_MCS1:527case MGN_VHT4SS_MCS1:528rate_num = 1;529break;530case MGN_VHT1SS_MCS2:531case MGN_VHT2SS_MCS2:532case MGN_VHT3SS_MCS2:533case MGN_VHT4SS_MCS2:534rate_num = 2;535break;536case MGN_VHT1SS_MCS3:537case MGN_VHT2SS_MCS3:538case MGN_VHT3SS_MCS3:539case MGN_VHT4SS_MCS3:540rate_num = 3;541break;542case MGN_VHT1SS_MCS4:543case MGN_VHT2SS_MCS4:544case MGN_VHT3SS_MCS4:545case MGN_VHT4SS_MCS4:546rate_num = 4;547break;548case MGN_VHT1SS_MCS5:549case MGN_VHT2SS_MCS5:550case MGN_VHT3SS_MCS5:551case MGN_VHT4SS_MCS5:552rate_num = 5;553break;554case MGN_VHT1SS_MCS6:555case MGN_VHT2SS_MCS6:556case MGN_VHT3SS_MCS6:557case MGN_VHT4SS_MCS6:558rate_num = 6;559break;560case MGN_VHT1SS_MCS7:561case MGN_VHT2SS_MCS7:562case MGN_VHT3SS_MCS7:563case MGN_VHT4SS_MCS7:564rate_num = 7;565break;566case MGN_VHT1SS_MCS8:567case MGN_VHT2SS_MCS8:568case MGN_VHT3SS_MCS8:569case MGN_VHT4SS_MCS8:570rate_num = 8;571break;572case MGN_VHT1SS_MCS9:573case MGN_VHT2SS_MCS9:574case MGN_VHT3SS_MCS9:575case MGN_VHT4SS_MCS9:576rate_num = 9;577break;578default:579break;580581}582return rate_num;583}584585/* output: pwr (unit dBm) */586int rm_get_tx_power(PADAPTER adapter, enum rf_path path, enum MGN_RATE rate, s8 *pwr)587{588struct hal_spec_t *hal_spec = GET_HAL_SPEC(adapter);589HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);590int tx_num, band, bw, ch, n, rs;591u8 base;592s8 limt_offset = 127; /* max value of s8 */593s8 rate_offset;594s8 powr_offset;595int rate_pos;596597598band = hal_data->current_band_type;599bw = hal_data->current_channel_bw;600ch = hal_data->current_channel;601602if (!HAL_SPEC_CHK_RF_PATH(hal_spec, band, path))603return -1;604605if (HAL_IsLegalChannel(adapter, ch) == _FALSE) {606RTW_INFO("Illegal channel!!\n");607return -2;608}609610/* find rs by rate */611if (IS_CCK_RATE(rate))612rs = CCK;613else if (IS_OFDM_RATE(rate))614rs = OFDM;615else if (IS_HT1SS_RATE(rate))616rs = HT_1SS;617else if (IS_HT2SS_RATE(rate))618rs = HT_2SS;619else if (IS_HT3SS_RATE(rate))620rs = HT_3SS;621else if (IS_HT4SS_RATE(rate))622rs = HT_4SS;623else if (IS_VHT1SS_RATE(rate))624rs = VHT_1SS;625else if (IS_VHT2SS_RATE(rate))626rs = VHT_2SS;627else if (IS_VHT3SS_RATE(rate))628rs = VHT_3SS;629else if (IS_VHT4SS_RATE(rate))630rs = VHT_4SS;631else632return -3;633634tx_num = rate_section_to_tx_num(rs);635636if (tx_num >= hal_spec->tx_nss_num)637return -4;638639if (band == BAND_ON_5G && IS_CCK_RATE_SECTION(rs))640return -5;641642if (IS_VHT_RATE_SECTION(rs) && !IS_HARDWARE_TYPE_JAGUAR_ALL(adapter))643return -6;644645base = PHY_GetTxPowerByRateBase(adapter, band, path, rs);646647/* get power by rate in db */648rate_pos = get_rate_index(rate);649if (rate_pos < 0)650return -7;651652rate_offset = PHY_GetTxPowerByRate(adapter, band, path,653rates_by_sections[rs].rates[rate_pos]);654#ifdef CONFIG_TXPWR_LIMIT655limt_offset = PHY_GetTxPowerLimit(adapter, NULL, band, bw,656path, rates_by_sections[rs].rates[rate_pos], RF_1TX, ch);657#endif658powr_offset = MIN(rate_offset, limt_offset);659660*pwr = (base + powr_offset) / hal_spec->txgi_pdbm;661#if (RM_MORE_DBG_MSG)662RTW_INFO("RM: [%s][path_%c] %s base=%d offset=min(%d|%d)=%d (%d,%d)\n",663band_str(band), rf_path_char(path),664MGN_RATE_STR(rate),base, rate_offset, limt_offset,665powr_offset, ((base + rate_offset) / hal_spec->txgi_pdbm), *pwr);666#endif667return 0;668}669670int rm_get_rx_sensitivity(PADAPTER adapter, enum channel_width bw, enum MGN_RATE rate, s8 *pwr)671{672s8 rx_sensitivity = -110;673674switch(rate) {675case MGN_1M:676rx_sensitivity= -101;677break;678case MGN_2M:679rx_sensitivity= -98;680break;681case MGN_5_5M:682rx_sensitivity= -92;683break;684case MGN_11M:685rx_sensitivity= -89;686break;687case MGN_6M:688case MGN_9M:689case MGN_12M:690rx_sensitivity = -92;691break;692case MGN_18M:693rx_sensitivity = -90;694break;695case MGN_24M:696rx_sensitivity = -88;697break;698case MGN_36M:699rx_sensitivity = -84;700break;701case MGN_48M:702rx_sensitivity = -79;703break;704case MGN_54M:705rx_sensitivity = -78;706break;707708case MGN_MCS0:709case MGN_MCS8:710case MGN_MCS16:711case MGN_MCS24:712case MGN_VHT1SS_MCS0:713case MGN_VHT2SS_MCS0:714case MGN_VHT3SS_MCS0:715case MGN_VHT4SS_MCS0:716/* BW20 BPSK 1/2 */717rx_sensitivity = -82;718break;719720case MGN_MCS1:721case MGN_MCS9:722case MGN_MCS17:723case MGN_MCS25:724case MGN_VHT1SS_MCS1:725case MGN_VHT2SS_MCS1:726case MGN_VHT3SS_MCS1:727case MGN_VHT4SS_MCS1:728/* BW20 QPSK 1/2 */729rx_sensitivity = -79;730break;731732case MGN_MCS2:733case MGN_MCS10:734case MGN_MCS18:735case MGN_MCS26:736case MGN_VHT1SS_MCS2:737case MGN_VHT2SS_MCS2:738case MGN_VHT3SS_MCS2:739case MGN_VHT4SS_MCS2:740/* BW20 QPSK 3/4 */741rx_sensitivity = -77;742break;743744case MGN_MCS3:745case MGN_MCS11:746case MGN_MCS19:747case MGN_MCS27:748case MGN_VHT1SS_MCS3:749case MGN_VHT2SS_MCS3:750case MGN_VHT3SS_MCS3:751case MGN_VHT4SS_MCS3:752/* BW20 16-QAM 1/2 */753rx_sensitivity = -74;754break;755756case MGN_MCS4:757case MGN_MCS12:758case MGN_MCS20:759case MGN_MCS28:760case MGN_VHT1SS_MCS4:761case MGN_VHT2SS_MCS4:762case MGN_VHT3SS_MCS4:763case MGN_VHT4SS_MCS4:764/* BW20 16-QAM 3/4 */765rx_sensitivity = -70;766break;767768case MGN_MCS5:769case MGN_MCS13:770case MGN_MCS21:771case MGN_MCS29:772case MGN_VHT1SS_MCS5:773case MGN_VHT2SS_MCS5:774case MGN_VHT3SS_MCS5:775case MGN_VHT4SS_MCS5:776/* BW20 64-QAM 2/3 */777rx_sensitivity = -66;778break;779780case MGN_MCS6:781case MGN_MCS14:782case MGN_MCS22:783case MGN_MCS30:784case MGN_VHT1SS_MCS6:785case MGN_VHT2SS_MCS6:786case MGN_VHT3SS_MCS6:787case MGN_VHT4SS_MCS6:788/* BW20 64-QAM 3/4 */789rx_sensitivity = -65;790break;791792case MGN_MCS7:793case MGN_MCS15:794case MGN_MCS23:795case MGN_MCS31:796case MGN_VHT1SS_MCS7:797case MGN_VHT2SS_MCS7:798case MGN_VHT3SS_MCS7:799case MGN_VHT4SS_MCS7:800/* BW20 64-QAM 5/6 */801rx_sensitivity = -64;802break;803804case MGN_VHT1SS_MCS8:805case MGN_VHT2SS_MCS8:806case MGN_VHT3SS_MCS8:807case MGN_VHT4SS_MCS8:808/* BW20 256-QAM 3/4 */809rx_sensitivity = -59;810break;811812case MGN_VHT1SS_MCS9:813case MGN_VHT2SS_MCS9:814case MGN_VHT3SS_MCS9:815case MGN_VHT4SS_MCS9:816/* BW20 256-QAM 5/6 */817rx_sensitivity = -57;818break;819820default:821return -1;822break;823824}825826switch(bw) {827case CHANNEL_WIDTH_20:828break;829case CHANNEL_WIDTH_40:830rx_sensitivity -= 3;831break;832case CHANNEL_WIDTH_80:833rx_sensitivity -= 6;834break;835case CHANNEL_WIDTH_160:836rx_sensitivity -= 9;837break;838case CHANNEL_WIDTH_5:839case CHANNEL_WIDTH_10:840case CHANNEL_WIDTH_80_80:841default:842return -1;843break;844}845*pwr = rx_sensitivity;846847return 0;848}849850/* output: path_a max tx power in dBm */851int rm_get_path_a_max_tx_power(_adapter *adapter, s8 *path_a)852{853struct hal_spec_t *hal_spec = GET_HAL_SPEC(adapter);854HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter);855int path, tx_num, band, bw, ch, n, rs;856u8 rate_num, base;857s8 limt_offset = 127; /* max value of s8 */858s8 rate_offset;859s8 powr_offset;860s8 max_pwr[RF_PATH_MAX], pwr;861862863band = hal_data->current_band_type;864bw = hal_data->current_channel_bw;865ch = hal_data->current_channel;866867for (path = 0; path < RF_PATH_MAX; path++) {868if (!HAL_SPEC_CHK_RF_PATH(hal_spec, band, path))869break;870871max_pwr[path] = -127; /* min value of s8 */872#if (RM_MORE_DBG_MSG)873RTW_INFO("RM: [%s][%c]\n", band_str(band), rf_path_char(path));874#endif875for (rs = 0; rs < RATE_SECTION_NUM; rs++) {876tx_num = rate_section_to_tx_num(rs);877878if (tx_num >= hal_spec->tx_nss_num)879continue;880881if (band == BAND_ON_5G && IS_CCK_RATE_SECTION(rs))882continue;883884if (IS_VHT_RATE_SECTION(rs) && !IS_HARDWARE_TYPE_JAGUAR_ALL(adapter))885continue;886887rate_num = rate_section_rate_num(rs);888base = PHY_GetTxPowerByRateBase(adapter, band, path, rs);889890/* get power by rate in db */891for (n = rate_num - 1; n >= 0; n--) {892rate_offset = PHY_GetTxPowerByRate(adapter, band,893path, rates_by_sections[rs].rates[n]);894#ifdef CONFIG_TXPWR_LIMIT895limt_offset = PHY_GetTxPowerLimit(adapter, NULL, band, bw,896path, rates_by_sections[rs].rates[n], RF_1TX, ch);897#endif898powr_offset = MIN(rate_offset, limt_offset);899pwr = (base + powr_offset) / hal_spec->txgi_pdbm;900max_pwr[path] = MAX(max_pwr[path], pwr);901#if (RM_MORE_DBG_MSG)902RTW_INFO("RM: %2d base=%7s(%2d), min(%2d|%2d)=%2d; (%2d,%2d)\n",903n, rate_section_str(rs), base,904rate_offset, limt_offset, powr_offset,905((base + rate_offset) / hal_spec->txgi_pdbm), pwr);906#endif907}908}909}910#if (RM_MORE_DBG_MSG)911RTW_INFO("RM: path_a max_pwr=%ddBm\n", max_pwr[0]);912#endif913*path_a = max_pwr[0];914return 0;915}916917#endif /* CONFIG_RTW_80211K */918919920