From 3600ffc9de5e43238eb8bf1b3daa60da52307a89 Mon Sep 17 00:00:00 2001 From: "Min Hu (Connor)" Date: Sat, 6 Nov 2021 09:43:03 +0800 Subject: [PATCH] net/hns3: move declarations in flow header file This patch adds a hns3_flow.h to make the code easier to maintain. Signed-off-by: Huisong Li Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.c | 1 + drivers/net/hns3/hns3_ethdev.h | 3 +-- drivers/net/hns3/hns3_ethdev_vf.c | 1 + drivers/net/hns3/hns3_fdir.h | 31 ---------------------- drivers/net/hns3/hns3_flow.c | 1 + drivers/net/hns3/hns3_flow.h | 44 +++++++++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 drivers/net/hns3/hns3_flow.h diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 2ddd29515a..181694bf8c 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -15,6 +15,7 @@ #include "hns3_regs.h" #include "hns3_dcb.h" #include "hns3_mp.h" +#include "hns3_flow.h" #define HNS3_SERVICE_INTERVAL 1000000 /* us */ #define HNS3_SERVICE_QUICK_INTERVAL 10 diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 7438a8a2a8..67e506f6df 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -17,6 +17,7 @@ #include "hns3_fdir.h" #include "hns3_stats.h" #include "hns3_tm.h" +#include "hns3_flow.h" /* Vendor ID */ #define PCI_VENDOR_ID_HUAWEI 0x19e5 @@ -1032,8 +1033,6 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr) } int hns3_buffer_alloc(struct hns3_hw *hw); -int hns3_dev_flow_ops_get(struct rte_eth_dev *dev, - const struct rte_flow_ops **ops); bool hns3_is_reset_pending(struct hns3_adapter *hns); bool hns3vf_is_reset_pending(struct hns3_adapter *hns); void hns3_update_linkstatus_and_event(struct hns3_hw *hw, bool query); diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 1df8966cea..8632c8f19b 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -17,6 +17,7 @@ #include "hns3_intr.h" #include "hns3_dcb.h" #include "hns3_mp.h" +#include "hns3_flow.h" #define HNS3VF_KEEP_ALIVE_INTERVAL 2000000 /* us */ #define HNS3VF_SERVICE_INTERVAL 1000000 /* us */ diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h index 3f610f7b11..f9efff3b52 100644 --- a/drivers/net/hns3/hns3_fdir.h +++ b/drivers/net/hns3/hns3_fdir.h @@ -5,8 +5,6 @@ #ifndef _HNS3_FDIR_H_ #define _HNS3_FDIR_H_ -#include - struct hns3_fd_key_cfg { uint8_t key_sel; uint8_t inner_sipv6_word_en; @@ -124,14 +122,6 @@ struct hns3_fd_ad_data { uint16_t rule_id; }; -struct hns3_flow_counter { - LIST_ENTRY(hns3_flow_counter) next; /* Pointer to the next counter. */ - uint32_t shared:1; /* Share counter ID with other flow rules. */ - uint32_t ref_cnt:31; /* Reference counter. */ - uint16_t id; /* Counter ID. */ - uint64_t hits; /* Number of packets matched by the rule. */ -}; - #define HNS3_RULE_FLAG_FDID 0x1 #define HNS3_RULE_FLAG_VF_ID 0x2 #define HNS3_RULE_FLAG_COUNTER 0x4 @@ -173,21 +163,7 @@ struct hns3_fdir_rule_ele { struct hns3_fdir_rule fdir_conf; }; -/* rss filter list structure */ -struct hns3_rss_conf_ele { - TAILQ_ENTRY(hns3_rss_conf_ele) entries; - struct hns3_rss_conf filter_info; -}; - -/* hns3_flow memory list structure */ -struct hns3_flow_mem { - TAILQ_ENTRY(hns3_flow_mem) entries; - struct rte_flow *flow; -}; - TAILQ_HEAD(hns3_fdir_rule_list, hns3_fdir_rule_ele); -TAILQ_HEAD(hns3_rss_filter_list, hns3_rss_conf_ele); -TAILQ_HEAD(hns3_flow_mem_list, hns3_flow_mem); /* * A structure used to define fields of a FDIR related info. @@ -199,11 +175,6 @@ struct hns3_fdir_info { struct hns3_fd_cfg fd_cfg; }; -struct rte_flow { - enum rte_filter_type filter_type; - void *rule; - uint32_t counter_id; -}; struct hns3_adapter; int hns3_init_fd_config(struct hns3_adapter *hns); @@ -213,8 +184,6 @@ int hns3_fdir_filter_program(struct hns3_adapter *hns, struct hns3_fdir_rule *rule, bool del); int hns3_clear_all_fdir_filter(struct hns3_adapter *hns); int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value); -void hns3_flow_init(struct rte_eth_dev *dev); -void hns3_flow_uninit(struct rte_eth_dev *dev); int hns3_restore_all_fdir_filter(struct hns3_adapter *hns); #endif /* _HNS3_FDIR_H_ */ diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index da6918fddd..9f2f9cb6cd 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -8,6 +8,7 @@ #include "hns3_ethdev.h" #include "hns3_logs.h" +#include "hns3_flow.h" /* Default default keys */ static uint8_t hns3_hash_key[] = { diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h new file mode 100644 index 0000000000..2eb451b720 --- /dev/null +++ b/drivers/net/hns3/hns3_flow.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2021 HiSilicon Limited + */ + +#ifndef _HNS3_FLOW_H_ +#define _HNS3_FLOW_H_ + +#include + +struct hns3_flow_counter { + LIST_ENTRY(hns3_flow_counter) next; /* Pointer to the next counter. */ + uint32_t shared:1; /* Share counter ID with other flow rules. */ + uint32_t ref_cnt:31; /* Reference counter. */ + uint16_t id; /* Counter ID. */ + uint64_t hits; /* Number of packets matched by the rule. */ +}; + +struct rte_flow { + enum rte_filter_type filter_type; + void *rule; + uint32_t counter_id; +}; + +/* rss filter list structure */ +struct hns3_rss_conf_ele { + TAILQ_ENTRY(hns3_rss_conf_ele) entries; + struct hns3_rss_conf filter_info; +}; + +/* hns3_flow memory list structure */ +struct hns3_flow_mem { + TAILQ_ENTRY(hns3_flow_mem) entries; + struct rte_flow *flow; +}; + +TAILQ_HEAD(hns3_rss_filter_list, hns3_rss_conf_ele); +TAILQ_HEAD(hns3_flow_mem_list, hns3_flow_mem); + +int hns3_dev_flow_ops_get(struct rte_eth_dev *dev, + const struct rte_flow_ops **ops); +void hns3_flow_init(struct rte_eth_dev *dev); +void hns3_flow_uninit(struct rte_eth_dev *dev); + +#endif /* _HNS3_FLOW_H_ */ -- 2.20.1