1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
8 #include <rte_hash_crc.h>
9 #include "base/ice_fdir.h"
10 #include "base/ice_flow.h"
11 #include "base/ice_type.h"
12 #include "ice_ethdev.h"
14 #include "ice_generic_flow.h"
16 #define ICE_FDIR_IPV6_TC_OFFSET 20
17 #define ICE_IPV6_TC_MASK (0xFF << ICE_FDIR_IPV6_TC_OFFSET)
19 #define ICE_FDIR_MAX_QREGION_SIZE 128
21 #define ICE_FDIR_INSET_ETH_IPV4 (\
23 ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
24 ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
26 #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
27 ICE_FDIR_INSET_ETH_IPV4 | \
28 ICE_INSET_UDP_SRC_PORT | ICE_INSET_UDP_DST_PORT)
30 #define ICE_FDIR_INSET_ETH_IPV4_TCP (\
31 ICE_FDIR_INSET_ETH_IPV4 | \
32 ICE_INSET_TCP_SRC_PORT | ICE_INSET_TCP_DST_PORT)
34 #define ICE_FDIR_INSET_ETH_IPV4_SCTP (\
35 ICE_FDIR_INSET_ETH_IPV4 | \
36 ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
38 #define ICE_FDIR_INSET_ETH_IPV6 (\
40 ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
41 ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
43 #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
44 ICE_FDIR_INSET_ETH_IPV6 | \
45 ICE_INSET_UDP_SRC_PORT | ICE_INSET_UDP_DST_PORT)
47 #define ICE_FDIR_INSET_ETH_IPV6_TCP (\
48 ICE_FDIR_INSET_ETH_IPV6 | \
49 ICE_INSET_TCP_SRC_PORT | ICE_INSET_TCP_DST_PORT)
51 #define ICE_FDIR_INSET_ETH_IPV6_SCTP (\
52 ICE_FDIR_INSET_ETH_IPV6 | \
53 ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
55 #define ICE_FDIR_INSET_VXLAN_IPV4 (\
56 ICE_INSET_TUN_IPV4_SRC | ICE_INSET_TUN_IPV4_DST)
58 #define ICE_FDIR_INSET_VXLAN_IPV4_TCP (\
59 ICE_FDIR_INSET_VXLAN_IPV4 | \
60 ICE_INSET_TUN_TCP_SRC_PORT | ICE_INSET_TUN_TCP_DST_PORT)
62 #define ICE_FDIR_INSET_VXLAN_IPV4_UDP (\
63 ICE_FDIR_INSET_VXLAN_IPV4 | \
64 ICE_INSET_TUN_UDP_SRC_PORT | ICE_INSET_TUN_UDP_DST_PORT)
66 #define ICE_FDIR_INSET_VXLAN_IPV4_SCTP (\
67 ICE_FDIR_INSET_VXLAN_IPV4 | \
68 ICE_INSET_TUN_SCTP_SRC_PORT | ICE_INSET_TUN_SCTP_DST_PORT)
70 #define ICE_FDIR_INSET_GTPU (\
73 #define ICE_FDIR_INSET_GTPU_EH (\
74 ICE_INSET_GTPU_TEID | ICE_INSET_GTPU_QFI)
76 static struct ice_pattern_match_item ice_fdir_pattern_os[] = {
77 {pattern_eth_ipv4, ICE_FDIR_INSET_ETH_IPV4, ICE_INSET_NONE},
78 {pattern_eth_ipv4_udp, ICE_FDIR_INSET_ETH_IPV4_UDP, ICE_INSET_NONE},
79 {pattern_eth_ipv4_tcp, ICE_FDIR_INSET_ETH_IPV4_TCP, ICE_INSET_NONE},
80 {pattern_eth_ipv4_sctp, ICE_FDIR_INSET_ETH_IPV4_SCTP, ICE_INSET_NONE},
81 {pattern_eth_ipv6, ICE_FDIR_INSET_ETH_IPV6, ICE_INSET_NONE},
82 {pattern_eth_ipv6_udp, ICE_FDIR_INSET_ETH_IPV6_UDP, ICE_INSET_NONE},
83 {pattern_eth_ipv6_tcp, ICE_FDIR_INSET_ETH_IPV6_TCP, ICE_INSET_NONE},
84 {pattern_eth_ipv6_sctp, ICE_FDIR_INSET_ETH_IPV6_SCTP, ICE_INSET_NONE},
85 {pattern_eth_ipv4_udp_vxlan_ipv4,
86 ICE_FDIR_INSET_VXLAN_IPV4, ICE_INSET_NONE},
87 {pattern_eth_ipv4_udp_vxlan_ipv4_udp,
88 ICE_FDIR_INSET_VXLAN_IPV4_UDP, ICE_INSET_NONE},
89 {pattern_eth_ipv4_udp_vxlan_ipv4_tcp,
90 ICE_FDIR_INSET_VXLAN_IPV4_TCP, ICE_INSET_NONE},
91 {pattern_eth_ipv4_udp_vxlan_ipv4_sctp,
92 ICE_FDIR_INSET_VXLAN_IPV4_SCTP, ICE_INSET_NONE},
93 {pattern_eth_ipv4_udp_vxlan_eth_ipv4,
94 ICE_FDIR_INSET_VXLAN_IPV4, ICE_INSET_NONE},
95 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp,
96 ICE_FDIR_INSET_VXLAN_IPV4_UDP, ICE_INSET_NONE},
97 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp,
98 ICE_FDIR_INSET_VXLAN_IPV4_TCP, ICE_INSET_NONE},
99 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_sctp,
100 ICE_FDIR_INSET_VXLAN_IPV4_SCTP, ICE_INSET_NONE},
103 static struct ice_pattern_match_item ice_fdir_pattern_comms[] = {
104 {pattern_eth_ipv4, ICE_FDIR_INSET_ETH_IPV4, ICE_INSET_NONE},
105 {pattern_eth_ipv4_udp, ICE_FDIR_INSET_ETH_IPV4_UDP, ICE_INSET_NONE},
106 {pattern_eth_ipv4_tcp, ICE_FDIR_INSET_ETH_IPV4_TCP, ICE_INSET_NONE},
107 {pattern_eth_ipv4_sctp, ICE_FDIR_INSET_ETH_IPV4_SCTP, ICE_INSET_NONE},
108 {pattern_eth_ipv6, ICE_FDIR_INSET_ETH_IPV6, ICE_INSET_NONE},
109 {pattern_eth_ipv6_udp, ICE_FDIR_INSET_ETH_IPV6_UDP, ICE_INSET_NONE},
110 {pattern_eth_ipv6_tcp, ICE_FDIR_INSET_ETH_IPV6_TCP, ICE_INSET_NONE},
111 {pattern_eth_ipv6_sctp, ICE_FDIR_INSET_ETH_IPV6_SCTP, ICE_INSET_NONE},
112 {pattern_eth_ipv4_udp_vxlan_ipv4,
113 ICE_FDIR_INSET_VXLAN_IPV4, ICE_INSET_NONE},
114 {pattern_eth_ipv4_udp_vxlan_ipv4_udp,
115 ICE_FDIR_INSET_VXLAN_IPV4_UDP, ICE_INSET_NONE},
116 {pattern_eth_ipv4_udp_vxlan_ipv4_tcp,
117 ICE_FDIR_INSET_VXLAN_IPV4_TCP, ICE_INSET_NONE},
118 {pattern_eth_ipv4_udp_vxlan_ipv4_sctp,
119 ICE_FDIR_INSET_VXLAN_IPV4_SCTP, ICE_INSET_NONE},
120 {pattern_eth_ipv4_udp_vxlan_eth_ipv4,
121 ICE_FDIR_INSET_VXLAN_IPV4, ICE_INSET_NONE},
122 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp,
123 ICE_FDIR_INSET_VXLAN_IPV4_UDP, ICE_INSET_NONE},
124 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp,
125 ICE_FDIR_INSET_VXLAN_IPV4_TCP, ICE_INSET_NONE},
126 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_sctp,
127 ICE_FDIR_INSET_VXLAN_IPV4_SCTP, ICE_INSET_NONE},
128 {pattern_eth_ipv4_gtpu, ICE_FDIR_INSET_GTPU, ICE_INSET_NONE},
129 {pattern_eth_ipv4_gtpu_eh, ICE_FDIR_INSET_GTPU_EH, ICE_INSET_NONE},
132 static struct ice_flow_parser ice_fdir_parser_os;
133 static struct ice_flow_parser ice_fdir_parser_comms;
135 static const struct rte_memzone *
136 ice_memzone_reserve(const char *name, uint32_t len, int socket_id)
138 const struct rte_memzone *mz;
140 mz = rte_memzone_lookup(name);
144 return rte_memzone_reserve_aligned(name, len, socket_id,
145 RTE_MEMZONE_IOVA_CONTIG,
146 ICE_RING_BASE_ALIGN);
149 #define ICE_FDIR_MZ_NAME "FDIR_MEMZONE"
152 ice_fdir_prof_alloc(struct ice_hw *hw)
154 enum ice_fltr_ptype ptype, fltr_ptype;
156 if (!hw->fdir_prof) {
157 hw->fdir_prof = (struct ice_fd_hw_prof **)
158 ice_malloc(hw, ICE_FLTR_PTYPE_MAX *
159 sizeof(*hw->fdir_prof));
163 for (ptype = ICE_FLTR_PTYPE_NONF_NONE + 1;
164 ptype < ICE_FLTR_PTYPE_MAX;
166 if (!hw->fdir_prof[ptype]) {
167 hw->fdir_prof[ptype] = (struct ice_fd_hw_prof *)
168 ice_malloc(hw, sizeof(**hw->fdir_prof));
169 if (!hw->fdir_prof[ptype])
176 for (fltr_ptype = ICE_FLTR_PTYPE_NONF_NONE + 1;
179 rte_free(hw->fdir_prof[fltr_ptype]);
180 hw->fdir_prof[fltr_ptype] = NULL;
183 rte_free(hw->fdir_prof);
184 hw->fdir_prof = NULL;
190 ice_fdir_counter_pool_add(__rte_unused struct ice_pf *pf,
191 struct ice_fdir_counter_pool_container *container,
192 uint32_t index_start,
195 struct ice_fdir_counter_pool *pool;
199 pool = rte_zmalloc("ice_fdir_counter_pool",
201 sizeof(struct ice_fdir_counter) * len,
205 "Failed to allocate memory for fdir counter pool");
209 TAILQ_INIT(&pool->counter_list);
210 TAILQ_INSERT_TAIL(&container->pool_list, pool, next);
212 for (i = 0; i < len; i++) {
213 struct ice_fdir_counter *counter = &pool->counters[i];
215 counter->hw_index = index_start + i;
216 TAILQ_INSERT_TAIL(&pool->counter_list, counter, next);
219 if (container->index_free == ICE_FDIR_COUNTER_MAX_POOL_SIZE) {
220 PMD_INIT_LOG(ERR, "FDIR counter pool is full");
225 container->pools[container->index_free++] = pool;
234 ice_fdir_counter_init(struct ice_pf *pf)
236 struct ice_hw *hw = ICE_PF_TO_HW(pf);
237 struct ice_fdir_info *fdir_info = &pf->fdir;
238 struct ice_fdir_counter_pool_container *container =
240 uint32_t cnt_index, len;
243 TAILQ_INIT(&container->pool_list);
245 cnt_index = ICE_FDIR_COUNTER_INDEX(hw->fd_ctr_base);
246 len = ICE_FDIR_COUNTERS_PER_BLOCK;
248 ret = ice_fdir_counter_pool_add(pf, container, cnt_index, len);
250 PMD_INIT_LOG(ERR, "Failed to add fdir pool to container");
258 ice_fdir_counter_release(struct ice_pf *pf)
260 struct ice_fdir_info *fdir_info = &pf->fdir;
261 struct ice_fdir_counter_pool_container *container =
265 for (i = 0; i < container->index_free; i++) {
266 rte_free(container->pools[i]);
267 container->pools[i] = NULL;
270 TAILQ_INIT(&container->pool_list);
271 container->index_free = 0;
276 static struct ice_fdir_counter *
277 ice_fdir_counter_shared_search(struct ice_fdir_counter_pool_container
281 struct ice_fdir_counter_pool *pool;
282 struct ice_fdir_counter *counter;
285 TAILQ_FOREACH(pool, &container->pool_list, next) {
286 for (i = 0; i < ICE_FDIR_COUNTERS_PER_BLOCK; i++) {
287 counter = &pool->counters[i];
289 if (counter->shared &&
299 static struct ice_fdir_counter *
300 ice_fdir_counter_alloc(struct ice_pf *pf, uint32_t shared, uint32_t id)
302 struct ice_hw *hw = ICE_PF_TO_HW(pf);
303 struct ice_fdir_info *fdir_info = &pf->fdir;
304 struct ice_fdir_counter_pool_container *container =
306 struct ice_fdir_counter_pool *pool = NULL;
307 struct ice_fdir_counter *counter_free = NULL;
310 counter_free = ice_fdir_counter_shared_search(container, id);
312 if (counter_free->ref_cnt + 1 == 0) {
316 counter_free->ref_cnt++;
321 TAILQ_FOREACH(pool, &container->pool_list, next) {
322 counter_free = TAILQ_FIRST(&pool->counter_list);
329 PMD_DRV_LOG(ERR, "No free counter found\n");
333 counter_free->shared = shared;
334 counter_free->id = id;
335 counter_free->ref_cnt = 1;
336 counter_free->pool = pool;
338 /* reset statistic counter value */
339 ICE_WRITE_REG(hw, GLSTAT_FD_CNT0H(counter_free->hw_index), 0);
340 ICE_WRITE_REG(hw, GLSTAT_FD_CNT0L(counter_free->hw_index), 0);
342 TAILQ_REMOVE(&pool->counter_list, counter_free, next);
343 if (TAILQ_EMPTY(&pool->counter_list)) {
344 TAILQ_REMOVE(&container->pool_list, pool, next);
345 TAILQ_INSERT_TAIL(&container->pool_list, pool, next);
352 ice_fdir_counter_free(__rte_unused struct ice_pf *pf,
353 struct ice_fdir_counter *counter)
358 if (--counter->ref_cnt == 0) {
359 struct ice_fdir_counter_pool *pool = counter->pool;
361 TAILQ_INSERT_TAIL(&pool->counter_list, counter, next);
366 ice_fdir_init_filter_list(struct ice_pf *pf)
368 struct rte_eth_dev *dev = pf->adapter->eth_dev;
369 struct ice_fdir_info *fdir_info = &pf->fdir;
370 char fdir_hash_name[RTE_HASH_NAMESIZE];
373 struct rte_hash_parameters fdir_hash_params = {
374 .name = fdir_hash_name,
375 .entries = ICE_MAX_FDIR_FILTER_NUM,
376 .key_len = sizeof(struct ice_fdir_fltr_pattern),
377 .hash_func = rte_hash_crc,
378 .hash_func_init_val = 0,
379 .socket_id = rte_socket_id(),
380 .extra_flag = RTE_HASH_EXTRA_FLAGS_EXT_TABLE,
383 /* Initialize hash */
384 snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
385 "fdir_%s", dev->device->name);
386 fdir_info->hash_table = rte_hash_create(&fdir_hash_params);
387 if (!fdir_info->hash_table) {
388 PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
391 fdir_info->hash_map = rte_zmalloc("ice_fdir_hash_map",
392 sizeof(*fdir_info->hash_map) *
393 ICE_MAX_FDIR_FILTER_NUM,
395 if (!fdir_info->hash_map) {
397 "Failed to allocate memory for fdir hash map!");
399 goto err_fdir_hash_map_alloc;
403 err_fdir_hash_map_alloc:
404 rte_hash_free(fdir_info->hash_table);
410 ice_fdir_release_filter_list(struct ice_pf *pf)
412 struct ice_fdir_info *fdir_info = &pf->fdir;
414 if (fdir_info->hash_map)
415 rte_free(fdir_info->hash_map);
416 if (fdir_info->hash_table)
417 rte_hash_free(fdir_info->hash_table);
419 fdir_info->hash_map = NULL;
420 fdir_info->hash_table = NULL;
424 * ice_fdir_setup - reserve and initialize the Flow Director resources
425 * @pf: board private structure
428 ice_fdir_setup(struct ice_pf *pf)
430 struct rte_eth_dev *eth_dev = pf->adapter->eth_dev;
431 struct ice_hw *hw = ICE_PF_TO_HW(pf);
432 const struct rte_memzone *mz = NULL;
433 char z_name[RTE_MEMZONE_NAMESIZE];
435 int err = ICE_SUCCESS;
437 if ((pf->flags & ICE_FLAG_FDIR) == 0) {
438 PMD_INIT_LOG(ERR, "HW doesn't support FDIR");
442 PMD_DRV_LOG(INFO, "FDIR HW Capabilities: fd_fltr_guar = %u,"
443 " fd_fltr_best_effort = %u.",
444 hw->func_caps.fd_fltr_guar,
445 hw->func_caps.fd_fltr_best_effort);
447 if (pf->fdir.fdir_vsi) {
448 PMD_DRV_LOG(INFO, "FDIR initialization has been done.");
452 /* make new FDIR VSI */
453 vsi = ice_setup_vsi(pf, ICE_VSI_CTRL);
455 PMD_DRV_LOG(ERR, "Couldn't create FDIR VSI.");
458 pf->fdir.fdir_vsi = vsi;
460 err = ice_fdir_init_filter_list(pf);
462 PMD_DRV_LOG(ERR, "Failed to init FDIR filter list.");
466 err = ice_fdir_counter_init(pf);
468 PMD_DRV_LOG(ERR, "Failed to init FDIR counter.");
472 /*Fdir tx queue setup*/
473 err = ice_fdir_setup_tx_resources(pf);
475 PMD_DRV_LOG(ERR, "Failed to setup FDIR TX resources.");
479 /*Fdir rx queue setup*/
480 err = ice_fdir_setup_rx_resources(pf);
482 PMD_DRV_LOG(ERR, "Failed to setup FDIR RX resources.");
486 err = ice_fdir_tx_queue_start(eth_dev, pf->fdir.txq->queue_id);
488 PMD_DRV_LOG(ERR, "Failed to start FDIR TX queue.");
492 err = ice_fdir_rx_queue_start(eth_dev, pf->fdir.rxq->queue_id);
494 PMD_DRV_LOG(ERR, "Failed to start FDIR RX queue.");
498 /* Enable FDIR MSIX interrupt */
499 vsi->nb_used_qps = 1;
500 ice_vsi_queues_bind_intr(vsi);
501 ice_vsi_enable_queues_intr(vsi);
503 /* reserve memory for the fdir programming packet */
504 snprintf(z_name, sizeof(z_name), "ICE_%s_%d",
506 eth_dev->data->port_id);
507 mz = ice_memzone_reserve(z_name, ICE_FDIR_PKT_LEN, SOCKET_ID_ANY);
509 PMD_DRV_LOG(ERR, "Cannot init memzone for "
510 "flow director program packet.");
514 pf->fdir.prg_pkt = mz->addr;
515 pf->fdir.dma_addr = mz->iova;
518 err = ice_fdir_prof_alloc(hw);
520 PMD_DRV_LOG(ERR, "Cannot allocate memory for "
521 "flow director profile.");
526 PMD_DRV_LOG(INFO, "FDIR setup successfully, with programming queue %u.",
531 rte_memzone_free(pf->fdir.mz);
534 ice_rx_queue_release(pf->fdir.rxq);
537 ice_tx_queue_release(pf->fdir.txq);
540 ice_release_vsi(vsi);
541 pf->fdir.fdir_vsi = NULL;
546 ice_fdir_prof_free(struct ice_hw *hw)
548 enum ice_fltr_ptype ptype;
550 for (ptype = ICE_FLTR_PTYPE_NONF_NONE + 1;
551 ptype < ICE_FLTR_PTYPE_MAX;
553 rte_free(hw->fdir_prof[ptype]);
554 hw->fdir_prof[ptype] = NULL;
557 rte_free(hw->fdir_prof);
558 hw->fdir_prof = NULL;
561 /* Remove a profile for some filter type */
563 ice_fdir_prof_rm(struct ice_pf *pf, enum ice_fltr_ptype ptype, bool is_tunnel)
565 struct ice_hw *hw = ICE_PF_TO_HW(pf);
566 struct ice_fd_hw_prof *hw_prof;
571 if (!hw->fdir_prof || !hw->fdir_prof[ptype])
574 hw_prof = hw->fdir_prof[ptype];
576 prof_id = ptype + is_tunnel * ICE_FLTR_PTYPE_MAX;
577 for (i = 0; i < pf->hw_prof_cnt[ptype][is_tunnel]; i++) {
578 if (hw_prof->entry_h[i][is_tunnel]) {
579 vsi_num = ice_get_hw_vsi_num(hw,
581 ice_rem_prof_id_flow(hw, ICE_BLK_FD,
583 ice_flow_rem_entry(hw,
584 hw_prof->entry_h[i][is_tunnel]);
585 hw_prof->entry_h[i][is_tunnel] = 0;
588 ice_flow_rem_prof(hw, ICE_BLK_FD, prof_id);
589 rte_free(hw_prof->fdir_seg[is_tunnel]);
590 hw_prof->fdir_seg[is_tunnel] = NULL;
592 for (i = 0; i < hw_prof->cnt; i++)
593 hw_prof->vsi_h[i] = 0;
594 pf->hw_prof_cnt[ptype][is_tunnel] = 0;
597 /* Remove all created profiles */
599 ice_fdir_prof_rm_all(struct ice_pf *pf)
601 enum ice_fltr_ptype ptype;
603 for (ptype = ICE_FLTR_PTYPE_NONF_NONE + 1;
604 ptype < ICE_FLTR_PTYPE_MAX;
606 ice_fdir_prof_rm(pf, ptype, false);
607 ice_fdir_prof_rm(pf, ptype, true);
612 * ice_fdir_teardown - release the Flow Director resources
613 * @pf: board private structure
616 ice_fdir_teardown(struct ice_pf *pf)
618 struct rte_eth_dev *eth_dev = pf->adapter->eth_dev;
619 struct ice_hw *hw = ICE_PF_TO_HW(pf);
623 vsi = pf->fdir.fdir_vsi;
627 ice_vsi_disable_queues_intr(vsi);
629 err = ice_fdir_tx_queue_stop(eth_dev, pf->fdir.txq->queue_id);
631 PMD_DRV_LOG(ERR, "Failed to stop TX queue.");
633 err = ice_fdir_rx_queue_stop(eth_dev, pf->fdir.rxq->queue_id);
635 PMD_DRV_LOG(ERR, "Failed to stop RX queue.");
637 err = ice_fdir_counter_release(pf);
639 PMD_DRV_LOG(ERR, "Failed to release FDIR counter resource.");
641 ice_fdir_release_filter_list(pf);
643 ice_tx_queue_release(pf->fdir.txq);
645 ice_rx_queue_release(pf->fdir.rxq);
647 ice_fdir_prof_rm_all(pf);
648 ice_fdir_prof_free(hw);
649 ice_release_vsi(vsi);
650 pf->fdir.fdir_vsi = NULL;
653 err = rte_memzone_free(pf->fdir.mz);
656 PMD_DRV_LOG(ERR, "Failed to free FDIR memezone.");
661 ice_fdir_cur_prof_conflict(struct ice_pf *pf,
662 enum ice_fltr_ptype ptype,
663 struct ice_flow_seg_info *seg,
666 struct ice_hw *hw = ICE_PF_TO_HW(pf);
667 struct ice_flow_seg_info *ori_seg;
668 struct ice_fd_hw_prof *hw_prof;
670 hw_prof = hw->fdir_prof[ptype];
671 ori_seg = hw_prof->fdir_seg[is_tunnel];
673 /* profile does not exist */
677 /* if no input set conflict, return -EEXIST */
678 if ((!is_tunnel && !memcmp(ori_seg, seg, sizeof(*seg))) ||
679 (is_tunnel && !memcmp(&ori_seg[1], &seg[1], sizeof(*seg)))) {
680 PMD_DRV_LOG(DEBUG, "Profile already exists for flow type %d.",
685 /* a rule with input set conflict already exist, so give up */
686 if (pf->fdir_fltr_cnt[ptype][is_tunnel]) {
687 PMD_DRV_LOG(DEBUG, "Failed to create profile for flow type %d due to conflict with existing rule.",
692 /* it's safe to delete an empty profile */
693 ice_fdir_prof_rm(pf, ptype, is_tunnel);
698 ice_fdir_prof_resolve_conflict(struct ice_pf *pf,
699 enum ice_fltr_ptype ptype,
702 struct ice_hw *hw = ICE_PF_TO_HW(pf);
703 struct ice_fd_hw_prof *hw_prof;
704 struct ice_flow_seg_info *seg;
706 hw_prof = hw->fdir_prof[ptype];
707 seg = hw_prof->fdir_seg[is_tunnel];
709 /* profile does not exist */
713 /* profile exists and rule exists, fail to resolve the conflict */
714 if (pf->fdir_fltr_cnt[ptype][is_tunnel] != 0)
717 /* it's safe to delete an empty profile */
718 ice_fdir_prof_rm(pf, ptype, is_tunnel);
724 ice_fdir_cross_prof_conflict(struct ice_pf *pf,
725 enum ice_fltr_ptype ptype,
728 enum ice_fltr_ptype cflct_ptype;
732 case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
733 case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
734 case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
735 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
736 if (!ice_fdir_prof_resolve_conflict
737 (pf, cflct_ptype, is_tunnel))
740 case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
741 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
742 if (!ice_fdir_prof_resolve_conflict
743 (pf, cflct_ptype, is_tunnel))
745 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
746 if (!ice_fdir_prof_resolve_conflict
747 (pf, cflct_ptype, is_tunnel))
749 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_SCTP;
750 if (!ice_fdir_prof_resolve_conflict
751 (pf, cflct_ptype, is_tunnel))
755 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_UDP:
756 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_TCP:
757 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_ICMP:
758 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER;
759 if (!ice_fdir_prof_resolve_conflict
760 (pf, cflct_ptype, is_tunnel))
763 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER:
764 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER;
765 if (!ice_fdir_prof_resolve_conflict
766 (pf, cflct_ptype, is_tunnel))
768 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER;
769 if (!ice_fdir_prof_resolve_conflict
770 (pf, cflct_ptype, is_tunnel))
772 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER;
773 if (!ice_fdir_prof_resolve_conflict
774 (pf, cflct_ptype, is_tunnel))
778 case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
779 case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
780 case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
781 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
782 if (!ice_fdir_prof_resolve_conflict
783 (pf, cflct_ptype, is_tunnel))
786 case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
787 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV6_UDP;
788 if (!ice_fdir_prof_resolve_conflict
789 (pf, cflct_ptype, is_tunnel))
791 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV6_TCP;
792 if (!ice_fdir_prof_resolve_conflict
793 (pf, cflct_ptype, is_tunnel))
795 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV6_SCTP;
796 if (!ice_fdir_prof_resolve_conflict
797 (pf, cflct_ptype, is_tunnel))
805 PMD_DRV_LOG(DEBUG, "Failed to create profile for flow type %d due to conflict with existing rule of flow type %d.",
811 ice_fdir_hw_tbl_conf(struct ice_pf *pf, struct ice_vsi *vsi,
812 struct ice_vsi *ctrl_vsi,
813 struct ice_flow_seg_info *seg,
814 enum ice_fltr_ptype ptype,
817 struct ice_hw *hw = ICE_PF_TO_HW(pf);
818 enum ice_flow_dir dir = ICE_FLOW_RX;
819 struct ice_fd_hw_prof *hw_prof;
820 struct ice_flow_prof *prof;
821 uint64_t entry_1 = 0;
822 uint64_t entry_2 = 0;
827 /* check if have input set conflict on current profile. */
828 ret = ice_fdir_cur_prof_conflict(pf, ptype, seg, is_tunnel);
832 /* check if the profile is conflict with other profile. */
833 ret = ice_fdir_cross_prof_conflict(pf, ptype, is_tunnel);
837 prof_id = ptype + is_tunnel * ICE_FLTR_PTYPE_MAX;
838 ret = ice_flow_add_prof(hw, ICE_BLK_FD, dir, prof_id, seg,
839 (is_tunnel) ? 2 : 1, NULL, 0, &prof);
842 ret = ice_flow_add_entry(hw, ICE_BLK_FD, prof_id, vsi->idx,
843 vsi->idx, ICE_FLOW_PRIO_NORMAL,
844 seg, NULL, 0, &entry_1);
846 PMD_DRV_LOG(ERR, "Failed to add main VSI flow entry for %d.",
850 ret = ice_flow_add_entry(hw, ICE_BLK_FD, prof_id, vsi->idx,
851 ctrl_vsi->idx, ICE_FLOW_PRIO_NORMAL,
852 seg, NULL, 0, &entry_2);
854 PMD_DRV_LOG(ERR, "Failed to add control VSI flow entry for %d.",
859 hw_prof = hw->fdir_prof[ptype];
860 pf->hw_prof_cnt[ptype][is_tunnel] = 0;
862 hw_prof->fdir_seg[is_tunnel] = seg;
863 hw_prof->vsi_h[hw_prof->cnt] = vsi->idx;
864 hw_prof->entry_h[hw_prof->cnt++][is_tunnel] = entry_1;
865 pf->hw_prof_cnt[ptype][is_tunnel]++;
866 hw_prof->vsi_h[hw_prof->cnt] = ctrl_vsi->idx;
867 hw_prof->entry_h[hw_prof->cnt++][is_tunnel] = entry_2;
868 pf->hw_prof_cnt[ptype][is_tunnel]++;
873 vsi_num = ice_get_hw_vsi_num(hw, vsi->idx);
874 ice_rem_prof_id_flow(hw, ICE_BLK_FD, vsi_num, prof_id);
875 ice_flow_rem_entry(hw, entry_1);
877 ice_flow_rem_prof(hw, ICE_BLK_FD, prof_id);
883 ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
887 struct ice_inset_map {
889 enum ice_flow_field fld;
891 static const struct ice_inset_map ice_inset_map[] = {
892 {ICE_INSET_DMAC, ICE_FLOW_FIELD_IDX_ETH_DA},
893 {ICE_INSET_IPV4_SRC, ICE_FLOW_FIELD_IDX_IPV4_SA},
894 {ICE_INSET_IPV4_DST, ICE_FLOW_FIELD_IDX_IPV4_DA},
895 {ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
896 {ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
897 {ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
898 {ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
899 {ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
900 {ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
901 {ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
902 {ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
903 {ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
904 {ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
905 {ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
906 {ICE_INSET_UDP_DST_PORT, ICE_FLOW_FIELD_IDX_UDP_DST_PORT},
907 {ICE_INSET_SCTP_SRC_PORT, ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT},
908 {ICE_INSET_SCTP_DST_PORT, ICE_FLOW_FIELD_IDX_SCTP_DST_PORT},
909 {ICE_INSET_TUN_IPV4_SRC, ICE_FLOW_FIELD_IDX_IPV4_SA},
910 {ICE_INSET_TUN_IPV4_DST, ICE_FLOW_FIELD_IDX_IPV4_DA},
911 {ICE_INSET_TUN_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
912 {ICE_INSET_TUN_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
913 {ICE_INSET_TUN_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
914 {ICE_INSET_TUN_UDP_DST_PORT, ICE_FLOW_FIELD_IDX_UDP_DST_PORT},
915 {ICE_INSET_TUN_SCTP_SRC_PORT, ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT},
916 {ICE_INSET_TUN_SCTP_DST_PORT, ICE_FLOW_FIELD_IDX_SCTP_DST_PORT},
917 {ICE_INSET_GTPU_TEID, ICE_FLOW_FIELD_IDX_GTPU_EH_TEID},
918 {ICE_INSET_GTPU_QFI, ICE_FLOW_FIELD_IDX_GTPU_EH_QFI},
921 for (i = 0, j = 0; i < RTE_DIM(ice_inset_map); i++) {
922 if ((inset & ice_inset_map[i].inset) ==
923 ice_inset_map[i].inset)
924 field[j++] = ice_inset_map[i].fld;
929 ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
930 uint64_t input_set, bool is_tunnel)
932 struct ice_flow_seg_info *seg;
933 struct ice_flow_seg_info *seg_tun = NULL;
934 enum ice_flow_field field[ICE_FLOW_FIELD_IDX_MAX];
940 seg = (struct ice_flow_seg_info *)
941 ice_malloc(hw, sizeof(*seg));
943 PMD_DRV_LOG(ERR, "No memory can be allocated");
947 for (i = 0; i < ICE_FLOW_FIELD_IDX_MAX; i++)
948 field[i] = ICE_FLOW_FIELD_IDX_MAX;
949 ice_fdir_input_set_parse(input_set, field);
952 case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
953 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
954 ICE_FLOW_SEG_HDR_IPV4);
956 case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
957 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_TCP |
958 ICE_FLOW_SEG_HDR_IPV4);
960 case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
961 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_SCTP |
962 ICE_FLOW_SEG_HDR_IPV4);
964 case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
965 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4);
967 case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
968 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
969 ICE_FLOW_SEG_HDR_IPV6);
971 case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
972 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_TCP |
973 ICE_FLOW_SEG_HDR_IPV6);
975 case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
976 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_SCTP |
977 ICE_FLOW_SEG_HDR_IPV6);
979 case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
980 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6);
982 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_UDP:
983 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_TCP:
984 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_ICMP:
985 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER:
986 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_GTPU_EH |
987 ICE_FLOW_SEG_HDR_GTPU_IP |
988 ICE_FLOW_SEG_HDR_IPV4);
991 PMD_DRV_LOG(ERR, "not supported filter type.");
995 for (i = 0; field[i] != ICE_FLOW_FIELD_IDX_MAX; i++) {
996 ice_flow_set_fld(seg, field[i],
997 ICE_FLOW_FLD_OFF_INVAL,
998 ICE_FLOW_FLD_OFF_INVAL,
999 ICE_FLOW_FLD_OFF_INVAL, false);
1003 ret = ice_fdir_hw_tbl_conf(pf, pf->main_vsi, pf->fdir.fdir_vsi,
1006 seg_tun = (struct ice_flow_seg_info *)
1007 ice_malloc(hw, sizeof(*seg) * ICE_FD_HW_SEG_MAX);
1009 PMD_DRV_LOG(ERR, "No memory can be allocated");
1013 rte_memcpy(&seg_tun[1], seg, sizeof(*seg));
1014 ret = ice_fdir_hw_tbl_conf(pf, pf->main_vsi, pf->fdir.fdir_vsi,
1015 seg_tun, flow, true);
1020 } else if (ret < 0) {
1024 return (ret == -EEXIST) ? 0 : ret;
1031 ice_fdir_cnt_update(struct ice_pf *pf, enum ice_fltr_ptype ptype,
1032 bool is_tunnel, bool add)
1034 struct ice_hw *hw = ICE_PF_TO_HW(pf);
1037 cnt = (add) ? 1 : -1;
1038 hw->fdir_active_fltr += cnt;
1039 if (ptype == ICE_FLTR_PTYPE_NONF_NONE || ptype >= ICE_FLTR_PTYPE_MAX)
1040 PMD_DRV_LOG(ERR, "Unknown filter type %d", ptype);
1042 pf->fdir_fltr_cnt[ptype][is_tunnel] += cnt;
1046 ice_fdir_init(struct ice_adapter *ad)
1048 struct ice_pf *pf = &ad->pf;
1049 struct ice_flow_parser *parser;
1052 ret = ice_fdir_setup(pf);
1056 if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS)
1057 parser = &ice_fdir_parser_comms;
1058 else if (ad->active_pkg_type == ICE_PKG_TYPE_OS_DEFAULT)
1059 parser = &ice_fdir_parser_os;
1063 return ice_register_parser(parser, ad);
1067 ice_fdir_uninit(struct ice_adapter *ad)
1069 struct ice_pf *pf = &ad->pf;
1070 struct ice_flow_parser *parser;
1072 if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS)
1073 parser = &ice_fdir_parser_comms;
1075 parser = &ice_fdir_parser_os;
1077 ice_unregister_parser(parser, ad);
1079 ice_fdir_teardown(pf);
1083 ice_fdir_is_tunnel_profile(enum ice_fdir_tunnel_type tunnel_type)
1085 if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_VXLAN)
1092 ice_fdir_add_del_filter(struct ice_pf *pf,
1093 struct ice_fdir_filter_conf *filter,
1096 struct ice_fltr_desc desc;
1097 struct ice_hw *hw = ICE_PF_TO_HW(pf);
1098 unsigned char *pkt = (unsigned char *)pf->fdir.prg_pkt;
1102 filter->input.dest_vsi = pf->main_vsi->idx;
1104 memset(&desc, 0, sizeof(desc));
1105 ice_fdir_get_prgm_desc(hw, &filter->input, &desc, add);
1107 is_tun = ice_fdir_is_tunnel_profile(filter->tunnel_type);
1109 memset(pkt, 0, ICE_FDIR_PKT_LEN);
1110 ret = ice_fdir_get_gen_prgm_pkt(hw, &filter->input, pkt, false, is_tun);
1112 PMD_DRV_LOG(ERR, "Generate dummy packet failed");
1116 return ice_fdir_programming(pf, &desc);
1120 ice_fdir_extract_fltr_key(struct ice_fdir_fltr_pattern *key,
1121 struct ice_fdir_filter_conf *filter)
1123 struct ice_fdir_fltr *input = &filter->input;
1124 memset(key, 0, sizeof(*key));
1126 key->flow_type = input->flow_type;
1127 rte_memcpy(&key->ip, &input->ip, sizeof(key->ip));
1128 rte_memcpy(&key->mask, &input->mask, sizeof(key->mask));
1129 rte_memcpy(&key->ext_data, &input->ext_data, sizeof(key->ext_data));
1130 rte_memcpy(&key->ext_mask, &input->ext_mask, sizeof(key->ext_mask));
1132 rte_memcpy(&key->gtpu_data, &input->gtpu_data, sizeof(key->gtpu_data));
1133 rte_memcpy(&key->gtpu_mask, &input->gtpu_mask, sizeof(key->gtpu_mask));
1135 key->tunnel_type = filter->tunnel_type;
1138 /* Check if there exists the flow director filter */
1139 static struct ice_fdir_filter_conf *
1140 ice_fdir_entry_lookup(struct ice_fdir_info *fdir_info,
1141 const struct ice_fdir_fltr_pattern *key)
1145 ret = rte_hash_lookup(fdir_info->hash_table, key);
1149 return fdir_info->hash_map[ret];
1152 /* Add a flow director entry into the SW list */
1154 ice_fdir_entry_insert(struct ice_pf *pf,
1155 struct ice_fdir_filter_conf *entry,
1156 struct ice_fdir_fltr_pattern *key)
1158 struct ice_fdir_info *fdir_info = &pf->fdir;
1161 ret = rte_hash_add_key(fdir_info->hash_table, key);
1164 "Failed to insert fdir entry to hash table %d!",
1168 fdir_info->hash_map[ret] = entry;
1173 /* Delete a flow director entry from the SW list */
1175 ice_fdir_entry_del(struct ice_pf *pf, struct ice_fdir_fltr_pattern *key)
1177 struct ice_fdir_info *fdir_info = &pf->fdir;
1180 ret = rte_hash_del_key(fdir_info->hash_table, key);
1183 "Failed to delete fdir filter to hash table %d!",
1187 fdir_info->hash_map[ret] = NULL;
1193 ice_fdir_create_filter(struct ice_adapter *ad,
1194 struct rte_flow *flow,
1196 struct rte_flow_error *error)
1198 struct ice_pf *pf = &ad->pf;
1199 struct ice_fdir_filter_conf *filter = meta;
1200 struct ice_fdir_info *fdir_info = &pf->fdir;
1201 struct ice_fdir_filter_conf *entry, *node;
1202 struct ice_fdir_fltr_pattern key;
1206 ice_fdir_extract_fltr_key(&key, filter);
1207 node = ice_fdir_entry_lookup(fdir_info, &key);
1209 rte_flow_error_set(error, EEXIST,
1210 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1211 "Rule already exists!");
1215 entry = rte_zmalloc("fdir_entry", sizeof(*entry), 0);
1217 rte_flow_error_set(error, ENOMEM,
1218 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1219 "Failed to allocate memory");
1223 is_tun = ice_fdir_is_tunnel_profile(filter->tunnel_type);
1225 ret = ice_fdir_input_set_conf(pf, filter->input.flow_type,
1226 filter->input_set, is_tun);
1228 rte_flow_error_set(error, -ret,
1229 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1230 "Profile configure failed.");
1234 /* alloc counter for FDIR */
1235 if (filter->input.cnt_ena) {
1236 struct rte_flow_action_count *act_count = &filter->act_count;
1238 filter->counter = ice_fdir_counter_alloc(pf,
1241 if (!filter->counter) {
1242 rte_flow_error_set(error, EINVAL,
1243 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
1244 "Failed to alloc FDIR counter.");
1247 filter->input.cnt_index = filter->counter->hw_index;
1250 ret = ice_fdir_add_del_filter(pf, filter, true);
1252 rte_flow_error_set(error, -ret,
1253 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1254 "Add filter rule failed.");
1258 rte_memcpy(entry, filter, sizeof(*entry));
1259 ret = ice_fdir_entry_insert(pf, entry, &key);
1261 rte_flow_error_set(error, -ret,
1262 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1263 "Insert entry to table failed.");
1268 ice_fdir_cnt_update(pf, filter->input.flow_type, is_tun, true);
1273 if (filter->counter) {
1274 ice_fdir_counter_free(pf, filter->counter);
1275 filter->counter = NULL;
1284 ice_fdir_destroy_filter(struct ice_adapter *ad,
1285 struct rte_flow *flow,
1286 struct rte_flow_error *error)
1288 struct ice_pf *pf = &ad->pf;
1289 struct ice_fdir_info *fdir_info = &pf->fdir;
1290 struct ice_fdir_filter_conf *filter, *entry;
1291 struct ice_fdir_fltr_pattern key;
1295 filter = (struct ice_fdir_filter_conf *)flow->rule;
1297 is_tun = ice_fdir_is_tunnel_profile(filter->tunnel_type);
1299 if (filter->counter) {
1300 ice_fdir_counter_free(pf, filter->counter);
1301 filter->counter = NULL;
1304 ice_fdir_extract_fltr_key(&key, filter);
1305 entry = ice_fdir_entry_lookup(fdir_info, &key);
1307 rte_flow_error_set(error, ENOENT,
1308 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1309 "Can't find entry.");
1313 ret = ice_fdir_add_del_filter(pf, filter, false);
1315 rte_flow_error_set(error, -ret,
1316 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1317 "Del filter rule failed.");
1321 ret = ice_fdir_entry_del(pf, &key);
1323 rte_flow_error_set(error, -ret,
1324 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1325 "Remove entry from table failed.");
1329 ice_fdir_cnt_update(pf, filter->input.flow_type, is_tun, false);
1338 ice_fdir_query_count(struct ice_adapter *ad,
1339 struct rte_flow *flow,
1340 struct rte_flow_query_count *flow_stats,
1341 struct rte_flow_error *error)
1343 struct ice_pf *pf = &ad->pf;
1344 struct ice_hw *hw = ICE_PF_TO_HW(pf);
1345 struct ice_fdir_filter_conf *filter = flow->rule;
1346 struct ice_fdir_counter *counter = filter->counter;
1347 uint64_t hits_lo, hits_hi;
1350 rte_flow_error_set(error, EINVAL,
1351 RTE_FLOW_ERROR_TYPE_ACTION,
1353 "FDIR counters not available");
1358 * Reading the low 32-bits latches the high 32-bits into a shadow
1359 * register. Reading the high 32-bit returns the value in the
1362 hits_lo = ICE_READ_REG(hw, GLSTAT_FD_CNT0L(counter->hw_index));
1363 hits_hi = ICE_READ_REG(hw, GLSTAT_FD_CNT0H(counter->hw_index));
1365 flow_stats->hits_set = 1;
1366 flow_stats->hits = hits_lo | (hits_hi << 32);
1367 flow_stats->bytes_set = 0;
1368 flow_stats->bytes = 0;
1370 if (flow_stats->reset) {
1371 /* reset statistic counter value */
1372 ICE_WRITE_REG(hw, GLSTAT_FD_CNT0H(counter->hw_index), 0);
1373 ICE_WRITE_REG(hw, GLSTAT_FD_CNT0L(counter->hw_index), 0);
1379 static struct ice_flow_engine ice_fdir_engine = {
1380 .init = ice_fdir_init,
1381 .uninit = ice_fdir_uninit,
1382 .create = ice_fdir_create_filter,
1383 .destroy = ice_fdir_destroy_filter,
1384 .query_count = ice_fdir_query_count,
1385 .type = ICE_FLOW_ENGINE_FDIR,
1389 ice_fdir_parse_action_qregion(struct ice_pf *pf,
1390 struct rte_flow_error *error,
1391 const struct rte_flow_action *act,
1392 struct ice_fdir_filter_conf *filter)
1394 const struct rte_flow_action_rss *rss = act->conf;
1397 if (act->type != RTE_FLOW_ACTION_TYPE_RSS) {
1398 rte_flow_error_set(error, EINVAL,
1399 RTE_FLOW_ERROR_TYPE_ACTION, act,
1404 if (rss->queue_num <= 1) {
1405 rte_flow_error_set(error, EINVAL,
1406 RTE_FLOW_ERROR_TYPE_ACTION, act,
1407 "Queue region size can't be 0 or 1.");
1411 /* check if queue index for queue region is continuous */
1412 for (i = 0; i < rss->queue_num - 1; i++) {
1413 if (rss->queue[i + 1] != rss->queue[i] + 1) {
1414 rte_flow_error_set(error, EINVAL,
1415 RTE_FLOW_ERROR_TYPE_ACTION, act,
1416 "Discontinuous queue region");
1421 if (rss->queue[rss->queue_num - 1] >= pf->dev_data->nb_rx_queues) {
1422 rte_flow_error_set(error, EINVAL,
1423 RTE_FLOW_ERROR_TYPE_ACTION, act,
1424 "Invalid queue region indexes.");
1428 if (!(rte_is_power_of_2(rss->queue_num) &&
1429 (rss->queue_num <= ICE_FDIR_MAX_QREGION_SIZE))) {
1430 rte_flow_error_set(error, EINVAL,
1431 RTE_FLOW_ERROR_TYPE_ACTION, act,
1432 "The region size should be any of the following values:"
1433 "1, 2, 4, 8, 16, 32, 64, 128 as long as the total number "
1434 "of queues do not exceed the VSI allocation.");
1438 filter->input.q_index = rss->queue[0];
1439 filter->input.q_region = rte_fls_u32(rss->queue_num) - 1;
1440 filter->input.dest_ctl = ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP;
1446 ice_fdir_parse_action(struct ice_adapter *ad,
1447 const struct rte_flow_action actions[],
1448 struct rte_flow_error *error,
1449 struct ice_fdir_filter_conf *filter)
1451 struct ice_pf *pf = &ad->pf;
1452 const struct rte_flow_action_queue *act_q;
1453 const struct rte_flow_action_mark *mark_spec = NULL;
1454 const struct rte_flow_action_count *act_count;
1455 uint32_t dest_num = 0;
1456 uint32_t mark_num = 0;
1457 uint32_t counter_num = 0;
1460 for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
1461 switch (actions->type) {
1462 case RTE_FLOW_ACTION_TYPE_VOID:
1464 case RTE_FLOW_ACTION_TYPE_QUEUE:
1467 act_q = actions->conf;
1468 filter->input.q_index = act_q->index;
1469 if (filter->input.q_index >=
1470 pf->dev_data->nb_rx_queues) {
1471 rte_flow_error_set(error, EINVAL,
1472 RTE_FLOW_ERROR_TYPE_ACTION,
1474 "Invalid queue for FDIR.");
1477 filter->input.dest_ctl =
1478 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX;
1480 case RTE_FLOW_ACTION_TYPE_DROP:
1483 filter->input.dest_ctl =
1484 ICE_FLTR_PRGM_DESC_DEST_DROP_PKT;
1486 case RTE_FLOW_ACTION_TYPE_PASSTHRU:
1489 filter->input.dest_ctl =
1490 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX;
1491 filter->input.q_index = 0;
1493 case RTE_FLOW_ACTION_TYPE_RSS:
1496 ret = ice_fdir_parse_action_qregion(pf,
1497 error, actions, filter);
1501 case RTE_FLOW_ACTION_TYPE_MARK:
1504 mark_spec = actions->conf;
1505 filter->input.fltr_id = mark_spec->id;
1506 filter->input.fdid_prio = ICE_FXD_FLTR_QW1_FDID_PRI_ONE;
1508 case RTE_FLOW_ACTION_TYPE_COUNT:
1511 act_count = actions->conf;
1512 filter->input.cnt_ena = ICE_FXD_FLTR_QW0_STAT_ENA_PKTS;
1513 rte_memcpy(&filter->act_count, act_count,
1514 sizeof(filter->act_count));
1518 rte_flow_error_set(error, EINVAL,
1519 RTE_FLOW_ERROR_TYPE_ACTION, actions,
1525 if (dest_num == 0 || dest_num >= 2) {
1526 rte_flow_error_set(error, EINVAL,
1527 RTE_FLOW_ERROR_TYPE_ACTION, actions,
1528 "Unsupported action combination");
1532 if (mark_num >= 2) {
1533 rte_flow_error_set(error, EINVAL,
1534 RTE_FLOW_ERROR_TYPE_ACTION, actions,
1535 "Too many mark actions");
1539 if (counter_num >= 2) {
1540 rte_flow_error_set(error, EINVAL,
1541 RTE_FLOW_ERROR_TYPE_ACTION, actions,
1542 "Too many count actions");
1550 ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
1551 const struct rte_flow_item pattern[],
1552 struct rte_flow_error *error,
1553 struct ice_fdir_filter_conf *filter)
1555 const struct rte_flow_item *item = pattern;
1556 enum rte_flow_item_type item_type;
1557 enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
1558 enum ice_fdir_tunnel_type tunnel_type = ICE_FDIR_TUNNEL_TYPE_NONE;
1559 const struct rte_flow_item_eth *eth_spec, *eth_mask;
1560 const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
1561 const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
1562 const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
1563 const struct rte_flow_item_udp *udp_spec, *udp_mask;
1564 const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
1565 const struct rte_flow_item_vxlan *vxlan_spec, *vxlan_mask;
1566 const struct rte_flow_item_gtp *gtp_spec, *gtp_mask;
1567 const struct rte_flow_item_gtp_psc *gtp_psc_spec, *gtp_psc_mask;
1568 uint64_t input_set = ICE_INSET_NONE;
1569 uint8_t flow_type = ICE_FLTR_PTYPE_NONF_NONE;
1570 uint8_t ipv6_addr_mask[16] = {
1571 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
1572 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
1574 uint32_t vtc_flow_cpu;
1577 for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
1579 rte_flow_error_set(error, EINVAL,
1580 RTE_FLOW_ERROR_TYPE_ITEM,
1582 "Not support range");
1585 item_type = item->type;
1587 switch (item_type) {
1588 case RTE_FLOW_ITEM_TYPE_ETH:
1589 eth_spec = item->spec;
1590 eth_mask = item->mask;
1592 if (eth_spec && eth_mask) {
1593 if (!rte_is_zero_ether_addr(ð_spec->src) ||
1594 !rte_is_zero_ether_addr(ð_mask->src)) {
1595 rte_flow_error_set(error, EINVAL,
1596 RTE_FLOW_ERROR_TYPE_ITEM,
1598 "Src mac not support");
1602 if (!rte_is_broadcast_ether_addr(ð_mask->dst)) {
1603 rte_flow_error_set(error, EINVAL,
1604 RTE_FLOW_ERROR_TYPE_ITEM,
1606 "Invalid mac addr mask");
1610 input_set |= ICE_INSET_DMAC;
1611 rte_memcpy(&filter->input.ext_data.dst_mac,
1613 RTE_ETHER_ADDR_LEN);
1616 case RTE_FLOW_ITEM_TYPE_IPV4:
1617 l3 = RTE_FLOW_ITEM_TYPE_IPV4;
1618 ipv4_spec = item->spec;
1619 ipv4_mask = item->mask;
1621 if (ipv4_spec && ipv4_mask) {
1622 /* Check IPv4 mask and update input set */
1623 if (ipv4_mask->hdr.version_ihl ||
1624 ipv4_mask->hdr.total_length ||
1625 ipv4_mask->hdr.packet_id ||
1626 ipv4_mask->hdr.fragment_offset ||
1627 ipv4_mask->hdr.hdr_checksum) {
1628 rte_flow_error_set(error, EINVAL,
1629 RTE_FLOW_ERROR_TYPE_ITEM,
1631 "Invalid IPv4 mask.");
1634 if (ipv4_mask->hdr.src_addr == UINT32_MAX)
1635 input_set |= tunnel_type ?
1636 ICE_INSET_TUN_IPV4_SRC :
1638 if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
1639 input_set |= tunnel_type ?
1640 ICE_INSET_TUN_IPV4_DST :
1642 if (ipv4_mask->hdr.type_of_service == UINT8_MAX)
1643 input_set |= ICE_INSET_IPV4_TOS;
1644 if (ipv4_mask->hdr.time_to_live == UINT8_MAX)
1645 input_set |= ICE_INSET_IPV4_TTL;
1646 if (ipv4_mask->hdr.next_proto_id == UINT8_MAX)
1647 input_set |= ICE_INSET_IPV4_PROTO;
1649 filter->input.ip.v4.dst_ip =
1650 ipv4_spec->hdr.src_addr;
1651 filter->input.ip.v4.src_ip =
1652 ipv4_spec->hdr.dst_addr;
1653 filter->input.ip.v4.tos =
1654 ipv4_spec->hdr.type_of_service;
1655 filter->input.ip.v4.ttl =
1656 ipv4_spec->hdr.time_to_live;
1657 filter->input.ip.v4.proto =
1658 ipv4_spec->hdr.next_proto_id;
1661 flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
1663 case RTE_FLOW_ITEM_TYPE_IPV6:
1664 l3 = RTE_FLOW_ITEM_TYPE_IPV6;
1665 ipv6_spec = item->spec;
1666 ipv6_mask = item->mask;
1668 if (ipv6_spec && ipv6_mask) {
1669 /* Check IPv6 mask and update input set */
1670 if (ipv6_mask->hdr.payload_len) {
1671 rte_flow_error_set(error, EINVAL,
1672 RTE_FLOW_ERROR_TYPE_ITEM,
1674 "Invalid IPv6 mask");
1678 if (!memcmp(ipv6_mask->hdr.src_addr,
1680 RTE_DIM(ipv6_mask->hdr.src_addr)))
1681 input_set |= ICE_INSET_IPV6_SRC;
1682 if (!memcmp(ipv6_mask->hdr.dst_addr,
1684 RTE_DIM(ipv6_mask->hdr.dst_addr)))
1685 input_set |= ICE_INSET_IPV6_DST;
1687 if ((ipv6_mask->hdr.vtc_flow &
1688 rte_cpu_to_be_32(ICE_IPV6_TC_MASK))
1689 == rte_cpu_to_be_32(ICE_IPV6_TC_MASK))
1690 input_set |= ICE_INSET_IPV6_TC;
1691 if (ipv6_mask->hdr.proto == UINT8_MAX)
1692 input_set |= ICE_INSET_IPV6_NEXT_HDR;
1693 if (ipv6_mask->hdr.hop_limits == UINT8_MAX)
1694 input_set |= ICE_INSET_IPV6_HOP_LIMIT;
1696 rte_memcpy(filter->input.ip.v6.dst_ip,
1697 ipv6_spec->hdr.src_addr, 16);
1698 rte_memcpy(filter->input.ip.v6.src_ip,
1699 ipv6_spec->hdr.dst_addr, 16);
1702 rte_be_to_cpu_32(ipv6_spec->hdr.vtc_flow);
1703 filter->input.ip.v6.tc =
1704 (uint8_t)(vtc_flow_cpu >>
1705 ICE_FDIR_IPV6_TC_OFFSET);
1706 filter->input.ip.v6.proto =
1707 ipv6_spec->hdr.proto;
1708 filter->input.ip.v6.hlim =
1709 ipv6_spec->hdr.hop_limits;
1712 flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
1714 case RTE_FLOW_ITEM_TYPE_TCP:
1715 tcp_spec = item->spec;
1716 tcp_mask = item->mask;
1718 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
1719 flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
1720 else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
1721 flow_type = ICE_FLTR_PTYPE_NONF_IPV6_TCP;
1723 if (tcp_spec && tcp_mask) {
1724 /* Check TCP mask and update input set */
1725 if (tcp_mask->hdr.sent_seq ||
1726 tcp_mask->hdr.recv_ack ||
1727 tcp_mask->hdr.data_off ||
1728 tcp_mask->hdr.tcp_flags ||
1729 tcp_mask->hdr.rx_win ||
1730 tcp_mask->hdr.cksum ||
1731 tcp_mask->hdr.tcp_urp) {
1732 rte_flow_error_set(error, EINVAL,
1733 RTE_FLOW_ERROR_TYPE_ITEM,
1735 "Invalid TCP mask");
1739 if (tcp_mask->hdr.src_port == UINT16_MAX)
1740 input_set |= tunnel_type ?
1741 ICE_INSET_TUN_TCP_SRC_PORT :
1742 ICE_INSET_TCP_SRC_PORT;
1743 if (tcp_mask->hdr.dst_port == UINT16_MAX)
1744 input_set |= tunnel_type ?
1745 ICE_INSET_TUN_TCP_DST_PORT :
1746 ICE_INSET_TCP_DST_PORT;
1748 /* Get filter info */
1749 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
1750 filter->input.ip.v4.dst_port =
1751 tcp_spec->hdr.src_port;
1752 filter->input.ip.v4.src_port =
1753 tcp_spec->hdr.dst_port;
1754 } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
1755 filter->input.ip.v6.dst_port =
1756 tcp_spec->hdr.src_port;
1757 filter->input.ip.v6.src_port =
1758 tcp_spec->hdr.dst_port;
1762 case RTE_FLOW_ITEM_TYPE_UDP:
1763 udp_spec = item->spec;
1764 udp_mask = item->mask;
1766 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
1767 flow_type = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
1768 else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
1769 flow_type = ICE_FLTR_PTYPE_NONF_IPV6_UDP;
1771 if (udp_spec && udp_mask) {
1772 /* Check UDP mask and update input set*/
1773 if (udp_mask->hdr.dgram_len ||
1774 udp_mask->hdr.dgram_cksum) {
1775 rte_flow_error_set(error, EINVAL,
1776 RTE_FLOW_ERROR_TYPE_ITEM,
1778 "Invalid UDP mask");
1782 if (udp_mask->hdr.src_port == UINT16_MAX)
1783 input_set |= tunnel_type ?
1784 ICE_INSET_TUN_UDP_SRC_PORT :
1785 ICE_INSET_UDP_SRC_PORT;
1786 if (udp_mask->hdr.dst_port == UINT16_MAX)
1787 input_set |= tunnel_type ?
1788 ICE_INSET_TUN_UDP_DST_PORT :
1789 ICE_INSET_UDP_DST_PORT;
1791 /* Get filter info */
1792 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
1793 filter->input.ip.v4.dst_port =
1794 udp_spec->hdr.src_port;
1795 filter->input.ip.v4.src_port =
1796 udp_spec->hdr.dst_port;
1797 } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
1798 filter->input.ip.v6.src_port =
1799 udp_spec->hdr.dst_port;
1800 filter->input.ip.v6.dst_port =
1801 udp_spec->hdr.src_port;
1805 case RTE_FLOW_ITEM_TYPE_SCTP:
1806 sctp_spec = item->spec;
1807 sctp_mask = item->mask;
1809 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
1810 flow_type = ICE_FLTR_PTYPE_NONF_IPV4_SCTP;
1811 else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
1812 flow_type = ICE_FLTR_PTYPE_NONF_IPV6_SCTP;
1814 if (sctp_spec && sctp_mask) {
1815 /* Check SCTP mask and update input set */
1816 if (sctp_mask->hdr.cksum) {
1817 rte_flow_error_set(error, EINVAL,
1818 RTE_FLOW_ERROR_TYPE_ITEM,
1820 "Invalid UDP mask");
1824 if (sctp_mask->hdr.src_port == UINT16_MAX)
1825 input_set |= tunnel_type ?
1826 ICE_INSET_TUN_SCTP_SRC_PORT :
1827 ICE_INSET_SCTP_SRC_PORT;
1828 if (sctp_mask->hdr.dst_port == UINT16_MAX)
1829 input_set |= tunnel_type ?
1830 ICE_INSET_TUN_SCTP_DST_PORT :
1831 ICE_INSET_SCTP_DST_PORT;
1833 /* Get filter info */
1834 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
1835 filter->input.ip.v4.dst_port =
1836 sctp_spec->hdr.src_port;
1837 filter->input.ip.v4.src_port =
1838 sctp_spec->hdr.dst_port;
1839 } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
1840 filter->input.ip.v6.dst_port =
1841 sctp_spec->hdr.src_port;
1842 filter->input.ip.v6.src_port =
1843 sctp_spec->hdr.dst_port;
1847 case RTE_FLOW_ITEM_TYPE_VOID:
1849 case RTE_FLOW_ITEM_TYPE_VXLAN:
1850 l3 = RTE_FLOW_ITEM_TYPE_END;
1851 vxlan_spec = item->spec;
1852 vxlan_mask = item->mask;
1854 if (vxlan_spec || vxlan_mask) {
1855 rte_flow_error_set(error, EINVAL,
1856 RTE_FLOW_ERROR_TYPE_ITEM,
1858 "Invalid vxlan field");
1862 tunnel_type = ICE_FDIR_TUNNEL_TYPE_VXLAN;
1864 case RTE_FLOW_ITEM_TYPE_GTPU:
1865 l3 = RTE_FLOW_ITEM_TYPE_END;
1866 gtp_spec = item->spec;
1867 gtp_mask = item->mask;
1869 if (gtp_spec && gtp_mask) {
1870 if (gtp_mask->v_pt_rsv_flags ||
1871 gtp_mask->msg_type ||
1872 gtp_mask->msg_len) {
1873 rte_flow_error_set(error, EINVAL,
1874 RTE_FLOW_ERROR_TYPE_ITEM,
1876 "Invalid GTP mask");
1880 if (gtp_mask->teid == UINT32_MAX)
1881 input_set |= ICE_INSET_GTPU_TEID;
1883 filter->input.gtpu_data.teid = gtp_spec->teid;
1886 tunnel_type = ICE_FDIR_TUNNEL_TYPE_GTPU;
1888 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
1889 gtp_psc_spec = item->spec;
1890 gtp_psc_mask = item->mask;
1892 if (gtp_psc_spec && gtp_psc_mask) {
1893 if (gtp_psc_mask->qfi == UINT8_MAX)
1894 input_set |= ICE_INSET_GTPU_QFI;
1896 filter->input.gtpu_data.qfi =
1901 rte_flow_error_set(error, EINVAL,
1902 RTE_FLOW_ERROR_TYPE_ITEM,
1904 "Invalid pattern item.");
1909 if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_GTPU)
1910 flow_type = ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER;
1912 filter->tunnel_type = tunnel_type;
1913 filter->input.flow_type = flow_type;
1914 filter->input_set = input_set;
1920 ice_fdir_parse(struct ice_adapter *ad,
1921 struct ice_pattern_match_item *array,
1923 const struct rte_flow_item pattern[],
1924 const struct rte_flow_action actions[],
1926 struct rte_flow_error *error)
1928 struct ice_pf *pf = &ad->pf;
1929 struct ice_fdir_filter_conf *filter = &pf->fdir.conf;
1930 struct ice_pattern_match_item *item = NULL;
1934 memset(filter, 0, sizeof(*filter));
1935 item = ice_search_pattern_match_item(pattern, array, array_len, error);
1939 ret = ice_fdir_parse_pattern(ad, pattern, error, filter);
1942 input_set = filter->input_set;
1943 if (!input_set || input_set & ~item->input_set_mask) {
1944 rte_flow_error_set(error, EINVAL,
1945 RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
1947 "Invalid input set");
1952 ret = ice_fdir_parse_action(ad, actions, error, filter);
1962 static struct ice_flow_parser ice_fdir_parser_os = {
1963 .engine = &ice_fdir_engine,
1964 .array = ice_fdir_pattern_os,
1965 .array_len = RTE_DIM(ice_fdir_pattern_os),
1966 .parse_pattern_action = ice_fdir_parse,
1967 .stage = ICE_FLOW_STAGE_DISTRIBUTOR,
1970 static struct ice_flow_parser ice_fdir_parser_comms = {
1971 .engine = &ice_fdir_engine,
1972 .array = ice_fdir_pattern_comms,
1973 .array_len = RTE_DIM(ice_fdir_pattern_comms),
1974 .parse_pattern_action = ice_fdir_parse,
1975 .stage = ICE_FLOW_STAGE_DISTRIBUTOR,
1978 RTE_INIT(ice_fdir_engine_register)
1980 ice_register_flow_engine(&ice_fdir_engine);