Show a patch.

GET /api/patches/365/
Content-Type: application/json
Vary: Accept

    "id": 365,
    "url": "",
    "web_url": "",
    "project": {
        "id": 1,
        "url": "",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "",
        "list_email": "",
        "web_url": "",
        "scm_url": "git://",
        "webscm_url": ""
    "msgid": "<>",
    "date": "2014-09-12T06:33:55",
    "name": "[dpdk-dev,v3,4/8] librte_ether:add a common filter API",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "0e2f80051f475fb992de76233dca35da5e7ecf60",
    "submitter": {
        "id": 52,
        "url": "",
        "name": "Jijiang Liu",
        "email": ""
    "delegate": null,
    "mbox": "",
    "series": [],
    "comments": "",
    "check": "pending",
    "checks": "",
    "tags": {},
    "headers": {
        "Return-Path": "<>",
        "References": "<>",
        "X-Mailman-Version": "2.1.15",
        "X-IronPort-AV": "E=Sophos;i=\"5.04,511,1406617200\"; d=\"scan'208\";a=\"477052394\"",
        "Date": "Fri, 12 Sep 2014 14:33:55 +0800",
        "List-Help": "<>",
        "X-BeenThere": "",
        "Message-Id": "<>",
        "X-Original-To": "",
        "Received": [
            "from [] (localhost [IPv6:::1])\n\tby (Postfix) with ESMTP id 31B98B397;\n\tFri, 12 Sep 2014 08:29:02 +0200 (CEST)",
            "from ( [])\n\tby (Postfix) with ESMTP id 380E0B397\n\tfor <>; Fri, 12 Sep 2014 08:28:59 +0200 (CEST)",
            "from ([])\n\tby with ESMTP; 11 Sep 2014 23:34:15 -0700",
            "from ([])\n\tby with ESMTP; 11 Sep 2014 23:34:14 -0700",
            "from (\n\t[])\n\tby with ESMTP id s8C6YCLc005980;\n\tFri, 12 Sep 2014 14:34:12 +0800",
            "from (localhost [])\n\tby (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid s8C6YA1U010816; Fri, 12 Sep 2014 14:34:12 +0800",
            "(from jijiangl@localhost)\n\tby (8.13.6/8.13.6/Submit) id s8C6YAZN010812; \n\tFri, 12 Sep 2014 14:34:10 +0800"
        "List-Post": "<>",
        "Subject": "[dpdk-dev] [PATCH v3 4/8]librte_ether:add a common filter API",
        "Sender": "\"dev\" <>",
        "X-Mailer": "git-send-email",
        "Precedence": "list",
        "From": "Jijiang Liu <>",
        "List-Archive": "<>",
        "X-ExtLoop1": "1",
        "List-Subscribe": "<>,\n\t<>",
        "List-Id": "patches and discussions about DPDK <>",
        "Delivered-To": "",
        "In-Reply-To": "<>",
        "List-Unsubscribe": "<>,\n\t<>",
        "To": "",
        "Errors-To": ""
    "content": "Introduce a new filter framewok in librte_ether. As to the implemetation discussion, please refer to\n, and VxLAN tunnel filter implementation is based on\nit.\n\nSigned-off-by: Jijiang Liu <>\nAcked-by: Helin Zhang <>\nAcked-by: Jingjing Wu <>\n\n---\n lib/librte_ether/Makefile       |    1 +\n lib/librte_ether/rte_eth_ctrl.h |  152 +++++++++++++++++++++++++++++++++++++++\n lib/librte_ether/rte_ethdev.c   |   32 ++++++++\n lib/librte_ether/rte_ethdev.h   |   56 +++++++++++---\n 4 files changed, 229 insertions(+), 12 deletions(-)\n create mode 100644 lib/librte_ether/rte_eth_ctrl.h",
    "diff": "diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile\nindex b310f8b..a461c31 100644\n--- a/lib/librte_ether/Makefile\n+++ b/lib/librte_ether/Makefile\n@@ -46,6 +46,7 @@ SRCS-y += rte_ethdev.c\n #\n SYMLINK-y-include += rte_ether.h\n SYMLINK-y-include += rte_ethdev.h\n+SYMLINK-y-include += rte_eth_ctrl.h\n \n # this lib depends upon:\n DEPDIRS-y += lib/librte_eal lib/librte_mempool lib/librte_ring lib/librte_mbuf\ndiff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h\nnew file mode 100644\nindex 0000000..3e2bf45\n--- /dev/null\n+++ b/lib/librte_ether/rte_eth_ctrl.h\n@@ -0,0 +1,152 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#ifndef _RTE_ETH_CTRL_H_\n+#define _RTE_ETH_CTRL_H_\n+\n+/**\n+ * @file\n+ *\n+ * Ethernet device features and related data structures used\n+ * by control APIs should be defined in this file.\n+ *\n+ */\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+/**\n+ * Feature filter types\n+ */\n+enum rte_filter_type {\n+\tRTE_ETH_FILTER_NONE = 0,\n+\tRTE_ETH_FILTER_RSS,\n+\tRTE_ETH_FILTER_FDIR,\n+\tRTE_ETH_FILTER_TUNNEL,\n+\tRTE_ETH_FILTER_MAX,\n+};\n+\n+/**\n+ * all generic operations to filters\n+ */\n+enum rte_filter_op {\n+\tRTE_ETH_FILTER_OP_NONE = 0,\n+\t/** used to check whether the type filter is supported */\n+\tRTE_ETH_FILTER_OP_ADD,      /**< add filter entry */\n+\tRTE_ETH_FILTER_OP_UPDATE,   /**< update filter entry */\n+\tRTE_ETH_FILTER_OP_DELETE,   /**< delete filter entry */\n+\tRTE_ETH_FILTER_OP_GET,      /**< get filter entry */\n+\tRTE_ETH_FILTER_OP_SET,      /**< configurations */\n+\tRTE_ETH_FILTER_OP_GET_INFO,\n+\t/** get information of filter, such as status or statistics */\n+\tRTE_ETH_FILTER_OP_MAX,\n+};\n+\n+/**** TUNNEL FILTER DATA DEFINATION *** */\n+\n+#define ETH_TUNNEL_FILTER_OMAC  0x01\n+#define ETH_TUNNEL_FILTER_OIP   0x02\n+#define ETH_TUNNEL_FILTER_TENID 0x04\n+#define ETH_TUNNEL_FILTER_IMAC  0x08\n+#define ETH_TUNNEL_FILTER_IVLAN 0x10\n+#define ETH_TUNNEL_FILTER_IIP   0x20\n+\n+#define RTE_TUNNEL_FLAGS_TO_QUEUE 1\n+\n+/*\n+ * Tunneled filter type\n+ */\n+enum rte_tunnel_filter_type {\n+\tRTE_TUNNEL_FILTER_TYPE_NONE = 0,\n+\tRTE_TUNNEL_FILTER_OIP = ETH_TUNNEL_FILTER_OIP,\n+\tRTE_TUNNEL_FILTER_IMAC_IVLAN =\n+\t\tETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN,\n+\tRTE_TUNNEL_FILTER_IMAC_IVLAN_TENID =\n+\t\tETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN |\n+\t\tETH_TUNNEL_FILTER_TENID,\n+\tRTE_TUNNEL_FILTER_IMAC_TENID =\n+\t\tETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_TENID,\n+\tRTE_TUNNEL_FILTER_IMAC = ETH_TUNNEL_FILTER_IMAC,\n+\tRTE_TUNNEL_FILTER_OMAC_TENID_IMAC =\n+\t\tETH_TUNNEL_FILTER_OMAC | ETH_TUNNEL_FILTER_TENID |\n+\t\tETH_TUNNEL_FILTER_IMAC,\n+\tRTE_TUNNEL_FILTER_IIP = ETH_TUNNEL_FILTER_IIP,\n+\tRTE_TUNNEL_FILTER_TYPE_MAX,\n+};\n+\n+/**\n+ *  Select IPv4 or IPv6 for tunnel filters.\n+ */\n+enum rte_tunnel_iptype {\n+\tRTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */\n+\tRTE_TUNNEL_IPTYPE_IPV6,     /**< IPv6. */\n+};\n+\n+/**\n+ * Tunneled type.\n+ */\n+enum rte_eth_tunnel_type {\n+\tRTE_TUNNEL_TYPE_NONE = 0,\n+\tRTE_TUNNEL_TYPE_VXLAN,\n+\tRTE_TUNNEL_TYPE_GENEVE,\n+\tRTE_TUNNEL_TYPE_TEREDO,\n+\tRTE_TUNNEL_TYPE_NVGRE,\n+\tRTE_TUNNEL_TYPE_MAX,\n+};\n+\n+/**\n+ * Tunnel Packet filter configuration.\n+ */\n+struct rte_eth_tunnel_filter_conf {\n+\tstruct ether_addr *outer_mac;  /**< Outer MAC address fiter. */\n+\tstruct ether_addr *inner_mac;  /**< Inner MAC address fiter. */\n+\tuint16_t inner_vlan;           /**< Inner VLAN fiter. */\n+\tenum rte_tunnel_iptype ip_type; /**< IP address type. */\n+\tunion {\n+\t\tuint32_t ipv4_addr;    /**< IPv4 source address to match. */\n+\t\tuint32_t ipv6_addr[4]; /**< IPv6 source address to match. */\n+\t} ip_addr; /**< IPv4/IPv6 source address to match (union of above). */\n+\n+\tuint8_t filter_type;           /**< Filter type. */\n+\tuint8_t to_queue;       /**< Use MAC and VLAN to point to a queue. */\n+\tenum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */\n+\tuint32_t tenant_id;            /** < Tenant number. */\n+\tuint16_t queue_id;             /** < queue number. */\n+};\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* _RTE_ETH_CTRL_H_ */\ndiff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c\nindex 325edb1..e5b24f5 100644\n--- a/lib/librte_ether/rte_ethdev.c\n+++ b/lib/librte_ether/rte_ethdev.c\n@@ -3065,3 +3065,35 @@ rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index,\n \treturn (*dev->dev_ops->get_flex_filter)(dev, index, filter,\n \t\t\t\t\t\trx_queue);\n }\n+\n+int\n+rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_type)\n+{\n+\tstruct rte_eth_dev *dev;\n+\n+\tif (port_id >= nb_ports) {\n+\t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tdev = &rte_eth_devices[port_id];\n+\tFUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);\n+\treturn (*dev->dev_ops->filter_ctrl)(dev, filter_type,\n+\t\t\t\tRTE_ETH_FILTER_OP_NONE, NULL);\n+}\n+\n+int\n+rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,\n+\t\t       enum rte_filter_op filter_op, void *arg)\n+{\n+\tstruct rte_eth_dev *dev;\n+\n+\tif (port_id >= nb_ports) {\n+\t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tdev = &rte_eth_devices[port_id];\n+\tFUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);\n+\treturn (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg);\n+}\ndiff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h\nindex 74ac313..156d05b 100644\n--- a/lib/librte_ether/rte_ethdev.h\n+++ b/lib/librte_ether/rte_ethdev.h\n@@ -177,6 +177,7 @@ extern \"C\" {\n #include <rte_pci.h>\n #include <rte_mbuf.h>\n #include \"rte_ether.h\"\n+#include \"rte_eth_ctrl.h\"\n \n /**\n  * A structure used to retrieve statistics for an Ethernet port.\n@@ -716,18 +717,6 @@ struct rte_eth_udp_tunnel {\n };\n \n /**\n- * Tunneled type.\n- */\n-enum rte_eth_tunnel_type {\n-\tRTE_TUNNEL_TYPE_NONE = 0,\n-\tRTE_TUNNEL_TYPE_VXLAN,\n-\tRTE_TUNNEL_TYPE_GENEVE,\n-\tRTE_TUNNEL_TYPE_TEREDO,\n-\tRTE_TUNNEL_TYPE_NVGRE,\n-\tRTE_TUNNEL_TYPE_MAX,\n-};\n-\n-/**\n  *  Possible l4type of FDIR filters.\n  */\n enum rte_l4type {\n@@ -1393,6 +1382,12 @@ typedef int (*eth_get_flex_filter_t)(struct rte_eth_dev *dev,\n \t\t\tuint16_t *rx_queue);\n /**< @internal Get a flex filter rule on an Ethernet device */\n \n+typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,\n+\t\t\t\t enum rte_filter_type filter_type,\n+\t\t\t\t enum rte_filter_op filter_op,\n+\t\t\t\t void *arg);\n+/**< @internal Take operations to assigned filter type on an Ethernet device */\n+\n /**\n  * @internal A structure containing the functions exported by an Ethernet driver.\n  */\n@@ -1501,6 +1496,7 @@ struct eth_dev_ops {\n \teth_add_flex_filter_t          add_flex_filter;      /**< add flex filter. */\n \teth_remove_flex_filter_t       remove_flex_filter;   /**< remove flex filter. */\n \teth_get_flex_filter_t          get_flex_filter;      /**< get flex filter. */\n+\teth_filter_ctrl_t              filter_ctrl;          /**< common filter control*/\n };\n \n /**\n@@ -3633,6 +3629,42 @@ int rte_eth_dev_remove_flex_filter(uint8_t port_id, uint16_t index);\n int rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index,\n \t\t\tstruct rte_flex_filter *filter, uint16_t *rx_queue);\n \n+/**\n+ * Check whether the filter type is supported on an Ethernet device.\n+ * All the supported filter types are defined in 'rte_eth_filter.h'.\n+ *\n+ * @param port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param filter_type\n+ *   filter type.\n+ * @return\n+ *   - (0) if successful.\n+ *   - (-ENOTSUP) if hardware doesn't support this filter type.\n+ *   - (-ENODEV) if *port_id* invalid.\n+ */\n+int rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_type);\n+\n+/**\n+ * Take operations to assigned filter type on an Ethernet device.\n+ * All the supported operations and filter types are defined in 'rte_eth_filter.h'.\n+ *\n+ * @param port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param filter_type\n+ *   filter type.\n+  * @param filter_op\n+ *   The operation taken to assigned filter.\n+ * @param arg\n+ *   A pointer to arguments defined specifically for the operation.\n+ * @return\n+ *   - (0) if successful.\n+ *   - (-ENOTSUP) if hardware doesn't support.\n+ *   - (-ENODEV) if *port_id* invalid.\n+ *   - others depends on the specific operations implementation.\n+ */\n+int rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,\n+\t\t\tenum rte_filter_op filter_op, void *arg);\n+\n #ifdef __cplusplus\n }\n #endif\n",
    "prefixes": [