[dpdk-dev,v5,4/8] librte_ether:add a common filter API

Message ID 1413006935-22535-5-git-send-email-jijiang.liu@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Jijiang Liu Oct. 11, 2014, 5:55 a.m. UTC
  Introduce a new filter framewok in librte_ether. As to the implemetation discussion, please refer to
http://dpdk.org/ml/archives/dev/2014-September/005179.html, and VxLAN tunnel filter implementation is based on
it.
 
Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>

---
 lib/librte_ether/Makefile       |    1 +
 lib/librte_ether/rte_eth_ctrl.h |  152 +++++++++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.c   |   32 ++++++++
 lib/librte_ether/rte_ethdev.h   |   56 +++++++++++---
 4 files changed, 229 insertions(+), 12 deletions(-)
 create mode 100644 lib/librte_ether/rte_eth_ctrl.h
  

Comments

De Lara Guarch, Pablo Oct. 15, 2014, 4:01 p.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jijiang Liu
> Sent: Saturday, October 11, 2014 6:56 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v5 4/8]librte_ether:add a common filter API
> 
> Introduce a new filter framewok in librte_ether. As to the implemetation
> discussion, please refer to
> http://dpdk.org/ml/archives/dev/2014-September/005179.html, and VxLAN
> tunnel filter implementation is based on
> it.
> 
> Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
> Acked-by: Helin Zhang <helin.zhang@intel.com>
> Acked-by: Jingjing Wu <jingjing.wu@intel.com>
> 
> ---
>  lib/librte_ether/Makefile       |    1 +
>  lib/librte_ether/rte_eth_ctrl.h |  152
> +++++++++++++++++++++++++++++++++++++++
>  lib/librte_ether/rte_ethdev.c   |   32 ++++++++
>  lib/librte_ether/rte_ethdev.h   |   56 +++++++++++---
>  4 files changed, 229 insertions(+), 12 deletions(-)
>  create mode 100644 lib/librte_ether/rte_eth_ctrl.h
> 
[...]
> +++ b/lib/librte_ether/rte_eth_ctrl.h

[...]

> +/**
> + * Tunnel Packet filter configuration.
> + */
> +struct rte_eth_tunnel_filter_conf {
> +	struct ether_addr *outer_mac;  /**< Outer MAC address fiter. */
> +	struct ether_addr *inner_mac;  /**< Inner MAC address fiter. */
> +	uint16_t inner_vlan;           /**< Inner VLAN fiter. */
> +	enum rte_tunnel_iptype ip_type; /**< IP address type. */
> +	union {
> +		uint32_t ipv4_addr;    /**< IPv4 source address to match. */
> +		uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
> +	} ip_addr; /**< IPv4/IPv6 source address to match (union of above).
> */
> +
> +	uint8_t filter_type;           /**< Filter type. */

This should be enum rte_tunnel_filter_type filter_type, and not uint8_t filter_type.

> +	uint8_t to_queue;       /**< Use MAC and VLAN to point to a queue.
> */
> +	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
> +	uint32_t tenant_id;            /** < Tenant number. */
> +	uint16_t queue_id;             /** < queue number. */
> +};
> +
[...]
  
Jijiang Liu Oct. 16, 2014, 1:24 a.m. UTC | #2
> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Thursday, October 16, 2014 12:01 AM
> To: Liu, Jijiang; dev@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH v5 4/8]librte_ether:add a common filter API
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jijiang Liu
> > Sent: Saturday, October 11, 2014 6:56 AM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH v5 4/8]librte_ether:add a common filter API
> >
> > Introduce a new filter framewok in librte_ether. As to the
> > implemetation discussion, please refer to
> > http://dpdk.org/ml/archives/dev/2014-September/005179.html, and VxLAN
> > tunnel filter implementation is based on it.
> >
> > Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
> > Acked-by: Helin Zhang <helin.zhang@intel.com>
> > Acked-by: Jingjing Wu <jingjing.wu@intel.com>
> >
> > ---
> >  lib/librte_ether/Makefile       |    1 +
> >  lib/librte_ether/rte_eth_ctrl.h |  152
> > +++++++++++++++++++++++++++++++++++++++
> >  lib/librte_ether/rte_ethdev.c   |   32 ++++++++
> >  lib/librte_ether/rte_ethdev.h   |   56 +++++++++++---
> >  4 files changed, 229 insertions(+), 12 deletions(-)  create mode
> > 100644 lib/librte_ether/rte_eth_ctrl.h
> >
> [...]
> > +++ b/lib/librte_ether/rte_eth_ctrl.h
> 
> [...]
> 
> > +/**
> > + * Tunnel Packet filter configuration.
> > + */
> > +struct rte_eth_tunnel_filter_conf {
> > +	struct ether_addr *outer_mac;  /**< Outer MAC address fiter. */
> > +	struct ether_addr *inner_mac;  /**< Inner MAC address fiter. */
> > +	uint16_t inner_vlan;           /**< Inner VLAN fiter. */
> > +	enum rte_tunnel_iptype ip_type; /**< IP address type. */
> > +	union {
> > +		uint32_t ipv4_addr;    /**< IPv4 source address to match. */
> > +		uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
> > +	} ip_addr; /**< IPv4/IPv6 source address to match (union of above).
> > */
> > +
> > +	uint8_t filter_type;           /**< Filter type. */
> 
> This should be enum rte_tunnel_filter_type filter_type, and not uint8_t
> filter_type.

I will fix this.

> > +	uint8_t to_queue;       /**< Use MAC and VLAN to point to a queue.
> > */
> > +	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
> > +	uint32_t tenant_id;            /** < Tenant number. */
> > +	uint16_t queue_id;             /** < queue number. */
> > +};
> > +
> [...]
  
De Lara Guarch, Pablo Oct. 16, 2014, 12:41 p.m. UTC | #3
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jijiang Liu
> Sent: Saturday, October 11, 2014 6:56 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v5 4/8]librte_ether:add a common filter API
> 
> Introduce a new filter framewok in librte_ether. As to the implemetation
> discussion, please refer to
> http://dpdk.org/ml/archives/dev/2014-September/005179.html, and VxLAN
> tunnel filter implementation is based on
> it.
> 
> Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
> Acked-by: Helin Zhang <helin.zhang@intel.com>
> Acked-by: Jingjing Wu <jingjing.wu@intel.com>
> 
[..]

> new file mode 100644
> index 0000000..574e9ff
> --- /dev/null
> +++ b/lib/librte_ether/rte_eth_ctrl.h

[...]
> +/**
> + * All generic operations to filters
> + */
> +enum rte_filter_op {
> +	/**< used to check whether the type filter is supported */

Shouldn't be this comment below?

> +	RTE_ETH_FILTER_OP_NONE = 0,
> +	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_GET,      /**< get filter entry */
> +	RTE_ETH_FILTER_OP_SET,      /**< configurations */
> +	/**< get information of filter, such as status or statistics */

Same here

> +	RTE_ETH_FILTER_OP_GET_INFO,
> +	RTE_ETH_FILTER_OP_MAX,
> +};
> +
  
Thomas Monjalon Oct. 16, 2014, 8:09 p.m. UTC | #4
I don't review the common API as it should be done in an unique place
and there are many copies in different patchsets. Let's focus on tunnels.

2014-10-11 13:55, Jijiang Liu:
> +/**** TUNNEL FILTER DATA DEFINATION *** */

We cannot miss this comment :)

> +#define ETH_TUNNEL_FILTER_OMAC  0x01
> +#define ETH_TUNNEL_FILTER_OIP   0x02
> +#define ETH_TUNNEL_FILTER_TENID 0x04
> +#define ETH_TUNNEL_FILTER_IMAC  0x08
> +#define ETH_TUNNEL_FILTER_IVLAN 0x10
> +#define ETH_TUNNEL_FILTER_IIP   0x20
> +
> +#define RTE_TUNNEL_FLAGS_TO_QUEUE 1

These values requires some comments.

> +/*
> + * Tunneled filter type
> + */
> +enum rte_tunnel_filter_type {
> +	RTE_TUNNEL_FILTER_TYPE_NONE = 0,
> +	RTE_TUNNEL_FILTER_OIP = ETH_TUNNEL_FILTER_OIP,
> +	RTE_TUNNEL_FILTER_IMAC_IVLAN =
> +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN,
> +	RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID =
> +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN |
> +		ETH_TUNNEL_FILTER_TENID,
> +	RTE_TUNNEL_FILTER_IMAC_TENID =
> +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_TENID,
> +	RTE_TUNNEL_FILTER_IMAC = ETH_TUNNEL_FILTER_IMAC,
> +	RTE_TUNNEL_FILTER_OMAC_TENID_IMAC =
> +		ETH_TUNNEL_FILTER_OMAC | ETH_TUNNEL_FILTER_TENID |
> +		ETH_TUNNEL_FILTER_IMAC,
> +	RTE_TUNNEL_FILTER_IIP = ETH_TUNNEL_FILTER_IIP,
> +	RTE_TUNNEL_FILTER_TYPE_MAX,
> +};

It's absolutely impossible to understand. Keep in mind the first goal of an
API: be used (which imply to be understood by users).
And I really don't understand why you define values for combination of
previous flags. Please, keep it simple.
  
Jijiang Liu Oct. 17, 2014, 6:53 a.m. UTC | #5
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Friday, October 17, 2014 4:10 AM
> To: Liu, Jijiang
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v5 4/8]librte_ether:add a common filter API
> 
> I don't review the common API as it should be done in an unique place and
> there are many copies in different patchsets. Let's focus on tunnels.
> 
> 2014-10-11 13:55, Jijiang Liu:
> > +/**** TUNNEL FILTER DATA DEFINATION *** */
> 
> We cannot miss this comment :)
> 
> > +#define ETH_TUNNEL_FILTER_OMAC  0x01
> > +#define ETH_TUNNEL_FILTER_OIP   0x02
> > +#define ETH_TUNNEL_FILTER_TENID 0x04
> > +#define ETH_TUNNEL_FILTER_IMAC  0x08
> > +#define ETH_TUNNEL_FILTER_IVLAN 0x10
> > +#define ETH_TUNNEL_FILTER_IIP   0x20
> > +
> > +#define RTE_TUNNEL_FLAGS_TO_QUEUE 1
> 
> These values requires some comments.
OK, add comments for these MACROs
> > +/*
> > + * Tunneled filter type
> > + */
> > +enum rte_tunnel_filter_type {
> > +	RTE_TUNNEL_FILTER_TYPE_NONE = 0,
> > +	RTE_TUNNEL_FILTER_OIP = ETH_TUNNEL_FILTER_OIP,
> > +	RTE_TUNNEL_FILTER_IMAC_IVLAN =
> > +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN,
> > +	RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID =
> > +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN |
> > +		ETH_TUNNEL_FILTER_TENID,
> > +	RTE_TUNNEL_FILTER_IMAC_TENID =
> > +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_TENID,
> > +	RTE_TUNNEL_FILTER_IMAC = ETH_TUNNEL_FILTER_IMAC,
> > +	RTE_TUNNEL_FILTER_OMAC_TENID_IMAC =
> > +		ETH_TUNNEL_FILTER_OMAC | ETH_TUNNEL_FILTER_TENID |
> > +		ETH_TUNNEL_FILTER_IMAC,
> > +	RTE_TUNNEL_FILTER_IIP = ETH_TUNNEL_FILTER_IIP,
> > +	RTE_TUNNEL_FILTER_TYPE_MAX,
> > +};
> 
> It's absolutely impossible to understand. Keep in mind the first goal of an
> API: be used (which imply to be understood by users).
> And I really don't understand why you define values for combination of
> previous flags. Please, keep it simple.

The goal of defining values for combination of filter type in order to easily distinguish/check if the mandatory parameters are valid for a specific filter type,
for example, if the filter type is RTE_TUNNEL_FILTER_IMAC_IVLAN,  we just need to check if the inner MAC address and inner VLAN ID are valid.
To limit sanity checks to valid parameters the rte_tunnel_filter_type enumeration can be replaced/initialized by bit mask.

Furthermore, please look at i40e_tunnel_filter_param_check () function in "[PATCH v5 5/8]i40e:implement API of VxLAN packet filter in librte_pmd_i40e" patch.
static int
+i40e_tunnel_filter_param_check(struct i40e_pf *pf,
+			struct rte_eth_tunnel_filter_conf *filter) {
+    ...

+	if ((filter->filter_type & ETH_TUNNEL_FILTER_OMAC) &&
+		(is_zero_ether_addr(filter->outer_mac))) {
+		PMD_DRV_LOG(ERR, "Cannot add NULL outer MAC address\n");
+		return -EINVAL;
+	}
+
+	if ((filter->filter_type & ETH_TUNNEL_FILTER_IMAC) &&
+		(is_zero_ether_addr(filter->inner_mac))) {
+		PMD_DRV_LOG(ERR, "Cannot add NULL inner MAC address\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}

Actually, If you really don't like rte_tunnel_filter_type definition style, and I can change it.

 
> --
> Thomas
  
Thomas Monjalon Oct. 17, 2014, 7:47 a.m. UTC | #6
2014-10-17 06:53, Liu, Jijiang:
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > 2014-10-11 13:55, Jijiang Liu:
> > > +#define ETH_TUNNEL_FILTER_OMAC  0x01
> > > +#define ETH_TUNNEL_FILTER_OIP   0x02
> > > +#define ETH_TUNNEL_FILTER_TENID 0x04
> > > +#define ETH_TUNNEL_FILTER_IMAC  0x08
> > > +#define ETH_TUNNEL_FILTER_IVLAN 0x10
> > > +#define ETH_TUNNEL_FILTER_IIP   0x20
> > > +
> > > +#define RTE_TUNNEL_FLAGS_TO_QUEUE 1
> > 
> > These values requires some comments.
> OK, add comments for these MACROs
> > > +/*
> > > + * Tunneled filter type
> > > + */
> > > +enum rte_tunnel_filter_type {
> > > +	RTE_TUNNEL_FILTER_TYPE_NONE = 0,
> > > +	RTE_TUNNEL_FILTER_OIP = ETH_TUNNEL_FILTER_OIP,
> > > +	RTE_TUNNEL_FILTER_IMAC_IVLAN =
> > > +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN,
> > > +	RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID =
> > > +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN |
> > > +		ETH_TUNNEL_FILTER_TENID,
> > > +	RTE_TUNNEL_FILTER_IMAC_TENID =
> > > +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_TENID,
> > > +	RTE_TUNNEL_FILTER_IMAC = ETH_TUNNEL_FILTER_IMAC,
> > > +	RTE_TUNNEL_FILTER_OMAC_TENID_IMAC =
> > > +		ETH_TUNNEL_FILTER_OMAC | ETH_TUNNEL_FILTER_TENID |
> > > +		ETH_TUNNEL_FILTER_IMAC,
> > > +	RTE_TUNNEL_FILTER_IIP = ETH_TUNNEL_FILTER_IIP,
> > > +	RTE_TUNNEL_FILTER_TYPE_MAX,
> > > +};
> > 
> > It's absolutely impossible to understand. Keep in mind the first goal of an
> > API: be used (which imply to be understood by users).
> > And I really don't understand why you define values for combination of
> > previous flags. Please, keep it simple.
> 
> The goal of defining values for combination of filter type in order to
> easily distinguish/check if the mandatory parameters are valid for a
> specific filter type, for example, if the filter type is
> RTE_TUNNEL_FILTER_IMAC_IVLAN,  we just need to check if the inner MAC
> address and inner VLAN ID are valid.
> To limit sanity checks to valid parameters the rte_tunnel_filter_type
> enumeration can be replaced/initialized by bit mask.
> 
> Furthermore, please look at i40e_tunnel_filter_param_check () function
> in "[PATCH v5 5/8]i40e:implement API of VxLAN packet filter in librte_pmd_i40e" patch.
> static int
> +i40e_tunnel_filter_param_check(struct i40e_pf *pf,
> +			struct rte_eth_tunnel_filter_conf *filter) {
> +    ...
> 
> +	if ((filter->filter_type & ETH_TUNNEL_FILTER_OMAC) &&
> +		(is_zero_ether_addr(filter->outer_mac))) {
> +		PMD_DRV_LOG(ERR, "Cannot add NULL outer MAC address\n");
> +		return -EINVAL;
> +	}
> +
> +	if ((filter->filter_type & ETH_TUNNEL_FILTER_IMAC) &&
> +		(is_zero_ether_addr(filter->inner_mac))) {
> +		PMD_DRV_LOG(ERR, "Cannot add NULL inner MAC address\n");
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> 
> Actually, If you really don't like rte_tunnel_filter_type definition style,
> and I can change it.

Yes, you can just  replace this "enum rte_tunnel_filter_type" by an integer
like uint16_t. It won't change your tests.
  
Jijiang Liu Oct. 20, 2014, 1:22 a.m. UTC | #7
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Friday, October 17, 2014 3:48 PM
> To: Liu, Jijiang
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v5 4/8]librte_ether:add a common filter API
> 
> 2014-10-17 06:53, Liu, Jijiang:
> > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > 2014-10-11 13:55, Jijiang Liu:
> > > > +#define ETH_TUNNEL_FILTER_OMAC  0x01
> > > > +#define ETH_TUNNEL_FILTER_OIP   0x02
> > > > +#define ETH_TUNNEL_FILTER_TENID 0x04 #define
> > > > +ETH_TUNNEL_FILTER_IMAC  0x08 #define ETH_TUNNEL_FILTER_IVLAN
> 0x10
> > > > +#define ETH_TUNNEL_FILTER_IIP   0x20
> > > > +
> > > > +#define RTE_TUNNEL_FLAGS_TO_QUEUE 1
> > >
> > > These values requires some comments.
> > OK, add comments for these MACROs
> > > > +/*
> > > > + * Tunneled filter type
> > > > + */
> > > > +enum rte_tunnel_filter_type {
> > > > +	RTE_TUNNEL_FILTER_TYPE_NONE = 0,
> > > > +	RTE_TUNNEL_FILTER_OIP = ETH_TUNNEL_FILTER_OIP,
> > > > +	RTE_TUNNEL_FILTER_IMAC_IVLAN =
> > > > +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN,
> > > > +	RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID =
> > > > +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN |
> > > > +		ETH_TUNNEL_FILTER_TENID,
> > > > +	RTE_TUNNEL_FILTER_IMAC_TENID =
> > > > +		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_TENID,
> > > > +	RTE_TUNNEL_FILTER_IMAC = ETH_TUNNEL_FILTER_IMAC,
> > > > +	RTE_TUNNEL_FILTER_OMAC_TENID_IMAC =
> > > > +		ETH_TUNNEL_FILTER_OMAC | ETH_TUNNEL_FILTER_TENID |
> > > > +		ETH_TUNNEL_FILTER_IMAC,
> > > > +	RTE_TUNNEL_FILTER_IIP = ETH_TUNNEL_FILTER_IIP,
> > > > +	RTE_TUNNEL_FILTER_TYPE_MAX,
> > > > +};
> > >
> > > It's absolutely impossible to understand. Keep in mind the first
> > > goal of an
> > > API: be used (which imply to be understood by users).
> > > And I really don't understand why you define values for combination
> > > of previous flags. Please, keep it simple.
> >
> > The goal of defining values for combination of filter type in order to
> > easily distinguish/check if the mandatory parameters are valid for a
> > specific filter type, for example, if the filter type is
> > RTE_TUNNEL_FILTER_IMAC_IVLAN,  we just need to check if the inner MAC
> > address and inner VLAN ID are valid.
> > To limit sanity checks to valid parameters the rte_tunnel_filter_type
> > enumeration can be replaced/initialized by bit mask.
> >
> > Furthermore, please look at i40e_tunnel_filter_param_check () function
> > in "[PATCH v5 5/8]i40e:implement API of VxLAN packet filter in
> librte_pmd_i40e" patch.
> > static int
> > +i40e_tunnel_filter_param_check(struct i40e_pf *pf,
> > +			struct rte_eth_tunnel_filter_conf *filter) {
> > +    ...
> >
> > +	if ((filter->filter_type & ETH_TUNNEL_FILTER_OMAC) &&
> > +		(is_zero_ether_addr(filter->outer_mac))) {
> > +		PMD_DRV_LOG(ERR, "Cannot add NULL outer MAC
> address\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	if ((filter->filter_type & ETH_TUNNEL_FILTER_IMAC) &&
> > +		(is_zero_ether_addr(filter->inner_mac))) {
> > +		PMD_DRV_LOG(ERR, "Cannot add NULL inner MAC
> address\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	return 0;
> > +}
> >
> > Actually, If you really don't like rte_tunnel_filter_type definition
> > style, and I can change it.
> 
> Yes, you can just  replace this "enum rte_tunnel_filter_type" by an integer
> like uint16_t. It won't change your tests.

Ok,thanks.
> --
> Thomas
  

Patch

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..574e9ff
--- /dev/null
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -0,0 +1,152 @@ 
+/*-
+ *   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_TUNNEL,
+	RTE_ETH_FILTER_MAX,
+};
+
+/**
+ * All generic operations to filters
+ */
+enum rte_filter_op {
+	/**< used to check whether the type filter is supported */
+	RTE_ETH_FILTER_OP_NONE = 0,
+	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_GET,      /**< get filter entry */
+	RTE_ETH_FILTER_OP_SET,      /**< configurations */
+	/**< get information of filter, such as status or statistics */
+	RTE_ETH_FILTER_OP_GET_INFO,
+	RTE_ETH_FILTER_OP_MAX,
+};
+
+/**** TUNNEL FILTER DATA DEFINATION *** */
+
+#define ETH_TUNNEL_FILTER_OMAC  0x01
+#define ETH_TUNNEL_FILTER_OIP   0x02
+#define ETH_TUNNEL_FILTER_TENID 0x04
+#define ETH_TUNNEL_FILTER_IMAC  0x08
+#define ETH_TUNNEL_FILTER_IVLAN 0x10
+#define ETH_TUNNEL_FILTER_IIP   0x20
+
+#define RTE_TUNNEL_FLAGS_TO_QUEUE 1
+
+/*
+ * Tunneled filter type
+ */
+enum rte_tunnel_filter_type {
+	RTE_TUNNEL_FILTER_TYPE_NONE = 0,
+	RTE_TUNNEL_FILTER_OIP = ETH_TUNNEL_FILTER_OIP,
+	RTE_TUNNEL_FILTER_IMAC_IVLAN =
+		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN,
+	RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID =
+		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN |
+		ETH_TUNNEL_FILTER_TENID,
+	RTE_TUNNEL_FILTER_IMAC_TENID =
+		ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_TENID,
+	RTE_TUNNEL_FILTER_IMAC = ETH_TUNNEL_FILTER_IMAC,
+	RTE_TUNNEL_FILTER_OMAC_TENID_IMAC =
+		ETH_TUNNEL_FILTER_OMAC | ETH_TUNNEL_FILTER_TENID |
+		ETH_TUNNEL_FILTER_IMAC,
+	RTE_TUNNEL_FILTER_IIP = ETH_TUNNEL_FILTER_IIP,
+	RTE_TUNNEL_FILTER_TYPE_MAX,
+};
+
+/**
+ *  Select IPv4 or IPv6 for tunnel filters.
+ */
+enum rte_tunnel_iptype {
+	RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
+	RTE_TUNNEL_IPTYPE_IPV6,     /**< IPv6. */
+};
+
+/**
+ * Tunneled type.
+ */
+enum rte_eth_tunnel_type {
+	RTE_TUNNEL_TYPE_NONE = 0,
+	RTE_TUNNEL_TYPE_VXLAN,
+	RTE_TUNNEL_TYPE_GENEVE,
+	RTE_TUNNEL_TYPE_TEREDO,
+	RTE_TUNNEL_TYPE_NVGRE,
+	RTE_TUNNEL_TYPE_MAX,
+};
+
+/**
+ * Tunnel Packet filter configuration.
+ */
+struct rte_eth_tunnel_filter_conf {
+	struct ether_addr *outer_mac;  /**< Outer MAC address fiter. */
+	struct ether_addr *inner_mac;  /**< Inner MAC address fiter. */
+	uint16_t inner_vlan;           /**< Inner VLAN fiter. */
+	enum rte_tunnel_iptype ip_type; /**< IP address type. */
+	union {
+		uint32_t ipv4_addr;    /**< IPv4 source address to match. */
+		uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
+	} ip_addr; /**< IPv4/IPv6 source address to match (union of above). */
+
+	uint8_t filter_type;           /**< Filter type. */
+	uint8_t to_queue;       /**< Use MAC and VLAN to point to a queue. */
+	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+	uint32_t tenant_id;            /** < Tenant number. */
+	uint16_t queue_id;             /** < queue number. */
+};
+
+#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 642d312..93f9f6f 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3202,3 +3202,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 3f84c23..68f4ab0 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -177,6 +177,7 @@  extern "C" {
 #include <rte_pci.h>
 #include <rte_mbuf.h>
 #include "rte_ether.h"
+#include "rte_eth_ctrl.h"
 
 /**
  * A structure used to retrieve statistics for an Ethernet port.
@@ -716,18 +717,6 @@  struct rte_eth_udp_tunnel {
 };
 
 /**
- * Tunneled type.
- */
-enum rte_eth_tunnel_type {
-	RTE_TUNNEL_TYPE_NONE = 0,
-	RTE_TUNNEL_TYPE_VXLAN,
-	RTE_TUNNEL_TYPE_GENEVE,
-	RTE_TUNNEL_TYPE_TEREDO,
-	RTE_TUNNEL_TYPE_NVGRE,
-	RTE_TUNNEL_TYPE_MAX,
-};
-
-/**
  *  Possible l4type of FDIR filters.
  */
 enum rte_l4type {
@@ -1415,6 +1404,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.
  */
@@ -1525,6 +1520,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*/
 };
 
 /**
@@ -3692,6 +3688,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