1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(C) 2021 HiSilicon Limited 3 */ 4 5 #ifndef HNS3_FLOW_H 6 #define HNS3_FLOW_H 7 8 #include <rte_flow.h> 9 #include <ethdev_driver.h> 10 11 #include "hns3_rss.h" 12 #include "hns3_fdir.h" 13 14 struct hns3_flow_counter { 15 LIST_ENTRY(hns3_flow_counter) next; /* Pointer to the next counter. */ 16 uint32_t indirect:1; /* Indirect counter flag */ 17 uint32_t ref_cnt:31; /* Reference counter. */ 18 uint16_t id; /* Counter ID. */ 19 uint64_t hits; /* Number of packets matched by the rule. */ 20 }; 21 22 struct rte_flow { 23 enum rte_filter_type filter_type; 24 void *rule; 25 uint32_t counter_id; 26 }; 27 28 struct hns3_flow_rss_conf { 29 struct rte_flow_action_rss conf; 30 uint8_t key[HNS3_RSS_KEY_SIZE_MAX]; /* Hash key */ 31 uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ 32 uint64_t pattern_type; 33 uint64_t hw_pctypes; /* packet types in driver */ 34 }; 35 36 /* rss filter list structure */ 37 struct hns3_rss_conf_ele { 38 TAILQ_ENTRY(hns3_rss_conf_ele) entries; 39 struct hns3_flow_rss_conf filter_info; 40 }; 41 42 /* hns3_flow memory list structure */ 43 struct hns3_flow_mem { 44 TAILQ_ENTRY(hns3_flow_mem) entries; 45 struct rte_flow *flow; 46 }; 47 48 enum { 49 HNS3_INDIRECT_ACTION_TYPE_COUNT = 1, 50 }; 51 52 struct rte_flow_action_handle { 53 int indirect_type; 54 uint32_t counter_id; 55 }; 56 57 union hns3_filter_conf { 58 struct hns3_fdir_rule fdir_conf; 59 struct hns3_flow_rss_conf rss_conf; 60 }; 61 62 struct hns3_filter_info { 63 enum rte_filter_type type; 64 union hns3_filter_conf conf; 65 }; 66 67 TAILQ_HEAD(hns3_rss_filter_list, hns3_rss_conf_ele); 68 TAILQ_HEAD(hns3_flow_mem_list, hns3_flow_mem); 69 70 int hns3_dev_flow_ops_get(struct rte_eth_dev *dev, 71 const struct rte_flow_ops **ops); 72 void hns3_flow_init(struct rte_eth_dev *dev); 73 void hns3_flow_uninit(struct rte_eth_dev *dev); 74 int hns3_restore_filter(struct hns3_adapter *hns); 75 76 #endif /* HNS3_FLOW_H */ 77