ipa_ipv6cti.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (c) 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. #ifndef IPA_IPV6CTI_H
  30. #define IPA_IPV6CTI_H
  31. #include "ipa_table.h"
  32. #include "ipa_mem_descriptor.h"
  33. #include "ipa_nat_utils.h"
  34. #define IPA_IPV6CT_MAX_TBLS 1
  35. #define IPA_IPV6CT_RULE_FLAG_FIELD_OFFSET 34
  36. #define IPA_IPV6CT_RULE_NEXT_FIELD_OFFSET 40
  37. #define IPA_IPV6CT_RULE_PROTO_FIELD_OFFSET 38
  38. #define IPA_IPV6CT_FLAG_ENABLE_BIT 1
  39. #define IPA_IPV6CT_DIRECTION_ALLOW_BIT 1
  40. #define IPA_IPV6CT_DIRECTION_DISALLOW_BIT 0
  41. #define IPA_IPV6CT_INVALID_PROTO_FIELD_VALUE 0xFF00
  42. #define IPA_IPV6CT_INVALID_PROTO_FIELD_CMP 0xFF
  43. typedef enum
  44. {
  45. IPA_IPV6CT_TABLE_FLAGS,
  46. IPA_IPV6CT_TABLE_NEXT_INDEX,
  47. IPA_IPV6CT_TABLE_PROTOCOL,
  48. IPA_IPV6CT_TABLE_DMA_CMD_MAX
  49. } ipa_ipv6ct_table_dma_cmd_type;
  50. /*------------------------ IPV6CT Table Entry ---------------------------------------------------
  51. -------------------------------------------------------------------------------------------------
  52. | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  53. ---------------------------------------------------------------------------------------------------
  54. | Outbound Src IPv6 Address (8 LSB Bytes) |
  55. ---------------------------------------------------------------------------------------------------
  56. | Outbound Src IPv6 Address (8 MSB Bytes) |
  57. ---------------------------------------------------------------------------------------------------
  58. | Outbound Dest IPv6 Address (8 LSB Bytes) |
  59. ---------------------------------------------------------------------------------------------------
  60. | Outbound Dest IPv6 Address (8 MSB Bytes) |
  61. ---------------------------------------------------------------------------------------------------
  62. | Protocol | TimeStamp (3B) | Flags (2B) |Rsvd |S |uC activatio|
  63. | (1B) | |Enable|Redirect|Resv |[15:14]|13|Index [12:0]|
  64. ---------------------------------------------------------------------------------------------------
  65. |Reserved |Settings | Src Port (2B) | Dest Port (2B) | Next Index (2B) |
  66. | (1B) | (1B) | | | |
  67. ---------------------------------------------------------------------------------------------------
  68. | SW Specific Parameters(4B) | Reserved (4B) |
  69. | Prev Index (2B) | Reserved (2B) | |
  70. ---------------------------------------------------------------------------------------------------
  71. | Reserved (8B) |
  72. ---------------------------------------------------------------------------------------------------
  73. Settings(1B)
  74. -----------------------------------------------
  75. |IN Allowed|OUT Allowed|Reserved|uC processing|
  76. |[7:7] |[6:6] |[5:1] |[0:0] |
  77. -----------------------------------------------
  78. Dont change below structure definition.
  79. It should be same as above(little endian order)
  80. -------------------------------------------------------------------------------------------------*/
  81. typedef struct
  82. {
  83. uint64_t src_ipv6_lsb : 64;
  84. uint64_t src_ipv6_msb : 64;
  85. uint64_t dest_ipv6_lsb : 64;
  86. uint64_t dest_ipv6_msb : 64;
  87. uint64_t uc_activation_index : 13;
  88. uint64_t s : 1;
  89. uint64_t rsvd1 : 16;
  90. uint64_t redirect : 1;
  91. uint64_t enable : 1;
  92. uint64_t time_stamp : 24;
  93. uint64_t protocol : 8;
  94. uint64_t next_index : 16;
  95. uint64_t dest_port : 16;
  96. uint64_t src_port : 16;
  97. uint64_t ucp : 1;
  98. uint64_t rsvd2 : 5;
  99. uint64_t out_allowed : 1;
  100. uint64_t in_allowed : 1;
  101. uint64_t rsvd3 : 8;
  102. uint64_t rsvd4 : 48;
  103. uint64_t prev_index : 16;
  104. uint64_t rsvd5 : 64;
  105. } ipa_ipv6ct_hw_entry;
  106. /*
  107. ----------------------
  108. | 1 | 0 |
  109. ----------------------
  110. | Flags(2B) |
  111. |Enable|Redirect|Resv|
  112. ----------------------
  113. */
  114. typedef struct
  115. {
  116. uint16_t rsvd1 : 14;
  117. uint16_t redirect : 1;
  118. uint16_t enable : 1;
  119. } ipa_ipv6ct_flags;
  120. typedef struct
  121. {
  122. ipa_mem_descriptor mem_desc;
  123. ipa_table table;
  124. ipa_table_dma_cmd_helper table_dma_cmd_helpers[IPA_IPV6CT_TABLE_DMA_CMD_MAX];
  125. } ipa_ipv6ct_table;
  126. typedef struct
  127. {
  128. ipa_descriptor* ipa_desc;
  129. ipa_ipv6ct_table tables[IPA_IPV6CT_MAX_TBLS];
  130. uint8_t table_cnt;
  131. } ipa_ipv6ct;
  132. #endif