123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934 |
- #include "targcfg.h"
- #include "qdf_lock.h"
- #include "qdf_status.h"
- #include "qdf_status.h"
- #include <qdf_atomic.h> /* qdf_atomic_read */
- #include <targaddrs.h>
- #include "hif_io32.h"
- #include <hif.h>
- #include "regtable.h"
- #define ATH_MODULE_NAME hif
- #include <a_debug.h>
- #include "hif_main.h"
- #include "ce_api.h"
- #include "qdf_trace.h"
- #include "pld_common.h"
- #include "hif_debug.h"
- #include "ce_internal.h"
- #include "ce_reg.h"
- #include "ce_assignment.h"
- #include "ce_tasklet.h"
- #ifndef CONFIG_WIN
- #include "qwlan_version.h"
- #endif
- #define CE_POLL_TIMEOUT 10
- #define AGC_DUMP 1
- #define CHANINFO_DUMP 2
- #define BB_WATCHDOG_DUMP 3
- #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
- #define PCIE_ACCESS_DUMP 4
- #endif
- #include "mp_dev.h"
- static int hif_post_recv_buffers_for_pipe(struct HIF_CE_pipe_info *pipe_info);
- #define BMI_RSP_TO_MILLISEC 1000
- #ifdef CONFIG_BYPASS_QMI
- #define BYPASS_QMI 1
- #else
- #define BYPASS_QMI 0
- #endif
- #ifdef CONFIG_WIN
- #if ENABLE_10_4_FW_HDR
- #define WDI_IPA_SERVICE_GROUP 5
- #define WDI_IPA_TX_SVC MAKE_SERVICE_ID(WDI_IPA_SERVICE_GROUP, 0)
- #define HTT_DATA2_MSG_SVC MAKE_SERVICE_ID(HTT_SERVICE_GROUP, 1)
- #define HTT_DATA3_MSG_SVC MAKE_SERVICE_ID(HTT_SERVICE_GROUP, 2)
- #endif
- #endif
- static int hif_post_recv_buffers(struct hif_softc *scn);
- static void hif_config_rri_on_ddr(struct hif_softc *scn);
- #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
- static void hif_target_access_log_dump(void)
- {
- hif_target_dump_access_log();
- }
- #endif
- void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
- uint8_t cmd_id, bool start)
- {
- struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
- switch (cmd_id) {
- case AGC_DUMP:
- if (start)
- priv_start_agc(scn);
- else
- priv_dump_agc(scn);
- break;
- case CHANINFO_DUMP:
- if (start)
- priv_start_cap_chaninfo(scn);
- else
- priv_dump_chaninfo(scn);
- break;
- case BB_WATCHDOG_DUMP:
- priv_dump_bbwatchdog(scn);
- break;
- #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
- case PCIE_ACCESS_DUMP:
- hif_target_access_log_dump();
- break;
- #endif
- default:
- HIF_ERROR("%s: Invalid htc dump command", __func__);
- break;
- }
- }
- static void ce_poll_timeout(void *arg)
- {
- struct CE_state *CE_state = (struct CE_state *)arg;
- if (CE_state->timer_inited) {
- ce_per_engine_service(CE_state->scn, CE_state->id);
- qdf_timer_mod(&CE_state->poll_timer, CE_POLL_TIMEOUT);
- }
- }
- static unsigned int roundup_pwr2(unsigned int n)
- {
- int i;
- unsigned int test_pwr2;
- if (!(n & (n - 1)))
- return n;
- test_pwr2 = 4;
- for (i = 0; i < 29; i++) {
- if (test_pwr2 > n)
- return test_pwr2;
- test_pwr2 = test_pwr2 << 1;
- }
- QDF_ASSERT(0);
- return 0;
- }
- #define ADRASTEA_SRC_WR_INDEX_OFFSET 0x3C
- #define ADRASTEA_DST_WR_INDEX_OFFSET 0x40
- static struct shadow_reg_cfg target_shadow_reg_cfg_map[] = {
- { 0, ADRASTEA_SRC_WR_INDEX_OFFSET},
- { 3, ADRASTEA_SRC_WR_INDEX_OFFSET},
- { 4, ADRASTEA_SRC_WR_INDEX_OFFSET},
- { 5, ADRASTEA_SRC_WR_INDEX_OFFSET},
- { 7, ADRASTEA_SRC_WR_INDEX_OFFSET},
- { 1, ADRASTEA_DST_WR_INDEX_OFFSET},
- { 2, ADRASTEA_DST_WR_INDEX_OFFSET},
- { 7, ADRASTEA_DST_WR_INDEX_OFFSET},
- { 8, ADRASTEA_DST_WR_INDEX_OFFSET},
- #ifdef QCA_WIFI_3_0_ADRASTEA
- { 9, ADRASTEA_DST_WR_INDEX_OFFSET},
- { 10, ADRASTEA_DST_WR_INDEX_OFFSET},
- { 11, ADRASTEA_DST_WR_INDEX_OFFSET},
- #endif
- };
- static struct shadow_reg_cfg target_shadow_reg_cfg_epping[] = {
- { 0, ADRASTEA_SRC_WR_INDEX_OFFSET},
- { 3, ADRASTEA_SRC_WR_INDEX_OFFSET},
- { 4, ADRASTEA_SRC_WR_INDEX_OFFSET},
- { 7, ADRASTEA_SRC_WR_INDEX_OFFSET},
- { 1, ADRASTEA_DST_WR_INDEX_OFFSET},
- { 2, ADRASTEA_DST_WR_INDEX_OFFSET},
- { 5, ADRASTEA_DST_WR_INDEX_OFFSET},
- { 7, ADRASTEA_DST_WR_INDEX_OFFSET},
- { 8, ADRASTEA_DST_WR_INDEX_OFFSET},
- };
- static struct service_to_pipe target_service_to_ce_map_wlan[] = {
- {
- WMI_DATA_VO_SVC,
- PIPEDIR_OUT,
- 3,
- },
- {
- WMI_DATA_VO_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- WMI_DATA_BK_SVC,
- PIPEDIR_OUT,
- 3,
- },
- {
- WMI_DATA_BK_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- WMI_DATA_BE_SVC,
- PIPEDIR_OUT,
- 3,
- },
- {
- WMI_DATA_BE_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- WMI_DATA_VI_SVC,
- PIPEDIR_OUT,
- 3,
- },
- {
- WMI_DATA_VI_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- WMI_CONTROL_SVC,
- PIPEDIR_OUT,
- 3,
- },
- {
- WMI_CONTROL_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- HTC_CTRL_RSVD_SVC,
- PIPEDIR_OUT,
- 0,
- },
- {
- HTC_CTRL_RSVD_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- HTC_RAW_STREAMS_SVC,
- PIPEDIR_OUT,
- 0,
- },
- {
- HTC_RAW_STREAMS_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- HTT_DATA_MSG_SVC,
- PIPEDIR_OUT,
- 4,
- },
- {
- HTT_DATA_MSG_SVC,
- PIPEDIR_IN,
- 1,
- },
- {
- WDI_IPA_TX_SVC,
- PIPEDIR_OUT,
- 5,
- },
- #if defined(QCA_WIFI_3_0_ADRASTEA)
- {
- HTT_DATA2_MSG_SVC,
- PIPEDIR_IN,
- 9,
- },
- {
- HTT_DATA3_MSG_SVC,
- PIPEDIR_IN,
- 10,
- },
- {
- PACKET_LOG_SVC,
- PIPEDIR_IN,
- 11,
- },
- #endif
-
- {
- 0,
- 0,
- 0,
- },
- };
- static struct service_to_pipe target_service_to_ce_map_ar900b[] = {
- {
- WMI_DATA_VO_SVC,
- PIPEDIR_OUT,
- 3,
- },
- {
- WMI_DATA_VO_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- WMI_DATA_BK_SVC,
- PIPEDIR_OUT,
- 3,
- },
- {
- WMI_DATA_BK_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- WMI_DATA_BE_SVC,
- PIPEDIR_OUT,
- 3,
- },
- {
- WMI_DATA_BE_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- WMI_DATA_VI_SVC,
- PIPEDIR_OUT,
- 3,
- },
- {
- WMI_DATA_VI_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- WMI_CONTROL_SVC,
- PIPEDIR_OUT,
- 3,
- },
- {
- WMI_CONTROL_SVC,
- PIPEDIR_IN,
- 2,
- },
- {
- HTC_CTRL_RSVD_SVC,
- PIPEDIR_OUT,
- 0,
- },
- {
- HTC_CTRL_RSVD_SVC,
- PIPEDIR_IN,
- 1,
- },
- {
- HTC_RAW_STREAMS_SVC,
- PIPEDIR_OUT,
- 0,
- },
- {
- HTC_RAW_STREAMS_SVC,
- PIPEDIR_IN,
- 1,
- },
- {
- HTT_DATA_MSG_SVC,
- PIPEDIR_OUT,
- 4,
- },
- #if WLAN_FEATURE_FASTPATH
- {
- HTT_DATA_MSG_SVC,
- PIPEDIR_IN,
- 5,
- },
- #else
- {
- HTT_DATA_MSG_SVC,
- PIPEDIR_IN,
- 1,
- },
- #endif
-
- {
- 0,
- 0,
- 0,
- },
- };
- static struct service_to_pipe *target_service_to_ce_map =
- target_service_to_ce_map_wlan;
- static int target_service_to_ce_map_sz = sizeof(target_service_to_ce_map_wlan);
- static struct shadow_reg_cfg *target_shadow_reg_cfg = target_shadow_reg_cfg_map;
- static int shadow_cfg_sz = sizeof(target_shadow_reg_cfg_map);
- static struct service_to_pipe target_service_to_ce_map_wlan_epping[] = {
- {WMI_DATA_VO_SVC, PIPEDIR_OUT, 3,},
- {WMI_DATA_VO_SVC, PIPEDIR_IN, 2,},
- {WMI_DATA_BK_SVC, PIPEDIR_OUT, 4,},
- {WMI_DATA_BK_SVC, PIPEDIR_IN, 1,},
- {WMI_DATA_BE_SVC, PIPEDIR_OUT, 3,},
- {WMI_DATA_BE_SVC, PIPEDIR_IN, 2,},
- {WMI_DATA_VI_SVC, PIPEDIR_OUT, 3,},
- {WMI_DATA_VI_SVC, PIPEDIR_IN, 2,},
- {WMI_CONTROL_SVC, PIPEDIR_OUT, 3,},
- {WMI_CONTROL_SVC, PIPEDIR_IN, 2,},
- {HTC_CTRL_RSVD_SVC, PIPEDIR_OUT, 0,},
- {HTC_CTRL_RSVD_SVC, PIPEDIR_IN, 2,},
- {HTC_RAW_STREAMS_SVC, PIPEDIR_OUT, 0,},
- {HTC_RAW_STREAMS_SVC, PIPEDIR_IN, 2,},
- {HTT_DATA_MSG_SVC, PIPEDIR_OUT, 4,},
- {HTT_DATA_MSG_SVC, PIPEDIR_IN, 1,},
- {0, 0, 0,},
- };
- bool ce_mark_datapath(struct CE_state *ce_state)
- {
- struct service_to_pipe *svc_map;
- size_t map_sz;
- int i;
- bool rc = false;
- struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(ce_state->scn);
- struct hif_target_info *tgt_info = hif_get_target_info_handle(hif_hdl);
- if (ce_state != NULL) {
- if (QDF_IS_EPPING_ENABLED(hif_get_conparam(ce_state->scn))) {
- svc_map = target_service_to_ce_map_wlan_epping;
- map_sz = sizeof(target_service_to_ce_map_wlan_epping) /
- sizeof(struct service_to_pipe);
- } else {
- switch (tgt_info->target_type) {
- default:
- svc_map = target_service_to_ce_map_wlan;
- map_sz =
- sizeof(target_service_to_ce_map_wlan) /
- sizeof(struct service_to_pipe);
- break;
- case TARGET_TYPE_AR900B:
- case TARGET_TYPE_QCA9984:
- case TARGET_TYPE_IPQ4019:
- case TARGET_TYPE_QCA9888:
- case TARGET_TYPE_AR9888:
- case TARGET_TYPE_AR9888V2:
- svc_map = target_service_to_ce_map_ar900b;
- map_sz =
- sizeof(target_service_to_ce_map_ar900b)
- / sizeof(struct service_to_pipe);
- break;
- }
- }
- for (i = 0; i < map_sz; i++) {
- if ((svc_map[i].pipenum == ce_state->id) &&
- ((svc_map[i].service_id == HTT_DATA_MSG_SVC) ||
- (svc_map[i].service_id == HTT_DATA2_MSG_SVC) ||
- (svc_map[i].service_id == HTT_DATA3_MSG_SVC))) {
-
- if (svc_map[i].pipedir == PIPEDIR_IN)
- ce_state->htt_rx_data = true;
- else
- ce_state->htt_tx_data = true;
- rc = true;
- }
- }
- }
- return rc;
- }
- static void ce_ring_test_initial_indexes(int ce_id, struct CE_ring_state *ring,
- char *type)
- {
- if (ring->write_index != 0 || ring->sw_index != 0)
- HIF_ERROR("ce %d, %s, initial sw_index = %d, initial write_index =%d",
- ce_id, type, ring->sw_index, ring->write_index);
- if (ring->write_index != ring->sw_index)
- QDF_BUG(0);
- }
- struct CE_handle *ce_init(struct hif_softc *scn,
- unsigned int CE_id, struct CE_attr *attr)
- {
- struct CE_state *CE_state;
- uint32_t ctrl_addr;
- unsigned int nentries;
- qdf_dma_addr_t base_addr;
- bool malloc_CE_state = false;
- bool malloc_src_ring = false;
- QDF_ASSERT(CE_id < scn->ce_count);
- ctrl_addr = CE_BASE_ADDRESS(CE_id);
- CE_state = scn->ce_id_to_state[CE_id];
- if (!CE_state) {
- CE_state =
- (struct CE_state *)qdf_mem_malloc(sizeof(*CE_state));
- if (!CE_state) {
- HIF_ERROR("%s: CE_state has no mem", __func__);
- return NULL;
- }
- malloc_CE_state = true;
- qdf_mem_zero(CE_state, sizeof(*CE_state));
- scn->ce_id_to_state[CE_id] = CE_state;
- qdf_spinlock_create(&CE_state->ce_index_lock);
- CE_state->id = CE_id;
- CE_state->ctrl_addr = ctrl_addr;
- CE_state->state = CE_RUNNING;
- CE_state->attr_flags = attr->flags;
- }
- CE_state->scn = scn;
- qdf_atomic_init(&CE_state->rx_pending);
- if (attr == NULL) {
-
- return (struct CE_handle *)CE_state;
- }
- if (CE_state->src_sz_max)
- QDF_ASSERT(CE_state->src_sz_max == attr->src_sz_max);
- else
- CE_state->src_sz_max = attr->src_sz_max;
- ce_init_ce_desc_event_log(CE_id,
- attr->src_nentries + attr->dest_nentries);
-
- nentries = attr->src_nentries;
- if (nentries) {
- struct CE_ring_state *src_ring;
- unsigned CE_nbytes;
- char *ptr;
- uint64_t dma_addr;
- nentries = roundup_pwr2(nentries);
- if (CE_state->src_ring) {
- QDF_ASSERT(CE_state->src_ring->nentries == nentries);
- } else {
- CE_nbytes = sizeof(struct CE_ring_state)
- + (nentries * sizeof(void *));
- ptr = qdf_mem_malloc(CE_nbytes);
- if (!ptr) {
-
- HIF_ERROR("%s: src ring has no mem", __func__);
- if (malloc_CE_state) {
-
- scn->ce_id_to_state[CE_id] = NULL;
- qdf_mem_free(CE_state);
- malloc_CE_state = false;
- }
- return NULL;
- } else {
-
- malloc_src_ring = true;
- }
- qdf_mem_zero(ptr, CE_nbytes);
- src_ring = CE_state->src_ring =
- (struct CE_ring_state *)ptr;
- ptr += sizeof(struct CE_ring_state);
- src_ring->nentries = nentries;
- src_ring->nentries_mask = nentries - 1;
- if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
- goto error_target_access;
- src_ring->hw_index =
- CE_SRC_RING_READ_IDX_GET_FROM_REGISTER(scn,
- ctrl_addr);
- src_ring->sw_index = src_ring->hw_index;
- src_ring->write_index =
- CE_SRC_RING_WRITE_IDX_GET_FROM_REGISTER(scn,
- ctrl_addr);
- ce_ring_test_initial_indexes(CE_id, src_ring,
- "src_ring");
- if (Q_TARGET_ACCESS_END(scn) < 0)
- goto error_target_access;
- src_ring->low_water_mark_nentries = 0;
- src_ring->high_water_mark_nentries = nentries;
- src_ring->per_transfer_context = (void **)ptr;
-
- src_ring->base_addr_owner_space_unaligned =
- qdf_mem_alloc_consistent(scn->qdf_dev,
- scn->qdf_dev->dev,
- (nentries *
- sizeof(struct CE_src_desc) +
- CE_DESC_RING_ALIGN),
- &base_addr);
- if (src_ring->base_addr_owner_space_unaligned
- == NULL) {
- HIF_ERROR("%s: src ring has no DMA mem",
- __func__);
- goto error_no_dma_mem;
- }
- src_ring->base_addr_CE_space_unaligned = base_addr;
- if (src_ring->
- base_addr_CE_space_unaligned & (CE_DESC_RING_ALIGN
- - 1)) {
- src_ring->base_addr_CE_space =
- (src_ring->base_addr_CE_space_unaligned
- + CE_DESC_RING_ALIGN -
- 1) & ~(CE_DESC_RING_ALIGN - 1);
- src_ring->base_addr_owner_space =
- (void
- *)(((size_t) src_ring->
- base_addr_owner_space_unaligned +
- CE_DESC_RING_ALIGN -
- 1) & ~(CE_DESC_RING_ALIGN - 1));
- } else {
- src_ring->base_addr_CE_space =
- src_ring->base_addr_CE_space_unaligned;
- src_ring->base_addr_owner_space =
- src_ring->
- base_addr_owner_space_unaligned;
- }
-
- src_ring->shadow_base_unaligned =
- qdf_mem_malloc(nentries *
- sizeof(struct CE_src_desc) +
- CE_DESC_RING_ALIGN);
- if (src_ring->shadow_base_unaligned == NULL) {
- HIF_ERROR("%s: src ring no shadow_base mem",
- __func__);
- goto error_no_dma_mem;
- }
- src_ring->shadow_base = (struct CE_src_desc *)
- (((size_t) src_ring->shadow_base_unaligned +
- CE_DESC_RING_ALIGN - 1) &
- ~(CE_DESC_RING_ALIGN - 1));
- if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
- goto error_target_access;
- dma_addr = src_ring->base_addr_CE_space;
- CE_SRC_RING_BASE_ADDR_SET(scn, ctrl_addr,
- (uint32_t)(dma_addr & 0xFFFFFFFF));
-
- if (is_register_supported(SR_BA_ADDRESS_HIGH)) {
- uint32_t tmp;
- tmp = CE_SRC_RING_BASE_ADDR_HIGH_GET(
- scn, ctrl_addr);
- tmp &= ~0x1F;
- dma_addr = ((dma_addr >> 32) & 0x1F)|tmp;
- CE_SRC_RING_BASE_ADDR_HIGH_SET(scn,
- ctrl_addr, (uint32_t)dma_addr);
- }
- CE_SRC_RING_SZ_SET(scn, ctrl_addr, nentries);
- CE_SRC_RING_DMAX_SET(scn, ctrl_addr, attr->src_sz_max);
- #ifdef BIG_ENDIAN_HOST
-
- CE_SRC_RING_BYTE_SWAP_SET(scn, ctrl_addr, 1);
- #endif
- CE_SRC_RING_LOWMARK_SET(scn, ctrl_addr, 0);
- CE_SRC_RING_HIGHMARK_SET(scn, ctrl_addr, nentries);
- if (Q_TARGET_ACCESS_END(scn) < 0)
- goto error_target_access;
- }
- }
-
- nentries = attr->dest_nentries;
- if (nentries) {
- struct CE_ring_state *dest_ring;
- unsigned CE_nbytes;
- char *ptr;
- uint64_t dma_addr;
- nentries = roundup_pwr2(nentries);
- if (CE_state->dest_ring) {
- QDF_ASSERT(CE_state->dest_ring->nentries == nentries);
- } else {
- CE_nbytes = sizeof(struct CE_ring_state)
- + (nentries * sizeof(void *));
- ptr = qdf_mem_malloc(CE_nbytes);
- if (!ptr) {
-
- HIF_ERROR("%s: dest ring has no mem",
- __func__);
- if (malloc_src_ring) {
- qdf_mem_free(CE_state->src_ring);
- CE_state->src_ring = NULL;
- malloc_src_ring = false;
- }
- if (malloc_CE_state) {
-
- scn->ce_id_to_state[CE_id] = NULL;
- qdf_mem_free(CE_state);
- malloc_CE_state = false;
- }
- return NULL;
- }
- qdf_mem_zero(ptr, CE_nbytes);
- dest_ring = CE_state->dest_ring =
- (struct CE_ring_state *)ptr;
- ptr += sizeof(struct CE_ring_state);
- dest_ring->nentries = nentries;
- dest_ring->nentries_mask = nentries - 1;
- if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
- goto error_target_access;
- dest_ring->sw_index =
- CE_DEST_RING_READ_IDX_GET_FROM_REGISTER(scn,
- ctrl_addr);
- dest_ring->write_index =
- CE_DEST_RING_WRITE_IDX_GET_FROM_REGISTER(scn,
- ctrl_addr);
- ce_ring_test_initial_indexes(CE_id, dest_ring,
- "dest_ring");
- if (Q_TARGET_ACCESS_END(scn) < 0)
- goto error_target_access;
- dest_ring->low_water_mark_nentries = 0;
- dest_ring->high_water_mark_nentries = nentries;
- dest_ring->per_transfer_context = (void **)ptr;
-
- dest_ring->base_addr_owner_space_unaligned =
- qdf_mem_alloc_consistent(scn->qdf_dev,
- scn->qdf_dev->dev,
- (nentries *
- sizeof(struct CE_dest_desc) +
- CE_DESC_RING_ALIGN),
- &base_addr);
- if (dest_ring->base_addr_owner_space_unaligned
- == NULL) {
- HIF_ERROR("%s: dest ring has no DMA mem",
- __func__);
- goto error_no_dma_mem;
- }
- dest_ring->base_addr_CE_space_unaligned = base_addr;
-
- qdf_mem_zero(dest_ring->base_addr_owner_space_unaligned,
- nentries * sizeof(struct CE_dest_desc) +
- CE_DESC_RING_ALIGN);
- if (dest_ring->
- base_addr_CE_space_unaligned & (CE_DESC_RING_ALIGN -
- 1)) {
- dest_ring->base_addr_CE_space =
- (dest_ring->
- base_addr_CE_space_unaligned +
- CE_DESC_RING_ALIGN -
- 1) & ~(CE_DESC_RING_ALIGN - 1);
- dest_ring->base_addr_owner_space =
- (void
- *)(((size_t) dest_ring->
- base_addr_owner_space_unaligned +
- CE_DESC_RING_ALIGN -
- 1) & ~(CE_DESC_RING_ALIGN - 1));
- } else {
- dest_ring->base_addr_CE_space =
- dest_ring->base_addr_CE_space_unaligned;
- dest_ring->base_addr_owner_space =
- dest_ring->
- base_addr_owner_space_unaligned;
- }
- if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
- goto error_target_access;
- dma_addr = dest_ring->base_addr_CE_space;
- CE_DEST_RING_BASE_ADDR_SET(scn, ctrl_addr,
- (uint32_t)(dma_addr & 0xFFFFFFFF));
-
- if (is_register_supported(DR_BA_ADDRESS_HIGH)) {
- uint32_t tmp;
- tmp = CE_DEST_RING_BASE_ADDR_HIGH_GET(scn,
- ctrl_addr);
- tmp &= ~0x1F;
- dma_addr = ((dma_addr >> 32) & 0x1F)|tmp;
- CE_DEST_RING_BASE_ADDR_HIGH_SET(scn,
- ctrl_addr, (uint32_t)dma_addr);
- }
- CE_DEST_RING_SZ_SET(scn, ctrl_addr, nentries);
- #ifdef BIG_ENDIAN_HOST
-
- CE_DEST_RING_BYTE_SWAP_SET(scn, ctrl_addr, 1);
- #endif
- CE_DEST_RING_LOWMARK_SET(scn, ctrl_addr, 0);
- CE_DEST_RING_HIGHMARK_SET(scn, ctrl_addr, nentries);
- if (Q_TARGET_ACCESS_END(scn) < 0)
- goto error_target_access;
-
-
- if ((CE_state->attr_flags & CE_ATTR_ENABLE_POLL)) {
- qdf_timer_init(scn->qdf_dev,
- &CE_state->poll_timer,
- ce_poll_timeout,
- CE_state,
- QDF_TIMER_TYPE_SW);
- CE_state->timer_inited = true;
- qdf_timer_mod(&CE_state->poll_timer,
- CE_POLL_TIMEOUT);
- }
- }
- }
-
- if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
- goto error_target_access;
- CE_ERROR_INTR_ENABLE(scn, ctrl_addr);
- if (Q_TARGET_ACCESS_END(scn) < 0)
- goto error_target_access;
-
- ce_mark_datapath(CE_state);
- return (struct CE_handle *)CE_state;
- error_target_access:
- error_no_dma_mem:
- ce_fini((struct CE_handle *)CE_state);
- return NULL;
- }
- #ifdef WLAN_FEATURE_FASTPATH
- void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx)
- {
- struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
- HIF_INFO("%s, Enabling fastpath mode", __func__);
- scn->fastpath_mode_on = true;
- }
- bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx)
- {
- struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
- return scn->fastpath_mode_on;
- }
- void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int id)
- {
- struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
- return scn->ce_id_to_state[id];
- }
- void
- ce_h2t_tx_ce_cleanup(struct CE_handle *ce_hdl)
- {
- struct CE_state *ce_state = (struct CE_state *)ce_hdl;
- struct CE_ring_state *src_ring = ce_state->src_ring;
- struct hif_softc *sc = ce_state->scn;
- uint32_t sw_index, write_index;
- if (hif_is_nss_wifi_enabled(sc))
- return;
- if (sc->fastpath_mode_on && ce_state->htt_tx_data) {
- HIF_INFO("%s %d Fastpath mode ON, Cleaning up HTT Tx CE",
- __func__, __LINE__);
- sw_index = src_ring->sw_index;
- write_index = src_ring->sw_index;
-
- qdf_assert_always(sw_index == write_index);
- }
- }
- void ce_t2h_msg_ce_cleanup(struct CE_handle *ce_hdl)
- {
- struct CE_state *ce_state = (struct CE_state *)ce_hdl;
- struct CE_ring_state *dst_ring = ce_state->dest_ring;
- qdf_nbuf_t nbuf;
- int i;
- if (!ce_state->fastpath_handler)
- return;
-
- for (i = 0; i < dst_ring->nentries; i++) {
- nbuf = dst_ring->per_transfer_context[i];
-
- if (nbuf)
- qdf_nbuf_free(nbuf);
- }
- }
- static void hif_update_fastpath_recv_bufs_cnt(struct hif_softc *scn)
- {
- int pipe_num;
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
- if (scn->fastpath_mode_on == false)
- return;
- for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
- struct HIF_CE_pipe_info *pipe_info =
- &hif_state->pipe_info[pipe_num];
- struct CE_state *ce_state =
- scn->ce_id_to_state[pipe_info->pipe_num];
- if (ce_state->htt_rx_data)
- atomic_inc(&pipe_info->recv_bufs_needed);
- }
- }
- #else
- static inline void hif_update_fastpath_recv_bufs_cnt(struct hif_softc *scn)
- {
- }
- static inline bool ce_is_fastpath_enabled(struct hif_softc *scn)
- {
- return false;
- }
- static inline bool ce_is_fastpath_handler_registered(struct CE_state *ce_state)
- {
- return false;
- }
- #endif
- void ce_fini(struct CE_handle *copyeng)
- {
- struct CE_state *CE_state = (struct CE_state *)copyeng;
- unsigned int CE_id = CE_state->id;
- struct hif_softc *scn = CE_state->scn;
- CE_state->state = CE_UNUSED;
- scn->ce_id_to_state[CE_id] = NULL;
- if (CE_state->src_ring) {
-
- ce_h2t_tx_ce_cleanup(copyeng);
- if (CE_state->src_ring->shadow_base_unaligned)
- qdf_mem_free(CE_state->src_ring->shadow_base_unaligned);
- if (CE_state->src_ring->base_addr_owner_space_unaligned)
- qdf_mem_free_consistent(scn->qdf_dev,
- scn->qdf_dev->dev,
- (CE_state->src_ring->nentries *
- sizeof(struct CE_src_desc) +
- CE_DESC_RING_ALIGN),
- CE_state->src_ring->
- base_addr_owner_space_unaligned,
- CE_state->src_ring->
- base_addr_CE_space, 0);
- qdf_mem_free(CE_state->src_ring);
- }
- if (CE_state->dest_ring) {
-
- ce_t2h_msg_ce_cleanup(copyeng);
- if (CE_state->dest_ring->base_addr_owner_space_unaligned)
- qdf_mem_free_consistent(scn->qdf_dev,
- scn->qdf_dev->dev,
- (CE_state->dest_ring->nentries *
- sizeof(struct CE_dest_desc) +
- CE_DESC_RING_ALIGN),
- CE_state->dest_ring->
- base_addr_owner_space_unaligned,
- CE_state->dest_ring->
- base_addr_CE_space, 0);
- qdf_mem_free(CE_state->dest_ring);
-
- if (CE_state->timer_inited) {
- CE_state->timer_inited = false;
- qdf_timer_free(&CE_state->poll_timer);
- }
- }
- qdf_mem_free(CE_state);
- }
- void hif_detach_htc(struct hif_opaque_softc *hif_ctx)
- {
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
- qdf_mem_zero(&hif_state->msg_callbacks_pending,
- sizeof(hif_state->msg_callbacks_pending));
- qdf_mem_zero(&hif_state->msg_callbacks_current,
- sizeof(hif_state->msg_callbacks_current));
- }
- QDF_STATUS
- hif_send_head(struct hif_opaque_softc *hif_ctx,
- uint8_t pipe, unsigned int transfer_id, unsigned int nbytes,
- qdf_nbuf_t nbuf, unsigned int data_attr)
- {
- struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
- struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]);
- struct CE_handle *ce_hdl = pipe_info->ce_hdl;
- int bytes = nbytes, nfrags = 0;
- struct ce_sendlist sendlist;
- int status, i = 0;
- unsigned int mux_id = 0;
- QDF_ASSERT(nbytes <= qdf_nbuf_len(nbuf));
- transfer_id =
- (mux_id & MUX_ID_MASK) |
- (transfer_id & TRANSACTION_ID_MASK);
- data_attr &= DESC_DATA_FLAG_MASK;
-
- ce_sendlist_init(&sendlist);
- do {
- qdf_dma_addr_t frag_paddr;
- int frag_bytes;
- frag_paddr = qdf_nbuf_get_frag_paddr(nbuf, nfrags);
- frag_bytes = qdf_nbuf_get_frag_len(nbuf, nfrags);
-
- if (i++ > 0)
- data_attr &= ~QDF_CE_TX_PKT_OFFSET_BIT_M;
- status = ce_sendlist_buf_add(&sendlist, frag_paddr,
- frag_bytes >
- bytes ? bytes : frag_bytes,
- qdf_nbuf_get_frag_is_wordstream
- (nbuf,
- nfrags) ? 0 :
- CE_SEND_FLAG_SWAP_DISABLE,
- data_attr);
- if (status != QDF_STATUS_SUCCESS) {
- HIF_ERROR("%s: error, frag_num %d larger than limit",
- __func__, nfrags);
- return status;
- }
- bytes -= frag_bytes;
- nfrags++;
- } while (bytes > 0);
-
- qdf_spin_lock_bh(&pipe_info->completion_freeq_lock);
- if (pipe_info->num_sends_allowed < nfrags) {
- qdf_spin_unlock_bh(&pipe_info->completion_freeq_lock);
- ce_pkt_error_count_incr(hif_state, HIF_PIPE_NO_RESOURCE);
- return QDF_STATUS_E_RESOURCES;
- }
- pipe_info->num_sends_allowed -= nfrags;
- qdf_spin_unlock_bh(&pipe_info->completion_freeq_lock);
- if (qdf_unlikely(ce_hdl == NULL)) {
- HIF_ERROR("%s: error CE handle is null", __func__);
- return A_ERROR;
- }
- QDF_NBUF_UPDATE_TX_PKT_COUNT(nbuf, QDF_NBUF_TX_PKT_HIF);
- DPTRACE(qdf_dp_trace(nbuf, QDF_DP_TRACE_HIF_PACKET_PTR_RECORD,
- qdf_nbuf_data_addr(nbuf),
- sizeof(qdf_nbuf_data(nbuf)), QDF_TX));
- status = ce_sendlist_send(ce_hdl, nbuf, &sendlist, transfer_id);
- QDF_ASSERT(status == QDF_STATUS_SUCCESS);
- return status;
- }
- void hif_send_complete_check(struct hif_opaque_softc *hif_ctx, uint8_t pipe,
- int force)
- {
- struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
- if (!force) {
- int resources;
-
- resources = hif_get_free_queue_number(hif_ctx, pipe);
-
- if (resources > (host_ce_config[pipe].src_nentries >> 1)) {
- return;
- }
- }
- #if ATH_11AC_TXCOMPACT
- ce_per_engine_servicereap(scn, pipe);
- #else
- ce_per_engine_service(scn, pipe);
- #endif
- }
- uint16_t
- hif_get_free_queue_number(struct hif_opaque_softc *hif_ctx, uint8_t pipe)
- {
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
- struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]);
- uint16_t rv;
- qdf_spin_lock_bh(&pipe_info->completion_freeq_lock);
- rv = pipe_info->num_sends_allowed;
- qdf_spin_unlock_bh(&pipe_info->completion_freeq_lock);
- return rv;
- }
- void
- hif_pci_ce_send_done(struct CE_handle *copyeng, void *ce_context,
- void *transfer_context, qdf_dma_addr_t CE_data,
- unsigned int nbytes, unsigned int transfer_id,
- unsigned int sw_index, unsigned int hw_index,
- unsigned int toeplitz_hash_result)
- {
- struct HIF_CE_pipe_info *pipe_info =
- (struct HIF_CE_pipe_info *)ce_context;
- struct HIF_CE_state *hif_state = pipe_info->HIF_CE_state;
- struct hif_softc *scn = HIF_GET_SOFTC(hif_state);
- unsigned int sw_idx = sw_index, hw_idx = hw_index;
- struct hif_msg_callbacks *msg_callbacks =
- &hif_state->msg_callbacks_current;
- do {
-
- if (transfer_context != CE_SENDLIST_ITEM_CTXT) {
- if (scn->target_status == TARGET_STATUS_RESET)
- qdf_nbuf_free(transfer_context);
- else
- msg_callbacks->txCompletionHandler(
- msg_callbacks->Context,
- transfer_context, transfer_id,
- toeplitz_hash_result);
- }
- qdf_spin_lock(&pipe_info->completion_freeq_lock);
- pipe_info->num_sends_allowed++;
- qdf_spin_unlock(&pipe_info->completion_freeq_lock);
- } while (ce_completed_send_next(copyeng,
- &ce_context, &transfer_context,
- &CE_data, &nbytes, &transfer_id,
- &sw_idx, &hw_idx,
- &toeplitz_hash_result) == QDF_STATUS_SUCCESS);
- }
- static inline void hif_ce_do_recv(struct hif_msg_callbacks *msg_callbacks,
- qdf_nbuf_t netbuf, int nbytes,
- struct HIF_CE_pipe_info *pipe_info) {
- if (nbytes <= pipe_info->buf_sz) {
- qdf_nbuf_set_pktlen(netbuf, nbytes);
- msg_callbacks->
- rxCompletionHandler(msg_callbacks->Context,
- netbuf, pipe_info->pipe_num);
- } else {
- HIF_ERROR("%s: Invalid Rx msg buf:%p nbytes:%d",
- __func__, netbuf, nbytes);
- qdf_nbuf_free(netbuf);
- }
- }
- void
- hif_pci_ce_recv_data(struct CE_handle *copyeng, void *ce_context,
- void *transfer_context, qdf_dma_addr_t CE_data,
- unsigned int nbytes, unsigned int transfer_id,
- unsigned int flags)
- {
- struct HIF_CE_pipe_info *pipe_info =
- (struct HIF_CE_pipe_info *)ce_context;
- struct HIF_CE_state *hif_state = pipe_info->HIF_CE_state;
- struct CE_state *ce_state = (struct CE_state *) copyeng;
- struct hif_softc *scn = HIF_GET_SOFTC(hif_state);
- #ifdef HIF_PCI
- struct hif_pci_softc *hif_pci_sc = HIF_GET_PCI_SOFTC(hif_state);
- #endif
- struct hif_msg_callbacks *msg_callbacks =
- &hif_state->msg_callbacks_current;
- do {
- #ifdef HIF_PCI
- hif_pm_runtime_mark_last_busy(hif_pci_sc->dev);
- #endif
- qdf_nbuf_unmap_single(scn->qdf_dev,
- (qdf_nbuf_t) transfer_context,
- QDF_DMA_FROM_DEVICE);
- atomic_inc(&pipe_info->recv_bufs_needed);
- hif_post_recv_buffers_for_pipe(pipe_info);
- if (scn->target_status == TARGET_STATUS_RESET)
- qdf_nbuf_free(transfer_context);
- else
- hif_ce_do_recv(msg_callbacks, transfer_context,
- nbytes, pipe_info);
-
- ce_state->receive_count++;
- if (qdf_unlikely(hif_ce_service_should_yield(scn, ce_state))) {
- ce_state->force_break = 1;
- break;
- }
- } while (ce_completed_recv_next(copyeng, &ce_context, &transfer_context,
- &CE_data, &nbytes, &transfer_id,
- &flags) == QDF_STATUS_SUCCESS);
- }
- void
- hif_post_init(struct hif_opaque_softc *hif_ctx, void *unused,
- struct hif_msg_callbacks *callbacks)
- {
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
- #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
- spin_lock_init(&pcie_access_log_lock);
- #endif
-
- qdf_mem_copy(&hif_state->msg_callbacks_pending, callbacks,
- sizeof(hif_state->msg_callbacks_pending));
- }
- int hif_completion_thread_startup(struct HIF_CE_state *hif_state)
- {
- struct CE_handle *ce_diag = hif_state->ce_diag;
- int pipe_num;
- struct hif_softc *scn = HIF_GET_SOFTC(hif_state);
- struct hif_msg_callbacks *hif_msg_callbacks =
- &hif_state->msg_callbacks_current;
-
- if (scn->ce_count == 0) {
- HIF_ERROR("%s: Invalid ce_count", __func__);
- return -EINVAL;
- }
- if (!hif_msg_callbacks ||
- !hif_msg_callbacks->rxCompletionHandler ||
- !hif_msg_callbacks->txCompletionHandler) {
- HIF_ERROR("%s: no completion handler registered", __func__);
- return -EFAULT;
- }
- A_TARGET_ACCESS_LIKELY(scn);
- for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
- struct CE_attr attr;
- struct HIF_CE_pipe_info *pipe_info;
- pipe_info = &hif_state->pipe_info[pipe_num];
- if (pipe_info->ce_hdl == ce_diag) {
- continue;
- }
- attr = host_ce_config[pipe_num];
- if (attr.src_nentries) {
-
- HIF_INFO_MED("%s: pipe_num:%d pipe_info:0x%p",
- __func__, pipe_num, pipe_info);
- ce_send_cb_register(pipe_info->ce_hdl,
- hif_pci_ce_send_done, pipe_info,
- attr.flags & CE_ATTR_DISABLE_INTR);
- pipe_info->num_sends_allowed = attr.src_nentries - 1;
- }
- if (attr.dest_nentries) {
-
- ce_recv_cb_register(pipe_info->ce_hdl,
- hif_pci_ce_recv_data, pipe_info,
- attr.flags & CE_ATTR_DISABLE_INTR);
- }
- if (attr.src_nentries)
- qdf_spinlock_create(&pipe_info->completion_freeq_lock);
- }
- A_TARGET_ACCESS_UNLIKELY(scn);
- return 0;
- }
- static void hif_msg_callbacks_install(struct hif_softc *scn)
- {
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
- qdf_mem_copy(&hif_state->msg_callbacks_current,
- &hif_state->msg_callbacks_pending,
- sizeof(hif_state->msg_callbacks_pending));
- }
- void hif_get_default_pipe(struct hif_opaque_softc *hif_hdl, uint8_t *ULPipe,
- uint8_t *DLPipe)
- {
- int ul_is_polled, dl_is_polled;
- (void)hif_map_service_to_pipe(hif_hdl, HTC_CTRL_RSVD_SVC,
- ULPipe, DLPipe, &ul_is_polled, &dl_is_polled);
- }
- void hif_dump_pipe_debug_count(struct hif_softc *scn)
- {
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
- int pipe_num;
- if (hif_state == NULL) {
- HIF_ERROR("%s hif_state is NULL", __func__);
- return;
- }
- for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
- struct HIF_CE_pipe_info *pipe_info;
- pipe_info = &hif_state->pipe_info[pipe_num];
- if (pipe_info->nbuf_alloc_err_count > 0 ||
- pipe_info->nbuf_dma_err_count > 0 ||
- pipe_info->nbuf_ce_enqueue_err_count)
- HIF_ERROR(
- "%s: pipe_id = %d, recv_bufs_needed = %d, nbuf_alloc_err_count = %u, nbuf_dma_err_count = %u, nbuf_ce_enqueue_err_count = %u",
- __func__, pipe_info->pipe_num,
- atomic_read(&pipe_info->recv_bufs_needed),
- pipe_info->nbuf_alloc_err_count,
- pipe_info->nbuf_dma_err_count,
- pipe_info->nbuf_ce_enqueue_err_count);
- }
- }
- static int hif_post_recv_buffers_for_pipe(struct HIF_CE_pipe_info *pipe_info)
- {
- struct CE_handle *ce_hdl;
- qdf_size_t buf_sz;
- struct hif_softc *scn = HIF_GET_SOFTC(pipe_info->HIF_CE_state);
- QDF_STATUS ret;
- uint32_t bufs_posted = 0;
- buf_sz = pipe_info->buf_sz;
- if (buf_sz == 0) {
-
- return 0;
- }
- ce_hdl = pipe_info->ce_hdl;
- qdf_spin_lock_bh(&pipe_info->recv_bufs_needed_lock);
- while (atomic_read(&pipe_info->recv_bufs_needed) > 0) {
- qdf_dma_addr_t CE_data;
- qdf_nbuf_t nbuf;
- int status;
- atomic_dec(&pipe_info->recv_bufs_needed);
- qdf_spin_unlock_bh(&pipe_info->recv_bufs_needed_lock);
- nbuf = qdf_nbuf_alloc(scn->qdf_dev, buf_sz, 0, 4, false);
- if (!nbuf) {
- qdf_spin_lock_bh(&pipe_info->recv_bufs_needed_lock);
- pipe_info->nbuf_alloc_err_count++;
- qdf_spin_unlock_bh(
- &pipe_info->recv_bufs_needed_lock);
- HIF_ERROR(
- "%s buf alloc error [%d] needed %d, nbuf_alloc_err_count = %u",
- __func__, pipe_info->pipe_num,
- atomic_read(&pipe_info->recv_bufs_needed),
- pipe_info->nbuf_alloc_err_count);
- atomic_inc(&pipe_info->recv_bufs_needed);
- return 1;
- }
-
- ret =
- qdf_nbuf_map_single(scn->qdf_dev, nbuf,
- QDF_DMA_FROM_DEVICE);
- if (unlikely(ret != QDF_STATUS_SUCCESS)) {
- qdf_spin_lock_bh(&pipe_info->recv_bufs_needed_lock);
- pipe_info->nbuf_dma_err_count++;
- qdf_spin_unlock_bh(&pipe_info->recv_bufs_needed_lock);
- HIF_ERROR(
- "%s buf alloc error [%d] needed %d, nbuf_dma_err_count = %u",
- __func__, pipe_info->pipe_num,
- atomic_read(&pipe_info->recv_bufs_needed),
- pipe_info->nbuf_dma_err_count);
- qdf_nbuf_free(nbuf);
- atomic_inc(&pipe_info->recv_bufs_needed);
- return 1;
- }
- CE_data = qdf_nbuf_get_frag_paddr(nbuf, 0);
- qdf_mem_dma_sync_single_for_device(scn->qdf_dev, CE_data,
- buf_sz, DMA_FROM_DEVICE);
- status = ce_recv_buf_enqueue(ce_hdl, (void *)nbuf, CE_data);
- QDF_ASSERT(status == QDF_STATUS_SUCCESS);
- if (status != EOK) {
- qdf_spin_lock_bh(&pipe_info->recv_bufs_needed_lock);
- pipe_info->nbuf_ce_enqueue_err_count++;
- qdf_spin_unlock_bh(&pipe_info->recv_bufs_needed_lock);
- HIF_ERROR(
- "%s buf alloc error [%d] needed %d, nbuf_alloc_err_count = %u",
- __func__, pipe_info->pipe_num,
- atomic_read(&pipe_info->recv_bufs_needed),
- pipe_info->nbuf_ce_enqueue_err_count);
- qdf_nbuf_unmap_single(scn->qdf_dev, nbuf,
- QDF_DMA_FROM_DEVICE);
- atomic_inc(&pipe_info->recv_bufs_needed);
- qdf_nbuf_free(nbuf);
- return 1;
- }
- qdf_spin_lock_bh(&pipe_info->recv_bufs_needed_lock);
- bufs_posted++;
- }
- pipe_info->nbuf_alloc_err_count =
- (pipe_info->nbuf_alloc_err_count > bufs_posted) ?
- pipe_info->nbuf_alloc_err_count - bufs_posted : 0;
- pipe_info->nbuf_dma_err_count =
- (pipe_info->nbuf_dma_err_count > bufs_posted) ?
- pipe_info->nbuf_dma_err_count - bufs_posted : 0;
- pipe_info->nbuf_ce_enqueue_err_count =
- (pipe_info->nbuf_ce_enqueue_err_count > bufs_posted) ?
- pipe_info->nbuf_ce_enqueue_err_count - bufs_posted : 0;
- qdf_spin_unlock_bh(&pipe_info->recv_bufs_needed_lock);
- return 0;
- }
- static int hif_post_recv_buffers(struct hif_softc *scn)
- {
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
- int pipe_num, rv = 0;
- struct CE_state *ce_state;
- A_TARGET_ACCESS_LIKELY(scn);
- for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
- struct HIF_CE_pipe_info *pipe_info;
- ce_state = scn->ce_id_to_state[pipe_num];
- pipe_info = &hif_state->pipe_info[pipe_num];
- if (hif_is_nss_wifi_enabled(scn) &&
- ce_state && (ce_state->htt_rx_data)) {
- continue;
- }
- if (hif_post_recv_buffers_for_pipe(pipe_info)) {
- rv = 1;
- goto done;
- }
- }
- done:
- A_TARGET_ACCESS_UNLIKELY(scn);
- return rv;
- }
- QDF_STATUS hif_start(struct hif_opaque_softc *hif_ctx)
- {
- struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
- hif_update_fastpath_recv_bufs_cnt(scn);
- hif_msg_callbacks_install(scn);
- if (hif_completion_thread_startup(hif_state))
- return QDF_STATUS_E_FAILURE;
-
- (void)hif_post_recv_buffers(scn);
- hif_state->started = true;
- return QDF_STATUS_SUCCESS;
- }
- void hif_recv_buffer_cleanup_on_pipe(struct HIF_CE_pipe_info *pipe_info)
- {
- struct hif_softc *scn;
- struct CE_handle *ce_hdl;
- uint32_t buf_sz;
- struct HIF_CE_state *hif_state;
- qdf_nbuf_t netbuf;
- qdf_dma_addr_t CE_data;
- void *per_CE_context;
- buf_sz = pipe_info->buf_sz;
- if (buf_sz == 0) {
-
- return;
- }
- hif_state = pipe_info->HIF_CE_state;
- if (!hif_state->started) {
- return;
- }
- scn = HIF_GET_SOFTC(hif_state);
- ce_hdl = pipe_info->ce_hdl;
- if (scn->qdf_dev == NULL) {
- return;
- }
- while (ce_revoke_recv_next
- (ce_hdl, &per_CE_context, (void **)&netbuf,
- &CE_data) == QDF_STATUS_SUCCESS) {
- qdf_nbuf_unmap_single(scn->qdf_dev, netbuf,
- QDF_DMA_FROM_DEVICE);
- qdf_nbuf_free(netbuf);
- }
- }
- void hif_send_buffer_cleanup_on_pipe(struct HIF_CE_pipe_info *pipe_info)
- {
- struct CE_handle *ce_hdl;
- struct HIF_CE_state *hif_state;
- struct hif_softc *scn;
- qdf_nbuf_t netbuf;
- void *per_CE_context;
- qdf_dma_addr_t CE_data;
- unsigned int nbytes;
- unsigned int id;
- uint32_t buf_sz;
- uint32_t toeplitz_hash_result;
- buf_sz = pipe_info->buf_sz;
- if (buf_sz == 0) {
-
- return;
- }
- hif_state = pipe_info->HIF_CE_state;
- if (!hif_state->started) {
- return;
- }
- scn = HIF_GET_SOFTC(hif_state);
- ce_hdl = pipe_info->ce_hdl;
- while (ce_cancel_send_next
- (ce_hdl, &per_CE_context,
- (void **)&netbuf, &CE_data, &nbytes,
- &id, &toeplitz_hash_result) == QDF_STATUS_SUCCESS) {
- if (netbuf != CE_SENDLIST_ITEM_CTXT) {
-
- if (id == scn->htc_htt_tx_endpoint)
- return;
-
- if (hif_state->msg_callbacks_current.
- txCompletionHandler)
- hif_state->msg_callbacks_current.
- txCompletionHandler(hif_state->
- msg_callbacks_current.Context,
- netbuf, id, toeplitz_hash_result);
- }
- }
- }
- void hif_buffer_cleanup(struct HIF_CE_state *hif_state)
- {
- int pipe_num;
- struct hif_softc *scn = HIF_GET_SOFTC(hif_state);
- struct CE_state *ce_state;
- for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
- struct HIF_CE_pipe_info *pipe_info;
- ce_state = scn->ce_id_to_state[pipe_num];
- if (hif_is_nss_wifi_enabled(scn) && ce_state &&
- ((ce_state->htt_tx_data) ||
- (ce_state->htt_rx_data))) {
- continue;
- }
- pipe_info = &hif_state->pipe_info[pipe_num];
- hif_recv_buffer_cleanup_on_pipe(pipe_info);
- hif_send_buffer_cleanup_on_pipe(pipe_info);
- }
- }
- void hif_flush_surprise_remove(struct hif_opaque_softc *hif_ctx)
- {
- struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
- hif_buffer_cleanup(hif_state);
- }
- void hif_ce_stop(struct hif_softc *scn)
- {
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
- int pipe_num;
- scn->hif_init_done = false;
-
- if (scn->athdiag_procfs_inited) {
- athdiag_procfs_remove();
- scn->athdiag_procfs_inited = false;
- }
- hif_buffer_cleanup(hif_state);
- for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
- struct HIF_CE_pipe_info *pipe_info;
- pipe_info = &hif_state->pipe_info[pipe_num];
- if (pipe_info->ce_hdl) {
- ce_fini(pipe_info->ce_hdl);
- pipe_info->ce_hdl = NULL;
- pipe_info->buf_sz = 0;
- }
- }
- if (hif_state->sleep_timer_init) {
- qdf_timer_stop(&hif_state->sleep_timer);
- qdf_timer_free(&hif_state->sleep_timer);
- hif_state->sleep_timer_init = false;
- }
- hif_state->started = false;
- }
- void hif_get_target_ce_config(struct CE_pipe_config **target_ce_config_ret,
- int *target_ce_config_sz_ret,
- struct service_to_pipe **target_service_to_ce_map_ret,
- int *target_service_to_ce_map_sz_ret,
- struct shadow_reg_cfg **target_shadow_reg_cfg_ret,
- int *shadow_cfg_sz_ret)
- {
- *target_ce_config_ret = target_ce_config;
- *target_ce_config_sz_ret = target_ce_config_sz;
- *target_service_to_ce_map_ret = target_service_to_ce_map;
- *target_service_to_ce_map_sz_ret = target_service_to_ce_map_sz;
- if (target_shadow_reg_cfg_ret)
- *target_shadow_reg_cfg_ret = target_shadow_reg_cfg;
- if (shadow_cfg_sz_ret)
- *shadow_cfg_sz_ret = shadow_cfg_sz;
- }
- int hif_wlan_enable(struct hif_softc *scn)
- {
- struct pld_wlan_enable_cfg cfg;
- enum pld_driver_mode mode;
- uint32_t con_mode = hif_get_conparam(scn);
- hif_get_target_ce_config((struct CE_pipe_config **)&cfg.ce_tgt_cfg,
- &cfg.num_ce_tgt_cfg,
- (struct service_to_pipe **)&cfg.ce_svc_cfg,
- &cfg.num_ce_svc_pipe_cfg,
- (struct shadow_reg_cfg **)&cfg.shadow_reg_cfg,
- &cfg.num_shadow_reg_cfg);
-
- cfg.num_ce_tgt_cfg /= sizeof(struct CE_pipe_config);
- cfg.num_ce_svc_pipe_cfg /= sizeof(struct service_to_pipe);
- cfg.num_shadow_reg_cfg /= sizeof(struct shadow_reg_cfg);
- if (QDF_GLOBAL_FTM_MODE == con_mode)
- mode = PLD_FTM;
- else if (QDF_IS_EPPING_ENABLED(con_mode))
- mode = PLD_EPPING;
- else
- mode = PLD_MISSION;
- if (BYPASS_QMI)
- return 0;
- else
- return pld_wlan_enable(scn->qdf_dev->dev, &cfg,
- mode, QWLAN_VERSIONSTR);
- }
- #define CE_EPPING_USES_IRQ true
- void hif_ce_prepare_config(struct hif_softc *scn)
- {
- uint32_t mode = hif_get_conparam(scn);
- struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn);
- struct hif_target_info *tgt_info = hif_get_target_info_handle(hif_hdl);
-
- if (QDF_IS_EPPING_ENABLED(mode)) {
- if (CE_EPPING_USES_IRQ)
- host_ce_config = host_ce_config_wlan_epping_irq;
- else
- host_ce_config = host_ce_config_wlan_epping_poll;
- target_ce_config = target_ce_config_wlan_epping;
- target_ce_config_sz = sizeof(target_ce_config_wlan_epping);
- target_service_to_ce_map =
- target_service_to_ce_map_wlan_epping;
- target_service_to_ce_map_sz =
- sizeof(target_service_to_ce_map_wlan_epping);
- target_shadow_reg_cfg = target_shadow_reg_cfg_epping;
- shadow_cfg_sz = sizeof(target_shadow_reg_cfg_epping);
- }
- switch (tgt_info->target_type) {
- default:
- break;
- case TARGET_TYPE_AR900B:
- case TARGET_TYPE_QCA9984:
- case TARGET_TYPE_IPQ4019:
- case TARGET_TYPE_QCA9888:
- host_ce_config = host_ce_config_wlan_ar900b;
- target_ce_config = target_ce_config_wlan_ar900b;
- target_ce_config_sz = sizeof(target_ce_config_wlan_ar900b);
- target_service_to_ce_map = target_service_to_ce_map_ar900b;
- target_service_to_ce_map_sz =
- sizeof(target_service_to_ce_map_ar900b);
- break;
- case TARGET_TYPE_AR9888:
- case TARGET_TYPE_AR9888V2:
- host_ce_config = host_ce_config_wlan_ar9888;
- target_ce_config = target_ce_config_wlan_ar9888;
- target_ce_config_sz = sizeof(target_ce_config_wlan_ar9888);
- target_service_to_ce_map = target_service_to_ce_map_ar900b;
- target_service_to_ce_map_sz =
- sizeof(target_service_to_ce_map_ar900b);
- break;
- }
- }
- QDF_STATUS hif_ce_open(struct hif_softc *hif_sc)
- {
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_sc);
- qdf_spinlock_create(&hif_state->keep_awake_lock);
- return QDF_STATUS_SUCCESS;
- }
- void hif_ce_close(struct hif_softc *hif_sc)
- {
- }
- void hif_unconfig_ce(struct hif_softc *hif_sc)
- {
- int pipe_num;
- struct HIF_CE_pipe_info *pipe_info;
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_sc);
- for (pipe_num = 0; pipe_num < hif_sc->ce_count; pipe_num++) {
- pipe_info = &hif_state->pipe_info[pipe_num];
- if (pipe_info->ce_hdl) {
- ce_unregister_irq(hif_state, (1 << pipe_num));
- hif_sc->request_irq_done = false;
- ce_fini(pipe_info->ce_hdl);
- pipe_info->ce_hdl = NULL;
- pipe_info->buf_sz = 0;
- }
- }
- if (hif_sc->athdiag_procfs_inited) {
- athdiag_procfs_remove();
- hif_sc->athdiag_procfs_inited = false;
- }
- }
- #ifdef CONFIG_BYPASS_QMI
- #define FW_SHARED_MEM (2 * 1024 * 1024)
- static void hif_post_static_buf_to_target(struct hif_softc *scn)
- {
- void *target_va;
- phys_addr_t target_pa;
- target_va = qdf_mem_alloc_consistent(scn->qdf_dev, scn->qdf_dev->dev,
- FW_SHARED_MEM, &target_pa);
- if (NULL == target_va) {
- HIF_TRACE("Memory allocation failed could not post target buf");
- return;
- }
- hif_write32_mb(scn->mem + BYPASS_QMI_TEMP_REGISTER, target_pa);
- HIF_TRACE("target va %pK target pa %pa", target_va, &target_pa);
- }
- #else
- static inline void hif_post_static_buf_to_target(struct hif_softc *scn)
- {
- return;
- }
- #endif
- int hif_config_ce(struct hif_softc *scn)
- {
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
- struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn);
- struct HIF_CE_pipe_info *pipe_info;
- int pipe_num;
- struct CE_state *ce_state;
- #ifdef ADRASTEA_SHADOW_REGISTERS
- int i;
- #endif
- QDF_STATUS rv = QDF_STATUS_SUCCESS;
- scn->notice_send = true;
- hif_post_static_buf_to_target(scn);
- hif_state->fw_indicator_address = FW_INDICATOR_ADDRESS;
- hif_config_rri_on_ddr(scn);
-
- scn->ce_count = HOST_CE_COUNT;
- for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
- struct CE_attr *attr;
- pipe_info = &hif_state->pipe_info[pipe_num];
- pipe_info->pipe_num = pipe_num;
- pipe_info->HIF_CE_state = hif_state;
- attr = &host_ce_config[pipe_num];
- pipe_info->ce_hdl = ce_init(scn, pipe_num, attr);
- ce_state = scn->ce_id_to_state[pipe_num];
- QDF_ASSERT(pipe_info->ce_hdl != NULL);
- if (pipe_info->ce_hdl == NULL) {
- rv = QDF_STATUS_E_FAILURE;
- A_TARGET_ACCESS_UNLIKELY(scn);
- goto err;
- }
- if (pipe_num == DIAG_CE_ID) {
-
- hif_state->ce_diag = pipe_info->ce_hdl;
- continue;
- }
- if (hif_is_nss_wifi_enabled(scn) && ce_state &&
- (ce_state->htt_rx_data))
- continue;
- pipe_info->buf_sz = (qdf_size_t) (attr->src_sz_max);
- qdf_spinlock_create(&pipe_info->recv_bufs_needed_lock);
- if (attr->dest_nentries > 0) {
- atomic_set(&pipe_info->recv_bufs_needed,
- init_buffer_count(attr->dest_nentries - 1));
- } else {
- atomic_set(&pipe_info->recv_bufs_needed, 0);
- }
- ce_tasklet_init(hif_state, (1 << pipe_num));
- ce_register_irq(hif_state, (1 << pipe_num));
- scn->request_irq_done = true;
- }
- if (athdiag_procfs_init(scn) != 0) {
- A_TARGET_ACCESS_UNLIKELY(scn);
- goto err;
- }
- scn->athdiag_procfs_inited = true;
- HIF_INFO_MED("%s: ce_init done", __func__);
- init_tasklet_workers(hif_hdl);
- HIF_TRACE("%s: X, ret = %d", __func__, rv);
- #ifdef ADRASTEA_SHADOW_REGISTERS
- HIF_INFO("%s, Using Shadow Registers instead of CE Registers", __func__);
- for (i = 0; i < NUM_SHADOW_REGISTERS; i++) {
- HIF_INFO("%s Shadow Register%d is mapped to address %x",
- __func__, i,
- (A_TARGET_READ(scn, (SHADOW_ADDRESS(i))) << 2));
- }
- #endif
- return rv != QDF_STATUS_SUCCESS;
- err:
-
- hif_unconfig_ce(scn);
- HIF_TRACE("%s: X, ret = %d", __func__, rv);
- return QDF_STATUS_SUCCESS != QDF_STATUS_E_FAILURE;
- }
- #ifdef WLAN_FEATURE_FASTPATH
- int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
- fastpath_msg_handler handler,
- void *context)
- {
- struct CE_state *ce_state;
- struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
- int i;
- if (!scn) {
- HIF_ERROR("%s: scn is NULL", __func__);
- QDF_ASSERT(0);
- return QDF_STATUS_E_FAILURE;
- }
- if (!scn->fastpath_mode_on) {
- HIF_WARN("%s: Fastpath mode disabled", __func__);
- return QDF_STATUS_E_FAILURE;
- }
- for (i = 0; i < scn->ce_count; i++) {
- ce_state = scn->ce_id_to_state[i];
- if (ce_state->htt_rx_data) {
- ce_state->fastpath_handler = handler;
- ce_state->context = context;
- }
- }
- return QDF_STATUS_SUCCESS;
- }
- #endif
- #ifdef IPA_OFFLOAD
- void hif_ce_ipa_get_ce_resource(struct hif_softc *scn,
- qdf_dma_addr_t *ce_sr_base_paddr,
- uint32_t *ce_sr_ring_size,
- qdf_dma_addr_t *ce_reg_paddr)
- {
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
- struct HIF_CE_pipe_info *pipe_info =
- &(hif_state->pipe_info[HIF_PCI_IPA_UC_ASSIGNED_CE]);
- struct CE_handle *ce_hdl = pipe_info->ce_hdl;
- ce_ipa_get_resource(ce_hdl, ce_sr_base_paddr, ce_sr_ring_size,
- ce_reg_paddr);
- return;
- }
- #endif
- #ifdef ADRASTEA_SHADOW_REGISTERS
- u32 shadow_sr_wr_ind_addr(struct hif_softc *scn, u32 ctrl_addr)
- {
- u32 addr = 0;
- u32 ce = COPY_ENGINE_ID(ctrl_addr);
- switch (ce) {
- case 0:
- addr = SHADOW_VALUE0;
- break;
- case 3:
- addr = SHADOW_VALUE3;
- break;
- case 4:
- addr = SHADOW_VALUE4;
- break;
- case 5:
- addr = SHADOW_VALUE5;
- break;
- case 7:
- addr = SHADOW_VALUE7;
- break;
- default:
- HIF_ERROR("invalid CE ctrl_addr (CE=%d)", ce);
- QDF_ASSERT(0);
- }
- return addr;
- }
- u32 shadow_dst_wr_ind_addr(struct hif_softc *scn, u32 ctrl_addr)
- {
- u32 addr = 0;
- u32 ce = COPY_ENGINE_ID(ctrl_addr);
- switch (ce) {
- case 1:
- addr = SHADOW_VALUE13;
- break;
- case 2:
- addr = SHADOW_VALUE14;
- break;
- case 5:
- addr = SHADOW_VALUE17;
- break;
- case 7:
- addr = SHADOW_VALUE19;
- break;
- case 8:
- addr = SHADOW_VALUE20;
- break;
- case 9:
- addr = SHADOW_VALUE21;
- break;
- case 10:
- addr = SHADOW_VALUE22;
- break;
- case 11:
- addr = SHADOW_VALUE23;
- break;
- default:
- HIF_ERROR("invalid CE ctrl_addr (CE=%d)", ce);
- QDF_ASSERT(0);
- }
- return addr;
- }
- #endif
- #if defined(FEATURE_LRO)
- int ce_lro_flush_cb_register(struct hif_opaque_softc *hif_hdl,
- void (handler)(void *), void *data)
- {
- int rc = 0;
- int i;
- struct CE_state *ce_state;
- struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl);
- QDF_ASSERT(scn != NULL);
- if (scn != NULL) {
- for (i = 0; i < scn->ce_count; i++) {
- ce_state = scn->ce_id_to_state[i];
- if ((ce_state != NULL) && (ce_state->htt_rx_data)) {
- ce_state->lro_flush_cb = handler;
- ce_state->lro_data = data;
- rc++;
- }
- }
- } else {
- HIF_ERROR("%s: hif_state NULL!", __func__);
- }
- return rc;
- }
- int ce_lro_flush_cb_deregister(struct hif_opaque_softc *hif_hdl)
- {
- int rc = 0;
- int i;
- struct CE_state *ce_state;
- struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl);
- QDF_ASSERT(scn != NULL);
- if (scn != NULL) {
- for (i = 0; i < scn->ce_count; i++) {
- ce_state = scn->ce_id_to_state[i];
- if ((ce_state != NULL) && (ce_state->htt_rx_data)) {
- ce_state->lro_flush_cb = NULL;
- ce_state->lro_data = NULL;
- rc++;
- }
- }
- } else {
- HIF_ERROR("%s: hif_state NULL!", __func__);
- }
- return rc;
- }
- #endif
- int hif_map_service_to_pipe(struct hif_opaque_softc *hif_hdl, uint16_t svc_id,
- uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
- int *dl_is_polled)
- {
- int status = QDF_STATUS_E_INVAL;
- unsigned int i;
- struct service_to_pipe element;
- struct service_to_pipe *tgt_svc_map_to_use;
- size_t sz_tgt_svc_map_to_use;
- struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl);
- uint32_t mode = hif_get_conparam(scn);
- struct hif_target_info *tgt_info = hif_get_target_info_handle(hif_hdl);
- bool dl_updated = false;
- bool ul_updated = false;
- if (QDF_IS_EPPING_ENABLED(mode)) {
- tgt_svc_map_to_use = target_service_to_ce_map_wlan_epping;
- sz_tgt_svc_map_to_use =
- sizeof(target_service_to_ce_map_wlan_epping);
- } else {
- switch (tgt_info->target_type) {
- default:
- tgt_svc_map_to_use = target_service_to_ce_map_wlan;
- sz_tgt_svc_map_to_use =
- sizeof(target_service_to_ce_map_wlan);
- break;
- case TARGET_TYPE_AR900B:
- case TARGET_TYPE_QCA9984:
- case TARGET_TYPE_IPQ4019:
- case TARGET_TYPE_QCA9888:
- case TARGET_TYPE_AR9888:
- case TARGET_TYPE_AR9888V2:
- tgt_svc_map_to_use = target_service_to_ce_map_ar900b;
- sz_tgt_svc_map_to_use =
- sizeof(target_service_to_ce_map_ar900b);
- break;
- }
- }
- *dl_is_polled = 0;
- for (i = 0; i < (sz_tgt_svc_map_to_use/sizeof(element)); i++) {
- memcpy(&element, &tgt_svc_map_to_use[i], sizeof(element));
- if (element.service_id == svc_id) {
- if (element.pipedir == PIPEDIR_OUT) {
- *ul_pipe = element.pipenum;
- *ul_is_polled =
- (host_ce_config[*ul_pipe].flags &
- CE_ATTR_DISABLE_INTR) != 0;
- ul_updated = true;
- } else if (element.pipedir == PIPEDIR_IN) {
- *dl_pipe = element.pipenum;
- dl_updated = true;
- }
- status = QDF_STATUS_SUCCESS;
- }
- }
- if (ul_updated == false)
- HIF_WARN("%s: ul pipe is NOT updated for service %d",
- __func__, svc_id);
- if (dl_updated == false)
- HIF_WARN("%s: dl pipe is NOT updated for service %d",
- __func__, svc_id);
- return status;
- }
- #ifdef SHADOW_REG_DEBUG
- inline uint32_t DEBUG_CE_SRC_RING_READ_IDX_GET(struct hif_softc *scn,
- uint32_t CE_ctrl_addr)
- {
- uint32_t read_from_hw, srri_from_ddr = 0;
- read_from_hw = A_TARGET_READ(scn, CE_ctrl_addr + CURRENT_SRRI_ADDRESS);
- srri_from_ddr = SRRI_FROM_DDR_ADDR(VADDR_FOR_CE(scn, CE_ctrl_addr));
- if (read_from_hw != srri_from_ddr) {
- HIF_ERROR("%s: error: read from ddr = %d actual read from register = %d, CE_MISC_INT_STATUS_GET = 0x%x",
- __func__, srri_from_ddr, read_from_hw,
- CE_MISC_INT_STATUS_GET(scn, CE_ctrl_addr));
- QDF_ASSERT(0);
- }
- return srri_from_ddr;
- }
- inline uint32_t DEBUG_CE_DEST_RING_READ_IDX_GET(struct hif_softc *scn,
- uint32_t CE_ctrl_addr)
- {
- uint32_t read_from_hw, drri_from_ddr = 0;
- read_from_hw = A_TARGET_READ(scn, CE_ctrl_addr + CURRENT_DRRI_ADDRESS);
- drri_from_ddr = DRRI_FROM_DDR_ADDR(VADDR_FOR_CE(scn, CE_ctrl_addr));
- if (read_from_hw != drri_from_ddr) {
- HIF_ERROR("error: read from ddr = %d actual read from register = %d, CE_MISC_INT_STATUS_GET = 0x%x",
- drri_from_ddr, read_from_hw,
- CE_MISC_INT_STATUS_GET(scn, CE_ctrl_addr));
- QDF_ASSERT(0);
- }
- return drri_from_ddr;
- }
- #endif
- #ifdef ADRASTEA_RRI_ON_DDR
- inline unsigned int hif_get_src_ring_read_index(struct hif_softc *scn,
- uint32_t CE_ctrl_addr)
- {
- struct CE_attr attr;
- attr = host_ce_config[COPY_ENGINE_ID(CE_ctrl_addr)];
- if (attr.flags & CE_ATTR_DISABLE_INTR)
- return CE_SRC_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr);
- else
- return A_TARGET_READ(scn,
- (CE_ctrl_addr) + CURRENT_SRRI_ADDRESS);
- }
- inline unsigned int hif_get_dst_ring_read_index(struct hif_softc *scn,
- uint32_t CE_ctrl_addr)
- {
- struct CE_attr attr;
- attr = host_ce_config[COPY_ENGINE_ID(CE_ctrl_addr)];
- if (attr.flags & CE_ATTR_DISABLE_INTR)
- return CE_DEST_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr);
- else
- return A_TARGET_READ(scn,
- (CE_ctrl_addr) + CURRENT_DRRI_ADDRESS);
- }
- static inline void hif_config_rri_on_ddr(struct hif_softc *scn)
- {
- unsigned int i;
- qdf_dma_addr_t paddr_rri_on_ddr;
- uint32_t high_paddr, low_paddr;
- scn->vaddr_rri_on_ddr =
- (uint32_t *)qdf_mem_alloc_consistent(scn->qdf_dev,
- scn->qdf_dev->dev, (CE_COUNT*sizeof(uint32_t)),
- &paddr_rri_on_ddr);
- low_paddr = BITS0_TO_31(paddr_rri_on_ddr);
- high_paddr = BITS32_TO_35(paddr_rri_on_ddr);
- HIF_INFO("%s using srri and drri from DDR", __func__);
- WRITE_CE_DDR_ADDRESS_FOR_RRI_LOW(scn, low_paddr);
- WRITE_CE_DDR_ADDRESS_FOR_RRI_HIGH(scn, high_paddr);
- for (i = 0; i < CE_COUNT; i++)
- CE_IDX_UPD_EN_SET(scn, CE_BASE_ADDRESS(i));
- qdf_mem_zero(scn->vaddr_rri_on_ddr, CE_COUNT*sizeof(uint32_t));
- return;
- }
- #else
- static inline void hif_config_rri_on_ddr(struct hif_softc *scn)
- {
- return;
- }
- #endif
- int hif_dump_ce_registers(struct hif_softc *scn)
- {
- struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn);
- uint32_t ce_reg_address = CE0_BASE_ADDRESS;
- uint32_t ce_reg_values[CE_USEFUL_SIZE >> 2];
- uint32_t ce_reg_word_size = CE_USEFUL_SIZE >> 2;
- uint16_t i;
- QDF_STATUS status;
- for (i = 0; i < scn->ce_count; i++, ce_reg_address += CE_OFFSET) {
- if (scn->ce_id_to_state[i] == NULL) {
- HIF_DBG("CE%d not used.", i);
- continue;
- }
- status = hif_diag_read_mem(hif_hdl, ce_reg_address,
- (uint8_t *) &ce_reg_values[0],
- ce_reg_word_size * sizeof(uint32_t));
- if (status != QDF_STATUS_SUCCESS) {
- HIF_ERROR("Dumping CE register failed!");
- return -EACCES;
- }
- HIF_ERROR("CE%d Registers:", i);
- qdf_trace_hex_dump(QDF_MODULE_ID_HIF, QDF_TRACE_LEVEL_DEBUG,
- (uint8_t *) &ce_reg_values[0],
- ce_reg_word_size * sizeof(uint32_t));
- }
- return 0;
- }
- #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
- struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
- struct hif_pipe_addl_info *hif_info, uint32_t pipe)
- {
- struct hif_softc *scn = HIF_GET_SOFTC(osc);
- struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn);
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(osc);
- struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]);
- struct CE_handle *ce_hdl = pipe_info->ce_hdl;
- struct CE_state *ce_state = (struct CE_state *)ce_hdl;
- struct CE_ring_state *src_ring = ce_state->src_ring;
- struct CE_ring_state *dest_ring = ce_state->dest_ring;
- if (src_ring) {
- hif_info->ul_pipe.nentries = src_ring->nentries;
- hif_info->ul_pipe.nentries_mask = src_ring->nentries_mask;
- hif_info->ul_pipe.sw_index = src_ring->sw_index;
- hif_info->ul_pipe.write_index = src_ring->write_index;
- hif_info->ul_pipe.hw_index = src_ring->hw_index;
- hif_info->ul_pipe.base_addr_CE_space =
- src_ring->base_addr_CE_space;
- hif_info->ul_pipe.base_addr_owner_space =
- src_ring->base_addr_owner_space;
- }
- if (dest_ring) {
- hif_info->dl_pipe.nentries = dest_ring->nentries;
- hif_info->dl_pipe.nentries_mask = dest_ring->nentries_mask;
- hif_info->dl_pipe.sw_index = dest_ring->sw_index;
- hif_info->dl_pipe.write_index = dest_ring->write_index;
- hif_info->dl_pipe.hw_index = dest_ring->hw_index;
- hif_info->dl_pipe.base_addr_CE_space =
- dest_ring->base_addr_CE_space;
- hif_info->dl_pipe.base_addr_owner_space =
- dest_ring->base_addr_owner_space;
- }
- hif_info->pci_mem = pci_resource_start(sc->pdev, 0);
- hif_info->ctrl_addr = ce_state->ctrl_addr;
- return hif_info;
- }
- uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc, uint32_t mode)
- {
- struct hif_softc *scn = HIF_GET_SOFTC(osc);
- scn->nss_wifi_ol_mode = mode;
- return 0;
- }
- #endif
- void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num)
- {
- struct hif_softc *scn = HIF_GET_SOFTC(osc);
- struct CE_state *CE_state = scn->ce_id_to_state[pipe_num];
- uint32_t ctrl_addr = CE_state->ctrl_addr;
- Q_TARGET_ACCESS_BEGIN(scn);
- CE_COPY_COMPLETE_INTR_DISABLE(scn, ctrl_addr);
- Q_TARGET_ACCESS_END(scn);
- }
- static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state)
- {
- struct hif_msg_callbacks *msg_callbacks =
- &hif_state->msg_callbacks_current;
- if (!msg_callbacks->fwEventHandler)
- return;
- msg_callbacks->fwEventHandler(msg_callbacks->Context,
- QDF_STATUS_E_FAILURE);
- }
- #ifndef QCA_WIFI_3_0
- irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
- {
- struct hif_softc *scn = arg;
- struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
- uint32_t fw_indicator_address, fw_indicator;
- if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
- return ATH_ISR_NOSCHED;
- fw_indicator_address = hif_state->fw_indicator_address;
-
- fw_indicator = A_TARGET_READ(scn, fw_indicator_address);
- if ((fw_indicator != ~0) && (fw_indicator & FW_IND_EVENT_PENDING)) {
-
- A_TARGET_WRITE(scn, fw_indicator_address,
- fw_indicator & ~FW_IND_EVENT_PENDING);
- if (Q_TARGET_ACCESS_END(scn) < 0)
- return ATH_ISR_SCHED;
- if (hif_state->started) {
- hif_fw_event_handler(hif_state);
- } else {
-
- AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
- ("%s: Early firmware event indicated\n",
- __func__));
- }
- } else {
- if (Q_TARGET_ACCESS_END(scn) < 0)
- return ATH_ISR_SCHED;
- }
- return ATH_ISR_SCHED;
- }
- #else
- irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
- {
- return ATH_ISR_SCHED;
- }
- #endif
- void hif_wlan_disable(struct hif_softc *scn)
- {
- enum pld_driver_mode mode;
- uint32_t con_mode = hif_get_conparam(scn);
- if (QDF_GLOBAL_FTM_MODE == con_mode)
- mode = PLD_FTM;
- else if (QDF_IS_EPPING_ENABLED(con_mode))
- mode = PLD_EPPING;
- else
- mode = PLD_MISSION;
- pld_wlan_disable(scn->qdf_dev->dev, mode);
- }
|