MBIMAggregationTestFixtureConf11.cpp 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  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 "MBIMAggregationTestFixtureConf11.h"
  30. #include "TestManager.h"
  31. /////////////////////////////////////////////////////////////////////////////////
  32. //define the static Pipes which will be used by all derived tests.
  33. Pipe MBIMAggregationTestFixtureConf11::m_IpaToUsbPipeAgg(IPA_CLIENT_TEST2_CONS,
  34. IPA_TEST_CONFIGURATION_11);
  35. Pipe MBIMAggregationTestFixtureConf11::m_UsbToIpaPipe(IPA_CLIENT_TEST_PROD,
  36. IPA_TEST_CONFIGURATION_11);
  37. Pipe MBIMAggregationTestFixtureConf11::m_IpaToUsbPipe(IPA_CLIENT_TEST3_CONS,
  38. IPA_TEST_CONFIGURATION_11);
  39. Pipe MBIMAggregationTestFixtureConf11::m_UsbToIpaPipeDeagg(IPA_CLIENT_TEST2_PROD,
  40. IPA_TEST_CONFIGURATION_11);
  41. Pipe MBIMAggregationTestFixtureConf11::m_IpaToUsbPipeAggTime(IPA_CLIENT_TEST_CONS,
  42. IPA_TEST_CONFIGURATION_11);
  43. Pipe MBIMAggregationTestFixtureConf11::m_IpaToUsbPipeAgg0Limits(IPA_CLIENT_TEST4_CONS,
  44. IPA_TEST_CONFIGURATION_11);
  45. RoutingDriverWrapper MBIMAggregationTestFixtureConf11::m_Routing;
  46. Filtering MBIMAggregationTestFixtureConf11::m_Filtering;
  47. HeaderInsertion MBIMAggregationTestFixtureConf11::m_HeaderInsertion;
  48. /////////////////////////////////////////////////////////////////////////////////
  49. MBIMAggregationTestFixtureConf11::MBIMAggregationTestFixtureConf11(bool generic_agg)
  50. : mGenericAgg(generic_agg)
  51. {
  52. if (mGenericAgg) {
  53. m_testSuiteName.push_back("GenMbimAgg");
  54. m_minIPAHwType = IPA_HW_v4_0;
  55. } else {
  56. m_testSuiteName.push_back("Mbim16Agg");
  57. m_maxIPAHwType = IPA_HW_v3_5_1;
  58. }
  59. Register(*this);
  60. }
  61. /////////////////////////////////////////////////////////////////////////////////
  62. int MBIMAggregationTestFixtureConf11::SetupKernelModule()
  63. {
  64. int retval;
  65. struct ipa_channel_config from_ipa_channels[4];
  66. struct test_ipa_ep_cfg from_ipa_cfg[4];
  67. struct ipa_channel_config to_ipa_channels[2];
  68. struct test_ipa_ep_cfg to_ipa_cfg[2];
  69. struct ipa_test_config_header header = {0};
  70. struct ipa_channel_config *to_ipa_array[2];
  71. struct ipa_channel_config *from_ipa_array[4];
  72. /* From ipa configurations - 4 pipes */
  73. memset(&from_ipa_cfg[0], 0, sizeof(from_ipa_cfg[0]));
  74. from_ipa_cfg[0].aggr.aggr_en = IPA_ENABLE_AGGR;
  75. from_ipa_cfg[0].aggr.aggr = IPA_MBIM_16;
  76. from_ipa_cfg[0].aggr.aggr_byte_limit = 1;
  77. from_ipa_cfg[0].aggr.aggr_time_limit = 0;
  78. if (mGenericAgg) {
  79. from_ipa_cfg[0].hdr.hdr_len = 4;
  80. from_ipa_cfg[0].hdr_ext.hdr_pad_to_alignment = 2;
  81. } else {
  82. from_ipa_cfg[0].hdr.hdr_len = 1;
  83. }
  84. prepare_channel_struct(&from_ipa_channels[0],
  85. header.from_ipa_channels_num++,
  86. IPA_CLIENT_TEST2_CONS,
  87. (void *)&from_ipa_cfg[0],
  88. sizeof(from_ipa_cfg[0]),
  89. false);
  90. from_ipa_array[0] = &from_ipa_channels[0];
  91. memset(&from_ipa_cfg[1], 0, sizeof(from_ipa_cfg[1]));
  92. prepare_channel_struct(&from_ipa_channels[1],
  93. header.from_ipa_channels_num++,
  94. IPA_CLIENT_TEST3_CONS,
  95. (void *)&from_ipa_cfg[1],
  96. sizeof(from_ipa_cfg[1]),
  97. false);
  98. from_ipa_array[1] = &from_ipa_channels[1];
  99. memset(&from_ipa_cfg[2], 0, sizeof(from_ipa_cfg[2]));
  100. from_ipa_cfg[2].aggr.aggr_en = IPA_ENABLE_AGGR;
  101. from_ipa_cfg[2].aggr.aggr = IPA_MBIM_16;
  102. from_ipa_cfg[2].aggr.aggr_byte_limit = 1;
  103. from_ipa_cfg[2].aggr.aggr_time_limit = 30;
  104. if (TestManager::GetInstance()->GetIPAHwType() >= IPA_HW_v4_2)
  105. from_ipa_cfg[2].aggr.aggr_time_limit *= 1000;
  106. if (mGenericAgg) {
  107. from_ipa_cfg[2].hdr.hdr_len = 4;
  108. from_ipa_cfg[2].hdr_ext.hdr_pad_to_alignment = 2;
  109. } else {
  110. from_ipa_cfg[2].hdr.hdr_len = 1;
  111. }
  112. prepare_channel_struct(&from_ipa_channels[2],
  113. header.from_ipa_channels_num++,
  114. IPA_CLIENT_TEST_CONS,
  115. (void *)&from_ipa_cfg[2],
  116. sizeof(from_ipa_cfg[2]),
  117. false);
  118. from_ipa_array[2] = &from_ipa_channels[2];
  119. memset(&from_ipa_cfg[3], 0, sizeof(from_ipa_cfg[3]));
  120. from_ipa_cfg[3].aggr.aggr_en = IPA_ENABLE_AGGR;
  121. from_ipa_cfg[3].aggr.aggr = IPA_MBIM_16;
  122. from_ipa_cfg[3].aggr.aggr_byte_limit = 0;
  123. from_ipa_cfg[3].aggr.aggr_time_limit = 0;
  124. if (mGenericAgg) {
  125. from_ipa_cfg[3].hdr.hdr_len = 4;
  126. from_ipa_cfg[3].hdr_ext.hdr_pad_to_alignment = 2;
  127. } else {
  128. from_ipa_cfg[3].hdr.hdr_len = 1;
  129. }
  130. prepare_channel_struct(&from_ipa_channels[3],
  131. header.from_ipa_channels_num++,
  132. IPA_CLIENT_TEST4_CONS,
  133. (void *)&from_ipa_cfg[3],
  134. sizeof(from_ipa_cfg[3]),
  135. false);
  136. from_ipa_array[3] = &from_ipa_channels[3];
  137. /* To ipa configurations - 2 pipes */
  138. memset(&to_ipa_cfg[0], 0, sizeof(to_ipa_cfg[0]));
  139. prepare_channel_struct(&to_ipa_channels[0],
  140. header.to_ipa_channels_num++,
  141. IPA_CLIENT_TEST_PROD,
  142. (void *)&to_ipa_cfg[0],
  143. sizeof(to_ipa_cfg[0]));
  144. to_ipa_array[0] = &to_ipa_channels[0];
  145. memset(&to_ipa_cfg[1], 0, sizeof(to_ipa_cfg[1]));
  146. to_ipa_cfg[1].aggr.aggr_en = IPA_ENABLE_DEAGGR;
  147. to_ipa_cfg[1].aggr.aggr = IPA_MBIM_16;
  148. prepare_channel_struct(&to_ipa_channels[1],
  149. header.to_ipa_channels_num++,
  150. IPA_CLIENT_TEST2_PROD,
  151. (void *)&to_ipa_cfg[1],
  152. sizeof(to_ipa_cfg[1]));
  153. to_ipa_array[1] = &to_ipa_channels[1];
  154. prepare_header_struct(&header, from_ipa_array, to_ipa_array);
  155. retval = GenericConfigureScenario(&header);
  156. return retval;
  157. }
  158. bool MBIMAggregationTestFixtureConf11::Setup()
  159. {
  160. bool bRetVal = true;
  161. //Set the configuration to support USB->IPA and IPA->USB pipes.
  162. if (SetupKernelModule() != true) {
  163. LOG_MSG_ERROR("fail to configure kernel module!\n");
  164. return false;
  165. }
  166. //Initialize the pipe for all the tests - this will open the inode which represents the pipe.
  167. bRetVal &= m_IpaToUsbPipeAgg.Init();
  168. bRetVal &= m_UsbToIpaPipe.Init();
  169. bRetVal &= m_IpaToUsbPipe.Init();
  170. bRetVal &= m_UsbToIpaPipeDeagg.Init();
  171. bRetVal &= m_IpaToUsbPipeAggTime.Init();
  172. bRetVal &= m_IpaToUsbPipeAgg0Limits.Init();
  173. if (!m_Routing.DeviceNodeIsOpened()) {
  174. LOG_MSG_ERROR(
  175. "Routing block is not ready for immediate commands!\n");
  176. return false;
  177. }
  178. if (!m_Filtering.DeviceNodeIsOpened()) {
  179. LOG_MSG_ERROR(
  180. "Filtering block is not ready for immediate commands!\n");
  181. return false;
  182. }
  183. if (!m_HeaderInsertion.DeviceNodeIsOpened())
  184. {
  185. LOG_MSG_ERROR("Header Insertion block is not ready for immediate commands!\n");
  186. return false;
  187. }
  188. m_HeaderInsertion.Reset();// resetting this component will reset both Routing and Filtering tables.
  189. return bRetVal;
  190. }
  191. /////////////////////////////////////////////////////////////////////////////////
  192. bool MBIMAggregationTestFixtureConf11::Teardown()
  193. {
  194. //The Destroy method will close the inode.
  195. m_IpaToUsbPipeAgg.Destroy();
  196. m_UsbToIpaPipe.Destroy();
  197. m_IpaToUsbPipe.Destroy();
  198. m_UsbToIpaPipeDeagg.Destroy();
  199. m_IpaToUsbPipeAggTime.Destroy();
  200. m_IpaToUsbPipeAgg0Limits.Destroy();
  201. return true;
  202. }
  203. /////////////////////////////////////////////////////////////////////////////////
  204. bool MBIMAggregationTestFixtureConf11::Run()
  205. {
  206. LOG_MSG_STACK("Entering Function");
  207. // Add the relevant filtering rules
  208. if (!AddRules()) {
  209. LOG_MSG_ERROR("Failed adding filtering rules.");
  210. return false;
  211. }
  212. if (!TestLogic()) {
  213. LOG_MSG_ERROR("Test failed, Input and expected output mismatch.");
  214. return false;
  215. }
  216. LOG_MSG_STACK("Leaving Function (Returning True)");
  217. return true;
  218. } // Run()
  219. /////////////////////////////////////////////////////////////////////////////////
  220. bool MBIMAggregationTestFixtureConf11::AddRules1HeaderAggregation() {
  221. m_eIP = IPA_IP_v4;
  222. const char aBypass[20] = "Bypass1";
  223. uint32_t nTableHdl;
  224. bool bRetVal = true;
  225. IPAFilteringTable cFilterTable0;
  226. IPAFilteringTable cFilterTable1;
  227. struct ipa_flt_rule_add sFilterRuleEntry;
  228. struct ipa_ioc_get_hdr sGetHeader;
  229. uint8_t aHeadertoAdd[4];
  230. int hdrSize;
  231. if (mGenericAgg) {
  232. hdrSize = 4;
  233. aHeadertoAdd[0]= 0x49;
  234. aHeadertoAdd[1] = 0x50;
  235. aHeadertoAdd[2] = 0x53;
  236. aHeadertoAdd[3] = 0x00;
  237. } else {
  238. hdrSize = 1;
  239. aHeadertoAdd[0] = 0x00;
  240. }
  241. LOG_MSG_STACK("Entering Function");
  242. memset(&sFilterRuleEntry, 0, sizeof(sFilterRuleEntry));
  243. memset(&sGetHeader, 0, sizeof(sGetHeader));
  244. // Create Header:
  245. // Allocate Memory, populate it, and add in to the Header Insertion.
  246. struct ipa_ioc_add_hdr * pHeaderDescriptor = NULL;
  247. pHeaderDescriptor = (struct ipa_ioc_add_hdr *) calloc(1,
  248. sizeof(struct ipa_ioc_add_hdr)
  249. + 1 * sizeof(struct ipa_hdr_add));
  250. if (!pHeaderDescriptor) {
  251. LOG_MSG_ERROR("calloc failed to allocate pHeaderDescriptor");
  252. bRetVal = false;
  253. goto bail;
  254. }
  255. pHeaderDescriptor->commit = true;
  256. pHeaderDescriptor->num_hdrs = 1;
  257. // Adding Header No1.
  258. strlcpy(pHeaderDescriptor->hdr[0].name, "StreamId0", sizeof(pHeaderDescriptor->hdr[0].name)); // Header's Name
  259. memcpy(pHeaderDescriptor->hdr[0].hdr, aHeadertoAdd, hdrSize); //Header's Data
  260. pHeaderDescriptor->hdr[0].hdr_len = hdrSize;
  261. pHeaderDescriptor->hdr[0].hdr_hdl = -1; //Return Value
  262. pHeaderDescriptor->hdr[0].is_partial = false;
  263. pHeaderDescriptor->hdr[0].status = -1; // Return Parameter
  264. strlcpy(sGetHeader.name, pHeaderDescriptor->hdr[0].name, sizeof(sGetHeader.name));
  265. if (!m_HeaderInsertion.AddHeader(pHeaderDescriptor))
  266. {
  267. LOG_MSG_ERROR("m_HeaderInsertion.AddHeader(pHeaderDescriptor) Failed.");
  268. bRetVal = false;
  269. goto bail;
  270. }
  271. if (!m_HeaderInsertion.GetHeaderHandle(&sGetHeader))
  272. {
  273. LOG_MSG_ERROR(" Failed");
  274. bRetVal = false;
  275. goto bail;
  276. }
  277. LOG_MSG_DEBUG("Received Header Handle = 0x%x", sGetHeader.hdl);
  278. if (!CreateBypassRoutingTable(&m_Routing, m_eIP, aBypass, IPA_CLIENT_TEST2_CONS,
  279. sGetHeader.hdl,&nTableHdl)) {
  280. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  281. bRetVal = false;
  282. goto bail;
  283. }
  284. LOG_MSG_INFO("Creation of bypass routing table completed successfully");
  285. // Creating Filtering Rules
  286. cFilterTable0.Init(m_eIP,IPA_CLIENT_TEST_PROD, false, 1);
  287. LOG_MSG_INFO("Creation of filtering table for IPA_CLIENT_TEST_PROD completed successfully");
  288. // Configuring Filtering Rule No.1
  289. cFilterTable0.GeneratePresetRule(1,sFilterRuleEntry);
  290. sFilterRuleEntry.at_rear = true;
  291. sFilterRuleEntry.flt_rule_hdl=-1; // return Value
  292. sFilterRuleEntry.status = -1; // return value
  293. sFilterRuleEntry.rule.action=IPA_PASS_TO_ROUTING;
  294. sFilterRuleEntry.rule.rt_tbl_hdl=nTableHdl; //put here the handle corresponding to Routing Rule 1
  295. sFilterRuleEntry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; // Destination IP Based Filtering
  296. sFilterRuleEntry.rule.attrib.u.v4.dst_addr_mask = 0xFF0000FF; // Mask
  297. sFilterRuleEntry.rule.attrib.u.v4.dst_addr = 0x7F000001; // Filter DST_IP == 127.0.0.1.
  298. if (
  299. ((uint8_t)-1 == cFilterTable0.AddRuleToTable(sFilterRuleEntry)) ||
  300. !m_Filtering.AddFilteringRule(cFilterTable0.GetFilteringTable())
  301. )
  302. {
  303. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  304. bRetVal = false;
  305. goto bail;
  306. } else
  307. {
  308. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable0.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable0.ReadRuleFromTable(0)->status);
  309. }
  310. memset(&sFilterRuleEntry, 0, sizeof(sFilterRuleEntry));
  311. // Creating Filtering Rule for De-aggregation PROD
  312. cFilterTable1.Init(m_eIP,IPA_CLIENT_TEST2_PROD, false, 1);
  313. LOG_MSG_INFO("Creation of filtering table for IPA_CLIENT_TEST2_PROD completed successfully");
  314. // Configuring Filtering Rule No.1
  315. cFilterTable1.GeneratePresetRule(1,sFilterRuleEntry);
  316. sFilterRuleEntry.at_rear = true;
  317. sFilterRuleEntry.flt_rule_hdl=-1; // return Value
  318. sFilterRuleEntry.status = -1; // return value
  319. sFilterRuleEntry.rule.action=IPA_PASS_TO_ROUTING;
  320. sFilterRuleEntry.rule.rt_tbl_hdl=nTableHdl; //put here the handle corresponding to Routing Rule 1
  321. sFilterRuleEntry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; // Destination IP Based Filtering
  322. sFilterRuleEntry.rule.attrib.u.v4.dst_addr_mask = 0xFF0000FF; // Mask
  323. sFilterRuleEntry.rule.attrib.u.v4.dst_addr = 0x7F000001; // Filter DST_IP == 127.0.0.1.
  324. if (
  325. ((uint8_t)-1 == cFilterTable1.AddRuleToTable(sFilterRuleEntry)) ||
  326. !m_Filtering.AddFilteringRule(cFilterTable1.GetFilteringTable())
  327. )
  328. {
  329. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  330. bRetVal = false;
  331. goto bail;
  332. } else
  333. {
  334. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable1.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable1.ReadRuleFromTable(0)->status);
  335. }
  336. bail:
  337. Free(pHeaderDescriptor);
  338. LOG_MSG_STACK(
  339. "Leaving Function (Returning %s)", bRetVal?"True":"False");
  340. return bRetVal;
  341. } // AddRules()
  342. bool MBIMAggregationTestFixtureConf11::AddRules1HeaderAggregation(bool bAggForceClose) {
  343. m_eIP = IPA_IP_v4;
  344. const char aBypass[20] = "Bypass1";
  345. uint32_t nTableHdl;
  346. bool bRetVal = true;
  347. IPAFilteringTable_v2 cFilterTable0;
  348. IPAFilteringTable_v2 cFilterTable1;
  349. struct ipa_flt_rule_add_v2 sFilterRuleEntry;
  350. struct ipa_ioc_get_hdr sGetHeader;
  351. uint8_t aHeadertoAdd[4];
  352. int hdrSize;
  353. if (mGenericAgg) {
  354. hdrSize = 4;
  355. aHeadertoAdd[0]= 0x49;
  356. aHeadertoAdd[1] = 0x50;
  357. aHeadertoAdd[2] = 0x53;
  358. aHeadertoAdd[3] = 0x00;
  359. } else {
  360. hdrSize = 1;
  361. aHeadertoAdd[0] = 0x00;
  362. }
  363. LOG_MSG_STACK("Entering Function");
  364. memset(&sFilterRuleEntry, 0, sizeof(sFilterRuleEntry));
  365. memset(&sGetHeader, 0, sizeof(sGetHeader));
  366. // Create Header:
  367. // Allocate Memory, populate it, and add in to the Header Insertion.
  368. struct ipa_ioc_add_hdr * pHeaderDescriptor = NULL;
  369. pHeaderDescriptor = (struct ipa_ioc_add_hdr *) calloc(1,
  370. sizeof(struct ipa_ioc_add_hdr)
  371. + 1 * sizeof(struct ipa_hdr_add));
  372. if (!pHeaderDescriptor) {
  373. LOG_MSG_ERROR("calloc failed to allocate pHeaderDescriptor");
  374. bRetVal = false;
  375. goto bail;
  376. }
  377. pHeaderDescriptor->commit = true;
  378. pHeaderDescriptor->num_hdrs = 1;
  379. // Adding Header No1.
  380. strlcpy(pHeaderDescriptor->hdr[0].name, "StreamId0", sizeof(pHeaderDescriptor->hdr[0].name)); // Header's Name
  381. memcpy(pHeaderDescriptor->hdr[0].hdr, aHeadertoAdd, hdrSize); //Header's Data
  382. pHeaderDescriptor->hdr[0].hdr_len = hdrSize;
  383. pHeaderDescriptor->hdr[0].hdr_hdl = -1; //Return Value
  384. pHeaderDescriptor->hdr[0].is_partial = false;
  385. pHeaderDescriptor->hdr[0].status = -1; // Return Parameter
  386. strlcpy(sGetHeader.name, pHeaderDescriptor->hdr[0].name, sizeof(sGetHeader.name));
  387. if (!m_HeaderInsertion.AddHeader(pHeaderDescriptor))
  388. {
  389. LOG_MSG_ERROR("m_HeaderInsertion.AddHeader(pHeaderDescriptor) Failed.");
  390. bRetVal = false;
  391. goto bail;
  392. }
  393. if (!m_HeaderInsertion.GetHeaderHandle(&sGetHeader))
  394. {
  395. LOG_MSG_ERROR(" Failed");
  396. bRetVal = false;
  397. goto bail;
  398. }
  399. LOG_MSG_DEBUG("Received Header Handle = 0x%x", sGetHeader.hdl);
  400. if (!CreateBypassRoutingTable_v2(&m_Routing, m_eIP, aBypass, IPA_CLIENT_TEST2_CONS,
  401. sGetHeader.hdl, &nTableHdl, 0)) {
  402. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  403. bRetVal = false;
  404. goto bail;
  405. }
  406. LOG_MSG_INFO("Creation of bypass routing table completed successfully");
  407. // Creating Filtering Rules
  408. cFilterTable0.Init(m_eIP,IPA_CLIENT_TEST_PROD, false, 1);
  409. LOG_MSG_INFO("Creation of filtering table for IPA_CLIENT_TEST_PROD completed successfully");
  410. // Configuring Filtering Rule No.1
  411. cFilterTable0.GeneratePresetRule(1,sFilterRuleEntry);
  412. sFilterRuleEntry.at_rear = true;
  413. sFilterRuleEntry.flt_rule_hdl=-1; // return Value
  414. sFilterRuleEntry.status = -1; // return value
  415. sFilterRuleEntry.rule.action=IPA_PASS_TO_ROUTING;
  416. sFilterRuleEntry.rule.rt_tbl_hdl=nTableHdl; //put here the handle corresponding to Routing Rule 1
  417. sFilterRuleEntry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; // Destination IP Based Filtering
  418. sFilterRuleEntry.rule.attrib.u.v4.dst_addr_mask = 0xFF0000FF; // Mask
  419. sFilterRuleEntry.rule.attrib.u.v4.dst_addr = 0x7F000001; // Filter DST_IP == 127.0.0.1.
  420. sFilterRuleEntry.rule.close_aggr_irq_mod = bAggForceClose;
  421. if (
  422. ((uint8_t)-1 == cFilterTable0.AddRuleToTable(sFilterRuleEntry)) ||
  423. !m_Filtering.AddFilteringRule(cFilterTable0.GetFilteringTable())
  424. )
  425. {
  426. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  427. bRetVal = false;
  428. goto bail;
  429. } else
  430. {
  431. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable0.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable0.ReadRuleFromTable(0)->status);
  432. }
  433. memset(&sFilterRuleEntry, 0, sizeof(sFilterRuleEntry));
  434. // Creating Filtering Rule for De-aggregation PROD
  435. cFilterTable1.Init(m_eIP,IPA_CLIENT_TEST2_PROD, false, 1);
  436. LOG_MSG_INFO("Creation of filtering table for IPA_CLIENT_TEST2_PROD completed successfully");
  437. // Configuring Filtering Rule No.1
  438. cFilterTable1.GeneratePresetRule(1,sFilterRuleEntry);
  439. sFilterRuleEntry.at_rear = true;
  440. sFilterRuleEntry.flt_rule_hdl=-1; // return Value
  441. sFilterRuleEntry.status = -1; // return value
  442. sFilterRuleEntry.rule.action=IPA_PASS_TO_ROUTING;
  443. sFilterRuleEntry.rule.rt_tbl_hdl=nTableHdl; //put here the handle corresponding to Routing Rule 1
  444. sFilterRuleEntry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; // Destination IP Based Filtering
  445. sFilterRuleEntry.rule.attrib.u.v4.dst_addr_mask = 0xFF0000FF; // Mask
  446. sFilterRuleEntry.rule.attrib.u.v4.dst_addr = 0x7F000001; // Filter DST_IP == 127.0.0.1.
  447. sFilterRuleEntry.rule.close_aggr_irq_mod = bAggForceClose;
  448. if (
  449. ((uint8_t)-1 == cFilterTable1.AddRuleToTable(sFilterRuleEntry)) ||
  450. !m_Filtering.AddFilteringRule(cFilterTable1.GetFilteringTable())
  451. )
  452. {
  453. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  454. bRetVal = false;
  455. goto bail;
  456. } else
  457. {
  458. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable1.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable1.ReadRuleFromTable(0)->status);
  459. }
  460. bail:
  461. Free(pHeaderDescriptor);
  462. LOG_MSG_STACK(
  463. "Leaving Function (Returning %s)", bRetVal?"True":"False");
  464. return bRetVal;
  465. } // AddRules()
  466. /////////////////////////////////////////////////////////////////////////////////
  467. bool MBIMAggregationTestFixtureConf11::AddRulesDeaggregation() {
  468. m_eIP = IPA_IP_v4;
  469. const char aBypass[20] = "Bypass1";
  470. uint32_t nTableHdl;
  471. bool bRetVal = true;
  472. IPAFilteringTable cFilterTable0;
  473. struct ipa_flt_rule_add sFilterRuleEntry;
  474. struct ipa_ioc_get_hdr sGetHeader;
  475. uint8_t aHeadertoAdd[4];
  476. int hdrSize;
  477. if (mGenericAgg) {
  478. hdrSize = 4;
  479. aHeadertoAdd[0] = 0x49;
  480. aHeadertoAdd[1] = 0x50;
  481. aHeadertoAdd[2] = 0x53;
  482. aHeadertoAdd[3] = 0x00;
  483. }
  484. else {
  485. hdrSize = 1;
  486. aHeadertoAdd[0] = 0x00;
  487. }
  488. LOG_MSG_STACK("Entering Function");
  489. memset(&sFilterRuleEntry, 0, sizeof(sFilterRuleEntry));
  490. memset(&sGetHeader, 0, sizeof(sGetHeader));
  491. // Create Header:
  492. // Allocate Memory, populate it, and add in to the Header Insertion.
  493. struct ipa_ioc_add_hdr * pHeaderDescriptor = NULL;
  494. pHeaderDescriptor = (struct ipa_ioc_add_hdr *) calloc(1,
  495. sizeof(struct ipa_ioc_add_hdr)
  496. + 1 * sizeof(struct ipa_hdr_add));
  497. if (!pHeaderDescriptor) {
  498. LOG_MSG_ERROR("calloc failed to allocate pHeaderDescriptor");
  499. bRetVal = false;
  500. goto bail;
  501. }
  502. pHeaderDescriptor->commit = true;
  503. pHeaderDescriptor->num_hdrs = 1;
  504. // Adding Header No1.
  505. strlcpy(pHeaderDescriptor->hdr[0].name, "StreamId0", sizeof(pHeaderDescriptor->hdr[0].name)); // Header's Name
  506. memcpy(pHeaderDescriptor->hdr[0].hdr, (void*)&aHeadertoAdd,
  507. hdrSize); //Header's Data
  508. pHeaderDescriptor->hdr[0].hdr_len = hdrSize;
  509. pHeaderDescriptor->hdr[0].hdr_hdl = -1; //Return Value
  510. pHeaderDescriptor->hdr[0].is_partial = false;
  511. pHeaderDescriptor->hdr[0].status = -1; // Return Parameter
  512. strlcpy(sGetHeader.name, pHeaderDescriptor->hdr[0].name, sizeof(sGetHeader.name));
  513. if (!m_HeaderInsertion.AddHeader(pHeaderDescriptor))
  514. {
  515. LOG_MSG_ERROR("m_HeaderInsertion.AddHeader(pHeaderDescriptor) Failed.");
  516. bRetVal = false;
  517. goto bail;
  518. }
  519. if (!m_HeaderInsertion.GetHeaderHandle(&sGetHeader))
  520. {
  521. LOG_MSG_ERROR(" Failed");
  522. bRetVal = false;
  523. goto bail;
  524. }
  525. LOG_MSG_DEBUG("Received Header Handle = 0x%x", sGetHeader.hdl);
  526. if (!CreateBypassRoutingTable(&m_Routing, m_eIP, aBypass, IPA_CLIENT_TEST3_CONS,
  527. sGetHeader.hdl,&nTableHdl)) {
  528. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  529. bRetVal = false;
  530. goto bail;
  531. }
  532. LOG_MSG_INFO("Creation of bypass routing table completed successfully");
  533. // Creating Filtering Rules
  534. cFilterTable0.Init(m_eIP,IPA_CLIENT_TEST2_PROD, false, 1);
  535. LOG_MSG_INFO("Creation of filtering table completed successfully");
  536. // Configuring Filtering Rule No.1
  537. cFilterTable0.GeneratePresetRule(1,sFilterRuleEntry);
  538. sFilterRuleEntry.at_rear = true;
  539. sFilterRuleEntry.flt_rule_hdl=-1; // return Value
  540. sFilterRuleEntry.status = -1; // return value
  541. sFilterRuleEntry.rule.action=IPA_PASS_TO_ROUTING;
  542. sFilterRuleEntry.rule.rt_tbl_hdl=nTableHdl; //put here the handle corresponding to Routing Rule 1
  543. sFilterRuleEntry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; // Destination IP Based Filtering
  544. sFilterRuleEntry.rule.attrib.u.v4.dst_addr_mask = 0xFF0000FF; // Mask
  545. sFilterRuleEntry.rule.attrib.u.v4.dst_addr = 0x7F000001; // Filter DST_IP == 127.0.0.1.
  546. if (
  547. ((uint8_t)-1 == cFilterTable0.AddRuleToTable(sFilterRuleEntry)) ||
  548. !m_Filtering.AddFilteringRule(cFilterTable0.GetFilteringTable())
  549. )
  550. {
  551. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  552. bRetVal = false;
  553. goto bail;
  554. } else
  555. {
  556. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable0.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable0.ReadRuleFromTable(0)->status);
  557. }
  558. bail:
  559. Free(pHeaderDescriptor);
  560. LOG_MSG_STACK(
  561. "Leaving Function (Returning %s)", bRetVal?"True":"False");
  562. return bRetVal;
  563. } // AddRules()
  564. /////////////////////////////////////////////////////////////////////////////////
  565. bool MBIMAggregationTestFixtureConf11::AddRules1HeaderAggregationTime() {
  566. m_eIP = IPA_IP_v4;
  567. const char aBypass[20] = "Bypass1";
  568. uint32_t nTableHdl;
  569. bool bRetVal = true;
  570. IPAFilteringTable cFilterTable0;
  571. struct ipa_flt_rule_add sFilterRuleEntry;
  572. struct ipa_ioc_get_hdr sGetHeader;
  573. uint8_t aHeadertoAdd[4];
  574. int hdrSize;
  575. if (mGenericAgg) {
  576. hdrSize = 4;
  577. aHeadertoAdd[0] = 0x49;
  578. aHeadertoAdd[1] = 0x50;
  579. aHeadertoAdd[2] = 0x53;
  580. aHeadertoAdd[3] = 0x00;
  581. }
  582. else {
  583. hdrSize = 1;
  584. aHeadertoAdd[0] = 0x00;
  585. }
  586. LOG_MSG_STACK("Entering Function");
  587. memset(&sFilterRuleEntry, 0, sizeof(sFilterRuleEntry));
  588. memset(&sGetHeader, 0, sizeof(sGetHeader));
  589. // Create Header:
  590. // Allocate Memory, populate it, and add in to the Header Insertion.
  591. struct ipa_ioc_add_hdr * pHeaderDescriptor = NULL;
  592. pHeaderDescriptor = (struct ipa_ioc_add_hdr *) calloc(1,
  593. sizeof(struct ipa_ioc_add_hdr)
  594. + 1 * sizeof(struct ipa_hdr_add));
  595. if (!pHeaderDescriptor) {
  596. LOG_MSG_ERROR("calloc failed to allocate pHeaderDescriptor");
  597. bRetVal = false;
  598. goto bail;
  599. }
  600. pHeaderDescriptor->commit = true;
  601. pHeaderDescriptor->num_hdrs = 1;
  602. // Adding Header No1.
  603. strlcpy(pHeaderDescriptor->hdr[0].name, "StreamId0", sizeof(pHeaderDescriptor->hdr[0].name)); // Header's Name
  604. memcpy(pHeaderDescriptor->hdr[0].hdr, (void*)&aHeadertoAdd,
  605. hdrSize); //Header's Data
  606. pHeaderDescriptor->hdr[0].hdr_len = hdrSize;
  607. pHeaderDescriptor->hdr[0].hdr_hdl = -1; //Return Value
  608. pHeaderDescriptor->hdr[0].is_partial = false;
  609. pHeaderDescriptor->hdr[0].status = -1; // Return Parameter
  610. strlcpy(sGetHeader.name, pHeaderDescriptor->hdr[0].name, sizeof(sGetHeader.name));
  611. if (!m_HeaderInsertion.AddHeader(pHeaderDescriptor))
  612. {
  613. LOG_MSG_ERROR("m_HeaderInsertion.AddHeader(pHeaderDescriptor) Failed.");
  614. bRetVal = false;
  615. goto bail;
  616. }
  617. if (!m_HeaderInsertion.GetHeaderHandle(&sGetHeader))
  618. {
  619. LOG_MSG_ERROR(" Failed");
  620. bRetVal = false;
  621. goto bail;
  622. }
  623. LOG_MSG_DEBUG("Received Header Handle = 0x%x", sGetHeader.hdl);
  624. if (!CreateBypassRoutingTable(&m_Routing, m_eIP, aBypass, IPA_CLIENT_TEST_CONS,
  625. sGetHeader.hdl,&nTableHdl)) {
  626. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  627. bRetVal = false;
  628. goto bail;
  629. }
  630. LOG_MSG_INFO("Creation of bypass routing table completed successfully");
  631. // Creating Filtering Rules
  632. cFilterTable0.Init(m_eIP,IPA_CLIENT_TEST_PROD, false, 1);
  633. LOG_MSG_INFO("Creation of filtering table completed successfully");
  634. // Configuring Filtering Rule No.1
  635. cFilterTable0.GeneratePresetRule(1,sFilterRuleEntry);
  636. sFilterRuleEntry.at_rear = true;
  637. sFilterRuleEntry.flt_rule_hdl=-1; // return Value
  638. sFilterRuleEntry.status = -1; // return value
  639. sFilterRuleEntry.rule.action=IPA_PASS_TO_ROUTING;
  640. sFilterRuleEntry.rule.rt_tbl_hdl=nTableHdl; //put here the handle corresponding to Routing Rule 1
  641. sFilterRuleEntry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; // Destination IP Based Filtering
  642. sFilterRuleEntry.rule.attrib.u.v4.dst_addr_mask = 0xFF0000FF; // Mask
  643. sFilterRuleEntry.rule.attrib.u.v4.dst_addr = 0x7F000001; // Filter DST_IP == 127.0.0.1.
  644. if (
  645. ((uint8_t)-1 == cFilterTable0.AddRuleToTable(sFilterRuleEntry)) ||
  646. !m_Filtering.AddFilteringRule(cFilterTable0.GetFilteringTable())
  647. )
  648. {
  649. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  650. bRetVal = false;
  651. goto bail;
  652. } else
  653. {
  654. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable0.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable0.ReadRuleFromTable(0)->status);
  655. }
  656. bail:
  657. Free(pHeaderDescriptor);
  658. LOG_MSG_STACK(
  659. "Leaving Function (Returning %s)", bRetVal?"True":"False");
  660. return bRetVal;
  661. } // AddRules()
  662. /////////////////////////////////////////////////////////////////////////////////
  663. bool MBIMAggregationTestFixtureConf11::AddRules1HeaderAggregation0Limits() {
  664. m_eIP = IPA_IP_v4;
  665. const char aBypass[20] = "Bypass1";
  666. uint32_t nTableHdl;
  667. bool bRetVal = true;
  668. IPAFilteringTable cFilterTable0;
  669. struct ipa_flt_rule_add sFilterRuleEntry;
  670. struct ipa_ioc_get_hdr sGetHeader;
  671. uint8_t aHeadertoAdd[4];
  672. int hdrSize;
  673. if (mGenericAgg) {
  674. hdrSize = 4;
  675. aHeadertoAdd[0] = 0x49;
  676. aHeadertoAdd[1] = 0x50;
  677. aHeadertoAdd[2] = 0x53;
  678. aHeadertoAdd[3] = 0x00;
  679. }
  680. else {
  681. hdrSize = 1;
  682. aHeadertoAdd[0] = 0x00;
  683. }
  684. LOG_MSG_STACK("Entering Function");
  685. memset(&sFilterRuleEntry, 0, sizeof(sFilterRuleEntry));
  686. memset(&sGetHeader, 0, sizeof(sGetHeader));
  687. // Create Header:
  688. // Allocate Memory, populate it, and add in to the Header Insertion.
  689. struct ipa_ioc_add_hdr * pHeaderDescriptor = NULL;
  690. pHeaderDescriptor = (struct ipa_ioc_add_hdr *) calloc(1,
  691. sizeof(struct ipa_ioc_add_hdr)
  692. + 1 * sizeof(struct ipa_hdr_add));
  693. if (!pHeaderDescriptor) {
  694. LOG_MSG_ERROR("calloc failed to allocate pHeaderDescriptor");
  695. bRetVal = false;
  696. goto bail;
  697. }
  698. pHeaderDescriptor->commit = true;
  699. pHeaderDescriptor->num_hdrs = 1;
  700. // Adding Header No1.
  701. strlcpy(pHeaderDescriptor->hdr[0].name, "StreamId0", sizeof(pHeaderDescriptor->hdr[0].name)); // Header's Name
  702. memcpy(pHeaderDescriptor->hdr[0].hdr, (void*)&aHeadertoAdd,
  703. hdrSize); //Header's Data
  704. pHeaderDescriptor->hdr[0].hdr_len = hdrSize;
  705. pHeaderDescriptor->hdr[0].hdr_hdl = -1; //Return Value
  706. pHeaderDescriptor->hdr[0].is_partial = false;
  707. pHeaderDescriptor->hdr[0].status = -1; // Return Parameter
  708. strlcpy(sGetHeader.name, pHeaderDescriptor->hdr[0].name, sizeof(sGetHeader.name));
  709. if (!m_HeaderInsertion.AddHeader(pHeaderDescriptor))
  710. {
  711. LOG_MSG_ERROR("m_HeaderInsertion.AddHeader(pHeaderDescriptor) Failed.");
  712. bRetVal = false;
  713. goto bail;
  714. }
  715. if (!m_HeaderInsertion.GetHeaderHandle(&sGetHeader))
  716. {
  717. LOG_MSG_ERROR(" Failed");
  718. bRetVal = false;
  719. goto bail;
  720. }
  721. LOG_MSG_DEBUG("Received Header Handle = 0x%x", sGetHeader.hdl);
  722. if (!CreateBypassRoutingTable(&m_Routing, m_eIP, aBypass, IPA_CLIENT_TEST4_CONS,
  723. sGetHeader.hdl,&nTableHdl)) {
  724. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  725. bRetVal = false;
  726. goto bail;
  727. }
  728. LOG_MSG_INFO("Creation of bypass routing table completed successfully");
  729. // Creating Filtering Rules
  730. cFilterTable0.Init(m_eIP,IPA_CLIENT_TEST_PROD, false, 1);
  731. LOG_MSG_INFO("Creation of filtering table completed successfully");
  732. // Configuring Filtering Rule No.1
  733. cFilterTable0.GeneratePresetRule(1,sFilterRuleEntry);
  734. sFilterRuleEntry.at_rear = true;
  735. sFilterRuleEntry.flt_rule_hdl=-1; // return Value
  736. sFilterRuleEntry.status = -1; // return value
  737. sFilterRuleEntry.rule.action=IPA_PASS_TO_ROUTING;
  738. sFilterRuleEntry.rule.rt_tbl_hdl=nTableHdl; //put here the handle corresponding to Routing Rule 1
  739. sFilterRuleEntry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; // Destination IP Based Filtering
  740. sFilterRuleEntry.rule.attrib.u.v4.dst_addr_mask = 0xFF0000FF; // Mask
  741. sFilterRuleEntry.rule.attrib.u.v4.dst_addr = 0x7F000001; // Filter DST_IP == 127.0.0.1.
  742. if (
  743. ((uint8_t)-1 == cFilterTable0.AddRuleToTable(sFilterRuleEntry)) ||
  744. !m_Filtering.AddFilteringRule(cFilterTable0.GetFilteringTable())
  745. )
  746. {
  747. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  748. bRetVal = false;
  749. goto bail;
  750. } else
  751. {
  752. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable0.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable0.ReadRuleFromTable(0)->status);
  753. }
  754. bail:
  755. Free(pHeaderDescriptor);
  756. LOG_MSG_STACK(
  757. "Leaving Function (Returning %s)", bRetVal?"True":"False");
  758. return bRetVal;
  759. } // AddRules()
  760. bool MBIMAggregationTestFixtureConf11::AddRulesAggDualFC(Pipe *input, Pipe *output1, Pipe *output2) {
  761. m_eIP = IPA_IP_v4;
  762. const char aBypass[2][20] = {"BypassTest2", "BypassTest4"};
  763. uint32_t nTableHdl[2];
  764. bool bRetVal = true;
  765. IPAFilteringTable_v2 cFilterTable0;
  766. struct ipa_flt_rule_add_v2 sFilterRuleEntry;
  767. struct ipa_ioc_get_hdr sGetHeader;
  768. uint8_t aHeadertoAdd[4];
  769. int hdrSize;
  770. if (mGenericAgg) {
  771. hdrSize = 4;
  772. aHeadertoAdd[0]= 0x49;
  773. aHeadertoAdd[1] = 0x50;
  774. aHeadertoAdd[2] = 0x53;
  775. aHeadertoAdd[3] = 0x00;
  776. } else {
  777. hdrSize = 1;
  778. aHeadertoAdd[0] = 0x00;
  779. }
  780. LOG_MSG_STACK("Entering Function");
  781. memset(&sFilterRuleEntry, 0, sizeof(sFilterRuleEntry));
  782. memset(&sGetHeader, 0, sizeof(sGetHeader));
  783. // Create Header:
  784. // Allocate Memory, populate it, and add in to the Header Insertion.
  785. struct ipa_ioc_add_hdr * pHeaderDescriptor = NULL;
  786. pHeaderDescriptor = (struct ipa_ioc_add_hdr *) calloc(1,
  787. sizeof(struct ipa_ioc_add_hdr)
  788. + 1 * sizeof(struct ipa_hdr_add));
  789. if (!pHeaderDescriptor) {
  790. LOG_MSG_ERROR("calloc failed to allocate pHeaderDescriptor");
  791. bRetVal = false;
  792. goto bail;
  793. }
  794. pHeaderDescriptor->commit = true;
  795. pHeaderDescriptor->num_hdrs = 1;
  796. // Adding Header No1.
  797. strlcpy(pHeaderDescriptor->hdr[0].name, "StreamId0", sizeof(pHeaderDescriptor->hdr[0].name)); // Header's Name
  798. memcpy(pHeaderDescriptor->hdr[0].hdr, aHeadertoAdd, hdrSize); //Header's Data
  799. pHeaderDescriptor->hdr[0].hdr_len = hdrSize;
  800. pHeaderDescriptor->hdr[0].hdr_hdl = -1; //Return Value
  801. pHeaderDescriptor->hdr[0].is_partial = false;
  802. pHeaderDescriptor->hdr[0].status = -1; // Return Parameter
  803. strlcpy(sGetHeader.name, pHeaderDescriptor->hdr[0].name, sizeof(sGetHeader.name));
  804. if (!m_HeaderInsertion.AddHeader(pHeaderDescriptor))
  805. {
  806. LOG_MSG_ERROR("m_HeaderInsertion.AddHeader(pHeaderDescriptor) Failed.");
  807. bRetVal = false;
  808. goto bail;
  809. }
  810. if (!m_HeaderInsertion.GetHeaderHandle(&sGetHeader))
  811. {
  812. LOG_MSG_ERROR(" Failed");
  813. bRetVal = false;
  814. goto bail;
  815. }
  816. LOG_MSG_DEBUG("Received Header Handle = 0x%x", sGetHeader.hdl);
  817. if (!CreateBypassRoutingTable_v2(&m_Routing, m_eIP, aBypass[0],
  818. output1->GetClientType(),
  819. sGetHeader.hdl, &nTableHdl[0], 0)) {
  820. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  821. bRetVal = false;
  822. goto bail;
  823. }
  824. if (!CreateBypassRoutingTable_v2(&m_Routing, m_eIP, aBypass[1],
  825. output2->GetClientType(),
  826. sGetHeader.hdl, &nTableHdl[1], 0)) {
  827. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  828. bRetVal = false;
  829. goto bail;
  830. }
  831. LOG_MSG_INFO("Creation of bypass routing tables completed successfully");
  832. // Creating Filtering Rules
  833. cFilterTable0.Init(m_eIP,input->GetClientType(), false, 2);
  834. LOG_MSG_INFO("Creation of filtering table completed successfully");
  835. // Configuring Filtering Rule No.1
  836. cFilterTable0.GeneratePresetRule(1,sFilterRuleEntry);
  837. sFilterRuleEntry.at_rear = true;
  838. sFilterRuleEntry.flt_rule_hdl=-1; // return Value
  839. sFilterRuleEntry.status = -1; // return value
  840. sFilterRuleEntry.rule.action=IPA_PASS_TO_ROUTING;
  841. sFilterRuleEntry.rule.rt_tbl_hdl = nTableHdl[0]; //put here the handle corresponding to Routing Rule 1
  842. sFilterRuleEntry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; // Destination IP Based Filtering
  843. sFilterRuleEntry.rule.attrib.u.v4.dst_addr_mask = 0xFF0000FF; // Mask
  844. sFilterRuleEntry.rule.attrib.u.v4.dst_addr = 0x7F000001; // Filter DST_IP == 127.0.0.1.
  845. sFilterRuleEntry.rule.close_aggr_irq_mod = 1;
  846. if (
  847. ((uint8_t)-1 == cFilterTable0.AddRuleToTable(sFilterRuleEntry)) ||
  848. !m_Filtering.AddFilteringRule(cFilterTable0.GetFilteringTable())
  849. )
  850. {
  851. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  852. bRetVal = false;
  853. goto bail;
  854. } else
  855. {
  856. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable0.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable0.ReadRuleFromTable(0)->status);
  857. }
  858. // Configuring Filtering Rule No.2
  859. cFilterTable0.GeneratePresetRule(1,sFilterRuleEntry);
  860. sFilterRuleEntry.at_rear = true;
  861. sFilterRuleEntry.flt_rule_hdl=-1; // return Value
  862. sFilterRuleEntry.status = -1; // return value
  863. sFilterRuleEntry.rule.action=IPA_PASS_TO_ROUTING;
  864. sFilterRuleEntry.rule.rt_tbl_hdl = nTableHdl[1]; //put here the handle corresponding to Routing Rule 1
  865. sFilterRuleEntry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; // Destination IP Based Filtering
  866. sFilterRuleEntry.rule.attrib.u.v4.dst_addr_mask = 0xFF0000FF; // Mask
  867. sFilterRuleEntry.rule.attrib.u.v4.dst_addr = 0x7F000002; // Filter DST_IP == 127.0.0.1.
  868. sFilterRuleEntry.rule.close_aggr_irq_mod = 0;
  869. if (
  870. ((uint8_t)-1 == cFilterTable0.AddRuleToTable(sFilterRuleEntry)) ||
  871. !m_Filtering.AddFilteringRule(cFilterTable0.GetFilteringTable())
  872. )
  873. {
  874. LOG_MSG_ERROR ("Adding Rule (1) to Filtering block Failed.");
  875. bRetVal = false;
  876. goto bail;
  877. } else
  878. {
  879. LOG_MSG_DEBUG("flt rule hdl1=0x%x, status=0x%x\n", cFilterTable0.ReadRuleFromTable(1)->flt_rule_hdl,cFilterTable0.ReadRuleFromTable(1)->status);
  880. }
  881. bail:
  882. Free(pHeaderDescriptor);
  883. LOG_MSG_STACK(
  884. "Leaving Function (Returning %s)", bRetVal?"True":"False");
  885. return bRetVal;
  886. } // AddRulesAggDualFC()
  887. bool MBIMAggregationTestFixtureConf11::AddRulesAggDualFcRoutingBased(Pipe *input, Pipe *output1, Pipe *output2) {
  888. m_eIP = IPA_IP_v4;
  889. const char aBypass[2][20] = {"BypassTest2", "BypassTest4"};
  890. uint32_t nTableHdl[2];
  891. bool bRetVal = true;
  892. IPAFilteringTable_v2 cFilterTable0;
  893. struct ipa_flt_rule_add_v2 sFilterRuleEntry;
  894. struct ipa_ioc_get_hdr sGetHeader;
  895. uint8_t aHeadertoAdd[4];
  896. int hdrSize;
  897. if (mGenericAgg) {
  898. hdrSize = 4;
  899. aHeadertoAdd[0]= 0x49;
  900. aHeadertoAdd[1] = 0x50;
  901. aHeadertoAdd[2] = 0x53;
  902. aHeadertoAdd[3] = 0x00;
  903. } else {
  904. hdrSize = 1;
  905. aHeadertoAdd[0] = 0x00;
  906. }
  907. LOG_MSG_STACK("Entering Function");
  908. memset(&sFilterRuleEntry, 0, sizeof(sFilterRuleEntry));
  909. memset(&sGetHeader, 0, sizeof(sGetHeader));
  910. // Create Header:
  911. // Allocate Memory, populate it, and add in to the Header Insertion.
  912. struct ipa_ioc_add_hdr * pHeaderDescriptor = NULL;
  913. pHeaderDescriptor = (struct ipa_ioc_add_hdr *) calloc(1,
  914. sizeof(struct ipa_ioc_add_hdr)
  915. + 1 * sizeof(struct ipa_hdr_add));
  916. if (!pHeaderDescriptor) {
  917. LOG_MSG_ERROR("calloc failed to allocate pHeaderDescriptor");
  918. bRetVal = false;
  919. goto bail;
  920. }
  921. pHeaderDescriptor->commit = true;
  922. pHeaderDescriptor->num_hdrs = 1;
  923. // Adding Header No1.
  924. strlcpy(pHeaderDescriptor->hdr[0].name, "StreamId0", sizeof(pHeaderDescriptor->hdr[0].name)); // Header's Name
  925. memcpy(pHeaderDescriptor->hdr[0].hdr, aHeadertoAdd, hdrSize); //Header's Data
  926. pHeaderDescriptor->hdr[0].hdr_len = hdrSize;
  927. pHeaderDescriptor->hdr[0].hdr_hdl = -1; //Return Value
  928. pHeaderDescriptor->hdr[0].is_partial = false;
  929. pHeaderDescriptor->hdr[0].status = -1; // Return Parameter
  930. strlcpy(sGetHeader.name, pHeaderDescriptor->hdr[0].name, sizeof(sGetHeader.name));
  931. if (!m_HeaderInsertion.AddHeader(pHeaderDescriptor))
  932. {
  933. LOG_MSG_ERROR("m_HeaderInsertion.AddHeader(pHeaderDescriptor) Failed.");
  934. bRetVal = false;
  935. goto bail;
  936. }
  937. if (!m_HeaderInsertion.GetHeaderHandle(&sGetHeader))
  938. {
  939. LOG_MSG_ERROR(" Failed");
  940. bRetVal = false;
  941. goto bail;
  942. }
  943. LOG_MSG_DEBUG("Received Header Handle = 0x%x", sGetHeader.hdl);
  944. if (!CreateBypassRoutingTable_v2(&m_Routing, m_eIP, aBypass[0],
  945. output1->GetClientType(),
  946. sGetHeader.hdl, &nTableHdl[0], 1)) {
  947. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  948. bRetVal = false;
  949. goto bail;
  950. }
  951. if (!CreateBypassRoutingTable_v2(&m_Routing, m_eIP, aBypass[1],
  952. output2->GetClientType(),
  953. sGetHeader.hdl, &nTableHdl[1], 0)) {
  954. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  955. bRetVal = false;
  956. goto bail;
  957. }
  958. LOG_MSG_INFO("Creation of bypass routing tables completed successfully");
  959. // Creating Filtering Rules
  960. cFilterTable0.Init(m_eIP,input->GetClientType(), false, 2);
  961. LOG_MSG_INFO("Creation of filtering table completed successfully");
  962. // Configuring Filtering Rule No.1
  963. cFilterTable0.GeneratePresetRule(1,sFilterRuleEntry);
  964. sFilterRuleEntry.at_rear = true;
  965. sFilterRuleEntry.flt_rule_hdl=-1; // return Value
  966. sFilterRuleEntry.status = -1; // return value
  967. sFilterRuleEntry.rule.action=IPA_PASS_TO_ROUTING;
  968. sFilterRuleEntry.rule.rt_tbl_hdl = nTableHdl[0]; //put here the handle corresponding to Routing Rule 1
  969. sFilterRuleEntry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; // Destination IP Based Filtering
  970. sFilterRuleEntry.rule.attrib.u.v4.dst_addr_mask = 0xFF0000FF; // Mask
  971. sFilterRuleEntry.rule.attrib.u.v4.dst_addr = 0x7F000001; // Filter DST_IP == 127.0.0.1.
  972. sFilterRuleEntry.rule.close_aggr_irq_mod = 0;
  973. if (
  974. ((uint8_t)-1 == cFilterTable0.AddRuleToTable(sFilterRuleEntry)) ||
  975. !m_Filtering.AddFilteringRule(cFilterTable0.GetFilteringTable())
  976. )
  977. {
  978. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  979. bRetVal = false;
  980. goto bail;
  981. } else
  982. {
  983. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable0.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable0.ReadRuleFromTable(0)->status);
  984. }
  985. // Configuring Filtering Rule No.2
  986. cFilterTable0.GeneratePresetRule(1,sFilterRuleEntry);
  987. sFilterRuleEntry.at_rear = true;
  988. sFilterRuleEntry.flt_rule_hdl=-1; // return Value
  989. sFilterRuleEntry.status = -1; // return value
  990. sFilterRuleEntry.rule.action=IPA_PASS_TO_ROUTING;
  991. sFilterRuleEntry.rule.rt_tbl_hdl = nTableHdl[1]; //put here the handle corresponding to Routing Rule 1
  992. sFilterRuleEntry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; // Destination IP Based Filtering
  993. sFilterRuleEntry.rule.attrib.u.v4.dst_addr_mask = 0xFF0000FF; // Mask
  994. sFilterRuleEntry.rule.attrib.u.v4.dst_addr = 0x7F000002; // Filter DST_IP == 127.0.0.1.
  995. sFilterRuleEntry.rule.close_aggr_irq_mod = 0;
  996. if (
  997. ((uint8_t)-1 == cFilterTable0.AddRuleToTable(sFilterRuleEntry)) ||
  998. !m_Filtering.AddFilteringRule(cFilterTable0.GetFilteringTable())
  999. )
  1000. {
  1001. LOG_MSG_ERROR ("Adding Rule (1) to Filtering block Failed.");
  1002. bRetVal = false;
  1003. goto bail;
  1004. } else
  1005. {
  1006. LOG_MSG_DEBUG("flt rule hdl1=0x%x, status=0x%x\n", cFilterTable0.ReadRuleFromTable(1)->flt_rule_hdl,cFilterTable0.ReadRuleFromTable(1)->status);
  1007. }
  1008. bail:
  1009. Free(pHeaderDescriptor);
  1010. LOG_MSG_STACK(
  1011. "Leaving Function (Returning %s)", bRetVal?"True":"False");
  1012. return bRetVal;
  1013. } // AddRulesAggDualFC()