From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by dpdk.org (Postfix) with ESMTP id 39AF22A7 for ; Mon, 16 Jun 2014 09:32:10 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 16 Jun 2014 00:32:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,484,1400050800"; d="scan'208";a="445908578" Received: from shilc102.sh.intel.com ([10.239.39.44]) by azsmga001.ch.intel.com with ESMTP; 16 Jun 2014 00:32:01 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shilc102.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s5G7VtE1009162; Mon, 16 Jun 2014 15:31:57 +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 s5G7Vrwc024423; Mon, 16 Jun 2014 15:31:55 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s5G7Vrxt024419; Mon, 16 Jun 2014 15:31:53 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Mon, 16 Jun 2014 15:31:43 +0800 Message-Id: <1402903906-24307-2-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1402903906-24307-1-git-send-email-jingjing.wu@intel.com> References: <1402903906-24307-1-git-send-email-jingjing.wu@intel.com> Subject: [dpdk-dev] [PATCH v4 1/4] ethdev: add ethdev APIs for NIC filters of generic filter 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, 16 Jun 2014 07:32:11 -0000 This patch adds APIs for NIC filters list below: ethertype filter, syn filter, 2tuple filter, flex filter, 5tuple filter Signed-off-by: jingjing.wu --- lib/librte_ether/rte_ethdev.c | 275 +++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 428 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 703 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 8011b8b..42333ee 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -2606,3 +2607,277 @@ rte_eth_dev_bypass_wd_reset(uint8_t port_id) return 0; } #endif + +int +rte_eth_dev_add_syn_filter(uint8_t port_id, + struct rte_syn_filter *filter, uint16_t rx_queue) +{ + 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->add_syn_filter, -ENOTSUP); + return (*dev->dev_ops->add_syn_filter)(dev, filter, rx_queue); +} + +int +rte_eth_dev_remove_syn_filter(uint8_t port_id) +{ + 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->remove_syn_filter, -ENOTSUP); + return (*dev->dev_ops->remove_syn_filter)(dev); +} + +int +rte_eth_dev_get_syn_filter(uint8_t port_id, + struct rte_syn_filter *filter, uint16_t *rx_queue) +{ + struct rte_eth_dev *dev; + + if (filter == NULL || rx_queue == NULL) + return -EINVAL; + + 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->get_syn_filter, -ENOTSUP); + return (*dev->dev_ops->get_syn_filter)(dev, filter, rx_queue); +} + +int +rte_eth_dev_add_ethertype_filter(uint8_t port_id, uint16_t index, + struct rte_ethertype_filter *filter, uint16_t rx_queue) +{ + struct rte_eth_dev *dev; + + if (port_id >= nb_ports) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -ENODEV; + } + if (filter->ethertype == ETHER_TYPE_IPv4 || + filter->ethertype == ETHER_TYPE_IPv6){ + PMD_DEBUG_TRACE("IP and IPv6 are not supported" + " in ethertype filter\n"); + return -EINVAL; + } + dev = &rte_eth_devices[port_id]; + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_ethertype_filter, -ENOTSUP); + return (*dev->dev_ops->add_ethertype_filter)(dev, index, + filter, rx_queue); +} + +int +rte_eth_dev_remove_ethertype_filter(uint8_t port_id, uint16_t index) +{ + 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->remove_ethertype_filter, -ENOTSUP); + return (*dev->dev_ops->remove_ethertype_filter)(dev, index); +} + +int +rte_eth_dev_get_ethertype_filter(uint8_t port_id, uint16_t index, + struct rte_ethertype_filter *filter, uint16_t *rx_queue) +{ + struct rte_eth_dev *dev; + + if (filter == NULL || rx_queue == NULL) + return -EINVAL; + + 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->get_ethertype_filter, -ENOTSUP); + return (*dev->dev_ops->get_ethertype_filter)(dev, index, + filter, rx_queue); +} + +int +rte_eth_dev_add_2tuple_filter(uint8_t port_id, uint16_t index, + struct rte_2tuple_filter *filter, uint16_t rx_queue) +{ + struct rte_eth_dev *dev; + + if (port_id >= nb_ports) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -ENODEV; + } + if (filter->protocol != IPPROTO_TCP && + filter->tcp_flags != 0){ + PMD_DEBUG_TRACE("tcp flags is 0x%x, but the protocol value" + " is not TCP\n", + filter->tcp_flags); + return -EINVAL; + } + + dev = &rte_eth_devices[port_id]; + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_2tuple_filter, -ENOTSUP); + return (*dev->dev_ops->add_2tuple_filter)(dev, index, filter, rx_queue); +} + +int +rte_eth_dev_remove_2tuple_filter(uint8_t port_id, uint16_t index) +{ + 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->remove_2tuple_filter, -ENOTSUP); + return (*dev->dev_ops->remove_2tuple_filter)(dev, index); +} + +int +rte_eth_dev_get_2tuple_filter(uint8_t port_id, uint16_t index, + struct rte_2tuple_filter *filter, uint16_t *rx_queue) +{ + struct rte_eth_dev *dev; + + if (filter == NULL || rx_queue == NULL) + return -EINVAL; + + 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->get_2tuple_filter, -ENOTSUP); + return (*dev->dev_ops->get_2tuple_filter)(dev, index, filter, rx_queue); +} + +int +rte_eth_dev_add_5tuple_filter(uint8_t port_id, uint16_t index, + struct rte_5tuple_filter *filter, uint16_t rx_queue) +{ + struct rte_eth_dev *dev; + + if (port_id >= nb_ports) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -ENODEV; + } + + if (filter->protocol != IPPROTO_TCP && + filter->tcp_flags != 0){ + PMD_DEBUG_TRACE("tcp flags is 0x%x, but the protocol value" + " is not TCP\n", + filter->tcp_flags); + return -EINVAL; + } + + dev = &rte_eth_devices[port_id]; + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_5tuple_filter, -ENOTSUP); + return (*dev->dev_ops->add_5tuple_filter)(dev, index, filter, rx_queue); +} + +int +rte_eth_dev_remove_5tuple_filter(uint8_t port_id, uint16_t index) +{ + 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->remove_5tuple_filter, -ENOTSUP); + return (*dev->dev_ops->remove_5tuple_filter)(dev, index); +} + +int +rte_eth_dev_get_5tuple_filter(uint8_t port_id, uint16_t index, + struct rte_5tuple_filter *filter, uint16_t *rx_queue) +{ + struct rte_eth_dev *dev; + + if (filter == NULL || rx_queue == NULL) + return -EINVAL; + + 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->get_5tuple_filter, -ENOTSUP); + return (*dev->dev_ops->get_5tuple_filter)(dev, index, filter, + rx_queue); +} + +int +rte_eth_dev_add_flex_filter(uint8_t port_id, uint16_t index, + struct rte_flex_filter *filter, uint16_t rx_queue) +{ + 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->add_flex_filter, -ENOTSUP); + return (*dev->dev_ops->add_flex_filter)(dev, index, filter, rx_queue); +} + +int +rte_eth_dev_remove_flex_filter(uint8_t port_id, uint16_t index) +{ + 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->remove_flex_filter, -ENOTSUP); + return (*dev->dev_ops->remove_flex_filter)(dev, index); +} + +int +rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index, + struct rte_flex_filter *filter, uint16_t *rx_queue) +{ + struct rte_eth_dev *dev; + + if (filter == NULL || rx_queue == NULL) + return -EINVAL; + + 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->get_flex_filter, -ENOTSUP); + return (*dev->dev_ops->get_flex_filter)(dev, index, filter, + rx_queue); +} diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 67eda50..38ae0b8 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -813,6 +813,73 @@ struct rte_eth_dev_callback; /** @internal Structure to keep track of registered callbacks */ TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback); +#define TCP_UGR_FLAG 0x20 +#define TCP_ACK_FLAG 0x10 +#define TCP_PSH_FLAG 0x08 +#define TCP_RST_FLAG 0x04 +#define TCP_SYN_FLAG 0x02 +#define TCP_FIN_FLAG 0x01 +#define TCP_FLAG_ALL 0x3F + +/** + * A structure used to define an ethertype filter. + */ +struct rte_ethertype_filter { + uint16_t ethertype; /**< little endian. */ + uint8_t priority_en; /**< compare priority enable. */ + uint8_t priority; +}; + +/** + * A structure used to define an syn filter. + */ +struct rte_syn_filter { + uint8_t hig_pri; /**< 1 means higher pri than 2tuple, 5tupe, + and flex filter, 0 means lower pri. */ +}; + +/** + * A structure used to define a 2tuple filter. + */ +struct rte_2tuple_filter { + uint16_t dst_port; /**< big endian. */ + uint8_t protocol; + uint8_t tcp_flags; + uint16_t priority; /**< used when more than one filter matches. */ + uint8_t dst_port_mask:1, /**< if mask is 1b, means not compare. */ + protocol_mask:1; +}; + +/** + * A structure used to define a flex filter. + */ +struct rte_flex_filter { + uint16_t len; + uint32_t dwords[32]; /**< flex bytes in big endian. */ + uint8_t mask[16]; /**< if mask bit is 1b, do not compare + corresponding byte in dwords. */ + uint8_t priority; +}; + +/** + * A structure used to define a 5tuple filter. + */ +struct rte_5tuple_filter { + uint32_t dst_ip; /**< destination IP address in big endian. */ + uint32_t src_ip; /**< source IP address in big endian. */ + uint16_t dst_port; /**< destination port in big endian. */ + uint16_t src_port; /**< source Port big endian. */ + uint8_t protocol; /**< l4 protocol. */ + uint8_t tcp_flags; /**< tcp flags. */ + uint16_t priority; /**< seven evels (001b-111b), 111b is highest, + used when more than one filter matches. */ + uint8_t dst_ip_mask:1, /**< if mask is 1b, do not compare dst ip. */ + src_ip_mask:1, /**< if mask is 1b, do not compare src ip. */ + dst_port_mask:1, /**< if mask is 1b, do not compare dst port. */ + src_port_mask:1, /**< if mask is 1b, do not compare src port. */ + protocol_mask:1; /**< if mask is 1b, do not compare protocol. */ +}; + /* * Definitions of all functions exported by an Ethernet driver through the * the generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev* @@ -1114,6 +1181,72 @@ typedef int32_t (*bypass_ver_show_t)(struct rte_eth_dev *dev, uint32_t *ver); typedef int32_t (*bypass_wd_reset_t)(struct rte_eth_dev *dev); #endif +typedef int (*eth_add_syn_filter_t)(struct rte_eth_dev *dev, + struct rte_syn_filter *filter, uint16_t rx_queue); +/**< @internal add syn filter rule on an Ethernet device */ + +typedef int (*eth_remove_syn_filter_t)(struct rte_eth_dev *dev); +/**< @internal remove syn filter rule on an Ethernet device */ + +typedef int (*eth_get_syn_filter_t)(struct rte_eth_dev *dev, + struct rte_syn_filter *filter, uint16_t *rx_queue); +/**< @internal Get syn filter rule on an Ethernet device */ + +typedef int (*eth_add_ethertype_filter_t)(struct rte_eth_dev *dev, + uint16_t index, struct rte_ethertype_filter *filter, + uint16_t rx_queue); +/**< @internal Setup a new ethertype filter rule on an Ethernet device */ + +typedef int (*eth_remove_ethertype_filter_t)(struct rte_eth_dev *dev, + uint16_t index); +/**< @internal Remove an ethertype filter rule on an Ethernet device */ + +typedef int (*eth_get_ethertype_filter_t)(struct rte_eth_dev *dev, + uint16_t index, struct rte_ethertype_filter *filter, + uint16_t *rx_queue); +/**< @internal Get an ethertype filter rule on an Ethernet device */ + +typedef int (*eth_add_2tuple_filter_t)(struct rte_eth_dev *dev, + uint16_t index, struct rte_2tuple_filter *filter, + uint16_t rx_queue); +/**< @internal Setup a new 2tuple filter rule on an Ethernet device */ + +typedef int (*eth_remove_2tuple_filter_t)(struct rte_eth_dev *dev, + uint16_t index); +/**< @internal Remove a 2tuple filter rule on an Ethernet device */ + +typedef int (*eth_get_2tuple_filter_t)(struct rte_eth_dev *dev, + uint16_t index, struct rte_2tuple_filter *filter, + uint16_t *rx_queue); +/**< @internal Get a 2tuple filter rule on an Ethernet device */ + +typedef int (*eth_add_5tuple_filter_t)(struct rte_eth_dev *dev, + uint16_t index, struct rte_5tuple_filter *filter, + uint16_t rx_queue); +/**< @internal Setup a new 5tuple filter rule on an Ethernet device */ + +typedef int (*eth_remove_5tuple_filter_t)(struct rte_eth_dev *dev, + uint16_t index); +/**< @internal Remove a 5tuple filter rule on an Ethernet device */ + +typedef int (*eth_get_5tuple_filter_t)(struct rte_eth_dev *dev, + uint16_t index, struct rte_5tuple_filter *filter, + uint16_t *rx_queue); +/**< @internal Get a 5tuple filter rule on an Ethernet device */ + +typedef int (*eth_add_flex_filter_t)(struct rte_eth_dev *dev, + uint16_t index, struct rte_flex_filter *filter, + uint16_t rx_queue); +/**< @internal Setup a new flex filter rule on an Ethernet device */ + +typedef int (*eth_remove_flex_filter_t)(struct rte_eth_dev *dev, + uint16_t index); +/**< @internal Remove a flex filter rule on an Ethernet device */ + +typedef int (*eth_get_flex_filter_t)(struct rte_eth_dev *dev, + uint16_t index, struct rte_flex_filter *filter, + uint16_t *rx_queue); +/**< @internal Get a flex filter rule on an Ethernet device */ /** * @internal A structure containing the functions exported by an Ethernet driver. @@ -1203,6 +1336,21 @@ struct eth_dev_ops { rss_hash_update_t rss_hash_update; /** Get current RSS hash configuration. */ rss_hash_conf_get_t rss_hash_conf_get; + eth_add_syn_filter_t add_syn_filter; /**< add syn filter. */ + eth_remove_syn_filter_t remove_syn_filter; /**< remove syn filter. */ + eth_get_syn_filter_t get_syn_filter; /**< get syn filter. */ + eth_add_ethertype_filter_t add_ethertype_filter; /**< add ethertype filter. */ + eth_remove_ethertype_filter_t remove_ethertype_filter; /**< remove ethertype filter. */ + eth_get_ethertype_filter_t get_ethertype_filter; /**< get ethertype filter. */ + eth_add_2tuple_filter_t add_2tuple_filter; /**< add 2tuple filter. */ + eth_remove_2tuple_filter_t remove_2tuple_filter; /**< remove 2tuple filter. */ + eth_get_2tuple_filter_t get_2tuple_filter; /**< get 2tuple filter. */ + eth_add_5tuple_filter_t add_5tuple_filter; /**< add 5tuple filter. */ + eth_remove_5tuple_filter_t remove_5tuple_filter; /**< remove 5tuple filter. */ + eth_get_5tuple_filter_t get_5tuple_filter; /**< get 5tuple filter. */ + 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. */ }; /** @@ -2937,6 +3085,286 @@ int rte_eth_dev_rss_hash_conf_get(uint8_t port_id, struct rte_eth_rss_conf *rss_conf); +/** + * add syn filter + * + * @param port_id + * The port identifier of the Ethernet device. + * @param rx_queue + * The index of RX queue where to store RX packets matching the syn filter. + * @param filter + * The pointer to the structure describing the syn filter rule. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support. + * - (-EINVAL) if bad parameter. + */ +int rte_eth_dev_add_syn_filter(uint8_t port_id, + struct rte_syn_filter *filter, uint16_t rx_queue); + +/** + * remove syn filter + * + * @param port_id + * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support. + * - (-EINVAL) if bad parameter. + */ +int rte_eth_dev_remove_syn_filter(uint8_t port_id); + +/** + * get syn filter + * + * @param port_id + * The port identifier of the Ethernet device. + * @param filter + * The pointer to the structure describing the syn filter. + * @param rx_queue + * the point of a int type to get the queue of syn filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support. + * - (-EINVAL) if bad parameter. + */ +int rte_eth_dev_get_syn_filter(uint8_t port_id, + struct rte_syn_filter *filter, uint16_t *rx_queue); + +/** + * Add a new ethertype filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of ethertype filter. + * @param filter + * The pointer to the structure describing the ethertype filter rule. + * The *rte_ethertype_filter* structure includes the values of the different + * fields to match: ethertype and priority in vlan tag. + * priority in vlan tag is not supported for E1000 dev. + * @param rx_queue + * The index of the RX queue where to store RX packets matching the added + * ethertype filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support ethertype filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + */ +int rte_eth_dev_add_ethertype_filter(uint8_t port_id, uint16_t index, + struct rte_ethertype_filter *filter, uint16_t rx_queue); +/** + * remove an ethertype filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of ethertype filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support ethertype filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + */ +int rte_eth_dev_remove_ethertype_filter(uint8_t port_id, + uint16_t index); + +/** + * Get an ethertype filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of ethertype filter. + * @param filter + * A pointer to a structure of type *rte_ethertype_filter* to be filled with + * the information of the Ethertype filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support ethertype filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + * - (-ENOENT) if no enabled filter in this index. + */ + +int rte_eth_dev_get_ethertype_filter(uint8_t port_id, uint16_t index, + struct rte_ethertype_filter *filter, uint16_t *rx_queue); +/** + * Add a new 2tuple filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of 2tuple filter. + * @param filter + * The pointer to the structure describing the 2tuple filter rule. + * The *rte_2tuple_filter* structure includes the values of the different + * fields to match: protocol, dst_port and + * tcp_flags if the protocol is tcp type. + * @param rx_queue + * The index of the RX queue where to store RX packets matching the added + * 2tuple filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support 2tuple filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + */ + +int rte_eth_dev_add_2tuple_filter(uint8_t port_id, uint16_t index, + struct rte_2tuple_filter *filter, uint16_t rx_queue); +/** + * remove a 2tuple filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of 2tuple filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support 2tuple filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + */ +int rte_eth_dev_remove_2tuple_filter(uint8_t port_id, uint16_t index); + +/** + * Get an 2tuple filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of 2tuple filter. + * @param filter + * A pointer to a structure of type *rte_2tuple_filter* to be filled with + * the information of the 2tuple filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support 2tuple filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + * - (-ENOENT) if no enabled filter in this index. + */ +int rte_eth_dev_get_2tuple_filter(uint8_t port_id, uint16_t index, + struct rte_2tuple_filter *filter, uint16_t *rx_queue); + +/** + * Add a new 5tuple filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of 5tuple filter. + * @param filter + * The pointer to the structure describing the 5tuple filter rule. + * The *rte_5tuple_filter* structure includes the values of the different + * fields to match: dst src IP, dst src port, protocol and relative masks + * @param rx_queue + * The index of the RX queue where to store RX packets matching the added + * 5tuple filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support 5tuple filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + */ +int rte_eth_dev_add_5tuple_filter(uint8_t port_id, uint16_t index, + struct rte_5tuple_filter *filter, uint16_t rx_queue); + +/** + * remove a 5tuple filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of 5tuple filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support 5tuple filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + */ +int rte_eth_dev_remove_5tuple_filter(uint8_t port_id, uint16_t index); + +/** + * Get an 5tuple filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of 5tuple filter. + * @param filter + * A pointer to a structure of type *rte_5tuple_filter* to be filled with + * the information of the 5tuple filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support 5tuple filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + */ +int rte_eth_dev_get_5tuple_filter(uint8_t port_id, uint16_t index, + struct rte_5tuple_filter *filter, uint16_t *rx_queue); + +/** + * Add a new flex filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of flex filter. + * @param filter + * The pointer to the structure describing the flex filter rule. + * The *rte_flex_filter* structure includes the values of the different fields + * to match: the dwords (first len bytes of packet ) and relative masks. + * @param rx_queue + * The index of the RX queue where to store RX packets matching the added + * flex filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support flex filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + * - (-ENOENT) if no enabled filter in this index. + */ +int rte_eth_dev_add_flex_filter(uint8_t port_id, uint16_t index, + struct rte_flex_filter *filter, uint16_t rx_queue); +/** + * remove a flex filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of flex filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support flex filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + */ +int rte_eth_dev_remove_flex_filter(uint8_t port_id, uint16_t index); + +/** + * Get an flex filter rule on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param index + * The identifier of flex filter. + * @param filter + * A pointer to a structure of type *rte_flex_filter* to be filled with + * the information of the flex filter. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support flex filter. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if the filter information is not correct. + * - (-ENOENT) if no enabled filter in this index. + */ + +int rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index, + struct rte_flex_filter *filter, uint16_t *rx_queue); + #ifdef __cplusplus } #endif -- 1.8.1.4