TestsUtils.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. /*
  2. * Copyright (c) 2017-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. #ifndef __TESTS_UTILS__H__
  30. #define __TESTS_UTILS__H__
  31. #include <stdarg.h>
  32. #include <vector>
  33. #include <string>
  34. #include <linux/if_ether.h>
  35. #include <linux/msm_ipa.h>
  36. #include "TestBase.h"
  37. #include "Constants.h"
  38. #include "RoutingDriverWrapper.h"
  39. #include "InterfaceAbstraction.h"
  40. #include "ipa_test_module.h"
  41. #include "TestManager.h"
  42. #include "Logger.h"
  43. #include "Constants.h"
  44. extern "C" {
  45. #include "ipa_nat_utils.h"
  46. }
  47. using namespace std;
  48. #define TEST_APP_VERSION "2.00"
  49. #define Free(x) do { if (x) {free(x); x = NULL; } } while (0)
  50. #define MAX3(_X, _Y, _Z) max(max((_X), (_Y)), (_Z))
  51. #define ETH2_DST_ADDR_OFFSET (0)
  52. #define ETH2_SRC_ADDR_OFFSET (ETH_ALEN)
  53. #define ETH2_ETH_TYPE_OFFSET (ETH2_SRC_ADDR_OFFSET + ETH_ALEN)
  54. #define ETH2_ETH_TYPE_LEN (2)
  55. #define ETH2_PAYLOAD_OFFSET (ETH2_ETH_TYPE_OFFSET + ETH2_ETH_TYPE_LEN)
  56. #define ETH8021Q_HEADER_LEN (18)
  57. #define ETH8021Q_METADATA_OFFSET (12)
  58. #define ETH8021Q_8021Q_TAG_LEN (4)
  59. #define ETH8021Q_ETH_TYPE_OFFSET (ETH8021Q_METADATA_OFFSET + ETH8021Q_8021Q_TAG_LEN)
  60. #define WLAN_HDR_SIZE (4)
  61. #define RNDIS_HDR_SIZE (44)
  62. // 26 ROME WLAN Frame =
  63. // 4 ROME WLAN header +
  64. // 14 IEEE 802.3 +
  65. // 8 802.2 LLC/SNAP
  66. #define _802_3_HDR_SIZE (26)
  67. // [WLAN][ETH2] header
  68. #define WLAN_ETH2_HDR_SIZE (WLAN_HDR_SIZE + ETH_HLEN)
  69. // [RNDIS][ETH2] header
  70. #define RNDIS_ETH2_HDR_SIZE (RNDIS_HDR_SIZE + ETH_HLEN)
  71. #define IP4_PACKET_SIZE (70) // Arbitrary number
  72. // OFFSET = sizeof(struct rndis_pkt_hdr) - RNDIS_HDR_OFST(data_ofst)
  73. #define RNDIS_DATA_OFFSET (36)
  74. // [WLAN][802.3] header
  75. #define WLAN_802_3_HDR_SIZE (WLAN_HDR_SIZE + _802_3_HDR_SIZE)
  76. #define IPA_CLIENT_IS_PROD(x) \
  77. (x < IPA_CLIENT_MAX && (x & 0x1) == 0)
  78. #define IPA_CLIENT_IS_CONS(x) \
  79. (x < IPA_CLIENT_MAX && (x & 0x1) == 1)
  80. enum msgType {
  81. ERROR = 0,
  82. DEBUG,
  83. INFO,
  84. STACK
  85. };
  86. /**
  87. @brief
  88. Do not Use this function. Use MACROs instead.
  89. @details
  90. Do not Use this function.
  91. Instead use the MACROs: LOG_MSG_ERROR, LOG_MSG_INFO & LOG_MSG_DEBUG
  92. */
  93. void __log_msg(enum msgType,
  94. const char *filename,
  95. int line, const char *function,
  96. const char *format, ...);
  97. #define LOG_MSG_ERROR(...) \
  98. __log_msg(ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__)
  99. #define LOG_MSG_DEBUG(...) \
  100. __log_msg(DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__)
  101. #define LOG_MSG_INFO(...) \
  102. __log_msg(INFO, __FILE__, __LINE__, __func__, __VA_ARGS__)
  103. #define LOG_MSG_STACK(...) \
  104. __log_msg(STACK, __FILE__, __LINE__, __func__, __VA_ARGS__)
  105. /*#define LOG_MSG_ERROR(x...)
  106. __log_msg(ERROR, __FILE__, __LINE__, __func__, x)
  107. #define LOG_MSG_DEBUG(x...)
  108. __log_msg(DEBUG, __FILE__, __LINE__, __func__, x)
  109. #define LOG_MSG_INFO(x...)
  110. __log_msg(INFO, __FILE__, __LINE__, __func__, x)
  111. #define LOG_MSG_STACK(x...)
  112. __log_msg(STACK, __FILE__, __LINE__, __func__, x)*/
  113. /**
  114. @brief
  115. Function loads a default IPv4 / IPv6 Packet
  116. @param [in] eIP - Type of Packet to load (IPA_IP_v4 / IPA_IP_v6)
  117. @param [in] pBuffer - pointer to the destination buffer
  118. @param [in,out] nMaxSize - The size of the buffer.
  119. Upon function return,
  120. the total number of bytes copied will be stored in this parameter.
  121. @return boolean indicating whether the
  122. operation completed successfully or not.
  123. @details
  124. Function loads a default IPv4 / IPv6 packet into pBuffer.
  125. */
  126. bool LoadDefaultPacket(
  127. enum ipa_ip_type eIP,
  128. uint8_t *pBuffer,
  129. size_t &nMaxSize);
  130. bool LoadDefaultEth2Packet(
  131. enum ipa_ip_type eIP,
  132. uint8_t *pBuffer,
  133. size_t &nMaxSize);
  134. bool LoadDefaultWLANEth2Packet(
  135. enum ipa_ip_type eIP,
  136. uint8_t *pBuffer,
  137. size_t &nMaxSize);
  138. bool LoadDefaultWLAN802_32Packet(
  139. enum ipa_ip_type eIP,
  140. uint8_t *pBuffer,
  141. size_t &nMaxSize);
  142. bool LoadNoPayloadPacket(
  143. enum ipa_ip_type eIP,
  144. uint8_t *pBuffer,
  145. size_t &nMaxSize);
  146. bool LoadDefault802_1Q(
  147. enum ipa_ip_type eIP,
  148. uint8_t *pBuffer,
  149. size_t &nMaxSize);
  150. /**
  151. @brief
  152. Function loads a default IPv4 / IPv6 Packet
  153. @param [in] eIP - Type of Packet to load (IPA_IP_v4 / IPA_IP_v6)
  154. @param [in] extHdrType - Type of IPV6 extension header(FRAGMENT / NONE)
  155. @param [in] pBuffer - pointer to the destination buffer
  156. @param [in,out] nMaxSize - The size of the buffer.
  157. Upon function return,
  158. the total number of bytes copied will be stored in this parameter.
  159. @return boolean indicating whether the
  160. operation completed successfully or not.
  161. @details
  162. Function loads a default IPv4 / IPv6 packet into pBuffer.
  163. */
  164. bool LoadDefaultPacket(
  165. enum ipa_ip_type eIP,
  166. enum ipv6_ext_hdr_type extHdrType,
  167. uint8_t *pBuffer,
  168. size_t &nMaxSize);
  169. /**
  170. @brief
  171. Function Sends a Packet, Receive a packet
  172. and compares the received result with an expected buffer
  173. @param [in] pSink - Destination to which a packet will be sent.
  174. @param [in] pSendBuffer -
  175. Pointer to a buffer containing the packet that will be sent.
  176. @param [in] nSendBuffSize - The size of the data in the packet.
  177. @param [in] pSource - Source from which a packet will be received.
  178. @param [in] pExpectedBuffer - Pointer a
  179. buffer containing the expected packet (from the receiver)
  180. @param [in] nExpectedBuffSize - The size of
  181. valid data within pExpectedBuffer.
  182. @return Boolean indicating whether the operation
  183. completed successfully and the buffers matching or not.
  184. @details
  185. Function sends a packet to pSink, and receives a packet from pSource.
  186. The packet received from pSource
  187. is compared to the expected data from pExpectedBuffer.
  188. If ExpectData is identical to the
  189. received data, the function returns TRUE.
  190. */
  191. bool SendReceiveAndCompare(
  192. InterfaceAbstraction * pSink,
  193. uint8_t *pSendBuffer,
  194. size_t nSendBuffSize,
  195. InterfaceAbstraction * pSource,
  196. uint8_t *pExpectedBuffer,
  197. size_t nExpectedBuffSize);
  198. /**
  199. @brief
  200. This function creates a bypass rule within a table in the Routing block
  201. @param [in] pRouting - pointer to the Routing Class
  202. @param [in] eIP - Type of Packet to load (IPA_IP_v4 / IPA_IP_v6)
  203. @param [in] pTableName - pointer to the Table's Name.
  204. @param [in] eRuleDestination - destination of the bypass rule.
  205. @param [in] uHeaderHandle -
  206. handle to the Header that should be Added (0 should be used as default).
  207. @param [out] pTableHdl -
  208. pointer to the table Handle (Can be Null)
  209. @return boolean indicating whether
  210. the operation completed successfully or not.
  211. @details
  212. This function creates bypass rule within a table in the Routing block.
  213. */
  214. bool CreateBypassRoutingTable(
  215. RoutingDriverWrapper * pRouting,
  216. enum ipa_ip_type eIP,
  217. const char *pTableName,
  218. enum ipa_client_type eRuleDestination,
  219. uint32_t uHeaderHandle,
  220. uint32_t *pTableHdl);
  221. /**
  222. @brief
  223. This function creates a bypass rule within a table in the Routing block
  224. @param [in] pRouting - pointer to the Routing Class
  225. @param [in] eIP - Type of Packet to load (IPA_IP_v4 / IPA_IP_v6)
  226. @param [in] pTableName - pointer to the Table's Name.
  227. @param [in] eRuleDestination - destination of the bypass rule.
  228. @param [in] uHeaderHandle -
  229. handle to the Header that should be Added (0 should be used as default).
  230. @param [out] pTableHdl -
  231. pointer to the table Handle (Can be Null)
  232. @return boolean indicating whether
  233. the operation completed successfully or not.
  234. @details
  235. This function creates bypass rule within a table in the Routing block.
  236. */
  237. bool CreateBypassRoutingTable_v2(
  238. RoutingDriverWrapper * pRouting,
  239. enum ipa_ip_type eIP,
  240. const char *pTableName,
  241. enum ipa_client_type eRuleDestination,
  242. uint32_t uHeaderHandle,
  243. uint32_t *pTableHdl,
  244. uint8_t uClsAggrIrqMod);
  245. /**
  246. @brief
  247. Configures the sytem to one of the pre-determined
  248. configurations.
  249. @param [in] testConfiguration - Configuration number
  250. @param [in] params - additional parameters
  251. @return void
  252. @details
  253. Writes the configuration index to /dev/ipa_test. In case
  254. the system has already been configured, returns.
  255. */
  256. void ConfigureScenario(int testConfiguration);
  257. void ConfigureScenario(int testConfiguration, const char *params);
  258. int GenericConfigureScenario(struct ipa_test_config_header *header,
  259. bool isUlso=false);
  260. int GenericConfigureScenarioDestory(void);
  261. int ConfigureSystem(int testConfiguration, int fd);
  262. int ConfigureSystem(int testConfiguration, int fd, const char *params);
  263. void prepare_channel_struct(struct ipa_channel_config *channel,
  264. int index,
  265. enum ipa_client_type client,
  266. void *cfg,
  267. size_t config_size,
  268. bool en_status = 0);
  269. void prepare_header_struct(struct ipa_test_config_header *header,
  270. struct ipa_channel_config **from,
  271. struct ipa_channel_config **to);
  272. /**
  273. @brief
  274. Compares two data buffers.
  275. @param [in] goldenBuffer - Pointer to the first data
  276. buffer
  277. @param [in] goldenSize - First data buffer size
  278. @param [in] receivedBuffer - Pointer to the second data
  279. buffer
  280. @param [in] receivedSize - Second data buffer size
  281. @return True - the buffers are identical. False
  282. otherwise.
  283. @details
  284. In case the sizes are differnt, false is returned.
  285. */
  286. bool CompareResultVsGolden(
  287. unsigned char *goldenBuffer,
  288. unsigned int goldenSize,
  289. unsigned char *receivedBuffer,
  290. unsigned int receivedSize);
  291. /**
  292. @brief
  293. Compares two data buffers considering the returned status.
  294. @param [in] goldenBuffer - Pointer to the first data
  295. buffer
  296. @param [in] goldenSize - First data buffer size
  297. @param [in] receivedBuffer - Pointer to the second data
  298. buffer
  299. @param [in] receivedSize - Second data buffer size
  300. @return True - the buffers are identical. False
  301. otherwise.
  302. @details
  303. In case the sizes are differnt, false is returned.
  304. */
  305. bool CompareResultVsGolden_w_Status(
  306. Byte *goldenBuffer,
  307. unsigned int goldenSize,
  308. Byte *receivedBuffer,
  309. unsigned int receivedSize);
  310. /**
  311. @brief
  312. Loads a file to memory
  313. @param [in] fileFullPath
  314. @param [inout] sizeLoaded - returns the number of bytes
  315. which were read from the file
  316. @return Address of the loaded data buffer
  317. @details
  318. Allocates memory by itself, user should free the memory
  319. */
  320. unsigned char *LoadFileToMemory(
  321. const string & fileFullPath,
  322. unsigned int *sizeLoaded);
  323. /**
  324. @brief
  325. Checks whether a file exists on disk
  326. @param [in] filename
  327. @return True if the file exists, false otherwise.
  328. @details
  329. */
  330. bool file_exists(const char *filename);
  331. /**
  332. @brief
  333. Prints a data buffer.
  334. @param [in] data - Pointer to the data
  335. @param [in] size - How many bytes to print
  336. @return void
  337. @details
  338. */
  339. void print_buff(void *data, size_t size);
  340. void add_buff(uint8_t *data, size_t size, uint8_t val);
  341. /**
  342. @brief
  343. Performes ep control of a specific endpoint.
  344. @param [in] ep_ctrl - Pointer to ipa_test_ep_ctrl struct with
  345. the data of the requested operation
  346. @return bool
  347. @details
  348. Suspend\Unsuspends\Delays\resumes an endpoint.
  349. */
  350. bool configure_ep_ctrl(struct ipa_test_ep_ctrl *ep_ctrl);
  351. /**
  352. @brief
  353. Performes holb config of a specific pipe.
  354. * @param [in] test_holb_config - Pointer to
  355. * ipa_test_holb_config struct with the data of
  356. * the requested operation
  357. @return bool
  358. @details
  359. Configures HOLB parameters on a pipe.
  360. */
  361. bool configure_holb(struct ipa_test_holb_config *test_holb_config);
  362. /**
  363. @brief
  364. Register an alternative suspend handler
  365. @param [in] deferred_flag - should the handler execute in defer mode
  366. @param [in] reg - register or unregister the suspend handler
  367. @param [in] DevNum - the index of the ep that the handler is registered to
  368. @return bool
  369. @details
  370. Register the test framework suspend handler for a given endpoint
  371. */
  372. bool RegSuspendHandler(bool deferred_flag, bool reg, int DevNum);
  373. class Eth2Helper {
  374. public:
  375. static const Byte m_ETH2_IP4_HDR[ETH_HLEN];
  376. static bool LoadEth2IP4Header(
  377. uint8_t *pBuffer,
  378. size_t bufferSize,
  379. size_t *pLen);
  380. static bool LoadEth2IP6Header(
  381. uint8_t *pBuffer,
  382. size_t bufferSize,
  383. size_t *pLen);
  384. static bool LoadEth2IP4Packet(
  385. uint8_t *pBuffer,
  386. size_t bufferSize,
  387. size_t *pLen);
  388. static bool LoadEth2IP6Packet(
  389. uint8_t *pBuffer,
  390. size_t bufferSize,
  391. size_t *pLen);
  392. };
  393. class WlanHelper {
  394. public:
  395. static const Byte m_WLAN_HDR[WLAN_HDR_SIZE];
  396. static bool LoadWlanHeader(
  397. uint8_t *pBuffer,
  398. size_t bufferSize,
  399. size_t *pLen);
  400. static bool LoadWlanEth2IP4Header(
  401. uint8_t *pBuffer,
  402. size_t bufferSize,
  403. size_t *pLen);
  404. static bool LoadWlanEth2IP6Header(
  405. uint8_t *pBuffer,
  406. size_t bufferSize,
  407. size_t *pLen);
  408. static bool LoadWlanEth2IP4Packet(
  409. uint8_t *pBuffer,
  410. size_t bufferSize,
  411. size_t *pLen);
  412. static bool LoadWlanEth2IP4PacketByLength(
  413. uint8_t *pBuffer,
  414. size_t bufferSize,
  415. size_t len,
  416. uint8_t padValue);
  417. static bool LoadWlanEth2IP6Packet(
  418. uint8_t *pBuffer,
  419. size_t bufferSize,
  420. size_t *pLen);
  421. };
  422. #pragma pack(push) /* push current alignment to stack */
  423. #pragma pack(1) /* set alignment to 1 byte boundary */
  424. struct RndisHeader {
  425. uint32_t MessageType;
  426. uint32_t MessageLength;
  427. uint32_t DataOffset;
  428. uint32_t DataLength;
  429. uint32_t OOBDataOffset;
  430. uint32_t OOBDataLength;
  431. uint32_t OOBNumber;
  432. uint32_t PacketInfoOffset;
  433. uint32_t PacketInfoLength;
  434. uint64_t Reserved;
  435. };
  436. struct RndisEtherHeader {
  437. struct RndisHeader rndisHeader;
  438. struct ethhdr etherHeader;
  439. };
  440. #pragma pack(pop) /* restore original alignment from stack */
  441. class RNDISAggregationHelper {
  442. public:
  443. static const size_t RNDIS_AGGREGATION_BYTE_LIMIT = 1024;
  444. static bool LoadRNDISHeader(
  445. uint8_t *pBuffer,
  446. size_t bufferSize,
  447. uint32_t messageLength,
  448. size_t *pLen);
  449. static bool LoadRNDISEth2IP4Header(
  450. uint8_t *pBuffer,
  451. size_t bufferSize,
  452. uint32_t messageLength,
  453. size_t *pLen);
  454. static bool LoadRNDISPacket(
  455. enum ipa_ip_type eIP,
  456. uint8_t *pBuffer,
  457. size_t &nMaxSize);
  458. static bool LoadEtherPacket(
  459. enum ipa_ip_type eIP,
  460. uint8_t *pBuffer,
  461. size_t &nMaxSize);
  462. static bool ComparePackets(
  463. Byte *pPacket1,
  464. int pPacket1Size,
  465. Byte *pPacket2,
  466. int pPacket2Size);
  467. static bool CompareEthervsRNDISPacket(
  468. Byte *pIPPacket,
  469. size_t ipPacketSize,
  470. Byte *pRNDISPacket,
  471. size_t rndisPacketSize);
  472. static bool CompareIPvsRNDISPacket(
  473. Byte *pIPPacket,
  474. int ipPacketSize,
  475. Byte *pRNDISPacket,
  476. size_t rndisPacketSize);
  477. };
  478. enum ipa_nat_en_type {
  479. IPA_BYPASS_NAT,
  480. IPA_SRC_NAT,
  481. IPA_DST_NAT,
  482. };
  483. enum ipa_ipv6ct_en_type {
  484. IPA_BYPASS_IPV6CT,
  485. IPA_ENABLE_IPV6CT,
  486. };
  487. enum ipa_mode_type {
  488. IPA_BASIC,
  489. IPA_ENABLE_FRAMING_HDLC,
  490. IPA_ENABLE_DEFRAMING_HDLC,
  491. IPA_DMA,
  492. };
  493. enum ipa_aggr_en_type {
  494. IPA_BYPASS_AGGR,
  495. IPA_ENABLE_AGGR,
  496. IPA_ENABLE_DEAGGR,
  497. };
  498. enum ipa_aggr_type {
  499. IPA_MBIM_16 = 0,
  500. IPA_HDLC = 1,
  501. IPA_TLP = 2,
  502. IPA_RNDIS = 3,
  503. IPA_GENERIC = 4,
  504. IPA_QCMAP = 6,
  505. };
  506. enum ipa_aggr_mode {
  507. IPA_MBIM_AGGR,
  508. IPA_QCNCM_AGGR,
  509. };
  510. enum hdr_total_len_or_pad_type {
  511. IPA_HDR_PAD = 0,
  512. IPA_HDR_TOTAL_LEN = 1,
  513. };
  514. struct ipa_ep_cfg_nat {
  515. enum ipa_nat_en_type nat_en;
  516. bool nat_exc_suppress;
  517. };
  518. struct ipa_ep_cfg_conn_track {
  519. enum ipa_ipv6ct_en_type conn_track_en;
  520. };
  521. struct ipa_ep_cfg_hdr {
  522. uint32_t hdr_len;
  523. uint32_t hdr_ofst_metadata_valid;
  524. uint32_t hdr_ofst_metadata;
  525. uint32_t hdr_additional_const_len;
  526. uint32_t hdr_ofst_pkt_size_valid;
  527. uint32_t hdr_ofst_pkt_size;
  528. uint32_t hdr_a5_mux;
  529. uint32_t hdr_remove_additional;
  530. uint32_t hdr_metadata_reg_valid;
  531. };
  532. struct ipa_ep_cfg_hdr_ext {
  533. uint32_t hdr_pad_to_alignment;
  534. uint32_t hdr_total_len_or_pad_offset;
  535. bool hdr_payload_len_inc_padding;
  536. enum hdr_total_len_or_pad_type hdr_total_len_or_pad;
  537. bool hdr_total_len_or_pad_valid;
  538. bool hdr_little_endian;
  539. struct ipa_ep_cfg_hdr *hdr;
  540. bool hdr_bytes_to_remove_valid;
  541. uint32_t hdr_bytes_to_remove;
  542. };
  543. struct ipa_ep_cfg_mode {
  544. enum ipa_mode_type mode;
  545. enum ipa_client_type dst;
  546. };
  547. struct ipa_ep_cfg_aggr {
  548. enum ipa_aggr_en_type aggr_en;
  549. enum ipa_aggr_type aggr;
  550. uint32_t aggr_byte_limit;
  551. uint32_t aggr_time_limit;
  552. uint32_t aggr_pkt_limit;
  553. uint32_t aggr_hard_byte_limit_en;
  554. bool aggr_sw_eof_active;
  555. uint8_t pulse_generator;
  556. uint8_t scaled_time;
  557. bool aggr_coal_l2;
  558. };
  559. struct ipa_ep_cfg_route {
  560. uint32_t rt_tbl_hdl;
  561. };
  562. struct ipa_ep_cfg_deaggr {
  563. uint32_t deaggr_hdr_len;
  564. bool syspipe_err_detection;
  565. bool packet_offset_valid;
  566. uint32_t packet_offset_location;
  567. bool ignore_min_pkt_err;
  568. uint32_t max_packet_len;
  569. };
  570. enum ipa_cs_offload {
  571. IPA_DISABLE_CS_OFFLOAD,
  572. IPA_ENABLE_CS_OFFLOAD_UL,
  573. IPA_ENABLE_CS_OFFLOAD_DL,
  574. IPA_CS_RSVD
  575. };
  576. struct ipa_ep_cfg_cfg {
  577. bool frag_offload_en;
  578. enum ipa_cs_offload cs_offload_en;
  579. uint8_t cs_metadata_hdr_offset;
  580. uint8_t gen_qmb_master_sel;
  581. uint8_t tx_instance;
  582. bool pipe_replicate_en;
  583. };
  584. struct ipa_ep_cfg_metadata_mask {
  585. uint32_t metadata_mask;
  586. };
  587. struct ipa_ep_cfg_metadata {
  588. uint32_t qmap_id;
  589. };
  590. struct ipa_ep_cfg_seq {
  591. bool set_dynamic;
  592. int seq_type;
  593. };
  594. struct ipa_ep_cfg_ulso {
  595. int ipid_min_max_idx;
  596. bool is_ulso_pipe;
  597. };
  598. struct ipa_ep_cfg_holb {
  599. uint32_t tmr_val;
  600. uint32_t base_val;
  601. uint32_t scale;
  602. uint16_t en;
  603. uint8_t pulse_generator;
  604. uint8_t scaled_time;
  605. };
  606. struct ipa_pkt_init_ex_hdr_ofst_set {
  607. char name[IPA_RESOURCE_NAME_MAX];
  608. enum ipa_client_type ep;
  609. };
  610. struct ipa_ep_cfg_prod_cfg {
  611. uint8_t tx_instance;
  612. bool tsp_enable;
  613. bool max_output_size_drop_enable;
  614. uint8_t tsp_idx;
  615. uint8_t max_output_size;
  616. uint8_t egress_tc_lowest;
  617. uint8_t egress_tc_highest;
  618. };
  619. /*
  620. * This struct is a mirroring of the ipa struct
  621. * the test module expect to get from user-space the
  622. * exact same struct as IPA driver defined.
  623. * In case of any change to IPA driver struct
  624. * this struct should be updated as well!
  625. */
  626. struct test_ipa_ep_cfg {
  627. struct ipa_ep_cfg_nat nat;
  628. struct ipa_ep_cfg_conn_track conn_track;
  629. struct ipa_ep_cfg_hdr hdr;
  630. struct ipa_ep_cfg_hdr_ext hdr_ext;
  631. struct ipa_ep_cfg_mode mode;
  632. struct ipa_ep_cfg_aggr aggr;
  633. struct ipa_ep_cfg_deaggr deaggr;
  634. struct ipa_ep_cfg_route route;
  635. struct ipa_ep_cfg_cfg cfg;
  636. struct ipa_ep_cfg_metadata_mask metadata_mask;
  637. struct ipa_ep_cfg_metadata meta;
  638. struct ipa_ep_cfg_seq seq;
  639. struct ipa_ep_cfg_ulso ulso;
  640. struct ipa_ep_cfg_prod_cfg prod_cfg;
  641. };
  642. /*! @brief Struct for the IPAv3.0 UL packet status header */
  643. struct ipa3_hw_pkt_status {
  644. uint64_t status_opcode:8;
  645. uint64_t exception:8;
  646. uint64_t status_mask:16;
  647. uint64_t pkt_len:16;
  648. uint64_t endp_src_idx:5;
  649. uint64_t reserved_1:3;
  650. uint64_t endp_dest_idx:5;
  651. uint64_t reserved_2:3;
  652. uint64_t metadata:32;
  653. uint64_t filt_local:1;
  654. uint64_t filt_hash:1;
  655. uint64_t filt_global:1;
  656. uint64_t ret_hdr:1;
  657. uint64_t filt_rule_id:10;
  658. uint64_t route_local:1;
  659. uint64_t route_hash:1;
  660. uint64_t ucp:1;
  661. uint64_t route_tbl_idx:5;
  662. uint64_t route_rule_id:10;
  663. uint64_t nat_hit:1;
  664. uint64_t nat_tbl_idx:13;
  665. uint64_t nat_type:2;
  666. uint64_t tag:48;
  667. uint64_t seq_num:8;
  668. uint64_t time_day_ctr:24;
  669. uint64_t hdr_local:1;
  670. uint64_t hdr_offset:10;
  671. uint64_t frag_hit:1;
  672. uint64_t frag_rule:4;
  673. uint64_t reserved_4:16;
  674. };
  675. struct ipa3_hw_pkt_status_hw_v5_0 {
  676. uint64_t status_opcode : 8;
  677. uint64_t exception : 8;
  678. uint64_t status_mask : 16;
  679. uint64_t pkt_len : 16;
  680. uint64_t endp_src_idx : 8;
  681. uint64_t reserved_1 : 3;
  682. uint64_t route_local : 1;
  683. uint64_t route_hash : 1;
  684. uint64_t reserved_2 : 3;
  685. uint64_t metadata : 32;
  686. uint64_t filt_local : 1;
  687. uint64_t filt_hash : 1;
  688. uint64_t filt_global : 1;
  689. uint64_t ret_hdr : 1;
  690. uint64_t filt_rule_id : 10;
  691. uint64_t route_tbl_idx : 8;
  692. uint64_t route_rule_id : 10;
  693. uint64_t nat_hit : 1;
  694. uint64_t nat_tbl_idx : 13;
  695. uint64_t nat_type : 2;
  696. uint64_t tag : 48;
  697. uint64_t seq_num : 8;
  698. uint64_t time_day_ctr : 24;
  699. uint64_t hdr_local : 1;
  700. uint64_t hdr_offset : 10;
  701. uint64_t frag_hit : 1;
  702. uint64_t frag_rule : 4;
  703. uint64_t endp_dest_idx : 8;
  704. uint64_t reserved_4 : 7;
  705. uint64_t ucp : 1;
  706. };
  707. struct ipa3_hw_pkt_status_hw_v5_5 {
  708. uint64_t status_opcode:8;
  709. uint64_t exception:8;
  710. uint64_t status_mask:16;
  711. uint64_t pkt_len:16;
  712. uint64_t endp_src_idx:8;
  713. uint64_t reserved_1:3;
  714. uint64_t rt_local:1;
  715. uint64_t rt_hash:1;
  716. uint64_t reserved_2:3;
  717. uint64_t metadata:32;
  718. uint64_t flt_local:1;
  719. uint64_t flt_hash:1;
  720. uint64_t flt_global:1;
  721. uint64_t flt_ret_hdr:1;
  722. uint64_t flt_rule_id:10;
  723. uint64_t rt_tbl_idx:8;
  724. uint64_t rt_rule_id:10;
  725. uint64_t nat_hit:1;
  726. uint64_t nat_entry_idx:13;
  727. uint64_t nat_type:2;
  728. uint64_t tag_info:36;
  729. uint64_t egress_tc:6;
  730. uint64_t ingress_tc:6;
  731. uint64_t seq_num:8;
  732. uint64_t time_of_day_ctr:24;
  733. uint64_t hdr_local:1;
  734. uint64_t hdr_offset:10;
  735. uint64_t frag_hit:1;
  736. uint64_t frag_rule:4;
  737. uint64_t endp_dest_idx:8;
  738. uint64_t hw_specific:4;
  739. uint64_t nat_exc_suppress:1;
  740. uint64_t tsp:1;
  741. uint64_t ttl_dec:1;
  742. uint64_t ucp:1;
  743. };
  744. #endif