12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774 |
- /*
- * Copyright (c) 2011,2017-2021 The Linux Foundation. All rights reserved.
- *
- *
- * Permission to use, copy, modify, and/or distribute this software for
- * any purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all
- * copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
- * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
- #ifndef _TARGET_IF_SPECTRAL_H_
- #define _TARGET_IF_SPECTRAL_H_
- #include <wlan_objmgr_cmn.h>
- #include <wlan_objmgr_psoc_obj.h>
- #include <wlan_objmgr_pdev_obj.h>
- #include <wlan_objmgr_vdev_obj.h>
- #include <wlan_reg_services_api.h>
- #include <qdf_lock.h>
- #include <wlan_spectral_public_structs.h>
- #include <reg_services_public_struct.h>
- #ifdef DIRECT_BUF_RX_ENABLE
- #include <target_if_direct_buf_rx_api.h>
- #endif
- #ifdef WIN32
- #pragma pack(push, target_if_spectral, 1)
- #define __ATTRIB_PACK
- #else
- #ifndef __ATTRIB_PACK
- #define __ATTRIB_PACK __attribute__ ((packed))
- #endif
- #endif
- #include <spectral_defs_i.h>
- #include <wmi_unified_param.h>
- #define FREQ_OFFSET_10MHZ (10)
- #define FREQ_OFFSET_40MHZ (40)
- #define FREQ_OFFSET_80MHZ (80)
- #ifndef SPECTRAL_USE_NL_BCAST
- #define SPECTRAL_USE_NL_BCAST (0)
- #endif
- #define STATUS_PASS 1
- #define STATUS_FAIL 0
- #undef spectral_dbg_line
- #define spectral_dbg_line() \
- spectral_debug("----------------------------------------------------")
- #undef spectral_ops_not_registered
- #define spectral_ops_not_registered(str) \
- spectral_info("SPECTRAL : %s not registered\n", (str))
- #undef not_yet_implemented
- #define not_yet_implemented() \
- spectral_info("SPECTRAL : %s : %d Not yet implemented\n", \
- __func__, __LINE__)
- #define SPECTRAL_HT20_NUM_BINS 56
- #define SPECTRAL_HT20_FFT_LEN 56
- #define SPECTRAL_HT20_DC_INDEX (SPECTRAL_HT20_FFT_LEN / 2)
- #define SPECTRAL_HT20_DATA_LEN 60
- #define SPECTRAL_HT20_TOTAL_DATA_LEN (SPECTRAL_HT20_DATA_LEN + 3)
- #define SPECTRAL_HT40_TOTAL_NUM_BINS 128
- #define SPECTRAL_HT40_DATA_LEN 135
- #define SPECTRAL_HT40_TOTAL_DATA_LEN (SPECTRAL_HT40_DATA_LEN + 3)
- #define SPECTRAL_HT40_FFT_LEN 128
- #define SPECTRAL_HT40_DC_INDEX (SPECTRAL_HT40_FFT_LEN / 2)
- /*
- * Used for the SWAR to obtain approximate combined rssi
- * in secondary 80Mhz segment
- */
- #define OFFSET_CH_WIDTH_20 65
- #define OFFSET_CH_WIDTH_40 62
- #define OFFSET_CH_WIDTH_80 56
- #define OFFSET_CH_WIDTH_160 50
- /* Min and max for relevant Spectral params */
- #define SPECTRAL_PARAM_FFT_SIZE_MIN_GEN2 (1)
- #define SPECTRAL_PARAM_FFT_SIZE_MAX_GEN2 (9)
- #define SPECTRAL_PARAM_FFT_SIZE_MIN_GEN3 (5)
- #define SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_DEFAULT (9)
- #define SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_QCN9000 (10)
- #define SPECTRAL_PARAM_RPT_MODE_MIN (0)
- #define SPECTRAL_PARAM_RPT_MODE_MAX (3)
- #define MAX_FFTBIN_VALUE (255)
- /* DBR ring debug size for Spectral */
- #define SPECTRAL_DBR_RING_DEBUG_SIZE 512
- #ifdef BIG_ENDIAN_HOST
- #define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) do { \
- int j; \
- uint32_t *src, *dest; \
- src = (uint32_t *)(srcp); \
- dest = (uint32_t *)(destp); \
- for (j = 0; j < roundup((len), sizeof(uint32_t)) / 4; j++) { \
- *(dest + j) = qdf_le32_to_cpu(*(src + j)); \
- } \
- } while (0)
- #else
- #define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) \
- OS_MEMCPY((destp), (srcp), (len));
- #endif
- #define DUMMY_NF_VALUE (-123)
- /* 5 categories x (lower + upper) bands */
- #define MAX_INTERF 10
- #define HOST_MAX_ANTENNA 3
- /* Mask for time stamp from descriptor */
- #define SPECTRAL_TSMASK 0xFFFFFFFF
- #define SPECTRAL_SIGNATURE 0xdeadbeef
- /* Signature to write onto spectral buffer and then later validate */
- #define MEM_POISON_SIGNATURE (htobe32(0xdeadbeef))
- /* START of spectral GEN II HW specific details */
- #define SPECTRAL_PHYERR_SIGNATURE_GEN2 0xbb
- #define TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN2 0xF9
- #define TLV_TAG_ADC_REPORT_GEN2 0xFA
- #define TLV_TAG_SEARCH_FFT_REPORT_GEN2 0xFB
- /**
- * The Maximum number of detector informations to be filled in the SAMP msg
- * is 3, only for 165MHz case. For all other cases this value will be 1.
- */
- #define MAX_NUM_DEST_DETECTOR_INFO (3)
- #define MAX_DETECTORS_PER_PDEV (3)
- #define FFT_BIN_SIZE_1BYTE (1)
- #ifdef OPTIMIZED_SAMP_MESSAGE
- /**
- * enum spectral_160mhz_report_delivery_state - 160 MHz state machine states
- * @SPECTRAL_REPORT_WAIT_PRIMARY80: Wait for primary80 report
- * @SPECTRAL_REPORT_WAIT_SECONDARY80: Wait for secondory 80 report
- */
- enum spectral_160mhz_report_delivery_state {
- SPECTRAL_REPORT_WAIT_PRIMARY80,
- SPECTRAL_REPORT_WAIT_SECONDARY80,
- };
- #else
- /**
- * enum spectral_160mhz_report_delivery_state - 160 MHz state machine states
- * @SPECTRAL_REPORT_WAIT_PRIMARY80: Wait for primary80 report
- * @SPECTRAL_REPORT_RX_PRIMARY80: Receive primary 80 report
- * @SPECTRAL_REPORT_WAIT_SECONDARY80: Wait for secondory 80 report
- * @SPECTRAL_REPORT_RX_SECONDARY80: Receive secondary 80 report
- */
- enum spectral_160mhz_report_delivery_state {
- SPECTRAL_REPORT_WAIT_PRIMARY80,
- SPECTRAL_REPORT_RX_PRIMARY80,
- SPECTRAL_REPORT_WAIT_SECONDARY80,
- SPECTRAL_REPORT_RX_SECONDARY80,
- };
- #endif /* OPTIMIZED_SAMP_MESSAGE */
- /**
- * enum spectral_freq_span_id - Spectral frequency span id
- * @SPECTRAL_FREQ_SPAN_ID_0: Frequency span 0
- * @SPECTRAL_FREQ_SPAN_ID_1: Frequency span 1
- * @SPECTRAL_FREQ_SPAN_ID_2: Frequency span 2
- */
- enum spectral_freq_span_id {
- SPECTRAL_FREQ_SPAN_ID_0,
- SPECTRAL_FREQ_SPAN_ID_1,
- SPECTRAL_FREQ_SPAN_ID_2,
- };
- /**
- * enum spectral_detector_id - Spectral detector id
- * @SPECTRAL_DETECTOR_ID_0: Spectral detector 0
- * @SPECTRAL_DETECTOR_ID_1: Spectral detector 1
- * @SPECTRAL_DETECTOR_ID_2: Spectral detector 2
- * @SPECTRAL_DETECTOR_ID_MAX: Max Spectral detector ID
- * @SPECTRAL_DETECTOR_ID_INVALID: Invalid Spectral detector ID
- */
- enum spectral_detector_id {
- SPECTRAL_DETECTOR_ID_0,
- SPECTRAL_DETECTOR_ID_1,
- SPECTRAL_DETECTOR_ID_2,
- SPECTRAL_DETECTOR_ID_MAX,
- SPECTRAL_DETECTOR_ID_INVALID = 0xff,
- };
- /**
- * struct spectral_search_fft_info_gen2 - spectral search fft report for gen2
- * @relpwr_db: Total bin power in db
- * @num_str_bins_ib: Number of strong bins
- * @base_pwr: Base power
- * @total_gain_info: Total gain
- * @fft_chn_idx: FFT chain on which report is originated
- * @avgpwr_db: Average power in db
- * @peak_mag: Peak power seen in the bins
- * @peak_inx: Index of bin holding peak power
- */
- struct spectral_search_fft_info_gen2 {
- uint32_t relpwr_db;
- uint32_t num_str_bins_ib;
- uint32_t base_pwr;
- uint32_t total_gain_info;
- uint32_t fft_chn_idx;
- uint32_t avgpwr_db;
- uint32_t peak_mag;
- int16_t peak_inx;
- };
- /*
- * XXX Check if we should be handling the endinness difference in some
- * other way opaque to the host
- */
- #ifdef BIG_ENDIAN_HOST
- /**
- * struct spectral_phyerr_tlv_gen2 - phyerr tlv info for big endian host
- * @signature: signature
- * @tag: tag
- * @length: length
- */
- struct spectral_phyerr_tlv_gen2 {
- uint8_t signature;
- uint8_t tag;
- uint16_t length;
- } __ATTRIB_PACK;
- #else
- /**
- * struct spectral_phyerr_tlv_gen2 - phyerr tlv info for little endian host
- * @length: length
- * @tag: tag
- * @signature: signature
- */
- struct spectral_phyerr_tlv_gen2 {
- uint16_t length;
- uint8_t tag;
- uint8_t signature;
- } __ATTRIB_PACK;
- #endif /* BIG_ENDIAN_HOST */
- /**
- * struct spectral_phyerr_hdr_gen2 - phyerr header for gen2 HW
- * @hdr_a: Header[0:31]
- * @hdr_b: Header[32:63]
- */
- struct spectral_phyerr_hdr_gen2 {
- uint32_t hdr_a;
- uint32_t hdr_b;
- };
- /*
- * Segment ID information for 80+80.
- *
- * If the HW micro-architecture specification extends this DWORD for other
- * purposes, then redefine+rename accordingly. For now, the specification
- * mentions only segment ID (though this doesn't require an entire DWORD)
- * without mention of any generic terminology for the DWORD, or any reservation.
- * We use nomenclature accordingly.
- */
- typedef uint32_t SPECTRAL_SEGID_INFO;
- /**
- * struct spectral_phyerr_fft_gen2 - fft info in phyerr event
- * @buf: fft report
- */
- struct spectral_phyerr_fft_gen2 {
- uint8_t buf[0];
- };
- /**
- * struct spectral_process_phyerr_info_gen2 - Processed phyerr info structures
- * needed to fill SAMP params for gen2
- * @p_rfqual: Pointer to RF quality info
- * @p_sfft: Pointer to Search fft report info
- * @pfft: Pointer to FFT info in Phyerr event
- * @acs_stats: Pointer to ACS stats struct
- * @tsf64: 64 bit TSF value
- * @seg_d : Segment ID
- */
- struct spectral_process_phyerr_info_gen2 {
- struct target_if_spectral_rfqual_info *p_rfqual;
- struct spectral_search_fft_info_gen2 *p_sfft;
- struct spectral_phyerr_fft_gen2 *pfft;
- struct target_if_spectral_acs_stats *acs_stats;
- uint64_t tsf64;
- uint8_t seg_id;
- };
- /* END of spectral GEN II HW specific details */
- /* START of spectral GEN III HW specific details */
- #define get_bitfield(value, size, pos) \
- (((value) >> (pos)) & ((1 << (size)) - 1))
- #define unsigned_to_signed(value, width) \
- (((value) >= (1 << ((width) - 1))) ? \
- (value - (1 << (width))) : (value))
- #define SSCAN_SUMMARY_REPORT_HDR_A_DETECTOR_ID_POS_GEN3 (29)
- #define SSCAN_SUMMARY_REPORT_HDR_A_DETECTOR_ID_SIZE_GEN3 (2)
- #define SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_POS_GEN3 (0)
- #define SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_SIZE_GEN3 (8)
- #define SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_POS_GEN3 (18)
- #define SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_SIZE_GEN3 (10)
- #define SSCAN_SUMMARY_REPORT_HDR_A_PRI80_POS_GEN3 (31)
- #define SSCAN_SUMMARY_REPORT_HDR_A_PRI80_SIZE_GEN3 (1)
- #define SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_POS_GEN3_V1 (30)
- #define SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_SIZE_GEN3_V1 (1)
- #define SSCAN_SUMMARY_REPORT_HDR_C_GAINCHANGE_POS_GEN3_V2 (16)
- #define SSCAN_SUMMARY_REPORT_HDR_C_GAINCHANGE_SIZE_GEN3_V2 (1)
- #define SPECTRAL_REPORT_LTS_HDR_LENGTH_POS_GEN3 (0)
- #define SPECTRAL_REPORT_LTS_HDR_LENGTH_SIZE_GEN3 (16)
- #define SPECTRAL_REPORT_LTS_TAG_POS_GEN3 (16)
- #define SPECTRAL_REPORT_LTS_TAG_SIZE_GEN3 (8)
- #define SPECTRAL_REPORT_LTS_SIGNATURE_POS_GEN3 (24)
- #define SPECTRAL_REPORT_LTS_SIGNATURE_SIZE_GEN3 (8)
- #define FFT_REPORT_HDR_A_DETECTOR_ID_POS_GEN3 (0)
- #define FFT_REPORT_HDR_A_DETECTOR_ID_SIZE_GEN3 (2)
- #define FFT_REPORT_HDR_A_FFT_NUM_POS_GEN3 (2)
- #define FFT_REPORT_HDR_A_FFT_NUM_SIZE_GEN3 (3)
- #define FFT_REPORT_HDR_A_RADAR_CHECK_POS_GEN3_V1 (5)
- #define FFT_REPORT_HDR_A_RADAR_CHECK_SIZE_GEN3_V1 (12)
- #define FFT_REPORT_HDR_A_RADAR_CHECK_POS_GEN3_V2 (5)
- #define FFT_REPORT_HDR_A_RADAR_CHECK_SIZE_GEN3_V2 (14)
- #define FFT_REPORT_HDR_A_PEAK_INDEX_POS_GEN3_V1 (17)
- #define FFT_REPORT_HDR_A_PEAK_INDEX_SIZE_GEN3_V1 (11)
- #define FFT_REPORT_HDR_A_PEAK_INDEX_POS_GEN3_V2 (19)
- #define FFT_REPORT_HDR_A_PEAK_INDEX_SIZE_GEN3_V2 (11)
- #define FFT_REPORT_HDR_A_CHAIN_INDEX_POS_GEN3_V1 (28)
- #define FFT_REPORT_HDR_A_CHAIN_INDEX_SIZE_GEN3_V1 (3)
- #define FFT_REPORT_HDR_B_CHAIN_INDEX_POS_GEN3_V2 (0)
- #define FFT_REPORT_HDR_B_CHAIN_INDEX_SIZE_GEN3_V2 (3)
- #define FFT_REPORT_HDR_B_BASE_PWR_POS_GEN3_V1 (0)
- #define FFT_REPORT_HDR_B_BASE_PWR_SIZE_GEN3_V1 (9)
- #define FFT_REPORT_HDR_B_BASE_PWR_POS_GEN3_V2 (3)
- #define FFT_REPORT_HDR_B_BASE_PWR_SIZE_GEN3_V2 (9)
- #define FFT_REPORT_HDR_B_TOTAL_GAIN_POS_GEN3_V1 (9)
- #define FFT_REPORT_HDR_B_TOTAL_GAIN_SIZE_GEN3_V1 (8)
- #define FFT_REPORT_HDR_B_TOTAL_GAIN_POS_GEN3_V2 (12)
- #define FFT_REPORT_HDR_B_TOTAL_GAIN_SIZE_GEN3_V2 (8)
- #define FFT_REPORT_HDR_C_NUM_STRONG_BINS_POS_GEN3 (0)
- #define FFT_REPORT_HDR_C_NUM_STRONG_BINS_SIZE_GEN3 (8)
- #define FFT_REPORT_HDR_C_PEAK_MAGNITUDE_POS_GEN3 (8)
- #define FFT_REPORT_HDR_C_PEAK_MAGNITUDE_SIZE_GEN3 (10)
- #define FFT_REPORT_HDR_C_AVG_PWR_POS_GEN3 (18)
- #define FFT_REPORT_HDR_C_AVG_PWR_SIZE_GEN3 (7)
- #define FFT_REPORT_HDR_C_RELATIVE_PWR_POS_GEN3 (25)
- #define FFT_REPORT_HDR_C_RELATIVE_PWR_SIZE_GEN3 (7)
- #define SPECTRAL_PHYERR_SIGNATURE_GEN3 (0xFA)
- #define TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3 (0x02)
- #define TLV_TAG_SEARCH_FFT_REPORT_GEN3 (0x03)
- #define SPECTRAL_PHYERR_TLVSIZE_GEN3 (4)
- #define NUM_SPECTRAL_DETECTORS_GEN3_V1 (3)
- #define NUM_SPECTRAL_DETECTORS_GEN3_V2 (2)
- #define FFT_REPORT_HEADER_LENGTH_GEN3_V2 (24)
- #define FFT_REPORT_HEADER_LENGTH_GEN3_V1 (16)
- #define NUM_PADDING_BYTES_SSCAN_SUMARY_REPORT_GEN3_V1 (0)
- #define NUM_PADDING_BYTES_SSCAN_SUMARY_REPORT_GEN3_V2 (16)
- #define SPECTRAL_PHYERR_HDR_LTS_POS \
- (offsetof(struct spectral_phyerr_fft_report_gen3, fft_hdr_lts))
- #define SPECTRAL_FFT_BINS_POS \
- (offsetof(struct spectral_phyerr_fft_report_gen3, buf))
- /**
- * struct phyerr_info - spectral search fft report for gen3
- * @data: handle to phyerror buffer
- * @datalen: length of phyerror bufer
- * @p_rfqual: rf quality matrices
- * @p_chaninfo: pointer to chaninfo
- * @tsf64: 64 bit TSF
- * @acs_stats: acs stats
- */
- struct phyerr_info {
- uint8_t *data;
- uint32_t datalen;
- struct target_if_spectral_rfqual_info *p_rfqual;
- struct target_if_spectral_chan_info *p_chaninfo;
- uint64_t tsf64;
- struct target_if_spectral_acs_stats *acs_stats;
- };
- /**
- * struct spectral_search_fft_info_gen3 - spectral search fft report for gen3
- * @timestamp: Timestamp at which fft report was generated
- * @last_raw_timestamp: Previous FFT report's raw timestamp
- * @adjusted_timestamp: Adjusted timestamp to account for target reset
- * @fft_detector_id: Which radio generated this report
- * @fft_num: The FFT count number. Set to 0 for short FFT.
- * @fft_radar_check: NA for spectral
- * @fft_peak_sidx: Index of bin with maximum power
- * @fft_chn_idx: Rx chain index
- * @fft_base_pwr_db: Base power in dB
- * @fft_total_gain_db: Total gain in dB
- * @fft_num_str_bins_ib: Number of strong bins in the report
- * @fft_peak_mag: Peak magnitude
- * @fft_avgpwr_db: Average power in dB
- * @fft_relpwr_db: Relative power in dB
- * @fft_bin_count: Number of FFT bins in the FFT report
- * @fft_bin_size: Size of one FFT bin in bytes
- * @bin_pwr_data: Contains FFT bins extracted from the report
- */
- struct spectral_search_fft_info_gen3 {
- uint32_t timestamp;
- uint32_t last_raw_timestamp;
- uint32_t adjusted_timestamp;
- uint32_t fft_detector_id;
- uint32_t fft_num;
- uint32_t fft_radar_check;
- int32_t fft_peak_sidx;
- uint32_t fft_chn_idx;
- uint32_t fft_base_pwr_db;
- uint32_t fft_total_gain_db;
- uint32_t fft_num_str_bins_ib;
- int32_t fft_peak_mag;
- uint32_t fft_avgpwr_db;
- uint32_t fft_relpwr_db;
- uint32_t fft_bin_count;
- uint8_t fft_bin_size;
- uint8_t *bin_pwr_data;
- };
- /**
- * struct spectral_phyerr_sfftreport_gen3 - fft info in phyerr event
- * @fft_timestamp: Timestamp at which fft report was generated
- * @fft_hdr_lts: length, tag, signature fields
- * @hdr_a: Header[0:31]
- * @hdr_b: Header[32:63]
- * @hdr_c: Header[64:95]
- * @resv: Header[96:127]
- * @buf: fft bins
- */
- struct spectral_phyerr_fft_report_gen3 {
- uint32_t fft_timestamp;
- uint32_t fft_hdr_lts;
- uint32_t hdr_a;
- uint32_t hdr_b;
- uint32_t hdr_c;
- uint32_t resv;
- uint8_t buf[0];
- } __ATTRIB_PACK;
- /**
- * struct sscan_report_fields_gen3 - Fields of spectral report
- * @sscan_agc_total_gain: The AGC total gain in DB.
- * @inband_pwr_db: The in-band power of the signal in 1/2 DB steps
- * @sscan_gainchange: This bit is set to 1 if a gainchange occurred during
- * the spectral scan FFT. Software may choose to
- * disregard the results.
- * @sscan_pri80: This is set to 1 to indicate that the Spectral scan was
- * performed on the pri80 segment. Software may choose to
- * disregard the FFT sample if this is set to 1 but detector ID
- * does not correspond to the ID for the pri80 segment.
- * @sscan_detector_id: Detector ID in Spectral scan report
- */
- struct sscan_report_fields_gen3 {
- uint8_t sscan_agc_total_gain;
- int16_t inband_pwr_db;
- uint8_t sscan_gainchange;
- uint8_t sscan_pri80;
- uint8_t sscan_detector_id;
- };
- /**
- * struct spectral_sscan_summary_report_gen3 - Spectral summary report
- * event
- * @sscan_timestamp: Timestamp at which fft report was generated
- * @sscan_hdr_lts: length, tag, signature fields
- * @hdr_a: Header[0:31]
- * @resv: Header[32:63]
- * @hdr_b: Header[64:95]
- * @hdr_c: Header[96:127]
- */
- struct spectral_sscan_summary_report_gen3 {
- u_int32_t sscan_timestamp;
- u_int32_t sscan_hdr_lts;
- u_int32_t hdr_a;
- u_int32_t res1;
- u_int32_t hdr_b;
- u_int32_t hdr_c;
- } __ATTRIB_PACK;
- #ifdef DIRECT_BUF_RX_ENABLE
- /**
- * struct Spectral_report - spectral report
- * @data: Report buffer
- * @noisefloor: Noise floor values
- * @reset_delay: Time taken for warm reset in us
- * @cfreq1: center frequency 1
- * @cfreq2: center frequency 2
- * @ch_width: channel width
- */
- struct spectral_report {
- uint8_t *data;
- int32_t noisefloor[DBR_MAX_CHAINS];
- uint32_t reset_delay;
- uint32_t cfreq1;
- uint32_t cfreq2;
- uint32_t ch_width;
- };
- #endif
- /* END of spectral GEN III HW specific details */
- typedef signed char pwr_dbm;
- /**
- * enum spectral_gen - spectral hw generation
- * @SPECTRAL_GEN1 : spectral hw gen 1
- * @SPECTRAL_GEN2 : spectral hw gen 2
- * @SPECTRAL_GEN3 : spectral hw gen 3
- */
- enum spectral_gen {
- SPECTRAL_GEN1,
- SPECTRAL_GEN2,
- SPECTRAL_GEN3,
- };
- /**
- * enum spectral_fftbin_size_war - spectral fft bin size war
- * @SPECTRAL_FFTBIN_SIZE_NO_WAR : No WAR applicable for Spectral FFT bin size
- * @SPECTRAL_FFTBIN_SIZE_2BYTE_TO_1BYTE : Spectral FFT bin size: Retain only
- * least significant byte from 2 byte
- * FFT bin transferred by HW
- * @SPECTRAL_FFTBIN_SIZE_4BYTE_TO_1BYTE : Spectral FFT bin size: Retain only
- * least significant byte from 4 byte
- * FFT bin transferred by HW
- */
- enum spectral_fftbin_size_war {
- SPECTRAL_FFTBIN_SIZE_NO_WAR = 0,
- SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE = 1,
- SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE = 2,
- };
- /**
- * enum spectral_report_format_version - This represents the report format
- * version number within each Spectral generation.
- * @SPECTRAL_REPORT_FORMAT_VERSION_1 : version 1
- * @SPECTRAL_REPORT_FORMAT_VERSION_2 : version 2
- */
- enum spectral_report_format_version {
- SPECTRAL_REPORT_FORMAT_VERSION_1,
- SPECTRAL_REPORT_FORMAT_VERSION_2,
- };
- /**
- * struct spectral_fft_bin_len_adj_swar - Encapsulate information required for
- * Spectral FFT bin length adjusting software WARS.
- * @inband_fftbin_size_adj: Whether to carry out FFT bin size adjustment for
- * in-band report format. This would be required on some chipsets under the
- * following circumstances: In report mode 2 only the in-band bins are DMA'ed.
- * Scatter/gather is used. However, the HW generates all bins, not just in-band,
- * and reports the number of bins accordingly. The subsystem arranging for the
- * DMA cannot change this value. On such chipsets the adjustment required at the
- * host driver is to check if report format is 2, and if so halve the number of
- * bins reported to get the number actually DMA'ed.
- * @null_fftbin_adj: Whether to remove NULL FFT bins for report mode (1) in
- * which only summary of metrics for each completed FFT + spectral scan summary
- * report are to be provided. This would be required on some chipsets under the
- * following circumstances: In report mode 1, HW reports a length corresponding
- * to all bins, and provides bins with value 0. This is because the subsystem
- * arranging for the FFT information does not arrange for DMA of FFT bin values
- * (as expected), but cannot arrange for a smaller length to be reported by HW.
- * In these circumstances, the driver would have to disregard the NULL bins and
- * report a bin count of 0 to higher layers.
- * @packmode_fftbin_size_adj: Pack mode in HW refers to packing of each Spectral
- * FFT bin into 2 bytes. But due to a bug HW reports 2 times the expected length
- * when packmode is enabled. This SWAR compensates this bug by dividing the
- * length with 2.
- * @fftbin_size_war: Type of FFT bin size SWAR
- */
- struct spectral_fft_bin_len_adj_swar {
- u_int8_t inband_fftbin_size_adj;
- u_int8_t null_fftbin_adj;
- uint8_t packmode_fftbin_size_adj;
- enum spectral_fftbin_size_war fftbin_size_war;
- };
- /**
- * struct spectral_report_params - Parameters related to format of Spectral
- * report.
- * @version: This represents the report format version number within each
- * Spectral generation.
- * @ssumaary_padding_bytes: Number of bytes of padding after Spectral summary
- * report
- * @fft_report_hdr_len: Number of bytes in the header of the FFT report. This
- * has to be subtracted from the length field of FFT report to find the length
- * of FFT bins.
- * @fragmentation_160: This indicates whether Spectral reports in 160/80p80 is
- * fragmented.
- * @max_agile_ch_width: Maximum agile BW supported by the target
- * @detid_mode_table: Detector ID to Spectral scan mode table
- * @num_spectral_detectors: Total number of Spectral detectors
- * @marker: Describes the boundaries of pri80, 5 MHz and sec80 bins
- */
- struct spectral_report_params {
- enum spectral_report_format_version version;
- uint8_t ssumaary_padding_bytes;
- uint8_t fft_report_hdr_len;
- bool fragmentation_160[SPECTRAL_SCAN_MODE_MAX];
- enum phy_ch_width max_agile_ch_width;
- enum spectral_scan_mode detid_mode_table[SPECTRAL_DETECTOR_ID_MAX];
- uint8_t num_spectral_detectors;
- struct spectral_fft_bin_markers_160_165mhz
- marker[SPECTRAL_SCAN_MODE_MAX];
- };
- /**
- * struct spectral_param_min_max - Spectral parameter minimum and maximum values
- * @fft_size_min: Minimum value of fft_size
- * @fft_size_max: Maximum value of fft_size for each BW
- */
- struct spectral_param_min_max {
- uint16_t fft_size_min;
- uint16_t fft_size_max[CH_WIDTH_MAX];
- };
- /**
- * struct spectral_timestamp_swar - Spectral time stamp WAR related parameters
- * @timestamp_war_offset: Offset to be added to correct timestamp
- * @target_reset_count: Number of times target exercised the reset routine
- * @last_fft_timestamp: last fft report timestamp
- */
- struct spectral_timestamp_war {
- uint32_t timestamp_war_offset[SPECTRAL_SCAN_MODE_MAX];
- uint64_t target_reset_count;
- uint32_t last_fft_timestamp[SPECTRAL_SCAN_MODE_MAX];
- };
- #if ATH_PERF_PWR_OFFLOAD
- /**
- * enum target_if_spectral_info - Enumerations for specifying which spectral
- * information (among parameters and states)
- * is desired.
- * @TARGET_IF_SPECTRAL_INFO_ACTIVE: Indicated whether spectral is active
- * @TARGET_IF_SPECTRAL_INFO_ENABLED: Indicated whether spectral is enabled
- * @TARGET_IF_SPECTRAL_INFO_PARAMS: Config params
- */
- enum target_if_spectral_info {
- TARGET_IF_SPECTRAL_INFO_ACTIVE,
- TARGET_IF_SPECTRAL_INFO_ENABLED,
- TARGET_IF_SPECTRAL_INFO_PARAMS,
- };
- #endif /* ATH_PERF_PWR_OFFLOAD */
- /* forward declaration */
- struct target_if_spectral;
- /**
- * struct target_if_spectral_chan_info - Channel information
- * @center_freq1: center frequency 1 in MHz
- * @center_freq2: center frequency 2 in MHz -valid only for
- * 11ACVHT 80PLUS80 mode
- * @chan_width: channel width in MHz
- */
- struct target_if_spectral_chan_info {
- uint16_t center_freq1;
- uint16_t center_freq2;
- uint8_t chan_width;
- };
- /**
- * struct target_if_spectral_acs_stats - EACS stats from spectral samples
- * @nfc_ctl_rssi: Control chan rssi
- * @nfc_ext_rssi: Extension chan rssi
- * @ctrl_nf: Control chan Noise Floor
- * @ext_nf: Extension chan Noise Floor
- */
- struct target_if_spectral_acs_stats {
- int8_t nfc_ctl_rssi;
- int8_t nfc_ext_rssi;
- int8_t ctrl_nf;
- int8_t ext_nf;
- };
- /**
- * struct target_if_spectral_perchain_rssi_info - per chain rssi info
- * @rssi_pri20: Rssi of primary 20 Mhz
- * @rssi_sec20: Rssi of secondary 20 Mhz
- * @rssi_sec40: Rssi of secondary 40 Mhz
- * @rssi_sec80: Rssi of secondary 80 Mhz
- */
- struct target_if_spectral_perchain_rssi_info {
- int8_t rssi_pri20;
- int8_t rssi_sec20;
- int8_t rssi_sec40;
- int8_t rssi_sec80;
- };
- /**
- * struct target_if_spectral_rfqual_info - RF measurement information
- * @rssi_comb: RSSI Information
- * @pc_rssi_info: XXX : For now, we know we are getting information
- * for only 4 chains at max. For future extensions
- * use a define
- * @noise_floor: Noise floor information
- */
- struct target_if_spectral_rfqual_info {
- int8_t rssi_comb;
- struct target_if_spectral_perchain_rssi_info pc_rssi_info[4];
- int16_t noise_floor[4];
- };
- #define GET_TARGET_IF_SPECTRAL_OPS(spectral) \
- ((struct target_if_spectral_ops *)(&((spectral)->spectral_ops)))
- /**
- * struct target_if_spectral_ops - spectral low level ops table
- * @get_tsf64: Get 64 bit TSF value
- * @get_capability: Get capability info
- * @set_rxfilter: Set rx filter
- * @get_rxfilter: Get rx filter
- * @is_spectral_active: Check whether icm is active
- * @is_spectral_enabled: Check whether spectral is enabled
- * @start_spectral_scan: Start spectral scan
- * @stop_spectral_scan: Stop spectral scan
- * @get_extension_channel: Get extension channel
- * @get_ctl_noisefloor: Get control noise floor
- * @get_ext_noisefloor: Get extension noise floor
- * @configure_spectral: Set spectral configurations
- * @get_spectral_config: Get spectral configurations
- * @get_ent_spectral_mask: Get spectral mask
- * @get_mac_address: Get mac address
- * @get_current_channel: Get current channel
- * @reset_hw: Reset HW
- * @get_chain_noise_floor: Get Channel noise floor
- * @spectral_process_phyerr: Process phyerr event
- * @process_spectral_report: Process spectral report
- * @byte_swap_headers: Apply byte-swap on report headers
- * @byte_swap_fft_bins: Apply byte-swap on FFT bins
- */
- struct target_if_spectral_ops {
- uint64_t (*get_tsf64)(void *arg);
- uint32_t (*get_capability)(
- void *arg, enum spectral_capability_type type);
- uint32_t (*set_rxfilter)(void *arg, int rxfilter);
- uint32_t (*get_rxfilter)(void *arg);
- uint32_t (*is_spectral_active)(void *arg,
- enum spectral_scan_mode smode);
- uint32_t (*is_spectral_enabled)(void *arg,
- enum spectral_scan_mode smode);
- uint32_t (*start_spectral_scan)(void *arg,
- enum spectral_scan_mode smode,
- enum spectral_cp_error_code *err);
- uint32_t (*stop_spectral_scan)(void *arg,
- enum spectral_scan_mode smode);
- uint32_t (*get_extension_channel)(void *arg,
- enum spectral_scan_mode smode);
- int8_t (*get_ctl_noisefloor)(void *arg);
- int8_t (*get_ext_noisefloor)(void *arg);
- uint32_t (*configure_spectral)(
- void *arg,
- struct spectral_config *params,
- enum spectral_scan_mode smode);
- uint32_t (*get_spectral_config)(
- void *arg,
- struct spectral_config *params,
- enum spectral_scan_mode smode);
- uint32_t (*get_ent_spectral_mask)(void *arg);
- uint32_t (*get_mac_address)(void *arg, char *addr);
- uint32_t (*get_current_channel)(void *arg,
- enum spectral_scan_mode smode);
- uint32_t (*reset_hw)(void *arg);
- uint32_t (*get_chain_noise_floor)(void *arg, int16_t *nf_buf);
- int (*spectral_process_phyerr)(struct target_if_spectral *spectral,
- uint8_t *data, uint32_t datalen,
- struct target_if_spectral_rfqual_info *p_rfqual,
- struct target_if_spectral_chan_info *p_chaninfo,
- uint64_t tsf64,
- struct target_if_spectral_acs_stats *acs_stats);
- int (*process_spectral_report)(struct wlan_objmgr_pdev *pdev,
- void *payload);
- QDF_STATUS (*byte_swap_headers)(
- struct target_if_spectral *spectral,
- void *data);
- QDF_STATUS (*byte_swap_fft_bins)(
- struct spectral_fft_bin_len_adj_swar *swar,
- void *bin_pwr_data, size_t num_fftbins);
- };
- /**
- * struct target_if_spectral_stats - spectral stats info
- * @num_spectral_detects: Total num. of spectral detects
- * @total_phy_errors: Total number of phyerrors
- * @owl_phy_errors: Indicated phyerrors in old gen1 chipsets
- * @pri_phy_errors: Phyerrors in primary channel
- * @ext_phy_errors: Phyerrors in secondary channel
- * @dc_phy_errors: Phyerrors due to dc
- * @early_ext_phy_errors: Early secondary channel phyerrors
- * @bwinfo_errors: Bandwidth info errors
- * @datalen_discards: Invalid data length errors, seen in gen1 chipsets
- * @rssi_discards bw: Indicates reports dropped due to RSSI threshold
- * @last_reset_tstamp: Last reset time stamp
- */
- struct target_if_spectral_stats {
- uint32_t num_spectral_detects;
- uint32_t total_phy_errors;
- uint32_t owl_phy_errors;
- uint32_t pri_phy_errors;
- uint32_t ext_phy_errors;
- uint32_t dc_phy_errors;
- uint32_t early_ext_phy_errors;
- uint32_t bwinfo_errors;
- uint32_t datalen_discards;
- uint32_t rssi_discards;
- uint64_t last_reset_tstamp;
- };
- /**
- * struct target_if_spectral_event - spectral event structure
- * @se_ts: Original 15 bit recv timestamp
- * @se_full_ts: 64-bit full timestamp from interrupt time
- * @se_rssi: Rssi of spectral event
- * @se_bwinfo: Rssi of spectral event
- * @se_dur: Duration of spectral pulse
- * @se_chanindex: Channel of event
- * @se_list: List of spectral events
- */
- struct target_if_spectral_event {
- uint32_t se_ts;
- uint64_t se_full_ts;
- uint8_t se_rssi;
- uint8_t se_bwinfo;
- uint8_t se_dur;
- uint8_t se_chanindex;
- STAILQ_ENTRY(spectral_event) se_list;
- };
- /**
- * struct target_if_chain_noise_pwr_info - Noise power info for each channel
- * @rptcount: Count of reports in pwr array
- * @un_cal_nf: Uncalibrated noise floor
- * @factory_cal_nf: Noise floor as calibrated at the factory for module
- * @median_pwr: Median power (median of pwr array)
- * @pwr: Power reports
- */
- struct target_if_chain_noise_pwr_info {
- int rptcount;
- pwr_dbm un_cal_nf;
- pwr_dbm factory_cal_nf;
- pwr_dbm median_pwr;
- pwr_dbm pwr[];
- } __ATTRIB_PACK;
- /**
- * struct target_if_spectral_chan_stats - Channel information
- * @cycle_count: Cycle count
- * @channel_load: Channel load
- * @per: Period
- * @noisefloor: Noise floor
- * @comp_usablity: Computed usability
- * @maxregpower: Maximum allowed regulatary power
- * @comp_usablity_sec80: Computed usability of secondary 80 Mhz
- * @maxregpower_sec80: Max regulatory power in secondary 80 Mhz
- */
- struct target_if_spectral_chan_stats {
- int cycle_count;
- int channel_load;
- int per;
- int noisefloor;
- uint16_t comp_usablity;
- int8_t maxregpower;
- uint16_t comp_usablity_sec80;
- int8_t maxregpower_sec80;
- };
- #if ATH_PERF_PWR_OFFLOAD
- /**
- * struct target_if_spectral_cache - Cache used to minimize WMI operations
- * in offload architecture
- * @osc_spectral_enabled: Whether Spectral is enabled
- * @osc_spectral_active: Whether spectral is active
- * XXX: Ideally, we should NOT cache this
- * since the hardware can self clear the bit,
- * the firmware can possibly stop spectral due to
- * intermittent off-channel activity, etc
- * A WMI read command should be introduced to handle
- * this This will be discussed.
- * @osc_params: Spectral parameters
- * @osc_is_valid: Whether the cache is valid
- */
- struct target_if_spectral_cache {
- uint8_t osc_spectral_enabled;
- uint8_t osc_spectral_active;
- struct spectral_config osc_params;
- uint8_t osc_is_valid;
- };
- /**
- * struct target_if_spectral_param_state_info - Structure used to represent and
- * manage spectral information
- * (parameters and states)
- * @osps_lock: Lock to synchronize accesses to information
- * @osps_cache: Cacheable' information
- */
- struct target_if_spectral_param_state_info {
- qdf_spinlock_t osps_lock;
- struct target_if_spectral_cache osps_cache;
- /* XXX - Non-cacheable information goes here, in the future */
- };
- #endif /* ATH_PERF_PWR_OFFLOAD */
- struct vdev_spectral_configure_params;
- struct vdev_spectral_enable_params;
- /**
- * struct spectral_wmi_ops - structure used holding the operations
- * related to Spectral WMI
- * @wmi_spectral_configure_cmd_send: Configure Spectral parameters
- * @wmi_spectral_enable_cmd_send: Enable/Disable Spectral
- * @wmi_spectral_crash_inject: Inject FW crash
- * @wmi_extract_pdev_sscan_fw_cmd_fixed_param: Extract Fixed params from
- * start scan response event
- * @wmi_extract_pdev_sscan_fft_bin_index: Extract TLV which describes FFT
- * bin indices from start scan response event
- * @wmi_unified_register_event_handler: Register WMI event handler
- * @wmi_unified_unregister_event_handler: Unregister WMI event handler
- * @wmi_service_enabled: API to check whether a given WMI service is enabled
- */
- struct spectral_wmi_ops {
- QDF_STATUS (*wmi_spectral_configure_cmd_send)(
- wmi_unified_t wmi_hdl,
- struct vdev_spectral_configure_params *param);
- QDF_STATUS (*wmi_spectral_enable_cmd_send)(
- wmi_unified_t wmi_hdl,
- struct vdev_spectral_enable_params *param);
- QDF_STATUS (*wmi_spectral_crash_inject)(
- wmi_unified_t wmi_handle, struct crash_inject *param);
- QDF_STATUS (*wmi_extract_pdev_sscan_fw_cmd_fixed_param)(
- wmi_unified_t wmi_handle, uint8_t *evt_buf,
- struct spectral_startscan_resp_params *param);
- QDF_STATUS (*wmi_extract_pdev_sscan_fft_bin_index)(
- wmi_unified_t wmi_handle, uint8_t *evt_buf,
- struct spectral_fft_bin_markers_160_165mhz *param);
- QDF_STATUS (*wmi_unified_register_event_handler)(
- wmi_unified_t wmi_handle,
- wmi_conv_event_id event_id,
- wmi_unified_event_handler handler_func,
- uint8_t rx_ctx);
- QDF_STATUS (*wmi_unified_unregister_event_handler)(
- wmi_unified_t wmi_handle,
- wmi_conv_event_id event_id);
- bool (*wmi_service_enabled)(wmi_unified_t wmi_handle,
- uint32_t service_id);
- };
- /**
- * struct spectral_tgt_ops - structure used holding the operations
- * related to target operations
- * @tgt_get_psoc_from_scn_hdl: Function to get psoc from scn
- */
- struct spectral_tgt_ops {
- struct wlan_objmgr_psoc *(*tgt_get_psoc_from_scn_hdl)(void *scn_handle);
- };
- /**
- * struct spectral_param_properties - structure holding Spectral
- * parameter properties
- * @supported: Parameter is supported or not
- * @common_all_modes: Parameter should be common for all modes or not
- */
- struct spectral_param_properties {
- bool supported;
- bool common_all_modes;
- };
- /**
- * struct target_if_finite_spectral_scan_params - Parameters related to finite
- * Spectral scan
- * @finite_spectral_scan: Indicates the Spectrl scan is finite/infinite
- * @num_reports_expected: Number of Spectral reports expected from target for a
- * finite Spectral scan
- */
- struct target_if_finite_spectral_scan_params {
- bool finite_spectral_scan;
- uint32_t num_reports_expected;
- };
- /**
- * struct per_session_dest_det_info - Per-session Detector information to be
- * filled to samp_detector_info
- * @freq_span_id: Contiguous frequency span ID within the SAMP message
- * @is_sec80: Indicates pri80/sec80 segment for 160/80p80 BW
- * @det_id: Detector ID within samp_freq_span_info corresponding to
- * freq_span_id
- * @dest_start_bin_idx: Start index of FFT bins within SAMP msg's bin_pwr array
- * @dest_end_bin_idx: End index of FFT bins within SAMP msg's bin_pwr array
- * @lb_extrabins_start_idx: Left band edge extra bins start index
- * @lb_extrabins_num: Number of left band edge extra bins
- * @rb_extrabins_start_idx: Right band edge extra bins start index
- * @rb_extrabins_num: Number of right band edge extra bins
- * @start_freq: Indicates start frequency per-detector (in MHz)
- * @end_freq: Indicates last frequency per-detector (in MHz)
- * @src_start_bin_idx: Start index within the Spectral report's bin_pwr array,
- * where the FFT bins corresponding to this dest_det_id start
- */
- struct per_session_dest_det_info {
- uint8_t freq_span_id;
- bool is_sec80;
- uint8_t det_id;
- uint16_t dest_start_bin_idx;
- uint16_t dest_end_bin_idx;
- uint16_t lb_extrabins_start_idx;
- uint16_t lb_extrabins_num;
- uint16_t rb_extrabins_start_idx;
- uint16_t rb_extrabins_num;
- uint32_t start_freq;
- uint32_t end_freq;
- uint16_t src_start_bin_idx;
- };
- /**
- * struct per_session_det_map - A map of per-session detector information,
- * keyed by the detector id obtained from the Spectral FFT report, mapping to
- * detination detector info in SAMP message.
- * @dest_det_info: Struct containing per-session detector information
- * @num_dest_det_info: Number of destination detectors to which information
- * of this detector is to be filled
- * @spectral_msg_buf_type: Spectral message buffer type
- * @send_to_upper_layers: Indicates whether to send SAMP msg to upper layers
- */
- struct per_session_det_map {
- struct per_session_dest_det_info
- dest_det_info[MAX_NUM_DEST_DETECTOR_INFO];
- uint8_t num_dest_det_info;
- enum spectral_msg_buf_type buf_type;
- bool send_to_upper_layers;
- };
- /**
- * struct per_session_report_info - Consists of per-session Spectral report
- * information to be filled at report level in SAMP message.
- * @pri20_freq: Primary 20MHz operating frequency in MHz
- * @cfreq1: Centre frequency of the frequency span for 20/40/80 MHz BW.
- * Segment 1 centre frequency in MHz for 80p80/160 BW.
- * @cfreq2: For 80p80, indicates segment 2 centre frequency in MHz. For 160MHz,
- * indicates the center frequency of 160MHz span.
- * @operating_bw: Device's operating bandwidth.Valid values = enum phy_ch_width
- * @sscan_cfreq1: Normal/Agile scan Centre frequency of the frequency span for
- * 20/40/80 MHz BW. Center frequency of Primary Segment in MHz for 80p80/160 BW
- * Based on Spectral scan mode.
- * @sscan_cfreq2: For 80p80, Normal/Agile scan Center frequency for Sec80
- * segment. For 160MHz, indicates the center frequency of 160MHz span. Based on
- * spectral scan mode
- * @sscan_bw: Normal/Agile Scan BW based on Spectral scan mode.
- * Valid values = enum phy_ch_width
- * @num_spans: Number of frequency spans
- */
- struct per_session_report_info {
- uint32_t pri20_freq;
- uint32_t cfreq1;
- uint32_t cfreq2;
- enum phy_ch_width operating_bw;
- uint32_t sscan_cfreq1;
- uint32_t sscan_cfreq2;
- enum phy_ch_width sscan_bw;
- uint8_t num_spans;
- };
- /**
- * struct sscan_detector_list - Spectral scan Detector list, for given Spectral
- * scan mode and operating BW
- * @detectors: List of detectors
- * @num_detectors: Number of detectors for given spectral scan mode, BW
- * and target type
- */
- struct sscan_detector_list {
- uint8_t detectors[SPECTRAL_DETECTOR_ID_MAX];
- uint8_t num_detectors;
- };
- /**
- * struct target_if_spectral - main spectral structure
- * @pdev: Pointer to pdev
- * @spectral_ops: Target if internal Spectral low level operations table
- * @capability: Spectral capabilities structure
- * @properties: Spectral parameter properties per mode
- * @spectral_lock: Lock used for internal Spectral operations
- * @vdev_id: VDEV id for all spectral modes
- * @spectral_curchan_radindex: Current channel spectral index
- * @spectral_extchan_radindex: Extension channel spectral index
- * @spectraldomain: Current Spectral domain
- * @spectral_proc_phyerr: Flags to process for PHY errors
- * @spectral_defaultparams: Default PHY params per Spectral stat
- * @spectral_stats: Spectral related stats
- * @events: Events structure
- * @sc_spectral_ext_chan_ok: Can spectral be detected on the extension channel?
- * @sc_spectral_combined_rssi_ok: Can use combined spectral RSSI?
- * @sc_spectral_20_40_mode: Is AP in 20-40 mode?
- * @sc_spectral_noise_pwr_cal: Noise power cal required?
- * @sc_spectral_non_edma: Is the spectral capable device Non-EDMA?
- * @upper_is_control: Upper segment is primary
- * @upper_is_extension: Upper segment is secondary
- * @lower_is_control: Lower segment is primary
- * @lower_is_extension: Lower segment is secondary
- * @sc_spectraltest_ieeechan: IEEE channel number to return to after a spectral
- * mute test
- * @spectral_numbins: Number of bins
- * @spectral_fft_len: FFT length
- * @spectral_data_len: Total phyerror report length
- * @lb_edge_extrabins: Number of extra bins on left band edge
- * @rb_edge_extrabins: Number of extra bins on right band edge
- * @spectral_max_index_offset: Max FFT index offset (20 MHz mode)
- * @spectral_upper_max_index_offset: Upper max FFT index offset (20/40 MHz mode)
- * @spectral_lower_max_index_offset: Lower max FFT index offset (20/40 MHz mode)
- * @spectral_dc_index: At which index DC is present
- * @send_single_packet: Deprecated
- * @spectral_sent_msg: Indicates whether we send report to upper layers
- * @params: Spectral parameters
- * @last_capture_time: Indicates timestamp of previouse report
- * @num_spectral_data: Number of Spectral samples received in current session
- * @total_spectral_data: Total number of Spectral samples received
- * @max_rssi: Maximum RSSI
- * @detects_control_channel: NA
- * @detects_extension_channel: NA
- * @detects_below_dc: NA
- * @detects_above_dc: NA
- * @sc_scanning: Indicates active wifi scan
- * @sc_spectral_scan: Indicates active specral scan
- * @sc_spectral_full_scan: Deprecated
- * @scan_start_tstamp: Deprecated
- * @last_tstamp: Deprecated
- * @first_tstamp: Deprecated
- * @spectral_samp_count: Deprecated
- * @sc_spectral_samp_count: Deprecated
- * @noise_pwr_reports_reqd: Number of noise power reports required
- * @noise_pwr_reports_recv: Number of noise power reports received
- * @noise_pwr_reports_lock: Lock used for Noise power report processing
- * @noise_pwr_chain_ctl: Noise power report - control channel
- * @noise_pwr_chain_ext: Noise power report - extension channel
- * @chaninfo: Channel statistics
- * @tsf64: Latest TSF Value
- * @param_info: Offload architecture Spectral parameter cache information
- * @ch_width: Indicates Channel Width 20/40/80/160 MHz for each Spectral mode
- * @diag_stats: Diagnostic statistics
- * @is_160_format: Indicates whether information provided by HW is in altered
- * format for 802.11ac 160/80+80 MHz support (QCA9984 onwards)
- * @is_lb_edge_extrabins_format: Indicates whether information provided by
- * HW has 4 extra bins, at left band edge, for report mode 2
- * @is_rb_edge_extrabins_format: Indicates whether information provided
- * by HW has 4 extra bins, at right band edge, for report mode 2
- * @is_sec80_rssi_war_required: Indicates whether the software workaround is
- * required to obtain approximate combined RSSI for secondary 80Mhz segment
- * @simctx: Spectral Simulation context
- * @spectral_gen: Spectral hardware generation
- * @hdr_sig_exp: Expected signature in PHYERR TLV header, for the given hardware
- * generation
- * @tag_sscan_summary_exp: Expected Spectral Scan Summary tag in PHYERR TLV
- * header, for the given hardware generation
- * @tag_sscan_fft_exp: Expected Spectral Scan FFT report tag in PHYERR TLV
- * header, for the given hardware generation
- * @tlvhdr_size: Expected PHYERR TLV header size, for the given hardware
- * generation
- * @nl_cb: Netlink callbacks
- * @use_nl_bcast: Whether to use Netlink broadcast/unicast
- * @send_phy_data: Send data to the application layer for a particular msg type
- * @len_adj_swar: Spectral fft bin length adjustment SWAR related info
- * @timestamp_war: Spectral time stamp WAR related info
- * @dbr_ring_debug: Whether Spectral DBR ring debug is enabled
- * @dbr_buff_debug: Whether Spectral DBR buffer debug is enabled
- * @direct_dma_support: Whether Direct-DMA is supported on the current radio
- * @prev_tstamp: Timestamp of the previously received sample, which has to be
- * compared with the current tstamp to check descrepancy
- * @rparams: Parameters related to Spectral report structure
- * @param_min_max: Spectral parameter's minimum and maximum values
- * @finite_scan: Parameters for finite Spectral scan
- * @detector_list: Detector list for a given Spectral scan mode and channel
- * width, based on the target type.
- * @det_map: Map of per-session detector information keyed by the Spectral HW
- * detector id.
- * @report_info: Per session info to be filled at report level in SAMP message
- */
- struct target_if_spectral {
- struct wlan_objmgr_pdev *pdev_obj;
- struct target_if_spectral_ops spectral_ops;
- struct spectral_caps capability;
- struct spectral_param_properties
- properties[SPECTRAL_SCAN_MODE_MAX][SPECTRAL_PARAM_MAX];
- qdf_spinlock_t spectral_lock;
- uint8_t vdev_id[SPECTRAL_SCAN_MODE_MAX];
- int16_t spectral_curchan_radindex;
- int16_t spectral_extchan_radindex;
- uint32_t spectraldomain;
- uint32_t spectral_proc_phyerr;
- struct spectral_config spectral_defaultparams;
- struct target_if_spectral_stats spectral_stats;
- struct target_if_spectral_event *events;
- unsigned int sc_spectral_ext_chan_ok:1,
- sc_spectral_combined_rssi_ok:1,
- sc_spectral_20_40_mode:1,
- sc_spectral_noise_pwr_cal:1,
- sc_spectral_non_edma:1;
- int upper_is_control;
- int upper_is_extension;
- int lower_is_control;
- int lower_is_extension;
- uint8_t sc_spectraltest_ieeechan;
- int spectral_numbins;
- int spectral_fft_len;
- int spectral_data_len;
- /*
- * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are
- * delivered. However, there can be additional bins reported for
- * AR900B version 2.0 and QCA9984 as described next:
- *
- * AR900B version 2.0: An additional tone is processed on the right
- * hand side in order to facilitate detection of radar pulses out to
- * the extreme band-edge of the channel frequency. Since the HW design
- * processes four tones at a time, this requires one additional Dword
- * to be added to the search FFT report.
- *
- * QCA9984: When spectral_scan_rpt_mode = 2, i.e 2-dword summary +
- * 1x-oversampled bins (in-band) per FFT, then 8 more bins
- * (4 more on left side and 4 more on right side)are added.
- */
- int lb_edge_extrabins;
- int rb_edge_extrabins;
- int spectral_max_index_offset;
- int spectral_upper_max_index_offset;
- int spectral_lower_max_index_offset;
- int spectral_dc_index;
- int send_single_packet;
- int spectral_sent_msg;
- int classify_scan;
- qdf_timer_t classify_timer;
- struct spectral_config params[SPECTRAL_SCAN_MODE_MAX];
- bool params_valid[SPECTRAL_SCAN_MODE_MAX];
- struct spectral_classifier_params classifier_params;
- int last_capture_time;
- int num_spectral_data;
- int total_spectral_data;
- int max_rssi;
- int detects_control_channel;
- int detects_extension_channel;
- int detects_below_dc;
- int detects_above_dc;
- int sc_scanning;
- int sc_spectral_scan;
- int sc_spectral_full_scan;
- uint64_t scan_start_tstamp;
- uint32_t last_tstamp;
- uint32_t first_tstamp;
- uint32_t spectral_samp_count;
- uint32_t sc_spectral_samp_count;
- int noise_pwr_reports_reqd;
- int noise_pwr_reports_recv;
- qdf_spinlock_t noise_pwr_reports_lock;
- struct target_if_chain_noise_pwr_info
- *noise_pwr_chain_ctl[HOST_MAX_ANTENNA];
- struct target_if_chain_noise_pwr_info
- *noise_pwr_chain_ext[HOST_MAX_ANTENNA];
- uint64_t tsf64;
- #if ATH_PERF_PWR_OFFLOAD
- struct target_if_spectral_param_state_info
- param_info[SPECTRAL_SCAN_MODE_MAX];
- #endif
- enum phy_ch_width ch_width[SPECTRAL_SCAN_MODE_MAX];
- struct spectral_diag_stats diag_stats;
- bool is_160_format;
- bool is_lb_edge_extrabins_format;
- bool is_rb_edge_extrabins_format;
- bool is_sec80_rssi_war_required;
- #ifdef QCA_SUPPORT_SPECTRAL_SIMULATION
- void *simctx;
- #endif
- enum spectral_gen spectral_gen;
- uint8_t hdr_sig_exp;
- uint8_t tag_sscan_summary_exp;
- uint8_t tag_sscan_fft_exp;
- uint8_t tlvhdr_size;
- struct spectral_nl_cb nl_cb;
- bool use_nl_bcast;
- int (*send_phy_data)(struct wlan_objmgr_pdev *pdev,
- enum spectral_msg_type smsg_type);
- struct spectral_fft_bin_len_adj_swar len_adj_swar;
- struct spectral_timestamp_war timestamp_war;
- enum spectral_160mhz_report_delivery_state
- state_160mhz_delivery[SPECTRAL_SCAN_MODE_MAX];
- bool dbr_ring_debug;
- bool dbr_buff_debug;
- bool direct_dma_support;
- #ifdef OPTIMIZED_SAMP_MESSAGE
- uint32_t prev_tstamp[MAX_DETECTORS_PER_PDEV];
- #else
- uint32_t prev_tstamp;
- #endif
- struct spectral_report_params rparams;
- struct spectral_param_min_max param_min_max;
- struct target_if_finite_spectral_scan_params
- finite_scan[SPECTRAL_SCAN_MODE_MAX];
- struct sscan_detector_list
- detector_list[SPECTRAL_SCAN_MODE_MAX][CH_WIDTH_MAX];
- struct per_session_det_map det_map[MAX_DETECTORS_PER_PDEV];
- struct per_session_report_info report_info[SPECTRAL_SCAN_MODE_MAX];
- };
- /**
- * struct target_if_psoc_spectral - Target if psoc Spectral object
- * @psoc_obj: psoc object
- * @wmi_ops: Spectral WMI operations
- */
- struct target_if_psoc_spectral {
- struct wlan_objmgr_psoc *psoc_obj;
- struct spectral_wmi_ops wmi_ops;
- };
- #ifdef OPTIMIZED_SAMP_MESSAGE
- /**
- * struct target_if_samp_msg_params - Spectral Analysis Messaging Protocol
- * data format
- * @hw_detector_id: Spectral HW detector ID
- * @rssi: Spectral RSSI
- * @lower_rssi: RSSI of lower band
- * @upper_rssi: RSSI of upper band
- * @chain_ctl_rssi: RSSI for control channel, for all antennas
- * @chain_ext_rssi: RSSI for extension channel, for all antennas
- * @last_raw_timestamp: Previous FFT report's raw timestamp.
- * @raw_timestamp: FFT timestamp reported by HW on primary segment.
- * @timestamp: timestamp
- * @reset_delay: Time gap between the last spectral report before reset and the
- * end of reset.
- * @max_mag: maximum magnitude
- * @max_index: index of max magnitude
- * @noise_floor: current noise floor
- * @pri80ind: Indication from hardware that the sample was received on the
- * primary 80 MHz segment. If this is set when smode =
- * SPECTRAL_SCAN_MODE_AGILE, it indicates that Spectral was carried
- * out on pri80 instead of the Agile frequency due to a channel
- * switch - Software may choose to ignore the sample in this case.
- * @bin_pwr_data: Contains FFT magnitudes
- */
- struct target_if_samp_msg_params {
- uint8_t hw_detector_id;
- int8_t rssi;
- int8_t lower_rssi;
- int8_t upper_rssi;
- int8_t chain_ctl_rssi[HOST_MAX_ANTENNA];
- int8_t chain_ext_rssi[HOST_MAX_ANTENNA];
- uint32_t last_raw_timestamp;
- uint32_t raw_timestamp;
- uint32_t timestamp;
- uint32_t reset_delay;
- uint16_t max_mag;
- uint16_t max_index;
- int16_t noise_floor;
- uint8_t agc_total_gain;
- uint8_t gainchange;
- uint8_t pri80ind;
- uint8_t *bin_pwr_data;
- };
- #else
- /**
- * struct target_if_samp_msg_params - Spectral Analysis Messaging Protocol
- * data format
- * @rssi: RSSI (except for secondary 80 segment)
- * @rssi_sec80: RSSI for secondary 80 segment
- * @lower_rssi: RSSI of lower band
- * @upper_rssi: RSSI of upper band
- * @chain_ctl_rssi: RSSI for control channel, for all antennas
- * @chain_ext_rssi: RSSI for extension channel, for all antennas
- * @bwinfo: bandwidth info
- * @data_len: length of FFT data (except for secondary 80 segment)
- * @data_len_sec80: length of FFT data for secondary 80 segment
- * @tstamp: timestamp
- * @last_tstamp: last time stamp
- * @max_mag: maximum magnitude (except for secondary 80 segment)
- * @max_mag_sec80: maximum magnitude for secondary 80 segment
- * @max_index: index of max magnitude (except for secondary 80 segment)
- * @max_index_sec80: index of max magnitude for secondary 80 segment
- * @max_exp: max exp
- * @peak: peak frequency (obsolete)
- * @pwr_count: number of FFT bins (except for secondary 80 segment)
- * @pwr_count_5mhz: number of FFT bins in extra 5 MHz in
- * 165 MHz/restricted 80p80 mode
- * @pwr_count_sec80: number of FFT bins in secondary 80 segment
- * @nb_lower: This is deprecated
- * @nb_upper: This is deprecated
- * @max_upper_index: index of max mag in upper band
- * @max_lower_index: index of max mag in lower band
- * @bin_pwr_data: Contains FFT magnitudes (except for secondary 80 segment)
- * @bin_pwr_data_5mhz: Contains FFT magnitudes for the extra 5 MHz
- * in 165 MHz/restricted 80p80 mode
- * @bin_pwr_data_sec80: Contains FFT magnitudes for the secondary 80 segment
- * @freq: Center frequency of primary 20MHz channel in MHz
- * @vhtop_ch_freq_seg1: VHT operation first segment center frequency in MHz
- * @vhtop_ch_freq_seg2: VHT operation second segment center frequency in MHz
- * @agile_freq1: Center frequency in MHz of the entire span(for 80+80 MHz
- * agile Scan it is primary 80 MHz span) across which
- * Agile Spectral is carried out. Applicable only for Agile
- * Spectral samples.
- * @agile_freq2: Center frequency in MHz of the secondary 80 MHz span
- * across which Agile Spectral is carried out. Applicable
- * only for Agile Spectral samples in 80+80 MHz mode.
- * @freq_loading: spectral control duty cycles
- * @noise_floor: current noise floor (except for secondary 80 segment)
- * @noise_floor_sec80: current noise floor for secondary 80 segment
- * @interf_list: List of interfernce sources
- * @classifier_params: classifier parameters
- * @sc: classifier parameters
- * @pri80ind: Indication from hardware that the sample was received on the
- * primary 80 MHz segment. If this is set when smode =
- * SPECTRAL_SCAN_MODE_AGILE, it indicates that Spectral was carried out on
- * pri80 instead of the Agile frequency due to a channel switch - Software may
- * choose to ignore the sample in this case.
- * @pri80ind_sec80: Indication from hardware that the sample was received on the
- * primary 80 MHz segment instead of the secondary 80 MHz segment due to a
- * channel switch - Software may choose to ignore the sample if this is set.
- * Applicable only if smode = SPECTRAL_SCAN_MODE_NORMAL and for 160/80+80 MHz
- * Spectral operation and if the chipset supports fragmented 160/80+80 MHz
- * operation.
- * @last_raw_timestamp: Previous FFT report's raw timestamp. In case of 160MHz
- * it will be primary 80 segment's timestamp as both primary & secondary
- * segment's timestamps are expected to be almost equal
- * @timestamp_war_offset: Offset calculated based on reset_delay and
- * last_raw_stamp. It will be added to raw_timestamp to get tstamp.
- * @raw_timestamp: FFT timestamp reported by HW on primary segment.
- * @raw_timestamp_sec80: FFT timestamp reported by HW on secondary 80 segment.
- * @reset_delay: Time gap between the last spectral report before reset and the
- * end of reset.
- * @target_reset_count: Indicates the the number of times the target went
- * through reset routine after spectral was enabled.
- */
- struct target_if_samp_msg_params {
- int8_t rssi;
- int8_t rssi_sec80;
- int8_t lower_rssi;
- int8_t upper_rssi;
- int8_t chain_ctl_rssi[HOST_MAX_ANTENNA];
- int8_t chain_ext_rssi[HOST_MAX_ANTENNA];
- uint16_t bwinfo;
- uint16_t datalen;
- uint16_t datalen_sec80;
- uint32_t tstamp;
- uint32_t last_tstamp;
- uint16_t max_mag;
- uint16_t max_mag_sec80;
- uint16_t max_index;
- uint16_t max_index_sec80;
- uint8_t max_exp;
- int peak;
- int pwr_count;
- int pwr_count_5mhz;
- int pwr_count_sec80;
- int8_t nb_lower;
- int8_t nb_upper;
- uint16_t max_lower_index;
- uint16_t max_upper_index;
- uint8_t *bin_pwr_data;
- uint8_t *bin_pwr_data_5mhz;
- uint8_t *bin_pwr_data_sec80;
- uint16_t freq;
- uint16_t vhtop_ch_freq_seg1;
- uint16_t vhtop_ch_freq_seg2;
- uint16_t agile_freq1;
- uint16_t agile_freq2;
- uint16_t freq_loading;
- int16_t noise_floor;
- int16_t noise_floor_sec80;
- struct interf_src_rsp interf_list;
- struct spectral_classifier_params classifier_params;
- struct ath_softc *sc;
- uint8_t agc_total_gain;
- uint8_t agc_total_gain_sec80;
- uint8_t gainchange;
- uint8_t gainchange_sec80;
- enum spectral_scan_mode smode;
- uint8_t pri80ind;
- uint8_t pri80ind_sec80;
- uint32_t last_raw_timestamp;
- uint32_t timestamp_war_offset;
- uint32_t raw_timestamp;
- uint32_t raw_timestamp_sec80;
- uint32_t reset_delay;
- uint32_t target_reset_count;
- };
- #endif
- /**
- * struct target_if_spectral_agile_mode_cap - Structure to hold agile
- * Spetcral scan capability
- * @agile_spectral_cap: agile Spectral scan capability for 20/40/80 MHz
- * @agile_spectral_cap_160: agile Spectral scan capability for 160 MHz
- * @agile_spectral_cap_80p80: agile Spectral scan capability for 80+80 MHz
- */
- struct target_if_spectral_agile_mode_cap {
- bool agile_spectral_cap;
- bool agile_spectral_cap_160;
- bool agile_spectral_cap_80p80;
- };
- #ifdef WLAN_CONV_SPECTRAL_ENABLE
- /**
- * target_if_spectral_dump_fft() - Dump Spectral FFT
- * @pfft: Pointer to Spectral Phyerr FFT
- * @fftlen: FFT length
- *
- * Return: Success or failure
- */
- int target_if_spectral_dump_fft(uint8_t *pfft, int fftlen);
- /**
- * target_if_dbg_print_samp_param() - Print contents of SAMP struct
- * @p: Pointer to SAMP message
- *
- * Return: Void
- */
- void target_if_dbg_print_samp_param(struct target_if_samp_msg_params *p);
- /**
- * target_if_get_offset_swar_sec80() - Get offset for SWAR according to
- * the channel width
- * @channel_width: Channel width
- *
- * Return: Offset for SWAR
- */
- uint32_t target_if_get_offset_swar_sec80(uint32_t channel_width);
- /**
- * target_if_sptrl_register_tx_ops() - Register Spectral target_if Tx Ops
- * @tx_ops: Tx Ops
- *
- * Return: void
- */
- void target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
- #ifndef OPTIMIZED_SAMP_MESSAGE
- /**
- * target_if_spectral_create_samp_msg() - Create the spectral samp message
- * @spectral : Pointer to spectral internal structure
- * @params : spectral samp message parameters
- *
- * API to create the spectral samp message
- *
- * Return: void
- */
- void target_if_spectral_create_samp_msg(
- struct target_if_spectral *spectral,
- struct target_if_samp_msg_params *params);
- #endif
- #ifdef OPTIMIZED_SAMP_MESSAGE
- /**
- * target_if_spectral_fill_samp_msg() - Fill the Spectral SAMP message
- * @spectral : Pointer to spectral internal structure
- * @params: Spectral SAMP message fields
- *
- * Fill the spectral SAMP message fields using params and detector map.
- *
- * Return: Success/Failure
- */
- QDF_STATUS target_if_spectral_fill_samp_msg(
- struct target_if_spectral *spectral,
- struct target_if_samp_msg_params *params);
- #endif
- /**
- * target_if_spectral_process_phyerr_gen3() - Process phyerror event for gen3
- * @pdev: Pointer to pdev object
- * @payload: Pointer to spectral report
- *
- * Process phyerror event for gen3
- *
- * Return: Success/Failure
- */
- int target_if_spectral_process_report_gen3(
- struct wlan_objmgr_pdev *pdev,
- void *buf);
- /**
- * target_if_process_phyerr_gen2() - Process PHY Error for gen2
- * @spectral: Pointer to Spectral object
- * @data: Pointer to phyerror event buffer
- * @datalen: Data length
- * @p_rfqual: RF quality info
- * @p_chaninfo: Channel info
- * @tsf64: 64 bit tsf timestamp
- * @acs_stats: ACS stats
- *
- * Process PHY Error for gen2
- *
- * Return: Success/Failure
- */
- int target_if_process_phyerr_gen2(
- struct target_if_spectral *spectral,
- uint8_t *data,
- uint32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual,
- struct target_if_spectral_chan_info *p_chaninfo,
- uint64_t tsf64,
- struct target_if_spectral_acs_stats *acs_stats);
- /**
- * target_if_spectral_send_intf_found_msg() - Indicate to application layer that
- * interference has been found
- * @pdev: Pointer to pdev
- * @cw_int: 1 if CW interference is found, 0 if WLAN interference is found
- * @dcs_enabled: 1 if DCS is enabled, 0 if DCS is disabled
- *
- * Send message to application layer
- * indicating that interference has been found
- *
- * Return: None
- */
- void target_if_spectral_send_intf_found_msg(
- struct wlan_objmgr_pdev *pdev,
- uint16_t cw_int, uint32_t dcs_enabled);
- /**
- * target_if_stop_spectral_scan() - Stop spectral scan
- * @pdev: Pointer to pdev object
- * @smode: Spectral scan mode
- * @err: Pointer to error code
- *
- * API to stop the current on-going spectral scan
- *
- * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
- */
- QDF_STATUS target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev,
- const enum spectral_scan_mode smode,
- enum spectral_cp_error_code *err);
- /**
- * target_if_spectral_get_vdev() - Get pointer to vdev to be used for Spectral
- * operations
- * @spectral: Pointer to Spectral target_if internal private data
- * @smode: spectral scan mode
- *
- * Spectral operates on pdev. However, in order to retrieve some WLAN
- * properties, a vdev is required. To facilitate this, the function returns the
- * first vdev in our pdev. The caller should release the reference to the vdev
- * once it is done using it.
- * TODO: If the framework later provides an API to obtain the first active
- * vdev, then it would be preferable to use this API.
- *
- * Return: Pointer to vdev on success, NULL on failure
- */
- struct wlan_objmgr_vdev *target_if_spectral_get_vdev(
- struct target_if_spectral *spectral,
- enum spectral_scan_mode smode);
- /**
- * target_if_spectral_dump_hdr_gen2() - Dump Spectral header for gen2
- * @phdr: Pointer to Spectral Phyerr Header
- *
- * Dump Spectral header
- *
- * Return: Success/Failure
- */
- int target_if_spectral_dump_hdr_gen2(struct spectral_phyerr_hdr_gen2 *phdr);
- /**
- * target_if_get_combrssi_sec80_seg_gen2() - Get approximate combined RSSI
- * for Secondary 80 segment
- * @spectral: Pointer to spectral object
- * @p_sfft_sec80: Pointer to search fft info of secondary 80 segment
- *
- * Get approximate combined RSSI for Secondary 80 segment
- *
- * Return: Combined RSSI for secondary 80Mhz segment
- */
- int8_t target_if_get_combrssi_sec80_seg_gen2(
- struct target_if_spectral *spectral,
- struct spectral_search_fft_info_gen2 *p_sfft_sec80);
- /**
- * target_if_spectral_dump_tlv_gen2() - Dump Spectral TLV for gen2
- * @ptlv: Pointer to Spectral Phyerr TLV
- * @is_160_format: Indicates 160 format
- *
- * Dump Spectral TLV for gen2
- *
- * Return: Success/Failure
- */
- int target_if_spectral_dump_tlv_gen2(
- struct spectral_phyerr_tlv_gen2 *ptlv, bool is_160_format);
- /**
- * target_if_spectral_dump_phyerr_data_gen2() - Dump Spectral
- * related PHY Error for gen2
- * @data: Pointer to phyerror buffer
- * @datalen: Data length
- * @is_160_format: Indicates 160 format
- *
- * Dump Spectral related PHY Error for gen2
- *
- * Return: Success/Failure
- */
- int target_if_spectral_dump_phyerr_data_gen2(
- uint8_t *data,
- uint32_t datalen,
- bool is_160_format);
- /**
- * target_if_dbg_print_samp_msg() - Print contents of SAMP Message
- * @p: Pointer to SAMP message
- *
- * Print contents of SAMP Message
- *
- * Return: Void
- */
- void target_if_dbg_print_samp_msg(struct spectral_samp_msg *pmsg);
- /**
- * get_target_if_spectral_handle_from_pdev() - Get handle to target_if internal
- * Spectral data
- * @pdev: Pointer to pdev
- *
- * Return: Handle to target_if internal Spectral data on success, NULL on
- * failure
- */
- struct target_if_spectral *get_target_if_spectral_handle_from_pdev(
- struct wlan_objmgr_pdev *pdev);
- /**
- * get_target_if_spectral_handle_from_psoc() - Get handle to psoc target_if
- * internal Spectral data
- * @psoc: Pointer to psoc
- *
- * Return: Handle to target_if psoc internal Spectral data on success, NULL on
- * failure
- */
- static inline
- struct target_if_psoc_spectral *get_target_if_spectral_handle_from_psoc(
- struct wlan_objmgr_psoc *psoc)
- {
- struct wlan_lmac_if_rx_ops *rx_ops;
- struct target_if_psoc_spectral *psoc_spectral;
- if (!psoc) {
- spectral_err("psoc is null");
- return NULL;
- }
- rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
- if (!rx_ops) {
- spectral_err("rx_ops is null");
- return NULL;
- }
- psoc_spectral = (struct target_if_psoc_spectral *)
- rx_ops->sptrl_rx_ops.sptrlro_get_psoc_target_handle(psoc);
- return psoc_spectral;
- }
- /**
- * target_if_vdev_get_chan_freq() - Get the operating channel frequency of a
- * given vdev
- * @pdev: Pointer to vdev
- *
- * Get the operating channel frequency of a given vdev
- *
- * Return: Operating channel frequency of a vdev
- */
- static inline
- int16_t target_if_vdev_get_chan_freq(struct wlan_objmgr_vdev *vdev)
- {
- struct wlan_objmgr_psoc *psoc = NULL;
- struct wlan_lmac_if_rx_ops *rx_ops;
- psoc = wlan_vdev_get_psoc(vdev);
- if (!psoc) {
- spectral_err("psoc is NULL");
- return -EINVAL;
- }
- rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
- if (!rx_ops) {
- spectral_err("rx_ops is null");
- return -EINVAL;
- }
- return rx_ops->sptrl_rx_ops.sptrlro_vdev_get_chan_freq(
- vdev);
- }
- /**
- * target_if_vdev_get_chan_freq_seg2() - Get center frequency of secondary 80 of
- * given vdev
- * @vdev: Pointer to vdev
- *
- * Get the center frequency of secondary 80 of given vdev
- *
- * Return: center frequency of secondary 80
- */
- static inline
- int16_t target_if_vdev_get_chan_freq_seg2(struct wlan_objmgr_vdev *vdev)
- {
- struct wlan_objmgr_psoc *psoc = NULL;
- struct wlan_lmac_if_rx_ops *rx_ops;
- psoc = wlan_vdev_get_psoc(vdev);
- if (!psoc) {
- spectral_err("psoc is NULL");
- return -EINVAL;
- }
- rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
- if (!rx_ops) {
- spectral_err("rx_ops is null");
- return -EINVAL;
- }
- return rx_ops->sptrl_rx_ops.sptrlro_vdev_get_chan_freq_seg2(vdev);
- }
- /**
- * target_if_vdev_get_ch_width() - Get the operating channel bandwidth of a
- * given vdev
- * @pdev: Pointer to vdev
- *
- * Get the operating channel bandwidth of a given vdev
- *
- * Return: channel bandwidth enumeration corresponding to the vdev
- */
- static inline
- enum phy_ch_width target_if_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev)
- {
- struct wlan_objmgr_psoc *psoc = NULL;
- enum phy_ch_width ch_width;
- struct wlan_lmac_if_rx_ops *rx_ops;
- psoc = wlan_vdev_get_psoc(vdev);
- if (!psoc) {
- spectral_err("psoc is NULL");
- return CH_WIDTH_INVALID;
- }
- rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
- if (!rx_ops) {
- spectral_err("rx_ops is null");
- return CH_WIDTH_INVALID;
- }
- ch_width = rx_ops->sptrl_rx_ops.sptrlro_vdev_get_ch_width(vdev);
- if (ch_width == CH_WIDTH_160MHZ) {
- int16_t cfreq2;
- cfreq2 = target_if_vdev_get_chan_freq_seg2(vdev);
- if (cfreq2 < 0) {
- spectral_err("Invalid value for cfreq2 %d", cfreq2);
- return CH_WIDTH_INVALID;
- }
- /* Use non zero cfreq2 to identify 80p80 */
- if (cfreq2)
- ch_width = CH_WIDTH_80P80MHZ;
- }
- return ch_width;
- }
- /**
- * target_if_vdev_get_sec20chan_freq_mhz() - Get the frequency of secondary
- * 20 MHz channel for a given vdev
- * @pdev: Pointer to vdev
- *
- * Get the frequency of secondary 20Mhz channel for a given vdev
- *
- * Return: Frequency of secondary 20Mhz channel for a given vdev
- */
- static inline
- int target_if_vdev_get_sec20chan_freq_mhz(
- struct wlan_objmgr_vdev *vdev,
- uint16_t *sec20chan_freq)
- {
- struct wlan_objmgr_psoc *psoc = NULL;
- struct wlan_lmac_if_rx_ops *rx_ops;
- psoc = wlan_vdev_get_psoc(vdev);
- if (!psoc) {
- spectral_err("psoc is NULL");
- return -EINVAL;
- }
- rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
- if (!rx_ops) {
- spectral_err("rx_ops is null");
- return -EINVAL;
- }
- return rx_ops->sptrl_rx_ops.
- sptrlro_vdev_get_sec20chan_freq_mhz(vdev, sec20chan_freq);
- }
- /**
- * target_if_spectral_is_feature_disabled_psoc() - Check if Spectral feature is
- * disabled for a given psoc
- * @psoc: Pointer to psoc
- *
- * Return: true or false
- */
- static inline
- bool target_if_spectral_is_feature_disabled_psoc(struct wlan_objmgr_psoc *psoc)
- {
- struct wlan_lmac_if_rx_ops *rx_ops;
- if (!psoc) {
- spectral_err("psoc is NULL");
- return true;
- }
- rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
- if (!rx_ops) {
- spectral_err("rx_ops is null");
- return true;
- }
- if (rx_ops->sptrl_rx_ops.
- sptrlro_spectral_is_feature_disabled_psoc)
- return rx_ops->sptrl_rx_ops.
- sptrlro_spectral_is_feature_disabled_psoc(psoc);
- return true;
- }
- /**
- * target_if_spectral_is_feature_disabled_pdev() - Check if Spectral feature is
- * disabled for a given pdev
- * @pdev: Pointer to pdev
- *
- * Return: true or false
- */
- static inline
- bool target_if_spectral_is_feature_disabled_pdev(struct wlan_objmgr_pdev *pdev)
- {
- struct wlan_lmac_if_rx_ops *rx_ops;
- struct wlan_objmgr_psoc *psoc;
- if (!pdev) {
- spectral_err("pdev is NULL");
- return true;
- }
- psoc = wlan_pdev_get_psoc(pdev);
- if (!psoc) {
- spectral_err("psoc is NULL");
- return true;
- }
- rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
- if (!rx_ops) {
- spectral_err("rx_ops is null");
- return true;
- }
- if (rx_ops->sptrl_rx_ops.
- sptrlro_spectral_is_feature_disabled_pdev)
- return rx_ops->sptrl_rx_ops.
- sptrlro_spectral_is_feature_disabled_pdev(pdev);
- return true;
- }
- /**
- * target_if_spectral_set_rxchainmask() - Set Spectral Rx chainmask
- * @pdev: Pointer to pdev
- * @spectral_rx_chainmask: Spectral Rx chainmask
- *
- * Return: None
- */
- static inline
- void target_if_spectral_set_rxchainmask(struct wlan_objmgr_pdev *pdev,
- uint8_t spectral_rx_chainmask)
- {
- struct wlan_objmgr_psoc *psoc = NULL;
- struct target_if_spectral *spectral = NULL;
- enum spectral_scan_mode smode = SPECTRAL_SCAN_MODE_NORMAL;
- struct wlan_lmac_if_rx_ops *rx_ops;
- psoc = wlan_pdev_get_psoc(pdev);
- if (!psoc) {
- spectral_err("psoc is NULL");
- return;
- }
- rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
- if (!rx_ops) {
- spectral_err("rx_ops is null");
- return;
- }
- if (smode >= SPECTRAL_SCAN_MODE_MAX) {
- spectral_err("Invalid Spectral mode %u", smode);
- return;
- }
- if (rx_ops->sptrl_rx_ops.
- sptrlro_spectral_is_feature_disabled_pdev(pdev)) {
- spectral_info("Spectral feature is disabled");
- return;
- }
- spectral = get_target_if_spectral_handle_from_pdev(pdev);
- if (!spectral) {
- spectral_err("Spectral target if object is null");
- return;
- }
- /* set chainmask for all the modes */
- for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++)
- spectral->params[smode].ss_chn_mask = spectral_rx_chainmask;
- }
- /**
- * target_if_spectral_process_phyerr() - Process Spectral PHY error
- * @pdev: Pointer to pdev
- * @data: PHY error data received from FW
- * @datalen: Length of data
- * @p_rfqual: Pointer to RF Quality information
- * @p_chaninfo: Pointer to channel information
- * @tsf: TSF time instance at which the Spectral sample was received
- * @acs_stats: ACS stats
- *
- * Process Spectral PHY error by extracting necessary information from the data
- * sent by FW, and send the extracted information to application layer.
- *
- * Return: None
- */
- static inline
- void target_if_spectral_process_phyerr(
- struct wlan_objmgr_pdev *pdev,
- uint8_t *data, uint32_t datalen,
- struct target_if_spectral_rfqual_info *p_rfqual,
- struct target_if_spectral_chan_info *p_chaninfo,
- uint64_t tsf64,
- struct target_if_spectral_acs_stats *acs_stats)
- {
- struct target_if_spectral *spectral = NULL;
- struct target_if_spectral_ops *p_sops = NULL;
- spectral = get_target_if_spectral_handle_from_pdev(pdev);
- if (!spectral) {
- spectral_err("Spectral target if object is null");
- return;
- }
- p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
- p_sops->spectral_process_phyerr(spectral, data, datalen,
- p_rfqual, p_chaninfo,
- tsf64, acs_stats);
- }
- static QDF_STATUS
- target_if_get_spectral_msg_type(enum spectral_scan_mode smode,
- enum spectral_msg_type *msg_type) {
- switch (smode) {
- case SPECTRAL_SCAN_MODE_NORMAL:
- *msg_type = SPECTRAL_MSG_NORMAL_MODE;
- break;
- case SPECTRAL_SCAN_MODE_AGILE:
- *msg_type = SPECTRAL_MSG_AGILE_MODE;
- break;
- default:
- spectral_err("Invalid spectral mode");
- return QDF_STATUS_E_FAILURE;
- }
- return QDF_STATUS_SUCCESS;
- }
- static inline bool
- is_ch_width_160_or_80p80(enum phy_ch_width ch_width)
- {
- return (ch_width == CH_WIDTH_160MHZ || ch_width == CH_WIDTH_80P80MHZ);
- }
- /**
- * init_160mhz_delivery_state_machine() - Initialize 160MHz Spectral
- * state machine
- * @spectral: Pointer to Spectral
- *
- * Initialize 160MHz Spectral state machine
- *
- * Return: void
- */
- static inline void
- init_160mhz_delivery_state_machine(struct target_if_spectral *spectral)
- {
- uint8_t smode;
- smode = 0;
- for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++)
- spectral->state_160mhz_delivery[smode] =
- SPECTRAL_REPORT_WAIT_PRIMARY80;
- }
- /**
- * reset_160mhz_delivery_state_machine() - Reset 160MHz Spectral state machine
- * @spectral: Pointer to Spectral
- *
- * Reset 160MHz Spectral state machine
- *
- * Return: void
- */
- static inline void
- reset_160mhz_delivery_state_machine(struct target_if_spectral *spectral,
- enum spectral_scan_mode smode)
- {
- enum spectral_msg_type smsg_type;
- QDF_STATUS ret;
- if (smode >= SPECTRAL_SCAN_MODE_MAX) {
- spectral_err_rl("Invalid Spectral mode %d", smode);
- return;
- }
- if (is_ch_width_160_or_80p80(spectral->ch_width[smode])) {
- spectral->state_160mhz_delivery[smode] =
- SPECTRAL_REPORT_WAIT_PRIMARY80;
- ret = target_if_get_spectral_msg_type(smode, &smsg_type);
- if (QDF_IS_STATUS_ERROR(ret)) {
- spectral_err("Failed to get spectral message type");
- return;
- }
- spectral->nl_cb.free_sbuff(spectral->pdev_obj,
- smsg_type);
- }
- }
- /**
- * is_secondaryseg_expected() - Is waiting for secondary 80 report
- * @spectral: Pointer to Spectral
- * @smode: Spectral scan mode
- *
- * Return true if secondary 80 report expected and mode is 160 MHz
- *
- * Return: true or false
- */
- static inline
- bool is_secondaryseg_expected(struct target_if_spectral *spectral,
- enum spectral_scan_mode smode)
- {
- return
- (is_ch_width_160_or_80p80(spectral->ch_width[smode]) &&
- spectral->rparams.fragmentation_160[smode] &&
- (spectral->state_160mhz_delivery[smode] ==
- SPECTRAL_REPORT_WAIT_SECONDARY80));
- }
- /**
- * is_primaryseg_expected() - Is waiting for primary 80 report
- * @spectral: Pointer to Spectral
- * @smode: Spectral scan mode
- *
- * Return true if mode is 160 Mhz and primary 80 report expected or
- * mode is not 160 Mhz
- *
- * Return: true or false
- */
- static inline
- bool is_primaryseg_expected(struct target_if_spectral *spectral,
- enum spectral_scan_mode smode)
- {
- return
- (!is_ch_width_160_or_80p80(spectral->ch_width[smode]) ||
- !spectral->rparams.fragmentation_160[smode] ||
- (spectral->state_160mhz_delivery[smode] ==
- SPECTRAL_REPORT_WAIT_PRIMARY80));
- }
- #ifndef OPTIMIZED_SAMP_MESSAGE
- /**
- * is_primaryseg_rx_inprog() - Is primary 80 report processing is in progress
- * @spectral: Pointer to Spectral
- * @smode: Spectral scan mode
- *
- * Is primary 80 report processing is in progress
- *
- * Return: true or false
- */
- static inline
- bool is_primaryseg_rx_inprog(struct target_if_spectral *spectral,
- enum spectral_scan_mode smode)
- {
- return
- (!is_ch_width_160_or_80p80(spectral->ch_width[smode]) ||
- spectral->spectral_gen == SPECTRAL_GEN2 ||
- (spectral->spectral_gen == SPECTRAL_GEN3 &&
- (!spectral->rparams.fragmentation_160[smode] ||
- spectral->state_160mhz_delivery[smode] ==
- SPECTRAL_REPORT_RX_PRIMARY80)));
- }
- /**
- * is_secondaryseg_rx_inprog() - Is secondary80 report processing is in progress
- * @spectral: Pointer to Spectral
- * @smode: Spectral scan mode
- *
- * Is secondary 80 report processing is in progress
- *
- * Return: true or false
- */
- static inline
- bool is_secondaryseg_rx_inprog(struct target_if_spectral *spectral,
- enum spectral_scan_mode smode)
- {
- return
- (is_ch_width_160_or_80p80(spectral->ch_width[smode]) &&
- (spectral->spectral_gen == SPECTRAL_GEN2 ||
- ((spectral->spectral_gen == SPECTRAL_GEN3) &&
- (!spectral->rparams.fragmentation_160[smode] ||
- spectral->state_160mhz_delivery[smode] ==
- SPECTRAL_REPORT_RX_SECONDARY80))));
- }
- #endif
- /**
- * target_if_160mhz_delivery_state_change() - State transition for 160Mhz
- * Spectral
- * @spectral: Pointer to spectral object
- * @smode: Spectral scan mode
- * @detector_id: Detector id
- *
- * Move the states of state machine for 160MHz spectral scan report receive
- *
- * Return: QDF_STATUS
- */
- QDF_STATUS
- target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral,
- enum spectral_scan_mode smode,
- uint8_t detector_id);
- /**
- * target_if_sops_is_spectral_enabled() - Get whether Spectral is enabled
- * @arg: Pointer to handle for Spectral target_if internal private data
- * @smode: Spectral scan mode
- *
- * Function to check whether Spectral is enabled
- *
- * Return: True if Spectral is enabled, false if Spectral is not enabled
- */
- uint32_t target_if_sops_is_spectral_enabled(void *arg,
- enum spectral_scan_mode smode);
- /**
- * target_if_sops_is_spectral_active() - Get whether Spectral is active
- * @arg: Pointer to handle for Spectral target_if internal private data
- * @smode: Spectral scan mode
- *
- * Function to check whether Spectral is active
- *
- * Return: True if Spectral is active, false if Spectral is not active
- */
- uint32_t target_if_sops_is_spectral_active(void *arg,
- enum spectral_scan_mode smode);
- /**
- * target_if_sops_start_spectral_scan() - Start Spectral scan
- * @arg: Pointer to handle for Spectral target_if internal private data
- * @smode: Spectral scan mode
- * @err: Pointer to error code
- *
- * Function to start spectral scan
- *
- * Return: 0 on success else failure
- */
- uint32_t target_if_sops_start_spectral_scan(void *arg,
- enum spectral_scan_mode smode,
- enum spectral_cp_error_code *err);
- /**
- * target_if_sops_stop_spectral_scan() - Stop Spectral scan
- * @arg: Pointer to handle for Spectral target_if internal private data
- * @smode: Spectral scan mode
- *
- * Function to stop spectral scan
- *
- * Return: 0 in case of success, -1 on failure
- */
- uint32_t target_if_sops_stop_spectral_scan(void *arg,
- enum spectral_scan_mode smode);
- /**
- * target_if_spectral_get_extension_channel() - Get the current Extension
- * channel (in MHz)
- * @arg: Pointer to handle for Spectral target_if internal private data
- * @smode: Spectral scan mode
- *
- * Return: Current Extension channel (in MHz) on success, 0 on failure or if
- * extension channel is not present.
- */
- uint32_t
- target_if_spectral_get_extension_channel(void *arg,
- enum spectral_scan_mode smode);
- /**
- * target_if_spectral_get_current_channel() - Get the current channel (in MHz)
- * @arg: Pointer to handle for Spectral target_if internal private data
- * @smode: Spectral scan mode
- *
- * Return: Current channel (in MHz) on success, 0 on failure
- */
- uint32_t
- target_if_spectral_get_current_channel(void *arg,
- enum spectral_scan_mode smode);
- /**
- * target_if_spectral_reset_hw() - Reset the hardware
- * @arg: Pointer to handle for Spectral target_if internal private data
- *
- * This is only a placeholder since it is not currently required in the offload
- * case.
- *
- * Return: 0
- */
- uint32_t target_if_spectral_reset_hw(void *arg);
- /**
- * target_if_spectral_get_chain_noise_floor() - Get the Chain noise floor from
- * Noisefloor history buffer
- * @arg: Pointer to handle for Spectral target_if internal private data
- * @nf_buf: Pointer to buffer into which chain Noise Floor data should be copied
- *
- * This is only a placeholder since it is not currently required in the offload
- * case.
- *
- * Return: 0
- */
- uint32_t target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf);
- /**
- * target_if_spectral_get_ext_noisefloor() - Get the extension channel
- * noisefloor
- * @arg: Pointer to handle for Spectral target_if internal private data
- *
- * This is only a placeholder since it is not currently required in the offload
- * case.
- *
- * Return: 0
- */
- int8_t target_if_spectral_get_ext_noisefloor(void *arg);
- /**
- * target_if_spectral_get_ctl_noisefloor() - Get the control channel noisefloor
- * @arg: Pointer to handle for Spectral target_if internal private data
- *
- * This is only a placeholder since it is not currently required in the offload
- * case.
- *
- * Return: 0
- */
- int8_t target_if_spectral_get_ctl_noisefloor(void *arg);
- /**
- * target_if_spectral_get_capability() - Get whether a given Spectral hardware
- * capability is available
- * @arg: Pointer to handle for Spectral target_if internal private data
- * @type: Spectral hardware capability type
- *
- * Return: True if the capability is available, false if the capability is not
- * available
- */
- uint32_t target_if_spectral_get_capability(
- void *arg, enum spectral_capability_type type);
- /**
- * target_if_spectral_set_rxfilter() - Set the RX Filter before Spectral start
- * @arg: Pointer to handle for Spectral target_if internal private data
- * @rxfilter: Rx filter to be used
- *
- * Note: This is only a placeholder function. It is not currently required since
- * FW should be taking care of setting the required filters.
- *
- * Return: 0
- */
- uint32_t target_if_spectral_set_rxfilter(void *arg, int rxfilter);
- /**
- * target_if_spectral_sops_configure_params() - Configure user supplied Spectral
- * parameters
- * @arg: Pointer to handle for Spectral target_if internal private data
- * @params: Spectral parameters
- * @smode: Spectral scan mode
- *
- * Return: 0 in case of success, -1 on failure
- */
- uint32_t target_if_spectral_sops_configure_params(
- void *arg, struct spectral_config *params,
- enum spectral_scan_mode smode);
- /**
- * target_if_spectral_get_rxfilter() - Get the current RX Filter settings
- * @arg: Pointer to handle for Spectral target_if internal private data
- *
- * Note: This is only a placeholder function. It is not currently required since
- * FW should be taking care of setting the required filters.
- *
- * Return: 0
- */
- uint32_t target_if_spectral_get_rxfilter(void *arg);
- /**
- * target_if_pdev_spectral_deinit() - De-initialize target_if Spectral
- * functionality for the given pdev
- * @pdev: Pointer to pdev object
- *
- * Return: None
- */
- void target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev);
- /**
- * target_if_set_spectral_config() - Set spectral config
- * @pdev: Pointer to pdev object
- * @param: Spectral parameter id and value
- * @smode: Spectral scan mode
- * @err: Pointer to Spectral error code
- *
- * API to set spectral configurations
- *
- * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
- */
- QDF_STATUS target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev,
- const struct spectral_cp_param *param,
- const enum spectral_scan_mode smode,
- enum spectral_cp_error_code *err);
- /**
- * target_if_pdev_spectral_init() - Initialize target_if Spectral
- * functionality for the given pdev
- * @pdev: Pointer to pdev object
- *
- * Return: On success, pointer to Spectral target_if internal private data, on
- * failure, NULL
- */
- void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev);
- /**
- * target_if_spectral_sops_get_params() - Get user configured Spectral
- * parameters
- * @arg: Pointer to handle for Spectral target_if internal private data
- * @params: Pointer to buffer into which Spectral parameters should be copied
- * @smode: Spectral scan mode
- *
- * Return: 0 in case of success, -1 on failure
- */
- uint32_t target_if_spectral_sops_get_params(
- void *arg, struct spectral_config *params,
- enum spectral_scan_mode smode);
- /**
- * target_if_init_spectral_capability() - Initialize Spectral capability
- *
- * @spectral: Pointer to Spectral target_if internal private data
- * @target_type: target type
- *
- * This is a workaround.
- *
- * Return: QDF_STATUS
- */
- QDF_STATUS
- target_if_init_spectral_capability(struct target_if_spectral *spectral,
- uint32_t target_type);
- /**
- * target_if_start_spectral_scan() - Start spectral scan
- * @pdev: Pointer to pdev object
- * @vdev_id: VDEV id
- * @smode: Spectral scan mode
- * @err: Spectral error code
- *
- * API to start spectral scan
- *
- * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
- */
- QDF_STATUS target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev,
- uint8_t vdev_id,
- enum spectral_scan_mode smode,
- enum spectral_cp_error_code *err);
- /**
- * target_if_get_spectral_config() - Get spectral configuration
- * @pdev: Pointer to pdev object
- * @param: Pointer to spectral_config structure in which the configuration
- * should be returned
- * @smode: Spectral scan mode
- *
- * API to get the current spectral configuration
- *
- * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
- */
- QDF_STATUS target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev,
- struct spectral_config *param,
- enum spectral_scan_mode smode);
- /**
- * target_if_spectral_scan_enable_params() - Enable use of desired Spectral
- * parameters
- * @spectral: Pointer to Spectral target_if internal private data
- * @spectral_params: Pointer to Spectral parameters
- * @smode: Spectral scan mode
- * @err: Spectral error code
- *
- * Enable use of desired Spectral parameters by configuring them into HW, and
- * starting Spectral scan
- *
- * Return: 0 on success, 1 on failure
- */
- int target_if_spectral_scan_enable_params(
- struct target_if_spectral *spectral,
- struct spectral_config *spectral_params,
- enum spectral_scan_mode smode,
- enum spectral_cp_error_code *err);
- /**
- * target_if_is_spectral_active() - Get whether Spectral is active
- * @pdev: Pointer to pdev object
- * @smode: Spectral scan mode
- *
- * Return: True if Spectral is active, false if Spectral is not active
- */
- bool target_if_is_spectral_active(struct wlan_objmgr_pdev *pdev,
- enum spectral_scan_mode smode);
- /**
- * target_if_is_spectral_enabled() - Get whether Spectral is enabled
- * @pdev: Pointer to pdev object
- * @smode: Spectral scan mode
- *
- * Return: True if Spectral is enabled, false if Spectral is not enabled
- */
- bool target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev,
- enum spectral_scan_mode smode);
- /**
- * target_if_set_debug_level() - Set debug level for Spectral
- * @pdev: Pointer to pdev object
- * @debug_level: Debug level
- *
- * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
- *
- */
- QDF_STATUS target_if_set_debug_level(struct wlan_objmgr_pdev *pdev,
- uint32_t debug_level);
- /**
- * target_if_get_debug_level() - Get debug level for Spectral
- * @pdev: Pointer to pdev object
- *
- * Return: Current debug level
- */
- uint32_t target_if_get_debug_level(struct wlan_objmgr_pdev *pdev);
- /**
- * target_if_get_spectral_capinfo() - Get Spectral capability information
- * @pdev: Pointer to pdev object
- * @scaps: Buffer into which data should be copied
- *
- * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
- */
- QDF_STATUS target_if_get_spectral_capinfo(struct wlan_objmgr_pdev *pdev,
- struct spectral_caps *scaps);
- /**
- * target_if_get_spectral_diagstats() - Get Spectral diagnostic statistics
- * @pdev: Pointer to pdev object
- * @stats: Buffer into which data should be copied
- *
- * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
- */
- QDF_STATUS target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev,
- struct spectral_diag_stats *stats);
- QDF_STATUS
- target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral,
- enum spectral_scan_mode smode,
- uint8_t detector_id);
- #ifdef OPTIMIZED_SAMP_MESSAGE
- /**
- * target_if_spectral_get_num_fft_bins() - Get number of FFT bins from FFT size
- * according to the Spectral report mode.
- * @fft_size: FFT length
- * @report_mode: Spectral report mode
- *
- * Get number of FFT bins from FFT size according to the Spectral
- * report mode.
- *
- * Return: Number of FFT bins
- */
- static inline uint32_t
- target_if_spectral_get_num_fft_bins(uint32_t fft_size,
- enum spectral_report_mode report_mode)
- {
- switch (report_mode) {
- case SPECTRAL_REPORT_MODE_0:
- case SPECTRAL_REPORT_MODE_1:
- return 0;
- case SPECTRAL_REPORT_MODE_2:
- return (1 << (fft_size - 1));
- case SPECTRAL_REPORT_MODE_3:
- return (1 << fft_size);
- default:
- return -EINVAL;
- }
- }
- #endif /* OPTIMIZED_SAMP_MESSAGE */
- #ifdef OPTIMIZED_SAMP_MESSAGE
- /**
- * target_if_get_detector_chwidth() - Get per-detector bandwidth
- * based on channel width and fragmentation.
- * @ch_width: Spectral scan channel width
- * @fragmentation_160: Target type has fragmentation or not
- *
- * Get per-detector BW.
- *
- * Return: detector BW
- */
- static inline
- enum phy_ch_width target_if_get_detector_chwidth(enum phy_ch_width ch_width,
- bool fragmentation_160)
- {
- return ((ch_width == CH_WIDTH_160MHZ && fragmentation_160) ?
- CH_WIDTH_80MHZ : ((ch_width == CH_WIDTH_80P80MHZ) ?
- CH_WIDTH_80MHZ : ch_width));
- }
- /**
- * target_if_spectral_set_start_end_freq() - Set start and end frequencies for
- * a given center frequency
- * @cfreq: Center frequency for which start and end freq need to be set
- * @ch_width: Spectral scan Channel width
- * @fragmentation_160: Target type has fragmentation or not
- * @start_end_freq: Array containing start and end frequency of detector
- *
- * Set the start and end frequencies for given center frequency in destination
- * detector info struct
- *
- * Return: void
- */
- static inline
- void target_if_spectral_set_start_end_freq(uint32_t cfreq,
- enum phy_ch_width ch_width,
- bool fragmentation_160,
- uint32_t *start_end_freq)
- {
- enum phy_ch_width det_ch_width;
- det_ch_width = target_if_get_detector_chwidth(ch_width,
- fragmentation_160);
- start_end_freq[0] = cfreq - (wlan_reg_get_bw_value(det_ch_width) >> 1);
- start_end_freq[1] = cfreq + (wlan_reg_get_bw_value(det_ch_width) >> 1);
- }
- #endif /* OPTIMIZED_SAMP_MESSAGE */
- #ifdef DIRECT_BUF_RX_ENABLE
- /**
- * target_if_consume_sfft_report_gen3() - Process fft report for gen3
- * @spectral: Pointer to spectral object
- * @report: Pointer to spectral report
- *
- * Process fft report for gen3
- *
- * Return: Success/Failure
- */
- int
- target_if_consume_spectral_report_gen3(
- struct target_if_spectral *spectral,
- struct spectral_report *report);
- #endif
- /**
- * target_if_spectral_fw_hang() - Crash the FW from Spectral module
- * @spectral: Pointer to Spectral LMAC object
- *
- * Return: QDF_STATUS of operation
- */
- QDF_STATUS target_if_spectral_fw_hang(struct target_if_spectral *spectral);
- /**
- * target_if_spectral_finite_scan_update() - Update scan count for finite scan
- * and stop Spectral scan when required
- * @spectral: Pointer to Spectral target_if internal private data
- * @smode: Spectral scan mode
- *
- * This API decrements the number of Spectral reports expected from target for
- * a finite Spectral scan. When expected number of reports are received from
- * target Spectral scan is stopped.
- *
- * Return: QDF_STATUS on success
- */
- QDF_STATUS
- target_if_spectral_finite_scan_update(struct target_if_spectral *spectral,
- enum spectral_scan_mode smode);
- /**
- * target_if_spectral_is_finite_scan() - Check Spectral scan is finite/infinite
- * @spectral: Pointer to Spectral target_if internal private data
- * @smode: Spectral scan mode
- *
- * API to check whether Spectral scan is finite/infinite for the give mode.
- * A non zero scan count indicates that scan is finite. Scan count of 0
- * indicates an infinite Spectral scan.
- *
- * Return: QDF_STATUS on success
- */
- QDF_STATUS
- target_if_spectral_is_finite_scan(struct target_if_spectral *spectral,
- enum spectral_scan_mode smode,
- bool *finite_spectral_scan);
- #ifdef BIG_ENDIAN_HOST
- /**
- * target_if_byte_swap_spectral_headers_gen3() - Apply byte-swap on headers
- * @spectral: Pointer to Spectral target_if internal private data
- * @data: Pointer to the start of Spectral Scan Summary report
- *
- * This API is only required for Big-endian Host platforms.
- * It applies 32-bit byte-swap on Spectral Scan Summary and Search FFT reports
- * and copies them back to the source location.
- * Padding bytes that lie between the reports won't be touched.
- *
- * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
- */
- QDF_STATUS target_if_byte_swap_spectral_headers_gen3(
- struct target_if_spectral *spectral,
- void *data);
- /**
- * target_if_byte_swap_spectral_fft_bins_gen3() - Apply byte-swap on FFT bins
- * @spectral: Pointer to Spectral FFT bin length adjustment WAR
- * @bin_pwr_data: Pointer to the start of FFT bins
- * @pwr_count: Number of FFT bins
- *
- * This API is only required for Big-endian Host platforms.
- * It applies pack-mode-aware byte-swap on the FFT bins as below:
- * 1. pack-mode 0 (i.e., 1 FFT bin per DWORD):
- * Reads the least significant 2 bytes of each DWORD, applies 16-bit
- * byte-swap on that value, and copies it back to the source location.
- * 2. pack-mode 1 (i.e., 2 FFT bins per DWORD):
- * Reads each FFT bin, applies 16-bit byte-swap on that value,
- * and copies it back to the source location.
- * 3. pack-mode 2 (4 FFT bins per DWORD):
- * Nothing
- *
- * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
- */
- QDF_STATUS target_if_byte_swap_spectral_fft_bins_gen3(
- struct spectral_fft_bin_len_adj_swar *swar,
- void *bin_pwr_data, size_t pwr_count);
- #endif /* BIG_ENDIAN_HOST */
- #ifdef WIN32
- #pragma pack(pop, target_if_spectral)
- #endif
- #ifdef __ATTRIB_PACK
- #undef __ATTRIB_PACK
- #endif
- #endif /* WLAN_CONV_SPECTRAL_ENABLE */
- #endif /* _TARGET_IF_SPECTRAL_H_ */
|