123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780 |
- /*
- * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- #include "HeaderProcessingContextTestFixture.h"
- /*----------------------------------------------------------------------------*/
- /* Test00: Header insertion scenario of [RNDIS][ETH_II][IP] -> */
- /* [WLAN][ETH_II][IP] */
- /*----------------------------------------------------------------------------*/
- class IpaHdrProcCtxTest00 : public IpaHdrProcCtxTestFixture
- {
- public:
- IpaHdrProcCtxTest00()
- {
- m_name = "IpaHdrProcCtxTest00";
- m_description =
- "Processing Context test 00 - \
- of [RNDIS][ETH_II][IP] -> [WLAN][ETH_II][IP] \
- 1. Generate and commit all headers for all tests. \
- 2. Generate and commit all processing context rules \
- for all tests.\
- 3. Generate and commit routing table 0. \
- The table contains 1 \"bypass\" rule. \
- All data goes to output pipe TEST2. \
- Routing rule will use processing context ETH2_2_WLAN_ETH2 \
- 4. Generate and commit 1 filtering rule. \
- All traffic goes to routing table 0";
- m_pCurrentProducer = &m_rndisEth2Producer;
- m_currProducerClient = IPA_CLIENT_TEST_PROD;
- m_pCurrentConsumer = &m_defaultConsumer;
- m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
- m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_2_WLAN_ETH2;
- m_minIPAHwType = IPA_HW_v2_5;
- m_maxIPAHwType = IPA_HW_MAX;
- m_runInRegression = false;
- Register(*this);
- }
- virtual bool LoadPackets(enum ipa_ip_type ip)
- {
- if (!RNDISAggregationHelper::LoadRNDISPacket(
- ip,
- m_sendBuffer1,
- m_sendSize1))
- {
- LOG_MSG_ERROR("Failed default Packet\n");
- return false;
- }
- printf ("Loaded %zu Bytes to Packet 1\n",m_sendSize1);
- add_buff(m_sendBuffer1+RNDIS_HDR_SIZE, ETH_HLEN, 2);
- print_buff(m_sendBuffer1, m_sendSize1);
- return true;
- }
- virtual bool GenerateExpectedPackets()
- {
- m_expectedBufferSize1 = WLAN_ETH2_HDR_SIZE +
- IP4_PACKET_SIZE;
- // copy WLAN header to the beginning of the buffer
- memcpy(m_expectedBuffer1, WLAN_ETH2_HDR, WLAN_HDR_SIZE);
- // copy ETH+IP packet right after WLAN header
- memcpy(m_expectedBuffer1 + WLAN_HDR_SIZE,
- m_sendBuffer1 + RNDIS_HDR_SIZE,
- ETH_HLEN + IP4_PACKET_SIZE);
- return true;
- } // GenerateExpectedPackets()
- };
- /*----------------------------------------------------------------------------*/
- /* Test01: Header insertion scenario of [WLAN][ETH_II][IP] -> */
- /* [RNDIS][ETH_II][IP] */
- /*----------------------------------------------------------------------------*/
- class IpaHdrProcCtxTest01 : public IpaHdrProcCtxTestFixture
- {
- public:
- IpaHdrProcCtxTest01()
- {
- m_name = "IpaHdrProcCtxTest01";
- m_description =
- "Processing context test 01 - \
- of [WLAN][ETH_II][IP] -> [RNDIS][ETH_II][IP] \
- 1. Generate and commit all headers for all tests. \
- 2. Generate and commit all processing context rules \
- for all tests.\
- 3. Generate and commit routing table 0. \
- The table contains 1 \"bypass\" rule. \
- All data goes to output pipe TEST3. \
- Routing rule will use processing context ETH2_2_RNDIS_ETH2 \
- 4. Generate and commit 1 filtering rule. \
- All traffic goes to routing table 0";
- m_pCurrentProducer = &m_wlanEth2producer;
- m_currProducerClient = IPA_CLIENT_TEST2_PROD;
- m_pCurrentConsumer = &m_rndisEth2Consumer;
- m_currConsumerPipeNum = IPA_CLIENT_TEST3_CONS;
- m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_2_RNDIS_ETH2;
- m_minIPAHwType = IPA_HW_v2_5;
- m_maxIPAHwType = IPA_HW_MAX;
- m_runInRegression = false;
- Register(*this);
- }
- virtual bool LoadPackets(enum ipa_ip_type ip)
- {
- // load WLAN ETH2 IP4 packet of size 1kB + 1 byte
- // This size will trigger RNDIS aggregation later
- m_sendSize1 =
- RNDISAggregationHelper::RNDIS_AGGREGATION_BYTE_LIMIT + 1;
- if (!WlanHelper::LoadWlanEth2IP4PacketByLength(
- m_sendBuffer1,
- m_BUFF_MAX_SIZE,
- m_sendSize1,
- 0x01))
- return false;
- printf ("Loaded %zu Bytes to Packet 1\n",m_sendSize1);
- add_buff(m_sendBuffer1+WLAN_HDR_SIZE, ETH_HLEN, 3);
- print_buff(m_sendBuffer1, m_sendSize1);
- return true;
- }
- virtual bool GenerateExpectedPackets()
- {
- size_t len = 0;
- size_t eth2PacketSize = m_sendSize1 - WLAN_HDR_SIZE;
- m_expectedBufferSize1 = eth2PacketSize + RNDIS_HDR_SIZE;
- // copy RNDIS header
- if (!RNDISAggregationHelper::LoadRNDISHeader(
- m_expectedBuffer1,
- m_BUFF_MAX_SIZE,
- m_expectedBufferSize1,
- &len))
- {
- LOG_MSG_ERROR("Failed default Packet\n");
- return false;
- }
- // copy ETH2 packet after RNDIS header
- memcpy(m_expectedBuffer1 + len,
- m_sendBuffer1 + WLAN_HDR_SIZE,
- eth2PacketSize);
- return true;
- } // GenerateExpectedPackets()
- };
- /*----------------------------------------------------------------------------*/
- /* Test02: Header insertion scenario of [WLAN][ETH_II][IP] -> */
- /* [WLAN'][ETH_II][IP] */
- /*----------------------------------------------------------------------------*/
- class IpaHdrProcCtxTest02 : public IpaHdrProcCtxTestFixture
- {
- public:
- IpaHdrProcCtxTest02()
- {
- m_name = "IpaHdrProcCtxTest02";
- m_description =
- "Processing context test 02 - \
- of [WLAN][ETH_II][IP] -> [WLAN'][ETH_II][IP] \
- 1. Generate and commit all headers for all tests. \
- 2. Generate and commit all processing context rules \
- for all tests.\
- 3. Generate and commit routing table 0. \
- The table contains 1 \"bypass\" rule. \
- All data goes to output pipe TEST2. \
- Routing rule will use processing context ETH2_2_WLAN_ETH2 \
- 4. Generate and commit 1 filtering rule. \
- All traffic goes to routing table 0";
- m_pCurrentProducer = &m_wlanEth2producer;
- m_currProducerClient = IPA_CLIENT_TEST2_PROD;
- m_pCurrentConsumer = &m_defaultConsumer;
- m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
- m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_2_WLAN_ETH2;
- m_minIPAHwType = IPA_HW_v2_5;
- m_maxIPAHwType = IPA_HW_MAX;
- m_runInRegression = false;
- Register(*this);
- }
- virtual bool LoadPackets(enum ipa_ip_type ip)
- {
- // load WLAN ETH2 IP4 packet of size 1kB
- // This size will trigger RNDIS aggregation later
- if (!WlanHelper::LoadWlanEth2IP4Packet(
- m_sendBuffer1,
- m_BUFF_MAX_SIZE,
- &m_sendSize1))
- return false;
- printf ("Loaded %zu Bytes to Packet 1\n",m_sendSize1);
- add_buff(m_sendBuffer1+WLAN_HDR_SIZE, ETH_HLEN, 5);
- return true;
- }
- virtual bool GenerateExpectedPackets()
- {
- m_expectedBufferSize1 = m_sendSize1;
- memcpy(m_expectedBuffer1, m_sendBuffer1, m_expectedBufferSize1);
- memcpy(m_expectedBuffer1, WLAN_ETH2_HDR, WLAN_HDR_SIZE);
- return true;
- } // GenerateExpectedPackets()
- };
- /*----------------------------------------------------------------------------*/
- /* Test03: Header insertion scenario of [WLAN][ETH_II][IP] -> */
- /* [RNDIS][ETH_II][IP] with RNDIS aggregation */
- /*----------------------------------------------------------------------------*/
- class IpaHdrProcCtxTest03 : public IpaHdrProcCtxTestFixture
- {
- public:
- IpaHdrProcCtxTest03()
- {
- m_name = "IpaHdrProcCtxTest03";
- m_description =
- "Processing Context test 03 - \
- of [RNDIS][ETH_II][IP] -> [WLAN][ETH_II][IP] \
- with RNDIS aggregation \
- 1. Generate and commit all headers for all tests. \
- 2. Generate and commit all processing context rules \
- for all tests.\
- 3. Generate and commit routing table 0. \
- The table contains 1 \"bypass\" rule. \
- All data goes to output pipe TEST3. \
- Routing rule will use processing context ETH2_2_RNDIS_ETH2 \
- 4. Generate and commit 1 filtering rule. \
- All traffic goes to routing table 0";
- m_pCurrentProducer = &m_wlanEth2producer;
- m_currProducerClient = IPA_CLIENT_TEST2_PROD;
- m_pCurrentConsumer = &m_rndisEth2Consumer;
- m_currConsumerPipeNum = IPA_CLIENT_TEST3_CONS;
- m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_2_RNDIS_ETH2;
- m_minIPAHwType = IPA_HW_v2_5;
- m_maxIPAHwType = IPA_HW_MAX;
- m_runInRegression = false;
- Register(*this);
- }
- virtual bool LoadPackets(enum ipa_ip_type ip)
- {
- // choose this size so that 2 such buffers would be aggregated
- m_sendSize1 = RNDISAggregationHelper::
- RNDIS_AGGREGATION_BYTE_LIMIT / 2 + 200;
- if (!WlanHelper::LoadWlanEth2IP4PacketByLength(
- m_sendBuffer1,
- m_BUFF_MAX_SIZE,
- m_sendSize1,
- 1))
- return false;
- printf ("Loaded %zu Bytes to Packet 1\n", m_sendSize1);
- add_buff(m_sendBuffer1+WLAN_HDR_SIZE, ETH_HLEN, 7);
- // choose this size so that 2 such buffers would be aggregated
- m_sendSize2 = RNDISAggregationHelper::
- RNDIS_AGGREGATION_BYTE_LIMIT / 2 + 200;
- if (!WlanHelper::LoadWlanEth2IP4PacketByLength(
- m_sendBuffer2,
- m_BUFF_MAX_SIZE,
- m_sendSize2,
- 2))
- return false;
- printf ("Loaded %zu Bytes to Packet 2\n", m_sendSize2);
- add_buff(m_sendBuffer2+WLAN_HDR_SIZE, ETH_HLEN, 11);
- return true;
- }
- virtual bool SendPackets()
- {
- bool isSuccess = false;
- // Send packet 1
- isSuccess = m_pCurrentProducer->SendData(
- m_sendBuffer1,
- m_sendSize1);
- if (false == isSuccess)
- {
- LOG_MSG_ERROR(
- "SendData Buffer 1 failed on producer %d\n", m_currProducerClient);
- return false;
- }
- // Send packet 2
- isSuccess = m_pCurrentProducer->SendData(
- m_sendBuffer2,
- m_sendSize2);
- if (false == isSuccess)
- {
- LOG_MSG_ERROR(
- "SendData Buffer 2 failed on producer %d\n", m_currProducerClient);
- return false;
- }
- return true;
- }
- virtual bool GenerateExpectedPackets()
- {
- size_t len = 0;
- size_t eth2PacketSize1 = m_sendSize1 - WLAN_HDR_SIZE;
- size_t rndisPacketSize1 = eth2PacketSize1 + RNDIS_HDR_SIZE;
- size_t eth2PacketSize2 = m_sendSize2 - WLAN_HDR_SIZE;
- size_t rndisPacketSize2 = eth2PacketSize2 + RNDIS_HDR_SIZE;
- Byte *currBuffLocation = NULL;
- m_expectedBufferSize1 = rndisPacketSize1 + rndisPacketSize2;
- currBuffLocation = m_expectedBuffer1;
- // copy first RNDIS header
- if (!RNDISAggregationHelper::LoadRNDISHeader(
- currBuffLocation,
- m_BUFF_MAX_SIZE,
- rndisPacketSize1,
- &len))
- return false;
- // copy ETH2 packet 1 after RNDIS header
- currBuffLocation += len;
- memcpy(currBuffLocation,
- m_sendBuffer1 + WLAN_HDR_SIZE,
- eth2PacketSize1);
- // copy second RNDIS header
- currBuffLocation += eth2PacketSize1;
- if (!RNDISAggregationHelper::LoadRNDISHeader(
- currBuffLocation,
- m_BUFF_MAX_SIZE - rndisPacketSize1,
- rndisPacketSize2,
- &len))
- return false;
- // copy ETH2 packet 2 after RNDIS header
- currBuffLocation += len;
- memcpy(currBuffLocation,
- m_sendBuffer2 + WLAN_HDR_SIZE,
- eth2PacketSize2);
- return true;
- } // GenerateExpectedPackets()
- };
- /*----------------------------------------------------------------------------*/
- /* Test04: Header insertion scenario when adding total header sizes > 2048 */
- /*----------------------------------------------------------------------------*/
- class IpaHdrProcCtxTest04 : public IpaHdrProcCtxTestFixture
- {
- public:
- IpaHdrProcCtxTest04()
- {
- m_name = "IpaHdrProcCtxTest04";
- m_description =
- "Processing context test 04 - \
- Header insertion scenario when adding \
- total header sizes > 2048 \
- 1. Generate and commit all headers for all tests. \
- 2. Generate and commit all processing context rules \
- for all tests.\
- 3. Generate and commit routing table 0. \
- The table contains 1 \"bypass\" rule. \
- All data goes to output pipe TEST2. \
- Routing rule will use header WLAN_ETH2 \
- 4. Generate and commit 1 filtering rule. \
- All traffic goes to routing table 0";
- m_pCurrentProducer = &m_wlanEth2producer;
- m_currProducerClient = IPA_CLIENT_TEST2_PROD;
- m_pCurrentConsumer = &m_defaultConsumer;
- m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
- m_minIPAHwType = IPA_HW_v2_5;
- m_maxIPAHwType = IPA_HW_MAX;
- m_runInRegression = false;
- Register(*this);
- }
- virtual void AddAllHeaders()
- {
- int cnt = 0;
- int allHeadersSize = 0;
- while (allHeadersSize <= m_ALL_HEADER_SIZE_LIMIT)
- {
- AddHeader(HEADER_HANDLE_ID_ETH2);
- /* header bins are power of 2 */
- allHeadersSize += ETH_HLEN + 2;
- cnt++;
- }
- AddHeader(HEADER_HANDLE_ID_WLAN_ETH2);
- }
- virtual bool AddRules()
- {
- printf("Entering %s, %s()\n",__FUNCTION__, __FILE__);
- AddAllHeaders();
- AddRtBypassRule(m_headerHandles[HEADER_HANDLE_ID_WLAN_ETH2], 0);
- AddFltBypassRule();
- printf("Leaving %s, %s()\n",__FUNCTION__, __FILE__);
- return true;
- }// AddRules()
- virtual bool LoadPackets(enum ipa_ip_type ip)
- {
- // load WLAN ETH2 IP4 packet of size 1kB
- // This size will trigger RNDIS aggregation later
- if (!WlanHelper::LoadWlanEth2IP4Packet(
- m_sendBuffer1,
- m_BUFF_MAX_SIZE,
- &m_sendSize1))
- return false;
- printf ("Loaded %zu Bytes to Packet 1\n",m_sendSize1);
- add_buff(m_sendBuffer1+WLAN_HDR_SIZE, ETH_HLEN, 13);
- return true;
- }
- virtual bool GenerateExpectedPackets()
- {
- m_expectedBufferSize1 = m_sendSize1;
- memcpy(m_expectedBuffer1, m_sendBuffer1, m_expectedBufferSize1);
- memcpy(m_expectedBuffer1, WLAN_ETH2_HDR, WLAN_ETH2_HDR_SIZE);
- return true;
- } // GenerateExpectedPackets()
- };
- /*----------------------------------------------------------------------------*/
- /* Test05: Header insertion scenario of [ETH_II_802_1Q][IP] -> */
- /* [ETH_II_802_1Q][IP] */
- /*----------------------------------------------------------------------------*/
- class IpaHdrProcCtxTest05 : public IpaHdrProcCtxTestFixture
- {
- public:
- IpaHdrProcCtxTest05()
- {
- m_name = "IpaHdrProcCtxTest05";
- m_description =
- "Processing Context test 05 - \
- of [ETH_II_802_1Q][IP] -> [ETH_II_802_1Q][IP] \
- 1. Generate and commit all headers for all tests. \
- 2. Generate and commit all processing context rules \
- for all tests.\
- 3. Generate and commit routing table 0. \
- The table contains 1 \"bypass\" rule. \
- All data goes to output pipe TEST2. \
- Routing rule will use processing context 802_1Q_2_802_1Q \
- 4. Generate and commit 1 filtering rule. \
- All traffic goes to routing table 0";
- /*
- * NOTE: we use the wlan + ETH header prod pipe since the header
- * length shall be equal to 8021Q ETH_II length
- */
- m_pCurrentProducer = &m_wlanEth2producer;
- m_currProducerClient = IPA_CLIENT_TEST2_PROD;
- m_pCurrentConsumer = &m_defaultConsumer;
- m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
- m_procCtxHandleId = PROC_CTX_HANDLE_ID_802_1Q_2_802_1Q;
- m_minIPAHwType = IPA_HW_v4_0;
- m_maxIPAHwType = IPA_HW_MAX;
- m_runInRegression = false;
- Register(*this);
- }
- virtual bool LoadPackets(enum ipa_ip_type ip)
- {
- if (!LoadDefault802_1Q(ip,
- m_sendBuffer1,
- m_sendSize1)) {
- LOG_MSG_ERROR("Failed default Packet\n");
- return false;
- }
- printf("Loaded %zu Bytes to Packet 1\n", m_sendSize1);
- // modify the MAC addresses only
- add_buff(m_sendBuffer1, 12, 14);
- //change vlan ID to 9
- m_sendBuffer1[15] = 0x9;
- print_buff(m_sendBuffer1, m_sendSize1);
- return true;
- }
- virtual bool GenerateExpectedPackets()
- {
- m_expectedBufferSize1 = m_sendSize1;
- // we actually expect the same packet to come out (but after uCP)
- memcpy(m_expectedBuffer1, m_sendBuffer1, m_expectedBufferSize1);
- return true;
- } // GenerateExpectedPackets()
- };
- /*----------------------------------------------------------------------------*/
- /* Test06: Header insertion scenario of [ETH_II][IP] -> */
- /* [ETH_II_802_1Q][IP] */
- /*----------------------------------------------------------------------------*/
- class IpaHdrProcCtxTest06 : public IpaHdrProcCtxTestFixture
- {
- public:
- IpaHdrProcCtxTest06()
- {
- m_name = "IpaHdrProcCtxTest06";
- m_description =
- "Processing Context test 06 - \
- of [ETH_II][IP] -> [ETH_II_802_1Q][IP] \
- 1. Generate and commit all headers for all tests. \
- 2. Generate and commit all processing context rules \
- for all tests.\
- 3. Generate and commit routing table 0. \
- The table contains 1 \"bypass\" rule. \
- All data goes to output pipe TEST2. \
- Routing rule will use processing context ETH2_2_802_1Q \
- 4. Generate and commit 1 filtering rule. \
- All traffic goes to routing table 0";
- m_pCurrentProducer = &m_eth2Producer;
- m_currProducerClient = IPA_CLIENT_TEST3_PROD;
- m_pCurrentConsumer = &m_defaultConsumer;
- m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
- m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_2_802_1Q;
- m_minIPAHwType = IPA_HW_v4_0;
- m_maxIPAHwType = IPA_HW_MAX;
- m_runInRegression = false;
- Register(*this);
- }
- virtual bool LoadPackets(enum ipa_ip_type ip)
- {
- if (!Eth2Helper::LoadEth2IP4Packet(
- m_sendBuffer1,
- m_BUFF_MAX_SIZE,
- &m_sendSize1)) {
- LOG_MSG_ERROR("Failed default Packet\n");
- return false;
- }
- printf("Loaded %zu Bytes to Packet 1\n", m_sendSize1);
- // modify the MAC addresses only
- add_buff(m_sendBuffer1, 12, 15);
- print_buff(m_sendBuffer1, m_sendSize1);
- return true;
- }
- virtual bool GenerateExpectedPackets()
- {
- size_t len;
- m_expectedBufferSize1 = ETH8021Q_HEADER_LEN +
- IP4_PACKET_SIZE;
- // copy the VLAN header to expected buffer
- memcpy(m_expectedBuffer1, ETH2_8021Q_HDR, ETH8021Q_HEADER_LEN);
- // fill src and dst mac and ethertype
- memcpy(m_expectedBuffer1, m_sendBuffer1, 2 * ETH_ALEN);
- memcpy(m_expectedBuffer1 + ETH8021Q_ETH_TYPE_OFFSET,
- m_sendBuffer1 + ETH2_ETH_TYPE_OFFSET, ETH2_ETH_TYPE_LEN);
- len = m_BUFF_MAX_SIZE - ETH8021Q_HEADER_LEN;
- if (!LoadDefaultPacket(IPA_IP_v4,
- m_expectedBuffer1 + ETH8021Q_HEADER_LEN,
- len)) {
- LOG_MSG_ERROR("Failed default Packet\n");
- return false;
- }
- return true;
- } // GenerateExpectedPackets()
- };
- /*----------------------------------------------------------------------------*/
- /* Test07: Header insertion scenario of [ETH_II_802_1Q][IP] -> */
- /* [ETH_II][IP] */
- /*----------------------------------------------------------------------------*/
- class IpaHdrProcCtxTest07 : public IpaHdrProcCtxTestFixture
- {
- public:
- IpaHdrProcCtxTest07()
- {
- m_name = "IpaHdrProcCtxTest07";
- m_description =
- "Processing Context test 07 - \
- of [ETH_II_802_1Q][IP] -> [ETH_II][IP] \
- 1. Generate and commit all headers for all tests. \
- 2. Generate and commit all processing context rules \
- for all tests.\
- 3. Generate and commit routing table 0. \
- The table contains 1 \"bypass\" rule. \
- All data goes to output pipe TEST2. \
- Routing rule will use processing context 802_1Q_2_ETH2 \
- 4. Generate and commit 1 filtering rule. \
- All traffic goes to routing table 0";
- m_pCurrentProducer = &m_wlanEth2producer;
- m_currProducerClient = IPA_CLIENT_TEST2_PROD;
- m_pCurrentConsumer = &m_defaultConsumer;
- m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
- m_procCtxHandleId = PROC_CTX_HANDLE_ID_802_1Q_2_ETH2;
- m_minIPAHwType = IPA_HW_v4_0;
- m_maxIPAHwType = IPA_HW_MAX;
- m_runInRegression = false;
- Register(*this);
- }
- virtual bool LoadPackets(enum ipa_ip_type ip)
- {
- if (!LoadDefault802_1Q(ip,
- m_sendBuffer1,
- m_sendSize1)) {
- LOG_MSG_ERROR("Failed default Packet\n");
- return false;
- }
- printf("Loaded %zu Bytes to Packet 1\n", m_sendSize1);
- // modify the MAC addresses only
- add_buff(m_sendBuffer1, ETH8021Q_METADATA_OFFSET, 16);
- print_buff(m_sendBuffer1, m_sendSize1);
- return true;
- }
- virtual bool GenerateExpectedPackets()
- {
- size_t len;
- m_expectedBufferSize1 = m_sendSize1 - ETH8021Q_8021Q_TAG_LEN;
- // copy the ETH2 header to expected buffer
- memcpy(m_expectedBuffer1, ETH2_HDR, ETH_HLEN);
- // fill src and dst mac and ethertype
- memcpy(m_expectedBuffer1, m_sendBuffer1, 2 * ETH_ALEN);
- memcpy(m_expectedBuffer1 + ETH2_ETH_TYPE_OFFSET,
- m_sendBuffer1 + ETH8021Q_ETH_TYPE_OFFSET,
- ETH2_ETH_TYPE_LEN);
- len = m_BUFF_MAX_SIZE - ETH_HLEN;
- if (!LoadDefaultPacket(IPA_IP_v4,
- m_expectedBuffer1 + ETH_HLEN,
- len)) {
- LOG_MSG_ERROR("Failed default Packet\n");
- return false;
- }
- return true;
- } // GenerateExpectedPackets()
- };
- /*----------------------------------------------------------------------------*/
- /* Test08: Header insertion scenario of [ETH_II][IP] -> */
- /* [ETH_II][IP] with generic ucp command */
- /*----------------------------------------------------------------------------*/
- class IpaHdrProcCtxTest08 : public IpaHdrProcCtxTestFixture
- {
- public:
- IpaHdrProcCtxTest08()
- {
- m_name = "IpaHdrProcCtxTest08";
- m_description =
- "Processing Context test 08 - \
- of [ETH_II][IP] -> [ETH_II][IP] with generic ucp \
- 1. Generate and commit all headers for all tests. \
- 2. Generate and commit all processing context rules \
- for all tests.\
- 3. Generate and commit routing table 0. \
- The table contains 1 \"bypass\" rule. \
- All data goes to output pipe TEST2. \
- Routing rule will use processing context ETH2_2_ETH2_EX \
- 4. Generate and commit 1 filtering rule. \
- All traffic goes to routing table 0";
- m_pCurrentProducer = &m_eth2Producer;
- m_currProducerClient = IPA_CLIENT_TEST3_PROD;
- m_pCurrentConsumer = &m_defaultConsumer;
- m_currConsumerPipeNum = IPA_CLIENT_TEST2_CONS;
- m_procCtxHandleId = PROC_CTX_HANDLE_ID_ETH2_ETH2_2_ETH2_EX;
- m_minIPAHwType = IPA_HW_v4_0;
- m_maxIPAHwType = IPA_HW_MAX;
- m_runInRegression = false;
- Register(*this);
- }
- virtual bool LoadPackets(enum ipa_ip_type ip)
- {
- if (!Eth2Helper::LoadEth2IP4Packet(
- m_sendBuffer1,
- m_BUFF_MAX_SIZE,
- &m_sendSize1)) {
- LOG_MSG_ERROR("Failed default Packet\n");
- return false;
- }
- printf("Loaded %zu Bytes to Packet 1\n", m_sendSize1);
- // modify the MAC addresses only
- add_buff(m_sendBuffer1, 12, 17);
- print_buff(m_sendBuffer1, m_sendSize1);
- return true;
- }
- virtual bool GenerateExpectedPackets()
- {
- m_expectedBufferSize1 = m_sendSize1;
- // we actually expect the same packet to come out (but after uCP)
- memcpy(m_expectedBuffer1, m_sendBuffer1, m_expectedBufferSize1);
- return true;
- } // GenerateExpectedPackets()
- };
- static IpaHdrProcCtxTest00 ipaHdrProcCtxTest00;
- static IpaHdrProcCtxTest01 ipaHdrProcCtxTest01;
- static IpaHdrProcCtxTest02 ipaHdrProcCtxTest02;
- static IpaHdrProcCtxTest03 ipaHdrProcCtxTest03;
- static IpaHdrProcCtxTest04 ipaHdrProcCtxTest04;
- static IpaHdrProcCtxTest05 ipaHdrProcCtxTest05;
- static IpaHdrProcCtxTest06 ipaHdrProcCtxTest06;
- static IpaHdrProcCtxTest07 ipaHdrProcCtxTest07;
- static IpaHdrProcCtxTest08 ipaHdrProcCtxTest08;
|