From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 966FDA0C4D; Tue, 2 Nov 2021 04:20:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 386774113E; Tue, 2 Nov 2021 04:19:40 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 2F12F4068F for ; Tue, 2 Nov 2021 04:19:32 +0100 (CET) Received: from dggeme756-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Hjw4N5rtnzcb59; Tue, 2 Nov 2021 11:14:44 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.15; Tue, 2 Nov 2021 11:19:27 +0800 From: "Min Hu (Connor)" To: CC: , Date: Tue, 2 Nov 2021 11:17:26 +0800 Message-ID: <20211102031729.35536-7-humin29@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211102031729.35536-1-humin29@huawei.com> References: <20211102031729.35536-1-humin29@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggeme756-chm.china.huawei.com (10.3.19.102) X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 6/9] net/hns3: add hns3 flow header file X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 2f1ecffd5a..2f4beacb87 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 634018c847..a28c7c262b 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 @@ -1034,8 +1035,6 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr) uint32_t hns3_get_speed_capa(struct hns3_hw *hw); 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 d06f863249..7e60090fd3 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.33.0