net/ixgbe: Consistent filter API
v2 cover net/ixgbe: Consistent filter API
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.
v2 changes:
fix git log error.
Modify some function call relationship.
Change return value type of all parse flow functions. Update error info for all flow ops.
Add ixgbe_filterlist_flush to flush flows and rules created.
zhao wei (18):
net/ixgbe: store 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
drivers/net/ixgbe/ixgbe_ethdev.c | 3285 ++++++++++++++++++++++++++++++++++++-- drivers/net/ixgbe/ixgbe_ethdev.h | 136 +- drivers/net/ixgbe/ixgbe_fdir.c | 403 ++++- drivers/net/ixgbe/ixgbe_pf.c | 26 +- lib/librte_ether/rte_flow.h | 55 + 5 files changed, 3713 insertions(+), 192 deletions(-)
Signature · 1 line
2.5.5
PATCH v2 1/18 net/ixgbe: store SYN filter
Add support for storing SYN filter in SW.
---
v2:
--synqf assignment location change
--- drivers/net/ixgbe/ixgbe_ethdev.c | 14 +++++++++++--- drivers/net/ixgbe/ixgbe_ethdev.h | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +11 -3
@@ -1274,6 +1274,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)memset (filter_info->fivetuple_mask,0 ,sizeof (uint32_t ) *IXGBE_5TUPLE_ARRAY_SIZE ); +/* initialize SYN filter */ + filter_info->syn_info =0 ;return 0 ; }
@@ -5580,15 +5582,18 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev, bool add) {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 syn_info;uint32_t synqf;if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM )return -EINVAL ; - synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); + syn_info = filter_info->syn_info;if (add) { -if (synqf &IXGBE_SYN_FILTER_ENABLE ) +if (syn_info &IXGBE_SYN_FILTER_ENABLE )return -EINVAL ; synqf = (uint32_t )(((filter->queue <<IXGBE_SYN_FILTER_QUEUE_SHIFT ) &IXGBE_SYN_FILTER_QUEUE ) |IXGBE_SYN_FILTER_ENABLE );
@@ -5598,10 +5603,13 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev,else synqf &= ~IXGBE_SYN_FILTER_SYNQFP ; }else { -if (!(synqf &IXGBE_SYN_FILTER_ENABLE )) + synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); +if (!(syn_info &IXGBE_SYN_FILTER_ENABLE ))return -ENOENT ; synqf &= ~(IXGBE_SYN_FILTER_QUEUE |IXGBE_SYN_FILTER_ENABLE ); } + + filter_info->syn_info = synqf;IXGBE_WRITE_REG (hw,IXGBE_SYNQF , synqf);IXGBE_WRITE_FLUSH (hw);return 0 ;
drivers/net/ixgbe/ixgbe_ethdev.h +2 -0
@@ -262,6 +262,8 @@ struct ixgbe_filter_info {/* Bit mask for every used 5tuple filter */ uint32_t fivetuple_mask[IXGBE_5TUPLE_ARRAY_SIZE ];struct ixgbe_5tuple_filter_list fivetuple_list; +/* store the SYN filter info */ +uint32_t syn_info; };/*
Signature · 1 line
2.5.5
Re: [PATCH v2 01/18] net/ixgbe: store SYN filter
Hi, Wei Zhao
I think that you had better give a cover letter for such a series of patches. You can give the changes between v2 and v1 in cover letter
and maybe no need describe it in each one.
Thanks &Best Regards
-Wei
Quoted 89 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 01/18] net/ixgbe: store SYN filterAdd support for storing SYN filter in SW.
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--synqf assignment location change--- drivers/net/ixgbe/ixgbe_ethdev.c | 14 +++++++++++--- drivers/net/ixgbe/ixgbe_ethdev.h | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +7
-2@@ -1274,6 +1274,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)memset (filter_info->fivetuple_mask,0 ,sizeof (uint32_t ) *IXGBE_5TUPLE_ARRAY_SIZE ); +/* initialize SYN filter */ + filter_info->syn_info =0 ;return 0 ; }@@ -5580,15 +5582,18 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev, bool add) {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 syn_info;uint32_t synqf;if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM )return -EINVAL ; - synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); + syn_info = filter_info->syn_info;if (add) { -if (synqf &IXGBE_SYN_FILTER_ENABLE ) +if (syn_info &IXGBE_SYN_FILTER_ENABLE )return -EINVAL ; synqf = (uint32_t)(((filter->queue <<
IXGBE_SYN_FILTER_QUEUE_SHIFT) &drivers/net/ixgbe/ixgbe_ethdev.c +4
-1IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);@@ -5598,10 +5603,13 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev,else synqf &= ~IXGBE_SYN_FILTER_SYNQFP ; }else { -if (!(synqf &IXGBE_SYN_FILTER_ENABLE )) + synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); +if (!(syn_info &IXGBE_SYN_FILTER_ENABLE ))return -ENOENT ; synqf &= ~(IXGBE_SYN_FILTER_QUEUE |IXGBE_SYN_FILTER_ENABLE ); } + + filter_info->syn_info = synqf;IXGBE_WRITE_REG (hw,IXGBE_SYNQF , synqf);IXGBE_WRITE_FLUSH (hw);drivers/net/ixgbe/ixgbe_ethdev.c +0
-0return 0 ;drivers/net/ixgbe/ixgbe_ethdev.h +2
-1@@ -262,6 +262,8 @@ struct ixgbe_filter_info {/* Bit mask for every used 5tuple filter */ uint32_t fivetuple_mask[IXGBE_5TUPLE_ARRAY_SIZE ];struct ixgbe_5tuple_filter_list fivetuple_list; +/* store the SYN filter info */ +uint32_t syn_info; };/* -- 2.5.5
Re: [PATCH v2 01/18] net/ixgbe: store SYN filter
Hi, Daiwei
Quoted 8 lines
-----Original Message-----
From: Dai, Wei
Sent: Tuesday, January 3, 2017 10:33 PM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 01/18] net/ixgbe: store SYN filter
Quoted 6 lines
Hi, Wei Zhao
I think that you had better give a cover letter for such a series of patches. You can give the changes between v2 and v1 in cover letter and maybe no need describe it in each one.
Ok, I will add cover letter in v3
Quoted 95 lines
Thanks &Best Regards
-WeiQuoted 56 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 01/18] net/ixgbe: store SYN filterAdd support for storing SYN filter in SW.
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--synqf assignment location change--- drivers/net/ixgbe/ixgbe_ethdev.c | 14 +++++++++++--- drivers/net/ixgbe/ixgbe_ethdev.h | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +7
-2@@ -1274,6 +1274,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)memset (filter_info->fivetuple_mask,0 ,sizeof (uint32_t ) *IXGBE_5TUPLE_ARRAY_SIZE ); +/* initialize SYN filter */ + filter_info->syn_info =0 ;return 0 ; }@@ -5580,15 +5582,18 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev, bool add) {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 syn_info;uint32_t synqf;if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM )return -EINVAL ; - synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); + syn_info = filter_info->syn_info;if (add) { -if (synqf &IXGBE_SYN_FILTER_ENABLE ) +if (syn_info &IXGBE_SYN_FILTER_ENABLE )return -EINVAL ;Quoted 3 lines
synqf = (uint32_t)(((filter->queue <<
IXGBE_SYN_FILTER_QUEUE_SHIFT) &
IXGBE_SYN_FILTER_QUEUE) |
IXGBE_SYN_FILTER_ENABLE); @@ -5598,10drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_syn_filter_set(struct rte_eth_dev *dev,
Quoted 9 lines
+5603,13 @@ ixgbe_syn_filter_set(struct
rte_eth_dev*dev,drivers/net/ixgbe/ixgbe_ethdev.c +2
-1else synqf &= ~IXGBE_SYN_FILTER_SYNQFP ; }else { -if (!(synqf &IXGBE_SYN_FILTER_ENABLE )) + synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); +if (!(syn_info &IXGBE_SYN_FILTER_ENABLE ))return -ENOENT ; synqf &= ~(IXGBE_SYN_FILTER_QUEUE |
IXGBE_SYN_FILTER_ENABLE);Quoted 22 lines
drivers/net/ixgbe/ixgbe_ethdev.c +2
-0} + + filter_info->syn_info = synqf;IXGBE_WRITE_REG (hw,IXGBE_SYNQF , synqf);IXGBE_WRITE_FLUSH (hw);return 0 ;drivers/net/ixgbe/ixgbe_ethdev.h +2
-1@@ -262,6 +262,8 @@ struct ixgbe_filter_info {/* Bit mask for every used 5tuple filter */ uint32_t fivetuple_mask[IXGBE_5TUPLE_ARRAY_SIZE ];struct ixgbe_5tuple_filter_list fivetuple_list; +/* store the SYN filter info */ +uint32_t syn_info; };/* -- 2.5.5
Re: [PATCH v2 01/18] net/ixgbe: store SYN filter
In reply to Wei ZhaoQuoted 1 line · Wei Zhao
Add support for storing SYN filter in SW.
I think you have mentioned in previous review that you will update this to "TCP SYN", I would like to remind in case it is missed.
Quoted 8 lines
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--synqf assignment location change
---
<...>
Re: [PATCH v2 01/18] net/ixgbe: store SYN filter
Hi, yigit
Quoted 14 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, January 7, 2017 12:29 AM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 01/18] net/ixgbe: store SYN filterQuoted 1 line · Wei Zhao
Add support for storing SYN filter in SW.
I think you have mentioned in previous review that you will update this to "TCP SYN", I would like to remind in case it is missed.
Quoted 1 line
Quoted 8 lines
Quoted 7 lines
Signed-off-by Wenzhuo Lu <[email protected]>Signed-off-by Wei Zhao <[email protected]>---
v2:
--synqf assignment location change
---<...>
There is something wrong when I update code in v2. I PROMISE it will be changed in v3.
v3 cover net/ixgbe: Consistent filter API
In reply to Wei ZhaoThe 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.
v2 changes:
fix git log error
Modify some function call relationship
Change return value type of all parse flow functions Update error info for all flow ops
Add ixgbe_filterlist_flush to flush flows and rules created
v3 change:
add new file ixgbe_flow.c to store generic API parser related functions add more comment about pattern and action rules
add attr check in parser functions
change struct name ixgbe_flow to rte_flow
change SYN to TCP SYN
change to use memset initizlize struct ixgbe_filter_info
break down filter uninit process to 3 indepedent functions in eth_ixgbe_dev_uninit() change struct rte_flow_item_nvgre definition
change struct rte_flow_item_e_tag definition
fix one bug in function ixgbe_dev_filter_ctrl
add goto in function ixgbe_flow_create
delete some useless initialization
eliminate some git log check warning
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 Add support for restoring n-tuple
filter in SW.
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 check if the rule is a TCP SYN
rule, and get the SYN info.
net/ixgbe: parse L2 tunnel filter check if the rule is a L2 tunnel
rule, and get the L2 tunnel info.
net/ixgbe: parse flow director filter
net/ixgbe: create consistent filter
net/ixgbe: destroy consistent filter
net/ixgbe: flush all the filter list
drivers/net/ixgbe/Makefile | 2 + drivers/net/ixgbe/ixgbe_ethdev.c | 667 +++++++-- drivers/net/ixgbe/ixgbe_ethdev.h | 203 ++- drivers/net/ixgbe/ixgbe_fdir.c | 407 ++++-- drivers/net/ixgbe/ixgbe_flow.c | 2811 ++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_pf.c | 26 +- lib/librte_ether/rte_flow.h | 48 + 7 files changed, 3953 insertions(+), 211 deletions(-) create mode 100644 drivers/net/ixgbe/ixgbe_flow.c
Signature · 1 line
2.5.5
PATCH v3 1/18 net/ixgbe: store TCP SYN filter
In reply to Wei ZhaoAdd support for storing TCP SYN filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 18 +++++++++++++----- drivers/net/ixgbe/ixgbe_ethdev.h | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +13 -5
@@ -1272,10 +1272,12 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* enable support intr */ ixgbe_enable_intr (eth_dev); +/* initialize filter info */ +memset (filter_info,0 , +sizeof (struct ixgbe_filter_info )); +/* initialize 5tuple filter list */ TAILQ_INIT (&filter_info->fivetuple_list); -memset (filter_info->fivetuple_mask,0 , -sizeof (uint32_t ) *IXGBE_5TUPLE_ARRAY_SIZE );return 0 ; }
@@ -5603,15 +5605,18 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev, bool add) {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 syn_info;uint32_t synqf;if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM )return -EINVAL ; - synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); + syn_info = filter_info->syn_info;if (add) { -if (synqf &IXGBE_SYN_FILTER_ENABLE ) +if (syn_info &IXGBE_SYN_FILTER_ENABLE )return -EINVAL ; synqf = (uint32_t )(((filter->queue <<IXGBE_SYN_FILTER_QUEUE_SHIFT ) &IXGBE_SYN_FILTER_QUEUE ) |IXGBE_SYN_FILTER_ENABLE );
@@ -5621,10 +5626,13 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev,else synqf &= ~IXGBE_SYN_FILTER_SYNQFP ; }else { -if (!(synqf &IXGBE_SYN_FILTER_ENABLE )) + synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); +if (!(syn_info &IXGBE_SYN_FILTER_ENABLE ))return -ENOENT ; synqf &= ~(IXGBE_SYN_FILTER_QUEUE |IXGBE_SYN_FILTER_ENABLE ); } + + filter_info->syn_info = synqf;IXGBE_WRITE_REG (hw,IXGBE_SYNQF , synqf);IXGBE_WRITE_FLUSH (hw);return 0 ;
drivers/net/ixgbe/ixgbe_ethdev.h +2 -0
@@ -262,6 +262,8 @@ struct ixgbe_filter_info {/* Bit mask for every used 5tuple filter */ uint32_t fivetuple_mask[IXGBE_5TUPLE_ARRAY_SIZE ];struct ixgbe_5tuple_filter_list fivetuple_list; +/* store the SYN filter info */ +uint32_t syn_info; };/*
Signature · 1 line
2.5.5
PATCH v3 2/18 net/ixgbe: store flow director filter
Add support for storing flow director filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 64 ++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 19 ++++++- drivers/net/ixgbe/ixgbe_fdir.c | 105 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 185 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +64 -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,8 @@ 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_fdir_filter_uninit (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);
@@ -1279,6 +1282,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* initialize 5tuple filter list */ TAILQ_INIT (&filter_info->fivetuple_list); +/* initialize flow director filter list & hash */ +ixgbe_fdir_filter_init (eth_dev); +return 0 ; }
@@ -1320,9 +1326,67 @@ 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 */ +ixgbe_fdir_filter_uninit (eth_dev); +return 0 ; } +static int ixgbe_fdir_filter_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); +struct ixgbe_fdir_filter *fdir_filter; + +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
PATCH v3 3/18 net/ixgbe: store L2 tunnel filter
In reply to Wei ZhaoAdd support for storing L2 tunnel filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 172 ++++++++++++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 24 ++++++ 2 files changed, 193 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +169 -3
@@ -168,6 +168,8 @@ 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_fdir_filter_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev); +static int ixgbe_l2_tn_filter_uninit (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);
@@ -1285,6 +1287,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 ; }
@@ -1329,6 +1333,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)/* remove all the fdir filters & hash */ ixgbe_fdir_filter_uninit (eth_dev); +/* remove all the L2 tunnel filters & hash */ +ixgbe_l2_tn_filter_uninit (eth_dev); +return 0 ; }
@@ -1353,6 +1360,27 @@ static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)return 0 ; } +static int ixgbe_l2_tn_filter_uninit (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); +struct ixgbe_l2_tn_filter *l2_tn_filter; + +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 ; +} +static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev) { struct ixgbe_hw_fdir_info *fdir_info =
@@ -1384,6 +1412,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 ; }
@@ -7210,12 +7272,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; + + 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; + + 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; +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 ; +int ret; +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 :
@@ -7227,6 +7381,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; }
@@ -7235,7 +7392,16 @@ static int ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel) { - int ret = 0; + int ret; +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 :
@@ -7261,7 +7427,7 @@ ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,enum rte_filter_op filter_op, void *arg) { - int ret = 0; + int ret;if (filter_op ==RTE_ETH_FILTER_NOP )return 0 ;
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;
@@ -349,6 +370,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
PATCH v3 4/18 net/ixgbe: restore n-tuple filter Add support for restoring n-tuple filter in SW.
In reply to Wei Zhao--- drivers/net/ixgbe/ixgbe_ethdev.c | 140 +++++++++++++++++++++++++-------------- 1 file changed, 92 insertions(+), 48 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +92 -48
@@ -170,6 +170,7 @@ static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);static int ixgbe_fdir_filter_uninit (struct rte_eth_dev *eth_dev);static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev);static int ixgbe_l2_tn_filter_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_ntuple_filter_uninit (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);
@@ -387,6 +388,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
@@ -1336,6 +1338,27 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)/* remove all the L2 tunnel filters & hash */ ixgbe_l2_tn_filter_uninit (eth_dev); +/* Remove all ntuple filters of the device */ +ixgbe_ntuple_filter_uninit (eth_dev); + +return 0 ; +} + +static int ixgbe_ntuple_filter_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (eth_dev->data->dev_private); +struct ixgbe_5tuple_filter *p_5tuple; + +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 ); +return 0 ; }
@@ -2504,6 +2527,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 ;
@@ -2524,9 +2548,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_pci_device *pci_dev =IXGBE_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;int vf;
@@ -2564,17 +2585,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,
@@ -5836,6 +5846,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 *
@@ -5853,13 +5909,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,
@@ -5882,37 +5934,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 ; }
@@ -7925,6 +7948,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 v3 4/9 net/ixgbe: restore n-tuple filter Add support for restoring n-tuple filter in SW.
In reply to Wei Zhao--- drivers/net/ixgbe/ixgbe_ethdev.c | 140 +++++++++++++++++++++++++-------------- 1 file changed, 92 insertions(+), 48 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +92 -48
@@ -170,6 +170,7 @@ static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);static int ixgbe_fdir_filter_uninit (struct rte_eth_dev *eth_dev);static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev);static int ixgbe_l2_tn_filter_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_ntuple_filter_uninit (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);
@@ -387,6 +388,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
@@ -1335,6 +1337,27 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)/* remove all the L2 tunnel filters & hash */ ixgbe_l2_tn_filter_uninit (eth_dev); +/* Remove all ntuple filters of the device */ +ixgbe_ntuple_filter_uninit (eth_dev); + +return 0 ; +} + +static int ixgbe_ntuple_filter_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (eth_dev->data->dev_private); +struct ixgbe_5tuple_filter *p_5tuple; + +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 ); +return 0 ; }
@@ -2503,6 +2526,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 ;
@@ -2523,9 +2547,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_pci_device *pci_dev =IXGBE_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;int vf;
@@ -2563,17 +2584,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,
@@ -5835,6 +5845,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 *
@@ -5852,13 +5908,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,
@@ -5881,37 +5933,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 ; }
@@ -7924,6 +7947,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 v3 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 | 79 ++++++++++++++++------------------------ drivers/net/ixgbe/ixgbe_ethdev.h | 57 ++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_pf.c | 25 ++++++++----- 3 files changed, 104 insertions(+), 57 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +32 -47
@@ -6259,47 +6259,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,
@@ -6311,6 +6270,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 ;
@@ -6344,18 +6304,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 )
@@ -7961,10 +7925,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
@@ -178,6 +178,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"
@@ -185,16 +186,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 v3 6/18 net/ixgbe: restore TCP SYN filter
In reply to Wei ZhaoAdd support for restoring TCP SYN filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +18 -0
@@ -7945,11 +7945,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 v3 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
@@ -7968,6 +7968,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
@@ -497,6 +497,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 v3 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
@@ -7324,7 +7324,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; struct ixgbe_l2_tn_info *l2_tn_info =
@@ -7332,30 +7333,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) {
@@ -7368,7 +7372,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;
@@ -7429,7 +7433,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
@@ -7962,6 +7967,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) {
@@ -7969,6 +7991,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 v3 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
@@ -389,6 +389,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
@@ -1469,6 +1470,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 ; }
@@ -2527,6 +2531,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 ;
@@ -7083,12 +7088,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 :
@@ -7127,9 +7135,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 :
@@ -7168,9 +7179,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 :
@@ -7477,10 +7491,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 :
@@ -7498,10 +7515,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 :
@@ -7996,6 +8016,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
PATCH v3 10/18 net/ixgbe: flush all the filters
In reply to Wei ZhaoAdd support for flush all the filters in SW.
--- drivers/net/ixgbe/Makefile | 2 + drivers/net/ixgbe/ixgbe_ethdev.c | 79 ++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 16 ++++++ drivers/net/ixgbe/ixgbe_fdir.c | 24 ++++++++ drivers/net/ixgbe/ixgbe_flow.c | 115 +++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_pf.c | 1 + 6 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ixgbe/ixgbe_flow.c
drivers/net/ixgbe/Makefile +2 -0
@@ -109,6 +109,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_fdir.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_pf.c +SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_flow.c ifeq ($(CONFIG_RTE_ARCH_ARM64),y) SRCS-$(CONFIG_RTE_IXGBE_INC_VECTOR) += ixgbe_rxtx_vec_neon.c else
@@ -127,5 +128,6 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_IXGBE_PMD)-include := rte_pmd_ixgbe.h DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_eal lib/librte_ether DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_mempool lib/librte_mbuf DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_net +DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_hash include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ixgbe/ixgbe_ethdev.c +78 -1
106 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_ethdev.h +16 -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; };/*
@@ -501,6 +506,14 @@ 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); + +extern const struct rte_flow_ops ixgbe_flow_ops; + +void ixgbe_clear_all_ethertype_filter (struct rte_eth_dev *dev); +void ixgbe_clear_all_ntuple_filter (struct rte_eth_dev *dev); +void ixgbe_clear_syn_filter (struct rte_eth_dev *dev); +int ixgbe_clear_all_l2_tn_filter (struct rte_eth_dev *dev); static inline int ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
@@ -531,6 +544,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; } }
@@ -547,6 +562,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_flow.c new file +115 -0
115 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_pf.c +1 -0
@@ -199,6 +199,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
PATCH v3 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.
--- drivers/net/ixgbe/ixgbe_flow.c | 429 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 424 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_flow.c +424 -5
@@ -77,15 +77,432 @@static int ixgbe_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error); +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);const struct rte_flow_ops ixgbe_flow_ops = { -NULL , + ixgbe_flow_validate,NULL ,NULL , ixgbe_flow_flush,NULL , }; +#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. +* pattern: +* The first not void item can be ETH or IPV4. +* The second not void item must be IPV4 if the first one is ETH. +* The third not void item must be UDP or TCP. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +*/ +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; + } + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +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) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +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 ; + +/** +* 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; +if (attr->priority <IXGBE_MIN_N_TUPLE_PRIO || + attr->priority >IXGBE_MAX_N_TUPLE_PRIO ) + filter->priority =1 ; + +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,
@@ -99,15 +516,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
PATCH v3 12/18 net/ixgbe: parse ethertype filter
In reply to Wei Zhaocheck if the rule is a ethertype rule, and get the ethertype info.
--- drivers/net/ixgbe/ixgbe_flow.c | 278 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+)
drivers/net/ixgbe/ixgbe_flow.c +278 -0
@@ -90,6 +90,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[],
@@ -480,6 +492,265 @@ 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. +* pattern: +* The first not void item can be ETH. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +*/ +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; + } + +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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 ) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"queue index much too big" ); +return -rte_errno; + } + +if (filter->ether_type == ETHER_TYPE_IPv4 || + filter->ether_type == ETHER_TYPE_IPv6) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"IPv4/IPv6 not supported by ethertype filter" ); +return -rte_errno; + } + +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 ,"mac compare is unsupported" ); +return -rte_errno; + } + +if (filter->flags &RTE_ETHTYPE_FLAGS_DROP ) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"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.
@@ -492,6 +763,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 ));
@@ -500,6 +772,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
PATCH v3 13/18 net/ixgbe: parse TCP SYN filter check if the rule is a TCP SYN rule, and get the SYN info.
In reply to Wei Zhao--- drivers/net/ixgbe/ixgbe_flow.c | 266 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+)
drivers/net/ixgbe/ixgbe_flow.c +266 -0
@@ -102,6 +102,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[],
@@ -751,6 +763,253 @@ 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. +* pattern: +* The first not void item must be ETH. +* The second not void item must be IPV4 or IPV6. +* The third not void item must be TCP. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +*/ +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; + } + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } + +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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 ; + +/* 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.
@@ -764,6 +1023,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 ));
@@ -778,6 +1038,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
PATCH v3 14/18 net/ixgbe: parse L2 tunnel filter check if the rule is a L2 tunnel rule, and get the L2 tunnel info.
In reply to Wei Zhao--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 203 +++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 253 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
@@ -8089,7 +8089,8 @@ ixgbe_clear_syn_filter(struct rte_eth_dev *dev) }/* remove all the L2 tunnel filters */ -int ixgbe_clear_all_l2_tn_filter (struct rte_eth_dev *dev) +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);
drivers/net/ixgbe/ixgbe_flow.c +203 -0
227 lines not on this page · raw message
lib/librte_ether/rte_flow.h +48 -0
60 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v3 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.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 2 + drivers/net/ixgbe/ixgbe_ethdev.h | 16 + drivers/net/ixgbe/ixgbe_fdir.c | 253 +++++--- drivers/net/ixgbe/ixgbe_flow.c | 1219 +++++++++++++++++++++++++++++++++++++- 4 files changed, 1381 insertions(+), 109 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +2 -0
@@ -1436,6 +1436,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 ; }
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 */
@@ -479,6 +491,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 +170 -83
473 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_flow.c +1193 -26
1,238 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v3 16/18 net/ixgbe: create consistent filter
In reply to Wei ZhaoThis patch adds a function to create the flow directory filter.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 25 +++-- drivers/net/ixgbe/ixgbe_ethdev.h | 61 ++++++++++++ drivers/net/ixgbe/ixgbe_flow.c | 194 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 266 insertions(+), 14 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +12 -13
@@ -305,9 +305,6 @@ static void ixgbevf_add_mac_addr(struct rte_eth_dev *dev,static void ixgbevf_remove_mac_addr (struct rte_eth_dev *dev,uint32_t index);static void ixgbevf_set_default_mac_addr (struct rte_eth_dev *dev,struct ether_addr *mac_addr); -static int ixgbe_syn_filter_set (struct rte_eth_dev *dev, -struct rte_eth_syn_filter *filter, -bool add);static int ixgbe_syn_filter_get (struct rte_eth_dev *dev,struct rte_eth_syn_filter *filter); static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
@@ -317,17 +314,11 @@ static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev, struct ixgbe_5tuple_filter *filter);static void ixgbe_remove_5tuple_filter (struct rte_eth_dev *dev,struct ixgbe_5tuple_filter *filter); -static int ixgbe_add_del_ntuple_filter (struct rte_eth_dev *dev, -struct rte_eth_ntuple_filter *filter, -bool add);static int ixgbe_ntuple_filter_handle (struct rte_eth_dev *dev,enum rte_filter_op filter_op,void *arg);static int ixgbe_get_ntuple_filter (struct rte_eth_dev *dev,struct rte_eth_ntuple_filter *filter); -static int ixgbe_add_del_ethertype_filter (struct rte_eth_dev *dev, -struct rte_eth_ethertype_filter *filter, -bool add);static int ixgbe_ethertype_filter_handle (struct rte_eth_dev *dev,enum rte_filter_op filter_op,void *arg);
@@ -1292,6 +1283,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 ; }
@@ -5742,7 +5741,7 @@ ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)return -ENOTSUP ;\ }while (0 ) -static int +int ixgbe_syn_filter_set(struct rte_eth_dev *dev, struct rte_eth_syn_filter *filter, bool add)
@@ -6121,7 +6120,7 @@ ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,* - On success, zero. * - On failure, a negative value. */ -static int +int ixgbe_add_del_ntuple_filter (struct rte_eth_dev *dev,struct rte_eth_ntuple_filter *ntuple_filter,bool add)
@@ -6266,7 +6265,7 @@ ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,return ret; } -static int +int ixgbe_add_del_ethertype_filter (struct rte_eth_dev *dev,struct rte_eth_ethertype_filter *filter,bool add)
@@ -7345,7 +7344,7 @@ ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info, }/* Add l2 tunnel filter */ -static int +int ixgbe_dev_l2_tunnel_filter_add (struct rte_eth_dev *dev,struct rte_eth_l2_tunnel_conf *l2_tunnel,bool restore)
drivers/net/ixgbe/ixgbe_ethdev.h +61 -0
73 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_flow.c +193 -1
209 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v3 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 v3 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
v4 cover net/ixgbe: Consistent filter API
In reply to Wei ZhaoFrom: zhao wei <[email protected]>
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.
v2 changes:
fix git log error
Modify some function call relationship
Change return value type of all parse flow functions Update error info for all flow ops
Add ixgbe_filterlist_flush to flush flows and rules created
v3 change:
add new file ixgbe_flow.c to store generic API parser related functions add more comment about pattern and action rules
add attr check in parser functions
change struct name ixgbe_flow to rte_flow
change SYN to TCP SYN
change to use memset initizlize struct ixgbe_filter_info
break down filter uninit process to 3 indepedent functions in eth_ixgbe_dev_uninit() change struct rte_flow_item_nvgre definition
change struct rte_flow_item_e_tag definition
fix one bug in function ixgbe_dev_filter_ctrl
add goto in function ixgbe_flow_create
delete some useless initialization
eliminate some git log check warning
v4 change:
fix some check patch warning
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 Add support for restoring n-tuple
filter in SW.
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 check if the rule is a TCP SYN
rule, and get the SYN info.
net/ixgbe: parse L2 tunnel filter check if the rule is a L2 tunnel
rule, and get the L2 tunnel info.
net/ixgbe: parse flow director filter
net/ixgbe: create consistent filter
net/ixgbe: destroy consistent filter
net/ixgbe: flush all the filter list
drivers/net/ixgbe/Makefile | 2 + drivers/net/ixgbe/ixgbe_ethdev.c | 667 +++++++-- drivers/net/ixgbe/ixgbe_ethdev.h | 203 ++- drivers/net/ixgbe/ixgbe_fdir.c | 407 ++++-- drivers/net/ixgbe/ixgbe_flow.c | 2808 ++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_pf.c | 26 +- lib/librte_ether/rte_flow.h | 48 + 7 files changed, 3950 insertions(+), 211 deletions(-) create mode 100644 drivers/net/ixgbe/ixgbe_flow.c
Signature · 1 line
2.5.5
PATCH v4 1/18 net/ixgbe: store TCP SYN filter
Add support for storing TCP SYN filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 18 +++++++++++++----- drivers/net/ixgbe/ixgbe_ethdev.h | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +13 -5
@@ -1272,10 +1272,12 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* enable support intr */ ixgbe_enable_intr (eth_dev); +/* initialize filter info */ +memset (filter_info,0 , +sizeof (struct ixgbe_filter_info )); +/* initialize 5tuple filter list */ TAILQ_INIT (&filter_info->fivetuple_list); -memset (filter_info->fivetuple_mask,0 , -sizeof (uint32_t ) *IXGBE_5TUPLE_ARRAY_SIZE );return 0 ; }
@@ -5603,15 +5605,18 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev, bool add) {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 syn_info;uint32_t synqf;if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM )return -EINVAL ; - synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); + syn_info = filter_info->syn_info;if (add) { -if (synqf &IXGBE_SYN_FILTER_ENABLE ) +if (syn_info &IXGBE_SYN_FILTER_ENABLE )return -EINVAL ; synqf = (uint32_t )(((filter->queue <<IXGBE_SYN_FILTER_QUEUE_SHIFT ) &IXGBE_SYN_FILTER_QUEUE ) |IXGBE_SYN_FILTER_ENABLE );
@@ -5621,10 +5626,13 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev,else synqf &= ~IXGBE_SYN_FILTER_SYNQFP ; }else { -if (!(synqf &IXGBE_SYN_FILTER_ENABLE )) + synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); +if (!(syn_info &IXGBE_SYN_FILTER_ENABLE ))return -ENOENT ; synqf &= ~(IXGBE_SYN_FILTER_QUEUE |IXGBE_SYN_FILTER_ENABLE ); } + + filter_info->syn_info = synqf;IXGBE_WRITE_REG (hw,IXGBE_SYNQF , synqf);IXGBE_WRITE_FLUSH (hw);return 0 ;
drivers/net/ixgbe/ixgbe_ethdev.h +2 -0
@@ -262,6 +262,8 @@ struct ixgbe_filter_info {/* Bit mask for every used 5tuple filter */ uint32_t fivetuple_mask[IXGBE_5TUPLE_ARRAY_SIZE ];struct ixgbe_5tuple_filter_list fivetuple_list; +/* store the SYN filter info */ +uint32_t syn_info; };/*
Signature · 1 line
2.5.5
PATCH v4 2/18 net/ixgbe: store flow director filter
In reply to Wei ZhaoAdd support for storing flow director filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 64 ++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 19 ++++++- drivers/net/ixgbe/ixgbe_fdir.c | 105 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 185 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +64 -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,8 @@ 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_fdir_filter_uninit (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);
@@ -1279,6 +1282,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* initialize 5tuple filter list */ TAILQ_INIT (&filter_info->fivetuple_list); +/* initialize flow director filter list & hash */ +ixgbe_fdir_filter_init (eth_dev); +return 0 ; }
@@ -1320,9 +1326,67 @@ 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 */ +ixgbe_fdir_filter_uninit (eth_dev); +return 0 ; } +static int ixgbe_fdir_filter_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); +struct ixgbe_fdir_filter *fdir_filter; + +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
PATCH v4 3/18 net/ixgbe: store L2 tunnel filter
In reply to Wei ZhaoAdd support for storing L2 tunnel filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 172 ++++++++++++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 24 ++++++ 2 files changed, 193 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +169 -3
@@ -168,6 +168,8 @@ 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_fdir_filter_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev); +static int ixgbe_l2_tn_filter_uninit (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);
@@ -1285,6 +1287,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 ; }
@@ -1329,6 +1333,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)/* remove all the fdir filters & hash */ ixgbe_fdir_filter_uninit (eth_dev); +/* remove all the L2 tunnel filters & hash */ +ixgbe_l2_tn_filter_uninit (eth_dev); +return 0 ; }
@@ -1353,6 +1360,27 @@ static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)return 0 ; } +static int ixgbe_l2_tn_filter_uninit (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); +struct ixgbe_l2_tn_filter *l2_tn_filter; + +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 ; +} +static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev) { struct ixgbe_hw_fdir_info *fdir_info =
@@ -1384,6 +1412,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 ; }
@@ -7210,12 +7272,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; + + 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; + + 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; +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 ; +int ret; +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 :
@@ -7227,6 +7381,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; }
@@ -7235,7 +7392,16 @@ static int ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel) { - int ret = 0; + int ret; +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 :
@@ -7261,7 +7427,7 @@ ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,enum rte_filter_op filter_op, void *arg) { - int ret = 0; + int ret;if (filter_op ==RTE_ETH_FILTER_NOP )return 0 ;
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;
@@ -349,6 +370,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
PATCH v4 4/18 net/ixgbe: restore n-tuple filter Add support for restoring n-tuple filter in SW.
In reply to Wei Zhao--- drivers/net/ixgbe/ixgbe_ethdev.c | 140 +++++++++++++++++++++++++-------------- 1 file changed, 92 insertions(+), 48 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +92 -48
@@ -170,6 +170,7 @@ static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);static int ixgbe_fdir_filter_uninit (struct rte_eth_dev *eth_dev);static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev);static int ixgbe_l2_tn_filter_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_ntuple_filter_uninit (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);
@@ -387,6 +388,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
@@ -1336,6 +1338,27 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)/* remove all the L2 tunnel filters & hash */ ixgbe_l2_tn_filter_uninit (eth_dev); +/* Remove all ntuple filters of the device */ +ixgbe_ntuple_filter_uninit (eth_dev); + +return 0 ; +} + +static int ixgbe_ntuple_filter_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (eth_dev->data->dev_private); +struct ixgbe_5tuple_filter *p_5tuple; + +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 ); +return 0 ; }
@@ -2504,6 +2527,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 ;
@@ -2524,9 +2548,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_pci_device *pci_dev =IXGBE_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;int vf;
@@ -2564,17 +2585,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,
@@ -5836,6 +5846,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 *
@@ -5853,13 +5909,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,
@@ -5882,37 +5934,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 ; }
@@ -7925,6 +7948,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 v4 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 | 79 ++++++++++++++++------------------------ drivers/net/ixgbe/ixgbe_ethdev.h | 57 ++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_pf.c | 25 ++++++++----- 3 files changed, 104 insertions(+), 57 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +32 -47
@@ -6259,47 +6259,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,
@@ -6311,6 +6270,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 ;
@@ -6344,18 +6304,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 )
@@ -7961,10 +7925,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
@@ -178,6 +178,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"
@@ -185,16 +186,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 v4 6/18 net/ixgbe: restore TCP SYN filter
In reply to Wei ZhaoAdd support for restoring TCP SYN filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +18 -0
@@ -7945,11 +7945,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 v4 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
@@ -7968,6 +7968,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
@@ -497,6 +497,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 v4 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
@@ -7324,7 +7324,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; struct ixgbe_l2_tn_info *l2_tn_info =
@@ -7332,30 +7333,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) {
@@ -7368,7 +7372,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;
@@ -7429,7 +7433,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
@@ -7962,6 +7967,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) {
@@ -7969,6 +7991,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 v4 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
@@ -389,6 +389,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
@@ -1469,6 +1470,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 ; }
@@ -2527,6 +2531,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 ;
@@ -7083,12 +7088,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 :
@@ -7127,9 +7135,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 :
@@ -7168,9 +7179,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 :
@@ -7477,10 +7491,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 :
@@ -7498,10 +7515,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 :
@@ -7996,6 +8016,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
PATCH v4 10/18 net/ixgbe: flush all the filters
In reply to Wei ZhaoAdd support for flush all the filters in SW.
--- drivers/net/ixgbe/Makefile | 2 + drivers/net/ixgbe/ixgbe_ethdev.c | 79 ++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 16 ++++++ drivers/net/ixgbe/ixgbe_fdir.c | 24 ++++++++ drivers/net/ixgbe/ixgbe_flow.c | 115 +++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_pf.c | 1 + 6 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ixgbe/ixgbe_flow.c
drivers/net/ixgbe/Makefile +2 -0
@@ -109,6 +109,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_fdir.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_pf.c +SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_flow.c ifeq ($(CONFIG_RTE_ARCH_ARM64),y) SRCS-$(CONFIG_RTE_IXGBE_INC_VECTOR) += ixgbe_rxtx_vec_neon.c else
@@ -127,5 +128,6 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_IXGBE_PMD)-include := rte_pmd_ixgbe.h DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_eal lib/librte_ether DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_mempool lib/librte_mbuf DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_net +DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_hash include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ixgbe/ixgbe_ethdev.c +78 -1
106 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_ethdev.h +16 -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; };/*
@@ -501,6 +506,14 @@ 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); + +extern const struct rte_flow_ops ixgbe_flow_ops; + +void ixgbe_clear_all_ethertype_filter (struct rte_eth_dev *dev); +void ixgbe_clear_all_ntuple_filter (struct rte_eth_dev *dev); +void ixgbe_clear_syn_filter (struct rte_eth_dev *dev); +int ixgbe_clear_all_l2_tn_filter (struct rte_eth_dev *dev); static inline int ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
@@ -531,6 +544,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; } }
@@ -547,6 +562,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_flow.c new file +115 -0
115 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_pf.c +1 -0
@@ -199,6 +199,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
PATCH v4 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.
--- drivers/net/ixgbe/ixgbe_flow.c | 429 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 424 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_flow.c +424 -5
@@ -77,15 +77,432 @@static int ixgbe_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error); +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);const struct rte_flow_ops ixgbe_flow_ops = { -NULL , + ixgbe_flow_validate,NULL ,NULL , ixgbe_flow_flush,NULL , }; +#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. +* pattern: +* The first not void item can be ETH or IPV4. +* The second not void item must be IPV4 if the first one is ETH. +* The third not void item must be UDP or TCP. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +*/ +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; + } + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +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) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +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 ; + +/** +* 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; +if (attr->priority <IXGBE_MIN_N_TUPLE_PRIO || + attr->priority >IXGBE_MAX_N_TUPLE_PRIO ) + filter->priority =1 ; + +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,
@@ -99,15 +516,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
PATCH v4 12/18 net/ixgbe: parse ethertype filter
In reply to Wei Zhaocheck if the rule is a ethertype rule, and get the ethertype info.
--- drivers/net/ixgbe/ixgbe_flow.c | 278 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+)
drivers/net/ixgbe/ixgbe_flow.c +278 -0
@@ -90,6 +90,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[],
@@ -480,6 +492,265 @@ 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. +* pattern: +* The first not void item can be ETH. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +*/ +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; + } + +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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 ) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"queue index much too big" ); +return -rte_errno; + } + +if (filter->ether_type == ETHER_TYPE_IPv4 || + filter->ether_type == ETHER_TYPE_IPv6) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"IPv4/IPv6 not supported by ethertype filter" ); +return -rte_errno; + } + +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 ,"mac compare is unsupported" ); +return -rte_errno; + } + +if (filter->flags &RTE_ETHTYPE_FLAGS_DROP ) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"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.
@@ -492,6 +763,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 ));
@@ -500,6 +772,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
PATCH v4 13/18 net/ixgbe: parse TCP SYN filter check if the rule is a TCP SYN rule, and get the SYN info.
In reply to Wei Zhao--- drivers/net/ixgbe/ixgbe_flow.c | 264 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 264 insertions(+)
drivers/net/ixgbe/ixgbe_flow.c +264 -0
@@ -102,6 +102,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[],
@@ -751,6 +763,251 @@ 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. +* pattern: +* The first not void item must be ETH. +* The second not void item must be IPV4 or IPV6. +* The third not void item must be TCP. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +*/ +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; + } + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } + +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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 ; + +/* 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.
@@ -764,6 +1021,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 ));
@@ -778,6 +1036,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
PATCH v4 14/18 net/ixgbe: parse L2 tunnel filter check if the rule is a L2 tunnel rule, and get the L2 tunnel info.
In reply to Wei Zhao--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 203 +++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 253 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
@@ -8089,7 +8089,8 @@ ixgbe_clear_syn_filter(struct rte_eth_dev *dev) }/* remove all the L2 tunnel filters */ -int ixgbe_clear_all_l2_tn_filter (struct rte_eth_dev *dev) +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);
drivers/net/ixgbe/ixgbe_flow.c +203 -0
227 lines not on this page · raw message
lib/librte_ether/rte_flow.h +48 -0
60 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v4 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.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 2 + drivers/net/ixgbe/ixgbe_ethdev.h | 16 + drivers/net/ixgbe/ixgbe_fdir.c | 253 +++++--- drivers/net/ixgbe/ixgbe_flow.c | 1218 +++++++++++++++++++++++++++++++++++++- 4 files changed, 1380 insertions(+), 109 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +2 -0
@@ -1436,6 +1436,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 ; }
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 */
@@ -479,6 +491,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 +170 -83
473 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_flow.c +1192 -26
1,237 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v4 16/18 net/ixgbe: create consistent filter
In reply to Wei ZhaoThis patch adds a function to create the flow directory filter.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 25 +++-- drivers/net/ixgbe/ixgbe_ethdev.h | 61 ++++++++++++ drivers/net/ixgbe/ixgbe_flow.c | 194 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 266 insertions(+), 14 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +12 -13
@@ -305,9 +305,6 @@ static void ixgbevf_add_mac_addr(struct rte_eth_dev *dev,static void ixgbevf_remove_mac_addr (struct rte_eth_dev *dev,uint32_t index);static void ixgbevf_set_default_mac_addr (struct rte_eth_dev *dev,struct ether_addr *mac_addr); -static int ixgbe_syn_filter_set (struct rte_eth_dev *dev, -struct rte_eth_syn_filter *filter, -bool add);static int ixgbe_syn_filter_get (struct rte_eth_dev *dev,struct rte_eth_syn_filter *filter); static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
@@ -317,17 +314,11 @@ static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev, struct ixgbe_5tuple_filter *filter);static void ixgbe_remove_5tuple_filter (struct rte_eth_dev *dev,struct ixgbe_5tuple_filter *filter); -static int ixgbe_add_del_ntuple_filter (struct rte_eth_dev *dev, -struct rte_eth_ntuple_filter *filter, -bool add);static int ixgbe_ntuple_filter_handle (struct rte_eth_dev *dev,enum rte_filter_op filter_op,void *arg);static int ixgbe_get_ntuple_filter (struct rte_eth_dev *dev,struct rte_eth_ntuple_filter *filter); -static int ixgbe_add_del_ethertype_filter (struct rte_eth_dev *dev, -struct rte_eth_ethertype_filter *filter, -bool add);static int ixgbe_ethertype_filter_handle (struct rte_eth_dev *dev,enum rte_filter_op filter_op,void *arg);
@@ -1292,6 +1283,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 ; }
@@ -5742,7 +5741,7 @@ ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)return -ENOTSUP ;\ }while (0 ) -static int +int ixgbe_syn_filter_set(struct rte_eth_dev *dev, struct rte_eth_syn_filter *filter, bool add)
@@ -6121,7 +6120,7 @@ ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,* - On success, zero. * - On failure, a negative value. */ -static int +int ixgbe_add_del_ntuple_filter (struct rte_eth_dev *dev,struct rte_eth_ntuple_filter *ntuple_filter,bool add)
@@ -6266,7 +6265,7 @@ ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,return ret; } -static int +int ixgbe_add_del_ethertype_filter (struct rte_eth_dev *dev,struct rte_eth_ethertype_filter *filter,bool add)
@@ -7345,7 +7344,7 @@ ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info, }/* Add l2 tunnel filter */ -static int +int ixgbe_dev_l2_tunnel_filter_add (struct rte_eth_dev *dev,struct rte_eth_l2_tunnel_conf *l2_tunnel,bool restore)
drivers/net/ixgbe/ixgbe_ethdev.h +61 -0
73 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_flow.c +193 -1
209 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v4 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 v4 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
v5 cover net/ixgbe: Consistent filter API
In reply to Wei ZhaoThe 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.
v2 changes:
fix git log error
Modify some function call relationship
Change return value type of all parse flow functions Update error info for all flow ops
Add ixgbe_filterlist_flush to flush flows and rules created
v3 change:
add new file ixgbe_flow.c to store generic API parser related functions add more comment about pattern and action rules
add attr check in parser functions
change struct name ixgbe_flow to rte_flow
change SYN to TCP SYN
change to use memset initizlize struct ixgbe_filter_info
break down filter uninit process to 3 indepedent functions in eth_ixgbe_dev_uninit() change struct rte_flow_item_nvgre definition
change struct rte_flow_item_e_tag definition
fix one bug in function ixgbe_dev_filter_ctrl
add goto in function ixgbe_flow_create
delete some useless initialization
eliminate some git log check warning
v4 change:
fix some check patch warning
v5 change:
fix some git log warning
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
drivers/net/ixgbe/Makefile | 2 + drivers/net/ixgbe/ixgbe_ethdev.c | 667 +++++++-- drivers/net/ixgbe/ixgbe_ethdev.h | 203 ++- drivers/net/ixgbe/ixgbe_fdir.c | 407 ++++-- drivers/net/ixgbe/ixgbe_flow.c | 2808 ++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_pf.c | 26 +- lib/librte_ether/rte_flow.h | 48 + 7 files changed, 3950 insertions(+), 211 deletions(-) create mode 100644 drivers/net/ixgbe/ixgbe_flow.c
Signature · 1 line
2.5.5
PATCH v5 1/18 net/ixgbe: store TCP SYN filter
Add support for storing TCP SYN filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 18 +++++++++++++----- drivers/net/ixgbe/ixgbe_ethdev.h | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +13 -5
@@ -1272,10 +1272,12 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* enable support intr */ ixgbe_enable_intr (eth_dev); +/* initialize filter info */ +memset (filter_info,0 , +sizeof (struct ixgbe_filter_info )); +/* initialize 5tuple filter list */ TAILQ_INIT (&filter_info->fivetuple_list); -memset (filter_info->fivetuple_mask,0 , -sizeof (uint32_t ) *IXGBE_5TUPLE_ARRAY_SIZE );return 0 ; }
@@ -5603,15 +5605,18 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev, bool add) {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 syn_info;uint32_t synqf;if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM )return -EINVAL ; - synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); + syn_info = filter_info->syn_info;if (add) { -if (synqf &IXGBE_SYN_FILTER_ENABLE ) +if (syn_info &IXGBE_SYN_FILTER_ENABLE )return -EINVAL ; synqf = (uint32_t )(((filter->queue <<IXGBE_SYN_FILTER_QUEUE_SHIFT ) &IXGBE_SYN_FILTER_QUEUE ) |IXGBE_SYN_FILTER_ENABLE );
@@ -5621,10 +5626,13 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev,else synqf &= ~IXGBE_SYN_FILTER_SYNQFP ; }else { -if (!(synqf &IXGBE_SYN_FILTER_ENABLE )) + synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); +if (!(syn_info &IXGBE_SYN_FILTER_ENABLE ))return -ENOENT ; synqf &= ~(IXGBE_SYN_FILTER_QUEUE |IXGBE_SYN_FILTER_ENABLE ); } + + filter_info->syn_info = synqf;IXGBE_WRITE_REG (hw,IXGBE_SYNQF , synqf);IXGBE_WRITE_FLUSH (hw);return 0 ;
drivers/net/ixgbe/ixgbe_ethdev.h +2 -0
@@ -262,6 +262,8 @@ struct ixgbe_filter_info {/* Bit mask for every used 5tuple filter */ uint32_t fivetuple_mask[IXGBE_5TUPLE_ARRAY_SIZE ];struct ixgbe_5tuple_filter_list fivetuple_list; +/* store the SYN filter info */ +uint32_t syn_info; };/*
Signature · 1 line
2.5.5
PATCH v5 2/18 net/ixgbe: store flow director filter
In reply to Wei ZhaoAdd support for storing flow director filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 64 ++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 19 ++++++- drivers/net/ixgbe/ixgbe_fdir.c | 105 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 185 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +64 -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,8 @@ 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_fdir_filter_uninit (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);
@@ -1279,6 +1282,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* initialize 5tuple filter list */ TAILQ_INIT (&filter_info->fivetuple_list); +/* initialize flow director filter list & hash */ +ixgbe_fdir_filter_init (eth_dev); +return 0 ; }
@@ -1320,9 +1326,67 @@ 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 */ +ixgbe_fdir_filter_uninit (eth_dev); +return 0 ; } +static int ixgbe_fdir_filter_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); +struct ixgbe_fdir_filter *fdir_filter; + +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
PATCH v5 3/18 net/ixgbe: store L2 tunnel filter
In reply to Wei ZhaoAdd support for storing L2 tunnel filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 172 ++++++++++++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 24 ++++++ 2 files changed, 193 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +169 -3
@@ -168,6 +168,8 @@ 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_fdir_filter_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev); +static int ixgbe_l2_tn_filter_uninit (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);
@@ -1285,6 +1287,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 ; }
@@ -1329,6 +1333,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)/* remove all the fdir filters & hash */ ixgbe_fdir_filter_uninit (eth_dev); +/* remove all the L2 tunnel filters & hash */ +ixgbe_l2_tn_filter_uninit (eth_dev); +return 0 ; }
@@ -1353,6 +1360,27 @@ static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)return 0 ; } +static int ixgbe_l2_tn_filter_uninit (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); +struct ixgbe_l2_tn_filter *l2_tn_filter; + +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 ; +} +static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev) { struct ixgbe_hw_fdir_info *fdir_info =
@@ -1384,6 +1412,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 ; }
@@ -7210,12 +7272,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; + + 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; + + 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; +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 ; +int ret; +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 :
@@ -7227,6 +7381,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; }
@@ -7235,7 +7392,16 @@ static int ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel) { - int ret = 0; + int ret; +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 :
@@ -7261,7 +7427,7 @@ ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,enum rte_filter_op filter_op, void *arg) { - int ret = 0; + int ret;if (filter_op ==RTE_ETH_FILTER_NOP )return 0 ;
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;
@@ -349,6 +370,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
PATCH v5 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 | 140 +++++++++++++++++++++++++-------------- 1 file changed, 92 insertions(+), 48 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +92 -48
@@ -170,6 +170,7 @@ static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);static int ixgbe_fdir_filter_uninit (struct rte_eth_dev *eth_dev);static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev);static int ixgbe_l2_tn_filter_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_ntuple_filter_uninit (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);
@@ -387,6 +388,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
@@ -1336,6 +1338,27 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)/* remove all the L2 tunnel filters & hash */ ixgbe_l2_tn_filter_uninit (eth_dev); +/* Remove all ntuple filters of the device */ +ixgbe_ntuple_filter_uninit (eth_dev); + +return 0 ; +} + +static int ixgbe_ntuple_filter_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (eth_dev->data->dev_private); +struct ixgbe_5tuple_filter *p_5tuple; + +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 ); +return 0 ; }
@@ -2504,6 +2527,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 ;
@@ -2524,9 +2548,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_pci_device *pci_dev =IXGBE_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;int vf;
@@ -2564,17 +2585,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,
@@ -5836,6 +5846,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 *
@@ -5853,13 +5909,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,
@@ -5882,37 +5934,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 ; }
@@ -7925,6 +7948,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 v5 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 | 79 ++++++++++++++++------------------------ drivers/net/ixgbe/ixgbe_ethdev.h | 57 ++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_pf.c | 25 ++++++++----- 3 files changed, 104 insertions(+), 57 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +32 -47
@@ -6259,47 +6259,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,
@@ -6311,6 +6270,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 ;
@@ -6344,18 +6304,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 )
@@ -7961,10 +7925,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
@@ -178,6 +178,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"
@@ -185,16 +186,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 v5 6/18 net/ixgbe: restore TCP SYN filter
In reply to Wei ZhaoAdd support for restoring TCP SYN filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +18 -0
@@ -7945,11 +7945,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 v5 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
@@ -7968,6 +7968,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
@@ -497,6 +497,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 v5 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
@@ -7324,7 +7324,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; struct ixgbe_l2_tn_info *l2_tn_info =
@@ -7332,30 +7333,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) {
@@ -7368,7 +7372,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;
@@ -7429,7 +7433,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
@@ -7962,6 +7967,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) {
@@ -7969,6 +7991,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 v5 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
@@ -389,6 +389,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
@@ -1469,6 +1470,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 ; }
@@ -2527,6 +2531,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 ;
@@ -7083,12 +7088,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 :
@@ -7127,9 +7135,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 :
@@ -7168,9 +7179,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 :
@@ -7477,10 +7491,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 :
@@ -7498,10 +7515,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 :
@@ -7996,6 +8016,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
PATCH v5 10/18 net/ixgbe: flush all the filters
In reply to Wei ZhaoAdd support for flush all the filters in SW.
--- drivers/net/ixgbe/Makefile | 2 + drivers/net/ixgbe/ixgbe_ethdev.c | 79 ++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 16 ++++++ drivers/net/ixgbe/ixgbe_fdir.c | 24 ++++++++ drivers/net/ixgbe/ixgbe_flow.c | 115 +++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_pf.c | 1 + 6 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ixgbe/ixgbe_flow.c
drivers/net/ixgbe/Makefile +2 -0
@@ -109,6 +109,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_fdir.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_pf.c +SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_flow.c ifeq ($(CONFIG_RTE_ARCH_ARM64),y) SRCS-$(CONFIG_RTE_IXGBE_INC_VECTOR) += ixgbe_rxtx_vec_neon.c else
@@ -127,5 +128,6 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_IXGBE_PMD)-include := rte_pmd_ixgbe.h DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_eal lib/librte_ether DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_mempool lib/librte_mbuf DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_net +DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_hash include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ixgbe/ixgbe_ethdev.c +78 -1
106 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_ethdev.h +16 -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; };/*
@@ -501,6 +506,14 @@ 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); + +extern const struct rte_flow_ops ixgbe_flow_ops; + +void ixgbe_clear_all_ethertype_filter (struct rte_eth_dev *dev); +void ixgbe_clear_all_ntuple_filter (struct rte_eth_dev *dev); +void ixgbe_clear_syn_filter (struct rte_eth_dev *dev); +int ixgbe_clear_all_l2_tn_filter (struct rte_eth_dev *dev); static inline int ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
@@ -531,6 +544,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; } }
@@ -547,6 +562,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_flow.c new file +115 -0
115 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_pf.c +1 -0
@@ -199,6 +199,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
PATCH v5 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.
--- drivers/net/ixgbe/ixgbe_flow.c | 429 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 424 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_flow.c +424 -5
@@ -77,15 +77,432 @@static int ixgbe_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error); +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);const struct rte_flow_ops ixgbe_flow_ops = { -NULL , + ixgbe_flow_validate,NULL ,NULL , ixgbe_flow_flush,NULL , }; +#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. +* pattern: +* The first not void item can be ETH or IPV4. +* The second not void item must be IPV4 if the first one is ETH. +* The third not void item must be UDP or TCP. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +*/ +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; + } + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +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) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +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 ; + +/** +* 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; +if (attr->priority <IXGBE_MIN_N_TUPLE_PRIO || + attr->priority >IXGBE_MAX_N_TUPLE_PRIO ) + filter->priority =1 ; + +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,
@@ -99,15 +516,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 v5 11/18] net/ixgbe: parse n-tuple filter
Quoted 6 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]>---
<...>
Quoted 14 lines
/* Destroy all flow rules associated with a port on ixgbe. */ static int
ixgbe_flow_flush(structrte_eth_dev*dev,drivers/net/ixgbe/ixgbe_flow.c +3
-2@@ -99,15 +516,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; }
drivers/net/ixgbe/ixgbe_flow.c ixgbe_flow_flush(struct rte_eth_dev *dev, · line 531
Quoted 10 lines
drivers/net/ixgbe/ixgbe_flow.c +3
-2ret =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; }
These are syntax modification to the updates added in previous patch. They can be fixed when they added at first place.
PATCH v5 12/18 net/ixgbe: parse ethertype filter
In reply to Wei Zhaocheck if the rule is a ethertype rule, and get the ethertype info.
--- drivers/net/ixgbe/ixgbe_flow.c | 278 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+)
drivers/net/ixgbe/ixgbe_flow.c +278 -0
@@ -90,6 +90,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[],
@@ -480,6 +492,265 @@ 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. +* pattern: +* The first not void item can be ETH. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +*/ +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; + } + +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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 ) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"queue index much too big" ); +return -rte_errno; + } + +if (filter->ether_type == ETHER_TYPE_IPv4 || + filter->ether_type == ETHER_TYPE_IPv6) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"IPv4/IPv6 not supported by ethertype filter" ); +return -rte_errno; + } + +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 ,"mac compare is unsupported" ); +return -rte_errno; + } + +if (filter->flags &RTE_ETHTYPE_FLAGS_DROP ) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"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.
@@ -492,6 +763,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 ));
@@ -500,6 +772,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 v5 12/18] net/ixgbe: parse ethertype filter
Quoted 13 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]>--- drivers/net/ixgbe/ixgbe_flow.c | 278 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+)drivers/net/ixgbe/ixgbe_flow.c +0
-0
drivers/net/ixgbe/ixgbe_flow.c ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 93
Quoted 4 lines
drivers/net/ixgbe/ixgbe_flow.c +1
-0@@ -90,6 +90,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,
Although this is static function, you may prefer to keep ixgbe_ namespace in the function.
Quoted 15 lines
drivers/net/ixgbe/ixgbe_flow.c +11
-0+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[],
drivers/net/ixgbe/ixgbe_flow.c ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 499
Quoted 8 lines
drivers/net/ixgbe/ixgbe_flow.c +5
-0@@ -480,6 +492,265 @@ 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. +* pattern: +* The first not void item can be ETH. +* The next not void item must be END.
This documents item.type, can you please also document expected/valid item->spec, item->last and item->mask values.
Same for all parse functions.
I am aware this is lots of comment when you think all parse functions, but I believe this can be very useful in the future.
And it is very unlikely that it will be done later, if it has not been done now.
Thanks,
ferruh
Quoted 10 lines
drivers/net/ixgbe/ixgbe_flow.c +10
-0+* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +*/ +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)
<...>
PATCH v5 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.
--- drivers/net/ixgbe/ixgbe_flow.c | 264 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 264 insertions(+)
drivers/net/ixgbe/ixgbe_flow.c +264 -0
@@ -102,6 +102,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[],
@@ -751,6 +763,251 @@ 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. +* pattern: +* The first not void item must be ETH. +* The second not void item must be IPV4 or IPV6. +* The third not void item must be TCP. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +*/ +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; + } + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } + +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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 ; + +/* 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.
@@ -764,6 +1021,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 ));
@@ -778,6 +1036,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
PATCH v5 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.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 203 +++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 253 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
@@ -8089,7 +8089,8 @@ ixgbe_clear_syn_filter(struct rte_eth_dev *dev) }/* remove all the L2 tunnel filters */ -int ixgbe_clear_all_l2_tn_filter (struct rte_eth_dev *dev) +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);
drivers/net/ixgbe/ixgbe_flow.c +203 -0
227 lines not on this page · raw message
lib/librte_ether/rte_flow.h +48 -0
60 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v5 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.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 2 + drivers/net/ixgbe/ixgbe_ethdev.h | 16 + drivers/net/ixgbe/ixgbe_fdir.c | 253 +++++--- drivers/net/ixgbe/ixgbe_flow.c | 1218 +++++++++++++++++++++++++++++++++++++- 4 files changed, 1380 insertions(+), 109 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +2 -0
@@ -1436,6 +1436,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 ; }
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 */
@@ -479,6 +491,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 +170 -83
473 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_flow.c +1192 -26
1,237 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v5 16/18 net/ixgbe: create consistent filter
In reply to Wei ZhaoThis patch adds a function to create the flow directory filter.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 25 +++-- drivers/net/ixgbe/ixgbe_ethdev.h | 61 ++++++++++++ drivers/net/ixgbe/ixgbe_flow.c | 194 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 266 insertions(+), 14 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +12 -13
@@ -305,9 +305,6 @@ static void ixgbevf_add_mac_addr(struct rte_eth_dev *dev,static void ixgbevf_remove_mac_addr (struct rte_eth_dev *dev,uint32_t index);static void ixgbevf_set_default_mac_addr (struct rte_eth_dev *dev,struct ether_addr *mac_addr); -static int ixgbe_syn_filter_set (struct rte_eth_dev *dev, -struct rte_eth_syn_filter *filter, -bool add);static int ixgbe_syn_filter_get (struct rte_eth_dev *dev,struct rte_eth_syn_filter *filter); static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
@@ -317,17 +314,11 @@ static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev, struct ixgbe_5tuple_filter *filter);static void ixgbe_remove_5tuple_filter (struct rte_eth_dev *dev,struct ixgbe_5tuple_filter *filter); -static int ixgbe_add_del_ntuple_filter (struct rte_eth_dev *dev, -struct rte_eth_ntuple_filter *filter, -bool add);static int ixgbe_ntuple_filter_handle (struct rte_eth_dev *dev,enum rte_filter_op filter_op,void *arg);static int ixgbe_get_ntuple_filter (struct rte_eth_dev *dev,struct rte_eth_ntuple_filter *filter); -static int ixgbe_add_del_ethertype_filter (struct rte_eth_dev *dev, -struct rte_eth_ethertype_filter *filter, -bool add);static int ixgbe_ethertype_filter_handle (struct rte_eth_dev *dev,enum rte_filter_op filter_op,void *arg);
@@ -1292,6 +1283,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 ; }
@@ -5742,7 +5741,7 @@ ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)return -ENOTSUP ;\ }while (0 ) -static int +int ixgbe_syn_filter_set(struct rte_eth_dev *dev, struct rte_eth_syn_filter *filter, bool add)
@@ -6121,7 +6120,7 @@ ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,* - On success, zero. * - On failure, a negative value. */ -static int +int ixgbe_add_del_ntuple_filter (struct rte_eth_dev *dev,struct rte_eth_ntuple_filter *ntuple_filter,bool add)
@@ -6266,7 +6265,7 @@ ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,return ret; } -static int +int ixgbe_add_del_ethertype_filter (struct rte_eth_dev *dev,struct rte_eth_ethertype_filter *filter,bool add)
@@ -7345,7 +7344,7 @@ ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info, }/* Add l2 tunnel filter */ -static int +int ixgbe_dev_l2_tunnel_filter_add (struct rte_eth_dev *dev,struct rte_eth_l2_tunnel_conf *l2_tunnel,bool restore)
drivers/net/ixgbe/ixgbe_ethdev.h +61 -0
73 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_flow.c +193 -1
209 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v5 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 v5 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 67 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Thursday, January 12, 2017 5:17 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v5 00/18] net/ixgbe: Consistent filter APIThe 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.v2 changes:
fix git log error
Modify some function call relationship
Change return value type of all parse flow functions Update error info for all
flow ops Addixgbe_filterlist_flushto flush flows and rules createdv3 change:
add new fileixgbe_flow.cto store generic API parser related functions add
more comment about pattern and action rules add attr check in parser functions change struct nameixgbe_flowtorte_flowchange SYN to TCP SYN change to use memset initizlize structixgbe_filter_infobreak down filter uninit process to 3 indepedent functions ineth_ixgbe_dev_uninit()change structrte_flow_item_nvgredefinition change structrte_flow_item_e_tagdefinition fix one bug in functionixgbe_dev_filter_ctrladd goto in functionixgbe_flow_createdelete some useless initialization eliminate some git log check warningv4 change:
fix some check patch warningv5 change:
fix some git log warningzhao 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 listdrivers/net/ixgbe/Makefile | 2 + drivers/net/ixgbe/ixgbe_ethdev.c | 667 +++++++-- drivers/net/ixgbe/ixgbe_ethdev.h | 203 ++- drivers/net/ixgbe/ixgbe_fdir.c | 407 ++++-- drivers/net/ixgbe/ixgbe_flow.c | 2808 ++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_pf.c | 26 +- lib/librte_ether/rte_flow.h | 48 + 7 files changed, 3950 insertions(+), 211 deletions(-) create mode 100644
Quoted 2 lines
drivers/net/ixgbe/ixgbe_flow.c
Dai, Wei
Acked-byQuoted 76 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xing, Beilei
Sent: Thursday, January 12, 2017 7:39 PM
To: Zhao1, Wei <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v5 00/18] net/ixgbe: Consistent filter APIQuoted 67 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Zhao
Sent: Thursday, January 12, 2017 5:17 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v5 00/18] net/ixgbe: Consistent filter APIThe 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.v2 changes:
fix git log error
Modify some function call relationship Change return value type of
all parse flow functions Update error info for all flow ops Addixgbe_filterlist_flushto flush flows and rules createdv3 change:
add new fileixgbe_flow.cto store generic API parser related
functions add more comment about pattern and action rules add attr check in parser functions change struct nameixgbe_flowtorte_flowchange SYN to TCP SYN change to use memset initizlize structixgbe_filter_infobreak down filter uninit process to 3 indepedent functions ineth_ixgbe_dev_uninit()change structrte_flow_item_nvgredefinition change structrte_flow_item_e_tagdefinition fix one bug in functionixgbe_dev_filter_ctrladd goto in functionixgbe_flow_createdelete some useless initialization eliminate some git log check warningv4 change:
fix some check patch warningv5 change:
fix some git log warningzhao 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 listdrivers/net/ixgbe/Makefile | 2 + drivers/net/ixgbe/ixgbe_ethdev.c | 667 +++++++-- drivers/net/ixgbe/ixgbe_ethdev.h | 203 ++- drivers/net/ixgbe/ixgbe_fdir.c | 407 ++++-- drivers/net/ixgbe/ixgbe_flow.c | 2808 ++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_pf.c | 26 +- lib/librte_ether/rte_flow.h | 48 + 7 files changed, 3950 insertions(+), 211 deletions(-) create modeQuoted 2 lines
100644
drivers/net/ixgbe/ixgbe_flow.c
Quoted 1 line
Acked-by Beilei Xing <[email protected]>
Hi Wei,
Quoted 7 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.
Overall patchset looks good, only major comment is adding more comments on parse_filter functions for expected/valid rules.
You can keep Beilei's Ack for next version of the patchset.
Thanks,
ferruh
v6 cover net/ixgbe: Consistent filter API
In reply to Wei ZhaoThe 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.
v2 changes:
fix git log error
Modify some function call relationship
Change return value type of all parse flow functions Update error info for all flow ops
Add ixgbe_filterlist_flush to flush flows and rules created
v3 change:
add new file ixgbe_flow.c to store generic API parser related functions add more comment about pattern and action rules
add attr check in parser functions
change struct name ixgbe_flow to rte_flow
change SYN to TCP SYN
change to use memset initizlize struct ixgbe_filter_info
break down filter uninit process to 3 indepedent functions in eth_ixgbe_dev_uninit() change struct rte_flow_item_nvgre definition
change struct rte_flow_item_e_tag definition
fix one bug in function ixgbe_dev_filter_ctrl
add goto in function ixgbe_flow_create
delete some useless initialization
eliminate some git log check warning
v4 change:
fix some check patch warning
v5 change:
fix some git log warning
v6 change:
add more comments on pattern rule example, supply the usage of spec last and mask
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
drivers/net/ixgbe/Makefile | 2 + drivers/net/ixgbe/ixgbe_ethdev.c | 667 +++++++-- drivers/net/ixgbe/ixgbe_ethdev.h | 203 ++- drivers/net/ixgbe/ixgbe_fdir.c | 407 ++++-- drivers/net/ixgbe/ixgbe_flow.c | 2878 ++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_pf.c | 26 +- lib/librte_ether/rte_flow.h | 48 + 7 files changed, 4020 insertions(+), 211 deletions(-) create mode 100644 drivers/net/ixgbe/ixgbe_flow.c
Signature · 1 line
2.5.5
PATCH v6 1/18 net/ixgbe: store TCP SYN filter
Add support for storing TCP SYN filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 18 +++++++++++++----- drivers/net/ixgbe/ixgbe_ethdev.h | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +13 -5
@@ -1272,10 +1272,12 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* enable support intr */ ixgbe_enable_intr (eth_dev); +/* initialize filter info */ +memset (filter_info,0 , +sizeof (struct ixgbe_filter_info )); +/* initialize 5tuple filter list */ TAILQ_INIT (&filter_info->fivetuple_list); -memset (filter_info->fivetuple_mask,0 , -sizeof (uint32_t ) *IXGBE_5TUPLE_ARRAY_SIZE );return 0 ; }
@@ -5603,15 +5605,18 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev, bool add) {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 syn_info;uint32_t synqf;if (filter->queue >=IXGBE_MAX_RX_QUEUE_NUM )return -EINVAL ; - synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); + syn_info = filter_info->syn_info;if (add) { -if (synqf &IXGBE_SYN_FILTER_ENABLE ) +if (syn_info &IXGBE_SYN_FILTER_ENABLE )return -EINVAL ; synqf = (uint32_t )(((filter->queue <<IXGBE_SYN_FILTER_QUEUE_SHIFT ) &IXGBE_SYN_FILTER_QUEUE ) |IXGBE_SYN_FILTER_ENABLE );
@@ -5621,10 +5626,13 @@ ixgbe_syn_filter_set(struct rte_eth_dev *dev,else synqf &= ~IXGBE_SYN_FILTER_SYNQFP ; }else { -if (!(synqf &IXGBE_SYN_FILTER_ENABLE )) + synqf =IXGBE_READ_REG (hw,IXGBE_SYNQF ); +if (!(syn_info &IXGBE_SYN_FILTER_ENABLE ))return -ENOENT ; synqf &= ~(IXGBE_SYN_FILTER_QUEUE |IXGBE_SYN_FILTER_ENABLE ); } + + filter_info->syn_info = synqf;IXGBE_WRITE_REG (hw,IXGBE_SYNQF , synqf);IXGBE_WRITE_FLUSH (hw);return 0 ;
drivers/net/ixgbe/ixgbe_ethdev.h +2 -0
@@ -262,6 +262,8 @@ struct ixgbe_filter_info {/* Bit mask for every used 5tuple filter */ uint32_t fivetuple_mask[IXGBE_5TUPLE_ARRAY_SIZE ];struct ixgbe_5tuple_filter_list fivetuple_list; +/* store the SYN filter info */ +uint32_t syn_info; };/*
Signature · 1 line
2.5.5
PATCH v6 2/18 net/ixgbe: store flow director filter
In reply to Wei ZhaoAdd support for storing flow director filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 64 ++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 19 ++++++- drivers/net/ixgbe/ixgbe_fdir.c | 105 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 185 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +64 -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,8 @@ 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_fdir_filter_uninit (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);
@@ -1279,6 +1282,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)/* initialize 5tuple filter list */ TAILQ_INIT (&filter_info->fivetuple_list); +/* initialize flow director filter list & hash */ +ixgbe_fdir_filter_init (eth_dev); +return 0 ; }
@@ -1320,9 +1326,67 @@ 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 */ +ixgbe_fdir_filter_uninit (eth_dev); +return 0 ; } +static int ixgbe_fdir_filter_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); +struct ixgbe_fdir_filter *fdir_filter; + +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
PATCH v6 3/18 net/ixgbe: store L2 tunnel filter
In reply to Wei ZhaoAdd support for storing L2 tunnel filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 172 ++++++++++++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 24 ++++++ 2 files changed, 193 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +169 -3
@@ -168,6 +168,8 @@ 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_fdir_filter_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev); +static int ixgbe_l2_tn_filter_uninit (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);
@@ -1285,6 +1287,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 ; }
@@ -1329,6 +1333,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)/* remove all the fdir filters & hash */ ixgbe_fdir_filter_uninit (eth_dev); +/* remove all the L2 tunnel filters & hash */ +ixgbe_l2_tn_filter_uninit (eth_dev); +return 0 ; }
@@ -1353,6 +1360,27 @@ static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)return 0 ; } +static int ixgbe_l2_tn_filter_uninit (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); +struct ixgbe_l2_tn_filter *l2_tn_filter; + +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 ; +} +static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev) { struct ixgbe_hw_fdir_info *fdir_info =
@@ -1384,6 +1412,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 ; }
@@ -7210,12 +7272,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; + + 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; + + 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; +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 ; +int ret; +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 :
@@ -7227,6 +7381,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; }
@@ -7235,7 +7392,16 @@ static int ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel) { - int ret = 0; + int ret; +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 :
@@ -7261,7 +7427,7 @@ ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,enum rte_filter_op filter_op, void *arg) { - int ret = 0; + int ret;if (filter_op ==RTE_ETH_FILTER_NOP )return 0 ;
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;
@@ -349,6 +370,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
PATCH v6 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 | 140 +++++++++++++++++++++++++-------------- 1 file changed, 92 insertions(+), 48 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +92 -48
@@ -170,6 +170,7 @@ static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);static int ixgbe_fdir_filter_uninit (struct rte_eth_dev *eth_dev);static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev);static int ixgbe_l2_tn_filter_uninit (struct rte_eth_dev *eth_dev); +static int ixgbe_ntuple_filter_uninit (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);
@@ -387,6 +388,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
@@ -1336,6 +1338,27 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)/* remove all the L2 tunnel filters & hash */ ixgbe_l2_tn_filter_uninit (eth_dev); +/* Remove all ntuple filters of the device */ +ixgbe_ntuple_filter_uninit (eth_dev); + +return 0 ; +} + +static int ixgbe_ntuple_filter_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_filter_info *filter_info = +IXGBE_DEV_PRIVATE_TO_FILTER_INFO (eth_dev->data->dev_private); +struct ixgbe_5tuple_filter *p_5tuple; + +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 ); +return 0 ; }
@@ -2504,6 +2527,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 ;
@@ -2524,9 +2548,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_pci_device *pci_dev =IXGBE_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;int vf;
@@ -2564,17 +2585,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,
@@ -5836,6 +5846,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 *
@@ -5853,13 +5909,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,
@@ -5882,37 +5934,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 ; }
@@ -7925,6 +7948,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 v6 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 | 79 ++++++++++++++++------------------------ drivers/net/ixgbe/ixgbe_ethdev.h | 57 ++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_pf.c | 25 ++++++++----- 3 files changed, 104 insertions(+), 57 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +32 -47
@@ -6259,47 +6259,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,
@@ -6311,6 +6270,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 ;
@@ -6344,18 +6304,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 )
@@ -7961,10 +7925,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
@@ -178,6 +178,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"
@@ -185,16 +186,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 v6 6/18 net/ixgbe: restore TCP SYN filter
In reply to Wei ZhaoAdd support for restoring TCP SYN filter in SW.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +18 -0
@@ -7945,11 +7945,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 v6 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
@@ -7968,6 +7968,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
@@ -497,6 +497,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 v6 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
@@ -7324,7 +7324,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; struct ixgbe_l2_tn_info *l2_tn_info =
@@ -7332,30 +7333,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) {
@@ -7368,7 +7372,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;
@@ -7429,7 +7433,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
@@ -7962,6 +7967,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) {
@@ -7969,6 +7991,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 v6 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
@@ -389,6 +389,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
@@ -1469,6 +1470,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 ; }
@@ -2527,6 +2531,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 ;
@@ -7083,12 +7088,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 :
@@ -7127,9 +7135,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 :
@@ -7168,9 +7179,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 :
@@ -7477,10 +7491,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 :
@@ -7498,10 +7515,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 :
@@ -7996,6 +8016,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
PATCH v6 10/18 net/ixgbe: flush all the filters
In reply to Wei ZhaoAdd support for flush all the filters in SW.
--- drivers/net/ixgbe/Makefile | 2 + drivers/net/ixgbe/ixgbe_ethdev.c | 79 ++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_ethdev.h | 16 ++++++ drivers/net/ixgbe/ixgbe_fdir.c | 24 ++++++++ drivers/net/ixgbe/ixgbe_flow.c | 115 +++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_pf.c | 1 + 6 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ixgbe/ixgbe_flow.c
drivers/net/ixgbe/Makefile +2 -0
@@ -109,6 +109,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_fdir.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_pf.c +SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_flow.c ifeq ($(CONFIG_RTE_ARCH_ARM64),y) SRCS-$(CONFIG_RTE_IXGBE_INC_VECTOR) += ixgbe_rxtx_vec_neon.c else
@@ -127,5 +128,6 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_IXGBE_PMD)-include := rte_pmd_ixgbe.h DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_eal lib/librte_ether DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_mempool lib/librte_mbuf DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_net +DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_hash include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ixgbe/ixgbe_ethdev.c +78 -1
106 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_ethdev.h +16 -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; };/*
@@ -501,6 +506,14 @@ 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); + +extern const struct rte_flow_ops ixgbe_flow_ops; + +void ixgbe_clear_all_ethertype_filter (struct rte_eth_dev *dev); +void ixgbe_clear_all_ntuple_filter (struct rte_eth_dev *dev); +void ixgbe_clear_syn_filter (struct rte_eth_dev *dev); +int ixgbe_clear_all_l2_tn_filter (struct rte_eth_dev *dev); static inline int ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
@@ -531,6 +544,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; } }
@@ -547,6 +562,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_flow.c new file +115 -0
115 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_pf.c +1 -0
@@ -199,6 +199,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
PATCH v6 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.
--- drivers/net/ixgbe/ixgbe_flow.c | 430 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 429 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_flow.c +429 -1
@@ -77,15 +77,443 @@static int ixgbe_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error); +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);const struct rte_flow_ops ixgbe_flow_ops = { -NULL , + ixgbe_flow_validate,NULL ,NULL , ixgbe_flow_flush,NULL , }; +#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. +* pattern: +* The first not void item can be ETH or IPV4. +* The second not void item must be IPV4 if the first one is ETH. +* The third not void item must be UDP or TCP. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +* pattern example: +* ITEM Spec Mask +* ETH NULL NULL +* IPV4 src_addr 192.168.1.20 0xFFFFFFFF +* dst_addr 192.167.3.50 0xFFFFFFFF +* next_proto_id 17 0xFF +* UDP/TCP src_port 80 0xFFFF +* dst_port 80 0xFFFF +* END +* other members in mask and spec should set to 0x00. +* item->last should be NULL. +*/ +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; + } + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +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) { +memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); +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 ; + +/** +* 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; +if (attr->priority <IXGBE_MIN_N_TUPLE_PRIO || + attr->priority >IXGBE_MAX_N_TUPLE_PRIO ) + filter->priority =1 ; + +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,
Signature · 1 line
2.5.5
PATCH v6 12/18 net/ixgbe: parse ethertype filter
In reply to Wei Zhaocheck if the rule is a ethertype rule, and get the ethertype info.
--- drivers/net/ixgbe/ixgbe_flow.c | 284 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 284 insertions(+)
drivers/net/ixgbe/ixgbe_flow.c +284 -0
@@ -90,6 +90,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[],
@@ -491,6 +503,271 @@ 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. +* pattern: +* The first not void item can be ETH. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +* pattern example: +* ITEM Spec Mask +* ETH type 0x0807 0xFFFF +* END +* other members in mask and spec should set to 0x00. +* item->last should be NULL. +*/ +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; + } + +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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 ) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"queue index much too big" ); +return -rte_errno; + } + +if (filter->ether_type == ETHER_TYPE_IPv4 || + filter->ether_type == ETHER_TYPE_IPv6) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"IPv4/IPv6 not supported by ethertype filter" ); +return -rte_errno; + } + +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 ,"mac compare is unsupported" ); +return -rte_errno; + } + +if (filter->flags &RTE_ETHTYPE_FLAGS_DROP ) { +memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"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.
@@ -503,6 +780,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 ));
@@ -511,6 +789,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
PATCH v6 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.
--- drivers/net/ixgbe/ixgbe_flow.c | 272 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 272 insertions(+)
drivers/net/ixgbe/ixgbe_flow.c +272 -0
@@ -102,6 +102,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[],
@@ -768,6 +780,259 @@ 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. +* pattern: +* The first not void item must be ETH. +* The second not void item must be IPV4 or IPV6. +* The third not void item must be TCP. +* The next not void item must be END. +* action: +* The first not void action should be QUEUE. +* The next not void action should be END. +* pattern example: +* ITEM Spec Mask +* ETH NULL NULL +* IPV4/IPV6 NULL NULL +* TCP tcp_flags 0x02 0xFF +* END +* other members in mask and spec should set to 0x00. +* item->last should be NULL. +*/ +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; + } + +if (!actions) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } + +if (!attr) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +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 ; + +/* 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.
@@ -781,6 +1046,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 ));
@@ -795,6 +1061,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
PATCH v6 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.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 216 +++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 266 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
@@ -8089,7 +8089,8 @@ ixgbe_clear_syn_filter(struct rte_eth_dev *dev) }/* remove all the L2 tunnel filters */ -int ixgbe_clear_all_l2_tn_filter (struct rte_eth_dev *dev) +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);
drivers/net/ixgbe/ixgbe_flow.c +216 -0
240 lines not on this page · raw message
lib/librte_ether/rte_flow.h +48 -0
60 lines not on this page · raw message
Signature · 1 line
2.5.5
Re: [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filter
Quoted 11 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]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 216 +++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 266 insertions(+), 1 deletion(-)<...>
Hi Adrien,
Can you please review rte_flow related part of the patch below?
I am OK with rest of the patch, and planning to apply to next-net if you don't have any objection.
Thanks,
ferruh
Quoted 68 lines
lib/librte_ether/rte_flow.h +48
-0@@ -268,6 +268,20 @@ 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 , + +/** +* Matches a NVGRE header. +* +* See struct rte_flow_item_nvgre. +*/ + RTE_FLOW_ITEM_TYPE_NVGRE, };/** @@ -454,6 +468,40 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +uint16_t tpid;/**< Tag protocol identifier (0x893F). */ +/** E-Tag control information (E-TCI). */ +/**< E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */ +uint16_t epcp_edei_in_ecid_b; +/**< Reserved (2b), GRP (2b), E-CID base (12b). */ +uint16_t rsvd_grp_ecid_b; +uint8_t in_ecid_e;/**< Ingress E-CID ext. */ +uint8_t ecid_e;/**< E-CID ext. */ +}; + +/** +* RTE_FLOW_ITEM_TYPE_NVGRE. +* +* Matches a NVGRE header. +*/ +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 protocol;/**< Protocol type (0x6558). */ +uint8_t tni[3 ];/**< Virtual subnet ID. */ +uint8_t flow_id;/**< Flow ID. */ +}; + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol
Re: [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filter
In reply to Wei ZhaoHi,
Quoted 9 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]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 216 +++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 266 insertions(+), 1 deletion(-)
[...]
Quoted 69 lines
lib/librte_ether/rte_flow.h +48
-0@@ -268,6 +268,20 @@ 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 , + +/** +* Matches a NVGRE header. +* +* See struct rte_flow_item_nvgre. +*/ + RTE_FLOW_ITEM_TYPE_NVGRE, };/** @@ -454,6 +468,40 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +uint16_t tpid;/**< Tag protocol identifier (0x893F). */ +/** E-Tag control information (E-TCI). */ +/**< E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */ +uint16_t epcp_edei_in_ecid_b; +/**< Reserved (2b), GRP (2b), E-CID base (12b). */ +uint16_t rsvd_grp_ecid_b; +uint8_t in_ecid_e;/**< Ingress E-CID ext. */ +uint8_t ecid_e;/**< E-CID ext. */ +}; + +/** +* RTE_FLOW_ITEM_TYPE_NVGRE. +* +* Matches a NVGRE header. +*/ +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 protocol;/**< Protocol type (0x6558). */ +uint8_t tni[3 ];/**< Virtual subnet ID. */ +uint8_t flow_id;/**< Flow ID. */ +}; + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol Signature · 1 line
2.5.5
OK for these definitions, however API documentation (doc/guides/prog_guide/rte_flow.rst) must be kept up to date, and it would be great if testpmd support for these new items was added simultaneously (changes in app/test-pmd/cmdline.c, app/test-pmd/cmdline_flow.c and doc/guides/testpmd_app_ug/testpmd_funcs.rst).
How about putting all rte_flow changes (API & testpmd) in their own separate patch?
You could use VLAN PCP/DEI/VID definitions as an example to expose partial bit-fields (e.g. epcp_edei_in_ecid_b) in testpmd, see:
1419fd5a6c9f ("app/testpmd: add protocol fields to flow command")
Now if re-spinning this series yet again is too much work, you can go ahead with this commit as long as you do not forget to submit the rest later, thanks.
Signature · 2 lines
Adrien Mazarguil 6WIND
Re: [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filter
Quoted 89 lines · Adrien Mazarguil
Hi,
Quoted 9 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]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 216 +++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 266 insertions(+), 1 deletion(-)[...]
Quoted 69 lines
lib/librte_ether/rte_flow.h +48
-0@@ -268,6 +268,20 @@ 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 , + +/** +* Matches a NVGRE header. +* +* See struct rte_flow_item_nvgre. +*/ + RTE_FLOW_ITEM_TYPE_NVGRE, };/** @@ -454,6 +468,40 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +uint16_t tpid;/**< Tag protocol identifier (0x893F). */ +/** E-Tag control information (E-TCI). */ +/**< E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */ +uint16_t epcp_edei_in_ecid_b; +/**< Reserved (2b), GRP (2b), E-CID base (12b). */ +uint16_t rsvd_grp_ecid_b; +uint8_t in_ecid_e;/**< Ingress E-CID ext. */ +uint8_t ecid_e;/**< E-CID ext. */ +}; + +/** +* RTE_FLOW_ITEM_TYPE_NVGRE. +* +* Matches a NVGRE header. +*/ +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 protocol;/**< Protocol type (0x6558). */ +uint8_t tni[3 ];/**< Virtual subnet ID. */ +uint8_t flow_id;/**< Flow ID. */ +}; + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol Signature · 1 line
2.5.5OK for these definitions, however API documentation (
doc/guides/prog_guide/rte_flow.rst) must be kept up to date, and it would be great if testpmd support for these new items was added simultaneously (changes inapp/test-pmd/cmdline.c,app/test-pmd/cmdline_flow.canddoc/guides/testpmd_app_ug/testpmd_funcs.rst).
Quoted 2 lines
How about putting all
rte_flowchanges (API & testpmd) in their own separate patch?
I thought it can be more useful to have library and its user updated in same patch, gives more context. But missed rte_flow documentation ...
Quoted 10 lines
You could use VLAN PCP/DEI/VID definitions as an example to expose partial bit-fields (e.g.
epcp_edei_in_ecid_b) in testpmd, see:
1419fd5a6c9f("app/testpmd: add protocol fields to flow command")Now if re-spinning this series yet again is too much work, you can go ahead with this commit as long as you do not forget to submit the rest later, thanks.
Is following todo list complete:
1- update rte_flow document, doc/guides/prog_guide/rte_flow.rst, document two new item types: E_TAG & NVGRE.
2- Add testpmd sample implementation and documentation.
Hi Wei,
Would you mind working on a patch to cover above items?
Thanks,
ferruh
Re: [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filter
Quoted 90 lines · Ferruh Yigit
Quoted 89 lines · Adrien Mazarguil
Hi,
Quoted 9 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]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 216 +++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 266 insertions(+), 1 deletion(-)[...]
Quoted 69 lines
lib/librte_ether/rte_flow.h +48
-0@@ -268,6 +268,20 @@ 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 , + +/** +* Matches a NVGRE header. +* +* See struct rte_flow_item_nvgre. +*/ + RTE_FLOW_ITEM_TYPE_NVGRE, };/** @@ -454,6 +468,40 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +uint16_t tpid;/**< Tag protocol identifier (0x893F). */ +/** E-Tag control information (E-TCI). */ +/**< E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */ +uint16_t epcp_edei_in_ecid_b; +/**< Reserved (2b), GRP (2b), E-CID base (12b). */ +uint16_t rsvd_grp_ecid_b; +uint8_t in_ecid_e;/**< Ingress E-CID ext. */ +uint8_t ecid_e;/**< E-CID ext. */ +}; + +/** +* RTE_FLOW_ITEM_TYPE_NVGRE. +* +* Matches a NVGRE header. +*/ +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 protocol;/**< Protocol type (0x6558). */ +uint8_t tni[3 ];/**< Virtual subnet ID. */ +uint8_t flow_id;/**< Flow ID. */ +}; + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol Signature · 1 line
2.5.5OK for these definitions, however API documentation (
doc/guides/prog_guide/rte_flow.rst) must be kept up to date, and it would be great if testpmd support for these new items was added simultaneously (changes inapp/test-pmd/cmdline.c,app/test-pmd/cmdline_flow.canddoc/guides/testpmd_app_ug/testpmd_funcs.rst).
Quoted 5 lines
Quoted 2 lines
How about putting all
rte_flowchanges (API & testpmd) in their own separate patch?I thought it can be more useful to have library and its user updated in same patch, gives more context. But missed
rte_flowdocumentation ...
Not much of an issue as long as it's updated, also I did not notice the series was already applied before replying.
Quoted 10 lines
Quoted 9 lines
You could use VLAN PCP/DEI/VID definitions as an example to expose partial bit-fields (e.g.
epcp_edei_in_ecid_b) in testpmd, see:
1419fd5a6c9f("app/testpmd: add protocol fields to flow command")Now if re-spinning this series yet again is too much work, you can go ahead with this commit as long as you do not forget to submit the rest later, thanks.
Quoted 5 lines
Is following todo list complete:
1- updaterte_flowdocument,doc/guides/prog_guide/rte_flow.rst, document two new item types:E_TAG& NVGRE.2- Add testpmd sample implementation and documentation.
Right, everything at once in a single patch is fine. The existing item definitions and testpmd commands can be used as templates.
Thanks.
Quoted 7 lines
Hi Wei,
Would you mind working on a patch to cover above items?
Thanks,
ferruh
Signature · 2 lines
Adrien Mazarguil 6WIND
Re: [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filter
In reply to Ferruh YigitHi, Ferruh
Quoted 117 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, January 17, 2017 12:39 AM
To: Adrien Mazarguil <[email protected]>; Zhao1, Wei <[email protected]>
Cc: [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filterQuoted 10 lines · Adrien Mazarguil
Hi,
Quoted 7 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]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 216+++++++++++++++++++++++++++++++++++++++
Quoted 70 lines
Quoted 2 lines
lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 266 insertions(+), 1 deletion(-)[...]
Quoted 67 lines
(quoted diff) +0
-0
b/lib/librte_ether/rte_flow.hindex 98084ac..7142479 100644lib/librte_ether/rte_flow.h +48
-0@@ -268,6 +268,20 @@ 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 , + +/** +* Matches a NVGRE header. +* +* See struct rte_flow_item_nvgre. +*/ + RTE_FLOW_ITEM_TYPE_NVGRE, };/** @@ -454,6 +468,40 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +uint16_t tpid;/**< Tag protocol identifier (0x893F). */ +/** E-Tag control information (E-TCI). */ +/**< E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */ +uint16_t epcp_edei_in_ecid_b; +/**< Reserved (2b), GRP (2b), E-CID base (12b). */ +uint16_t rsvd_grp_ecid_b; +uint8_t in_ecid_e;/**< Ingress E-CID ext. */ +uint8_t ecid_e;/**< E-CID ext. */ +}; + +/** +* RTE_FLOW_ITEM_TYPE_NVGRE. +* +* Matches a NVGRE header. +*/ +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 protocol;/**< Protocol type (0x6558). */ +uint8_t tni[3 ];/**< Virtual subnet ID. */ +uint8_t flow_id;/**< Flow ID. */ +}; + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol
--Quoted 8 lines
Quoted 2 lines
2.5.5
OK for these definitions, however API documentation (
doc/guides/prog_guide/rte_flow.rst) must be kept up to date, and it would be great if testpmd support for these new items was added simultaneously (changes inapp/test-pmd/cmdline.c,app/test-pmd/cmdline_flow.cand
doc/guides/testpmd_app_ug/testpmd_funcs.rst).Quoted 3 lines
How about putting all
rte_flowchanges (API & testpmd) in their own separate patch?I thought it can be more useful to have library and its user updated in same patch, gives more context. But missed
rte_flowdocumentation ...Quoted 10 lines
You could use VLAN PCP/DEI/VID definitions as an example to expose partial bit-fields (e.g.
epcp_edei_in_ecid_b) in testpmd, see:
1419fd5a6c9f("app/testpmd: add protocol fields to flow command")Now if re-spinning this series yet again is too much work, you can go ahead with this commit as long as you do not forget to submit the rest later, thanks.
Quoted 6 lines
Is following todo list complete:
1- updaterte_flowdocument,doc/guides/prog_guide/rte_flow.rst, document two new item types:E_TAG& NVGRE.2- Add testpmd sample implementation and documentation.
I am sorry for miss rte_flow.rst document update, I DON'T know there is such a new file of rte_flow.rst. And also these two types of E_TAG & NVGRE are added into code after rte_flow patch,
So testpmd implementation do not support for these type.
Now, we have been work on task of 17.05.
How about finish (1) first as one patch, then after busy work of 17.05 to add (2) as another patch?
OR, if these two work merge in to patch set, I will may be begin to do after the 17.05 task finish?
Which one is OK for you?
Thank you.
Quoted 7 lines
Hi Wei,
Would you mind working on a patch to cover above items?
Thanks,
ferruh
Re: [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filter
Quoted 126 lines · Wei
Hi, Ferruh
Quoted 117 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, January 17, 2017 12:39 AM
To: Adrien Mazarguil <[email protected]>; Zhao1, Wei <[email protected]>
Cc: [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filterQuoted 10 lines · Adrien Mazarguil
Hi,
Quoted 7 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]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 216+++++++++++++++++++++++++++++++++++++++
Quoted 70 lines
Quoted 2 lines
lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 266 insertions(+), 1 deletion(-)[...]
Quoted 67 lines
(quoted diff) +0
-0
b/lib/librte_ether/rte_flow.hindex 98084ac..7142479 100644lib/librte_ether/rte_flow.h +48
-0@@ -268,6 +268,20 @@ 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 , + +/** +* Matches a NVGRE header. +* +* See struct rte_flow_item_nvgre. +*/ + RTE_FLOW_ITEM_TYPE_NVGRE, };/** @@ -454,6 +468,40 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +uint16_t tpid;/**< Tag protocol identifier (0x893F). */ +/** E-Tag control information (E-TCI). */ +/**< E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */ +uint16_t epcp_edei_in_ecid_b; +/**< Reserved (2b), GRP (2b), E-CID base (12b). */ +uint16_t rsvd_grp_ecid_b; +uint8_t in_ecid_e;/**< Ingress E-CID ext. */ +uint8_t ecid_e;/**< E-CID ext. */ +}; + +/** +* RTE_FLOW_ITEM_TYPE_NVGRE. +* +* Matches a NVGRE header. +*/ +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 protocol;/**< Protocol type (0x6558). */ +uint8_t tni[3 ];/**< Virtual subnet ID. */ +uint8_t flow_id;/**< Flow ID. */ +}; + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol
--Quoted 8 lines
Quoted 2 lines
2.5.5
OK for these definitions, however API documentation (
doc/guides/prog_guide/rte_flow.rst) must be kept up to date, and it would be great if testpmd support for these new items was added simultaneously (changes inapp/test-pmd/cmdline.c,app/test-pmd/cmdline_flow.cand
doc/guides/testpmd_app_ug/testpmd_funcs.rst).Quoted 3 lines
How about putting all
rte_flowchanges (API & testpmd) in their own separate patch?I thought it can be more useful to have library and its user updated in same patch, gives more context. But missed
rte_flowdocumentation ...Quoted 10 lines
You could use VLAN PCP/DEI/VID definitions as an example to expose partial bit-fields (e.g.
epcp_edei_in_ecid_b) in testpmd, see:
1419fd5a6c9f("app/testpmd: add protocol fields to flow command")Now if re-spinning this series yet again is too much work, you can go ahead with this commit as long as you do not forget to submit the rest later, thanks.
Quoted 6 lines
Is following todo list complete:
1- updaterte_flowdocument,doc/guides/prog_guide/rte_flow.rst, document two new item types:E_TAG& NVGRE.2- Add testpmd sample implementation and documentation.
Quoted 7 lines
I am sorry for miss
rte_flow.rstdocument update, I DON'T know there is such a new file ofrte_flow.rst. And also these two types ofE_TAG& NVGRE are added into code afterrte_flowpatch,
So testpmd implementation do not support for these type.
Now, we have been work on task of 17.05.
How about finish (1) first as one patch, then after busy work of 17.05 to add (2) as another patch?
OR, if these two work merge in to patch set, I will may be begin to do after the 17.05 task finish?
Which one is OK for you?
Changes can be in two separate patches, and if possible, can this get priority against 17.05 task?
This is for 17.02 feature and not completely finished, missing for last touches..
Thanks,
ferruh
Quoted 10 lines
Thank you.
Quoted 7 lines
Hi Wei,
Would you mind working on a patch to cover above items?
Thanks,
ferruh
Re: [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filter
Hi, Ferruh
Quoted 144 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, January 17, 2017 6:03 PM
To: Zhao1, Wei <[email protected]>; Adrien Mazarguil <[email protected]>
Cc: [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filterQuoted 68 lines · Wei
Hi, Ferruh
Quoted 66 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, January 17, 2017 12:39 AM
To: Adrien Mazarguil <[email protected]>; Zhao1, Wei <[email protected]>
Cc: [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filterQuoted 10 lines · Adrien Mazarguil
Hi,
Quoted 7 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]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 216+++++++++++++++++++++++++++++++++++++++
Quoted 45 lines
Quoted 2 lines
lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 266 insertions(+), 1 deletion(-)[...]
Quoted 42 lines
(quoted diff) +0
-0
b/lib/librte_ether/rte_flow.hindex 98084ac..7142479 100644lib/librte_ether/rte_flow.h +28
-0@@ -268,6 +268,20 @@ 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 , + +/** +* Matches a NVGRE header. +* +* See struct rte_flow_item_nvgre. +*/ + RTE_FLOW_ITEM_TYPE_NVGRE, };/** @@ -454,6 +468,40 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +uint16_t tpid;/**< Tag protocol identifier (0x893F). */ +/** E-Tag control information (E-TCI). */ +/**< E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */ +uint16_t epcp_edei_in_ecid_b; +/**< Reserved (2b), GRP (2b), E-CID base (12b). */ +uint16_t rsvd_grp_ecid_b; +uint8_t in_ecid_e;/**< Ingress E-CID ext. */ +uint8_t ecid_e;/**< E-CID ext. */ }; +Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_ether/rte_flow.h struct rte_flow_item_vxlan {
Quoted 8 lines
lib/librte_ether/rte_flow.h +8
-0+/** +* RTE_FLOW_ITEM_TYPE_NVGRE. +* +* Matches a NVGRE header. +*/ +struct rte_flow_item_nvgre { +/** +* Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
Quoted 42 lines
Quoted 42 lines
Quoted 15 lines
Quoted 15 lines
lib/librte_ether/rte_flow.h +10
-0+* 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 protocol;/**< Protocol type (0x6558). */ +uint8_t tni[3 ];/**< Virtual subnet ID. */ +uint8_t flow_id;/**< Flow ID. */ }; + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol
--Quoted 8 lines
Quoted 2 lines
2.5.5
OK for these definitions, however API documentation (
doc/guides/prog_guide/rte_flow.rst) must be kept up to date, and it would be great if testpmd support for these new items was added simultaneously (changes inapp/test-pmd/cmdline.c,app/test-pmd/cmdline_flow.cand
doc/guides/testpmd_app_ug/testpmd_funcs.rst).Quoted 3 lines
How about putting all
rte_flowchanges (API & testpmd) in their own separate patch?I thought it can be more useful to have library and its user updated in same patch, gives more context. But missed
rte_flowdocumentation ...Quoted 10 lines
You could use VLAN PCP/DEI/VID definitions as an example to expose partial bit-fields (e.g.
epcp_edei_in_ecid_b) in testpmd, see:
1419fd5a6c9f("app/testpmd: add protocol fields to flow command")Now if re-spinning this series yet again is too much work, you can go ahead with this commit as long as you do not forget to submit the rest later, thanks.
Quoted 8 lines
Quoted 6 lines
Is following todo list complete:
1- updaterte_flowdocument,doc/guides/prog_guide/rte_flow.rst, document two new item types:E_TAG& NVGRE.2- Add testpmd sample implementation and documentation.
I am sorry for miss
rte_flow.rstdocument update, I DON'T know there issuch a new file of
rte_flow.rst.Quoted 4 lines
And also these two types of
E_TAG& NVGRE are added into code afterrte_flowpatch, So testpmd implementation do not support for these type. Now, we have been work on task of 17.05.
How about finish (1) first as one patch, then after busy work of 17.05 toadd (2) as another patch?
Quoted 1 line
OR, if these two work merge in to patch set, I will may be begin to do after
the 17.05 task finish?
Quoted 19 lines
Quoted 1 line
Which one is OK for you?
Changes can be in two separate patches, and if possible, can this get priority against 17.05 task?
This is for 17.02 feature and not completely finished, missing for last touches..Thanks,
ferruhQuoted 10 lines
Thank you.
Quoted 7 lines
Hi Wei,
Would you mind working on a patch to cover above items?
Thanks,
ferruh
Add testpmd implementation example is not in our plan from the begin of the task generic filter API by us, Because all this part is not covered by us(intel) when task allocation.
BUT if this component is need by community, I will report to my leader and add it into our next work plan and try to finish it ASAP.
Thank you.
Re: [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filter
Quoted 160 lines · Wei
Hi, Ferruh
Quoted 158 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, January 17, 2017 6:03 PM
To: Zhao1, Wei <[email protected]>; Adrien Mazarguil <[email protected]>
Cc: [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filterQuoted 68 lines · Wei
Hi, Ferruh
Quoted 66 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, January 17, 2017 12:39 AM
To: Adrien Mazarguil <[email protected]>; Zhao1, Wei <[email protected]>
Cc: [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filterQuoted 10 lines · Adrien Mazarguil
Hi,
Quoted 7 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]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/ixgbe/ixgbe_flow.c | 216+++++++++++++++++++++++++++++++++++++++
Quoted 45 lines
Quoted 2 lines
lib/librte_ether/rte_flow.h | 48 +++++++++ 3 files changed, 266 insertions(+), 1 deletion(-)[...]
Quoted 42 lines
(quoted diff) +0
-0
b/lib/librte_ether/rte_flow.hindex 98084ac..7142479 100644lib/librte_ether/rte_flow.h +28
-0@@ -268,6 +268,20 @@ 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 , + +/** +* Matches a NVGRE header. +* +* See struct rte_flow_item_nvgre. +*/ + RTE_FLOW_ITEM_TYPE_NVGRE, };/** @@ -454,6 +468,40 @@ struct rte_flow_item_vxlan { };/** +* RTE_FLOW_ITEM_TYPE_E_TAG. +* +* Matches a E-tag header. +*/ +struct rte_flow_item_e_tag { +uint16_t tpid;/**< Tag protocol identifier (0x893F). */ +/** E-Tag control information (E-TCI). */ +/**< E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */ +uint16_t epcp_edei_in_ecid_b; +/**< Reserved (2b), GRP (2b), E-CID base (12b). */ +uint16_t rsvd_grp_ecid_b; +uint8_t in_ecid_e;/**< Ingress E-CID ext. */ +uint8_t ecid_e;/**< E-CID ext. */ }; +Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_ether/rte_flow.h struct rte_flow_item_vxlan {
Quoted 8 lines
lib/librte_ether/rte_flow.h +8
-0+/** +* RTE_FLOW_ITEM_TYPE_NVGRE. +* +* Matches a NVGRE header. +*/ +struct rte_flow_item_nvgre { +/** +* Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
Quoted 42 lines
Quoted 42 lines
Quoted 15 lines
Quoted 15 lines
lib/librte_ether/rte_flow.h +10
-0+* 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 protocol;/**< Protocol type (0x6558). */ +uint8_t tni[3 ];/**< Virtual subnet ID. */ +uint8_t flow_id;/**< Flow ID. */ }; + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol
--Quoted 8 lines
Quoted 2 lines
2.5.5
OK for these definitions, however API documentation (
doc/guides/prog_guide/rte_flow.rst) must be kept up to date, and it would be great if testpmd support for these new items was added simultaneously (changes inapp/test-pmd/cmdline.c,app/test-pmd/cmdline_flow.cand
doc/guides/testpmd_app_ug/testpmd_funcs.rst).Quoted 3 lines
How about putting all
rte_flowchanges (API & testpmd) in their own separate patch?I thought it can be more useful to have library and its user updated in same patch, gives more context. But missed
rte_flowdocumentation ...Quoted 10 lines
You could use VLAN PCP/DEI/VID definitions as an example to expose partial bit-fields (e.g.
epcp_edei_in_ecid_b) in testpmd, see:
1419fd5a6c9f("app/testpmd: add protocol fields to flow command")Now if re-spinning this series yet again is too much work, you can go ahead with this commit as long as you do not forget to submit the rest later, thanks.
Quoted 8 lines
Quoted 6 lines
Is following todo list complete:
1- updaterte_flowdocument,doc/guides/prog_guide/rte_flow.rst, document two new item types:E_TAG& NVGRE.2- Add testpmd sample implementation and documentation.
I am sorry for miss
rte_flow.rstdocument update, I DON'T know there issuch a new file of
rte_flow.rst.Quoted 4 lines
And also these two types of
E_TAG& NVGRE are added into code afterrte_flowpatch, So testpmd implementation do not support for these type. Now, we have been work on task of 17.05.
How about finish (1) first as one patch, then after busy work of 17.05 toadd (2) as another patch?
Quoted 1 line
OR, if these two work merge in to patch set, I will may be begin to do after
the 17.05 task finish?
Quoted 1 line
Which one is OK for you?
Changes can be in two separate patches, and if possible, can this get priority against 17.05 task?
This is for 17.02 feature and not completely finished, missing for last touches..Thanks,
ferruhQuoted 5 lines
Thank you.
Quoted 3 lines
Hi Wei,
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Would you mind working on a patch to cover above items?
Thanks,
ferruhAdd testpmd implementation example is not in our plan from the begin of the task generic filter API by us, Because all this part is not covered by us(intel) when task allocation.
Right, sample testpmd implementation is not directly related to the adding rte_flow support to the driver.
But for this, a rte_flow library update required, and sample testpmd implementation is part of rte_flow update.
Quoted 1 line
BUT if this component is need by community, I will report to my leader and add it into our next work plan and try to finish it ASAP.
Yes please, I believe it is needed.
Thanks,
ferruh
Quoted 3 lines
Thank you.
Re: [PATCH v6 14/18] net/ixgbe: parse L2 tunnel filter
On 1/18/2017 5:49 PM, Ferruh Yigit wrote:
<...>
Quoted 68 lines
Quoted 56 lines
Quoted 56 lines
Quoted 26 lines
Quoted 26 lines
Quoted 7 lines
Quoted 1 line
OK for these definitions, however API documentation (
doc/guides/prog_guide/rte_flow.rst) must be kept up to date, and it would be great if testpmd support for these new items was added simultaneously (changes inapp/test-pmd/cmdline.c,app/test-pmd/cmdline_flow.cand
doc/guides/testpmd_app_ug/testpmd_funcs.rst).Quoted 3 lines
How about putting all
rte_flowchanges (API & testpmd) in their own separate patch?I thought it can be more useful to have library and its user updated in same patch, gives more context. But missed
rte_flowdocumentation ...Quoted 10 lines
You could use VLAN PCP/DEI/VID definitions as an example to expose partial bit-fields (e.g.
epcp_edei_in_ecid_b) in testpmd, see:
1419fd5a6c9f("app/testpmd: add protocol fields to flow command")Now if re-spinning this series yet again is too much work, you can go ahead with this commit as long as you do not forget to submit the rest later, thanks.
Quoted 8 lines
Quoted 6 lines
Is following todo list complete:
1- updaterte_flowdocument,doc/guides/prog_guide/rte_flow.rst, document two new item types:E_TAG& NVGRE.2- Add testpmd sample implementation and documentation.
I am sorry for miss
rte_flow.rstdocument update, I DON'T know there issuch a new file of
rte_flow.rst.Quoted 4 lines
And also these two types of
E_TAG& NVGRE are added into code afterrte_flowpatch, So testpmd implementation do not support for these type. Now, we have been work on task of 17.05.
How about finish (1) first as one patch, then after busy work of 17.05 toadd (2) as another patch?
Quoted 1 line
OR, if these two work merge in to patch set, I will may be begin to do after
the 17.05 task finish?
Quoted 1 line
Which one is OK for you?
Changes can be in two separate patches, and if possible, can this get priority against 17.05 task?
This is for 17.02 feature and not completely finished, missing for last touches..Thanks,
ferruhQuoted 5 lines
Thank you.
Quoted 3 lines
Hi Wei,
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Would you mind working on a patch to cover above items?
Thanks,
ferruhAdd testpmd implementation example is not in our plan from the begin of the task generic filter API by us, Because all this part is not covered by us(intel) when task allocation.
Right, sample testpmd implementation is not directly related to the adding
rte_flowsupport to the driver.
Quoted 6 lines
But for this, a
rte_flowlibrary update required, and sample testpmd implementation is part ofrte_flowupdate.Quoted 1 line
BUT if this component is need by community, I will report to my leader and add it into our next work plan and try to finish it ASAP.
Yes please, I believe it is needed.
Is there any update from this work?
Quoted 8 lines
Thanks,
ferruhQuoted 3 lines
Thank you.
PATCH v6 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.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 2 + drivers/net/ixgbe/ixgbe_ethdev.h | 16 + drivers/net/ixgbe/ixgbe_fdir.c | 253 +++++--- drivers/net/ixgbe/ixgbe_flow.c | 1252 +++++++++++++++++++++++++++++++++++++- 4 files changed, 1414 insertions(+), 109 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +2 -0
@@ -1436,6 +1436,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 ; }
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 */
@@ -479,6 +491,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 +170 -83
473 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_flow.c +1226 -26
1,271 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v6 16/18 net/ixgbe: create consistent filter
In reply to Wei ZhaoThis patch adds a function to create the flow directory filter.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 25 +++-- drivers/net/ixgbe/ixgbe_ethdev.h | 61 ++++++++++++ drivers/net/ixgbe/ixgbe_flow.c | 194 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 266 insertions(+), 14 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +12 -13
@@ -305,9 +305,6 @@ static void ixgbevf_add_mac_addr(struct rte_eth_dev *dev,static void ixgbevf_remove_mac_addr (struct rte_eth_dev *dev,uint32_t index);static void ixgbevf_set_default_mac_addr (struct rte_eth_dev *dev,struct ether_addr *mac_addr); -static int ixgbe_syn_filter_set (struct rte_eth_dev *dev, -struct rte_eth_syn_filter *filter, -bool add);static int ixgbe_syn_filter_get (struct rte_eth_dev *dev,struct rte_eth_syn_filter *filter); static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
@@ -317,17 +314,11 @@ static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev, struct ixgbe_5tuple_filter *filter);static void ixgbe_remove_5tuple_filter (struct rte_eth_dev *dev,struct ixgbe_5tuple_filter *filter); -static int ixgbe_add_del_ntuple_filter (struct rte_eth_dev *dev, -struct rte_eth_ntuple_filter *filter, -bool add);static int ixgbe_ntuple_filter_handle (struct rte_eth_dev *dev,enum rte_filter_op filter_op,void *arg);static int ixgbe_get_ntuple_filter (struct rte_eth_dev *dev,struct rte_eth_ntuple_filter *filter); -static int ixgbe_add_del_ethertype_filter (struct rte_eth_dev *dev, -struct rte_eth_ethertype_filter *filter, -bool add);static int ixgbe_ethertype_filter_handle (struct rte_eth_dev *dev,enum rte_filter_op filter_op,void *arg);
@@ -1292,6 +1283,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 ; }
@@ -5742,7 +5741,7 @@ ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)return -ENOTSUP ;\ }while (0 ) -static int +int ixgbe_syn_filter_set(struct rte_eth_dev *dev, struct rte_eth_syn_filter *filter, bool add)
@@ -6121,7 +6120,7 @@ ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,* - On success, zero. * - On failure, a negative value. */ -static int +int ixgbe_add_del_ntuple_filter (struct rte_eth_dev *dev,struct rte_eth_ntuple_filter *ntuple_filter,bool add)
@@ -6266,7 +6265,7 @@ ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,return ret; } -static int +int ixgbe_add_del_ethertype_filter (struct rte_eth_dev *dev,struct rte_eth_ethertype_filter *filter,bool add)
@@ -7345,7 +7344,7 @@ ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info, }/* Add l2 tunnel filter */ -static int +int ixgbe_dev_l2_tunnel_filter_add (struct rte_eth_dev *dev,struct rte_eth_l2_tunnel_conf *l2_tunnel,bool restore)
drivers/net/ixgbe/ixgbe_ethdev.h +61 -0
73 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_flow.c +193 -1
209 lines not on this page · raw message
Signature · 1 line
2.5.5