123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498 |
- /*
- * Copyright (c) 2016-2019 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.
- */
- #include <qdf_types.h>
- #include <qdf_lock.h>
- #include <hal_hw_headers.h>
- #include "dp_htt.h"
- #include "dp_types.h"
- #include "dp_internal.h"
- #include "dp_peer.h"
- #include "dp_rx_defrag.h"
- #include "dp_rx.h"
- #include <hal_api.h>
- #include <hal_reo.h>
- #include <cdp_txrx_handle.h>
- #include <wlan_cfg.h>
- #ifdef WLAN_TX_PKT_CAPTURE_ENH
- #include "dp_tx_capture.h"
- #endif
- static inline void
- dp_set_ssn_valid_flag(struct hal_reo_cmd_params *params,
- uint8_t valid)
- {
- params->u.upd_queue_params.update_svld = 1;
- params->u.upd_queue_params.svld = valid;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "%s: Setting SSN valid bit to %d",
- __func__, valid);
- }
- static inline int dp_peer_find_mac_addr_cmp(
- union dp_align_mac_addr *mac_addr1,
- union dp_align_mac_addr *mac_addr2)
- {
- /*
- * Intentionally use & rather than &&.
- * because the operands are binary rather than generic boolean,
- * the functionality is equivalent.
- * Using && has the advantage of short-circuited evaluation,
- * but using & has the advantage of no conditional branching,
- * which is a more significant benefit.
- */
- return !((mac_addr1->align4.bytes_abcd == mac_addr2->align4.bytes_abcd)
- & (mac_addr1->align4.bytes_ef == mac_addr2->align4.bytes_ef));
- }
- static int dp_peer_ast_table_attach(struct dp_soc *soc)
- {
- uint32_t max_ast_index;
- max_ast_index = wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx);
- /* allocate ast_table for ast entry to ast_index map */
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- "\n<=== cfg max ast idx %d ====>", max_ast_index);
- soc->ast_table = qdf_mem_malloc(max_ast_index *
- sizeof(struct dp_ast_entry *));
- if (!soc->ast_table) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: ast_table memory allocation failed", __func__);
- return QDF_STATUS_E_NOMEM;
- }
- return 0; /* success */
- }
- static int dp_peer_find_map_attach(struct dp_soc *soc)
- {
- uint32_t max_peers, peer_map_size;
- max_peers = soc->max_peers;
- /* allocate the peer ID -> peer object map */
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- "\n<=== cfg max peer id %d ====>", max_peers);
- peer_map_size = max_peers * sizeof(soc->peer_id_to_obj_map[0]);
- soc->peer_id_to_obj_map = qdf_mem_malloc(peer_map_size);
- if (!soc->peer_id_to_obj_map) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: peer map memory allocation failed", __func__);
- return QDF_STATUS_E_NOMEM;
- }
- /*
- * The peer_id_to_obj_map doesn't really need to be initialized,
- * since elements are only used after they have been individually
- * initialized.
- * However, it is convenient for debugging to have all elements
- * that are not in use set to 0.
- */
- qdf_mem_zero(soc->peer_id_to_obj_map, peer_map_size);
- return 0; /* success */
- }
- static int dp_log2_ceil(unsigned int value)
- {
- unsigned int tmp = value;
- int log2 = -1;
- while (tmp) {
- log2++;
- tmp >>= 1;
- }
- if (1 << log2 != value)
- log2++;
- return log2;
- }
- static int dp_peer_find_add_id_to_obj(
- struct dp_peer *peer,
- uint16_t peer_id)
- {
- int i;
- for (i = 0; i < MAX_NUM_PEER_ID_PER_PEER; i++) {
- if (peer->peer_ids[i] == HTT_INVALID_PEER) {
- peer->peer_ids[i] = peer_id;
- return 0; /* success */
- }
- }
- return QDF_STATUS_E_FAILURE; /* failure */
- }
- #define DP_PEER_HASH_LOAD_MULT 2
- #define DP_PEER_HASH_LOAD_SHIFT 0
- #define DP_AST_HASH_LOAD_MULT 2
- #define DP_AST_HASH_LOAD_SHIFT 0
- static int dp_peer_find_hash_attach(struct dp_soc *soc)
- {
- int i, hash_elems, log2;
- /* allocate the peer MAC address -> peer object hash table */
- hash_elems = soc->max_peers;
- hash_elems *= DP_PEER_HASH_LOAD_MULT;
- hash_elems >>= DP_PEER_HASH_LOAD_SHIFT;
- log2 = dp_log2_ceil(hash_elems);
- hash_elems = 1 << log2;
- soc->peer_hash.mask = hash_elems - 1;
- soc->peer_hash.idx_bits = log2;
- /* allocate an array of TAILQ peer object lists */
- soc->peer_hash.bins = qdf_mem_malloc(
- hash_elems * sizeof(TAILQ_HEAD(anonymous_tail_q, dp_peer)));
- if (!soc->peer_hash.bins)
- return QDF_STATUS_E_NOMEM;
- for (i = 0; i < hash_elems; i++)
- TAILQ_INIT(&soc->peer_hash.bins[i]);
- return 0;
- }
- static void dp_peer_find_hash_detach(struct dp_soc *soc)
- {
- if (soc->peer_hash.bins) {
- qdf_mem_free(soc->peer_hash.bins);
- soc->peer_hash.bins = NULL;
- }
- }
- static inline unsigned dp_peer_find_hash_index(struct dp_soc *soc,
- union dp_align_mac_addr *mac_addr)
- {
- unsigned index;
- index =
- mac_addr->align2.bytes_ab ^
- mac_addr->align2.bytes_cd ^
- mac_addr->align2.bytes_ef;
- index ^= index >> soc->peer_hash.idx_bits;
- index &= soc->peer_hash.mask;
- return index;
- }
- void dp_peer_find_hash_add(struct dp_soc *soc, struct dp_peer *peer)
- {
- unsigned index;
- index = dp_peer_find_hash_index(soc, &peer->mac_addr);
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- /*
- * It is important to add the new peer at the tail of the peer list
- * with the bin index. Together with having the hash_find function
- * search from head to tail, this ensures that if two entries with
- * the same MAC address are stored, the one added first will be
- * found first.
- */
- TAILQ_INSERT_TAIL(&soc->peer_hash.bins[index], peer, hash_list_elem);
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- }
- #ifdef FEATURE_AST
- /*
- * dp_peer_ast_hash_attach() - Allocate and initialize AST Hash Table
- * @soc: SoC handle
- *
- * Return: None
- */
- static int dp_peer_ast_hash_attach(struct dp_soc *soc)
- {
- int i, hash_elems, log2;
- unsigned int max_ast_idx = wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx);
- hash_elems = ((max_ast_idx * DP_AST_HASH_LOAD_MULT) >>
- DP_AST_HASH_LOAD_SHIFT);
- log2 = dp_log2_ceil(hash_elems);
- hash_elems = 1 << log2;
- soc->ast_hash.mask = hash_elems - 1;
- soc->ast_hash.idx_bits = log2;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- "ast hash_elems: %d, max_ast_idx: %d",
- hash_elems, max_ast_idx);
- /* allocate an array of TAILQ peer object lists */
- soc->ast_hash.bins = qdf_mem_malloc(
- hash_elems * sizeof(TAILQ_HEAD(anonymous_tail_q,
- dp_ast_entry)));
- if (!soc->ast_hash.bins)
- return QDF_STATUS_E_NOMEM;
- for (i = 0; i < hash_elems; i++)
- TAILQ_INIT(&soc->ast_hash.bins[i]);
- return 0;
- }
- /*
- * dp_peer_ast_cleanup() - cleanup the references
- * @soc: SoC handle
- * @ast: ast entry
- *
- * Return: None
- */
- static inline void dp_peer_ast_cleanup(struct dp_soc *soc,
- struct dp_ast_entry *ast)
- {
- txrx_ast_free_cb cb = ast->callback;
- void *cookie = ast->cookie;
- /* Call the callbacks to free up the cookie */
- if (cb) {
- ast->callback = NULL;
- ast->cookie = NULL;
- cb(soc->ctrl_psoc,
- dp_soc_to_cdp_soc(soc),
- cookie,
- CDP_TXRX_AST_DELETE_IN_PROGRESS);
- }
- }
- /*
- * dp_peer_ast_hash_detach() - Free AST Hash table
- * @soc: SoC handle
- *
- * Return: None
- */
- static void dp_peer_ast_hash_detach(struct dp_soc *soc)
- {
- unsigned int index;
- struct dp_ast_entry *ast, *ast_next;
- if (!soc->ast_hash.mask)
- return;
- if (!soc->ast_hash.bins)
- return;
- qdf_spin_lock_bh(&soc->ast_lock);
- for (index = 0; index <= soc->ast_hash.mask; index++) {
- if (!TAILQ_EMPTY(&soc->ast_hash.bins[index])) {
- TAILQ_FOREACH_SAFE(ast, &soc->ast_hash.bins[index],
- hash_list_elem, ast_next) {
- TAILQ_REMOVE(&soc->ast_hash.bins[index], ast,
- hash_list_elem);
- dp_peer_ast_cleanup(soc, ast);
- qdf_mem_free(ast);
- }
- }
- }
- qdf_spin_unlock_bh(&soc->ast_lock);
- qdf_mem_free(soc->ast_hash.bins);
- soc->ast_hash.bins = NULL;
- }
- /*
- * dp_peer_ast_hash_index() - Compute the AST hash from MAC address
- * @soc: SoC handle
- *
- * Return: AST hash
- */
- static inline uint32_t dp_peer_ast_hash_index(struct dp_soc *soc,
- union dp_align_mac_addr *mac_addr)
- {
- uint32_t index;
- index =
- mac_addr->align2.bytes_ab ^
- mac_addr->align2.bytes_cd ^
- mac_addr->align2.bytes_ef;
- index ^= index >> soc->ast_hash.idx_bits;
- index &= soc->ast_hash.mask;
- return index;
- }
- /*
- * dp_peer_ast_hash_add() - Add AST entry into hash table
- * @soc: SoC handle
- *
- * This function adds the AST entry into SoC AST hash table
- * It assumes caller has taken the ast lock to protect the access to this table
- *
- * Return: None
- */
- static inline void dp_peer_ast_hash_add(struct dp_soc *soc,
- struct dp_ast_entry *ase)
- {
- uint32_t index;
- index = dp_peer_ast_hash_index(soc, &ase->mac_addr);
- TAILQ_INSERT_TAIL(&soc->ast_hash.bins[index], ase, hash_list_elem);
- }
- /*
- * dp_peer_ast_hash_remove() - Look up and remove AST entry from hash table
- * @soc: SoC handle
- *
- * This function removes the AST entry from soc AST hash table
- * It assumes caller has taken the ast lock to protect the access to this table
- *
- * Return: None
- */
- void dp_peer_ast_hash_remove(struct dp_soc *soc,
- struct dp_ast_entry *ase)
- {
- unsigned index;
- struct dp_ast_entry *tmpase;
- int found = 0;
- index = dp_peer_ast_hash_index(soc, &ase->mac_addr);
- /* Check if tail is not empty before delete*/
- QDF_ASSERT(!TAILQ_EMPTY(&soc->ast_hash.bins[index]));
- TAILQ_FOREACH(tmpase, &soc->ast_hash.bins[index], hash_list_elem) {
- if (tmpase == ase) {
- found = 1;
- break;
- }
- }
- QDF_ASSERT(found);
- TAILQ_REMOVE(&soc->ast_hash.bins[index], ase, hash_list_elem);
- }
- /*
- * dp_peer_ast_list_find() - Find AST entry by MAC address from peer ast list
- * @soc: SoC handle
- * @peer: peer handle
- * @ast_mac_addr: mac address
- *
- * It assumes caller has taken the ast lock to protect the access to ast list
- *
- * Return: AST entry
- */
- struct dp_ast_entry *dp_peer_ast_list_find(struct dp_soc *soc,
- struct dp_peer *peer,
- uint8_t *ast_mac_addr)
- {
- struct dp_ast_entry *ast_entry = NULL;
- union dp_align_mac_addr *mac_addr =
- (union dp_align_mac_addr *)ast_mac_addr;
- TAILQ_FOREACH(ast_entry, &peer->ast_entry_list, ase_list_elem) {
- if (!dp_peer_find_mac_addr_cmp(mac_addr,
- &ast_entry->mac_addr)) {
- return ast_entry;
- }
- }
- return NULL;
- }
- /*
- * dp_peer_ast_hash_find_by_pdevid() - Find AST entry by MAC address
- * @soc: SoC handle
- *
- * It assumes caller has taken the ast lock to protect the access to
- * AST hash table
- *
- * Return: AST entry
- */
- struct dp_ast_entry *dp_peer_ast_hash_find_by_pdevid(struct dp_soc *soc,
- uint8_t *ast_mac_addr,
- uint8_t pdev_id)
- {
- union dp_align_mac_addr local_mac_addr_aligned, *mac_addr;
- uint32_t index;
- struct dp_ast_entry *ase;
- qdf_mem_copy(&local_mac_addr_aligned.raw[0],
- ast_mac_addr, QDF_MAC_ADDR_SIZE);
- mac_addr = &local_mac_addr_aligned;
- index = dp_peer_ast_hash_index(soc, mac_addr);
- TAILQ_FOREACH(ase, &soc->ast_hash.bins[index], hash_list_elem) {
- if ((pdev_id == ase->pdev_id) &&
- !dp_peer_find_mac_addr_cmp(mac_addr, &ase->mac_addr)) {
- return ase;
- }
- }
- return NULL;
- }
- /*
- * dp_peer_ast_hash_find_soc() - Find AST entry by MAC address
- * @soc: SoC handle
- *
- * It assumes caller has taken the ast lock to protect the access to
- * AST hash table
- *
- * Return: AST entry
- */
- struct dp_ast_entry *dp_peer_ast_hash_find_soc(struct dp_soc *soc,
- uint8_t *ast_mac_addr)
- {
- union dp_align_mac_addr local_mac_addr_aligned, *mac_addr;
- unsigned index;
- struct dp_ast_entry *ase;
- qdf_mem_copy(&local_mac_addr_aligned.raw[0],
- ast_mac_addr, QDF_MAC_ADDR_SIZE);
- mac_addr = &local_mac_addr_aligned;
- index = dp_peer_ast_hash_index(soc, mac_addr);
- TAILQ_FOREACH(ase, &soc->ast_hash.bins[index], hash_list_elem) {
- if (dp_peer_find_mac_addr_cmp(mac_addr, &ase->mac_addr) == 0) {
- return ase;
- }
- }
- return NULL;
- }
- /*
- * dp_peer_map_ast() - Map the ast entry with HW AST Index
- * @soc: SoC handle
- * @peer: peer to which ast node belongs
- * @mac_addr: MAC address of ast node
- * @hw_peer_id: HW AST Index returned by target in peer map event
- * @vdev_id: vdev id for VAP to which the peer belongs to
- * @ast_hash: ast hash value in HW
- *
- * Return: None
- */
- static inline void dp_peer_map_ast(struct dp_soc *soc,
- struct dp_peer *peer, uint8_t *mac_addr, uint16_t hw_peer_id,
- uint8_t vdev_id, uint16_t ast_hash)
- {
- struct dp_ast_entry *ast_entry = NULL;
- enum cdp_txrx_ast_entry_type peer_type = CDP_TXRX_AST_TYPE_STATIC;
- if (!peer) {
- return;
- }
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: peer %pK ID %d vid %d mac %02x:%02x:%02x:%02x:%02x:%02x",
- __func__, peer, hw_peer_id, vdev_id, mac_addr[0],
- mac_addr[1], mac_addr[2], mac_addr[3],
- mac_addr[4], mac_addr[5]);
- qdf_spin_lock_bh(&soc->ast_lock);
- ast_entry = dp_peer_ast_list_find(soc, peer, mac_addr);
- if (ast_entry) {
- ast_entry->ast_idx = hw_peer_id;
- soc->ast_table[hw_peer_id] = ast_entry;
- ast_entry->is_active = TRUE;
- peer_type = ast_entry->type;
- ast_entry->ast_hash_value = ast_hash;
- ast_entry->is_mapped = TRUE;
- }
- if (ast_entry || (peer->vdev && peer->vdev->proxysta_vdev)) {
- if (soc->cdp_soc.ol_ops->peer_map_event) {
- soc->cdp_soc.ol_ops->peer_map_event(
- soc->ctrl_psoc, peer->peer_ids[0],
- hw_peer_id, vdev_id,
- mac_addr, peer_type, ast_hash);
- }
- } else {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "AST entry not found");
- }
- qdf_spin_unlock_bh(&soc->ast_lock);
- return;
- }
- void dp_peer_free_hmwds_cb(struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
- struct cdp_soc *dp_soc,
- void *cookie,
- enum cdp_ast_free_status status)
- {
- struct dp_ast_free_cb_params *param =
- (struct dp_ast_free_cb_params *)cookie;
- struct dp_soc *soc = (struct dp_soc *)dp_soc;
- struct dp_peer *peer = NULL;
- if (status != CDP_TXRX_AST_DELETED) {
- qdf_mem_free(cookie);
- return;
- }
- peer = dp_peer_find_hash_find(soc, ¶m->peer_mac_addr.raw[0],
- 0, param->vdev_id);
- if (peer) {
- dp_peer_add_ast(soc, peer,
- ¶m->mac_addr.raw[0],
- param->type,
- param->flags);
- dp_peer_unref_delete(peer);
- }
- qdf_mem_free(cookie);
- }
- /*
- * dp_peer_add_ast() - Allocate and add AST entry into peer list
- * @soc: SoC handle
- * @peer: peer to which ast node belongs
- * @mac_addr: MAC address of ast node
- * @is_self: Is this base AST entry with peer mac address
- *
- * This API is used by WDS source port learning function to
- * add a new AST entry into peer AST list
- *
- * Return: 0 if new entry is allocated,
- * -1 if entry add failed
- */
- int dp_peer_add_ast(struct dp_soc *soc,
- struct dp_peer *peer,
- uint8_t *mac_addr,
- enum cdp_txrx_ast_entry_type type,
- uint32_t flags)
- {
- struct dp_ast_entry *ast_entry = NULL;
- struct dp_vdev *vdev = NULL, *tmp_vdev = NULL;
- struct dp_pdev *pdev = NULL;
- uint8_t next_node_mac[6];
- int ret = -1;
- txrx_ast_free_cb cb = NULL;
- void *cookie = NULL;
- struct dp_peer *tmp_peer = NULL;
- bool is_peer_found = false;
- vdev = peer->vdev;
- if (!vdev) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Peers vdev is NULL"));
- QDF_ASSERT(0);
- return ret;
- }
- pdev = vdev->pdev;
- tmp_peer = dp_peer_find_hash_find(soc, mac_addr, 0,
- DP_VDEV_ALL);
- if (tmp_peer) {
- tmp_vdev = tmp_peer->vdev;
- if (!tmp_vdev) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Peers vdev is NULL"));
- QDF_ASSERT(0);
- dp_peer_unref_delete(tmp_peer);
- return ret;
- }
- if (tmp_vdev->pdev->pdev_id == pdev->pdev_id)
- is_peer_found = true;
- dp_peer_unref_delete(tmp_peer);
- }
- qdf_spin_lock_bh(&soc->ast_lock);
- if (peer->delete_in_progress) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return ret;
- }
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "%s: pdevid: %u vdev: %u ast_entry->type: %d flags: 0x%x peer_mac: %pM peer: %pK mac %pM",
- __func__, pdev->pdev_id, vdev->vdev_id, type, flags,
- peer->mac_addr.raw, peer, mac_addr);
- /* fw supports only 2 times the max_peers ast entries */
- if (soc->num_ast_entries >=
- wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Max ast entries reached"));
- return ret;
- }
- /* If AST entry already exists , just return from here
- * ast entry with same mac address can exist on different radios
- * if ast_override support is enabled use search by pdev in this
- * case
- */
- if (soc->ast_override_support) {
- ast_entry = dp_peer_ast_hash_find_by_pdevid(soc, mac_addr,
- pdev->pdev_id);
- if (ast_entry) {
- if ((type == CDP_TXRX_AST_TYPE_MEC) &&
- (ast_entry->type == CDP_TXRX_AST_TYPE_MEC))
- ast_entry->is_active = TRUE;
- qdf_spin_unlock_bh(&soc->ast_lock);
- return 0;
- }
- if (is_peer_found) {
- /* During WDS to static roaming, peer is added
- * to the list before static AST entry create.
- * So, allow AST entry for STATIC type
- * even if peer is present
- */
- if (type != CDP_TXRX_AST_TYPE_STATIC) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return 0;
- }
- }
- } else {
- /* For HWMWDS_SEC entries can be added for same mac address
- * do not check for existing entry
- */
- if (type == CDP_TXRX_AST_TYPE_WDS_HM_SEC)
- goto add_ast_entry;
- ast_entry = dp_peer_ast_hash_find_soc(soc, mac_addr);
- if (ast_entry) {
- if ((type == CDP_TXRX_AST_TYPE_MEC) &&
- (ast_entry->type == CDP_TXRX_AST_TYPE_MEC))
- ast_entry->is_active = TRUE;
- if ((ast_entry->type == CDP_TXRX_AST_TYPE_WDS_HM) &&
- !ast_entry->delete_in_progress) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return 0;
- }
- /* Add for HMWDS entry we cannot be ignored if there
- * is AST entry with same mac address
- *
- * if ast entry exists with the requested mac address
- * send a delete command and register callback which
- * can take care of adding HMWDS ast enty on delete
- * confirmation from target
- */
- if ((type == CDP_TXRX_AST_TYPE_WDS_HM) &&
- soc->is_peer_map_unmap_v2) {
- struct dp_ast_free_cb_params *param = NULL;
- if (ast_entry->type ==
- CDP_TXRX_AST_TYPE_WDS_HM_SEC)
- goto add_ast_entry;
- /* save existing callback */
- if (ast_entry->callback) {
- cb = ast_entry->callback;
- cookie = ast_entry->cookie;
- }
- param = qdf_mem_malloc(sizeof(*param));
- if (!param) {
- QDF_TRACE(QDF_MODULE_ID_TXRX,
- QDF_TRACE_LEVEL_ERROR,
- "Allocation failed");
- qdf_spin_unlock_bh(&soc->ast_lock);
- return ret;
- }
- qdf_mem_copy(¶m->mac_addr.raw[0], mac_addr,
- QDF_MAC_ADDR_SIZE);
- qdf_mem_copy(¶m->peer_mac_addr.raw[0],
- &peer->mac_addr.raw[0],
- QDF_MAC_ADDR_SIZE);
- param->type = type;
- param->flags = flags;
- param->vdev_id = vdev->vdev_id;
- ast_entry->callback = dp_peer_free_hmwds_cb;
- ast_entry->pdev_id = vdev->pdev->pdev_id;
- ast_entry->type = type;
- ast_entry->cookie = (void *)param;
- if (!ast_entry->delete_in_progress)
- dp_peer_del_ast(soc, ast_entry);
- }
- /* Modify an already existing AST entry from type
- * WDS to MEC on promption. This serves as a fix when
- * backbone of interfaces are interchanged wherein
- * wds entr becomes its own MEC. The entry should be
- * replaced only when the ast_entry peer matches the
- * peer received in mec event. This additional check
- * is needed in wds repeater cases where a multicast
- * packet from station to the root via the repeater
- * should not remove the wds entry.
- */
- if ((ast_entry->type == CDP_TXRX_AST_TYPE_WDS) &&
- (type == CDP_TXRX_AST_TYPE_MEC) &&
- (ast_entry->peer == peer)) {
- ast_entry->is_active = FALSE;
- dp_peer_del_ast(soc, ast_entry);
- }
- qdf_spin_unlock_bh(&soc->ast_lock);
- /* Call the saved callback*/
- if (cb) {
- cb(soc->ctrl_psoc,
- dp_soc_to_cdp_soc(soc),
- cookie,
- CDP_TXRX_AST_DELETE_IN_PROGRESS);
- }
- return 0;
- }
- }
- add_ast_entry:
- ast_entry = (struct dp_ast_entry *)
- qdf_mem_malloc(sizeof(struct dp_ast_entry));
- if (!ast_entry) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("fail to allocate ast_entry"));
- QDF_ASSERT(0);
- return ret;
- }
- qdf_mem_copy(&ast_entry->mac_addr.raw[0], mac_addr, QDF_MAC_ADDR_SIZE);
- ast_entry->pdev_id = vdev->pdev->pdev_id;
- ast_entry->is_mapped = false;
- ast_entry->delete_in_progress = false;
- switch (type) {
- case CDP_TXRX_AST_TYPE_STATIC:
- peer->self_ast_entry = ast_entry;
- ast_entry->type = CDP_TXRX_AST_TYPE_STATIC;
- if (peer->vdev->opmode == wlan_op_mode_sta)
- ast_entry->type = CDP_TXRX_AST_TYPE_STA_BSS;
- break;
- case CDP_TXRX_AST_TYPE_SELF:
- peer->self_ast_entry = ast_entry;
- ast_entry->type = CDP_TXRX_AST_TYPE_SELF;
- break;
- case CDP_TXRX_AST_TYPE_WDS:
- ast_entry->next_hop = 1;
- ast_entry->type = CDP_TXRX_AST_TYPE_WDS;
- break;
- case CDP_TXRX_AST_TYPE_WDS_HM:
- ast_entry->next_hop = 1;
- ast_entry->type = CDP_TXRX_AST_TYPE_WDS_HM;
- break;
- case CDP_TXRX_AST_TYPE_WDS_HM_SEC:
- ast_entry->next_hop = 1;
- ast_entry->type = CDP_TXRX_AST_TYPE_WDS_HM_SEC;
- break;
- case CDP_TXRX_AST_TYPE_MEC:
- ast_entry->next_hop = 1;
- ast_entry->type = CDP_TXRX_AST_TYPE_MEC;
- break;
- case CDP_TXRX_AST_TYPE_DA:
- peer = peer->vdev->vap_bss_peer;
- ast_entry->next_hop = 1;
- ast_entry->type = CDP_TXRX_AST_TYPE_DA;
- break;
- default:
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Incorrect AST entry type"));
- }
- ast_entry->is_active = TRUE;
- DP_STATS_INC(soc, ast.added, 1);
- soc->num_ast_entries++;
- dp_peer_ast_hash_add(soc, ast_entry);
- ast_entry->peer = peer;
- if (type == CDP_TXRX_AST_TYPE_MEC)
- qdf_mem_copy(next_node_mac, peer->vdev->mac_addr.raw, 6);
- else
- qdf_mem_copy(next_node_mac, peer->mac_addr.raw, 6);
- TAILQ_INSERT_TAIL(&peer->ast_entry_list, ast_entry, ase_list_elem);
- if ((ast_entry->type != CDP_TXRX_AST_TYPE_STATIC) &&
- (ast_entry->type != CDP_TXRX_AST_TYPE_SELF) &&
- (ast_entry->type != CDP_TXRX_AST_TYPE_STA_BSS) &&
- (ast_entry->type != CDP_TXRX_AST_TYPE_WDS_HM_SEC)) {
- if (QDF_STATUS_SUCCESS ==
- soc->cdp_soc.ol_ops->peer_add_wds_entry(
- peer->vdev->osif_vdev,
- (struct cdp_peer *)peer,
- mac_addr,
- next_node_mac,
- flags)) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return 0;
- }
- }
- qdf_spin_unlock_bh(&soc->ast_lock);
- return ret;
- }
- /*
- * dp_peer_del_ast() - Delete and free AST entry
- * @soc: SoC handle
- * @ast_entry: AST entry of the node
- *
- * This function removes the AST entry from peer and soc tables
- * It assumes caller has taken the ast lock to protect the access to these
- * tables
- *
- * Return: None
- */
- void dp_peer_del_ast(struct dp_soc *soc, struct dp_ast_entry *ast_entry)
- {
- struct dp_peer *peer;
- if (!ast_entry)
- return;
- peer = ast_entry->peer;
- dp_peer_ast_send_wds_del(soc, ast_entry);
- /*
- * release the reference only if it is mapped
- * to ast_table
- */
- if (ast_entry->is_mapped)
- soc->ast_table[ast_entry->ast_idx] = NULL;
- /*
- * if peer map v2 is enabled we are not freeing ast entry
- * here and it is supposed to be freed in unmap event (after
- * we receive delete confirmation from target)
- *
- * if peer_id is invalid we did not get the peer map event
- * for the peer free ast entry from here only in this case
- */
- if (soc->is_peer_map_unmap_v2) {
- /*
- * For HM_SEC and SELF type we do not receive unmap event
- * free ast_entry from here it self
- */
- if ((ast_entry->type != CDP_TXRX_AST_TYPE_WDS_HM_SEC) &&
- (ast_entry->type != CDP_TXRX_AST_TYPE_SELF))
- return;
- }
- /* SELF and STATIC entries are removed in teardown itself */
- if (ast_entry->next_hop)
- TAILQ_REMOVE(&peer->ast_entry_list, ast_entry, ase_list_elem);
- DP_STATS_INC(soc, ast.deleted, 1);
- dp_peer_ast_hash_remove(soc, ast_entry);
- dp_peer_ast_cleanup(soc, ast_entry);
- qdf_mem_free(ast_entry);
- soc->num_ast_entries--;
- }
- /*
- * dp_peer_update_ast() - Delete and free AST entry
- * @soc: SoC handle
- * @peer: peer to which ast node belongs
- * @ast_entry: AST entry of the node
- * @flags: wds or hmwds
- *
- * This function update the AST entry to the roamed peer and soc tables
- * It assumes caller has taken the ast lock to protect the access to these
- * tables
- *
- * Return: 0 if ast entry is updated successfully
- * -1 failure
- */
- int dp_peer_update_ast(struct dp_soc *soc, struct dp_peer *peer,
- struct dp_ast_entry *ast_entry, uint32_t flags)
- {
- int ret = -1;
- struct dp_peer *old_peer;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "%s: ast_entry->type: %d pdevid: %u vdevid: %u flags: 0x%x mac_addr: %pM peer_mac: %pM\n",
- __func__, ast_entry->type, peer->vdev->pdev->pdev_id,
- peer->vdev->vdev_id, flags, ast_entry->mac_addr.raw,
- peer->mac_addr.raw);
- /* Do not send AST update in below cases
- * 1) Ast entry delete has already triggered
- * 2) Peer delete is already triggered
- * 3) We did not get the HTT map for create event
- */
- if (ast_entry->delete_in_progress || peer->delete_in_progress ||
- !ast_entry->is_mapped)
- return ret;
- if ((ast_entry->type == CDP_TXRX_AST_TYPE_STATIC) ||
- (ast_entry->type == CDP_TXRX_AST_TYPE_SELF) ||
- (ast_entry->type == CDP_TXRX_AST_TYPE_STA_BSS) ||
- (ast_entry->type == CDP_TXRX_AST_TYPE_WDS_HM_SEC))
- return 0;
- /*
- * Avoids flood of WMI update messages sent to FW for same peer.
- */
- if (qdf_unlikely(ast_entry->peer == peer) &&
- (ast_entry->type == CDP_TXRX_AST_TYPE_WDS) &&
- (ast_entry->peer->vdev == peer->vdev) &&
- (ast_entry->is_active))
- return 0;
- old_peer = ast_entry->peer;
- TAILQ_REMOVE(&old_peer->ast_entry_list, ast_entry, ase_list_elem);
- ast_entry->peer = peer;
- ast_entry->type = CDP_TXRX_AST_TYPE_WDS;
- ast_entry->pdev_id = peer->vdev->pdev->pdev_id;
- ast_entry->is_active = TRUE;
- TAILQ_INSERT_TAIL(&peer->ast_entry_list, ast_entry, ase_list_elem);
- ret = soc->cdp_soc.ol_ops->peer_update_wds_entry(
- peer->vdev->osif_vdev,
- ast_entry->mac_addr.raw,
- peer->mac_addr.raw,
- flags);
- return ret;
- }
- /*
- * dp_peer_ast_get_pdev_id() - get pdev_id from the ast entry
- * @soc: SoC handle
- * @ast_entry: AST entry of the node
- *
- * This function gets the pdev_id from the ast entry.
- *
- * Return: (uint8_t) pdev_id
- */
- uint8_t dp_peer_ast_get_pdev_id(struct dp_soc *soc,
- struct dp_ast_entry *ast_entry)
- {
- return ast_entry->pdev_id;
- }
- /*
- * dp_peer_ast_get_next_hop() - get next_hop from the ast entry
- * @soc: SoC handle
- * @ast_entry: AST entry of the node
- *
- * This function gets the next hop from the ast entry.
- *
- * Return: (uint8_t) next_hop
- */
- uint8_t dp_peer_ast_get_next_hop(struct dp_soc *soc,
- struct dp_ast_entry *ast_entry)
- {
- return ast_entry->next_hop;
- }
- /*
- * dp_peer_ast_set_type() - set type from the ast entry
- * @soc: SoC handle
- * @ast_entry: AST entry of the node
- *
- * This function sets the type in the ast entry.
- *
- * Return:
- */
- void dp_peer_ast_set_type(struct dp_soc *soc,
- struct dp_ast_entry *ast_entry,
- enum cdp_txrx_ast_entry_type type)
- {
- ast_entry->type = type;
- }
- #else
- int dp_peer_add_ast(struct dp_soc *soc, struct dp_peer *peer,
- uint8_t *mac_addr, enum cdp_txrx_ast_entry_type type,
- uint32_t flags)
- {
- return 1;
- }
- void dp_peer_del_ast(struct dp_soc *soc, struct dp_ast_entry *ast_entry)
- {
- }
- int dp_peer_update_ast(struct dp_soc *soc, struct dp_peer *peer,
- struct dp_ast_entry *ast_entry, uint32_t flags)
- {
- return 1;
- }
- struct dp_ast_entry *dp_peer_ast_hash_find_soc(struct dp_soc *soc,
- uint8_t *ast_mac_addr)
- {
- return NULL;
- }
- struct dp_ast_entry *dp_peer_ast_hash_find_by_pdevid(struct dp_soc *soc,
- uint8_t *ast_mac_addr,
- uint8_t pdev_id)
- {
- return NULL;
- }
- static int dp_peer_ast_hash_attach(struct dp_soc *soc)
- {
- return 0;
- }
- static inline void dp_peer_map_ast(struct dp_soc *soc,
- struct dp_peer *peer, uint8_t *mac_addr, uint16_t hw_peer_id,
- uint8_t vdev_id, uint16_t ast_hash)
- {
- return;
- }
- static void dp_peer_ast_hash_detach(struct dp_soc *soc)
- {
- }
- void dp_peer_ast_set_type(struct dp_soc *soc,
- struct dp_ast_entry *ast_entry,
- enum cdp_txrx_ast_entry_type type)
- {
- }
- uint8_t dp_peer_ast_get_pdev_id(struct dp_soc *soc,
- struct dp_ast_entry *ast_entry)
- {
- return 0xff;
- }
- uint8_t dp_peer_ast_get_next_hop(struct dp_soc *soc,
- struct dp_ast_entry *ast_entry)
- {
- return 0xff;
- }
- int dp_peer_update_ast(struct dp_soc *soc, struct dp_peer *peer,
- struct dp_ast_entry *ast_entry, uint32_t flags)
- {
- return 1;
- }
- #endif
- void dp_peer_ast_send_wds_del(struct dp_soc *soc,
- struct dp_ast_entry *ast_entry)
- {
- struct dp_peer *peer = ast_entry->peer;
- struct cdp_soc_t *cdp_soc = &soc->cdp_soc;
- if (ast_entry->delete_in_progress)
- return;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_TRACE,
- "%s: ast_entry->type: %d pdevid: %u vdev: %u mac_addr: %pM next_hop: %u peer_mac: %pM\n",
- __func__, ast_entry->type, peer->vdev->pdev->pdev_id,
- peer->vdev->vdev_id, ast_entry->mac_addr.raw,
- ast_entry->next_hop, ast_entry->peer->mac_addr.raw);
- if (ast_entry->next_hop) {
- cdp_soc->ol_ops->peer_del_wds_entry(peer->vdev->osif_vdev,
- ast_entry->mac_addr.raw,
- ast_entry->type);
- }
- /* Remove SELF and STATIC entries in teardown itself */
- if (!ast_entry->next_hop) {
- TAILQ_REMOVE(&peer->ast_entry_list, ast_entry, ase_list_elem);
- peer->self_ast_entry = NULL;
- ast_entry->peer = NULL;
- }
- ast_entry->delete_in_progress = true;
- }
- /**
- * dp_peer_ast_free_entry_by_mac() - find ast entry by MAC address and delete
- * @soc: soc handle
- * @peer: peer handle
- * @mac_addr: mac address of the AST entry to searc and delete
- *
- * find the ast entry from the peer list using the mac address and free
- * the entry.
- *
- * Return: SUCCESS or NOENT
- */
- static int dp_peer_ast_free_entry_by_mac(struct dp_soc *soc,
- struct dp_peer *peer,
- uint8_t *mac_addr)
- {
- struct dp_ast_entry *ast_entry;
- void *cookie = NULL;
- txrx_ast_free_cb cb = NULL;
- /*
- * release the reference only if it is mapped
- * to ast_table
- */
- qdf_spin_lock_bh(&soc->ast_lock);
- ast_entry = dp_peer_ast_list_find(soc, peer, mac_addr);
- if (!ast_entry) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return QDF_STATUS_E_NOENT;
- } else if (ast_entry->is_mapped) {
- soc->ast_table[ast_entry->ast_idx] = NULL;
- }
- TAILQ_REMOVE(&peer->ast_entry_list, ast_entry, ase_list_elem);
- DP_STATS_INC(soc, ast.deleted, 1);
- dp_peer_ast_hash_remove(soc, ast_entry);
- cb = ast_entry->callback;
- cookie = ast_entry->cookie;
- ast_entry->callback = NULL;
- ast_entry->cookie = NULL;
- if (ast_entry == peer->self_ast_entry)
- peer->self_ast_entry = NULL;
- soc->num_ast_entries--;
- qdf_spin_unlock_bh(&soc->ast_lock);
- if (cb) {
- cb(soc->ctrl_psoc,
- dp_soc_to_cdp_soc(soc),
- cookie,
- CDP_TXRX_AST_DELETED);
- }
- qdf_mem_free(ast_entry);
- return QDF_STATUS_SUCCESS;
- }
- struct dp_peer *dp_peer_find_hash_find(struct dp_soc *soc,
- uint8_t *peer_mac_addr, int mac_addr_is_aligned, uint8_t vdev_id)
- {
- union dp_align_mac_addr local_mac_addr_aligned, *mac_addr;
- unsigned index;
- struct dp_peer *peer;
- if (mac_addr_is_aligned) {
- mac_addr = (union dp_align_mac_addr *) peer_mac_addr;
- } else {
- qdf_mem_copy(
- &local_mac_addr_aligned.raw[0],
- peer_mac_addr, QDF_MAC_ADDR_SIZE);
- mac_addr = &local_mac_addr_aligned;
- }
- index = dp_peer_find_hash_index(soc, mac_addr);
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- TAILQ_FOREACH(peer, &soc->peer_hash.bins[index], hash_list_elem) {
- #if ATH_SUPPORT_WRAP
- /* ProxySTA may have multiple BSS peer with same MAC address,
- * modified find will take care of finding the correct BSS peer.
- */
- if (dp_peer_find_mac_addr_cmp(mac_addr, &peer->mac_addr) == 0 &&
- ((peer->vdev->vdev_id == vdev_id) ||
- (vdev_id == DP_VDEV_ALL))) {
- #else
- if (dp_peer_find_mac_addr_cmp(mac_addr, &peer->mac_addr) == 0) {
- #endif
- /* found it - increment the ref count before releasing
- * the lock
- */
- qdf_atomic_inc(&peer->ref_cnt);
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- return peer;
- }
- }
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- return NULL; /* failure */
- }
- void dp_peer_find_hash_remove(struct dp_soc *soc, struct dp_peer *peer)
- {
- unsigned index;
- struct dp_peer *tmppeer = NULL;
- int found = 0;
- index = dp_peer_find_hash_index(soc, &peer->mac_addr);
- /* Check if tail is not empty before delete*/
- QDF_ASSERT(!TAILQ_EMPTY(&soc->peer_hash.bins[index]));
- /*
- * DO NOT take the peer_ref_mutex lock here - it needs to be taken
- * by the caller.
- * The caller needs to hold the lock from the time the peer object's
- * reference count is decremented and tested up through the time the
- * reference to the peer object is removed from the hash table, by
- * this function.
- * Holding the lock only while removing the peer object reference
- * from the hash table keeps the hash table consistent, but does not
- * protect against a new HL tx context starting to use the peer object
- * if it looks up the peer object from its MAC address just after the
- * peer ref count is decremented to zero, but just before the peer
- * object reference is removed from the hash table.
- */
- TAILQ_FOREACH(tmppeer, &soc->peer_hash.bins[index], hash_list_elem) {
- if (tmppeer == peer) {
- found = 1;
- break;
- }
- }
- QDF_ASSERT(found);
- TAILQ_REMOVE(&soc->peer_hash.bins[index], peer, hash_list_elem);
- }
- void dp_peer_find_hash_erase(struct dp_soc *soc)
- {
- int i;
- /*
- * Not really necessary to take peer_ref_mutex lock - by this point,
- * it's known that the soc is no longer in use.
- */
- for (i = 0; i <= soc->peer_hash.mask; i++) {
- if (!TAILQ_EMPTY(&soc->peer_hash.bins[i])) {
- struct dp_peer *peer, *peer_next;
- /*
- * TAILQ_FOREACH_SAFE must be used here to avoid any
- * memory access violation after peer is freed
- */
- TAILQ_FOREACH_SAFE(peer, &soc->peer_hash.bins[i],
- hash_list_elem, peer_next) {
- /*
- * Don't remove the peer from the hash table -
- * that would modify the list we are currently
- * traversing, and it's not necessary anyway.
- */
- /*
- * Artificially adjust the peer's ref count to
- * 1, so it will get deleted by
- * dp_peer_unref_delete.
- */
- /* set to zero */
- qdf_atomic_init(&peer->ref_cnt);
- /* incr to one */
- qdf_atomic_inc(&peer->ref_cnt);
- dp_peer_unref_delete(peer);
- }
- }
- }
- }
- static void dp_peer_ast_table_detach(struct dp_soc *soc)
- {
- if (soc->ast_table) {
- qdf_mem_free(soc->ast_table);
- soc->ast_table = NULL;
- }
- }
- static void dp_peer_find_map_detach(struct dp_soc *soc)
- {
- if (soc->peer_id_to_obj_map) {
- qdf_mem_free(soc->peer_id_to_obj_map);
- soc->peer_id_to_obj_map = NULL;
- }
- }
- int dp_peer_find_attach(struct dp_soc *soc)
- {
- if (dp_peer_find_map_attach(soc))
- return 1;
- if (dp_peer_find_hash_attach(soc)) {
- dp_peer_find_map_detach(soc);
- return 1;
- }
- if (dp_peer_ast_table_attach(soc)) {
- dp_peer_find_hash_detach(soc);
- dp_peer_find_map_detach(soc);
- return 1;
- }
- if (dp_peer_ast_hash_attach(soc)) {
- dp_peer_ast_table_detach(soc);
- dp_peer_find_hash_detach(soc);
- dp_peer_find_map_detach(soc);
- return 1;
- }
- return 0; /* success */
- }
- void dp_rx_tid_stats_cb(struct dp_soc *soc, void *cb_ctxt,
- union hal_reo_status *reo_status)
- {
- struct dp_rx_tid *rx_tid = (struct dp_rx_tid *)cb_ctxt;
- struct hal_reo_queue_status *queue_status = &(reo_status->queue_status);
- if (queue_status->header.status == HAL_REO_CMD_DRAIN)
- return;
- if (queue_status->header.status != HAL_REO_CMD_SUCCESS) {
- DP_PRINT_STATS("REO stats failure %d for TID %d\n",
- queue_status->header.status, rx_tid->tid);
- return;
- }
- DP_PRINT_STATS("REO queue stats (TID: %d):\n"
- "ssn: %d\n"
- "curr_idx : %d\n"
- "pn_31_0 : %08x\n"
- "pn_63_32 : %08x\n"
- "pn_95_64 : %08x\n"
- "pn_127_96 : %08x\n"
- "last_rx_enq_tstamp : %08x\n"
- "last_rx_deq_tstamp : %08x\n"
- "rx_bitmap_31_0 : %08x\n"
- "rx_bitmap_63_32 : %08x\n"
- "rx_bitmap_95_64 : %08x\n"
- "rx_bitmap_127_96 : %08x\n"
- "rx_bitmap_159_128 : %08x\n"
- "rx_bitmap_191_160 : %08x\n"
- "rx_bitmap_223_192 : %08x\n"
- "rx_bitmap_255_224 : %08x\n",
- rx_tid->tid,
- queue_status->ssn, queue_status->curr_idx,
- queue_status->pn_31_0, queue_status->pn_63_32,
- queue_status->pn_95_64, queue_status->pn_127_96,
- queue_status->last_rx_enq_tstamp,
- queue_status->last_rx_deq_tstamp,
- queue_status->rx_bitmap_31_0,
- queue_status->rx_bitmap_63_32,
- queue_status->rx_bitmap_95_64,
- queue_status->rx_bitmap_127_96,
- queue_status->rx_bitmap_159_128,
- queue_status->rx_bitmap_191_160,
- queue_status->rx_bitmap_223_192,
- queue_status->rx_bitmap_255_224);
- DP_PRINT_STATS(
- "curr_mpdu_cnt : %d\n"
- "curr_msdu_cnt : %d\n"
- "fwd_timeout_cnt : %d\n"
- "fwd_bar_cnt : %d\n"
- "dup_cnt : %d\n"
- "frms_in_order_cnt : %d\n"
- "bar_rcvd_cnt : %d\n"
- "mpdu_frms_cnt : %d\n"
- "msdu_frms_cnt : %d\n"
- "total_byte_cnt : %d\n"
- "late_recv_mpdu_cnt : %d\n"
- "win_jump_2k : %d\n"
- "hole_cnt : %d\n",
- queue_status->curr_mpdu_cnt,
- queue_status->curr_msdu_cnt,
- queue_status->fwd_timeout_cnt,
- queue_status->fwd_bar_cnt,
- queue_status->dup_cnt,
- queue_status->frms_in_order_cnt,
- queue_status->bar_rcvd_cnt,
- queue_status->mpdu_frms_cnt,
- queue_status->msdu_frms_cnt,
- queue_status->total_cnt,
- queue_status->late_recv_mpdu_cnt,
- queue_status->win_jump_2k,
- queue_status->hole_cnt);
- DP_PRINT_STATS("Addba Req : %d\n"
- "Addba Resp : %d\n"
- "Addba Resp success : %d\n"
- "Addba Resp failed : %d\n"
- "Delba Req received : %d\n"
- "Delba Tx success : %d\n"
- "Delba Tx Fail : %d\n"
- "BA window size : %d\n"
- "Pn size : %d\n",
- rx_tid->num_of_addba_req,
- rx_tid->num_of_addba_resp,
- rx_tid->num_addba_rsp_success,
- rx_tid->num_addba_rsp_failed,
- rx_tid->num_of_delba_req,
- rx_tid->delba_tx_success_cnt,
- rx_tid->delba_tx_fail_cnt,
- rx_tid->ba_win_size,
- rx_tid->pn_size);
- }
- static inline struct dp_peer *dp_peer_find_add_id(struct dp_soc *soc,
- uint8_t *peer_mac_addr, uint16_t peer_id, uint16_t hw_peer_id,
- uint8_t vdev_id)
- {
- struct dp_peer *peer;
- QDF_ASSERT(peer_id <= soc->max_peers);
- /* check if there's already a peer object with this MAC address */
- peer = dp_peer_find_hash_find(soc, peer_mac_addr,
- 0 /* is aligned */, vdev_id);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: peer %pK ID %d vid %d mac %02x:%02x:%02x:%02x:%02x:%02x",
- __func__, peer, peer_id, vdev_id, peer_mac_addr[0],
- peer_mac_addr[1], peer_mac_addr[2], peer_mac_addr[3],
- peer_mac_addr[4], peer_mac_addr[5]);
- if (peer) {
- /* peer's ref count was already incremented by
- * peer_find_hash_find
- */
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- "%s: ref_cnt: %d", __func__,
- qdf_atomic_read(&peer->ref_cnt));
- if (!soc->peer_id_to_obj_map[peer_id])
- soc->peer_id_to_obj_map[peer_id] = peer;
- else {
- /* Peer map event came for peer_id which
- * is already mapped, this is not expected
- */
- QDF_ASSERT(0);
- }
- if (dp_peer_find_add_id_to_obj(peer, peer_id)) {
- /* TBDXXX: assert for now */
- QDF_ASSERT(0);
- }
- return peer;
- }
- return NULL;
- }
- /**
- * dp_rx_peer_map_handler() - handle peer map event from firmware
- * @soc_handle - genereic soc handle
- * @peeri_id - peer_id from firmware
- * @hw_peer_id - ast index for this peer
- * @vdev_id - vdev ID
- * @peer_mac_addr - mac address of the peer
- * @ast_hash - ast hash value
- * @is_wds - flag to indicate peer map event for WDS ast entry
- *
- * associate the peer_id that firmware provided with peer entry
- * and update the ast table in the host with the hw_peer_id.
- *
- * Return: none
- */
- void
- dp_rx_peer_map_handler(struct dp_soc *soc, uint16_t peer_id,
- uint16_t hw_peer_id, uint8_t vdev_id,
- uint8_t *peer_mac_addr, uint16_t ast_hash,
- uint8_t is_wds)
- {
- struct dp_peer *peer = NULL;
- enum cdp_txrx_ast_entry_type type = CDP_TXRX_AST_TYPE_STATIC;
- dp_info("peer_map_event (soc:%pK): peer_id %d, hw_peer_id %d, peer_mac %02x:%02x:%02x:%02x:%02x:%02x, vdev_id %d",
- soc, peer_id, hw_peer_id, peer_mac_addr[0], peer_mac_addr[1],
- peer_mac_addr[2], peer_mac_addr[3], peer_mac_addr[4],
- peer_mac_addr[5], vdev_id);
- /* Peer map event for WDS ast entry get the peer from
- * obj map
- */
- if (is_wds) {
- peer = soc->peer_id_to_obj_map[peer_id];
- /*
- * In certain cases like Auth attack on a repeater
- * can result in the number of ast_entries falling
- * in the same hash bucket to exceed the max_skid
- * length supported by HW in root AP. In these cases
- * the FW will return the hw_peer_id (ast_index) as
- * 0xffff indicating HW could not add the entry in
- * its table. Host has to delete the entry from its
- * table in these cases.
- */
- if (hw_peer_id == HTT_INVALID_PEER) {
- DP_STATS_INC(soc, ast.map_err, 1);
- if (!dp_peer_ast_free_entry_by_mac(soc,
- peer,
- peer_mac_addr))
- return;
- dp_alert("AST entry not found with peer %pK peer_id %u peer_mac %pM mac_addr %pM vdev_id %u next_hop %u",
- peer, peer->peer_ids[0],
- peer->mac_addr.raw, peer_mac_addr, vdev_id,
- is_wds);
- return;
- }
- } else {
- /*
- * It's the responsibility of the CP and FW to ensure
- * that peer is created successfully. Ideally DP should
- * not hit the below condition for directly assocaited
- * peers.
- */
- if ((hw_peer_id < 0) ||
- (hw_peer_id >=
- wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx))) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "invalid hw_peer_id: %d", hw_peer_id);
- qdf_assert_always(0);
- }
- peer = dp_peer_find_add_id(soc, peer_mac_addr, peer_id,
- hw_peer_id, vdev_id);
- if (peer) {
- if (wlan_op_mode_sta == peer->vdev->opmode &&
- qdf_mem_cmp(peer->mac_addr.raw,
- peer->vdev->mac_addr.raw,
- QDF_MAC_ADDR_SIZE) != 0) {
- dp_info("STA vdev bss_peer!!!!");
- peer->bss_peer = 1;
- peer->vdev->vap_bss_peer = peer;
- }
- if (peer->vdev->opmode == wlan_op_mode_sta) {
- peer->vdev->bss_ast_hash = ast_hash;
- peer->vdev->bss_ast_idx = hw_peer_id;
- }
- /* Add ast entry incase self ast entry is
- * deleted due to DP CP sync issue
- *
- * self_ast_entry is modified in peer create
- * and peer unmap path which cannot run in
- * parllel with peer map, no lock need before
- * referring it
- */
- if (!peer->self_ast_entry) {
- dp_info("Add self ast from map %pM",
- peer_mac_addr);
- dp_peer_add_ast(soc, peer,
- peer_mac_addr,
- type, 0);
- }
- }
- }
- dp_peer_map_ast(soc, peer, peer_mac_addr,
- hw_peer_id, vdev_id, ast_hash);
- }
- /**
- * dp_rx_peer_unmap_handler() - handle peer unmap event from firmware
- * @soc_handle - genereic soc handle
- * @peeri_id - peer_id from firmware
- * @vdev_id - vdev ID
- * @mac_addr - mac address of the peer or wds entry
- * @is_wds - flag to indicate peer map event for WDS ast entry
- *
- * Return: none
- */
- void
- dp_rx_peer_unmap_handler(struct dp_soc *soc, uint16_t peer_id,
- uint8_t vdev_id, uint8_t *mac_addr,
- uint8_t is_wds)
- {
- struct dp_peer *peer;
- uint8_t i;
- peer = __dp_peer_find_by_id(soc, peer_id);
- /*
- * Currently peer IDs are assigned for vdevs as well as peers.
- * If the peer ID is for a vdev, then the peer pointer stored
- * in peer_id_to_obj_map will be NULL.
- */
- if (!peer) {
- dp_err("Received unmap event for invalid peer_id %u", peer_id);
- return;
- }
- /* If V2 Peer map messages are enabled AST entry has to be freed here
- */
- if (soc->is_peer_map_unmap_v2 && is_wds) {
- if (!dp_peer_ast_free_entry_by_mac(soc, peer, mac_addr))
- return;
- dp_alert("AST entry not found with peer %pK peer_id %u peer_mac %pM mac_addr %pM vdev_id %u next_hop %u",
- peer, peer->peer_ids[0],
- peer->mac_addr.raw, mac_addr, vdev_id,
- is_wds);
- return;
- }
- dp_info("peer_unmap_event (soc:%pK) peer_id %d peer %pK",
- soc, peer_id, peer);
- soc->peer_id_to_obj_map[peer_id] = NULL;
- for (i = 0; i < MAX_NUM_PEER_ID_PER_PEER; i++) {
- if (peer->peer_ids[i] == peer_id) {
- peer->peer_ids[i] = HTT_INVALID_PEER;
- break;
- }
- }
- if (soc->cdp_soc.ol_ops->peer_unmap_event) {
- soc->cdp_soc.ol_ops->peer_unmap_event(soc->ctrl_psoc,
- peer_id, vdev_id);
- }
- /*
- * Remove a reference to the peer.
- * If there are no more references, delete the peer object.
- */
- dp_peer_unref_delete(peer);
- }
- void
- dp_peer_find_detach(struct dp_soc *soc)
- {
- dp_peer_find_map_detach(soc);
- dp_peer_find_hash_detach(soc);
- dp_peer_ast_hash_detach(soc);
- dp_peer_ast_table_detach(soc);
- }
- static void dp_rx_tid_update_cb(struct dp_soc *soc, void *cb_ctxt,
- union hal_reo_status *reo_status)
- {
- struct dp_rx_tid *rx_tid = (struct dp_rx_tid *)cb_ctxt;
- if ((reo_status->rx_queue_status.header.status !=
- HAL_REO_CMD_SUCCESS) &&
- (reo_status->rx_queue_status.header.status !=
- HAL_REO_CMD_DRAIN)) {
- /* Should not happen normally. Just print error for now */
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Rx tid HW desc update failed(%d): tid %d",
- __func__,
- reo_status->rx_queue_status.header.status,
- rx_tid->tid);
- }
- }
- /*
- * dp_find_peer_by_addr - find peer instance by mac address
- * @dev: physical device instance
- * @peer_mac_addr: peer mac address
- * @local_id: local id for the peer
- *
- * Return: peer instance pointer
- */
- void *dp_find_peer_by_addr(struct cdp_pdev *dev, uint8_t *peer_mac_addr,
- uint8_t *local_id)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)dev;
- struct dp_peer *peer;
- peer = dp_peer_find_hash_find(pdev->soc, peer_mac_addr, 0, DP_VDEV_ALL);
- if (!peer)
- return NULL;
- /* Multiple peer ids? How can know peer id? */
- *local_id = peer->local_id;
- dp_verbose_debug("peer %pK id %d", peer, *local_id);
- /* ref_cnt is incremented inside dp_peer_find_hash_find().
- * Decrement it here.
- */
- dp_peer_unref_delete(peer);
- return peer;
- }
- static bool dp_get_peer_vdev_roaming_in_progress(struct dp_peer *peer)
- {
- struct ol_if_ops *ol_ops = NULL;
- bool is_roaming = false;
- uint8_t vdev_id = -1;
- if (!peer) {
- dp_info("Peer is NULL. No roaming possible");
- return false;
- }
- ol_ops = peer->vdev->pdev->soc->cdp_soc.ol_ops;
- if (ol_ops && ol_ops->is_roam_inprogress) {
- dp_get_vdevid(peer, &vdev_id);
- is_roaming = ol_ops->is_roam_inprogress(vdev_id);
- }
- dp_info("peer: %pM, vdev_id: %d, is_roaming: %d",
- peer->mac_addr.raw, vdev_id, is_roaming);
- return is_roaming;
- }
- /*
- * dp_rx_tid_update_wifi3() – Update receive TID state
- * @peer: Datapath peer handle
- * @tid: TID
- * @ba_window_size: BlockAck window size
- * @start_seq: Starting sequence number
- *
- * Return: QDF_STATUS code
- */
- static QDF_STATUS dp_rx_tid_update_wifi3(struct dp_peer *peer, int tid, uint32_t
- ba_window_size, uint32_t start_seq)
- {
- struct dp_rx_tid *rx_tid = &peer->rx_tid[tid];
- struct dp_soc *soc = peer->vdev->pdev->soc;
- struct hal_reo_cmd_params params;
- qdf_mem_zero(¶ms, sizeof(params));
- params.std.need_status = 1;
- params.std.addr_lo = rx_tid->hw_qdesc_paddr & 0xffffffff;
- params.std.addr_hi = (uint64_t)(rx_tid->hw_qdesc_paddr) >> 32;
- params.u.upd_queue_params.update_ba_window_size = 1;
- params.u.upd_queue_params.ba_window_size = ba_window_size;
- if (start_seq < IEEE80211_SEQ_MAX) {
- params.u.upd_queue_params.update_ssn = 1;
- params.u.upd_queue_params.ssn = start_seq;
- } else {
- dp_set_ssn_valid_flag(¶ms, 0);
- }
- dp_reo_send_cmd(soc, CMD_UPDATE_RX_REO_QUEUE, ¶ms,
- dp_rx_tid_update_cb, rx_tid);
- rx_tid->ba_win_size = ba_window_size;
- if (dp_get_peer_vdev_roaming_in_progress(peer))
- return QDF_STATUS_E_PERM;
- if (soc->cdp_soc.ol_ops->peer_rx_reorder_queue_setup)
- soc->cdp_soc.ol_ops->peer_rx_reorder_queue_setup(
- peer->vdev->pdev->ctrl_pdev,
- peer->vdev->vdev_id, peer->mac_addr.raw,
- rx_tid->hw_qdesc_paddr, tid, tid, 1, ba_window_size);
- return QDF_STATUS_SUCCESS;
- }
- /*
- * dp_reo_desc_free() - Callback free reo descriptor memory after
- * HW cache flush
- *
- * @soc: DP SOC handle
- * @cb_ctxt: Callback context
- * @reo_status: REO command status
- */
- static void dp_reo_desc_free(struct dp_soc *soc, void *cb_ctxt,
- union hal_reo_status *reo_status)
- {
- struct reo_desc_list_node *freedesc =
- (struct reo_desc_list_node *)cb_ctxt;
- struct dp_rx_tid *rx_tid = &freedesc->rx_tid;
- if ((reo_status->fl_cache_status.header.status !=
- HAL_REO_CMD_SUCCESS) &&
- (reo_status->fl_cache_status.header.status !=
- HAL_REO_CMD_DRAIN)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Rx tid HW desc flush failed(%d): tid %d",
- __func__,
- reo_status->rx_queue_status.header.status,
- freedesc->rx_tid.tid);
- }
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
- "%s: hw_qdesc_paddr: %pK, tid:%d", __func__,
- (void *)(rx_tid->hw_qdesc_paddr), rx_tid->tid);
- qdf_mem_unmap_nbytes_single(soc->osdev,
- rx_tid->hw_qdesc_paddr,
- QDF_DMA_BIDIRECTIONAL,
- rx_tid->hw_qdesc_alloc_size);
- qdf_mem_free(rx_tid->hw_qdesc_vaddr_unaligned);
- qdf_mem_free(freedesc);
- }
- #if defined(QCA_WIFI_QCA8074_VP) && defined(BUILD_X86)
- /* Hawkeye emulation requires bus address to be >= 0x50000000 */
- static inline int dp_reo_desc_addr_chk(qdf_dma_addr_t dma_addr)
- {
- if (dma_addr < 0x50000000)
- return QDF_STATUS_E_FAILURE;
- else
- return QDF_STATUS_SUCCESS;
- }
- #else
- static inline int dp_reo_desc_addr_chk(qdf_dma_addr_t dma_addr)
- {
- return QDF_STATUS_SUCCESS;
- }
- #endif
- /*
- * dp_rx_tid_setup_wifi3() – Setup receive TID state
- * @peer: Datapath peer handle
- * @tid: TID
- * @ba_window_size: BlockAck window size
- * @start_seq: Starting sequence number
- *
- * Return: QDF_STATUS code
- */
- QDF_STATUS dp_rx_tid_setup_wifi3(struct dp_peer *peer, int tid,
- uint32_t ba_window_size, uint32_t start_seq)
- {
- struct dp_rx_tid *rx_tid = &peer->rx_tid[tid];
- struct dp_vdev *vdev = peer->vdev;
- struct dp_soc *soc = vdev->pdev->soc;
- uint32_t hw_qdesc_size;
- uint32_t hw_qdesc_align;
- int hal_pn_type;
- void *hw_qdesc_vaddr;
- uint32_t alloc_tries = 0;
- QDF_STATUS err = QDF_STATUS_SUCCESS;
- if (peer->delete_in_progress ||
- !qdf_atomic_read(&peer->is_default_route_set))
- return QDF_STATUS_E_FAILURE;
- rx_tid->ba_win_size = ba_window_size;
- if (rx_tid->hw_qdesc_vaddr_unaligned)
- return dp_rx_tid_update_wifi3(peer, tid, ba_window_size,
- start_seq);
- rx_tid->delba_tx_status = 0;
- rx_tid->ppdu_id_2k = 0;
- rx_tid->num_of_addba_req = 0;
- rx_tid->num_of_delba_req = 0;
- rx_tid->num_of_addba_resp = 0;
- rx_tid->num_addba_rsp_failed = 0;
- rx_tid->num_addba_rsp_success = 0;
- rx_tid->delba_tx_success_cnt = 0;
- rx_tid->delba_tx_fail_cnt = 0;
- rx_tid->statuscode = 0;
- /* TODO: Allocating HW queue descriptors based on max BA window size
- * for all QOS TIDs so that same descriptor can be used later when
- * ADDBA request is recevied. This should be changed to allocate HW
- * queue descriptors based on BA window size being negotiated (0 for
- * non BA cases), and reallocate when BA window size changes and also
- * send WMI message to FW to change the REO queue descriptor in Rx
- * peer entry as part of dp_rx_tid_update.
- */
- if (tid != DP_NON_QOS_TID)
- hw_qdesc_size = hal_get_reo_qdesc_size(soc->hal_soc,
- HAL_RX_MAX_BA_WINDOW, tid);
- else
- hw_qdesc_size = hal_get_reo_qdesc_size(soc->hal_soc,
- ba_window_size, tid);
- hw_qdesc_align = hal_get_reo_qdesc_align(soc->hal_soc);
- /* To avoid unnecessary extra allocation for alignment, try allocating
- * exact size and see if we already have aligned address.
- */
- rx_tid->hw_qdesc_alloc_size = hw_qdesc_size;
- try_desc_alloc:
- rx_tid->hw_qdesc_vaddr_unaligned =
- qdf_mem_malloc(rx_tid->hw_qdesc_alloc_size);
- if (!rx_tid->hw_qdesc_vaddr_unaligned) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Rx tid HW desc alloc failed: tid %d",
- __func__, tid);
- return QDF_STATUS_E_NOMEM;
- }
- if ((unsigned long)(rx_tid->hw_qdesc_vaddr_unaligned) %
- hw_qdesc_align) {
- /* Address allocated above is not alinged. Allocate extra
- * memory for alignment
- */
- qdf_mem_free(rx_tid->hw_qdesc_vaddr_unaligned);
- rx_tid->hw_qdesc_vaddr_unaligned =
- qdf_mem_malloc(rx_tid->hw_qdesc_alloc_size +
- hw_qdesc_align - 1);
- if (!rx_tid->hw_qdesc_vaddr_unaligned) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Rx tid HW desc alloc failed: tid %d",
- __func__, tid);
- return QDF_STATUS_E_NOMEM;
- }
- hw_qdesc_vaddr = (void *)qdf_align((unsigned long)
- rx_tid->hw_qdesc_vaddr_unaligned,
- hw_qdesc_align);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "%s: Total Size %d Aligned Addr %pK",
- __func__, rx_tid->hw_qdesc_alloc_size,
- hw_qdesc_vaddr);
- } else {
- hw_qdesc_vaddr = rx_tid->hw_qdesc_vaddr_unaligned;
- }
- /* TODO: Ensure that sec_type is set before ADDBA is received.
- * Currently this is set based on htt indication
- * HTT_T2H_MSG_TYPE_SEC_IND from target
- */
- switch (peer->security[dp_sec_ucast].sec_type) {
- case cdp_sec_type_tkip_nomic:
- case cdp_sec_type_aes_ccmp:
- case cdp_sec_type_aes_ccmp_256:
- case cdp_sec_type_aes_gcmp:
- case cdp_sec_type_aes_gcmp_256:
- hal_pn_type = HAL_PN_WPA;
- break;
- case cdp_sec_type_wapi:
- if (vdev->opmode == wlan_op_mode_ap)
- hal_pn_type = HAL_PN_WAPI_EVEN;
- else
- hal_pn_type = HAL_PN_WAPI_UNEVEN;
- break;
- default:
- hal_pn_type = HAL_PN_NONE;
- break;
- }
- hal_reo_qdesc_setup(soc->hal_soc, tid, ba_window_size, start_seq,
- hw_qdesc_vaddr, rx_tid->hw_qdesc_paddr, hal_pn_type);
- qdf_mem_map_nbytes_single(soc->osdev, hw_qdesc_vaddr,
- QDF_DMA_BIDIRECTIONAL, rx_tid->hw_qdesc_alloc_size,
- &(rx_tid->hw_qdesc_paddr));
- if (dp_reo_desc_addr_chk(rx_tid->hw_qdesc_paddr) !=
- QDF_STATUS_SUCCESS) {
- if (alloc_tries++ < 10) {
- qdf_mem_free(rx_tid->hw_qdesc_vaddr_unaligned);
- rx_tid->hw_qdesc_vaddr_unaligned = NULL;
- goto try_desc_alloc;
- } else {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Rx tid HW desc alloc failed (lowmem): tid %d",
- __func__, tid);
- err = QDF_STATUS_E_NOMEM;
- goto error;
- }
- }
- if (dp_get_peer_vdev_roaming_in_progress(peer)) {
- err = QDF_STATUS_E_PERM;
- goto error;
- }
- if (soc->cdp_soc.ol_ops->peer_rx_reorder_queue_setup) {
- if (soc->cdp_soc.ol_ops->peer_rx_reorder_queue_setup(
- vdev->pdev->ctrl_pdev, peer->vdev->vdev_id,
- peer->mac_addr.raw, rx_tid->hw_qdesc_paddr, tid, tid,
- 1, ba_window_size)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Failed to send reo queue setup to FW - tid %d\n",
- __func__, tid);
- err = QDF_STATUS_E_FAILURE;
- goto error;
- }
- }
- return 0;
- error:
- if (rx_tid->hw_qdesc_vaddr_unaligned) {
- if (dp_reo_desc_addr_chk(rx_tid->hw_qdesc_paddr) ==
- QDF_STATUS_SUCCESS)
- qdf_mem_unmap_nbytes_single(
- soc->osdev,
- rx_tid->hw_qdesc_paddr,
- QDF_DMA_BIDIRECTIONAL,
- rx_tid->hw_qdesc_alloc_size);
- qdf_mem_free(rx_tid->hw_qdesc_vaddr_unaligned);
- rx_tid->hw_qdesc_vaddr_unaligned = NULL;
- }
- return err;
- }
- #ifdef REO_DESC_DEFER_FREE
- /*
- * dp_reo_desc_clean_up() - If cmd to flush base desc fails add
- * desc back to freelist and defer the deletion
- *
- * @soc: DP SOC handle
- * @desc: Base descriptor to be freed
- * @reo_status: REO command status
- */
- static void dp_reo_desc_clean_up(struct dp_soc *soc,
- struct reo_desc_list_node *desc,
- union hal_reo_status *reo_status)
- {
- desc->free_ts = qdf_get_system_timestamp();
- DP_STATS_INC(soc, rx.err.reo_cmd_send_fail, 1);
- qdf_list_insert_back(&soc->reo_desc_freelist,
- (qdf_list_node_t *)desc);
- }
- #else
- /*
- * dp_reo_desc_clean_up() - If send cmd to REO inorder to flush
- * cache fails free the base REO desc anyway
- *
- * @soc: DP SOC handle
- * @desc: Base descriptor to be freed
- * @reo_status: REO command status
- */
- static void dp_reo_desc_clean_up(struct dp_soc *soc,
- struct reo_desc_list_node *desc,
- union hal_reo_status *reo_status)
- {
- if (reo_status) {
- qdf_mem_zero(reo_status, sizeof(*reo_status));
- reo_status->fl_cache_status.header.status = 0;
- dp_reo_desc_free(soc, (void *)desc, reo_status);
- }
- }
- #endif
- /*
- * dp_resend_update_reo_cmd() - Resend the UPDATE_REO_QUEUE
- * cmd and re-insert desc into free list if send fails.
- *
- * @soc: DP SOC handle
- * @desc: desc with resend update cmd flag set
- * @rx_tid: Desc RX tid associated with update cmd for resetting
- * valid field to 0 in h/w
- */
- static void dp_resend_update_reo_cmd(struct dp_soc *soc,
- struct reo_desc_list_node *desc,
- struct dp_rx_tid *rx_tid)
- {
- struct hal_reo_cmd_params params;
- qdf_mem_zero(¶ms, sizeof(params));
- params.std.need_status = 1;
- params.std.addr_lo =
- rx_tid->hw_qdesc_paddr & 0xffffffff;
- params.std.addr_hi =
- (uint64_t)(rx_tid->hw_qdesc_paddr) >> 32;
- params.u.upd_queue_params.update_vld = 1;
- params.u.upd_queue_params.vld = 0;
- desc->resend_update_reo_cmd = false;
- /*
- * If the cmd send fails then set resend_update_reo_cmd flag
- * and insert the desc at the end of the free list to retry.
- */
- if (dp_reo_send_cmd(soc,
- CMD_UPDATE_RX_REO_QUEUE,
- ¶ms,
- dp_rx_tid_delete_cb,
- (void *)desc)
- != QDF_STATUS_SUCCESS) {
- desc->resend_update_reo_cmd = true;
- desc->free_ts = qdf_get_system_timestamp();
- qdf_list_insert_back(&soc->reo_desc_freelist,
- (qdf_list_node_t *)desc);
- DP_STATS_INC(soc, rx.err.reo_cmd_send_fail, 1);
- }
- }
- /*
- * dp_rx_tid_delete_cb() - Callback to flush reo descriptor HW cache
- * after deleting the entries (ie., setting valid=0)
- *
- * @soc: DP SOC handle
- * @cb_ctxt: Callback context
- * @reo_status: REO command status
- */
- void dp_rx_tid_delete_cb(struct dp_soc *soc, void *cb_ctxt,
- union hal_reo_status *reo_status)
- {
- struct reo_desc_list_node *freedesc =
- (struct reo_desc_list_node *)cb_ctxt;
- uint32_t list_size;
- struct reo_desc_list_node *desc;
- unsigned long curr_ts = qdf_get_system_timestamp();
- uint32_t desc_size, tot_desc_size;
- struct hal_reo_cmd_params params;
- if (reo_status->rx_queue_status.header.status == HAL_REO_CMD_DRAIN) {
- qdf_mem_zero(reo_status, sizeof(*reo_status));
- reo_status->fl_cache_status.header.status = HAL_REO_CMD_DRAIN;
- dp_reo_desc_free(soc, (void *)freedesc, reo_status);
- return;
- } else if (reo_status->rx_queue_status.header.status !=
- HAL_REO_CMD_SUCCESS) {
- /* Should not happen normally. Just print error for now */
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Rx tid HW desc deletion failed(%d): tid %d",
- __func__,
- reo_status->rx_queue_status.header.status,
- freedesc->rx_tid.tid);
- }
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
- "%s: rx_tid: %d status: %d", __func__,
- freedesc->rx_tid.tid,
- reo_status->rx_queue_status.header.status);
- qdf_spin_lock_bh(&soc->reo_desc_freelist_lock);
- freedesc->free_ts = curr_ts;
- qdf_list_insert_back_size(&soc->reo_desc_freelist,
- (qdf_list_node_t *)freedesc, &list_size);
- while ((qdf_list_peek_front(&soc->reo_desc_freelist,
- (qdf_list_node_t **)&desc) == QDF_STATUS_SUCCESS) &&
- ((list_size >= REO_DESC_FREELIST_SIZE) ||
- (curr_ts > (desc->free_ts + REO_DESC_FREE_DEFER_MS)) ||
- (desc->resend_update_reo_cmd && list_size))) {
- struct dp_rx_tid *rx_tid;
- qdf_list_remove_front(&soc->reo_desc_freelist,
- (qdf_list_node_t **)&desc);
- list_size--;
- rx_tid = &desc->rx_tid;
- /* First process descs with resend_update_reo_cmd set */
- if (desc->resend_update_reo_cmd) {
- dp_resend_update_reo_cmd(soc, desc, rx_tid);
- continue;
- }
- /* Flush and invalidate REO descriptor from HW cache: Base and
- * extension descriptors should be flushed separately */
- tot_desc_size = rx_tid->hw_qdesc_alloc_size;
- /* Get base descriptor size by passing non-qos TID */
- desc_size = hal_get_reo_qdesc_size(soc->hal_soc, 0,
- DP_NON_QOS_TID);
- /* Flush reo extension descriptors */
- while ((tot_desc_size -= desc_size) > 0) {
- qdf_mem_zero(¶ms, sizeof(params));
- params.std.addr_lo =
- ((uint64_t)(rx_tid->hw_qdesc_paddr) +
- tot_desc_size) & 0xffffffff;
- params.std.addr_hi =
- (uint64_t)(rx_tid->hw_qdesc_paddr) >> 32;
- if (QDF_STATUS_SUCCESS != dp_reo_send_cmd(soc,
- CMD_FLUSH_CACHE,
- ¶ms,
- NULL,
- NULL)) {
- dp_err_log("fail to send CMD_CACHE_FLUSH:"
- "tid %d desc %pK", rx_tid->tid,
- (void *)(rx_tid->hw_qdesc_paddr));
- }
- }
- /* Flush base descriptor */
- qdf_mem_zero(¶ms, sizeof(params));
- params.std.need_status = 1;
- params.std.addr_lo =
- (uint64_t)(rx_tid->hw_qdesc_paddr) & 0xffffffff;
- params.std.addr_hi = (uint64_t)(rx_tid->hw_qdesc_paddr) >> 32;
- if (QDF_STATUS_SUCCESS != dp_reo_send_cmd(soc,
- CMD_FLUSH_CACHE,
- ¶ms,
- dp_reo_desc_free,
- (void *)desc)) {
- union hal_reo_status reo_status;
- /*
- * If dp_reo_send_cmd return failure, related TID queue desc
- * should be unmapped. Also locally reo_desc, together with
- * TID queue desc also need to be freed accordingly.
- *
- * Here invoke desc_free function directly to do clean up.
- *
- * In case of MCL path add the desc back to the free
- * desc list and defer deletion.
- */
- dp_err_log("%s: fail to send REO cmd to flush cache: tid %d",
- __func__, rx_tid->tid);
- dp_reo_desc_clean_up(soc, desc, &reo_status);
- }
- }
- qdf_spin_unlock_bh(&soc->reo_desc_freelist_lock);
- }
- /*
- * dp_rx_tid_delete_wifi3() – Delete receive TID queue
- * @peer: Datapath peer handle
- * @tid: TID
- *
- * Return: 0 on success, error code on failure
- */
- static int dp_rx_tid_delete_wifi3(struct dp_peer *peer, int tid)
- {
- struct dp_rx_tid *rx_tid = &(peer->rx_tid[tid]);
- struct dp_soc *soc = peer->vdev->pdev->soc;
- struct hal_reo_cmd_params params;
- struct reo_desc_list_node *freedesc =
- qdf_mem_malloc(sizeof(*freedesc));
- if (!freedesc) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: malloc failed for freedesc: tid %d",
- __func__, tid);
- return -ENOMEM;
- }
- freedesc->rx_tid = *rx_tid;
- freedesc->resend_update_reo_cmd = false;
- qdf_mem_zero(¶ms, sizeof(params));
- params.std.need_status = 1;
- params.std.addr_lo = rx_tid->hw_qdesc_paddr & 0xffffffff;
- params.std.addr_hi = (uint64_t)(rx_tid->hw_qdesc_paddr) >> 32;
- params.u.upd_queue_params.update_vld = 1;
- params.u.upd_queue_params.vld = 0;
- if (dp_reo_send_cmd(soc, CMD_UPDATE_RX_REO_QUEUE, ¶ms,
- dp_rx_tid_delete_cb, (void *)freedesc)
- != QDF_STATUS_SUCCESS) {
- /* Defer the clean up to the call back context */
- qdf_spin_lock_bh(&soc->reo_desc_freelist_lock);
- freedesc->free_ts = qdf_get_system_timestamp();
- freedesc->resend_update_reo_cmd = true;
- qdf_list_insert_front(&soc->reo_desc_freelist,
- (qdf_list_node_t *)freedesc);
- DP_STATS_INC(soc, rx.err.reo_cmd_send_fail, 1);
- qdf_spin_unlock_bh(&soc->reo_desc_freelist_lock);
- dp_info("Failed to send CMD_UPDATE_RX_REO_QUEUE");
- }
- rx_tid->hw_qdesc_vaddr_unaligned = NULL;
- rx_tid->hw_qdesc_alloc_size = 0;
- rx_tid->hw_qdesc_paddr = 0;
- return 0;
- }
- #ifdef DP_LFR
- static void dp_peer_setup_remaining_tids(struct dp_peer *peer)
- {
- int tid;
- for (tid = 1; tid < DP_MAX_TIDS-1; tid++) {
- dp_rx_tid_setup_wifi3(peer, tid, 1, 0);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "Setting up TID %d for peer %pK peer->local_id %d",
- tid, peer, peer->local_id);
- }
- }
- #else
- static void dp_peer_setup_remaining_tids(struct dp_peer *peer) {};
- #endif
- #ifndef WLAN_TX_PKT_CAPTURE_ENH
- /*
- * dp_peer_tid_queue_init() – Initialize ppdu stats queue per TID
- * @peer: Datapath peer
- *
- */
- static inline void dp_peer_tid_queue_init(struct dp_peer *peer)
- {
- }
- /*
- * dp_peer_tid_queue_cleanup() – remove ppdu stats queue per TID
- * @peer: Datapath peer
- *
- */
- static inline void dp_peer_tid_queue_cleanup(struct dp_peer *peer)
- {
- }
- /*
- * dp_peer_update_80211_hdr() – dp peer update 80211 hdr
- * @vdev: Datapath vdev
- * @peer: Datapath peer
- *
- */
- static inline void
- dp_peer_update_80211_hdr(struct dp_vdev *vdev, struct dp_peer *peer)
- {
- }
- #endif
- /*
- * dp_peer_tx_init() – Initialize receive TID state
- * @pdev: Datapath pdev
- * @peer: Datapath peer
- *
- */
- void dp_peer_tx_init(struct dp_pdev *pdev, struct dp_peer *peer)
- {
- dp_peer_tid_queue_init(peer);
- dp_peer_update_80211_hdr(peer->vdev, peer);
- }
- /*
- * dp_peer_tx_cleanup() – Deinitialize receive TID state
- * @vdev: Datapath vdev
- * @peer: Datapath peer
- *
- */
- static inline void
- dp_peer_tx_cleanup(struct dp_vdev *vdev, struct dp_peer *peer)
- {
- dp_peer_tid_queue_cleanup(peer);
- }
- /*
- * dp_peer_rx_init() – Initialize receive TID state
- * @pdev: Datapath pdev
- * @peer: Datapath peer
- *
- */
- void dp_peer_rx_init(struct dp_pdev *pdev, struct dp_peer *peer)
- {
- int tid;
- struct dp_rx_tid *rx_tid;
- for (tid = 0; tid < DP_MAX_TIDS; tid++) {
- rx_tid = &peer->rx_tid[tid];
- rx_tid->array = &rx_tid->base;
- rx_tid->base.head = rx_tid->base.tail = NULL;
- rx_tid->tid = tid;
- rx_tid->defrag_timeout_ms = 0;
- rx_tid->ba_win_size = 0;
- rx_tid->ba_status = DP_RX_BA_INACTIVE;
- rx_tid->defrag_waitlist_elem.tqe_next = NULL;
- rx_tid->defrag_waitlist_elem.tqe_prev = NULL;
- }
- peer->active_ba_session_cnt = 0;
- peer->hw_buffer_size = 0;
- peer->kill_256_sessions = 0;
- /* Setup default (non-qos) rx tid queue */
- dp_rx_tid_setup_wifi3(peer, DP_NON_QOS_TID, 1, 0);
- /* Setup rx tid queue for TID 0.
- * Other queues will be setup on receiving first packet, which will cause
- * NULL REO queue error
- */
- dp_rx_tid_setup_wifi3(peer, 0, 1, 0);
- /*
- * Setup the rest of TID's to handle LFR
- */
- dp_peer_setup_remaining_tids(peer);
- /*
- * Set security defaults: no PN check, no security. The target may
- * send a HTT SEC_IND message to overwrite these defaults.
- */
- peer->security[dp_sec_ucast].sec_type =
- peer->security[dp_sec_mcast].sec_type = cdp_sec_type_none;
- }
- /*
- * dp_peer_rx_cleanup() – Cleanup receive TID state
- * @vdev: Datapath vdev
- * @peer: Datapath peer
- * @reuse: Peer reference reuse
- *
- */
- void dp_peer_rx_cleanup(struct dp_vdev *vdev, struct dp_peer *peer, bool reuse)
- {
- int tid;
- uint32_t tid_delete_mask = 0;
- dp_info("Remove tids for peer: %pK", peer);
- for (tid = 0; tid < DP_MAX_TIDS; tid++) {
- struct dp_rx_tid *rx_tid = &peer->rx_tid[tid];
- qdf_spin_lock_bh(&rx_tid->tid_lock);
- if (!peer->bss_peer || peer->vdev->opmode == wlan_op_mode_sta) {
- /* Cleanup defrag related resource */
- dp_rx_defrag_waitlist_remove(peer, tid);
- dp_rx_reorder_flush_frag(peer, tid);
- }
- if (peer->rx_tid[tid].hw_qdesc_vaddr_unaligned) {
- dp_rx_tid_delete_wifi3(peer, tid);
- tid_delete_mask |= (1 << tid);
- }
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- }
- #ifdef notyet /* See if FW can remove queues as part of peer cleanup */
- if (soc->ol_ops->peer_rx_reorder_queue_remove) {
- soc->ol_ops->peer_rx_reorder_queue_remove(vdev->pdev->ctrl_pdev,
- peer->vdev->vdev_id, peer->mac_addr.raw,
- tid_delete_mask);
- }
- #endif
- if (!reuse)
- for (tid = 0; tid < DP_MAX_TIDS; tid++)
- qdf_spinlock_destroy(&peer->rx_tid[tid].tid_lock);
- }
- #ifdef FEATURE_PERPKT_INFO
- /*
- * dp_peer_ppdu_delayed_ba_init() Initialize ppdu in peer
- * @peer: Datapath peer
- *
- * return: void
- */
- void dp_peer_ppdu_delayed_ba_init(struct dp_peer *peer)
- {
- qdf_mem_zero(&peer->delayed_ba_ppdu_stats,
- sizeof(struct cdp_delayed_tx_completion_ppdu_user));
- peer->last_delayed_ba = false;
- peer->last_delayed_ba_ppduid = 0;
- }
- #else
- /*
- * dp_peer_ppdu_delayed_ba_init() Initialize ppdu in peer
- * @peer: Datapath peer
- *
- * return: void
- */
- void dp_peer_ppdu_delayed_ba_init(struct dp_peer *peer)
- {
- }
- #endif
- /*
- * dp_peer_cleanup() – Cleanup peer information
- * @vdev: Datapath vdev
- * @peer: Datapath peer
- * @reuse: Peer reference reuse
- *
- */
- void dp_peer_cleanup(struct dp_vdev *vdev, struct dp_peer *peer, bool reuse)
- {
- dp_peer_tx_cleanup(vdev, peer);
- /* cleanup the Rx reorder queues for this peer */
- dp_peer_rx_cleanup(vdev, peer, reuse);
- }
- /* dp_teardown_256_ba_session() - Teardown sessions using 256
- * window size when a request with
- * 64 window size is received.
- * This is done as a WAR since HW can
- * have only one setting per peer (64 or 256).
- * For HKv2, we use per tid buffersize setting
- * for 0 to per_tid_basize_max_tid. For tid
- * more than per_tid_basize_max_tid we use HKv1
- * method.
- * @peer: Datapath peer
- *
- * Return: void
- */
- static void dp_teardown_256_ba_sessions(struct dp_peer *peer)
- {
- uint8_t delba_rcode = 0;
- int tid;
- struct dp_rx_tid *rx_tid = NULL;
- tid = peer->vdev->pdev->soc->per_tid_basize_max_tid;
- for (; tid < DP_MAX_TIDS; tid++) {
- rx_tid = &peer->rx_tid[tid];
- qdf_spin_lock_bh(&rx_tid->tid_lock);
- if (rx_tid->ba_win_size <= 64) {
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- continue;
- } else {
- if (rx_tid->ba_status == DP_RX_BA_ACTIVE ||
- rx_tid->ba_status == DP_RX_BA_IN_PROGRESS) {
- /* send delba */
- if (!rx_tid->delba_tx_status) {
- rx_tid->delba_tx_retry++;
- rx_tid->delba_tx_status = 1;
- rx_tid->delba_rcode =
- IEEE80211_REASON_QOS_SETUP_REQUIRED;
- delba_rcode = rx_tid->delba_rcode;
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- if (peer->vdev->pdev->soc->cdp_soc.ol_ops->send_delba)
- peer->vdev->pdev->soc->cdp_soc.ol_ops->send_delba(
- peer->vdev->pdev->ctrl_pdev,
- peer->ctrl_peer,
- peer->mac_addr.raw,
- tid, peer->vdev->ctrl_vdev,
- delba_rcode);
- } else {
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- }
- } else {
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- }
- }
- }
- }
- /*
- * dp_rx_addba_resp_tx_completion_wifi3() – Update Rx Tid State
- *
- * @peer: Datapath peer handle
- * @tid: TID number
- * @status: tx completion status
- * Return: 0 on success, error code on failure
- */
- int dp_addba_resp_tx_completion_wifi3(void *peer_handle,
- uint8_t tid, int status)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- struct dp_rx_tid *rx_tid = NULL;
- QDF_STATUS qdf_status;
- if (!peer || peer->delete_in_progress) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "%s: Peer is NULL!\n", __func__);
- return QDF_STATUS_E_FAILURE;
- }
- rx_tid = &peer->rx_tid[tid];
- qdf_spin_lock_bh(&rx_tid->tid_lock);
- if (status) {
- rx_tid->num_addba_rsp_failed++;
- qdf_status = dp_rx_tid_update_wifi3(peer, tid, 1,
- IEEE80211_SEQ_MAX);
- if (qdf_status == QDF_STATUS_SUCCESS)
- rx_tid->ba_status = DP_RX_BA_INACTIVE;
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- dp_err("RxTid- %d addba rsp tx completion failed", tid);
- return QDF_STATUS_SUCCESS;
- }
- rx_tid->num_addba_rsp_success++;
- if (rx_tid->ba_status == DP_RX_BA_INACTIVE) {
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Rx Tid- %d hw qdesc is not in IN_PROGRESS",
- __func__, tid);
- return QDF_STATUS_E_FAILURE;
- }
- if (!qdf_atomic_read(&peer->is_default_route_set)) {
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "%s: default route is not set for peer: %pM",
- __func__, peer->mac_addr.raw);
- return QDF_STATUS_E_FAILURE;
- }
- /* First Session */
- if (peer->active_ba_session_cnt == 0) {
- if (rx_tid->ba_win_size > 64 && rx_tid->ba_win_size <= 256)
- peer->hw_buffer_size = 256;
- else
- peer->hw_buffer_size = 64;
- }
- rx_tid->ba_status = DP_RX_BA_ACTIVE;
- peer->active_ba_session_cnt++;
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- /* Kill any session having 256 buffer size
- * when 64 buffer size request is received.
- * Also, latch on to 64 as new buffer size.
- */
- if (peer->kill_256_sessions) {
- dp_teardown_256_ba_sessions(peer);
- peer->kill_256_sessions = 0;
- }
- return QDF_STATUS_SUCCESS;
- }
- /*
- * dp_rx_addba_responsesetup_wifi3() – Process ADDBA request from peer
- *
- * @peer: Datapath peer handle
- * @tid: TID number
- * @dialogtoken: output dialogtoken
- * @statuscode: output dialogtoken
- * @buffersize: Output BA window size
- * @batimeout: Output BA timeout
- */
- void dp_addba_responsesetup_wifi3(void *peer_handle, uint8_t tid,
- uint8_t *dialogtoken, uint16_t *statuscode,
- uint16_t *buffersize, uint16_t *batimeout)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- struct dp_rx_tid *rx_tid = NULL;
- if (!peer || peer->delete_in_progress) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "%s: Peer is NULL!\n", __func__);
- return;
- }
- rx_tid = &peer->rx_tid[tid];
- qdf_spin_lock_bh(&rx_tid->tid_lock);
- rx_tid->num_of_addba_resp++;
- /* setup ADDBA response parameters */
- *dialogtoken = rx_tid->dialogtoken;
- *statuscode = rx_tid->statuscode;
- *buffersize = rx_tid->ba_win_size;
- *batimeout = 0;
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- }
- /* dp_check_ba_buffersize() - Check buffer size in request
- * and latch onto this size based on
- * size used in first active session.
- * @peer: Datapath peer
- * @tid: Tid
- * @buffersize: Block ack window size
- *
- * Return: void
- */
- static void dp_check_ba_buffersize(struct dp_peer *peer,
- uint16_t tid,
- uint16_t buffersize)
- {
- struct dp_rx_tid *rx_tid = NULL;
- rx_tid = &peer->rx_tid[tid];
- if (peer->vdev->pdev->soc->per_tid_basize_max_tid &&
- tid < peer->vdev->pdev->soc->per_tid_basize_max_tid) {
- rx_tid->ba_win_size = buffersize;
- return;
- } else {
- if (peer->active_ba_session_cnt == 0) {
- rx_tid->ba_win_size = buffersize;
- } else {
- if (peer->hw_buffer_size == 64) {
- if (buffersize <= 64)
- rx_tid->ba_win_size = buffersize;
- else
- rx_tid->ba_win_size = peer->hw_buffer_size;
- } else if (peer->hw_buffer_size == 256) {
- if (buffersize > 64) {
- rx_tid->ba_win_size = buffersize;
- } else {
- rx_tid->ba_win_size = buffersize;
- peer->hw_buffer_size = 64;
- peer->kill_256_sessions = 1;
- }
- }
- }
- }
- }
- /*
- * dp_addba_requestprocess_wifi3() - Process ADDBA request from peer
- *
- * @peer: Datapath peer handle
- * @dialogtoken: dialogtoken from ADDBA frame
- * @tid: TID number
- * @batimeout: BA timeout
- * @buffersize: BA window size
- * @startseqnum: Start seq. number received in BA sequence control
- *
- * Return: 0 on success, error code on failure
- */
- int dp_addba_requestprocess_wifi3(void *peer_handle,
- uint8_t dialogtoken,
- uint16_t tid, uint16_t batimeout,
- uint16_t buffersize,
- uint16_t startseqnum)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- struct dp_rx_tid *rx_tid = NULL;
- if (!peer || peer->delete_in_progress) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "%s: Peer is NULL!\n", __func__);
- return QDF_STATUS_E_FAILURE;
- }
- rx_tid = &peer->rx_tid[tid];
- qdf_spin_lock_bh(&rx_tid->tid_lock);
- rx_tid->num_of_addba_req++;
- if ((rx_tid->ba_status == DP_RX_BA_ACTIVE &&
- rx_tid->hw_qdesc_vaddr_unaligned)) {
- dp_rx_tid_update_wifi3(peer, tid, 1, IEEE80211_SEQ_MAX);
- rx_tid->ba_status = DP_RX_BA_INACTIVE;
- peer->active_ba_session_cnt--;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "%s: Addba recvd for Rx Tid-%d hw qdesc is already setup",
- __func__, tid);
- }
- if (rx_tid->ba_status == DP_RX_BA_IN_PROGRESS) {
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- return QDF_STATUS_E_FAILURE;
- }
- dp_check_ba_buffersize(peer, tid, buffersize);
- if (dp_rx_tid_setup_wifi3(peer, tid,
- rx_tid->ba_win_size, startseqnum)) {
- rx_tid->ba_status = DP_RX_BA_INACTIVE;
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- return QDF_STATUS_E_FAILURE;
- }
- rx_tid->ba_status = DP_RX_BA_IN_PROGRESS;
- rx_tid->dialogtoken = dialogtoken;
- rx_tid->startseqnum = startseqnum;
- if (rx_tid->userstatuscode != IEEE80211_STATUS_SUCCESS)
- rx_tid->statuscode = rx_tid->userstatuscode;
- else
- rx_tid->statuscode = IEEE80211_STATUS_SUCCESS;
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- return QDF_STATUS_SUCCESS;
- }
- /*
- * dp_set_addba_response() – Set a user defined ADDBA response status code
- *
- * @peer: Datapath peer handle
- * @tid: TID number
- * @statuscode: response status code to be set
- */
- void dp_set_addba_response(void *peer_handle, uint8_t tid,
- uint16_t statuscode)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- struct dp_rx_tid *rx_tid = &peer->rx_tid[tid];
- qdf_spin_lock_bh(&rx_tid->tid_lock);
- rx_tid->userstatuscode = statuscode;
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- }
- /*
- * dp_rx_delba_process_wifi3() – Process DELBA from peer
- * @peer: Datapath peer handle
- * @tid: TID number
- * @reasoncode: Reason code received in DELBA frame
- *
- * Return: 0 on success, error code on failure
- */
- int dp_delba_process_wifi3(void *peer_handle,
- int tid, uint16_t reasoncode)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- struct dp_rx_tid *rx_tid = &peer->rx_tid[tid];
- qdf_spin_lock_bh(&rx_tid->tid_lock);
- if (rx_tid->ba_status == DP_RX_BA_INACTIVE ||
- rx_tid->ba_status == DP_RX_BA_IN_PROGRESS) {
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- return QDF_STATUS_E_FAILURE;
- }
- /* TODO: See if we can delete the existing REO queue descriptor and
- * replace with a new one without queue extenstion descript to save
- * memory
- */
- rx_tid->delba_rcode = reasoncode;
- rx_tid->num_of_delba_req++;
- dp_rx_tid_update_wifi3(peer, tid, 1, IEEE80211_SEQ_MAX);
- rx_tid->ba_status = DP_RX_BA_INACTIVE;
- peer->active_ba_session_cnt--;
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- return 0;
- }
- /*
- * dp_rx_delba_tx_completion_wifi3() – Send Delba Request
- *
- * @peer: Datapath peer handle
- * @tid: TID number
- * @status: tx completion status
- * Return: 0 on success, error code on failure
- */
- int dp_delba_tx_completion_wifi3(void *peer_handle,
- uint8_t tid, int status)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- struct dp_rx_tid *rx_tid = NULL;
- if (!peer || peer->delete_in_progress) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "%s: Peer is NULL!", __func__);
- return QDF_STATUS_E_FAILURE;
- }
- rx_tid = &peer->rx_tid[tid];
- qdf_spin_lock_bh(&rx_tid->tid_lock);
- if (status) {
- rx_tid->delba_tx_fail_cnt++;
- if (rx_tid->delba_tx_retry >= DP_MAX_DELBA_RETRY) {
- rx_tid->delba_tx_retry = 0;
- rx_tid->delba_tx_status = 0;
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- } else {
- rx_tid->delba_tx_retry++;
- rx_tid->delba_tx_status = 1;
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- if (peer->vdev->pdev->soc->cdp_soc.ol_ops->send_delba)
- peer->vdev->pdev->soc->cdp_soc.ol_ops->send_delba(
- peer->vdev->pdev->ctrl_pdev, peer->ctrl_peer,
- peer->mac_addr.raw, tid, peer->vdev->ctrl_vdev,
- rx_tid->delba_rcode);
- }
- return QDF_STATUS_SUCCESS;
- } else {
- rx_tid->delba_tx_success_cnt++;
- rx_tid->delba_tx_retry = 0;
- rx_tid->delba_tx_status = 0;
- }
- if (rx_tid->ba_status == DP_RX_BA_ACTIVE) {
- dp_rx_tid_update_wifi3(peer, tid, 1, IEEE80211_SEQ_MAX);
- rx_tid->ba_status = DP_RX_BA_INACTIVE;
- peer->active_ba_session_cnt--;
- }
- if (rx_tid->ba_status == DP_RX_BA_IN_PROGRESS) {
- dp_rx_tid_update_wifi3(peer, tid, 1, IEEE80211_SEQ_MAX);
- rx_tid->ba_status = DP_RX_BA_INACTIVE;
- }
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- return QDF_STATUS_SUCCESS;
- }
- /**
- * dp_set_pn_check_wifi3() - enable PN check in REO for security
- * @peer: Datapath peer handle
- * @vdev: Datapath vdev
- * @pdev - data path device instance
- * @sec_type - security type
- * @rx_pn - Receive pn starting number
- *
- */
- void
- dp_set_pn_check_wifi3(struct cdp_vdev *vdev_handle, struct cdp_peer *peer_handle, enum cdp_sec_type sec_type, uint32_t *rx_pn)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev;
- struct dp_soc *soc;
- int i;
- uint8_t pn_size;
- struct hal_reo_cmd_params params;
- /* preconditions */
- qdf_assert(vdev);
- pdev = vdev->pdev;
- soc = pdev->soc;
- qdf_mem_zero(¶ms, sizeof(params));
- params.std.need_status = 1;
- params.u.upd_queue_params.update_pn_valid = 1;
- params.u.upd_queue_params.update_pn_size = 1;
- params.u.upd_queue_params.update_pn = 1;
- params.u.upd_queue_params.update_pn_check_needed = 1;
- params.u.upd_queue_params.update_svld = 1;
- params.u.upd_queue_params.svld = 0;
- peer->security[dp_sec_ucast].sec_type = sec_type;
- switch (sec_type) {
- case cdp_sec_type_tkip_nomic:
- case cdp_sec_type_aes_ccmp:
- case cdp_sec_type_aes_ccmp_256:
- case cdp_sec_type_aes_gcmp:
- case cdp_sec_type_aes_gcmp_256:
- params.u.upd_queue_params.pn_check_needed = 1;
- params.u.upd_queue_params.pn_size = 48;
- pn_size = 48;
- break;
- case cdp_sec_type_wapi:
- params.u.upd_queue_params.pn_check_needed = 1;
- params.u.upd_queue_params.pn_size = 128;
- pn_size = 128;
- if (vdev->opmode == wlan_op_mode_ap) {
- params.u.upd_queue_params.pn_even = 1;
- params.u.upd_queue_params.update_pn_even = 1;
- } else {
- params.u.upd_queue_params.pn_uneven = 1;
- params.u.upd_queue_params.update_pn_uneven = 1;
- }
- break;
- default:
- params.u.upd_queue_params.pn_check_needed = 0;
- pn_size = 0;
- break;
- }
- for (i = 0; i < DP_MAX_TIDS; i++) {
- struct dp_rx_tid *rx_tid = &peer->rx_tid[i];
- qdf_spin_lock_bh(&rx_tid->tid_lock);
- if (rx_tid->hw_qdesc_vaddr_unaligned) {
- params.std.addr_lo =
- rx_tid->hw_qdesc_paddr & 0xffffffff;
- params.std.addr_hi =
- (uint64_t)(rx_tid->hw_qdesc_paddr) >> 32;
- if (pn_size) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_INFO_HIGH,
- "%s PN set for TID:%d pn:%x:%x:%x:%x",
- __func__, i, rx_pn[3], rx_pn[2],
- rx_pn[1], rx_pn[0]);
- params.u.upd_queue_params.update_pn_valid = 1;
- params.u.upd_queue_params.pn_31_0 = rx_pn[0];
- params.u.upd_queue_params.pn_63_32 = rx_pn[1];
- params.u.upd_queue_params.pn_95_64 = rx_pn[2];
- params.u.upd_queue_params.pn_127_96 = rx_pn[3];
- }
- rx_tid->pn_size = pn_size;
- dp_reo_send_cmd(soc, CMD_UPDATE_RX_REO_QUEUE, ¶ms,
- dp_rx_tid_update_cb, rx_tid);
- } else {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
- "PN Check not setup for TID :%d ", i);
- }
- qdf_spin_unlock_bh(&rx_tid->tid_lock);
- }
- }
- void
- dp_rx_sec_ind_handler(struct dp_soc *soc, uint16_t peer_id,
- enum cdp_sec_type sec_type, int is_unicast,
- u_int32_t *michael_key,
- u_int32_t *rx_pn)
- {
- struct dp_peer *peer;
- int sec_index;
- peer = dp_peer_find_by_id(soc, peer_id);
- if (!peer) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "Couldn't find peer from ID %d - skipping security inits",
- peer_id);
- return;
- }
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
- "sec spec for peer %pK (%02x:%02x:%02x:%02x:%02x:%02x): %s key of type %d",
- peer,
- peer->mac_addr.raw[0], peer->mac_addr.raw[1],
- peer->mac_addr.raw[2], peer->mac_addr.raw[3],
- peer->mac_addr.raw[4], peer->mac_addr.raw[5],
- is_unicast ? "ucast" : "mcast",
- sec_type);
- sec_index = is_unicast ? dp_sec_ucast : dp_sec_mcast;
- peer->security[sec_index].sec_type = sec_type;
- #ifdef notyet /* TODO: See if this is required for defrag support */
- /* michael key only valid for TKIP, but for simplicity,
- * copy it anyway
- */
- qdf_mem_copy(
- &peer->security[sec_index].michael_key[0],
- michael_key,
- sizeof(peer->security[sec_index].michael_key));
- #ifdef BIG_ENDIAN_HOST
- OL_IF_SWAPBO(peer->security[sec_index].michael_key[0],
- sizeof(peer->security[sec_index].michael_key));
- #endif /* BIG_ENDIAN_HOST */
- #endif
- #ifdef notyet /* TODO: Check if this is required for wifi3.0 */
- if (sec_type != cdp_sec_type_wapi) {
- qdf_mem_zero(peer->tids_last_pn_valid, _EXT_TIDS);
- } else {
- for (i = 0; i < DP_MAX_TIDS; i++) {
- /*
- * Setting PN valid bit for WAPI sec_type,
- * since WAPI PN has to be started with predefined value
- */
- peer->tids_last_pn_valid[i] = 1;
- qdf_mem_copy(
- (u_int8_t *) &peer->tids_last_pn[i],
- (u_int8_t *) rx_pn, sizeof(union htt_rx_pn_t));
- peer->tids_last_pn[i].pn128[1] =
- qdf_cpu_to_le64(peer->tids_last_pn[i].pn128[1]);
- peer->tids_last_pn[i].pn128[0] =
- qdf_cpu_to_le64(peer->tids_last_pn[i].pn128[0]);
- }
- }
- #endif
- /* TODO: Update HW TID queue with PN check parameters (pn type for
- * all security types and last pn for WAPI) once REO command API
- * is available
- */
- dp_peer_unref_del_find_by_id(peer);
- }
- #ifdef DP_PEER_EXTENDED_API
- /**
- * dp_register_peer() - Register peer into physical device
- * @pdev - data path device instance
- * @sta_desc - peer description
- *
- * Register peer into physical device
- *
- * Return: QDF_STATUS_SUCCESS registration success
- * QDF_STATUS_E_FAULT peer not found
- */
- QDF_STATUS dp_register_peer(struct cdp_pdev *pdev_handle,
- struct ol_txrx_desc_type *sta_desc)
- {
- struct dp_peer *peer;
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- uint8_t peer_id;
- peer = dp_find_peer_by_addr((struct cdp_pdev *)pdev,
- sta_desc->peer_addr.bytes,
- &peer_id);
- if (!peer)
- return QDF_STATUS_E_FAULT;
- qdf_spin_lock_bh(&peer->peer_info_lock);
- peer->state = OL_TXRX_PEER_STATE_CONN;
- qdf_spin_unlock_bh(&peer->peer_info_lock);
- dp_rx_flush_rx_cached(peer, false);
- return QDF_STATUS_SUCCESS;
- }
- /**
- * dp_clear_peer() - remove peer from physical device
- * @pdev - data path device instance
- * @peer_addr - peer mac address
- *
- * remove peer from physical device
- *
- * Return: QDF_STATUS_SUCCESS registration success
- * QDF_STATUS_E_FAULT peer not found
- */
- QDF_STATUS
- dp_clear_peer(struct cdp_pdev *pdev_handle, struct qdf_mac_addr peer_addr)
- {
- struct dp_peer *peer;
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- /* peer_id to be removed */
- uint8_t peer_id;
- peer = dp_find_peer_by_addr((struct cdp_pdev *)pdev, peer_addr.bytes,
- &peer_id);
- if (!peer)
- return QDF_STATUS_E_FAULT;
- qdf_spin_lock_bh(&peer->peer_info_lock);
- peer->state = OL_TXRX_PEER_STATE_DISC;
- qdf_spin_unlock_bh(&peer->peer_info_lock);
- dp_rx_flush_rx_cached(peer, true);
- return QDF_STATUS_SUCCESS;
- }
- /**
- * dp_find_peer_by_addr_and_vdev() - Find peer by peer mac address within vdev
- * @pdev - data path device instance
- * @vdev - virtual interface instance
- * @peer_addr - peer mac address
- * @peer_id - local peer id with target mac address
- *
- * Find peer by peer mac address within vdev
- *
- * Return: peer instance void pointer
- * NULL cannot find target peer
- */
- void *dp_find_peer_by_addr_and_vdev(struct cdp_pdev *pdev_handle,
- struct cdp_vdev *vdev_handle,
- uint8_t *peer_addr, uint8_t *local_id)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_peer *peer;
- peer = dp_peer_find_hash_find(pdev->soc, peer_addr, 0, 0);
- if (!peer)
- return NULL;
- if (peer->vdev != vdev) {
- dp_peer_unref_delete(peer);
- return NULL;
- }
- *local_id = peer->local_id;
- /* ref_cnt is incremented inside dp_peer_find_hash_find().
- * Decrement it here.
- */
- dp_peer_unref_delete(peer);
- return peer;
- }
- /**
- * dp_local_peer_id() - Find local peer id within peer instance
- * @peer - peer instance
- *
- * Find local peer id within peer instance
- *
- * Return: local peer id
- */
- uint16_t dp_local_peer_id(void *peer)
- {
- return ((struct dp_peer *)peer)->local_id;
- }
- /**
- * dp_peer_find_by_local_id() - Find peer by local peer id
- * @pdev - data path device instance
- * @local_peer_id - local peer id want to find
- *
- * Find peer by local peer id within physical device
- *
- * Return: peer instance void pointer
- * NULL cannot find target peer
- */
- void *dp_peer_find_by_local_id(struct cdp_pdev *pdev_handle, uint8_t local_id)
- {
- struct dp_peer *peer;
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- if (local_id >= OL_TXRX_NUM_LOCAL_PEER_IDS) {
- QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_DP,
- "Incorrect local id %u", local_id);
- return NULL;
- }
- qdf_spin_lock_bh(&pdev->local_peer_ids.lock);
- peer = pdev->local_peer_ids.map[local_id];
- qdf_spin_unlock_bh(&pdev->local_peer_ids.lock);
- DP_TRACE(DEBUG, "peer %pK local id %d", peer, local_id);
- return peer;
- }
- /**
- * dp_peer_state_update() - update peer local state
- * @pdev - data path device instance
- * @peer_addr - peer mac address
- * @state - new peer local state
- *
- * update peer local state
- *
- * Return: QDF_STATUS_SUCCESS registration success
- */
- QDF_STATUS dp_peer_state_update(struct cdp_pdev *pdev_handle, uint8_t *peer_mac,
- enum ol_txrx_peer_state state)
- {
- struct dp_peer *peer;
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- peer = dp_peer_find_hash_find(pdev->soc, peer_mac, 0, DP_VDEV_ALL);
- if (!peer) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "Failed to find peer for: [%pM]", peer_mac);
- return QDF_STATUS_E_FAILURE;
- }
- peer->state = state;
- DP_TRACE(INFO, "peer %pK state %d", peer, peer->state);
- /* ref_cnt is incremented inside dp_peer_find_hash_find().
- * Decrement it here.
- */
- dp_peer_unref_delete(peer);
- return QDF_STATUS_SUCCESS;
- }
- /**
- * dp_get_vdevid() - Get virtual interface id which peer registered
- * @peer - peer instance
- * @vdev_id - virtual interface id which peer registered
- *
- * Get virtual interface id which peer registered
- *
- * Return: QDF_STATUS_SUCCESS registration success
- */
- QDF_STATUS dp_get_vdevid(void *peer_handle, uint8_t *vdev_id)
- {
- struct dp_peer *peer = peer_handle;
- dp_info("peer %pK vdev %pK vdev id %d",
- peer, peer->vdev, peer->vdev->vdev_id);
- *vdev_id = peer->vdev->vdev_id;
- return QDF_STATUS_SUCCESS;
- }
- struct cdp_vdev *
- dp_get_vdev_by_peer_addr(struct cdp_pdev *pdev_handle,
- struct qdf_mac_addr peer_addr)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- struct dp_peer *peer = NULL;
- /* peer_id to be removed PEER_ID_CLEANUP */
- uint8_t peer_id;
- if (!pdev) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
- "PDEV not found for peer_addr: " QDF_MAC_ADDR_STR,
- QDF_MAC_ADDR_ARRAY(peer_addr.bytes));
- return NULL;
- }
- peer = dp_find_peer_by_addr((struct cdp_pdev *)pdev, peer_addr.bytes,
- &peer_id);
- if (!peer) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH,
- "PDEV not found for peer_addr:" QDF_MAC_ADDR_STR,
- QDF_MAC_ADDR_ARRAY(peer_addr.bytes));
- return NULL;
- }
- return (struct cdp_vdev *)peer->vdev;
- }
- /**
- * dp_get_vdev_for_peer() - Get virtual interface instance which peer belongs
- * @peer - peer instance
- *
- * Get virtual interface instance which peer belongs
- *
- * Return: virtual interface instance pointer
- * NULL in case cannot find
- */
- struct cdp_vdev *dp_get_vdev_for_peer(void *peer_handle)
- {
- struct dp_peer *peer = peer_handle;
- DP_TRACE(DEBUG, "peer %pK vdev %pK", peer, peer->vdev);
- return (struct cdp_vdev *)peer->vdev;
- }
- /**
- * dp_peer_get_peer_mac_addr() - Get peer mac address
- * @peer - peer instance
- *
- * Get peer mac address
- *
- * Return: peer mac address pointer
- * NULL in case cannot find
- */
- uint8_t *dp_peer_get_peer_mac_addr(void *peer_handle)
- {
- struct dp_peer *peer = peer_handle;
- uint8_t *mac;
- mac = peer->mac_addr.raw;
- DP_TRACE(INFO, "peer %pK mac 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
- peer, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
- return peer->mac_addr.raw;
- }
- /**
- * dp_get_peer_state() - Get local peer state
- * @peer - peer instance
- *
- * Get local peer state
- *
- * Return: peer status
- */
- int dp_get_peer_state(void *peer_handle)
- {
- struct dp_peer *peer = peer_handle;
- DP_TRACE(DEBUG, "peer %pK stats %d", peer, peer->state);
- return peer->state;
- }
- /**
- * dp_local_peer_id_pool_init() - local peer id pool alloc for physical device
- * @pdev - data path device instance
- *
- * local peer id pool alloc for physical device
- *
- * Return: none
- */
- void dp_local_peer_id_pool_init(struct dp_pdev *pdev)
- {
- int i;
- /* point the freelist to the first ID */
- pdev->local_peer_ids.freelist = 0;
- /* link each ID to the next one */
- for (i = 0; i < OL_TXRX_NUM_LOCAL_PEER_IDS; i++) {
- pdev->local_peer_ids.pool[i] = i + 1;
- pdev->local_peer_ids.map[i] = NULL;
- }
- /* link the last ID to itself, to mark the end of the list */
- i = OL_TXRX_NUM_LOCAL_PEER_IDS;
- pdev->local_peer_ids.pool[i] = i;
- qdf_spinlock_create(&pdev->local_peer_ids.lock);
- DP_TRACE(INFO, "Peer pool init");
- }
- /**
- * dp_local_peer_id_alloc() - allocate local peer id
- * @pdev - data path device instance
- * @peer - new peer instance
- *
- * allocate local peer id
- *
- * Return: none
- */
- void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer)
- {
- int i;
- qdf_spin_lock_bh(&pdev->local_peer_ids.lock);
- i = pdev->local_peer_ids.freelist;
- if (pdev->local_peer_ids.pool[i] == i) {
- /* the list is empty, except for the list-end marker */
- peer->local_id = OL_TXRX_INVALID_LOCAL_PEER_ID;
- } else {
- /* take the head ID and advance the freelist */
- peer->local_id = i;
- pdev->local_peer_ids.freelist = pdev->local_peer_ids.pool[i];
- pdev->local_peer_ids.map[i] = peer;
- }
- qdf_spin_unlock_bh(&pdev->local_peer_ids.lock);
- DP_TRACE(INFO, "peer %pK, local id %d", peer, peer->local_id);
- }
- /**
- * dp_local_peer_id_free() - remove local peer id
- * @pdev - data path device instance
- * @peer - peer instance should be removed
- *
- * remove local peer id
- *
- * Return: none
- */
- void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer)
- {
- int i = peer->local_id;
- if ((i == OL_TXRX_INVALID_LOCAL_PEER_ID) ||
- (i >= OL_TXRX_NUM_LOCAL_PEER_IDS)) {
- return;
- }
- /* put this ID on the head of the freelist */
- qdf_spin_lock_bh(&pdev->local_peer_ids.lock);
- pdev->local_peer_ids.pool[i] = pdev->local_peer_ids.freelist;
- pdev->local_peer_ids.freelist = i;
- pdev->local_peer_ids.map[i] = NULL;
- qdf_spin_unlock_bh(&pdev->local_peer_ids.lock);
- }
- #endif
- /**
- * dp_get_peer_mac_addr_frm_id(): get mac address of the peer
- * @soc_handle: DP SOC handle
- * @peer_id:peer_id of the peer
- *
- * return: vdev_id of the vap
- */
- uint8_t dp_get_peer_mac_addr_frm_id(struct cdp_soc_t *soc_handle,
- uint16_t peer_id, uint8_t *peer_mac)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_handle;
- struct dp_peer *peer;
- uint8_t vdev_id;
- peer = dp_peer_find_by_id(soc, peer_id);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "soc %pK peer_id %d", soc, peer_id);
- if (!peer) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "peer not found ");
- return CDP_INVALID_VDEV_ID;
- }
- qdf_mem_copy(peer_mac, peer->mac_addr.raw, 6);
- vdev_id = peer->vdev->vdev_id;
- dp_peer_unref_del_find_by_id(peer);
- return vdev_id;
- }
- /**
- * dp_peer_rxtid_stats: Retried Rx TID (REO queue) stats from HW
- * @peer: DP peer handle
- * @dp_stats_cmd_cb: REO command callback function
- * @cb_ctxt: Callback context
- *
- * Return: none
- */
- void dp_peer_rxtid_stats(struct dp_peer *peer, void (*dp_stats_cmd_cb),
- void *cb_ctxt)
- {
- struct dp_soc *soc = peer->vdev->pdev->soc;
- struct hal_reo_cmd_params params;
- int i;
- if (!dp_stats_cmd_cb)
- return;
- qdf_mem_zero(¶ms, sizeof(params));
- for (i = 0; i < DP_MAX_TIDS; i++) {
- struct dp_rx_tid *rx_tid = &peer->rx_tid[i];
- if (rx_tid->hw_qdesc_vaddr_unaligned) {
- params.std.need_status = 1;
- params.std.addr_lo =
- rx_tid->hw_qdesc_paddr & 0xffffffff;
- params.std.addr_hi =
- (uint64_t)(rx_tid->hw_qdesc_paddr) >> 32;
- if (cb_ctxt) {
- dp_reo_send_cmd(soc, CMD_GET_QUEUE_STATS,
- ¶ms, dp_stats_cmd_cb, cb_ctxt);
- } else {
- dp_reo_send_cmd(soc, CMD_GET_QUEUE_STATS,
- ¶ms, dp_stats_cmd_cb, rx_tid);
- }
- /* Flush REO descriptor from HW cache to update stats
- * in descriptor memory. This is to help debugging */
- qdf_mem_zero(¶ms, sizeof(params));
- params.std.need_status = 0;
- params.std.addr_lo =
- rx_tid->hw_qdesc_paddr & 0xffffffff;
- params.std.addr_hi =
- (uint64_t)(rx_tid->hw_qdesc_paddr) >> 32;
- params.u.fl_cache_params.flush_no_inval = 1;
- dp_reo_send_cmd(soc, CMD_FLUSH_CACHE, ¶ms, NULL,
- NULL);
- }
- }
- }
- void dp_set_michael_key(struct cdp_peer *peer_handle,
- bool is_unicast, uint32_t *key)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- uint8_t sec_index = is_unicast ? 1 : 0;
- if (!peer) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "peer not found ");
- return;
- }
- qdf_mem_copy(&peer->security[sec_index].michael_key[0],
- key, IEEE80211_WEP_MICLEN);
- }
- bool dp_peer_find_by_id_valid(struct dp_soc *soc, uint16_t peer_id)
- {
- struct dp_peer *peer = dp_peer_find_by_id(soc, peer_id);
- if (peer) {
- /*
- * Decrement the peer ref which is taken as part of
- * dp_peer_find_by_id if PEER_LOCK_REF_PROTECT is enabled
- */
- dp_peer_unref_del_find_by_id(peer);
- return true;
- }
- return false;
- }
|