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 (\
71 ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_GTPU_TEID)
73 #define ICE_FDIR_INSET_GTPU_EH (\
74 ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
75 ICE_INSET_GTPU_TEID | ICE_INSET_GTPU_QFI)
77 static struct ice_pattern_match_item ice_fdir_pattern_os[] = {
78 {pattern_eth_ipv4, ICE_FDIR_INSET_ETH_IPV4, ICE_INSET_NONE},
79 {pattern_eth_ipv4_udp, ICE_FDIR_INSET_ETH_IPV4_UDP, ICE_INSET_NONE},
80 {pattern_eth_ipv4_tcp, ICE_FDIR_INSET_ETH_IPV4_TCP, ICE_INSET_NONE},
81 {pattern_eth_ipv4_sctp, ICE_FDIR_INSET_ETH_IPV4_SCTP, ICE_INSET_NONE},
82 {pattern_eth_ipv6, ICE_FDIR_INSET_ETH_IPV6, ICE_INSET_NONE},
83 {pattern_eth_ipv6_udp, ICE_FDIR_INSET_ETH_IPV6_UDP, ICE_INSET_NONE},
84 {pattern_eth_ipv6_tcp, ICE_FDIR_INSET_ETH_IPV6_TCP, ICE_INSET_NONE},
85 {pattern_eth_ipv6_sctp, ICE_FDIR_INSET_ETH_IPV6_SCTP, ICE_INSET_NONE},
86 {pattern_eth_ipv4_udp_vxlan_ipv4,
87 ICE_FDIR_INSET_VXLAN_IPV4, ICE_INSET_NONE},
88 {pattern_eth_ipv4_udp_vxlan_ipv4_udp,
89 ICE_FDIR_INSET_VXLAN_IPV4_UDP, ICE_INSET_NONE},
90 {pattern_eth_ipv4_udp_vxlan_ipv4_tcp,
91 ICE_FDIR_INSET_VXLAN_IPV4_TCP, ICE_INSET_NONE},
92 {pattern_eth_ipv4_udp_vxlan_ipv4_sctp,
93 ICE_FDIR_INSET_VXLAN_IPV4_SCTP, ICE_INSET_NONE},
94 {pattern_eth_ipv4_udp_vxlan_eth_ipv4,
95 ICE_FDIR_INSET_VXLAN_IPV4, ICE_INSET_NONE},
96 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp,
97 ICE_FDIR_INSET_VXLAN_IPV4_UDP, ICE_INSET_NONE},
98 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp,
99 ICE_FDIR_INSET_VXLAN_IPV4_TCP, ICE_INSET_NONE},
100 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_sctp,
101 ICE_FDIR_INSET_VXLAN_IPV4_SCTP, ICE_INSET_NONE},
104 static struct ice_pattern_match_item ice_fdir_pattern_comms[] = {
105 {pattern_eth_ipv4, ICE_FDIR_INSET_ETH_IPV4, ICE_INSET_NONE},
106 {pattern_eth_ipv4_udp, ICE_FDIR_INSET_ETH_IPV4_UDP, ICE_INSET_NONE},
107 {pattern_eth_ipv4_tcp, ICE_FDIR_INSET_ETH_IPV4_TCP, ICE_INSET_NONE},
108 {pattern_eth_ipv4_sctp, ICE_FDIR_INSET_ETH_IPV4_SCTP, ICE_INSET_NONE},
109 {pattern_eth_ipv6, ICE_FDIR_INSET_ETH_IPV6, ICE_INSET_NONE},
110 {pattern_eth_ipv6_udp, ICE_FDIR_INSET_ETH_IPV6_UDP, ICE_INSET_NONE},
111 {pattern_eth_ipv6_tcp, ICE_FDIR_INSET_ETH_IPV6_TCP, ICE_INSET_NONE},
112 {pattern_eth_ipv6_sctp, ICE_FDIR_INSET_ETH_IPV6_SCTP, ICE_INSET_NONE},
113 {pattern_eth_ipv4_udp_vxlan_ipv4,
114 ICE_FDIR_INSET_VXLAN_IPV4, ICE_INSET_NONE},
115 {pattern_eth_ipv4_udp_vxlan_ipv4_udp,
116 ICE_FDIR_INSET_VXLAN_IPV4_UDP, ICE_INSET_NONE},
117 {pattern_eth_ipv4_udp_vxlan_ipv4_tcp,
118 ICE_FDIR_INSET_VXLAN_IPV4_TCP, ICE_INSET_NONE},
119 {pattern_eth_ipv4_udp_vxlan_ipv4_sctp,
120 ICE_FDIR_INSET_VXLAN_IPV4_SCTP, ICE_INSET_NONE},
121 {pattern_eth_ipv4_udp_vxlan_eth_ipv4,
122 ICE_FDIR_INSET_VXLAN_IPV4, ICE_INSET_NONE},
123 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp,
124 ICE_FDIR_INSET_VXLAN_IPV4_UDP, ICE_INSET_NONE},
125 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp,
126 ICE_FDIR_INSET_VXLAN_IPV4_TCP, ICE_INSET_NONE},
127 {pattern_eth_ipv4_udp_vxlan_eth_ipv4_sctp,
128 ICE_FDIR_INSET_VXLAN_IPV4_SCTP, ICE_INSET_NONE},
129 {pattern_eth_ipv4_gtpu, ICE_FDIR_INSET_GTPU, ICE_INSET_NONE},
130 {pattern_eth_ipv4_gtpu_eh, ICE_FDIR_INSET_GTPU_EH, ICE_INSET_NONE},
133 static struct ice_flow_parser ice_fdir_parser_os;
134 static struct ice_flow_parser ice_fdir_parser_comms;
137 ice_fdir_is_tunnel_profile(enum ice_fdir_tunnel_type tunnel_type);
139 static const struct rte_memzone *
140 ice_memzone_reserve(const char *name, uint32_t len, int socket_id)
142 const struct rte_memzone *mz;
144 mz = rte_memzone_lookup(name);
148 return rte_memzone_reserve_aligned(name, len, socket_id,
149 RTE_MEMZONE_IOVA_CONTIG,
150 ICE_RING_BASE_ALIGN);
153 #define ICE_FDIR_MZ_NAME "FDIR_MEMZONE"
156 ice_fdir_prof_alloc(struct ice_hw *hw)
158 enum ice_fltr_ptype ptype, fltr_ptype;
160 if (!hw->fdir_prof) {
161 hw->fdir_prof = (struct ice_fd_hw_prof **)
162 ice_malloc(hw, ICE_FLTR_PTYPE_MAX *
163 sizeof(*hw->fdir_prof));
167 for (ptype = ICE_FLTR_PTYPE_NONF_NONE + 1;
168 ptype < ICE_FLTR_PTYPE_MAX;
170 if (!hw->fdir_prof[ptype]) {
171 hw->fdir_prof[ptype] = (struct ice_fd_hw_prof *)
172 ice_malloc(hw, sizeof(**hw->fdir_prof));
173 if (!hw->fdir_prof[ptype])
180 for (fltr_ptype = ICE_FLTR_PTYPE_NONF_NONE + 1;
183 rte_free(hw->fdir_prof[fltr_ptype]);
184 hw->fdir_prof[fltr_ptype] = NULL;
187 rte_free(hw->fdir_prof);
188 hw->fdir_prof = NULL;
194 ice_fdir_counter_pool_add(__rte_unused struct ice_pf *pf,
195 struct ice_fdir_counter_pool_container *container,
196 uint32_t index_start,
199 struct ice_fdir_counter_pool *pool;
203 pool = rte_zmalloc("ice_fdir_counter_pool",
205 sizeof(struct ice_fdir_counter) * len,
209 "Failed to allocate memory for fdir counter pool");
213 TAILQ_INIT(&pool->counter_list);
214 TAILQ_INSERT_TAIL(&container->pool_list, pool, next);
216 for (i = 0; i < len; i++) {
217 struct ice_fdir_counter *counter = &pool->counters[i];
219 counter->hw_index = index_start + i;
220 TAILQ_INSERT_TAIL(&pool->counter_list, counter, next);
223 if (container->index_free == ICE_FDIR_COUNTER_MAX_POOL_SIZE) {
224 PMD_INIT_LOG(ERR, "FDIR counter pool is full");
229 container->pools[container->index_free++] = pool;
238 ice_fdir_counter_init(struct ice_pf *pf)
240 struct ice_hw *hw = ICE_PF_TO_HW(pf);
241 struct ice_fdir_info *fdir_info = &pf->fdir;
242 struct ice_fdir_counter_pool_container *container =
244 uint32_t cnt_index, len;
247 TAILQ_INIT(&container->pool_list);
249 cnt_index = ICE_FDIR_COUNTER_INDEX(hw->fd_ctr_base);
250 len = ICE_FDIR_COUNTERS_PER_BLOCK;
252 ret = ice_fdir_counter_pool_add(pf, container, cnt_index, len);
254 PMD_INIT_LOG(ERR, "Failed to add fdir pool to container");
262 ice_fdir_counter_release(struct ice_pf *pf)
264 struct ice_fdir_info *fdir_info = &pf->fdir;
265 struct ice_fdir_counter_pool_container *container =
269 for (i = 0; i < container->index_free; i++) {
270 rte_free(container->pools[i]);
271 container->pools[i] = NULL;
274 TAILQ_INIT(&container->pool_list);
275 container->index_free = 0;
280 static struct ice_fdir_counter *
281 ice_fdir_counter_shared_search(struct ice_fdir_counter_pool_container
285 struct ice_fdir_counter_pool *pool;
286 struct ice_fdir_counter *counter;
289 TAILQ_FOREACH(pool, &container->pool_list, next) {
290 for (i = 0; i < ICE_FDIR_COUNTERS_PER_BLOCK; i++) {
291 counter = &pool->counters[i];
293 if (counter->shared &&
303 static struct ice_fdir_counter *
304 ice_fdir_counter_alloc(struct ice_pf *pf, uint32_t shared, uint32_t id)
306 struct ice_hw *hw = ICE_PF_TO_HW(pf);
307 struct ice_fdir_info *fdir_info = &pf->fdir;
308 struct ice_fdir_counter_pool_container *container =
310 struct ice_fdir_counter_pool *pool = NULL;
311 struct ice_fdir_counter *counter_free = NULL;
314 counter_free = ice_fdir_counter_shared_search(container, id);
316 if (counter_free->ref_cnt + 1 == 0) {
320 counter_free->ref_cnt++;
325 TAILQ_FOREACH(pool, &container->pool_list, next) {
326 counter_free = TAILQ_FIRST(&pool->counter_list);
333 PMD_DRV_LOG(ERR, "No free counter found\n");
337 counter_free->shared = shared;
338 counter_free->id = id;
339 counter_free->ref_cnt = 1;
340 counter_free->pool = pool;
342 /* reset statistic counter value */
343 ICE_WRITE_REG(hw, GLSTAT_FD_CNT0H(counter_free->hw_index), 0);
344 ICE_WRITE_REG(hw, GLSTAT_FD_CNT0L(counter_free->hw_index), 0);
346 TAILQ_REMOVE(&pool->counter_list, counter_free, next);
347 if (TAILQ_EMPTY(&pool->counter_list)) {
348 TAILQ_REMOVE(&container->pool_list, pool, next);
349 TAILQ_INSERT_TAIL(&container->pool_list, pool, next);
356 ice_fdir_counter_free(__rte_unused struct ice_pf *pf,
357 struct ice_fdir_counter *counter)
362 if (--counter->ref_cnt == 0) {
363 struct ice_fdir_counter_pool *pool = counter->pool;
365 TAILQ_INSERT_TAIL(&pool->counter_list, counter, next);
370 ice_fdir_init_filter_list(struct ice_pf *pf)
372 struct rte_eth_dev *dev = pf->adapter->eth_dev;
373 struct ice_fdir_info *fdir_info = &pf->fdir;
374 char fdir_hash_name[RTE_HASH_NAMESIZE];
377 struct rte_hash_parameters fdir_hash_params = {
378 .name = fdir_hash_name,
379 .entries = ICE_MAX_FDIR_FILTER_NUM,
380 .key_len = sizeof(struct ice_fdir_fltr_pattern),
381 .hash_func = rte_hash_crc,
382 .hash_func_init_val = 0,
383 .socket_id = rte_socket_id(),
384 .extra_flag = RTE_HASH_EXTRA_FLAGS_EXT_TABLE,
387 /* Initialize hash */
388 snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
389 "fdir_%s", dev->device->name);
390 fdir_info->hash_table = rte_hash_create(&fdir_hash_params);
391 if (!fdir_info->hash_table) {
392 PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
395 fdir_info->hash_map = rte_zmalloc("ice_fdir_hash_map",
396 sizeof(*fdir_info->hash_map) *
397 ICE_MAX_FDIR_FILTER_NUM,
399 if (!fdir_info->hash_map) {
401 "Failed to allocate memory for fdir hash map!");
403 goto err_fdir_hash_map_alloc;
407 err_fdir_hash_map_alloc:
408 rte_hash_free(fdir_info->hash_table);
414 ice_fdir_release_filter_list(struct ice_pf *pf)
416 struct ice_fdir_info *fdir_info = &pf->fdir;
418 if (fdir_info->hash_map)
419 rte_free(fdir_info->hash_map);
420 if (fdir_info->hash_table)
421 rte_hash_free(fdir_info->hash_table);
423 fdir_info->hash_map = NULL;
424 fdir_info->hash_table = NULL;
428 * ice_fdir_setup - reserve and initialize the Flow Director resources
429 * @pf: board private structure
432 ice_fdir_setup(struct ice_pf *pf)
434 struct rte_eth_dev *eth_dev = pf->adapter->eth_dev;
435 struct ice_hw *hw = ICE_PF_TO_HW(pf);
436 const struct rte_memzone *mz = NULL;
437 char z_name[RTE_MEMZONE_NAMESIZE];
439 int err = ICE_SUCCESS;
441 if ((pf->flags & ICE_FLAG_FDIR) == 0) {
442 PMD_INIT_LOG(ERR, "HW doesn't support FDIR");
446 PMD_DRV_LOG(INFO, "FDIR HW Capabilities: fd_fltr_guar = %u,"
447 " fd_fltr_best_effort = %u.",
448 hw->func_caps.fd_fltr_guar,
449 hw->func_caps.fd_fltr_best_effort);
451 if (pf->fdir.fdir_vsi) {
452 PMD_DRV_LOG(INFO, "FDIR initialization has been done.");
456 /* make new FDIR VSI */
457 vsi = ice_setup_vsi(pf, ICE_VSI_CTRL);
459 PMD_DRV_LOG(ERR, "Couldn't create FDIR VSI.");
462 pf->fdir.fdir_vsi = vsi;
464 err = ice_fdir_init_filter_list(pf);
466 PMD_DRV_LOG(ERR, "Failed to init FDIR filter list.");
470 err = ice_fdir_counter_init(pf);
472 PMD_DRV_LOG(ERR, "Failed to init FDIR counter.");
476 /*Fdir tx queue setup*/
477 err = ice_fdir_setup_tx_resources(pf);
479 PMD_DRV_LOG(ERR, "Failed to setup FDIR TX resources.");
483 /*Fdir rx queue setup*/
484 err = ice_fdir_setup_rx_resources(pf);
486 PMD_DRV_LOG(ERR, "Failed to setup FDIR RX resources.");
490 err = ice_fdir_tx_queue_start(eth_dev, pf->fdir.txq->queue_id);
492 PMD_DRV_LOG(ERR, "Failed to start FDIR TX queue.");
496 err = ice_fdir_rx_queue_start(eth_dev, pf->fdir.rxq->queue_id);
498 PMD_DRV_LOG(ERR, "Failed to start FDIR RX queue.");
502 /* Enable FDIR MSIX interrupt */
503 vsi->nb_used_qps = 1;
504 ice_vsi_queues_bind_intr(vsi);
505 ice_vsi_enable_queues_intr(vsi);
507 /* reserve memory for the fdir programming packet */
508 snprintf(z_name, sizeof(z_name), "ICE_%s_%d",
510 eth_dev->data->port_id);
511 mz = ice_memzone_reserve(z_name, ICE_FDIR_PKT_LEN, SOCKET_ID_ANY);
513 PMD_DRV_LOG(ERR, "Cannot init memzone for "
514 "flow director program packet.");
518 pf->fdir.prg_pkt = mz->addr;
519 pf->fdir.dma_addr = mz->iova;
522 err = ice_fdir_prof_alloc(hw);
524 PMD_DRV_LOG(ERR, "Cannot allocate memory for "
525 "flow director profile.");
530 PMD_DRV_LOG(INFO, "FDIR setup successfully, with programming queue %u.",
535 rte_memzone_free(pf->fdir.mz);
538 ice_rx_queue_release(pf->fdir.rxq);
541 ice_tx_queue_release(pf->fdir.txq);
544 ice_release_vsi(vsi);
545 pf->fdir.fdir_vsi = NULL;
550 ice_fdir_prof_free(struct ice_hw *hw)
552 enum ice_fltr_ptype ptype;
554 for (ptype = ICE_FLTR_PTYPE_NONF_NONE + 1;
555 ptype < ICE_FLTR_PTYPE_MAX;
557 rte_free(hw->fdir_prof[ptype]);
558 hw->fdir_prof[ptype] = NULL;
561 rte_free(hw->fdir_prof);
562 hw->fdir_prof = NULL;
565 /* Remove a profile for some filter type */
567 ice_fdir_prof_rm(struct ice_pf *pf, enum ice_fltr_ptype ptype, bool is_tunnel)
569 struct ice_hw *hw = ICE_PF_TO_HW(pf);
570 struct ice_fd_hw_prof *hw_prof;
575 if (!hw->fdir_prof || !hw->fdir_prof[ptype])
578 hw_prof = hw->fdir_prof[ptype];
580 prof_id = ptype + is_tunnel * ICE_FLTR_PTYPE_MAX;
581 for (i = 0; i < pf->hw_prof_cnt[ptype][is_tunnel]; i++) {
582 if (hw_prof->entry_h[i][is_tunnel]) {
583 vsi_num = ice_get_hw_vsi_num(hw,
585 ice_rem_prof_id_flow(hw, ICE_BLK_FD,
587 ice_flow_rem_entry(hw, ICE_BLK_FD,
588 hw_prof->entry_h[i][is_tunnel]);
589 hw_prof->entry_h[i][is_tunnel] = 0;
592 ice_flow_rem_prof(hw, ICE_BLK_FD, prof_id);
593 rte_free(hw_prof->fdir_seg[is_tunnel]);
594 hw_prof->fdir_seg[is_tunnel] = NULL;
596 for (i = 0; i < hw_prof->cnt; i++)
597 hw_prof->vsi_h[i] = 0;
598 pf->hw_prof_cnt[ptype][is_tunnel] = 0;
601 /* Remove all created profiles */
603 ice_fdir_prof_rm_all(struct ice_pf *pf)
605 enum ice_fltr_ptype ptype;
607 for (ptype = ICE_FLTR_PTYPE_NONF_NONE + 1;
608 ptype < ICE_FLTR_PTYPE_MAX;
610 ice_fdir_prof_rm(pf, ptype, false);
611 ice_fdir_prof_rm(pf, ptype, true);
616 * ice_fdir_teardown - release the Flow Director resources
617 * @pf: board private structure
620 ice_fdir_teardown(struct ice_pf *pf)
622 struct rte_eth_dev *eth_dev = pf->adapter->eth_dev;
623 struct ice_hw *hw = ICE_PF_TO_HW(pf);
627 vsi = pf->fdir.fdir_vsi;
631 ice_vsi_disable_queues_intr(vsi);
633 err = ice_fdir_tx_queue_stop(eth_dev, pf->fdir.txq->queue_id);
635 PMD_DRV_LOG(ERR, "Failed to stop TX queue.");
637 err = ice_fdir_rx_queue_stop(eth_dev, pf->fdir.rxq->queue_id);
639 PMD_DRV_LOG(ERR, "Failed to stop RX queue.");
641 err = ice_fdir_counter_release(pf);
643 PMD_DRV_LOG(ERR, "Failed to release FDIR counter resource.");
645 ice_fdir_release_filter_list(pf);
647 ice_tx_queue_release(pf->fdir.txq);
649 ice_rx_queue_release(pf->fdir.rxq);
651 ice_fdir_prof_rm_all(pf);
652 ice_fdir_prof_free(hw);
653 ice_release_vsi(vsi);
654 pf->fdir.fdir_vsi = NULL;
657 err = rte_memzone_free(pf->fdir.mz);
660 PMD_DRV_LOG(ERR, "Failed to free FDIR memezone.");
665 ice_fdir_cur_prof_conflict(struct ice_pf *pf,
666 enum ice_fltr_ptype ptype,
667 struct ice_flow_seg_info *seg,
670 struct ice_hw *hw = ICE_PF_TO_HW(pf);
671 struct ice_flow_seg_info *ori_seg;
672 struct ice_fd_hw_prof *hw_prof;
674 hw_prof = hw->fdir_prof[ptype];
675 ori_seg = hw_prof->fdir_seg[is_tunnel];
677 /* profile does not exist */
681 /* if no input set conflict, return -EEXIST */
682 if ((!is_tunnel && !memcmp(ori_seg, seg, sizeof(*seg))) ||
683 (is_tunnel && !memcmp(&ori_seg[1], &seg[1], sizeof(*seg)))) {
684 PMD_DRV_LOG(DEBUG, "Profile already exists for flow type %d.",
689 /* a rule with input set conflict already exist, so give up */
690 if (pf->fdir_fltr_cnt[ptype][is_tunnel]) {
691 PMD_DRV_LOG(DEBUG, "Failed to create profile for flow type %d due to conflict with existing rule.",
696 /* it's safe to delete an empty profile */
697 ice_fdir_prof_rm(pf, ptype, is_tunnel);
702 ice_fdir_prof_resolve_conflict(struct ice_pf *pf,
703 enum ice_fltr_ptype ptype,
706 struct ice_hw *hw = ICE_PF_TO_HW(pf);
707 struct ice_fd_hw_prof *hw_prof;
708 struct ice_flow_seg_info *seg;
710 hw_prof = hw->fdir_prof[ptype];
711 seg = hw_prof->fdir_seg[is_tunnel];
713 /* profile does not exist */
717 /* profile exists and rule exists, fail to resolve the conflict */
718 if (pf->fdir_fltr_cnt[ptype][is_tunnel] != 0)
721 /* it's safe to delete an empty profile */
722 ice_fdir_prof_rm(pf, ptype, is_tunnel);
728 ice_fdir_cross_prof_conflict(struct ice_pf *pf,
729 enum ice_fltr_ptype ptype,
732 enum ice_fltr_ptype cflct_ptype;
736 case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
737 case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
738 case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
739 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
740 if (!ice_fdir_prof_resolve_conflict
741 (pf, cflct_ptype, is_tunnel))
744 case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
745 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
746 if (!ice_fdir_prof_resolve_conflict
747 (pf, cflct_ptype, is_tunnel))
749 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
750 if (!ice_fdir_prof_resolve_conflict
751 (pf, cflct_ptype, is_tunnel))
753 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_SCTP;
754 if (!ice_fdir_prof_resolve_conflict
755 (pf, cflct_ptype, is_tunnel))
759 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_UDP:
760 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_TCP:
761 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_ICMP:
762 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER;
763 if (!ice_fdir_prof_resolve_conflict
764 (pf, cflct_ptype, is_tunnel))
767 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER:
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))
776 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER;
777 if (!ice_fdir_prof_resolve_conflict
778 (pf, cflct_ptype, is_tunnel))
782 case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
783 case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
784 case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
785 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
786 if (!ice_fdir_prof_resolve_conflict
787 (pf, cflct_ptype, is_tunnel))
790 case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
791 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV6_UDP;
792 if (!ice_fdir_prof_resolve_conflict
793 (pf, cflct_ptype, is_tunnel))
795 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV6_TCP;
796 if (!ice_fdir_prof_resolve_conflict
797 (pf, cflct_ptype, is_tunnel))
799 cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV6_SCTP;
800 if (!ice_fdir_prof_resolve_conflict
801 (pf, cflct_ptype, is_tunnel))
809 PMD_DRV_LOG(DEBUG, "Failed to create profile for flow type %d due to conflict with existing rule of flow type %d.",
815 ice_fdir_hw_tbl_conf(struct ice_pf *pf, struct ice_vsi *vsi,
816 struct ice_vsi *ctrl_vsi,
817 struct ice_flow_seg_info *seg,
818 enum ice_fltr_ptype ptype,
821 struct ice_hw *hw = ICE_PF_TO_HW(pf);
822 enum ice_flow_dir dir = ICE_FLOW_RX;
823 struct ice_fd_hw_prof *hw_prof;
824 struct ice_flow_prof *prof;
825 uint64_t entry_1 = 0;
826 uint64_t entry_2 = 0;
831 /* check if have input set conflict on current profile. */
832 ret = ice_fdir_cur_prof_conflict(pf, ptype, seg, is_tunnel);
836 /* check if the profile is conflict with other profile. */
837 ret = ice_fdir_cross_prof_conflict(pf, ptype, is_tunnel);
841 prof_id = ptype + is_tunnel * ICE_FLTR_PTYPE_MAX;
842 ret = ice_flow_add_prof(hw, ICE_BLK_FD, dir, prof_id, seg,
843 (is_tunnel) ? 2 : 1, NULL, 0, &prof);
846 ret = ice_flow_add_entry(hw, ICE_BLK_FD, prof_id, vsi->idx,
847 vsi->idx, ICE_FLOW_PRIO_NORMAL,
848 seg, NULL, 0, &entry_1);
850 PMD_DRV_LOG(ERR, "Failed to add main VSI flow entry for %d.",
854 ret = ice_flow_add_entry(hw, ICE_BLK_FD, prof_id, vsi->idx,
855 ctrl_vsi->idx, ICE_FLOW_PRIO_NORMAL,
856 seg, NULL, 0, &entry_2);
858 PMD_DRV_LOG(ERR, "Failed to add control VSI flow entry for %d.",
863 hw_prof = hw->fdir_prof[ptype];
864 pf->hw_prof_cnt[ptype][is_tunnel] = 0;
866 hw_prof->fdir_seg[is_tunnel] = seg;
867 hw_prof->vsi_h[hw_prof->cnt] = vsi->idx;
868 hw_prof->entry_h[hw_prof->cnt++][is_tunnel] = entry_1;
869 pf->hw_prof_cnt[ptype][is_tunnel]++;
870 hw_prof->vsi_h[hw_prof->cnt] = ctrl_vsi->idx;
871 hw_prof->entry_h[hw_prof->cnt++][is_tunnel] = entry_2;
872 pf->hw_prof_cnt[ptype][is_tunnel]++;
877 vsi_num = ice_get_hw_vsi_num(hw, vsi->idx);
878 ice_rem_prof_id_flow(hw, ICE_BLK_FD, vsi_num, prof_id);
879 ice_flow_rem_entry(hw, ICE_BLK_FD, entry_1);
881 ice_flow_rem_prof(hw, ICE_BLK_FD, prof_id);
887 ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
891 struct ice_inset_map {
893 enum ice_flow_field fld;
895 static const struct ice_inset_map ice_inset_map[] = {
896 {ICE_INSET_DMAC, ICE_FLOW_FIELD_IDX_ETH_DA},
897 {ICE_INSET_IPV4_SRC, ICE_FLOW_FIELD_IDX_IPV4_SA},
898 {ICE_INSET_IPV4_DST, ICE_FLOW_FIELD_IDX_IPV4_DA},
899 {ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
900 {ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
901 {ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
902 {ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
903 {ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
904 {ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
905 {ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
906 {ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
907 {ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
908 {ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
909 {ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
910 {ICE_INSET_UDP_DST_PORT, ICE_FLOW_FIELD_IDX_UDP_DST_PORT},
911 {ICE_INSET_SCTP_SRC_PORT, ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT},
912 {ICE_INSET_SCTP_DST_PORT, ICE_FLOW_FIELD_IDX_SCTP_DST_PORT},
913 {ICE_INSET_TUN_IPV4_SRC, ICE_FLOW_FIELD_IDX_IPV4_SA},
914 {ICE_INSET_TUN_IPV4_DST, ICE_FLOW_FIELD_IDX_IPV4_DA},
915 {ICE_INSET_TUN_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
916 {ICE_INSET_TUN_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
917 {ICE_INSET_TUN_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
918 {ICE_INSET_TUN_UDP_DST_PORT, ICE_FLOW_FIELD_IDX_UDP_DST_PORT},
919 {ICE_INSET_TUN_SCTP_SRC_PORT, ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT},
920 {ICE_INSET_TUN_SCTP_DST_PORT, ICE_FLOW_FIELD_IDX_SCTP_DST_PORT},
921 {ICE_INSET_GTPU_TEID, ICE_FLOW_FIELD_IDX_GTPU_IP_TEID},
922 {ICE_INSET_GTPU_QFI, ICE_FLOW_FIELD_IDX_GTPU_EH_QFI},
925 for (i = 0, j = 0; i < RTE_DIM(ice_inset_map); i++) {
926 if ((inset & ice_inset_map[i].inset) ==
927 ice_inset_map[i].inset)
928 field[j++] = ice_inset_map[i].fld;
933 ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
934 uint64_t input_set, enum ice_fdir_tunnel_type ttype)
936 struct ice_flow_seg_info *seg;
937 struct ice_flow_seg_info *seg_tun = NULL;
938 enum ice_flow_field field[ICE_FLOW_FIELD_IDX_MAX];
945 seg = (struct ice_flow_seg_info *)
946 ice_malloc(hw, sizeof(*seg));
948 PMD_DRV_LOG(ERR, "No memory can be allocated");
952 for (i = 0; i < ICE_FLOW_FIELD_IDX_MAX; i++)
953 field[i] = ICE_FLOW_FIELD_IDX_MAX;
954 ice_fdir_input_set_parse(input_set, field);
957 case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
958 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
959 ICE_FLOW_SEG_HDR_IPV4);
961 case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
962 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_TCP |
963 ICE_FLOW_SEG_HDR_IPV4);
965 case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
966 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_SCTP |
967 ICE_FLOW_SEG_HDR_IPV4);
969 case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
970 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4);
972 case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
973 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
974 ICE_FLOW_SEG_HDR_IPV6);
976 case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
977 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_TCP |
978 ICE_FLOW_SEG_HDR_IPV6);
980 case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
981 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_SCTP |
982 ICE_FLOW_SEG_HDR_IPV6);
984 case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
985 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6);
987 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_UDP:
988 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_TCP:
989 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_ICMP:
990 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER:
991 if (ttype == ICE_FDIR_TUNNEL_TYPE_GTPU)
992 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_GTPU_IP |
993 ICE_FLOW_SEG_HDR_IPV4);
994 else if (ttype == ICE_FDIR_TUNNEL_TYPE_GTPU_EH)
995 ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_GTPU_EH |
996 ICE_FLOW_SEG_HDR_GTPU_IP |
997 ICE_FLOW_SEG_HDR_IPV4);
999 PMD_DRV_LOG(ERR, "not supported tunnel type.");
1002 PMD_DRV_LOG(ERR, "not supported filter type.");
1006 for (i = 0; field[i] != ICE_FLOW_FIELD_IDX_MAX; i++) {
1007 ice_flow_set_fld(seg, field[i],
1008 ICE_FLOW_FLD_OFF_INVAL,
1009 ICE_FLOW_FLD_OFF_INVAL,
1010 ICE_FLOW_FLD_OFF_INVAL, false);
1013 is_tunnel = ice_fdir_is_tunnel_profile(ttype);
1015 ret = ice_fdir_hw_tbl_conf(pf, pf->main_vsi, pf->fdir.fdir_vsi,
1018 seg_tun = (struct ice_flow_seg_info *)
1019 ice_malloc(hw, sizeof(*seg) * ICE_FD_HW_SEG_MAX);
1021 PMD_DRV_LOG(ERR, "No memory can be allocated");
1025 rte_memcpy(&seg_tun[1], seg, sizeof(*seg));
1026 ret = ice_fdir_hw_tbl_conf(pf, pf->main_vsi, pf->fdir.fdir_vsi,
1027 seg_tun, flow, true);
1032 } else if (ret < 0) {
1036 return (ret == -EEXIST) ? 0 : ret;
1043 ice_fdir_cnt_update(struct ice_pf *pf, enum ice_fltr_ptype ptype,
1044 bool is_tunnel, bool add)
1046 struct ice_hw *hw = ICE_PF_TO_HW(pf);
1049 cnt = (add) ? 1 : -1;
1050 hw->fdir_active_fltr += cnt;
1051 if (ptype == ICE_FLTR_PTYPE_NONF_NONE || ptype >= ICE_FLTR_PTYPE_MAX)
1052 PMD_DRV_LOG(ERR, "Unknown filter type %d", ptype);
1054 pf->fdir_fltr_cnt[ptype][is_tunnel] += cnt;
1058 ice_fdir_init(struct ice_adapter *ad)
1060 struct ice_pf *pf = &ad->pf;
1061 struct ice_flow_parser *parser;
1064 if (ad->hw.dcf_enabled)
1067 ret = ice_fdir_setup(pf);
1071 if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS)
1072 parser = &ice_fdir_parser_comms;
1073 else if (ad->active_pkg_type == ICE_PKG_TYPE_OS_DEFAULT)
1074 parser = &ice_fdir_parser_os;
1078 return ice_register_parser(parser, ad);
1082 ice_fdir_uninit(struct ice_adapter *ad)
1084 struct ice_pf *pf = &ad->pf;
1085 struct ice_flow_parser *parser;
1087 if (ad->hw.dcf_enabled)
1090 if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS)
1091 parser = &ice_fdir_parser_comms;
1093 parser = &ice_fdir_parser_os;
1095 ice_unregister_parser(parser, ad);
1097 ice_fdir_teardown(pf);
1101 ice_fdir_is_tunnel_profile(enum ice_fdir_tunnel_type tunnel_type)
1103 if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_VXLAN)
1110 ice_fdir_add_del_filter(struct ice_pf *pf,
1111 struct ice_fdir_filter_conf *filter,
1114 struct ice_fltr_desc desc;
1115 struct ice_hw *hw = ICE_PF_TO_HW(pf);
1116 unsigned char *pkt = (unsigned char *)pf->fdir.prg_pkt;
1120 filter->input.dest_vsi = pf->main_vsi->idx;
1122 memset(&desc, 0, sizeof(desc));
1123 filter->input.comp_report = ICE_FXD_FLTR_QW0_COMP_REPORT_SW;
1124 ice_fdir_get_prgm_desc(hw, &filter->input, &desc, add);
1126 is_tun = ice_fdir_is_tunnel_profile(filter->tunnel_type);
1128 memset(pkt, 0, ICE_FDIR_PKT_LEN);
1129 ret = ice_fdir_get_gen_prgm_pkt(hw, &filter->input, pkt, false, is_tun);
1131 PMD_DRV_LOG(ERR, "Generate dummy packet failed");
1135 return ice_fdir_programming(pf, &desc);
1139 ice_fdir_extract_fltr_key(struct ice_fdir_fltr_pattern *key,
1140 struct ice_fdir_filter_conf *filter)
1142 struct ice_fdir_fltr *input = &filter->input;
1143 memset(key, 0, sizeof(*key));
1145 key->flow_type = input->flow_type;
1146 rte_memcpy(&key->ip, &input->ip, sizeof(key->ip));
1147 rte_memcpy(&key->mask, &input->mask, sizeof(key->mask));
1148 rte_memcpy(&key->ext_data, &input->ext_data, sizeof(key->ext_data));
1149 rte_memcpy(&key->ext_mask, &input->ext_mask, sizeof(key->ext_mask));
1151 rte_memcpy(&key->gtpu_data, &input->gtpu_data, sizeof(key->gtpu_data));
1152 rte_memcpy(&key->gtpu_mask, &input->gtpu_mask, sizeof(key->gtpu_mask));
1154 key->tunnel_type = filter->tunnel_type;
1157 /* Check if there exists the flow director filter */
1158 static struct ice_fdir_filter_conf *
1159 ice_fdir_entry_lookup(struct ice_fdir_info *fdir_info,
1160 const struct ice_fdir_fltr_pattern *key)
1164 ret = rte_hash_lookup(fdir_info->hash_table, key);
1168 return fdir_info->hash_map[ret];
1171 /* Add a flow director entry into the SW list */
1173 ice_fdir_entry_insert(struct ice_pf *pf,
1174 struct ice_fdir_filter_conf *entry,
1175 struct ice_fdir_fltr_pattern *key)
1177 struct ice_fdir_info *fdir_info = &pf->fdir;
1180 ret = rte_hash_add_key(fdir_info->hash_table, key);
1183 "Failed to insert fdir entry to hash table %d!",
1187 fdir_info->hash_map[ret] = entry;
1192 /* Delete a flow director entry from the SW list */
1194 ice_fdir_entry_del(struct ice_pf *pf, struct ice_fdir_fltr_pattern *key)
1196 struct ice_fdir_info *fdir_info = &pf->fdir;
1199 ret = rte_hash_del_key(fdir_info->hash_table, key);
1202 "Failed to delete fdir filter to hash table %d!",
1206 fdir_info->hash_map[ret] = NULL;
1212 ice_fdir_create_filter(struct ice_adapter *ad,
1213 struct rte_flow *flow,
1215 struct rte_flow_error *error)
1217 struct ice_pf *pf = &ad->pf;
1218 struct ice_fdir_filter_conf *filter = meta;
1219 struct ice_fdir_info *fdir_info = &pf->fdir;
1220 struct ice_fdir_filter_conf *entry, *node;
1221 struct ice_fdir_fltr_pattern key;
1225 ice_fdir_extract_fltr_key(&key, filter);
1226 node = ice_fdir_entry_lookup(fdir_info, &key);
1228 rte_flow_error_set(error, EEXIST,
1229 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1230 "Rule already exists!");
1234 entry = rte_zmalloc("fdir_entry", sizeof(*entry), 0);
1236 rte_flow_error_set(error, ENOMEM,
1237 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1238 "Failed to allocate memory");
1242 is_tun = ice_fdir_is_tunnel_profile(filter->tunnel_type);
1244 ret = ice_fdir_input_set_conf(pf, filter->input.flow_type,
1245 filter->input_set, filter->tunnel_type);
1247 rte_flow_error_set(error, -ret,
1248 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1249 "Profile configure failed.");
1253 /* alloc counter for FDIR */
1254 if (filter->input.cnt_ena) {
1255 struct rte_flow_action_count *act_count = &filter->act_count;
1257 filter->counter = ice_fdir_counter_alloc(pf,
1260 if (!filter->counter) {
1261 rte_flow_error_set(error, EINVAL,
1262 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
1263 "Failed to alloc FDIR counter.");
1266 filter->input.cnt_index = filter->counter->hw_index;
1269 ret = ice_fdir_add_del_filter(pf, filter, true);
1271 rte_flow_error_set(error, -ret,
1272 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1273 "Add filter rule failed.");
1277 rte_memcpy(entry, filter, sizeof(*entry));
1278 ret = ice_fdir_entry_insert(pf, entry, &key);
1280 rte_flow_error_set(error, -ret,
1281 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1282 "Insert entry to table failed.");
1287 ice_fdir_cnt_update(pf, filter->input.flow_type, is_tun, true);
1292 if (filter->counter) {
1293 ice_fdir_counter_free(pf, filter->counter);
1294 filter->counter = NULL;
1303 ice_fdir_destroy_filter(struct ice_adapter *ad,
1304 struct rte_flow *flow,
1305 struct rte_flow_error *error)
1307 struct ice_pf *pf = &ad->pf;
1308 struct ice_fdir_info *fdir_info = &pf->fdir;
1309 struct ice_fdir_filter_conf *filter, *entry;
1310 struct ice_fdir_fltr_pattern key;
1314 filter = (struct ice_fdir_filter_conf *)flow->rule;
1316 is_tun = ice_fdir_is_tunnel_profile(filter->tunnel_type);
1318 if (filter->counter) {
1319 ice_fdir_counter_free(pf, filter->counter);
1320 filter->counter = NULL;
1323 ice_fdir_extract_fltr_key(&key, filter);
1324 entry = ice_fdir_entry_lookup(fdir_info, &key);
1326 rte_flow_error_set(error, ENOENT,
1327 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1328 "Can't find entry.");
1332 ret = ice_fdir_add_del_filter(pf, filter, false);
1334 rte_flow_error_set(error, -ret,
1335 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1336 "Del filter rule failed.");
1340 ret = ice_fdir_entry_del(pf, &key);
1342 rte_flow_error_set(error, -ret,
1343 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1344 "Remove entry from table failed.");
1348 ice_fdir_cnt_update(pf, filter->input.flow_type, is_tun, false);
1357 ice_fdir_query_count(struct ice_adapter *ad,
1358 struct rte_flow *flow,
1359 struct rte_flow_query_count *flow_stats,
1360 struct rte_flow_error *error)
1362 struct ice_pf *pf = &ad->pf;
1363 struct ice_hw *hw = ICE_PF_TO_HW(pf);
1364 struct ice_fdir_filter_conf *filter = flow->rule;
1365 struct ice_fdir_counter *counter = filter->counter;
1366 uint64_t hits_lo, hits_hi;
1369 rte_flow_error_set(error, EINVAL,
1370 RTE_FLOW_ERROR_TYPE_ACTION,
1372 "FDIR counters not available");
1377 * Reading the low 32-bits latches the high 32-bits into a shadow
1378 * register. Reading the high 32-bit returns the value in the
1381 hits_lo = ICE_READ_REG(hw, GLSTAT_FD_CNT0L(counter->hw_index));
1382 hits_hi = ICE_READ_REG(hw, GLSTAT_FD_CNT0H(counter->hw_index));
1384 flow_stats->hits_set = 1;
1385 flow_stats->hits = hits_lo | (hits_hi << 32);
1386 flow_stats->bytes_set = 0;
1387 flow_stats->bytes = 0;
1389 if (flow_stats->reset) {
1390 /* reset statistic counter value */
1391 ICE_WRITE_REG(hw, GLSTAT_FD_CNT0H(counter->hw_index), 0);
1392 ICE_WRITE_REG(hw, GLSTAT_FD_CNT0L(counter->hw_index), 0);
1398 static struct ice_flow_engine ice_fdir_engine = {
1399 .init = ice_fdir_init,
1400 .uninit = ice_fdir_uninit,
1401 .create = ice_fdir_create_filter,
1402 .destroy = ice_fdir_destroy_filter,
1403 .query_count = ice_fdir_query_count,
1404 .type = ICE_FLOW_ENGINE_FDIR,
1408 ice_fdir_parse_action_qregion(struct ice_pf *pf,
1409 struct rte_flow_error *error,
1410 const struct rte_flow_action *act,
1411 struct ice_fdir_filter_conf *filter)
1413 const struct rte_flow_action_rss *rss = act->conf;
1416 if (act->type != RTE_FLOW_ACTION_TYPE_RSS) {
1417 rte_flow_error_set(error, EINVAL,
1418 RTE_FLOW_ERROR_TYPE_ACTION, act,
1423 if (rss->queue_num <= 1) {
1424 rte_flow_error_set(error, EINVAL,
1425 RTE_FLOW_ERROR_TYPE_ACTION, act,
1426 "Queue region size can't be 0 or 1.");
1430 /* check if queue index for queue region is continuous */
1431 for (i = 0; i < rss->queue_num - 1; i++) {
1432 if (rss->queue[i + 1] != rss->queue[i] + 1) {
1433 rte_flow_error_set(error, EINVAL,
1434 RTE_FLOW_ERROR_TYPE_ACTION, act,
1435 "Discontinuous queue region");
1440 if (rss->queue[rss->queue_num - 1] >= pf->dev_data->nb_rx_queues) {
1441 rte_flow_error_set(error, EINVAL,
1442 RTE_FLOW_ERROR_TYPE_ACTION, act,
1443 "Invalid queue region indexes.");
1447 if (!(rte_is_power_of_2(rss->queue_num) &&
1448 (rss->queue_num <= ICE_FDIR_MAX_QREGION_SIZE))) {
1449 rte_flow_error_set(error, EINVAL,
1450 RTE_FLOW_ERROR_TYPE_ACTION, act,
1451 "The region size should be any of the following values:"
1452 "1, 2, 4, 8, 16, 32, 64, 128 as long as the total number "
1453 "of queues do not exceed the VSI allocation.");
1457 filter->input.q_index = rss->queue[0];
1458 filter->input.q_region = rte_fls_u32(rss->queue_num) - 1;
1459 filter->input.dest_ctl = ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP;
1465 ice_fdir_parse_action(struct ice_adapter *ad,
1466 const struct rte_flow_action actions[],
1467 struct rte_flow_error *error,
1468 struct ice_fdir_filter_conf *filter)
1470 struct ice_pf *pf = &ad->pf;
1471 const struct rte_flow_action_queue *act_q;
1472 const struct rte_flow_action_mark *mark_spec = NULL;
1473 const struct rte_flow_action_count *act_count;
1474 uint32_t dest_num = 0;
1475 uint32_t mark_num = 0;
1476 uint32_t counter_num = 0;
1479 for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
1480 switch (actions->type) {
1481 case RTE_FLOW_ACTION_TYPE_VOID:
1483 case RTE_FLOW_ACTION_TYPE_QUEUE:
1486 act_q = actions->conf;
1487 filter->input.q_index = act_q->index;
1488 if (filter->input.q_index >=
1489 pf->dev_data->nb_rx_queues) {
1490 rte_flow_error_set(error, EINVAL,
1491 RTE_FLOW_ERROR_TYPE_ACTION,
1493 "Invalid queue for FDIR.");
1496 filter->input.dest_ctl =
1497 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX;
1499 case RTE_FLOW_ACTION_TYPE_DROP:
1502 filter->input.dest_ctl =
1503 ICE_FLTR_PRGM_DESC_DEST_DROP_PKT;
1505 case RTE_FLOW_ACTION_TYPE_PASSTHRU:
1508 filter->input.dest_ctl =
1509 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER;
1511 case RTE_FLOW_ACTION_TYPE_RSS:
1514 ret = ice_fdir_parse_action_qregion(pf,
1515 error, actions, filter);
1519 case RTE_FLOW_ACTION_TYPE_MARK:
1522 mark_spec = actions->conf;
1523 filter->input.fltr_id = mark_spec->id;
1524 filter->input.fdid_prio = ICE_FXD_FLTR_QW1_FDID_PRI_ONE;
1526 case RTE_FLOW_ACTION_TYPE_COUNT:
1529 act_count = actions->conf;
1530 filter->input.cnt_ena = ICE_FXD_FLTR_QW0_STAT_ENA_PKTS;
1531 rte_memcpy(&filter->act_count, act_count,
1532 sizeof(filter->act_count));
1536 rte_flow_error_set(error, EINVAL,
1537 RTE_FLOW_ERROR_TYPE_ACTION, actions,
1543 if (dest_num >= 2) {
1544 rte_flow_error_set(error, EINVAL,
1545 RTE_FLOW_ERROR_TYPE_ACTION, actions,
1546 "Unsupported action combination");
1550 if (mark_num >= 2) {
1551 rte_flow_error_set(error, EINVAL,
1552 RTE_FLOW_ERROR_TYPE_ACTION, actions,
1553 "Too many mark actions");
1557 if (counter_num >= 2) {
1558 rte_flow_error_set(error, EINVAL,
1559 RTE_FLOW_ERROR_TYPE_ACTION, actions,
1560 "Too many count actions");
1564 if (dest_num + mark_num + counter_num == 0) {
1565 rte_flow_error_set(error, EINVAL,
1566 RTE_FLOW_ERROR_TYPE_ACTION, actions,
1571 /* set default action to PASSTHRU mode, in "mark/count only" case. */
1573 filter->input.dest_ctl =
1574 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER;
1580 ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
1581 const struct rte_flow_item pattern[],
1582 struct rte_flow_error *error,
1583 struct ice_fdir_filter_conf *filter)
1585 const struct rte_flow_item *item = pattern;
1586 enum rte_flow_item_type item_type;
1587 enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
1588 enum ice_fdir_tunnel_type tunnel_type = ICE_FDIR_TUNNEL_TYPE_NONE;
1589 const struct rte_flow_item_eth *eth_spec, *eth_mask;
1590 const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
1591 const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
1592 const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
1593 const struct rte_flow_item_udp *udp_spec, *udp_mask;
1594 const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
1595 const struct rte_flow_item_vxlan *vxlan_spec, *vxlan_mask;
1596 const struct rte_flow_item_gtp *gtp_spec, *gtp_mask;
1597 const struct rte_flow_item_gtp_psc *gtp_psc_spec, *gtp_psc_mask;
1598 uint64_t input_set = ICE_INSET_NONE;
1599 uint8_t flow_type = ICE_FLTR_PTYPE_NONF_NONE;
1600 uint8_t ipv6_addr_mask[16] = {
1601 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
1602 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
1604 uint32_t vtc_flow_cpu;
1607 for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
1609 rte_flow_error_set(error, EINVAL,
1610 RTE_FLOW_ERROR_TYPE_ITEM,
1612 "Not support range");
1615 item_type = item->type;
1617 switch (item_type) {
1618 case RTE_FLOW_ITEM_TYPE_ETH:
1619 eth_spec = item->spec;
1620 eth_mask = item->mask;
1622 if (eth_spec && eth_mask) {
1623 if (!rte_is_zero_ether_addr(ð_spec->src) ||
1624 !rte_is_zero_ether_addr(ð_mask->src)) {
1625 rte_flow_error_set(error, EINVAL,
1626 RTE_FLOW_ERROR_TYPE_ITEM,
1628 "Src mac not support");
1632 if (!rte_is_broadcast_ether_addr(ð_mask->dst)) {
1633 rte_flow_error_set(error, EINVAL,
1634 RTE_FLOW_ERROR_TYPE_ITEM,
1636 "Invalid mac addr mask");
1640 input_set |= ICE_INSET_DMAC;
1641 rte_memcpy(&filter->input.ext_data.dst_mac,
1643 RTE_ETHER_ADDR_LEN);
1646 case RTE_FLOW_ITEM_TYPE_IPV4:
1647 l3 = RTE_FLOW_ITEM_TYPE_IPV4;
1648 ipv4_spec = item->spec;
1649 ipv4_mask = item->mask;
1651 if (ipv4_spec && ipv4_mask) {
1652 /* Check IPv4 mask and update input set */
1653 if (ipv4_mask->hdr.version_ihl ||
1654 ipv4_mask->hdr.total_length ||
1655 ipv4_mask->hdr.packet_id ||
1656 ipv4_mask->hdr.fragment_offset ||
1657 ipv4_mask->hdr.hdr_checksum) {
1658 rte_flow_error_set(error, EINVAL,
1659 RTE_FLOW_ERROR_TYPE_ITEM,
1661 "Invalid IPv4 mask.");
1664 if (ipv4_mask->hdr.src_addr == UINT32_MAX)
1665 input_set |= tunnel_type ?
1666 ICE_INSET_TUN_IPV4_SRC :
1668 if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
1669 input_set |= tunnel_type ?
1670 ICE_INSET_TUN_IPV4_DST :
1672 if (ipv4_mask->hdr.type_of_service == UINT8_MAX)
1673 input_set |= ICE_INSET_IPV4_TOS;
1674 if (ipv4_mask->hdr.time_to_live == UINT8_MAX)
1675 input_set |= ICE_INSET_IPV4_TTL;
1676 if (ipv4_mask->hdr.next_proto_id == UINT8_MAX)
1677 input_set |= ICE_INSET_IPV4_PROTO;
1679 filter->input.ip.v4.dst_ip =
1680 ipv4_spec->hdr.dst_addr;
1681 filter->input.ip.v4.src_ip =
1682 ipv4_spec->hdr.src_addr;
1683 filter->input.ip.v4.tos =
1684 ipv4_spec->hdr.type_of_service;
1685 filter->input.ip.v4.ttl =
1686 ipv4_spec->hdr.time_to_live;
1687 filter->input.ip.v4.proto =
1688 ipv4_spec->hdr.next_proto_id;
1691 flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
1693 case RTE_FLOW_ITEM_TYPE_IPV6:
1694 l3 = RTE_FLOW_ITEM_TYPE_IPV6;
1695 ipv6_spec = item->spec;
1696 ipv6_mask = item->mask;
1698 if (ipv6_spec && ipv6_mask) {
1699 /* Check IPv6 mask and update input set */
1700 if (ipv6_mask->hdr.payload_len) {
1701 rte_flow_error_set(error, EINVAL,
1702 RTE_FLOW_ERROR_TYPE_ITEM,
1704 "Invalid IPv6 mask");
1708 if (!memcmp(ipv6_mask->hdr.src_addr,
1710 RTE_DIM(ipv6_mask->hdr.src_addr)))
1711 input_set |= ICE_INSET_IPV6_SRC;
1712 if (!memcmp(ipv6_mask->hdr.dst_addr,
1714 RTE_DIM(ipv6_mask->hdr.dst_addr)))
1715 input_set |= ICE_INSET_IPV6_DST;
1717 if ((ipv6_mask->hdr.vtc_flow &
1718 rte_cpu_to_be_32(ICE_IPV6_TC_MASK))
1719 == rte_cpu_to_be_32(ICE_IPV6_TC_MASK))
1720 input_set |= ICE_INSET_IPV6_TC;
1721 if (ipv6_mask->hdr.proto == UINT8_MAX)
1722 input_set |= ICE_INSET_IPV6_NEXT_HDR;
1723 if (ipv6_mask->hdr.hop_limits == UINT8_MAX)
1724 input_set |= ICE_INSET_IPV6_HOP_LIMIT;
1726 rte_memcpy(filter->input.ip.v6.dst_ip,
1727 ipv6_spec->hdr.dst_addr, 16);
1728 rte_memcpy(filter->input.ip.v6.src_ip,
1729 ipv6_spec->hdr.src_addr, 16);
1732 rte_be_to_cpu_32(ipv6_spec->hdr.vtc_flow);
1733 filter->input.ip.v6.tc =
1734 (uint8_t)(vtc_flow_cpu >>
1735 ICE_FDIR_IPV6_TC_OFFSET);
1736 filter->input.ip.v6.proto =
1737 ipv6_spec->hdr.proto;
1738 filter->input.ip.v6.hlim =
1739 ipv6_spec->hdr.hop_limits;
1742 flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
1744 case RTE_FLOW_ITEM_TYPE_TCP:
1745 tcp_spec = item->spec;
1746 tcp_mask = item->mask;
1748 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
1749 flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
1750 else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
1751 flow_type = ICE_FLTR_PTYPE_NONF_IPV6_TCP;
1753 if (tcp_spec && tcp_mask) {
1754 /* Check TCP mask and update input set */
1755 if (tcp_mask->hdr.sent_seq ||
1756 tcp_mask->hdr.recv_ack ||
1757 tcp_mask->hdr.data_off ||
1758 tcp_mask->hdr.tcp_flags ||
1759 tcp_mask->hdr.rx_win ||
1760 tcp_mask->hdr.cksum ||
1761 tcp_mask->hdr.tcp_urp) {
1762 rte_flow_error_set(error, EINVAL,
1763 RTE_FLOW_ERROR_TYPE_ITEM,
1765 "Invalid TCP mask");
1769 if (tcp_mask->hdr.src_port == UINT16_MAX)
1770 input_set |= tunnel_type ?
1771 ICE_INSET_TUN_TCP_SRC_PORT :
1772 ICE_INSET_TCP_SRC_PORT;
1773 if (tcp_mask->hdr.dst_port == UINT16_MAX)
1774 input_set |= tunnel_type ?
1775 ICE_INSET_TUN_TCP_DST_PORT :
1776 ICE_INSET_TCP_DST_PORT;
1778 /* Get filter info */
1779 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
1780 filter->input.ip.v4.dst_port =
1781 tcp_spec->hdr.dst_port;
1782 filter->input.ip.v4.src_port =
1783 tcp_spec->hdr.src_port;
1784 } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
1785 filter->input.ip.v6.dst_port =
1786 tcp_spec->hdr.dst_port;
1787 filter->input.ip.v6.src_port =
1788 tcp_spec->hdr.src_port;
1792 case RTE_FLOW_ITEM_TYPE_UDP:
1793 udp_spec = item->spec;
1794 udp_mask = item->mask;
1796 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
1797 flow_type = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
1798 else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
1799 flow_type = ICE_FLTR_PTYPE_NONF_IPV6_UDP;
1801 if (udp_spec && udp_mask) {
1802 /* Check UDP mask and update input set*/
1803 if (udp_mask->hdr.dgram_len ||
1804 udp_mask->hdr.dgram_cksum) {
1805 rte_flow_error_set(error, EINVAL,
1806 RTE_FLOW_ERROR_TYPE_ITEM,
1808 "Invalid UDP mask");
1812 if (udp_mask->hdr.src_port == UINT16_MAX)
1813 input_set |= tunnel_type ?
1814 ICE_INSET_TUN_UDP_SRC_PORT :
1815 ICE_INSET_UDP_SRC_PORT;
1816 if (udp_mask->hdr.dst_port == UINT16_MAX)
1817 input_set |= tunnel_type ?
1818 ICE_INSET_TUN_UDP_DST_PORT :
1819 ICE_INSET_UDP_DST_PORT;
1821 /* Get filter info */
1822 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
1823 filter->input.ip.v4.dst_port =
1824 udp_spec->hdr.dst_port;
1825 filter->input.ip.v4.src_port =
1826 udp_spec->hdr.src_port;
1827 } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
1828 filter->input.ip.v6.src_port =
1829 udp_spec->hdr.src_port;
1830 filter->input.ip.v6.dst_port =
1831 udp_spec->hdr.dst_port;
1835 case RTE_FLOW_ITEM_TYPE_SCTP:
1836 sctp_spec = item->spec;
1837 sctp_mask = item->mask;
1839 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
1840 flow_type = ICE_FLTR_PTYPE_NONF_IPV4_SCTP;
1841 else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
1842 flow_type = ICE_FLTR_PTYPE_NONF_IPV6_SCTP;
1844 if (sctp_spec && sctp_mask) {
1845 /* Check SCTP mask and update input set */
1846 if (sctp_mask->hdr.cksum) {
1847 rte_flow_error_set(error, EINVAL,
1848 RTE_FLOW_ERROR_TYPE_ITEM,
1850 "Invalid UDP mask");
1854 if (sctp_mask->hdr.src_port == UINT16_MAX)
1855 input_set |= tunnel_type ?
1856 ICE_INSET_TUN_SCTP_SRC_PORT :
1857 ICE_INSET_SCTP_SRC_PORT;
1858 if (sctp_mask->hdr.dst_port == UINT16_MAX)
1859 input_set |= tunnel_type ?
1860 ICE_INSET_TUN_SCTP_DST_PORT :
1861 ICE_INSET_SCTP_DST_PORT;
1863 /* Get filter info */
1864 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
1865 filter->input.ip.v4.dst_port =
1866 sctp_spec->hdr.dst_port;
1867 filter->input.ip.v4.src_port =
1868 sctp_spec->hdr.src_port;
1869 } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
1870 filter->input.ip.v6.dst_port =
1871 sctp_spec->hdr.dst_port;
1872 filter->input.ip.v6.src_port =
1873 sctp_spec->hdr.src_port;
1877 case RTE_FLOW_ITEM_TYPE_VOID:
1879 case RTE_FLOW_ITEM_TYPE_VXLAN:
1880 l3 = RTE_FLOW_ITEM_TYPE_END;
1881 vxlan_spec = item->spec;
1882 vxlan_mask = item->mask;
1884 if (vxlan_spec || vxlan_mask) {
1885 rte_flow_error_set(error, EINVAL,
1886 RTE_FLOW_ERROR_TYPE_ITEM,
1888 "Invalid vxlan field");
1892 tunnel_type = ICE_FDIR_TUNNEL_TYPE_VXLAN;
1894 case RTE_FLOW_ITEM_TYPE_GTPU:
1895 l3 = RTE_FLOW_ITEM_TYPE_END;
1896 gtp_spec = item->spec;
1897 gtp_mask = item->mask;
1899 if (gtp_spec && gtp_mask) {
1900 if (gtp_mask->v_pt_rsv_flags ||
1901 gtp_mask->msg_type ||
1902 gtp_mask->msg_len) {
1903 rte_flow_error_set(error, EINVAL,
1904 RTE_FLOW_ERROR_TYPE_ITEM,
1906 "Invalid GTP mask");
1910 if (gtp_mask->teid == UINT32_MAX)
1911 input_set |= ICE_INSET_GTPU_TEID;
1913 filter->input.gtpu_data.teid = gtp_spec->teid;
1916 tunnel_type = ICE_FDIR_TUNNEL_TYPE_GTPU;
1918 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
1919 gtp_psc_spec = item->spec;
1920 gtp_psc_mask = item->mask;
1922 if (gtp_psc_spec && gtp_psc_mask) {
1923 if (gtp_psc_mask->qfi == UINT8_MAX)
1924 input_set |= ICE_INSET_GTPU_QFI;
1926 filter->input.gtpu_data.qfi =
1929 tunnel_type = ICE_FDIR_TUNNEL_TYPE_GTPU_EH;
1932 rte_flow_error_set(error, EINVAL,
1933 RTE_FLOW_ERROR_TYPE_ITEM,
1935 "Invalid pattern item.");
1940 if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_GTPU ||
1941 tunnel_type == ICE_FDIR_TUNNEL_TYPE_GTPU_EH)
1942 flow_type = ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER;
1944 filter->tunnel_type = tunnel_type;
1945 filter->input.flow_type = flow_type;
1946 filter->input_set = input_set;
1952 ice_fdir_parse(struct ice_adapter *ad,
1953 struct ice_pattern_match_item *array,
1955 const struct rte_flow_item pattern[],
1956 const struct rte_flow_action actions[],
1958 struct rte_flow_error *error)
1960 struct ice_pf *pf = &ad->pf;
1961 struct ice_fdir_filter_conf *filter = &pf->fdir.conf;
1962 struct ice_pattern_match_item *item = NULL;
1966 memset(filter, 0, sizeof(*filter));
1967 item = ice_search_pattern_match_item(pattern, array, array_len, error);
1971 ret = ice_fdir_parse_pattern(ad, pattern, error, filter);
1974 input_set = filter->input_set;
1975 if (!input_set || input_set & ~item->input_set_mask) {
1976 rte_flow_error_set(error, EINVAL,
1977 RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
1979 "Invalid input set");
1984 ret = ice_fdir_parse_action(ad, actions, error, filter);
1995 static struct ice_flow_parser ice_fdir_parser_os = {
1996 .engine = &ice_fdir_engine,
1997 .array = ice_fdir_pattern_os,
1998 .array_len = RTE_DIM(ice_fdir_pattern_os),
1999 .parse_pattern_action = ice_fdir_parse,
2000 .stage = ICE_FLOW_STAGE_DISTRIBUTOR,
2003 static struct ice_flow_parser ice_fdir_parser_comms = {
2004 .engine = &ice_fdir_engine,
2005 .array = ice_fdir_pattern_comms,
2006 .array_len = RTE_DIM(ice_fdir_pattern_comms),
2007 .parse_pattern_action = ice_fdir_parse,
2008 .stage = ICE_FLOW_STAGE_DISTRIBUTOR,
2011 RTE_INIT(ice_fdir_engine_register)
2013 ice_register_flow_engine(&ice_fdir_engine);