HeaderProcessingContextTests.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. /*
  2. * Copyright (c) 2017-2019 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 "HeaderProcessingContextTestFixture.h"
  30. /*----------------------------------------------------------------------------*/
  31. /* Test00: Header insertion scenario of [RNDIS][ETH_II][IP] -> */
  32. /* [WLAN][ETH_II][IP] */
  33. /*----------------------------------------------------------------------------*/
  34. class IpaHdrProcCtxTest00 : public IpaHdrProcCtxTestFixture
  35. {
  36. public:
  37. IpaHdrProcCtxTest00()
  38. {
  39. m_name = "IpaHdrProcCtxTest00";
  40. m_description =
  41. "Processing Context test 00 - \
  42. of [RNDIS][ETH_II][IP] -> [WLAN][ETH_II][IP] \
  43. 1. Generate and commit all headers for all tests. \
  44. 2. Generate and commit all processing context rules \
  45. for all tests.\
  46. 3. Generate and commit routing table 0. \
  47. The table contains 1 \"bypass\" rule. \
  48. All data goes to output pipe TEST2. \
  49. Routing rule will use processing context ETH2_2_WLAN_ETH2 \
  50. 4. Generate and commit 1 filtering rule. \
  51. All traffic goes to routing table 0";
  52. m_pCurrentProducer = &m_rndisEth2Producer;
  53. m_currProducerClient = IPA_CLIENT_TEST_PROD;
  54. m_pCurrentConsumer = &m_defaultConsumer;
  55. m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
  56. m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_2_WLAN_ETH2;
  57. m_minIPAHwType = IPA_HW_v2_5;
  58. m_maxIPAHwType = IPA_HW_MAX;
  59. m_runInRegression = false;
  60. Register(*this);
  61. }
  62. virtual bool LoadPackets(enum ipa_ip_type ip)
  63. {
  64. if (!RNDISAggregationHelper::LoadRNDISPacket(
  65. ip,
  66. m_sendBuffer1,
  67. m_sendSize1))
  68. {
  69. LOG_MSG_ERROR("Failed default Packet\n");
  70. return false;
  71. }
  72. printf ("Loaded %zu Bytes to Packet 1\n",m_sendSize1);
  73. add_buff(m_sendBuffer1+RNDIS_HDR_SIZE, ETH_HLEN, 2);
  74. print_buff(m_sendBuffer1, m_sendSize1);
  75. return true;
  76. }
  77. virtual bool GenerateExpectedPackets()
  78. {
  79. m_expectedBufferSize1 = WLAN_ETH2_HDR_SIZE +
  80. IP4_PACKET_SIZE;
  81. // copy WLAN header to the beginning of the buffer
  82. memcpy(m_expectedBuffer1, WLAN_ETH2_HDR, WLAN_HDR_SIZE);
  83. // copy ETH+IP packet right after WLAN header
  84. memcpy(m_expectedBuffer1 + WLAN_HDR_SIZE,
  85. m_sendBuffer1 + RNDIS_HDR_SIZE,
  86. ETH_HLEN + IP4_PACKET_SIZE);
  87. return true;
  88. } // GenerateExpectedPackets()
  89. };
  90. /*----------------------------------------------------------------------------*/
  91. /* Test01: Header insertion scenario of [WLAN][ETH_II][IP] -> */
  92. /* [RNDIS][ETH_II][IP] */
  93. /*----------------------------------------------------------------------------*/
  94. class IpaHdrProcCtxTest01 : public IpaHdrProcCtxTestFixture
  95. {
  96. public:
  97. IpaHdrProcCtxTest01()
  98. {
  99. m_name = "IpaHdrProcCtxTest01";
  100. m_description =
  101. "Processing context test 01 - \
  102. of [WLAN][ETH_II][IP] -> [RNDIS][ETH_II][IP] \
  103. 1. Generate and commit all headers for all tests. \
  104. 2. Generate and commit all processing context rules \
  105. for all tests.\
  106. 3. Generate and commit routing table 0. \
  107. The table contains 1 \"bypass\" rule. \
  108. All data goes to output pipe TEST3. \
  109. Routing rule will use processing context ETH2_2_RNDIS_ETH2 \
  110. 4. Generate and commit 1 filtering rule. \
  111. All traffic goes to routing table 0";
  112. m_pCurrentProducer = &m_wlanEth2producer;
  113. m_currProducerClient = IPA_CLIENT_TEST2_PROD;
  114. m_pCurrentConsumer = &m_rndisEth2Consumer;
  115. m_currConsumerPipeNum = IPA_CLIENT_TEST3_CONS;
  116. m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_2_RNDIS_ETH2;
  117. m_minIPAHwType = IPA_HW_v2_5;
  118. m_maxIPAHwType = IPA_HW_MAX;
  119. m_runInRegression = false;
  120. Register(*this);
  121. }
  122. virtual bool LoadPackets(enum ipa_ip_type ip)
  123. {
  124. // load WLAN ETH2 IP4 packet of size 1kB + 1 byte
  125. // This size will trigger RNDIS aggregation later
  126. m_sendSize1 =
  127. RNDISAggregationHelper::RNDIS_AGGREGATION_BYTE_LIMIT + 1;
  128. if (!WlanHelper::LoadWlanEth2IP4PacketByLength(
  129. m_sendBuffer1,
  130. m_BUFF_MAX_SIZE,
  131. m_sendSize1,
  132. 0x01))
  133. return false;
  134. printf ("Loaded %zu Bytes to Packet 1\n",m_sendSize1);
  135. add_buff(m_sendBuffer1+WLAN_HDR_SIZE, ETH_HLEN, 3);
  136. print_buff(m_sendBuffer1, m_sendSize1);
  137. return true;
  138. }
  139. virtual bool GenerateExpectedPackets()
  140. {
  141. size_t len = 0;
  142. size_t eth2PacketSize = m_sendSize1 - WLAN_HDR_SIZE;
  143. m_expectedBufferSize1 = eth2PacketSize + RNDIS_HDR_SIZE;
  144. // copy RNDIS header
  145. if (!RNDISAggregationHelper::LoadRNDISHeader(
  146. m_expectedBuffer1,
  147. m_BUFF_MAX_SIZE,
  148. m_expectedBufferSize1,
  149. &len))
  150. {
  151. LOG_MSG_ERROR("Failed default Packet\n");
  152. return false;
  153. }
  154. // copy ETH2 packet after RNDIS header
  155. memcpy(m_expectedBuffer1 + len,
  156. m_sendBuffer1 + WLAN_HDR_SIZE,
  157. eth2PacketSize);
  158. return true;
  159. } // GenerateExpectedPackets()
  160. };
  161. /*----------------------------------------------------------------------------*/
  162. /* Test02: Header insertion scenario of [WLAN][ETH_II][IP] -> */
  163. /* [WLAN'][ETH_II][IP] */
  164. /*----------------------------------------------------------------------------*/
  165. class IpaHdrProcCtxTest02 : public IpaHdrProcCtxTestFixture
  166. {
  167. public:
  168. IpaHdrProcCtxTest02()
  169. {
  170. m_name = "IpaHdrProcCtxTest02";
  171. m_description =
  172. "Processing context test 02 - \
  173. of [WLAN][ETH_II][IP] -> [WLAN'][ETH_II][IP] \
  174. 1. Generate and commit all headers for all tests. \
  175. 2. Generate and commit all processing context rules \
  176. for all tests.\
  177. 3. Generate and commit routing table 0. \
  178. The table contains 1 \"bypass\" rule. \
  179. All data goes to output pipe TEST2. \
  180. Routing rule will use processing context ETH2_2_WLAN_ETH2 \
  181. 4. Generate and commit 1 filtering rule. \
  182. All traffic goes to routing table 0";
  183. m_pCurrentProducer = &m_wlanEth2producer;
  184. m_currProducerClient = IPA_CLIENT_TEST2_PROD;
  185. m_pCurrentConsumer = &m_defaultConsumer;
  186. m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
  187. m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_2_WLAN_ETH2;
  188. m_minIPAHwType = IPA_HW_v2_5;
  189. m_maxIPAHwType = IPA_HW_MAX;
  190. m_runInRegression = false;
  191. Register(*this);
  192. }
  193. virtual bool LoadPackets(enum ipa_ip_type ip)
  194. {
  195. // load WLAN ETH2 IP4 packet of size 1kB
  196. // This size will trigger RNDIS aggregation later
  197. if (!WlanHelper::LoadWlanEth2IP4Packet(
  198. m_sendBuffer1,
  199. m_BUFF_MAX_SIZE,
  200. &m_sendSize1))
  201. return false;
  202. printf ("Loaded %zu Bytes to Packet 1\n",m_sendSize1);
  203. add_buff(m_sendBuffer1+WLAN_HDR_SIZE, ETH_HLEN, 5);
  204. return true;
  205. }
  206. virtual bool GenerateExpectedPackets()
  207. {
  208. m_expectedBufferSize1 = m_sendSize1;
  209. memcpy(m_expectedBuffer1, m_sendBuffer1, m_expectedBufferSize1);
  210. memcpy(m_expectedBuffer1, WLAN_ETH2_HDR, WLAN_HDR_SIZE);
  211. return true;
  212. } // GenerateExpectedPackets()
  213. };
  214. /*----------------------------------------------------------------------------*/
  215. /* Test03: Header insertion scenario of [WLAN][ETH_II][IP] -> */
  216. /* [RNDIS][ETH_II][IP] with RNDIS aggregation */
  217. /*----------------------------------------------------------------------------*/
  218. class IpaHdrProcCtxTest03 : public IpaHdrProcCtxTestFixture
  219. {
  220. public:
  221. IpaHdrProcCtxTest03()
  222. {
  223. m_name = "IpaHdrProcCtxTest03";
  224. m_description =
  225. "Processing Context test 03 - \
  226. of [RNDIS][ETH_II][IP] -> [WLAN][ETH_II][IP] \
  227. with RNDIS aggregation \
  228. 1. Generate and commit all headers for all tests. \
  229. 2. Generate and commit all processing context rules \
  230. for all tests.\
  231. 3. Generate and commit routing table 0. \
  232. The table contains 1 \"bypass\" rule. \
  233. All data goes to output pipe TEST3. \
  234. Routing rule will use processing context ETH2_2_RNDIS_ETH2 \
  235. 4. Generate and commit 1 filtering rule. \
  236. All traffic goes to routing table 0";
  237. m_pCurrentProducer = &m_wlanEth2producer;
  238. m_currProducerClient = IPA_CLIENT_TEST2_PROD;
  239. m_pCurrentConsumer = &m_rndisEth2Consumer;
  240. m_currConsumerPipeNum = IPA_CLIENT_TEST3_CONS;
  241. m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_2_RNDIS_ETH2;
  242. m_minIPAHwType = IPA_HW_v2_5;
  243. m_maxIPAHwType = IPA_HW_MAX;
  244. m_runInRegression = false;
  245. Register(*this);
  246. }
  247. virtual bool LoadPackets(enum ipa_ip_type ip)
  248. {
  249. // choose this size so that 2 such buffers would be aggregated
  250. m_sendSize1 = RNDISAggregationHelper::
  251. RNDIS_AGGREGATION_BYTE_LIMIT / 2 + 200;
  252. if (!WlanHelper::LoadWlanEth2IP4PacketByLength(
  253. m_sendBuffer1,
  254. m_BUFF_MAX_SIZE,
  255. m_sendSize1,
  256. 1))
  257. return false;
  258. printf ("Loaded %zu Bytes to Packet 1\n", m_sendSize1);
  259. add_buff(m_sendBuffer1+WLAN_HDR_SIZE, ETH_HLEN, 7);
  260. // choose this size so that 2 such buffers would be aggregated
  261. m_sendSize2 = RNDISAggregationHelper::
  262. RNDIS_AGGREGATION_BYTE_LIMIT / 2 + 200;
  263. if (!WlanHelper::LoadWlanEth2IP4PacketByLength(
  264. m_sendBuffer2,
  265. m_BUFF_MAX_SIZE,
  266. m_sendSize2,
  267. 2))
  268. return false;
  269. printf ("Loaded %zu Bytes to Packet 2\n", m_sendSize2);
  270. add_buff(m_sendBuffer2+WLAN_HDR_SIZE, ETH_HLEN, 11);
  271. return true;
  272. }
  273. virtual bool SendPackets()
  274. {
  275. bool isSuccess = false;
  276. // Send packet 1
  277. isSuccess = m_pCurrentProducer->SendData(
  278. m_sendBuffer1,
  279. m_sendSize1);
  280. if (false == isSuccess)
  281. {
  282. LOG_MSG_ERROR(
  283. "SendData Buffer 1 failed on producer %d\n", m_currProducerClient);
  284. return false;
  285. }
  286. // Send packet 2
  287. isSuccess = m_pCurrentProducer->SendData(
  288. m_sendBuffer2,
  289. m_sendSize2);
  290. if (false == isSuccess)
  291. {
  292. LOG_MSG_ERROR(
  293. "SendData Buffer 2 failed on producer %d\n", m_currProducerClient);
  294. return false;
  295. }
  296. return true;
  297. }
  298. virtual bool GenerateExpectedPackets()
  299. {
  300. size_t len = 0;
  301. size_t eth2PacketSize1 = m_sendSize1 - WLAN_HDR_SIZE;
  302. size_t rndisPacketSize1 = eth2PacketSize1 + RNDIS_HDR_SIZE;
  303. size_t eth2PacketSize2 = m_sendSize2 - WLAN_HDR_SIZE;
  304. size_t rndisPacketSize2 = eth2PacketSize2 + RNDIS_HDR_SIZE;
  305. Byte *currBuffLocation = NULL;
  306. m_expectedBufferSize1 = rndisPacketSize1 + rndisPacketSize2;
  307. currBuffLocation = m_expectedBuffer1;
  308. // copy first RNDIS header
  309. if (!RNDISAggregationHelper::LoadRNDISHeader(
  310. currBuffLocation,
  311. m_BUFF_MAX_SIZE,
  312. rndisPacketSize1,
  313. &len))
  314. return false;
  315. // copy ETH2 packet 1 after RNDIS header
  316. currBuffLocation += len;
  317. memcpy(currBuffLocation,
  318. m_sendBuffer1 + WLAN_HDR_SIZE,
  319. eth2PacketSize1);
  320. // copy second RNDIS header
  321. currBuffLocation += eth2PacketSize1;
  322. if (!RNDISAggregationHelper::LoadRNDISHeader(
  323. currBuffLocation,
  324. m_BUFF_MAX_SIZE - rndisPacketSize1,
  325. rndisPacketSize2,
  326. &len))
  327. return false;
  328. // copy ETH2 packet 2 after RNDIS header
  329. currBuffLocation += len;
  330. memcpy(currBuffLocation,
  331. m_sendBuffer2 + WLAN_HDR_SIZE,
  332. eth2PacketSize2);
  333. return true;
  334. } // GenerateExpectedPackets()
  335. };
  336. /*----------------------------------------------------------------------------*/
  337. /* Test04: Header insertion scenario when adding total header sizes > 2048 */
  338. /*----------------------------------------------------------------------------*/
  339. class IpaHdrProcCtxTest04 : public IpaHdrProcCtxTestFixture
  340. {
  341. public:
  342. IpaHdrProcCtxTest04()
  343. {
  344. m_name = "IpaHdrProcCtxTest04";
  345. m_description =
  346. "Processing context test 04 - \
  347. Header insertion scenario when adding \
  348. total header sizes > 2048 \
  349. 1. Generate and commit all headers for all tests. \
  350. 2. Generate and commit all processing context rules \
  351. for all tests.\
  352. 3. Generate and commit routing table 0. \
  353. The table contains 1 \"bypass\" rule. \
  354. All data goes to output pipe TEST2. \
  355. Routing rule will use header WLAN_ETH2 \
  356. 4. Generate and commit 1 filtering rule. \
  357. All traffic goes to routing table 0";
  358. m_pCurrentProducer = &m_wlanEth2producer;
  359. m_currProducerClient = IPA_CLIENT_TEST2_PROD;
  360. m_pCurrentConsumer = &m_defaultConsumer;
  361. m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
  362. m_minIPAHwType = IPA_HW_v2_5;
  363. m_maxIPAHwType = IPA_HW_MAX;
  364. m_runInRegression = false;
  365. Register(*this);
  366. }
  367. virtual void AddAllHeaders()
  368. {
  369. int cnt = 0;
  370. int allHeadersSize = 0;
  371. while (allHeadersSize <= m_ALL_HEADER_SIZE_LIMIT)
  372. {
  373. AddHeader(HEADER_HANDLE_ID_ETH2);
  374. /* header bins are power of 2 */
  375. allHeadersSize += ETH_HLEN + 2;
  376. cnt++;
  377. }
  378. AddHeader(HEADER_HANDLE_ID_WLAN_ETH2);
  379. }
  380. virtual bool AddRules()
  381. {
  382. printf("Entering %s, %s()\n",__FUNCTION__, __FILE__);
  383. AddAllHeaders();
  384. AddRtBypassRule(m_headerHandles[HEADER_HANDLE_ID_WLAN_ETH2], 0);
  385. AddFltBypassRule();
  386. printf("Leaving %s, %s()\n",__FUNCTION__, __FILE__);
  387. return true;
  388. }// AddRules()
  389. virtual bool LoadPackets(enum ipa_ip_type ip)
  390. {
  391. // load WLAN ETH2 IP4 packet of size 1kB
  392. // This size will trigger RNDIS aggregation later
  393. if (!WlanHelper::LoadWlanEth2IP4Packet(
  394. m_sendBuffer1,
  395. m_BUFF_MAX_SIZE,
  396. &m_sendSize1))
  397. return false;
  398. printf ("Loaded %zu Bytes to Packet 1\n",m_sendSize1);
  399. add_buff(m_sendBuffer1+WLAN_HDR_SIZE, ETH_HLEN, 13);
  400. return true;
  401. }
  402. virtual bool GenerateExpectedPackets()
  403. {
  404. m_expectedBufferSize1 = m_sendSize1;
  405. memcpy(m_expectedBuffer1, m_sendBuffer1, m_expectedBufferSize1);
  406. memcpy(m_expectedBuffer1, WLAN_ETH2_HDR, WLAN_ETH2_HDR_SIZE);
  407. return true;
  408. } // GenerateExpectedPackets()
  409. };
  410. /*----------------------------------------------------------------------------*/
  411. /* Test05: Header insertion scenario of [ETH_II_802_1Q][IP] -> */
  412. /* [ETH_II_802_1Q][IP] */
  413. /*----------------------------------------------------------------------------*/
  414. class IpaHdrProcCtxTest05 : public IpaHdrProcCtxTestFixture
  415. {
  416. public:
  417. IpaHdrProcCtxTest05()
  418. {
  419. m_name = "IpaHdrProcCtxTest05";
  420. m_description =
  421. "Processing Context test 05 - \
  422. of [ETH_II_802_1Q][IP] -> [ETH_II_802_1Q][IP] \
  423. 1. Generate and commit all headers for all tests. \
  424. 2. Generate and commit all processing context rules \
  425. for all tests.\
  426. 3. Generate and commit routing table 0. \
  427. The table contains 1 \"bypass\" rule. \
  428. All data goes to output pipe TEST2. \
  429. Routing rule will use processing context 802_1Q_2_802_1Q \
  430. 4. Generate and commit 1 filtering rule. \
  431. All traffic goes to routing table 0";
  432. /*
  433. * NOTE: we use the wlan + ETH header prod pipe since the header
  434. * length shall be equal to 8021Q ETH_II length
  435. */
  436. m_pCurrentProducer = &m_wlanEth2producer;
  437. m_currProducerClient = IPA_CLIENT_TEST2_PROD;
  438. m_pCurrentConsumer = &m_defaultConsumer;
  439. m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
  440. m_procCtxHandleId = PROC_CTX_HANDLE_ID_802_1Q_2_802_1Q;
  441. m_minIPAHwType = IPA_HW_v4_0;
  442. m_maxIPAHwType = IPA_HW_MAX;
  443. m_runInRegression = false;
  444. Register(*this);
  445. }
  446. virtual bool LoadPackets(enum ipa_ip_type ip)
  447. {
  448. if (!LoadDefault802_1Q(ip,
  449. m_sendBuffer1,
  450. m_sendSize1)) {
  451. LOG_MSG_ERROR("Failed default Packet\n");
  452. return false;
  453. }
  454. printf("Loaded %zu Bytes to Packet 1\n", m_sendSize1);
  455. // modify the MAC addresses only
  456. add_buff(m_sendBuffer1, 12, 14);
  457. //change vlan ID to 9
  458. m_sendBuffer1[15] = 0x9;
  459. print_buff(m_sendBuffer1, m_sendSize1);
  460. return true;
  461. }
  462. virtual bool GenerateExpectedPackets()
  463. {
  464. m_expectedBufferSize1 = m_sendSize1;
  465. // we actually expect the same packet to come out (but after uCP)
  466. memcpy(m_expectedBuffer1, m_sendBuffer1, m_expectedBufferSize1);
  467. return true;
  468. } // GenerateExpectedPackets()
  469. };
  470. /*----------------------------------------------------------------------------*/
  471. /* Test06: Header insertion scenario of [ETH_II][IP] -> */
  472. /* [ETH_II_802_1Q][IP] */
  473. /*----------------------------------------------------------------------------*/
  474. class IpaHdrProcCtxTest06 : public IpaHdrProcCtxTestFixture
  475. {
  476. public:
  477. IpaHdrProcCtxTest06()
  478. {
  479. m_name = "IpaHdrProcCtxTest06";
  480. m_description =
  481. "Processing Context test 06 - \
  482. of [ETH_II][IP] -> [ETH_II_802_1Q][IP] \
  483. 1. Generate and commit all headers for all tests. \
  484. 2. Generate and commit all processing context rules \
  485. for all tests.\
  486. 3. Generate and commit routing table 0. \
  487. The table contains 1 \"bypass\" rule. \
  488. All data goes to output pipe TEST2. \
  489. Routing rule will use processing context ETH2_2_802_1Q \
  490. 4. Generate and commit 1 filtering rule. \
  491. All traffic goes to routing table 0";
  492. m_pCurrentProducer = &m_eth2Producer;
  493. m_currProducerClient = IPA_CLIENT_TEST3_PROD;
  494. m_pCurrentConsumer = &m_defaultConsumer;
  495. m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
  496. m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_2_802_1Q;
  497. m_minIPAHwType = IPA_HW_v4_0;
  498. m_maxIPAHwType = IPA_HW_MAX;
  499. m_runInRegression = false;
  500. Register(*this);
  501. }
  502. virtual bool LoadPackets(enum ipa_ip_type ip)
  503. {
  504. if (!Eth2Helper::LoadEth2IP4Packet(
  505. m_sendBuffer1,
  506. m_BUFF_MAX_SIZE,
  507. &m_sendSize1)) {
  508. LOG_MSG_ERROR("Failed default Packet\n");
  509. return false;
  510. }
  511. printf("Loaded %zu Bytes to Packet 1\n", m_sendSize1);
  512. // modify the MAC addresses only
  513. add_buff(m_sendBuffer1, 12, 15);
  514. print_buff(m_sendBuffer1, m_sendSize1);
  515. return true;
  516. }
  517. virtual bool GenerateExpectedPackets()
  518. {
  519. size_t len;
  520. m_expectedBufferSize1 = ETH8021Q_HEADER_LEN +
  521. IP4_PACKET_SIZE;
  522. // copy the VLAN header to expected buffer
  523. memcpy(m_expectedBuffer1, ETH2_8021Q_HDR, ETH8021Q_HEADER_LEN);
  524. // fill src and dst mac and ethertype
  525. memcpy(m_expectedBuffer1, m_sendBuffer1, 2 * ETH_ALEN);
  526. memcpy(m_expectedBuffer1 + ETH8021Q_ETH_TYPE_OFFSET,
  527. m_sendBuffer1 + ETH2_ETH_TYPE_OFFSET, ETH2_ETH_TYPE_LEN);
  528. len = m_BUFF_MAX_SIZE - ETH8021Q_HEADER_LEN;
  529. if (!LoadDefaultPacket(IPA_IP_v4,
  530. m_expectedBuffer1 + ETH8021Q_HEADER_LEN,
  531. len)) {
  532. LOG_MSG_ERROR("Failed default Packet\n");
  533. return false;
  534. }
  535. return true;
  536. } // GenerateExpectedPackets()
  537. };
  538. /*----------------------------------------------------------------------------*/
  539. /* Test07: Header insertion scenario of [ETH_II_802_1Q][IP] -> */
  540. /* [ETH_II][IP] */
  541. /*----------------------------------------------------------------------------*/
  542. class IpaHdrProcCtxTest07 : public IpaHdrProcCtxTestFixture
  543. {
  544. public:
  545. IpaHdrProcCtxTest07()
  546. {
  547. m_name = "IpaHdrProcCtxTest07";
  548. m_description =
  549. "Processing Context test 07 - \
  550. of [ETH_II_802_1Q][IP] -> [ETH_II][IP] \
  551. 1. Generate and commit all headers for all tests. \
  552. 2. Generate and commit all processing context rules \
  553. for all tests.\
  554. 3. Generate and commit routing table 0. \
  555. The table contains 1 \"bypass\" rule. \
  556. All data goes to output pipe TEST2. \
  557. Routing rule will use processing context 802_1Q_2_ETH2 \
  558. 4. Generate and commit 1 filtering rule. \
  559. All traffic goes to routing table 0";
  560. m_pCurrentProducer = &m_wlanEth2producer;
  561. m_currProducerClient = IPA_CLIENT_TEST2_PROD;
  562. m_pCurrentConsumer = &m_defaultConsumer;
  563. m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
  564. m_procCtxHandleId = PROC_CTX_HANDLE_ID_802_1Q_2_ETH2;
  565. m_minIPAHwType = IPA_HW_v4_0;
  566. m_maxIPAHwType = IPA_HW_MAX;
  567. m_runInRegression = false;
  568. Register(*this);
  569. }
  570. virtual bool LoadPackets(enum ipa_ip_type ip)
  571. {
  572. if (!LoadDefault802_1Q(ip,
  573. m_sendBuffer1,
  574. m_sendSize1)) {
  575. LOG_MSG_ERROR("Failed default Packet\n");
  576. return false;
  577. }
  578. printf("Loaded %zu Bytes to Packet 1\n", m_sendSize1);
  579. // modify the MAC addresses only
  580. add_buff(m_sendBuffer1, ETH8021Q_METADATA_OFFSET, 16);
  581. print_buff(m_sendBuffer1, m_sendSize1);
  582. return true;
  583. }
  584. virtual bool GenerateExpectedPackets()
  585. {
  586. size_t len;
  587. m_expectedBufferSize1 = m_sendSize1 - ETH8021Q_8021Q_TAG_LEN;
  588. // copy the ETH2 header to expected buffer
  589. memcpy(m_expectedBuffer1, ETH2_HDR, ETH_HLEN);
  590. // fill src and dst mac and ethertype
  591. memcpy(m_expectedBuffer1, m_sendBuffer1, 2 * ETH_ALEN);
  592. memcpy(m_expectedBuffer1 + ETH2_ETH_TYPE_OFFSET,
  593. m_sendBuffer1 + ETH8021Q_ETH_TYPE_OFFSET,
  594. ETH2_ETH_TYPE_LEN);
  595. len = m_BUFF_MAX_SIZE - ETH_HLEN;
  596. if (!LoadDefaultPacket(IPA_IP_v4,
  597. m_expectedBuffer1 + ETH_HLEN,
  598. len)) {
  599. LOG_MSG_ERROR("Failed default Packet\n");
  600. return false;
  601. }
  602. return true;
  603. } // GenerateExpectedPackets()
  604. };
  605. /*----------------------------------------------------------------------------*/
  606. /* Test08: Header insertion scenario of [ETH_II][IP] -> */
  607. /* [ETH_II][IP] with generic ucp command */
  608. /*----------------------------------------------------------------------------*/
  609. class IpaHdrProcCtxTest08 : public IpaHdrProcCtxTestFixture
  610. {
  611. public:
  612. IpaHdrProcCtxTest08()
  613. {
  614. m_name = "IpaHdrProcCtxTest08";
  615. m_description =
  616. "Processing Context test 08 - \
  617. of [ETH_II][IP] -> [ETH_II][IP] with generic ucp \
  618. 1. Generate and commit all headers for all tests. \
  619. 2. Generate and commit all processing context rules \
  620. for all tests.\
  621. 3. Generate and commit routing table 0. \
  622. The table contains 1 \"bypass\" rule. \
  623. All data goes to output pipe TEST2. \
  624. Routing rule will use processing context ETH2_2_ETH2_EX \
  625. 4. Generate and commit 1 filtering rule. \
  626. All traffic goes to routing table 0";
  627. m_pCurrentProducer = &m_eth2Producer;
  628. m_currProducerClient = IPA_CLIENT_TEST3_PROD;
  629. m_pCurrentConsumer = &m_defaultConsumer;
  630. m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
  631. m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_ETH2_2_ETH2_EX;
  632. m_minIPAHwType = IPA_HW_v4_0;
  633. m_maxIPAHwType = IPA_HW_MAX;
  634. m_runInRegression = false;
  635. Register(*this);
  636. }
  637. virtual bool LoadPackets(enum ipa_ip_type ip)
  638. {
  639. if (!Eth2Helper::LoadEth2IP4Packet(
  640. m_sendBuffer1,
  641. m_BUFF_MAX_SIZE,
  642. &m_sendSize1)) {
  643. LOG_MSG_ERROR("Failed default Packet\n");
  644. return false;
  645. }
  646. printf("Loaded %zu Bytes to Packet 1\n", m_sendSize1);
  647. // modify the MAC addresses only
  648. add_buff(m_sendBuffer1, 12, 17);
  649. print_buff(m_sendBuffer1, m_sendSize1);
  650. return true;
  651. }
  652. virtual bool GenerateExpectedPackets()
  653. {
  654. m_expectedBufferSize1 = m_sendSize1;
  655. // we actually expect the same packet to come out (but after uCP)
  656. memcpy(m_expectedBuffer1, m_sendBuffer1, m_expectedBufferSize1);
  657. return true;
  658. } // GenerateExpectedPackets()
  659. };
  660. static IpaHdrProcCtxTest00 ipaHdrProcCtxTest00;
  661. static IpaHdrProcCtxTest01 ipaHdrProcCtxTest01;
  662. static IpaHdrProcCtxTest02 ipaHdrProcCtxTest02;
  663. static IpaHdrProcCtxTest03 ipaHdrProcCtxTest03;
  664. static IpaHdrProcCtxTest04 ipaHdrProcCtxTest04;
  665. static IpaHdrProcCtxTest05 ipaHdrProcCtxTest05;
  666. static IpaHdrProcCtxTest06 ipaHdrProcCtxTest06;
  667. static IpaHdrProcCtxTest07 ipaHdrProcCtxTest07;
  668. static IpaHdrProcCtxTest08 ipaHdrProcCtxTest08;