From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 35C83A09F6; Fri, 18 Dec 2020 10:34:42 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3E207CA35; Fri, 18 Dec 2020 10:34:40 +0100 (CET) Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) by dpdk.org (Postfix) with ESMTP id 0F3B6CA2C for ; Fri, 18 Dec 2020 10:34:38 +0100 (CET) X-QQ-mid: bizesmtp28t1608284071tqpbwkix Received: from localhost.localdomain.com (unknown [183.129.236.74]) by esmtp10.qq.com (ESMTP) with id ; Fri, 18 Dec 2020 17:34:31 +0800 (CST) X-QQ-SSF: 01400000002000C0D000B00A0000000 X-QQ-FEAT: /Lyl1CoviYR9+4+fvyYdCdxk1DT+Cz86zavZaE084MVA/vIlvL5Cj7q2ApaoI rOfOBF5N9QNOG4GC8vfvD9Yw65zmtQeJhAyRH3QTStpBjcBiQKgO7KlxffDA6Ucc+etm14p F4KHwdsiCgVNnJOkxUr2fZRue80YajfEnFT6HEJV9tHNA4u6trLAt40Fpnnv9Xt13e3TEzH Ko9aFJI57cCXWlGbyB9rQolAUS/Y+gc/GIUhR99DAjzBJIWVCi5ncnz0hym42nb3AkOlNta zJpqStW/hmcSdqA7sRWslx7EvUOEx+ybxMnuZ9DdQmwAkM/9ltvnJmXOhB4vZ0c7oU9BEPX cR8UJbv7X+qcnr+vjdMrH4ug9ZH1w== X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Fri, 18 Dec 2020 17:36:30 +0800 Message-Id: <20201218093702.3651867-2-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201218093702.3651867-1-jiawenwu@trustnetic.com> References: <20201218093702.3651867-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign7 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v3 01/33] net/txgbe: add generic flow API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Introduce rte_flow with its validate, create, destroy and flush operations into txgbe PMD. Signed-off-by: Jiawen Wu --- doc/guides/nics/features/txgbe.ini | 1 + doc/guides/nics/txgbe.rst | 1 + drivers/net/txgbe/meson.build | 1 + drivers/net/txgbe/txgbe_ethdev.c | 25 +++++++++++ drivers/net/txgbe/txgbe_ethdev.h | 5 +++ drivers/net/txgbe/txgbe_flow.c | 71 ++++++++++++++++++++++++++++++ 6 files changed, 104 insertions(+) create mode 100644 drivers/net/txgbe/txgbe_flow.c diff --git a/doc/guides/nics/features/txgbe.ini b/doc/guides/nics/features/txgbe.ini index 573bf1604..ffeecfd20 100644 --- a/doc/guides/nics/features/txgbe.ini +++ b/doc/guides/nics/features/txgbe.ini @@ -26,6 +26,7 @@ SR-IOV = Y DCB = Y VLAN filter = Y Flow control = Y +Flow API = Y Rate limitation = Y CRC offload = P VLAN offload = P diff --git a/doc/guides/nics/txgbe.rst b/doc/guides/nics/txgbe.rst index cd293698b..5a7299964 100644 --- a/doc/guides/nics/txgbe.rst +++ b/doc/guides/nics/txgbe.rst @@ -29,6 +29,7 @@ Features - IEEE 1588 - FW version - LRO +- Generic flow API Prerequisites ------------- diff --git a/drivers/net/txgbe/meson.build b/drivers/net/txgbe/meson.build index 345dffaf6..45379175d 100644 --- a/drivers/net/txgbe/meson.build +++ b/drivers/net/txgbe/meson.build @@ -6,6 +6,7 @@ objs = [base_objs] sources = files( 'txgbe_ethdev.c', + 'txgbe_flow.c', 'txgbe_ptypes.c', 'txgbe_pf.c', 'txgbe_rxtx.c', diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index f8dffe1f1..0cd4c0908 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -3480,6 +3480,30 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev, return 0; } +static int +txgbe_dev_filter_ctrl(__rte_unused struct rte_eth_dev *dev, + enum rte_filter_type filter_type, + enum rte_filter_op filter_op, + void *arg) +{ + int ret = 0; + + switch (filter_type) { + case RTE_ETH_FILTER_GENERIC: + if (filter_op != RTE_ETH_FILTER_GET) + return -EINVAL; + *(const void **)arg = &txgbe_flow_ops; + break; + default: + PMD_DRV_LOG(WARNING, "Filter type (%d) not supported", + filter_type); + ret = -EINVAL; + break; + } + + return ret; +} + static u8 * txgbe_dev_addr_list_itr(__rte_unused struct txgbe_hw *hw, u8 **mc_addr_ptr, u32 *vmdq) @@ -4055,6 +4079,7 @@ static const struct eth_dev_ops txgbe_eth_dev_ops = { .reta_query = txgbe_dev_rss_reta_query, .rss_hash_update = txgbe_dev_rss_hash_update, .rss_hash_conf_get = txgbe_dev_rss_hash_conf_get, + .filter_ctrl = txgbe_dev_filter_ctrl, .set_mc_addr_list = txgbe_dev_set_mc_addr_list, .rxq_info_get = txgbe_rxq_info_get, .txq_info_get = txgbe_txq_info_get, diff --git a/drivers/net/txgbe/txgbe_ethdev.h b/drivers/net/txgbe/txgbe_ethdev.h index 696dd5a7e..e4eab6342 100644 --- a/drivers/net/txgbe/txgbe_ethdev.h +++ b/drivers/net/txgbe/txgbe_ethdev.h @@ -9,7 +9,10 @@ #include "base/txgbe.h" #include "txgbe_ptypes.h" +#include #include +#include +#include /* need update link, bit flag */ #define TXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0) @@ -298,6 +301,8 @@ int txgbe_pf_host_configure(struct rte_eth_dev *eth_dev); uint32_t txgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val); +extern const struct rte_flow_ops txgbe_flow_ops; + int txgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf, uint16_t tx_rate, uint64_t q_msk); int txgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx, diff --git a/drivers/net/txgbe/txgbe_flow.c b/drivers/net/txgbe/txgbe_flow.c new file mode 100644 index 000000000..d39ab6416 --- /dev/null +++ b/drivers/net/txgbe/txgbe_flow.c @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2015-2020 + */ + +#include +#include + +#include "txgbe_ethdev.h" + +/** + * Create or destroy a flow rule. + * Theorically one rule can match more than one filters. + * We will let it use the filter which it hitt first. + * So, the sequence matters. + */ +static struct rte_flow * +txgbe_flow_create(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], + const struct rte_flow_action actions[], + struct rte_flow_error *error) +{ + struct rte_flow *flow = NULL; + return flow; +} + +/** + * Check if the flow rule is supported by txgbe. + * It only checks the format. Don't guarantee the rule can be programmed into + * the HW. Because there can be no enough room for the rule. + */ +static int +txgbe_flow_validate(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], + const struct rte_flow_action actions[], + struct rte_flow_error *error) +{ + int ret = 0; + + return ret; +} + +/* Destroy a flow rule on txgbe. */ +static int +txgbe_flow_destroy(struct rte_eth_dev *dev, + struct rte_flow *flow, + struct rte_flow_error *error) +{ + int ret = 0; + + return ret; +} + +/* Destroy all flow rules associated with a port on txgbe. */ +static int +txgbe_flow_flush(struct rte_eth_dev *dev, + struct rte_flow_error *error) +{ + int ret = 0; + + return ret; +} + +const struct rte_flow_ops txgbe_flow_ops = { + .validate = txgbe_flow_validate, + .create = txgbe_flow_create, + .destroy = txgbe_flow_destroy, + .flush = txgbe_flow_flush, +}; + -- 2.18.2