net/ixgbe: Consistent filter API
PATCH v6 17/18 net/ixgbe: destroy consistent filter
In reply to Wei ZhaoThis patch adds a function to destroy the flow fliter.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.h | 3 + drivers/net/ixgbe/ixgbe_flow.c | 117 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 120 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
@@ -7401,7 +7401,7 @@ ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev, }/* Delete l2 tunnel filter */ -static int +int ixgbe_dev_l2_tunnel_filter_del (struct rte_eth_dev *dev,struct rte_eth_l2_tunnel_conf *l2_tunnel) {
drivers/net/ixgbe/ixgbe_ethdev.h +3 -0
@@ -548,6 +548,9 @@ int ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel, bool restore); +int +ixgbe_dev_l2_tunnel_filter_del (struct rte_eth_dev *dev, +struct rte_eth_l2_tunnel_conf *l2_tunnel);/* * Flow director function prototypes */
drivers/net/ixgbe/ixgbe_flow.c +116 -1
133 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v6 18/18 net/ixgbe: flush all the filter list
In reply to Wei ZhaoThis patch adds a function to flush all the fliter list filter on a port.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +++ drivers/net/ixgbe/ixgbe_ethdev.h | 1 + drivers/net/ixgbe/ixgbe_flow.c | 56 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +3 -0
@@ -1341,6 +1341,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)/* Remove all ntuple filters of the device */ ixgbe_ntuple_filter_uninit (eth_dev); +/* clear all the filters list */ +ixgbe_filterlist_flush (); +return 0 ; }
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
@@ -551,6 +551,7 @@ ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,int ixgbe_dev_l2_tunnel_filter_del (struct rte_eth_dev *dev,struct rte_eth_l2_tunnel_conf *l2_tunnel); +void ixgbe_filterlist_flush (void );/* * Flow director function prototypes */
drivers/net/ixgbe/ixgbe_flow.c +56 -0
67 lines not on this page · raw message
Signature · 1 line
2.5.5
Quoted 8 lines · Wei Zhao
The patches mainly finish following functions:
1) Store and restore all kinds of filters.
2) Parse all kinds of filters.
3) Add flow validate function.
4) Add flow create function.
5) Add flow destroy function.
6) Add flow flush function.
<...>
Quoted 21 lines
zhao wei (18):
net/ixgbe: store TCP SYN filter
net/ixgbe: store flow director filter net/ixgbe: store L2 tunnel filter net/ixgbe: restore n-tuple filter net/ixgbe: restore ether type filter net/ixgbe: restore TCP SYN filter net/ixgbe: restore flow director filter net/ixgbe: restore L2 tunnel filter net/ixgbe: store and restore L2 tunnel configuration net/ixgbe: flush all the filters
net/ixgbe: parse n-tuple filter
net/ixgbe: parse ethertype filter net/ixgbe: parse TCP SYN filter
net/ixgbe: parse L2 tunnel filter net/ixgbe: parse flow director filter net/ixgbe: create consistent filter net/ixgbe: destroy consistent filter net/ixgbe: flush all the filter list
<...>
Quoted 4 lines
Acked-by Beilei Xing <[email protected]>Acked-by Wei Dai <[email protected]>
Series applied to dpdk-next-net/master, thanks.
Hi Ferruh,
Quoted 1 line
Series applied to dpdk-next-net/master, thanks.
Great, thanks for applying this patch set!
2017-01-13 15:54, Ferruh Yigit:
Quoted 21 lines · Wei Zhao
Quoted 11 lines
zhao wei (18):
net/ixgbe: store TCP SYN filter
net/ixgbe: store flow director filter net/ixgbe: store L2 tunnel filter net/ixgbe: restore n-tuple filter net/ixgbe: restore ether type filter net/ixgbe: restore TCP SYN filter net/ixgbe: restore flow director filter net/ixgbe: restore L2 tunnel filter net/ixgbe: store and restore L2 tunnel configuration net/ixgbe: flush all the filtersQuoted 9 lines
net/ixgbe: parse n-tuple filter
net/ixgbe: parse ethertype filter
net/ixgbe: parse TCP SYN filter
net/ixgbe: parse L2 tunnel filter
net/ixgbe: parse flow director filter
net/ixgbe: create consistent filter
net/ixgbe: destroy consistent filter
net/ixgbe: flush all the filter list
Quoted 7 lines
<...>
Quoted 4 lines
Acked-by Beilei Xing <[email protected]>Acked-by Wei Dai <[email protected]>Series applied to dpdk-next-net/master, thanks.
There is a build issue:
patch 2/18 uses rte_hash
which is linked to ixgbe only in patch 10/18.
I am fixing it in mainline.
PATCH v2 2/18 net/ixgbe: store flow director filter
In reply to Wei ZhaoAdd support for storing flow director filter in SW.
---
v2:
--add a fdir initialization function in device start process
--- drivers/net/ixgbe/ixgbe_ethdev.c | 55 ++++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 19 ++++++- drivers/net/ixgbe/ixgbe_fdir.c | 105 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 176 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +55 -0
@@ -60,6 +60,7 @@#include <rte_malloc.h> #include <rte_random.h> #include <rte_dev.h> +#include <rte_hash_crc.h> #include "ixgbe_logs.h" #include "base/ixgbe_api.h"
@@ -165,6 +166,7 @@ enum ixgbevf_xcast_modes {static int eth_ixgbe_dev_init (struct rte_eth_dev *eth_dev);static int eth_ixgbe_dev_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev);static int ixgbe_dev_configure (struct rte_eth_dev *dev);static int ixgbe_dev_start (struct rte_eth_dev *dev);static void ixgbe_dev_stop (struct rte_eth_dev *dev);
@@ -1276,6 +1278,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* initialize SYN filter */ filter_info->syn_info =0 ; +/* initialize flow director filter list & hash */ +ixgbe_fdir_filter_init (eth_dev); +return 0 ; }
@@ -1284,6 +1289,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev;struct ixgbe_hw *hw; +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); +struct ixgbe_fdir_filter *fdir_filter;PMD_INIT_FUNC_TRACE ();
@@ -1317,9 +1325,56 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)rte_free (eth_dev->data->hash_mac_addrs); eth_dev->data->hash_mac_addrs =NULL ; +/* remove all the fdir filters & hash */ +if (fdir_info->hash_map) +rte_free (fdir_info->hash_map); +if (fdir_info->hash_handle) +rte_hash_free (fdir_info->hash_handle); + +while ((fdir_filter =TAILQ_FIRST (&fdir_info->fdir_list))) { +TAILQ_REMOVE (&fdir_info->fdir_list, + fdir_filter, + entries); +rte_free (fdir_filter); + } +return 0 ; } +static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); +char fdir_hash_name[RTE_HASH_NAMESIZE ]; +struct rte_hash_parameters fdir_hash_params = { + .name = fdir_hash_name, + .entries =IXGBE_MAX_FDIR_FILTER_NUM , + .key_len =sizeof (union ixgbe_atr_input ), + .hash_func = rte_hash_crc, + .hash_func_init_val =0 , + .socket_id =rte_socket_id (), + }; + +TAILQ_INIT (&fdir_info->fdir_list); +snprintf (fdir_hash_name,RTE_HASH_NAMESIZE , +"fdir_%s" , eth_dev->data->name); + fdir_info->hash_handle =rte_hash_create (&fdir_hash_params); +if (!fdir_info->hash_handle) { +PMD_INIT_LOG (ERR ,"Failed to create fdir hash table!" ); +return -EINVAL ; + } + fdir_info->hash_map =rte_zmalloc ("ixgbe" , +sizeof (struct ixgbe_fdir_filter *) * +IXGBE_MAX_FDIR_FILTER_NUM , +0 ); +if (!fdir_info->hash_map) { +PMD_INIT_LOG (ERR , +"Failed to allocate memory for fdir hash map!" ); +return -ENOMEM ; + } + +return 0 ; +}/* * Negotiate mailbox API version with the PF. * After reset API version is always set to the basic one (ixgbe_mbox_api_10).
drivers/net/ixgbe/ixgbe_ethdev.h +18 -1
@@ -38,6 +38,7 @@#include "base/ixgbe_dcb_82598.h" #include "ixgbe_bypass.h" #include <rte_time.h> +#include <rte_hash.h> /* need update link, bit flag */ #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
@@ -130,10 +131,11 @@#define IXGBE_MISC_VEC_ID RTE_INTR_VEC_ZERO_OFFSET#define IXGBE_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET +#define IXGBE_MAX_FDIR_FILTER_NUM (1024 * 32) +/* * Information about the fdir mode. */ -struct ixgbe_hw_fdir_mask {uint16_t vlan_tci_mask;uint32_t src_ipv4_mask;
@@ -148,6 +150,17 @@ struct ixgbe_hw_fdir_mask {uint8_t tunnel_type_mask; }; +struct ixgbe_fdir_filter { +TAILQ_ENTRY (ixgbe_fdir_filter) entries; +union ixgbe_atr_input ixgbe_fdir;/* key of fdir filter*/ +uint32_t fdirflags;/* drop or forward */ +uint32_t fdirhash;/* hash value for fdir */ +uint8_t queue;/* assigned rx queue */ +}; + +/* list of fdir filters */ +TAILQ_HEAD (ixgbe_fdir_filter_list, ixgbe_fdir_filter); +struct ixgbe_hw_fdir_info {struct ixgbe_hw_fdir_mask mask;uint8_t flex_bytes_offset;
@@ -159,6 +172,10 @@ struct ixgbe_hw_fdir_info {uint64_t remove;uint64_t f_add;uint64_t f_remove; +struct ixgbe_fdir_filter_list fdir_list;/* filter list*/ +/* store the pointers of the filters, index is the hash value. */ +struct ixgbe_fdir_filter **hash_map; +struct rte_hash *hash_handle;/* cuckoo hash handler */ };/* structure for interrupt relative data */
drivers/net/ixgbe/ixgbe_fdir.c +103 -2
143 lines not on this page · raw message
Signature · 1 line
2.5.5
Re: [PATCH v2 02/18] net/ixgbe: store flow director filter
Quoted 17 lines
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhao1, Wei <[email protected]>
Subject: [dpdk-dev] [PATCH v2 02/18] net/ixgbe: store flow director filterAdd support for storing flow director filter in SW.
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--add a fdir initialization function in device start process
---
drivers/net/ixgbe/ixgbe_fdir.c fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash) · line 1083
Quoted 5 lines
drivers/net/ixgbe/ixgbe_fdir.c +5
-0+static inline struct ixgbe_fdir_filter * +ixgbe_fdir_filter_lookup (struct ixgbe_hw_fdir_info *fdir_info, +union ixgbe_atr_input *key) +{ +int ret =0 ;
Needless initialization here since ret will be set below.
drivers/net/ixgbe/ixgbe_fdir.c fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash) · line 1096
Quoted 11 lines
drivers/net/ixgbe/ixgbe_fdir.c +11
-0+ ret =rte_hash_lookup (fdir_info->hash_handle, (const void *)key); +if (ret <0 ) +return NULL ; + +return fdir_info->hash_map[ret]; +} + +static inline int +ixgbe_insert_fdir_filter (struct ixgbe_hw_fdir_info *fdir_info, +struct ixgbe_fdir_filter *fdir_filter) { +int ret =0 ;
Same above.
Quoted 13 lines
drivers/net/ixgbe/ixgbe_fdir.c +13
-0+ + ret =rte_hash_add_key (fdir_info->hash_handle, + &fdir_filter->ixgbe_fdir); + +if (ret <0 ) { +PMD_DRV_LOG (ERR , +"Failed to insert fdir filter to hash table %d!" , + ret); +return ret; + } + + fdir_info->hash_map[ret] = fdir_filter; +
drivers/net/ixgbe/ixgbe_fdir.c fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash) · line 1119
Quoted 10 lines
drivers/net/ixgbe/ixgbe_fdir.c +10
-0+TAILQ_INSERT_TAIL (&fdir_info->fdir_list, fdir_filter, entries); + +return 0 ; +} + +static inline int +ixgbe_remove_fdir_filter (struct ixgbe_hw_fdir_info *fdir_info, +union ixgbe_atr_input *key) +{ +int ret =0 ;
Same above.
Quoted 99 lines
drivers/net/ixgbe/ixgbe_fdir.c +18
-0+struct ixgbe_fdir_filter *fdir_filter; + + ret =rte_hash_del_key (fdir_info->hash_handle, key); + +if (ret <0 ) { +PMD_DRV_LOG (ERR ,"No such fdir filter to delete %d!" , ret); +return ret; + } + + fdir_filter = fdir_info->hash_map[ret]; + fdir_info->hash_map[ret] =NULL ; + +TAILQ_REMOVE (&fdir_info->fdir_list, fdir_filter, entries); +rte_free (fdir_filter); + +return 0 ; +} +/* * ixgbe_add_del_fdir_filter - add or remove a flow diretor filter. * @dev: pointer to the structure rte_eth_dev @@ -1098,6 +1158,8 @@ ixgbe_add_del_fdir_filter(struct
rte_eth_dev*dev,drivers/net/ixgbe/ixgbe_fdir.c +44
-2struct ixgbe_hw_fdir_info *info =IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data->dev_private);enum rte_fdir_mode fdir_mode = dev->data->dev_conf.fdir_conf.mode; +struct ixgbe_fdir_filter *node; +bool add_node = FALSE;if (fdir_mode ==RTE_FDIR_MODE_NONE )return -ENOTSUP ;@@ -1148,6 +1210,10 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev, dev->data->dev_conf.fdir_conf.pballoc);if (del) { + err =ixgbe_remove_fdir_filter (info, &input); +if (err <0 ) +return err; + err =fdir_erase_filter_82599 (hw, fdirhash);if (err <0 ) PMD_DRV_LOG(ERR, "Fail to delete FDIR filter!"); @@ -1172,6 +1238,37 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev, else return -EINVAL; + node = ixgbe_fdir_filter_lookup(info, &input); +if (node) { +if (update) { + node->fdirflags = fdircmd_flags; + node->fdirhash = fdirhash; + node->queue = queue; + }else { +PMD_DRV_LOG (ERR ,"Conflict with existing fdir filter!" ); +return -EINVAL ; + } + }else { + add_node = TRUE; + node =rte_zmalloc ("ixgbe_fdir" , +sizeof (struct ixgbe_fdir_filter ), +0 ); +if (!node) +return -ENOMEM ; + (void )rte_memcpy (&node->ixgbe_fdir, + &input, +sizeof (union ixgbe_atr_input )); + node->fdirflags = fdircmd_flags; + node->fdirhash = fdirhash; + node->queue = queue; + + err =ixgbe_insert_fdir_filter (info, node); +if (err <0 ) { +rte_free (node); +return err; + } + } +if (is_perfect) { err = fdir_write_perfect_filter_82599(hw, &input, queue, fdircmd_flags, fdirhash,@@ -1180,10 +1277,14 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev, err =fdir_add_signature_filter_82599 (hw, &input, queue, fdircmd_flags, fdirhash); } -if (err <0 ) +if (err <0 ) {PMD_DRV_LOG (ERR ,"Fail to add FDIR filter!" ); -else + +if (add_node) + (void )ixgbe_remove_fdir_filter (info, &input); + }else {PMD_DRV_LOG (DEBUG ,"Success to add FDIR filter" ); + }return err;}
--
2.5.5
Re: [PATCH v2 02/18] net/ixgbe: store flow director filter
Hi, beilei
Quoted 27 lines
-----Original Message-----
From: Xing, Beilei
Sent: Monday, January 2, 2017 5:59 PM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 02/18] net/ixgbe: store flow director filterQuoted 19 lines
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhao1, Wei <[email protected]>
Subject: [dpdk-dev] [PATCH v2 02/18] net/ixgbe: store flow director filterAdd support for storing flow director filter in SW.
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--add a fdir initialization function in device start process
---
Quoted 8 lines
drivers/net/ixgbe/ixgbe_fdir.c fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash) · line 1083
Quoted 5 lines
drivers/net/ixgbe/ixgbe_fdir.c +5
-0+static inline struct ixgbe_fdir_filter * +ixgbe_fdir_filter_lookup (struct ixgbe_hw_fdir_info *fdir_info, +union ixgbe_atr_input *key) +{ +int ret =0 ;Needless initialization here since ret will be set below.
Ok, I will make some change in v3
Quoted 31 lines
drivers/net/ixgbe/ixgbe_fdir.c fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash) · line 1096
Quoted 11 lines
drivers/net/ixgbe/ixgbe_fdir.c +11
-0+ ret =rte_hash_lookup (fdir_info->hash_handle, (const void *)key); +if (ret <0 ) +return NULL ; + +return fdir_info->hash_map[ret]; +} + +static inline int +ixgbe_insert_fdir_filter (struct ixgbe_hw_fdir_info *fdir_info, +struct ixgbe_fdir_filter *fdir_filter) { +int ret =0 ;Same above.
Quoted 17 lines
drivers/net/ixgbe/ixgbe_fdir.c +17
-0+ + ret =rte_hash_add_key (fdir_info->hash_handle, + &fdir_filter->ixgbe_fdir); + +if (ret <0 ) { +PMD_DRV_LOG (ERR , +"Failed to insert fdir filter to hash table %d!" , + ret); +return ret; + } + + fdir_info->hash_map[ret] = fdir_filter; + +TAILQ_INSERT_TAIL (&fdir_info->fdir_list, fdir_filter, entries); + +return 0 ; +}
Quoted 9 lines
drivers/net/ixgbe/ixgbe_fdir.c fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash) · line 1119
Quoted 6 lines
drivers/net/ixgbe/ixgbe_fdir.c +6
-0+ +static inline int +ixgbe_remove_fdir_filter (struct ixgbe_hw_fdir_info *fdir_info, +union ixgbe_atr_input *key) +{ +int ret =0 ;Same above.
Ok, I will make some change in v3
Quoted 105 lines
drivers/net/ixgbe/ixgbe_fdir.c ixgbe_add_del_fdir_filter(struct rte_eth_dev
Quoted 33 lines
drivers/net/ixgbe/ixgbe_fdir.c +18
-0+struct ixgbe_fdir_filter *fdir_filter; + + ret =rte_hash_del_key (fdir_info->hash_handle, key); + +if (ret <0 ) { +PMD_DRV_LOG (ERR ,"No such fdir filter to delete %d!" , ret); +return ret; + } + + fdir_filter = fdir_info->hash_map[ret]; + fdir_info->hash_map[ret] =NULL ; + +TAILQ_REMOVE (&fdir_info->fdir_list, fdir_filter, entries); +rte_free (fdir_filter); + +return 0 ; +} +/* * ixgbe_add_del_fdir_filter - add or remove a flow diretor filter. * @dev: pointer to the structure rte_eth_dev @@ -1098,6 +1158,8 @@ ixgbe_add_del_fdir_filter(struct
rte_eth_dev*dev,(quoted diff) +0
-0struct ixgbe_hw_fdir_info *info = IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data-
dev_private);
enumrte_fdir_modefdir_mode= dev->data-
dev_conf.fdir_conf.mode;drivers/net/ixgbe/ixgbe_fdir.c +2
-0+struct ixgbe_fdir_filter *node; +bool add_node = FALSE;if (fdir_mode ==RTE_FDIR_MODE_NONE )return -ENOTSUP ;@@ -1148,6 +1210,10 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev*dev,
Quoted 11 lines
drivers/net/ixgbe/ixgbe_fdir.c +4
-0dev->data- dev_conf.fdir_conf.pballoc);if (del) { + err =ixgbe_remove_fdir_filter (info, &input); +if (err <0 ) +return err; + err =fdir_erase_filter_82599 (hw, fdirhash);if (err <0 )
PMD_DRV_LOG(ERR, "Fail to delete FDIR filter!");@@ -1172,6
drivers/net/ixgbe/ixgbe_fdir.c ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,
Quoted 12 lines
+1238,37 @@ ixgbe_add_del_fdir_filter(struct
rte_eth_dev*dev,drivers/net/ixgbe/ixgbe_fdir.c +8
-0else return -EINVAL ; + node =ixgbe_fdir_filter_lookup (info, &input); +if (node) { +if (update) { + node->fdirflags = fdircmd_flags; + node->fdirhash = fdirhash; + node->queue = queue; + }else { + PMD_DRV_LOG(ERR, "Conflict with existing fdirfilter!");
Quoted 46 lines
drivers/net/ixgbe/ixgbe_fdir.c +29
-2+return -EINVAL ; + } + }else { + add_node = TRUE; + node =rte_zmalloc ("ixgbe_fdir" , +sizeof (struct ixgbe_fdir_filter ), +0 ); +if (!node) +return -ENOMEM ; + (void )rte_memcpy (&node->ixgbe_fdir, + &input, +sizeof (union ixgbe_atr_input )); + node->fdirflags = fdircmd_flags; + node->fdirhash = fdirhash; + node->queue = queue; + + err =ixgbe_insert_fdir_filter (info, node); +if (err <0 ) { +rte_free (node); +return err; + } + } +if (is_perfect) { err = fdir_write_perfect_filter_82599(hw, &input, queue, fdircmd_flags, fdirhash,@@ -1180,10 +1277,14 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev, err =fdir_add_signature_filter_82599 (hw, &input, queue, fdircmd_flags, fdirhash); } -if (err <0 ) +if (err <0 ) {PMD_DRV_LOG (ERR ,"Fail to add FDIR filter!" ); -else + +if (add_node) + (void )ixgbe_remove_fdir_filter (info, &input); + }else {PMD_DRV_LOG (DEBUG ,"Success to add FDIR filter" ); + }return err;}
--
2.5.5
Re: [PATCH v2 02/18] net/ixgbe: store flow director filter
In reply to Wei ZhaoHi, Wei Zhao
Would you please do git rebase master for this patch set?
When I do git pull and then git apply this patch, following errors are reported:
[root@dpdk4 dpdk-org]# git am ../patches/bundle-488-zhaowei-ixgbe-filter-api-v2.mbox
Applying: net/ixgbe: store SYN filter
Applying: net/ixgbe: store flow director filter
error: patch failed: drivers/net/ixgbe/ixgbe_ethdev.c:1284
error: drivers/net/ixgbe/ixgbe_ethdev.c: patch does not apply Patch failed at 0002 net/ixgbe: store flow director filter The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
Quoted 332 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhao1, Wei <[email protected]>
Subject: [dpdk-dev] [PATCH v2 02/18] net/ixgbe: store flow director filterAdd support for storing flow director filter in SW.
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--add a fdir initialization function in device start process--- drivers/net/ixgbe/ixgbe_ethdev.c | 55 ++++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 19 ++++++- drivers/net/ixgbe/ixgbe_fdir.c | 105 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 176 insertions(+), 3 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +2
-0@@ -60,6 +60,7 @@#include <rte_malloc.h> #include <rte_random.h> #include <rte_dev.h> +#include <rte_hash_crc.h> #include "ixgbe_logs.h" #include "base/ixgbe_api.h" @@ -165,6 +166,7 @@ enum ixgbevf_xcast_modes {static int eth_ixgbe_dev_init (struct rte_eth_dev *eth_dev);static int eth_ixgbe_dev_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev); static int ixgbe_dev_configure(struct rte_eth_dev *dev); static int
ixgbe_dev_start(struct rte_eth_dev *dev); static voidixgbe_dev_stop(struct rte_eth_dev *dev); @@ -1276,6 +1278,9 @@eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)drivers/net/ixgbe/ixgbe_ethdev.c +52
-0/* initialize SYN filter */ filter_info->syn_info =0 ; +/* initialize flow director filter list & hash */ +ixgbe_fdir_filter_init (eth_dev); +return 0 ; }@@ -1284,6 +1289,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev;struct ixgbe_hw *hw; +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); +struct ixgbe_fdir_filter *fdir_filter;PMD_INIT_FUNC_TRACE ();@@ -1317,9 +1325,56 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)rte_free (eth_dev->data->hash_mac_addrs); eth_dev->data->hash_mac_addrs =NULL ; +/* remove all the fdir filters & hash */ +if (fdir_info->hash_map) +rte_free (fdir_info->hash_map); +if (fdir_info->hash_handle) +rte_hash_free (fdir_info->hash_handle); + +while ((fdir_filter =TAILQ_FIRST (&fdir_info->fdir_list))) { +TAILQ_REMOVE (&fdir_info->fdir_list, + fdir_filter, + entries); +rte_free (fdir_filter); + } +return 0 ; } +static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev) { +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); +char fdir_hash_name[RTE_HASH_NAMESIZE ]; +struct rte_hash_parameters fdir_hash_params = { + .name = fdir_hash_name, + .entries =IXGBE_MAX_FDIR_FILTER_NUM , + .key_len =sizeof (union ixgbe_atr_input ), + .hash_func = rte_hash_crc, + .hash_func_init_val =0 , + .socket_id =rte_socket_id (), + }; + +TAILQ_INIT (&fdir_info->fdir_list); +snprintf (fdir_hash_name,RTE_HASH_NAMESIZE , +"fdir_%s" , eth_dev->data->name); + fdir_info->hash_handle =rte_hash_create (&fdir_hash_params); +if (!fdir_info->hash_handle) { +PMD_INIT_LOG (ERR ,"Failed to create fdir hash table!" ); +return -EINVAL ; + } + fdir_info->hash_map =rte_zmalloc ("ixgbe" , +sizeof (struct ixgbe_fdir_filter *) * +IXGBE_MAX_FDIR_FILTER_NUM , +0 ); +if (!fdir_info->hash_map) { +PMD_INIT_LOG (ERR , +"Failed to allocate memory for fdir hash map!" ); +return -ENOMEM ; + } + +return 0 ; +}/* * Negotiate mailbox API version with the PF. * After reset API version is always set to the basic one (ixgbe_mbox_api_10). drivers/net/ixgbe/ixgbe_ethdev.h +2
-0@@ -38,6 +38,7 @@#include "base/ixgbe_dcb_82598.h" #include "ixgbe_bypass.h" #include <rte_time.h> +#include <rte_hash.h> /* need update link, bit flag */ #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0) @@ -130,10 +131,11 @@#define IXGBE_MISC_VEC_ID
RTE_INTR_VEC_ZERO_OFFSET
#defineIXGBE_RX_VEC_STARTRTE_INTR_VEC_RXTX_OFFSETdrivers/net/ixgbe/ixgbe_ethdev.h +16
-1+#define IXGBE_MAX_FDIR_FILTER_NUM (1024 * 32) +/* * Information about the fdir mode. */ -struct ixgbe_hw_fdir_mask {uint16_t vlan_tci_mask;uint32_t src_ipv4_mask;@@ -148,6 +150,17 @@ struct ixgbe_hw_fdir_mask {uint8_t tunnel_type_mask; }; +struct ixgbe_fdir_filter { +TAILQ_ENTRY (ixgbe_fdir_filter) entries; +union ixgbe_atr_input ixgbe_fdir;/* key of fdir filter*/ +uint32_t fdirflags;/* drop or forward */ +uint32_t fdirhash;/* hash value for fdir */ +uint8_t queue;/* assigned rx queue */ }; + +/* list of fdir filters */ +TAILQ_HEAD (ixgbe_fdir_filter_list, ixgbe_fdir_filter); +struct ixgbe_hw_fdir_info {struct ixgbe_hw_fdir_mask mask;uint8_t flex_bytes_offset;@@ -159,6 +172,10 @@ struct ixgbe_hw_fdir_info {uint64_t remove;uint64_t f_add;uint64_t f_remove; +struct ixgbe_fdir_filter_list fdir_list;/* filter list*/ +/* store the pointers of the filters, index is the hash value. */ +struct ixgbe_fdir_filter **hash_map; +struct rte_hash *hash_handle;/* cuckoo hash handler */ }; /* structure for interrupt relative data */ diff --git
a/drivers/net/ixgbe/ixgbe_fdir.cb/drivers/net/ixgbe/ixgbe_fdir.cindex 4b81ee3..bfcd294 100644drivers/net/ixgbe/ixgbe_fdir.c +59
-0@@ -43,6 +43,7 @@#include <rte_pci.h> #include <rte_ether.h> #include <rte_ethdev.h> +#include <rte_malloc.h> #include "ixgbe_logs.h" #include "base/ixgbe_api.h" @@ -1075,6 +1076,65 @@ fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash) } +static inline struct ixgbe_fdir_filter * +ixgbe_fdir_filter_lookup (struct ixgbe_hw_fdir_info *fdir_info, +union ixgbe_atr_input *key) +{ +int ret =0 ; + + ret =rte_hash_lookup (fdir_info->hash_handle, (const void *)key); +if (ret <0 ) +return NULL ; + +return fdir_info->hash_map[ret]; +} + +static inline int +ixgbe_insert_fdir_filter (struct ixgbe_hw_fdir_info *fdir_info, +struct ixgbe_fdir_filter *fdir_filter) { +int ret =0 ; + + ret =rte_hash_add_key (fdir_info->hash_handle, + &fdir_filter->ixgbe_fdir); + +if (ret <0 ) { +PMD_DRV_LOG (ERR , +"Failed to insert fdir filter to hash table %d!" , + ret); +return ret; + } + + fdir_info->hash_map[ret] = fdir_filter; + +TAILQ_INSERT_TAIL (&fdir_info->fdir_list, fdir_filter, entries); + +return 0 ; +} + +static inline int +ixgbe_remove_fdir_filter (struct ixgbe_hw_fdir_info *fdir_info, +union ixgbe_atr_input *key) +{ +int ret =0 ; +struct ixgbe_fdir_filter *fdir_filter; + + ret =rte_hash_del_key (fdir_info->hash_handle, key); + +if (ret <0 ) { +PMD_DRV_LOG (ERR ,"No such fdir filter to delete %d!" , ret); +return ret; + } + + fdir_filter = fdir_info->hash_map[ret]; + fdir_info->hash_map[ret] =NULL ; + +TAILQ_REMOVE (&fdir_info->fdir_list, fdir_filter, entries); +rte_free (fdir_filter); + +return 0 ; +} +/* * ixgbe_add_del_fdir_filter - add or remove a flow diretor filter. * @dev: pointer to the structure rte_eth_dev @@ -1098,6 +1158,8 @@ ixgbe_add_del_fdir_filter(struct
rte_eth_dev*dev,drivers/net/ixgbe/ixgbe_fdir.c +44
-2struct ixgbe_hw_fdir_info *info =IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data->dev_private);enum rte_fdir_mode fdir_mode = dev->data->dev_conf.fdir_conf.mode; +struct ixgbe_fdir_filter *node; +bool add_node = FALSE;if (fdir_mode ==RTE_FDIR_MODE_NONE )return -ENOTSUP ;@@ -1148,6 +1210,10 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev, dev->data->dev_conf.fdir_conf.pballoc);if (del) { + err =ixgbe_remove_fdir_filter (info, &input); +if (err <0 ) +return err; + err =fdir_erase_filter_82599 (hw, fdirhash);if (err <0 ) PMD_DRV_LOG(ERR, "Fail to delete FDIR filter!"); @@ -1172,6 +1238,37 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev, else return -EINVAL; + node = ixgbe_fdir_filter_lookup(info, &input); +if (node) { +if (update) { + node->fdirflags = fdircmd_flags; + node->fdirhash = fdirhash; + node->queue = queue; + }else { +PMD_DRV_LOG (ERR ,"Conflict with existing fdir filter!" ); +return -EINVAL ; + } + }else { + add_node = TRUE; + node =rte_zmalloc ("ixgbe_fdir" , +sizeof (struct ixgbe_fdir_filter ), +0 ); +if (!node) +return -ENOMEM ; + (void )rte_memcpy (&node->ixgbe_fdir, + &input, +sizeof (union ixgbe_atr_input )); + node->fdirflags = fdircmd_flags; + node->fdirhash = fdirhash; + node->queue = queue; + + err =ixgbe_insert_fdir_filter (info, node); +if (err <0 ) { +rte_free (node); +return err; + } + } +if (is_perfect) { err = fdir_write_perfect_filter_82599(hw, &input, queue, fdircmd_flags, fdirhash,@@ -1180,10 +1277,14 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev, err =fdir_add_signature_filter_82599 (hw, &input, queue, fdircmd_flags, fdirhash); } -if (err <0 ) +if (err <0 ) {PMD_DRV_LOG (ERR ,"Fail to add FDIR filter!" ); -else + +if (add_node) + (void )ixgbe_remove_fdir_filter (info, &input); + }else {PMD_DRV_LOG (DEBUG ,"Success to add FDIR filter" ); + }return err;}
--
2.5.5
Re: [PATCH v2 02/18] net/ixgbe: store flow director filter
Hi, weid
Quoted 8 lines
-----Original Message-----
From: Dai, Wei
Sent: Tuesday, January 3, 2017 10:28 PM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 02/18] net/ixgbe: store flow director filter
Quoted 7 lines
Hi, Wei Zhao
Would you please do git rebase master for this patch set?
When I do git pull and then git apply this patch, following errors are reported:
[root@dpdk4 dpdk-org]# git am ../patches/bundle-488-zhaowei-ixgbe-filter- api-v2.mbox
This patch is based on dpdk_next_net lib.
Quoted 354 lines
Applying: net/ixgbe: store SYN filter
Applying: net/ixgbe: store flow director filter
error: patch failed:drivers/net/ixgbe/ixgbe_ethdev.c:1284
error:drivers/net/ixgbe/ixgbe_ethdev.c: patch does not apply Patch failed at 0002 net/ixgbe: store flow director filter The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".Quoted 114 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhao1, Wei <[email protected]>
Subject: [dpdk-dev] [PATCH v2 02/18] net/ixgbe: store flow director filterAdd support for storing flow director filter in SW.
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--add a fdir initialization function in device start process--- drivers/net/ixgbe/ixgbe_ethdev.c | 55 ++++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 19 ++++++- drivers/net/ixgbe/ixgbe_fdir.c | 105 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 176 insertions(+), 3 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +2
-0@@ -60,6 +60,7 @@#include <rte_malloc.h> #include <rte_random.h> #include <rte_dev.h> +#include <rte_hash_crc.h> #include "ixgbe_logs.h" #include "base/ixgbe_api.h" @@ -165,6 +166,7 @@ enum ixgbevf_xcast_modes {static int eth_ixgbe_dev_init (struct rte_eth_dev *eth_dev);static int eth_ixgbe_dev_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev); static int ixgbe_dev_configure(struct rte_eth_dev *dev); static int
ixgbe_dev_start(struct rte_eth_dev *dev); static voidixgbe_dev_stop(struct rte_eth_dev *dev); @@ -1276,6 +1278,9 @@eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)drivers/net/ixgbe/ixgbe_ethdev.c +45
-0/* initialize SYN filter */ filter_info->syn_info =0 ; +/* initialize flow director filter list & hash */ +ixgbe_fdir_filter_init (eth_dev); +return 0 ; }@@ -1284,6 +1289,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev;struct ixgbe_hw *hw; +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data- dev_private); +struct ixgbe_fdir_filter *fdir_filter;PMD_INIT_FUNC_TRACE ();@@ -1317,9 +1325,56 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)rte_free (eth_dev->data->hash_mac_addrs); eth_dev->data->hash_mac_addrs =NULL ; +/* remove all the fdir filters & hash */ +if (fdir_info->hash_map) +rte_free (fdir_info->hash_map); +if (fdir_info->hash_handle) +rte_hash_free (fdir_info->hash_handle); + +while ((fdir_filter =TAILQ_FIRST (&fdir_info->fdir_list))) { +TAILQ_REMOVE (&fdir_info->fdir_list, + fdir_filter, + entries); +rte_free (fdir_filter); + } +return 0 ; } +static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev) { +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data- dev_private); +char fdir_hash_name[RTE_HASH_NAMESIZE ]; +struct rte_hash_parameters fdir_hash_params = { + .name = fdir_hash_name, + .entries =IXGBE_MAX_FDIR_FILTER_NUM , + .key_len =sizeof (union ixgbe_atr_input ), + .hash_func = rte_hash_crc, + .hash_func_init_val =0 , + .socket_id =rte_socket_id (), + }; + +TAILQ_INIT (&fdir_info->fdir_list); +snprintf (fdir_hash_name,RTE_HASH_NAMESIZE , +"fdir_%s" , eth_dev->data->name); + fdir_info->hash_handle =rte_hash_create (&fdir_hash_params); +if (!fdir_info->hash_handle) { +PMD_INIT_LOG (ERR ,"Failed to create fdir hash table!" ); +return -EINVAL ; + } + fdir_info->hash_map =rte_zmalloc ("ixgbe" , +sizeof (struct ixgbe_fdir_filter *) * +IXGBE_MAX_FDIR_FILTER_NUM , +0 ); +if (!fdir_info->hash_map) {drivers/net/ixgbe/ixgbe_ethdev.c eth_ixgbe_dev_uninit(struct rte_eth_dev
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +7
-0+PMD_INIT_LOG (ERR , +"Failed to allocate memory for fdir hash map!" ); +return -ENOMEM ; + } + +return 0 ; +}/* * Negotiate mailbox API version with the PF. * After reset API version is always set to the basic one (
ixgbe_mbox_api_10).drivers/net/ixgbe/ixgbe_fdir.c ixgbe_add_del_fdir_filter(struct rte_eth_dev
Quoted 147 lines
drivers/net/ixgbe/ixgbe_ethdev.h +2
-0@@ -38,6 +38,7 @@#include "base/ixgbe_dcb_82598.h" #include "ixgbe_bypass.h" #include <rte_time.h> +#include <rte_hash.h> /* need update link, bit flag */ #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0) @@ -130,10 +131,11 @@#define IXGBE_MISC_VEC_ID
RTE_INTR_VEC_ZERO_OFFSET
#defineIXGBE_RX_VEC_STARTRTE_INTR_VEC_RXTX_OFFSETdrivers/net/ixgbe/ixgbe_ethdev.h +16
-1+#define IXGBE_MAX_FDIR_FILTER_NUM (1024 * 32) +/* * Information about the fdir mode. */ -struct ixgbe_hw_fdir_mask {uint16_t vlan_tci_mask;uint32_t src_ipv4_mask;@@ -148,6 +150,17 @@ struct ixgbe_hw_fdir_mask {uint8_t tunnel_type_mask; }; +struct ixgbe_fdir_filter { +TAILQ_ENTRY (ixgbe_fdir_filter) entries; +union ixgbe_atr_input ixgbe_fdir;/* key of fdir filter*/ +uint32_t fdirflags;/* drop or forward */ +uint32_t fdirhash;/* hash value for fdir */ +uint8_t queue;/* assigned rx queue */ }; + +/* list of fdir filters */ +TAILQ_HEAD (ixgbe_fdir_filter_list, ixgbe_fdir_filter); +struct ixgbe_hw_fdir_info {struct ixgbe_hw_fdir_mask mask;uint8_t flex_bytes_offset;@@ -159,6 +172,10 @@ struct ixgbe_hw_fdir_info {uint64_t remove;uint64_t f_add;uint64_t f_remove; +struct ixgbe_fdir_filter_list fdir_list;/* filter list*/ +/* store the pointers of the filters, index is the hash value. */ +struct ixgbe_fdir_filter **hash_map; +struct rte_hash *hash_handle;/* cuckoo hash handler */ }; /* structure for interrupt relative data */ diff --git
a/drivers/net/ixgbe/ixgbe_fdir.cb/drivers/net/ixgbe/ixgbe_fdir.cindex
4b81ee3..bfcd294 100644drivers/net/ixgbe/ixgbe_fdir.c +59
-0@@ -43,6 +43,7 @@#include <rte_pci.h> #include <rte_ether.h> #include <rte_ethdev.h> +#include <rte_malloc.h> #include "ixgbe_logs.h" #include "base/ixgbe_api.h" @@ -1075,6 +1076,65 @@ fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash) } +static inline struct ixgbe_fdir_filter * +ixgbe_fdir_filter_lookup (struct ixgbe_hw_fdir_info *fdir_info, +union ixgbe_atr_input *key) +{ +int ret =0 ; + + ret =rte_hash_lookup (fdir_info->hash_handle, (const void *)key); +if (ret <0 ) +return NULL ; + +return fdir_info->hash_map[ret]; +} + +static inline int +ixgbe_insert_fdir_filter (struct ixgbe_hw_fdir_info *fdir_info, +struct ixgbe_fdir_filter *fdir_filter) { +int ret =0 ; + + ret =rte_hash_add_key (fdir_info->hash_handle, + &fdir_filter->ixgbe_fdir); + +if (ret <0 ) { +PMD_DRV_LOG (ERR , +"Failed to insert fdir filter to hash table %d!" , + ret); +return ret; + } + + fdir_info->hash_map[ret] = fdir_filter; + +TAILQ_INSERT_TAIL (&fdir_info->fdir_list, fdir_filter, entries); + +return 0 ; +} + +static inline int +ixgbe_remove_fdir_filter (struct ixgbe_hw_fdir_info *fdir_info, +union ixgbe_atr_input *key) +{ +int ret =0 ; +struct ixgbe_fdir_filter *fdir_filter; + + ret =rte_hash_del_key (fdir_info->hash_handle, key); + +if (ret <0 ) { +PMD_DRV_LOG (ERR ,"No such fdir filter to delete %d!" , ret); +return ret; + } + + fdir_filter = fdir_info->hash_map[ret]; + fdir_info->hash_map[ret] =NULL ; + +TAILQ_REMOVE (&fdir_info->fdir_list, fdir_filter, entries); +rte_free (fdir_filter); + +return 0 ; +} +/* * ixgbe_add_del_fdir_filter - add or remove a flow diretor filter. * @dev: pointer to the structure rte_eth_dev @@ -1098,6 +1158,8 @@ ixgbe_add_del_fdir_filter(struct
rte_eth_dev*dev,drivers/net/ixgbe/ixgbe_fdir.c +0
-0struct ixgbe_hw_fdir_info *info = IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data-
dev_private);
enumrte_fdir_modefdir_mode= dev->data-
dev_conf.fdir_conf.mode;drivers/net/ixgbe/ixgbe_fdir.c +2
-0+struct ixgbe_fdir_filter *node; +bool add_node = FALSE;if (fdir_mode ==RTE_FDIR_MODE_NONE )return -ENOTSUP ;@@ -1148,6 +1210,10 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev*dev,
Quoted 11 lines
drivers/net/ixgbe/ixgbe_fdir.c +4
-0dev->data- dev_conf.fdir_conf.pballoc);if (del) { + err =ixgbe_remove_fdir_filter (info, &input); +if (err <0 ) +return err; + err =fdir_erase_filter_82599 (hw, fdirhash);if (err <0 )
PMD_DRV_LOG(ERR, "Fail to delete FDIR filter!");@@ -1172,6
drivers/net/ixgbe/ixgbe_fdir.c ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,
Quoted 12 lines
+1238,37 @@ ixgbe_add_del_fdir_filter(struct
rte_eth_dev*dev,drivers/net/ixgbe/ixgbe_fdir.c +8
-0else return -EINVAL ; + node =ixgbe_fdir_filter_lookup (info, &input); +if (node) { +if (update) { + node->fdirflags = fdircmd_flags; + node->fdirhash = fdirhash; + node->queue = queue; + }else { + PMD_DRV_LOG(ERR, "Conflict with existing fdirfilter!");
Quoted 46 lines
drivers/net/ixgbe/ixgbe_fdir.c +29
-2+return -EINVAL ; + } + }else { + add_node = TRUE; + node =rte_zmalloc ("ixgbe_fdir" , +sizeof (struct ixgbe_fdir_filter ), +0 ); +if (!node) +return -ENOMEM ; + (void )rte_memcpy (&node->ixgbe_fdir, + &input, +sizeof (union ixgbe_atr_input )); + node->fdirflags = fdircmd_flags; + node->fdirhash = fdirhash; + node->queue = queue; + + err =ixgbe_insert_fdir_filter (info, node); +if (err <0 ) { +rte_free (node); +return err; + } + } +if (is_perfect) { err = fdir_write_perfect_filter_82599(hw, &input, queue, fdircmd_flags, fdirhash,@@ -1180,10 +1277,14 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev, err =fdir_add_signature_filter_82599 (hw, &input, queue, fdircmd_flags, fdirhash); } -if (err <0 ) +if (err <0 ) {PMD_DRV_LOG (ERR ,"Fail to add FDIR filter!" ); -else + +if (add_node) + (void )ixgbe_remove_fdir_filter (info, &input); + }else {PMD_DRV_LOG (DEBUG ,"Success to add FDIR filter" ); + }return err;}
--
2.5.5
Re: [PATCH v2 02/18] net/ixgbe: store flow director filter
In reply to Wei ZhaoQuoted 9 lines · Wei Zhao
Add support for storing flow director filter in SW.
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--add a fdir initialization function in device start process
---
<...>
Quoted 27 lines
drivers/net/ixgbe/ixgbe_ethdev.c +9
-0@@ -1276,6 +1278,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* initialize SYN filter */ filter_info->syn_info =0 ; +/* initialize flow director filter list & hash */ +ixgbe_fdir_filter_init (eth_dev); +return 0 ; }@@ -1284,6 +1289,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev;struct ixgbe_hw *hw; +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); +struct ixgbe_fdir_filter *fdir_filter;PMD_INIT_FUNC_TRACE ();@@ -1317,9 +1325,56 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)rte_free (eth_dev->data->hash_mac_addrs); eth_dev->data->hash_mac_addrs =NULL ; +/* remove all the fdir filters & hash */ +if (fdir_info->hash_map) +rte_free (fdir_info->hash_map);
drivers/net/ixgbe/ixgbe_ethdev.c eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev) · line 1340
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+if (fdir_info->hash_handle) +rte_hash_free (fdir_info->hash_handle); + +while ((fdir_filter =TAILQ_FIRST (&fdir_info->fdir_list))) { +TAILQ_REMOVE (&fdir_info->fdir_list, + fdir_filter, + entries); +rte_free (fdir_filter); + } +
What do you think extracting these into a function as done in init() ?
<...>
Re: [PATCH v2 02/18] net/ixgbe: store flow director filter
Hi, yigit
Quoted 60 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, January 7, 2017 12:31 AM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 02/18] net/ixgbe: store flow director filterQuoted 9 lines · Wei Zhao
Add support for storing flow director filter in SW.
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--add a fdir initialization function in device start process
---<...>
drivers/net/ixgbe/ixgbe_ethdev.c eth_ixgbe_dev_uninit(struct rte_eth_dev
Quoted 22 lines
drivers/net/ixgbe/ixgbe_ethdev.c +6
-0@@ -1276,6 +1278,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* initialize SYN filter */ filter_info->syn_info =0 ; +/* initialize flow director filter list & hash */ +ixgbe_fdir_filter_init (eth_dev); +return 0 ; }@@ -1284,6 +1289,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev;struct ixgbe_hw *hw; +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data- dev_private); +struct ixgbe_fdir_filter *fdir_filter;PMD_INIT_FUNC_TRACE ();@@ -1317,9 +1325,56 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev
*eth_dev)Quoted 6 lines
drivers/net/ixgbe/ixgbe_ethdev.c +3
-0rte_free (eth_dev->data->hash_mac_addrs); eth_dev->data->hash_mac_addrs =NULL ; +/* remove all the fdir filters & hash */ +if (fdir_info->hash_map) +rte_free (fdir_info->hash_map);drivers/net/ixgbe/ixgbe_ethdev.c eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev) · line 1340
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+if (fdir_info->hash_handle) +rte_hash_free (fdir_info->hash_handle); + +while ((fdir_filter =TAILQ_FIRST (&fdir_info->fdir_list))) { +TAILQ_REMOVE (&fdir_info->fdir_list, + fdir_filter, + entries); +rte_free (fdir_filter); + } +What do you think extracting these into a function as done in
init()?
Quoted 1 line
<...>
Ok , I will do as your suggestion.
PATCH v2 3/18 net/ixgbe: store L2 tunnel filter
In reply to Wei ZhaoAdd support for storing L2 tunnel filter in SW.
---
v2:
--add a L2 tunnel initialization function in device start process
--- drivers/net/ixgbe/ixgbe_ethdev.c | 157 +++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 24 ++++++ 2 files changed, 181 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +157 -0
@@ -167,6 +167,7 @@ enum ixgbevf_xcast_modes {static int eth_ixgbe_dev_init (struct rte_eth_dev *eth_dev);static int eth_ixgbe_dev_uninit (struct rte_eth_dev *eth_dev);static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev); +static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev);static int ixgbe_dev_configure (struct rte_eth_dev *dev);static int ixgbe_dev_start (struct rte_eth_dev *dev);static void ixgbe_dev_stop (struct rte_eth_dev *dev);
@@ -1281,6 +1282,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* initialize flow director filter list & hash */ ixgbe_fdir_filter_init (eth_dev); +/* initialize l2 tunnel filter list & hash */ +ixgbe_l2_tn_filter_init (eth_dev);return 0 ; }
@@ -1291,7 +1294,10 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)struct ixgbe_hw *hw;struct ixgbe_hw_fdir_info *fdir_info =IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (eth_dev->data->dev_private);struct ixgbe_fdir_filter *fdir_filter; +struct ixgbe_l2_tn_filter *l2_tn_filter;PMD_INIT_FUNC_TRACE ();
@@ -1338,6 +1344,19 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)rte_free (fdir_filter); } +/* remove all the L2 tunnel filters & hash */ +if (l2_tn_info->hash_map) +rte_free (l2_tn_info->hash_map); +if (l2_tn_info->hash_handle) +rte_hash_free (l2_tn_info->hash_handle); + +while ((l2_tn_filter =TAILQ_FIRST (&l2_tn_info->l2_tn_list))) { +TAILQ_REMOVE (&l2_tn_info->l2_tn_list, + l2_tn_filter, + entries); +rte_free (l2_tn_filter); + } +return 0 ; }
@@ -1372,6 +1391,40 @@ static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev) "Failed to allocate memory for fdir hash map!");return -ENOMEM ; } +return 0 ; +} + +static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (eth_dev->data->dev_private); +char l2_tn_hash_name[RTE_HASH_NAMESIZE ]; +struct rte_hash_parameters l2_tn_hash_params = { + .name = l2_tn_hash_name, + .entries =IXGBE_MAX_L2_TN_FILTER_NUM , + .key_len =sizeof (struct ixgbe_l2_tn_key ), + .hash_func = rte_hash_crc, + .hash_func_init_val =0 , + .socket_id =rte_socket_id (), + }; + +TAILQ_INIT (&l2_tn_info->l2_tn_list); +snprintf (l2_tn_hash_name,RTE_HASH_NAMESIZE , +"l2_tn_%s" , eth_dev->data->name); + l2_tn_info->hash_handle =rte_hash_create (&l2_tn_hash_params); +if (!l2_tn_info->hash_handle) { +PMD_INIT_LOG (ERR ,"Failed to create L2 TN hash table!" ); +return -EINVAL ; + } + l2_tn_info->hash_map =rte_zmalloc ("ixgbe" , +sizeof (struct ixgbe_l2_tn_filter *) * +IXGBE_MAX_L2_TN_FILTER_NUM , +0 ); +if (!l2_tn_info->hash_map) { +PMD_INIT_LOG (ERR , +"Failed to allocate memory for L2 TN hash map!" ); +return -ENOMEM ; + }return 0 ; }
@@ -7178,12 +7231,104 @@ ixgbe_e_tag_filter_add(struct rte_eth_dev *dev,return -EINVAL ; } +static inline struct ixgbe_l2_tn_filter * +ixgbe_l2_tn_filter_lookup (struct ixgbe_l2_tn_info *l2_tn_info, +struct ixgbe_l2_tn_key *key) +{ +int ret =0 ; + + ret =rte_hash_lookup (l2_tn_info->hash_handle, (const void *)key); +if (ret <0 ) +return NULL ; + +return l2_tn_info->hash_map[ret]; +} + +static inline int +ixgbe_insert_l2_tn_filter (struct ixgbe_l2_tn_info *l2_tn_info, +struct ixgbe_l2_tn_filter *l2_tn_filter) +{ +int ret =0 ; + + ret =rte_hash_add_key (l2_tn_info->hash_handle, + &l2_tn_filter->key); + +if (ret <0 ) { +PMD_DRV_LOG (ERR , +"Failed to insert L2 tunnel filter" +" to hash table %d!" , + ret); +return ret; + } + + l2_tn_info->hash_map[ret] = l2_tn_filter; + +TAILQ_INSERT_TAIL (&l2_tn_info->l2_tn_list, l2_tn_filter, entries); + +return 0 ; +} + +static inline int +ixgbe_remove_l2_tn_filter (struct ixgbe_l2_tn_info *l2_tn_info, +struct ixgbe_l2_tn_key *key) +{ +int ret =0 ; +struct ixgbe_l2_tn_filter *l2_tn_filter; + + ret =rte_hash_del_key (l2_tn_info->hash_handle, key); + +if (ret <0 ) { +PMD_DRV_LOG (ERR , +"No such L2 tunnel filter to delete %d!" , + ret); +return ret; + } + + l2_tn_filter = l2_tn_info->hash_map[ret]; + l2_tn_info->hash_map[ret] =NULL ; + +TAILQ_REMOVE (&l2_tn_info->l2_tn_list, l2_tn_filter, entries); +rte_free (l2_tn_filter); + +return 0 ; +} +/* Add l2 tunnel filter */ static int ixgbe_dev_l2_tunnel_filter_add (struct rte_eth_dev *dev,struct rte_eth_l2_tunnel_conf *l2_tunnel) {int ret =0 ; +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private); +struct ixgbe_l2_tn_key key; +struct ixgbe_l2_tn_filter *node; + + key.l2_tn_type = l2_tunnel->l2_tunnel_type; + key.tn_id = l2_tunnel->tunnel_id; + + node =ixgbe_l2_tn_filter_lookup (l2_tn_info, &key); + +if (node) { +PMD_DRV_LOG (ERR ,"The L2 tunnel filter already exists!" ); +return -EINVAL ; + } + + node =rte_zmalloc ("ixgbe_l2_tn" , +sizeof (struct ixgbe_l2_tn_filter ), +0 ); +if (!node) +return -ENOMEM ; + + (void )rte_memcpy (&node->key, + &key, +sizeof (struct ixgbe_l2_tn_key )); + node->pool = l2_tunnel->pool; + ret =ixgbe_insert_l2_tn_filter (l2_tn_info, node); +if (ret <0 ) { +rte_free (node); +return ret; + }switch (l2_tunnel->l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG :
@@ -7195,6 +7340,9 @@ ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,break ; } +if (ret <0 ) + (void )ixgbe_remove_l2_tn_filter (l2_tn_info, &key); +return ret; }
@@ -7204,6 +7352,15 @@ ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel) {int ret =0 ; +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private); +struct ixgbe_l2_tn_key key; + + key.l2_tn_type = l2_tunnel->l2_tunnel_type; + key.tn_id = l2_tunnel->tunnel_id; + ret =ixgbe_remove_l2_tn_filter (l2_tn_info, &key); +if (ret <0 ) +return ret;switch (l2_tunnel->l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG :
drivers/net/ixgbe/ixgbe_ethdev.h +24 -0
@@ -132,6 +132,7 @@#define IXGBE_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET#define IXGBE_MAX_FDIR_FILTER_NUM (1024 * 32) +#define IXGBE_MAX_L2_TN_FILTER_NUM 128/* * Information about the fdir mode.
@@ -283,6 +284,25 @@ struct ixgbe_filter_info {uint32_t syn_info; }; +struct ixgbe_l2_tn_key { +enum rte_eth_tunnel_type l2_tn_type; +uint32_t tn_id; +}; + +struct ixgbe_l2_tn_filter { +TAILQ_ENTRY (ixgbe_l2_tn_filter) entries; +struct ixgbe_l2_tn_key key; +uint32_t pool; +}; + +TAILQ_HEAD (ixgbe_l2_tn_filter_list, ixgbe_l2_tn_filter); + +struct ixgbe_l2_tn_info { +struct ixgbe_l2_tn_filter_list l2_tn_list; +struct ixgbe_l2_tn_filter **hash_map; +struct rte_hash *hash_handle; +}; +/* * Structure to store private data for each driver instance (for each port). */
@@ -302,6 +322,7 @@ struct ixgbe_adapter {struct ixgbe_bypass_info bps;#endif /* RTE_NIC_BYPASS */ struct ixgbe_filter_info filter; +struct ixgbe_l2_tn_info l2_tn;bool rx_bulk_alloc_allowed;bool rx_vec_allowed;
@@ -346,6 +367,9 @@ struct ixgbe_adapter {#define IXGBE_DEV_PRIVATE_TO_FILTER_INFO (adapter) \ (&((struct ixgbe_adapter *)adapter)->filter) +#define IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (adapter) \ + (&((struct ixgbe_adapter *)adapter)->l2_tn) +/* * RX/TX function prototypes */
Signature · 1 line
2.5.5
Re: [PATCH v2 03/18] net/ixgbe: store L2 tunnel filter
Quoted 15 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhao1, Wei <[email protected]>
Subject: [dpdk-dev] [PATCH v2 03/18] net/ixgbe: store L2 tunnel filterAdd support for storing L2 tunnel filter in SW.
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_e_tag_filter_add(struct rte_eth_dev *dev, · line 7238
Quoted 5 lines
drivers/net/ixgbe/ixgbe_ethdev.c +5
-0+static inline struct ixgbe_l2_tn_filter * +ixgbe_l2_tn_filter_lookup (struct ixgbe_l2_tn_info *l2_tn_info, +struct ixgbe_l2_tn_key *key) +{ +int ret =0 ;
Needles initialization since ret will be set bellow, it can be removed.
And this initialization can be removed in other filter lookup/insert/delete functions, either.
Quoted 70 lines
drivers/net/ixgbe/ixgbe_ethdev.c +60
-0+ + ret =rte_hash_lookup (l2_tn_info->hash_handle, (const void *)key); +if (ret <0 ) +return NULL ; + +return l2_tn_info->hash_map[ret]; +} + +static inline int +ixgbe_insert_l2_tn_filter (struct ixgbe_l2_tn_info *l2_tn_info, +struct ixgbe_l2_tn_filter *l2_tn_filter) { +int ret =0 ; + + ret =rte_hash_add_key (l2_tn_info->hash_handle, + &l2_tn_filter->key); + +if (ret <0 ) { +PMD_DRV_LOG (ERR , +"Failed to insert L2 tunnel filter" +" to hash table %d!" , + ret); +return ret; + } + + l2_tn_info->hash_map[ret] = l2_tn_filter; + +TAILQ_INSERT_TAIL (&l2_tn_info->l2_tn_list, l2_tn_filter, entries); + +return 0 ; +}/* Add l2 tunnel filter */ static int ixgbe_dev_l2_tunnel_filter_add (struct rte_eth_dev *dev,struct rte_eth_l2_tunnel_conf *l2_tunnel) {int ret =0 ; +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private); +struct ixgbe_l2_tn_key key; +struct ixgbe_l2_tn_filter *node; + + key.l2_tn_type = l2_tunnel->l2_tunnel_type; + key.tn_id = l2_tunnel->tunnel_id; + + node =ixgbe_l2_tn_filter_lookup (l2_tn_info, &key); + +if (node) { +PMD_DRV_LOG (ERR ,"The L2 tunnel filter already exists!" ); +return -EINVAL ; + } + + node =rte_zmalloc ("ixgbe_l2_tn" , +sizeof (struct ixgbe_l2_tn_filter ), +0 ); +if (!node) +return -ENOMEM ; + + (void )rte_memcpy (&node->key, + &key, +sizeof (struct ixgbe_l2_tn_key )); + node->pool = l2_tunnel->pool; + ret =ixgbe_insert_l2_tn_filter (l2_tn_info, node); +if (ret <0 ) { +rte_free (node); +return ret; + }switch (l2_tunnel->l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG :
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev · line 7345
Quoted 6 lines
drivers/net/ixgbe/ixgbe_ethdev.c +2
-0@@ -7195,6 +7340,9 @@ ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev, break; } +if (ret <0 ) + (void )ixgbe_remove_l2_tn_filter (l2_tn_info, &key);
Some confusion, why remove l2_tn_filter here? Can this check be moved before ixgbe_insert_l2_tn_filter?
Quoted 37 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+return ret; }@@ -7204,6 +7352,15 @@ ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel) {int ret =0 ; +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private); +struct ixgbe_l2_tn_key key; + + key.l2_tn_type = l2_tunnel->l2_tunnel_type; + key.tn_id = l2_tunnel->tunnel_id; + ret =ixgbe_remove_l2_tn_filter (l2_tn_info, &key); +if (ret <0 ) +return ret;switch (l2_tunnel->l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG :drivers/net/ixgbe/ixgbe_ethdev.h +0
-0@@ -132,6 +132,7 @@#define IXGBE_RX_VEC_START
RTE_INTR_VEC_RXTX_OFFSET#define
IXGBE_MAX_FDIR_FILTER_NUM(1024 * 32)drivers/net/ixgbe/ixgbe_ethdev.h +1
-0+#define IXGBE_MAX_L2_TN_FILTER_NUM 128/* * Information about the fdir mode. @@ -283,6 +284,25 @@ struct ixgbe_filter_info {uint32_t syn_info; };
drivers/net/ixgbe/ixgbe_ethdev.h struct ixgbe_filter_info { · line 295
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.h +9
-0+struct ixgbe_l2_tn_key { +enum rte_eth_tunnel_type l2_tn_type; +uint32_t tn_id; +}; + +struct ixgbe_l2_tn_filter { +TAILQ_ENTRY (ixgbe_l2_tn_filter) entries; +struct ixgbe_l2_tn_key key; +uint32_t pool;
Maybe more comments here will be helpful.
Quoted 2 lines
drivers/net/ixgbe/ixgbe_ethdev.h +2
-0+}; +
PATCH v2 4/18 net/ixgbe: restore n-tuple filter
In reply to Wei ZhaoAdd support for restoring n-tuple filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 131 +++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 48 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +83 -48
@@ -384,6 +384,7 @@ static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel);static int ixgbe_dev_udp_tunnel_port_del (struct rte_eth_dev *dev,struct rte_eth_udp_tunnel *udp_tunnel); +static int ixgbe_filter_restore (struct rte_eth_dev *dev);/* * Define VF Stats MACRO for Non "cleared on read" register
@@ -1292,6 +1293,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev;struct ixgbe_hw *hw; +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (eth_dev->data->dev_private); +struct ixgbe_5tuple_filter *p_5tuple;struct ixgbe_hw_fdir_info *fdir_info =IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); struct ixgbe_l2_tn_info *l2_tn_info =
@@ -1331,6 +1335,16 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)rte_free (eth_dev->data->hash_mac_addrs); eth_dev->data->hash_mac_addrs =NULL ; +/* Remove all ntuple filters of the device */ +while ((p_5tuple =TAILQ_FIRST (&filter_info->fivetuple_list))) { +TAILQ_REMOVE (&filter_info->fivetuple_list, + p_5tuple, + entries); +rte_free (p_5tuple); + } +memset (filter_info->fivetuple_mask,0 , +sizeof (uint32_t ) *IXGBE_5TUPLE_ARRAY_SIZE ); +/* remove all the fdir filters & hash */ if (fdir_info->hash_map)rte_free (fdir_info->hash_map);
@@ -2483,6 +2497,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)/* resume enabled intr since hw reset */ ixgbe_enable_intr (dev); +ixgbe_filter_restore (dev);return 0 ;
@@ -2503,9 +2518,6 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct ixgbe_vf_info *vfinfo = *IXGBE_DEV_PRIVATE_TO_P_VFDATA (dev->data->dev_private); -struct ixgbe_filter_info *filter_info = -IXGBE_DEV_PRIVATE_TO_FILTER_INFO (dev->data->dev_private); -struct ixgbe_5tuple_filter *p_5tuple, *p_5tuple_next;struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;int vf;
@@ -2543,17 +2555,6 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)memset (&link,0 ,sizeof (link));rte_ixgbe_dev_atomic_write_link_status (dev, &link); -/* Remove all ntuple filters of the device */ -for (p_5tuple =TAILQ_FIRST (&filter_info->fivetuple_list); - p_5tuple !=NULL ; p_5tuple = p_5tuple_next) { - p_5tuple_next =TAILQ_NEXT (p_5tuple, entries); -TAILQ_REMOVE (&filter_info->fivetuple_list, - p_5tuple, entries); -rte_free (p_5tuple); - } -memset (filter_info->fivetuple_mask,0 , -sizeof (uint32_t ) *IXGBE_5TUPLE_ARRAY_SIZE ); -if (!rte_intr_allow_others (intr_handle))/* resume to the default handler */ rte_intr_callback_register(intr_handle,
@@ -5795,6 +5796,52 @@ convert_protocol_type(uint8_t protocol_value)return IXGBE_FILTER_PROTOCOL_NONE ; } +/* inject a 5-tuple filter to HW */ +static inline void +ixgbe_inject_5tuple_filter (struct rte_eth_dev *dev, +struct ixgbe_5tuple_filter *filter) +{ +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +int i; +uint32_t ftqf, sdpqf; +uint32_t l34timir =0 ; +uint8_t mask =0xff ; + + i = filter->index; + + sdpqf = (uint32_t )(filter->filter_info.dst_port << +IXGBE_SDPQF_DSTPORT_SHIFT ); + sdpqf = sdpqf | (filter->filter_info.src_port &IXGBE_SDPQF_SRCPORT ); + + ftqf = (uint32_t )(filter->filter_info.proto & +IXGBE_FTQF_PROTOCOL_MASK ); + ftqf |= (uint32_t )((filter->filter_info.priority & +IXGBE_FTQF_PRIORITY_MASK ) <<IXGBE_FTQF_PRIORITY_SHIFT ); +if (filter->filter_info.src_ip_mask ==0 )/* 0 means compare. */ + mask &=IXGBE_FTQF_SOURCE_ADDR_MASK ; +if (filter->filter_info.dst_ip_mask ==0 ) + mask &=IXGBE_FTQF_DEST_ADDR_MASK ; +if (filter->filter_info.src_port_mask ==0 ) + mask &=IXGBE_FTQF_SOURCE_PORT_MASK ; +if (filter->filter_info.dst_port_mask ==0 ) + mask &=IXGBE_FTQF_DEST_PORT_MASK ; +if (filter->filter_info.proto_mask ==0 ) + mask &=IXGBE_FTQF_PROTOCOL_COMP_MASK ; + ftqf |= mask <<IXGBE_FTQF_5TUPLE_MASK_SHIFT ; + ftqf |=IXGBE_FTQF_POOL_MASK_EN ; + ftqf |=IXGBE_FTQF_QUEUE_ENABLE ; + +IXGBE_WRITE_REG (hw,IXGBE_DAQF (i), filter->filter_info.dst_ip); +IXGBE_WRITE_REG (hw,IXGBE_SAQF (i), filter->filter_info.src_ip); +IXGBE_WRITE_REG (hw,IXGBE_SDPQF (i), sdpqf); +IXGBE_WRITE_REG (hw,IXGBE_FTQF (i), ftqf); + + l34timir |=IXGBE_L34T_IMIR_RESERVE ; + l34timir |= (uint32_t )(filter->queue << +IXGBE_L34T_IMIR_QUEUE_SHIFT ); +IXGBE_WRITE_REG (hw,IXGBE_L34T_IMIR (i), l34timir); +} +/* * add a 5tuple filter *
@@ -5812,13 +5859,9 @@ static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev, struct ixgbe_5tuple_filter *filter) { - struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct ixgbe_filter_info *filter_info =IXGBE_DEV_PRIVATE_TO_FILTER_INFO (dev->data->dev_private);int i, idx, shift; -uint32_t ftqf, sdpqf; -uint32_t l34timir =0 ; -uint8_t mask =0xff ;/* * look for an unused 5tuple filter index,
@@ -5841,37 +5884,8 @@ ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,return -ENOSYS ; } - sdpqf = (uint32_t )(filter->filter_info.dst_port << -IXGBE_SDPQF_DSTPORT_SHIFT ); - sdpqf = sdpqf | (filter->filter_info.src_port &IXGBE_SDPQF_SRCPORT ); - - ftqf = (uint32_t )(filter->filter_info.proto & -IXGBE_FTQF_PROTOCOL_MASK ); - ftqf |= (uint32_t )((filter->filter_info.priority & -IXGBE_FTQF_PRIORITY_MASK ) <<IXGBE_FTQF_PRIORITY_SHIFT ); -if (filter->filter_info.src_ip_mask ==0 )/* 0 means compare. */ - mask &=IXGBE_FTQF_SOURCE_ADDR_MASK ; -if (filter->filter_info.dst_ip_mask ==0 ) - mask &=IXGBE_FTQF_DEST_ADDR_MASK ; -if (filter->filter_info.src_port_mask ==0 ) - mask &=IXGBE_FTQF_SOURCE_PORT_MASK ; -if (filter->filter_info.dst_port_mask ==0 ) - mask &=IXGBE_FTQF_DEST_PORT_MASK ; -if (filter->filter_info.proto_mask ==0 ) - mask &=IXGBE_FTQF_PROTOCOL_COMP_MASK ; - ftqf |= mask <<IXGBE_FTQF_5TUPLE_MASK_SHIFT ; - ftqf |=IXGBE_FTQF_POOL_MASK_EN ; - ftqf |=IXGBE_FTQF_QUEUE_ENABLE ; - -IXGBE_WRITE_REG (hw,IXGBE_DAQF (i), filter->filter_info.dst_ip); -IXGBE_WRITE_REG (hw,IXGBE_SAQF (i), filter->filter_info.src_ip); -IXGBE_WRITE_REG (hw,IXGBE_SDPQF (i), sdpqf); -IXGBE_WRITE_REG (hw,IXGBE_FTQF (i), ftqf); +ixgbe_inject_5tuple_filter (dev, filter); - l34timir |=IXGBE_L34T_IMIR_RESERVE ; - l34timir |= (uint32_t )(filter->queue << -IXGBE_L34T_IMIR_QUEUE_SHIFT ); -IXGBE_WRITE_REG (hw,IXGBE_L34T_IMIR (i), l34timir);return 0 ; }
@@ -7883,6 +7897,27 @@ ixgbevf_dev_interrupt_handler(__rte_unused struct rte_intr_handle *handle,ixgbevf_dev_interrupt_action (dev); } +/* restore n-tuple filter */ +static inline void +ixgbe_ntuple_filter_restore (struct rte_eth_dev *dev) +{ +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (dev->data->dev_private); +struct ixgbe_5tuple_filter *node; + + TAILQ_FOREACH(node, &filter_info->fivetuple_list, entries) { +ixgbe_inject_5tuple_filter (dev, node); + } +} + +static int +ixgbe_filter_restore (struct rte_eth_dev *dev) +{ +ixgbe_ntuple_filter_restore (dev); + +return 0 ; +} +RTE_PMD_REGISTER_PCI (net_ixgbe, rte_ixgbe_pmd.pci_drv);RTE_PMD_REGISTER_PCI_TABLE (net_ixgbe, pci_id_ixgbe_map);RTE_PMD_REGISTER_KMOD_DEP (net_ixgbe,"* igb_uio | uio_pci_generic | vfio" );
Signature · 1 line
2.5.5
PATCH v2 5/18 net/ixgbe: restore ether type filter
In reply to Wei ZhaoAdd support for restoring ether type filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 84 ++++++++++++++++++---------------------- drivers/net/ixgbe/ixgbe_ethdev.h | 57 ++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_pf.c | 25 +++++++----- 3 files changed, 109 insertions(+), 57 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +37 -47
@@ -1273,6 +1273,11 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* enable support intr */ ixgbe_enable_intr (eth_dev); +/* initialize ether type filter */ + filter_info->ethertype_mask =0 ; +memset (filter_info->ethertype_filters,0 , +sizeof (struct ixgbe_ethertype_filter ) *IXGBE_MAX_ETQF_FILTERS ); +/* initialize 5tuple filter list */ TAILQ_INIT (&filter_info->fivetuple_list); memset(filter_info->fivetuple_mask, 0,
@@ -6209,47 +6214,6 @@ ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,return ret; } -static inline int -ixgbe_ethertype_filter_lookup (struct ixgbe_filter_info *filter_info, -uint16_t ethertype) -{ -int i; - -for (i =0 ; i <IXGBE_MAX_ETQF_FILTERS ; i++) { -if (filter_info->ethertype_filters[i] == ethertype && - (filter_info->ethertype_mask & (1 << i))) -return i; - } -return -1 ; -} - -static inline int -ixgbe_ethertype_filter_insert (struct ixgbe_filter_info *filter_info, -uint16_t ethertype) -{ -int i; - -for (i =0 ; i <IXGBE_MAX_ETQF_FILTERS ; i++) { -if (!(filter_info->ethertype_mask & (1 << i))) { - filter_info->ethertype_mask |=1 << i; - filter_info->ethertype_filters[i] = ethertype; -return i; - } - } -return -1 ; -} - -static inline int -ixgbe_ethertype_filter_remove (struct ixgbe_filter_info *filter_info, -uint8_t idx) -{ -if (idx >=IXGBE_MAX_ETQF_FILTERS ) -return -1 ; - filter_info->ethertype_mask &= ~(1 << idx); - filter_info->ethertype_filters[idx] =0 ; -return idx; -} - static int ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev, struct rte_eth_ethertype_filter *filter,
@@ -6261,6 +6225,7 @@ ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,uint32_t etqf =0 ;uint32_t etqs =0 ;int ret; +struct ixgbe_ethertype_filter ethertype_filter;if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM )return -EINVAL ;
@@ -6294,18 +6259,22 @@ ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev, }if (add) { - ret =ixgbe_ethertype_filter_insert (filter_info, - filter->ether_type); -if (ret <0 ) { -PMD_DRV_LOG (ERR ,"ethertype filters are full." ); -return -ENOSYS ; - } etqf =IXGBE_ETQF_FILTER_EN ; etqf |= (uint32_t )filter->ether_type; etqs |= (uint32_t )((filter->queue <<IXGBE_ETQS_RX_QUEUE_SHIFT ) &IXGBE_ETQS_RX_QUEUE ); etqs |=IXGBE_ETQS_QUEUE_EN ; + + ethertype_filter.ethertype = filter->ether_type; + ethertype_filter.etqf = etqf; + ethertype_filter.etqs = etqs; + ret =ixgbe_ethertype_filter_insert (filter_info, + ðertype_filter); +if (ret <0 ) { +PMD_DRV_LOG (ERR ,"ethertype filters are full." ); +return -ENOSPC ; + } }else { ret =ixgbe_ethertype_filter_remove (filter_info, (uint8_t )ret);if (ret <0 )
@@ -7910,10 +7879,31 @@ ixgbe_ntuple_filter_restore(struct rte_eth_dev *dev) } } +/* restore ethernet type filter */ +static inline void +ixgbe_ethertype_filter_restore (struct rte_eth_dev *dev) +{ +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (dev->data->dev_private); +int i; + +for (i =0 ; i <IXGBE_MAX_ETQF_FILTERS ; i++) { +if (filter_info->ethertype_mask & (1 << i)) { +IXGBE_WRITE_REG (hw,IXGBE_ETQF (i), + filter_info->ethertype_filters[i].etqf); +IXGBE_WRITE_REG (hw,IXGBE_ETQS (i), + filter_info->ethertype_filters[i].etqs); +IXGBE_WRITE_FLUSH (hw); + } + } +} +static int ixgbe_filter_restore (struct rte_eth_dev *dev) {ixgbe_ntuple_filter_restore (dev); +ixgbe_ethertype_filter_restore (dev);return 0 ; }
drivers/net/ixgbe/ixgbe_ethdev.h +56 -1
73 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_pf.c +16 -9
@@ -176,6 +176,7 @@ ixgbe_add_tx_flow_control_drop_filter(struct rte_eth_dev *eth_dev)IXGBE_DEV_PRIVATE_TO_FILTER_INFO (eth_dev->data->dev_private);uint16_t vf_num;int i; +struct ixgbe_ethertype_filter ethertype_filter;if (!hw->mac.ops.set_ethertype_anti_spoofing) { RTE_LOG(INFO, PMD, "ether type anti-spoofing is not"
@@ -183,16 +184,22 @@ ixgbe_add_tx_flow_control_drop_filter(struct rte_eth_dev *eth_dev)return ; } -/* occupy an entity of ether type filter */ -for (i =0 ; i <IXGBE_MAX_ETQF_FILTERS ; i++) { -if (!(filter_info->ethertype_mask & (1 << i))) { - filter_info->ethertype_mask |=1 << i; - filter_info->ethertype_filters[i] = -IXGBE_ETHERTYPE_FLOW_CTRL ; -break ; - } + i =ixgbe_ethertype_filter_lookup (filter_info, +IXGBE_ETHERTYPE_FLOW_CTRL ); +if (i >=0 ) { +RTE_LOG (ERR ,PMD ,"A ether type filter" +" entity for flow control already exists!\n" ); +return ; } -if (i ==IXGBE_MAX_ETQF_FILTERS ) { + + ethertype_filter.ethertype =IXGBE_ETHERTYPE_FLOW_CTRL ; + ethertype_filter.etqf =IXGBE_ETQF_FILTER_EN | +IXGBE_ETQF_TX_ANTISPOOF | +IXGBE_ETHERTYPE_FLOW_CTRL ; + ethertype_filter.etqs =0 ; + i =ixgbe_ethertype_filter_insert (filter_info, + ðertype_filter); +if (i <0 ) {RTE_LOG (ERR ,PMD ,"Cannot find an unused ether type filter" " entity for flow control.\n" );return ;
Signature · 1 line
2.5.5
PATCH v2 6/18 net/ixgbe: restore TCP SYN filter
In reply to Wei ZhaoAdd support for restoring TCP SYN filter in SW.
---
v2:
--change git log expression
--- drivers/net/ixgbe/ixgbe_ethdev.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +18 -0
@@ -7899,11 +7899,29 @@ ixgbe_ethertype_filter_restore(struct rte_eth_dev *dev) } } +/* restore SYN filter */ +static inline void +ixgbe_syn_filter_restore (struct rte_eth_dev *dev) +{ +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (dev->data->dev_private); +uint32_t synqf; + + synqf = filter_info->syn_info; + +if (synqf &IXGBE_SYN_FILTER_ENABLE ) { +IXGBE_WRITE_REG (hw,IXGBE_SYNQF , synqf); +IXGBE_WRITE_FLUSH (hw); + } +} +static int ixgbe_filter_restore (struct rte_eth_dev *dev) {ixgbe_ntuple_filter_restore (dev);ixgbe_ethertype_filter_restore (dev); +ixgbe_syn_filter_restore (dev);return 0 ; }
Signature · 1 line
2.5.5
PATCH v2 7/18 net/ixgbe: restore flow director filter
In reply to Wei ZhaoAdd support for storing flow director filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 1 + drivers/net/ixgbe/ixgbe_fdir.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -0
@@ -7922,6 +7922,7 @@ ixgbe_filter_restore(struct rte_eth_dev *dev)ixgbe_ntuple_filter_restore (dev);ixgbe_ethertype_filter_restore (dev);ixgbe_syn_filter_restore (dev); +ixgbe_fdir_filter_restore (dev);return 0 ; }
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
@@ -491,6 +491,7 @@ uint32_t ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val);int ixgbe_fdir_ctrl_func (struct rte_eth_dev *dev,enum rte_filter_op filter_op,void *arg); +void ixgbe_fdir_filter_restore (struct rte_eth_dev *dev); static inline int ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
drivers/net/ixgbe/ixgbe_fdir.c +35 -0
@@ -1479,3 +1479,38 @@ ixgbe_fdir_ctrl_func(struct rte_eth_dev *dev, }return ret; } + +/* restore flow director filter */ +void +ixgbe_fdir_filter_restore (struct rte_eth_dev *dev) +{ +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data->dev_private); +struct ixgbe_fdir_filter *node; +bool is_perfect = FALSE; +enum rte_fdir_mode fdir_mode = dev->data->dev_conf.fdir_conf.mode; + +if (fdir_mode >=RTE_FDIR_MODE_PERFECT && + fdir_mode <=RTE_FDIR_MODE_PERFECT_TUNNEL ) + is_perfect = TRUE; + +if (is_perfect) { + TAILQ_FOREACH(node, &fdir_info->fdir_list, entries) { + (void )fdir_write_perfect_filter_82599 (hw, + &node->ixgbe_fdir, + node->queue, + node->fdirflags, + node->fdirhash, + fdir_mode); + } + }else { + TAILQ_FOREACH(node, &fdir_info->fdir_list, entries) { + (void )fdir_add_signature_filter_82599 (hw, + &node->ixgbe_fdir, + node->queue, + node->fdirflags, + node->fdirhash); + } + } +}
Signature · 1 line
2.5.5
PATCH v2 8/18 net/ixgbe: restore L2 tunnel filter
In reply to Wei ZhaoAdd support for restoring L2 tunnel filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 69 ++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 23 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +46 -23
@@ -7279,7 +7279,8 @@ ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,/* Add l2 tunnel filter */ static int ixgbe_dev_l2_tunnel_filter_add (struct rte_eth_dev *dev, -struct rte_eth_l2_tunnel_conf *l2_tunnel) +struct rte_eth_l2_tunnel_conf *l2_tunnel, +bool restore) {int ret =0 ; struct ixgbe_l2_tn_info *l2_tn_info =
@@ -7287,30 +7288,33 @@ ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,struct ixgbe_l2_tn_key key;struct ixgbe_l2_tn_filter *node; - key.l2_tn_type = l2_tunnel->l2_tunnel_type; - key.tn_id = l2_tunnel->tunnel_id; +if (!restore) { + key.l2_tn_type = l2_tunnel->l2_tunnel_type; + key.tn_id = l2_tunnel->tunnel_id; - node =ixgbe_l2_tn_filter_lookup (l2_tn_info, &key); + node =ixgbe_l2_tn_filter_lookup (l2_tn_info, &key); -if (node) { -PMD_DRV_LOG (ERR ,"The L2 tunnel filter already exists!" ); -return -EINVAL ; - } +if (node) { +PMD_DRV_LOG (ERR , +"The L2 tunnel filter already exists!" ); +return -EINVAL ; + } - node =rte_zmalloc ("ixgbe_l2_tn" , -sizeof (struct ixgbe_l2_tn_filter ), -0 ); -if (!node) -return -ENOMEM ; + node =rte_zmalloc ("ixgbe_l2_tn" , +sizeof (struct ixgbe_l2_tn_filter ), +0 ); +if (!node) +return -ENOMEM ; - (void )rte_memcpy (&node->key, - &key, -sizeof (struct ixgbe_l2_tn_key )); - node->pool = l2_tunnel->pool; - ret =ixgbe_insert_l2_tn_filter (l2_tn_info, node); -if (ret <0 ) { -rte_free (node); -return ret; + (void )rte_memcpy (&node->key, + &key, +sizeof (struct ixgbe_l2_tn_key )); + node->pool = l2_tunnel->pool; + ret =ixgbe_insert_l2_tn_filter (l2_tn_info, node); +if (ret <0 ) { +rte_free (node); +return ret; + } }switch (l2_tunnel->l2_tunnel_type) {
@@ -7323,7 +7327,7 @@ ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,break ; } -if (ret <0 ) +if ((!restore) && (ret <0 )) (void )ixgbe_remove_l2_tn_filter (l2_tn_info, &key);return ret;
@@ -7384,7 +7388,8 @@ ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,case RTE_ETH_FILTER_ADD : ret =ixgbe_dev_l2_tunnel_filter_add (dev, - (struct rte_eth_l2_tunnel_conf *)arg); + (struct rte_eth_l2_tunnel_conf *)arg, + FALSE);break ;case RTE_ETH_FILTER_DELETE : ret = ixgbe_dev_l2_tunnel_filter_del
@@ -7916,6 +7921,23 @@ ixgbe_syn_filter_restore(struct rte_eth_dev *dev) } } +/* restore L2 tunnel filter */ +static inline void +ixgbe_l2_tn_filter_restore (struct rte_eth_dev *dev) +{ +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private); +struct ixgbe_l2_tn_filter *node; +struct rte_eth_l2_tunnel_conf l2_tn_conf; + + TAILQ_FOREACH(node, &l2_tn_info->l2_tn_list, entries) { + l2_tn_conf.l2_tunnel_type = node->key.l2_tn_type; + l2_tn_conf.tunnel_id = node->key.tn_id; + l2_tn_conf.pool = node->pool; + (void )ixgbe_dev_l2_tunnel_filter_add (dev, &l2_tn_conf, TRUE); + } +} +static int ixgbe_filter_restore (struct rte_eth_dev *dev) {
@@ -7923,6 +7945,7 @@ ixgbe_filter_restore(struct rte_eth_dev *dev)ixgbe_ethertype_filter_restore (dev);ixgbe_syn_filter_restore (dev);ixgbe_fdir_filter_restore (dev); +ixgbe_l2_tn_filter_restore (dev);return 0 ; }
Signature · 1 line
2.5.5
PATCH v2 9/18 net/ixgbe: store and restore L2 tunnel configuration
In reply to Wei ZhaoAdd support for store and restore L2 tunnel filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 3 +++ 2 files changed, 39 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +36 -0
@@ -385,6 +385,7 @@ static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,static int ixgbe_dev_udp_tunnel_port_del (struct rte_eth_dev *dev,struct rte_eth_udp_tunnel *udp_tunnel);static int ixgbe_filter_restore (struct rte_eth_dev *dev); +static void ixgbe_l2_tunnel_conf (struct rte_eth_dev *dev);/* * Define VF Stats MACRO for Non "cleared on read" register
@@ -1444,6 +1445,9 @@ static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev) "Failed to allocate memory for L2 TN hash map!");return -ENOMEM ; } + l2_tn_info->e_tag_en = FALSE; + l2_tn_info->e_tag_fwd_en = FALSE; + l2_tn_info->e_tag_ether_type =DEFAULT_ETAG_ETYPE ;return 0 ; }
@@ -2502,6 +2506,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)/* resume enabled intr since hw reset */ ixgbe_enable_intr (dev); +ixgbe_l2_tunnel_conf (dev);ixgbe_filter_restore (dev);return 0 ;
@@ -7038,12 +7043,15 @@ ixgbe_dev_l2_tunnel_eth_type_conf(struct rte_eth_dev *dev, {int ret =0 ;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private);if (l2_tunnel ==NULL )return -EINVAL ;switch (l2_tunnel->l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG : + l2_tn_info->e_tag_ether_type = l2_tunnel->ether_type; ret =ixgbe_update_e_tag_eth_type (hw, l2_tunnel->ether_type);break ;default :
@@ -7082,9 +7090,12 @@ ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev *dev, {int ret =0 ;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private);switch (l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG : + l2_tn_info->e_tag_en = TRUE; ret =ixgbe_e_tag_enable (hw);break ;default :
@@ -7123,9 +7134,12 @@ ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev *dev, {int ret =0 ;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private);switch (l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG : + l2_tn_info->e_tag_en = FALSE; ret =ixgbe_e_tag_disable (hw);break ;default :
@@ -7432,10 +7446,13 @@ ixgbe_dev_l2_tunnel_forwarding_enable (struct rte_eth_dev *dev, enum rte_eth_tunnel_type l2_tunnel_type) { +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private);int ret =0 ;switch (l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG : + l2_tn_info->e_tag_fwd_en = TRUE; ret =ixgbe_e_tag_forwarding_en_dis (dev,1 );break ;default :
@@ -7453,10 +7470,13 @@ ixgbe_dev_l2_tunnel_forwarding_disable (struct rte_eth_dev *dev, enum rte_eth_tunnel_type l2_tunnel_type) { +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private);int ret =0 ;switch (l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG : + l2_tn_info->e_tag_fwd_en = FALSE; ret =ixgbe_e_tag_forwarding_en_dis (dev,0 );break ;default :
@@ -7950,6 +7970,22 @@ ixgbe_filter_restore(struct rte_eth_dev *dev)return 0 ; } +static void +ixgbe_l2_tunnel_conf (struct rte_eth_dev *dev) +{ +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private); +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); + +if (l2_tn_info->e_tag_en) + (void )ixgbe_e_tag_enable (hw); + +if (l2_tn_info->e_tag_fwd_en) + (void )ixgbe_e_tag_forwarding_en_dis (dev,1 ); + + (void )ixgbe_update_e_tag_eth_type (hw, l2_tn_info->e_tag_ether_type); +} +RTE_PMD_REGISTER_PCI (net_ixgbe, rte_ixgbe_pmd.pci_drv);RTE_PMD_REGISTER_PCI_TABLE (net_ixgbe, pci_id_ixgbe_map);RTE_PMD_REGISTER_KMOD_DEP (net_ixgbe,"* igb_uio | uio_pci_generic | vfio" );
drivers/net/ixgbe/ixgbe_ethdev.h +3 -0
@@ -307,6 +307,9 @@ struct ixgbe_l2_tn_info {struct ixgbe_l2_tn_filter_list l2_tn_list;struct ixgbe_l2_tn_filter **hash_map;struct rte_hash *hash_handle; +bool e_tag_en;/* e-tag enabled */ +bool e_tag_fwd_en;/* e-tag based forwarding enabled */ +bool e_tag_ether_type;/* ether type for e-tag */ };/*
Signature · 1 line
2.5.5
Re: [PATCH v2 09/18] net/ixgbe: store and restore L2 tunnel configuration
Quoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhao1, Wei <[email protected]>
Subject: [dpdk-dev] [PATCH v2 09/18] net/ixgbe: store and restore L2 tunnel configurationAdd support for store and restore L2 tunnel filter in SW.
The whole patch set is related to filter, so do you think it's better to move the patch from his patch set since it's related to configuration? Please help to check.
Quoted 151 lines
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 3 +++ 2 files changed, 39 insertions(+)drivers/net/ixgbe/ixgbe_ethdev.c +0
-0@@ -385,6 +385,7 @@ static int ixgbe_dev_udp_tunnel_port_add(struct
rte_eth_dev*dev, static int ixgbe_dev_udp_tunnel_port_del(structrte_eth_dev*dev,
structrte_eth_udp_tunnel*udp_tunnel); static intixgbe_filter_restore(struct rte_eth_dev *dev);drivers/net/ixgbe/ixgbe_ethdev.c +9
-0+static void ixgbe_l2_tunnel_conf (struct rte_eth_dev *dev);/* * Define VF Stats MACRO for Non "cleared on read" register @@ -1444,6 +1445,9 @@ static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev) "Failed to allocate memory for L2 TN hash map!"); return -ENOMEM; } +l2_tn_info->e_tag_en = FALSE; +l2_tn_info->e_tag_fwd_en = FALSE; +l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE; return 0; } @@ -2502,6 +2506,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)/* resume enabled intr since hw reset */ ixgbe_enable_intr (dev); +ixgbe_l2_tunnel_conf (dev);ixgbe_filter_restore (dev);return 0 ;@@ -7038,12 +7043,15 @@ ixgbe_dev_l2_tunnel_eth_type_conf(struct rte_eth_dev *dev, { int ret = 0;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private);if (l2_tunnel ==NULL )return -EINVAL ;switch (l2_tunnel->l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG : + l2_tn_info->e_tag_ether_type = l2_tunnel->ether_type; ret =ixgbe_update_e_tag_eth_type (hw, l2_tunnel->ether_type);break ;drivers/net/ixgbe/ixgbe_ethdev.c +3
-0default :@@ -7082,9 +7090,12 @@ ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev *dev, {int ret =0 ;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private);switch (l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG : + l2_tn_info->e_tag_en = TRUE; ret =ixgbe_e_tag_enable (hw);break ;drivers/net/ixgbe/ixgbe_ethdev.c +3
-0default :@@ -7123,9 +7134,12 @@ ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev *dev, {int ret =0 ;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private);switch (l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG : + l2_tn_info->e_tag_en = FALSE; ret =ixgbe_e_tag_disable (hw);break ;drivers/net/ixgbe/ixgbe_ethdev.c +20
-0default :@@ -7432,10 +7446,13 @@ ixgbe_dev_l2_tunnel_forwarding_enable (struct rte_eth_dev *dev, enum rte_eth_tunnel_type l2_tunnel_type) { +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private);int ret =0 ;switch (l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG : + l2_tn_info->e_tag_fwd_en = TRUE; ret =ixgbe_e_tag_forwarding_en_dis (dev,1 );break ;default :@@ -7453,10 +7470,13 @@ ixgbe_dev_l2_tunnel_forwarding_disable (struct rte_eth_dev *dev, enum rte_eth_tunnel_type l2_tunnel_type) { +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private);int ret =0 ;switch (l2_tunnel_type) {case RTE_L2_TUNNEL_TYPE_E_TAG : + l2_tn_info->e_tag_fwd_en = FALSE; ret =ixgbe_e_tag_forwarding_en_dis (dev,0 );break ;default :@@ -7950,6 +7970,22 @@ ixgbe_filter_restore(struct rte_eth_dev *dev)return 0 ; } +static void +ixgbe_l2_tunnel_conf (struct rte_eth_dev *dev) { +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private); +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); + +if (l2_tn_info->e_tag_en) + (void )ixgbe_e_tag_enable (hw); + +if (l2_tn_info->e_tag_fwd_en) + (void )ixgbe_e_tag_forwarding_en_dis (dev,1 ); + + (void )ixgbe_update_e_tag_eth_type (hw, l2_tn_info->e_tag_ether_type); } +RTE_PMD_REGISTER_PCI (net_ixgbe, rte_ixgbe_pmd.pci_drv);RTE_PMD_REGISTER_PCI_TABLE (net_ixgbe, pci_id_ixgbe_map);
RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio"); diff --gita/drivers/net/ixgbe/ixgbe_ethdev.hb/drivers/net/ixgbe/ixgbe_ethdev.h
index d6253ad..6327962 100644drivers/net/ixgbe/ixgbe_ethdev.h +3
-1@@ -307,6 +307,9 @@ struct ixgbe_l2_tn_info {struct ixgbe_l2_tn_filter_list l2_tn_list;struct ixgbe_l2_tn_filter **hash_map;struct rte_hash *hash_handle; +bool e_tag_en;/* e-tag enabled */ +bool e_tag_fwd_en;/* e-tag based forwarding enabled */ +bool e_tag_ether_type;/* ether type for e-tag */ };/* -- 2.5.5
PATCH v2 10/18 net/ixgbe: flush all the filters
In reply to Wei ZhaoAdd support for flush all the filters in SW.
---
v2:
--change flush filter function call relationship
--- drivers/net/ixgbe/ixgbe_ethdev.c | 118 ++++++++++++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 9 +++ drivers/net/ixgbe/ixgbe_fdir.c | 24 ++++++++ drivers/net/ixgbe/ixgbe_pf.c | 1 + 4 files changed, 150 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +116 -2
@@ -61,6 +61,8 @@#include <rte_random.h> #include <rte_dev.h> #include <rte_hash_crc.h> +#include <rte_flow.h> +#include <rte_flow_driver.h> #include "ixgbe_logs.h" #include "base/ixgbe_api.h"
@@ -386,7 +388,8 @@ static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel);static int ixgbe_filter_restore (struct rte_eth_dev *dev);static void ixgbe_l2_tunnel_conf (struct rte_eth_dev *dev); - +static int ixgbe_flow_flush (struct rte_eth_dev *dev, +struct rte_flow_error *error);/* * Define VF Stats MACRO for Non "cleared on read" register */
@@ -765,7 +768,13 @@ static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {#define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \ sizeof(rte_ixgbevf_stats_strings[0])) - +static const struct rte_flow_ops ixgbe_flow_ops = { +NULL , +NULL , +NULL , + ixgbe_flow_flush, +NULL , +};/** * Atomically reads the link status information from global * structure rte_eth_dev.
@@ -6274,6 +6283,7 @@ ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev, ethertype_filter.ethertype = filter->ether_type; ethertype_filter.etqf = etqf; ethertype_filter.etqs = etqs; + ethertype_filter.conf = FALSE; ret =ixgbe_ethertype_filter_insert (filter_info, ðertype_filter);if (ret <0 ) {
@@ -6393,6 +6403,11 @@ ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,case RTE_ETH_FILTER_L2_TUNNEL : ret =ixgbe_dev_l2_tunnel_filter_handle (dev, filter_op, arg);break ; +case RTE_ETH_FILTER_GENERIC : +if (filter_op !=RTE_ETH_FILTER_GET ) +return -EINVAL ; + *(const void **)arg = &ixgbe_flow_ops; +break ;default :PMD_DRV_LOG (WARNING ,"Filter type (%d) not supported" , filter_type);
@@ -7986,6 +8001,105 @@ ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev) (void )ixgbe_update_e_tag_eth_type (hw, l2_tn_info->e_tag_ether_type); } +/* remove all the n-tuple filters */ +static void +ixgbe_clear_all_ntuple_filter (struct rte_eth_dev *dev) +{ +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (dev->data->dev_private); +struct ixgbe_5tuple_filter *p_5tuple; + +while ((p_5tuple =TAILQ_FIRST (&filter_info->fivetuple_list))) +ixgbe_remove_5tuple_filter (dev, p_5tuple); +} + +/* remove all the ether type filters */ +static void +ixgbe_clear_all_ethertype_filter (struct rte_eth_dev *dev) +{ +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (dev->data->dev_private); +int i; + +for (i =0 ; i <IXGBE_MAX_ETQF_FILTERS ; i++) { +if (filter_info->ethertype_mask & (1 << i) && + !filter_info->ethertype_filters[i].conf) { + (void )ixgbe_ethertype_filter_remove (filter_info, + (uint8_t )i); +IXGBE_WRITE_REG (hw,IXGBE_ETQF (i),0 ); +IXGBE_WRITE_REG (hw,IXGBE_ETQS (i),0 ); +IXGBE_WRITE_FLUSH (hw); + } + } +} + +/* remove the SYN filter */ +static void +ixgbe_clear_syn_filter (struct rte_eth_dev *dev) +{ +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (dev->data->dev_private); + +if (filter_info->syn_info &IXGBE_SYN_FILTER_ENABLE ) { + filter_info->syn_info =0 ; + +IXGBE_WRITE_REG (hw,IXGBE_SYNQF ,0 ); +IXGBE_WRITE_FLUSH (hw); + } +} + +/* remove all the L2 tunnel filters */ +static int +ixgbe_clear_all_l2_tn_filter (struct rte_eth_dev *dev) +{ +struct ixgbe_l2_tn_info *l2_tn_info = +IXGBE_DEV_PRIVATE_TO_L2_TN_INFO (dev->data->dev_private); +struct ixgbe_l2_tn_filter *l2_tn_filter; +struct rte_eth_l2_tunnel_conf l2_tn_conf; +int ret =0 ; + +while ((l2_tn_filter =TAILQ_FIRST (&l2_tn_info->l2_tn_list))) { + l2_tn_conf.l2_tunnel_type = l2_tn_filter->key.l2_tn_type; + l2_tn_conf.tunnel_id = l2_tn_filter->key.tn_id; + l2_tn_conf.pool = l2_tn_filter->pool; + ret =ixgbe_dev_l2_tunnel_filter_del (dev, &l2_tn_conf); +if (ret <0 ) +return ret; + } + +return 0 ; +} + +/* Destroy all flow rules associated with a port on ixgbe. */ +static int +ixgbe_flow_flush (struct rte_eth_dev *dev, +struct rte_flow_error *error) +{ +int ret =0 ; + +ixgbe_clear_all_ntuple_filter (dev); +ixgbe_clear_all_ethertype_filter (dev); +ixgbe_clear_syn_filter (dev); + + ret =ixgbe_clear_all_fdir_filter (dev); +if (ret <0 ) { +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_HANDLE , +NULL ,"Failed to flush rule" ); +return ret; + } + + ret =ixgbe_clear_all_l2_tn_filter (dev); +if (ret <0 ) { +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_HANDLE , +NULL ,"Failed to flush rule" ); +return ret; + } + +return 0 ; +} +RTE_PMD_REGISTER_PCI (net_ixgbe, rte_ixgbe_pmd.pci_drv);RTE_PMD_REGISTER_PCI_TABLE (net_ixgbe, pci_id_ixgbe_map);RTE_PMD_REGISTER_KMOD_DEP (net_ixgbe,"* igb_uio | uio_pci_generic | vfio" );
drivers/net/ixgbe/ixgbe_ethdev.h +9 -0
@@ -274,6 +274,11 @@ struct ixgbe_ethertype_filter {uint16_t ethertype;uint32_t etqf;uint32_t etqs; +/** +* If this filter is added by configuration, +* it should not be removed. +*/ +bool conf; };/*
@@ -495,6 +500,7 @@ uint32_t ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val);int ixgbe_fdir_ctrl_func (struct rte_eth_dev *dev,enum rte_filter_op filter_op,void *arg);void ixgbe_fdir_filter_restore (struct rte_eth_dev *dev); +int ixgbe_clear_all_fdir_filter (struct rte_eth_dev *dev); static inline int ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
@@ -525,6 +531,8 @@ ixgbe_ethertype_filter_insert(struct ixgbe_filter_info *filter_info, ethertype_filter->etqf; filter_info->ethertype_filters[i].etqs = ethertype_filter->etqs; + filter_info->ethertype_filters[i].conf = + ethertype_filter->conf;return i; } }
@@ -541,6 +549,7 @@ ixgbe_ethertype_filter_remove(struct ixgbe_filter_info *filter_info, filter_info->ethertype_filters[idx].ethertype =0 ; filter_info->ethertype_filters[idx].etqf =0 ; filter_info->ethertype_filters[idx].etqs =0 ; + filter_info->ethertype_filters[idx].etqs = FALSE;return idx; }
drivers/net/ixgbe/ixgbe_fdir.c +24 -0
@@ -1514,3 +1514,27 @@ ixgbe_fdir_filter_restore(struct rte_eth_dev *dev) } } } + +/* remove all the flow director filters */ +int +ixgbe_clear_all_fdir_filter (struct rte_eth_dev *dev) +{ +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data->dev_private); +struct ixgbe_fdir_filter *fdir_filter; +int ret =0 ; + +/* flush flow director */ +rte_hash_reset (fdir_info->hash_handle); +memset (fdir_info->hash_map,0 , +sizeof (struct ixgbe_fdir_filter *) *IXGBE_MAX_FDIR_FILTER_NUM ); +while ((fdir_filter =TAILQ_FIRST (&fdir_info->fdir_list))) { +TAILQ_REMOVE (&fdir_info->fdir_list, + fdir_filter, + entries); +rte_free (fdir_filter); + } + ret =ixgbe_fdir_flush (dev); + +return ret; +}
drivers/net/ixgbe/ixgbe_pf.c +1 -0
@@ -197,6 +197,7 @@ ixgbe_add_tx_flow_control_drop_filter(struct rte_eth_dev *eth_dev)IXGBE_ETQF_TX_ANTISPOOF |IXGBE_ETHERTYPE_FLOW_CTRL ; ethertype_filter.etqs =0 ; + ethertype_filter.conf = TRUE; i =ixgbe_ethertype_filter_insert (filter_info, ðertype_filter);if (i <0 ) {
Signature · 1 line
2.5.5
Re: [PATCH v2 10/18] net/ixgbe: flush all the filters
Quoted 30 lines · Wei Zhao
Add support for flush all the filters in SW.
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--change flush filter function call relationship--- drivers/net/ixgbe/ixgbe_ethdev.c | 118 ++++++++++++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 9 +++ drivers/net/ixgbe/ixgbe_fdir.c | 24 ++++++++ drivers/net/ixgbe/ixgbe_pf.c | 1 + 4 files changed, 150 insertions(+), 2 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +2
-0@@ -61,6 +61,8 @@#include <rte_random.h> #include <rte_dev.h> #include <rte_hash_crc.h> +#include <rte_flow.h> +#include <rte_flow_driver.h> #include "ixgbe_logs.h" #include "base/ixgbe_api.h"
drivers/net/ixgbe/ixgbe_ethdev.c static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, · line 392
Quoted 6 lines
drivers/net/ixgbe/ixgbe_ethdev.c +2
-1@@ -386,7 +388,8 @@ static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel);static int ixgbe_filter_restore (struct rte_eth_dev *dev);static void ixgbe_l2_tunnel_conf (struct rte_eth_dev *dev); - +static int ixgbe_flow_flush (struct rte_eth_dev *dev, +struct rte_flow_error *error);
I think it is good idea to move all rte_flow related code into a new file, as done in i40e (i40e_flow.c)? What do you think, can it be done?
<...>
Re: [PATCH v2 10/18] net/ixgbe: flush all the filters
Hi,yigit
Quoted 43 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, January 7, 2017 12:40 AM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 10/18] net/ixgbe: flush all the filtersQuoted 11 lines · Wei Zhao
Add support for flush all the filters in SW.
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--change flush filter function call relationship--- drivers/net/ixgbe/ixgbe_ethdev.c | 118++++++++++++++++++++++++++++++++++++++-
drivers/net/ixgbe/ixgbe_ethdev.c static int ixgbe_dev_udp_tunnel_port_del(struct
Quoted 20 lines
drivers/net/ixgbe/ixgbe_ethdev.h | 9 +++ drivers/net/ixgbe/ixgbe_fdir.c | 24 ++++++++ drivers/net/ixgbe/ixgbe_pf.c | 1 + 4 files changed, 150 insertions(+), 2 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +2
-0@@ -61,6 +61,8 @@#include <rte_random.h> #include <rte_dev.h> #include <rte_hash_crc.h> +#include <rte_flow.h> +#include <rte_flow_driver.h> #include "ixgbe_logs.h" #include "base/ixgbe_api.h" @@ -386,7 +388,8 @@ static int ixgbe_dev_udp_tunnel_port_del(struct
rte_eth_dev*dev,drivers/net/ixgbe/ixgbe_ethdev.c static int ixgbe_dev_udp_tunnel_port_del(struct · line 388
Quoted 1 line
drivers/net/ixgbe/ixgbe_ethdev.c +0
-0struct rte_eth_udp_tunnel
*udp_tunnel); static int
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, · line 392
Quoted 5 lines
ixgbe_filter_restore(struct rte_eth_dev *dev); static voidixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);drivers/net/ixgbe/ixgbe_ethdev.c +2
-1- +static int ixgbe_flow_flush (struct rte_eth_dev *dev, +struct rte_flow_error *error);I think it is good idea to move all
rte_flowrelated code into a new file, as done in i40e (i40e_flow.c)? What do you think, can it be done?
I will do as your suggestion in v3.
Quoted 2 lines
<...>
PATCH v2 11/18 net/ixgbe: parse n-tuple filter
In reply to Wei ZhaoAdd rule validate function and check if the rule is a n-tuple rule, and get the n-tuple info.
---
v2:add new error set function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 414 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 409 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +409 -5
@@ -388,6 +388,24 @@ static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel);static int ixgbe_filter_restore (struct rte_eth_dev *dev);static void ixgbe_l2_tunnel_conf (struct rte_eth_dev *dev); +static int +cons_parse_ntuple_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ntuple_filter *filter, +struct rte_flow_error *error); +static int +ixgbe_parse_ntuple_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ntuple_filter *filter, +struct rte_flow_error *error); +static int +ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error);static int ixgbe_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error);/*
@@ -769,7 +787,7 @@ static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {#define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \ sizeof(rte_ixgbevf_stats_strings[0]))static const struct rte_flow_ops ixgbe_flow_ops = { -NULL , + ixgbe_flow_validate,NULL ,NULL , ixgbe_flow_flush,
@@ -8072,6 +8090,390 @@ ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)return 0 ; } +static inline uint32_t +rte_be_to_cpu_24 (uint32_t x) +{ +return ((x &0x000000ffUL ) <<16 ) | + (x &0x0000ff00UL ) | + ((x &0x00ff0000UL ) >>16 ); +} + +#define IXGBE_MIN_N_TUPLE_PRIO 1 +#define IXGBE_MAX_N_TUPLE_PRIO 7 +#define NEXT_ITEM_OF_PATTERN (item, pattern, index)\ + do { \ + item = pattern + index;\ + while (item->type == RTE_FLOW_ITEM_TYPE_VOID) {\ + index++; \ + item = pattern + index; \ + } \ + } while (0) + +#define NEXT_ITEM_OF_ACTION (act, actions, index)\ + do { \ + act = actions + index; \ + while (act->type == RTE_FLOW_ACTION_TYPE_VOID) {\ + index++; \ + act = actions + index; \ + } \ + } while (0) + +/** +* Please aware there's an asumption for all the parsers. +* rte_flow_item is using big endian, rte_flow_attr and +* rte_flow_action are using CPU order. +* Because the pattern is used to describe the packets, +* normally the packets should use network order. +*/ + +/** +* Parse the rule to see if it is a n-tuple rule. +* And get the n-tuple filter info BTW. +*/ +static int +cons_parse_ntuple_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ntuple_filter *filter, +struct rte_flow_error *error) +{ +const struct rte_flow_item *item; +const struct rte_flow_action *act; +const struct rte_flow_item_ipv4 *ipv4_spec; +const struct rte_flow_item_ipv4 *ipv4_mask; +const struct rte_flow_item_tcp *tcp_spec; +const struct rte_flow_item_tcp *tcp_mask; +const struct rte_flow_item_udp *udp_spec; +const struct rte_flow_item_udp *udp_mask; +uint32_t index; + +if (!pattern) { +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } + +/* parse pattern */ + index =0 ; + +/* the first not void item can be MAC or IPv4 */ +NEXT_ITEM_OF_PATTERN (item, pattern, index); + +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH && + item->type !=RTE_FLOW_ITEM_TYPE_IPV4 ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } +/* Skip Ethernet */ +if (item->type ==RTE_FLOW_ITEM_TYPE_ETH ) { +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + + } +/* if the first item is MAC, the content should be NULL */ +if (item->spec || item->mask) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } +/* check if the next not void item is IPv4 */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 ) { +rte_flow_error_set (error, +EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + } + +/* get the IPv4 info */ +if (!item->spec || !item->mask) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Invalid ntuple mask" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + + } + + ipv4_mask = (const struct rte_flow_item_ipv4 *)item->mask; +/** +* Only support src & dst addresses, protocol, +* others should be masked. +*/ +if (ipv4_mask->hdr.version_ihl || + ipv4_mask->hdr.type_of_service || + ipv4_mask->hdr.total_length || + ipv4_mask->hdr.packet_id || + ipv4_mask->hdr.fragment_offset || + ipv4_mask->hdr.time_to_live || + ipv4_mask->hdr.hdr_checksum) { +rte_flow_error_set (error, +EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + + filter->dst_ip_mask = ipv4_mask->hdr.dst_addr; + filter->src_ip_mask = ipv4_mask->hdr.src_addr; + filter->proto_mask = ipv4_mask->hdr.next_proto_id; + + ipv4_spec = (const struct rte_flow_item_ipv4 *)item->spec; + filter->dst_ip = ipv4_spec->hdr.dst_addr; + filter->src_ip = ipv4_spec->hdr.src_addr; + filter->proto = ipv4_spec->hdr.next_proto_id; + +/* check if the next not void item is TCP or UDP */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_TCP && + item->type !=RTE_FLOW_ITEM_TYPE_UDP ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + +/* get the TCP/UDP info */ +if (!item->spec || !item->mask) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Invalid ntuple mask" ); +return -rte_errno; + } + +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + + } + +if (item->type ==RTE_FLOW_ITEM_TYPE_TCP ) { + tcp_mask = (const struct rte_flow_item_tcp *)item->mask; + +/** +* Only support src & dst ports, tcp flags, +* others should be masked. +*/ +if (tcp_mask->hdr.sent_seq || + tcp_mask->hdr.recv_ack || + tcp_mask->hdr.data_off || + tcp_mask->hdr.rx_win || + tcp_mask->hdr.cksum || + tcp_mask->hdr.tcp_urp) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + + filter->dst_port_mask = tcp_mask->hdr.dst_port; + filter->src_port_mask = tcp_mask->hdr.src_port; +if (tcp_mask->hdr.tcp_flags ==0xFF ) { + filter->flags |=RTE_NTUPLE_FLAGS_TCP_FLAG ; + }else if (!tcp_mask->hdr.tcp_flags) { + filter->flags &= ~RTE_NTUPLE_FLAGS_TCP_FLAG ; + }else { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + + tcp_spec = (const struct rte_flow_item_tcp *)item->spec; + filter->dst_port = tcp_spec->hdr.dst_port; + filter->src_port = tcp_spec->hdr.src_port; + filter->tcp_flags = tcp_spec->hdr.tcp_flags; + }else { + udp_mask = (const struct rte_flow_item_udp *)item->mask; + +/** +* Only support src & dst ports, +* others should be masked. +*/ +if (udp_mask->hdr.dgram_len || + udp_mask->hdr.dgram_cksum) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + + filter->dst_port_mask = udp_mask->hdr.dst_port; + filter->src_port_mask = udp_mask->hdr.src_port; + + udp_spec = (const struct rte_flow_item_udp *)item->spec; + filter->dst_port = udp_spec->hdr.dst_port; + filter->src_port = udp_spec->hdr.src_port; + } + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + +/* parse action */ + index =0 ; + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } + +/** +* n-tuple only supports forwarding, +* check if the first not void action is QUEUE. +*/ +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + item,"Not supported action." ); +return -rte_errno; + } + filter->queue = + ((const struct rte_flow_action_queue *)act->conf)->index; + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + +/* parse attr */ +/* must be input direction */ +if (!attr->ingress) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , + attr,"Only support ingress." ); +return -rte_errno; + } + +/* not supported */ +if (attr->egress) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , + attr,"Not support egress." ); +return -rte_errno; + } + +if (attr->priority >0xFFFF ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , + attr,"Error priority." ); +return -rte_errno; + } + filter->priority = (uint16_t )attr->priority; + +return 0 ; +} + +/* a specific function for ixgbe because the flags is specific */ +static int +ixgbe_parse_ntuple_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ntuple_filter *filter, +struct rte_flow_error *error) +{ +int ret; + + ret =cons_parse_ntuple_filter (attr, pattern, actions, filter, error); + +if (ret) +return ret; + +/* Ixgbe doesn't support tcp flags. */ +if (filter->flags &RTE_NTUPLE_FLAGS_TCP_FLAG ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"Not supported by ntuple filter" ); +return -rte_errno; + } + +/* Ixgbe doesn't support many priorities. */ +if (filter->priority <IXGBE_MIN_N_TUPLE_PRIO || + filter->priority >IXGBE_MAX_N_TUPLE_PRIO ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"Priority not supported by ntuple filter" ); +return -rte_errno; + } + +if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM || + filter->priority >IXGBE_5TUPLE_MAX_PRI || + filter->priority <IXGBE_5TUPLE_MIN_PRI ) +return -rte_errno; + +/* fixed value for ixgbe */ + filter->flags =RTE_5TUPLE_FLAGS ; +return 0 ; +} + +/** +* Check if the flow rule is supported by ixgbe. +* It only checkes the format. Don't guarantee the rule can be programmed into +* the HW. Because there can be no enough room for the rule. +*/ +static int +ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error) +{ +struct rte_eth_ntuple_filter ntuple_filter; +int ret; + +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); + ret =ixgbe_parse_ntuple_filter (attr, pattern, + actions, &ntuple_filter, error); +if (!ret) +return 0 ; + +return ret; +} +/* Destroy all flow rules associated with a port on ixgbe. */ static int ixgbe_flow_flush(struct rte_eth_dev *dev,
@@ -8085,15 +8487,17 @@ ixgbe_flow_flush(struct rte_eth_dev *dev, ret =ixgbe_clear_all_fdir_filter (dev);if (ret <0 ) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_HANDLE , -NULL ,"Failed to flush rule" ); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_HANDLE , +NULL ,"Failed to flush rule" );return ret; } ret =ixgbe_clear_all_l2_tn_filter (dev);if (ret <0 ) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_HANDLE , -NULL ,"Failed to flush rule" ); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_HANDLE , +NULL ,"Failed to flush rule" );return ret; }
Signature · 1 line
2.5.5
Re: [PATCH v2 11/18] net/ixgbe: parse n-tuple filter
Quoted 32 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Zhao1, Wei <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: [dpdk-dev] [PATCH v2 11/18] net/ixgbe: parse n-tuple filterAdd rule validate function and check if the rule is a n-tuple rule, and get the n-tuple info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:add new error set function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 414 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 409 insertions(+), 5 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +0
-0@@ -388,6 +388,24 @@ static int ixgbe_dev_udp_tunnel_port_del(structrte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel); static int
ixgbe_filter_restore(struct rte_eth_dev *dev); static voidixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
drivers/net/ixgbe/ixgbe_ethdev.c static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, · line 396
Quoted 6 lines
drivers/net/ixgbe/ixgbe_ethdev.c +6
-0+static int +cons_parse_ntuple_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ntuple_filter *filter, +struct rte_flow_error *error);
Why do you declare cons_parse_ntuple_filter here? And seems it doesn't align with the name rule.
Quoted 27 lines
drivers/net/ixgbe/ixgbe_ethdev.c +13
-1+static int +ixgbe_parse_ntuple_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ntuple_filter *filter, +struct rte_flow_error *error); +static int +ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error);static int ixgbe_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error);/* @@ -769,7 +787,7 @@ static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {#define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \ sizeof(rte_ixgbevf_stats_strings[0]))static const struct rte_flow_ops ixgbe_flow_ops = { -NULL , + ixgbe_flow_validate,NULL ,NULL ,drivers/net/ixgbe/ixgbe_ethdev.c +0
-0ixgbe_flow_flush,@@ -8072,6 +8090,390 @@ ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev · line 8100
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +7
-0return 0 ; } +static inline uint32_t +rte_be_to_cpu_24 (uint32_t x) +{ +return ((x &0x000000ffUL ) <<16 ) | + (x &0x0000ff00UL ) | + ((x &0x00ff0000UL ) >>16 ); +}
Why do you define the function in PMD with rte_ prefixed? Do you want to move it to rte library?
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8138
Quoted 12 lines
drivers/net/ixgbe/ixgbe_ethdev.c +12
-0+ + +/** +* Parse the rule to see if it is a n-tuple rule. +* And get the n-tuple filter info BTW. +*/ +static int +cons_parse_ntuple_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ntuple_filter *filter, +struct rte_flow_error *error)
How about splitting the function into three functions? Including parse pattern/parse actions/parse attr.
Quoted 37 lines
drivers/net/ixgbe/ixgbe_ethdev.c +37
-0+ +/* a specific function for ixgbe because the flags is specific */ +static int ixgbe_parse_ntuple_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ntuple_filter *filter, +struct rte_flow_error *error) +{ +int ret; + + ret =cons_parse_ntuple_filter (attr, pattern, actions, filter, error); + +if (ret) +return ret; + +/* Ixgbe doesn't support tcp flags. */ +if (filter->flags &RTE_NTUPLE_FLAGS_TCP_FLAG ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"Not supported by ntuple filter" ); +return -rte_errno; + } + +/* Ixgbe doesn't support many priorities. */ +if (filter->priority <IXGBE_MIN_N_TUPLE_PRIO || + filter->priority >IXGBE_MAX_N_TUPLE_PRIO ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"Priority not supported by ntuple filter" ); +return -rte_errno; + } + +if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM || + filter->priority >IXGBE_5TUPLE_MAX_PRI || + filter->priority <IXGBE_5TUPLE_MIN_PRI )
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+return -rte_errno; + +/* fixed value for ixgbe */ + filter->flags =RTE_5TUPLE_FLAGS ; +return 0 ; +} + +/** +* Check if the flow rule is supported by ixgbe. +* It only checkes the format. Don't guarantee the rule can be
Typo: checkes -> checks
Quoted 50 lines
drivers/net/ixgbe/ixgbe_ethdev.c +22
-0+programmed into +* the HW. Because there can be no enough room for the rule. +*/ +static int +ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error) +{ +struct rte_eth_ntuple_filter ntuple_filter; +int ret; + +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); + ret =ixgbe_parse_ntuple_filter (attr, pattern, + actions, &ntuple_filter, error); +if (!ret) +return 0 ; + +return ret; +} + /* Destroy all flow rules associated with a port on ixgbe. */ static intixgbe_flow_flush(struct
rte_eth_dev*dev, @@ -8085,15 +8487,17 @@ ixgbe_flow_flush(structrte_eth_dev*dev,drivers/net/ixgbe/ixgbe_ethdev.c +0
-1ret =ixgbe_clear_all_fdir_filter (dev);if (ret <0 ) { - rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_HANDLE,drivers/net/ixgbe/ixgbe_ethdev.c +3
-2- NULL, "Failed to flush rule"); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_HANDLE , +NULL ,"Failed to flush rule" );return ret; } ret =ixgbe_clear_all_l2_tn_filter (dev);if (ret <0 ) { - rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_HANDLE,drivers/net/ixgbe/ixgbe_ethdev.c +3
-2- NULL, "Failed to flush rule"); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_HANDLE , +NULL ,"Failed to flush rule" );return ret; } --2.5.5
Re: [PATCH v2 11/18] net/ixgbe: parse n-tuple filter
In reply to Wei Zhaodrivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8291
Quoted 4 lines
drivers/net/ixgbe/ixgbe_ethdev.c +4
-0+ + filter->dst_port_mask = tcp_mask->hdr.dst_port; + filter->src_port_mask = tcp_mask->hdr.src_port; +if (tcp_mask->hdr.tcp_flags ==0xFF ) {
It's better to use UINT8_MAX here.
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8397
Quoted 12 lines
drivers/net/ixgbe/ixgbe_ethdev.c +12
-0+ filter->flags |=RTE_NTUPLE_FLAGS_TCP_FLAG ; + }else if (!tcp_mask->hdr.tcp_flags) { + filter->flags &= ~RTE_NTUPLE_FLAGS_TCP_FLAG ; + }else { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + +if (attr->priority >0xFFFF ) {
How about UINT16_MAX?
Quoted 11 lines
drivers/net/ixgbe/ixgbe_ethdev.c +11
-0+memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , + attr,"Error priority." ); +return -rte_errno; + } + filter->priority = (uint16_t )attr->priority; + +return 0 ; +} +
Re: [PATCH v2 11/18] net/ixgbe: parse n-tuple filter
In reply to Wei ZhaoQuoted 19 lines · Wei Zhao
Add rule validate function and check if the rule is a n-tuple rule, and get the n-tuple info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:add new error set function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 414 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 409 insertions(+), 5 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +0
-0@@ -388,6 +388,24 @@ static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel);
<...>
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8132
Quoted 5 lines
drivers/net/ixgbe/ixgbe_ethdev.c +5
-0+ +/** +* Parse the rule to see if it is a n-tuple rule. +* And get the n-tuple filter info BTW. +*/
It would be nice to comment here valid/expected pattern values (spec/mask/last). Otherwise it is hard to decode from code also it is good to document intention, so makes easy if there is any defect.
Also valid actions.
Quoted 50 lines
drivers/net/ixgbe/ixgbe_ethdev.c +50
-0+static int +cons_parse_ntuple_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ntuple_filter *filter, +struct rte_flow_error *error) +{ +const struct rte_flow_item *item; +const struct rte_flow_action *act; +const struct rte_flow_item_ipv4 *ipv4_spec; +const struct rte_flow_item_ipv4 *ipv4_mask; +const struct rte_flow_item_tcp *tcp_spec; +const struct rte_flow_item_tcp *tcp_mask; +const struct rte_flow_item_udp *udp_spec; +const struct rte_flow_item_udp *udp_mask; +uint32_t index; + +if (!pattern) { +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } + +/* parse pattern */ + index =0 ; + +/* the first not void item can be MAC or IPv4 */ +NEXT_ITEM_OF_PATTERN (item, pattern, index); + +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH && + item->type !=RTE_FLOW_ITEM_TYPE_IPV4 ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } +/* Skip Ethernet */ +if (item->type ==RTE_FLOW_ITEM_TYPE_ETH ) { +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + + } +/* if the first item is MAC, the content should be NULL */ +if (item->spec || item->mask) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM,
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8192
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+ item, "Not supported by ntuple filter"); +return -rte_errno; + } +/* check if the next not void item is IPv4 */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 ) { +rte_flow_error_set (error, +EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" );
Wrong indentation.
Quoted 43 lines
drivers/net/ixgbe/ixgbe_ethdev.c +43
-0+return -rte_errno; + } + } + +/* get the IPv4 info */ +if (!item->spec || !item->mask) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Invalid ntuple mask" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + + } + + ipv4_mask = (const struct rte_flow_item_ipv4 *)item->mask; +/** +* Only support src & dst addresses, protocol, +* others should be masked. +*/ +if (ipv4_mask->hdr.version_ihl || + ipv4_mask->hdr.type_of_service || + ipv4_mask->hdr.total_length || + ipv4_mask->hdr.packet_id || + ipv4_mask->hdr.fragment_offset || + ipv4_mask->hdr.time_to_live || + ipv4_mask->hdr.hdr_checksum) { +rte_flow_error_set (error, +EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + + filter->dst_ip_mask = ipv4_mask->hdr.dst_addr; + filter->src_ip_mask = ipv4_mask->hdr.src_addr; + filter->proto_mask = ipv4_mask->hdr.next_proto_id; + + ipv4_spec = (const struct rte_flow_item_ipv4 *)item->spec;
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8245
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+ filter->dst_ip = ipv4_spec->hdr.dst_addr; + filter->src_ip = ipv4_spec->hdr.src_addr; + filter->proto = ipv4_spec->hdr.next_proto_id; + +/* check if the next not void item is TCP or UDP */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_TCP && + item->type !=RTE_FLOW_ITEM_TYPE_UDP ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter ));
Sometimes meset filter before return from error, sometimes not. Is memset required at all?
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8253
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c +8
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + +/* get the TCP/UDP info */ +if (!item->spec || !item->mask) {
For example there is no memset here for filter ..
Quoted 82 lines
drivers/net/ixgbe/ixgbe_ethdev.c +82
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Invalid ntuple mask" ); +return -rte_errno; + } + +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + + } + +if (item->type ==RTE_FLOW_ITEM_TYPE_TCP ) { + tcp_mask = (const struct rte_flow_item_tcp *)item->mask; + +/** +* Only support src & dst ports, tcp flags, +* others should be masked. +*/ +if (tcp_mask->hdr.sent_seq || + tcp_mask->hdr.recv_ack || + tcp_mask->hdr.data_off || + tcp_mask->hdr.rx_win || + tcp_mask->hdr.cksum || + tcp_mask->hdr.tcp_urp) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + + filter->dst_port_mask = tcp_mask->hdr.dst_port; + filter->src_port_mask = tcp_mask->hdr.src_port; +if (tcp_mask->hdr.tcp_flags ==0xFF ) { + filter->flags |=RTE_NTUPLE_FLAGS_TCP_FLAG ; + }else if (!tcp_mask->hdr.tcp_flags) { + filter->flags &= ~RTE_NTUPLE_FLAGS_TCP_FLAG ; + }else { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + + tcp_spec = (const struct rte_flow_item_tcp *)item->spec; + filter->dst_port = tcp_spec->hdr.dst_port; + filter->src_port = tcp_spec->hdr.src_port; + filter->tcp_flags = tcp_spec->hdr.tcp_flags; + }else { + udp_mask = (const struct rte_flow_item_udp *)item->mask; + +/** +* Only support src & dst ports, +* others should be masked. +*/ +if (udp_mask->hdr.dgram_len || + udp_mask->hdr.dgram_cksum) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + + filter->dst_port_mask = udp_mask->hdr.dst_port; + filter->src_port_mask = udp_mask->hdr.src_port; + + udp_spec = (const struct rte_flow_item_udp *)item->spec; + filter->dst_port = udp_spec->hdr.dst_port; + filter->src_port = udp_spec->hdr.src_port; + } + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter ));
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8345
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + +/* parse action */ + index =0 ; + +if (!actions) {
Although there is no harm, I would do input check at the beginning of the function, to not do extra work if we hit this case.
Quoted 24 lines
drivers/net/ixgbe/ixgbe_ethdev.c +24
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } + +/** +* n-tuple only supports forwarding, +* check if the first not void action is QUEUE. +*/ +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + item,"Not supported action." ); +return -rte_errno; + } + filter->queue = + ((const struct rte_flow_action_queue *)act->conf)->index; + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_ACTION (act, actions, index);
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8379
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + +/* parse attr */ +/* must be input direction */
May be good idea to check if attr is NULL.
Quoted 15 lines
drivers/net/ixgbe/ixgbe_ethdev.c +15
-0+if (!attr->ingress) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , + attr,"Only support ingress." ); +return -rte_errno; + } + +/* not supported */ +if (attr->egress) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , + attr,"Not support egress." ); +return -rte_errno;
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8404
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+ } + +if (attr->priority >0xFFFF ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , + attr,"Error priority." ); +return -rte_errno; + } + filter->priority = (uint16_t )attr->priority;
Should check attr->group? Do we support groups?
Quoted 4 lines
drivers/net/ixgbe/ixgbe_ethdev.c +4
-0+ +return 0 ; +} +
<...>
Re: [PATCH v2 11/18] net/ixgbe: parse n-tuple filter
Hi, yigit
Quoted 34 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, January 7, 2017 12:56 AM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 11/18] net/ixgbe: parse n-tuple filterdrivers/net/ixgbe/ixgbe_ethdev.c static int ixgbe_dev_udp_tunnel_port_del(struct
Quoted 20 lines · Wei Zhao
Add rule validate function and check if the rule is a n-tuple rule, and get the n-tuple info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:add new error set function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 414 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 409 insertions(+), 5 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +0
-0@@ -388,6 +388,24 @@ static int ixgbe_dev_udp_tunnel_port_del(struct
rte_eth_dev*dev,drivers/net/ixgbe/ixgbe_ethdev.c static int ixgbe_dev_udp_tunnel_port_del(struct · line 388
Quoted 1 line
drivers/net/ixgbe/ixgbe_ethdev.c +0
-0struct rte_eth_udp_tunnel
*udp_tunnel);<...>
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8132
Quoted 5 lines
drivers/net/ixgbe/ixgbe_ethdev.c +5
-0+ +/** +* Parse the rule to see if it is a n-tuple rule. +* And get the n-tuple filter info BTW. +*/ It would be nice to comment here valid/expected pattern values (spec/mask/last). Otherwise it is hard to decode from code also it is good to document intention, so makes easy if there is any defect.
I will do as your suggestion in v3.
Quoted 57 lines
Also valid actions.
Quoted 9 lines
drivers/net/ixgbe/ixgbe_ethdev.c +9
-0+static int +cons_parse_ntuple_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ntuple_filter *filter, +struct rte_flow_error *error) +{ +const struct rte_flow_item *item; +const struct rte_flow_action *act;drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8164
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+const struct rte_flow_item_ipv4 *ipv4_spec; +const struct rte_flow_item_ipv4 *ipv4_mask; +const struct rte_flow_item_tcp *tcp_spec; +const struct rte_flow_item_tcp *tcp_mask; +const struct rte_flow_item_udp *udp_spec; +const struct rte_flow_item_udp *udp_mask; +uint32_t index; + +if (!pattern) { + rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_ITEM_NUM,Quoted 35 lines
drivers/net/ixgbe/ixgbe_ethdev.c +35
-0+ NULL, "NULL pattern."); +return -rte_errno; + } + +/* parse pattern */ + index =0 ; + +/* the first not void item can be MAC or IPv4 */ +NEXT_ITEM_OF_PATTERN (item, pattern, index); + +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH && + item->type !=RTE_FLOW_ITEM_TYPE_IPV4 ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } +/* Skip Ethernet */ +if (item->type ==RTE_FLOW_ITEM_TYPE_ETH ) { +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + + } +/* if the first item is MAC, the content should be NULL */ +if (item->spec || item->mask) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } +/* check if the next not void item is IPv4 */
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8192
Quoted 6 lines
drivers/net/ixgbe/ixgbe_ethdev.c +6
-0+ index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 ) { +rte_flow_error_set (error, +EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" );Wrong indentation.
I will do as your suggestion in v3.
Quoted 49 lines
Quoted 49 lines
drivers/net/ixgbe/ixgbe_ethdev.c +48
-0+return -rte_errno; + } + } + +/* get the IPv4 info */ +if (!item->spec || !item->mask) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Invalid ntuple mask" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + + } + + ipv4_mask = (const struct rte_flow_item_ipv4 *)item->mask; +/** +* Only support src & dst addresses, protocol, +* others should be masked. +*/ +if (ipv4_mask->hdr.version_ihl || + ipv4_mask->hdr.type_of_service || + ipv4_mask->hdr.total_length || + ipv4_mask->hdr.packet_id || + ipv4_mask->hdr.fragment_offset || + ipv4_mask->hdr.time_to_live || + ipv4_mask->hdr.hdr_checksum) { +rte_flow_error_set (error, +EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + + filter->dst_ip_mask = ipv4_mask->hdr.dst_addr; + filter->src_ip_mask = ipv4_mask->hdr.src_addr; + filter->proto_mask = ipv4_mask->hdr.next_proto_id; + + ipv4_spec = (const struct rte_flow_item_ipv4 *)item->spec; + filter->dst_ip = ipv4_spec->hdr.dst_addr; + filter->src_ip = ipv4_spec->hdr.src_addr; + filter->proto = ipv4_spec->hdr.next_proto_id; + +/* check if the next not void item is TCP or UDP */
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8245
Quoted 5 lines
drivers/net/ixgbe/ixgbe_ethdev.c +5
-0+ index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_TCP && + item->type !=RTE_FLOW_ITEM_TYPE_UDP ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter ));Sometimes meset filter before return from error, sometimes not. Is memset required at all?
Not all necessary, at the beginning ,filter is not config any value, so it do not need to memset .
Quoted 102 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8253
Quoted 9 lines
drivers/net/ixgbe/ixgbe_ethdev.c +8
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + +/* get the TCP/UDP info */ +if (!item->spec || !item->mask) {For example there is no memset here for filter ..
Quoted 19 lines
drivers/net/ixgbe/ixgbe_ethdev.c +19
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Invalid ntuple mask" ); +return -rte_errno; + } + +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + + } + +if (item->type ==RTE_FLOW_ITEM_TYPE_TCP ) { + tcp_mask = (const struct rte_flow_item_tcp *)item->mask; + +/** drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+* Only support src & dst ports, tcp flags, +* others should be masked. +*/ +if (tcp_mask->hdr.sent_seq || + tcp_mask->hdr.recv_ack || + tcp_mask->hdr.data_off || + tcp_mask->hdr.rx_win || + tcp_mask->hdr.cksum || + tcp_mask->hdr.tcp_urp) { + memset(filter, 0, sizeof(struct
rte_eth_ntuple_filter));Quoted 4 lines
drivers/net/ixgbe/ixgbe_ethdev.c +4
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno;drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+ } + + filter->dst_port_mask = tcp_mask->hdr.dst_port; + filter->src_port_mask = tcp_mask->hdr.src_port; +if (tcp_mask->hdr.tcp_flags ==0xFF ) { + filter->flags |=RTE_NTUPLE_FLAGS_TCP_FLAG ; + }else if (!tcp_mask->hdr.tcp_flags) { + filter->flags &= ~RTE_NTUPLE_FLAGS_TCP_FLAG ; + }else { + memset(filter, 0, sizeof(struct
rte_eth_ntuple_filter));Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + + tcp_spec = (const struct rte_flow_item_tcp *)item->spec; + filter->dst_port = tcp_spec->hdr.dst_port; + filter->src_port = tcp_spec->hdr.src_port; + filter->tcp_flags = tcp_spec->hdr.tcp_flags;drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+ }else { + udp_mask = (const struct rte_flow_item_udp *)item->mask; + +/** +* Only support src & dst ports, +* others should be masked. +*/ +if (udp_mask->hdr.dgram_len || + udp_mask->hdr.dgram_cksum) { + memset(filter, 0, sizeof(struct
rte_eth_ntuple_filter));Quoted 24 lines
drivers/net/ixgbe/ixgbe_ethdev.c +24
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + } + + filter->dst_port_mask = udp_mask->hdr.dst_port; + filter->src_port_mask = udp_mask->hdr.src_port; + + udp_spec = (const struct rte_flow_item_udp *)item->spec; + filter->dst_port = udp_spec->hdr.dst_port; + filter->src_port = udp_spec->hdr.src_port; + } + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ntuple filter" ); +return -rte_errno; + }
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8345
Quoted 5 lines
drivers/net/ixgbe/ixgbe_ethdev.c +5
-0+ +/* parse action */ + index =0 ; + +if (!actions) {Although there is no harm, I would do input check at the beginning of the function, to not do extra work if we hit this case.
I will do as your suggestion in v3.
Quoted 29 lines
Quoted 29 lines
drivers/net/ixgbe/ixgbe_ethdev.c +28
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } + +/** +* n-tuple only supports forwarding, +* check if the first not void action is QUEUE. +*/ +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + item,"Not supported action." ); +return -rte_errno; + } + filter->queue = + ((const struct rte_flow_action_queue *)act->conf)->index; + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION,
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8379
Quoted 6 lines
drivers/net/ixgbe/ixgbe_ethdev.c +6
-0+ act, "Not supported action."); +return -rte_errno; + } + +/* parse attr */ +/* must be input direction */ May be good idea to check if attr is NULL.
I will do as your suggestion in v3. Add it at the beginning of function.
Quoted 20 lines
Quoted 20 lines
drivers/net/ixgbe/ixgbe_ethdev.c +19
-0+if (!attr->ingress) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , + attr,"Only support ingress." ); +return -rte_errno; + } + +/* not supported */ +if (attr->egress) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , + attr,"Not support egress." ); +return -rte_errno; + } + +if (attr->priority >0xFFFF ) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter ));
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev) · line 8404
Quoted 6 lines
drivers/net/ixgbe/ixgbe_ethdev.c +6
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , + attr,"Error priority." ); +return -rte_errno; + } + filter->priority = (uint16_t )attr->priority;Should check
attr->group? Do we support groups?
No , we do not.
Quoted 7 lines
Quoted 5 lines
drivers/net/ixgbe/ixgbe_ethdev.c +4
-0+ +return 0 ; +} +<...>
PATCH v2 12/18 net/ixgbe: parse ethertype filter
In reply to Wei Zhaocheck if the rule is a ethertype rule, and get the ethertype info.
---
v2:add new error set function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 251 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +251 -0
@@ -401,6 +401,18 @@ ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr,struct rte_eth_ntuple_filter *filter, struct rte_flow_error *error);static int +cons_parse_ethertype_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item *pattern, +const struct rte_flow_action *actions, +struct rte_eth_ethertype_filter *filter, +struct rte_flow_error *error); +static int +ixgbe_parse_ethertype_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ethertype_filter *filter, +struct rte_flow_error *error); +static int ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item pattern[],
@@ -8451,6 +8463,238 @@ ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, }/** +* Parse the rule to see if it is a ethertype rule. +* And get the ethertype filter info BTW. +*/ +static int +cons_parse_ethertype_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item *pattern, +const struct rte_flow_action *actions, +struct rte_eth_ethertype_filter *filter, +struct rte_flow_error *error) +{ +const struct rte_flow_item *item; +const struct rte_flow_action *act; +const struct rte_flow_item_eth *eth_spec; +const struct rte_flow_item_eth *eth_mask; +const struct rte_flow_action_queue *act_q; +uint32_t index; + +if (!pattern) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } + +/* Parse pattern */ + index =0 ; + +/* The first non-void item should be MAC. */ + item = pattern + index; +while (item->type ==RTE_FLOW_ITEM_TYPE_VOID ) { + index++; + item = pattern + index; + } +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ethertype filter" ); +return -rte_errno; + } + +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } + +/* Get the MAC info. */ +if (!item->spec || !item->mask) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ethertype filter" ); +return -rte_errno; + } + + eth_spec = (const struct rte_flow_item_eth *)item->spec; + eth_mask = (const struct rte_flow_item_eth *)item->mask; + +/* Mask bits of source MAC address must be full of 0. +* Mask bits of destination MAC address must be full +* of 1 or full of 0. +*/ +if (!is_zero_ether_addr (ð_mask->src) || + (!is_zero_ether_addr (ð_mask->dst) && + !is_broadcast_ether_addr (ð_mask->dst))) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Invalid ether address mask" ); +return -rte_errno; + } + +if ((eth_mask->type &UINT16_MAX ) !=UINT16_MAX ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Invalid ethertype mask" ); +return -rte_errno; + } + +/* If mask bits of destination MAC address +* are full of 1, set RTE_ETHTYPE_FLAGS_MAC. +*/ +if (is_broadcast_ether_addr (ð_mask->dst)) { + filter->mac_addr = eth_spec->dst; + filter->flags |=RTE_ETHTYPE_FLAGS_MAC ; + }else { + filter->flags &= ~RTE_ETHTYPE_FLAGS_MAC ; + } + filter->ether_type =rte_be_to_cpu_16 (eth_spec->type); + +/* Check if the next non-void item is END. */ + index++; + item = pattern + index; +while (item->type ==RTE_FLOW_ITEM_TYPE_VOID ) { + index++; + item = pattern + index; + } +if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by ethertype filter." ); +return -rte_errno; + } + +/* Parse action */ + + index =0 ; +/* Check if the first non-void action is QUEUE or DROP. */ + act = actions + index; +while (act->type ==RTE_FLOW_ACTION_TYPE_VOID ) { + index++; + act = actions + index; + } +if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE && + act->type !=RTE_FLOW_ACTION_TYPE_DROP ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + +if (act->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { + act_q = (const struct rte_flow_action_queue *)act->conf; + filter->queue = act_q->index; + }else { + filter->flags |=RTE_ETHTYPE_FLAGS_DROP ; + } + +/* Check if the next non-void item is END */ + index++; + act = actions + index; +while (act->type ==RTE_FLOW_ACTION_TYPE_VOID ) { + index++; + act = actions + index; + } +if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + +/* Parse attr */ +/* Must be input direction */ +if (!attr->ingress) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , + attr,"Only support ingress." ); +return -rte_errno; + } + +/* Not supported */ +if (attr->egress) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , + attr,"Not support egress." ); +return -rte_errno; + } + +/* Not supported */ +if (attr->priority) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , + attr,"Not support priority." ); +return -rte_errno; + } + +/* Not supported */ +if (attr->group) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_GROUP , + attr,"Not support group." ); +return -rte_errno; + } + +return 0 ; +} + +static int +ixgbe_parse_ethertype_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ethertype_filter *filter, +struct rte_flow_error *error) +{ +int ret; + + ret =cons_parse_ethertype_filter (attr, pattern, + actions, filter, error); + +if (ret) +return ret; + +/* Ixgbe doesn't support MAC address. */ +if (filter->flags &RTE_ETHTYPE_FLAGS_MAC ) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"Not supported by ethertype filter" ); +return -rte_errno; + } + +if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM ) +return -rte_errno; + +if (filter->ether_type == ETHER_TYPE_IPv4 || + filter->ether_type == ETHER_TYPE_IPv6) { +PMD_DRV_LOG (ERR ,"unsupported ether_type(0x%04x) in" +" ethertype filter." , filter->ether_type); +return -rte_errno; + } + +if (filter->flags &RTE_ETHTYPE_FLAGS_MAC ) { +PMD_DRV_LOG (ERR ,"mac compare is unsupported." ); +return -rte_errno; + } + +if (filter->flags &RTE_ETHTYPE_FLAGS_DROP ) { +PMD_DRV_LOG (ERR ,"drop option is unsupported." ); +return -rte_errno; + } + +return 0 ; +} + +/** * Check if the flow rule is supported by ixgbe. * It only checkes the format. Don't guarantee the rule can be programmed into * the HW. Because there can be no enough room for the rule.
@@ -8463,6 +8707,7 @@ ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, struct rte_flow_error *error) {struct rte_eth_ntuple_filter ntuple_filter; +struct rte_eth_ethertype_filter ethertype_filter;int ret;memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter ));
@@ -8471,6 +8716,12 @@ ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev,if (!ret)return 0 ; +memset (ðertype_filter,0 ,sizeof (struct rte_eth_ethertype_filter )); + ret =ixgbe_parse_ethertype_filter (attr, pattern, + actions, ðertype_filter, error); +if (!ret) +return 0 ; +return ret; }
Signature · 1 line
2.5.5
Re: [PATCH v2 12/18] net/ixgbe: parse ethertype filter
Quoted 8 lines · Wei Zhao
check if the rule is a ethertype rule, and get the ethertype info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:add new error set function
---
<...>
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c +8
-0+static int +ixgbe_parse_ethertype_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ethertype_filter *filter, +struct rte_flow_error *error) +{ +int ret;
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 8667
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+ + ret =cons_parse_ethertype_filter (attr, pattern, + actions, filter, error); + +if (ret) +return ret; + +/* Ixgbe doesn't support MAC address. */ +if (filter->flags &RTE_ETHTYPE_FLAGS_MAC ) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter ));
Is memset required for error cases, if so is other error cases also require it?
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 8680
Quoted 13 lines
drivers/net/ixgbe/ixgbe_ethdev.c +13
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"Not supported by ethertype filter" ); +return -rte_errno; + } + +if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM ) +return -rte_errno; + +if (filter->ether_type == ETHER_TYPE_IPv4 || + filter->ether_type == ETHER_TYPE_IPv6) { +PMD_DRV_LOG (ERR ,"unsupported ether_type(0x%04x) in" +" ethertype filter." , filter->ether_type);
Not sure about this log here, specially it is in ERR level. This function is returning error, and public API will return an error, if we want to notify user with a log, should app do this as library (here) should do this? More comment welcome?
btw, should rte_flow_error_set() used here (and below) ?
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 8666
Quoted 4 lines
drivers/net/ixgbe/ixgbe_ethdev.c +4
-0+return -rte_errno; + } + +if (filter->flags &RTE_ETHTYPE_FLAGS_MAC ) {
Isn't this duplicate with above check?
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 8689
Quoted 5 lines
drivers/net/ixgbe/ixgbe_ethdev.c +5
-0+PMD_DRV_LOG (ERR ,"mac compare is unsupported." ); +return -rte_errno; + } + +if (filter->flags &RTE_ETHTYPE_FLAGS_DROP ) {
Just to double check, isn't drop action by ether filters?
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c +8
-0+PMD_DRV_LOG (ERR ,"drop option is unsupported." ); +return -rte_errno; + } + +return 0 ; +} + +/**
<...>
Re: [PATCH v2 12/18] net/ixgbe: parse ethertype filter
Hi, Yigit
Quoted 30 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, January 7, 2017 1:11 AM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 12/18] net/ixgbe: parse ethertype filterQuoted 8 lines · Wei Zhao
check if the rule is a ethertype rule, and get the ethertype info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:add new error set function
---<...>
Quoted 11 lines
drivers/net/ixgbe/ixgbe_ethdev.c +11
-0+static int +ixgbe_parse_ethertype_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_ethertype_filter *filter, +struct rte_flow_error *error) { +int ret; + + ret =cons_parse_ethertype_filter (attr, pattern, + actions, filter, error); +
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 8667
Quoted 6 lines
drivers/net/ixgbe/ixgbe_ethdev.c +6
-0+if (ret) +return ret; + +/* Ixgbe doesn't support MAC address. */ +if (filter->flags &RTE_ETHTYPE_FLAGS_MAC ) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter ));Is memset required for error cases, if so is other error cases also require it?
Yes, Ok , I will do as your suggestion.
Quoted 20 lines
Quoted 4 lines
drivers/net/ixgbe/ixgbe_ethdev.c +3
-0+rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"Not supported by ethertype filter" );drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 8680
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+return -rte_errno; + } + +if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM ) +return -rte_errno; + +if (filter->ether_type == ETHER_TYPE_IPv4 || + filter->ether_type == ETHER_TYPE_IPv6) { +PMD_DRV_LOG (ERR ,"unsupported ether_type(0x%04x) in" +" ethertype filter." , filter->ether_type);Not sure about this log here, specially it is in ERR level.
This function is returning error, and public API will return an error, if we want to notify user with a log, should app do this as library
(here) should do this? More comment welcome?
Quoted 1 line
btw, should
rte_flow_error_set()used here (and below) ?
Yes, I will change to rte_flow_error_set()
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 8666
Quoted 5 lines
drivers/net/ixgbe/ixgbe_ethdev.c +4
-0+return -rte_errno; + } + +if (filter->flags &RTE_ETHTYPE_FLAGS_MAC ) {Isn't this duplicate with above check?
Quoted 7 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 8689
Quoted 5 lines
drivers/net/ixgbe/ixgbe_ethdev.c +5
-0+PMD_DRV_LOG (ERR ,"mac compare is unsupported." ); +return -rte_errno; + } + +if (filter->flags &RTE_ETHTYPE_FLAGS_DROP ) {Just to double check, isn't drop action by ether filters?
Yse , ixgbe do not, but i40e is.
Quoted 10 lines
Quoted 9 lines
drivers/net/ixgbe/ixgbe_ethdev.c +8
-0+PMD_DRV_LOG (ERR ,"drop option is unsupported." ); +return -rte_errno; + } + +return 0 ; +} + +/** <...>
PATCH v2 13/18 net/ixgbe: parse TCP SYN filter
In reply to Wei Zhaocheck if the rule is a TCP SYN rule, and get the SYN info.
---
v2:add new error set function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 251 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +251 -0
@@ -413,6 +413,18 @@ ixgbe_parse_ethertype_filter(const struct rte_flow_attr *attr,struct rte_eth_ethertype_filter *filter, struct rte_flow_error *error);static int +cons_parse_syn_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_syn_filter *filter, +struct rte_flow_error *error); +static int +ixgbe_parse_syn_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_syn_filter *filter, +struct rte_flow_error *error); +static int ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item pattern[],
@@ -8695,6 +8707,238 @@ ixgbe_parse_ethertype_filter(const struct rte_flow_attr *attr, }/** +* Parse the rule to see if it is a TCP SYN rule. +* And get the TCP SYN filter info BTW. +*/ +static int +cons_parse_syn_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_syn_filter *filter, +struct rte_flow_error *error) +{ +const struct rte_flow_item *item; +const struct rte_flow_action *act; +const struct rte_flow_item_tcp *tcp_spec; +const struct rte_flow_item_tcp *tcp_mask; +const struct rte_flow_action_queue *act_q; +uint32_t index; + +if (!pattern) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } + +/* parse pattern */ + index =0 ; + +/* the first not void item should be MAC or IPv4 or IPv6 or TCP */ +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH && + item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_IPV6 && + item->type !=RTE_FLOW_ITEM_TYPE_TCP ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by syn filter" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + + } + +/* Skip Ethernet */ +if (item->type ==RTE_FLOW_ITEM_TYPE_ETH ) { +/* if the item is MAC, the content should be NULL */ +if (item->spec || item->mask) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Invalid SYN address mask" ); +return -rte_errno; + } + +/* check if the next not void item is IPv4 or IPv6 */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by syn filter" ); +return -rte_errno; + } + } + +/* Skip IP */ +if (item->type ==RTE_FLOW_ITEM_TYPE_IPV4 || + item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ) { +/* if the item is IP, the content should be NULL */ +if (item->spec || item->mask) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Invalid SYN mask" ); +return -rte_errno; + } + +/* check if the next not void item is TCP */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_TCP ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by syn filter" ); +return -rte_errno; + } + } + +/* Get the TCP info. Only support SYN. */ +if (!item->spec || !item->mask) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Invalid SYN mask" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + + } + + tcp_spec = (const struct rte_flow_item_tcp *)item->spec; + tcp_mask = (const struct rte_flow_item_tcp *)item->mask; +if (!(tcp_spec->hdr.tcp_flags &TCP_SYN_FLAG ) || + tcp_mask->hdr.src_port || + tcp_mask->hdr.dst_port || + tcp_mask->hdr.sent_seq || + tcp_mask->hdr.recv_ack || + tcp_mask->hdr.data_off || + tcp_mask->hdr.tcp_flags !=TCP_SYN_FLAG || + tcp_mask->hdr.rx_win || + tcp_mask->hdr.cksum || + tcp_mask->hdr.tcp_urp) { +memset (filter,0 ,sizeof (struct rte_eth_syn_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by syn filter" ); +return -rte_errno; + } + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_syn_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by syn filter" ); +return -rte_errno; + } + +/* parse action */ + index =0 ; + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } + +/* check if the first not void action is QUEUE. */ +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE ) { +memset (filter,0 ,sizeof (struct rte_eth_syn_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + + act_q = (const struct rte_flow_action_queue *)act->conf; + filter->queue = act_q->index; +if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM ) { +memset (filter,0 ,sizeof (struct rte_eth_syn_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_syn_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + +/* parse attr */ +/* must be input direction */ +if (!attr->ingress) { +memset (filter,0 ,sizeof (struct rte_eth_syn_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , + attr,"Only support ingress." ); +return -rte_errno; + } + +/* not supported */ +if (attr->egress) { +memset (filter,0 ,sizeof (struct rte_eth_syn_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , + attr,"Not support egress." ); +return -rte_errno; + } + +/* Support 2 priorities, the lowest or highest. */ +if (!attr->priority) { + filter->hig_pri =0 ; + }else if (attr->priority == (uint32_t )~0U ) { + filter->hig_pri =1 ; + }else { +memset (filter,0 ,sizeof (struct rte_eth_syn_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , + attr,"Not support priority." ); +return -rte_errno; + } + +return 0 ; +} + +static int +ixgbe_parse_syn_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_syn_filter *filter, +struct rte_flow_error *error) +{ +int ret; + + ret =cons_parse_syn_filter (attr, pattern, + actions, filter, error); + +if (ret) +return ret; + +return 0 ; +} + +/** * Check if the flow rule is supported by ixgbe. * It only checkes the format. Don't guarantee the rule can be programmed into * the HW. Because there can be no enough room for the rule.
@@ -8708,6 +8952,7 @@ ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, {struct rte_eth_ntuple_filter ntuple_filter;struct rte_eth_ethertype_filter ethertype_filter; +struct rte_eth_syn_filter syn_filter;int ret;memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter ));
@@ -8722,6 +8967,12 @@ ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev,if (!ret)return 0 ; +memset (&syn_filter,0 ,sizeof (struct rte_eth_syn_filter )); + ret =ixgbe_parse_syn_filter (attr, pattern, + actions, &syn_filter, error); +if (!ret) +return 0 ; +return ret; }
Signature · 1 line
2.5.5
Re: [PATCH v2 13/18] net/ixgbe: parse TCP SYN filter
Quoted 9 lines · Wei Zhao
check if the rule is a TCP SYN rule, and get the SYN info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:add new error set function
---
<...>
Quoted 7 lines
drivers/net/ixgbe/ixgbe_ethdev.c +7
-0+static int +ixgbe_parse_syn_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_syn_filter *filter, +struct rte_flow_error *error) +{
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_ethertype_filter(const struct rte_flow_attr *attr, · line 8938
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +9
-0+int ret; + + ret =cons_parse_syn_filter (attr, pattern, + actions, filter, error); + +if (ret) +return ret; + +return 0 ;
"return ret;" will do the same.
Or remove ret completely perhaps.
Quoted 2 lines
(quoted diff) +2
-0+} +
<...>
Re: [PATCH v2 13/18] net/ixgbe: parse TCP SYN filter
Hi, Yigit
Quoted 40 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, January 7, 2017 1:20 AM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 13/18] net/ixgbe: parse TCP SYN filterQuoted 9 lines · Wei Zhao
check if the rule is a TCP SYN rule, and get the SYN info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:add new error set function
---<...>
Quoted 6 lines
drivers/net/ixgbe/ixgbe_ethdev.c +6
-0+static int +ixgbe_parse_syn_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_syn_filter *filter, +struct rte_flow_error *error) {drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_ethertype_filter(const struct rte_flow_attr *attr, · line 8938
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +9
-0+int ret; + + ret =cons_parse_syn_filter (attr, pattern, + actions, filter, error); + +if (ret) +return ret; + +return 0 ;"return ret;" will do the same.
Or remove ret completely perhaps.
Quoted 3 lines
Quoted 2 lines
(quoted diff) +2
-0+} +<...>
Yes, "return ret;" may be more appropriate.
Re: [PATCH v2 13/18] net/ixgbe: parse TCP SYN filter
In reply to Ferruh YigitHI, yigit
Quoted 32 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, January 7, 2017 1:20 AM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 13/18] net/ixgbe: parse TCP SYN filterQuoted 9 lines · Wei Zhao
check if the rule is a TCP SYN rule, and get the SYN info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:add new error set function
---<...>
Quoted 11 lines
drivers/net/ixgbe/ixgbe_ethdev.c +11
-0+static int +ixgbe_parse_syn_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_syn_filter *filter, +struct rte_flow_error *error) { +int ret; + + ret =cons_parse_syn_filter (attr, pattern, + actions, filter, error); +
Quoted 7 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_ethertype_filter(const struct rte_flow_attr *attr, · line 8938
Quoted 4 lines
drivers/net/ixgbe/ixgbe_ethdev.c +4
-0+if (ret) +return ret; + +return 0 ;"return ret;" will do the same.
Or remove ret completely perhaps.
Return 0 is the same as "return ret;", so this may be not to need change.
Quoted 4 lines
Quoted 3 lines
(quoted diff) +2
-0+} +<...>
PATCH v2 14/18 net/ixgbe: parse L2 tunnel filter
In reply to Wei Zhaocheck if the rule is a L2 tunnel rule, and get the L2 tunnel info.
---
v2:
--add new error set function
--change return value type of parser function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 269 +++++++++++++++++++++++++++++++++++---- lib/librte_ether/rte_flow.h | 32 +++++ 2 files changed, 273 insertions(+), 28 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +241 -28
@@ -425,6 +425,19 @@ ixgbe_parse_syn_filter(const struct rte_flow_attr *attr,struct rte_eth_syn_filter *filter, struct rte_flow_error *error);static int +cons_parse_l2_tn_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_l2_tunnel_conf *filter, +struct rte_flow_error *error); +static int +ixgbe_validate_l2_tn_filter (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_l2_tunnel_conf *rule, +struct rte_flow_error *error); +static int ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item pattern[],
@@ -8939,41 +8952,175 @@ ixgbe_parse_syn_filter(const struct rte_flow_attr *attr, }/** -* Check if the flow rule is supported by ixgbe. -* It only checkes the format. Don't guarantee the rule can be programmed into -* the HW. Because there can be no enough room for the rule. +* Parse the rule to see if it is a L2 tunnel rule. +* And get the L2 tunnel filter info BTW. +* Only support E-tag now. */ static int -ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, -const struct rte_flow_attr *attr, -const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], -struct rte_flow_error *error) +cons_parse_l2_tn_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_l2_tunnel_conf *filter, +struct rte_flow_error *error) { -struct rte_eth_ntuple_filter ntuple_filter; -struct rte_eth_ethertype_filter ethertype_filter; -struct rte_eth_syn_filter syn_filter; -int ret; +const struct rte_flow_item *item; +const struct rte_flow_item_e_tag *e_tag_spec; +const struct rte_flow_item_e_tag *e_tag_mask; +const struct rte_flow_action *act; +const struct rte_flow_action_queue *act_q; +uint32_t index, j; -memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); - ret =ixgbe_parse_ntuple_filter (attr, pattern, - actions, &ntuple_filter, error); -if (!ret) -return 0 ; +if (!pattern) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } -memset (ðertype_filter,0 ,sizeof (struct rte_eth_ethertype_filter )); - ret =ixgbe_parse_ethertype_filter (attr, pattern, - actions, ðertype_filter, error); -if (!ret) -return 0 ; +/* parse pattern */ + index =0 ; -memset (&syn_filter,0 ,sizeof (struct rte_eth_syn_filter )); - ret =ixgbe_parse_syn_filter (attr, pattern, - actions, &syn_filter, error); -if (!ret) -return 0 ; +/* The first not void item should be e-tag. */ +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_E_TAG ) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by L2 tunnel filter" ); +return -rte_errno; + } -return ret; +if (!item->spec || !item->mask) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by L2 tunnel filter" ); +return -rte_errno; + } + +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } + + e_tag_spec = (const struct rte_flow_item_e_tag *)item->spec; + e_tag_mask = (const struct rte_flow_item_e_tag *)item->mask; + +/* Src & dst MAC address should be masked. */ +for (j =0 ; j <ETHER_ADDR_LEN ; j++) { +if (e_tag_mask->src.addr_bytes[j] || + e_tag_mask->dst.addr_bytes[j]) { +memset (filter,0 , +sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by L2 tunnel filter" ); +return -rte_errno; + } + } + +/* Only care about GRP and E cid base. */ +if (e_tag_mask->e_tag_ethertype || + e_tag_mask->e_pcp || + e_tag_mask->dei || + e_tag_mask->in_e_cid_base || + e_tag_mask->in_e_cid_ext || + e_tag_mask->e_cid_ext || + e_tag_mask->type || + e_tag_mask->tags || + e_tag_mask->grp !=0x3 || + e_tag_mask->e_cid_base !=0xFFF ) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by L2 tunnel filter" ); +return -rte_errno; + } + + filter->l2_tunnel_type =RTE_L2_TUNNEL_TYPE_E_TAG ; +/** +* grp and e_cid_base are bit fields and only use 14 bits. +* e-tag id is taken as little endian by HW. +*/ + filter->tunnel_id = e_tag_spec->grp <<12 ; + filter->tunnel_id |=rte_be_to_cpu_16 (e_tag_spec->e_cid_base); + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by L2 tunnel filter" ); +return -rte_errno; + } + +/* parse attr */ +/* must be input direction */ +if (!attr->ingress) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , + attr,"Only support ingress." ); +return -rte_errno; + } + +/* not supported */ +if (attr->egress) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , + attr,"Not support egress." ); +return -rte_errno; + } + +/* not supported */ +if (attr->priority) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , + attr,"Not support priority." ); +return -rte_errno; + } + +/* parse action */ + index =0 ; + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } + +/* check if the first not void action is QUEUE. */ +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE ) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + + act_q = (const struct rte_flow_action_queue *)act->conf; + filter->pool = act_q->index; + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + +return 0 ; }/* Destroy all flow rules associated with a port on ixgbe. */
@@ -9006,6 +9153,72 @@ ixgbe_flow_flush(struct rte_eth_dev *dev,return 0 ; } +static int +ixgbe_validate_l2_tn_filter (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_l2_tunnel_conf *l2_tn_filter, +struct rte_flow_error *error) +{ +int ret =0 ; +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); + + ret =cons_parse_l2_tn_filter (attr, pattern, + actions, l2_tn_filter, error); + +if (hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a) { +return -ENOTSUP ; + } + +return ret; +} + +/** +* Check if the flow rule is supported by ixgbe. +* It only checkes the format. Don't guarantee the rule can be programmed into +* the HW. Because there can be no enough room for the rule. +*/ +static int +ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error) +{ +struct rte_eth_ntuple_filter ntuple_filter; +struct rte_eth_ethertype_filter ethertype_filter; +struct rte_eth_syn_filter syn_filter; +struct rte_eth_l2_tunnel_conf l2_tn_filter; +int ret; + +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); + ret =ixgbe_parse_ntuple_filter (attr, pattern, + actions, &ntuple_filter, error); +if (!ret) +return 0 ; + +memset (ðertype_filter,0 ,sizeof (struct rte_eth_ethertype_filter )); + ret =ixgbe_parse_ethertype_filter (attr, pattern, + actions, ðertype_filter, error); +if (!ret) +return 0 ; + +memset (&syn_filter,0 ,sizeof (struct rte_eth_syn_filter )); + ret =ixgbe_parse_syn_filter (attr, pattern, + actions, &syn_filter, error); +if (!ret) +return 0 ; + +memset (&l2_tn_filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); + ret =ixgbe_validate_l2_tn_filter (dev, attr, pattern, + actions, &l2_tn_filter, error); + +return ret; +} +RTE_PMD_REGISTER_PCI (net_ixgbe, rte_ixgbe_pmd.pci_drv);RTE_PMD_REGISTER_PCI_TABLE (net_ixgbe, pci_id_ixgbe_map);RTE_PMD_REGISTER_KMOD_DEP (net_ixgbe,"* igb_uio | uio_pci_generic | vfio" );
lib/librte_ether/rte_flow.h +32 -0
@@ -268,6 +268,13 @@ enum rte_flow_item_type {* See struct rte_flow_item_vxlan. */ RTE_FLOW_ITEM_TYPE_VXLAN , + +/** +* Matches a E_TAG header. +* +* See struct rte_flow_item_e_tag. +*/ + RTE_FLOW_ITEM_TYPE_E_TAG, };/**
@@ -454,6 +461,31 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +struct ether_addr dst;/**< Destination MAC. */ +struct ether_addr src;/**< Source MAC. */ +uint16_t e_tag_ethertype;/**< E-tag EtherType, 0x893F. */ +uint16_t e_pcp:3 ;/**< E-PCP */ +uint16_t dei:1 ;/**< DEI */ +uint16_t in_e_cid_base:12 ;/**< Ingress E-CID base */ +uint16_t rsv:2 ;/**< reserved */ +uint16_t grp:2 ;/**< GRP */ +uint16_t e_cid_base:12 ;/**< E-CID base */ +uint16_t in_e_cid_ext:8 ;/**< Ingress E-CID extend */ +uint16_t e_cid_ext:8 ;/**< E-CID extend */ +uint16_t type;/**< MAC type. */ +unsigned int tags;/**< Number of 802.1Q/ad tags defined. */ +struct { +uint16_t tpid;/**< Tag protocol identifier. */ +uint16_t tci;/**< Tag control information. */ + } tag[];/**< 802.1Q/ad tag definitions, outermost first. */ +}; + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol
Signature · 1 line
2.5.5
Re: [PATCH v2 14/18] net/ixgbe: parse L2 tunnel filter
Hi Wei,
Quoted 14 lines · Wei Zhao
check if the rule is a L2 tunnel rule, and get the L2 tunnel info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:
--add new error set function
--change return value type of parser function--- drivers/net/ixgbe/ixgbe_ethdev.c | 269 +++++++++++++++++++++++++++++++++++---- lib/librte_ether/rte_flow.h | 32 +++++ 2 files changed, 273 insertions(+), 28 deletions(-)
[...]
Quoted 35 lines
lib/librte_ether/rte_flow.h +20
-0@@ -268,6 +268,13 @@ enum rte_flow_item_type {* See struct rte_flow_item_vxlan. */ RTE_FLOW_ITEM_TYPE_VXLAN , + +/** +* Matches a E_TAG header. +* +* See struct rte_flow_item_e_tag. +*/ + RTE_FLOW_ITEM_TYPE_E_TAG, };/** @@ -454,6 +461,31 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +struct ether_addr dst;/**< Destination MAC. */ +struct ether_addr src;/**< Source MAC. */ +uint16_t e_tag_ethertype;/**< E-tag EtherType, 0x893F. */ +uint16_t e_pcp:3 ;/**< E-PCP */ +uint16_t dei:1 ;/**< DEI */ +uint16_t in_e_cid_base:12 ;/**< Ingress E-CID base */ +uint16_t rsv:2 ;/**< reserved */ +uint16_t grp:2 ;/**< GRP */
lib/librte_ether/rte_flow.h struct rte_flow_item_vxlan { · line 486
Quoted 10 lines
lib/librte_ether/rte_flow.h +10
-0+ uint16_t e_cid_base:12; /**< E-CID base */ + uint16_t in_e_cid_ext:8; /**< Ingress E-CID extend */ + uint16_t e_cid_ext:8; /**< E-CID extend */ +uint16_t type;/**< MAC type. */ +unsigned int tags;/**< Number of 802.1Q/ad tags defined. */ +struct { +uint16_t tpid;/**< Tag protocol identifier. */ +uint16_t tci;/**< Tag control information. */ + } tag[];/**< 802.1Q/ad tag definitions, outermost first. */ +};
[...]
See my previous reply [1], this definition is not endian-safe and comprises protocols defined as independent items (namely ETH and VLAN). Here is an untested suggestion:
struct rte_flow_item_e_tag {
uint16_t tpid; /**< Tag protocol identifier (0x893F). */
/** E-Tag control information (E-TCI). */
uint16_t epcp_edei_in_ecid_b; /**< E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */
uint16_t rsvd_grp_ecid_b; /**< Reserved (2b), GRP (2b), E-CID base (12b). */
uint8_t in_ecid_e; /**< Ingress E-CID ext. */
uint8_t ecid_e; /**< E-CID ext. */};
Applications are responsibile for breaking down and filling individual fields properly. Ethernet header would be provided as its own item as shown in this testpmd flow command example:
flow create 0 ingress pattern eth / e_tag in_ecid_base is 42 / end actions drop / end
Note, all multibyte values are in network order like other protocol header definitions.
[1] http://dpdk.org/ml/archives/dev/2016-December/053181.html
Message ID: [email protected]
Signature · 2 lines
Adrien Mazarguil 6WIND
Re: [PATCH v2 14/18] net/ixgbe: parse L2 tunnel filter
Hi, adrien
Quoted 84 lines
-----Original Message-----
From: Adrien Mazarguil [mailto:[email protected]]
Sent: Tuesday, January 3, 2017 10:08 PM
To: Zhao1, Wei <[email protected]>
Cc: [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 14/18] net/ixgbe: parse L2 tunnel filterHi Wei,
Quoted 5 lines · Wei Zhao
check if the rule is a L2 tunnel rule, and get the L2 tunnel info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>Quoted 7 lines
---
v2:
--add new error set function
--change return value type of parser function--- drivers/net/ixgbe/ixgbe_ethdev.c | 269+++++++++++++++++++++++++++++++++++----
Quoted 2 lines
lib/librte_ether/rte_flow.h | 32 +++++ 2 files changed, 273 insertions(+), 28 deletions(-)[...]
Quoted 33 lines
lib/librte_ether/rte_flow.h +19
-0@@ -268,6 +268,13 @@ enum rte_flow_item_type {* See struct rte_flow_item_vxlan. */ RTE_FLOW_ITEM_TYPE_VXLAN , + +/** +* Matches a E_TAG header. +* +* See struct rte_flow_item_e_tag. +*/ + RTE_FLOW_ITEM_TYPE_E_TAG, };/** @@ -454,6 +461,31 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +struct ether_addr dst;/**< Destination MAC. */ +struct ether_addr src;/**< Source MAC. */ +uint16_t e_tag_ethertype;/**< E-tag EtherType, 0x893F. */ +uint16_t e_pcp:3 ;/**< E-PCP */ +uint16_t dei:1 ;/**< DEI */ +uint16_t in_e_cid_base:12 ;/**< Ingress E-CID base */ +uint16_t rsv:2 ;/**< reserved */ lib/librte_ether/rte_flow.h struct rte_flow_item_vxlan { }; · line 484
Quoted 10 lines
lib/librte_ether/rte_flow.h +10
-0+ uint16_t grp:2; /**< GRP */ + uint16_t e_cid_base:12; /**< E-CID base */ + uint16_t in_e_cid_ext:8; /**< Ingress E-CID extend */ + uint16_t e_cid_ext:8; /**< E-CID extend */ +uint16_t type;/**< MAC type. */ +unsigned int tags;/**< Number of 802.1Q/ad tags defined. */ +struct { +uint16_t tpid;/**< Tag protocol identifier. */ +uint16_t tci;/**< Tag control information. */ + } tag[];/**< 802.1Q/ad tag definitions, outermost first. */ };[...]
See my previous reply [1], this definition is not endian-safe and comprises protocols defined as independent items (namely ETH and VLAN). Here is an untested suggestion:
struct rte_flow_item_e_tag { uint16_t tpid; /**< Tag protocol identifier (0x893F). */ /** E-Tag control information (E-TCI). */ uint16_t epcp_edei_in_ecid_b; /**< E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */ uint16_t rsvd_grp_ecid_b; /**< Reserved (2b), GRP (2b), E-CID base (12b). */ uint8_t in_ecid_e; /**< Ingress E-CID ext. */ uint8_t ecid_e; /**< E-CID ext. */
Quoted 9 lines
};
Applications are responsibile for breaking down and filling individual fields properly. Ethernet header would be provided as its own item as shown in this testpmd flow command example:
flow create 0 ingress pattern eth /
e_tagin_ecid_baseis 42 / end actions
drop / end
In this case , is eth an option or mandatory?
I think it is optional, because user may do not have any parameter in ETH config.
Quoted 9 lines
Note, all multibyte values are in network order like other protocol header definitions.
[1] http://dpdk.org/ml/archives/dev/2016-December/053181.html
Message ID: [email protected]--
Adrien Mazarguil
6WIND
Re: [PATCH v2 14/18] net/ixgbe: parse L2 tunnel filter
Quoted 92 lines · Wei
Hi, adrien
Quoted 90 lines
-----Original Message-----
From: Adrien Mazarguil [mailto:[email protected]]
Sent: Tuesday, January 3, 2017 10:08 PM
To: Zhao1, Wei <[email protected]>
Cc: [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 14/18] net/ixgbe: parse L2 tunnel filterHi Wei,
Quoted 5 lines · Wei Zhao
check if the rule is a L2 tunnel rule, and get the L2 tunnel info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>Quoted 7 lines
---
v2:
--add new error set function
--change return value type of parser function--- drivers/net/ixgbe/ixgbe_ethdev.c | 269+++++++++++++++++++++++++++++++++++----
Quoted 2 lines
lib/librte_ether/rte_flow.h | 32 +++++ 2 files changed, 273 insertions(+), 28 deletions(-)[...]
Quoted 33 lines
lib/librte_ether/rte_flow.h +19
-0@@ -268,6 +268,13 @@ enum rte_flow_item_type {* See struct rte_flow_item_vxlan. */ RTE_FLOW_ITEM_TYPE_VXLAN , + +/** +* Matches a E_TAG header. +* +* See struct rte_flow_item_e_tag. +*/ + RTE_FLOW_ITEM_TYPE_E_TAG, };/** @@ -454,6 +461,31 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +struct ether_addr dst;/**< Destination MAC. */ +struct ether_addr src;/**< Source MAC. */ +uint16_t e_tag_ethertype;/**< E-tag EtherType, 0x893F. */ +uint16_t e_pcp:3 ;/**< E-PCP */ +uint16_t dei:1 ;/**< DEI */ +uint16_t in_e_cid_base:12 ;/**< Ingress E-CID base */ +uint16_t rsv:2 ;/**< reserved */ lib/librte_ether/rte_flow.h struct rte_flow_item_vxlan { }; · line 484
Quoted 10 lines
lib/librte_ether/rte_flow.h +10
-0+ uint16_t grp:2; /**< GRP */ + uint16_t e_cid_base:12; /**< E-CID base */ + uint16_t in_e_cid_ext:8; /**< Ingress E-CID extend */ + uint16_t e_cid_ext:8; /**< E-CID extend */ +uint16_t type;/**< MAC type. */ +unsigned int tags;/**< Number of 802.1Q/ad tags defined. */ +struct { +uint16_t tpid;/**< Tag protocol identifier. */ +uint16_t tci;/**< Tag control information. */ + } tag[];/**< 802.1Q/ad tag definitions, outermost first. */ };[...]
See my previous reply [1], this definition is not endian-safe and comprises protocols defined as independent items (namely ETH and VLAN). Here is an untested suggestion:
struct rte_flow_item_e_tag { uint16_t tpid; /**< Tag protocol identifier (0x893F). */ /** E-Tag control information (E-TCI). */ uint16_t epcp_edei_in_ecid_b; /**< E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */ uint16_t rsvd_grp_ecid_b; /**< Reserved (2b), GRP (2b), E-CID base (12b). */ uint8_t in_ecid_e; /**< Ingress E-CID ext. */ uint8_t ecid_e; /**< E-CID ext. */};
Applications are responsibile for breaking down and filling individual fields properly. Ethernet header would be provided as its own item as shown in this testpmd flow command example:
Quoted 6 lines
Quoted 3 lines
flow create 0 ingress pattern eth /
e_tagin_ecid_baseis 42 / end actions
drop / endIn this case , is eth an option or mandatory?
I think it is optional, because user may do not have any parameter in ETH config.
Normally, protocol items start from L2 so applications *should* provide ETH otherwise it is an error.
Now a PMD may also allow it to be implicit when it is unambiguous (e.g. an imaginary ETH item provided without a mask) as described in the "UDPv6 anywhere" example [2]. It's up to you.
Quoted 5 lines
Quoted 5 lines
Note, all multibyte values are in network order like other protocol header definitions.
[1] http://dpdk.org/ml/archives/dev/2016-December/053181.html
Message ID: [email protected]
[2] http://dpdk.org/doc/guides/prog_guide/rte_flow.html#matching-pattern
Signature · 2 lines
Adrien Mazarguil 6WIND
PATCH v2 15/18 net/ixgbe: parse flow director filter
In reply to Wei Zhaocheck if the rule is a flow director rule, and get the flow director info.
---
v2:add new error set function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 1467 +++++++++++++++++++++++++++++++++----- drivers/net/ixgbe/ixgbe_ethdev.h | 16 + drivers/net/ixgbe/ixgbe_fdir.c | 247 ++++--- lib/librte_ether/rte_flow.h | 23 + 4 files changed, 1495 insertions(+), 258 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1291 -176
@@ -438,6 +438,31 @@ ixgbe_validate_l2_tn_filter(struct rte_eth_dev *dev,struct rte_eth_l2_tunnel_conf *rule, struct rte_flow_error *error);static int +ixgbe_validate_fdir_filter (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error); +static int +ixgbe_parse_fdir_filter_normal (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error); +static int +ixgbe_parse_fdir_filter_tunnel (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error); +static int +ixgbe_parse_fdir_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error); +static int ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item pattern[],
@@ -1475,6 +1500,8 @@ static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev) "Failed to allocate memory for fdir hash map!");return -ENOMEM ; } + fdir_info->mask_added = FALSE; +return 0 ; }
@@ -8951,117 +8978,22 @@ ixgbe_parse_syn_filter(const struct rte_flow_attr *attr,return 0 ; } -/** -* Parse the rule to see if it is a L2 tunnel rule. -* And get the L2 tunnel filter info BTW. -* Only support E-tag now. -*/ +/* Parse to get the attr and action info of flow director rule. */ static int -cons_parse_l2_tn_filter (const struct rte_flow_attr *attr, -const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], -struct rte_eth_l2_tunnel_conf *filter, -struct rte_flow_error *error) +ixgbe_parse_fdir_act_attr (const struct rte_flow_attr *attr, +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error) { -const struct rte_flow_item *item; -const struct rte_flow_item_e_tag *e_tag_spec; -const struct rte_flow_item_e_tag *e_tag_mask;const struct rte_flow_action *act;const struct rte_flow_action_queue *act_q; -uint32_t index, j; - -if (!pattern) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM_NUM , -NULL ,"NULL pattern." ); -return -rte_errno; - } - -/* parse pattern */ - index =0 ; - -/* The first not void item should be e-tag. */ -NEXT_ITEM_OF_PATTERN (item, pattern, index); -if (item->type !=RTE_FLOW_ITEM_TYPE_E_TAG ) { -memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item,"Not supported by L2 tunnel filter" ); -return -rte_errno; - } - -if (!item->spec || !item->mask) { -memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , - item,"Not supported by L2 tunnel filter" ); -return -rte_errno; - } - -/*Not supported last point for range*/ -if (item->last) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , - item,"Not supported last point for range" ); -return -rte_errno; - } - - e_tag_spec = (const struct rte_flow_item_e_tag *)item->spec; - e_tag_mask = (const struct rte_flow_item_e_tag *)item->mask; - -/* Src & dst MAC address should be masked. */ -for (j =0 ; j <ETHER_ADDR_LEN ; j++) { -if (e_tag_mask->src.addr_bytes[j] || - e_tag_mask->dst.addr_bytes[j]) { -memset (filter,0 , -sizeof (struct rte_eth_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item,"Not supported by L2 tunnel filter" ); -return -rte_errno; - } - } - -/* Only care about GRP and E cid base. */ -if (e_tag_mask->e_tag_ethertype || - e_tag_mask->e_pcp || - e_tag_mask->dei || - e_tag_mask->in_e_cid_base || - e_tag_mask->in_e_cid_ext || - e_tag_mask->e_cid_ext || - e_tag_mask->type || - e_tag_mask->tags || - e_tag_mask->grp !=0x3 || - e_tag_mask->e_cid_base !=0xFFF ) { -memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item,"Not supported by L2 tunnel filter" ); -return -rte_errno; - } - - filter->l2_tunnel_type =RTE_L2_TUNNEL_TYPE_E_TAG ; -/** -* grp and e_cid_base are bit fields and only use 14 bits. -* e-tag id is taken as little endian by HW. -*/ - filter->tunnel_id = e_tag_spec->grp <<12 ; - filter->tunnel_id |=rte_be_to_cpu_16 (e_tag_spec->e_cid_base); - -/* check if the next not void item is END */ - index++; -NEXT_ITEM_OF_PATTERN (item, pattern, index); -if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { -memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item,"Not supported by L2 tunnel filter" ); -return -rte_errno; - } +const struct rte_flow_action_mark *mark; +uint32_t index;/* parse attr */ /* must be input direction */ if (!attr->ingress) { -memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule ));rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , attr,"Only support ingress." );
@@ -9070,7 +9002,7 @@ cons_parse_l2_tn_filter(const struct rte_flow_attr *attr,/* not supported */ if (attr->egress) { -memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule ));rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , attr,"Not support egress." );
@@ -9079,7 +9011,7 @@ cons_parse_l2_tn_filter(const struct rte_flow_attr *attr,/* not supported */ if (attr->priority) { -memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule ));rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , attr,"Not support priority." );
@@ -9096,24 +9028,43 @@ cons_parse_l2_tn_filter(const struct rte_flow_attr *attr,return -rte_errno; } -/* check if the first not void action is QUEUE. */ +/* check if the first not void action is QUEUE or DROP. */ NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE ) { -memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE && + act->type !=RTE_FLOW_ACTION_TYPE_DROP ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule ));rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , act,"Not supported action." );return -rte_errno; } - act_q = (const struct rte_flow_action_queue *)act->conf; - filter->pool = act_q->index; +if (act->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { + act_q = (const struct rte_flow_action_queue *)act->conf; + rule->queue = act_q->index; + }else {/* drop */ + rule->fdirflags =IXGBE_FDIRCMD_DROP ; + } + +/* check if the next not void item is MARK */ + index++; +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_MARK ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + + mark = (const struct rte_flow_action_mark *)act->conf; + rule->soft_id = mark->id;/* check if the next not void item is END */ index++;NEXT_ITEM_OF_ACTION (act, actions, index);if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule ));rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , act,"Not supported action." );
@@ -9123,87 +9074,1245 @@ cons_parse_l2_tn_filter(const struct rte_flow_attr *attr,return 0 ; } -/* Destroy all flow rules associated with a port on ixgbe. */ +/** +* Parse the rule to see if it is a IP or MAC VLAN flow director rule. +* And get the flow director filter info BTW. +*/ static int -ixgbe_flow_flush (struct rte_eth_dev *dev, -struct rte_flow_error *error) +ixgbe_parse_fdir_filter_normal (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error) { -int ret =0 ; +const struct rte_flow_item *item; +const struct rte_flow_item_eth *eth_spec; +const struct rte_flow_item_eth *eth_mask; +const struct rte_flow_item_ipv4 *ipv4_spec; +const struct rte_flow_item_ipv4 *ipv4_mask; +const struct rte_flow_item_tcp *tcp_spec; +const struct rte_flow_item_tcp *tcp_mask; +const struct rte_flow_item_udp *udp_spec; +const struct rte_flow_item_udp *udp_mask; +const struct rte_flow_item_sctp *sctp_spec; +const struct rte_flow_item_sctp *sctp_mask; +const struct rte_flow_item_vlan *vlan_spec; +const struct rte_flow_item_vlan *vlan_mask; -ixgbe_clear_all_ntuple_filter (dev); -ixgbe_clear_all_ethertype_filter (dev); -ixgbe_clear_syn_filter (dev); +uint32_t index, j; - ret =ixgbe_clear_all_fdir_filter (dev); -if (ret <0 ) { +if (!pattern) {rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_HANDLE , -NULL ,"Failed to flush rule" ); -return ret; +RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; } - ret =ixgbe_clear_all_l2_tn_filter (dev); -if (ret <0 ) { +/** +* Some fields may not be provided. Set spec to 0 and mask to default +* value. So, we need not do anything for the not provided fields later. +*/ +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +memset (&rule->mask,0xFF ,sizeof (struct ixgbe_hw_fdir_mask )); + rule->mask.vlan_tci_mask =0 ; + +/* parse pattern */ + index =0 ; + +/** +* The first not void item should be +* MAC or IPv4 or TCP or UDP or SCTP. +*/ +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH && + item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_TCP && + item->type !=RTE_FLOW_ITEM_TYPE_UDP && + item->type !=RTE_FLOW_ITEM_TYPE_SCTP ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule ));rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_HANDLE , -NULL ,"Failed to flush rule" ); -return ret; +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; } -return 0 ; -} - -static int -ixgbe_validate_l2_tn_filter (struct rte_eth_dev *dev, -const struct rte_flow_attr *attr, -const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], -struct rte_eth_l2_tunnel_conf *l2_tn_filter, -struct rte_flow_error *error) -{ -int ret =0 ; -struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); + rule->mode =RTE_FDIR_MODE_PERFECT ; - ret =cons_parse_l2_tn_filter (attr, pattern, - actions, l2_tn_filter, error); +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; -if (hw->mac.type != ixgbe_mac_X550 && - hw->mac.type != ixgbe_mac_X550EM_x && - hw->mac.type != ixgbe_mac_X550EM_a) { -return -ENOTSUP ; } -return ret; -} +/* Get the MAC info. */ +if (item->type ==RTE_FLOW_ITEM_TYPE_ETH ) { +/** +* Only support vlan and dst MAC address, +* others should be masked. +*/ +if (item->spec && !item->mask) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } -/** -* Check if the flow rule is supported by ixgbe. -* It only checkes the format. Don't guarantee the rule can be programmed into -* the HW. Because there can be no enough room for the rule. -*/ -static int -ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, -const struct rte_flow_attr *attr, -const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], -struct rte_flow_error *error) -{ -struct rte_eth_ntuple_filter ntuple_filter; -struct rte_eth_ethertype_filter ethertype_filter; -struct rte_eth_syn_filter syn_filter; -struct rte_eth_l2_tunnel_conf l2_tn_filter; -int ret; +if (item->spec) { + rule->b_spec = TRUE; + eth_spec = (const struct rte_flow_item_eth *)item->spec; -memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); - ret =ixgbe_parse_ntuple_filter (attr, pattern, - actions, &ntuple_filter, error); -if (!ret) -return 0 ; +/* Get the dst MAC. */ +for (j =0 ; j <ETHER_ADDR_LEN ; j++) { + rule->ixgbe_fdir.formatted.inner_mac[j] = + eth_spec->dst.addr_bytes[j]; + } + } -memset (ðertype_filter,0 ,sizeof (struct rte_eth_ethertype_filter )); - ret =ixgbe_parse_ethertype_filter (attr, pattern, - actions, ðertype_filter, error); -if (!ret) + +if (item->mask) { +/* If ethernet has meaning, it means MAC VLAN mode. */ + rule->mode =RTE_FDIR_MODE_PERFECT_MAC_VLAN ; + + rule->b_mask = TRUE; + eth_mask = (const struct rte_flow_item_eth *)item->mask; + +/* Ether type should be masked. */ +if (eth_mask->type) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + +/** +* src MAC address must be masked, +* and don't support dst MAC address mask. +*/ +for (j =0 ; j <ETHER_ADDR_LEN ; j++) { +if (eth_mask->src.addr_bytes[j] || + eth_mask->dst.addr_bytes[j] !=0xFF ) { +memset (rule,0 , +sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + } + +/* When no VLAN, considered as full mask. */ + rule->mask.vlan_tci_mask =rte_cpu_to_be_16 (0xEFFF ); + } +/*** If both spec and mask are item, +* it means don't care about ETH. +* Do nothing. +*/ + +/** +* Check if the next not void item is vlan or ipv4. +* IPv6 is not supported. +*/ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (rule->mode ==RTE_FDIR_MODE_PERFECT_MAC_VLAN ) { +if (item->type !=RTE_FLOW_ITEM_TYPE_VLAN ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + }else { +if (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + } + } + +if (item->type ==RTE_FLOW_ITEM_TYPE_VLAN ) { +if (!(item->spec && item->mask)) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } + + vlan_spec = (const struct rte_flow_item_vlan *)item->spec; + vlan_mask = (const struct rte_flow_item_vlan *)item->mask; + +if (vlan_spec->tpid !=rte_cpu_to_be_16 (ETHER_TYPE_VLAN )) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + + rule->ixgbe_fdir.formatted.vlan_id = vlan_spec->tci; + +if (vlan_mask->tpid != (uint16_t )~0U ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + rule->mask.vlan_tci_mask = vlan_mask->tci; +/* More than one tags are not supported. */ + +/** +* Check if the next not void item is not vlan. +*/ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type ==RTE_FLOW_ITEM_TYPE_VLAN ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + }else if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + } + +/* Get the IP info. */ +if (item->type ==RTE_FLOW_ITEM_TYPE_IPV4 ) { +/** +* Set the flow type even if there's no content +* as we must have a flow type. +*/ + rule->ixgbe_fdir.formatted.flow_type = +IXGBE_ATR_FLOW_TYPE_IPV4 ; +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } +/** +* Only care about src & dst addresses, +* others should be masked. +*/ +if (!item->mask) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + rule->b_mask = TRUE; + ipv4_mask = + (const struct rte_flow_item_ipv4 *)item->mask; +if (ipv4_mask->hdr.version_ihl || + ipv4_mask->hdr.type_of_service || + ipv4_mask->hdr.total_length || + ipv4_mask->hdr.packet_id || + ipv4_mask->hdr.fragment_offset || + ipv4_mask->hdr.time_to_live || + ipv4_mask->hdr.next_proto_id || + ipv4_mask->hdr.hdr_checksum) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + rule->mask.dst_ipv4_mask = ipv4_mask->hdr.dst_addr; + rule->mask.src_ipv4_mask = ipv4_mask->hdr.src_addr; + +if (item->spec) { + rule->b_spec = TRUE; + ipv4_spec = + (const struct rte_flow_item_ipv4 *)item->spec; + rule->ixgbe_fdir.formatted.dst_ip[0 ] = + ipv4_spec->hdr.dst_addr; + rule->ixgbe_fdir.formatted.src_ip[0 ] = + ipv4_spec->hdr.src_addr; + } + +/** +* Check if the next not void item is +* TCP or UDP or SCTP or END. +*/ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_TCP && + item->type !=RTE_FLOW_ITEM_TYPE_UDP && + item->type !=RTE_FLOW_ITEM_TYPE_SCTP && + item->type !=RTE_FLOW_ITEM_TYPE_END ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + } + +/* Get the TCP info. */ +if (item->type ==RTE_FLOW_ITEM_TYPE_TCP ) { +/** +* Set the flow type even if there's no content +* as we must have a flow type. +*/ + rule->ixgbe_fdir.formatted.flow_type = +IXGBE_ATR_FLOW_TYPE_TCPV4 ; +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } +/** +* Only care about src & dst ports, +* others should be masked. +*/ +if (!item->mask) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + rule->b_mask = TRUE; + tcp_mask = (const struct rte_flow_item_tcp *)item->mask; +if (tcp_mask->hdr.sent_seq || + tcp_mask->hdr.recv_ack || + tcp_mask->hdr.data_off || + tcp_mask->hdr.tcp_flags || + tcp_mask->hdr.rx_win || + tcp_mask->hdr.cksum || + tcp_mask->hdr.tcp_urp) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + rule->mask.src_port_mask = tcp_mask->hdr.src_port; + rule->mask.dst_port_mask = tcp_mask->hdr.dst_port; + +if (item->spec) { + rule->b_spec = TRUE; + tcp_spec = (const struct rte_flow_item_tcp *)item->spec; + rule->ixgbe_fdir.formatted.src_port = + tcp_spec->hdr.src_port; + rule->ixgbe_fdir.formatted.dst_port = + tcp_spec->hdr.dst_port; + } + } + +/* Get the UDP info */ +if (item->type ==RTE_FLOW_ITEM_TYPE_UDP ) { +/** +* Set the flow type even if there's no content +* as we must have a flow type. +*/ + rule->ixgbe_fdir.formatted.flow_type = +IXGBE_ATR_FLOW_TYPE_UDPV4 ; +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } +/** +* Only care about src & dst ports, +* others should be masked. +*/ +if (!item->mask) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + rule->b_mask = TRUE; + udp_mask = (const struct rte_flow_item_udp *)item->mask; +if (udp_mask->hdr.dgram_len || + udp_mask->hdr.dgram_cksum) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + rule->mask.src_port_mask = udp_mask->hdr.src_port; + rule->mask.dst_port_mask = udp_mask->hdr.dst_port; + +if (item->spec) { + rule->b_spec = TRUE; + udp_spec = (const struct rte_flow_item_udp *)item->spec; + rule->ixgbe_fdir.formatted.src_port = + udp_spec->hdr.src_port; + rule->ixgbe_fdir.formatted.dst_port = + udp_spec->hdr.dst_port; + } + } + +/* Get the SCTP info */ +if (item->type ==RTE_FLOW_ITEM_TYPE_SCTP ) { +/** +* Set the flow type even if there's no content +* as we must have a flow type. +*/ + rule->ixgbe_fdir.formatted.flow_type = +IXGBE_ATR_FLOW_TYPE_SCTPV4 ; +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } +/** +* Only care about src & dst ports, +* others should be masked. +*/ +if (!item->mask) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + rule->b_mask = TRUE; + sctp_mask = + (const struct rte_flow_item_sctp *)item->mask; +if (sctp_mask->hdr.tag || + sctp_mask->hdr.cksum) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + rule->mask.src_port_mask = sctp_mask->hdr.src_port; + rule->mask.dst_port_mask = sctp_mask->hdr.dst_port; + +if (item->spec) { + rule->b_spec = TRUE; + sctp_spec = + (const struct rte_flow_item_sctp *)item->spec; + rule->ixgbe_fdir.formatted.src_port = + sctp_spec->hdr.src_port; + rule->ixgbe_fdir.formatted.dst_port = + sctp_spec->hdr.dst_port; + } + } + +if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + } + +return ixgbe_parse_fdir_act_attr (attr, actions, rule, error); +} + +#define NVGRE_PROTOCOL 0x6558 + +/** +* Parse the rule to see if it is a VxLAN or NVGRE flow director rule. +* And get the flow director filter info BTW. +*/ +static int +ixgbe_parse_fdir_filter_tunnel (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error) +{ +const struct rte_flow_item *item; +const struct rte_flow_item_vxlan *vxlan_spec; +const struct rte_flow_item_vxlan *vxlan_mask; +const struct rte_flow_item_nvgre *nvgre_spec; +const struct rte_flow_item_nvgre *nvgre_mask; +const struct rte_flow_item_eth *eth_spec; +const struct rte_flow_item_eth *eth_mask; +const struct rte_flow_item_vlan *vlan_spec; +const struct rte_flow_item_vlan *vlan_mask; +uint32_t index, j; + +if (!pattern) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } + +/** +* Some fields may not be provided. Set spec to 0 and mask to default +* value. So, we need not do anything for the not provided fields later. +*/ +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +memset (&rule->mask,0xFF ,sizeof (struct ixgbe_hw_fdir_mask )); + rule->mask.vlan_tci_mask =0 ; + +/* parse pattern */ + index =0 ; + +/** +* The first not void item should be +* MAC or IPv4 or IPv6 or UDP or VxLAN. +*/ +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH && + item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_IPV6 && + item->type !=RTE_FLOW_ITEM_TYPE_UDP && + item->type !=RTE_FLOW_ITEM_TYPE_VXLAN && + item->type !=RTE_FLOW_ITEM_TYPE_NVGRE ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + + rule->mode =RTE_FDIR_MODE_PERFECT_TUNNEL ; + +/* Skip MAC. */ +if (item->type ==RTE_FLOW_ITEM_TYPE_ETH ) { +/* Only used to describe the protocol stack. */ +if (item->spec || item->mask) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } + +/* Check if the next not void item is IPv4 or IPv6. */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + } + +/* Skip IP. */ +if (item->type ==RTE_FLOW_ITEM_TYPE_IPV4 || + item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ) { +/* Only used to describe the protocol stack. */ +if (item->spec || item->mask) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } + +/* Check if the next not void item is UDP or NVGRE. */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_UDP && + item->type !=RTE_FLOW_ITEM_TYPE_NVGRE ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + } + +/* Skip UDP. */ +if (item->type ==RTE_FLOW_ITEM_TYPE_UDP ) { +/* Only used to describe the protocol stack. */ +if (item->spec || item->mask) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } + +/* Check if the next not void item is VxLAN. */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_VXLAN ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + } + +/* Get the VxLAN info */ +if (item->type ==RTE_FLOW_ITEM_TYPE_VXLAN ) { + rule->ixgbe_fdir.formatted.tunnel_type = +RTE_FDIR_TUNNEL_TYPE_VXLAN ; + +/* Only care about VNI, others should be masked. */ +if (!item->mask) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } + rule->b_mask = TRUE; + +/* Tunnel type is always meaningful. */ + rule->mask.tunnel_type_mask =1 ; + + vxlan_mask = + (const struct rte_flow_item_vxlan *)item->mask; +if (vxlan_mask->flags) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/* VNI must be totally masked or not. */ +if ((vxlan_mask->vni[0 ] || vxlan_mask->vni[1 ] || + vxlan_mask->vni[2 ]) && + ((vxlan_mask->vni[0 ] !=0xFF ) || + (vxlan_mask->vni[1 ] !=0xFF ) || + (vxlan_mask->vni[2 ] !=0xFF ))) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + +rte_memcpy (&rule->mask.tunnel_id_mask, vxlan_mask->vni, +RTE_DIM (vxlan_mask->vni)); + rule->mask.tunnel_id_mask <<=8 ; + +if (item->spec) { + rule->b_spec = TRUE; + vxlan_spec = (const struct rte_flow_item_vxlan *) + item->spec; +rte_memcpy (&rule->ixgbe_fdir.formatted.tni_vni, + vxlan_spec->vni,RTE_DIM (vxlan_spec->vni)); + rule->ixgbe_fdir.formatted.tni_vni <<=8 ; + } + } + +/* Get the NVGRE info */ +if (item->type ==RTE_FLOW_ITEM_TYPE_NVGRE ) { + rule->ixgbe_fdir.formatted.tunnel_type = +RTE_FDIR_TUNNEL_TYPE_NVGRE ; + +/** +* Only care about flags0, flags1, protocol and TNI, +* others should be masked. +*/ +if (!item->mask) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } + rule->b_mask = TRUE; + +/* Tunnel type is always meaningful. */ + rule->mask.tunnel_type_mask =1 ; + + nvgre_mask = + (const struct rte_flow_item_nvgre *)item->mask; +if (nvgre_mask->ver || + nvgre_mask->flow_id) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +if (!nvgre_mask->flags0 || + nvgre_mask->flags1 !=0x3 || + nvgre_mask->protocol !=0xFFFF ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/* TNI must be totally masked or not. */ +if (nvgre_mask->tni[0 ] && + ((nvgre_mask->tni[0 ] !=0xFF ) || + (nvgre_mask->tni[1 ] !=0xFF ) || + (nvgre_mask->tni[2 ] !=0xFF ))) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/* tni is a 24-bits bit field */ +rte_memcpy (&rule->mask.tunnel_id_mask, nvgre_mask->tni, +RTE_DIM (nvgre_mask->tni)); + rule->mask.tunnel_id_mask <<=8 ; + +if (item->spec) { + rule->b_spec = TRUE; + nvgre_spec = + (const struct rte_flow_item_nvgre *)item->spec; +if (nvgre_spec->flags0 || + nvgre_spec->flags1 !=2 || + nvgre_spec->protocol != +rte_cpu_to_be_16 (NVGRE_PROTOCOL )) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/* tni is a 24-bits bit field */ +rte_memcpy (&rule->ixgbe_fdir.formatted.tni_vni, + nvgre_spec->tni,RTE_DIM (nvgre_spec->tni)); + rule->ixgbe_fdir.formatted.tni_vni <<=8 ; + } + } + +/* check if the next not void item is MAC */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + +/** +* Only support vlan and dst MAC address, +* others should be masked. +*/ + +if (!item->mask) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } + rule->b_mask = TRUE; + eth_mask = (const struct rte_flow_item_eth *)item->mask; + +/* Ether type should be masked. */ +if (eth_mask->type) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + +/* src MAC address should be masked. */ +for (j =0 ; j <ETHER_ADDR_LEN ; j++) { +if (eth_mask->src.addr_bytes[j]) { +memset (rule,0 , +sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + } + rule->mask.mac_addr_byte_mask =0 ; +for (j =0 ; j <ETHER_ADDR_LEN ; j++) { +/* It's a per byte mask. */ +if (eth_mask->dst.addr_bytes[j] ==0xFF ) { + rule->mask.mac_addr_byte_mask |=0x1 << j; + }else if (eth_mask->dst.addr_bytes[j]) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + } + +/* When no vlan, considered as full mask. */ + rule->mask.vlan_tci_mask =rte_cpu_to_be_16 (0xEFFF ); + +if (item->spec) { + rule->b_spec = TRUE; + eth_spec = (const struct rte_flow_item_eth *)item->spec; + +/* Get the dst MAC. */ +for (j =0 ; j <ETHER_ADDR_LEN ; j++) { + rule->ixgbe_fdir.formatted.inner_mac[j] = + eth_spec->dst.addr_bytes[j]; + } + } + +/** +* Check if the next not void item is vlan or ipv4. +* IPv6 is not supported. +*/ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if ((item->type !=RTE_FLOW_ITEM_TYPE_VLAN ) && + (item->type !=RTE_FLOW_ITEM_TYPE_VLAN )) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } + +if (item->type ==RTE_FLOW_ITEM_TYPE_VLAN ) { +if (!(item->spec && item->mask)) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + + vlan_spec = (const struct rte_flow_item_vlan *)item->spec; + vlan_mask = (const struct rte_flow_item_vlan *)item->mask; + +if (vlan_spec->tpid !=rte_cpu_to_be_16 (ETHER_TYPE_VLAN )) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + + rule->ixgbe_fdir.formatted.vlan_id = vlan_spec->tci; + +if (vlan_mask->tpid != (uint16_t )~0U ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + rule->mask.vlan_tci_mask = vlan_mask->tci; +/* More than one tags are not supported. */ + +/** +* Check if the next not void item is not vlan. +*/ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type ==RTE_FLOW_ITEM_TYPE_VLAN ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + }else if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } + } + +/** +* If the tags is 0, it means don't care about the VLAN. +* Do nothing. +*/ + +return ixgbe_parse_fdir_act_attr (attr, actions, rule, error); +} + +static int +ixgbe_validate_fdir_filter (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error) +{ +int ret =0 ; + +enum rte_fdir_mode fdir_mode = dev->data->dev_conf.fdir_conf.mode; + +ixgbe_parse_fdir_filter (attr, pattern, actions, + rule, error); + + +if (fdir_mode ==RTE_FDIR_MODE_NONE || + fdir_mode != rule->mode) +return -ENOTSUP ; + +return ret; +} + +static int +ixgbe_parse_fdir_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error) +{ +int ret; + + ret =ixgbe_parse_fdir_filter_normal (attr, pattern, + actions, rule, error); + +if (!ret) +return 0 ; + + ret =ixgbe_parse_fdir_filter_tunnel (attr, pattern, + actions, rule, error); + +return ret; +} + +/** +* Parse the rule to see if it is a L2 tunnel rule. +* And get the L2 tunnel filter info BTW. +* Only support E-tag now. +*/ +static int +cons_parse_l2_tn_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_l2_tunnel_conf *filter, +struct rte_flow_error *error) +{ +const struct rte_flow_item *item; +const struct rte_flow_item_e_tag *e_tag_spec; +const struct rte_flow_item_e_tag *e_tag_mask; +const struct rte_flow_action *act; +const struct rte_flow_action_queue *act_q; +uint32_t index, j; + +if (!pattern) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } + +/* parse pattern */ + index =0 ; + +/* The first not void item should be e-tag. */ +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_E_TAG ) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by L2 tunnel filter" ); +return -rte_errno; + } + +if (!item->spec || !item->mask) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by L2 tunnel filter" ); +return -rte_errno; + } + +/*Not supported last point for range*/ +if (item->last) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , + item,"Not supported last point for range" ); +return -rte_errno; + } + + e_tag_spec = (const struct rte_flow_item_e_tag *)item->spec; + e_tag_mask = (const struct rte_flow_item_e_tag *)item->mask; + +/* Src & dst MAC address should be masked. */ +for (j =0 ; j <ETHER_ADDR_LEN ; j++) { +if (e_tag_mask->src.addr_bytes[j] || + e_tag_mask->dst.addr_bytes[j]) { +memset (filter,0 , +sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by L2 tunnel filter" ); +return -rte_errno; + } + } + +/* Only care about GRP and E cid base. */ +if (e_tag_mask->e_tag_ethertype || + e_tag_mask->e_pcp || + e_tag_mask->dei || + e_tag_mask->in_e_cid_base || + e_tag_mask->in_e_cid_ext || + e_tag_mask->e_cid_ext || + e_tag_mask->type || + e_tag_mask->tags || + e_tag_mask->grp !=0x3 || + e_tag_mask->e_cid_base !=0xFFF ) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by L2 tunnel filter" ); +return -rte_errno; + } + + filter->l2_tunnel_type =RTE_L2_TUNNEL_TYPE_E_TAG ; +/** +* grp and e_cid_base are bit fields and only use 14 bits. +* e-tag id is taken as little endian by HW. +*/ + filter->tunnel_id = e_tag_spec->grp <<12 ; + filter->tunnel_id |=rte_be_to_cpu_16 (e_tag_spec->e_cid_base); + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_PATTERN (item, pattern, index); +if (item->type !=RTE_FLOW_ITEM_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by L2 tunnel filter" ); +return -rte_errno; + } + +/* parse attr */ +/* must be input direction */ +if (!attr->ingress) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , + attr,"Only support ingress." ); +return -rte_errno; + } + +/* not supported */ +if (attr->egress) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , + attr,"Not support egress." ); +return -rte_errno; + } + +/* not supported */ +if (attr->priority) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , + attr,"Not support priority." ); +return -rte_errno; + } + +/* parse action */ + index =0 ; + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } + +/* check if the first not void action is QUEUE. */ +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE ) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + + act_q = (const struct rte_flow_action_queue *)act->conf; + filter->pool = act_q->index; + +/* check if the next not void item is END */ + index++; +NEXT_ITEM_OF_ACTION (act, actions, index); +if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +memset (filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); +return -rte_errno; + } + +return 0 ; +} + +/* Destroy all flow rules associated with a port on ixgbe. */ +static int +ixgbe_flow_flush (struct rte_eth_dev *dev, +struct rte_flow_error *error) +{ +int ret =0 ; + +ixgbe_clear_all_ntuple_filter (dev); +ixgbe_clear_all_ethertype_filter (dev); +ixgbe_clear_syn_filter (dev); + + ret =ixgbe_clear_all_fdir_filter (dev); +if (ret <0 ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_HANDLE , +NULL ,"Failed to flush rule" ); +return ret; + } + + ret =ixgbe_clear_all_l2_tn_filter (dev); +if (ret <0 ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_HANDLE , +NULL ,"Failed to flush rule" ); +return ret; + } + +return 0 ; +} + +static int +ixgbe_validate_l2_tn_filter (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_eth_l2_tunnel_conf *l2_tn_filter, +struct rte_flow_error *error) +{ +int ret =0 ; +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); + + ret =cons_parse_l2_tn_filter (attr, pattern, + actions, l2_tn_filter, error); + +if (hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a) { +return -ENOTSUP ; + } + +return ret; +} + +/** +* Check if the flow rule is supported by ixgbe. +* It only checkes the format. Don't guarantee the rule can be programmed into +* the HW. Because there can be no enough room for the rule. +*/ +static int +ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error) +{ +struct rte_eth_ntuple_filter ntuple_filter; +struct rte_eth_ethertype_filter ethertype_filter; +struct rte_eth_syn_filter syn_filter; +struct rte_eth_l2_tunnel_conf l2_tn_filter; +struct ixgbe_fdir_rule fdir_rule; +int ret; + +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); + ret =ixgbe_parse_ntuple_filter (attr, pattern, + actions, &ntuple_filter, error); +if (!ret) +return 0 ; + +memset (ðertype_filter,0 ,sizeof (struct rte_eth_ethertype_filter )); + ret =ixgbe_parse_ethertype_filter (attr, pattern, + actions, ðertype_filter, error); +if (!ret)return 0 ;memset (&syn_filter,0 ,sizeof (struct rte_eth_syn_filter ));
@@ -9212,7 +10321,13 @@ ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev,if (!ret)return 0 ; -memset (&l2_tn_filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); +memset (&fdir_rule,0 ,sizeof (struct ixgbe_fdir_rule )); + ret =ixgbe_validate_fdir_filter (dev, attr, pattern, + actions, &fdir_rule, error); +if (!ret) +return 0 ; + +memset (&l2_tn_filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); ret =ixgbe_validate_l2_tn_filter (dev, attr, pattern, actions, &l2_tn_filter, error);
drivers/net/ixgbe/ixgbe_ethdev.h +16 -0
@@ -162,6 +162,17 @@ struct ixgbe_fdir_filter {/* list of fdir filters */ TAILQ_HEAD (ixgbe_fdir_filter_list, ixgbe_fdir_filter); +struct ixgbe_fdir_rule { +struct ixgbe_hw_fdir_mask mask; +union ixgbe_atr_input ixgbe_fdir;/* key of fdir filter*/ +bool b_spec;/* If TRUE, ixgbe_fdir, fdirflags, queue have meaning. */ +bool b_mask;/* If TRUE, mask has meaning. */ +enum rte_fdir_mode mode;/* IP, MAC VLAN, Tunnel */ +uint32_t fdirflags;/* drop or forward */ +uint32_t soft_id;/* an unique value for this rule */ +uint8_t queue;/* assigned rx queue */ +}; +struct ixgbe_hw_fdir_info {struct ixgbe_hw_fdir_mask mask;uint8_t flex_bytes_offset;
@@ -177,6 +188,7 @@ struct ixgbe_hw_fdir_info {/* store the pointers of the filters, index is the hash value. */ struct ixgbe_fdir_filter **hash_map;struct rte_hash *hash_handle;/* cuckoo hash handler */ +bool mask_added;/* If already got mask from consistent filter */ };/* structure for interrupt relative data */
@@ -473,6 +485,10 @@ bool ixgbe_rss_update_sp(enum ixgbe_mac_type mac_type);* Flow director function prototypes */ int ixgbe_fdir_configure (struct rte_eth_dev *dev); +int ixgbe_fdir_set_input_mask (struct rte_eth_dev *dev); +int ixgbe_fdir_filter_program (struct rte_eth_dev *dev, +struct ixgbe_fdir_rule *rule, +bool del,bool update);void ixgbe_configure_dcb (struct rte_eth_dev *dev);
drivers/net/ixgbe/ixgbe_fdir.c +165 -82
449 lines not on this page · raw message
lib/librte_ether/rte_flow.h +23 -0
@@ -275,6 +275,13 @@ enum rte_flow_item_type {* See struct rte_flow_item_e_tag. */ RTE_FLOW_ITEM_TYPE_E_TAG , + +/** +* Matches a NVGRE header. +* +* See struct rte_flow_item_nvgre. +*/ + RTE_FLOW_ITEM_TYPE_NVGRE, };/**
@@ -486,6 +493,22 @@ struct rte_flow_item_e_tag { };/** +* RTE_FLOW_ITEM_TYPE_NVGRE. +* +* Matches a NVGRE header. +*/ +struct rte_flow_item_nvgre { +uint32_t flags0:1 ;/**< 0 */ +uint32_t rsvd1:1 ;/**< 1 bit not defined */ +uint32_t flags1:2 ;/**< 2 bits, 1 0 */ +uint32_t rsvd0:9 ;/**< Reserved0 */ +uint32_t ver:3 ;/**< version */ +uint32_t protocol:16 ;/**< protocol type, 0x6558 */ +uint8_t tni[3 ];/**< tenant network ID or virtual subnet ID */ +uint8_t flow_id;/**< flow ID or Reserved */ +}; + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol
Signature · 1 line
2.5.5
Re: [PATCH v2 15/18] net/ixgbe: parse flow director filter
Quoted 78 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Zhao1, Wei <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: [dpdk-dev] [PATCH v2 15/18] net/ixgbe: parse flow director filtercheck if the rule is a flow director rule, and get the flow director info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:add new error set function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 1467 +++++++++++++++++++++++++++++++++----- drivers/net/ixgbe/ixgbe_ethdev.h | 16 + drivers/net/ixgbe/ixgbe_fdir.c | 247 ++++--- lib/librte_ether/rte_flow.h | 23 + 4 files changed, 1495 insertions(+), 258 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +27
-2@@ -438,6 +438,31 @@ ixgbe_validate_l2_tn_filter(struct rte_eth_dev *dev,struct rte_eth_l2_tunnel_conf *rule, struct rte_flow_error *error);static int +ixgbe_validate_fdir_filter (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error); +static int +ixgbe_parse_fdir_filter_normal (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error); +static int +ixgbe_parse_fdir_filter_tunnel (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error); +static int +ixgbe_parse_fdir_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error); +static int ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item pattern[],@@ -1475,6 +1500,8 @@ static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev) "Failed to allocate memory for fdir hash map!");return -ENOMEM ; } + fdir_info->mask_added = FALSE; +return 0 ; }@@ -8951,117 +8978,22 @@ ixgbe_parse_syn_filter(const structrte_flow_attr *attr, return 0; } -/** -* Parse the rule to see if it is a L2 tunnel rule.
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_syn_filter(const struct · line 8965
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1
-8-* And get the L2 tunnel filter info BTW. -* Only support E-tag now. -*/ +/* Parse to get the attr and action info of flow director rule. */ static int -cons_parse_l2_tn_filter (const struct rte_flow_attr *attr, -const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], -struct rte_eth_l2_tunnel_conf *filter, -struct rte_flow_error *error)
Why do u remove functions added in patch 14/18? If the functions don't be needed, how about changing patch 14/18?
Re: [PATCH v2 15/18] net/ixgbe: parse flow director filter
Hi, beilei
Quoted 198 lines
-----Original Message-----
From: Xing, Beilei
Sent: Monday, January 2, 2017 11:24 PM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc Zhao1, Wei <[email protected]>; Lu, WenzhuoSubject: RE: [dpdk-dev] [PATCH v2 15/18] net/ixgbe: parse flow director filter
Review ixgbe_validate_l2_tn_filter(struct rte_eth_dev
Quoted 61 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]<mailto:[email protected]>
Cc Zhao1, Wei <[email protected]<mailto:[email protected]>>; Lu, Wenzhuo<[email protected]<mailto:[email protected]>>
Subject: [dpdk-dev] [PATCH v2 15/18] net/ixgbe: parse flow director
filter
check if the rule is a flow director rule, and get the flow director info.
Signed-off-by Wei Zhao <[email protected]<mailto:[email protected]>>Signed-off-by Wenzhuo Lu <[email protected]<mailto:[email protected]>>---
v2:add new error set function
---
drivers/net/ixgbe/ixgbe_ethdev.c | 1467+++++++++++++++++++++++++++++++++-----
drivers/net/ixgbe/ixgbe_ethdev.h | 16 +drivers/net/ixgbe/ixgbe_fdir.c | 247 ++++---lib/librte_ether/rte_flow.h | 23 +4 files changed, 1495 insertions(+), 258 deletions(-)(quoted diff) +0
-0
b/drivers/net/ixgbe/ixgbe_ethdev.cindex 0a5ac4f..c98aa0d 100644
---
a/drivers/net/ixgbe/ixgbe_ethdev.c+++
b/drivers/net/ixgbe/ixgbe_ethdev.c(quoted diff) +0
-0@@ -438,6 +438,31 @@ ixgbe_validate_l2_tn_filter(struct rte_eth_dev*dev,
Quoted 51 lines
(quoted diff) +23
-0struct rte_eth_l2_tunnel_conf *rule, struct rte_flow_error *error); static int +ixgbe_validate_fdir_filter(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], + const struct rte_flow_action actions[], + struct ixgbe_fdir_rule *rule, + struct rte_flow_error *error); +static int +ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], + const struct rte_flow_action actions[], + struct ixgbe_fdir_rule *rule, + struct rte_flow_error *error); +static int +ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], + const struct rte_flow_action actions[], + struct ixgbe_fdir_rule *rule, + struct rte_flow_error *error); +static int +ixgbe_parse_fdir_filter(const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], + const struct rte_flow_action actions[], + struct ixgbe_fdir_rule *rule,Review ixgbe_validate_l2_tn_filter(struct rte_eth_dev
Quoted 10 lines
(quoted diff) +2
-0+ struct rte_flow_error *error); +static int ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], @@ -1475,6 +1500,8@@ static
Quoted 51 lines
int ixgbe_fdir_filter_init(struct
rte_eth_dev
*eth_dev)"Failed to allocate memory for fdir hash map!"); return -ENOMEM; }drivers/net/ixgbe/ixgbe_ethdev.c +3
-9+ fdir_info->mask_added = FALSE; +return 0 ; }@@ -8951,117 +8978,22 @@ ixgbe_parse_syn_filter(const structrte_flow_attr *attr, return 0; } -/** -* Parse the rule to see if it is a L2 tunnel rule. -* And get the L2 tunnel filter info BTW. -* Only support E-tag now. -*/ +/* Parse to get the attr and action info of flow director rule. */ static int -cons_parse_l2_tn_filter(const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - struct rte_eth_l2_tunnel_conf *filter,
Quoted 7 lines
Review ixgbe_parse_syn_filter(const struct · line 8980
Quoted 1 line
(quoted diff) +0
-1- struct rte_flow_error *error)Why do u remove functions added in patch 14/18? If the functions don't be
needed, how about changing patch 14/18?
This patch is generate in a very complicated way.
If you go on reading this patch, you will find the following statement, path add the functions back itself latter
So the git seem to generate a patch in a peculiar way.
+static int
+cons_parse_l2_tn_filter(const struct rte_flow_attr *attr,
+ const struct rte_flow_item pattern[],
+ const struct rte_flow_action actions[],
+ struct rte_eth_l2_tunnel_conf *filter,
+ struct rte_flow_error *error)
Re: [PATCH v2 15/18] net/ixgbe: parse flow director filter
In reply to Xing, BeileiHi, beilei
Quoted 88 lines
-----Original Message-----
From: Xing, Beilei
Sent: Monday, January 2, 2017 11:24 PM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Zhao1, Wei <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 15/18] net/ixgbe: parse flow director filterdrivers/net/ixgbe/ixgbe_ethdev.c ixgbe_validate_l2_tn_filter(struct rte_eth_dev
Quoted 31 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Zhao1, Wei <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: [dpdk-dev] [PATCH v2 15/18] net/ixgbe: parse flow director filtercheck if the rule is a flow director rule, and get the flow director info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:add new error set function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 1467 +++++++++++++++++++++++++++++++++----- drivers/net/ixgbe/ixgbe_ethdev.h | 16 + drivers/net/ixgbe/ixgbe_fdir.c | 247 ++++--- lib/librte_ether/rte_flow.h | 23 + 4 files changed, 1495 insertions(+), 258 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +0
-0@@ -438,6 +438,31 @@ ixgbe_validate_l2_tn_filter(struct rte_eth_dev*dev,
Quoted 21 lines
drivers/net/ixgbe/ixgbe_ethdev.c +18
-0struct rte_eth_l2_tunnel_conf *rule, struct rte_flow_error *error);static int +ixgbe_validate_fdir_filter (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error); +static int +ixgbe_parse_fdir_filter_normal (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error); +static int +ixgbe_parse_fdir_filter_tunnel (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error);drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_validate_l2_tn_filter(struct rte_eth_dev *dev,
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +7
-0+static int +ixgbe_parse_fdir_filter (const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct ixgbe_fdir_rule *rule, +struct rte_flow_error *error); +static int ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], @@ -1475,6 +1500,8@@ static
Quoted 15 lines
int ixgbe_fdir_filter_init(struct
rte_eth_dev*eth_dev)drivers/net/ixgbe/ixgbe_ethdev.c +2
-0"Failed to allocate memory for fdir hash map!");return -ENOMEM ; } + fdir_info->mask_added = FALSE; +return 0 ; }@@ -8951,117 +8978,22 @@ ixgbe_parse_syn_filter(const structrte_flow_attr *attr, return 0; }
Quoted 15 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_parse_syn_filter(const struct rte_flow_attr *attr, · line 8964
Quoted 12 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1
-10-/** -* Parse the rule to see if it is a L2 tunnel rule. -* And get the L2 tunnel filter info BTW. -* Only support E-tag now. -*/ +/* Parse to get the attr and action info of flow director rule. */ static int -cons_parse_l2_tn_filter (const struct rte_flow_attr *attr, -const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], -struct rte_eth_l2_tunnel_conf *filter, -struct rte_flow_error *error)Why do u remove functions added in patch 14/18? If the functions don't be needed, how about changing patch 14/18?
This patch is generate in a very complicated way.
If you go on reading this patch, you will find the following statement, path add the functions back itself latter So the git seem to generate a patch in a peculiar way.
+static int
+cons_parse_l2_tn_filter(const struct rte_flow_attr *attr,
+ const struct rte_flow_item pattern[], + const struct rte_flow_action actions[], + struct rte_eth_l2_tunnel_conf *filter, + struct rte_flow_error *error)
Re: [PATCH v2 15/18] net/ixgbe: parse flow director filter
In reply to Wei ZhaoHi Wei,
Quoted 14 lines · Wei Zhao
check if the rule is a flow director rule, and get the flow director info.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:add new error set function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 1467 +++++++++++++++++++++++++++++++++----- drivers/net/ixgbe/ixgbe_ethdev.h | 16 + drivers/net/ixgbe/ixgbe_fdir.c | 247 ++++--- lib/librte_ether/rte_flow.h | 23 + 4 files changed, 1495 insertions(+), 258 deletions(-)
[...]
Quoted 26 lines
lib/librte_ether/rte_flow.h +11
-0@@ -275,6 +275,13 @@ enum rte_flow_item_type {* See struct rte_flow_item_e_tag. */ RTE_FLOW_ITEM_TYPE_E_TAG , + +/** +* Matches a NVGRE header. +* +* See struct rte_flow_item_nvgre. +*/ + RTE_FLOW_ITEM_TYPE_NVGRE, };/** @@ -486,6 +493,22 @@ struct rte_flow_item_e_tag { };/** +* RTE_FLOW_ITEM_TYPE_NVGRE. +* +* Matches a NVGRE header. +*/
lib/librte_ether/rte_flow.h struct rte_flow_item_e_tag { · line 509
Quoted 10 lines
lib/librte_ether/rte_flow.h +10
-0+struct rte_flow_item_nvgre { +uint32_t flags0:1 ;/**< 0 */ +uint32_t rsvd1:1 ;/**< 1 bit not defined */ +uint32_t flags1:2 ;/**< 2 bits, 1 0 */ +uint32_t rsvd0:9 ;/**< Reserved0 */ +uint32_t ver:3 ;/**< version */ +uint32_t protocol:16 ;/**< protocol type, 0x6558 */ +uint8_t tni[3 ];/**< tenant network ID or virtual subnet ID */ +uint8_t flow_id;/**< flow ID or Reserved */ +};
[...]
See my previous reply [1], this definition is not endian-safe due to the use of bit-fields and should look more like the VXLAN item. Here is an untested suggestion (not sure about all values):
struct rte_flow_item_nvgre {
/**
* Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
* reserved 0 (9b), version (3b).
*
* \c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
*/
uint16_t c_k_s_rsvd0_ver;
uint16_t proto; /**< Protocol type (0x6558). */
uint8_t vsid[3]; /**< Virtual subnet ID. */
uint8_t flow_id; /**< Flow ID. */ };
Like for E-Tag, applications are responsibile for breaking down and filling individual fields properly.
[1] http://dpdk.org/ml/archives/dev/2016-December/053181.html
Message ID: [email protected]
Signature · 2 lines
Adrien Mazarguil 6WIND
PATCH v2 16/18 net/ixgbe: create consistent filter
In reply to Wei ZhaoThis patch adds a function to create the flow directory filter.
---
v2:
--add new error set function
--- drivers/net/ixgbe/ixgbe_ethdev.c | 240 ++++++++++++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 5 + 2 files changed, 244 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +239 -1
@@ -468,6 +468,11 @@ ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev,const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct rte_flow_error *error); +static struct rte_flow *ixgbe_flow_create (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error);static int ixgbe_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error);/*
@@ -850,11 +855,55 @@ static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = { sizeof(rte_ixgbevf_stats_strings[0]))static const struct rte_flow_ops ixgbe_flow_ops = { ixgbe_flow_validate, -NULL , + ixgbe_flow_create,NULL , ixgbe_flow_flush,NULL , }; +/* ntuple filter list structure */ +struct ixgbe_ntuple_filter_ele { +TAILQ_ENTRY (ixgbe_ntuple_filter_ele) entries; +struct rte_eth_ntuple_filter filter_info; +}; +/* ethertype filter list structure */ +struct ixgbe_ethertype_filter_ele { +TAILQ_ENTRY (ixgbe_ethertype_filter_ele) entries; +struct rte_eth_ethertype_filter filter_info; +}; +/* syn filter list structure */ +struct ixgbe_eth_syn_filter_ele { +TAILQ_ENTRY (ixgbe_eth_syn_filter_ele) entries; +struct rte_eth_syn_filter filter_info; +}; +/* fdir filter list structure */ +struct ixgbe_fdir_rule_ele { +TAILQ_ENTRY (ixgbe_fdir_rule_ele) entries; +struct ixgbe_fdir_rule filter_info; +}; +/* l2_tunnel filter list structure */ +struct ixgbe_eth_l2_tunnel_conf_ele { +TAILQ_ENTRY (ixgbe_eth_l2_tunnel_conf_ele) entries; +struct rte_eth_l2_tunnel_conf filter_info; +}; +/* ixgbe_flow memory list structure */ +struct ixgbe_flow_mem { +TAILQ_ENTRY (ixgbe_flow_mem) entries; +struct ixgbe_flow *flow; +}; + +TAILQ_HEAD (ixgbe_ntuple_filter_list, ixgbe_ntuple_filter_ele); +struct ixgbe_ntuple_filter_list filter_ntuple_list; +TAILQ_HEAD (ixgbe_ethertype_filter_list, ixgbe_ethertype_filter_ele); +struct ixgbe_ethertype_filter_list filter_ethertype_list; +TAILQ_HEAD (ixgbe_syn_filter_list, ixgbe_eth_syn_filter_ele); +struct ixgbe_syn_filter_list filter_syn_list; +TAILQ_HEAD (ixgbe_fdir_rule_filter_list, ixgbe_fdir_rule_ele); +struct ixgbe_fdir_rule_filter_list filter_fdir_list; +TAILQ_HEAD (ixgbe_l2_tunnel_filter_list, ixgbe_eth_l2_tunnel_conf_ele); +struct ixgbe_l2_tunnel_filter_list filter_l2_tunnel_list; +TAILQ_HEAD (ixgbe_flow_mem_list, ixgbe_flow_mem); +struct ixgbe_flow_mem_list ixgbe_flow_list; +/** * Atomically reads the link status information from global * structure rte_eth_dev.
@@ -1380,6 +1429,14 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* initialize l2 tunnel filter list & hash */ ixgbe_l2_tn_filter_init (eth_dev); + +TAILQ_INIT (&filter_ntuple_list); +TAILQ_INIT (&filter_ethertype_list); +TAILQ_INIT (&filter_syn_list); +TAILQ_INIT (&filter_fdir_list); +TAILQ_INIT (&filter_l2_tunnel_list); +TAILQ_INIT (&ixgbe_flow_list); +return 0 ; }
@@ -10334,6 +10391,187 @@ ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev,return ret; } +/** +* Create or destroy a flow rule. +* Theorically one rule can match more than one filters. +* We will let it use the filter which it hitt first. +* So, the sequence matters. +*/ +static struct rte_flow * +ixgbe_flow_create (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error) +{ +int ret; +struct rte_eth_ntuple_filter ntuple_filter; +struct rte_eth_ethertype_filter ethertype_filter; +struct rte_eth_syn_filter syn_filter; +struct ixgbe_fdir_rule fdir_rule; +struct rte_eth_l2_tunnel_conf l2_tn_filter; +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data->dev_private); +struct ixgbe_flow *flow =NULL ; +struct ixgbe_ntuple_filter_ele *ntuple_filter_ptr; +struct ixgbe_ethertype_filter_ele *ethertype_filter_ptr; +struct ixgbe_eth_syn_filter_ele *syn_filter_ptr; +struct ixgbe_eth_l2_tunnel_conf_ele *l2_tn_filter_ptr; +struct ixgbe_fdir_rule_ele *fdir_rule_ptr; +struct ixgbe_flow_mem *ixgbe_flow_mem_ptr; + + flow =rte_zmalloc ("ixgbe_flow" ,sizeof (struct ixgbe_flow ),0 ); +if (!flow) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return (struct rte_flow *)flow; + } + ixgbe_flow_mem_ptr =rte_zmalloc ("ixgbe_flow_mem" , +sizeof (struct ixgbe_flow_mem ),0 ); +if (!ixgbe_flow_mem_ptr) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return NULL ; + } + ixgbe_flow_mem_ptr->flow = flow; +TAILQ_INSERT_TAIL (&ixgbe_flow_list, + ixgbe_flow_mem_ptr, entries); + +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); + ret =ixgbe_parse_ntuple_filter (attr, pattern, + actions, &ntuple_filter, error); +if (!ret) { + ret =ixgbe_add_del_ntuple_filter (dev, &ntuple_filter, TRUE); +if (!ret) { + ntuple_filter_ptr =rte_zmalloc ("ixgbe_ntuple_filter" , +sizeof (struct ixgbe_ntuple_filter_ele ),0 ); + (void )rte_memcpy (&ntuple_filter_ptr->filter_info, + &ntuple_filter, +sizeof (struct rte_eth_ntuple_filter )); +TAILQ_INSERT_TAIL (&filter_ntuple_list, + ntuple_filter_ptr, entries); + flow->rule = ntuple_filter_ptr; + flow->filter_type =RTE_ETH_FILTER_NTUPLE ; + } +return (struct rte_flow *)flow; + } + +memset (ðertype_filter,0 ,sizeof (struct rte_eth_ethertype_filter )); + ret =ixgbe_parse_ethertype_filter (attr, pattern, + actions, ðertype_filter, error); +if (!ret) { + ret =ixgbe_add_del_ethertype_filter (dev, + ðertype_filter, TRUE); +if (!ret) { + ethertype_filter_ptr =rte_zmalloc ( +"ixgbe_ethertype_filter" , +sizeof (struct ixgbe_ethertype_filter_ele ),0 ); + (void )rte_memcpy (ðertype_filter_ptr->filter_info, + ðertype_filter, +sizeof (struct rte_eth_ethertype_filter )); +TAILQ_INSERT_TAIL (&filter_ethertype_list, + ethertype_filter_ptr, entries); + flow->rule = ethertype_filter_ptr; + flow->filter_type =RTE_ETH_FILTER_ETHERTYPE ; + } +return (struct rte_flow *)flow; + } + +memset (&syn_filter,0 ,sizeof (struct rte_eth_syn_filter )); + ret =cons_parse_syn_filter (attr, pattern, actions, &syn_filter, error); +if (!ret) { + ret =ixgbe_syn_filter_set (dev, &syn_filter, TRUE); +if (!ret) { + syn_filter_ptr =rte_zmalloc ("ixgbe_syn_filter" , +sizeof (struct ixgbe_eth_syn_filter_ele ),0 ); + (void )rte_memcpy (&syn_filter_ptr->filter_info, + &syn_filter, +sizeof (struct rte_eth_syn_filter )); +TAILQ_INSERT_TAIL (&filter_syn_list, + syn_filter_ptr, + entries); + flow->rule = syn_filter_ptr; + flow->filter_type =RTE_ETH_FILTER_SYN ; + } +return (struct rte_flow *)flow; + } + +memset (&fdir_rule,0 ,sizeof (struct ixgbe_fdir_rule )); + ret =ixgbe_parse_fdir_filter (attr, pattern, + actions, &fdir_rule, error); +if (!ret) { +/* A mask cannot be deleted. */ +if (fdir_rule.b_mask) { +if (!fdir_info->mask_added) { +/* It's the first time the mask is set. */ +rte_memcpy (&fdir_info->mask, + &fdir_rule.mask, +sizeof (struct ixgbe_hw_fdir_mask )); + ret =ixgbe_fdir_set_input_mask (dev); +if (ret) +return NULL ; + + fdir_info->mask_added = TRUE; + }else { +/** +* Only support one global mask, +* all the masks should be the same. +*/ + ret =memcmp (&fdir_info->mask, + &fdir_rule.mask, +sizeof (struct ixgbe_hw_fdir_mask )); +if (ret) +return NULL ; + } + } + +if (fdir_rule.b_spec) { + ret =ixgbe_fdir_filter_program (dev, &fdir_rule, + FALSE, FALSE); +if (!ret) { + fdir_rule_ptr =rte_zmalloc ("ixgbe_fdir_filter" , +sizeof (struct ixgbe_fdir_rule_ele ),0 ); + (void )rte_memcpy (&fdir_rule_ptr->filter_info, + &fdir_rule, +sizeof (struct ixgbe_fdir_rule )); +TAILQ_INSERT_TAIL (&filter_fdir_list, + fdir_rule_ptr, entries); + flow->rule = fdir_rule_ptr; + flow->filter_type =RTE_ETH_FILTER_FDIR ; + +return (struct rte_flow *)flow; + } + +if (ret) +return NULL ; + } + +return NULL ; + } + +memset (&l2_tn_filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); + ret =cons_parse_l2_tn_filter (attr, pattern, + actions, &l2_tn_filter, error); +if (!ret) { + ret =ixgbe_dev_l2_tunnel_filter_add (dev, &l2_tn_filter, FALSE); +if (!ret) { + l2_tn_filter_ptr =rte_zmalloc ("ixgbe_l2_tn_filter" , +sizeof (struct ixgbe_eth_l2_tunnel_conf_ele ),0 ); + (void )rte_memcpy (&l2_tn_filter_ptr->filter_info, + &l2_tn_filter, +sizeof (struct rte_eth_l2_tunnel_conf )); +TAILQ_INSERT_TAIL (&filter_l2_tunnel_list, + l2_tn_filter_ptr, entries); + flow->rule = l2_tn_filter_ptr; + flow->filter_type =RTE_ETH_FILTER_L2_TUNNEL ; + +return (struct rte_flow *)flow; + } + } + +rte_free (ixgbe_flow_mem_ptr); +rte_free (flow); +return NULL ; +} +RTE_PMD_REGISTER_PCI (net_ixgbe, rte_ixgbe_pmd.pci_drv);RTE_PMD_REGISTER_PCI_TABLE (net_ixgbe, pci_id_ixgbe_map);RTE_PMD_REGISTER_KMOD_DEP (net_ixgbe,"* igb_uio | uio_pci_generic | vfio" );
drivers/net/ixgbe/ixgbe_ethdev.h +5 -0
@@ -329,6 +329,11 @@ struct ixgbe_l2_tn_info {bool e_tag_ether_type;/* ether type for e-tag */ }; +struct ixgbe_flow { +enum rte_filter_type filter_type; +void *rule; +}; +/* * Structure to store private data for each driver instance (for each port). */
Signature · 1 line
2.5.5
Re: [PATCH v2 16/18] net/ixgbe: create consistent filter
Quoted 66 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Zhao1, Wei <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: [dpdk-dev] [PATCH v2 16/18] net/ixgbe: create consistent filterThis patch adds a function to create the flow directory filter.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:
--add new error set function--- drivers/net/ixgbe/ixgbe_ethdev.c | 240 ++++++++++++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 5 + 2 files changed, 244 insertions(+), 1 deletion(-)drivers/net/ixgbe/ixgbe_ethdev.c +5
-0@@ -468,6 +468,11 @@ ixgbe_flow_validate(__rte_unused structrte_eth_dev *dev, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct rte_flow_error *error); +static struct rte_flow *ixgbe_flow_create (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error);static int ixgbe_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error);/*
drivers/net/ixgbe/ixgbe_ethdev.c +13
-1@@ -850,11 +855,55 @@ static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = { sizeof(rte_ixgbevf_stats_strings[0]))static const struct rte_flow_ops ixgbe_flow_ops = { ixgbe_flow_validate, -NULL , + ixgbe_flow_create,NULL , ixgbe_flow_flush,NULL , }; +/* ntuple filter list structure */ +struct ixgbe_ntuple_filter_ele { +TAILQ_ENTRY (ixgbe_ntuple_filter_ele) entries; +struct rte_eth_ntuple_filter filter_info; }; +/* ethertype filter list structure */ +struct ixgbe_ethertype_filter_ele { +TAILQ_ENTRY (ixgbe_ethertype_filter_ele) entries; +struct rte_eth_ethertype_filter filter_info; }; +/* syn filter list structure */ +struct ixgbe_eth_syn_filter_ele { +TAILQ_ENTRY (ixgbe_eth_syn_filter_ele) entries; +struct rte_eth_syn_filter filter_info; };
drivers/net/ixgbe/ixgbe_ethdev.c static const struct rte_ixgbe_xstats_name_off · line 885
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+/* fdir filter list structure */ +struct ixgbe_fdir_rule_ele { +TAILQ_ENTRY (ixgbe_fdir_rule_ele) entries; +struct ixgbe_fdir_rule filter_info; +}; +/* l2_tunnel filter list structure */ +struct ixgbe_eth_l2_tunnel_conf_ele { +TAILQ_ENTRY (ixgbe_eth_l2_tunnel_conf_ele) entries; +struct rte_eth_l2_tunnel_conf filter_info; }; +/* ixgbe_flow memory list structure */
Why need to define these structures? There has been structures to store the filter before, isn't it?
Quoted 36 lines
drivers/net/ixgbe/ixgbe_ethdev.c +26
-0+struct ixgbe_flow_mem { +TAILQ_ENTRY (ixgbe_flow_mem) entries; +struct ixgbe_flow *flow; +}; + +TAILQ_HEAD (ixgbe_ntuple_filter_list, ixgbe_ntuple_filter_ele);struct +ixgbe_ntuple_filter_list filter_ntuple_list; +TAILQ_HEAD (ixgbe_ethertype_filter_list, ixgbe_ethertype_filter_ele); +struct ixgbe_ethertype_filter_list filter_ethertype_list; +TAILQ_HEAD (ixgbe_syn_filter_list, ixgbe_eth_syn_filter_ele);struct +ixgbe_syn_filter_list filter_syn_list; +TAILQ_HEAD (ixgbe_fdir_rule_filter_list, ixgbe_fdir_rule_ele);struct +ixgbe_fdir_rule_filter_list filter_fdir_list; +TAILQ_HEAD (ixgbe_l2_tunnel_filter_list, ixgbe_eth_l2_tunnel_conf_ele); +struct ixgbe_l2_tunnel_filter_list filter_l2_tunnel_list; +TAILQ_HEAD (ixgbe_flow_mem_list, ixgbe_flow_mem);struct +ixgbe_flow_mem_list ixgbe_flow_list; +/** * Atomically reads the link status information from global * structure rte_eth_dev. @@ -1380,6 +1429,14 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* initialize l2 tunnel filter list & hash */ ixgbe_l2_tn_filter_init (eth_dev); + +TAILQ_INIT (&filter_ntuple_list); +TAILQ_INIT (&filter_ethertype_list); +TAILQ_INIT (&filter_syn_list); +TAILQ_INIT (&filter_fdir_list); +TAILQ_INIT (&filter_l2_tunnel_list); +TAILQ_INIT (&ixgbe_flow_list); +return 0 ; }
Re: [PATCH v2 16/18] net/ixgbe: create consistent filter
Hi,beilei
Quoted 80 lines
-----Original Message-----
From: Xing, Beilei
Sent: Tuesday, January 3, 2017 10:04 AM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Zhao1, Wei <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 16/18] net/ixgbe: create consistent filterQuoted 70 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Zhao1, Wei <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: [dpdk-dev] [PATCH v2 16/18] net/ixgbe: create consistent filterThis patch adds a function to create the flow directory filter.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:
--add new error set function--- drivers/net/ixgbe/ixgbe_ethdev.c | 240 ++++++++++++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 5 + 2 files changed, 244 insertions(+), 1 deletion(-)drivers/net/ixgbe/ixgbe_ethdev.c +5
-0@@ -468,6 +468,11 @@ ixgbe_flow_validate(__rte_unused structrte_eth_dev *dev, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct rte_flow_error *error); +static struct rte_flow *ixgbe_flow_create (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error);static int ixgbe_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error);/*
drivers/net/ixgbe/ixgbe_ethdev.c +18
-1@@ -850,11 +855,55 @@ static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = { sizeof(rte_ixgbevf_stats_strings[0]))static const struct rte_flow_ops ixgbe_flow_ops = { ixgbe_flow_validate, -NULL , + ixgbe_flow_create,NULL , ixgbe_flow_flush,NULL , }; +/* ntuple filter list structure */ +struct ixgbe_ntuple_filter_ele { +TAILQ_ENTRY (ixgbe_ntuple_filter_ele) entries; +struct rte_eth_ntuple_filter filter_info; }; +/* ethertype filter list structure */ struct +ixgbe_ethertype_filter_ele { +TAILQ_ENTRY (ixgbe_ethertype_filter_ele) entries; +struct rte_eth_ethertype_filter filter_info; }; +/* syn filter list structure */ +struct ixgbe_eth_syn_filter_ele { +TAILQ_ENTRY (ixgbe_eth_syn_filter_ele) entries; +struct rte_eth_syn_filter filter_info; }; +/* fdir filter list structure */ +struct ixgbe_fdir_rule_ele { +TAILQ_ENTRY (ixgbe_fdir_rule_ele) entries; +struct ixgbe_fdir_rule filter_info; +};
Quoted 9 lines
drivers/net/ixgbe/ixgbe_ethdev.c static const struct rte_ixgbe_xstats_name_off · line 885
Quoted 5 lines
drivers/net/ixgbe/ixgbe_ethdev.c +5
-0+/* l2_tunnel filter list structure */ struct +ixgbe_eth_l2_tunnel_conf_ele { +TAILQ_ENTRY (ixgbe_eth_l2_tunnel_conf_ele) entries; +struct rte_eth_l2_tunnel_conf filter_info; }; +/* ixgbe_flow memory list structure */ Why need to define these structures? There has been structures to store the filter before, isn't it?
These list are created to store flow parameters, which is required by rte layer.
Quoted 37 lines
drivers/net/ixgbe/ixgbe_ethdev.c eth_ixgbe_dev_init(struct rte_eth_dev
Quoted 22 lines
drivers/net/ixgbe/ixgbe_ethdev.c +18
-0+struct ixgbe_flow_mem { +TAILQ_ENTRY (ixgbe_flow_mem) entries; +struct ixgbe_flow *flow; +}; + +TAILQ_HEAD (ixgbe_ntuple_filter_list, ixgbe_ntuple_filter_ele);struct +ixgbe_ntuple_filter_list filter_ntuple_list; +TAILQ_HEAD (ixgbe_ethertype_filter_list, ixgbe_ethertype_filter_ele); +struct ixgbe_ethertype_filter_list filter_ethertype_list; +TAILQ_HEAD (ixgbe_syn_filter_list, ixgbe_eth_syn_filter_ele);struct +ixgbe_syn_filter_list filter_syn_list; +TAILQ_HEAD (ixgbe_fdir_rule_filter_list, ixgbe_fdir_rule_ele);struct +ixgbe_fdir_rule_filter_list filter_fdir_list; +TAILQ_HEAD (ixgbe_l2_tunnel_filter_list, +ixgbe_eth_l2_tunnel_conf_ele);struct ixgbe_l2_tunnel_filter_list +filter_l2_tunnel_list;TAILQ_HEAD (ixgbe_flow_mem_list, +ixgbe_flow_mem);struct ixgbe_flow_mem_list ixgbe_flow_list; +/** * Atomically reads the link status information from global * structure rte_eth_dev. @@ -1380,6 +1429,14 @@ eth_ixgbe_dev_init(struct rte_eth_dev
*eth_dev)Quoted 14 lines
drivers/net/ixgbe/ixgbe_ethdev.c +8
-0/* initialize l2 tunnel filter list & hash */ ixgbe_l2_tn_filter_init (eth_dev); + +TAILQ_INIT (&filter_ntuple_list); +TAILQ_INIT (&filter_ethertype_list); +TAILQ_INIT (&filter_syn_list); +TAILQ_INIT (&filter_fdir_list); +TAILQ_INIT (&filter_l2_tunnel_list); +TAILQ_INIT (&ixgbe_flow_list); +return 0 ; }
A message that is not in the archive (sent off-list or not yet received): 94479800C636CB44BD422CB454846E013158D036@SHSMSX101.ccr.corp.intel.com
Re: [PATCH v2 16/18] net/ixgbe: create consistent filter
Hi ,beilei
Quoted 33 lines
-----Original Message-----
From: Xing, Beilei
Sent: Tuesday, January 3, 2017 10:34 AM
To: Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 16/18] net/ixgbe: create consistent filterReview eth_ixgbe_dev_init(struct rte_eth_dev
Quoted 25 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Zhao1, Wei <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: [dpdk-dev] [PATCH v2 16/18] net/ixgbe: create consistent filterThis patch adds a function to create the flow directory filter.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:
--add new error set function--- drivers/net/ixgbe/ixgbe_ethdev.c | 240 ++++++++++++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 5 + 2 files changed, 244 insertions(+), 1 deletion(-)(quoted diff) +0
-0@@ -1380,6 +1429,14 @@ eth_ixgbe_dev_init(struct rte_eth_dev
*eth_dev)Quoted 1 line
Quoted 16 lines
drivers/net/ixgbe/ixgbe_ethdev.c eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev) · line 1438
Quoted 9 lines
drivers/net/ixgbe/ixgbe_ethdev.c +7
-0/* initialize l2 tunnel filter list & hash */ ixgbe_l2_tn_filter_init (eth_dev); + +TAILQ_INIT (&filter_ntuple_list); +TAILQ_INIT (&filter_ethertype_list); +TAILQ_INIT (&filter_syn_list); +TAILQ_INIT (&filter_fdir_list); +TAILQ_INIT (&filter_l2_tunnel_list); +TAILQ_INIT (&ixgbe_flow_list);You need to destroy these lists in
dev_unintfunction.Quoted 4 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1
-0+return 0 ; }
Yes, I have add a function ixgbe_filterlist_flush() in 18/18 in dev_unint patch to flush these list.
Re: [PATCH v2 16/18] net/ixgbe: create consistent filter
In reply to Wei ZhaoQuoted 70 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Friday, December 30, 2016 3:53 PM
To: [email protected]
Cc: Zhao1, Wei <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: [dpdk-dev] [PATCH v2 16/18] net/ixgbe: create consistent filterThis patch adds a function to create the flow directory filter.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
drivers/net/ixgbe/ixgbe_ethdev.c +21
-0+/** +* Create or destroy a flow rule. +* Theorically one rule can match more than one filters. +* We will let it use the filter which it hitt first. +* So, the sequence matters. +*/ +static struct rte_flow * +ixgbe_flow_create (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error) +{ +int ret; +struct rte_eth_ntuple_filter ntuple_filter; +struct rte_eth_ethertype_filter ethertype_filter; +struct rte_eth_syn_filter syn_filter; +struct ixgbe_fdir_rule fdir_rule; +struct rte_eth_l2_tunnel_conf l2_tn_filter; +struct ixgbe_hw_fdir_info *fdir_info = + IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data-Quoted 1 line
dev_private);drivers/net/ixgbe/ixgbe_ethdev.c +30
-0+struct ixgbe_flow *flow =NULL ; +struct ixgbe_ntuple_filter_ele *ntuple_filter_ptr; +struct ixgbe_ethertype_filter_ele *ethertype_filter_ptr; +struct ixgbe_eth_syn_filter_ele *syn_filter_ptr; +struct ixgbe_eth_l2_tunnel_conf_ele *l2_tn_filter_ptr; +struct ixgbe_fdir_rule_ele *fdir_rule_ptr; +struct ixgbe_flow_mem *ixgbe_flow_mem_ptr; + + flow =rte_zmalloc ("ixgbe_flow" ,sizeof (struct ixgbe_flow ),0 ); +if (!flow) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return (struct rte_flow *)flow; + } + ixgbe_flow_mem_ptr =rte_zmalloc ("ixgbe_flow_mem" , +sizeof (struct ixgbe_flow_mem ),0 ); +if (!ixgbe_flow_mem_ptr) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return NULL ; + } + ixgbe_flow_mem_ptr->flow = flow; +TAILQ_INSERT_TAIL (&ixgbe_flow_list, + ixgbe_flow_mem_ptr, entries); + +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); + ret =ixgbe_parse_ntuple_filter (attr, pattern, + actions, &ntuple_filter, error); +if (!ret) { + ret =ixgbe_add_del_ntuple_filter (dev, &ntuple_filter, TRUE); +if (!ret) { + ntuple_filter_ptr = rte_zmalloc("ixgbe_ntuple_filter",
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, · line 10454
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+ sizeof(struct ixgbe_ntuple_filter_ele), 0); + (void )rte_memcpy (&ntuple_filter_ptr->filter_info, + &ntuple_filter, +sizeof (struct rte_eth_ntuple_filter )); +TAILQ_INSERT_TAIL (&filter_ntuple_list, + ntuple_filter_ptr, entries); + flow->rule = ntuple_filter_ptr; + flow->filter_type =RTE_ETH_FILTER_NTUPLE ; + } +return (struct rte_flow *)flow;
Should the return statement be in the parantheses above? And is there any process if (ret<0) ?
Quoted 15 lines
drivers/net/ixgbe/ixgbe_ethdev.c +3
-0+ } + + memset(ðertype_filter, 0, sizeof(struct
rte_eth_ethertype_filter));drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+ ret =ixgbe_parse_ethertype_filter (attr, pattern, + actions, ðertype_filter, error); +if (!ret) { + ret =ixgbe_add_del_ethertype_filter (dev, + ðertype_filter, TRUE); +if (!ret) { + ethertype_filter_ptr =rte_zmalloc ( +"ixgbe_ethertype_filter" , +sizeof (struct ixgbe_ethertype_filter_ele ),0 ); + (void)rte_memcpy(ðertype_filter_ptr-Quoted 1 line
filter_info,
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, · line 10475
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c +8
-0+ ðertype_filter, + sizeof(struct rte_eth_ethertype_filter)); +TAILQ_INSERT_TAIL (&filter_ethertype_list, + ethertype_filter_ptr, entries); + flow->rule = ethertype_filter_ptr; + flow->filter_type =RTE_ETH_FILTER_ETHERTYPE ; + } +return (struct rte_flow *)flow;
Same above.
Quoted 9 lines
drivers/net/ixgbe/ixgbe_ethdev.c +9
-0+ } + +memset (&syn_filter,0 ,sizeof (struct rte_eth_syn_filter )); + ret =cons_parse_syn_filter (attr, pattern, actions, &syn_filter, error); +if (!ret) { + ret =ixgbe_syn_filter_set (dev, &syn_filter, TRUE); +if (!ret) { + syn_filter_ptr =rte_zmalloc ("ixgbe_syn_filter" , +sizeof (struct ixgbe_eth_syn_filter_ele ),0 );
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, · line 10494
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+ (void )rte_memcpy (&syn_filter_ptr->filter_info, + &syn_filter, +sizeof (struct rte_eth_syn_filter )); +TAILQ_INSERT_TAIL (&filter_syn_list, + syn_filter_ptr, + entries); + flow->rule = syn_filter_ptr; + flow->filter_type =RTE_ETH_FILTER_SYN ; + } +return (struct rte_flow *)flow;
Same above.
Quoted 6 lines
drivers/net/ixgbe/ixgbe_ethdev.c +6
-0+ } + +memset (&fdir_rule,0 ,sizeof (struct ixgbe_fdir_rule )); + ret =ixgbe_parse_fdir_filter (attr, pattern, + actions, &fdir_rule, error); +if (!ret) {
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, · line 10510
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+/* A mask cannot be deleted. */ +if (fdir_rule.b_mask) { +if (!fdir_info->mask_added) { +/* It's the first time the mask is set. */ +rte_memcpy (&fdir_info->mask, + &fdir_rule.mask, +sizeof (struct ixgbe_hw_fdir_mask )); + ret =ixgbe_fdir_set_input_mask (dev); +if (ret) +return NULL ;
Before return NULL, ixgbe_flow_mem_ptr and flow should be freed, right?
And ixgbe_flow_mem_ptr should be removed from ixgbe_flow_list. Or you can move TAILQ_INSERT_TAIL(&ixgbe_flow_list, ixgbe_flow_mem_ptr, entries) after a flow is added successfully. Same comments for "return NULL" below.
Quoted 29 lines
drivers/net/ixgbe/ixgbe_ethdev.c +20
-0+ + fdir_info->mask_added = TRUE; + }else { +/** +* Only support one global mask, +* all the masks should be the same. +*/ + ret =memcmp (&fdir_info->mask, + &fdir_rule.mask, +sizeof (struct ixgbe_hw_fdir_mask )); +if (ret) +return NULL ; + } + } + +if (fdir_rule.b_spec) { + ret =ixgbe_fdir_filter_program (dev, &fdir_rule, + FALSE, FALSE); +if (!ret) { + fdir_rule_ptr =rte_zmalloc("ixgbe_fdir_filter",
(quoted diff) +2
-0+ sizeof(struct ixgbe_fdir_rule_ele), 0); + (void)rte_memcpy(&fdir_rule_ptr-Quoted 1 line
filter_info,drivers/net/ixgbe/ixgbe_ethdev.c +5
-0+ &fdir_rule, + sizeof(struct ixgbe_fdir_rule)); +TAILQ_INSERT_TAIL (&filter_fdir_list, + fdir_rule_ptr, entries); + flow->rule = fdir_rule_ptr;
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, · line 10547
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+ flow->filter_type =RTE_ETH_FILTER_FDIR ; + +return (struct rte_flow *)flow; + } + +if (ret) +return NULL ; + } + +return NULL ;
Why to return NULL here?
Quoted 12 lines
drivers/net/ixgbe/ixgbe_ethdev.c +7
-0+ } + +memset (&l2_tn_filter,0 ,sizeof (struct rte_eth_l2_tunnel_conf )); + ret =cons_parse_l2_tn_filter (attr, pattern, + actions, &l2_tn_filter, error); +if (!ret) { + ret = ixgbe_dev_l2_tunnel_filter_add(dev, &l2_tn_filter,FALSE);
drivers/net/ixgbe/ixgbe_ethdev.c +3
-0+if (!ret) { + l2_tn_filter_ptr = rte_zmalloc("ixgbe_l2_tn_filter", + sizeof(struct ixgbe_eth_l2_tunnel_conf_ele),0);
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, · line 10567
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +10
-0+ (void )rte_memcpy (&l2_tn_filter_ptr->filter_info, + &l2_tn_filter, +sizeof (struct rte_eth_l2_tunnel_conf )); +TAILQ_INSERT_TAIL (&filter_l2_tunnel_list, + l2_tn_filter_ptr, entries); + flow->rule = l2_tn_filter_ptr; + flow->filter_type =RTE_ETH_FILTER_L2_TUNNEL ; + +return (struct rte_flow *)flow; + }
is there any process if (ret<0) ?
Quoted 7 lines
drivers/net/ixgbe/ixgbe_ethdev.c +7
-0+ } + +rte_free (ixgbe_flow_mem_ptr); +rte_free (flow); +return NULL ; +} +
Re: [PATCH v2 16/18] net/ixgbe: create consistent filter
In reply to Wei ZhaoQuoted 10 lines · Wei Zhao
This patch adds a function to create the flow directory filter.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:
--add new error set function
---
<...>
drivers/net/ixgbe/ixgbe_ethdev.h struct ixgbe_l2_tn_info { · line 335
Quoted 5 lines
drivers/net/ixgbe/ixgbe_ethdev.h +4
-0+struct ixgbe_flow { +enum rte_filter_type filter_type; +void *rule; +};
It is possible to rename this struct to rte_flow, to prevent casting. Although functionally there is no difference.
Quoted 5 lines
+
/*
* Structure to store private data for each driver instance (for each port). */
Re: [PATCH v2 16/18] net/ixgbe: create consistent filter
Quoted 24 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, January 7, 2017 1:27 AM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 16/18] net/ixgbe: create consistent filterQuoted 10 lines · Wei Zhao
This patch adds a function to create the flow directory filter.
Signed-off-by Wei Zhao <[email protected]>Signed-off-by Wenzhuo Lu <[email protected]>---
v2:
--add new error set function
---<...>
Quoted 1 line
Quoted 7 lines
drivers/net/ixgbe/ixgbe_ethdev.h struct ixgbe_l2_tn_info { · line 335
Quoted 4 lines
drivers/net/ixgbe/ixgbe_ethdev.h +4
-0+struct ixgbe_flow { +enum rte_filter_type filter_type; +void *rule; +};It is possible to rename this struct to
rte_flow, to prevent casting. Although functionally there is no difference.
Ok, I will do that in v3
Quoted 6 lines
Quoted 6 lines
+
/*
* Structure to store private data for each driver instance (for each port). */
PATCH v2 17/18 net/ixgbe: destroy consistent filter
In reply to Wei ZhaoThis patch adds a function to destroy the flow fliter.
---
v2:
--fix git log error
--- drivers/net/ixgbe/ixgbe_ethdev.c | 117 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +116 -1
@@ -473,6 +473,9 @@ static struct rte_flow *ixgbe_flow_create(struct rte_eth_dev *dev,const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct rte_flow_error *error); +static int ixgbe_flow_destroy (struct rte_eth_dev *dev, +struct rte_flow *flow, +struct rte_flow_error *error);static int ixgbe_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error);/*
@@ -856,7 +859,7 @@ static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {static const struct rte_flow_ops ixgbe_flow_ops = { ixgbe_flow_validate, ixgbe_flow_create, -NULL , + ixgbe_flow_destroy, ixgbe_flow_flush,NULL , };
@@ -10572,6 +10575,118 @@ ixgbe_flow_create(struct rte_eth_dev *dev,return NULL ; } +/* Destroy a flow rule on ixgbe. */ +static int +ixgbe_flow_destroy (struct rte_eth_dev *dev, +struct rte_flow *flow, +struct rte_flow_error *error) +{ +int ret; +struct ixgbe_flow *pmd_flow = (struct ixgbe_flow *)flow; +enum rte_filter_type filter_type = pmd_flow->filter_type; +struct rte_eth_ntuple_filter ntuple_filter; +struct rte_eth_ethertype_filter ethertype_filter; +struct rte_eth_syn_filter syn_filter; +struct ixgbe_fdir_rule fdir_rule; +struct rte_eth_l2_tunnel_conf l2_tn_filter; +struct ixgbe_ntuple_filter_ele *ntuple_filter_ptr; +struct ixgbe_ethertype_filter_ele *ethertype_filter_ptr; +struct ixgbe_eth_syn_filter_ele *syn_filter_ptr; +struct ixgbe_eth_l2_tunnel_conf_ele *l2_tn_filter_ptr; +struct ixgbe_fdir_rule_ele *fdir_rule_ptr; +struct ixgbe_flow_mem *ixgbe_flow_mem_ptr; + +switch (filter_type) { +case RTE_ETH_FILTER_NTUPLE : + ntuple_filter_ptr = (struct ixgbe_ntuple_filter_ele *) + pmd_flow->rule; + (void )rte_memcpy (&ntuple_filter, + &ntuple_filter_ptr->filter_info, +sizeof (struct rte_eth_ntuple_filter )); + ret =ixgbe_add_del_ntuple_filter (dev, &ntuple_filter, FALSE); +if (!ret) { +TAILQ_REMOVE (&filter_ntuple_list, + ntuple_filter_ptr, entries); +rte_free (ntuple_filter_ptr); + } +break ; +case RTE_ETH_FILTER_ETHERTYPE : + ethertype_filter_ptr = (struct ixgbe_ethertype_filter_ele *) + pmd_flow->rule; + (void )rte_memcpy (ðertype_filter, + ðertype_filter_ptr->filter_info, +sizeof (struct rte_eth_ethertype_filter )); + ret =ixgbe_add_del_ethertype_filter (dev, + ðertype_filter, FALSE); +if (!ret) { +TAILQ_REMOVE (&filter_ethertype_list, + ethertype_filter_ptr, entries); +rte_free (ethertype_filter_ptr); + } +break ; +case RTE_ETH_FILTER_SYN : + syn_filter_ptr = (struct ixgbe_eth_syn_filter_ele *) + pmd_flow->rule; + (void )rte_memcpy (&syn_filter, + &syn_filter_ptr->filter_info, +sizeof (struct rte_eth_syn_filter )); + ret =ixgbe_syn_filter_set (dev, &syn_filter, FALSE); +if (!ret) { +TAILQ_REMOVE (&filter_syn_list, + syn_filter_ptr, entries); +rte_free (syn_filter_ptr); + } +break ; +case RTE_ETH_FILTER_FDIR : + fdir_rule_ptr = (struct ixgbe_fdir_rule_ele *)pmd_flow->rule; + (void )rte_memcpy (&fdir_rule, + &fdir_rule_ptr->filter_info, +sizeof (struct ixgbe_fdir_rule )); + ret =ixgbe_fdir_filter_program (dev, &fdir_rule, TRUE, FALSE); +if (!ret) { +TAILQ_REMOVE (&filter_fdir_list, + fdir_rule_ptr, entries); +rte_free (fdir_rule_ptr); + } +break ; +case RTE_ETH_FILTER_L2_TUNNEL : + l2_tn_filter_ptr = (struct ixgbe_eth_l2_tunnel_conf_ele *) + pmd_flow->rule; + (void )rte_memcpy (&l2_tn_filter, &l2_tn_filter_ptr->filter_info, +sizeof (struct rte_eth_l2_tunnel_conf )); + ret =ixgbe_dev_l2_tunnel_filter_del (dev, &l2_tn_filter); +if (!ret) { +TAILQ_REMOVE (&filter_l2_tunnel_list, + l2_tn_filter_ptr, entries); +rte_free (l2_tn_filter_ptr); + } +break ; +default : +PMD_DRV_LOG (WARNING ,"Filter type (%d) not supported" , + filter_type); + ret = -EINVAL ; +break ; + } + +if (ret) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_HANDLE , +NULL ,"Failed to destroy flow" ); +return ret; + } + + TAILQ_FOREACH(ixgbe_flow_mem_ptr, &ixgbe_flow_list, entries) { +if (ixgbe_flow_mem_ptr->flow == pmd_flow) { +TAILQ_REMOVE (&ixgbe_flow_list, + ixgbe_flow_mem_ptr, entries); +rte_free (ixgbe_flow_mem_ptr); + } + } +rte_free (flow); + +return ret; +} +RTE_PMD_REGISTER_PCI (net_ixgbe, rte_ixgbe_pmd.pci_drv);RTE_PMD_REGISTER_PCI_TABLE (net_ixgbe, pci_id_ixgbe_map);RTE_PMD_REGISTER_KMOD_DEP (net_ixgbe,"* igb_uio | uio_pci_generic | vfio" );
Signature · 1 line
2.5.5
PATCH v2 18/18 net/ixgbe: flush all the filter list
In reply to Wei ZhaoThis patch adds a function to flush all the fliter list filter on a port.
---
--- drivers/net/ixgbe/ixgbe_ethdev.c | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +59 -0
@@ -478,6 +478,7 @@ static int ixgbe_flow_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error);static int ixgbe_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error); +static void ixgbe_filterlist_flush (void );/* * Define VF Stats MACRO for Non "cleared on read" register */
@@ -1526,6 +1527,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)rte_free (l2_tn_filter); } +/* clear all the filters list */ +ixgbe_filterlist_flush (); +return 0 ; }
@@ -10318,6 +10322,8 @@ ixgbe_flow_flush(struct rte_eth_dev *dev,return ret; } +ixgbe_filterlist_flush (); +return 0 ; }
@@ -10394,6 +10400,59 @@ ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev,return ret; } +static void ixgbe_filterlist_flush (void ) +{ +struct ixgbe_ntuple_filter_ele *ntuple_filter_ptr; +struct ixgbe_ethertype_filter_ele *ethertype_filter_ptr; +struct ixgbe_eth_syn_filter_ele *syn_filter_ptr; +struct ixgbe_eth_l2_tunnel_conf_ele *l2_tn_filter_ptr; +struct ixgbe_fdir_rule_ele *fdir_rule_ptr; +struct ixgbe_flow_mem *ixgbe_flow_mem_ptr; + +while ((ntuple_filter_ptr =TAILQ_FIRST (&filter_ntuple_list))) { +TAILQ_REMOVE (&filter_ntuple_list, + ntuple_filter_ptr, + entries); +rte_free (ntuple_filter_ptr); + } + +while ((ethertype_filter_ptr =TAILQ_FIRST (&filter_ethertype_list))) { +TAILQ_REMOVE (&filter_ethertype_list, + ethertype_filter_ptr, + entries); +rte_free (ethertype_filter_ptr); + } + +while ((syn_filter_ptr =TAILQ_FIRST (&filter_syn_list))) { +TAILQ_REMOVE (&filter_syn_list, + syn_filter_ptr, + entries); +rte_free (syn_filter_ptr); + } + +while ((l2_tn_filter_ptr =TAILQ_FIRST (&filter_l2_tunnel_list))) { +TAILQ_REMOVE (&filter_l2_tunnel_list, + l2_tn_filter_ptr, + entries); +rte_free (l2_tn_filter_ptr); + } + +while ((fdir_rule_ptr =TAILQ_FIRST (&filter_fdir_list))) { +TAILQ_REMOVE (&filter_fdir_list, + fdir_rule_ptr, + entries); +rte_free (fdir_rule_ptr); + } + +while ((ixgbe_flow_mem_ptr =TAILQ_FIRST (&ixgbe_flow_list))) { +TAILQ_REMOVE (&ixgbe_flow_list, + ixgbe_flow_mem_ptr, + entries); +rte_free (ixgbe_flow_mem_ptr->flow); +rte_free (ixgbe_flow_mem_ptr); + } +} +/** * Create or destroy a flow rule. * Theorically one rule can match more than one filters.
Signature · 1 line
2.5.5