From patchwork Thu Oct 16 23:29:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingjing Wu X-Patchwork-Id: 839 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id C9D316A89; Fri, 17 Oct 2014 01:21:39 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id E60186946 for ; Fri, 17 Oct 2014 01:21:36 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 16 Oct 2014 16:26:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,735,1406617200"; d="scan'208";a="590519737" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 16 Oct 2014 16:29:26 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s9GNTOCg004517; Fri, 17 Oct 2014 07:29:24 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s9GNTMFT031438; Fri, 17 Oct 2014 07:29:24 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s9GNTMai031434; Fri, 17 Oct 2014 07:29:22 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Fri, 17 Oct 2014 07:29:21 +0800 Message-Id: <1413502161-31403-1-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] lib/librte_ether: new filter APIs definition X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Define new APIs to support configure multi-kind filters using same APIs, instead of creating each API set for each kind of filter. - rte_eth_dev_filter_supported - rte_eth_dev_filter_ctrl Filter types, operations, and structures are defined specifically in new header file lib/librte_eth/rte_dev_ctrl.h. As to the implementation discussion, please refer to http://dpdk.org/ml/archives/dev/2014-September/005179.html Signed-off-by: Jingjing Wu Acked-by: Helin Zhang , if the title can be changed to "ethdev: new filter APIs definition". Acked-by: Thomas Monjalon --- lib/librte_ether/Makefile | 1 + lib/librte_ether/rte_eth_ctrl.h | 80 +++++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.c | 32 +++++++++++++++++ lib/librte_ether/rte_ethdev.h | 44 +++++++++++++++++++++++ 4 files changed, 157 insertions(+) create mode 100644 lib/librte_ether/rte_eth_ctrl.h diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile index b310f8b..a461c31 100644 --- a/lib/librte_ether/Makefile +++ b/lib/librte_ether/Makefile @@ -46,6 +46,7 @@ SRCS-y += rte_ethdev.c # SYMLINK-y-include += rte_ether.h SYMLINK-y-include += rte_ethdev.h +SYMLINK-y-include += rte_eth_ctrl.h # this lib depends upon: DEPDIRS-y += lib/librte_eal lib/librte_mempool lib/librte_ring lib/librte_mbuf diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h new file mode 100644 index 0000000..e4d54c4 --- /dev/null +++ b/lib/librte_ether/rte_eth_ctrl.h @@ -0,0 +1,80 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _RTE_ETH_CTRL_H_ +#define _RTE_ETH_CTRL_H_ + +/** + * @file + * + * Ethernet device features and related data structures used + * by control APIs should be defined in this file. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Feature filter types + */ +enum rte_filter_type { + RTE_ETH_FILTER_NONE = 0, + RTE_ETH_FILTER_HASH, + RTE_ETH_FILTER_FDIR, + RTE_ETH_FILTER_MAX, +}; + +/** + * All generic operations to filters + */ +enum rte_filter_op { + RTE_ETH_FILTER_OP_NONE = 0, + /**< used to check whether the type filter is supported */ + RTE_ETH_FILTER_OP_ADD, /**< add filter entry */ + RTE_ETH_FILTER_OP_UPDATE, /**< update filter entry */ + RTE_ETH_FILTER_OP_DELETE, /**< delete filter entry */ + RTE_ETH_FILTER_OP_FLUSH, /**< flush all entries */ + RTE_ETH_FILTER_OP_GET, /**< get filter entry */ + RTE_ETH_FILTER_OP_SET, /**< configurations */ + RTE_ETH_FILTER_OP_GET_INFO, + /**< get information of filter, such as status or statistics */ + RTE_ETH_FILTER_OP_MAX, +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_ETH_CTRL_H_ */ diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 1659340..1edc816 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3148,3 +3148,35 @@ rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index, return (*dev->dev_ops->get_flex_filter)(dev, index, filter, rx_queue); } + +int +rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_type) +{ + struct rte_eth_dev *dev; + + if (port_id >= nb_ports) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -ENODEV; + } + + dev = &rte_eth_devices[port_id]; + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP); + return (*dev->dev_ops->filter_ctrl)(dev, filter_type, + RTE_ETH_FILTER_OP_NONE, NULL); +} + +int +rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type, + enum rte_filter_op filter_op, void *arg) +{ + struct rte_eth_dev *dev; + + if (port_id >= nb_ports) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -ENODEV; + } + + dev = &rte_eth_devices[port_id]; + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP); + return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg); +} diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 13be711..85c229d 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -177,6 +177,7 @@ extern "C" { #include #include #include "rte_ether.h" +#include "rte_eth_ctrl.h" /** * A structure used to retrieve statistics for an Ethernet port. @@ -1385,6 +1386,12 @@ typedef int (*eth_get_flex_filter_t)(struct rte_eth_dev *dev, uint16_t *rx_queue); /**< @internal Get a flex filter rule on an Ethernet device */ +typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev, + enum rte_filter_type filter_type, + enum rte_filter_op filter_op, + void *arg); +/**< @internal Take operations to assigned filter type on an Ethernet device */ + /** * @internal A structure containing the functions exported by an Ethernet driver. */ @@ -1493,6 +1500,7 @@ struct eth_dev_ops { eth_add_flex_filter_t add_flex_filter; /**< add flex filter. */ eth_remove_flex_filter_t remove_flex_filter; /**< remove flex filter. */ eth_get_flex_filter_t get_flex_filter; /**< get flex filter. */ + eth_filter_ctrl_t filter_ctrl; /**< common filter control*/ }; /** @@ -3622,6 +3630,42 @@ int rte_eth_dev_remove_flex_filter(uint8_t port_id, uint16_t index); int rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index, struct rte_flex_filter *filter, uint16_t *rx_queue); +/** + * Check whether the filter type is supported on an Ethernet device. + * All the supported filter types are defined in 'rte_eth_ctrl.h'. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param filter_type + * filter type. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support this filter type. + * - (-ENODEV) if *port_id* invalid. + */ +int rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_type); + +/** + * Take operations to assigned filter type on an Ethernet device. + * All the supported operations and filter types are defined in 'rte_eth_ctrl.h'. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param filter_type + * filter type. + * @param filter_op + * The operation taken to assigned filter. + * @param arg + * A pointer to arguments defined specifically for the operation. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support. + * - (-ENODEV) if *port_id* invalid. + * - others depends on the specific operations implementation. + */ +int rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type, + enum rte_filter_op filter_op, void *arg); + #ifdef __cplusplus } #endif