From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 4747A58EE for ; Wed, 27 Aug 2014 04:10:33 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 26 Aug 2014 19:14:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,408,1406617200"; d="scan'208";a="593783863" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 26 Aug 2014 19:14:15 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s7R2EEsb005232; Wed, 27 Aug 2014 10:14:14 +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 s7R2EBCM030103; Wed, 27 Aug 2014 10:14:13 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s7R2EB8M030099; Wed, 27 Aug 2014 10:14:11 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Wed, 27 Aug 2014 10:13:49 +0800 Message-Id: <1409105634-29980-3-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1409105634-29980-1-git-send-email-jingjing.wu@intel.com> References: <1409105634-29980-1-git-send-email-jingjing.wu@intel.com> Subject: [dpdk-dev] [PATCH v2 2/7] ethdev: define new ethdev API 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: Wed, 27 Aug 2014 02:10:34 -0000 support a new ethdev API rx_classification_filter_ctl for all the configuration or queries for receive classification filters. this patch supports commands the API used below: RTE_CMD_FDIR_RULE_ADD RTE_CMD_FDIR_RULE_DEL RTE_CMD_FDIR_FLUSH RTE_CMD_FDIR_INFO_GET Signed-off-by: jingjing.wu Reviewed-by: Helin Zhang Reviewed-by: Jing Chen Reviewed-by: Jijiang Liu --- lib/librte_ether/Makefile | 3 +- lib/librte_ether/rte_eth_features.h | 65 ++++++++++++++++++++++ lib/librte_ether/rte_ethdev.c | 19 ++++++- lib/librte_ether/rte_ethdev.h | 108 +++++++++++++++++++++++------------- 4 files changed, 155 insertions(+), 40 deletions(-) create mode 100644 lib/librte_ether/rte_eth_features.h diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile index b310f8b..03dec8a 100644 --- a/lib/librte_ether/Makefile +++ b/lib/librte_ether/Makefile @@ -46,8 +46,9 @@ 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 +DEPDIRS-y += lib/librte_eal lib/librte_mempool lib/librte_ring lib/librte_mbuf lib/librte_net include $(RTE_SDK)/mk/rte.lib.mk diff --git a/lib/librte_ether/rte_eth_features.h b/lib/librte_ether/rte_eth_features.h new file mode 100644 index 0000000..ea77b69 --- /dev/null +++ b/lib/librte_ether/rte_eth_features.h @@ -0,0 +1,65 @@ +/*- + * 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, + RTE_CMD_FDIR_RULE_ADD, + /**< Command to add a new FDIR filter rule. */ + RTE_CMD_FDIR_RULE_DEL, + /**< Command to delete a FDIR filter rule. */ + RTE_CMD_FDIR_FLUSH, + /**< Command to clear all FDIR filter rules. */ + RTE_CMD_FDIR_INFO_GET, + /**< Command to get FDIR information. */ + RTE_CMD_MAX = 255, +}; + +#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..10a08de 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include @@ -66,6 +65,7 @@ #include #include #include +#include #include "rte_ether.h" #include "rte_ethdev.h" @@ -3002,3 +3002,20 @@ 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_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 50df654..a2d9596 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. @@ -345,47 +346,47 @@ struct rte_eth_rss_conf { #define ETH_RSS_IPV4_UDP_SHIFT 6 #define ETH_RSS_IPV6_UDP_SHIFT 7 #define ETH_RSS_IPV6_UDP_EX_SHIFT 8 -/* for 40G only */ -#define ETH_RSS_NONF_IPV4_UDP_SHIFT 31 -#define ETH_RSS_NONF_IPV4_TCP_SHIFT 33 -#define ETH_RSS_NONF_IPV4_SCTP_SHIFT 34 -#define ETH_RSS_NONF_IPV4_OTHER_SHIFT 35 -#define ETH_RSS_FRAG_IPV4_SHIFT 36 -#define ETH_RSS_NONF_IPV6_UDP_SHIFT 41 -#define ETH_RSS_NONF_IPV6_TCP_SHIFT 43 -#define ETH_RSS_NONF_IPV6_SCTP_SHIFT 44 -#define ETH_RSS_NONF_IPV6_OTHER_SHIFT 45 -#define ETH_RSS_FRAG_IPV6_SHIFT 46 -#define ETH_RSS_FCOE_OX_SHIFT 48 -#define ETH_RSS_FCOE_RX_SHIFT 49 -#define ETH_RSS_FCOE_OTHER_SHIFT 50 -#define ETH_RSS_L2_PAYLOAD_SHIFT 63 +/* Packet Classification Type for 40G only */ +#define ETH_PCTYPE_NONF_IPV4_UDP 31 +#define ETH_PCTYPE_NONF_IPV4_TCP 33 +#define ETH_PCTYPE_NONF_IPV4_SCTP 34 +#define ETH_PCTYPE_NONF_IPV4_OTHER 35 +#define ETH_PCTYPE_FRAG_IPV4 36 +#define ETH_PCTYPE_NONF_IPV6_UDP 41 +#define ETH_PCTYPE_NONF_IPV6_TCP 43 +#define ETH_PCTYPE_NONF_IPV6_SCTP 44 +#define ETH_PCTYPE_NONF_IPV6_OTHER 45 +#define ETH_PCTYPE_FRAG_IPV6 46 +#define ETH_PCTYPE_FCOE_OX 48 /* not used */ +#define ETH_PCTYPE_FCOE_RX 49 /* not used */ +#define ETH_PCTYPE_FCOE_OTHER 50 /* not used */ +#define ETH_PCTYPE_L2_PAYLOAD 63 /* for 1G & 10G */ -#define ETH_RSS_IPV4 ((uint16_t)1 << ETH_RSS_IPV4_SHIFT) -#define ETH_RSS_IPV4_TCP ((uint16_t)1 << ETH_RSS_IPV4_TCP_SHIFT) -#define ETH_RSS_IPV6 ((uint16_t)1 << ETH_RSS_IPV6_SHIFT) -#define ETH_RSS_IPV6_EX ((uint16_t)1 << ETH_RSS_IPV6_EX_SHIFT) -#define ETH_RSS_IPV6_TCP ((uint16_t)1 << ETH_RSS_IPV6_TCP_SHIFT) -#define ETH_RSS_IPV6_TCP_EX ((uint16_t)1 << ETH_RSS_IPV6_TCP_EX_SHIFT) -#define ETH_RSS_IPV4_UDP ((uint16_t)1 << ETH_RSS_IPV4_UDP_SHIFT) -#define ETH_RSS_IPV6_UDP ((uint16_t)1 << ETH_RSS_IPV6_UDP_SHIFT) -#define ETH_RSS_IPV6_UDP_EX ((uint16_t)1 << ETH_RSS_IPV6_UDP_EX_SHIFT) +#define ETH_RSS_IPV4 (1 << ETH_RSS_IPV4_SHIFT) +#define ETH_RSS_IPV4_TCP (1 << ETH_RSS_IPV4_TCP_SHIFT) +#define ETH_RSS_IPV6 (1 << ETH_RSS_IPV6_SHIFT) +#define ETH_RSS_IPV6_EX (1 << ETH_RSS_IPV6_EX_SHIFT) +#define ETH_RSS_IPV6_TCP (1 << ETH_RSS_IPV6_TCP_SHIFT) +#define ETH_RSS_IPV6_TCP_EX (1 << ETH_RSS_IPV6_TCP_EX_SHIFT) +#define ETH_RSS_IPV4_UDP (1 << ETH_RSS_IPV4_UDP_SHIFT) +#define ETH_RSS_IPV6_UDP (1 << ETH_RSS_IPV6_UDP_SHIFT) +#define ETH_RSS_IPV6_UDP_EX (1 << ETH_RSS_IPV6_UDP_EX_SHIFT) /* for 40G only */ -#define ETH_RSS_NONF_IPV4_UDP ((uint64_t)1 << ETH_RSS_NONF_IPV4_UDP_SHIFT) -#define ETH_RSS_NONF_IPV4_TCP ((uint64_t)1 << ETH_RSS_NONF_IPV4_TCP_SHIFT) -#define ETH_RSS_NONF_IPV4_SCTP ((uint64_t)1 << ETH_RSS_NONF_IPV4_SCTP_SHIFT) -#define ETH_RSS_NONF_IPV4_OTHER ((uint64_t)1 << ETH_RSS_NONF_IPV4_OTHER_SHIFT) -#define ETH_RSS_FRAG_IPV4 ((uint64_t)1 << ETH_RSS_FRAG_IPV4_SHIFT) -#define ETH_RSS_NONF_IPV6_UDP ((uint64_t)1 << ETH_RSS_NONF_IPV6_UDP_SHIFT) -#define ETH_RSS_NONF_IPV6_TCP ((uint64_t)1 << ETH_RSS_NONF_IPV6_TCP_SHIFT) -#define ETH_RSS_NONF_IPV6_SCTP ((uint64_t)1 << ETH_RSS_NONF_IPV6_SCTP_SHIFT) -#define ETH_RSS_NONF_IPV6_OTHER ((uint64_t)1 << ETH_RSS_NONF_IPV6_OTHER_SHIFT) -#define ETH_RSS_FRAG_IPV6 ((uint64_t)1 << ETH_RSS_FRAG_IPV6_SHIFT) -#define ETH_RSS_FCOE_OX ((uint64_t)1 << ETH_RSS_FCOE_OX_SHIFT) /* not used */ -#define ETH_RSS_FCOE_RX ((uint64_t)1 << ETH_RSS_FCOE_RX_SHIFT) /* not used */ -#define ETH_RSS_FCOE_OTHER ((uint64_t)1 << ETH_RSS_FCOE_OTHER_SHIFT) /* not used */ -#define ETH_RSS_L2_PAYLOAD ((uint64_t)1 << ETH_RSS_L2_PAYLOAD_SHIFT) +#define ETH_RSS_NONF_IPV4_UDP (1ULL << ETH_PCTYPE_NONF_IPV4_UDP) +#define ETH_RSS_NONF_IPV4_TCP (1ULL << ETH_PCTYPE_NONF_IPV4_TCP) +#define ETH_RSS_NONF_IPV4_SCTP (1ULL << ETH_PCTYPE_NONF_IPV4_SCTP) +#define ETH_RSS_NONF_IPV4_OTHER (1ULL << ETH_PCTYPE_NONF_IPV4_OTHER) +#define ETH_RSS_FRAG_IPV4 (1ULL << ETH_PCTYPE_FRAG_IPV4) +#define ETH_RSS_NONF_IPV6_UDP (1ULL << ETH_PCTYPE_NONF_IPV6_UDP) +#define ETH_RSS_NONF_IPV6_TCP (1ULL << ETH_PCTYPE_NONF_IPV6_TCP) +#define ETH_RSS_NONF_IPV6_SCTP (1ULL << ETH_PCTYPE_NONF_IPV6_SCTP) +#define ETH_RSS_NONF_IPV6_OTHER (1ULL << ETH_PCTYPE_NONF_IPV6_OTHER) +#define ETH_RSS_FRAG_IPV6 (1ULL << ETH_PCTYPE_FRAG_IPV6) +#define ETH_RSS_FCOE_OX (1ULL << ETH_PCTYPE_FCOE_OX) +#define ETH_RSS_FCOE_RX (1ULL << ETH_PCTYPE_FCOE_RX) +#define ETH_RSS_FCOE_OTHER (1ULL << ETH_PCTYPE_FCOE_OTHER) +#define ETH_RSS_L2_PAYLOAD (1ULL << ETH_PCTYPE_L2_PAYLOAD) #define ETH_RSS_IP ( \ ETH_RSS_IPV4 | \ @@ -1361,6 +1362,11 @@ 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_rx_classification_filter_ctl_t)(struct rte_eth_dev *dev, + enum rte_eth_command cmd, + void *arg); +/**< @internal receive classification filter control operations */ + /** * @internal A structure containing the functions exported by an Ethernet driver. */ @@ -1467,6 +1473,8 @@ 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. */ + /*common ccontrol function for receive classification filters*/ + eth_rx_classification_filter_ctl_t rx_classification_filter_ctl; }; /** @@ -3557,6 +3565,30 @@ 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); + +/** + * 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