From: Jiawen Wu Date: Fri, 18 Dec 2020 09:36:30 +0000 (+0800) Subject: net/txgbe: add generic flow API X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=43bb1f8dd09207938a580d028066db34dc86be7e;p=dpdk.git net/txgbe: add generic flow API Introduce rte_flow with its validate, create, destroy and flush operations into txgbe PMD. Signed-off-by: Jiawen Wu --- diff --git a/doc/guides/nics/features/txgbe.ini b/doc/guides/nics/features/txgbe.ini index 573bf1604f..ffeecfd205 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 cd293698ba..5a72999646 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 345dffaf68..45379175d1 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 f8dffe1f12..0cd4c09087 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 696dd5a7e4..e4eab63429 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 0000000000..d39ab6416b --- /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, +}; +