RoutingTests.cpp 153 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133
  1. /*
  2. * Copyright (c) 2017-2018,2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above
  10. * copyright notice, this list of conditions and the following
  11. * disclaimer in the documentation and/or other materials provided
  12. * with the distribution.
  13. * * Neither the name of The Linux Foundation nor the names of its
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  18. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  21. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  24. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  25. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  26. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  27. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <unistd.h>
  32. #include <string.h>
  33. #include <stdint.h>
  34. #include "hton.h" // for htonl
  35. #include "InterfaceAbstraction.h"
  36. #include "Constants.h"
  37. #include "Logger.h"
  38. #include "TestsUtils.h"
  39. #include "linux/msm_ipa.h"
  40. #include "RoutingDriverWrapper.h"
  41. #include "Filtering.h"
  42. #include "IPAFilteringTable.h"
  43. #define TOS_FIELD_OFFSET (1)
  44. #define DST_ADDR_LSB_OFFSET_IPV4 (19)
  45. #define SRC_ADDR_LSB_OFFSET_IPV4 (15)
  46. #define DST_ADDR_MSB_OFFSET_IPV6 (24)
  47. #define DST_ADDR_LSB_OFFSET_IPV6 (39)
  48. #define TRAFFIC_CLASS_MSB_OFFSET_IPV6 (0)
  49. #define TRAFFIC_CLASS_LSB_OFFSET_IPV6 (1)
  50. #define FLOW_CLASS_MSB_OFFSET_IPV6 (1)
  51. #define FLOW_CLASS_MB_OFFSET_IPV6 (2)
  52. #define FLOW_CLASS_LSB_OFFSET_IPV6 (3)
  53. #define IPV4_DST_PORT_OFFSET (20+2)
  54. #define IPV6_SRC_PORT_OFFSET (40)
  55. #define IPV6_DST_PORT_OFFSET (40+2)
  56. #define IPv4_TCP_FLAGS_OFFSET (20+13)
  57. #define IPv6_TCP_FLAGS_OFFSET (40+13)
  58. #define TCP_ACK_FLAG_MASK (0x10)
  59. extern Logger g_Logger;
  60. class IpaRoutingBlockTestFixture:public TestBase
  61. {
  62. public:
  63. IpaRoutingBlockTestFixture():
  64. m_sendSize (BUFF_MAX_SIZE),
  65. m_sendSize2 (BUFF_MAX_SIZE),
  66. m_sendSize3 (BUFF_MAX_SIZE),
  67. m_IpaIPType(IPA_IP_v4)
  68. {
  69. memset(m_sendBuffer, 0, sizeof(m_sendBuffer));
  70. memset(m_sendBuffer2, 0, sizeof(m_sendBuffer2));
  71. memset(m_sendBuffer3, 0, sizeof(m_sendBuffer3));
  72. m_testSuiteName.push_back("Routing");
  73. }
  74. static int SetupKernelModule(bool en_status = false)
  75. {
  76. int retval;
  77. struct ipa_channel_config from_ipa_channels[3];
  78. struct test_ipa_ep_cfg from_ipa_cfg[3];
  79. struct ipa_channel_config to_ipa_channels[1];
  80. struct test_ipa_ep_cfg to_ipa_cfg[1];
  81. struct ipa_test_config_header header = {0};
  82. struct ipa_channel_config *to_ipa_array[1];
  83. struct ipa_channel_config *from_ipa_array[3];
  84. /* From ipa configurations - 3 pipes */
  85. memset(&from_ipa_cfg[0], 0, sizeof(from_ipa_cfg[0]));
  86. prepare_channel_struct(&from_ipa_channels[0],
  87. header.from_ipa_channels_num++,
  88. IPA_CLIENT_TEST2_CONS,
  89. (void *)&from_ipa_cfg[0],
  90. sizeof(from_ipa_cfg[0]), en_status);
  91. from_ipa_array[0] = &from_ipa_channels[0];
  92. memset(&from_ipa_cfg[1], 0, sizeof(from_ipa_cfg[1]));
  93. prepare_channel_struct(&from_ipa_channels[1],
  94. header.from_ipa_channels_num++,
  95. IPA_CLIENT_TEST3_CONS,
  96. (void *)&from_ipa_cfg[1],
  97. sizeof(from_ipa_cfg[1]), en_status);
  98. from_ipa_array[1] = &from_ipa_channels[1];
  99. memset(&from_ipa_cfg[2], 0, sizeof(from_ipa_cfg[2]));
  100. prepare_channel_struct(&from_ipa_channels[2],
  101. header.from_ipa_channels_num++,
  102. IPA_CLIENT_TEST4_CONS,
  103. (void *)&from_ipa_cfg[2],
  104. sizeof(from_ipa_cfg[2]), en_status);
  105. from_ipa_array[2] = &from_ipa_channels[2];
  106. /* To ipa configurations - 1 pipes */
  107. memset(&to_ipa_cfg[0], 0, sizeof(to_ipa_cfg[0]));
  108. prepare_channel_struct(&to_ipa_channels[0],
  109. header.to_ipa_channels_num++,
  110. IPA_CLIENT_TEST_PROD,
  111. (void *)&to_ipa_cfg[0],
  112. sizeof(to_ipa_cfg[0]));
  113. to_ipa_array[0] = &to_ipa_channels[0];
  114. prepare_header_struct(&header, from_ipa_array, to_ipa_array);
  115. retval = GenericConfigureScenario(&header);
  116. return retval;
  117. }
  118. bool Setup(bool en_status)
  119. {
  120. bool bRetVal = true;
  121. bRetVal = SetupKernelModule(en_status);
  122. if (bRetVal != true) {
  123. return bRetVal;
  124. }
  125. m_producer.Open(INTERFACE0_TO_IPA_DATA_PATH, INTERFACE0_FROM_IPA_DATA_PATH);
  126. m_consumer.Open(INTERFACE1_TO_IPA_DATA_PATH, INTERFACE1_FROM_IPA_DATA_PATH);
  127. m_consumer2.Open(INTERFACE2_TO_IPA_DATA_PATH, INTERFACE2_FROM_IPA_DATA_PATH);
  128. m_defaultConsumer.Open(INTERFACE3_TO_IPA_DATA_PATH, INTERFACE3_FROM_IPA_DATA_PATH);
  129. if (!m_routing.DeviceNodeIsOpened()) {
  130. printf("Routing block is not ready for immediate commands!\n");
  131. return false;
  132. }
  133. if (!m_filtering.DeviceNodeIsOpened()) {
  134. printf("Filtering block is not ready for immediate commands!\n");
  135. return false;
  136. }
  137. m_routing.Reset(IPA_IP_v4);
  138. m_routing.Reset(IPA_IP_v6);
  139. return true;
  140. } /* Setup()*/
  141. bool Setup()
  142. {
  143. return Setup(false);
  144. }
  145. bool Teardown()
  146. {
  147. if (!m_routing.DeviceNodeIsOpened()) {
  148. printf("Routing block is not ready for immediate commands!\n");
  149. return false;
  150. }
  151. if (!m_filtering.DeviceNodeIsOpened()) {
  152. printf("Filtering block is not ready for immediate commands!\n");
  153. return false;
  154. }
  155. m_producer.Close();
  156. m_consumer.Close();
  157. m_consumer2.Close();
  158. m_defaultConsumer.Close();
  159. return true;
  160. } /* Teardown() */
  161. bool LoadFiles(enum ipa_ip_type ip)
  162. {
  163. string fileName;
  164. if (IPA_IP_v4 == ip) {
  165. fileName = "Input/IPv4_1";
  166. } else {
  167. fileName = "Input/IPv6";
  168. }
  169. if (!LoadDefaultPacket(ip, m_sendBuffer, m_sendSize)) {
  170. LOG_MSG_ERROR("Failed loading default Packet");
  171. return false;
  172. }
  173. if (!LoadDefaultPacket(ip, m_sendBuffer2, m_sendSize2)) {
  174. LOG_MSG_ERROR("Failed loading default Packet");
  175. return false;
  176. }
  177. if (!LoadDefaultPacket(ip, m_sendBuffer3, m_sendSize3)) {
  178. LOG_MSG_ERROR("Failed loading default Packet");
  179. return false;
  180. }
  181. return true;
  182. }
  183. bool ReceivePacketAndCompareFrom(InterfaceAbstraction& cons, Byte* send,
  184. size_t send_sz, bool shouldBeHit)
  185. {
  186. size_t receivedSize = 0;
  187. bool isSuccess = true;
  188. /* Receive results*/
  189. Byte *rxBuff1 = new Byte[0x400];
  190. if (NULL == rxBuff1)
  191. {
  192. printf("Memory allocation error.\n");
  193. return false;
  194. }
  195. receivedSize = cons.ReceiveData(rxBuff1, 0x400);
  196. printf("Received %zu bytes on %s.\n", receivedSize, cons.m_fromChannelName.c_str());
  197. // Compare results
  198. isSuccess &= CompareResultVsGolden_w_Status(send, send_sz, rxBuff1, receivedSize);
  199. if (shouldBeHit) {
  200. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  201. IsCacheHit_v5_0(send_sz, receivedSize, rxBuff1) : IsCacheHit(send_sz, receivedSize, rxBuff1);
  202. }
  203. else
  204. {
  205. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  206. IsCacheMiss_v5_0(send_sz, receivedSize, rxBuff1) : IsCacheMiss(send_sz, receivedSize, rxBuff1);
  207. }
  208. size_t recievedBufferSize = receivedSize * 3;
  209. size_t sentBufferSize = m_sendSize * 3;
  210. char *recievedBuffer = new char[recievedBufferSize];
  211. char *sentBuffer = new char[sentBufferSize];
  212. // char * p = recievedBuffer;
  213. size_t j;
  214. for(j = 0; j < m_sendSize; j++)
  215. snprintf(&sentBuffer[3 * j], sentBufferSize - (3 * j + 1), " %02X", send[j]);
  216. for(j = 0; j < receivedSize; j++)
  217. // recievedBuffer += sprintf(recievedBuffer, "%02X", rxBuff1[i]);
  218. snprintf(&recievedBuffer[3 * j], recievedBufferSize - (3 * j + 1), " %02X", rxBuff1[j]);
  219. printf("Expected Value (%zu)\n%s\n, Received Value1(%zu)\n%s\n",send_sz,sentBuffer,receivedSize,recievedBuffer);
  220. delete[] rxBuff1;
  221. delete[] recievedBuffer;
  222. delete[] sentBuffer;
  223. return isSuccess;
  224. }
  225. bool ReceivePacketsAndCompare()
  226. {
  227. size_t receivedSize = 0;
  228. size_t receivedSize2 = 0;
  229. size_t receivedSize3 = 0;
  230. bool pkt1_cmp_succ, pkt2_cmp_succ, pkt3_cmp_succ;
  231. // Receive results
  232. Byte *rxBuff1 = new Byte[0x400];
  233. Byte *rxBuff2 = new Byte[0x400];
  234. Byte *rxBuff3 = new Byte[0x400];
  235. if (NULL == rxBuff1 || NULL == rxBuff2 || NULL == rxBuff3)
  236. {
  237. printf("Memory allocation error.\n");
  238. return false;
  239. }
  240. memset(rxBuff1, 0, 0x400);
  241. memset(rxBuff2, 0, 0x400);
  242. memset(rxBuff3, 0, 0x400);
  243. receivedSize = m_consumer.ReceiveData(rxBuff1, 0x400);
  244. printf("Received %zu bytes on %s.\n", receivedSize, m_consumer.m_fromChannelName.c_str());
  245. receivedSize2 = m_consumer2.ReceiveData(rxBuff2, 0x400);
  246. printf("Received %zu bytes on %s.\n", receivedSize2, m_consumer2.m_fromChannelName.c_str());
  247. receivedSize3 = m_defaultConsumer.ReceiveData(rxBuff3, 0x400);
  248. printf("Received %zu bytes on %s.\n", receivedSize3, m_defaultConsumer.m_fromChannelName.c_str());
  249. /* Compare results */
  250. pkt1_cmp_succ = CompareResultVsGolden(m_sendBuffer, m_sendSize, rxBuff1, receivedSize);
  251. pkt2_cmp_succ = CompareResultVsGolden(m_sendBuffer2, m_sendSize2, rxBuff2, receivedSize2);
  252. pkt3_cmp_succ = CompareResultVsGolden(m_sendBuffer3, m_sendSize3, rxBuff3, receivedSize3);
  253. size_t recievedBufferSize =
  254. MAX3(receivedSize, receivedSize2, receivedSize3) * 3;
  255. size_t sentBufferSize =
  256. MAX3(m_sendSize, m_sendSize2, m_sendSize3) * 3;
  257. char *recievedBuffer = new char[recievedBufferSize];
  258. char *sentBuffer = new char[sentBufferSize];
  259. if (NULL == recievedBuffer || NULL == sentBuffer) {
  260. printf("Memory allocation error\n");
  261. return false;
  262. }
  263. size_t j;
  264. memset(recievedBuffer, 0, recievedBufferSize);
  265. memset(sentBuffer, 0, sentBufferSize);
  266. for(j = 0; j < m_sendSize; j++)
  267. snprintf(&sentBuffer[3 * j], sentBufferSize - (3 * j + 1), " %02X", m_sendBuffer[j]);
  268. for(j = 0; j < receivedSize; j++)
  269. snprintf(&recievedBuffer[3 * j], recievedBufferSize - (3 * j + 1), " %02X", rxBuff1[j]);
  270. printf("Expected Value1(%zu)\n%s\n, Received Value1(%zu)\n%s\n-->Value1 %s\n",
  271. m_sendSize,sentBuffer,receivedSize,recievedBuffer,
  272. pkt1_cmp_succ?"Match":"no Match");
  273. memset(recievedBuffer, 0, recievedBufferSize);
  274. memset(sentBuffer, 0, sentBufferSize);
  275. for(j = 0; j < m_sendSize2; j++)
  276. snprintf(&sentBuffer[3 * j], sentBufferSize - (3 * j + 1), " %02X", m_sendBuffer2[j]);
  277. for(j = 0; j < receivedSize2; j++)
  278. snprintf(&recievedBuffer[3 * j], recievedBufferSize - (3 * j + 1), " %02X", rxBuff2[j]);
  279. printf("Expected Value2 (%zu)\n%s\n, Received Value2(%zu)\n%s\n-->Value2 %s\n",
  280. m_sendSize2,sentBuffer,receivedSize2,recievedBuffer,
  281. pkt2_cmp_succ?"Match":"no Match");
  282. memset(recievedBuffer, 0, recievedBufferSize);
  283. memset(sentBuffer, 0, sentBufferSize);
  284. for(j = 0; j < m_sendSize3; j++)
  285. snprintf(&sentBuffer[3 * j], sentBufferSize - (3 * j + 1), " %02X", m_sendBuffer3[j]);
  286. for(j = 0; j < receivedSize3; j++)
  287. snprintf(&recievedBuffer[3 * j], recievedBufferSize - (3 * j + 1), " %02X", rxBuff3[j]);
  288. printf("Expected Value3 (%zu)\n%s\n, Received Value3(%zu)\n%s\n-->Value3 %s\n",
  289. m_sendSize3,sentBuffer,receivedSize3,recievedBuffer,
  290. pkt3_cmp_succ?"Match":"no Match");
  291. delete[] recievedBuffer;
  292. delete[] sentBuffer;
  293. delete[] rxBuff1;
  294. delete[] rxBuff2;
  295. delete[] rxBuff3;
  296. return pkt1_cmp_succ && pkt2_cmp_succ && pkt3_cmp_succ;
  297. }
  298. void print_packets(size_t receivedSize, size_t m_sendSize, size_t recievedBufferSize, size_t sentBufferSize, Byte *rxBuff, Byte *m_sendBuffer, char *recievedBuffer, char *sentBuffer)
  299. {
  300. size_t j;
  301. for(j = 0; j < m_sendSize; j++) {
  302. snprintf(&sentBuffer[3 * j], sentBufferSize - 3 * j,
  303. " %02X", m_sendBuffer[j]);
  304. }
  305. for(j = 0; j < receivedSize; j++) {
  306. snprintf(&recievedBuffer[3 * j], recievedBufferSize- 3 * j,
  307. " %02X", rxBuff[j]);
  308. }
  309. printf("Expected Value (%zu)\n%s\n, Received Value(%zu)\n%s\n",m_sendSize,sentBuffer,receivedSize,recievedBuffer);
  310. }
  311. ~IpaRoutingBlockTestFixture()
  312. {
  313. m_sendSize = 0;
  314. m_sendSize2 = 0;
  315. m_sendSize3 = 0;
  316. }
  317. void InitFilteringBlock()
  318. {
  319. IPAFilteringTable fltTable;
  320. struct ipa_ioc_get_rt_tbl st_rt_tbl;
  321. struct ipa_flt_rule_add flt_rule_entry;
  322. memset(&st_rt_tbl, 0, sizeof(st_rt_tbl));
  323. memset(&flt_rule_entry, 0, sizeof(flt_rule_entry));
  324. strlcpy(st_rt_tbl.name, "LAN", sizeof(st_rt_tbl.name));
  325. st_rt_tbl.ip = m_IpaIPType;
  326. fltTable.Init(m_IpaIPType, IPA_CLIENT_TEST_PROD, false, 1);
  327. m_routing.GetRoutingTable(&st_rt_tbl);
  328. flt_rule_entry.rule.rt_tbl_hdl = st_rt_tbl.hdl;
  329. fltTable.AddRuleToTable(flt_rule_entry);
  330. m_filtering.AddFilteringRule(fltTable.GetFilteringTable());
  331. }
  332. inline bool VerifyStatusReceived(size_t SendSize, size_t RecvSize)
  333. {
  334. size_t stts_size = sizeof(struct ipa3_hw_pkt_status);
  335. if (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) {
  336. stts_size = sizeof(struct ipa3_hw_pkt_status_hw_v5_0);
  337. }
  338. if ((RecvSize <= SendSize) ||
  339. ((RecvSize - SendSize) != stts_size)){
  340. printf("received buffer size does not match! sent:receive [%zu]:[%zu]\n",SendSize,RecvSize);
  341. return false;
  342. }
  343. return true;
  344. }
  345. inline bool IsCacheHit(size_t SendSize, size_t RecvSize, void *Buff)
  346. {
  347. struct ipa3_hw_pkt_status *pStatus = (struct ipa3_hw_pkt_status *)Buff;
  348. if (VerifyStatusReceived(SendSize,RecvSize) == false){
  349. return false;
  350. }
  351. if((bool)pStatus->route_hash){
  352. printf ("%s::cache hit!! \n",__FUNCTION__);
  353. return true;
  354. }
  355. printf ("%s::cache miss!! \n",__FUNCTION__);
  356. return false;
  357. }
  358. inline bool IsCacheHit_v5_0(size_t SendSize, size_t RecvSize, void *Buff)
  359. {
  360. struct ipa3_hw_pkt_status_hw_v5_0 *pStatus = (struct ipa3_hw_pkt_status_hw_v5_0 *)Buff;
  361. if (VerifyStatusReceived(SendSize,RecvSize) == false){
  362. return false;
  363. }
  364. if((bool)pStatus->route_hash){
  365. printf ("%s::cache hit!! \n",__FUNCTION__);
  366. return true;
  367. }
  368. printf ("%s::cache miss!! \n",__FUNCTION__);
  369. return false;
  370. }
  371. inline bool IsCacheMiss(size_t SendSize, size_t RecvSize, void *Buff)
  372. {
  373. struct ipa3_hw_pkt_status *pStatus = (struct ipa3_hw_pkt_status *)Buff;
  374. if (VerifyStatusReceived(SendSize,RecvSize) == false){
  375. return false;
  376. }
  377. if(!((bool)pStatus->route_hash)){
  378. printf ("%s::cache miss!! \n",__FUNCTION__);
  379. return true;
  380. }
  381. printf ("%s::cache hit!! \n",__FUNCTION__);
  382. return false;
  383. }
  384. inline bool IsCacheMiss_v5_0(size_t SendSize, size_t RecvSize, void *Buff)
  385. {
  386. struct ipa3_hw_pkt_status_hw_v5_0 *pStatus = (struct ipa3_hw_pkt_status_hw_v5_0 *)Buff;
  387. if (VerifyStatusReceived(SendSize,RecvSize) == false){
  388. return false;
  389. }
  390. if(!((bool)pStatus->route_hash)){
  391. printf ("%s::cache miss!! \n",__FUNCTION__);
  392. return true;
  393. }
  394. printf ("%s::cache hit!! \n",__FUNCTION__);
  395. return false;
  396. }
  397. static RoutingDriverWrapper m_routing;
  398. static Filtering m_filtering;
  399. static const size_t BUFF_MAX_SIZE = 1024;
  400. InterfaceAbstraction m_producer;
  401. InterfaceAbstraction m_consumer;
  402. InterfaceAbstraction m_consumer2;
  403. InterfaceAbstraction m_defaultConsumer;
  404. Byte m_sendBuffer[BUFF_MAX_SIZE]; // First input file / IP packet
  405. Byte m_sendBuffer2[BUFF_MAX_SIZE]; // Second input file / IP packet
  406. Byte m_sendBuffer3[BUFF_MAX_SIZE]; // Third input file (default) / IP packet
  407. size_t m_sendSize;
  408. size_t m_sendSize2;
  409. size_t m_sendSize3;
  410. enum ipa_ip_type m_IpaIPType;
  411. private:
  412. };
  413. RoutingDriverWrapper IpaRoutingBlockTestFixture::m_routing;
  414. Filtering IpaRoutingBlockTestFixture::m_filtering;
  415. /*---------------------------------------------------------------------------*/
  416. /* Test1: Tests routing by destination address */
  417. /*---------------------------------------------------------------------------*/
  418. class IpaRoutingBlockTest1 : public IpaRoutingBlockTestFixture
  419. {
  420. public:
  421. IpaRoutingBlockTest1()
  422. {
  423. m_name = "IpaRoutingBlockTest1";
  424. m_description =" \
  425. Routing block test 001 - Destination address exact match\1. Generate and commit a single routing tables. \
  426. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  427. All DST_IP == (192.169.2.170 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  428. All DST_IP == (192.168.2.255 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  429. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  430. m_IpaIPType = IPA_IP_v4;
  431. Register(*this);
  432. }
  433. bool Run()
  434. {
  435. bool res = false;
  436. bool isSuccess = false;
  437. // Add the relevant routing rules
  438. res = AddRules();
  439. if (false == res) {
  440. printf("Failed adding routing rules.\n");
  441. return false;
  442. }
  443. // Load input data (IP packet) from file
  444. res = LoadFiles(IPA_IP_v4);
  445. if (false == res) {
  446. printf("Failed loading files.\n");
  447. return false;
  448. }
  449. // Send first packet
  450. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xFF;
  451. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  452. if (false == isSuccess)
  453. {
  454. printf("SendData failure.\n");
  455. return false;
  456. }
  457. // Send second packet
  458. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  459. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  460. if (false == isSuccess)
  461. {
  462. printf("SendData failure.\n");
  463. return false;
  464. }
  465. // Send third packet
  466. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  467. if (false == isSuccess)
  468. {
  469. printf("SendData failure.\n");
  470. return false;
  471. }
  472. // Receive packets from the channels and compare results
  473. isSuccess = ReceivePacketsAndCompare();
  474. return isSuccess;
  475. } // Run()
  476. bool AddRules()
  477. {
  478. struct ipa_ioc_add_rt_rule *rt_rule;
  479. struct ipa_rt_rule_add *rt_rule_entry;
  480. const int NUM_RULES = 3;
  481. rt_rule = (struct ipa_ioc_add_rt_rule *)
  482. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  483. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  484. if(!rt_rule) {
  485. printf("Failed memory allocation for rt_rule\n");
  486. return false;
  487. }
  488. rt_rule->commit = 1;
  489. rt_rule->num_rules = NUM_RULES;
  490. rt_rule->ip = IPA_IP_v4;
  491. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  492. rt_rule_entry = &rt_rule->rules[0];
  493. rt_rule_entry->at_rear = 0;
  494. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  495. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // gidons, there is no support for header insertion / removal yet.
  496. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  497. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802FF;
  498. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  499. rt_rule_entry = &rt_rule->rules[1];
  500. rt_rule_entry->at_rear = 0;
  501. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  502. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // gidons, there is no support for header insertion / removal yet.
  503. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  504. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA;
  505. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  506. rt_rule_entry = &rt_rule->rules[2];
  507. rt_rule_entry->at_rear = 1;
  508. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  509. if (false == m_routing.AddRoutingRule(rt_rule))
  510. {
  511. printf("Routing rule addition failed!\n");
  512. return false;
  513. }
  514. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  515. free(rt_rule);
  516. InitFilteringBlock();
  517. return true;
  518. }
  519. };
  520. /*---------------------------------------------------------------------------*/
  521. /* Test2: Tests routing by destination address with a subnet (mask) */
  522. /*---------------------------------------------------------------------------*/
  523. class IpaRoutingBlockTest2 : IpaRoutingBlockTestFixture
  524. {
  525. public:
  526. IpaRoutingBlockTest2()
  527. {
  528. m_name = "IpaRoutingBlockTest2";
  529. m_description =" \
  530. Routing block test 002 - Destination address subnet match \
  531. 1. Generate and commit a single routing tables. \
  532. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  533. All DST_IP == (192.169.170.0 & 255.255.255.0)traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  534. All DST_IP == (192.168.255.0 & 255.255.255.0)traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  535. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  536. m_IpaIPType = IPA_IP_v4;
  537. Register(*this);
  538. }
  539. bool Run()
  540. {
  541. bool res = false;
  542. bool isSuccess = false;
  543. printf("ENTRY: IpaRoutingBlockTest2::Run()\n");
  544. // Add the relevant routing rules
  545. res = AddRules();
  546. if (false == res) {
  547. printf("Failed adding routing rules.\n");
  548. return false;
  549. }
  550. // Load input data (IP packet) from file
  551. res = LoadFiles(IPA_IP_v4);
  552. if (false == res) {
  553. printf("Failed loading files.\n");
  554. return false;
  555. }
  556. // Send first packet
  557. m_sendBuffer[18] = 0xFF;
  558. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  559. if (false == isSuccess)
  560. {
  561. printf("SendData failure.\n");
  562. return false;
  563. }
  564. // Send second packet
  565. m_sendBuffer2[18] = 0xAA;
  566. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  567. if (false == isSuccess)
  568. {
  569. printf("SendData failure.\n");
  570. return false;
  571. }
  572. // Send third packet
  573. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  574. if (false == isSuccess)
  575. {
  576. printf("SendData failure.\n");
  577. return false;
  578. }
  579. // Receive packets from the channels and compare results
  580. isSuccess = ReceivePacketsAndCompare();
  581. return isSuccess;
  582. } // Run()
  583. bool AddRules()
  584. {
  585. struct ipa_ioc_add_rt_rule *rt_rule;
  586. struct ipa_rt_rule_add *rt_rule_entry;
  587. const int NUM_RULES = 3;
  588. printf("ENTRY: IpaRoutingBlockTest2::AddRules()\n");
  589. rt_rule = (struct ipa_ioc_add_rt_rule *)
  590. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  591. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  592. if(!rt_rule) {
  593. printf("fail\n");
  594. return false;
  595. }
  596. rt_rule->commit = 1;
  597. rt_rule->num_rules = NUM_RULES;
  598. rt_rule->ip = IPA_IP_v4;
  599. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  600. rt_rule_entry = &rt_rule->rules[0];
  601. rt_rule_entry->at_rear = 0;
  602. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  603. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // gidons, there is no support for header insertion / removal yet.
  604. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  605. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A8FF00;
  606. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFF00;
  607. rt_rule_entry = &rt_rule->rules[1];
  608. rt_rule_entry->at_rear = 0;
  609. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  610. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // gidons, there is no support for header insertion / removal yet.
  611. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  612. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A8AA00;
  613. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFF00;
  614. rt_rule_entry = &rt_rule->rules[2];
  615. rt_rule_entry->at_rear = 1;
  616. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  617. printf("Before calling m_routing.AddRoutingRule()\n");
  618. printf("m_routing = %p\n", &m_routing);
  619. if (false == m_routing.AddRoutingRule(rt_rule))
  620. {
  621. printf("Routing rule addition failed!\n");
  622. return false;
  623. }
  624. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  625. free(rt_rule);
  626. InitFilteringBlock();
  627. return true;
  628. }
  629. };
  630. /*---------------------------------------------------------------------------*/
  631. /* Test3: Tests routing by TOS (Type Of Service) */
  632. /*---------------------------------------------------------------------------*/
  633. class IpaRoutingBlockTest3 : IpaRoutingBlockTestFixture
  634. {
  635. public:
  636. IpaRoutingBlockTest3()
  637. {
  638. m_name = "IpaRoutingBlockTest3";
  639. m_description = " \
  640. Routing block test 003 - TOS exact match\
  641. 1. Generate and commit a single routing tables. \
  642. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  643. All TOS == 0xBF traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  644. All TOS == 0x3A traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  645. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  646. m_IpaIPType = IPA_IP_v4;
  647. Register(*this);
  648. }
  649. bool Run()
  650. {
  651. bool res = false;
  652. bool isSuccess = false;
  653. // Add the relevant routing rules
  654. res = AddRules();
  655. if (false == res) {
  656. printf("Failed adding routing rules.\n");
  657. return false;
  658. }
  659. // Load input data (IP packet) from file
  660. res = LoadFiles(IPA_IP_v4);
  661. if (false == res) {
  662. printf("Failed loading files.\n");
  663. return false;
  664. }
  665. // Send first packet
  666. m_sendBuffer[TOS_FIELD_OFFSET] = 0xBF;
  667. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  668. if (false == isSuccess)
  669. {
  670. printf("SendData failure.\n");
  671. return false;
  672. }
  673. // Send second packet
  674. m_sendBuffer2[TOS_FIELD_OFFSET] = 0x3A;
  675. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  676. if (false == isSuccess)
  677. {
  678. printf("SendData failure.\n");
  679. return false;
  680. }
  681. // Send third packet
  682. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  683. if (false == isSuccess)
  684. {
  685. printf("SendData failure.\n");
  686. return false;
  687. }
  688. // Receive packets from the channels and compare results
  689. isSuccess = ReceivePacketsAndCompare();
  690. return isSuccess;
  691. } // Run()
  692. bool AddRules()
  693. {
  694. struct ipa_ioc_add_rt_rule *rt_rule;
  695. struct ipa_rt_rule_add *rt_rule_entry;
  696. const int NUM_RULES = 3;
  697. rt_rule = (struct ipa_ioc_add_rt_rule *)
  698. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  699. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  700. if (!rt_rule) {
  701. printf("fail\n");
  702. return false;
  703. }
  704. rt_rule->commit = 1;
  705. rt_rule->num_rules = NUM_RULES;
  706. rt_rule->ip = IPA_IP_v4;
  707. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  708. rt_rule_entry = &rt_rule->rules[0];
  709. rt_rule_entry->at_rear = 0;
  710. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  711. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl;
  712. // gidons, there is no support for header insertion / removal yet.
  713. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_TOS;
  714. rt_rule_entry->rule.attrib.u.v4.tos = 0xBF;
  715. rt_rule_entry = &rt_rule->rules[1];
  716. rt_rule_entry->at_rear = 0;
  717. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  718. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // gidons, there is no support for header insertion / removal yet.
  719. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_TOS;
  720. rt_rule_entry->rule.attrib.u.v4.tos = 0x3A;
  721. rt_rule_entry = &rt_rule->rules[2];
  722. rt_rule_entry->at_rear = 1;
  723. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  724. if (false == m_routing.AddRoutingRule(rt_rule))
  725. {
  726. printf("Routing rule addition failed!\n");
  727. return false;
  728. }
  729. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  730. free(rt_rule);
  731. InitFilteringBlock();
  732. return true;
  733. }
  734. };
  735. /*---------------------------------------------------------------------------*/
  736. /* Test4: Destination address exact match and TOS exact match */
  737. /*---------------------------------------------------------------------------*/
  738. class IpaRoutingBlockTest4 : IpaRoutingBlockTestFixture
  739. {
  740. public:
  741. IpaRoutingBlockTest4()
  742. {
  743. m_name = "IpaRoutingBlockTest4";
  744. m_description =" \
  745. Routing block test 004 - Source and Destination address and TOS exact match \
  746. 1. Generate and commit a single routing tables. \
  747. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  748. All DST_IP == (192.169.2.255 & 255.255.255.255) and TOS == 0xFF traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  749. All DST_IP == (192.168.2.170 & 255.255.255.255) and TOS == 0xAA traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  750. All DST_IP == (192.168.2.85 & 255.255.255.255) and SRC_IP == (192.168.2.241 & 255.255.255.255) TOS == 0x24 traffic goes to pipe IPA_CLIENT_TEST3_CONS";
  751. m_IpaIPType = IPA_IP_v4;
  752. Register(*this);
  753. }
  754. bool Run()
  755. {
  756. bool res = false;
  757. bool isSuccess = false;
  758. // Add the relevant routing rules
  759. res = AddRules();
  760. if (false == res) {
  761. printf("Failed adding routing rules.\n");
  762. return false;
  763. }
  764. // Load input data (IP packet) from file
  765. res = LoadFiles(IPA_IP_v4);
  766. if (false == res) {
  767. printf("Failed loading files.\n");
  768. return false;
  769. }
  770. // Send first packet
  771. m_sendBuffer[TOS_FIELD_OFFSET] = 0xFF;
  772. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xFF;
  773. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  774. if (false == isSuccess)
  775. {
  776. printf("SendData failure.\n");
  777. return false;
  778. }
  779. // Send second packet
  780. m_sendBuffer2[TOS_FIELD_OFFSET] = 0xAA;
  781. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  782. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  783. if (false == isSuccess)
  784. {
  785. printf("SendData failure.\n");
  786. return false;
  787. }
  788. // Send third packet
  789. m_sendBuffer3[TOS_FIELD_OFFSET] = 0x24;
  790. m_sendBuffer3[DST_ADDR_LSB_OFFSET_IPV4] = 0x55;
  791. m_sendBuffer3[SRC_ADDR_LSB_OFFSET_IPV4] = 0xF1;
  792. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  793. if (false == isSuccess)
  794. {
  795. printf("SendData failure.\n");
  796. return false;
  797. }
  798. // Receive packets from the channels and compare results
  799. isSuccess = ReceivePacketsAndCompare();
  800. return isSuccess;
  801. } // Run()
  802. bool AddRules()
  803. {
  804. struct ipa_ioc_add_rt_rule *rt_rule;
  805. struct ipa_rt_rule_add *rt_rule_entry;
  806. const int NUM_RULES = 3;
  807. rt_rule = (struct ipa_ioc_add_rt_rule *)
  808. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  809. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  810. if(!rt_rule) {
  811. printf("fail\n");
  812. return false;
  813. }
  814. rt_rule->commit = 1;
  815. rt_rule->num_rules = NUM_RULES;
  816. rt_rule->ip = IPA_IP_v4;
  817. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  818. rt_rule_entry = &rt_rule->rules[0];
  819. rt_rule_entry->at_rear = 0;
  820. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  821. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_TOS | IPA_FLT_DST_ADDR;
  822. rt_rule_entry->rule.attrib.u.v4.tos = 0xFF;
  823. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802FF;
  824. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  825. rt_rule_entry = &rt_rule->rules[1];
  826. rt_rule_entry->at_rear = 0;
  827. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  828. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_TOS | IPA_FLT_DST_ADDR;
  829. rt_rule_entry->rule.attrib.u.v4.tos = 0xAA;
  830. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA;
  831. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  832. rt_rule_entry = &rt_rule->rules[2];
  833. rt_rule_entry->at_rear = 1;
  834. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  835. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_TOS | IPA_FLT_DST_ADDR | IPA_FLT_SRC_ADDR;
  836. rt_rule_entry->rule.attrib.u.v4.tos = 0x24;
  837. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A80255;
  838. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  839. rt_rule_entry->rule.attrib.u.v4.src_addr = 0xC0A802F1;
  840. rt_rule_entry->rule.attrib.u.v4.src_addr_mask = 0xFFFFFFFF;
  841. if (false == m_routing.AddRoutingRule(rt_rule))
  842. {
  843. printf("Routing rule addition failed!\n");
  844. return false;
  845. }
  846. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  847. free(rt_rule);
  848. InitFilteringBlock();
  849. return true;
  850. }
  851. };
  852. /*---------------------------------------------------------------------------*/
  853. /* Test5: IPv6 - Tests routing by destination address */
  854. /*---------------------------------------------------------------------------*/
  855. class IpaRoutingBlockTest5 : public IpaRoutingBlockTestFixture
  856. {
  857. public:
  858. IpaRoutingBlockTest5()
  859. {
  860. m_name = "IpaRoutingBlockTest5";
  861. m_description =" \
  862. Routing block test 005 - IPv6 Destination address exact match \
  863. 1. Generate and commit a single routing tables. \
  864. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  865. All DST_IP == 0XFF020000 \
  866. 0x00000000 \
  867. 0x00000000 \
  868. 0X000000FF \
  869. traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  870. All DST_IP == 0XFF020000 \
  871. 0x00000000 \
  872. 0x00000000 \
  873. 0X000000FF \
  874. traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  875. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  876. m_IpaIPType = IPA_IP_v6;
  877. Register(*this);
  878. }
  879. bool Run()
  880. {
  881. bool res = false;
  882. bool isSuccess = false;
  883. // Add the relevant routing rules
  884. res = AddRules();
  885. if (false == res) {
  886. printf("Failed adding routing rules.\n");
  887. return false;
  888. }
  889. // Load input data (IP packet) from file
  890. res = LoadFiles(IPA_IP_v6);
  891. if (false == res) {
  892. printf("Failed loading files.\n");
  893. return false;
  894. }
  895. // Send first packet
  896. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  897. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  898. if (false == isSuccess)
  899. {
  900. printf("SendData failure.\n");
  901. return false;
  902. }
  903. // Send second packet
  904. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xAA;
  905. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  906. if (false == isSuccess)
  907. {
  908. printf("SendData failure.\n");
  909. return false;
  910. }
  911. // Send third packet
  912. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  913. if (false == isSuccess)
  914. {
  915. printf("SendData failure.\n");
  916. return false;
  917. }
  918. // Receive packets from the channels and compare results
  919. isSuccess = ReceivePacketsAndCompare();
  920. return isSuccess;
  921. } // Run()
  922. bool AddRules()
  923. {
  924. struct ipa_ioc_add_rt_rule *rt_rule;
  925. struct ipa_rt_rule_add *rt_rule_entry;
  926. const int NUM_RULES = 3;
  927. rt_rule = (struct ipa_ioc_add_rt_rule *)
  928. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  929. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  930. if(!rt_rule) {
  931. printf("fail\n");
  932. return false;
  933. }
  934. rt_rule->commit = 1;
  935. rt_rule->num_rules = NUM_RULES;
  936. rt_rule->ip = IPA_IP_v6;
  937. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  938. rt_rule_entry = &rt_rule->rules[0];
  939. rt_rule_entry->at_rear = 0;
  940. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  941. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // gidons, there is no support for header insertion / removal yet.
  942. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  943. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  944. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  945. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  946. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  947. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  948. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  949. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  950. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  951. rt_rule_entry = &rt_rule->rules[1];
  952. rt_rule_entry->at_rear = 0;
  953. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  954. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // gidons, there is no support for header insertion / removal yet.
  955. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  956. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  957. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  958. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  959. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000AA;
  960. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  961. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  962. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  963. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  964. rt_rule_entry = &rt_rule->rules[2];
  965. rt_rule_entry->at_rear = 1;
  966. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  967. if (false == m_routing.AddRoutingRule(rt_rule))
  968. {
  969. printf("Routing rule addition failed!\n");
  970. return false;
  971. }
  972. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  973. free(rt_rule);
  974. InitFilteringBlock();
  975. return true;
  976. }
  977. };
  978. /*---------------------------------------------------------------------------*/
  979. /* Test6: IPv6 - Tests routing by destination address */
  980. /*---------------------------------------------------------------------------*/
  981. class IpaRoutingBlockTest006 : public IpaRoutingBlockTestFixture
  982. {
  983. public:
  984. IpaRoutingBlockTest006()
  985. {
  986. m_name = "IpaRoutingBlockTest006";
  987. m_description =" \
  988. Routing block test 006 - IPv6 Destination address Subnet match \
  989. 1. Generate and commit a single routing tables. \
  990. 2. Generate and commit Three routing rules: (DST & Mask Match 0xFFFFFFFF,0xFFFFFFFF,0x00000000,0x0000000). \
  991. All DST_IP == 0X11020000 \
  992. 0x00000000 \
  993. 0x00000000 \
  994. 0X0000000C \
  995. traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  996. All DST_IP == 0X22020000 \
  997. 0x00000000 \
  998. 0x00000000 \
  999. 0X0000000C \
  1000. traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  1001. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  1002. m_IpaIPType = IPA_IP_v6;
  1003. Register(*this);
  1004. }
  1005. bool Run()
  1006. {
  1007. bool res = false;
  1008. bool isSuccess = false;
  1009. // Add the relevant routing rules
  1010. res = AddRules();
  1011. if (false == res) {
  1012. printf("Failed adding routing rules.\n");
  1013. return false;
  1014. }
  1015. // Load input data (IP packet) from file
  1016. res = LoadFiles(IPA_IP_v6);
  1017. if (false == res) {
  1018. printf("Failed loading files.\n");
  1019. return false;
  1020. }
  1021. // Send first packet
  1022. m_sendBuffer[DST_ADDR_MSB_OFFSET_IPV6] = 0x11;
  1023. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  1024. if (false == isSuccess)
  1025. {
  1026. printf("SendData failure.\n");
  1027. return false;
  1028. }
  1029. // Send second packet
  1030. m_sendBuffer2[DST_ADDR_MSB_OFFSET_IPV6] = 0x22;
  1031. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  1032. if (false == isSuccess)
  1033. {
  1034. printf("SendData failure.\n");
  1035. return false;
  1036. }
  1037. // Send third packet
  1038. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  1039. if (false == isSuccess)
  1040. {
  1041. printf("SendData failure.\n");
  1042. return false;
  1043. }
  1044. // Receive packets from the channels and compare results
  1045. isSuccess = ReceivePacketsAndCompare();
  1046. return isSuccess;
  1047. } // Run()
  1048. bool AddRules()
  1049. {
  1050. struct ipa_ioc_add_rt_rule *rt_rule;
  1051. struct ipa_rt_rule_add *rt_rule_entry;
  1052. const int NUM_RULES = 3;
  1053. rt_rule = (struct ipa_ioc_add_rt_rule *)
  1054. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  1055. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  1056. if(!rt_rule) {
  1057. printf("fail\n");
  1058. return false;
  1059. }
  1060. rt_rule->commit = 1;
  1061. rt_rule->num_rules = NUM_RULES;
  1062. rt_rule->ip = IPA_IP_v6;
  1063. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  1064. rt_rule_entry = &rt_rule->rules[0];
  1065. rt_rule_entry->at_rear = 0;
  1066. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  1067. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // TODO: Header Insertion gidons, there is no support for header insertion / removal yet.
  1068. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  1069. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0X11020000;
  1070. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  1071. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  1072. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X0000000C;
  1073. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  1074. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  1075. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;
  1076. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;
  1077. rt_rule_entry = &rt_rule->rules[1];
  1078. rt_rule_entry->at_rear = 0;
  1079. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  1080. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // TODO: Header Insertion gidons, there is no support for header insertion / removal yet.
  1081. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  1082. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0X22020000;
  1083. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  1084. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  1085. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X0000000C;
  1086. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  1087. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  1088. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;
  1089. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;
  1090. rt_rule_entry = &rt_rule->rules[2];
  1091. rt_rule_entry->at_rear = 1;
  1092. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  1093. if (false == m_routing.AddRoutingRule(rt_rule))
  1094. {
  1095. printf("Routing rule addition failed!\n");
  1096. return false;
  1097. }
  1098. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  1099. free(rt_rule);
  1100. InitFilteringBlock();
  1101. return true;
  1102. }
  1103. };
  1104. /*---------------------------------------------------------------------------*/
  1105. /* Test7: IPv6 - Tests routing by destination address */
  1106. /*---------------------------------------------------------------------------*/
  1107. class IpaRoutingBlockTest007 : public IpaRoutingBlockTestFixture
  1108. {
  1109. public:
  1110. IpaRoutingBlockTest007()
  1111. {
  1112. m_name = "IpaRoutingBlockTest007";
  1113. m_description = " \
  1114. Routing block test 007 - IPv6 Exact Traffic Class Match \
  1115. 1. Generate and commit a single routing tables. \
  1116. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  1117. All Traffic Class == 0xAA traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  1118. All Traffic Class == 0xBB traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  1119. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  1120. m_IpaIPType = IPA_IP_v6;
  1121. Register(*this);
  1122. }
  1123. bool Run()
  1124. {
  1125. bool res = false;
  1126. bool isSuccess = false;
  1127. // Add the relevant routing rules
  1128. res = AddRules();
  1129. if (false == res) {
  1130. printf("Failed adding routing rules.\n");
  1131. return false;
  1132. }
  1133. // Load input data (IP packet) from file
  1134. res = LoadFiles(IPA_IP_v6);
  1135. if (false == res) {
  1136. printf("Failed loading files.\n");
  1137. return false;
  1138. }
  1139. // Send first packet
  1140. m_sendBuffer[TRAFFIC_CLASS_MSB_OFFSET_IPV6] &= 0xF0;
  1141. m_sendBuffer[TRAFFIC_CLASS_MSB_OFFSET_IPV6] |= 0x0A;
  1142. m_sendBuffer[TRAFFIC_CLASS_LSB_OFFSET_IPV6] &= 0x0F;
  1143. m_sendBuffer[TRAFFIC_CLASS_LSB_OFFSET_IPV6] |= 0xA0;
  1144. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  1145. if (false == isSuccess)
  1146. {
  1147. printf("SendData failure.\n");
  1148. return false;
  1149. }
  1150. // Send second packet
  1151. m_sendBuffer2[TRAFFIC_CLASS_MSB_OFFSET_IPV6] &= 0xF0;
  1152. m_sendBuffer2[TRAFFIC_CLASS_MSB_OFFSET_IPV6] |= 0x0B;
  1153. m_sendBuffer2[TRAFFIC_CLASS_LSB_OFFSET_IPV6] &= 0x0F;
  1154. m_sendBuffer2[TRAFFIC_CLASS_LSB_OFFSET_IPV6] |= 0xB0;
  1155. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  1156. if (false == isSuccess)
  1157. {
  1158. printf("SendData failure.\n");
  1159. return false;
  1160. }
  1161. // Send third packet
  1162. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  1163. if (false == isSuccess)
  1164. {
  1165. printf("SendData failure.\n");
  1166. return false;
  1167. }
  1168. // Receive packets from the channels and compare results
  1169. isSuccess = ReceivePacketsAndCompare();
  1170. return isSuccess;
  1171. } // Run()
  1172. bool AddRules()
  1173. {
  1174. struct ipa_ioc_add_rt_rule *rt_rule;
  1175. struct ipa_rt_rule_add *rt_rule_entry;
  1176. const int NUM_RULES = 3;
  1177. rt_rule = (struct ipa_ioc_add_rt_rule *)
  1178. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  1179. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  1180. if(!rt_rule) {
  1181. printf("fail\n");
  1182. return false;
  1183. }
  1184. rt_rule->commit = 1;
  1185. rt_rule->num_rules = NUM_RULES;
  1186. rt_rule->ip = IPA_IP_v6;
  1187. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  1188. rt_rule_entry = &rt_rule->rules[0];
  1189. rt_rule_entry->at_rear = 0;
  1190. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  1191. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // TODO: Header Insertion gidons, there is no support for header insertion / removal yet.
  1192. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_TC;
  1193. rt_rule_entry->rule.attrib.u.v6.tc = 0xAA;
  1194. rt_rule_entry = &rt_rule->rules[1];
  1195. rt_rule_entry->at_rear = 0;
  1196. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  1197. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // TODO: Header Insertion gidons, there is no support for header insertion / removal yet.
  1198. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_TC;
  1199. rt_rule_entry->rule.attrib.u.v6.tc = 0xBB;
  1200. rt_rule_entry = &rt_rule->rules[2];
  1201. rt_rule_entry->at_rear = 1;
  1202. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  1203. if (false == m_routing.AddRoutingRule(rt_rule))
  1204. {
  1205. printf("Routing rule addition failed!\n");
  1206. return false;
  1207. }
  1208. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  1209. free(rt_rule);
  1210. InitFilteringBlock();
  1211. return true;
  1212. }
  1213. };
  1214. /*---------------------------------------------------------------------------*/
  1215. /* Test8: IPv6 - Tests routing by destination address */
  1216. /*---------------------------------------------------------------------------*/
  1217. class IpaRoutingBlockTest008 : public IpaRoutingBlockTestFixture
  1218. {
  1219. public:
  1220. IpaRoutingBlockTest008()
  1221. {
  1222. m_name = "IpaRoutingBlockTest008";
  1223. m_description = " \
  1224. Routing block test 008 - IPv6 Destination address exact match and Traffic Class Match \
  1225. 1. Generate and commit a single routing tables. \
  1226. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  1227. All Traffic Class == 0xAA & IPv6 DST Addr 0xFF020000...00AA traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  1228. All Traffic Class == 0xBB & IPv6 DST Addr 0xFF020000...00BB traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  1229. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  1230. m_IpaIPType = IPA_IP_v6;
  1231. Register(*this);
  1232. }
  1233. bool Run()
  1234. {
  1235. bool res = false;
  1236. bool isSuccess = false;
  1237. // Add the relevant routing rules
  1238. res = AddRules();
  1239. if (false == res) {
  1240. printf("Failed adding routing rules.\n");
  1241. return false;
  1242. }
  1243. // Load input data (IP packet) from file
  1244. res = LoadFiles(IPA_IP_v6);
  1245. if (false == res) {
  1246. printf("Failed loading files.\n");
  1247. return false;
  1248. }
  1249. // Send first packet
  1250. m_sendBuffer[TRAFFIC_CLASS_MSB_OFFSET_IPV6] &= 0xF0;
  1251. m_sendBuffer[TRAFFIC_CLASS_MSB_OFFSET_IPV6] |= 0x0A;
  1252. m_sendBuffer[TRAFFIC_CLASS_LSB_OFFSET_IPV6] &= 0x0F;
  1253. m_sendBuffer[TRAFFIC_CLASS_LSB_OFFSET_IPV6] |= 0xA0;
  1254. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  1255. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  1256. if (false == isSuccess)
  1257. {
  1258. printf("SendData failure.\n");
  1259. return false;
  1260. }
  1261. // Send second packet
  1262. m_sendBuffer2[TRAFFIC_CLASS_MSB_OFFSET_IPV6] &= 0xF0;
  1263. m_sendBuffer2[TRAFFIC_CLASS_MSB_OFFSET_IPV6] |= 0x0B;
  1264. m_sendBuffer2[TRAFFIC_CLASS_LSB_OFFSET_IPV6] &= 0x0F;
  1265. m_sendBuffer2[TRAFFIC_CLASS_LSB_OFFSET_IPV6] |= 0xB0;
  1266. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xAA;
  1267. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  1268. if (false == isSuccess)
  1269. {
  1270. printf("SendData failure.\n");
  1271. return false;
  1272. }
  1273. // Send third packet
  1274. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  1275. if (false == isSuccess)
  1276. {
  1277. printf("SendData failure.\n");
  1278. return false;
  1279. }
  1280. // Receive packets from the channels and compare results
  1281. isSuccess = ReceivePacketsAndCompare();
  1282. return isSuccess;
  1283. } // Run()
  1284. bool AddRules()
  1285. {
  1286. struct ipa_ioc_add_rt_rule *rt_rule;
  1287. struct ipa_rt_rule_add *rt_rule_entry;
  1288. const int NUM_RULES = 3;
  1289. rt_rule = (struct ipa_ioc_add_rt_rule *)
  1290. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  1291. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  1292. if(!rt_rule) {
  1293. printf("fail\n");
  1294. return false;
  1295. }
  1296. rt_rule->commit = 1;
  1297. rt_rule->num_rules = NUM_RULES;
  1298. rt_rule->ip = IPA_IP_v6;
  1299. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  1300. rt_rule_entry = &rt_rule->rules[0];
  1301. rt_rule_entry->at_rear = 0;
  1302. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  1303. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // gidons, there is no support for header insertion / removal yet.
  1304. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR | IPA_FLT_TC;
  1305. rt_rule_entry->rule.attrib.u.v6.tc = 0xAA;
  1306. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  1307. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  1308. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  1309. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  1310. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  1311. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  1312. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  1313. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  1314. rt_rule_entry = &rt_rule->rules[1];
  1315. rt_rule_entry->at_rear = 0;
  1316. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  1317. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // gidons, there is no support for header insertion / removal yet.
  1318. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR | IPA_FLT_TC;
  1319. rt_rule_entry->rule.attrib.u.v6.tc = 0xBB;
  1320. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  1321. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  1322. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  1323. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000AA;
  1324. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  1325. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  1326. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  1327. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  1328. rt_rule_entry = &rt_rule->rules[2];
  1329. rt_rule_entry->at_rear = 1;
  1330. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  1331. if (false == m_routing.AddRoutingRule(rt_rule))
  1332. {
  1333. printf("Routing rule addition failed!\n");
  1334. return false;
  1335. }
  1336. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  1337. free(rt_rule);
  1338. InitFilteringBlock();
  1339. return true;
  1340. }
  1341. };
  1342. /*---------------------------------------------------------------------------*/
  1343. /* Test9: IPv6 - Tests routing by destination address */
  1344. /*---------------------------------------------------------------------------*/
  1345. class IpaRoutingBlockTest009 : public IpaRoutingBlockTestFixture
  1346. {
  1347. public:
  1348. IpaRoutingBlockTest009()
  1349. {
  1350. m_name = "IpaRoutingBlockTest009";
  1351. m_description = " \
  1352. Routing block test 009 - IPv6 Exact Flow Label Match \
  1353. 1. Generate and commit a single routing tables. \
  1354. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  1355. All Flow Label == 0xABCDE traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  1356. All Flow Label == 0x12345 traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  1357. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  1358. m_IpaIPType = IPA_IP_v6;
  1359. Register(*this);
  1360. }
  1361. bool Run()
  1362. {
  1363. bool res = false;
  1364. bool isSuccess = false;
  1365. // Add the relevant routing rules
  1366. res = AddRules();
  1367. if (false == res) {
  1368. printf("Failed adding routing rules.\n");
  1369. return false;
  1370. }
  1371. // Load input data (IP packet) from file
  1372. res = LoadFiles(IPA_IP_v6);
  1373. if (false == res) {
  1374. printf("Failed loading files.\n");
  1375. return false;
  1376. }
  1377. // Send first packet
  1378. m_sendBuffer[FLOW_CLASS_MSB_OFFSET_IPV6] &= 0xF0;
  1379. m_sendBuffer[FLOW_CLASS_MSB_OFFSET_IPV6] |= 0x0A;
  1380. m_sendBuffer[FLOW_CLASS_MB_OFFSET_IPV6] = 0xBC;
  1381. m_sendBuffer[FLOW_CLASS_LSB_OFFSET_IPV6] = 0xDE;
  1382. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  1383. if (false == isSuccess)
  1384. {
  1385. printf("SendData failure.\n");
  1386. return false;
  1387. }
  1388. // Send second packet
  1389. m_sendBuffer2[FLOW_CLASS_MSB_OFFSET_IPV6] &= 0xF0;
  1390. m_sendBuffer2[FLOW_CLASS_MSB_OFFSET_IPV6] |= 0x01;
  1391. m_sendBuffer2[FLOW_CLASS_MB_OFFSET_IPV6] = 0x23;
  1392. m_sendBuffer2[FLOW_CLASS_LSB_OFFSET_IPV6] = 0x45;
  1393. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  1394. if (false == isSuccess)
  1395. {
  1396. printf("SendData failure.\n");
  1397. return false;
  1398. }
  1399. // Send third packet
  1400. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  1401. if (false == isSuccess)
  1402. {
  1403. printf("SendData failure.\n");
  1404. return false;
  1405. }
  1406. // Receive packets from the channels and compare results
  1407. isSuccess = ReceivePacketsAndCompare();
  1408. return isSuccess;
  1409. } // Run()
  1410. bool AddRules()
  1411. {
  1412. struct ipa_ioc_add_rt_rule *rt_rule;
  1413. struct ipa_rt_rule_add *rt_rule_entry;
  1414. const int NUM_RULES = 3;
  1415. rt_rule = (struct ipa_ioc_add_rt_rule *)
  1416. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  1417. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  1418. if(!rt_rule) {
  1419. printf("fail\n");
  1420. return false;
  1421. }
  1422. rt_rule->commit = 1;
  1423. rt_rule->num_rules = NUM_RULES;
  1424. rt_rule->ip = IPA_IP_v6;
  1425. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  1426. rt_rule_entry = &rt_rule->rules[0];
  1427. rt_rule_entry->at_rear = 0;
  1428. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  1429. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // gidons, there is no support for header insertion / removal yet.
  1430. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_FLOW_LABEL;
  1431. rt_rule_entry->rule.attrib.u.v6.flow_label = 0xABCDE;
  1432. rt_rule_entry = &rt_rule->rules[1];
  1433. rt_rule_entry->at_rear = 0;
  1434. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  1435. // rt_rule_entry->rule.hdr_hdl = hdr_entry->hdr_hdl; // gidons, there is no support for header insertion / removal yet.
  1436. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_FLOW_LABEL;
  1437. rt_rule_entry->rule.attrib.u.v6.flow_label = 0x12345;
  1438. rt_rule_entry = &rt_rule->rules[2];
  1439. rt_rule_entry->at_rear = 1;
  1440. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  1441. if (false == m_routing.AddRoutingRule(rt_rule))
  1442. {
  1443. printf("Routing rule addition failed!\n");
  1444. return false;
  1445. }
  1446. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  1447. free(rt_rule);
  1448. InitFilteringBlock();
  1449. return true;
  1450. }
  1451. };
  1452. /*--------------------------------------------------------------------------*/
  1453. /* Test10: IPv4 - Tests routing hashable vs non hashable priorities */
  1454. /*--------------------------------------------------------------------------*/
  1455. class IpaRoutingBlockTest010 : public IpaRoutingBlockTestFixture
  1456. {
  1457. public:
  1458. IpaRoutingBlockTest010()
  1459. {
  1460. m_name = "IpaRoutingBlockTest10";
  1461. m_description =" \
  1462. Routing block test 010 - Destination address exact match non hashable priority higher than hashable \
  1463. both match the packet but only non hashable should hit\
  1464. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  1465. All DST_IP == (192.168.2.170 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  1466. All DST_IP == (192.168.2.170 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  1467. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  1468. m_IpaIPType = IPA_IP_v4;
  1469. m_minIPAHwType = IPA_HW_v3_0;
  1470. Register(*this);
  1471. }
  1472. bool AddRules()
  1473. {
  1474. struct ipa_ioc_add_rt_rule *rt_rule;
  1475. struct ipa_rt_rule_add *rt_rule_entry;
  1476. const int NUM_RULES = 3;
  1477. rt_rule = (struct ipa_ioc_add_rt_rule *)
  1478. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  1479. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  1480. if(!rt_rule) {
  1481. printf("fail\n");
  1482. return false;
  1483. }
  1484. rt_rule->commit = 1;
  1485. rt_rule->num_rules = NUM_RULES;
  1486. rt_rule->ip = IPA_IP_v4;
  1487. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  1488. rt_rule_entry = &rt_rule->rules[0];
  1489. rt_rule_entry->at_rear = 1;
  1490. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  1491. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  1492. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA; //192.168.02.170
  1493. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  1494. rt_rule_entry->rule.hashable = 0; // non hashable
  1495. rt_rule_entry = &rt_rule->rules[1];
  1496. rt_rule_entry->at_rear = 1;
  1497. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  1498. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  1499. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA; //192.168.02.170
  1500. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  1501. rt_rule_entry->rule.hashable = 1; // hashable
  1502. rt_rule_entry = &rt_rule->rules[2];
  1503. rt_rule_entry->at_rear = 1;
  1504. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  1505. if (false == m_routing.AddRoutingRule(rt_rule))
  1506. {
  1507. printf("Routing rule addition failed!\n");
  1508. return false;
  1509. }
  1510. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  1511. free(rt_rule);
  1512. InitFilteringBlock();
  1513. return true;
  1514. }
  1515. bool Run()
  1516. {
  1517. bool res = false;
  1518. bool isSuccess = false;
  1519. // Add the relevant routing rules
  1520. res = AddRules();
  1521. if (false == res) {
  1522. printf("Failed adding routing rules.\n");
  1523. return false;
  1524. }
  1525. // Load input data (IP packet) from file
  1526. res = LoadFiles(IPA_IP_v4);
  1527. if (false == res) {
  1528. printf("Failed loading files.\n");
  1529. return false;
  1530. }
  1531. // Send first packet
  1532. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  1533. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  1534. if (false == isSuccess)
  1535. {
  1536. printf("SendData failure.\n");
  1537. return false;
  1538. }
  1539. // Send second packet
  1540. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  1541. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  1542. if (false == isSuccess)
  1543. {
  1544. printf("SendData failure.\n");
  1545. return false;
  1546. }
  1547. // Send third packet
  1548. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  1549. if (false == isSuccess)
  1550. {
  1551. printf("SendData failure.\n");
  1552. return false;
  1553. }
  1554. // Receive packets from the channels and compare results
  1555. isSuccess = ReceivePacketsAndCompare();
  1556. return isSuccess;
  1557. } // Run()
  1558. bool ReceivePacketsAndCompare()
  1559. {
  1560. size_t receivedSize = 0;
  1561. size_t receivedSize2 = 0;
  1562. size_t receivedSize3 = 0;
  1563. bool isSuccess = true;
  1564. // Receive results
  1565. Byte *rxBuff1 = new Byte[0x400];
  1566. Byte *rxBuff2 = new Byte[0x400];
  1567. Byte *rxBuff3 = new Byte[0x400];
  1568. if (NULL == rxBuff1 || NULL == rxBuff2 || NULL == rxBuff3)
  1569. {
  1570. printf("Memory allocation error.\n");
  1571. return false;
  1572. }
  1573. receivedSize = m_consumer.ReceiveData(rxBuff1, 0x400);
  1574. printf("Received %zu bytes on %s.\n", receivedSize, m_consumer.m_fromChannelName.c_str());
  1575. receivedSize2 = m_consumer.ReceiveData(rxBuff2, 0x400);
  1576. printf("Received %zu bytes on %s.\n", receivedSize2, m_consumer2.m_fromChannelName.c_str());
  1577. receivedSize3 = m_defaultConsumer.ReceiveData(rxBuff3, 0x400);
  1578. printf("Received %zu bytes on %s.\n", receivedSize3, m_defaultConsumer.m_fromChannelName.c_str());
  1579. /* Compare results */
  1580. isSuccess &= CompareResultVsGolden(m_sendBuffer, m_sendSize, rxBuff1, receivedSize);
  1581. isSuccess &= CompareResultVsGolden(m_sendBuffer2, m_sendSize2, rxBuff2, receivedSize2);
  1582. isSuccess &= CompareResultVsGolden(m_sendBuffer3, m_sendSize3, rxBuff3, receivedSize3);
  1583. size_t recievedBufferSize = receivedSize * 3;
  1584. size_t sentBufferSize = m_sendSize * 3;
  1585. char *recievedBuffer = new char[recievedBufferSize];
  1586. char *sentBuffer = new char[sentBufferSize];
  1587. memset(recievedBuffer, 0, recievedBufferSize);
  1588. memset(sentBuffer, 0, sentBufferSize);
  1589. print_packets(receivedSize, m_sendSize, recievedBufferSize, sentBufferSize, rxBuff1, m_sendBuffer, recievedBuffer, sentBuffer);
  1590. print_packets(receivedSize2, m_sendSize2, recievedBufferSize, sentBufferSize, rxBuff2, m_sendBuffer2, recievedBuffer, sentBuffer);
  1591. print_packets(receivedSize3, m_sendSize3, recievedBufferSize, sentBufferSize, rxBuff3, m_sendBuffer3, recievedBuffer, sentBuffer);
  1592. delete[] recievedBuffer;
  1593. delete[] sentBuffer;
  1594. delete[] rxBuff1;
  1595. delete[] rxBuff2;
  1596. delete[] rxBuff3;
  1597. return isSuccess;
  1598. }
  1599. };
  1600. /*--------------------------------------------------------------------------*/
  1601. /* Test11: IPv4 - Tests routing hashable vs non hashable priorities */
  1602. /*--------------------------------------------------------------------------*/
  1603. class IpaRoutingBlockTest011 : public IpaRoutingBlockTestFixture
  1604. {
  1605. public:
  1606. IpaRoutingBlockTest011()
  1607. {
  1608. m_name = "IpaRoutingBlockTest011";
  1609. m_description =" \
  1610. Routing block test 011 - Destination address exact match hashable priority higher than non hashable \
  1611. both match the packet but only hashable should hit, second packet should get cache hit\
  1612. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  1613. All DST_IP == (192.168.2.170 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  1614. All DST_IP == (192.168.2.170 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  1615. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  1616. m_IpaIPType = IPA_IP_v4;
  1617. m_minIPAHwType = IPA_HW_v3_0;
  1618. Register(*this);
  1619. }
  1620. bool Setup()
  1621. {
  1622. return IpaRoutingBlockTestFixture:: Setup(true);
  1623. }
  1624. bool AddRules()
  1625. {
  1626. struct ipa_ioc_add_rt_rule *rt_rule;
  1627. struct ipa_rt_rule_add *rt_rule_entry;
  1628. const int NUM_RULES = 3;
  1629. rt_rule = (struct ipa_ioc_add_rt_rule *)
  1630. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  1631. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  1632. if(!rt_rule) {
  1633. printf("fail\n");
  1634. return false;
  1635. }
  1636. rt_rule->commit = 1;
  1637. rt_rule->num_rules = NUM_RULES;
  1638. rt_rule->ip = IPA_IP_v4;
  1639. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  1640. rt_rule_entry = &rt_rule->rules[0];
  1641. rt_rule_entry->at_rear = 1;
  1642. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  1643. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  1644. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA; //192.168.02.170
  1645. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  1646. rt_rule_entry->rule.hashable = 1; // hashable
  1647. rt_rule_entry = &rt_rule->rules[1];
  1648. rt_rule_entry->at_rear = 1;
  1649. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  1650. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  1651. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA; //192.168.02.170
  1652. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  1653. rt_rule_entry->rule.hashable = 0; // non hashable
  1654. rt_rule_entry = &rt_rule->rules[2];
  1655. rt_rule_entry->at_rear = 1;
  1656. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  1657. if (false == m_routing.AddRoutingRule(rt_rule))
  1658. {
  1659. printf("Routing rule addition failed!\n");
  1660. return false;
  1661. }
  1662. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  1663. free(rt_rule);
  1664. InitFilteringBlock();
  1665. return true;
  1666. }
  1667. bool Run()
  1668. {
  1669. bool res = false;
  1670. bool isSuccess = false;
  1671. // Add the relevant routing rules
  1672. res = AddRules();
  1673. if (false == res) {
  1674. printf("Failed adding routing rules.\n");
  1675. return false;
  1676. }
  1677. // Load input data (IP packet) from file
  1678. res = LoadFiles(IPA_IP_v4);
  1679. if (false == res) {
  1680. printf("Failed loading files.\n");
  1681. return false;
  1682. }
  1683. // Send first packet
  1684. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  1685. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  1686. if (false == isSuccess)
  1687. {
  1688. printf("SendData failure.\n");
  1689. return false;
  1690. }
  1691. // Send second packet
  1692. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  1693. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  1694. if (false == isSuccess)
  1695. {
  1696. printf("SendData failure.\n");
  1697. return false;
  1698. }
  1699. // Send third packet
  1700. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  1701. if (false == isSuccess)
  1702. {
  1703. printf("SendData failure.\n");
  1704. return false;
  1705. }
  1706. // Receive packets from the channels and compare results
  1707. isSuccess = ReceivePacketsAndCompare();
  1708. return isSuccess;
  1709. } // Run()
  1710. bool ReceivePacketsAndCompare()
  1711. {
  1712. size_t receivedSize = 0;
  1713. size_t receivedSize2 = 0;
  1714. size_t receivedSize3 = 0;
  1715. bool isSuccess = true;
  1716. // Receive results
  1717. Byte *rxBuff1 = new Byte[0x400];
  1718. Byte *rxBuff2 = new Byte[0x400];
  1719. Byte *rxBuff3 = new Byte[0x400];
  1720. if (NULL == rxBuff1 || NULL == rxBuff2 || NULL == rxBuff3)
  1721. {
  1722. printf("Memory allocation error.\n");
  1723. return false;
  1724. }
  1725. receivedSize = m_consumer.ReceiveData(rxBuff1, 0x400);
  1726. printf("Received %zu bytes on %s.\n", receivedSize, m_consumer.m_fromChannelName.c_str());
  1727. receivedSize2 = m_consumer.ReceiveData(rxBuff2, 0x400);
  1728. printf("Received %zu bytes on %s.\n", receivedSize2, m_consumer2.m_fromChannelName.c_str());
  1729. receivedSize3 = m_defaultConsumer.ReceiveData(rxBuff3, 0x400);
  1730. printf("Received %zu bytes on %s.\n", receivedSize3, m_defaultConsumer.m_fromChannelName.c_str());
  1731. /* Compare results */
  1732. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer, m_sendSize, rxBuff1, receivedSize);
  1733. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer2, m_sendSize2, rxBuff2, receivedSize2);
  1734. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer3, m_sendSize3, rxBuff3, receivedSize3);
  1735. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  1736. IsCacheMiss_v5_0(m_sendSize, receivedSize, rxBuff1) : IsCacheMiss(m_sendSize,receivedSize,rxBuff1);
  1737. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  1738. IsCacheHit_v5_0(m_sendSize2, receivedSize2, rxBuff2) : IsCacheHit(m_sendSize2,receivedSize2,rxBuff2);
  1739. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  1740. IsCacheMiss_v5_0(m_sendSize3, receivedSize3, rxBuff3) : IsCacheMiss(m_sendSize3,receivedSize3,rxBuff3);
  1741. size_t recievedBufferSize = receivedSize * 3;
  1742. size_t sentBufferSize = m_sendSize * 3;
  1743. char *recievedBuffer = new char[recievedBufferSize];
  1744. char *sentBuffer = new char[sentBufferSize];
  1745. memset(recievedBuffer, 0, recievedBufferSize);
  1746. memset(sentBuffer, 0, sentBufferSize);
  1747. print_packets(receivedSize, m_sendSize, recievedBufferSize, sentBufferSize, rxBuff1, m_sendBuffer, recievedBuffer, sentBuffer);
  1748. print_packets(receivedSize2, m_sendSize2, recievedBufferSize, sentBufferSize, rxBuff2, m_sendBuffer2, recievedBuffer, sentBuffer);
  1749. print_packets(receivedSize3, m_sendSize3, recievedBufferSize, sentBufferSize, rxBuff3, m_sendBuffer3, recievedBuffer, sentBuffer);
  1750. delete[] recievedBuffer;
  1751. delete[] sentBuffer;
  1752. delete[] rxBuff1;
  1753. delete[] rxBuff2;
  1754. delete[] rxBuff3;
  1755. return isSuccess;
  1756. }
  1757. };
  1758. /*--------------------------------------------------------------------------*/
  1759. /* Test12: IPv4 - Tests routing hashable vs non hashable priorities */
  1760. /*--------------------------------------------------------------------------*/
  1761. class IpaRoutingBlockTest012 : public IpaRoutingBlockTestFixture
  1762. {
  1763. public:
  1764. IpaRoutingBlockTest012()
  1765. {
  1766. m_name = "IpaRoutingBlockTest012";
  1767. m_description =" \
  1768. Routing block test 012 - Destination address exact match hashable priority lower than non hashable \
  1769. no match on non hashable rule (with higher priority), match on hashable rule. two packets with\
  1770. different tuple are sent (but match the rule) cache miss expected\
  1771. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  1772. All DST_IP == (192.168.2.170 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  1773. All DST_IP == (192.168.2.171 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  1774. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  1775. m_IpaIPType = IPA_IP_v4;
  1776. m_minIPAHwType = IPA_HW_v3_0;
  1777. Register(*this);
  1778. }
  1779. bool Setup()
  1780. {
  1781. return IpaRoutingBlockTestFixture:: Setup(true);
  1782. }
  1783. bool AddRules()
  1784. {
  1785. struct ipa_ioc_add_rt_rule *rt_rule;
  1786. struct ipa_rt_rule_add *rt_rule_entry;
  1787. const int NUM_RULES = 3;
  1788. rt_rule = (struct ipa_ioc_add_rt_rule *)
  1789. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  1790. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  1791. if(!rt_rule) {
  1792. printf("fail\n");
  1793. return false;
  1794. }
  1795. rt_rule->commit = 1;
  1796. rt_rule->num_rules = NUM_RULES;
  1797. rt_rule->ip = IPA_IP_v4;
  1798. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  1799. rt_rule_entry = &rt_rule->rules[0];
  1800. rt_rule_entry->at_rear = 1;
  1801. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  1802. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  1803. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AB; //192.168.02.171
  1804. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  1805. rt_rule_entry->rule.hashable = 0; // non hashable
  1806. rt_rule_entry = &rt_rule->rules[1];
  1807. rt_rule_entry->at_rear = 1;
  1808. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  1809. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  1810. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA; //192.168.02.170
  1811. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  1812. rt_rule_entry->rule.hashable = 1; // hashable
  1813. rt_rule_entry = &rt_rule->rules[2];
  1814. rt_rule_entry->at_rear = 1;
  1815. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  1816. if (false == m_routing.AddRoutingRule(rt_rule))
  1817. {
  1818. printf("Routing rule addition failed!\n");
  1819. return false;
  1820. }
  1821. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  1822. free(rt_rule);
  1823. InitFilteringBlock();
  1824. return true;
  1825. }
  1826. bool Run()
  1827. {
  1828. bool res = false;
  1829. bool isSuccess = false;
  1830. unsigned short port;
  1831. // Add the relevant routing rules
  1832. res = AddRules();
  1833. if (false == res) {
  1834. printf("Failed adding routing rules.\n");
  1835. return false;
  1836. }
  1837. // Load input data (IP packet) from file
  1838. res = LoadFiles(IPA_IP_v4);
  1839. if (false == res) {
  1840. printf("Failed loading files.\n");
  1841. return false;
  1842. }
  1843. // Send first packet
  1844. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  1845. port = ntohs(547);//DHCP Client Port
  1846. memcpy (&m_sendBuffer[IPV4_DST_PORT_OFFSET], &port, sizeof(port));
  1847. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  1848. if (false == isSuccess)
  1849. {
  1850. printf("SendData failure.\n");
  1851. return false;
  1852. }
  1853. // Send second packet
  1854. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  1855. port = ntohs(546);//DHCP Client Port
  1856. memcpy (&m_sendBuffer2[IPV4_DST_PORT_OFFSET], &port, sizeof(port));
  1857. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  1858. if (false == isSuccess)
  1859. {
  1860. printf("SendData failure.\n");
  1861. return false;
  1862. }
  1863. // Send third packet
  1864. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  1865. if (false == isSuccess)
  1866. {
  1867. printf("SendData failure.\n");
  1868. return false;
  1869. }
  1870. // Receive packets from the channels and compare results
  1871. isSuccess = ReceivePacketsAndCompare();
  1872. return isSuccess;
  1873. } // Run()
  1874. bool ReceivePacketsAndCompare()
  1875. {
  1876. size_t receivedSize = 0;
  1877. size_t receivedSize2 = 0;
  1878. size_t receivedSize3 = 0;
  1879. bool isSuccess = true;
  1880. // Receive results
  1881. Byte *rxBuff1 = new Byte[0x400];
  1882. Byte *rxBuff2 = new Byte[0x400];
  1883. Byte *rxBuff3 = new Byte[0x400];
  1884. if (NULL == rxBuff1 || NULL == rxBuff2 || NULL == rxBuff3)
  1885. {
  1886. printf("Memory allocation error.\n");
  1887. return false;
  1888. }
  1889. receivedSize = m_consumer2.ReceiveData(rxBuff1, 0x400);
  1890. printf("Received %zu bytes on %s.\n", receivedSize, m_consumer2.m_fromChannelName.c_str());
  1891. receivedSize2 = m_consumer2.ReceiveData(rxBuff2, 0x400);
  1892. printf("Received %zu bytes on %s.\n", receivedSize2, m_consumer2.m_fromChannelName.c_str());
  1893. receivedSize3 = m_defaultConsumer.ReceiveData(rxBuff3, 0x400);
  1894. printf("Received %zu bytes on %s.\n", receivedSize3, m_defaultConsumer.m_fromChannelName.c_str());
  1895. /* Compare results */
  1896. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer, m_sendSize, rxBuff1, receivedSize);
  1897. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer2, m_sendSize2, rxBuff2, receivedSize2);
  1898. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer3, m_sendSize3, rxBuff3, receivedSize3);
  1899. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  1900. IsCacheMiss_v5_0(m_sendSize, receivedSize, rxBuff1) : IsCacheMiss(m_sendSize,receivedSize,rxBuff1);
  1901. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  1902. IsCacheMiss_v5_0(m_sendSize2, receivedSize2, rxBuff2) : IsCacheMiss(m_sendSize2,receivedSize2,rxBuff2);
  1903. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  1904. IsCacheMiss_v5_0(m_sendSize3, receivedSize3, rxBuff3) : IsCacheMiss(m_sendSize3,receivedSize3,rxBuff3);
  1905. size_t recievedBufferSize = receivedSize * 3;
  1906. size_t sentBufferSize = m_sendSize * 3;
  1907. char *recievedBuffer = new char[recievedBufferSize];
  1908. char *sentBuffer = new char[sentBufferSize];
  1909. memset(recievedBuffer, 0, recievedBufferSize);
  1910. memset(sentBuffer, 0, sentBufferSize);
  1911. print_packets(receivedSize, m_sendSize, recievedBufferSize, sentBufferSize, rxBuff1, m_sendBuffer, recievedBuffer, sentBuffer);
  1912. print_packets(receivedSize2, m_sendSize2, recievedBufferSize, sentBufferSize, rxBuff2, m_sendBuffer2, recievedBuffer, sentBuffer);
  1913. print_packets(receivedSize3, m_sendSize3, recievedBufferSize, sentBufferSize, rxBuff3, m_sendBuffer3, recievedBuffer, sentBuffer);
  1914. delete[] recievedBuffer;
  1915. delete[] sentBuffer;
  1916. delete[] rxBuff1;
  1917. delete[] rxBuff2;
  1918. delete[] rxBuff3;
  1919. return isSuccess;
  1920. }
  1921. };
  1922. /*--------------------------------------------------------------------------*/
  1923. /* Test13: IPv4 - Tests routing hashable vs non hashable priorities */
  1924. /*--------------------------------------------------------------------------*/
  1925. class IpaRoutingBlockTest013 : public IpaRoutingBlockTestFixture
  1926. {
  1927. public:
  1928. IpaRoutingBlockTest013()
  1929. {
  1930. m_name = "IpaRoutingBlockTest013";
  1931. m_description =" \
  1932. Routing block test 013 - Destination address exact match \
  1933. no match on non hashable rule (with lower priority), match on hashable rule. two packets with\
  1934. different tuple are sent (but match the rule) cache miss expected\
  1935. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  1936. All DST_IP == (192.168.2.170 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  1937. All DST_IP == (192.168.2.171 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  1938. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  1939. m_IpaIPType = IPA_IP_v4;
  1940. m_minIPAHwType = IPA_HW_v3_0;
  1941. Register(*this);
  1942. }
  1943. bool Setup()
  1944. {
  1945. return IpaRoutingBlockTestFixture:: Setup(true);
  1946. }
  1947. bool AddRules()
  1948. {
  1949. struct ipa_ioc_add_rt_rule *rt_rule;
  1950. struct ipa_rt_rule_add *rt_rule_entry;
  1951. const int NUM_RULES = 3;
  1952. rt_rule = (struct ipa_ioc_add_rt_rule *)
  1953. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  1954. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  1955. if(!rt_rule) {
  1956. printf("fail\n");
  1957. return false;
  1958. }
  1959. rt_rule->commit = 1;
  1960. rt_rule->num_rules = NUM_RULES;
  1961. rt_rule->ip = IPA_IP_v4;
  1962. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  1963. rt_rule_entry = &rt_rule->rules[0];
  1964. rt_rule_entry->at_rear = 1;
  1965. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  1966. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  1967. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA; //192.168.02.170
  1968. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  1969. rt_rule_entry->rule.hashable = 1; // hashable
  1970. rt_rule_entry = &rt_rule->rules[1];
  1971. rt_rule_entry->at_rear = 1;
  1972. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  1973. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  1974. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AB; //192.168.02.171
  1975. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  1976. rt_rule_entry->rule.hashable = 0; // non hashable
  1977. rt_rule_entry = &rt_rule->rules[2];
  1978. rt_rule_entry->at_rear = 1;
  1979. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  1980. if (false == m_routing.AddRoutingRule(rt_rule))
  1981. {
  1982. printf("Routing rule addition failed!\n");
  1983. return false;
  1984. }
  1985. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  1986. free(rt_rule);
  1987. InitFilteringBlock();
  1988. return true;
  1989. }
  1990. bool Run()
  1991. {
  1992. bool res = false;
  1993. bool isSuccess = false;
  1994. unsigned short port;
  1995. // Add the relevant routing rules
  1996. res = AddRules();
  1997. if (false == res) {
  1998. printf("Failed adding routing rules.\n");
  1999. return false;
  2000. }
  2001. // Load input data (IP packet) from file
  2002. res = LoadFiles(IPA_IP_v4);
  2003. if (false == res) {
  2004. printf("Failed loading files.\n");
  2005. return false;
  2006. }
  2007. // Send first packet
  2008. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2009. port = ntohs(547);//DHCP Client Port
  2010. memcpy (&m_sendBuffer[IPV4_DST_PORT_OFFSET], &port, sizeof(port));
  2011. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  2012. if (false == isSuccess)
  2013. {
  2014. printf("SendData failure.\n");
  2015. return false;
  2016. }
  2017. // Send second packet
  2018. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2019. port = ntohs(546);//DHCP Client Port
  2020. memcpy (&m_sendBuffer2[IPV4_DST_PORT_OFFSET], &port, sizeof(port));
  2021. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  2022. if (false == isSuccess)
  2023. {
  2024. printf("SendData failure.\n");
  2025. return false;
  2026. }
  2027. // Send third packet
  2028. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  2029. if (false == isSuccess)
  2030. {
  2031. printf("SendData failure.\n");
  2032. return false;
  2033. }
  2034. // Receive packets from the channels and compare results
  2035. isSuccess = ReceivePacketsAndCompare();
  2036. return isSuccess;
  2037. } // Run()
  2038. bool ReceivePacketsAndCompare()
  2039. {
  2040. size_t receivedSize = 0;
  2041. size_t receivedSize2 = 0;
  2042. size_t receivedSize3 = 0;
  2043. bool isSuccess = true;
  2044. // Receive results
  2045. Byte *rxBuff1 = new Byte[0x400];
  2046. Byte *rxBuff2 = new Byte[0x400];
  2047. Byte *rxBuff3 = new Byte[0x400];
  2048. if (NULL == rxBuff1 || NULL == rxBuff2 || NULL == rxBuff3)
  2049. {
  2050. printf("Memory allocation error.\n");
  2051. return false;
  2052. }
  2053. receivedSize = m_consumer.ReceiveData(rxBuff1, 0x400);
  2054. printf("Received %zu bytes on %s.\n", receivedSize, m_consumer.m_fromChannelName.c_str());
  2055. receivedSize2 = m_consumer.ReceiveData(rxBuff2, 0x400);
  2056. printf("Received %zu bytes on %s.\n", receivedSize2, m_consumer.m_fromChannelName.c_str());
  2057. receivedSize3 = m_defaultConsumer.ReceiveData(rxBuff3, 0x400);
  2058. printf("Received %zu bytes on %s.\n", receivedSize3, m_defaultConsumer.m_fromChannelName.c_str());
  2059. /* Compare results */
  2060. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer, m_sendSize, rxBuff1, receivedSize);
  2061. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer2, m_sendSize2, rxBuff2, receivedSize2);
  2062. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer3, m_sendSize3, rxBuff3, receivedSize3);
  2063. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  2064. IsCacheMiss_v5_0(m_sendSize, receivedSize, rxBuff1) : IsCacheMiss(m_sendSize,receivedSize,rxBuff1);
  2065. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  2066. IsCacheMiss_v5_0(m_sendSize2, receivedSize2, rxBuff2) : IsCacheMiss(m_sendSize2,receivedSize2,rxBuff2);
  2067. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  2068. IsCacheMiss_v5_0(m_sendSize3, receivedSize3, rxBuff3) : IsCacheMiss(m_sendSize3,receivedSize3,rxBuff3);
  2069. size_t recievedBufferSize = receivedSize * 3;
  2070. size_t sentBufferSize = m_sendSize * 3;
  2071. char *recievedBuffer = new char[recievedBufferSize];
  2072. char *sentBuffer = new char[sentBufferSize];
  2073. memset(recievedBuffer, 0, recievedBufferSize);
  2074. memset(sentBuffer, 0, sentBufferSize);
  2075. print_packets(receivedSize, m_sendSize, recievedBufferSize, sentBufferSize, rxBuff1, m_sendBuffer, recievedBuffer, sentBuffer);
  2076. print_packets(receivedSize2, m_sendSize2, recievedBufferSize, sentBufferSize, rxBuff2, m_sendBuffer2, recievedBuffer, sentBuffer);
  2077. print_packets(receivedSize3, m_sendSize3, recievedBufferSize, sentBufferSize, rxBuff3, m_sendBuffer3, recievedBuffer, sentBuffer);
  2078. delete[] recievedBuffer;
  2079. delete[] sentBuffer;
  2080. delete[] rxBuff1;
  2081. delete[] rxBuff2;
  2082. delete[] rxBuff3;
  2083. return isSuccess;
  2084. }
  2085. };
  2086. /*--------------------------------------------------------------------------*/
  2087. /* Test14: IPv4 - Tests routing hashable vs non hashable priorities */
  2088. /*--------------------------------------------------------------------------*/
  2089. class IpaRoutingBlockTest014 : public IpaRoutingBlockTestFixture
  2090. {
  2091. public:
  2092. IpaRoutingBlockTest014()
  2093. {
  2094. m_name = "IpaRoutingBlockTest014";
  2095. m_description =" \
  2096. Routing block test 014 - Destination address exact match \
  2097. no match on non hashable rule(with higher priority) , match on hashable rule. two identical\
  2098. packets are sent cache hit expected on the second one\
  2099. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  2100. All DST_IP == (192.168.2.171 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  2101. All DST_IP == (192.168.2.170 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  2102. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  2103. m_IpaIPType = IPA_IP_v4;
  2104. m_minIPAHwType = IPA_HW_v3_0;
  2105. Register(*this);
  2106. }
  2107. bool Setup()
  2108. {
  2109. return IpaRoutingBlockTestFixture:: Setup(true);
  2110. }
  2111. bool AddRules()
  2112. {
  2113. struct ipa_ioc_add_rt_rule *rt_rule;
  2114. struct ipa_rt_rule_add *rt_rule_entry;
  2115. const int NUM_RULES = 3;
  2116. rt_rule = (struct ipa_ioc_add_rt_rule *)
  2117. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  2118. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  2119. if(!rt_rule) {
  2120. printf("Failed memory allocation for rt_rule\n");
  2121. return false;
  2122. }
  2123. rt_rule->commit = 1;
  2124. rt_rule->num_rules = NUM_RULES;
  2125. rt_rule->ip = IPA_IP_v4;
  2126. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  2127. rt_rule_entry = &rt_rule->rules[0];
  2128. rt_rule_entry->at_rear = 1;
  2129. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  2130. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  2131. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AB; //192.168.02.171
  2132. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  2133. rt_rule_entry->rule.hashable = 0; // non hashable
  2134. rt_rule_entry = &rt_rule->rules[1];
  2135. rt_rule_entry->at_rear = 1;
  2136. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  2137. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  2138. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA; //192.168.02.170
  2139. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  2140. rt_rule_entry->rule.hashable = 1; // hashable
  2141. rt_rule_entry = &rt_rule->rules[2];
  2142. rt_rule_entry->at_rear = 1;
  2143. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  2144. if (false == m_routing.AddRoutingRule(rt_rule))
  2145. {
  2146. printf("Routing rule addition failed!\n");
  2147. free(rt_rule);
  2148. return false;
  2149. }
  2150. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  2151. free(rt_rule);
  2152. InitFilteringBlock();
  2153. return true;
  2154. }
  2155. bool Run()
  2156. {
  2157. bool res = false;
  2158. bool isSuccess = false;
  2159. // Add the relevant routing rules
  2160. res = AddRules();
  2161. if (false == res) {
  2162. printf("Failed adding routing rules.\n");
  2163. return false;
  2164. }
  2165. // Load input data (IP packet) from file
  2166. res = LoadFiles(IPA_IP_v4);
  2167. if (false == res) {
  2168. printf("Failed loading files.\n");
  2169. return false;
  2170. }
  2171. // Send first packet
  2172. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2173. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  2174. if (false == isSuccess)
  2175. {
  2176. printf("SendData failure.\n");
  2177. return false;
  2178. }
  2179. // Send second packet
  2180. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2181. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  2182. if (false == isSuccess)
  2183. {
  2184. printf("SendData failure.\n");
  2185. return false;
  2186. }
  2187. // Send third packet
  2188. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  2189. if (false == isSuccess)
  2190. {
  2191. printf("SendData failure.\n");
  2192. return false;
  2193. }
  2194. // Receive packets from the channels and compare results
  2195. isSuccess = ReceivePacketsAndCompare();
  2196. return isSuccess;
  2197. } // Run()
  2198. bool ReceivePacketsAndCompare()
  2199. {
  2200. size_t receivedSize = 0;
  2201. size_t receivedSize2 = 0;
  2202. size_t receivedSize3 = 0;
  2203. bool isSuccess = true;
  2204. // Receive results
  2205. Byte *rxBuff1 = new Byte[0x400];
  2206. Byte *rxBuff2 = new Byte[0x400];
  2207. Byte *rxBuff3 = new Byte[0x400];
  2208. if (NULL == rxBuff1 || NULL == rxBuff2 || NULL == rxBuff3)
  2209. {
  2210. printf("Memory allocation error.\n");
  2211. return false;
  2212. }
  2213. receivedSize = m_consumer2.ReceiveData(rxBuff1, 0x400);
  2214. printf("Received %zu bytes on %s.\n", receivedSize, m_consumer2.m_fromChannelName.c_str());
  2215. receivedSize2 = m_consumer2.ReceiveData(rxBuff2, 0x400);
  2216. printf("Received %zu bytes on %s.\n", receivedSize2, m_consumer2.m_fromChannelName.c_str());
  2217. receivedSize3 = m_defaultConsumer.ReceiveData(rxBuff3, 0x400);
  2218. printf("Received %zu bytes on %s.\n", receivedSize3, m_defaultConsumer.m_fromChannelName.c_str());
  2219. /* Compare results */
  2220. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer, m_sendSize, rxBuff1, receivedSize);
  2221. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer2, m_sendSize2, rxBuff2, receivedSize2);
  2222. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer3, m_sendSize3, rxBuff3, receivedSize3);
  2223. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  2224. IsCacheMiss_v5_0(m_sendSize, receivedSize, rxBuff1) : IsCacheMiss(m_sendSize,receivedSize,rxBuff1);
  2225. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  2226. IsCacheHit_v5_0(m_sendSize2, receivedSize2, rxBuff2) : IsCacheHit(m_sendSize2,receivedSize2,rxBuff2);
  2227. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  2228. IsCacheMiss_v5_0(m_sendSize3, receivedSize3, rxBuff3) : IsCacheMiss(m_sendSize3,receivedSize3,rxBuff3);
  2229. size_t recievedBufferSize = receivedSize * 3;
  2230. size_t sentBufferSize = m_sendSize * 3;
  2231. char *recievedBuffer = new char[recievedBufferSize];
  2232. char *sentBuffer = new char[sentBufferSize];
  2233. memset(recievedBuffer, 0, recievedBufferSize);
  2234. memset(sentBuffer, 0, sentBufferSize);
  2235. print_packets(receivedSize, m_sendSize, recievedBufferSize, sentBufferSize, rxBuff1, m_sendBuffer, recievedBuffer, sentBuffer);
  2236. print_packets(receivedSize2, m_sendSize2, recievedBufferSize, sentBufferSize, rxBuff2, m_sendBuffer2, recievedBuffer, sentBuffer);
  2237. print_packets(receivedSize3, m_sendSize3, recievedBufferSize, sentBufferSize, rxBuff3, m_sendBuffer3, recievedBuffer, sentBuffer);
  2238. delete[] recievedBuffer;
  2239. delete[] sentBuffer;
  2240. delete[] rxBuff1;
  2241. delete[] rxBuff2;
  2242. delete[] rxBuff3;
  2243. return isSuccess;
  2244. }
  2245. };
  2246. /*--------------------------------------------------------------------------*/
  2247. /* Test15: IPv4 - Tests routing hashable vs non hashable priorities */
  2248. /*--------------------------------------------------------------------------*/
  2249. class IpaRoutingBlockTest015 : public IpaRoutingBlockTestFixture
  2250. {
  2251. public:
  2252. IpaRoutingBlockTest015()
  2253. {
  2254. m_name = "IpaRoutingBlockTest015";
  2255. m_description =" \
  2256. Routing block test 015 - Destination address exact match \
  2257. no match on non hashable rule(with lower priority) , match on hashable rule. two identical\
  2258. packets are sent cache hit expected on the second one\
  2259. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  2260. All DST_IP == (192.168.2.170 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  2261. All DST_IP == (192.168.2.171 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  2262. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  2263. m_IpaIPType = IPA_IP_v4;
  2264. m_minIPAHwType = IPA_HW_v3_0;
  2265. Register(*this);
  2266. }
  2267. bool Setup()
  2268. {
  2269. return IpaRoutingBlockTestFixture:: Setup(true);
  2270. }
  2271. bool AddRules()
  2272. {
  2273. struct ipa_ioc_add_rt_rule *rt_rule;
  2274. struct ipa_rt_rule_add *rt_rule_entry;
  2275. const int NUM_RULES = 3;
  2276. rt_rule = (struct ipa_ioc_add_rt_rule *)
  2277. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  2278. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  2279. if(!rt_rule) {
  2280. printf("Failed memory allocation for rt_rule\n");
  2281. return false;
  2282. }
  2283. rt_rule->commit = 1;
  2284. rt_rule->num_rules = NUM_RULES;
  2285. rt_rule->ip = IPA_IP_v4;
  2286. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  2287. rt_rule_entry = &rt_rule->rules[0];
  2288. rt_rule_entry->at_rear = 1;
  2289. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  2290. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  2291. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA; //192.168.02.170
  2292. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  2293. rt_rule_entry->rule.hashable = 1; // hashable
  2294. rt_rule_entry = &rt_rule->rules[1];
  2295. rt_rule_entry->at_rear = 1;
  2296. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  2297. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  2298. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AB; //192.168.02.171
  2299. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  2300. rt_rule_entry->rule.hashable = 0; // non hashable
  2301. rt_rule_entry = &rt_rule->rules[2];
  2302. rt_rule_entry->at_rear = 1;
  2303. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  2304. if (false == m_routing.AddRoutingRule(rt_rule))
  2305. {
  2306. printf("Routing rule addition failed!\n");
  2307. return false;
  2308. }
  2309. for (int i = 0; i < rt_rule->num_rules; i++) {
  2310. uRtRuleHdl[i] = rt_rule->rules[i].rt_rule_hdl;
  2311. }
  2312. uNumRtRules = rt_rule->num_rules;
  2313. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  2314. free(rt_rule);
  2315. InitFilteringBlock();
  2316. return true;
  2317. }
  2318. bool RemoveLastRule(enum ipa_ip_type ipType)
  2319. {
  2320. struct ipa_ioc_del_rt_rule *ruleTable;
  2321. ruleTable = (struct ipa_ioc_del_rt_rule *)
  2322. calloc(1, sizeof(struct ipa_ioc_del_rt_rule) +
  2323. sizeof(struct ipa_rt_rule_del));
  2324. ruleTable->commit = 1;
  2325. ruleTable->ip = ipType;
  2326. ruleTable->num_hdls = 1;
  2327. ruleTable->hdl[0].hdl = uRtRuleHdl[uNumRtRules - 1];
  2328. ruleTable->hdl[0].status = 0;
  2329. if (false == m_routing.DeleteRoutingRule(ruleTable))
  2330. {
  2331. printf("Routing rule deletion failed!\n");
  2332. return false;
  2333. }
  2334. return true;
  2335. }
  2336. bool Run()
  2337. {
  2338. bool res = false;
  2339. bool isSuccess = false;
  2340. // Add the relevant routing rules
  2341. res = AddRules();
  2342. if (false == res) {
  2343. printf("Failed adding routing rules.\n");
  2344. return false;
  2345. }
  2346. // Load input data (IP packet) from file
  2347. res = LoadFiles(IPA_IP_v4);
  2348. if (false == res) {
  2349. printf("Failed loading files.\n");
  2350. return false;
  2351. }
  2352. // Send first packet
  2353. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2354. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  2355. if (false == isSuccess)
  2356. {
  2357. printf("SendData failure.\n");
  2358. return false;
  2359. }
  2360. // Send second packet
  2361. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2362. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  2363. if (false == isSuccess)
  2364. {
  2365. printf("SendData failure.\n");
  2366. return false;
  2367. }
  2368. // Send third packet
  2369. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  2370. if (false == isSuccess)
  2371. {
  2372. printf("SendData failure.\n");
  2373. return false;
  2374. }
  2375. // Receive packets from the channels and compare results
  2376. isSuccess = ReceivePacketsAndCompare();
  2377. return isSuccess;
  2378. } // Run()
  2379. bool ReceivePacketsAndCompare()
  2380. {
  2381. size_t receivedSize = 0;
  2382. size_t receivedSize2 = 0;
  2383. size_t receivedSize3 = 0;
  2384. bool isSuccess = true;
  2385. // Receive results
  2386. Byte *rxBuff1 = new Byte[0x400];
  2387. Byte *rxBuff2 = new Byte[0x400];
  2388. Byte *rxBuff3 = new Byte[0x400];
  2389. if (NULL == rxBuff1 || NULL == rxBuff2 || NULL == rxBuff3)
  2390. {
  2391. printf("Memory allocation error.\n");
  2392. return false;
  2393. }
  2394. receivedSize = m_consumer.ReceiveData(rxBuff1, 0x400);
  2395. printf("Received %zu bytes on %s.\n", receivedSize, m_consumer.m_fromChannelName.c_str());
  2396. receivedSize2 = m_consumer.ReceiveData(rxBuff2, 0x400);
  2397. printf("Received %zu bytes on %s.\n", receivedSize2, m_consumer.m_fromChannelName.c_str());
  2398. receivedSize3 = m_defaultConsumer.ReceiveData(rxBuff3, 0x400);
  2399. printf("Received %zu bytes on %s.\n", receivedSize3, m_defaultConsumer.m_fromChannelName.c_str());
  2400. /* Compare results */
  2401. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer, m_sendSize, rxBuff1, receivedSize);
  2402. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer2, m_sendSize2, rxBuff2, receivedSize2);
  2403. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer3, m_sendSize3, rxBuff3, receivedSize3);
  2404. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  2405. IsCacheMiss_v5_0(m_sendSize, receivedSize, rxBuff1) : IsCacheMiss(m_sendSize,receivedSize,rxBuff1);
  2406. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  2407. IsCacheHit_v5_0(m_sendSize2, receivedSize2, rxBuff2) : IsCacheHit(m_sendSize2,receivedSize2,rxBuff2);
  2408. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  2409. IsCacheMiss_v5_0(m_sendSize3, receivedSize3, rxBuff3) : IsCacheMiss(m_sendSize3,receivedSize3,rxBuff3);
  2410. size_t recievedBufferSize = receivedSize * 3;
  2411. size_t sentBufferSize = m_sendSize * 3;
  2412. char *recievedBuffer = new char[recievedBufferSize];
  2413. char *sentBuffer = new char[sentBufferSize];
  2414. memset(recievedBuffer, 0, recievedBufferSize);
  2415. memset(sentBuffer, 0, sentBufferSize);
  2416. print_packets(receivedSize, m_sendSize, recievedBufferSize, sentBufferSize, rxBuff1, m_sendBuffer, recievedBuffer, sentBuffer);
  2417. print_packets(receivedSize2, m_sendSize2, recievedBufferSize, sentBufferSize, rxBuff2, m_sendBuffer2, recievedBuffer, sentBuffer);
  2418. print_packets(receivedSize3, m_sendSize3, recievedBufferSize, sentBufferSize, rxBuff3, m_sendBuffer3, recievedBuffer, sentBuffer);
  2419. delete[] recievedBuffer;
  2420. delete[] sentBuffer;
  2421. delete[] rxBuff1;
  2422. delete[] rxBuff2;
  2423. delete[] rxBuff3;
  2424. return isSuccess;
  2425. }
  2426. bool ReceivePacketsAndCompareSpecial()
  2427. {
  2428. size_t receivedSize = 0;
  2429. bool isSuccess = true;
  2430. // Receive results
  2431. Byte *rxBuff1 = new Byte[0x400];
  2432. if (NULL == rxBuff1)
  2433. {
  2434. printf("Memory allocation error.\n");
  2435. return false;
  2436. }
  2437. receivedSize = m_consumer.ReceiveData(rxBuff1, 0x400);
  2438. printf("Received %zu bytes on %s.\n", receivedSize, m_consumer.m_fromChannelName.c_str());
  2439. /* Compare results */
  2440. isSuccess &= CompareResultVsGolden_w_Status(m_sendBuffer, m_sendSize, rxBuff1, receivedSize);
  2441. isSuccess &= (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v5_0) ?
  2442. IsCacheMiss_v5_0(m_sendSize, receivedSize, rxBuff1) : IsCacheMiss(m_sendSize,receivedSize,rxBuff1);
  2443. size_t recievedBufferSize = receivedSize * 3;
  2444. size_t sentBufferSize = m_sendSize * 3;
  2445. char *recievedBuffer = new char[recievedBufferSize];
  2446. char *sentBuffer = new char[sentBufferSize];
  2447. size_t j;
  2448. for(j = 0; j < m_sendSize; j++)
  2449. snprintf(&sentBuffer[3 * j], sentBufferSize - 3 * j,
  2450. " %02X", m_sendBuffer[j]);
  2451. for(j = 0; j < receivedSize; j++)
  2452. snprintf(&recievedBuffer[3 * j], recievedBufferSize - 3 * j,
  2453. " %02X", rxBuff1[j]);
  2454. printf("Expected Value1 (%zu)\n%s\n, Received Value1(%zu)\n%s\n",m_sendSize,sentBuffer,receivedSize,recievedBuffer);
  2455. delete[] rxBuff1;
  2456. return isSuccess;
  2457. }
  2458. protected:
  2459. uint32_t uRtRuleHdl[3];
  2460. uint8_t uNumRtRules;
  2461. };
  2462. /*--------------------------------------------------------------------------*/
  2463. /* Test16: IPv4 - Tests routing hashable vs non hashable priorities */
  2464. /*--------------------------------------------------------------------------*/
  2465. class IpaRoutingBlockTest016 : public IpaRoutingBlockTestFixture
  2466. {
  2467. public:
  2468. IpaRoutingBlockTest016()
  2469. {
  2470. m_name = "IpaRoutingBlockTest016";
  2471. m_description =" \
  2472. Routing block test 016 - Destination address exact match max priority for non hashable \
  2473. match on both rule, non hashable rule should win because max priority\
  2474. packets are sent. No cache hit is expected\
  2475. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  2476. All DST_IP == (192.168.2.170 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  2477. All DST_IP == (192.168.2.170 & 255.255.255.255)traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  2478. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  2479. m_IpaIPType = IPA_IP_v4;
  2480. m_minIPAHwType = IPA_HW_v3_0;
  2481. Register(*this);
  2482. }
  2483. bool AddRules()
  2484. {
  2485. struct ipa_ioc_add_rt_rule *rt_rule;
  2486. struct ipa_rt_rule_add *rt_rule_entry;
  2487. const int NUM_RULES = 3;
  2488. rt_rule = (struct ipa_ioc_add_rt_rule *)
  2489. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  2490. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  2491. if(!rt_rule) {
  2492. printf("Failed memory allocation for rt_rule\n");
  2493. return false;
  2494. }
  2495. rt_rule->commit = 1;
  2496. rt_rule->num_rules = NUM_RULES;
  2497. rt_rule->ip = IPA_IP_v4;
  2498. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  2499. rt_rule_entry = &rt_rule->rules[0];
  2500. rt_rule_entry->at_rear = 1;
  2501. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  2502. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  2503. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA; //192.168.02.170
  2504. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  2505. rt_rule_entry->rule.hashable = 1; // hashable
  2506. rt_rule_entry = &rt_rule->rules[1];
  2507. rt_rule_entry->at_rear = 1;
  2508. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  2509. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  2510. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802AA; //192.168.02.170
  2511. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  2512. rt_rule_entry->rule.hashable = 0; // non hashable
  2513. rt_rule_entry->rule.max_prio = 1; // max priority
  2514. rt_rule_entry = &rt_rule->rules[2];
  2515. rt_rule_entry->at_rear = 1;
  2516. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  2517. if (false == m_routing.AddRoutingRule(rt_rule))
  2518. {
  2519. printf("Routing rule addition failed!\n");
  2520. return false;
  2521. }
  2522. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  2523. free(rt_rule);
  2524. InitFilteringBlock();
  2525. return true;
  2526. }
  2527. bool Run()
  2528. {
  2529. bool res = false;
  2530. bool isSuccess = false;
  2531. // Add the relevant routing rules
  2532. res = AddRules();
  2533. if (false == res) {
  2534. printf("Failed adding routing rules.\n");
  2535. return false;
  2536. }
  2537. // Load input data (IP packet) from file
  2538. res = LoadFiles(IPA_IP_v4);
  2539. if (false == res) {
  2540. printf("Failed loading files.\n");
  2541. return false;
  2542. }
  2543. // Send first packet
  2544. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2545. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  2546. if (false == isSuccess)
  2547. {
  2548. printf("SendData failure.\n");
  2549. return false;
  2550. }
  2551. // Send second packet
  2552. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2553. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  2554. if (false == isSuccess)
  2555. {
  2556. printf("SendData failure.\n");
  2557. return false;
  2558. }
  2559. // Send third packet
  2560. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  2561. if (false == isSuccess)
  2562. {
  2563. printf("SendData failure.\n");
  2564. return false;
  2565. }
  2566. // Receive packets from the channels and compare results
  2567. isSuccess = ReceivePacketsAndCompare();
  2568. return isSuccess;
  2569. } // Run()
  2570. bool ReceivePacketsAndCompare()
  2571. {
  2572. size_t receivedSize = 0;
  2573. size_t receivedSize2 = 0;
  2574. size_t receivedSize3 = 0;
  2575. bool isSuccess = true;
  2576. // Receive results
  2577. Byte *rxBuff1 = new Byte[0x400];
  2578. Byte *rxBuff2 = new Byte[0x400];
  2579. Byte *rxBuff3 = new Byte[0x400];
  2580. if (NULL == rxBuff1 || NULL == rxBuff2 || NULL == rxBuff3)
  2581. {
  2582. printf("Memory allocation error.\n");
  2583. return false;
  2584. }
  2585. receivedSize = m_consumer2.ReceiveData(rxBuff1, 0x400);
  2586. printf("Received %zu bytes on %s.\n", receivedSize, m_consumer.m_fromChannelName.c_str());
  2587. receivedSize2 = m_consumer2.ReceiveData(rxBuff2, 0x400);
  2588. printf("Received %zu bytes on %s.\n", receivedSize2, m_consumer.m_fromChannelName.c_str());
  2589. receivedSize3 = m_defaultConsumer.ReceiveData(rxBuff3, 0x400);
  2590. printf("Received %zu bytes on %s.\n", receivedSize3, m_defaultConsumer.m_fromChannelName.c_str());
  2591. /* Compare results */
  2592. isSuccess &= CompareResultVsGolden(m_sendBuffer, m_sendSize, rxBuff1, receivedSize);
  2593. isSuccess &= CompareResultVsGolden(m_sendBuffer2, m_sendSize2, rxBuff2, receivedSize2);
  2594. isSuccess &= CompareResultVsGolden(m_sendBuffer3, m_sendSize3, rxBuff3, receivedSize3);
  2595. size_t recievedBufferSize = receivedSize * 3;
  2596. size_t sentBufferSize = m_sendSize * 3;
  2597. char *recievedBuffer = new char[recievedBufferSize];
  2598. char *sentBuffer = new char[sentBufferSize];
  2599. memset(recievedBuffer, 0, recievedBufferSize);
  2600. memset(sentBuffer, 0, sentBufferSize);
  2601. print_packets(receivedSize, m_sendSize, recievedBufferSize, sentBufferSize, rxBuff1, m_sendBuffer, recievedBuffer, sentBuffer);
  2602. print_packets(receivedSize2, m_sendSize2, recievedBufferSize, sentBufferSize, rxBuff2, m_sendBuffer2, recievedBuffer, sentBuffer);
  2603. print_packets(receivedSize3, m_sendSize3, recievedBufferSize, sentBufferSize, rxBuff3, m_sendBuffer3, recievedBuffer, sentBuffer);
  2604. delete[] recievedBuffer;
  2605. delete[] sentBuffer;
  2606. delete[] rxBuff1;
  2607. delete[] rxBuff2;
  2608. delete[] rxBuff3;
  2609. return isSuccess;
  2610. }
  2611. };
  2612. /*--------------------------------------------------------------------------*/
  2613. /* Test17: IPv4 - Tests routing hashable, non hashable, */
  2614. /* cache/hash invalidation test on rule addition */
  2615. /*--------------------------------------------------------------------------*/
  2616. class IpaRoutingBlockTest017 : public IpaRoutingBlockTest015
  2617. {
  2618. public:
  2619. IpaRoutingBlockTest017()
  2620. {
  2621. m_name = "IpaRoutingBlockTest017";
  2622. m_description =" \
  2623. Routing block test 017 - this test perform test 015 and then commits another rule\
  2624. another identical packet is sent: DST_IP == 192.168.02.170 and expected to get cache miss";
  2625. }
  2626. bool Run()
  2627. {
  2628. bool res = false;
  2629. bool isSuccess = false;
  2630. // Add the relevant routing rules
  2631. res = AddRules();
  2632. if (false == res) {
  2633. printf("Failed adding routing rules.\n");
  2634. return false;
  2635. }
  2636. // Load input data (IP packet) from file
  2637. res = LoadFiles(IPA_IP_v4);
  2638. if (false == res) {
  2639. printf("Failed loading files.\n");
  2640. return false;
  2641. }
  2642. // Send first packet
  2643. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2644. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  2645. if (false == isSuccess)
  2646. {
  2647. printf("SendData failure.\n");
  2648. return false;
  2649. }
  2650. // Send second packet
  2651. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2652. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  2653. if (false == isSuccess)
  2654. {
  2655. printf("SendData failure.\n");
  2656. return false;
  2657. }
  2658. // Send third packet
  2659. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  2660. if (false == isSuccess)
  2661. {
  2662. printf("SendData failure.\n");
  2663. return false;
  2664. }
  2665. // Receive packets from the channels and compare results
  2666. isSuccess = ReceivePacketsAndCompare();
  2667. if (false == isSuccess)
  2668. {
  2669. printf("ReceivePacketsAndCompare failure.\n");
  2670. return false;
  2671. }
  2672. // until here test 15 was run, now we test hash invalidation
  2673. // commit the rules again to clear the cache
  2674. res = AddRules();
  2675. if (false == res) {
  2676. printf("Failed adding routing rules.\n");
  2677. return false;
  2678. }
  2679. // send the packet again
  2680. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  2681. if (false == isSuccess)
  2682. {
  2683. printf("SendData failure.\n");
  2684. return false;
  2685. }
  2686. // validate we got cache miss
  2687. isSuccess = ReceivePacketsAndCompareSpecial();
  2688. if (false == isSuccess)
  2689. {
  2690. printf("ReceivePacketsAndCompareSpecial failure.\n");
  2691. }
  2692. return isSuccess;
  2693. } // Run()
  2694. };
  2695. /*--------------------------------------------------------------------------*/
  2696. /* Test18: IPv4 - Tests routing hashable, non hashable, */
  2697. /* cache/hash invalidation test on rule delition */
  2698. /*--------------------------------------------------------------------------*/
  2699. class IpaRoutingBlockTest018 : public IpaRoutingBlockTest015
  2700. {
  2701. public:
  2702. IpaRoutingBlockTest018()
  2703. {
  2704. m_name = "IpaRoutingBlockTest018";
  2705. m_description =" \
  2706. Routing block test 018 - this test perform test 015 and then removes last rule\
  2707. another identical packet is sent: DST_IP == 192.168.02.170 and expected to get cache miss";
  2708. }
  2709. bool Run()
  2710. {
  2711. bool res = false;
  2712. bool isSuccess = false;
  2713. // Add the relevant routing rules
  2714. res = AddRules();
  2715. if (false == res) {
  2716. printf("Failed adding routing rules.\n");
  2717. return false;
  2718. }
  2719. // Load input data (IP packet) from file
  2720. res = LoadFiles(IPA_IP_v4);
  2721. if (false == res) {
  2722. printf("Failed loading files.\n");
  2723. return false;
  2724. }
  2725. // Send first packet
  2726. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2727. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  2728. if (false == isSuccess)
  2729. {
  2730. printf("SendData failure.\n");
  2731. return false;
  2732. }
  2733. // Send second packet
  2734. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xAA;
  2735. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  2736. if (false == isSuccess)
  2737. {
  2738. printf("SendData failure.\n");
  2739. return false;
  2740. }
  2741. // Send third packet
  2742. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  2743. if (false == isSuccess)
  2744. {
  2745. printf("SendData failure.\n");
  2746. return false;
  2747. }
  2748. // Receive packets from the channels and compare results
  2749. isSuccess = ReceivePacketsAndCompare();
  2750. if (false == isSuccess)
  2751. {
  2752. printf("ReceivePacketsAndCompare failure.\n");
  2753. return false;
  2754. }
  2755. // until here test 15 was run, now we test hash invalidation
  2756. // delete the last rule, this should clear the cache
  2757. res = RemoveLastRule(IPA_IP_v4);
  2758. if (false == res) {
  2759. printf("Failed removing filtering rules.\n");
  2760. return false;
  2761. }
  2762. // send the packet again
  2763. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  2764. if (false == isSuccess)
  2765. {
  2766. printf("SendData failure.\n");
  2767. return false;
  2768. }
  2769. // validate we got cache miss
  2770. isSuccess = ReceivePacketsAndCompareSpecial();
  2771. if (false == isSuccess)
  2772. {
  2773. printf("ReceivePacketsAndCompareSpecial failure.\n");
  2774. }
  2775. return isSuccess;
  2776. } // Run()
  2777. };
  2778. /*--------------------------------------------------------------------------*/
  2779. /* Test20: IPv6 - Tests routing hashable vs non hashable priorities */
  2780. /*--------------------------------------------------------------------------*/
  2781. class IpaRoutingBlockTest020 : public IpaRoutingBlockTest010
  2782. {
  2783. public:
  2784. IpaRoutingBlockTest020()
  2785. {
  2786. m_name = "IpaRoutingBlockTest20";
  2787. m_description =" \
  2788. Routing block test 020 - Destination address exact match non hashable priority higher than hashable \
  2789. both match the packet but only non hashable should hit\
  2790. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  2791. All DST_IP == 0XFF020000 \
  2792. 0x00000000 \
  2793. 0x00000000 \
  2794. 0X000000FF \
  2795. traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  2796. All DST_IP == 0XFF020000 \
  2797. 0x00000000 \
  2798. 0x00000000 \
  2799. 0X000000FF \
  2800. traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  2801. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  2802. m_IpaIPType = IPA_IP_v6;
  2803. m_minIPAHwType = IPA_HW_v3_0;
  2804. }
  2805. bool AddRules()
  2806. {
  2807. struct ipa_ioc_add_rt_rule *rt_rule;
  2808. struct ipa_rt_rule_add *rt_rule_entry;
  2809. const int NUM_RULES = 3;
  2810. rt_rule = (struct ipa_ioc_add_rt_rule *)
  2811. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  2812. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  2813. if(!rt_rule) {
  2814. printf("Failed memory allocation for rt_rule\n");
  2815. return false;
  2816. }
  2817. rt_rule->commit = 1;
  2818. rt_rule->num_rules = NUM_RULES;
  2819. rt_rule->ip = IPA_IP_v6;
  2820. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  2821. rt_rule_entry = &rt_rule->rules[0];
  2822. rt_rule_entry->at_rear = 1;
  2823. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  2824. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  2825. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  2826. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  2827. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  2828. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  2829. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  2830. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  2831. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  2832. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  2833. rt_rule_entry->rule.hashable = 0; // non hashable
  2834. rt_rule_entry = &rt_rule->rules[1];
  2835. rt_rule_entry->at_rear = 1;
  2836. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  2837. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  2838. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  2839. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  2840. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  2841. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  2842. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  2843. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  2844. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  2845. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  2846. rt_rule_entry->rule.hashable = 1; // hashable
  2847. rt_rule_entry = &rt_rule->rules[2];
  2848. rt_rule_entry->at_rear = 1;
  2849. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  2850. rt_rule_entry->rule.hashable = 0; // non hashable
  2851. if (false == m_routing.AddRoutingRule(rt_rule))
  2852. {
  2853. printf("Routing rule addition failed!\n");
  2854. free(rt_rule);
  2855. return false;
  2856. }
  2857. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  2858. free(rt_rule);
  2859. InitFilteringBlock();
  2860. return true;
  2861. }
  2862. bool Run()
  2863. {
  2864. bool res = false;
  2865. bool isSuccess = false;
  2866. // Add the relevant routing rules
  2867. res = AddRules();
  2868. if (false == res) {
  2869. printf("Failed adding routing rules.\n");
  2870. return false;
  2871. }
  2872. // Load input data (IP packet) from file
  2873. res = LoadFiles(IPA_IP_v6);
  2874. if (false == res) {
  2875. printf("Failed loading files.\n");
  2876. return false;
  2877. }
  2878. // Send first packet
  2879. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  2880. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  2881. if (false == isSuccess)
  2882. {
  2883. printf("SendData failure.\n");
  2884. return false;
  2885. }
  2886. // Send second packet
  2887. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  2888. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  2889. if (false == isSuccess)
  2890. {
  2891. printf("SendData failure.\n");
  2892. return false;
  2893. }
  2894. // Send third packet
  2895. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  2896. if (false == isSuccess)
  2897. {
  2898. printf("SendData failure.\n");
  2899. return false;
  2900. }
  2901. // Receive packets from the channels and compare results
  2902. isSuccess = ReceivePacketsAndCompare();
  2903. return isSuccess;
  2904. } // Run()
  2905. };
  2906. /*--------------------------------------------------------------------------*/
  2907. /* Test21: IPv6 - Tests routing hashable vs non hashable priorities */
  2908. /*--------------------------------------------------------------------------*/
  2909. class IpaRoutingBlockTest021 : public IpaRoutingBlockTest011
  2910. {
  2911. public:
  2912. IpaRoutingBlockTest021()
  2913. {
  2914. m_name = "IpaRoutingBlockTest021";
  2915. m_description =" \
  2916. Routing block test 021 - Destination address exact match hashable priority higher than non hashable \
  2917. both match the packet but only hashable should hit, second packet should get cache hit\
  2918. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  2919. All DST_IP == 0XFF020000 \
  2920. 0x00000000 \
  2921. 0x00000000 \
  2922. 0X000000FF - hashable\
  2923. All DST_IP == 0XFF020000 \
  2924. 0x00000000 \
  2925. 0x00000000 \
  2926. 0X000000FF - non hahsable \
  2927. traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  2928. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  2929. m_IpaIPType = IPA_IP_v6;
  2930. m_minIPAHwType = IPA_HW_v3_0;
  2931. }
  2932. bool AddRules()
  2933. {
  2934. struct ipa_ioc_add_rt_rule *rt_rule;
  2935. struct ipa_rt_rule_add *rt_rule_entry;
  2936. const int NUM_RULES = 3;
  2937. rt_rule = (struct ipa_ioc_add_rt_rule *)
  2938. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  2939. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  2940. if(!rt_rule) {
  2941. printf("Failed memory allocation for rt_rule\n");
  2942. return false;
  2943. }
  2944. rt_rule->commit = 1;
  2945. rt_rule->num_rules = NUM_RULES;
  2946. rt_rule->ip = IPA_IP_v6;
  2947. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  2948. rt_rule_entry = &rt_rule->rules[0];
  2949. rt_rule_entry->at_rear = 1;
  2950. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  2951. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  2952. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  2953. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  2954. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  2955. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  2956. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  2957. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  2958. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  2959. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  2960. rt_rule_entry->rule.hashable = 1; // hashable
  2961. rt_rule_entry = &rt_rule->rules[1];
  2962. rt_rule_entry->at_rear = 1;
  2963. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  2964. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  2965. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  2966. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  2967. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  2968. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  2969. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  2970. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  2971. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  2972. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  2973. rt_rule_entry->rule.hashable = 0; // non hashable
  2974. rt_rule_entry = &rt_rule->rules[2];
  2975. rt_rule_entry->at_rear = 1;
  2976. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  2977. rt_rule_entry->rule.hashable = 0; // non hashable
  2978. if (false == m_routing.AddRoutingRule(rt_rule))
  2979. {
  2980. printf("Routing rule addition failed!\n");
  2981. free(rt_rule);
  2982. return false;
  2983. }
  2984. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  2985. free(rt_rule);
  2986. InitFilteringBlock();
  2987. return true;
  2988. }
  2989. bool Run()
  2990. {
  2991. bool res = false;
  2992. bool isSuccess = false;
  2993. // Add the relevant routing rules
  2994. res = AddRules();
  2995. if (false == res) {
  2996. printf("Failed adding routing rules.\n");
  2997. return false;
  2998. }
  2999. // Load input data (IP packet) from file
  3000. res = LoadFiles(IPA_IP_v6);
  3001. if (false == res) {
  3002. printf("Failed loading files.\n");
  3003. return false;
  3004. }
  3005. // Send first packet
  3006. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3007. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  3008. if (false == isSuccess)
  3009. {
  3010. printf("SendData failure.\n");
  3011. return false;
  3012. }
  3013. // Send second packet
  3014. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3015. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  3016. if (false == isSuccess)
  3017. {
  3018. printf("SendData failure.\n");
  3019. return false;
  3020. }
  3021. // Send third packet
  3022. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  3023. if (false == isSuccess)
  3024. {
  3025. printf("SendData failure.\n");
  3026. return false;
  3027. }
  3028. // Receive packets from the channels and compare results
  3029. isSuccess = ReceivePacketsAndCompare();
  3030. return isSuccess;
  3031. } // Run()
  3032. };
  3033. /*--------------------------------------------------------------------------*/
  3034. /* Test22: IPv6 - Tests routing hashable vs non hashable priorities */
  3035. /*--------------------------------------------------------------------------*/
  3036. class IpaRoutingBlockTest022 : public IpaRoutingBlockTest012
  3037. {
  3038. public:
  3039. IpaRoutingBlockTest022()
  3040. {
  3041. m_name = "IpaRoutingBlockTest022";
  3042. m_description =" \
  3043. Routing block test 022 - Destination address exact match hashable priority higher than non hashable \
  3044. no match on non hashable rule (with higher priority), match on hashable rule. two packets with\
  3045. different tuple are sent (but match the rule) cache miss expected\
  3046. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  3047. All DST_IP == 0XFF020000 \
  3048. 0x00000000 \
  3049. 0x00000000 \
  3050. 0X000000AA - non hashable\
  3051. All DST_IP == 0XFF020000 \
  3052. 0x00000000 \
  3053. 0x00000000 \
  3054. 0X000000FF - hahsable \
  3055. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  3056. m_IpaIPType = IPA_IP_v6;
  3057. m_minIPAHwType = IPA_HW_v3_0;
  3058. }
  3059. bool AddRules()
  3060. {
  3061. struct ipa_ioc_add_rt_rule *rt_rule;
  3062. struct ipa_rt_rule_add *rt_rule_entry;
  3063. const int NUM_RULES = 3;
  3064. rt_rule = (struct ipa_ioc_add_rt_rule *)
  3065. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  3066. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  3067. if(!rt_rule) {
  3068. printf("Failed memory allocation for rt_rule\n");
  3069. return false;
  3070. }
  3071. rt_rule->commit = 1;
  3072. rt_rule->num_rules = NUM_RULES;
  3073. rt_rule->ip = IPA_IP_v6;
  3074. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  3075. rt_rule_entry = &rt_rule->rules[0];
  3076. rt_rule_entry->at_rear = 1;
  3077. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  3078. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  3079. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  3080. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  3081. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  3082. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000AA;
  3083. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  3084. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  3085. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  3086. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  3087. rt_rule_entry->rule.hashable = 0; // non hashable
  3088. rt_rule_entry = &rt_rule->rules[1];
  3089. rt_rule_entry->at_rear = 1;
  3090. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  3091. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  3092. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  3093. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  3094. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  3095. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  3096. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  3097. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  3098. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  3099. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  3100. rt_rule_entry->rule.hashable = 1; // hashable
  3101. rt_rule_entry = &rt_rule->rules[2];
  3102. rt_rule_entry->at_rear = 1;
  3103. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  3104. rt_rule_entry->rule.hashable = 0; // non hashable
  3105. if (false == m_routing.AddRoutingRule(rt_rule))
  3106. {
  3107. printf("Routing rule addition failed!\n");
  3108. free(rt_rule);
  3109. return false;
  3110. }
  3111. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  3112. free(rt_rule);
  3113. InitFilteringBlock();
  3114. return true;
  3115. }
  3116. bool Run()
  3117. {
  3118. bool res = false;
  3119. bool isSuccess = false;
  3120. unsigned short port;
  3121. // Add the relevant routing rules
  3122. res = AddRules();
  3123. if (false == res) {
  3124. printf("Failed adding routing rules.\n");
  3125. return false;
  3126. }
  3127. // Load input data (IP packet) from file
  3128. res = LoadFiles(IPA_IP_v6);
  3129. if (false == res) {
  3130. printf("Failed loading files.\n");
  3131. return false;
  3132. }
  3133. // Send first packet
  3134. port = ntohs(546);//DHCP Client Port
  3135. memcpy (&m_sendBuffer[IPV6_DST_PORT_OFFSET], &port, sizeof(port));
  3136. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3137. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  3138. if (false == isSuccess)
  3139. {
  3140. printf("SendData failure.\n");
  3141. return false;
  3142. }
  3143. // Send second packet
  3144. port = ntohs(547);//DHCP Client Port
  3145. memcpy (&m_sendBuffer2[IPV6_DST_PORT_OFFSET], &port, sizeof(port));
  3146. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3147. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  3148. if (false == isSuccess)
  3149. {
  3150. printf("SendData failure.\n");
  3151. return false;
  3152. }
  3153. // Send third packet
  3154. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  3155. if (false == isSuccess)
  3156. {
  3157. printf("SendData failure.\n");
  3158. return false;
  3159. }
  3160. // Receive packets from the channels and compare results
  3161. isSuccess = ReceivePacketsAndCompare();
  3162. return isSuccess;
  3163. } // Run()
  3164. };
  3165. /*--------------------------------------------------------------------------*/
  3166. /* Test23: IPv6 - Tests routing hashable vs non hashable priorities */
  3167. /*--------------------------------------------------------------------------*/
  3168. class IpaRoutingBlockTest023 : public IpaRoutingBlockTest013
  3169. {
  3170. public:
  3171. IpaRoutingBlockTest023()
  3172. {
  3173. m_name = "IpaRoutingBlockTest023";
  3174. m_description =" \
  3175. Routing block test 023 - Destination address exact match \
  3176. no match on non hashable rule (with lower priority), match on hashable rule. two packets with\
  3177. different tuple are sent (but match the rule) cache miss expected\
  3178. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  3179. All DST_IP == 0XFF020000 \
  3180. 0x00000000 \
  3181. 0x00000000 \
  3182. 0X000000FF - hashable\
  3183. traffic goes to pipe IPA_CLIENT_TEST2_CONS\
  3184. All DST_IP == 0XFF020000 \
  3185. 0x00000000 \
  3186. 0x00000000 \
  3187. 0X000000AA - non hahsable \
  3188. traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  3189. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  3190. m_IpaIPType = IPA_IP_v6;
  3191. m_minIPAHwType = IPA_HW_v3_0;
  3192. }
  3193. bool AddRules()
  3194. {
  3195. struct ipa_ioc_add_rt_rule *rt_rule;
  3196. struct ipa_rt_rule_add *rt_rule_entry;
  3197. const int NUM_RULES = 3;
  3198. rt_rule = (struct ipa_ioc_add_rt_rule *)
  3199. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  3200. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  3201. if(!rt_rule) {
  3202. printf("Failed memory allocation for rt_rule\n");
  3203. return false;
  3204. }
  3205. rt_rule->commit = 1;
  3206. rt_rule->num_rules = NUM_RULES;
  3207. rt_rule->ip = IPA_IP_v6;
  3208. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  3209. rt_rule_entry = &rt_rule->rules[0];
  3210. rt_rule_entry->at_rear = 1;
  3211. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  3212. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  3213. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  3214. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  3215. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  3216. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  3217. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  3218. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  3219. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  3220. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  3221. rt_rule_entry->rule.hashable = 1; // hashable
  3222. rt_rule_entry = &rt_rule->rules[1];
  3223. rt_rule_entry->at_rear = 1;
  3224. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  3225. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  3226. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  3227. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  3228. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  3229. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000AA;
  3230. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  3231. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  3232. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  3233. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  3234. rt_rule_entry->rule.hashable = 0; // non hashable
  3235. rt_rule_entry = &rt_rule->rules[2];
  3236. rt_rule_entry->at_rear = 1;
  3237. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  3238. rt_rule_entry->rule.hashable = 0; // non hashable
  3239. if (false == m_routing.AddRoutingRule(rt_rule))
  3240. {
  3241. printf("Routing rule addition failed!\n");
  3242. free(rt_rule);
  3243. return false;
  3244. }
  3245. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  3246. free(rt_rule);
  3247. InitFilteringBlock();
  3248. return true;
  3249. }
  3250. bool Run()
  3251. {
  3252. bool res = false;
  3253. bool isSuccess = false;
  3254. unsigned short port;
  3255. // Add the relevant routing rules
  3256. res = AddRules();
  3257. if (false == res) {
  3258. printf("Failed adding routing rules.\n");
  3259. return false;
  3260. }
  3261. // Load input data (IP packet) from file
  3262. res = LoadFiles(IPA_IP_v6);
  3263. if (false == res) {
  3264. printf("Failed loading files.\n");
  3265. return false;
  3266. }
  3267. // Send first packet
  3268. port = ntohs(546);//DHCP Client Port
  3269. memcpy (&m_sendBuffer[IPV6_DST_PORT_OFFSET], &port, sizeof(port));
  3270. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3271. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  3272. if (false == isSuccess)
  3273. {
  3274. printf("SendData failure.\n");
  3275. return false;
  3276. }
  3277. // Send second packet
  3278. port = ntohs(547);//DHCP Client Port
  3279. memcpy (&m_sendBuffer2[IPV6_DST_PORT_OFFSET], &port, sizeof(port));
  3280. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3281. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  3282. if (false == isSuccess)
  3283. {
  3284. printf("SendData failure.\n");
  3285. return false;
  3286. }
  3287. // Send third packet
  3288. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  3289. if (false == isSuccess)
  3290. {
  3291. printf("SendData failure.\n");
  3292. return false;
  3293. }
  3294. // Receive packets from the channels and compare results
  3295. isSuccess = ReceivePacketsAndCompare();
  3296. return isSuccess;
  3297. } // Run()
  3298. };
  3299. /*--------------------------------------------------------------------------*/
  3300. /* Test24: IPv6 - Tests routing hashable vs non hashable priorities */
  3301. /*--------------------------------------------------------------------------*/
  3302. class IpaRoutingBlockTest024 : public IpaRoutingBlockTest014
  3303. {
  3304. public:
  3305. IpaRoutingBlockTest024()
  3306. {
  3307. m_name = "IpaRoutingBlockTest024";
  3308. m_description =" \
  3309. Routing block test 024 - Destination address exact match \
  3310. no match on non hashable rule(with higher priority) , match on hashable rule. two identical\
  3311. packets are sent cache hit expected on the second one\
  3312. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  3313. All DST_IP == 0XFF020000 \
  3314. 0x00000000 \
  3315. 0x00000000 \
  3316. 0X000000AA - non hashable\
  3317. traffic goes to pipe IPA_CLIENT_TEST2_CONS\
  3318. All DST_IP == 0XFF020000 \
  3319. 0x00000000 \
  3320. 0x00000000 \
  3321. 0X000000FF - hahsable \
  3322. traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  3323. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  3324. m_IpaIPType = IPA_IP_v6;
  3325. m_minIPAHwType = IPA_HW_v3_0;
  3326. }
  3327. bool AddRules()
  3328. {
  3329. struct ipa_ioc_add_rt_rule *rt_rule;
  3330. struct ipa_rt_rule_add *rt_rule_entry;
  3331. const int NUM_RULES = 3;
  3332. rt_rule = (struct ipa_ioc_add_rt_rule *)
  3333. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  3334. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  3335. if(!rt_rule) {
  3336. printf("Failed memory allocation for rt_rule\n");
  3337. return false;
  3338. }
  3339. rt_rule->commit = 1;
  3340. rt_rule->num_rules = NUM_RULES;
  3341. rt_rule->ip = IPA_IP_v6;
  3342. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  3343. rt_rule_entry = &rt_rule->rules[0];
  3344. rt_rule_entry->at_rear = 1;
  3345. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  3346. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  3347. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  3348. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  3349. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  3350. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000AA;
  3351. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  3352. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  3353. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  3354. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  3355. rt_rule_entry->rule.hashable = 0; // non hashable
  3356. rt_rule_entry = &rt_rule->rules[1];
  3357. rt_rule_entry->at_rear = 1;
  3358. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  3359. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  3360. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  3361. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  3362. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  3363. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  3364. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  3365. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  3366. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  3367. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  3368. rt_rule_entry->rule.hashable = 1; // hashable
  3369. rt_rule_entry = &rt_rule->rules[2];
  3370. rt_rule_entry->at_rear = 1;
  3371. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  3372. rt_rule_entry->rule.hashable = 0; // non hashable
  3373. if (false == m_routing.AddRoutingRule(rt_rule))
  3374. {
  3375. printf("Routing rule addition failed!\n");
  3376. free(rt_rule);
  3377. return false;
  3378. }
  3379. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  3380. free(rt_rule);
  3381. InitFilteringBlock();
  3382. return true;
  3383. }
  3384. bool Run()
  3385. {
  3386. bool res = false;
  3387. bool isSuccess = false;
  3388. // Add the relevant routing rules
  3389. res = AddRules();
  3390. if (false == res) {
  3391. printf("Failed adding routing rules.\n");
  3392. return false;
  3393. }
  3394. // Load input data (IP packet) from file
  3395. res = LoadFiles(IPA_IP_v6);
  3396. if (false == res) {
  3397. printf("Failed loading files.\n");
  3398. return false;
  3399. }
  3400. // Send first packet
  3401. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3402. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  3403. if (false == isSuccess)
  3404. {
  3405. printf("SendData failure.\n");
  3406. return false;
  3407. }
  3408. // Send second packet
  3409. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3410. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  3411. if (false == isSuccess)
  3412. {
  3413. printf("SendData failure.\n");
  3414. return false;
  3415. }
  3416. // Send third packet
  3417. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  3418. if (false == isSuccess)
  3419. {
  3420. printf("SendData failure.\n");
  3421. return false;
  3422. }
  3423. // Receive packets from the channels and compare results
  3424. isSuccess = ReceivePacketsAndCompare();
  3425. return isSuccess;
  3426. } // Run()
  3427. };
  3428. /*--------------------------------------------------------------------------*/
  3429. /* Test25: IPv6 - Tests routing hashable vs non hashable priorities */
  3430. /*--------------------------------------------------------------------------*/
  3431. class IpaRoutingBlockTest025 : public IpaRoutingBlockTest015
  3432. {
  3433. public:
  3434. IpaRoutingBlockTest025()
  3435. {
  3436. m_name = "IpaRoutingBlockTest025";
  3437. m_description =" \
  3438. Routing block test 025 - Destination address exact match \
  3439. no match on non hashable rule(with lower priority) , match on hashable rule. two identical\
  3440. packets are sent cache hit expected on the second one\
  3441. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  3442. All DST_IP == 0XFF020000 \
  3443. 0x00000000 \
  3444. 0x00000000 \
  3445. 0X000000FF - hashable\
  3446. traffic goes to pipe IPA_CLIENT_TEST2_CONS\
  3447. All DST_IP == 0XFF020000 \
  3448. 0x00000000 \
  3449. 0x00000000 \
  3450. 0X000000AA - non hahsable \
  3451. traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  3452. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  3453. m_IpaIPType = IPA_IP_v6;
  3454. m_minIPAHwType = IPA_HW_v3_0;
  3455. }
  3456. bool AddRules()
  3457. {
  3458. struct ipa_ioc_add_rt_rule *rt_rule;
  3459. struct ipa_rt_rule_add *rt_rule_entry;
  3460. const int NUM_RULES = 3;
  3461. rt_rule = (struct ipa_ioc_add_rt_rule *)
  3462. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  3463. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  3464. if(!rt_rule) {
  3465. printf("Failed memory allocation for rt_rule\n");
  3466. return false;
  3467. }
  3468. rt_rule->commit = 1;
  3469. rt_rule->num_rules = NUM_RULES;
  3470. rt_rule->ip = IPA_IP_v6;
  3471. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  3472. rt_rule_entry = &rt_rule->rules[0];
  3473. rt_rule_entry->at_rear = 1;
  3474. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  3475. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  3476. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  3477. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  3478. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  3479. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  3480. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  3481. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  3482. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  3483. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  3484. rt_rule_entry->rule.hashable = 1; // hashable
  3485. rt_rule_entry = &rt_rule->rules[1];
  3486. rt_rule_entry->at_rear = 1;
  3487. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  3488. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  3489. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  3490. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  3491. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  3492. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000AA;
  3493. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  3494. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  3495. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  3496. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  3497. rt_rule_entry->rule.hashable = 0; // non hashable
  3498. rt_rule_entry = &rt_rule->rules[2];
  3499. rt_rule_entry->at_rear = 1;
  3500. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  3501. rt_rule_entry->rule.hashable = 0; // non hashable
  3502. if (false == m_routing.AddRoutingRule(rt_rule))
  3503. {
  3504. printf("Routing rule addition failed!\n");
  3505. free(rt_rule);
  3506. return false;
  3507. }
  3508. for (int i = 0; i < rt_rule->num_rules; i++) {
  3509. uRtRuleHdl[i] = rt_rule->rules[i].rt_rule_hdl;
  3510. }
  3511. uNumRtRules = rt_rule->num_rules;
  3512. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  3513. free(rt_rule);
  3514. InitFilteringBlock();
  3515. return true;
  3516. }
  3517. bool Run()
  3518. {
  3519. bool res = false;
  3520. bool isSuccess = false;
  3521. // Add the relevant routing rules
  3522. res = AddRules();
  3523. if (false == res) {
  3524. printf("Failed adding routing rules.\n");
  3525. return false;
  3526. }
  3527. // Load input data (IP packet) from file
  3528. res = LoadFiles(IPA_IP_v6);
  3529. if (false == res) {
  3530. printf("Failed loading files.\n");
  3531. return false;
  3532. }
  3533. // Send first packet
  3534. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3535. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  3536. if (false == isSuccess)
  3537. {
  3538. printf("SendData failure.\n");
  3539. return false;
  3540. }
  3541. // Send second packet
  3542. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3543. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  3544. if (false == isSuccess)
  3545. {
  3546. printf("SendData failure.\n");
  3547. return false;
  3548. }
  3549. // Send third packet
  3550. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  3551. if (false == isSuccess)
  3552. {
  3553. printf("SendData failure.\n");
  3554. return false;
  3555. }
  3556. // Receive packets from the channels and compare results
  3557. isSuccess = ReceivePacketsAndCompare();
  3558. return isSuccess;
  3559. } // Run()
  3560. };
  3561. /*--------------------------------------------------------------------------*/
  3562. /* Test26: IPv6 - Tests routing hashable vs non hashable priorities */
  3563. /*--------------------------------------------------------------------------*/
  3564. class IpaRoutingBlockTest026 : public IpaRoutingBlockTest016
  3565. {
  3566. public:
  3567. IpaRoutingBlockTest026()
  3568. {
  3569. m_name = "IpaRoutingBlockTest026";
  3570. m_description =" \
  3571. Routing block test 026 - Destination address exact match max priority for non hashable \
  3572. match on both rule, non hashable rule should win because max priority\
  3573. packets are sent cache hit expected on the second one\
  3574. 2. Generate and commit Three routing rules: (DST & Mask Match). \
  3575. All DST_IP == 0XFF020000 \
  3576. 0x00000000 \
  3577. 0x00000000 \
  3578. 0X000000FF - hashable\
  3579. traffic goes to pipe IPA_CLIENT_TEST2_CONS\
  3580. All DST_IP == 0XFF020000 \
  3581. 0x00000000 \
  3582. 0x00000000 \
  3583. 0X000000FF - non hahsable max prio \
  3584. traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  3585. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  3586. m_IpaIPType = IPA_IP_v6;
  3587. m_minIPAHwType = IPA_HW_v3_0;
  3588. }
  3589. bool AddRules()
  3590. {
  3591. struct ipa_ioc_add_rt_rule *rt_rule;
  3592. struct ipa_rt_rule_add *rt_rule_entry;
  3593. const int NUM_RULES = 3;
  3594. rt_rule = (struct ipa_ioc_add_rt_rule *)
  3595. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  3596. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  3597. if(!rt_rule) {
  3598. printf("Failed memory allocation for rt_rule\n");
  3599. return false;
  3600. }
  3601. rt_rule->commit = 1;
  3602. rt_rule->num_rules = NUM_RULES;
  3603. rt_rule->ip = IPA_IP_v6;
  3604. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  3605. rt_rule_entry = &rt_rule->rules[0];
  3606. rt_rule_entry->at_rear = 1;
  3607. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  3608. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  3609. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  3610. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  3611. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  3612. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  3613. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  3614. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  3615. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  3616. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  3617. rt_rule_entry->rule.hashable = 1; // hashable
  3618. rt_rule_entry = &rt_rule->rules[1];
  3619. rt_rule_entry->at_rear = 1;
  3620. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  3621. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  3622. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  3623. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  3624. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  3625. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000FF;
  3626. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  3627. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  3628. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  3629. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  3630. rt_rule_entry->rule.hashable = 0; // non hashable
  3631. rt_rule_entry->rule.max_prio = 1; // max prio
  3632. rt_rule_entry = &rt_rule->rules[2];
  3633. rt_rule_entry->at_rear = 1;
  3634. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  3635. rt_rule_entry->rule.hashable = 0; // non hashable
  3636. if (false == m_routing.AddRoutingRule(rt_rule))
  3637. {
  3638. printf("Routing rule addition failed!\n");
  3639. free(rt_rule);
  3640. return false;
  3641. }
  3642. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  3643. free(rt_rule);
  3644. InitFilteringBlock();
  3645. return true;
  3646. }
  3647. bool Run()
  3648. {
  3649. bool res = false;
  3650. bool isSuccess = false;
  3651. // Add the relevant routing rules
  3652. res = AddRules();
  3653. if (false == res) {
  3654. printf("Failed adding routing rules.\n");
  3655. return false;
  3656. }
  3657. // Load input data (IP packet) from file
  3658. res = LoadFiles(IPA_IP_v6);
  3659. if (false == res) {
  3660. printf("Failed loading files.\n");
  3661. return false;
  3662. }
  3663. // Send first packet
  3664. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3665. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  3666. if (false == isSuccess)
  3667. {
  3668. printf("SendData failure.\n");
  3669. return false;
  3670. }
  3671. // Send second packet
  3672. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3673. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  3674. if (false == isSuccess)
  3675. {
  3676. printf("SendData failure.\n");
  3677. return false;
  3678. }
  3679. // Send third packet
  3680. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  3681. if (false == isSuccess)
  3682. {
  3683. printf("SendData failure.\n");
  3684. return false;
  3685. }
  3686. // Receive packets from the channels and compare results
  3687. isSuccess = ReceivePacketsAndCompare();
  3688. return isSuccess;
  3689. } // Run()
  3690. };
  3691. /*--------------------------------------------------------------------------*/
  3692. /* Test27: IPv6 - Tests routing hashable, non hashable, */
  3693. /* cache/hash invalidation test on rule addition */
  3694. /*--------------------------------------------------------------------------*/
  3695. class IpaRoutingBlockTest027 : public IpaRoutingBlockTest025
  3696. {
  3697. public:
  3698. IpaRoutingBlockTest027()
  3699. {
  3700. m_name = "IpaRoutingBlockTest027";
  3701. m_description =" \
  3702. Routing block test 027 - this test perform test 025 and then commits another rule\
  3703. another identical packet is sent: DST_IP == 192.168.02.170 and expected to get cache miss";
  3704. }
  3705. bool Run()
  3706. {
  3707. bool res = false;
  3708. bool isSuccess = false;
  3709. // Add the relevant routing rules
  3710. res = AddRules();
  3711. if (false == res) {
  3712. printf("Failed adding routing rules.\n");
  3713. return false;
  3714. }
  3715. // Load input data (IP packet) from file
  3716. res = LoadFiles(IPA_IP_v6);
  3717. if (false == res) {
  3718. printf("Failed loading files.\n");
  3719. return false;
  3720. }
  3721. // Send first packet
  3722. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3723. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  3724. if (false == isSuccess)
  3725. {
  3726. printf("SendData failure.\n");
  3727. return false;
  3728. }
  3729. // Send second packet
  3730. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3731. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  3732. if (false == isSuccess)
  3733. {
  3734. printf("SendData failure.\n");
  3735. return false;
  3736. }
  3737. // Send third packet
  3738. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  3739. if (false == isSuccess)
  3740. {
  3741. printf("SendData failure.\n");
  3742. return false;
  3743. }
  3744. // Receive packets from the channels and compare results
  3745. isSuccess = ReceivePacketsAndCompare();
  3746. if (false == isSuccess)
  3747. {
  3748. printf("ReceivePacketsAndCompare failure.\n");
  3749. return false;
  3750. }
  3751. // until here test 25 was run, now we test hash invalidation
  3752. // commit the rules again to clear the cache
  3753. res = AddRules();
  3754. if (false == res) {
  3755. printf("Failed adding routing rules.\n");
  3756. return false;
  3757. }
  3758. // send the packet again
  3759. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  3760. if (false == isSuccess)
  3761. {
  3762. printf("SendData failure.\n");
  3763. return false;
  3764. }
  3765. // validate we got cache miss
  3766. isSuccess = ReceivePacketsAndCompareSpecial();
  3767. if (false == isSuccess)
  3768. {
  3769. printf("ReceivePacketsAndCompareSpecial failure.\n");
  3770. }
  3771. return isSuccess;
  3772. } // Run()
  3773. };
  3774. /*--------------------------------------------------------------------------*/
  3775. /* Test28: IPv6 - Tests routing hashable, non hashable, */
  3776. /* cache/hash invalidation test on rule delition */
  3777. /*--------------------------------------------------------------------------*/
  3778. class IpaRoutingBlockTest028 : public IpaRoutingBlockTest025
  3779. {
  3780. public:
  3781. IpaRoutingBlockTest028()
  3782. {
  3783. m_name = "IpaRoutingBlockTest028";
  3784. m_description =" \
  3785. Routing block test 028 - this test perform test 025 and then deletes last rule\
  3786. another identical packet is sent: DST_IP == 192.168.02.170 and expected to get cache miss";
  3787. }
  3788. bool Run()
  3789. {
  3790. bool res = false;
  3791. bool isSuccess = false;
  3792. // Add the relevant routing rules
  3793. res = AddRules();
  3794. if (false == res) {
  3795. printf("Failed adding routing rules.\n");
  3796. return false;
  3797. }
  3798. // Load input data (IP packet) from file
  3799. res = LoadFiles(IPA_IP_v6);
  3800. if (false == res) {
  3801. printf("Failed loading files.\n");
  3802. return false;
  3803. }
  3804. // Send first packet
  3805. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3806. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  3807. if (false == isSuccess)
  3808. {
  3809. printf("SendData failure.\n");
  3810. return false;
  3811. }
  3812. // Send second packet
  3813. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xFF;
  3814. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  3815. if (false == isSuccess)
  3816. {
  3817. printf("SendData failure.\n");
  3818. return false;
  3819. }
  3820. // Send third packet
  3821. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  3822. if (false == isSuccess)
  3823. {
  3824. printf("SendData failure.\n");
  3825. return false;
  3826. }
  3827. // Receive packets from the channels and compare results
  3828. isSuccess = ReceivePacketsAndCompare();
  3829. if (false == isSuccess)
  3830. {
  3831. printf("ReceivePacketsAndCompare failure.\n");
  3832. return false;
  3833. }
  3834. // until here test 25 was run, now we test hash invalidation
  3835. // delete the last rule, this should clear the cache
  3836. res = RemoveLastRule(IPA_IP_v6);
  3837. if (false == res) {
  3838. printf("Failed removing filtering rules.\n");
  3839. return false;
  3840. }
  3841. // send the packet again
  3842. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  3843. if (false == isSuccess)
  3844. {
  3845. printf("SendData failure.\n");
  3846. return false;
  3847. }
  3848. // validate we got cache miss
  3849. isSuccess = ReceivePacketsAndCompareSpecial();
  3850. if (false == isSuccess)
  3851. {
  3852. printf("ReceivePacketsAndCompareSpecial failure.\n");
  3853. }
  3854. return isSuccess;
  3855. } // Run()
  3856. };
  3857. /*--------------------------------------------------------------------------*/
  3858. /* Test30: Pure ack packet matching */
  3859. /*--------------------------------------------------------------------------*/
  3860. class IpaRoutingBlockTest030 : IpaRoutingBlockTestFixture
  3861. {
  3862. public:
  3863. IpaRoutingBlockTest030()
  3864. {
  3865. m_name = "IpaRoutingBlockTest030";
  3866. m_description =" \
  3867. Routing block test 030 - Pure Ack packet matching \
  3868. 1. Generate and commit a single routing table. \
  3869. 2. Generate and commit Three routing rules: \
  3870. All TCP pure ack traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  3871. All DST_IP == (192.168.2.200 & 255.255.255.255) traffic goes to pipe IPA_CLIENT_TEST3_CONS\
  3872. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  3873. m_IpaIPType = IPA_IP_v4;
  3874. m_minIPAHwType = IPA_HW_v4_5;
  3875. Register(*this);
  3876. }
  3877. bool LoadPackets()
  3878. {
  3879. if (!LoadNoPayloadPacket(m_IpaIPType, m_sendBuffer, m_sendSize)) {
  3880. LOG_MSG_ERROR("Failed loading No Payload Packet");
  3881. return false;
  3882. }
  3883. if (!LoadDefaultPacket(m_IpaIPType, m_sendBuffer2, m_sendSize2)) {
  3884. LOG_MSG_ERROR("Failed loading default Packet");
  3885. return false;
  3886. }
  3887. if (!LoadDefaultPacket(m_IpaIPType, m_sendBuffer3, m_sendSize3)) {
  3888. LOG_MSG_ERROR("Failed loading default Packet");
  3889. return false;
  3890. }
  3891. return true;
  3892. }
  3893. bool Run()
  3894. {
  3895. bool res = false;
  3896. bool isSuccess = false;
  3897. // Add the relevant routing rules
  3898. res = AddRules();
  3899. if (false == res) {
  3900. printf("Failed adding routing rules.\n");
  3901. return false;
  3902. }
  3903. // Load IP packets
  3904. res = LoadPackets();
  3905. if (false == res) {
  3906. printf("Failed loading packets\n");
  3907. return false;
  3908. }
  3909. // Send first packet
  3910. m_sendBuffer[IPv4_TCP_FLAGS_OFFSET] |= TCP_ACK_FLAG_MASK;
  3911. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0xC8;
  3912. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  3913. if (false == isSuccess)
  3914. {
  3915. printf("SendData failure.\n");
  3916. return false;
  3917. }
  3918. // Send second packet
  3919. m_sendBuffer2[IPv4_TCP_FLAGS_OFFSET] |= TCP_ACK_FLAG_MASK;
  3920. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV4] = 0xC8;
  3921. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize2);
  3922. if (false == isSuccess)
  3923. {
  3924. printf("SendData failure.\n");
  3925. return false;
  3926. }
  3927. // Send third packet
  3928. m_sendBuffer3[IPv4_TCP_FLAGS_OFFSET] |= TCP_ACK_FLAG_MASK;
  3929. m_sendBuffer3[DST_ADDR_LSB_OFFSET_IPV4] = 0x64;
  3930. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  3931. if (false == isSuccess)
  3932. {
  3933. printf("SendData failure.\n");
  3934. return false;
  3935. }
  3936. // Receive packets from the channels and compare results
  3937. isSuccess = ReceivePacketsAndCompare();
  3938. return isSuccess;
  3939. } // Run()
  3940. bool AddRules()
  3941. {
  3942. struct ipa_ioc_add_rt_rule *rt_rule;
  3943. struct ipa_rt_rule_add *rt_rule_entry;
  3944. const int NUM_RULES = 3;
  3945. rt_rule = (struct ipa_ioc_add_rt_rule *)
  3946. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  3947. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  3948. if(!rt_rule) {
  3949. printf("fail\n");
  3950. return false;
  3951. }
  3952. rt_rule->commit = 1;
  3953. rt_rule->num_rules = NUM_RULES;
  3954. rt_rule->ip = IPA_IP_v4;
  3955. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  3956. rt_rule_entry = &rt_rule->rules[0];
  3957. rt_rule_entry->at_rear = 0;
  3958. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  3959. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_IS_PURE_ACK;
  3960. rt_rule_entry = &rt_rule->rules[1];
  3961. rt_rule_entry->at_rear = 1;
  3962. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  3963. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  3964. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A802C8;
  3965. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  3966. rt_rule_entry = &rt_rule->rules[2];
  3967. rt_rule_entry->at_rear = 1;
  3968. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  3969. if (false == m_routing.AddRoutingRule(rt_rule))
  3970. {
  3971. printf("Routing rule addition failed!\n");
  3972. return false;
  3973. }
  3974. free(rt_rule);
  3975. InitFilteringBlock();
  3976. return true;
  3977. }
  3978. };
  3979. /*--------------------------------------------------------------------------*/
  3980. /* Test31: IPv6 Pure ack packet matching */
  3981. /*--------------------------------------------------------------------------*/
  3982. class IpaRoutingBlockTest031 : public IpaRoutingBlockTestFixture
  3983. {
  3984. public:
  3985. IpaRoutingBlockTest031()
  3986. {
  3987. m_name = "IpaRoutingBlockTest031";
  3988. m_description =" \
  3989. Routing block test 031 - IPv6 Pure Ack packet matching \
  3990. 1. Generate and commit a single routing table. \
  3991. 2. Generate and commit Three routing rules: \
  3992. All TCP pure ack traffic goes to pipe IPA_CLIENT_TEST2_CONS \
  3993. All DST_IP == 0XFF020000 \
  3994. 0x00000000 \
  3995. 0x00000000 \
  3996. 0X000000F5 \
  3997. traffic goes to pipe IPA_CLIENT_TEST3_CONS \
  3998. All other traffic goes to pipe IPA_CLIENT_TEST4_CONS";
  3999. m_IpaIPType = IPA_IP_v6;
  4000. m_minIPAHwType = IPA_HW_v4_5;
  4001. Register(*this);
  4002. }
  4003. bool LoadPackets()
  4004. {
  4005. if (!LoadNoPayloadPacket(m_IpaIPType, m_sendBuffer, m_sendSize)) {
  4006. LOG_MSG_ERROR("Failed loading No Payload Packet");
  4007. return false;
  4008. }
  4009. if (!LoadNoPayloadPacket(m_IpaIPType, m_sendBuffer2, m_sendSize2)) {
  4010. LOG_MSG_ERROR("Failed loading default Packet");
  4011. return false;
  4012. }
  4013. if (!LoadNoPayloadPacket(m_IpaIPType, m_sendBuffer3, m_sendSize3)) {
  4014. LOG_MSG_ERROR("Failed loading default Packet");
  4015. return false;
  4016. }
  4017. return true;
  4018. }
  4019. bool Run()
  4020. {
  4021. bool res = false;
  4022. bool isSuccess = false;
  4023. // Add the relevant routing rules
  4024. res = AddRules();
  4025. if (false == res) {
  4026. printf("Failed adding routing rules.\n");
  4027. return false;
  4028. }
  4029. // Load input data (IP packet)
  4030. res = LoadPackets();
  4031. if (false == res) {
  4032. printf("Failed loading packets\n");
  4033. return false;
  4034. }
  4035. // Send first packet
  4036. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV6] = 0xF5;
  4037. m_sendBuffer[IPv6_TCP_FLAGS_OFFSET] |= TCP_ACK_FLAG_MASK;
  4038. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  4039. if (false == isSuccess)
  4040. {
  4041. printf("SendData failure.\n");
  4042. return false;
  4043. }
  4044. // Send second packet
  4045. m_sendBuffer2[DST_ADDR_LSB_OFFSET_IPV6] = 0xF5;
  4046. isSuccess = m_producer.SendData(m_sendBuffer2, m_sendSize);
  4047. if (false == isSuccess)
  4048. {
  4049. printf("SendData failure.\n");
  4050. return false;
  4051. }
  4052. // Send third packet
  4053. isSuccess = m_producer.SendData(m_sendBuffer3, m_sendSize3);
  4054. if (false == isSuccess)
  4055. {
  4056. printf("SendData failure.\n");
  4057. return false;
  4058. }
  4059. // Receive packets from the channels and compare results
  4060. isSuccess = ReceivePacketsAndCompare();
  4061. return isSuccess;
  4062. } // Run()
  4063. bool AddRules()
  4064. {
  4065. struct ipa_ioc_add_rt_rule *rt_rule;
  4066. struct ipa_rt_rule_add *rt_rule_entry;
  4067. const int NUM_RULES = 3;
  4068. rt_rule = (struct ipa_ioc_add_rt_rule *)
  4069. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  4070. NUM_RULES*sizeof(struct ipa_rt_rule_add));
  4071. if(!rt_rule) {
  4072. printf("fail\n");
  4073. return false;
  4074. }
  4075. rt_rule->commit = 1;
  4076. rt_rule->num_rules = NUM_RULES;
  4077. rt_rule->ip = IPA_IP_v6;
  4078. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  4079. rt_rule_entry = &rt_rule->rules[0];
  4080. rt_rule_entry->at_rear = 0;
  4081. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  4082. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_IS_PURE_ACK;
  4083. rt_rule_entry = &rt_rule->rules[1];
  4084. rt_rule_entry->at_rear = 1;
  4085. rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
  4086. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  4087. rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0XFF020000;
  4088. rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0x00000000;
  4089. rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x00000000;
  4090. rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0X000000F5;
  4091. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
  4092. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
  4093. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
  4094. rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
  4095. rt_rule_entry = &rt_rule->rules[2];
  4096. rt_rule_entry->at_rear = 1;
  4097. rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
  4098. if (false == m_routing.AddRoutingRule(rt_rule))
  4099. {
  4100. printf("Routing rule addition failed!\n");
  4101. return false;
  4102. }
  4103. free(rt_rule);
  4104. InitFilteringBlock();
  4105. return true;
  4106. }
  4107. };
  4108. /*---------------------------------------------------------------------------*/
  4109. /* Test100: Cache LRU behavior test */
  4110. /*---------------------------------------------------------------------------*/
  4111. #define CHACHE_ENTRIES 64
  4112. #define CHACHE_PLUS_ONE (CHACHE_ENTRIES +1)
  4113. class IpaRoutingBlockTest040 : public IpaRoutingBlockTestFixture
  4114. {
  4115. public:
  4116. IpaRoutingBlockTest040()
  4117. {
  4118. m_name = "IpaRoutingBlockTest040";
  4119. m_description = " \
  4120. Routing block test 40 - Cache LRU behavior test \
  4121. 1. Preload the cache by sending 64 packets for different connections \
  4122. 2. Send another packet for 65th connection \
  4123. 3. Send packets for first 64 connections \
  4124. 4. Verify that 1st connection’s entry was reclaimed";
  4125. m_IpaIPType = IPA_IP_v4;
  4126. m_minIPAHwType = IPA_HW_v4_0;
  4127. Register(*this);
  4128. }
  4129. bool Setup()
  4130. {
  4131. return IpaRoutingBlockTestFixture:: Setup(true);
  4132. }
  4133. virtual bool AddRules()
  4134. {
  4135. struct ipa_ioc_add_rt_rule *rt_rule;
  4136. struct ipa_rt_rule_add *rt_rule_entry;
  4137. printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
  4138. rt_rule = (struct ipa_ioc_add_rt_rule *)
  4139. calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
  4140. CHACHE_PLUS_ONE * sizeof(struct ipa_rt_rule_add));
  4141. if(!rt_rule) {
  4142. printf("Failed memory allocation for rt_rule\n");
  4143. return false;
  4144. }
  4145. rt_rule->commit = 1;
  4146. rt_rule->num_rules = CHACHE_PLUS_ONE;
  4147. rt_rule->ip = IPA_IP_v4;
  4148. strlcpy(rt_rule->rt_tbl_name, "LAN", sizeof(rt_rule->rt_tbl_name));
  4149. for (int i = 0; i < CHACHE_PLUS_ONE; i++) {
  4150. rt_rule_entry = &rt_rule->rules[i];
  4151. rt_rule_entry->at_rear = 1;
  4152. rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
  4153. rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
  4154. rt_rule_entry->rule.attrib.u.v4.dst_addr = 0xC0A80101 + i; // DST_IP == 192.168.1.(1+i)
  4155. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
  4156. rt_rule_entry->rule.hashable = 1;
  4157. }
  4158. // The last rule has to be catch all, otherwize no rule will work
  4159. rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0x0;
  4160. if (false == m_routing.AddRoutingRule(rt_rule))
  4161. {
  4162. printf("Routing rule addition failed!\n");
  4163. return false;
  4164. }
  4165. printf("rt rule hdl1=%x\n", rt_rule_entry->rt_rule_hdl);
  4166. free(rt_rule);
  4167. InitFilteringBlock();
  4168. printf("Leaving %s, %s()\n",__FUNCTION__, __FILE__);
  4169. return true;
  4170. }
  4171. bool Run()
  4172. {
  4173. bool res = false;
  4174. bool isSuccess = false;
  4175. printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
  4176. // Add the relevant filtering rules
  4177. res = AddRules();
  4178. if (false == res) {
  4179. printf("Failed adding filtering rules.\n");
  4180. return false;
  4181. }
  4182. // Load input data (IP packet) from file
  4183. res = LoadFiles(IPA_IP_v4);
  4184. if (false == res) {
  4185. printf("Failed loading files.\n");
  4186. return false;
  4187. }
  4188. // Send the first CHACHE_ENTRIES packets
  4189. // Receive packets from the channels and compare results
  4190. // All rules should be cache miss
  4191. for (int i = 0; i < CHACHE_ENTRIES; i++) {
  4192. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0x1 + i;
  4193. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  4194. if (false == isSuccess)
  4195. {
  4196. printf("SendData failure.\n");
  4197. return false;
  4198. }
  4199. isSuccess = ReceivePacketAndCompareFrom(m_consumer, m_sendBuffer, m_sendSize, false);
  4200. if (false == isSuccess) {
  4201. printf("%s:%d: ReceivePacketAndCompareFrom failure.\n", __FUNCTION__, __LINE__);
  4202. return false;
  4203. }
  4204. }
  4205. // Send again the first CHACHE_ENTRIES packets
  4206. // Receive packets from the channels and compare results
  4207. // All rules should be cache hit
  4208. for (int i = 0; i < CHACHE_ENTRIES; i++) {
  4209. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0x1 + i;
  4210. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  4211. if (false == isSuccess)
  4212. {
  4213. printf("SendData failure.\n");
  4214. return false;
  4215. }
  4216. isSuccess = ReceivePacketAndCompareFrom(m_consumer, m_sendBuffer, m_sendSize, true);
  4217. if (false == isSuccess) {
  4218. printf("%s:%d: ReceivePacketAndCompareFrom failure.\n", __FUNCTION__, __LINE__);
  4219. return false;
  4220. }
  4221. }
  4222. // Send a packet to a new filter entry, this should trigger the LRU clear
  4223. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0x1 + CHACHE_ENTRIES;
  4224. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  4225. if (false == isSuccess) {
  4226. printf("SendData failure.\n");
  4227. return false;
  4228. }
  4229. // receive and verify that cache was missed
  4230. isSuccess = ReceivePacketAndCompareFrom(m_consumer, m_sendBuffer, m_sendSize, false);
  4231. if (false == isSuccess) {
  4232. printf("%s:%d: ReceivePacketAndCompareFrom failure.\n", __FUNCTION__, __LINE__);
  4233. return false;
  4234. }
  4235. // send the first packet again
  4236. m_sendBuffer[DST_ADDR_LSB_OFFSET_IPV4] = 0x1;
  4237. isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
  4238. if (false == isSuccess) {
  4239. printf("SendData failure.\n");
  4240. return false;
  4241. }
  4242. // receive and verify that cache was missed
  4243. isSuccess = ReceivePacketAndCompareFrom(m_consumer, m_sendBuffer, m_sendSize, false);
  4244. if (false == isSuccess) {
  4245. printf("%s:%d: ReceivePacketAndCompareFrom failure.\n", __FUNCTION__, __LINE__);
  4246. return false;
  4247. }
  4248. printf("Leaving %s, %s(), Returning %d\n",__FUNCTION__, __FILE__, isSuccess);
  4249. return isSuccess;
  4250. } // Run()
  4251. };
  4252. static class IpaRoutingBlockTest1 ipaRoutingBlockTest1;
  4253. static class IpaRoutingBlockTest2 ipaRoutingBlockTest2;
  4254. static class IpaRoutingBlockTest3 ipaRoutingBlockTest3;
  4255. static class IpaRoutingBlockTest4 ipaRoutingBlockTest4;
  4256. static class IpaRoutingBlockTest5 ipaRoutingBlockTest5;
  4257. static class IpaRoutingBlockTest006 ipaRoutingBlockTest006;
  4258. static class IpaRoutingBlockTest007 ipaRoutingBlockTest007;
  4259. static class IpaRoutingBlockTest008 ipaRoutingBlockTest008;
  4260. static class IpaRoutingBlockTest009 ipaRoutingBlockTest009;
  4261. static class IpaRoutingBlockTest010 ipaRoutingBlockTest010;
  4262. static class IpaRoutingBlockTest011 ipaRoutingBlockTest011;
  4263. static class IpaRoutingBlockTest012 ipaRoutingBlockTest012;
  4264. static class IpaRoutingBlockTest013 ipaRoutingBlockTest013;
  4265. static class IpaRoutingBlockTest014 ipaRoutingBlockTest014;
  4266. static class IpaRoutingBlockTest015 ipaRoutingBlockTest015;
  4267. static class IpaRoutingBlockTest016 ipaRoutingBlockTest016;
  4268. static class IpaRoutingBlockTest017 ipaRoutingBlockTest017;
  4269. static class IpaRoutingBlockTest018 ipaRoutingBlockTest018;
  4270. static class IpaRoutingBlockTest020 ipaRoutingBlockTest020;
  4271. static class IpaRoutingBlockTest021 ipaRoutingBlockTest021;
  4272. static class IpaRoutingBlockTest022 ipaRoutingBlockTest022;
  4273. static class IpaRoutingBlockTest023 ipaRoutingBlockTest023;
  4274. static class IpaRoutingBlockTest024 ipaRoutingBlockTest024;
  4275. static class IpaRoutingBlockTest025 ipaRoutingBlockTest025;
  4276. static class IpaRoutingBlockTest026 ipaRoutingBlockTest026;
  4277. static class IpaRoutingBlockTest027 ipaRoutingBlockTest027;
  4278. static class IpaRoutingBlockTest028 ipaRoutingBlockTest028;
  4279. static class IpaRoutingBlockTest030 ipaRoutingBlockTest030;
  4280. static class IpaRoutingBlockTest031 ipaRoutingBlockTest031;
  4281. static class IpaRoutingBlockTest040 ipaRoutingBlockTest040;