1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
6 #include <netinet/in.h>
13 /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
15 #pragma GCC diagnostic ignored "-Wpedantic"
17 #include <infiniband/verbs.h>
19 #pragma GCC diagnostic error "-Wpedantic"
22 #include <rte_common.h>
23 #include <rte_ether.h>
24 #include <rte_ethdev_driver.h>
26 #include <rte_flow_driver.h>
27 #include <rte_malloc.h>
31 #include "mlx5_defs.h"
32 #include "mlx5_flow.h"
33 #include "mlx5_glue.h"
35 #include "mlx5_rxtx.h"
37 /* Dev ops structure defined in mlx5.c */
38 extern const struct eth_dev_ops mlx5_dev_ops;
39 extern const struct eth_dev_ops mlx5_dev_ops_isolate;
41 /** Device flow drivers. */
42 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
43 extern const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops;
45 extern const struct mlx5_flow_driver_ops mlx5_flow_tcf_drv_ops;
46 extern const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops;
48 const struct mlx5_flow_driver_ops mlx5_flow_null_drv_ops;
50 const struct mlx5_flow_driver_ops *flow_drv_ops[] = {
51 [MLX5_FLOW_TYPE_MIN] = &mlx5_flow_null_drv_ops,
52 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
53 [MLX5_FLOW_TYPE_DV] = &mlx5_flow_dv_drv_ops,
55 [MLX5_FLOW_TYPE_TCF] = &mlx5_flow_tcf_drv_ops,
56 [MLX5_FLOW_TYPE_VERBS] = &mlx5_flow_verbs_drv_ops,
57 [MLX5_FLOW_TYPE_MAX] = &mlx5_flow_null_drv_ops
62 MLX5_EXPANSION_ROOT_OUTER,
63 MLX5_EXPANSION_ROOT_ETH_VLAN,
64 MLX5_EXPANSION_ROOT_OUTER_ETH_VLAN,
65 MLX5_EXPANSION_OUTER_ETH,
66 MLX5_EXPANSION_OUTER_ETH_VLAN,
67 MLX5_EXPANSION_OUTER_VLAN,
68 MLX5_EXPANSION_OUTER_IPV4,
69 MLX5_EXPANSION_OUTER_IPV4_UDP,
70 MLX5_EXPANSION_OUTER_IPV4_TCP,
71 MLX5_EXPANSION_OUTER_IPV6,
72 MLX5_EXPANSION_OUTER_IPV6_UDP,
73 MLX5_EXPANSION_OUTER_IPV6_TCP,
75 MLX5_EXPANSION_VXLAN_GPE,
79 MLX5_EXPANSION_ETH_VLAN,
82 MLX5_EXPANSION_IPV4_UDP,
83 MLX5_EXPANSION_IPV4_TCP,
85 MLX5_EXPANSION_IPV6_UDP,
86 MLX5_EXPANSION_IPV6_TCP,
89 /** Supported expansion of items. */
90 static const struct rte_flow_expand_node mlx5_support_expansion[] = {
91 [MLX5_EXPANSION_ROOT] = {
92 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_ETH,
95 .type = RTE_FLOW_ITEM_TYPE_END,
97 [MLX5_EXPANSION_ROOT_OUTER] = {
98 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_ETH,
99 MLX5_EXPANSION_OUTER_IPV4,
100 MLX5_EXPANSION_OUTER_IPV6),
101 .type = RTE_FLOW_ITEM_TYPE_END,
103 [MLX5_EXPANSION_ROOT_ETH_VLAN] = {
104 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_ETH_VLAN),
105 .type = RTE_FLOW_ITEM_TYPE_END,
107 [MLX5_EXPANSION_ROOT_OUTER_ETH_VLAN] = {
108 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_ETH_VLAN),
109 .type = RTE_FLOW_ITEM_TYPE_END,
111 [MLX5_EXPANSION_OUTER_ETH] = {
112 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_IPV4,
113 MLX5_EXPANSION_OUTER_IPV6,
114 MLX5_EXPANSION_MPLS),
115 .type = RTE_FLOW_ITEM_TYPE_ETH,
118 [MLX5_EXPANSION_OUTER_ETH_VLAN] = {
119 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_VLAN),
120 .type = RTE_FLOW_ITEM_TYPE_ETH,
123 [MLX5_EXPANSION_OUTER_VLAN] = {
124 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_IPV4,
125 MLX5_EXPANSION_OUTER_IPV6),
126 .type = RTE_FLOW_ITEM_TYPE_VLAN,
128 [MLX5_EXPANSION_OUTER_IPV4] = {
129 .next = RTE_FLOW_EXPAND_RSS_NEXT
130 (MLX5_EXPANSION_OUTER_IPV4_UDP,
131 MLX5_EXPANSION_OUTER_IPV4_TCP,
133 .type = RTE_FLOW_ITEM_TYPE_IPV4,
134 .rss_types = ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |
135 ETH_RSS_NONFRAG_IPV4_OTHER,
137 [MLX5_EXPANSION_OUTER_IPV4_UDP] = {
138 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_VXLAN,
139 MLX5_EXPANSION_VXLAN_GPE),
140 .type = RTE_FLOW_ITEM_TYPE_UDP,
141 .rss_types = ETH_RSS_NONFRAG_IPV4_UDP,
143 [MLX5_EXPANSION_OUTER_IPV4_TCP] = {
144 .type = RTE_FLOW_ITEM_TYPE_TCP,
145 .rss_types = ETH_RSS_NONFRAG_IPV4_TCP,
147 [MLX5_EXPANSION_OUTER_IPV6] = {
148 .next = RTE_FLOW_EXPAND_RSS_NEXT
149 (MLX5_EXPANSION_OUTER_IPV6_UDP,
150 MLX5_EXPANSION_OUTER_IPV6_TCP),
151 .type = RTE_FLOW_ITEM_TYPE_IPV6,
152 .rss_types = ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |
153 ETH_RSS_NONFRAG_IPV6_OTHER,
155 [MLX5_EXPANSION_OUTER_IPV6_UDP] = {
156 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_VXLAN,
157 MLX5_EXPANSION_VXLAN_GPE),
158 .type = RTE_FLOW_ITEM_TYPE_UDP,
159 .rss_types = ETH_RSS_NONFRAG_IPV6_UDP,
161 [MLX5_EXPANSION_OUTER_IPV6_TCP] = {
162 .type = RTE_FLOW_ITEM_TYPE_TCP,
163 .rss_types = ETH_RSS_NONFRAG_IPV6_TCP,
165 [MLX5_EXPANSION_VXLAN] = {
166 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_ETH),
167 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
169 [MLX5_EXPANSION_VXLAN_GPE] = {
170 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_ETH,
172 MLX5_EXPANSION_IPV6),
173 .type = RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
175 [MLX5_EXPANSION_GRE] = {
176 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4),
177 .type = RTE_FLOW_ITEM_TYPE_GRE,
179 [MLX5_EXPANSION_MPLS] = {
180 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4,
181 MLX5_EXPANSION_IPV6),
182 .type = RTE_FLOW_ITEM_TYPE_MPLS,
184 [MLX5_EXPANSION_ETH] = {
185 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4,
186 MLX5_EXPANSION_IPV6),
187 .type = RTE_FLOW_ITEM_TYPE_ETH,
189 [MLX5_EXPANSION_ETH_VLAN] = {
190 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_VLAN),
191 .type = RTE_FLOW_ITEM_TYPE_ETH,
193 [MLX5_EXPANSION_VLAN] = {
194 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4,
195 MLX5_EXPANSION_IPV6),
196 .type = RTE_FLOW_ITEM_TYPE_VLAN,
198 [MLX5_EXPANSION_IPV4] = {
199 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4_UDP,
200 MLX5_EXPANSION_IPV4_TCP),
201 .type = RTE_FLOW_ITEM_TYPE_IPV4,
202 .rss_types = ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |
203 ETH_RSS_NONFRAG_IPV4_OTHER,
205 [MLX5_EXPANSION_IPV4_UDP] = {
206 .type = RTE_FLOW_ITEM_TYPE_UDP,
207 .rss_types = ETH_RSS_NONFRAG_IPV4_UDP,
209 [MLX5_EXPANSION_IPV4_TCP] = {
210 .type = RTE_FLOW_ITEM_TYPE_TCP,
211 .rss_types = ETH_RSS_NONFRAG_IPV4_TCP,
213 [MLX5_EXPANSION_IPV6] = {
214 .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV6_UDP,
215 MLX5_EXPANSION_IPV6_TCP),
216 .type = RTE_FLOW_ITEM_TYPE_IPV6,
217 .rss_types = ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |
218 ETH_RSS_NONFRAG_IPV6_OTHER,
220 [MLX5_EXPANSION_IPV6_UDP] = {
221 .type = RTE_FLOW_ITEM_TYPE_UDP,
222 .rss_types = ETH_RSS_NONFRAG_IPV6_UDP,
224 [MLX5_EXPANSION_IPV6_TCP] = {
225 .type = RTE_FLOW_ITEM_TYPE_TCP,
226 .rss_types = ETH_RSS_NONFRAG_IPV6_TCP,
230 static const struct rte_flow_ops mlx5_flow_ops = {
231 .validate = mlx5_flow_validate,
232 .create = mlx5_flow_create,
233 .destroy = mlx5_flow_destroy,
234 .flush = mlx5_flow_flush,
235 .isolate = mlx5_flow_isolate,
236 .query = mlx5_flow_query,
239 /* Convert FDIR request to Generic flow. */
241 struct rte_flow_attr attr;
242 struct rte_flow_item items[4];
243 struct rte_flow_item_eth l2;
244 struct rte_flow_item_eth l2_mask;
246 struct rte_flow_item_ipv4 ipv4;
247 struct rte_flow_item_ipv6 ipv6;
250 struct rte_flow_item_ipv4 ipv4;
251 struct rte_flow_item_ipv6 ipv6;
254 struct rte_flow_item_udp udp;
255 struct rte_flow_item_tcp tcp;
258 struct rte_flow_item_udp udp;
259 struct rte_flow_item_tcp tcp;
261 struct rte_flow_action actions[2];
262 struct rte_flow_action_queue queue;
265 /* Map of Verbs to Flow priority with 8 Verbs priorities. */
266 static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = {
267 { 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 },
270 /* Map of Verbs to Flow priority with 16 Verbs priorities. */
271 static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = {
272 { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 },
273 { 9, 10, 11 }, { 12, 13, 14 },
276 /* Tunnel information. */
277 struct mlx5_flow_tunnel_info {
278 uint64_t tunnel; /**< Tunnel bit (see MLX5_FLOW_*). */
279 uint32_t ptype; /**< Tunnel Ptype (see RTE_PTYPE_*). */
282 static struct mlx5_flow_tunnel_info tunnels_info[] = {
284 .tunnel = MLX5_FLOW_LAYER_VXLAN,
285 .ptype = RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_L4_UDP,
288 .tunnel = MLX5_FLOW_LAYER_VXLAN_GPE,
289 .ptype = RTE_PTYPE_TUNNEL_VXLAN_GPE | RTE_PTYPE_L4_UDP,
292 .tunnel = MLX5_FLOW_LAYER_GRE,
293 .ptype = RTE_PTYPE_TUNNEL_GRE,
296 .tunnel = MLX5_FLOW_LAYER_MPLS | MLX5_FLOW_LAYER_OUTER_L4_UDP,
297 .ptype = RTE_PTYPE_TUNNEL_MPLS_IN_UDP | RTE_PTYPE_L4_UDP,
300 .tunnel = MLX5_FLOW_LAYER_MPLS,
301 .ptype = RTE_PTYPE_TUNNEL_MPLS_IN_GRE,
306 * Discover the maximum number of priority available.
309 * Pointer to the Ethernet device structure.
312 * number of supported flow priority on success, a negative errno
313 * value otherwise and rte_errno is set.
316 mlx5_flow_discover_priorities(struct rte_eth_dev *dev)
318 struct mlx5_priv *priv = dev->data->dev_private;
320 struct ibv_flow_attr attr;
321 struct ibv_flow_spec_eth eth;
322 struct ibv_flow_spec_action_drop drop;
326 .port = (uint8_t)priv->ibv_port,
329 .type = IBV_FLOW_SPEC_ETH,
330 .size = sizeof(struct ibv_flow_spec_eth),
333 .size = sizeof(struct ibv_flow_spec_action_drop),
334 .type = IBV_FLOW_SPEC_ACTION_DROP,
337 struct ibv_flow *flow;
338 struct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev);
339 uint16_t vprio[] = { 8, 16 };
347 for (i = 0; i != RTE_DIM(vprio); i++) {
348 flow_attr.attr.priority = vprio[i] - 1;
349 flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr);
352 claim_zero(mlx5_glue->destroy_flow(flow));
355 mlx5_hrxq_drop_release(dev);
358 priority = RTE_DIM(priority_map_3);
361 priority = RTE_DIM(priority_map_5);
366 "port %u verbs maximum priority: %d expected 8/16",
367 dev->data->port_id, priority);
370 DRV_LOG(INFO, "port %u flow maximum priority: %d",
371 dev->data->port_id, priority);
376 * Adjust flow priority based on the highest layer and the request priority.
379 * Pointer to the Ethernet device structure.
380 * @param[in] priority
381 * The rule base priority.
382 * @param[in] subpriority
383 * The priority based on the items.
388 uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
389 uint32_t subpriority)
392 struct mlx5_priv *priv = dev->data->dev_private;
394 switch (priv->config.flow_prio) {
395 case RTE_DIM(priority_map_3):
396 res = priority_map_3[priority][subpriority];
398 case RTE_DIM(priority_map_5):
399 res = priority_map_5[priority][subpriority];
406 * Verify the @p item specifications (spec, last, mask) are compatible with the
410 * Item specification.
412 * @p item->mask or flow default bit-masks.
413 * @param[in] nic_mask
414 * Bit-masks covering supported fields by the NIC to compare with user mask.
416 * Bit-masks size in bytes.
418 * Pointer to error structure.
421 * 0 on success, a negative errno value otherwise and rte_errno is set.
424 mlx5_flow_item_acceptable(const struct rte_flow_item *item,
426 const uint8_t *nic_mask,
428 struct rte_flow_error *error)
433 for (i = 0; i < size; ++i)
434 if ((nic_mask[i] | mask[i]) != nic_mask[i])
435 return rte_flow_error_set(error, ENOTSUP,
436 RTE_FLOW_ERROR_TYPE_ITEM,
438 "mask enables non supported"
440 if (!item->spec && (item->mask || item->last))
441 return rte_flow_error_set(error, EINVAL,
442 RTE_FLOW_ERROR_TYPE_ITEM, item,
443 "mask/last without a spec is not"
445 if (item->spec && item->last) {
451 for (i = 0; i < size; ++i) {
452 spec[i] = ((const uint8_t *)item->spec)[i] & mask[i];
453 last[i] = ((const uint8_t *)item->last)[i] & mask[i];
455 ret = memcmp(spec, last, size);
457 return rte_flow_error_set(error, EINVAL,
458 RTE_FLOW_ERROR_TYPE_ITEM,
460 "range is not valid");
466 * Adjust the hash fields according to the @p flow information.
468 * @param[in] dev_flow.
469 * Pointer to the mlx5_flow.
471 * 1 when the hash field is for a tunnel item.
472 * @param[in] layer_types
474 * @param[in] hash_fields
478 * The hash fileds that should be used.
481 mlx5_flow_hashfields_adjust(struct mlx5_flow *dev_flow,
482 int tunnel __rte_unused, uint64_t layer_types,
483 uint64_t hash_fields)
485 struct rte_flow *flow = dev_flow->flow;
486 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
487 int rss_request_inner = flow->rss.level >= 2;
489 /* Check RSS hash level for tunnel. */
490 if (tunnel && rss_request_inner)
491 hash_fields |= IBV_RX_HASH_INNER;
492 else if (tunnel || rss_request_inner)
495 /* Check if requested layer matches RSS hash fields. */
496 if (!(flow->rss.types & layer_types))
502 * Lookup and set the ptype in the data Rx part. A single Ptype can be used,
503 * if several tunnel rules are used on this queue, the tunnel ptype will be
507 * Rx queue to update.
510 flow_rxq_tunnel_ptype_update(struct mlx5_rxq_ctrl *rxq_ctrl)
513 uint32_t tunnel_ptype = 0;
515 /* Look up for the ptype to use. */
516 for (i = 0; i != MLX5_FLOW_TUNNEL; ++i) {
517 if (!rxq_ctrl->flow_tunnels_n[i])
520 tunnel_ptype = tunnels_info[i].ptype;
526 rxq_ctrl->rxq.tunnel = tunnel_ptype;
530 * Set the Rx queue flags (Mark/Flag and Tunnel Ptypes) according to the devive
534 * Pointer to the Ethernet device structure.
535 * @param[in] dev_flow
536 * Pointer to device flow structure.
539 flow_drv_rxq_flags_set(struct rte_eth_dev *dev, struct mlx5_flow *dev_flow)
541 struct mlx5_priv *priv = dev->data->dev_private;
542 struct rte_flow *flow = dev_flow->flow;
543 const int mark = !!(flow->actions &
544 (MLX5_FLOW_ACTION_FLAG | MLX5_FLOW_ACTION_MARK));
545 const int tunnel = !!(dev_flow->layers & MLX5_FLOW_LAYER_TUNNEL);
548 for (i = 0; i != flow->rss.queue_num; ++i) {
549 int idx = (*flow->queue)[i];
550 struct mlx5_rxq_ctrl *rxq_ctrl =
551 container_of((*priv->rxqs)[idx],
552 struct mlx5_rxq_ctrl, rxq);
555 rxq_ctrl->rxq.mark = 1;
556 rxq_ctrl->flow_mark_n++;
561 /* Increase the counter matching the flow. */
562 for (j = 0; j != MLX5_FLOW_TUNNEL; ++j) {
563 if ((tunnels_info[j].tunnel &
565 tunnels_info[j].tunnel) {
566 rxq_ctrl->flow_tunnels_n[j]++;
570 flow_rxq_tunnel_ptype_update(rxq_ctrl);
576 * Set the Rx queue flags (Mark/Flag and Tunnel Ptypes) for a flow
579 * Pointer to the Ethernet device structure.
581 * Pointer to flow structure.
584 flow_rxq_flags_set(struct rte_eth_dev *dev, struct rte_flow *flow)
586 struct mlx5_flow *dev_flow;
588 LIST_FOREACH(dev_flow, &flow->dev_flows, next)
589 flow_drv_rxq_flags_set(dev, dev_flow);
593 * Clear the Rx queue flags (Mark/Flag and Tunnel Ptype) associated with the
594 * device flow if no other flow uses it with the same kind of request.
597 * Pointer to Ethernet device.
598 * @param[in] dev_flow
599 * Pointer to the device flow.
602 flow_drv_rxq_flags_trim(struct rte_eth_dev *dev, struct mlx5_flow *dev_flow)
604 struct mlx5_priv *priv = dev->data->dev_private;
605 struct rte_flow *flow = dev_flow->flow;
606 const int mark = !!(flow->actions &
607 (MLX5_FLOW_ACTION_FLAG | MLX5_FLOW_ACTION_MARK));
608 const int tunnel = !!(dev_flow->layers & MLX5_FLOW_LAYER_TUNNEL);
611 assert(dev->data->dev_started);
612 for (i = 0; i != flow->rss.queue_num; ++i) {
613 int idx = (*flow->queue)[i];
614 struct mlx5_rxq_ctrl *rxq_ctrl =
615 container_of((*priv->rxqs)[idx],
616 struct mlx5_rxq_ctrl, rxq);
619 rxq_ctrl->flow_mark_n--;
620 rxq_ctrl->rxq.mark = !!rxq_ctrl->flow_mark_n;
625 /* Decrease the counter matching the flow. */
626 for (j = 0; j != MLX5_FLOW_TUNNEL; ++j) {
627 if ((tunnels_info[j].tunnel &
629 tunnels_info[j].tunnel) {
630 rxq_ctrl->flow_tunnels_n[j]--;
634 flow_rxq_tunnel_ptype_update(rxq_ctrl);
640 * Clear the Rx queue flags (Mark/Flag and Tunnel Ptype) associated with the
641 * @p flow if no other flow uses it with the same kind of request.
644 * Pointer to Ethernet device.
646 * Pointer to the flow.
649 flow_rxq_flags_trim(struct rte_eth_dev *dev, struct rte_flow *flow)
651 struct mlx5_flow *dev_flow;
653 LIST_FOREACH(dev_flow, &flow->dev_flows, next)
654 flow_drv_rxq_flags_trim(dev, dev_flow);
658 * Clear the Mark/Flag and Tunnel ptype information in all Rx queues.
661 * Pointer to Ethernet device.
664 flow_rxq_flags_clear(struct rte_eth_dev *dev)
666 struct mlx5_priv *priv = dev->data->dev_private;
669 for (i = 0; i != priv->rxqs_n; ++i) {
670 struct mlx5_rxq_ctrl *rxq_ctrl;
673 if (!(*priv->rxqs)[i])
675 rxq_ctrl = container_of((*priv->rxqs)[i],
676 struct mlx5_rxq_ctrl, rxq);
677 rxq_ctrl->flow_mark_n = 0;
678 rxq_ctrl->rxq.mark = 0;
679 for (j = 0; j != MLX5_FLOW_TUNNEL; ++j)
680 rxq_ctrl->flow_tunnels_n[j] = 0;
681 rxq_ctrl->rxq.tunnel = 0;
686 * Validate the flag action.
688 * @param[in] action_flags
689 * Bit-fields that holds the actions detected until now.
691 * Attributes of flow that includes this action.
693 * Pointer to error structure.
696 * 0 on success, a negative errno value otherwise and rte_errno is set.
699 mlx5_flow_validate_action_flag(uint64_t action_flags,
700 const struct rte_flow_attr *attr,
701 struct rte_flow_error *error)
704 if (action_flags & MLX5_FLOW_ACTION_DROP)
705 return rte_flow_error_set(error, EINVAL,
706 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
707 "can't drop and flag in same flow");
708 if (action_flags & MLX5_FLOW_ACTION_MARK)
709 return rte_flow_error_set(error, EINVAL,
710 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
711 "can't mark and flag in same flow");
712 if (action_flags & MLX5_FLOW_ACTION_FLAG)
713 return rte_flow_error_set(error, EINVAL,
714 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
716 " actions in same flow");
718 return rte_flow_error_set(error, ENOTSUP,
719 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
720 "flag action not supported for "
726 * Validate the mark action.
729 * Pointer to the queue action.
730 * @param[in] action_flags
731 * Bit-fields that holds the actions detected until now.
733 * Attributes of flow that includes this action.
735 * Pointer to error structure.
738 * 0 on success, a negative errno value otherwise and rte_errno is set.
741 mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
742 uint64_t action_flags,
743 const struct rte_flow_attr *attr,
744 struct rte_flow_error *error)
746 const struct rte_flow_action_mark *mark = action->conf;
749 return rte_flow_error_set(error, EINVAL,
750 RTE_FLOW_ERROR_TYPE_ACTION,
752 "configuration cannot be null");
753 if (mark->id >= MLX5_FLOW_MARK_MAX)
754 return rte_flow_error_set(error, EINVAL,
755 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
757 "mark id must in 0 <= id < "
758 RTE_STR(MLX5_FLOW_MARK_MAX));
759 if (action_flags & MLX5_FLOW_ACTION_DROP)
760 return rte_flow_error_set(error, EINVAL,
761 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
762 "can't drop and mark in same flow");
763 if (action_flags & MLX5_FLOW_ACTION_FLAG)
764 return rte_flow_error_set(error, EINVAL,
765 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
766 "can't flag and mark in same flow");
767 if (action_flags & MLX5_FLOW_ACTION_MARK)
768 return rte_flow_error_set(error, EINVAL,
769 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
770 "can't have 2 mark actions in same"
773 return rte_flow_error_set(error, ENOTSUP,
774 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
775 "mark action not supported for "
781 * Validate the drop action.
783 * @param[in] action_flags
784 * Bit-fields that holds the actions detected until now.
786 * Attributes of flow that includes this action.
788 * Pointer to error structure.
791 * 0 on success, a negative errno value otherwise and rte_errno is set.
794 mlx5_flow_validate_action_drop(uint64_t action_flags,
795 const struct rte_flow_attr *attr,
796 struct rte_flow_error *error)
798 if (action_flags & MLX5_FLOW_ACTION_FLAG)
799 return rte_flow_error_set(error, EINVAL,
800 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
801 "can't drop and flag in same flow");
802 if (action_flags & MLX5_FLOW_ACTION_MARK)
803 return rte_flow_error_set(error, EINVAL,
804 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
805 "can't drop and mark in same flow");
806 if (action_flags & MLX5_FLOW_FATE_ACTIONS)
807 return rte_flow_error_set(error, EINVAL,
808 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
809 "can't have 2 fate actions in"
812 return rte_flow_error_set(error, ENOTSUP,
813 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
814 "drop action not supported for "
820 * Validate the queue action.
823 * Pointer to the queue action.
824 * @param[in] action_flags
825 * Bit-fields that holds the actions detected until now.
827 * Pointer to the Ethernet device structure.
829 * Attributes of flow that includes this action.
831 * Pointer to error structure.
834 * 0 on success, a negative errno value otherwise and rte_errno is set.
837 mlx5_flow_validate_action_queue(const struct rte_flow_action *action,
838 uint64_t action_flags,
839 struct rte_eth_dev *dev,
840 const struct rte_flow_attr *attr,
841 struct rte_flow_error *error)
843 struct mlx5_priv *priv = dev->data->dev_private;
844 const struct rte_flow_action_queue *queue = action->conf;
846 if (action_flags & MLX5_FLOW_FATE_ACTIONS)
847 return rte_flow_error_set(error, EINVAL,
848 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
849 "can't have 2 fate actions in"
852 return rte_flow_error_set(error, EINVAL,
853 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
854 NULL, "No Rx queues configured");
855 if (queue->index >= priv->rxqs_n)
856 return rte_flow_error_set(error, EINVAL,
857 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
859 "queue index out of range");
860 if (!(*priv->rxqs)[queue->index])
861 return rte_flow_error_set(error, EINVAL,
862 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
864 "queue is not configured");
866 return rte_flow_error_set(error, ENOTSUP,
867 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
868 "queue action not supported for "
874 * Validate the rss action.
877 * Pointer to the queue action.
878 * @param[in] action_flags
879 * Bit-fields that holds the actions detected until now.
881 * Pointer to the Ethernet device structure.
883 * Attributes of flow that includes this action.
884 * @param[in] item_flags
885 * Items that were detected.
887 * Pointer to error structure.
890 * 0 on success, a negative errno value otherwise and rte_errno is set.
893 mlx5_flow_validate_action_rss(const struct rte_flow_action *action,
894 uint64_t action_flags,
895 struct rte_eth_dev *dev,
896 const struct rte_flow_attr *attr,
898 struct rte_flow_error *error)
900 struct mlx5_priv *priv = dev->data->dev_private;
901 const struct rte_flow_action_rss *rss = action->conf;
902 int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
905 if (action_flags & MLX5_FLOW_FATE_ACTIONS)
906 return rte_flow_error_set(error, EINVAL,
907 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
908 "can't have 2 fate actions"
910 if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT &&
911 rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ)
912 return rte_flow_error_set(error, ENOTSUP,
913 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
915 "RSS hash function not supported");
916 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
921 return rte_flow_error_set(error, ENOTSUP,
922 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
924 "tunnel RSS is not supported");
925 /* allow RSS key_len 0 in case of NULL (default) RSS key. */
926 if (rss->key_len == 0 && rss->key != NULL)
927 return rte_flow_error_set(error, ENOTSUP,
928 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
930 "RSS hash key length 0");
931 if (rss->key_len > 0 && rss->key_len < MLX5_RSS_HASH_KEY_LEN)
932 return rte_flow_error_set(error, ENOTSUP,
933 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
935 "RSS hash key too small");
936 if (rss->key_len > MLX5_RSS_HASH_KEY_LEN)
937 return rte_flow_error_set(error, ENOTSUP,
938 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
940 "RSS hash key too large");
941 if (rss->queue_num > priv->config.ind_table_max_size)
942 return rte_flow_error_set(error, ENOTSUP,
943 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
945 "number of queues too large");
946 if (rss->types & MLX5_RSS_HF_MASK)
947 return rte_flow_error_set(error, ENOTSUP,
948 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
950 "some RSS protocols are not"
953 return rte_flow_error_set(error, EINVAL,
954 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
955 NULL, "No Rx queues configured");
957 return rte_flow_error_set(error, EINVAL,
958 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
959 NULL, "No queues configured");
960 for (i = 0; i != rss->queue_num; ++i) {
961 if (!(*priv->rxqs)[rss->queue[i]])
962 return rte_flow_error_set
963 (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF,
964 &rss->queue[i], "queue is not configured");
967 return rte_flow_error_set(error, ENOTSUP,
968 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
969 "rss action not supported for "
971 if (rss->level > 1 && !tunnel)
972 return rte_flow_error_set(error, EINVAL,
973 RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL,
974 "inner RSS is not supported for "
980 * Validate the count action.
983 * Pointer to the Ethernet device structure.
985 * Attributes of flow that includes this action.
987 * Pointer to error structure.
990 * 0 on success, a negative errno value otherwise and rte_errno is set.
993 mlx5_flow_validate_action_count(struct rte_eth_dev *dev __rte_unused,
994 const struct rte_flow_attr *attr,
995 struct rte_flow_error *error)
998 return rte_flow_error_set(error, ENOTSUP,
999 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
1000 "count action not supported for "
1006 * Verify the @p attributes will be correctly understood by the NIC and store
1007 * them in the @p flow if everything is correct.
1010 * Pointer to the Ethernet device structure.
1011 * @param[in] attributes
1012 * Pointer to flow attributes
1014 * Pointer to error structure.
1017 * 0 on success, a negative errno value otherwise and rte_errno is set.
1020 mlx5_flow_validate_attributes(struct rte_eth_dev *dev,
1021 const struct rte_flow_attr *attributes,
1022 struct rte_flow_error *error)
1024 struct mlx5_priv *priv = dev->data->dev_private;
1025 uint32_t priority_max = priv->config.flow_prio - 1;
1027 if (attributes->group)
1028 return rte_flow_error_set(error, ENOTSUP,
1029 RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
1030 NULL, "groups is not supported");
1031 if (attributes->priority != MLX5_FLOW_PRIO_RSVD &&
1032 attributes->priority >= priority_max)
1033 return rte_flow_error_set(error, ENOTSUP,
1034 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
1035 NULL, "priority out of range");
1036 if (attributes->egress)
1037 return rte_flow_error_set(error, ENOTSUP,
1038 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
1039 "egress is not supported");
1040 if (attributes->transfer)
1041 return rte_flow_error_set(error, ENOTSUP,
1042 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
1043 NULL, "transfer is not supported");
1044 if (!attributes->ingress)
1045 return rte_flow_error_set(error, EINVAL,
1046 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
1048 "ingress attribute is mandatory");
1053 * Validate Ethernet item.
1056 * Item specification.
1057 * @param[in] item_flags
1058 * Bit-fields that holds the items detected until now.
1060 * Pointer to error structure.
1063 * 0 on success, a negative errno value otherwise and rte_errno is set.
1066 mlx5_flow_validate_item_eth(const struct rte_flow_item *item,
1067 uint64_t item_flags,
1068 struct rte_flow_error *error)
1070 const struct rte_flow_item_eth *mask = item->mask;
1071 const struct rte_flow_item_eth nic_mask = {
1072 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1073 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1074 .type = RTE_BE16(0xffff),
1077 int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
1078 const uint64_t ethm = tunnel ? MLX5_FLOW_LAYER_INNER_L2 :
1079 MLX5_FLOW_LAYER_OUTER_L2;
1081 if (item_flags & ethm)
1082 return rte_flow_error_set(error, ENOTSUP,
1083 RTE_FLOW_ERROR_TYPE_ITEM, item,
1084 "multiple L2 layers not supported");
1086 mask = &rte_flow_item_eth_mask;
1087 ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask,
1088 (const uint8_t *)&nic_mask,
1089 sizeof(struct rte_flow_item_eth),
1095 * Validate VLAN item.
1098 * Item specification.
1099 * @param[in] item_flags
1100 * Bit-fields that holds the items detected until now.
1102 * Pointer to error structure.
1105 * 0 on success, a negative errno value otherwise and rte_errno is set.
1108 mlx5_flow_validate_item_vlan(const struct rte_flow_item *item,
1109 uint64_t item_flags,
1110 struct rte_flow_error *error)
1112 const struct rte_flow_item_vlan *spec = item->spec;
1113 const struct rte_flow_item_vlan *mask = item->mask;
1114 const struct rte_flow_item_vlan nic_mask = {
1115 .tci = RTE_BE16(0x0fff),
1116 .inner_type = RTE_BE16(0xffff),
1118 uint16_t vlan_tag = 0;
1119 const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
1121 const uint64_t l34m = tunnel ? (MLX5_FLOW_LAYER_INNER_L3 |
1122 MLX5_FLOW_LAYER_INNER_L4) :
1123 (MLX5_FLOW_LAYER_OUTER_L3 |
1124 MLX5_FLOW_LAYER_OUTER_L4);
1125 const uint64_t vlanm = tunnel ? MLX5_FLOW_LAYER_INNER_VLAN :
1126 MLX5_FLOW_LAYER_OUTER_VLAN;
1128 if (item_flags & vlanm)
1129 return rte_flow_error_set(error, EINVAL,
1130 RTE_FLOW_ERROR_TYPE_ITEM, item,
1131 "multiple VLAN layers not supported");
1132 else if ((item_flags & l34m) != 0)
1133 return rte_flow_error_set(error, EINVAL,
1134 RTE_FLOW_ERROR_TYPE_ITEM, item,
1135 "L2 layer cannot follow L3/L4 layer");
1137 mask = &rte_flow_item_vlan_mask;
1138 ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask,
1139 (const uint8_t *)&nic_mask,
1140 sizeof(struct rte_flow_item_vlan),
1145 vlan_tag = spec->tci;
1146 vlan_tag &= mask->tci;
1149 * From verbs perspective an empty VLAN is equivalent
1150 * to a packet without VLAN layer.
1153 return rte_flow_error_set(error, EINVAL,
1154 RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
1156 "VLAN cannot be empty");
1161 * Validate IPV4 item.
1164 * Item specification.
1165 * @param[in] item_flags
1166 * Bit-fields that holds the items detected until now.
1167 * @param[in] acc_mask
1168 * Acceptable mask, if NULL default internal default mask
1169 * will be used to check whether item fields are supported.
1171 * Pointer to error structure.
1174 * 0 on success, a negative errno value otherwise and rte_errno is set.
1177 mlx5_flow_validate_item_ipv4(const struct rte_flow_item *item,
1178 uint64_t item_flags,
1179 const struct rte_flow_item_ipv4 *acc_mask,
1180 struct rte_flow_error *error)
1182 const struct rte_flow_item_ipv4 *mask = item->mask;
1183 const struct rte_flow_item_ipv4 nic_mask = {
1185 .src_addr = RTE_BE32(0xffffffff),
1186 .dst_addr = RTE_BE32(0xffffffff),
1187 .type_of_service = 0xff,
1188 .next_proto_id = 0xff,
1191 const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
1192 const uint64_t l3m = tunnel ? MLX5_FLOW_LAYER_INNER_L3 :
1193 MLX5_FLOW_LAYER_OUTER_L3;
1194 const uint64_t l4m = tunnel ? MLX5_FLOW_LAYER_INNER_L4 :
1195 MLX5_FLOW_LAYER_OUTER_L4;
1198 if (item_flags & l3m)
1199 return rte_flow_error_set(error, ENOTSUP,
1200 RTE_FLOW_ERROR_TYPE_ITEM, item,
1201 "multiple L3 layers not supported");
1202 else if (item_flags & l4m)
1203 return rte_flow_error_set(error, EINVAL,
1204 RTE_FLOW_ERROR_TYPE_ITEM, item,
1205 "L3 cannot follow an L4 layer.");
1207 mask = &rte_flow_item_ipv4_mask;
1208 else if (mask->hdr.next_proto_id != 0 &&
1209 mask->hdr.next_proto_id != 0xff)
1210 return rte_flow_error_set(error, EINVAL,
1211 RTE_FLOW_ERROR_TYPE_ITEM_MASK, mask,
1212 "partial mask is not supported"
1214 ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask,
1215 acc_mask ? (const uint8_t *)acc_mask
1216 : (const uint8_t *)&nic_mask,
1217 sizeof(struct rte_flow_item_ipv4),
1225 * Validate IPV6 item.
1228 * Item specification.
1229 * @param[in] item_flags
1230 * Bit-fields that holds the items detected until now.
1231 * @param[in] acc_mask
1232 * Acceptable mask, if NULL default internal default mask
1233 * will be used to check whether item fields are supported.
1235 * Pointer to error structure.
1238 * 0 on success, a negative errno value otherwise and rte_errno is set.
1241 mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,
1242 uint64_t item_flags,
1243 const struct rte_flow_item_ipv6 *acc_mask,
1244 struct rte_flow_error *error)
1246 const struct rte_flow_item_ipv6 *mask = item->mask;
1247 const struct rte_flow_item_ipv6 nic_mask = {
1250 "\xff\xff\xff\xff\xff\xff\xff\xff"
1251 "\xff\xff\xff\xff\xff\xff\xff\xff",
1253 "\xff\xff\xff\xff\xff\xff\xff\xff"
1254 "\xff\xff\xff\xff\xff\xff\xff\xff",
1255 .vtc_flow = RTE_BE32(0xffffffff),
1260 const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
1261 const uint64_t l3m = tunnel ? MLX5_FLOW_LAYER_INNER_L3 :
1262 MLX5_FLOW_LAYER_OUTER_L3;
1263 const uint64_t l4m = tunnel ? MLX5_FLOW_LAYER_INNER_L4 :
1264 MLX5_FLOW_LAYER_OUTER_L4;
1267 if (item_flags & l3m)
1268 return rte_flow_error_set(error, ENOTSUP,
1269 RTE_FLOW_ERROR_TYPE_ITEM, item,
1270 "multiple L3 layers not supported");
1271 else if (item_flags & l4m)
1272 return rte_flow_error_set(error, EINVAL,
1273 RTE_FLOW_ERROR_TYPE_ITEM, item,
1274 "L3 cannot follow an L4 layer.");
1276 mask = &rte_flow_item_ipv6_mask;
1277 ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask,
1278 acc_mask ? (const uint8_t *)acc_mask
1279 : (const uint8_t *)&nic_mask,
1280 sizeof(struct rte_flow_item_ipv6),
1288 * Validate UDP item.
1291 * Item specification.
1292 * @param[in] item_flags
1293 * Bit-fields that holds the items detected until now.
1294 * @param[in] target_protocol
1295 * The next protocol in the previous item.
1296 * @param[in] flow_mask
1297 * mlx5 flow-specific (TCF, DV, verbs, etc.) supported header fields mask.
1299 * Pointer to error structure.
1302 * 0 on success, a negative errno value otherwise and rte_errno is set.
1305 mlx5_flow_validate_item_udp(const struct rte_flow_item *item,
1306 uint64_t item_flags,
1307 uint8_t target_protocol,
1308 struct rte_flow_error *error)
1310 const struct rte_flow_item_udp *mask = item->mask;
1311 const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
1312 const uint64_t l3m = tunnel ? MLX5_FLOW_LAYER_INNER_L3 :
1313 MLX5_FLOW_LAYER_OUTER_L3;
1314 const uint64_t l4m = tunnel ? MLX5_FLOW_LAYER_INNER_L4 :
1315 MLX5_FLOW_LAYER_OUTER_L4;
1318 if (target_protocol != 0xff && target_protocol != IPPROTO_UDP)
1319 return rte_flow_error_set(error, EINVAL,
1320 RTE_FLOW_ERROR_TYPE_ITEM, item,
1321 "protocol filtering not compatible"
1323 if (!(item_flags & l3m))
1324 return rte_flow_error_set(error, EINVAL,
1325 RTE_FLOW_ERROR_TYPE_ITEM, item,
1326 "L3 is mandatory to filter on L4");
1327 if (item_flags & l4m)
1328 return rte_flow_error_set(error, EINVAL,
1329 RTE_FLOW_ERROR_TYPE_ITEM, item,
1330 "multiple L4 layers not supported");
1332 mask = &rte_flow_item_udp_mask;
1333 ret = mlx5_flow_item_acceptable
1334 (item, (const uint8_t *)mask,
1335 (const uint8_t *)&rte_flow_item_udp_mask,
1336 sizeof(struct rte_flow_item_udp), error);
1343 * Validate TCP item.
1346 * Item specification.
1347 * @param[in] item_flags
1348 * Bit-fields that holds the items detected until now.
1349 * @param[in] target_protocol
1350 * The next protocol in the previous item.
1352 * Pointer to error structure.
1355 * 0 on success, a negative errno value otherwise and rte_errno is set.
1358 mlx5_flow_validate_item_tcp(const struct rte_flow_item *item,
1359 uint64_t item_flags,
1360 uint8_t target_protocol,
1361 const struct rte_flow_item_tcp *flow_mask,
1362 struct rte_flow_error *error)
1364 const struct rte_flow_item_tcp *mask = item->mask;
1365 const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
1366 const uint64_t l3m = tunnel ? MLX5_FLOW_LAYER_INNER_L3 :
1367 MLX5_FLOW_LAYER_OUTER_L3;
1368 const uint64_t l4m = tunnel ? MLX5_FLOW_LAYER_INNER_L4 :
1369 MLX5_FLOW_LAYER_OUTER_L4;
1373 if (target_protocol != 0xff && target_protocol != IPPROTO_TCP)
1374 return rte_flow_error_set(error, EINVAL,
1375 RTE_FLOW_ERROR_TYPE_ITEM, item,
1376 "protocol filtering not compatible"
1378 if (!(item_flags & l3m))
1379 return rte_flow_error_set(error, EINVAL,
1380 RTE_FLOW_ERROR_TYPE_ITEM, item,
1381 "L3 is mandatory to filter on L4");
1382 if (item_flags & l4m)
1383 return rte_flow_error_set(error, EINVAL,
1384 RTE_FLOW_ERROR_TYPE_ITEM, item,
1385 "multiple L4 layers not supported");
1387 mask = &rte_flow_item_tcp_mask;
1388 ret = mlx5_flow_item_acceptable
1389 (item, (const uint8_t *)mask,
1390 (const uint8_t *)flow_mask,
1391 sizeof(struct rte_flow_item_tcp), error);
1398 * Validate VXLAN item.
1401 * Item specification.
1402 * @param[in] item_flags
1403 * Bit-fields that holds the items detected until now.
1404 * @param[in] target_protocol
1405 * The next protocol in the previous item.
1407 * Pointer to error structure.
1410 * 0 on success, a negative errno value otherwise and rte_errno is set.
1413 mlx5_flow_validate_item_vxlan(const struct rte_flow_item *item,
1414 uint64_t item_flags,
1415 struct rte_flow_error *error)
1417 const struct rte_flow_item_vxlan *spec = item->spec;
1418 const struct rte_flow_item_vxlan *mask = item->mask;
1423 } id = { .vlan_id = 0, };
1424 uint32_t vlan_id = 0;
1427 if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
1428 return rte_flow_error_set(error, ENOTSUP,
1429 RTE_FLOW_ERROR_TYPE_ITEM, item,
1430 "multiple tunnel layers not"
1433 * Verify only UDPv4 is present as defined in
1434 * https://tools.ietf.org/html/rfc7348
1436 if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_UDP))
1437 return rte_flow_error_set(error, EINVAL,
1438 RTE_FLOW_ERROR_TYPE_ITEM, item,
1439 "no outer UDP layer found");
1441 mask = &rte_flow_item_vxlan_mask;
1442 ret = mlx5_flow_item_acceptable
1443 (item, (const uint8_t *)mask,
1444 (const uint8_t *)&rte_flow_item_vxlan_mask,
1445 sizeof(struct rte_flow_item_vxlan),
1450 memcpy(&id.vni[1], spec->vni, 3);
1451 vlan_id = id.vlan_id;
1452 memcpy(&id.vni[1], mask->vni, 3);
1453 vlan_id &= id.vlan_id;
1456 * Tunnel id 0 is equivalent as not adding a VXLAN layer, if
1457 * only this layer is defined in the Verbs specification it is
1458 * interpreted as wildcard and all packets will match this
1459 * rule, if it follows a full stack layer (ex: eth / ipv4 /
1460 * udp), all packets matching the layers before will also
1461 * match this rule. To avoid such situation, VNI 0 is
1462 * currently refused.
1465 return rte_flow_error_set(error, ENOTSUP,
1466 RTE_FLOW_ERROR_TYPE_ITEM, item,
1467 "VXLAN vni cannot be 0");
1468 if (!(item_flags & MLX5_FLOW_LAYER_OUTER))
1469 return rte_flow_error_set(error, ENOTSUP,
1470 RTE_FLOW_ERROR_TYPE_ITEM, item,
1471 "VXLAN tunnel must be fully defined");
1476 * Validate VXLAN_GPE item.
1479 * Item specification.
1480 * @param[in] item_flags
1481 * Bit-fields that holds the items detected until now.
1483 * Pointer to the private data structure.
1484 * @param[in] target_protocol
1485 * The next protocol in the previous item.
1487 * Pointer to error structure.
1490 * 0 on success, a negative errno value otherwise and rte_errno is set.
1493 mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
1494 uint64_t item_flags,
1495 struct rte_eth_dev *dev,
1496 struct rte_flow_error *error)
1498 struct mlx5_priv *priv = dev->data->dev_private;
1499 const struct rte_flow_item_vxlan_gpe *spec = item->spec;
1500 const struct rte_flow_item_vxlan_gpe *mask = item->mask;
1505 } id = { .vlan_id = 0, };
1506 uint32_t vlan_id = 0;
1508 if (!priv->config.l3_vxlan_en)
1509 return rte_flow_error_set(error, ENOTSUP,
1510 RTE_FLOW_ERROR_TYPE_ITEM, item,
1511 "L3 VXLAN is not enabled by device"
1512 " parameter and/or not configured in"
1514 if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
1515 return rte_flow_error_set(error, ENOTSUP,
1516 RTE_FLOW_ERROR_TYPE_ITEM, item,
1517 "multiple tunnel layers not"
1520 * Verify only UDPv4 is present as defined in
1521 * https://tools.ietf.org/html/rfc7348
1523 if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_UDP))
1524 return rte_flow_error_set(error, EINVAL,
1525 RTE_FLOW_ERROR_TYPE_ITEM, item,
1526 "no outer UDP layer found");
1528 mask = &rte_flow_item_vxlan_gpe_mask;
1529 ret = mlx5_flow_item_acceptable
1530 (item, (const uint8_t *)mask,
1531 (const uint8_t *)&rte_flow_item_vxlan_gpe_mask,
1532 sizeof(struct rte_flow_item_vxlan_gpe),
1538 return rte_flow_error_set(error, ENOTSUP,
1539 RTE_FLOW_ERROR_TYPE_ITEM,
1541 "VxLAN-GPE protocol"
1543 memcpy(&id.vni[1], spec->vni, 3);
1544 vlan_id = id.vlan_id;
1545 memcpy(&id.vni[1], mask->vni, 3);
1546 vlan_id &= id.vlan_id;
1549 * Tunnel id 0 is equivalent as not adding a VXLAN layer, if only this
1550 * layer is defined in the Verbs specification it is interpreted as
1551 * wildcard and all packets will match this rule, if it follows a full
1552 * stack layer (ex: eth / ipv4 / udp), all packets matching the layers
1553 * before will also match this rule. To avoid such situation, VNI 0
1554 * is currently refused.
1557 return rte_flow_error_set(error, ENOTSUP,
1558 RTE_FLOW_ERROR_TYPE_ITEM, item,
1559 "VXLAN-GPE vni cannot be 0");
1560 if (!(item_flags & MLX5_FLOW_LAYER_OUTER))
1561 return rte_flow_error_set(error, ENOTSUP,
1562 RTE_FLOW_ERROR_TYPE_ITEM, item,
1563 "VXLAN-GPE tunnel must be fully"
1569 * Validate GRE item.
1572 * Item specification.
1573 * @param[in] item_flags
1574 * Bit flags to mark detected items.
1575 * @param[in] target_protocol
1576 * The next protocol in the previous item.
1578 * Pointer to error structure.
1581 * 0 on success, a negative errno value otherwise and rte_errno is set.
1584 mlx5_flow_validate_item_gre(const struct rte_flow_item *item,
1585 uint64_t item_flags,
1586 uint8_t target_protocol,
1587 struct rte_flow_error *error)
1589 const struct rte_flow_item_gre *spec __rte_unused = item->spec;
1590 const struct rte_flow_item_gre *mask = item->mask;
1593 if (target_protocol != 0xff && target_protocol != IPPROTO_GRE)
1594 return rte_flow_error_set(error, EINVAL,
1595 RTE_FLOW_ERROR_TYPE_ITEM, item,
1596 "protocol filtering not compatible"
1597 " with this GRE layer");
1598 if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
1599 return rte_flow_error_set(error, ENOTSUP,
1600 RTE_FLOW_ERROR_TYPE_ITEM, item,
1601 "multiple tunnel layers not"
1603 if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L3))
1604 return rte_flow_error_set(error, ENOTSUP,
1605 RTE_FLOW_ERROR_TYPE_ITEM, item,
1606 "L3 Layer is missing");
1608 mask = &rte_flow_item_gre_mask;
1609 ret = mlx5_flow_item_acceptable
1610 (item, (const uint8_t *)mask,
1611 (const uint8_t *)&rte_flow_item_gre_mask,
1612 sizeof(struct rte_flow_item_gre), error);
1615 #ifndef HAVE_IBV_DEVICE_MPLS_SUPPORT
1616 if (spec && (spec->protocol & mask->protocol))
1617 return rte_flow_error_set(error, ENOTSUP,
1618 RTE_FLOW_ERROR_TYPE_ITEM, item,
1619 "without MPLS support the"
1620 " specification cannot be used for"
1627 * Validate MPLS item.
1630 * Pointer to the rte_eth_dev structure.
1632 * Item specification.
1633 * @param[in] item_flags
1634 * Bit-fields that holds the items detected until now.
1635 * @param[in] prev_layer
1636 * The protocol layer indicated in previous item.
1638 * Pointer to error structure.
1641 * 0 on success, a negative errno value otherwise and rte_errno is set.
1644 mlx5_flow_validate_item_mpls(struct rte_eth_dev *dev __rte_unused,
1645 const struct rte_flow_item *item __rte_unused,
1646 uint64_t item_flags __rte_unused,
1647 uint64_t prev_layer __rte_unused,
1648 struct rte_flow_error *error)
1650 #ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT
1651 const struct rte_flow_item_mpls *mask = item->mask;
1652 struct mlx5_priv *priv = dev->data->dev_private;
1655 if (!priv->config.mpls_en)
1656 return rte_flow_error_set(error, ENOTSUP,
1657 RTE_FLOW_ERROR_TYPE_ITEM, item,
1658 "MPLS not supported or"
1659 " disabled in firmware"
1661 /* MPLS over IP, UDP, GRE is allowed */
1662 if (!(prev_layer & (MLX5_FLOW_LAYER_OUTER_L3 |
1663 MLX5_FLOW_LAYER_OUTER_L4_UDP |
1664 MLX5_FLOW_LAYER_GRE)))
1665 return rte_flow_error_set(error, EINVAL,
1666 RTE_FLOW_ERROR_TYPE_ITEM, item,
1667 "protocol filtering not compatible"
1668 " with MPLS layer");
1669 /* Multi-tunnel isn't allowed but MPLS over GRE is an exception. */
1670 if ((item_flags & MLX5_FLOW_LAYER_TUNNEL) &&
1671 !(item_flags & MLX5_FLOW_LAYER_GRE))
1672 return rte_flow_error_set(error, ENOTSUP,
1673 RTE_FLOW_ERROR_TYPE_ITEM, item,
1674 "multiple tunnel layers not"
1677 mask = &rte_flow_item_mpls_mask;
1678 ret = mlx5_flow_item_acceptable
1679 (item, (const uint8_t *)mask,
1680 (const uint8_t *)&rte_flow_item_mpls_mask,
1681 sizeof(struct rte_flow_item_mpls), error);
1686 return rte_flow_error_set(error, ENOTSUP,
1687 RTE_FLOW_ERROR_TYPE_ITEM, item,
1688 "MPLS is not supported by Verbs, please"
1693 flow_null_validate(struct rte_eth_dev *dev __rte_unused,
1694 const struct rte_flow_attr *attr __rte_unused,
1695 const struct rte_flow_item items[] __rte_unused,
1696 const struct rte_flow_action actions[] __rte_unused,
1697 struct rte_flow_error *error)
1699 return rte_flow_error_set(error, ENOTSUP,
1700 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, NULL);
1703 static struct mlx5_flow *
1704 flow_null_prepare(const struct rte_flow_attr *attr __rte_unused,
1705 const struct rte_flow_item items[] __rte_unused,
1706 const struct rte_flow_action actions[] __rte_unused,
1707 struct rte_flow_error *error)
1709 rte_flow_error_set(error, ENOTSUP,
1710 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, NULL);
1715 flow_null_translate(struct rte_eth_dev *dev __rte_unused,
1716 struct mlx5_flow *dev_flow __rte_unused,
1717 const struct rte_flow_attr *attr __rte_unused,
1718 const struct rte_flow_item items[] __rte_unused,
1719 const struct rte_flow_action actions[] __rte_unused,
1720 struct rte_flow_error *error)
1722 return rte_flow_error_set(error, ENOTSUP,
1723 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, NULL);
1727 flow_null_apply(struct rte_eth_dev *dev __rte_unused,
1728 struct rte_flow *flow __rte_unused,
1729 struct rte_flow_error *error)
1731 return rte_flow_error_set(error, ENOTSUP,
1732 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, NULL);
1736 flow_null_remove(struct rte_eth_dev *dev __rte_unused,
1737 struct rte_flow *flow __rte_unused)
1742 flow_null_destroy(struct rte_eth_dev *dev __rte_unused,
1743 struct rte_flow *flow __rte_unused)
1748 flow_null_query(struct rte_eth_dev *dev __rte_unused,
1749 struct rte_flow *flow __rte_unused,
1750 const struct rte_flow_action *actions __rte_unused,
1751 void *data __rte_unused,
1752 struct rte_flow_error *error)
1754 return rte_flow_error_set(error, ENOTSUP,
1755 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, NULL);
1758 /* Void driver to protect from null pointer reference. */
1759 const struct mlx5_flow_driver_ops mlx5_flow_null_drv_ops = {
1760 .validate = flow_null_validate,
1761 .prepare = flow_null_prepare,
1762 .translate = flow_null_translate,
1763 .apply = flow_null_apply,
1764 .remove = flow_null_remove,
1765 .destroy = flow_null_destroy,
1766 .query = flow_null_query,
1770 * Select flow driver type according to flow attributes and device
1774 * Pointer to the dev structure.
1776 * Pointer to the flow attributes.
1779 * flow driver type, MLX5_FLOW_TYPE_MAX otherwise.
1781 static enum mlx5_flow_drv_type
1782 flow_get_drv_type(struct rte_eth_dev *dev, const struct rte_flow_attr *attr)
1784 struct mlx5_priv *priv = dev->data->dev_private;
1785 enum mlx5_flow_drv_type type = MLX5_FLOW_TYPE_MAX;
1787 if (attr->transfer && !priv->config.dv_esw_en)
1788 type = MLX5_FLOW_TYPE_TCF;
1790 type = priv->config.dv_flow_en ? MLX5_FLOW_TYPE_DV :
1791 MLX5_FLOW_TYPE_VERBS;
1795 #define flow_get_drv_ops(type) flow_drv_ops[type]
1798 * Flow driver validation API. This abstracts calling driver specific functions.
1799 * The type of flow driver is determined according to flow attributes.
1802 * Pointer to the dev structure.
1804 * Pointer to the flow attributes.
1806 * Pointer to the list of items.
1807 * @param[in] actions
1808 * Pointer to the list of actions.
1810 * Pointer to the error structure.
1813 * 0 on success, a negative errno value otherwise and rte_errno is set.
1816 flow_drv_validate(struct rte_eth_dev *dev,
1817 const struct rte_flow_attr *attr,
1818 const struct rte_flow_item items[],
1819 const struct rte_flow_action actions[],
1820 struct rte_flow_error *error)
1822 const struct mlx5_flow_driver_ops *fops;
1823 enum mlx5_flow_drv_type type = flow_get_drv_type(dev, attr);
1825 fops = flow_get_drv_ops(type);
1826 return fops->validate(dev, attr, items, actions, error);
1830 * Flow driver preparation API. This abstracts calling driver specific
1831 * functions. Parent flow (rte_flow) should have driver type (drv_type). It
1832 * calculates the size of memory required for device flow, allocates the memory,
1833 * initializes the device flow and returns the pointer.
1836 * This function initializes device flow structure such as dv, tcf or verbs in
1837 * struct mlx5_flow. However, it is caller's responsibility to initialize the
1838 * rest. For example, adding returning device flow to flow->dev_flow list and
1839 * setting backward reference to the flow should be done out of this function.
1840 * layers field is not filled either.
1843 * Pointer to the flow attributes.
1845 * Pointer to the list of items.
1846 * @param[in] actions
1847 * Pointer to the list of actions.
1849 * Pointer to the error structure.
1852 * Pointer to device flow on success, otherwise NULL and rte_errno is set.
1854 static inline struct mlx5_flow *
1855 flow_drv_prepare(const struct rte_flow *flow,
1856 const struct rte_flow_attr *attr,
1857 const struct rte_flow_item items[],
1858 const struct rte_flow_action actions[],
1859 struct rte_flow_error *error)
1861 const struct mlx5_flow_driver_ops *fops;
1862 enum mlx5_flow_drv_type type = flow->drv_type;
1864 assert(type > MLX5_FLOW_TYPE_MIN && type < MLX5_FLOW_TYPE_MAX);
1865 fops = flow_get_drv_ops(type);
1866 return fops->prepare(attr, items, actions, error);
1870 * Flow driver translation API. This abstracts calling driver specific
1871 * functions. Parent flow (rte_flow) should have driver type (drv_type). It
1872 * translates a generic flow into a driver flow. flow_drv_prepare() must
1876 * dev_flow->layers could be filled as a result of parsing during translation
1877 * if needed by flow_drv_apply(). dev_flow->flow->actions can also be filled
1878 * if necessary. As a flow can have multiple dev_flows by RSS flow expansion,
1879 * flow->actions could be overwritten even though all the expanded dev_flows
1880 * have the same actions.
1883 * Pointer to the rte dev structure.
1884 * @param[in, out] dev_flow
1885 * Pointer to the mlx5 flow.
1887 * Pointer to the flow attributes.
1889 * Pointer to the list of items.
1890 * @param[in] actions
1891 * Pointer to the list of actions.
1893 * Pointer to the error structure.
1896 * 0 on success, a negative errno value otherwise and rte_errno is set.
1899 flow_drv_translate(struct rte_eth_dev *dev, struct mlx5_flow *dev_flow,
1900 const struct rte_flow_attr *attr,
1901 const struct rte_flow_item items[],
1902 const struct rte_flow_action actions[],
1903 struct rte_flow_error *error)
1905 const struct mlx5_flow_driver_ops *fops;
1906 enum mlx5_flow_drv_type type = dev_flow->flow->drv_type;
1908 assert(type > MLX5_FLOW_TYPE_MIN && type < MLX5_FLOW_TYPE_MAX);
1909 fops = flow_get_drv_ops(type);
1910 return fops->translate(dev, dev_flow, attr, items, actions, error);
1914 * Flow driver apply API. This abstracts calling driver specific functions.
1915 * Parent flow (rte_flow) should have driver type (drv_type). It applies
1916 * translated driver flows on to device. flow_drv_translate() must precede.
1919 * Pointer to Ethernet device structure.
1920 * @param[in, out] flow
1921 * Pointer to flow structure.
1923 * Pointer to error structure.
1926 * 0 on success, a negative errno value otherwise and rte_errno is set.
1929 flow_drv_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
1930 struct rte_flow_error *error)
1932 const struct mlx5_flow_driver_ops *fops;
1933 enum mlx5_flow_drv_type type = flow->drv_type;
1935 assert(type > MLX5_FLOW_TYPE_MIN && type < MLX5_FLOW_TYPE_MAX);
1936 fops = flow_get_drv_ops(type);
1937 return fops->apply(dev, flow, error);
1941 * Flow driver remove API. This abstracts calling driver specific functions.
1942 * Parent flow (rte_flow) should have driver type (drv_type). It removes a flow
1943 * on device. All the resources of the flow should be freed by calling
1944 * flow_drv_destroy().
1947 * Pointer to Ethernet device.
1948 * @param[in, out] flow
1949 * Pointer to flow structure.
1952 flow_drv_remove(struct rte_eth_dev *dev, struct rte_flow *flow)
1954 const struct mlx5_flow_driver_ops *fops;
1955 enum mlx5_flow_drv_type type = flow->drv_type;
1957 assert(type > MLX5_FLOW_TYPE_MIN && type < MLX5_FLOW_TYPE_MAX);
1958 fops = flow_get_drv_ops(type);
1959 fops->remove(dev, flow);
1963 * Flow driver destroy API. This abstracts calling driver specific functions.
1964 * Parent flow (rte_flow) should have driver type (drv_type). It removes a flow
1965 * on device and releases resources of the flow.
1968 * Pointer to Ethernet device.
1969 * @param[in, out] flow
1970 * Pointer to flow structure.
1973 flow_drv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)
1975 const struct mlx5_flow_driver_ops *fops;
1976 enum mlx5_flow_drv_type type = flow->drv_type;
1978 assert(type > MLX5_FLOW_TYPE_MIN && type < MLX5_FLOW_TYPE_MAX);
1979 fops = flow_get_drv_ops(type);
1980 fops->destroy(dev, flow);
1984 * Validate a flow supported by the NIC.
1986 * @see rte_flow_validate()
1990 mlx5_flow_validate(struct rte_eth_dev *dev,
1991 const struct rte_flow_attr *attr,
1992 const struct rte_flow_item items[],
1993 const struct rte_flow_action actions[],
1994 struct rte_flow_error *error)
1998 ret = flow_drv_validate(dev, attr, items, actions, error);
2005 * Get RSS action from the action list.
2007 * @param[in] actions
2008 * Pointer to the list of actions.
2011 * Pointer to the RSS action if exist, else return NULL.
2013 static const struct rte_flow_action_rss*
2014 flow_get_rss_action(const struct rte_flow_action actions[])
2016 for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
2017 switch (actions->type) {
2018 case RTE_FLOW_ACTION_TYPE_RSS:
2019 return (const struct rte_flow_action_rss *)
2029 find_graph_root(const struct rte_flow_item pattern[], uint32_t rss_level)
2031 const struct rte_flow_item *item;
2032 unsigned int has_vlan = 0;
2034 for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
2035 if (item->type == RTE_FLOW_ITEM_TYPE_VLAN) {
2041 return rss_level < 2 ? MLX5_EXPANSION_ROOT_ETH_VLAN :
2042 MLX5_EXPANSION_ROOT_OUTER_ETH_VLAN;
2043 return rss_level < 2 ? MLX5_EXPANSION_ROOT :
2044 MLX5_EXPANSION_ROOT_OUTER;
2048 * Create a flow and add it to @p list.
2051 * Pointer to Ethernet device.
2053 * Pointer to a TAILQ flow list.
2055 * Flow rule attributes.
2057 * Pattern specification (list terminated by the END pattern item).
2058 * @param[in] actions
2059 * Associated actions (list terminated by the END action).
2061 * Perform verbose error reporting if not NULL.
2064 * A flow on success, NULL otherwise and rte_errno is set.
2066 static struct rte_flow *
2067 flow_list_create(struct rte_eth_dev *dev, struct mlx5_flows *list,
2068 const struct rte_flow_attr *attr,
2069 const struct rte_flow_item items[],
2070 const struct rte_flow_action actions[],
2071 struct rte_flow_error *error)
2073 struct rte_flow *flow = NULL;
2074 struct mlx5_flow *dev_flow;
2075 const struct rte_flow_action_rss *rss;
2077 struct rte_flow_expand_rss buf;
2078 uint8_t buffer[2048];
2080 struct rte_flow_expand_rss *buf = &expand_buffer.buf;
2085 ret = flow_drv_validate(dev, attr, items, actions, error);
2088 flow_size = sizeof(struct rte_flow);
2089 rss = flow_get_rss_action(actions);
2091 flow_size += RTE_ALIGN_CEIL(rss->queue_num * sizeof(uint16_t),
2094 flow_size += RTE_ALIGN_CEIL(sizeof(uint16_t), sizeof(void *));
2095 flow = rte_calloc(__func__, 1, flow_size, 0);
2096 flow->drv_type = flow_get_drv_type(dev, attr);
2097 flow->ingress = attr->ingress;
2098 flow->transfer = attr->transfer;
2099 assert(flow->drv_type > MLX5_FLOW_TYPE_MIN &&
2100 flow->drv_type < MLX5_FLOW_TYPE_MAX);
2101 flow->queue = (void *)(flow + 1);
2102 LIST_INIT(&flow->dev_flows);
2103 if (rss && rss->types) {
2104 unsigned int graph_root;
2106 graph_root = find_graph_root(items, rss->level);
2107 ret = rte_flow_expand_rss(buf, sizeof(expand_buffer.buffer),
2109 mlx5_support_expansion,
2112 (unsigned int)ret < sizeof(expand_buffer.buffer));
2115 buf->entry[0].pattern = (void *)(uintptr_t)items;
2117 for (i = 0; i < buf->entries; ++i) {
2118 dev_flow = flow_drv_prepare(flow, attr, buf->entry[i].pattern,
2122 dev_flow->flow = flow;
2123 LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next);
2124 ret = flow_drv_translate(dev, dev_flow, attr,
2125 buf->entry[i].pattern,
2130 if (dev->data->dev_started) {
2131 ret = flow_drv_apply(dev, flow, error);
2135 TAILQ_INSERT_TAIL(list, flow, next);
2136 flow_rxq_flags_set(dev, flow);
2139 ret = rte_errno; /* Save rte_errno before cleanup. */
2141 flow_drv_destroy(dev, flow);
2143 rte_errno = ret; /* Restore rte_errno. */
2150 * @see rte_flow_create()
2154 mlx5_flow_create(struct rte_eth_dev *dev,
2155 const struct rte_flow_attr *attr,
2156 const struct rte_flow_item items[],
2157 const struct rte_flow_action actions[],
2158 struct rte_flow_error *error)
2160 struct mlx5_priv *priv = dev->data->dev_private;
2162 return flow_list_create(dev, &priv->flows,
2163 attr, items, actions, error);
2167 * Destroy a flow in a list.
2170 * Pointer to Ethernet device.
2172 * Pointer to a TAILQ flow list.
2177 flow_list_destroy(struct rte_eth_dev *dev, struct mlx5_flows *list,
2178 struct rte_flow *flow)
2181 * Update RX queue flags only if port is started, otherwise it is
2184 if (dev->data->dev_started)
2185 flow_rxq_flags_trim(dev, flow);
2186 flow_drv_destroy(dev, flow);
2187 TAILQ_REMOVE(list, flow, next);
2188 rte_free(flow->fdir);
2193 * Destroy all flows.
2196 * Pointer to Ethernet device.
2198 * Pointer to a TAILQ flow list.
2201 mlx5_flow_list_flush(struct rte_eth_dev *dev, struct mlx5_flows *list)
2203 while (!TAILQ_EMPTY(list)) {
2204 struct rte_flow *flow;
2206 flow = TAILQ_FIRST(list);
2207 flow_list_destroy(dev, list, flow);
2215 * Pointer to Ethernet device.
2217 * Pointer to a TAILQ flow list.
2220 mlx5_flow_stop(struct rte_eth_dev *dev, struct mlx5_flows *list)
2222 struct rte_flow *flow;
2224 TAILQ_FOREACH_REVERSE(flow, list, mlx5_flows, next)
2225 flow_drv_remove(dev, flow);
2226 flow_rxq_flags_clear(dev);
2233 * Pointer to Ethernet device.
2235 * Pointer to a TAILQ flow list.
2238 * 0 on success, a negative errno value otherwise and rte_errno is set.
2241 mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list)
2243 struct rte_flow *flow;
2244 struct rte_flow_error error;
2247 TAILQ_FOREACH(flow, list, next) {
2248 ret = flow_drv_apply(dev, flow, &error);
2251 flow_rxq_flags_set(dev, flow);
2255 ret = rte_errno; /* Save rte_errno before cleanup. */
2256 mlx5_flow_stop(dev, list);
2257 rte_errno = ret; /* Restore rte_errno. */
2262 * Verify the flow list is empty
2265 * Pointer to Ethernet device.
2267 * @return the number of flows not released.
2270 mlx5_flow_verify(struct rte_eth_dev *dev)
2272 struct mlx5_priv *priv = dev->data->dev_private;
2273 struct rte_flow *flow;
2276 TAILQ_FOREACH(flow, &priv->flows, next) {
2277 DRV_LOG(DEBUG, "port %u flow %p still referenced",
2278 dev->data->port_id, (void *)flow);
2285 * Enable a control flow configured from the control plane.
2288 * Pointer to Ethernet device.
2290 * An Ethernet flow spec to apply.
2292 * An Ethernet flow mask to apply.
2294 * A VLAN flow spec to apply.
2296 * A VLAN flow mask to apply.
2299 * 0 on success, a negative errno value otherwise and rte_errno is set.
2302 mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev,
2303 struct rte_flow_item_eth *eth_spec,
2304 struct rte_flow_item_eth *eth_mask,
2305 struct rte_flow_item_vlan *vlan_spec,
2306 struct rte_flow_item_vlan *vlan_mask)
2308 struct mlx5_priv *priv = dev->data->dev_private;
2309 const struct rte_flow_attr attr = {
2311 .priority = MLX5_FLOW_PRIO_RSVD,
2313 struct rte_flow_item items[] = {
2315 .type = RTE_FLOW_ITEM_TYPE_ETH,
2321 .type = (vlan_spec) ? RTE_FLOW_ITEM_TYPE_VLAN :
2322 RTE_FLOW_ITEM_TYPE_END,
2328 .type = RTE_FLOW_ITEM_TYPE_END,
2331 uint16_t queue[priv->reta_idx_n];
2332 struct rte_flow_action_rss action_rss = {
2333 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
2335 .types = priv->rss_conf.rss_hf,
2336 .key_len = priv->rss_conf.rss_key_len,
2337 .queue_num = priv->reta_idx_n,
2338 .key = priv->rss_conf.rss_key,
2341 struct rte_flow_action actions[] = {
2343 .type = RTE_FLOW_ACTION_TYPE_RSS,
2344 .conf = &action_rss,
2347 .type = RTE_FLOW_ACTION_TYPE_END,
2350 struct rte_flow *flow;
2351 struct rte_flow_error error;
2354 if (!priv->reta_idx_n || !priv->rxqs_n) {
2357 for (i = 0; i != priv->reta_idx_n; ++i)
2358 queue[i] = (*priv->reta_idx)[i];
2359 flow = flow_list_create(dev, &priv->ctrl_flows,
2360 &attr, items, actions, &error);
2367 * Enable a flow control configured from the control plane.
2370 * Pointer to Ethernet device.
2372 * An Ethernet flow spec to apply.
2374 * An Ethernet flow mask to apply.
2377 * 0 on success, a negative errno value otherwise and rte_errno is set.
2380 mlx5_ctrl_flow(struct rte_eth_dev *dev,
2381 struct rte_flow_item_eth *eth_spec,
2382 struct rte_flow_item_eth *eth_mask)
2384 return mlx5_ctrl_flow_vlan(dev, eth_spec, eth_mask, NULL, NULL);
2390 * @see rte_flow_destroy()
2394 mlx5_flow_destroy(struct rte_eth_dev *dev,
2395 struct rte_flow *flow,
2396 struct rte_flow_error *error __rte_unused)
2398 struct mlx5_priv *priv = dev->data->dev_private;
2400 flow_list_destroy(dev, &priv->flows, flow);
2405 * Destroy all flows.
2407 * @see rte_flow_flush()
2411 mlx5_flow_flush(struct rte_eth_dev *dev,
2412 struct rte_flow_error *error __rte_unused)
2414 struct mlx5_priv *priv = dev->data->dev_private;
2416 mlx5_flow_list_flush(dev, &priv->flows);
2423 * @see rte_flow_isolate()
2427 mlx5_flow_isolate(struct rte_eth_dev *dev,
2429 struct rte_flow_error *error)
2431 struct mlx5_priv *priv = dev->data->dev_private;
2433 if (dev->data->dev_started) {
2434 rte_flow_error_set(error, EBUSY,
2435 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
2437 "port must be stopped first");
2440 priv->isolated = !!enable;
2442 dev->dev_ops = &mlx5_dev_ops_isolate;
2444 dev->dev_ops = &mlx5_dev_ops;
2451 * @see rte_flow_query()
2455 flow_drv_query(struct rte_eth_dev *dev,
2456 struct rte_flow *flow,
2457 const struct rte_flow_action *actions,
2459 struct rte_flow_error *error)
2461 const struct mlx5_flow_driver_ops *fops;
2462 enum mlx5_flow_drv_type ftype = flow->drv_type;
2464 assert(ftype > MLX5_FLOW_TYPE_MIN && ftype < MLX5_FLOW_TYPE_MAX);
2465 fops = flow_get_drv_ops(ftype);
2467 return fops->query(dev, flow, actions, data, error);
2473 * @see rte_flow_query()
2477 mlx5_flow_query(struct rte_eth_dev *dev,
2478 struct rte_flow *flow,
2479 const struct rte_flow_action *actions,
2481 struct rte_flow_error *error)
2485 ret = flow_drv_query(dev, flow, actions, data, error);
2492 * Convert a flow director filter to a generic flow.
2495 * Pointer to Ethernet device.
2496 * @param fdir_filter
2497 * Flow director filter to add.
2499 * Generic flow parameters structure.
2502 * 0 on success, a negative errno value otherwise and rte_errno is set.
2505 flow_fdir_filter_convert(struct rte_eth_dev *dev,
2506 const struct rte_eth_fdir_filter *fdir_filter,
2507 struct mlx5_fdir *attributes)
2509 struct mlx5_priv *priv = dev->data->dev_private;
2510 const struct rte_eth_fdir_input *input = &fdir_filter->input;
2511 const struct rte_eth_fdir_masks *mask =
2512 &dev->data->dev_conf.fdir_conf.mask;
2514 /* Validate queue number. */
2515 if (fdir_filter->action.rx_queue >= priv->rxqs_n) {
2516 DRV_LOG(ERR, "port %u invalid queue number %d",
2517 dev->data->port_id, fdir_filter->action.rx_queue);
2521 attributes->attr.ingress = 1;
2522 attributes->items[0] = (struct rte_flow_item) {
2523 .type = RTE_FLOW_ITEM_TYPE_ETH,
2524 .spec = &attributes->l2,
2525 .mask = &attributes->l2_mask,
2527 switch (fdir_filter->action.behavior) {
2528 case RTE_ETH_FDIR_ACCEPT:
2529 attributes->actions[0] = (struct rte_flow_action){
2530 .type = RTE_FLOW_ACTION_TYPE_QUEUE,
2531 .conf = &attributes->queue,
2534 case RTE_ETH_FDIR_REJECT:
2535 attributes->actions[0] = (struct rte_flow_action){
2536 .type = RTE_FLOW_ACTION_TYPE_DROP,
2540 DRV_LOG(ERR, "port %u invalid behavior %d",
2542 fdir_filter->action.behavior);
2543 rte_errno = ENOTSUP;
2546 attributes->queue.index = fdir_filter->action.rx_queue;
2548 switch (fdir_filter->input.flow_type) {
2549 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
2550 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
2551 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
2552 attributes->l3.ipv4.hdr = (struct rte_ipv4_hdr){
2553 .src_addr = input->flow.ip4_flow.src_ip,
2554 .dst_addr = input->flow.ip4_flow.dst_ip,
2555 .time_to_live = input->flow.ip4_flow.ttl,
2556 .type_of_service = input->flow.ip4_flow.tos,
2558 attributes->l3_mask.ipv4.hdr = (struct rte_ipv4_hdr){
2559 .src_addr = mask->ipv4_mask.src_ip,
2560 .dst_addr = mask->ipv4_mask.dst_ip,
2561 .time_to_live = mask->ipv4_mask.ttl,
2562 .type_of_service = mask->ipv4_mask.tos,
2563 .next_proto_id = mask->ipv4_mask.proto,
2565 attributes->items[1] = (struct rte_flow_item){
2566 .type = RTE_FLOW_ITEM_TYPE_IPV4,
2567 .spec = &attributes->l3,
2568 .mask = &attributes->l3_mask,
2571 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
2572 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
2573 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
2574 attributes->l3.ipv6.hdr = (struct rte_ipv6_hdr){
2575 .hop_limits = input->flow.ipv6_flow.hop_limits,
2576 .proto = input->flow.ipv6_flow.proto,
2579 memcpy(attributes->l3.ipv6.hdr.src_addr,
2580 input->flow.ipv6_flow.src_ip,
2581 RTE_DIM(attributes->l3.ipv6.hdr.src_addr));
2582 memcpy(attributes->l3.ipv6.hdr.dst_addr,
2583 input->flow.ipv6_flow.dst_ip,
2584 RTE_DIM(attributes->l3.ipv6.hdr.src_addr));
2585 memcpy(attributes->l3_mask.ipv6.hdr.src_addr,
2586 mask->ipv6_mask.src_ip,
2587 RTE_DIM(attributes->l3_mask.ipv6.hdr.src_addr));
2588 memcpy(attributes->l3_mask.ipv6.hdr.dst_addr,
2589 mask->ipv6_mask.dst_ip,
2590 RTE_DIM(attributes->l3_mask.ipv6.hdr.src_addr));
2591 attributes->items[1] = (struct rte_flow_item){
2592 .type = RTE_FLOW_ITEM_TYPE_IPV6,
2593 .spec = &attributes->l3,
2594 .mask = &attributes->l3_mask,
2598 DRV_LOG(ERR, "port %u invalid flow type%d",
2599 dev->data->port_id, fdir_filter->input.flow_type);
2600 rte_errno = ENOTSUP;
2604 switch (fdir_filter->input.flow_type) {
2605 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
2606 attributes->l4.udp.hdr = (struct rte_udp_hdr){
2607 .src_port = input->flow.udp4_flow.src_port,
2608 .dst_port = input->flow.udp4_flow.dst_port,
2610 attributes->l4_mask.udp.hdr = (struct rte_udp_hdr){
2611 .src_port = mask->src_port_mask,
2612 .dst_port = mask->dst_port_mask,
2614 attributes->items[2] = (struct rte_flow_item){
2615 .type = RTE_FLOW_ITEM_TYPE_UDP,
2616 .spec = &attributes->l4,
2617 .mask = &attributes->l4_mask,
2620 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
2621 attributes->l4.tcp.hdr = (struct rte_tcp_hdr){
2622 .src_port = input->flow.tcp4_flow.src_port,
2623 .dst_port = input->flow.tcp4_flow.dst_port,
2625 attributes->l4_mask.tcp.hdr = (struct rte_tcp_hdr){
2626 .src_port = mask->src_port_mask,
2627 .dst_port = mask->dst_port_mask,
2629 attributes->items[2] = (struct rte_flow_item){
2630 .type = RTE_FLOW_ITEM_TYPE_TCP,
2631 .spec = &attributes->l4,
2632 .mask = &attributes->l4_mask,
2635 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
2636 attributes->l4.udp.hdr = (struct rte_udp_hdr){
2637 .src_port = input->flow.udp6_flow.src_port,
2638 .dst_port = input->flow.udp6_flow.dst_port,
2640 attributes->l4_mask.udp.hdr = (struct rte_udp_hdr){
2641 .src_port = mask->src_port_mask,
2642 .dst_port = mask->dst_port_mask,
2644 attributes->items[2] = (struct rte_flow_item){
2645 .type = RTE_FLOW_ITEM_TYPE_UDP,
2646 .spec = &attributes->l4,
2647 .mask = &attributes->l4_mask,
2650 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
2651 attributes->l4.tcp.hdr = (struct rte_tcp_hdr){
2652 .src_port = input->flow.tcp6_flow.src_port,
2653 .dst_port = input->flow.tcp6_flow.dst_port,
2655 attributes->l4_mask.tcp.hdr = (struct rte_tcp_hdr){
2656 .src_port = mask->src_port_mask,
2657 .dst_port = mask->dst_port_mask,
2659 attributes->items[2] = (struct rte_flow_item){
2660 .type = RTE_FLOW_ITEM_TYPE_TCP,
2661 .spec = &attributes->l4,
2662 .mask = &attributes->l4_mask,
2665 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
2666 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
2669 DRV_LOG(ERR, "port %u invalid flow type%d",
2670 dev->data->port_id, fdir_filter->input.flow_type);
2671 rte_errno = ENOTSUP;
2677 #define FLOW_FDIR_CMP(f1, f2, fld) \
2678 memcmp(&(f1)->fld, &(f2)->fld, sizeof(f1->fld))
2681 * Compare two FDIR flows. If items and actions are identical, the two flows are
2685 * Pointer to Ethernet device.
2687 * FDIR flow to compare.
2689 * FDIR flow to compare.
2692 * Zero on match, 1 otherwise.
2695 flow_fdir_cmp(const struct mlx5_fdir *f1, const struct mlx5_fdir *f2)
2697 if (FLOW_FDIR_CMP(f1, f2, attr) ||
2698 FLOW_FDIR_CMP(f1, f2, l2) ||
2699 FLOW_FDIR_CMP(f1, f2, l2_mask) ||
2700 FLOW_FDIR_CMP(f1, f2, l3) ||
2701 FLOW_FDIR_CMP(f1, f2, l3_mask) ||
2702 FLOW_FDIR_CMP(f1, f2, l4) ||
2703 FLOW_FDIR_CMP(f1, f2, l4_mask) ||
2704 FLOW_FDIR_CMP(f1, f2, actions[0].type))
2706 if (f1->actions[0].type == RTE_FLOW_ACTION_TYPE_QUEUE &&
2707 FLOW_FDIR_CMP(f1, f2, queue))
2713 * Search device flow list to find out a matched FDIR flow.
2716 * Pointer to Ethernet device.
2718 * FDIR flow to lookup.
2721 * Pointer of flow if found, NULL otherwise.
2723 static struct rte_flow *
2724 flow_fdir_filter_lookup(struct rte_eth_dev *dev, struct mlx5_fdir *fdir_flow)
2726 struct mlx5_priv *priv = dev->data->dev_private;
2727 struct rte_flow *flow = NULL;
2730 TAILQ_FOREACH(flow, &priv->flows, next) {
2731 if (flow->fdir && !flow_fdir_cmp(flow->fdir, fdir_flow)) {
2732 DRV_LOG(DEBUG, "port %u found FDIR flow %p",
2733 dev->data->port_id, (void *)flow);
2741 * Add new flow director filter and store it in list.
2744 * Pointer to Ethernet device.
2745 * @param fdir_filter
2746 * Flow director filter to add.
2749 * 0 on success, a negative errno value otherwise and rte_errno is set.
2752 flow_fdir_filter_add(struct rte_eth_dev *dev,
2753 const struct rte_eth_fdir_filter *fdir_filter)
2755 struct mlx5_priv *priv = dev->data->dev_private;
2756 struct mlx5_fdir *fdir_flow;
2757 struct rte_flow *flow;
2760 fdir_flow = rte_zmalloc(__func__, sizeof(*fdir_flow), 0);
2765 ret = flow_fdir_filter_convert(dev, fdir_filter, fdir_flow);
2768 flow = flow_fdir_filter_lookup(dev, fdir_flow);
2773 flow = flow_list_create(dev, &priv->flows, &fdir_flow->attr,
2774 fdir_flow->items, fdir_flow->actions, NULL);
2777 assert(!flow->fdir);
2778 flow->fdir = fdir_flow;
2779 DRV_LOG(DEBUG, "port %u created FDIR flow %p",
2780 dev->data->port_id, (void *)flow);
2783 rte_free(fdir_flow);
2788 * Delete specific filter.
2791 * Pointer to Ethernet device.
2792 * @param fdir_filter
2793 * Filter to be deleted.
2796 * 0 on success, a negative errno value otherwise and rte_errno is set.
2799 flow_fdir_filter_delete(struct rte_eth_dev *dev,
2800 const struct rte_eth_fdir_filter *fdir_filter)
2802 struct mlx5_priv *priv = dev->data->dev_private;
2803 struct rte_flow *flow;
2804 struct mlx5_fdir fdir_flow = {
2809 ret = flow_fdir_filter_convert(dev, fdir_filter, &fdir_flow);
2812 flow = flow_fdir_filter_lookup(dev, &fdir_flow);
2817 flow_list_destroy(dev, &priv->flows, flow);
2818 DRV_LOG(DEBUG, "port %u deleted FDIR flow %p",
2819 dev->data->port_id, (void *)flow);
2824 * Update queue for specific filter.
2827 * Pointer to Ethernet device.
2828 * @param fdir_filter
2829 * Filter to be updated.
2832 * 0 on success, a negative errno value otherwise and rte_errno is set.
2835 flow_fdir_filter_update(struct rte_eth_dev *dev,
2836 const struct rte_eth_fdir_filter *fdir_filter)
2840 ret = flow_fdir_filter_delete(dev, fdir_filter);
2843 return flow_fdir_filter_add(dev, fdir_filter);
2847 * Flush all filters.
2850 * Pointer to Ethernet device.
2853 flow_fdir_filter_flush(struct rte_eth_dev *dev)
2855 struct mlx5_priv *priv = dev->data->dev_private;
2857 mlx5_flow_list_flush(dev, &priv->flows);
2861 * Get flow director information.
2864 * Pointer to Ethernet device.
2865 * @param[out] fdir_info
2866 * Resulting flow director information.
2869 flow_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir_info *fdir_info)
2871 struct rte_eth_fdir_masks *mask =
2872 &dev->data->dev_conf.fdir_conf.mask;
2874 fdir_info->mode = dev->data->dev_conf.fdir_conf.mode;
2875 fdir_info->guarant_spc = 0;
2876 rte_memcpy(&fdir_info->mask, mask, sizeof(fdir_info->mask));
2877 fdir_info->max_flexpayload = 0;
2878 fdir_info->flow_types_mask[0] = 0;
2879 fdir_info->flex_payload_unit = 0;
2880 fdir_info->max_flex_payload_segment_num = 0;
2881 fdir_info->flex_payload_limit = 0;
2882 memset(&fdir_info->flex_conf, 0, sizeof(fdir_info->flex_conf));
2886 * Deal with flow director operations.
2889 * Pointer to Ethernet device.
2891 * Operation to perform.
2893 * Pointer to operation-specific structure.
2896 * 0 on success, a negative errno value otherwise and rte_errno is set.
2899 flow_fdir_ctrl_func(struct rte_eth_dev *dev, enum rte_filter_op filter_op,
2902 enum rte_fdir_mode fdir_mode =
2903 dev->data->dev_conf.fdir_conf.mode;
2905 if (filter_op == RTE_ETH_FILTER_NOP)
2907 if (fdir_mode != RTE_FDIR_MODE_PERFECT &&
2908 fdir_mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
2909 DRV_LOG(ERR, "port %u flow director mode %d not supported",
2910 dev->data->port_id, fdir_mode);
2914 switch (filter_op) {
2915 case RTE_ETH_FILTER_ADD:
2916 return flow_fdir_filter_add(dev, arg);
2917 case RTE_ETH_FILTER_UPDATE:
2918 return flow_fdir_filter_update(dev, arg);
2919 case RTE_ETH_FILTER_DELETE:
2920 return flow_fdir_filter_delete(dev, arg);
2921 case RTE_ETH_FILTER_FLUSH:
2922 flow_fdir_filter_flush(dev);
2924 case RTE_ETH_FILTER_INFO:
2925 flow_fdir_info_get(dev, arg);
2928 DRV_LOG(DEBUG, "port %u unknown operation %u",
2929 dev->data->port_id, filter_op);
2937 * Manage filter operations.
2940 * Pointer to Ethernet device structure.
2941 * @param filter_type
2944 * Operation to perform.
2946 * Pointer to operation-specific structure.
2949 * 0 on success, a negative errno value otherwise and rte_errno is set.
2952 mlx5_dev_filter_ctrl(struct rte_eth_dev *dev,
2953 enum rte_filter_type filter_type,
2954 enum rte_filter_op filter_op,
2957 switch (filter_type) {
2958 case RTE_ETH_FILTER_GENERIC:
2959 if (filter_op != RTE_ETH_FILTER_GET) {
2963 *(const void **)arg = &mlx5_flow_ops;
2965 case RTE_ETH_FILTER_FDIR:
2966 return flow_fdir_ctrl_func(dev, filter_op, arg);
2968 DRV_LOG(ERR, "port %u filter type (%d) not supported",
2969 dev->data->port_id, filter_type);
2970 rte_errno = ENOTSUP;