/drivers/net/ethernet/intel/ice/ice_protocol_type.h

https://gitlab.com/dieselnutjob/linux-next · C Header · 243 lines · 179 code · 32 blank · 32 comment · 0 complexity · a02acb599797088b703bc9cd6c63a9e3 MD5 · raw file

  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2019, Intel Corporation. */
  3. #ifndef _ICE_PROTOCOL_TYPE_H_
  4. #define _ICE_PROTOCOL_TYPE_H_
  5. #define ICE_IPV6_ADDR_LENGTH 16
  6. /* Each recipe can match up to 5 different fields. Fields to match can be meta-
  7. * data, values extracted from packet headers, or results from other recipes.
  8. * One of the 5 fields is reserved for matching the switch ID. So, up to 4
  9. * recipes can provide intermediate results to another one through chaining,
  10. * e.g. recipes 0, 1, 2, and 3 can provide intermediate results to recipe 4.
  11. */
  12. #define ICE_NUM_WORDS_RECIPE 4
  13. /* Max recipes that can be chained */
  14. #define ICE_MAX_CHAIN_RECIPE 5
  15. /* 1 word reserved for switch ID from allowed 5 words.
  16. * So a recipe can have max 4 words. And you can chain 5 such recipes
  17. * together. So maximum words that can be programmed for look up is 5 * 4.
  18. */
  19. #define ICE_MAX_CHAIN_WORDS (ICE_NUM_WORDS_RECIPE * ICE_MAX_CHAIN_RECIPE)
  20. /* Field vector index corresponding to chaining */
  21. #define ICE_CHAIN_FV_INDEX_START 47
  22. enum ice_protocol_type {
  23. ICE_MAC_OFOS = 0,
  24. ICE_MAC_IL,
  25. ICE_ETYPE_OL,
  26. ICE_VLAN_OFOS,
  27. ICE_IPV4_OFOS,
  28. ICE_IPV4_IL,
  29. ICE_IPV6_OFOS,
  30. ICE_IPV6_IL,
  31. ICE_TCP_IL,
  32. ICE_UDP_OF,
  33. ICE_UDP_ILOS,
  34. ICE_VXLAN,
  35. ICE_GENEVE,
  36. ICE_NVGRE,
  37. ICE_VXLAN_GPE,
  38. ICE_SCTP_IL,
  39. ICE_PROTOCOL_LAST
  40. };
  41. enum ice_sw_tunnel_type {
  42. ICE_NON_TUN = 0,
  43. ICE_SW_TUN_AND_NON_TUN,
  44. ICE_SW_TUN_VXLAN,
  45. ICE_SW_TUN_GENEVE,
  46. ICE_SW_TUN_NVGRE,
  47. ICE_ALL_TUNNELS /* All tunnel types including NVGRE */
  48. };
  49. /* Decoders for ice_prot_id:
  50. * - F: First
  51. * - I: Inner
  52. * - L: Last
  53. * - O: Outer
  54. * - S: Single
  55. */
  56. enum ice_prot_id {
  57. ICE_PROT_ID_INVAL = 0,
  58. ICE_PROT_MAC_OF_OR_S = 1,
  59. ICE_PROT_MAC_IL = 4,
  60. ICE_PROT_ETYPE_OL = 9,
  61. ICE_PROT_ETYPE_IL = 10,
  62. ICE_PROT_IPV4_OF_OR_S = 32,
  63. ICE_PROT_IPV4_IL = 33,
  64. ICE_PROT_IPV6_OF_OR_S = 40,
  65. ICE_PROT_IPV6_IL = 41,
  66. ICE_PROT_TCP_IL = 49,
  67. ICE_PROT_UDP_OF = 52,
  68. ICE_PROT_UDP_IL_OR_S = 53,
  69. ICE_PROT_GRE_OF = 64,
  70. ICE_PROT_ESP_F = 88,
  71. ICE_PROT_ESP_2 = 89,
  72. ICE_PROT_SCTP_IL = 96,
  73. ICE_PROT_ICMP_IL = 98,
  74. ICE_PROT_ICMPV6_IL = 100,
  75. ICE_PROT_PPPOE = 103,
  76. ICE_PROT_L2TPV3 = 104,
  77. ICE_PROT_ARP_OF = 118,
  78. ICE_PROT_META_ID = 255, /* when offset == metadata */
  79. ICE_PROT_INVALID = 255 /* when offset == ICE_FV_OFFSET_INVAL */
  80. };
  81. #define ICE_VNI_OFFSET 12 /* offset of VNI from ICE_PROT_UDP_OF */
  82. #define ICE_MAC_OFOS_HW 1
  83. #define ICE_MAC_IL_HW 4
  84. #define ICE_ETYPE_OL_HW 9
  85. #define ICE_VLAN_OF_HW 16
  86. #define ICE_VLAN_OL_HW 17
  87. #define ICE_IPV4_OFOS_HW 32
  88. #define ICE_IPV4_IL_HW 33
  89. #define ICE_IPV6_OFOS_HW 40
  90. #define ICE_IPV6_IL_HW 41
  91. #define ICE_TCP_IL_HW 49
  92. #define ICE_UDP_ILOS_HW 53
  93. #define ICE_GRE_OF_HW 64
  94. #define ICE_UDP_OF_HW 52 /* UDP Tunnels */
  95. #define ICE_META_DATA_ID_HW 255 /* this is used for tunnel type */
  96. #define ICE_MDID_SIZE 2
  97. #define ICE_TUN_FLAG_MDID 21
  98. #define ICE_TUN_FLAG_MDID_OFF (ICE_MDID_SIZE * ICE_TUN_FLAG_MDID)
  99. #define ICE_TUN_FLAG_MASK 0xFF
  100. #define ICE_TUN_FLAG_FV_IND 2
  101. /* Mapping of software defined protocol ID to hardware defined protocol ID */
  102. struct ice_protocol_entry {
  103. enum ice_protocol_type type;
  104. u8 protocol_id;
  105. };
  106. struct ice_ether_hdr {
  107. u8 dst_addr[ETH_ALEN];
  108. u8 src_addr[ETH_ALEN];
  109. };
  110. struct ice_ethtype_hdr {
  111. __be16 ethtype_id;
  112. };
  113. struct ice_ether_vlan_hdr {
  114. u8 dst_addr[ETH_ALEN];
  115. u8 src_addr[ETH_ALEN];
  116. __be32 vlan_id;
  117. };
  118. struct ice_vlan_hdr {
  119. __be16 type;
  120. __be16 vlan;
  121. };
  122. struct ice_ipv4_hdr {
  123. u8 version;
  124. u8 tos;
  125. __be16 total_length;
  126. __be16 id;
  127. __be16 frag_off;
  128. u8 time_to_live;
  129. u8 protocol;
  130. __be16 check;
  131. __be32 src_addr;
  132. __be32 dst_addr;
  133. };
  134. struct ice_ipv6_hdr {
  135. __be32 be_ver_tc_flow;
  136. __be16 payload_len;
  137. u8 next_hdr;
  138. u8 hop_limit;
  139. u8 src_addr[ICE_IPV6_ADDR_LENGTH];
  140. u8 dst_addr[ICE_IPV6_ADDR_LENGTH];
  141. };
  142. struct ice_sctp_hdr {
  143. __be16 src_port;
  144. __be16 dst_port;
  145. __be32 verification_tag;
  146. __be32 check;
  147. };
  148. struct ice_l4_hdr {
  149. __be16 src_port;
  150. __be16 dst_port;
  151. __be16 len;
  152. __be16 check;
  153. };
  154. struct ice_udp_tnl_hdr {
  155. __be16 field;
  156. __be16 proto_type;
  157. __be32 vni; /* only use lower 24-bits */
  158. };
  159. struct ice_nvgre_hdr {
  160. __be16 flags;
  161. __be16 protocol;
  162. __be32 tni_flow;
  163. };
  164. union ice_prot_hdr {
  165. struct ice_ether_hdr eth_hdr;
  166. struct ice_ethtype_hdr ethertype;
  167. struct ice_vlan_hdr vlan_hdr;
  168. struct ice_ipv4_hdr ipv4_hdr;
  169. struct ice_ipv6_hdr ipv6_hdr;
  170. struct ice_l4_hdr l4_hdr;
  171. struct ice_sctp_hdr sctp_hdr;
  172. struct ice_udp_tnl_hdr tnl_hdr;
  173. struct ice_nvgre_hdr nvgre_hdr;
  174. };
  175. /* This is mapping table entry that maps every word within a given protocol
  176. * structure to the real byte offset as per the specification of that
  177. * protocol header.
  178. * for e.g. dst address is 3 words in ethertype header and corresponding bytes
  179. * are 0, 2, 3 in the actual packet header and src address is at 4, 6, 8
  180. */
  181. struct ice_prot_ext_tbl_entry {
  182. enum ice_protocol_type prot_type;
  183. /* Byte offset into header of given protocol type */
  184. u8 offs[sizeof(union ice_prot_hdr)];
  185. };
  186. /* Extractions to be looked up for a given recipe */
  187. struct ice_prot_lkup_ext {
  188. u16 prot_type;
  189. u8 n_val_words;
  190. /* create a buffer to hold max words per recipe */
  191. u16 field_off[ICE_MAX_CHAIN_WORDS];
  192. u16 field_mask[ICE_MAX_CHAIN_WORDS];
  193. struct ice_fv_word fv_words[ICE_MAX_CHAIN_WORDS];
  194. /* Indicate field offsets that have field vector indices assigned */
  195. DECLARE_BITMAP(done, ICE_MAX_CHAIN_WORDS);
  196. };
  197. struct ice_pref_recipe_group {
  198. u8 n_val_pairs; /* Number of valid pairs */
  199. struct ice_fv_word pairs[ICE_NUM_WORDS_RECIPE];
  200. u16 mask[ICE_NUM_WORDS_RECIPE];
  201. };
  202. struct ice_recp_grp_entry {
  203. struct list_head l_entry;
  204. #define ICE_INVAL_CHAIN_IND 0xFF
  205. u16 rid;
  206. u8 chain_idx;
  207. u16 fv_idx[ICE_NUM_WORDS_RECIPE];
  208. u16 fv_mask[ICE_NUM_WORDS_RECIPE];
  209. struct ice_pref_recipe_group r_group;
  210. };
  211. #endif /* _ICE_PROTOCOL_TYPE_H_ */