1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2014-2023 Broadcom 3 * All rights reserved. 4 */ 5 6 #ifndef _ULP_RTE_PARSER_H_ 7 #define _ULP_RTE_PARSER_H_ 8 9 #include <rte_log.h> 10 #include <rte_flow.h> 11 #include <rte_flow_driver.h> 12 #include "ulp_template_db_enum.h" 13 #include "ulp_template_struct.h" 14 #include "ulp_mapper.h" 15 #include "bnxt_tf_common.h" 16 17 /* defines to be used in the tunnel header parsing */ 18 #define BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS 2 19 #define BNXT_ULP_ENCAP_IPV4_ID_PROTO 6 20 #define BNXT_ULP_ENCAP_IPV4_DEST_IP 4 21 #define BNXT_ULP_ENCAP_IPV4_SIZE 12 22 #define BNXT_ULP_ENCAP_IPV6_VTC_FLOW 4 23 #define BNXT_ULP_ENCAP_IPV6_PROTO_TTL 2 24 #define BNXT_ULP_ENCAP_IPV6_DO 2 25 #define BNXT_ULP_ENCAP_IPV6_SIZE 24 26 #define BNXT_ULP_ENCAP_UDP_SIZE 4 27 #define BNXT_ULP_INVALID_SVIF_VAL -1UL 28 29 #define BNXT_ULP_GET_IPV6_VER(vtcf) \ 30 (((vtcf) & BNXT_ULP_PARSER_IPV6_VER_MASK) >> 28) 31 #define BNXT_ULP_GET_IPV6_TC(vtcf) \ 32 (((vtcf) & BNXT_ULP_PARSER_IPV6_TC) >> 20) 33 #define BNXT_ULP_GET_IPV6_FLOWLABEL(vtcf) \ 34 ((vtcf) & BNXT_ULP_PARSER_IPV6_FLOW_LABEL) 35 #define BNXT_ULP_PARSER_IPV6_VER_MASK 0xf0000000 36 #define BNXT_ULP_IPV6_DFLT_VER 0x60000000 37 #define BNXT_ULP_PARSER_IPV6_TC 0x0ff00000 38 #define BNXT_ULP_PARSER_IPV6_FLOW_LABEL 0x000fffff 39 #define BNXT_ULP_DEFAULT_TTL 64 40 41 enum bnxt_ulp_prsr_action { 42 ULP_PRSR_ACT_DEFAULT = 0, 43 ULP_PRSR_ACT_MATCH_IGNORE = 1, 44 ULP_PRSR_ACT_MASK_IGNORE = 2, 45 ULP_PRSR_ACT_SPEC_IGNORE = 4 46 }; 47 48 void 49 bnxt_ulp_init_mapper_params(struct bnxt_ulp_mapper_parms *mparms, 50 struct ulp_rte_parser_params *params, 51 enum bnxt_ulp_fdb_type flow_type); 52 53 /* Function to handle the parsing of the RTE port id. */ 54 int32_t 55 ulp_rte_parser_implicit_match_port_process(struct ulp_rte_parser_params *param); 56 57 /* Function to handle the implicit action port id */ 58 int32_t 59 ulp_rte_parser_implicit_act_port_process(struct ulp_rte_parser_params *params); 60 61 /* 62 * Function to handle the parsing of RTE Flows and placing 63 * the RTE flow items into the ulp structures. 64 */ 65 int32_t 66 bnxt_ulp_rte_parser_hdr_parse(const struct rte_flow_item pattern[], 67 struct ulp_rte_parser_params *params); 68 69 /* 70 * Function to handle the parsing of RTE Flows and placing 71 * the RTE flow actions into the ulp structures. 72 */ 73 int32_t 74 bnxt_ulp_rte_parser_act_parse(const struct rte_flow_action actions[], 75 struct ulp_rte_parser_params *params); 76 77 /* 78 * Function to handle the post processing of the parsing details 79 */ 80 void 81 bnxt_ulp_rte_parser_post_process(struct ulp_rte_parser_params *params); 82 83 /* Function to handle the parsing of RTE Flow item PF Header. */ 84 int32_t 85 ulp_rte_pf_hdr_handler(const struct rte_flow_item *item, 86 struct ulp_rte_parser_params *params); 87 88 /* Function to handle the parsing of RTE Flow item VF Header. */ 89 int32_t 90 ulp_rte_vf_hdr_handler(const struct rte_flow_item *item, 91 struct ulp_rte_parser_params *params); 92 93 /* Parse items PORT_ID, PORT_REPRESENTOR and REPRESENTED_PORT. */ 94 int32_t 95 ulp_rte_port_hdr_handler(const struct rte_flow_item *item, 96 struct ulp_rte_parser_params *params); 97 98 /* Function to handle the RTE item Ethernet Header. */ 99 int32_t 100 ulp_rte_eth_hdr_handler(const struct rte_flow_item *item, 101 struct ulp_rte_parser_params *params); 102 103 /* Function to handle the parsing of RTE Flow item Vlan Header. */ 104 int32_t 105 ulp_rte_vlan_hdr_handler(const struct rte_flow_item *item, 106 struct ulp_rte_parser_params *params); 107 108 /* Function to handle the parsing of RTE Flow item IPV4 Header. */ 109 int32_t 110 ulp_rte_ipv4_hdr_handler(const struct rte_flow_item *item, 111 struct ulp_rte_parser_params *params); 112 113 /* Function to handle the parsing of RTE Flow item IPV6 Header. */ 114 int32_t 115 ulp_rte_ipv6_hdr_handler(const struct rte_flow_item *item, 116 struct ulp_rte_parser_params *params); 117 118 /* Function to handle the parsing of RTE Flow item UDP Header. */ 119 int32_t 120 ulp_rte_udp_hdr_handler(const struct rte_flow_item *item, 121 struct ulp_rte_parser_params *params); 122 123 /* Function to handle the parsing of RTE Flow item TCP Header. */ 124 int32_t 125 ulp_rte_tcp_hdr_handler(const struct rte_flow_item *item, 126 struct ulp_rte_parser_params *params); 127 128 /* Function to handle the parsing of RTE Flow item Vxlan Header. */ 129 int32_t 130 ulp_rte_vxlan_hdr_handler(const struct rte_flow_item *item, 131 struct ulp_rte_parser_params *params); 132 133 /* Function to handle the parsing of RTE Flow item Vxlan GPE Header. */ 134 int32_t 135 ulp_rte_vxlan_gpe_hdr_handler(const struct rte_flow_item *item, 136 struct ulp_rte_parser_params *params); 137 138 /* Function to handle the parsing of RTE Flow item GENEVE Header. */ 139 int32_t 140 ulp_rte_geneve_hdr_handler(const struct rte_flow_item *item, 141 struct ulp_rte_parser_params *params); 142 143 /* Function to handle the parsing of RTE Flow item GRE Header. */ 144 int32_t 145 ulp_rte_gre_hdr_handler(const struct rte_flow_item *item, 146 struct ulp_rte_parser_params *params); 147 148 int32_t 149 ulp_rte_item_any_handler(const struct rte_flow_item *item __rte_unused, 150 struct ulp_rte_parser_params *params __rte_unused); 151 152 /* Function to handle the parsing of RTE Flow item ICMP Header. */ 153 int32_t 154 ulp_rte_icmp_hdr_handler(const struct rte_flow_item *item, 155 struct ulp_rte_parser_params *params); 156 157 /* Function to handle the parsing of RTE Flow item ICMP6 Header. */ 158 int32_t 159 ulp_rte_icmp6_hdr_handler(const struct rte_flow_item *item, 160 struct ulp_rte_parser_params *params); 161 162 /* Function to handle the parsing of RTE Flow item ECPRI Header. */ 163 int32_t 164 ulp_rte_ecpri_hdr_handler(const struct rte_flow_item *item, 165 struct ulp_rte_parser_params *params); 166 167 /* Function to handle the parsing of RTE Flow item void Header. */ 168 int32_t 169 ulp_rte_void_hdr_handler(const struct rte_flow_item *item, 170 struct ulp_rte_parser_params *params); 171 172 /* Function to handle the parsing of RTE Flow action void Header. */ 173 int32_t 174 ulp_rte_void_act_handler(const struct rte_flow_action *action_item, 175 struct ulp_rte_parser_params *params); 176 177 /* Function to handle the parsing of RTE Flow action RSS Header. */ 178 int32_t 179 ulp_rte_rss_act_handler(const struct rte_flow_action *action_item, 180 struct ulp_rte_parser_params *params); 181 182 /* Function to handle the parsing of RTE Flow action Mark Header. */ 183 int32_t 184 ulp_rte_mark_act_handler(const struct rte_flow_action *action_item, 185 struct ulp_rte_parser_params *params); 186 187 /* Function to handle the parsing of RTE Flow action vxlan_encap Header. */ 188 int32_t 189 ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item, 190 struct ulp_rte_parser_params *params); 191 192 /* Function to handle the parsing of RTE Flow action vxlan_encap Header. */ 193 int32_t 194 ulp_rte_vxlan_decap_act_handler(const struct rte_flow_action *action_item, 195 struct ulp_rte_parser_params *params); 196 197 /* Function to handle the parsing of RTE Flow action drop Header. */ 198 int32_t 199 ulp_rte_drop_act_handler(const struct rte_flow_action *action_item, 200 struct ulp_rte_parser_params *params); 201 202 /* Function to handle the parsing of RTE Flow action count. */ 203 int32_t 204 ulp_rte_count_act_handler(const struct rte_flow_action *action_item, 205 struct ulp_rte_parser_params *params); 206 207 /* Function to handle the parsing of RTE Flow action PF. */ 208 int32_t 209 ulp_rte_pf_act_handler(const struct rte_flow_action *action_item, 210 struct ulp_rte_parser_params *params); 211 212 /* Function to handle the parsing of RTE Flow action VF. */ 213 int32_t 214 ulp_rte_vf_act_handler(const struct rte_flow_action *action_item, 215 struct ulp_rte_parser_params *params); 216 217 /* Parse actions PORT_ID, PORT_REPRESENTOR and REPRESENTED_PORT. */ 218 int32_t 219 ulp_rte_port_act_handler(const struct rte_flow_action *act_item, 220 struct ulp_rte_parser_params *params); 221 222 /* Function to handle the parsing of RTE Flow action pop vlan. */ 223 int32_t 224 ulp_rte_of_pop_vlan_act_handler(const struct rte_flow_action *action_item, 225 struct ulp_rte_parser_params *params); 226 227 /* Function to handle the parsing of RTE Flow action push vlan. */ 228 int32_t 229 ulp_rte_of_push_vlan_act_handler(const struct rte_flow_action *action_item, 230 struct ulp_rte_parser_params *params); 231 232 /* Function to handle the parsing of RTE Flow action set vlan id. */ 233 int32_t 234 ulp_rte_of_set_vlan_vid_act_handler(const struct rte_flow_action *action_item, 235 struct ulp_rte_parser_params *params); 236 237 /* Function to handle the parsing of RTE Flow action set vlan pcp. */ 238 int32_t 239 ulp_rte_of_set_vlan_pcp_act_handler(const struct rte_flow_action *action_item, 240 struct ulp_rte_parser_params *params); 241 242 /* Function to handle the parsing of RTE Flow action set ipv4 src.*/ 243 int32_t 244 ulp_rte_set_ipv4_src_act_handler(const struct rte_flow_action *action_item, 245 struct ulp_rte_parser_params *params); 246 247 /* Function to handle the parsing of RTE Flow action set ipv4 dst.*/ 248 int32_t 249 ulp_rte_set_ipv4_dst_act_handler(const struct rte_flow_action *action_item, 250 struct ulp_rte_parser_params *params); 251 252 /* Function to handle the parsing of RTE Flow action set ipv6 src.*/ 253 int32_t 254 ulp_rte_set_ipv6_src_act_handler(const struct rte_flow_action *action_item, 255 struct ulp_rte_parser_params *params); 256 257 /* Function to handle the parsing of RTE Flow action set ipv6 dst.*/ 258 int32_t 259 ulp_rte_set_ipv6_dst_act_handler(const struct rte_flow_action *action_item, 260 struct ulp_rte_parser_params *params); 261 262 /* Function to handle the parsing of RTE Flow action set tp src.*/ 263 int32_t 264 ulp_rte_set_tp_src_act_handler(const struct rte_flow_action *action_item, 265 struct ulp_rte_parser_params *params); 266 267 /* Function to handle the parsing of RTE Flow action set tp dst.*/ 268 int32_t 269 ulp_rte_set_tp_dst_act_handler(const struct rte_flow_action *action_item, 270 struct ulp_rte_parser_params *params); 271 272 /* Function to handle the parsing of RTE Flow action dec ttl.*/ 273 int32_t 274 ulp_rte_dec_ttl_act_handler(const struct rte_flow_action *action_item, 275 struct ulp_rte_parser_params *params); 276 /* Function to handle the parsing of RTE Flow action set ttl.*/ 277 int32_t 278 ulp_rte_set_ttl_act_handler(const struct rte_flow_action *action_item, 279 struct ulp_rte_parser_params *params); 280 /* Function to handle the parsing of RTE Flow action set mac src.*/ 281 int32_t 282 ulp_rte_set_mac_src_act_handler(const struct rte_flow_action *action_item, 283 struct ulp_rte_parser_params *params); 284 285 /* Function to handle the parsing of RTE Flow action set mac dst.*/ 286 int32_t 287 ulp_rte_set_mac_dst_act_handler(const struct rte_flow_action *action_item, 288 struct ulp_rte_parser_params *params); 289 290 /* Function to handle the parsing of RTE Flow action JUMP .*/ 291 int32_t 292 ulp_rte_jump_act_handler(const struct rte_flow_action *action_item, 293 struct ulp_rte_parser_params *params); 294 295 int32_t 296 ulp_rte_sample_act_handler(const struct rte_flow_action *action_item, 297 struct ulp_rte_parser_params *params); 298 299 int32_t 300 ulp_rte_action_hdlr_handler(const struct rte_flow_action *action_item, 301 struct ulp_rte_parser_params *params); 302 303 int32_t 304 ulp_vendor_vxlan_decap_act_handler(const struct rte_flow_action *action_item, 305 struct ulp_rte_parser_params *params); 306 307 int32_t 308 ulp_rte_vendor_vxlan_decap_hdr_handler(const struct rte_flow_item *item, 309 struct ulp_rte_parser_params *params); 310 311 int32_t 312 ulp_rte_queue_act_handler(const struct rte_flow_action *act_item, 313 struct ulp_rte_parser_params *param); 314 315 /* Function to handle the parsing of RTE Flow action set mac src.*/ 316 int32_t 317 ulp_rte_set_mac_src_act_handler(const struct rte_flow_action *action_item, 318 struct ulp_rte_parser_params *params); 319 320 /* Function to handle the parsing of RTE Flow action set mac dst.*/ 321 int32_t 322 ulp_rte_set_mac_dst_act_handler(const struct rte_flow_action *action_item, 323 struct ulp_rte_parser_params *params); 324 325 /* Function to handle the parsing of RTE Flow action meter. */ 326 int32_t 327 ulp_rte_meter_act_handler(const struct rte_flow_action *action_item, 328 struct ulp_rte_parser_params *params); 329 #endif /* _ULP_RTE_PARSER_H_ */ 330