From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 2CB43B361 for ; Mon, 28 Jul 2014 10:24:37 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 28 Jul 2014 01:26:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,747,1400050800"; d="scan'208";a="568219922" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 28 Jul 2014 01:26:09 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s6S8Q7kQ022882; Mon, 28 Jul 2014 16:26:07 +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 s6S8Q3q3031194; Mon, 28 Jul 2014 16:26:05 +0800 Received: (from hzhan75@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s6S8Q3ce031190; Mon, 28 Jul 2014 16:26:03 +0800 From: Helin Zhang To: dev@dpdk.org Date: Mon, 28 Jul 2014 16:25:51 +0800 Message-Id: <1406535955-31070-3-git-send-email-helin.zhang@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1406535955-31070-1-git-send-email-helin.zhang@intel.com> References: <1406535955-31070-1-git-send-email-helin.zhang@intel.com> Subject: [dpdk-dev] [PATCH v2 2/6] ethdev: add new ops of 'is_command_supported' and 'rx_classification_filter_ctl' 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: , X-List-Received-Date: Mon, 28 Jul 2014 08:24:38 -0000 Two ops of 'is_command_supported' and 'rx_classification_filter_ctl' are added. New header file of 'rte_eth_features.h' is added. * 'is_command_supported': It is for capability discovery, that is to check if specific feature/command is supported on a port. * 'rx_classification_filter_ctl': It is for receive classification filter configuring. e.g. selecting hash function, possibly configuring flow director. It is a common API where a lot of commands can be implemented for different sub features, to avoid defining quite a lot of ops for device specific features. * 'rte_eth_features.h': It includes all the feature commands which can be checked and processed in above two ops. Also it may include other commands for future implementations. Signed-off-by: Helin Zhang --- lib/librte_ether/Makefile | 1 + lib/librte_ether/rte_eth_features.h | 73 +++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.c | 31 ++++++++++++++++ lib/librte_ether/rte_ethdev.h | 55 ++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 lib/librte_ether/rte_eth_features.h diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile index b310f8b..8089723 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_features.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_features.h b/lib/librte_ether/rte_eth_features.h new file mode 100644 index 0000000..983d7c6 --- /dev/null +++ b/lib/librte_ether/rte_eth_features.h @@ -0,0 +1,73 @@ +/*- + * 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_FEATURES_H_ +#define _RTE_ETH_FEATURES_H_ + +/** + * @file + * + * Ethernet device specific features + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Commands defined for NIC specific features */ +enum rte_eth_command { + RTE_CMD_UNKNOWN = 0, + /**< Unknown command */ + RTE_CMD_GET_SYM_HASH_ENABLE_PER_PCTYPE, + /**< Get symmetric hash enable per pctype */ + RTE_CMD_SET_SYM_HASH_ENABLE_PER_PCTYPE, + /**< Set symmetric hash enable per pctype */ + RTE_CMD_GET_SYM_HASH_ENABLE_PER_PORT, + /**< Get symmetric hash enable per port */ + RTE_CMD_SET_SYM_HASH_ENABLE_PER_PORT, + /**< Set symmetric hash enable per port */ + RTE_CMD_GET_FILTER_SWAP, + /**< Get filter swap configurations */ + RTE_CMD_SET_FILTER_SWAP, + /**< Set filter swap configurations */ + RTE_CMD_GET_HASH_FUNCTION, + /**< Get hash function */ + RTE_CMD_SET_HASH_FUNCTION, + /**< Set hash function */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_ETH_FEATURES_H_ */ diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index fd1010a..dfeb804 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3002,3 +3002,34 @@ 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_is_command_supported(uint8_t port_id, enum rte_eth_command cmd) +{ + 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->is_command_supported, -ENOTSUP); + return (*dev->dev_ops->is_command_supported)(dev, cmd); +} + +int +rte_eth_dev_rx_classification_filter_ctl(uint8_t port_id, + enum rte_eth_command cmd, + void *args) +{ + 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->rx_classification_filter_ctl, + -ENOTSUP); + return (*dev->dev_ops->rx_classification_filter_ctl)(dev, cmd, args); +} diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index dd36605..5c5d84e 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_features.h" /** * A structure used to retrieve statistics for an Ethernet port. @@ -1240,6 +1241,15 @@ typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev, uint8_t rule_id); /**< @internal Remove a traffic mirroring rule on an Ethernet device */ +typedef int (*eth_is_command_supported_t)(struct rte_eth_dev *dev, + enum rte_eth_command cmd); +/**< @internal check if the command is supported by the Ethernet device */ + +typedef int (*eth_rx_classification_filter_ctl_t)(struct rte_eth_dev *dev, + enum rte_eth_command cmd, + void *arg); +/**< @internal receive classification filter control operations */ + #ifdef RTE_NIC_BYPASS enum { @@ -1467,6 +1477,10 @@ 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_is_command_supported_t is_command_supported; + /**< check if a command is supported. */ + eth_rx_classification_filter_ctl_t rx_classification_filter_ctl; + /**< common control function of hw hash */ }; /** @@ -3557,6 +3571,47 @@ 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 if the command is supported by an Ethernet device. All the commands + * are defined in 'rte_eth_features.h'. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param cmd + * The command. + * + * @return + * - (> 0) The command is supported. + * - (0) The command is not supported. + * - (-ENOTSUP) if hardware doesn't support. + * - (-ENODEV) if is invalid. + */ +int rte_eth_dev_is_command_supported(uint8_t port_id, + enum rte_eth_command cmd); + +/** + * Configure the receive classification filter, including hash function + * selection. The commands are NIC specific in its exported public header + * file. Different types of NIC may have different commands. + * All the supported commands are defined in 'rte_eth_features.h'. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param cmd + * The command. + * @param args + * A pointer to arguments defined specifically for the command. + * + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support. + * - (-ENODEV) if is invalid. + * - others depends on the specific command implementation. + */ +int rte_eth_dev_rx_classification_filter_ctl(uint8_t port_id, + enum rte_eth_command cmd, + void *args); + #ifdef __cplusplus } #endif -- 1.8.1.4