1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 Mellanox Technologies, Ltd
11 /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
13 #pragma GCC diagnostic ignored "-Wpedantic"
15 #include <infiniband/verbs.h>
17 #pragma GCC diagnostic error "-Wpedantic"
20 #include <rte_common.h>
21 #include <rte_ether.h>
22 #include <rte_eth_ctrl.h>
23 #include <rte_ethdev_driver.h>
25 #include <rte_flow_driver.h>
26 #include <rte_malloc.h>
30 #include "mlx5_defs.h"
32 #include "mlx5_glue.h"
33 #include "mlx5_flow.h"
35 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
41 * Pointer to the rte_eth_dev structure.
45 * Attributes of flow that includes this item.
47 * Pointer to error structure.
50 * 0 on success, a negative errno value otherwise and rte_errno is set.
53 flow_dv_validate_item_meta(struct rte_eth_dev *dev,
54 const struct rte_flow_item *item,
55 const struct rte_flow_attr *attr,
56 struct rte_flow_error *error)
58 const struct rte_flow_item_meta *spec = item->spec;
59 const struct rte_flow_item_meta *mask = item->mask;
60 const struct rte_flow_item_meta nic_mask = {
61 .data = RTE_BE32(UINT32_MAX)
64 uint64_t offloads = dev->data->dev_conf.txmode.offloads;
66 if (!(offloads & DEV_TX_OFFLOAD_MATCH_METADATA))
67 return rte_flow_error_set(error, EPERM,
68 RTE_FLOW_ERROR_TYPE_ITEM,
70 "match on metadata offload "
71 "configuration is off for this port");
73 return rte_flow_error_set(error, EINVAL,
74 RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
76 "data cannot be empty");
78 return rte_flow_error_set(error, EINVAL,
79 RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
81 "data cannot be zero");
83 mask = &rte_flow_item_meta_mask;
84 ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask,
85 (const uint8_t *)&nic_mask,
86 sizeof(struct rte_flow_item_meta),
91 return rte_flow_error_set(error, ENOTSUP,
92 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
94 "pattern not supported for ingress");
99 * Verify the @p attributes will be correctly understood by the NIC and store
100 * them in the @p flow if everything is correct.
103 * Pointer to dev struct.
104 * @param[in] attributes
105 * Pointer to flow attributes
107 * Pointer to error structure.
110 * 0 on success, a negative errno value otherwise and rte_errno is set.
113 flow_dv_validate_attributes(struct rte_eth_dev *dev,
114 const struct rte_flow_attr *attributes,
115 struct rte_flow_error *error)
117 struct priv *priv = dev->data->dev_private;
118 uint32_t priority_max = priv->config.flow_prio - 1;
120 if (attributes->group)
121 return rte_flow_error_set(error, ENOTSUP,
122 RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
124 "groups is not supported");
125 if (attributes->priority != MLX5_FLOW_PRIO_RSVD &&
126 attributes->priority >= priority_max)
127 return rte_flow_error_set(error, ENOTSUP,
128 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
130 "priority out of range");
131 if (attributes->transfer)
132 return rte_flow_error_set(error, ENOTSUP,
133 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
135 "transfer is not supported");
136 if (!(attributes->egress ^ attributes->ingress))
137 return rte_flow_error_set(error, ENOTSUP,
138 RTE_FLOW_ERROR_TYPE_ATTR, NULL,
139 "must specify exactly one of "
140 "ingress or egress");
145 * Internal validation function. For validating both actions and items.
148 * Pointer to the rte_eth_dev structure.
150 * Pointer to the flow attributes.
152 * Pointer to the list of items.
154 * Pointer to the list of actions.
156 * Pointer to the error structure.
159 * 0 on success, a negative errno value otherwise and rte_ernno is set.
162 flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
163 const struct rte_flow_item items[],
164 const struct rte_flow_action actions[],
165 struct rte_flow_error *error)
168 uint64_t action_flags = 0;
169 uint64_t item_flags = 0;
171 uint8_t next_protocol = 0xff;
176 ret = flow_dv_validate_attributes(dev, attr, error);
179 for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) {
180 tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
181 switch (items->type) {
182 case RTE_FLOW_ITEM_TYPE_VOID:
184 case RTE_FLOW_ITEM_TYPE_ETH:
185 ret = mlx5_flow_validate_item_eth(items, item_flags,
189 item_flags |= tunnel ? MLX5_FLOW_LAYER_INNER_L2 :
190 MLX5_FLOW_LAYER_OUTER_L2;
192 case RTE_FLOW_ITEM_TYPE_VLAN:
193 ret = mlx5_flow_validate_item_vlan(items, item_flags,
197 item_flags |= tunnel ? MLX5_FLOW_LAYER_INNER_VLAN :
198 MLX5_FLOW_LAYER_OUTER_VLAN;
200 case RTE_FLOW_ITEM_TYPE_IPV4:
201 ret = mlx5_flow_validate_item_ipv4(items, item_flags,
205 item_flags |= tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV4 :
206 MLX5_FLOW_LAYER_OUTER_L3_IPV4;
207 if (items->mask != NULL &&
208 ((const struct rte_flow_item_ipv4 *)
209 items->mask)->hdr.next_proto_id)
211 ((const struct rte_flow_item_ipv4 *)
212 (items->spec))->hdr.next_proto_id;
214 case RTE_FLOW_ITEM_TYPE_IPV6:
215 ret = mlx5_flow_validate_item_ipv6(items, item_flags,
219 item_flags |= tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV6 :
220 MLX5_FLOW_LAYER_OUTER_L3_IPV6;
221 if (items->mask != NULL &&
222 ((const struct rte_flow_item_ipv6 *)
223 items->mask)->hdr.proto)
225 ((const struct rte_flow_item_ipv6 *)
226 items->spec)->hdr.proto;
228 case RTE_FLOW_ITEM_TYPE_TCP:
229 ret = mlx5_flow_validate_item_tcp
232 &rte_flow_item_tcp_mask,
236 item_flags |= tunnel ? MLX5_FLOW_LAYER_INNER_L4_TCP :
237 MLX5_FLOW_LAYER_OUTER_L4_TCP;
239 case RTE_FLOW_ITEM_TYPE_UDP:
240 ret = mlx5_flow_validate_item_udp(items, item_flags,
245 item_flags |= tunnel ? MLX5_FLOW_LAYER_INNER_L4_UDP :
246 MLX5_FLOW_LAYER_OUTER_L4_UDP;
248 case RTE_FLOW_ITEM_TYPE_GRE:
249 case RTE_FLOW_ITEM_TYPE_NVGRE:
250 ret = mlx5_flow_validate_item_gre(items, item_flags,
251 next_protocol, error);
254 item_flags |= MLX5_FLOW_LAYER_GRE;
256 case RTE_FLOW_ITEM_TYPE_VXLAN:
257 ret = mlx5_flow_validate_item_vxlan(items, item_flags,
261 item_flags |= MLX5_FLOW_LAYER_VXLAN;
263 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
264 ret = mlx5_flow_validate_item_vxlan_gpe(items,
269 item_flags |= MLX5_FLOW_LAYER_VXLAN_GPE;
271 case RTE_FLOW_ITEM_TYPE_META:
272 ret = flow_dv_validate_item_meta(dev, items, attr,
276 item_flags |= MLX5_FLOW_ITEM_METADATA;
279 return rte_flow_error_set(error, ENOTSUP,
280 RTE_FLOW_ERROR_TYPE_ITEM,
281 NULL, "item not supported");
284 for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
285 if (actions_n == MLX5_DV_MAX_NUMBER_OF_ACTIONS)
286 return rte_flow_error_set(error, ENOTSUP,
287 RTE_FLOW_ERROR_TYPE_ACTION,
288 actions, "too many actions");
289 switch (actions->type) {
290 case RTE_FLOW_ACTION_TYPE_VOID:
292 case RTE_FLOW_ACTION_TYPE_FLAG:
293 ret = mlx5_flow_validate_action_flag(action_flags,
297 action_flags |= MLX5_FLOW_ACTION_FLAG;
300 case RTE_FLOW_ACTION_TYPE_MARK:
301 ret = mlx5_flow_validate_action_mark(actions,
306 action_flags |= MLX5_FLOW_ACTION_MARK;
309 case RTE_FLOW_ACTION_TYPE_DROP:
310 ret = mlx5_flow_validate_action_drop(action_flags,
314 action_flags |= MLX5_FLOW_ACTION_DROP;
317 case RTE_FLOW_ACTION_TYPE_QUEUE:
318 ret = mlx5_flow_validate_action_queue(actions,
323 action_flags |= MLX5_FLOW_ACTION_QUEUE;
326 case RTE_FLOW_ACTION_TYPE_RSS:
327 ret = mlx5_flow_validate_action_rss(actions,
332 action_flags |= MLX5_FLOW_ACTION_RSS;
335 case RTE_FLOW_ACTION_TYPE_COUNT:
336 ret = mlx5_flow_validate_action_count(dev, attr, error);
339 action_flags |= MLX5_FLOW_ACTION_COUNT;
343 return rte_flow_error_set(error, ENOTSUP,
344 RTE_FLOW_ERROR_TYPE_ACTION,
346 "action not supported");
349 if (!(action_flags & MLX5_FLOW_FATE_ACTIONS) && attr->ingress)
350 return rte_flow_error_set(error, EINVAL,
351 RTE_FLOW_ERROR_TYPE_ACTION, actions,
352 "no fate action is found");
357 * Internal preparation function. Allocates the DV flow size,
358 * this size is constant.
361 * Pointer to the flow attributes.
363 * Pointer to the list of items.
365 * Pointer to the list of actions.
366 * @param[out] item_flags
367 * Pointer to bit mask of all items detected.
368 * @param[out] action_flags
369 * Pointer to bit mask of all actions detected.
371 * Pointer to the error structure.
374 * Pointer to mlx5_flow object on success,
375 * otherwise NULL and rte_ernno is set.
377 static struct mlx5_flow *
378 flow_dv_prepare(const struct rte_flow_attr *attr __rte_unused,
379 const struct rte_flow_item items[] __rte_unused,
380 const struct rte_flow_action actions[] __rte_unused,
381 uint64_t *item_flags __rte_unused,
382 uint64_t *action_flags __rte_unused,
383 struct rte_flow_error *error)
385 uint32_t size = sizeof(struct mlx5_flow);
386 struct mlx5_flow *flow;
388 flow = rte_calloc(__func__, 1, size, 0);
390 rte_flow_error_set(error, ENOMEM,
391 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
392 "not enough memory to create flow");
395 flow->dv.value.size = MLX5_ST_SZ_DB(fte_match_param);
400 * Add Ethernet item to matcher and to the value.
402 * @param[in, out] matcher
404 * @param[in, out] key
405 * Flow matcher value.
407 * Flow pattern to translate.
409 * Item is inner pattern.
412 flow_dv_translate_item_eth(void *matcher, void *key,
413 const struct rte_flow_item *item, int inner)
415 const struct rte_flow_item_eth *eth_m = item->mask;
416 const struct rte_flow_item_eth *eth_v = item->spec;
417 const struct rte_flow_item_eth nic_mask = {
418 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
419 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
420 .type = RTE_BE16(0xffff),
432 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
434 headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers);
436 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
438 headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
440 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_m, dmac_47_16),
441 ð_m->dst, sizeof(eth_m->dst));
442 /* The value must be in the range of the mask. */
443 l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v, dmac_47_16);
444 for (i = 0; i < sizeof(eth_m->dst); ++i)
445 l24_v[i] = eth_m->dst.addr_bytes[i] & eth_v->dst.addr_bytes[i];
446 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_m, smac_47_16),
447 ð_m->src, sizeof(eth_m->src));
448 l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v, smac_47_16);
449 /* The value must be in the range of the mask. */
450 for (i = 0; i < sizeof(eth_m->dst); ++i)
451 l24_v[i] = eth_m->src.addr_bytes[i] & eth_v->src.addr_bytes[i];
452 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ethertype,
453 rte_be_to_cpu_16(eth_m->type));
454 l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v, ethertype);
455 *(uint16_t *)(l24_v) = eth_m->type & eth_v->type;
459 * Add VLAN item to matcher and to the value.
461 * @param[in, out] matcher
463 * @param[in, out] key
464 * Flow matcher value.
466 * Flow pattern to translate.
468 * Item is inner pattern.
471 flow_dv_translate_item_vlan(void *matcher, void *key,
472 const struct rte_flow_item *item,
475 const struct rte_flow_item_vlan *vlan_m = item->mask;
476 const struct rte_flow_item_vlan *vlan_v = item->spec;
477 const struct rte_flow_item_vlan nic_mask = {
478 .tci = RTE_BE16(0x0fff),
479 .inner_type = RTE_BE16(0xffff),
491 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
493 headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers);
495 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
497 headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
499 tci_m = rte_be_to_cpu_16(vlan_m->tci);
500 tci_v = rte_be_to_cpu_16(vlan_m->tci & vlan_v->tci);
501 MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag, 1);
502 MLX5_SET(fte_match_set_lyr_2_4, headers_v, cvlan_tag, 1);
503 MLX5_SET(fte_match_set_lyr_2_4, headers_m, first_vid, tci_m);
504 MLX5_SET(fte_match_set_lyr_2_4, headers_v, first_vid, tci_v);
505 MLX5_SET(fte_match_set_lyr_2_4, headers_m, first_cfi, tci_m >> 12);
506 MLX5_SET(fte_match_set_lyr_2_4, headers_v, first_cfi, tci_v >> 12);
507 MLX5_SET(fte_match_set_lyr_2_4, headers_m, first_prio, tci_m >> 13);
508 MLX5_SET(fte_match_set_lyr_2_4, headers_v, first_prio, tci_v >> 13);
512 * Add IPV4 item to matcher and to the value.
514 * @param[in, out] matcher
516 * @param[in, out] key
517 * Flow matcher value.
519 * Flow pattern to translate.
521 * Item is inner pattern.
524 flow_dv_translate_item_ipv4(void *matcher, void *key,
525 const struct rte_flow_item *item,
528 const struct rte_flow_item_ipv4 *ipv4_m = item->mask;
529 const struct rte_flow_item_ipv4 *ipv4_v = item->spec;
530 const struct rte_flow_item_ipv4 nic_mask = {
532 .src_addr = RTE_BE32(0xffffffff),
533 .dst_addr = RTE_BE32(0xffffffff),
534 .type_of_service = 0xff,
535 .next_proto_id = 0xff,
545 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
547 headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers);
549 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
551 headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
553 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_version, 0xf);
554 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_version, 4);
559 l24_m = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_m,
560 dst_ipv4_dst_ipv6.ipv4_layout.ipv4);
561 l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
562 dst_ipv4_dst_ipv6.ipv4_layout.ipv4);
563 *(uint32_t *)l24_m = ipv4_m->hdr.dst_addr;
564 *(uint32_t *)l24_v = ipv4_m->hdr.dst_addr & ipv4_v->hdr.dst_addr;
565 l24_m = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_m,
566 src_ipv4_src_ipv6.ipv4_layout.ipv4);
567 l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
568 src_ipv4_src_ipv6.ipv4_layout.ipv4);
569 *(uint32_t *)l24_m = ipv4_m->hdr.src_addr;
570 *(uint32_t *)l24_v = ipv4_m->hdr.src_addr & ipv4_v->hdr.src_addr;
571 tos = ipv4_m->hdr.type_of_service & ipv4_v->hdr.type_of_service;
572 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_ecn,
573 ipv4_m->hdr.type_of_service);
574 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ecn, tos);
575 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_dscp,
576 ipv4_m->hdr.type_of_service >> 2);
577 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_dscp, tos >> 2);
578 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_protocol,
579 ipv4_m->hdr.next_proto_id);
580 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol,
581 ipv4_v->hdr.next_proto_id & ipv4_m->hdr.next_proto_id);
585 * Add IPV6 item to matcher and to the value.
587 * @param[in, out] matcher
589 * @param[in, out] key
590 * Flow matcher value.
592 * Flow pattern to translate.
594 * Item is inner pattern.
597 flow_dv_translate_item_ipv6(void *matcher, void *key,
598 const struct rte_flow_item *item,
601 const struct rte_flow_item_ipv6 *ipv6_m = item->mask;
602 const struct rte_flow_item_ipv6 *ipv6_v = item->spec;
603 const struct rte_flow_item_ipv6 nic_mask = {
606 "\xff\xff\xff\xff\xff\xff\xff\xff"
607 "\xff\xff\xff\xff\xff\xff\xff\xff",
609 "\xff\xff\xff\xff\xff\xff\xff\xff"
610 "\xff\xff\xff\xff\xff\xff\xff\xff",
611 .vtc_flow = RTE_BE32(0xffffffff),
618 void *misc_m = MLX5_ADDR_OF(fte_match_param, matcher, misc_parameters);
619 void *misc_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters);
628 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
630 headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers);
632 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
634 headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
636 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_version, 0xf);
637 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_version, 6);
642 size = sizeof(ipv6_m->hdr.dst_addr);
643 l24_m = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_m,
644 dst_ipv4_dst_ipv6.ipv6_layout.ipv6);
645 l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
646 dst_ipv4_dst_ipv6.ipv6_layout.ipv6);
647 memcpy(l24_m, ipv6_m->hdr.dst_addr, size);
648 for (i = 0; i < size; ++i)
649 l24_v[i] = l24_m[i] & ipv6_v->hdr.dst_addr[i];
650 l24_m = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_m,
651 src_ipv4_src_ipv6.ipv6_layout.ipv6);
652 l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
653 src_ipv4_src_ipv6.ipv6_layout.ipv6);
654 memcpy(l24_m, ipv6_m->hdr.src_addr, size);
655 for (i = 0; i < size; ++i)
656 l24_v[i] = l24_m[i] & ipv6_v->hdr.src_addr[i];
658 vtc_m = rte_be_to_cpu_32(ipv6_m->hdr.vtc_flow);
659 vtc_v = rte_be_to_cpu_32(ipv6_m->hdr.vtc_flow & ipv6_v->hdr.vtc_flow);
660 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_ecn, vtc_m >> 20);
661 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ecn, vtc_v >> 20);
662 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_dscp, vtc_m >> 22);
663 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_dscp, vtc_v >> 22);
666 MLX5_SET(fte_match_set_misc, misc_m, inner_ipv6_flow_label,
668 MLX5_SET(fte_match_set_misc, misc_v, inner_ipv6_flow_label,
671 MLX5_SET(fte_match_set_misc, misc_m, outer_ipv6_flow_label,
673 MLX5_SET(fte_match_set_misc, misc_v, outer_ipv6_flow_label,
677 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_protocol,
679 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol,
680 ipv6_v->hdr.proto & ipv6_m->hdr.proto);
684 * Add TCP item to matcher and to the value.
686 * @param[in, out] matcher
688 * @param[in, out] key
689 * Flow matcher value.
691 * Flow pattern to translate.
693 * Item is inner pattern.
696 flow_dv_translate_item_tcp(void *matcher, void *key,
697 const struct rte_flow_item *item,
700 const struct rte_flow_item_tcp *tcp_m = item->mask;
701 const struct rte_flow_item_tcp *tcp_v = item->spec;
706 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
708 headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers);
710 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
712 headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
714 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_protocol, 0xff);
715 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol, IPPROTO_TCP);
719 tcp_m = &rte_flow_item_tcp_mask;
720 MLX5_SET(fte_match_set_lyr_2_4, headers_m, tcp_sport,
721 rte_be_to_cpu_16(tcp_m->hdr.src_port));
722 MLX5_SET(fte_match_set_lyr_2_4, headers_v, tcp_sport,
723 rte_be_to_cpu_16(tcp_v->hdr.src_port & tcp_m->hdr.src_port));
724 MLX5_SET(fte_match_set_lyr_2_4, headers_m, tcp_dport,
725 rte_be_to_cpu_16(tcp_m->hdr.dst_port));
726 MLX5_SET(fte_match_set_lyr_2_4, headers_v, tcp_dport,
727 rte_be_to_cpu_16(tcp_v->hdr.dst_port & tcp_m->hdr.dst_port));
731 * Add UDP item to matcher and to the value.
733 * @param[in, out] matcher
735 * @param[in, out] key
736 * Flow matcher value.
738 * Flow pattern to translate.
740 * Item is inner pattern.
743 flow_dv_translate_item_udp(void *matcher, void *key,
744 const struct rte_flow_item *item,
747 const struct rte_flow_item_udp *udp_m = item->mask;
748 const struct rte_flow_item_udp *udp_v = item->spec;
753 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
755 headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers);
757 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
759 headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
761 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_protocol, 0xff);
762 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol, IPPROTO_UDP);
766 udp_m = &rte_flow_item_udp_mask;
767 MLX5_SET(fte_match_set_lyr_2_4, headers_m, udp_sport,
768 rte_be_to_cpu_16(udp_m->hdr.src_port));
769 MLX5_SET(fte_match_set_lyr_2_4, headers_v, udp_sport,
770 rte_be_to_cpu_16(udp_v->hdr.src_port & udp_m->hdr.src_port));
771 MLX5_SET(fte_match_set_lyr_2_4, headers_m, udp_dport,
772 rte_be_to_cpu_16(udp_m->hdr.dst_port));
773 MLX5_SET(fte_match_set_lyr_2_4, headers_v, udp_dport,
774 rte_be_to_cpu_16(udp_v->hdr.dst_port & udp_m->hdr.dst_port));
778 * Add GRE item to matcher and to the value.
780 * @param[in, out] matcher
782 * @param[in, out] key
783 * Flow matcher value.
785 * Flow pattern to translate.
787 * Item is inner pattern.
790 flow_dv_translate_item_gre(void *matcher, void *key,
791 const struct rte_flow_item *item,
794 const struct rte_flow_item_gre *gre_m = item->mask;
795 const struct rte_flow_item_gre *gre_v = item->spec;
798 void *misc_m = MLX5_ADDR_OF(fte_match_param, matcher, misc_parameters);
799 void *misc_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters);
802 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
804 headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers);
806 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
808 headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
810 MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_protocol, 0xff);
811 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol, IPPROTO_GRE);
815 gre_m = &rte_flow_item_gre_mask;
816 MLX5_SET(fte_match_set_misc, misc_m, gre_protocol,
817 rte_be_to_cpu_16(gre_m->protocol));
818 MLX5_SET(fte_match_set_misc, misc_v, gre_protocol,
819 rte_be_to_cpu_16(gre_v->protocol & gre_m->protocol));
823 * Add NVGRE item to matcher and to the value.
825 * @param[in, out] matcher
827 * @param[in, out] key
828 * Flow matcher value.
830 * Flow pattern to translate.
832 * Item is inner pattern.
835 flow_dv_translate_item_nvgre(void *matcher, void *key,
836 const struct rte_flow_item *item,
839 const struct rte_flow_item_nvgre *nvgre_m = item->mask;
840 const struct rte_flow_item_nvgre *nvgre_v = item->spec;
841 void *misc_m = MLX5_ADDR_OF(fte_match_param, matcher, misc_parameters);
842 void *misc_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters);
843 const char *tni_flow_id_m = (const char *)nvgre_m->tni;
844 const char *tni_flow_id_v = (const char *)nvgre_v->tni;
850 flow_dv_translate_item_gre(matcher, key, item, inner);
854 nvgre_m = &rte_flow_item_nvgre_mask;
855 size = sizeof(nvgre_m->tni) + sizeof(nvgre_m->flow_id);
856 gre_key_m = MLX5_ADDR_OF(fte_match_set_misc, misc_m, gre_key_h);
857 gre_key_v = MLX5_ADDR_OF(fte_match_set_misc, misc_v, gre_key_h);
858 memcpy(gre_key_m, tni_flow_id_m, size);
859 for (i = 0; i < size; ++i)
860 gre_key_v[i] = gre_key_m[i] & tni_flow_id_v[i];
864 * Add VXLAN item to matcher and to the value.
866 * @param[in, out] matcher
868 * @param[in, out] key
869 * Flow matcher value.
871 * Flow pattern to translate.
873 * Item is inner pattern.
876 flow_dv_translate_item_vxlan(void *matcher, void *key,
877 const struct rte_flow_item *item,
880 const struct rte_flow_item_vxlan *vxlan_m = item->mask;
881 const struct rte_flow_item_vxlan *vxlan_v = item->spec;
884 void *misc_m = MLX5_ADDR_OF(fte_match_param, matcher, misc_parameters);
885 void *misc_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters);
893 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
895 headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers);
897 headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
899 headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
901 dport = item->type == RTE_FLOW_ITEM_TYPE_VXLAN ?
902 MLX5_UDP_PORT_VXLAN : MLX5_UDP_PORT_VXLAN_GPE;
903 if (!MLX5_GET16(fte_match_set_lyr_2_4, headers_v, udp_dport)) {
904 MLX5_SET(fte_match_set_lyr_2_4, headers_m, udp_dport, 0xFFFF);
905 MLX5_SET(fte_match_set_lyr_2_4, headers_v, udp_dport, dport);
910 vxlan_m = &rte_flow_item_vxlan_mask;
911 size = sizeof(vxlan_m->vni);
912 vni_m = MLX5_ADDR_OF(fte_match_set_misc, misc_m, vxlan_vni);
913 vni_v = MLX5_ADDR_OF(fte_match_set_misc, misc_v, vxlan_vni);
914 memcpy(vni_m, vxlan_m->vni, size);
915 for (i = 0; i < size; ++i)
916 vni_v[i] = vni_m[i] & vxlan_v->vni[i];
920 * Add META item to matcher
922 * @param[in, out] matcher
924 * @param[in, out] key
925 * Flow matcher value.
927 * Flow pattern to translate.
929 * Item is inner pattern.
932 flow_dv_translate_item_meta(void *matcher, void *key,
933 const struct rte_flow_item *item)
935 const struct rte_flow_item_meta *meta_m;
936 const struct rte_flow_item_meta *meta_v;
938 MLX5_ADDR_OF(fte_match_param, matcher, misc_parameters_2);
940 MLX5_ADDR_OF(fte_match_param, key, misc_parameters_2);
942 meta_m = (const void *)item->mask;
944 meta_m = &rte_flow_item_meta_mask;
945 meta_v = (const void *)item->spec;
947 MLX5_SET(fte_match_set_misc2, misc2_m, metadata_reg_a,
948 rte_be_to_cpu_32(meta_m->data));
949 MLX5_SET(fte_match_set_misc2, misc2_v, metadata_reg_a,
950 rte_be_to_cpu_32(meta_v->data & meta_m->data));
955 * Update the matcher and the value based the selected item.
957 * @param[in, out] matcher
959 * @param[in, out] key
960 * Flow matcher value.
962 * Flow pattern to translate.
963 * @param[in, out] dev_flow
964 * Pointer to the mlx5_flow.
966 * Item is inner pattern.
969 flow_dv_create_item(void *matcher, void *key,
970 const struct rte_flow_item *item,
971 struct mlx5_flow *dev_flow,
974 struct mlx5_flow_dv_matcher *tmatcher = matcher;
976 switch (item->type) {
977 case RTE_FLOW_ITEM_TYPE_ETH:
978 flow_dv_translate_item_eth(tmatcher->mask.buf, key, item,
980 tmatcher->priority = MLX5_PRIORITY_MAP_L2;
982 case RTE_FLOW_ITEM_TYPE_VLAN:
983 flow_dv_translate_item_vlan(tmatcher->mask.buf, key, item,
986 case RTE_FLOW_ITEM_TYPE_IPV4:
987 flow_dv_translate_item_ipv4(tmatcher->mask.buf, key, item,
989 tmatcher->priority = MLX5_PRIORITY_MAP_L3;
990 dev_flow->dv.hash_fields |=
991 mlx5_flow_hashfields_adjust(dev_flow, inner,
992 MLX5_IPV4_LAYER_TYPES,
993 MLX5_IPV4_IBV_RX_HASH);
995 case RTE_FLOW_ITEM_TYPE_IPV6:
996 flow_dv_translate_item_ipv6(tmatcher->mask.buf, key, item,
998 tmatcher->priority = MLX5_PRIORITY_MAP_L3;
999 dev_flow->dv.hash_fields |=
1000 mlx5_flow_hashfields_adjust(dev_flow, inner,
1001 MLX5_IPV6_LAYER_TYPES,
1002 MLX5_IPV6_IBV_RX_HASH);
1004 case RTE_FLOW_ITEM_TYPE_TCP:
1005 flow_dv_translate_item_tcp(tmatcher->mask.buf, key, item,
1007 tmatcher->priority = MLX5_PRIORITY_MAP_L4;
1008 dev_flow->dv.hash_fields |=
1009 mlx5_flow_hashfields_adjust(dev_flow, inner,
1011 (IBV_RX_HASH_SRC_PORT_TCP |
1012 IBV_RX_HASH_DST_PORT_TCP));
1014 case RTE_FLOW_ITEM_TYPE_UDP:
1015 flow_dv_translate_item_udp(tmatcher->mask.buf, key, item,
1017 tmatcher->priority = MLX5_PRIORITY_MAP_L4;
1018 dev_flow->verbs.hash_fields |=
1019 mlx5_flow_hashfields_adjust(dev_flow, inner,
1021 (IBV_RX_HASH_SRC_PORT_UDP |
1022 IBV_RX_HASH_DST_PORT_UDP));
1024 case RTE_FLOW_ITEM_TYPE_GRE:
1025 flow_dv_translate_item_gre(tmatcher->mask.buf, key, item,
1028 case RTE_FLOW_ITEM_TYPE_NVGRE:
1029 flow_dv_translate_item_nvgre(tmatcher->mask.buf, key, item,
1032 case RTE_FLOW_ITEM_TYPE_VXLAN:
1033 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
1034 flow_dv_translate_item_vxlan(tmatcher->mask.buf, key, item,
1037 case RTE_FLOW_ITEM_TYPE_META:
1038 flow_dv_translate_item_meta(tmatcher->mask.buf, key, item);
1046 * Store the requested actions in an array.
1049 * Flow action to translate.
1050 * @param[in, out] dev_flow
1051 * Pointer to the mlx5_flow.
1054 flow_dv_create_action(const struct rte_flow_action *action,
1055 struct mlx5_flow *dev_flow)
1057 const struct rte_flow_action_queue *queue;
1058 const struct rte_flow_action_rss *rss;
1059 int actions_n = dev_flow->dv.actions_n;
1060 struct rte_flow *flow = dev_flow->flow;
1062 switch (action->type) {
1063 case RTE_FLOW_ACTION_TYPE_VOID:
1065 case RTE_FLOW_ACTION_TYPE_FLAG:
1066 dev_flow->dv.actions[actions_n].type = MLX5DV_FLOW_ACTION_TAG;
1067 dev_flow->dv.actions[actions_n].tag_value =
1068 mlx5_flow_mark_set(MLX5_FLOW_MARK_DEFAULT);
1070 flow->actions |= MLX5_FLOW_ACTION_FLAG;
1072 case RTE_FLOW_ACTION_TYPE_MARK:
1073 dev_flow->dv.actions[actions_n].type = MLX5DV_FLOW_ACTION_TAG;
1074 dev_flow->dv.actions[actions_n].tag_value =
1076 (((const struct rte_flow_action_mark *)
1077 (action->conf))->id);
1078 flow->actions |= MLX5_FLOW_ACTION_MARK;
1081 case RTE_FLOW_ACTION_TYPE_DROP:
1082 dev_flow->dv.actions[actions_n].type = MLX5DV_FLOW_ACTION_DROP;
1083 flow->actions |= MLX5_FLOW_ACTION_DROP;
1085 case RTE_FLOW_ACTION_TYPE_QUEUE:
1086 queue = action->conf;
1087 flow->rss.queue_num = 1;
1088 (*flow->queue)[0] = queue->index;
1089 flow->actions |= MLX5_FLOW_ACTION_QUEUE;
1091 case RTE_FLOW_ACTION_TYPE_RSS:
1094 memcpy((*flow->queue), rss->queue,
1095 rss->queue_num * sizeof(uint16_t));
1096 flow->rss.queue_num = rss->queue_num;
1097 memcpy(flow->key, rss->key, MLX5_RSS_HASH_KEY_LEN);
1098 flow->rss.types = rss->types;
1099 flow->rss.level = rss->level;
1100 /* Added to array only in apply since we need the QP */
1101 flow->actions |= MLX5_FLOW_ACTION_RSS;
1106 dev_flow->dv.actions_n = actions_n;
1109 static uint32_t matcher_zero[MLX5_ST_SZ_DW(fte_match_param)] = { 0 };
1111 #define HEADER_IS_ZERO(match_criteria, headers) \
1112 !(memcmp(MLX5_ADDR_OF(fte_match_param, match_criteria, headers), \
1113 matcher_zero, MLX5_FLD_SZ_BYTES(fte_match_param, headers))) \
1116 * Calculate flow matcher enable bitmap.
1118 * @param match_criteria
1119 * Pointer to flow matcher criteria.
1122 * Bitmap of enabled fields.
1125 flow_dv_matcher_enable(uint32_t *match_criteria)
1127 uint8_t match_criteria_enable;
1129 match_criteria_enable =
1130 (!HEADER_IS_ZERO(match_criteria, outer_headers)) <<
1131 MLX5_MATCH_CRITERIA_ENABLE_OUTER_BIT;
1132 match_criteria_enable |=
1133 (!HEADER_IS_ZERO(match_criteria, misc_parameters)) <<
1134 MLX5_MATCH_CRITERIA_ENABLE_MISC_BIT;
1135 match_criteria_enable |=
1136 (!HEADER_IS_ZERO(match_criteria, inner_headers)) <<
1137 MLX5_MATCH_CRITERIA_ENABLE_INNER_BIT;
1138 match_criteria_enable |=
1139 (!HEADER_IS_ZERO(match_criteria, misc_parameters_2)) <<
1140 MLX5_MATCH_CRITERIA_ENABLE_MISC2_BIT;
1142 return match_criteria_enable;
1146 * Register the flow matcher.
1148 * @param dev[in, out]
1149 * Pointer to rte_eth_dev structure.
1150 * @param[in, out] matcher
1151 * Pointer to flow matcher.
1152 * @parm[in, out] dev_flow
1153 * Pointer to the dev_flow.
1155 * pointer to error structure.
1158 * 0 on success otherwise -errno and errno is set.
1161 flow_dv_matcher_register(struct rte_eth_dev *dev,
1162 struct mlx5_flow_dv_matcher *matcher,
1163 struct mlx5_flow *dev_flow,
1164 struct rte_flow_error *error)
1166 struct priv *priv = dev->data->dev_private;
1167 struct mlx5_flow_dv_matcher *cache_matcher;
1168 struct mlx5dv_flow_matcher_attr dv_attr = {
1169 .type = IBV_FLOW_ATTR_NORMAL,
1170 .match_mask = (void *)&matcher->mask,
1173 /* Lookup from cache. */
1174 LIST_FOREACH(cache_matcher, &priv->matchers, next) {
1175 if (matcher->crc == cache_matcher->crc &&
1176 matcher->priority == cache_matcher->priority &&
1177 matcher->egress == cache_matcher->egress &&
1178 !memcmp((const void *)matcher->mask.buf,
1179 (const void *)cache_matcher->mask.buf,
1180 cache_matcher->mask.size)) {
1182 "priority %hd use %s matcher %p: refcnt %d++",
1183 cache_matcher->priority,
1184 cache_matcher->egress ? "tx" : "rx",
1185 (void *)cache_matcher,
1186 rte_atomic32_read(&cache_matcher->refcnt));
1187 rte_atomic32_inc(&cache_matcher->refcnt);
1188 dev_flow->dv.matcher = cache_matcher;
1192 /* Register new matcher. */
1193 cache_matcher = rte_calloc(__func__, 1, sizeof(*cache_matcher), 0);
1195 return rte_flow_error_set(error, ENOMEM,
1196 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
1197 "cannot allocate matcher memory");
1198 *cache_matcher = *matcher;
1199 dv_attr.match_criteria_enable =
1200 flow_dv_matcher_enable(cache_matcher->mask.buf);
1201 dv_attr.priority = matcher->priority;
1202 if (matcher->egress)
1203 dv_attr.flags |= IBV_FLOW_ATTR_FLAGS_EGRESS;
1204 cache_matcher->matcher_object =
1205 mlx5_glue->dv_create_flow_matcher(priv->ctx, &dv_attr);
1206 if (!cache_matcher->matcher_object) {
1207 rte_free(cache_matcher);
1208 return rte_flow_error_set(error, ENOMEM,
1209 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
1210 NULL, "cannot create matcher");
1212 rte_atomic32_inc(&cache_matcher->refcnt);
1213 LIST_INSERT_HEAD(&priv->matchers, cache_matcher, next);
1214 dev_flow->dv.matcher = cache_matcher;
1215 DRV_LOG(DEBUG, "priority %hd new %s matcher %p: refcnt %d",
1216 cache_matcher->priority,
1217 cache_matcher->egress ? "tx" : "rx", (void *)cache_matcher,
1218 rte_atomic32_read(&cache_matcher->refcnt));
1224 * Fill the flow with DV spec.
1227 * Pointer to rte_eth_dev structure.
1228 * @param[in, out] dev_flow
1229 * Pointer to the sub flow.
1231 * Pointer to the flow attributes.
1233 * Pointer to the list of items.
1234 * @param[in] actions
1235 * Pointer to the list of actions.
1237 * Pointer to the error structure.
1240 * 0 on success, a negative errno value otherwise and rte_ernno is set.
1243 flow_dv_translate(struct rte_eth_dev *dev,
1244 struct mlx5_flow *dev_flow,
1245 const struct rte_flow_attr *attr,
1246 const struct rte_flow_item items[],
1247 const struct rte_flow_action actions[] __rte_unused,
1248 struct rte_flow_error *error)
1250 struct priv *priv = dev->data->dev_private;
1251 uint64_t priority = attr->priority;
1252 struct mlx5_flow_dv_matcher matcher = {
1254 .size = sizeof(matcher.mask.buf),
1257 void *match_value = dev_flow->dv.value.buf;
1260 if (priority == MLX5_FLOW_PRIO_RSVD)
1261 priority = priv->config.flow_prio - 1;
1262 for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) {
1263 tunnel = !!(dev_flow->layers & MLX5_FLOW_LAYER_TUNNEL);
1264 flow_dv_create_item(&matcher, match_value, items, dev_flow,
1267 matcher.crc = rte_raw_cksum((const void *)matcher.mask.buf,
1269 if (priority == MLX5_FLOW_PRIO_RSVD)
1270 priority = priv->config.flow_prio - 1;
1271 matcher.priority = mlx5_flow_adjust_priority(dev, priority,
1273 matcher.egress = attr->egress;
1274 if (flow_dv_matcher_register(dev, &matcher, dev_flow, error))
1276 for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++)
1277 flow_dv_create_action(actions, dev_flow);
1282 * Apply the flow to the NIC.
1285 * Pointer to the Ethernet device structure.
1286 * @param[in, out] flow
1287 * Pointer to flow structure.
1289 * Pointer to error structure.
1292 * 0 on success, a negative errno value otherwise and rte_errno is set.
1295 flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
1296 struct rte_flow_error *error)
1298 struct mlx5_flow_dv *dv;
1299 struct mlx5_flow *dev_flow;
1303 LIST_FOREACH(dev_flow, &flow->dev_flows, next) {
1306 if (flow->actions & MLX5_FLOW_ACTION_DROP) {
1307 dv->hrxq = mlx5_hrxq_drop_new(dev);
1311 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
1312 "cannot get drop hash queue");
1315 dv->actions[n].type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
1316 dv->actions[n].qp = dv->hrxq->qp;
1318 } else if (flow->actions &
1319 (MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)) {
1320 struct mlx5_hrxq *hrxq;
1321 hrxq = mlx5_hrxq_get(dev, flow->key,
1322 MLX5_RSS_HASH_KEY_LEN,
1325 flow->rss.queue_num);
1327 hrxq = mlx5_hrxq_new
1328 (dev, flow->key, MLX5_RSS_HASH_KEY_LEN,
1329 dv->hash_fields, (*flow->queue),
1330 flow->rss.queue_num,
1331 !!(dev_flow->layers &
1332 MLX5_FLOW_LAYER_TUNNEL));
1336 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
1337 "cannot get hash queue");
1341 dv->actions[n].type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
1342 dv->actions[n].qp = hrxq->qp;
1346 mlx5_glue->dv_create_flow(dv->matcher->matcher_object,
1347 (void *)&dv->value, n,
1350 rte_flow_error_set(error, errno,
1351 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
1353 "hardware refuses to create flow");
1359 err = rte_errno; /* Save rte_errno before cleanup. */
1360 LIST_FOREACH(dev_flow, &flow->dev_flows, next) {
1361 struct mlx5_flow_dv *dv = &dev_flow->dv;
1363 if (flow->actions & MLX5_FLOW_ACTION_DROP)
1364 mlx5_hrxq_drop_release(dev);
1366 mlx5_hrxq_release(dev, dv->hrxq);
1370 rte_errno = err; /* Restore rte_errno. */
1375 * Release the flow matcher.
1378 * Pointer to Ethernet device.
1380 * Pointer to mlx5_flow.
1383 * 1 while a reference on it exists, 0 when freed.
1386 flow_dv_matcher_release(struct rte_eth_dev *dev,
1387 struct mlx5_flow *flow)
1389 struct mlx5_flow_dv_matcher *matcher = flow->dv.matcher;
1391 assert(matcher->matcher_object);
1392 DRV_LOG(DEBUG, "port %u matcher %p: refcnt %d--",
1393 dev->data->port_id, (void *)matcher,
1394 rte_atomic32_read(&matcher->refcnt));
1395 if (rte_atomic32_dec_and_test(&matcher->refcnt)) {
1396 claim_zero(mlx5_glue->dv_destroy_flow_matcher
1397 (matcher->matcher_object));
1398 LIST_REMOVE(matcher, next);
1400 DRV_LOG(DEBUG, "port %u matcher %p: removed",
1401 dev->data->port_id, (void *)matcher);
1408 * Remove the flow from the NIC but keeps it in memory.
1411 * Pointer to Ethernet device.
1412 * @param[in, out] flow
1413 * Pointer to flow structure.
1416 flow_dv_remove(struct rte_eth_dev *dev, struct rte_flow *flow)
1418 struct mlx5_flow_dv *dv;
1419 struct mlx5_flow *dev_flow;
1423 LIST_FOREACH(dev_flow, &flow->dev_flows, next) {
1426 claim_zero(mlx5_glue->destroy_flow(dv->flow));
1430 if (flow->actions & MLX5_FLOW_ACTION_DROP)
1431 mlx5_hrxq_drop_release(dev);
1433 mlx5_hrxq_release(dev, dv->hrxq);
1438 flow->counter = NULL;
1442 * Remove the flow from the NIC and the memory.
1445 * Pointer to the Ethernet device structure.
1446 * @param[in, out] flow
1447 * Pointer to flow structure.
1450 flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)
1452 struct mlx5_flow *dev_flow;
1456 flow_dv_remove(dev, flow);
1457 while (!LIST_EMPTY(&flow->dev_flows)) {
1458 dev_flow = LIST_FIRST(&flow->dev_flows);
1459 LIST_REMOVE(dev_flow, next);
1460 if (dev_flow->dv.matcher)
1461 flow_dv_matcher_release(dev, dev_flow);
1469 * @see rte_flow_query()
1473 flow_dv_query(struct rte_eth_dev *dev __rte_unused,
1474 struct rte_flow *flow __rte_unused,
1475 const struct rte_flow_action *actions __rte_unused,
1476 void *data __rte_unused,
1477 struct rte_flow_error *error __rte_unused)
1479 rte_errno = ENOTSUP;
1484 const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = {
1485 .validate = flow_dv_validate,
1486 .prepare = flow_dv_prepare,
1487 .translate = flow_dv_translate,
1488 .apply = flow_dv_apply,
1489 .remove = flow_dv_remove,
1490 .destroy = flow_dv_destroy,
1491 .query = flow_dv_query,
1494 #endif /* HAVE_IBV_FLOW_DV_SUPPORT */