Create pattern template */
| 2307 | |
| 2308 | /** Create pattern template */ |
| 2309 | int |
| 2310 | port_flow_pattern_template_create(portid_t port_id, uint32_t id, |
| 2311 | const struct rte_flow_pattern_template_attr *attr, |
| 2312 | const struct rte_flow_item *pattern) |
| 2313 | { |
| 2314 | struct rte_port *port; |
| 2315 | struct port_template *pit; |
| 2316 | int ret; |
| 2317 | struct rte_flow_error error; |
| 2318 | |
| 2319 | if (port_id_is_invalid(port_id, ENABLED_WARN) || |
| 2320 | port_id == (portid_t)RTE_PORT_ALL) |
| 2321 | return -EINVAL; |
| 2322 | port = &ports[port_id]; |
| 2323 | ret = template_alloc(id, &pit, &port->pattern_templ_list); |
| 2324 | if (ret) |
| 2325 | return ret; |
| 2326 | /* Poisoning to make sure PMDs update it in case of error. */ |
| 2327 | memset(&error, 0x22, sizeof(error)); |
| 2328 | pit->template.pattern_template = rte_flow_pattern_template_create(port_id, |
| 2329 | attr, pattern, &error); |
| 2330 | if (!pit->template.pattern_template) { |
| 2331 | uint32_t destroy_id = pit->id; |
| 2332 | port_flow_pattern_template_destroy(port_id, 1, &destroy_id); |
| 2333 | return port_flow_complain(&error); |
| 2334 | } |
| 2335 | printf("Pattern template #%u created\n", pit->id); |
| 2336 | return 0; |
| 2337 | } |
| 2338 | |
| 2339 | /** Destroy pattern template */ |
| 2340 | int |
no test coverage detected