Building a better rte_flow parser
Subsystems (2)
PATCH v7 14/25 net/ixgbe: reimplement security parser
In reply to Anatoly BurakovUse the new flow graph API and common flow engine infrastructure to implement flow parser for security filter. As a result, flow item checks have become more stringent:
- Mask is now explicitly validated to not have unsupported items in it, when previously they were ignored
- Mask is also validated to mask src/dst addresses, as otherwise it is inconsistent with rte_flow API
- The security engine was only looking for IPv4/IPv6 pattern items and completely ignored both prefix and suffix. This logic has been replaced by allowing [ETH]/IP/[UDP|ESP] patterns, as is used in ipsec-gw app
Previously, security parser was a special case, now it is a first class citizen. All decryption SA tracking has been moved into the engine, as the engine is now the authoritative source of new Rx flows and the state of the Rx SA table (the Tx SA table is still up to IPsec code to manage).
Because IPsec code does not manage the Rx SA table now, a synchronization mechanism is needed to prevent IPsec code from deallocating a security session when it is still referenced by security flows, so the security session is now atomically refcounted. For Tx, the refcount is effectively a noop, whereas for Rx it is now managed by rte_flow security engine.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 2 - drivers/net/intel/ixgbe/ixgbe_flow.c | 120 +--- drivers/net/intel/ixgbe/ixgbe_flow.h | 1 + drivers/net/intel/ixgbe/ixgbe_flow_security.c | 586 ++++++++++++++++++ drivers/net/intel/ixgbe/ixgbe_ipsec.c | 361 +++++------ drivers/net/intel/ixgbe/ixgbe_ipsec.h | 50 +- drivers/net/intel/ixgbe/meson.build | 1 + 7 files changed, 773 insertions(+), 348 deletions(-) create mode 100644 drivers/net/intel/ixgbe/ixgbe_flow_security.c
drivers/net/intel/ixgbe/ixgbe_ethdev.h +0 -2
@@ -313,8 +313,6 @@ struct ixgbe_l2_tn_info {struct rte_flow {struct ci_flow flow;enum rte_filter_type filter_type; -/* security flows are not rte_filter_type */ -bool is_security;void *rule; };
drivers/net/intel/ixgbe/ixgbe_flow.c +2 -118
174 lines not on this page · raw message
drivers/net/intel/ixgbe/ixgbe_flow.h +1 -0
@@ -19,5 +19,6 @@ extern const struct ci_flow_engine ixgbe_ethertype_flow_engine;extern const struct ci_flow_engine ixgbe_syn_flow_engine;extern const struct ci_flow_engine ixgbe_l2_tunnel_flow_engine;extern const struct ci_flow_engine ixgbe_ntuple_flow_engine; +extern const struct ci_flow_engine ixgbe_security_flow_engine;#endif /* _IXGBE_FLOW_H_ */
drivers/net/intel/ixgbe/ixgbe_flow_security.c new file +586 -0
586 lines not on this page · raw message
drivers/net/intel/ixgbe/ixgbe_ipsec.c +161 -200
446 lines not on this page · raw message
drivers/net/intel/ixgbe/ixgbe_ipsec.h +22 -28
91 lines not on this page · raw message
drivers/net/intel/ixgbe/meson.build +1 -0
@@ -30,6 +30,7 @@ sources += files( 'ixgbe_flow_syn.c', 'ixgbe_flow_l2tun.c', 'ixgbe_flow_ntuple.c', + 'ixgbe_flow_security.c', 'ixgbe_ipsec.c', 'ixgbe_pf.c', 'ixgbe_rxtx.c',
Signature · 1 line
2.52.0
Re: [PATCH v7 14/25] net/ixgbe: reimplement security parser
Quoted 26 lines · Anatoly Burakov
Use the new flow graph API and common flow engine infrastructure to implement flow parser for security filter. As a result, flow item checks have become more stringent:
- Mask is now explicitly validated to not have unsupported items in it, when previously they were ignored
- Mask is also validated to mask src/dst addresses, as otherwise it is inconsistent withrte_flowAPI
- The security engine was only looking for IPv4/IPv6 pattern items and completely ignored both prefix and suffix. This logic has been replaced by allowing [ETH]/IP/[UDP|ESP] patterns, as is used in ipsec-gw appPreviously, security parser was a special case, now it is a first class citizen. All decryption SA tracking has been moved into the engine, as the engine is now the authoritative source of new Rx flows and the state of the Rx SA table (the Tx SA table is still up to IPsec code to manage).
Because IPsec code does not manage the Rx SA table now, a synchronization mechanism is needed to prevent IPsec code from deallocating a security session when it is still referenced by security flows, so the security session is now atomically refcounted. For Tx, the refcount is effectively a noop, whereas for Rx it is now managed by
rte_flowsecurity engine.Signed-off-by Anatoly Burakov <[email protected]>---
Signature · 2 lines
Regards, Vladimir
PATCH v7 15/25 net/ixgbe: reimplement FDIR parser
In reply to Anatoly BurakovUse the new flow graph API and the common parsing framework to implement flow parser for flow director.
The FDIR flow tracking is moved inside the new engine, and the FDIR code is refactored to not mix software tracking with HW writes, remove redundant state and configuration stages, and structure the state storage better.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 117 +- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 98 +- drivers/net/intel/ixgbe/ixgbe_fdir.c | 610 ++---- drivers/net/intel/ixgbe/ixgbe_flow.c | 1605 +--------------- drivers/net/intel/ixgbe/ixgbe_flow.h | 2 + drivers/net/intel/ixgbe/ixgbe_flow_fdir.c | 1663 +++++++++++++++++ .../net/intel/ixgbe/ixgbe_rxtx_vec_common.c | 4 +- drivers/net/intel/ixgbe/meson.build | 1 + 8 files changed, 1955 insertions(+), 2145 deletions(-) create mode 100644 drivers/net/intel/ixgbe/ixgbe_flow_fdir.c
drivers/net/intel/ixgbe/ixgbe_ethdev.c +53 -64
@@ -147,8 +147,6 @@ static const char * const ixgbevf_valid_arguments[] = {static int eth_ixgbe_dev_init (struct rte_eth_dev *eth_dev,void *init_params);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_dev_configure (struct rte_eth_dev *dev);static int ixgbe_dev_start (struct rte_eth_dev *dev);
@@ -1008,7 +1006,7 @@ ixgbe_parse_devargs(struct ixgbe_adapter *adapter, &pballoc) != 0) ret = -EINVAL ; else - adapter->fdir_conf.pballoc = pballoc; + adapter->fdir_hw_config.pballoc = pballoc; }rte_kvargs_free (kvlist);
@@ -1261,11 +1259,6 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)memset (filter_info,0 ,sizeof (struct ixgbe_filter_info )); -/* initialize flow director filter list & hash */ - ret =ixgbe_fdir_filter_init (eth_dev); -if (ret) - goto err_fdir_filter_init; -/* initialize l2 tunnel filter list & hash */ ret =ixgbe_l2_tn_filter_init (eth_dev);if (ret)
@@ -1289,8 +1282,6 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)return 0 ; err_l2_tn_filter_init: -ixgbe_fdir_filter_uninit (eth_dev); -err_fdir_filter_init:ixgbe_disable_intr (hw);rte_intr_disable (intr_handle); rte_intr_callback_unregister(intr_handle,
@@ -1320,31 +1311,24 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)return 0 ; } -static int ixgbe_fdir_filter_uninit (struct rte_eth_dev *eth_dev) +void +ixgbe_fdir_state_detach (struct ixgbe_fdir_state *state) { -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 (!ci_usage_count_release (&state->engine_use_count)) +return ; -rte_free (fdir_info->hash_map); -rte_hash_free (fdir_info->hash_handle); +rte_hash_free (state->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 ; + *state = (struct ixgbe_fdir_state ){0 }; } -static int ixgbe_fdir_filter_init (struct rte_eth_dev *eth_dev) +struct ixgbe_fdir_state * +ixgbe_fdir_state_attach (struct rte_eth_dev_data *dev_data) { -struct ixgbe_hw_fdir_info *fdir_info = -IXGBE_DEV_PRIVATE_TO_FDIR_INFO (eth_dev->data->dev_private); +struct ixgbe_adapter *adapter =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev_data->dev_private); +struct ixgbe_fdir_state *state = &adapter->fdir_state;char fdir_hash_name[RTE_HASH_NAMESIZE ]; -struct rte_hash_parameters fdir_hash_params = { +struct rte_hash_parameters hash_params = { .name = fdir_hash_name, .entries =IXGBE_MAX_FDIR_FILTER_NUM , .key_len =sizeof (union ixgbe_atr_input ),
@@ -1353,31 +1337,28 @@ static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev) .socket_id = rte_socket_id(), }; -TAILQ_INIT (&fdir_info->fdir_list); -snprintf (fdir_hash_name,RTE_HASH_NAMESIZE , -"fdir_%s" , eth_dev->device->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!" ); -rte_hash_free (fdir_info->hash_handle); -return -ENOMEM ; - } - fdir_info->n_flows =0 ; - fdir_info->mask_added = FALSE; +snprintf (fdir_hash_name,RTE_HASH_NAMESIZE ,"fdir_%s" , + dev_data->name); + +if (ci_usage_count_claim (&state->engine_use_count)) { +struct rte_hash *hash_handle; + + hash_handle =rte_hash_create (&hash_params); -/* drop queue is always fixed */ -IXGBE_DEV_FDIR_CONF (eth_dev)->drop_queue =IXGBE_FDIR_DROP_QUEUE ; +if (hash_handle ==NULL ) { +PMD_INIT_LOG (ERR ,"Failed to create fdir hash table!" ); +ci_usage_count_release (&state->engine_use_count); +return NULL ; + } + + state->hash_handle = hash_handle; + state->config.mode =RTE_FDIR_MODE_NONE ; + +/* set up default values for the mask */ +ixgbe_fdir_mask_set_default (&state->mask_conf.mask); + } -return 0 ; +return state; }static int ixgbe_l2_tn_filter_init (struct rte_eth_dev *eth_dev)
@@ -2177,9 +2158,27 @@ ixgbe_check_mq_mode(struct rte_eth_dev *dev) {struct rte_eth_conf *dev_conf = &dev->data->dev_conf;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_adapter *adapter =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private);uint16_t nb_rx_q = dev->data->nb_rx_queues;uint16_t nb_tx_q = dev->data->nb_tx_queues; +/* DCB-family modes reprogram RXPBSIZE and clash with FDIR's own use of it */ +switch (dev_conf->rxmode.mq_mode) { +case RTE_ETH_MQ_RX_VMDQ_DCB : +case RTE_ETH_MQ_RX_DCB : +case RTE_ETH_MQ_RX_DCB_RSS : +case RTE_ETH_MQ_RX_VMDQ_DCB_RSS : +if (adapter->fdir_state.config.mode !=RTE_FDIR_MODE_NONE ) { +PMD_INIT_LOG (ERR ,"Cannot use DCB mq_mode %d while " +"flow director rules are active." , + dev_conf->rxmode.mq_mode); +return -EINVAL ; + } +break ; +default : +break ; + } +if (RTE_ETH_DEV_SRIOV (dev).active !=0 ) {/* check multi-queue mode */ switch (dev_conf->rxmode.mq_mode) {
@@ -2500,7 +2499,6 @@ ixgbe_dev_start(struct rte_eth_dev *dev)struct ixgbe_adapter *adapter =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private);struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (adapter); -struct rte_eth_fdir_conf *fdir_conf =IXGBE_DEV_FDIR_CONF (dev);struct ixgbe_vf_info *vfinfo = *IXGBE_DEV_PRIVATE_TO_P_VFDATA (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);
@@ -2605,14 +2603,6 @@ ixgbe_dev_start(struct rte_eth_dev *dev)/* Configure DCB hw */ ixgbe_configure_dcb (dev); -if (fdir_conf->mode !=RTE_FDIR_MODE_NONE ) { -struct ixgbe_hw_fdir_info *info = -IXGBE_DEV_PRIVATE_TO_FDIR_INFO (adapter); - err =ixgbe_fdir_configure (dev, fdir_conf, &info->mask); -if (err) - goto error; - } -/* Restore vf rate limit */ if (vfinfo !=NULL ) {for (vf =0 ; vf < pci_dev->max_vfs; vf++)
@@ -2881,6 +2871,9 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)/* reset hierarchy commit */ tm_conf->committed = false; +/* reinit fdir on next flow replay */ +ixgbe_fdir_hw_invalidate (dev); + adapter->rss_reta_updated =0 ; hw->adapter_stopped = true;
@@ -3025,9 +3018,6 @@ ixgbe_dev_close(struct rte_eth_dev *dev)/* uninitialize PF if max_vfs not zero */ ixgbe_pf_host_uninit (dev); -/* remove all the fdir filters & hash */ -ixgbe_fdir_filter_uninit (dev); -/* clear all the filters list */ ixgbe_filterlist_flush (dev);
@@ -7862,7 +7852,6 @@ ixgbe_rss_filter_restore(struct rte_eth_dev *dev)static int ixgbe_filter_restore (struct rte_eth_dev *dev) { -ixgbe_fdir_filter_restore (dev);ixgbe_rss_filter_restore (dev);return 0 ;
drivers/net/intel/ixgbe/ixgbe_ethdev.h +50 -48
165 lines not on this page · raw message
drivers/net/intel/ixgbe/ixgbe_fdir.c +181 -429
799 lines not on this page · raw message
drivers/net/intel/ixgbe/ixgbe_flow.c +3 -1602
1,674 lines not on this page · raw message
drivers/net/intel/ixgbe/ixgbe_flow.h +2 -0
@@ -20,5 +20,7 @@ extern const struct ci_flow_engine ixgbe_syn_flow_engine;extern const struct ci_flow_engine ixgbe_l2_tunnel_flow_engine;extern const struct ci_flow_engine ixgbe_ntuple_flow_engine;extern const struct ci_flow_engine ixgbe_security_flow_engine; +extern const struct ci_flow_engine ixgbe_fdir_flow_engine; +extern const struct ci_flow_engine ixgbe_fdir_tunnel_flow_engine;#endif /* _IXGBE_FLOW_H_ */
drivers/net/intel/ixgbe/ixgbe_flow_fdir.c new file +1663 -0
154 lines not on this page · raw message
drivers/net/intel/ixgbe/ixgbe_rxtx_vec_common.c +2 -2
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.52.0
Part of the diff is not shown here. View the raw message.
PATCH v7 16/25 net/ixgbe: don't embed RSS conf in filter structs
In reply to Anatoly BurakovCurrently, the RSS configuration driver structure directly embeds rte_flow RSS configuration item, which makes it so 1) the structure actually has duplicate data (or, to be more precise, a local copy of data pointed to by the RSS conf), and 2) direct struct assignments don't work because the RSS conf contains pointers.
Fix the structure to not embed RSS conf, and instead just store the data directly, so that we can perform struct assignments without any problems with poiinters.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 18 ++++---- drivers/net/intel/ixgbe/ixgbe_flow.c | 37 +++++++++------- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 61 ++++++++++++-------------- 4 files changed, 59 insertions(+), 59 deletions(-)
drivers/net/intel/ixgbe/ixgbe_ethdev.c +1 -1
@@ -7844,7 +7844,7 @@ ixgbe_rss_filter_restore(struct rte_eth_dev *dev)struct ixgbe_filter_info *filter_info =IXGBE_DEV_PRIVATE_TO_FILTER_INFO (adapter); -if (filter_info->rss_info.conf.queue_num) +if (filter_info->rss_info.queue_num)ixgbe_config_rss_filter (adapter, &filter_info->rss_info, TRUE); }
drivers/net/intel/ixgbe/ixgbe_ethdev.h +9 -9
@@ -210,9 +210,11 @@ struct ixgbe_fdir_state {struct ixgbe_fdir_stats stats; }; -struct ixgbe_rte_flow_rss_conf { -struct rte_flow_action_rss conf;/**< RSS parameters. */ -uint8_t key[IXGBE_HKEY_MAX_INDEX *sizeof (uint32_t )];/* Hash key. */ +struct ixgbe_rss_conf { +uint64_t types;/**< RSS hash types. */ +uint32_t key_len;/**< Hash key length, 0 for default key. */ +uint32_t queue_num;/**< Number of entries in queue. */ +uint8_t key[IXGBE_HKEY_MAX_INDEX *sizeof (uint32_t )];/**< Hash key. */ uint16_t queue[IXGBE_MAX_RX_QUEUE_NUM ];/**< Queues indices to use. */ };
@@ -300,7 +302,7 @@ struct ixgbe_ethertype_table {*/ struct ixgbe_filter_info {/* store the rss filter info */ -struct ixgbe_rte_flow_rss_conf rss_info; +struct ixgbe_rss_conf rss_info;/* shared EtherType (ETQF) slot table */ struct ixgbe_ethertype_table ethertype_table;/* 1588 timestamping ETQF slot (valid when timesync_installed) */
@@ -731,12 +733,10 @@ void ixgbe_tm_conf_init(struct rte_eth_dev *dev);void ixgbe_tm_conf_uninit (struct rte_eth_dev *dev);int ixgbe_set_queue_rate_limit (struct rte_eth_dev *dev,uint16_t queue_idx,uint32_t tx_rate); -int ixgbe_rss_conf_init (struct ixgbe_rte_flow_rss_conf *out, -const struct rte_flow_action_rss *in); -int ixgbe_action_rss_same (const struct rte_flow_action_rss *comp, -const struct rte_flow_action_rss *with); +int ixgbe_rss_conf_init (struct ixgbe_rss_conf *out, +const struct rte_flow_action_rss *in);int ixgbe_config_rss_filter (struct ixgbe_adapter *adapter, -struct ixgbe_rte_flow_rss_conf *conf,bool add); +const struct ixgbe_rss_conf *conf,bool add);void ixgbe_dev_macsec_register_enable (struct rte_eth_dev *dev,struct ixgbe_macsec_setting *macsec_setting);
drivers/net/intel/ixgbe/ixgbe_flow.c +21 -16
@@ -57,7 +57,7 @@ struct ixgbe_filter_ele_base {/* rss filter list structure */ struct ixgbe_rss_conf_ele {struct ixgbe_filter_ele_base base; -struct ixgbe_rte_flow_rss_conf filter_info; +struct ixgbe_rss_conf filter_info; };/* ixgbe_flow memory list structure */ struct ixgbe_flow_mem {
@@ -140,7 +140,8 @@ ixgbe_flow_actions_check_rss(const struct ci_flow_actions *parsed_actions,const struct rte_flow_action *action = parsed_actions->actions[0 ];const struct rte_flow_action_rss *rss_act = action->conf;struct rte_eth_dev_data *dev_data = param->driver_ctx; -const size_t rss_key_len =sizeof (((struct ixgbe_rte_flow_rss_conf *)0 )->key); +const size_t rss_key_len =sizeof (((struct ixgbe_rss_conf *)0 )->key); +const size_t rss_queue_max =RTE_DIM (((struct ixgbe_rss_conf *)0 )->queue);size_t q_idx, q;/* check if queue list is not empty */
@@ -149,6 +150,11 @@ ixgbe_flow_actions_check_rss(const struct ci_flow_actions *parsed_actions,RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, "RSS queue list is empty"); } +if (rss_act->queue_num > rss_queue_max) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, +"RSS queue list is too long" ); + }/* check if each RSS queue is valid */ for (q_idx =0 ; q_idx < rss_act->queue_num; q_idx++) {
@@ -185,7 +191,7 @@ static int ixgbe_parse_rss_filter(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_action actions[], - struct ixgbe_rte_flow_rss_conf *rss_conf, + struct ixgbe_rss_conf *rss_conf, struct rte_flow_error *error) { struct ci_flow_actions parsed_actions;
@@ -199,8 +205,8 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, .check = ixgbe_flow_actions_check_rss, .max_actions = 1, }; +const struct rte_flow_action_rss *rss_act;int ret; -const struct rte_flow_action *action;/* validate attributes */ ret =ci_flow_check_attr (attr,NULL , error);
@@ -211,12 +217,14 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, ret =ci_flow_check_actions (actions, &ap_param, &parsed_actions, error);if (ret)return ret; - action = parsed_actions.actions[0 ]; + rss_act = parsed_actions.actions[0 ]->conf; -if (ixgbe_rss_conf_init (rss_conf, action->conf)) -return rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION ,NULL , + ret =ixgbe_rss_conf_init (rss_conf, rss_act); +if (ret) { +return rte_flow_error_set (error, -ret, +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act,"RSS context initialization failure" ); + }return 0 ; }
@@ -230,7 +238,7 @@ ixgbe_clear_rss_filter(struct rte_eth_dev *dev)struct ixgbe_filter_info *filter_info =IXGBE_DEV_PRIVATE_TO_FILTER_INFO (dev->data->dev_private); -if (filter_info->rss_info.conf.queue_num) +if (filter_info->rss_info.queue_num)ixgbe_config_rss_filter (adapter, &filter_info->rss_info, FALSE); }
@@ -275,7 +283,7 @@ ixgbe_flow_create(struct rte_eth_dev *dev, {int ret;struct ixgbe_adapter *adapter =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -struct ixgbe_rte_flow_rss_conf rss_conf; +struct ixgbe_rss_conf rss_conf = {0 };struct rte_flow *flow =NULL ;struct ixgbe_rss_conf_ele *rss_filter_ptr;struct ixgbe_flow_mem *ixgbe_flow_mem_ptr;
@@ -303,7 +311,6 @@ ixgbe_flow_create(struct rte_eth_dev *dev,TAILQ_INSERT_TAIL (&adapter->flow_list, &ixgbe_flow_mem_ptr->base, entries); -memset (&rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); ret =ixgbe_parse_rss_filter (dev, attr, actions, &rss_conf, error);if (!ret) {
@@ -319,8 +326,7 @@ ixgbe_flow_create(struct rte_eth_dev *dev,rte_free (rss_filter_ptr); goto out; } -ixgbe_rss_conf_init (&rss_filter_ptr->filter_info, - &rss_conf.conf); + rss_filter_ptr->filter_info = rss_conf; flow->rule = rss_filter_ptr; flow->filter_type =RTE_ETH_FILTER_HASH ;return flow;
@@ -350,7 +356,7 @@ ixgbe_flow_validate(struct rte_eth_dev *dev, struct rte_flow_error *error) {struct ixgbe_adapter *ad =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -struct ixgbe_rte_flow_rss_conf rss_conf; +struct ixgbe_rss_conf rss_conf = {0 };int ret;/* try the new flow engine first */
@@ -360,7 +366,6 @@ ixgbe_flow_validate(struct rte_eth_dev *dev,/* fall back to legacy engines */ -memset (&rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); ret =ixgbe_parse_rss_filter (dev, attr, actions, &rss_conf, error);
@@ -488,7 +493,7 @@ ixgbe_flow_rule_size(const struct rte_flow *flow)case RTE_ETH_FILTER_L2_TUNNEL :return sizeof (struct ixgbe_l2_tunnel_conf );case RTE_ETH_FILTER_HASH : -return sizeof (struct ixgbe_rte_flow_rss_conf ); +return sizeof (struct ixgbe_rss_conf );default :return 0 ; }
drivers/net/intel/ixgbe/ixgbe_rxtx.c +28 -33
114 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v7 17/25 net/ixgbe: reimplement hash parser
In reply to Anatoly BurakovUse the new flow graph API and the common parsing framework to implement flow parser for RSS configuration.
RSS flow parser doesn't really parse any "flows", it was completely ignoring the flow patterns and was only looking at actions. It will therefore not specify a pattern graph and will match NULL pattern, empty patterns (START -> END), and ANY patterns (START -> ANY -> END).
RSS was the last engine using "filter list", so that is now removed. The RSS engine filter tracking was also moved completely into the new engine, and all of the "filter list" infrastructure is removed for good.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 30 -- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 16 +- drivers/net/intel/ixgbe/ixgbe_flow.c | 423 +--------------------- drivers/net/intel/ixgbe/ixgbe_flow.h | 1 + drivers/net/intel/ixgbe/ixgbe_flow_hash.c | 216 +++++++++++ drivers/net/intel/ixgbe/ixgbe_rxtx.c | 43 +-- drivers/net/intel/ixgbe/meson.build | 1 + 7 files changed, 239 insertions(+), 491 deletions(-) create mode 100644 drivers/net/intel/ixgbe/ixgbe_flow_hash.c
drivers/net/intel/ixgbe/ixgbe_ethdev.c +0 -30
@@ -344,7 +344,6 @@ 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);static void ixgbe_l2_tunnel_conf (struct rte_eth_dev *dev);static int ixgbe_wait_for_link_up (struct ixgbe_hw *hw); static int devarg_handle_int(__rte_unused const char *key, const char *value,
@@ -1270,9 +1269,6 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)if (ret) goto err_l2_tn_filter_init; -/* initialize flow filter lists */ -ixgbe_filterlist_init (eth_dev); -/* initialize bandwidth configuration info */ memset (bw_conf,0 ,sizeof (struct ixgbe_bw_conf ));
@@ -2761,7 +2757,6 @@ 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);if (tm_conf->root && !tm_conf->committed) PMD_DRV_LOG(WARNING,
@@ -3018,9 +3013,6 @@ ixgbe_dev_close(struct rte_eth_dev *dev)/* uninitialize PF if max_vfs not zero */ ixgbe_pf_host_uninit (dev); -/* clear all the filters list */ -ixgbe_filterlist_flush (dev); -/* Remove all Traffic Manager configuration */ ixgbe_tm_conf_uninit (dev);
@@ -7835,28 +7827,6 @@ int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)return IXGBE_SUCCESS ; } -/* restore rss filter */ -static inline void -ixgbe_rss_filter_restore (struct rte_eth_dev *dev) -{ -struct ixgbe_adapter *adapter = -IXGBE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -struct ixgbe_filter_info *filter_info = -IXGBE_DEV_PRIVATE_TO_FILTER_INFO (adapter); - -if (filter_info->rss_info.queue_num) -ixgbe_config_rss_filter (adapter, - &filter_info->rss_info, TRUE); -} - -static int -ixgbe_filter_restore (struct rte_eth_dev *dev) -{ -ixgbe_rss_filter_restore (dev); - -return 0 ; -} -static void ixgbe_l2_tunnel_conf (struct rte_eth_dev *dev) {
drivers/net/intel/ixgbe/ixgbe_ethdev.h +4 -12
@@ -301,8 +301,6 @@ struct ixgbe_ethertype_table {* Structure to store filters' info. */ struct ixgbe_filter_info { -/* store the rss filter info */ -struct ixgbe_rss_conf rss_info;/* shared EtherType (ETQF) slot table */ struct ixgbe_ethertype_table ethertype_table;/* 1588 timestamping ETQF slot (valid when timesync_installed) */
@@ -319,10 +317,9 @@ struct ixgbe_l2_tn_info {uint16_t e_tag_ether_type;/* ether type for e-tag */ }; +/* no driver-specific data needed */ struct rte_flow {struct ci_flow flow; -enum rte_filter_type filter_type; -void *rule; };struct ixgbe_macsec_setting {
@@ -430,9 +427,6 @@ struct ixgbe_tm_conf {bool committed; }; -struct ixgbe_filter_ele_base ; -TAILQ_HEAD (ixgbe_filter_ele_list, ixgbe_filter_ele_base); -/* * Structure to store private data for each driver instance (for each port). */
@@ -453,7 +447,6 @@ struct ixgbe_adapter {struct ixgbe_bypass_info bps;#endif /* RTE_LIBRTE_IXGBE_BYPASS */ struct ixgbe_filter_info filter; -struct ixgbe_filter_ele_list flow_list;struct ixgbe_l2_tn_info l2_tn;struct ixgbe_bw_conf bw_conf;struct ixgbe_ipsec ipsec;
@@ -666,8 +659,6 @@ ixgbe_e_tag_filter_add(struct ixgbe_adapter *adapter,int ixgbe_e_tag_filter_del (struct ixgbe_adapter *adapter,struct ixgbe_l2_tunnel_conf *l2_tunnel); -void ixgbe_filterlist_init (struct rte_eth_dev *dev); -void ixgbe_filterlist_flush (struct rte_eth_dev *dev);/* * Flow director function prototypes */
@@ -735,8 +726,9 @@ int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx, uint32_t tx_rate);int ixgbe_rss_conf_init (struct ixgbe_rss_conf *out,const struct rte_flow_action_rss *in); -int ixgbe_config_rss_filter (struct ixgbe_adapter *adapter, -const struct ixgbe_rss_conf *conf,bool add); +void ixgbe_hw_rss_filter_program (struct ixgbe_hw *hw, +const struct ixgbe_rss_conf *conf); +void ixgbe_hw_rss_filter_clear (struct ixgbe_hw *hw);void ixgbe_dev_macsec_register_enable (struct rte_eth_dev *dev,struct ixgbe_macsec_setting *macsec_setting);
drivers/net/intel/ixgbe/ixgbe_flow.c +8 -415
484 lines not on this page · raw message
drivers/net/intel/ixgbe/ixgbe_flow.h +1 -0
@@ -22,5 +22,6 @@ extern const struct ci_flow_engine ixgbe_ntuple_flow_engine;extern const struct ci_flow_engine ixgbe_security_flow_engine;extern const struct ci_flow_engine ixgbe_fdir_flow_engine;extern const struct ci_flow_engine ixgbe_fdir_tunnel_flow_engine; +extern const struct ci_flow_engine ixgbe_hash_flow_engine;#endif /* _IXGBE_FLOW_H_ */
drivers/net/intel/ixgbe/ixgbe_flow_hash.c new file +216 -0
216 lines not on this page · raw message
drivers/net/intel/ixgbe/ixgbe_rxtx.c +9 -34
70 lines not on this page · raw message
drivers/net/intel/ixgbe/meson.build +1 -0
@@ -32,6 +32,7 @@ sources += files( 'ixgbe_flow_ntuple.c', 'ixgbe_flow_security.c', 'ixgbe_flow_fdir.c', + 'ixgbe_flow_hash.c', 'ixgbe_ipsec.c', 'ixgbe_pf.c', 'ixgbe_rxtx.c',
Signature · 1 line
2.52.0
PATCH v7 18/25 net/ixgbe: advertise flow keep capability
In reply to Anatoly BurakovThe ixgbe driver's rte_flow implementation has always endeavored to keep flows across device restart, however it never advertised this capability. Advertise it explicitly.
--- doc/guides/rel_notes/release_26_11.rst | 7 +++++-- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_26_11.rst +5 -2
@@ -103,8 +103,11 @@ New Features * **Updated Intel ixgbe driver.** - Added ``fdir_buffer_size`` devarg to select the Flow Director table size - (``64k``, ``128k`` or ``256k``) at probe time. The default remains ``64k``. + * Added ``fdir_buffer_size`` devarg to select the Flow Director table size + (``64k``, ``128k`` or ``256k``) at probe time. The default remains ``64k``. + + * Advertised ``RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP`` capability, + as flow rules were already kept across device restart. * **Updated NXP DPAA2 ethernet driver.**
drivers/net/intel/ixgbe/ixgbe_ethdev.c +3 -0
@@ -3916,6 +3916,9 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->reta_size =ixgbe_reta_size_get (hw->mac.type); dev_info->flow_type_rss_offloads =IXGBE_RSS_OFFLOAD_ALL ; +/* rte_flow rules are kept across dev_stop/dev_start and replayed on start */ + dev_info->dev_capa |=RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP ; + dev_info->speed_capa =RTE_ETH_LINK_SPEED_1G |RTE_ETH_LINK_SPEED_10G ;if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L )
Signature · 1 line
2.52.0
PATCH v7 19/25 net/i40e: add support for common flow parsing
In reply to Anatoly BurakovImplement support for common flow parsing infrastructure in preparation for migration of flow engines. The following features are enabled:
- Conf init on dev_init
- Conf uninit on dev_close
- Flow replay on dev_start
Currently, i40e explicitly clears KEEP_FLOW capability flag, meaning that it advertises that all flows are flushed on dev stop. However, in practice i40e actually restores all flows on dev start, so while we will not (yet) advertise the KEEP_FLOW capability flag, we will also not flush the flows on dev stop with the new engines, and instead replay them.
--- drivers/net/intel/i40e/i40e_ethdev.c | 21 +++++++++++ drivers/net/intel/i40e/i40e_ethdev.h | 5 +++ drivers/net/intel/i40e/i40e_flow.c | 53 +++++++++++++++++++++++++++- drivers/net/intel/i40e/i40e_flow.h | 12 +++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 drivers/net/intel/i40e/i40e_flow.h
drivers/net/intel/i40e/i40e_ethdev.c +21 -0
@@ -42,6 +42,9 @@#include "i40e_regs.h" #include "rte_pmd_i40e.h" #include "i40e_hash.h" +#include "i40e_flow.h" + +#include "../common/flow_engine.h" #define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb"#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list"
@@ -1838,6 +1841,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)if (ret <0 ) goto err_init_fdir_filter_list; +/* initialize flow engine configuration */ + ret =ci_flow_engine_conf_init (&pf->flow_engine_conf, + &i40e_flow_engine_list, dev->data); +if (ret <0 ) + goto err_flow_engine_conf_init; +/* initialize queue region configuration */ i40e_init_queue_region_conf (dev);
@@ -1846,6 +1855,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)return 0 ; +err_flow_engine_conf_init: +rte_free (pf->fdir.fdir_flow_pool.bitmap); +rte_free (pf->fdir.fdir_flow_pool.pool); +rte_free (pf->fdir.fdir_filter_array); +rte_free (pf->fdir.hash_map); +rte_hash_free (pf->fdir.hash_table); err_init_fdir_filter_list:rte_hash_free (pf->tunnel.hash_table);rte_free (pf->tunnel.hash_map);
@@ -2613,6 +2628,8 @@ i40e_dev_start(struct rte_eth_dev *dev)/* Set the max frame size to HW*/ i40e_aq_set_mac_config (hw, max_frame_size, TRUE, false,0 ,NULL ); +ci_flow_engine_conf_replay (&pf->flow_engine_conf); +return I40E_SUCCESS ; tx_err:
@@ -2715,6 +2732,10 @@ i40e_dev_close(struct rte_eth_dev *dev) ret =i40e_dev_stop (dev); +/* free the flows and reset flow config */ +ci_flow_engine_conf_cleanup (&pf->flow_engine_conf); +ci_flow_engine_conf_reset (&pf->flow_engine_conf); +i40e_dev_free_queues (dev);/* Disable interrupt */
drivers/net/intel/i40e/i40e_ethdev.h +5 -0
@@ -21,6 +21,8 @@#include "base/i40e_type.h" #include "base/virtchnl.h" +#include "../common/flow_engine.h" +#define I40E_AQ_LEN 32#define I40E_AQ_BUF_SZ 4096/* Number of queues per TC should be one of 1, 2, 4, 8, 16, 32, 64 */
@@ -278,6 +280,7 @@ enum i40e_flxpld_layer_idx {* Struct to store flow created. */ struct rte_flow { +struct ci_flow base;TAILQ_ENTRY (rte_flow) node;enum rte_filter_type filter_type;void *rule;
@@ -1182,6 +1185,8 @@ struct i40e_pf {/* The floating enable flag for the specific VF */ bool floating_veb_list[I40E_MAX_VF ];struct i40e_flow_list flow_list; +/* flow engine configuration */ +struct ci_flow_engine_conf flow_engine_conf;bool mpls_replace_flag;/* 1 - MPLS filter replace is done */ bool gtp_replace_flag;/* 1 - GTP-C/U filter replace is done */ bool qinq_replace_flag;/* QINQ filter replace is done */
drivers/net/intel/i40e/i40e_flow.c +52 -1
107 lines not on this page · raw message
drivers/net/intel/i40e/i40e_flow.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2026 Intel Corporation +*/ + +#ifndef _I40E_FLOW_H_ +#define _I40E_FLOW_H_ + +#include "../common/flow_engine.h" + +extern const struct ci_flow_engine_list i40e_flow_engine_list; + +#endif /* _I40E_FLOW_H_ */
Signature · 1 line
2.52.0
Re: [PATCH v7 19/25] net/i40e: add support for common flow parsing
Quoted 16 lines · Anatoly Burakov
Implement support for common flow parsing infrastructure in preparation for migration of flow engines. The following features are enabled:
- Conf init on
dev_init
- Conf uninit ondev_close
- Flow replay ondev_startCurrently, i40e explicitly clears
KEEP_FLOWcapability flag, meaning that it advertises that all flows are flushed on dev stop. However, in practice i40e actually restores all flows on dev start, so while we will not (yet) advertise theKEEP_FLOWcapability flag, we will also not flush the flows on dev stop with the new engines, and instead replay them.Signed-off-by Anatoly Burakov <[email protected]>
Quoted 8 lines
--- drivers/net/intel/i40e/i40e_ethdev.c | 21 +++++++++++ drivers/net/intel/i40e/i40e_ethdev.h | 5 +++ drivers/net/intel/i40e/i40e_flow.c | 53 +++++++++++++++++++++++++++- drivers/net/intel/i40e/i40e_flow.h | 12 +++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 drivers/net/intel/i40e/i40e_flow.h
This fails to build for arm, due to missing include of stdlib.h for calloc() and free().
Will fix on apply.
PATCH v7 20/25 net/i40e: reimplement ethertype parser
In reply to Anatoly BurakovUse the new flow graph API and the common parsing framework to implement flow parser for Ethertype.
The ethertype filter tracking has been moved completely inside the new engine, and the ethertype code is refactored to enabled that use case by decoupling hardware writes from software tracking.
--- drivers/net/intel/i40e/i40e_ethdev.c | 260 +------------- drivers/net/intel/i40e/i40e_ethdev.h | 30 +- drivers/net/intel/i40e/i40e_flow.c | 298 +--------------- drivers/net/intel/i40e/i40e_flow.h | 4 + drivers/net/intel/i40e/i40e_flow_ethertype.c | 351 +++++++++++++++++++ drivers/net/intel/i40e/meson.build | 1 + 6 files changed, 370 insertions(+), 574 deletions(-) create mode 100644 drivers/net/intel/i40e/i40e_flow_ethertype.c
drivers/net/intel/i40e/i40e_ethdev.c +2 -258
@@ -392,12 +392,6 @@ static int i40e_set_default_mac_addr(struct rte_eth_dev *dev,static int i40e_dev_mtu_set (struct rte_eth_dev *dev,uint16_t mtu); -static int i40e_ethertype_filter_convert ( -const struct rte_eth_ethertype_filter *input, -struct i40e_ethertype_filter *filter); -static int i40e_sw_ethertype_filter_insert (struct i40e_pf *pf, -struct i40e_ethertype_filter *filter); -static int i40e_tunnel_filter_convert (struct i40e_aqc_cloud_filters_element_bb *cld_filter,struct i40e_tunnel_filter *tunnel_filter);
@@ -405,7 +399,6 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf, struct i40e_tunnel_filter *tunnel_filter);static int i40e_cloud_filter_qinq_create (struct i40e_pf *pf); -static void i40e_ethertype_filter_restore (struct i40e_pf *pf);static void i40e_tunnel_filter_restore (struct i40e_pf *pf);static void i40e_filter_restore (struct i40e_pf *pf);static void i40e_notify_all_vfs_link_status (struct rte_eth_dev *dev);
@@ -1003,51 +996,6 @@ config_floating_veb(struct rte_eth_dev *dev)#define I40E_L2_TAGS_S_TAG_SHIFT 1#define I40E_L2_TAGS_S_TAG_MASK I40E_MASK(0x1, I40E_L2_TAGS_S_TAG_SHIFT) -static int -i40e_init_ethtype_filter_list (struct rte_eth_dev *dev) -{ -struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); -struct i40e_ethertype_rule *ethertype_rule = &pf->ethertype; -char ethertype_hash_name[RTE_HASH_NAMESIZE ]; -int ret; - -struct rte_hash_parameters ethertype_hash_params = { - .name = ethertype_hash_name, - .entries =I40E_MAX_ETHERTYPE_FILTER_NUM , - .key_len =sizeof (struct i40e_ethertype_filter_input ), - .hash_func = rte_hash_crc, - .hash_func_init_val =0 , - .socket_id =rte_socket_id (), - }; - -/* Initialize ethertype filter rule list and hash */ -TAILQ_INIT (ðertype_rule->ethertype_list); -snprintf (ethertype_hash_name,RTE_HASH_NAMESIZE , -"ethertype_%s" , dev->device->name); - ethertype_rule->hash_table =rte_hash_create (ðertype_hash_params); -if (!ethertype_rule->hash_table) { -PMD_INIT_LOG (ERR ,"Failed to create ethertype hash table!" ); -return -EINVAL ; - } - ethertype_rule->hash_map =rte_zmalloc ("i40e_ethertype_hash_map" , -sizeof (struct i40e_ethertype_filter *) * -I40E_MAX_ETHERTYPE_FILTER_NUM , -0 ); -if (!ethertype_rule->hash_map) { -PMD_INIT_LOG (ERR , -"Failed to allocate memory for ethertype hash map!" ); - ret = -ENOMEM ; - goto err_ethertype_hash_map_alloc; - } - -return 0 ; - -err_ethertype_hash_map_alloc: -rte_hash_free (ethertype_rule->hash_table); - -return ret; -} -static int i40e_init_tunnel_filter_list (struct rte_eth_dev *dev) {
@@ -1831,9 +1779,6 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)/* Initialize the filter invalidation configuration */ i40e_init_filter_invalidation (pf); - ret =i40e_init_ethtype_filter_list (dev); -if (ret <0 ) - goto err_init_ethtype_filter_list; ret =i40e_init_tunnel_filter_list (dev);if (ret <0 ) goto err_init_tunnel_filter_list;
@@ -1865,9 +1810,6 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)rte_hash_free (pf->tunnel.hash_table);rte_free (pf->tunnel.hash_map); err_init_tunnel_filter_list: -rte_hash_free (pf->ethertype.hash_table); -rte_free (pf->ethertype.hash_map); -err_init_ethtype_filter_list:rte_intr_callback_unregister (intr_handle, i40e_dev_interrupt_handler, dev);rte_free (dev->data->mac_addrs);
@@ -1890,24 +1832,6 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)return ret; } -static void -i40e_rm_ethtype_filter_list (struct i40e_pf *pf) -{ -struct i40e_ethertype_filter *p_ethertype; -struct i40e_ethertype_rule *ethertype_rule; - - ethertype_rule = &pf->ethertype; -/* Remove all ethertype filter rules and hash */ -rte_free (ethertype_rule->hash_map); -rte_hash_free (ethertype_rule->hash_table); - -while ((p_ethertype =TAILQ_FIRST (ðertype_rule->ethertype_list))) { -TAILQ_REMOVE (ðertype_rule->ethertype_list, - p_ethertype, rules); -rte_free (p_ethertype); - } -} -static void i40e_rm_tunnel_filter_list (struct i40e_pf *pf) {
@@ -2805,7 +2729,6 @@ i40e_dev_close(struct rte_eth_dev *dev)i40e_msec_delay (500 ); }while (retries++ <5 ); -i40e_rm_ethtype_filter_list (pf);i40e_rm_tunnel_filter_list (pf);i40e_rm_fdir_filter_list (pf);
@@ -9891,130 +9814,16 @@ i40e_set_hash_inset(struct i40e_hw *hw, uint64_t input_set,return 0 ; } -/* Convert ethertype filter structure */ -static int -i40e_ethertype_filter_convert (const struct rte_eth_ethertype_filter *input, -struct i40e_ethertype_filter *filter) -{ -memcpy (&filter->input.mac_addr, &input->mac_addr, -RTE_ETHER_ADDR_LEN ); - filter->input.ether_type = input->ether_type; - filter->flags = input->flags; - filter->queue = input->queue; - -return 0 ; -} - -/* Check if there exists the ethertype filter */ -struct i40e_ethertype_filter * -i40e_sw_ethertype_filter_lookup (struct i40e_ethertype_rule *ethertype_rule, -const struct i40e_ethertype_filter_input *input) -{ -int ret; - - ret =rte_hash_lookup (ethertype_rule->hash_table, (const void *)input); -if (ret <0 ) -return NULL ; - -return ethertype_rule->hash_map[ret]; -} - -/* Add ethertype filter in SW list */ -static int -i40e_sw_ethertype_filter_insert (struct i40e_pf *pf, -struct i40e_ethertype_filter *filter) -{ -struct i40e_ethertype_rule *rule = &pf->ethertype; -int ret; - - ret =rte_hash_add_key (rule->hash_table, &filter->input); -if (ret <0 ) { -PMD_DRV_LOG (ERR , -"Failed to insert ethertype filter" -" to hash table %d!" , - ret); -return ret; - } - rule->hash_map[ret] = filter; - -TAILQ_INSERT_TAIL (&rule->ethertype_list, filter, rules); - -return 0 ; -} - -/* Delete ethertype filter in SW list */ int -i40e_sw_ethertype_filter_del (struct i40e_pf *pf, -struct i40e_ethertype_filter_input *input) -{ -struct i40e_ethertype_rule *rule = &pf->ethertype; -struct i40e_ethertype_filter *filter; -int ret; - - ret =rte_hash_del_key (rule->hash_table, input); -if (ret <0 ) { -PMD_DRV_LOG (ERR , -"Failed to delete ethertype filter" -" to hash table %d!" , - ret); -return ret; - } - filter = rule->hash_map[ret]; - rule->hash_map[ret] =NULL ; - -TAILQ_REMOVE (&rule->ethertype_list, filter, rules); -rte_free (filter); - -return 0 ; -} - -/* -* Configure ethertype filter, which can director packet by filtering -* with mac address and ether_type or only ether_type -*/ -int -i40e_ethertype_filter_set (struct i40e_pf *pf, +i40e_ethertype_filter_program (struct i40e_pf *pf,struct rte_eth_ethertype_filter *filter,bool add) {struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct i40e_ethertype_rule *ethertype_rule = &pf->ethertype; -struct i40e_ethertype_filter *ethertype_filter, *node; -struct i40e_ethertype_filter check_filter;struct i40e_control_filter_stats stats;uint16_t flags =0 ;int ret; -if (filter->queue >= pf->dev_data->nb_rx_queues) { -PMD_DRV_LOG (ERR ,"Invalid queue ID" ); -return -EINVAL ; - } -if (filter->ether_type ==RTE_ETHER_TYPE_IPV4 || - filter->ether_type ==RTE_ETHER_TYPE_IPV6 ) { -PMD_DRV_LOG (ERR , -"unsupported ether_type(0x%04x) in control packet filter." , - filter->ether_type); -return -EINVAL ; - } -if (filter->ether_type ==RTE_ETHER_TYPE_VLAN ) -PMD_DRV_LOG (WARNING , -"filter vlan ether_type in first tag is not supported." ); - -/* Check if there is the filter in SW list */ -memset (&check_filter,0 ,sizeof (check_filter)); -i40e_ethertype_filter_convert (filter, &check_filter); - node =i40e_sw_ethertype_filter_lookup (ethertype_rule, - &check_filter.input); -if (add && node) { -PMD_DRV_LOG (ERR ,"Conflict with existing ethertype rules!" ); -return -EINVAL ; - } - -if (!add && !node) { -PMD_DRV_LOG (ERR ,"There's no corresponding ethertype filter!" ); -return -EINVAL ; - } -if (!(filter->flags &RTE_ETHTYPE_FLAGS_MAC )) flags |=I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC ;if (filter->flags &RTE_ETHTYPE_FLAGS_DROP )
@@ -10035,25 +9844,7 @@ i40e_ethertype_filter_set(struct i40e_pf *pf,if (ret <0 )return -ENOSYS ; -/* Add or delete a filter in SW list */ -if (add) { - ethertype_filter =rte_zmalloc ("ethertype_filter" , -sizeof (*ethertype_filter),0 ); -if (ethertype_filter ==NULL ) { -PMD_DRV_LOG (ERR ,"Failed to alloc memory." ); -return -ENOMEM ; - } - -memcpy (ethertype_filter, &check_filter, -sizeof (check_filter)); - ret =i40e_sw_ethertype_filter_insert (pf, ethertype_filter); -if (ret <0 ) -rte_free (ethertype_filter); - }else { - ret =i40e_sw_ethertype_filter_del (pf, &node->input); - } - -return ret; +return 0 ; } static int
@@ -11624,52 +11415,6 @@ i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused)return 0 ; } -/* Restore ethertype filter */ -static void -i40e_ethertype_filter_restore (struct i40e_pf *pf) -{ -struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct i40e_ethertype_filter_list - *ethertype_list = &pf->ethertype.ethertype_list; -struct i40e_ethertype_filter *f; -struct i40e_control_filter_stats stats; -enum i40e_status_code ret; -uint16_t flags; -bool stats_valid = false; - - TAILQ_FOREACH(f, ethertype_list, rules) { - flags =0 ; -if (!(f->flags &RTE_ETHTYPE_FLAGS_MAC )) - flags |=I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC ; -if (f->flags &RTE_ETHTYPE_FLAGS_DROP ) - flags |=I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP ; - flags |=I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE ; - - ret =i40e_aq_add_rem_control_packet_filter (hw, - f->input.mac_addr.addr_bytes, - f->input.ether_type, - flags, pf->main_vsi->seid, - f->queue,1 , &stats,NULL ); -if (ret !=I40E_SUCCESS ) { -PMD_DRV_LOG (ERR , -"Failed to restore ethertype filter, ether_type=0x%04x, queue=%u, vsi_seid=%u, err %d" , - f->input.ether_type, f->queue, - pf->main_vsi->seid, ret); -continue ; - } - - stats_valid = true; - } - -if (stats_valid) { -PMD_DRV_LOG (INFO ,"Ethertype filter:" -" mac_etype_used = %u, etype_used = %u," -" mac_etype_free = %u, etype_free = %u" , - stats.mac_etype_used, stats.etype_used, - stats.mac_etype_free, stats.etype_free); - } -} -/* Restore tunnel filter */ static void i40e_tunnel_filter_restore (struct i40e_pf *pf)
@@ -11728,7 +11473,6 @@ i40e_tunnel_filter_restore(struct i40e_pf *pf)static void i40e_filter_restore (struct i40e_pf *pf) { -i40e_ethertype_filter_restore (pf);i40e_tunnel_filter_restore (pf);i40e_fdir_filter_restore (pf); (void )i40e_hash_filter_restore (pf);
drivers/net/intel/i40e/i40e_ethdev.h +1 -29
@@ -805,27 +805,6 @@ struct i40e_fdir_info {/* Ethertype filter number HW supports */ #define I40E_MAX_ETHERTYPE_FILTER_NUM 768 -/* Ethertype filter struct */ -struct i40e_ethertype_filter_input { -struct rte_ether_addr mac_addr;/* Mac address to match */ -uint16_t ether_type;/* Ether type to match */ -}; - -struct i40e_ethertype_filter { -TAILQ_ENTRY (i40e_ethertype_filter) rules; -struct i40e_ethertype_filter_input input; -uint16_t flags;/* Flags from RTE_ETHTYPE_FLAGS_* */ -uint16_t queue;/* Queue assigned to when match */ -}; - -TAILQ_HEAD (i40e_ethertype_filter_list, i40e_ethertype_filter); - -struct i40e_ethertype_rule { -struct i40e_ethertype_filter_list ethertype_list; -struct i40e_ethertype_filter **hash_map; -struct rte_hash *hash_table; -}; -/* queue region info */ struct i40e_queue_region_info {/* the region id for this configuration */
@@ -1176,7 +1155,6 @@ struct i40e_pf {struct i40e_vmdq_info *vmdq;struct i40e_fdir_info fdir;/* flow director info */ -struct i40e_ethertype_rule ethertype;/* Ethertype filter rule */ struct i40e_tunnel_rule tunnel;/* Tunnel filter rule */ struct i40e_rss_conf_list rss_config_list;/* RSS rule list */ struct i40e_queue_regions queue_region;/* queue region info */
@@ -1325,7 +1303,6 @@ extern const struct rte_flow_ops i40e_flow_ops;struct i40e_filter_ctx {union { -struct rte_eth_ethertype_filter ethertype_filter;struct i40e_fdir_filter_conf fdir_filter;struct i40e_tunnel_filter_conf consistent_tunnel_filter;struct i40e_rte_flow_rss_conf rss_conf;
@@ -1407,11 +1384,6 @@ int i40e_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id, struct rte_eth_burst_mode *mode);int i40e_tx_burst_mode_get (struct rte_eth_dev *dev,uint16_t queue_id,struct rte_eth_burst_mode *mode); -struct i40e_ethertype_filter * -i40e_sw_ethertype_filter_lookup (struct i40e_ethertype_rule *ethertype_rule, -const struct i40e_ethertype_filter_input *input); -int i40e_sw_ethertype_filter_del (struct i40e_pf *pf, -struct i40e_ethertype_filter_input *input);int i40e_sw_fdir_filter_del (struct i40e_pf *pf,struct i40e_fdir_input *input); struct i40e_tunnel_filter *
@@ -1420,7 +1392,7 @@ i40e_sw_tunnel_filter_lookup(struct i40e_tunnel_rule *tunnel_rule,int i40e_sw_tunnel_filter_del (struct i40e_pf *pf,struct i40e_tunnel_filter_input *input);uint64_t i40e_get_default_input_set (uint16_t pctype); -int i40e_ethertype_filter_set (struct i40e_pf *pf, +int i40e_ethertype_filter_program (struct i40e_pf *pf,struct rte_eth_ethertype_filter *filter,bool add); struct rte_flow *
drivers/net/intel/i40e/i40e_flow.c +11 -287
398 lines not on this page · raw message
drivers/net/intel/i40e/i40e_flow.h +4 -0
@@ -7,6 +7,10 @@#include "../common/flow_engine.h" +int i40e_get_outer_vlan (struct i40e_pf *pf,uint16_t *tpid); +extern const struct ci_flow_engine_list i40e_flow_engine_list; +extern const struct ci_flow_engine i40e_flow_engine_ethertype; +#endif /* _I40E_FLOW_H_ */
drivers/net/intel/i40e/i40e_flow_ethertype.c new file +351 -0
351 lines not on this page · raw message
drivers/net/intel/i40e/meson.build +1 -0
@@ -33,6 +33,7 @@ sources += files( 'i40e_pf.c', 'i40e_fdir.c', 'i40e_flow.c', + 'i40e_flow_ethertype.c', 'i40e_tm.c', 'i40e_hash.c', 'i40e_vf_representor.c',
Signature · 1 line
2.52.0
PATCH v7 21/25 net/i40e: refactor FDIR engine infrastructure
In reply to Anatoly BurakovCurrently, there are multiple problems with how i40e flow directory feature is implemented, both in terms of how it works with rte_flow, and how it integrates with the PMD-specific packet template API.
For one, these two subsystems, while using shared infrastructure, do not really interact or cooperate, and are built on top of special cases in FDIR path. More specifically, the packet template code does not store its packet in the hash map, and has a different hashing scheme, yet it still registers itself in FDIR flow list, hash table, and hash map. This list is then used by dev_start to restore FDIR filters that user has inserted into the list. These filters, as written, cannot be reprogrammed that way because the information a filter restore function would need is lost on insert (the packet pointer is not added to the hash map).
Another issue is that while rte_flow FDIR code does lazy FDIR init on first added flow, the packet template API does not, even though it too relies on the same hardware feature, nor does it ever do teardown on last FDIR flow.
Yet another issue is how the "filter restore" code itself is implemented, namely that currently it simply does not work. When doing filter restore, the driver will walk every FDIR filter stored in the TAILQ, and attempt to program it. However, inside the program function, there is a deduplication check (to see if flow being installed is already present in the flow hash table), which fails because the flows we are programming come from the same list that is being checked for deduplication, which makes the entire filter restore a no-op.
The FDIR filter programming code itself also has a number of readability problems as well as being otherwise hard to use - SW bookkeeping, validation, and flow programming is interspersed within the code, and it is difficult to reason about what happens when the code is called from this or that context.
So, this refactor does the following:
- Reorganize FDIR internals to track packet templates and rte_flow FDIR flows separately
- Refactor FDIR init/teardown to always happen on first/last rule, so that whichever API happens to call FDIR first, the state is consistent
- Rework the FDIR code to disentangle FDIR flow rule programming, Flex PIT checks, SW bookkeeping, etc. from each other
- Remove both the rte_flow FDIR TAILQ and the hash map (filter array) structure, because they are redundant (information about the flow is already stored in the rte_flow flow list, and hash_map structure only stored pointers to data we also have in that same list)
- Fix FDIR filter restore to replay all configuration correctly, as well as re-init the FDIR queue enablement tracking
- Rework the internal FDIR global state data structure to make a little more sense by grouping things that belong together into structures
Additionally, there was a delay mechanism at flow director rule program time, as when programming a rule we might not know if it's actually possible to install the rule, because space for the rules may come either from our own pool, or it may come from a pool that is shared with other VSI's. However, it only makes sense to wait on rule create (i.e. when it is programmed into the hardware for the first time), but not when we are replaying or removing these rules. So, adjust the waiting mechanism to only wait on FDIR rule creation.
--- drivers/net/intel/i40e/i40e_ethdev.c | 169 +--- drivers/net/intel/i40e/i40e_ethdev.h | 128 ++- drivers/net/intel/i40e/i40e_fdir.c | 1173 +++++++++++++++++-------- drivers/net/intel/i40e/i40e_flow.c | 136 +-- drivers/net/intel/i40e/rte_pmd_i40e.c | 6 +- 5 files changed, 966 insertions(+), 646 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +14 -155
@@ -1041,129 +1041,6 @@ i40e_init_tunnel_filter_list(struct rte_eth_dev *dev)return ret; } -static int -i40e_init_fdir_filter_list (struct rte_eth_dev *dev) -{ -struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); -struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct i40e_fdir_info *fdir_info = &pf->fdir; -char fdir_hash_name[RTE_HASH_NAMESIZE ]; -uint32_t alloc = hw->func_caps.fd_filters_guaranteed; -uint32_t best = hw->func_caps.fd_filters_best_effort; -enum i40e_filter_pctype pctype; -struct rte_bitmap *bmp =NULL ; -uint32_t bmp_size; -void *mem =NULL ; -uint32_t i =0 ; -int ret; - -struct rte_hash_parameters fdir_hash_params = { - .name = fdir_hash_name, - .entries =I40E_MAX_FDIR_FILTER_NUM , - .key_len =sizeof (struct i40e_fdir_input ), - .hash_func = rte_hash_crc, - .hash_func_init_val =0 , - .socket_id =rte_socket_id (), - }; - -/* Initialize flow director filter rule list and hash */ -TAILQ_INIT (&fdir_info->fdir_list); -snprintf (fdir_hash_name,RTE_HASH_NAMESIZE , -"fdir_%s" , dev->device->name); - fdir_info->hash_table =rte_hash_create (&fdir_hash_params); -if (!fdir_info->hash_table) { -PMD_INIT_LOG (ERR ,"Failed to create fdir hash table!" ); -return -EINVAL ; - } - - fdir_info->hash_map =rte_zmalloc ("i40e_fdir_hash_map" , -sizeof (struct i40e_fdir_filter *) * -I40E_MAX_FDIR_FILTER_NUM , -0 ); -if (!fdir_info->hash_map) { -PMD_INIT_LOG (ERR , -"Failed to allocate memory for fdir hash map!" ); - ret = -ENOMEM ; - goto err_fdir_hash_map_alloc; - } - - fdir_info->fdir_filter_array =rte_zmalloc ("fdir_filter" , -sizeof (struct i40e_fdir_filter ) * -I40E_MAX_FDIR_FILTER_NUM , -0 ); - -if (!fdir_info->fdir_filter_array) { -PMD_INIT_LOG (ERR , -"Failed to allocate memory for fdir filter array!" ); - ret = -ENOMEM ; - goto err_fdir_filter_array_alloc; - } - -for (pctype =I40E_FILTER_PCTYPE_NONF_IPV4_UDP ; - pctype <=I40E_FILTER_PCTYPE_L2_PAYLOAD ; pctype++) - pf->fdir.flow_count[pctype] =0 ; - - fdir_info->fdir_space_size = alloc + best; - fdir_info->fdir_actual_cnt =0 ; - fdir_info->fdir_guarantee_total_space = alloc; - fdir_info->fdir_guarantee_free_space = - fdir_info->fdir_guarantee_total_space; - -PMD_DRV_LOG (INFO ,"FDIR guarantee space: %u, best_effort space %u." , alloc, best); - - fdir_info->fdir_flow_pool.pool = -rte_zmalloc ("i40e_fdir_entry" , -sizeof (struct i40e_fdir_entry ) * - fdir_info->fdir_space_size, -0 ); - -if (!fdir_info->fdir_flow_pool.pool) { -PMD_INIT_LOG (ERR , -"Failed to allocate memory for bitmap flow!" ); - ret = -ENOMEM ; - goto err_fdir_bitmap_flow_alloc; - } - -for (i =0 ; i < fdir_info->fdir_space_size; i++) - fdir_info->fdir_flow_pool.pool[i].idx = i; - - bmp_size = -rte_bitmap_get_memory_footprint (fdir_info->fdir_space_size); - mem =rte_zmalloc ("fdir_bmap" , bmp_size,RTE_CACHE_LINE_SIZE ); -if (mem ==NULL ) { -PMD_INIT_LOG (ERR , -"Failed to allocate memory for fdir bitmap!" ); - ret = -ENOMEM ; - goto err_fdir_mem_alloc; - } - bmp =rte_bitmap_init (fdir_info->fdir_space_size, mem, bmp_size); -if (bmp ==NULL ) { -PMD_INIT_LOG (ERR , -"Failed to initialization fdir bitmap!" ); - ret = -ENOMEM ; - goto err_fdir_bmp_alloc; - } -for (i =0 ; i < fdir_info->fdir_space_size; i++) -rte_bitmap_set (bmp, i); - - fdir_info->fdir_flow_pool.bitmap = bmp; - -return 0 ; - -err_fdir_bmp_alloc: -rte_free (mem); -err_fdir_mem_alloc: -rte_free (fdir_info->fdir_flow_pool.pool); -err_fdir_bitmap_flow_alloc: -rte_free (fdir_info->fdir_filter_array); -err_fdir_filter_array_alloc: -rte_free (fdir_info->hash_map); -err_fdir_hash_map_alloc: -rte_hash_free (fdir_info->hash_table); - -return ret; -} -static void i40e_init_customized_info (struct i40e_pf *pf) {
@@ -1782,9 +1659,9 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused) ret =i40e_init_tunnel_filter_list (dev);if (ret <0 ) goto err_init_tunnel_filter_list; - ret =i40e_init_fdir_filter_list (dev); + ret =i40e_fdir_flow_store_init (dev);if (ret <0 ) - goto err_init_fdir_filter_list; + goto err_init_fdir_flow_store;/* initialize flow engine configuration */ ret = ci_flow_engine_conf_init(&pf->flow_engine_conf,
@@ -1801,12 +1678,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)return 0 ; err_flow_engine_conf_init: -rte_free (pf->fdir.fdir_flow_pool.bitmap); -rte_free (pf->fdir.fdir_flow_pool.pool); -rte_free (pf->fdir.fdir_filter_array); -rte_free (pf->fdir.hash_map); -rte_hash_free (pf->fdir.hash_table); -err_init_fdir_filter_list: +i40e_fdir_flow_store_free (&pf->fdir); +err_init_fdir_flow_store:rte_hash_free (pf->tunnel.hash_table);rte_free (pf->tunnel.hash_map); err_init_tunnel_filter_list:
@@ -1849,32 +1722,13 @@ i40e_rm_tunnel_filter_list(struct i40e_pf *pf) } } -static void -i40e_rm_fdir_filter_list (struct i40e_pf *pf) -{ -struct i40e_fdir_filter *p_fdir; -struct i40e_fdir_info *fdir_info; - - fdir_info = &pf->fdir; - -/* Remove all flow director rules */ -while ((p_fdir =TAILQ_FIRST (&fdir_info->fdir_list))) -TAILQ_REMOVE (&fdir_info->fdir_list, p_fdir, rules); -} -static void i40e_fdir_memory_cleanup (struct i40e_pf *pf) { -struct i40e_fdir_info *fdir_info; +struct i40e_fdir_info *fdir_info = &pf->fdir; - fdir_info = &pf->fdir; - -/* flow director memory cleanup */ -rte_free (fdir_info->hash_map); -rte_hash_free (fdir_info->hash_table); -rte_free (fdir_info->fdir_flow_pool.bitmap); -rte_free (fdir_info->fdir_flow_pool.pool); -rte_free (fdir_info->fdir_filter_array); +i40e_fdir_flow_store_free (fdir_info); +i40e_fdir_tmpl_store_free (fdir_info); }void i40e_flex_payload_reg_set_default (struct i40e_hw *hw)
@@ -2659,6 +2513,7 @@ i40e_dev_close(struct rte_eth_dev *dev)/* free the flows and reset flow config */ ci_flow_engine_conf_cleanup (&pf->flow_engine_conf);ci_flow_engine_conf_reset (&pf->flow_engine_conf); +i40e_fdir_teardown (pf);i40e_dev_free_queues (dev);
@@ -2730,7 +2585,6 @@ i40e_dev_close(struct rte_eth_dev *dev) }while (retries++ <5 );i40e_rm_tunnel_filter_list (pf); -i40e_rm_fdir_filter_list (pf);/* Remove all flows */ while ((p_flow =TAILQ_FIRST (&pf->flow_list))) {
@@ -9758,7 +9612,12 @@ i40e_filter_input_set_init(struct i40e_pf *pf)/* store the default input set */ if (!pf->support_multi_driver) pf->hash_input_set[pctype] = input_set; - pf->fdir.input_set[pctype] = input_set; + { +struct i40e_fdir_pctype_state *state = + &pf->fdir.flows.pctype[pctype]; + + state->input_set = input_set; + } } }
drivers/net/intel/i40e/i40e_ethdev.h +89 -39
186 lines not on this page · raw message
drivers/net/intel/i40e/i40e_fdir.c +811 -362
1,513 lines not on this page · raw message
drivers/net/intel/i40e/i40e_flow.c +48 -88
210 lines not on this page · raw message
drivers/net/intel/i40e/rte_pmd_i40e.c +4 -2
@@ -3044,7 +3044,7 @@ int rte_pmd_i40e_flow_add_del_packet_template( uint8_t add) {struct rte_eth_dev *dev = &rte_eth_devices[port]; -struct i40e_fdir_filter_conf filter_conf; +struct i40e_fdir_filter filter_conf;RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV );
@@ -3068,7 +3068,9 @@ int rte_pmd_i40e_flow_add_del_packet_template( (enum i40e_fdir_status )conf->action.report_status; filter_conf.action.flex_off = conf->action.flex_off; -return i40e_flow_add_del_fdir_filter (dev, &filter_conf, add); +if (add) +return i40e_fdir_tmpl_add (dev, &filter_conf); +return i40e_fdir_tmpl_del (dev, &filter_conf); }RTE_EXPORT_SYMBOL (rte_pmd_i40e_inset_get)
Signature · 1 line
2.52.0
PATCH v7 22/25 net/i40e: reimplement FDIR parser
In reply to Anatoly BurakovUse the new flow graph API and the common parsing framework to implement flow parser for flow director.
As a result of transitioning to more formalized validation, some checks have become more stringent. In particular, some protocols (such as SCTP) were previously accepting non-zero or invalid masks and either ignoring them or misinterpreting them to mean "fully masked". This has now been corrected.
The FDIR engine in i40e has also relied on a custom memory allocation scheme for fdir flows - also migrated to the new infrastructure.
Finally, some of the FDIR infrastructure has been migrated into the new flow engine, so that the engine itself is managing its own allocator and its own flow deduplication scheme, and the FDIR storage and programming has been refactored to manage flow programming with better separation between various parts of the flow programming process.
--- drivers/net/intel/i40e/i40e_ethdev.c | 26 +- drivers/net/intel/i40e/i40e_ethdev.h | 128 +- drivers/net/intel/i40e/i40e_fdir.c | 709 ++------ drivers/net/intel/i40e/i40e_flow.c | 1921 +------------------- drivers/net/intel/i40e/i40e_flow.h | 5 + drivers/net/intel/i40e/i40e_flow_fdir.c | 2160 +++++++++++++++++++++++ drivers/net/intel/i40e/meson.build | 1 + drivers/net/intel/i40e/rte_pmd_i40e.c | 6 + 8 files changed, 2436 insertions(+), 2520 deletions(-) create mode 100644 drivers/net/intel/i40e/i40e_flow_fdir.c
drivers/net/intel/i40e/i40e_ethdev.c +4 -22
@@ -1659,9 +1659,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused) ret =i40e_init_tunnel_filter_list (dev);if (ret <0 ) goto err_init_tunnel_filter_list; - ret =i40e_fdir_flow_store_init (dev); -if (ret <0 ) - goto err_init_fdir_flow_store; +i40e_fdir_flow_store_init (dev);/* initialize flow engine configuration */ ret = ci_flow_engine_conf_init(&pf->flow_engine_conf,
@@ -1678,8 +1676,6 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)return 0 ; err_flow_engine_conf_init: -i40e_fdir_flow_store_free (&pf->fdir); -err_init_fdir_flow_store:rte_hash_free (pf->tunnel.hash_table);rte_free (pf->tunnel.hash_map); err_init_tunnel_filter_list:
@@ -1722,15 +1718,6 @@ i40e_rm_tunnel_filter_list(struct i40e_pf *pf) } } -static void -i40e_fdir_memory_cleanup (struct i40e_pf *pf) -{ -struct i40e_fdir_info *fdir_info = &pf->fdir; - -i40e_fdir_flow_store_free (fdir_info); -i40e_fdir_tmpl_store_free (fdir_info); -} -void i40e_flex_payload_reg_set_default (struct i40e_hw *hw) {/*
@@ -2513,7 +2500,7 @@ i40e_dev_close(struct rte_eth_dev *dev)/* free the flows and reset flow config */ ci_flow_engine_conf_cleanup (&pf->flow_engine_conf);ci_flow_engine_conf_reset (&pf->flow_engine_conf); -i40e_fdir_teardown (pf); +i40e_fdir_cleanup (dev);i40e_dev_free_queues (dev);
@@ -2589,14 +2576,9 @@ i40e_dev_close(struct rte_eth_dev *dev)/* Remove all flows */ while ((p_flow =TAILQ_FIRST (&pf->flow_list))) {TAILQ_REMOVE (&pf->flow_list, p_flow, node); -/* Do not free FDIR flows since they are static allocated */ -if (p_flow->filter_type !=RTE_ETH_FILTER_FDIR ) -rte_free (p_flow); +rte_free (p_flow); } -/* release the fdir static allocated memory */ -i40e_fdir_memory_cleanup (pf); -/* Remove all Traffic Manager configuration */ i40e_tm_conf_uninit (dev);
@@ -9614,7 +9596,7 @@ i40e_filter_input_set_init(struct i40e_pf *pf) pf->hash_input_set[pctype] = input_set; {struct i40e_fdir_pctype_state *state = - &pf->fdir.flows.pctype[pctype]; + &pf->fdir.fdir_state.pctype[pctype]; state->input_set = input_set; }
drivers/net/intel/i40e/i40e_ethdev.h +66 -62
208 lines not on this page · raw message
drivers/net/intel/i40e/i40e_fdir.c +184 -525
1,016 lines not on this page · raw message
drivers/net/intel/i40e/i40e_flow.c +10 -1911
1,712 lines not on this page · raw message
drivers/net/intel/i40e/i40e_flow_fdir.c new file +2160 -0
2,160 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.52.0
Part of the diff is not shown here. View the raw message.
PATCH v7 23/25 net/i40e: reimplement tunnel parsers
In reply to Anatoly BurakovUse the new flow graph API and the common parsing framework to implement flow parser for tunnel filters: QinQ, VXLAN, NVGRE, MPLS, GTP, and L4.
As a result of transitioning to more formalized validation, some checks have become more stringent:
- VLAN TCI mask is now required to be fully masked (all-ones); previously the mask was only checked for eth_proto and any non-zero vlan_tci mask value was silently accepted
- For QinQ, VLAN TCI mask is now required whereas previously it was ignored
- Old code did not check for whether fields other than ports are masked (they are now rejected)
- Old code did not check for whether src/ports are fully masked (masks other than full are now rejected)
- Old code used spec to decide which port to copy (as a result, it was not possible to match port 0 - this is now allowed)
Tunnel engine now also share a refcounted global state, and track all flows and do deduplication inside the engine.
--- drivers/net/intel/i40e/i40e_ethdev.c | 1056 ++--------- drivers/net/intel/i40e/i40e_ethdev.h | 84 +- drivers/net/intel/i40e/i40e_flow.c | 1702 +----------------- drivers/net/intel/i40e/i40e_flow.h | 6 + drivers/net/intel/i40e/i40e_flow_tunnel.c | 1958 +++++++++++++++++++++ drivers/net/intel/i40e/meson.build | 1 + 6 files changed, 2178 insertions(+), 2629 deletions(-) create mode 100644 drivers/net/intel/i40e/i40e_flow_tunnel.c
drivers/net/intel/i40e/i40e_ethdev.c +163 -893
@@ -392,14 +392,6 @@ static int i40e_set_default_mac_addr(struct rte_eth_dev *dev,static int i40e_dev_mtu_set (struct rte_eth_dev *dev,uint16_t mtu); -static int i40e_tunnel_filter_convert ( -struct i40e_aqc_cloud_filters_element_bb *cld_filter, -struct i40e_tunnel_filter *tunnel_filter); -static int i40e_sw_tunnel_filter_insert (struct i40e_pf *pf, -struct i40e_tunnel_filter *tunnel_filter); -static int i40e_cloud_filter_qinq_create (struct i40e_pf *pf); - -static void i40e_tunnel_filter_restore (struct i40e_pf *pf);static void i40e_filter_restore (struct i40e_pf *pf);static void i40e_notify_all_vfs_link_status (struct rte_eth_dev *dev); static int i40e_fec_get_capability(struct rte_eth_dev *dev,
@@ -996,49 +988,43 @@ config_floating_veb(struct rte_eth_dev *dev)#define I40E_L2_TAGS_S_TAG_SHIFT 1#define I40E_L2_TAGS_S_TAG_MASK I40E_MASK(0x1, I40E_L2_TAGS_S_TAG_SHIFT) -static int -i40e_init_tunnel_filter_list (struct rte_eth_dev *dev) +struct i40e_tunnel_state * +i40e_tunnel_state_attach (struct rte_eth_dev_data *dev_data) { -struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); -struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel; -char tunnel_hash_name[RTE_HASH_NAMESIZE ]; -int ret; - -struct rte_hash_parameters tunnel_hash_params = { +struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev_data->dev_private); +struct i40e_tunnel_state *state = &pf->tunnel_state; +char tunnel_hash_name[RTE_HASH_NAMESIZE ] = {0 }; +struct rte_hash_parameters hash_params = { .name = tunnel_hash_name, .entries =I40E_MAX_TUNNEL_FILTER_NUM , - .key_len =sizeof (struct i40e_tunnel_filter_input ), + .key_len =sizeof (struct i40e_tunnel_filter_match_key ), .hash_func = rte_hash_crc, .hash_func_init_val =0 , .socket_id =rte_socket_id (), }; -/* Initialize tunnel filter rule list and hash */ -TAILQ_INIT (&tunnel_rule->tunnel_list); -snprintf (tunnel_hash_name,RTE_HASH_NAMESIZE , -"tunnel_%s" , dev->device->name); - tunnel_rule->hash_table =rte_hash_create (&tunnel_hash_params); -if (!tunnel_rule->hash_table) { -PMD_INIT_LOG (ERR ,"Failed to create tunnel hash table!" ); -return -EINVAL ; - } - tunnel_rule->hash_map =rte_zmalloc ("i40e_tunnel_hash_map" , -sizeof (struct i40e_tunnel_filter *) * -I40E_MAX_TUNNEL_FILTER_NUM , -0 ); -if (!tunnel_rule->hash_map) { -PMD_INIT_LOG (ERR , -"Failed to allocate memory for tunnel hash map!" ); - ret = -ENOMEM ; - goto err_tunnel_hash_map_alloc; +snprintf (tunnel_hash_name,RTE_HASH_NAMESIZE ,"tunnel_%s" , dev_data->name); + +if (ci_usage_count_claim (&state->use_count)) { + state->hash_table =rte_hash_create (&hash_params); +if (state->hash_table ==NULL ) { +PMD_DRV_LOG (ERR ,"Failed to create tunnel hash table" ); +ci_usage_count_release (&state->use_count); +return NULL ; + } } -return 0 ; +return state; +} -err_tunnel_hash_map_alloc: -rte_hash_free (tunnel_rule->hash_table); +void +i40e_tunnel_state_detach (struct i40e_tunnel_state *state) +{ +if (!ci_usage_count_release (&state->use_count)) +return ; -return ret; +rte_hash_free (state->hash_table); + state->hash_table =NULL ; } static void
@@ -1656,10 +1642,9 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)/* Initialize the filter invalidation configuration */ i40e_init_filter_invalidation (pf); - ret =i40e_init_tunnel_filter_list (dev); -if (ret <0 ) - goto err_init_tunnel_filter_list;i40e_fdir_flow_store_init (dev); +/* after device init, tunnel configuration is in its default state */ + pf->tunnel_state = (struct i40e_tunnel_state ){0 };/* initialize flow engine configuration */ ret = ci_flow_engine_conf_init(&pf->flow_engine_conf,
@@ -1676,9 +1661,6 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)return 0 ; err_flow_engine_conf_init: -rte_hash_free (pf->tunnel.hash_table); -rte_free (pf->tunnel.hash_map); -err_init_tunnel_filter_list:rte_intr_callback_unregister (intr_handle, i40e_dev_interrupt_handler, dev);rte_free (dev->data->mac_addrs);
@@ -1701,23 +1683,6 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)return ret; } -static void -i40e_rm_tunnel_filter_list (struct i40e_pf *pf) -{ -struct i40e_tunnel_filter *p_tunnel; -struct i40e_tunnel_rule *tunnel_rule; - - tunnel_rule = &pf->tunnel; -/* Remove all tunnel director rules and hash */ -rte_free (tunnel_rule->hash_map); -rte_hash_free (tunnel_rule->hash_table); - -while ((p_tunnel =TAILQ_FIRST (&tunnel_rule->tunnel_list))) { -TAILQ_REMOVE (&tunnel_rule->tunnel_list, p_tunnel, rules); -rte_free (p_tunnel); - } -} -void i40e_flex_payload_reg_set_default (struct i40e_hw *hw) {/*
@@ -2571,8 +2536,6 @@ i40e_dev_close(struct rte_eth_dev *dev)i40e_msec_delay (500 ); }while (retries++ <5 ); -i40e_rm_tunnel_filter_list (pf); -/* Remove all flows */ while ((p_flow =TAILQ_FIRST (&pf->flow_list))) {TAILQ_REMOVE (&pf->flow_list, p_flow, node);
@@ -7719,569 +7682,76 @@ i40e_dev_get_filter_type(uint16_t filter_type, uint16_t *flag)return 0 ; } -/* Convert tunnel filter structure */ -static int -i40e_tunnel_filter_convert ( -struct i40e_aqc_cloud_filters_element_bb *cld_filter, -struct i40e_tunnel_filter *tunnel_filter) -{ -rte_ether_addr_copy ((struct rte_ether_addr *) - &cld_filter->element.outer_mac, - (struct rte_ether_addr *)&tunnel_filter->input.outer_mac); -rte_ether_addr_copy ((struct rte_ether_addr *) - &cld_filter->element.inner_mac, - (struct rte_ether_addr *)&tunnel_filter->input.inner_mac); - tunnel_filter->input.inner_vlan = cld_filter->element.inner_vlan; -if ((rte_le_to_cpu_16 (cld_filter->element.flags) & -I40E_AQC_ADD_CLOUD_FLAGS_IPV6 ) == -I40E_AQC_ADD_CLOUD_FLAGS_IPV6 ) - tunnel_filter->input.ip_type =I40E_TUNNEL_IPTYPE_IPV6 ; -else - tunnel_filter->input.ip_type =I40E_TUNNEL_IPTYPE_IPV4 ; - tunnel_filter->input.flags = cld_filter->element.flags; - tunnel_filter->input.tenant_id = cld_filter->element.tenant_id; - tunnel_filter->queue = cld_filter->element.queue_number; -memcpy (tunnel_filter->input.general_fields, - cld_filter->general_fields, -sizeof (cld_filter->general_fields)); - -return 0 ; -} - -/* Check if there exists the tunnel filter */ -struct i40e_tunnel_filter * -i40e_sw_tunnel_filter_lookup (struct i40e_tunnel_rule *tunnel_rule, -const struct i40e_tunnel_filter_input *input) -{ -int ret; - - ret =rte_hash_lookup (tunnel_rule->hash_table, (const void *)input); -if (ret <0 ) -return NULL ; - -return tunnel_rule->hash_map[ret]; -} - -/* Add a tunnel filter into the SW list */ -static int -i40e_sw_tunnel_filter_insert (struct i40e_pf *pf, -struct i40e_tunnel_filter *tunnel_filter) -{ -struct i40e_tunnel_rule *rule = &pf->tunnel; -int ret; - - ret =rte_hash_add_key (rule->hash_table, &tunnel_filter->input); -if (ret <0 ) { -PMD_DRV_LOG (ERR , -"Failed to insert tunnel filter to hash table %d!" , - ret); -return ret; - } - rule->hash_map[ret] = tunnel_filter; - -TAILQ_INSERT_TAIL (&rule->tunnel_list, tunnel_filter, rules); - -return 0 ; -} - -/* Delete a tunnel filter from the SW list */ int -i40e_sw_tunnel_filter_del (struct i40e_pf *pf, -struct i40e_tunnel_filter_input *input) +i40e_tunnel_filter_replace (struct i40e_pf *pf, +const struct i40e_tunnel_filter_replacement *replacement) { -struct i40e_tunnel_rule *rule = &pf->tunnel; -struct i40e_tunnel_filter *tunnel_filter; +struct i40e_aqc_replace_cloud_filters_cmd_buf buffer = {0 }; +struct i40e_aqc_replace_cloud_filters_cmd command = { + .valid_flags = replacement->valid_flags, + .old_filter_type = replacement->old_filter_type, + .new_filter_type = replacement->new_filter_type, + .tr_bit = replacement->tr_bit, + .tr_bit2 = replacement->tr_bit2, + }; +struct i40e_hw *hw =I40E_PF_TO_HW (pf); +struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id];int ret; - ret =rte_hash_del_key (rule->hash_table, input); -if (ret <0 ) { -PMD_DRV_LOG (ERR , -"Failed to delete tunnel filter to hash table %d!" , - ret); -return ret; +if (pf->support_multi_driver) { +PMD_DRV_LOG (ERR ,"Replacing tunnel filters is not supported." ); +return I40E_NOT_SUPPORTED ; } - tunnel_filter = rule->hash_map[ret]; - rule->hash_map[ret] =NULL ; -TAILQ_REMOVE (&rule->tunnel_list, tunnel_filter, rules); -rte_free (tunnel_filter); +memcpy (buffer.data, replacement->data,sizeof (replacement->data)); + ret =i40e_aq_replace_cloud_filters (hw, &command, &buffer); +if (ret !=I40E_SUCCESS ) +return ret; + +PMD_DRV_LOG (WARNING ,"i40e device %s changed %s filter type." +" original: 0x%x, new: 0x%x" , + dev->device->name, + (command.valid_flags &I40E_AQC_REPLACE_CLOUD_FILTER ) !=0 ? +"cloud" :"cloud l1" , + command.old_filter_type, command.new_filter_type);return 0 ; } -#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_TR_WORD0 0x48 -#define I40E_TR_VXLAN_GRE_KEY_MASK 0x4 -#define I40E_TR_GENEVE_KEY_MASK 0x8 -#define I40E_TR_GENERIC_UDP_TUNNEL_MASK 0x40 -#define I40E_TR_GRE_KEY_MASK 0x400 -#define I40E_TR_GRE_KEY_WITH_XSUM_MASK 0x800 -#define I40E_TR_GRE_NO_KEY_MASK 0x8000 -#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_PORT_TR_WORD0 0x49 -#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_DIRECTION_WORD0 0x41 -#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_INGRESS_WORD0 0x80#define I40E_DIRECTION_INGRESS_KEY 0x8000#define I40E_TR_L4_TYPE_TCP 0x2#define I40E_TR_L4_TYPE_UDP 0x4#define I40E_TR_L4_TYPE_SCTP 0x8 -static enum -i40e_status_code i40e_replace_mpls_l1_filter (struct i40e_pf *pf) -{ -struct i40e_aqc_replace_cloud_filters_cmd filter_replace; -struct i40e_aqc_replace_cloud_filters_cmd_buf filter_replace_buf; -struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id]; -enum i40e_status_code status =I40E_SUCCESS ; - -if (pf->support_multi_driver) { -PMD_DRV_LOG (ERR ,"Replace l1 filter is not supported." ); -return I40E_NOT_SUPPORTED ; - } - -memset (&filter_replace,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd )); -memset (&filter_replace_buf,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd_buf )); - -/* create L1 filter */ - filter_replace.old_filter_type = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_IMAC ; - filter_replace.new_filter_type =I40E_AQC_ADD_L1_FILTER_0X11 ; - filter_replace.tr_bit =0 ; - -/* Prepare the buffer, 3 entries */ - filter_replace_buf.data[0 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TEID_WORD0 ; - filter_replace_buf.data[0 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[2 ] =0xFF ; - filter_replace_buf.data[3 ] =0xFF ; - filter_replace_buf.data[4 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TEID_WORD1 ; - filter_replace_buf.data[4 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[7 ] =0xF0 ; - filter_replace_buf.data[8 ] - =I40E_AQC_REPLACE_CLOUD_CMD_INPUT_TR_WORD0 ; - filter_replace_buf.data[8 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[10 ] =I40E_TR_VXLAN_GRE_KEY_MASK | -I40E_TR_GENEVE_KEY_MASK | -I40E_TR_GENERIC_UDP_TUNNEL_MASK ; - filter_replace_buf.data[11 ] = (I40E_TR_GRE_KEY_MASK | -I40E_TR_GRE_KEY_WITH_XSUM_MASK | -I40E_TR_GRE_NO_KEY_MASK ) >>8 ; - - status =i40e_aq_replace_cloud_filters (hw, &filter_replace, - &filter_replace_buf); -if (!status && (filter_replace.old_filter_type != - filter_replace.new_filter_type)) -PMD_DRV_LOG (WARNING ,"i40e device %s changed cloud l1 type." -" original: 0x%x, new: 0x%x" , - dev->device->name, - filter_replace.old_filter_type, - filter_replace.new_filter_type); - -return status; -} - -static enum -i40e_status_code i40e_replace_mpls_cloud_filter (struct i40e_pf *pf) -{ -struct i40e_aqc_replace_cloud_filters_cmd filter_replace; -struct i40e_aqc_replace_cloud_filters_cmd_buf filter_replace_buf; -struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id]; -enum i40e_status_code status =I40E_SUCCESS ; - -if (pf->support_multi_driver) { -PMD_DRV_LOG (ERR ,"Replace cloud filter is not supported." ); -return I40E_NOT_SUPPORTED ; - } - -/* For MPLSoUDP */ -memset (&filter_replace,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd )); -memset (&filter_replace_buf,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd_buf )); - filter_replace.valid_flags =I40E_AQC_REPLACE_CLOUD_FILTER | -I40E_AQC_MIRROR_CLOUD_FILTER ; - filter_replace.old_filter_type =I40E_AQC_ADD_CLOUD_FILTER_IIP ; - filter_replace.new_filter_type = -I40E_AQC_ADD_CLOUD_FILTER_0X11 ; -/* Prepare the buffer, 2 entries */ - filter_replace_buf.data[0 ] =I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG ; - filter_replace_buf.data[0 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[4 ] =I40E_AQC_ADD_L1_FILTER_0X11 ; - filter_replace_buf.data[4 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - status =i40e_aq_replace_cloud_filters (hw, &filter_replace, - &filter_replace_buf); -if (status <0 ) -return status; -if (filter_replace.old_filter_type != - filter_replace.new_filter_type) -PMD_DRV_LOG (WARNING ,"i40e device %s changed cloud filter type." -" original: 0x%x, new: 0x%x" , - dev->device->name, - filter_replace.old_filter_type, - filter_replace.new_filter_type); - -/* For MPLSoGRE */ -memset (&filter_replace,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd )); -memset (&filter_replace_buf,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd_buf )); - - filter_replace.valid_flags =I40E_AQC_REPLACE_CLOUD_FILTER | -I40E_AQC_MIRROR_CLOUD_FILTER ; - filter_replace.old_filter_type =I40E_AQC_ADD_CLOUD_FILTER_IMAC ; - filter_replace.new_filter_type = -I40E_AQC_ADD_CLOUD_FILTER_0X12 ; -/* Prepare the buffer, 2 entries */ - filter_replace_buf.data[0 ] =I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG ; - filter_replace_buf.data[0 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[4 ] =I40E_AQC_ADD_L1_FILTER_0X11 ; - filter_replace_buf.data[4 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - - status =i40e_aq_replace_cloud_filters (hw, &filter_replace, - &filter_replace_buf); -if (!status && (filter_replace.old_filter_type != - filter_replace.new_filter_type)) -PMD_DRV_LOG (WARNING ,"i40e device %s changed cloud filter type." -" original: 0x%x, new: 0x%x" , - dev->device->name, - filter_replace.old_filter_type, - filter_replace.new_filter_type); - -return status; -} - -static enum i40e_status_code -i40e_replace_gtp_l1_filter (struct i40e_pf *pf) -{ -struct i40e_aqc_replace_cloud_filters_cmd filter_replace; -struct i40e_aqc_replace_cloud_filters_cmd_buf filter_replace_buf; -struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id]; -enum i40e_status_code status =I40E_SUCCESS ; - -if (pf->support_multi_driver) { -PMD_DRV_LOG (ERR ,"Replace l1 filter is not supported." ); -return I40E_NOT_SUPPORTED ; - } - -/* For GTP-C */ -memset (&filter_replace,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd )); -memset (&filter_replace_buf,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd_buf )); -/* create L1 filter */ - filter_replace.old_filter_type = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_IMAC ; - filter_replace.new_filter_type =I40E_AQC_ADD_L1_FILTER_0X12 ; - filter_replace.tr_bit =I40E_AQC_NEW_TR_22 | -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; -/* Prepare the buffer, 2 entries */ - filter_replace_buf.data[0 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TEID_WORD0 ; - filter_replace_buf.data[0 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[2 ] =0xFF ; - filter_replace_buf.data[3 ] =0xFF ; - filter_replace_buf.data[4 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TEID_WORD1 ; - filter_replace_buf.data[4 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[6 ] =0xFF ; - filter_replace_buf.data[7 ] =0xFF ; - status =i40e_aq_replace_cloud_filters (hw, &filter_replace, - &filter_replace_buf); -if (status <0 ) -return status; -if (filter_replace.old_filter_type != - filter_replace.new_filter_type) -PMD_DRV_LOG (WARNING ,"i40e device %s changed cloud l1 type." -" original: 0x%x, new: 0x%x" , - dev->device->name, - filter_replace.old_filter_type, - filter_replace.new_filter_type); - -/* for GTP-U */ -memset (&filter_replace,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd )); -memset (&filter_replace_buf,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd_buf )); -/* create L1 filter */ - filter_replace.old_filter_type = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TUNNLE_KEY ; - filter_replace.new_filter_type =I40E_AQC_ADD_L1_FILTER_0X13 ; - filter_replace.tr_bit =I40E_AQC_NEW_TR_21 | -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; -/* Prepare the buffer, 2 entries */ - filter_replace_buf.data[0 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TEID_WORD0 ; - filter_replace_buf.data[0 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[2 ] =0xFF ; - filter_replace_buf.data[3 ] =0xFF ; - filter_replace_buf.data[4 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TEID_WORD1 ; - filter_replace_buf.data[4 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[6 ] =0xFF ; - filter_replace_buf.data[7 ] =0xFF ; - - status =i40e_aq_replace_cloud_filters (hw, &filter_replace, - &filter_replace_buf); -if (!status && (filter_replace.old_filter_type != - filter_replace.new_filter_type)) -PMD_DRV_LOG (WARNING ,"i40e device %s changed cloud l1 type." -" original: 0x%x, new: 0x%x" , - dev->device->name, - filter_replace.old_filter_type, - filter_replace.new_filter_type); - -return status; -} - -static enum -i40e_status_code i40e_replace_gtp_cloud_filter (struct i40e_pf *pf) -{ -struct i40e_aqc_replace_cloud_filters_cmd filter_replace; -struct i40e_aqc_replace_cloud_filters_cmd_buf filter_replace_buf; -struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id]; -enum i40e_status_code status =I40E_SUCCESS ; - -if (pf->support_multi_driver) { -PMD_DRV_LOG (ERR ,"Replace cloud filter is not supported." ); -return I40E_NOT_SUPPORTED ; - } - -/* for GTP-C */ -memset (&filter_replace,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd )); -memset (&filter_replace_buf,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd_buf )); - filter_replace.valid_flags =I40E_AQC_REPLACE_CLOUD_FILTER ; - filter_replace.old_filter_type =I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN ; - filter_replace.new_filter_type = -I40E_AQC_ADD_CLOUD_FILTER_0X11 ; -/* Prepare the buffer, 2 entries */ - filter_replace_buf.data[0 ] =I40E_AQC_ADD_L1_FILTER_0X12 ; - filter_replace_buf.data[0 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[4 ] =I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG ; - filter_replace_buf.data[4 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - status =i40e_aq_replace_cloud_filters (hw, &filter_replace, - &filter_replace_buf); -if (status <0 ) -return status; -if (filter_replace.old_filter_type != - filter_replace.new_filter_type) -PMD_DRV_LOG (WARNING ,"i40e device %s changed cloud filter type." -" original: 0x%x, new: 0x%x" , - dev->device->name, - filter_replace.old_filter_type, - filter_replace.new_filter_type); - -/* for GTP-U */ -memset (&filter_replace,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd )); -memset (&filter_replace_buf,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd_buf )); - filter_replace.valid_flags =I40E_AQC_REPLACE_CLOUD_FILTER ; - filter_replace.old_filter_type = -I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN_TEN_ID ; - filter_replace.new_filter_type = -I40E_AQC_ADD_CLOUD_FILTER_0X12 ; -/* Prepare the buffer, 2 entries */ - filter_replace_buf.data[0 ] =I40E_AQC_ADD_L1_FILTER_0X13 ; - filter_replace_buf.data[0 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[4 ] =I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG ; - filter_replace_buf.data[4 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - - status =i40e_aq_replace_cloud_filters (hw, &filter_replace, - &filter_replace_buf); -if (!status && (filter_replace.old_filter_type != - filter_replace.new_filter_type)) -PMD_DRV_LOG (WARNING ,"i40e device %s changed cloud filter type." -" original: 0x%x, new: 0x%x" , - dev->device->name, - filter_replace.old_filter_type, - filter_replace.new_filter_type); - -return status; -} - -static enum i40e_status_code -i40e_replace_port_l1_filter (struct i40e_pf *pf, -enum i40e_l4_port_type l4_port_type) -{ -struct i40e_aqc_replace_cloud_filters_cmd_buf filter_replace_buf; -struct i40e_aqc_replace_cloud_filters_cmd filter_replace; -enum i40e_status_code status =I40E_SUCCESS ; -struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id]; - -if (pf->support_multi_driver) { -PMD_DRV_LOG (ERR ,"Replace l1 filter is not supported." ); -return I40E_NOT_SUPPORTED ; - } - -memset (&filter_replace,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd )); -memset (&filter_replace_buf,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd_buf )); - -/* create L1 filter */ -if (l4_port_type ==I40E_L4_PORT_TYPE_SRC ) { - filter_replace.old_filter_type = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TUNNLE_KEY ; - filter_replace.new_filter_type =I40E_AQC_ADD_L1_FILTER_0X11 ; - filter_replace_buf.data[8 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_SRC_PORT ; - }else { - filter_replace.old_filter_type = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG_IVLAN ; - filter_replace.new_filter_type =I40E_AQC_ADD_L1_FILTER_0X10 ; - filter_replace_buf.data[8 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_DST_PORT ; - } - - filter_replace.tr_bit =0 ; -/* Prepare the buffer, 3 entries */ - filter_replace_buf.data[0 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_DIRECTION_WORD0 ; - filter_replace_buf.data[0 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[2 ] =0x00 ; - filter_replace_buf.data[3 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_INGRESS_WORD0 ; - filter_replace_buf.data[4 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_PORT_TR_WORD0 ; - filter_replace_buf.data[4 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[5 ] =0x00 ; - filter_replace_buf.data[6 ] =I40E_TR_L4_TYPE_UDP | -I40E_TR_L4_TYPE_TCP | -I40E_TR_L4_TYPE_SCTP ; - filter_replace_buf.data[7 ] =0x00 ; - filter_replace_buf.data[8 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[9 ] =0x00 ; - filter_replace_buf.data[10 ] =0xFF ; - filter_replace_buf.data[11 ] =0xFF ; - - status =i40e_aq_replace_cloud_filters (hw, &filter_replace, - &filter_replace_buf); -if (!status && filter_replace.old_filter_type != - filter_replace.new_filter_type) -PMD_DRV_LOG (WARNING ,"i40e device %s changed cloud l1 type." -" original: 0x%x, new: 0x%x" , - dev->device->name, - filter_replace.old_filter_type, - filter_replace.new_filter_type); - -return status; -} - -static enum i40e_status_code -i40e_replace_port_cloud_filter (struct i40e_pf *pf, -enum i40e_l4_port_type l4_port_type) -{ -struct i40e_aqc_replace_cloud_filters_cmd_buf filter_replace_buf; -struct i40e_aqc_replace_cloud_filters_cmd filter_replace; -enum i40e_status_code status =I40E_SUCCESS ; -struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id]; - -if (pf->support_multi_driver) { -PMD_DRV_LOG (ERR ,"Replace cloud filter is not supported." ); -return I40E_NOT_SUPPORTED ; - } - -memset (&filter_replace,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd )); -memset (&filter_replace_buf,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd_buf )); - -if (l4_port_type ==I40E_L4_PORT_TYPE_SRC ) { - filter_replace.old_filter_type =I40E_AQC_ADD_CLOUD_FILTER_IIP ; - filter_replace.new_filter_type = -I40E_AQC_ADD_CLOUD_FILTER_0X11 ; - filter_replace_buf.data[4 ] =I40E_AQC_ADD_CLOUD_FILTER_0X11 ; - }else { - filter_replace.old_filter_type =I40E_AQC_ADD_CLOUD_FILTER_OIP ; - filter_replace.new_filter_type = -I40E_AQC_ADD_CLOUD_FILTER_0X10 ; - filter_replace_buf.data[4 ] =I40E_AQC_ADD_CLOUD_FILTER_0X10 ; - } - - filter_replace.valid_flags =I40E_AQC_REPLACE_CLOUD_FILTER ; - filter_replace.tr_bit =0 ; -/* Prepare the buffer, 2 entries */ - filter_replace_buf.data[0 ] =I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG ; - filter_replace_buf.data[0 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[4 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - status =i40e_aq_replace_cloud_filters (hw, &filter_replace, - &filter_replace_buf); - -if (!status && filter_replace.old_filter_type != - filter_replace.new_filter_type) -PMD_DRV_LOG (WARNING ,"i40e device %s changed cloud filter type." -" original: 0x%x, new: 0x%x" , - dev->device->name, - filter_replace.old_filter_type, - filter_replace.new_filter_type); - -return status; -} - -int -i40e_dev_consistent_tunnel_filter_set (struct i40e_pf *pf, -struct i40e_tunnel_filter_conf *tunnel_filter, -uint8_t add) +static int +i40e_tunnel_filter_convert_conf (struct i40e_pf *pf, +struct i40e_tunnel_filter_conf *tunnel_filter, +struct i40e_aqc_cloud_filters_element_bb *cld_filter, +struct i40e_vsi **vsi,bool *big_buffer) {uint16_t ip_type;uint32_t ipv4_addr, ipv4_addr_le;uint8_t i, tun_type =0 ;/* internal variable to convert ipv6 byte order */ uint32_t convert_ipv6[4 ]; -int val, ret =0 ; +int val;struct i40e_pf_vf *vf =NULL ; -struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct i40e_vsi *vsi; -struct i40e_aqc_cloud_filters_element_bb cld_filter = {0 }; -struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel; -struct i40e_tunnel_filter *node; -struct i40e_tunnel_filter check_filter;/* Check if filter exists */ uint32_t teid_le; -bool big_buffer =0 ;rte_ether_addr_copy (&tunnel_filter->outer_mac, - (struct rte_ether_addr *)&cld_filter.element.outer_mac); + (struct rte_ether_addr *)&cld_filter->element.outer_mac);rte_ether_addr_copy (&tunnel_filter->inner_mac, - (struct rte_ether_addr *)&cld_filter.element.inner_mac); + (struct rte_ether_addr *)&cld_filter->element.inner_mac); - cld_filter.element.inner_vlan = + cld_filter->element.inner_vlan =rte_cpu_to_le_16 (tunnel_filter->inner_vlan);if (tunnel_filter->ip_type ==I40E_TUNNEL_IPTYPE_IPV4 ) { ip_type =I40E_AQC_ADD_CLOUD_FLAGS_IPV4 ; ipv4_addr =rte_be_to_cpu_32 (tunnel_filter->ip_addr.ipv4_addr); ipv4_addr_le =rte_cpu_to_le_32 (ipv4_addr); -memcpy (&cld_filter.element.ipaddr.v4.data, +memcpy (&cld_filter->element.ipaddr.v4.data, &ipv4_addr_le, -sizeof (cld_filter.element.ipaddr.v4.data)); +sizeof (cld_filter->element.ipaddr.v4.data)); }else { ip_type =I40E_AQC_ADD_CLOUD_FLAGS_IPV6 ;for (i =0 ; i <4 ; i++) {
@@ -8289,9 +7759,9 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,rte_cpu_to_le_32 (rte_be_to_cpu_32 ( tunnel_filter->ip_addr.ipv6_addr[i])); } -memcpy (&cld_filter.element.ipaddr.v6.data, +memcpy (&cld_filter->element.ipaddr.v6.data, &convert_ipv6, -sizeof (cld_filter.element.ipaddr.v6.data)); +sizeof (cld_filter->element.ipaddr.v6.data)); }/* check tunneled type */
@@ -8306,139 +7776,96 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, tun_type =I40E_AQC_ADD_CLOUD_TNL_TYPE_IP ;break ;case I40E_TUNNEL_TYPE_MPLSoUDP: -if (!pf->mpls_replace_flag) { -i40e_replace_mpls_l1_filter (pf); -i40e_replace_mpls_cloud_filter (pf); - pf->mpls_replace_flag =1 ; - } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = teid_le >>4 ; - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = (teid_le &0xF ) <<12 ; - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] =0x40 ; - big_buffer =1 ; + *big_buffer =1 ; tun_type =I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOUDP ;break ;case I40E_TUNNEL_TYPE_MPLSoGRE: -if (!pf->mpls_replace_flag) { -i40e_replace_mpls_l1_filter (pf); -i40e_replace_mpls_cloud_filter (pf); - pf->mpls_replace_flag =1 ; - } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = teid_le >>4 ; - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = (teid_le &0xF ) <<12 ; - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] =0x0 ; - big_buffer =1 ; + *big_buffer =1 ; tun_type =I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOGRE ;break ;case I40E_TUNNEL_TYPE_GTPC : -if (!pf->gtp_replace_flag) { -i40e_replace_gtp_l1_filter (pf); -i40e_replace_gtp_cloud_filter (pf); - pf->gtp_replace_flag =1 ; - } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0 ] = (teid_le >>16 ) &0xFFFF ; - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1 ] = teid_le &0xFFFF ; - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2 ] =0x0 ; - big_buffer =1 ; + *big_buffer =1 ;break ;case I40E_TUNNEL_TYPE_GTPU : -if (!pf->gtp_replace_flag) { -i40e_replace_gtp_l1_filter (pf); -i40e_replace_gtp_cloud_filter (pf); - pf->gtp_replace_flag =1 ; - } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0 ] = (teid_le >>16 ) &0xFFFF ; - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1 ] = teid_le &0xFFFF ; - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2 ] =0x0 ; - big_buffer =1 ; + *big_buffer =1 ;break ;case I40E_TUNNEL_TYPE_QINQ : -if (!pf->qinq_replace_flag) { - ret =i40e_cloud_filter_qinq_create (pf); -if (ret <0 ) { -PMD_DRV_LOG (ERR ,"Failed to create QinQ tunnel filter." ); -/* ret is a raw i40e_status_code, not an errno */ -return -ENOTSUP ; - } - pf->qinq_replace_flag =1 ; - }/* Add in the General fields the values of * the Outer and Inner VLAN * Big Buffer should be set, see changes in * i40e_aq_add_cloud_filters */ - cld_filter.general_fields[0 ] = tunnel_filter->inner_vlan; - cld_filter.general_fields[1 ] = tunnel_filter->outer_vlan; - big_buffer =1 ; + cld_filter->general_fields[0 ] = tunnel_filter->inner_vlan; + cld_filter->general_fields[1 ] = tunnel_filter->outer_vlan; + *big_buffer =1 ;break ;case I40E_CLOUD_TYPE_UDP :case I40E_CLOUD_TYPE_TCP :case I40E_CLOUD_TYPE_SCTP :if (tunnel_filter->l4_port_type ==I40E_L4_PORT_TYPE_SRC ) { -if (!pf->sport_replace_flag) { -i40e_replace_port_l1_filter (pf, - tunnel_filter->l4_port_type); -i40e_replace_port_cloud_filter (pf, - tunnel_filter->l4_port_type); - pf->sport_replace_flag =1 ; - } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] =I40E_DIRECTION_INGRESS_KEY ;if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP ) - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_UDP ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP ) - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_TCP ;else - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_SCTP ; - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = (teid_le >>16 ) &0xFFFF ; - big_buffer =1 ; + *big_buffer =1 ; }else { -if (!pf->dport_replace_flag) { -i40e_replace_port_l1_filter (pf, - tunnel_filter->l4_port_type); -i40e_replace_port_cloud_filter (pf, - tunnel_filter->l4_port_type); - pf->dport_replace_flag =1 ; - } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0 ] =I40E_DIRECTION_INGRESS_KEY ;if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP ) - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_UDP ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP ) - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_TCP ;else - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_SCTP ; - cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2 ] = + cld_filter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2 ] = (teid_le >>16 ) &0xFFFF ; - big_buffer =1 ; + *big_buffer =1 ; }break ;
@@ -8449,74 +7876,111 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, }if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoUDP) - cld_filter.element.flags = + cld_filter->element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoGRE) - cld_filter.element.flags = + cld_filter->element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X12 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_GTPC ) - cld_filter.element.flags = + cld_filter->element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_GTPU ) - cld_filter.element.flags = + cld_filter->element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X12 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_QINQ ) - cld_filter.element.flags |= + cld_filter->element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X10 ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP || tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP || tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_SCTP ) {if (tunnel_filter->l4_port_type ==I40E_L4_PORT_TYPE_SRC ) - cld_filter.element.flags |= + cld_filter->element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else - cld_filter.element.flags |= + cld_filter->element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X10 ; }else { val =i40e_dev_get_filter_type (tunnel_filter->filter_type, - &cld_filter.element.flags); + &cld_filter->element.flags);if (val <0 ) {return -EINVAL ; } } - cld_filter.element.flags |= + cld_filter->element.flags |=rte_cpu_to_le_16 (I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | ip_type | (tun_type <<I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT )); - cld_filter.element.tenant_id =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - cld_filter.element.queue_number = + cld_filter->element.tenant_id =rte_cpu_to_le_32 (tunnel_filter->tenant_id); + cld_filter->element.queue_number =rte_cpu_to_le_16 (tunnel_filter->queue_id);if (!tunnel_filter->is_to_vf) - vsi = pf->main_vsi; + *vsi = pf->main_vsi;else {if (tunnel_filter->vf_id >= pf->vf_num) {PMD_DRV_LOG (ERR ,"Invalid argument." );return -EINVAL ; } vf = &pf->vfs[tunnel_filter->vf_id]; - vsi = vf->vsi; + *vsi = vf->vsi; } -/* Check if there is the filter in SW list */ -memset (&check_filter,0 ,sizeof (check_filter)); -i40e_tunnel_filter_convert (&cld_filter, &check_filter); - check_filter.is_to_vf = tunnel_filter->is_to_vf; - check_filter.vf_id = tunnel_filter->vf_id; - node =i40e_sw_tunnel_filter_lookup (tunnel_rule, &check_filter.input); -if (add && node) { -PMD_DRV_LOG (ERR ,"Conflict with existing tunnel rules!" ); -return -EINVAL ; - } +return 0 ; +} -if (!add && !node) { -PMD_DRV_LOG (ERR ,"There's no corresponding tunnel filter!" ); -return -EINVAL ; - } +int +i40e_tunnel_filter_match_key_get (struct i40e_pf *pf, +struct i40e_tunnel_filter_conf *tunnel_filter, +struct i40e_tunnel_filter_match_key *input) +{ +struct i40e_aqc_cloud_filters_element_bb cld_filter = {0 }; +struct i40e_vsi *vsi; +bool big_buffer =0 ; +int ret; + + ret =i40e_tunnel_filter_convert_conf (pf, tunnel_filter, &cld_filter, + &vsi, &big_buffer); +if (ret !=0 ) +return ret; + +rte_ether_addr_copy ((struct rte_ether_addr *) + &cld_filter.element.outer_mac, + (struct rte_ether_addr *)&input->outer_mac); +rte_ether_addr_copy ((struct rte_ether_addr *) + &cld_filter.element.inner_mac, + (struct rte_ether_addr *)&input->inner_mac); + input->inner_vlan = cld_filter.element.inner_vlan; +if ((rte_le_to_cpu_16 (cld_filter.element.flags) & +I40E_AQC_ADD_CLOUD_FLAGS_IPV6 ) == +I40E_AQC_ADD_CLOUD_FLAGS_IPV6 ) + input->ip_type =I40E_TUNNEL_IPTYPE_IPV6 ; +else + input->ip_type =I40E_TUNNEL_IPTYPE_IPV4 ; + input->flags = cld_filter.element.flags; + input->tenant_id = cld_filter.element.tenant_id; +memcpy (input->general_fields, cld_filter.general_fields, +sizeof (cld_filter.general_fields)); + +return 0 ; +} + +int +i40e_tunnel_filter_program (struct i40e_pf *pf, +struct i40e_tunnel_filter_conf *tunnel_filter, +uint8_t add) +{ +struct i40e_hw *hw =I40E_PF_TO_HW (pf); +struct i40e_aqc_cloud_filters_element_bb cld_filter = {0 }; +struct i40e_vsi *vsi; +bool big_buffer =0 ; +int ret; + + ret =i40e_tunnel_filter_convert_conf (pf, tunnel_filter, &cld_filter, + &vsi, &big_buffer); +if (ret !=0 ) +return ret;if (add) { -struct i40e_tunnel_filter *tunnel; -if (big_buffer) ret =i40e_aq_add_cloud_filters_bb (hw, vsi->seid, &cld_filter,1 );
@@ -8527,16 +7991,6 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,PMD_DRV_LOG (ERR ,"Failed to add a tunnel filter." );return -ENOTSUP ; } - tunnel =rte_zmalloc ("tunnel_filter" ,sizeof (*tunnel),0 ); -if (tunnel ==NULL ) { -PMD_DRV_LOG (ERR ,"Failed to alloc memory." ); -return -ENOMEM ; - } - -memcpy (tunnel, &check_filter,sizeof (check_filter)); - ret =i40e_sw_tunnel_filter_insert (pf, tunnel); -if (ret <0 ) -rte_free (tunnel); }else {if (big_buffer) ret = i40e_aq_rem_cloud_filters_bb(
@@ -8548,7 +8002,6 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,PMD_DRV_LOG (ERR ,"Failed to delete a tunnel filter." );return -ENOTSUP ; } - ret =i40e_sw_tunnel_filter_del (pf, &node->input); }return ret;
@@ -11256,65 +10709,9 @@ i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused)return 0 ; } -/* Restore tunnel filter */ -static void -i40e_tunnel_filter_restore (struct i40e_pf *pf) -{ -struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct i40e_vsi *vsi; -struct i40e_pf_vf *vf; -struct i40e_tunnel_filter_list - *tunnel_list = &pf->tunnel.tunnel_list; -struct i40e_tunnel_filter *f; -struct i40e_aqc_cloud_filters_element_bb cld_filter; -bool big_buffer =0 ; - - TAILQ_FOREACH(f, tunnel_list, rules) { -if (!f->is_to_vf) - vsi = pf->main_vsi; -else { - vf = &pf->vfs[f->vf_id]; - vsi = vf->vsi; - } -memset (&cld_filter,0 ,sizeof (cld_filter)); -rte_ether_addr_copy ((struct rte_ether_addr *) - &f->input.outer_mac, - (struct rte_ether_addr *)&cld_filter.element.outer_mac); -rte_ether_addr_copy ((struct rte_ether_addr *) - &f->input.inner_mac, - (struct rte_ether_addr *)&cld_filter.element.inner_mac); - cld_filter.element.inner_vlan = f->input.inner_vlan; - cld_filter.element.flags = f->input.flags; - cld_filter.element.tenant_id = f->input.tenant_id; - cld_filter.element.queue_number = f->queue; -memcpy (cld_filter.general_fields, - f->input.general_fields, -sizeof (f->input.general_fields)); - -if (((f->input.flags & -I40E_AQC_ADD_CLOUD_FILTER_0X11 ) == -I40E_AQC_ADD_CLOUD_FILTER_0X11 ) || - ((f->input.flags & -I40E_AQC_ADD_CLOUD_FILTER_0X12 ) == -I40E_AQC_ADD_CLOUD_FILTER_0X12 ) || - ((f->input.flags & -I40E_AQC_ADD_CLOUD_FILTER_0X10 ) == -I40E_AQC_ADD_CLOUD_FILTER_0X10 )) - big_buffer =1 ; - -if (big_buffer) -i40e_aq_add_cloud_filters_bb (hw, - vsi->seid, &cld_filter,1 ); -else -i40e_aq_add_cloud_filters (hw, vsi->seid, - &cld_filter.element,1 ); - } -} -static void i40e_filter_restore (struct i40e_pf *pf) { -i40e_tunnel_filter_restore (pf);i40e_fdir_filter_restore (pf); (void )i40e_hash_filter_restore (pf); }
@@ -11747,133 +11144,6 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg,free (proto); } -/* Create a QinQ cloud filter -* -* The Fortville NIC has limited resources for tunnel filters, -* so we can only reuse existing filters. -* -* In step 1 we define which Field Vector fields can be used for -* filter types. -* As we do not have the inner tag defined as a field, -* we have to define it first, by reusing one of L1 entries. -* -* In step 2 we are replacing one of existing filter types with -* a new one for QinQ. -* As we reusing L1 and replacing L2, some of the default filter -* types will disappear,which depends on L1 and L2 entries we reuse. -* -* Step 1: Create L1 filter of outer vlan (12b) + inner vlan (12b) -* -* 1. Create L1 filter of outer vlan (12b) which will be in use -* later when we define the cloud filter. -* a. Valid_flags.replace_cloud = 0 -* b. Old_filter = 10 (Stag_Inner_Vlan) -* c. New_filter = 0x10 -* d. TR bit = 0xff (optional, not used here) -* e. Buffer – 2 entries: -* i. Byte 0 = 8 (outer vlan FV index). -* Byte 1 = 0 (rsv) -* Byte 2-3 = 0x0fff -* ii. Byte 0 = 37 (inner vlan FV index). -* Byte 1 =0 (rsv) -* Byte 2-3 = 0x0fff -* -* Step 2: -* 2. Create cloud filter using two L1 filters entries: stag and -* new filter(outer vlan+ inner vlan) -* a. Valid_flags.replace_cloud = 1 -* b. Old_filter = 1 (instead of outer IP) -* c. New_filter = 0x10 -* d. Buffer – 2 entries: -* i. Byte 0 = 0x80 | 7 (valid | Stag). -* Byte 1-3 = 0 (rsv) -* ii. Byte 8 = 0x80 | 0x10 (valid | new l1 filter step1) -* Byte 9-11 = 0 (rsv) -*/ -static int -i40e_cloud_filter_qinq_create (struct i40e_pf *pf) -{ -int ret = -ENOTSUP ; -struct i40e_aqc_replace_cloud_filters_cmd filter_replace; -struct i40e_aqc_replace_cloud_filters_cmd_buf filter_replace_buf; -struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id]; - -if (pf->support_multi_driver) { -PMD_DRV_LOG (ERR ,"Replace cloud filter is not supported." ); -return ret; - } - -/* Init */ -memset (&filter_replace,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd )); -memset (&filter_replace_buf,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd_buf )); - -/* create L1 filter */ - filter_replace.old_filter_type = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG_IVLAN ; - filter_replace.new_filter_type =I40E_AQC_ADD_CLOUD_FILTER_0X10 ; - filter_replace.tr_bit =0 ; - -/* Prepare the buffer, 2 entries */ - filter_replace_buf.data[0 ] =I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_VLAN ; - filter_replace_buf.data[0 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; -/* Field Vector 12b mask */ - filter_replace_buf.data[2 ] =0xff ; - filter_replace_buf.data[3 ] =0x0f ; - filter_replace_buf.data[4 ] = -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_INNER_VLAN ; - filter_replace_buf.data[4 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; -/* Field Vector 12b mask */ - filter_replace_buf.data[6 ] =0xff ; - filter_replace_buf.data[7 ] =0x0f ; - ret =i40e_aq_replace_cloud_filters (hw, &filter_replace, - &filter_replace_buf); -if (ret !=I40E_SUCCESS ) -return ret; - -if (filter_replace.old_filter_type != - filter_replace.new_filter_type) -PMD_DRV_LOG (WARNING ,"i40e device %s changed cloud l1 type." -" original: 0x%x, new: 0x%x" , - dev->device->name, - filter_replace.old_filter_type, - filter_replace.new_filter_type); - -/* Apply the second L2 cloud filter */ -memset (&filter_replace,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd )); -memset (&filter_replace_buf,0 , -sizeof (struct i40e_aqc_replace_cloud_filters_cmd_buf )); - -/* create L2 filter, input for L2 filter will be L1 filter */ - filter_replace.valid_flags =I40E_AQC_REPLACE_CLOUD_FILTER ; - filter_replace.old_filter_type =I40E_AQC_ADD_CLOUD_FILTER_OIP ; - filter_replace.new_filter_type =I40E_AQC_ADD_CLOUD_FILTER_0X10 ; - -/* Prepare the buffer, 2 entries */ - filter_replace_buf.data[0 ] =I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG ; - filter_replace_buf.data[0 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - filter_replace_buf.data[4 ] =I40E_AQC_ADD_CLOUD_FILTER_0X10 ; - filter_replace_buf.data[4 ] |= -I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED ; - ret =i40e_aq_replace_cloud_filters (hw, &filter_replace, - &filter_replace_buf); -if (!ret && (filter_replace.old_filter_type != - filter_replace.new_filter_type)) -PMD_DRV_LOG (WARNING ,"i40e device %s changed cloud filter type." -" original: 0x%x, new: 0x%x" , - dev->device->name, - filter_replace.old_filter_type, - filter_replace.new_filter_type); - -return ret; -} -static int i40e_fec_get_capability (struct rte_eth_dev *dev, struct rte_eth_fec_capa *speed_fec_capa, __rte_unused unsigned int num)
drivers/net/intel/i40e/i40e_ethdev.h +43 -41
133 lines not on this page · raw message
drivers/net/intel/i40e/i40e_flow.c +7 -1695
1,579 lines not on this page · raw message
drivers/net/intel/i40e/i40e_flow_tunnel.c new file +1958 -0
1,958 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.52.0
Part of the diff is not shown here. View the raw message.
PATCH v7 24/25 net/i40e: reimplement hash parser
In reply to Anatoly BurakovUse the new flow graph API and the common parsing framework to implement flow parser for RSS.
The RSS parser was bypassing the other generic infrastructure, probably because it was very convoluted and did not map onto that model very well. It has now been made a first-class citizen.
The hash parser is multiple engines that share state, so each engine will attach to the shared refcounted RSS configuration state.
Additionally, this is the final engine in i40e, so remaining legacy flow infrastructure has been removed.
--- drivers/net/intel/i40e/i40e_ethdev.c | 34 +- drivers/net/intel/i40e/i40e_ethdev.h | 36 +- drivers/net/intel/i40e/i40e_flow.c | 289 +---- drivers/net/intel/i40e/i40e_flow.h | 3 + drivers/net/intel/i40e/i40e_flow_hash.c | 1482 +++++++++++++++++++++++ drivers/net/intel/i40e/i40e_hash.c | 1212 +----------------- drivers/net/intel/i40e/i40e_hash.h | 19 +- drivers/net/intel/i40e/meson.build | 1 + 8 files changed, 1593 insertions(+), 1483 deletions(-) create mode 100644 drivers/net/intel/i40e/i40e_flow_hash.c
drivers/net/intel/i40e/i40e_ethdev.c +21 -13
@@ -1027,6 +1027,27 @@ i40e_tunnel_state_detach(struct i40e_tunnel_state *state) state->hash_table =NULL ; } +struct i40e_rss_state * +i40e_rss_state_attach (struct rte_eth_dev_data *dev_data) +{ +struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev_data->dev_private); +struct i40e_rss_state *state = &pf->rss_state; + +if (ci_usage_count_claim (&state->use_count)) +TAILQ_INIT (&state->list); + +return state; +} + +void +i40e_rss_state_detach (struct i40e_rss_state *state) +{ +if (!ci_usage_count_release (&state->use_count)) +return ; + + *state = (struct i40e_rss_state ){0 }; +} +static void i40e_init_customized_info (struct i40e_pf *pf) {
@@ -1630,9 +1651,6 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)*/ i40e_add_tx_flow_control_drop_filter (pf); -/* initialize RSS rule list */ -TAILQ_INIT (&pf->rss_config_list); -/* initialize Traffic Manager configuration */ i40e_tm_conf_init (dev);
@@ -1775,8 +1793,6 @@ i40e_dev_configure(struct rte_eth_dev *dev) } } -TAILQ_INIT (&pf->flow_list); -return 0 ; err_dcb:
@@ -2444,7 +2460,6 @@ i40e_dev_close(struct rte_eth_dev *dev)struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct i40e_filter_control_settings settings; -struct rte_flow *p_flow;uint32_t reg;int i;int ret;
@@ -2536,12 +2551,6 @@ i40e_dev_close(struct rte_eth_dev *dev)i40e_msec_delay (500 ); }while (retries++ <5 ); -/* Remove all flows */ -while ((p_flow =TAILQ_FIRST (&pf->flow_list))) { -TAILQ_REMOVE (&pf->flow_list, p_flow, node); -rte_free (p_flow); - } -/* Remove all Traffic Manager configuration */ i40e_tm_conf_uninit (dev);
@@ -10713,7 +10722,6 @@ static void i40e_filter_restore(struct i40e_pf *pf) {i40e_fdir_filter_restore (pf); - (void )i40e_hash_filter_restore (pf); }bool
drivers/net/intel/i40e/i40e_ethdev.h +18 -18
@@ -282,9 +282,6 @@ enum i40e_flxpld_layer_idx {*/ struct rte_flow {struct ci_flow base; -TAILQ_ENTRY (rte_flow) node; -enum rte_filter_type filter_type; -void *rule; };/**
@@ -993,8 +990,6 @@ struct i40e_tunnel_filter_conf {uint16_t vf_id;/**< VF id, available when is_to_vf is 1. */ }; -TAILQ_HEAD (i40e_flow_list, rte_flow); -/* Struct to store Traffic Manager shaper profile. */ struct i40e_tm_shaper_profile {TAILQ_ENTRY (i40e_tm_shaper_profile) node;
@@ -1081,7 +1076,7 @@ struct i40e_customized_pctype {#define I40E_RSS_KEY_LEN ((I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t)) -struct i40e_rte_flow_rss_conf { +struct i40e_rss_conf {enum rte_eth_hash_function func;uint64_t types;/**< Specific RSS hash types (see RTE_ETH_RSS_*). */ uint32_t key_len;/**< Hash key length in bytes. */
@@ -1116,14 +1111,23 @@ struct i40e_rss_filter_data {uint64_t reset_symmetric_pctypes; }; -/* RSS filter list structure */ -struct i40e_rss_filter { -TAILQ_ENTRY (i40e_rss_filter) next; -struct i40e_rte_flow_rss_conf rss_filter_info; +/* +* Tracking entry for a registered RSS flow: points back to the flow that +* owns the rss_conf, plus the metadata recording which HW state it owns. +*/ +struct i40e_rss_flow_node { +TAILQ_ENTRY (i40e_rss_flow_node) next; +struct ci_flow *flow;struct i40e_rss_filter_data filter_data; }; -TAILQ_HEAD (i40e_rss_conf_list, i40e_rss_filter); +TAILQ_HEAD (i40e_rss_node_list, i40e_rss_flow_node); + +/* RSS flow engine shared state, attached/detached by the RSS engines */ +struct i40e_rss_state { +ci_usage_count_t use_count; +struct i40e_rss_node_list list; +};struct i40e_vf_msg_cfg {/* maximal VF message during a statistic period */
@@ -1200,13 +1204,12 @@ struct i40e_pf {struct i40e_fdir_info fdir;/* flow director info */ struct i40e_tunnel_state tunnel_state;/* tunnel flow engine state */ -struct i40e_rss_conf_list rss_config_list;/* RSS rule list */ +struct i40e_rss_state rss_state;/* RSS flow engine state */ struct i40e_queue_regions queue_region;/* queue region info */ struct i40e_fc_conf fc_conf;/* Flow control conf */ bool floating_veb;/* The flag to use the floating VEB */ /* The floating enable flag for the specific VF */ bool floating_veb_list[I40E_MAX_VF ]; -struct i40e_flow_list flow_list;/* flow engine configuration */ struct ci_flow_engine_conf flow_engine_conf;struct i40e_tm_conf tm_conf;
@@ -1339,11 +1342,6 @@ struct i40e_vf_representor {extern const struct rte_flow_ops i40e_flow_ops; -struct i40e_filter_ctx { -struct i40e_rte_flow_rss_conf rss_conf; -enum rte_filter_type type; -}; -int i40e_dev_switch_queues (struct i40e_pf *pf,bool on);int i40e_vsi_release (struct i40e_vsi *vsi); struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf,
@@ -1459,6 +1457,8 @@ int i40e_tunnel_filter_match_key_get(struct i40e_pf *pf, struct i40e_tunnel_filter_match_key *out);struct i40e_tunnel_state *i40e_tunnel_state_attach (struct rte_eth_dev_data *dev_data);void i40e_tunnel_state_detach (struct i40e_tunnel_state *state); +struct i40e_rss_state *i40e_rss_state_attach (struct rte_eth_dev_data *dev_data); +void i40e_rss_state_detach (struct i40e_rss_state *state);int i40e_tunnel_filter_program (struct i40e_pf *pf,struct i40e_tunnel_filter_conf *tunnel_filter,uint8_t add);
drivers/net/intel/i40e/i40e_flow.c +10 -279
347 lines not on this page · raw message
drivers/net/intel/i40e/i40e_flow.h +3 -0
@@ -23,5 +23,8 @@ extern const struct ci_flow_engine i40e_flow_engine_tunnel_nvgre;extern const struct ci_flow_engine i40e_flow_engine_tunnel_mpls;extern const struct ci_flow_engine i40e_flow_engine_tunnel_gtp;extern const struct ci_flow_engine i40e_flow_engine_tunnel_l4; +extern const struct ci_flow_engine i40e_flow_engine_hash_pattern; +extern const struct ci_flow_engine i40e_flow_engine_hash_vlan; +extern const struct ci_flow_engine i40e_flow_engine_hash_empty;#endif /* _I40E_FLOW_H_ */
drivers/net/intel/i40e/i40e_flow_hash.c new file +1482 -0
1,482 lines not on this page · raw message
drivers/net/intel/i40e/i40e_hash.c +52 -1160
1,007 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.52.0
Part of the diff is not shown here. View the raw message.
PATCH v7 25/25 net/i40e: advertise flow keep capability
In reply to Anatoly BurakovThe i40e driver's rte_flow implementation has always endeavored to keep flows across device restart, however it never advertised this capability. Advertise it explicitly.
--- doc/guides/rel_notes/release_26_11.rst | 5 +++++ drivers/net/intel/i40e/i40e_ethdev.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_26_11.rst +5 -0
@@ -109,6 +109,11 @@ New Features * Advertised ``RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP`` capability, as flow rules were already kept across device restart. +* **Updated Intel i40e driver.** + + * Advertised ``RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP`` capability, + as flow rules were already kept across device restart. + * **Updated NXP DPAA2 ethernet driver.** * Added the inner IP header to the RSS hash so tunneled traffic is
drivers/net/intel/i40e/i40e_ethdev.c +2 -1
@@ -3631,7 +3631,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->dev_capa =RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP ; - dev_info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP ; +/* rte_flow rules are kept across dev_stop/dev_start and replayed on start */ + dev_info->dev_capa |=RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP ; dev_info->hash_key_size = (I40E_PFQF_HKEY_MAX_INDEX +1 ) *sizeof (uint32_t );
Signature · 1 line
2.52.0
Quoted 45 lines · Anatoly Burakov
Most
rte_flowparsers in DPDK suffer from huge implementation complexity because even though 99% of what people userte_flowparsers for is parsing protocol graphs, no parser is written explicitly as a graph. This patchset attempts to suggest a viable model to buildrte_flowparsers as graphs, by offering a library to buildrte_flowparser graphs without too much boilerplate and complexity.Most of the patchset is about Intel drivers, but they are meant as reimplementations as well as examples for the rest of the community to assess how to build parsers using this new infrastructure. I expect the first three patches will be of most interest to non-Intel reviewers, as they deal with building two reusable parser architecture pieces.
The first piece is a new flow graph helper in ethdev. Its purpose is deliberately narrow: it targets the protocol-graph part of
rte_flowpattern parsing, where drivers walk packet headers and validate legal item sequences and parameters. That does not cover all possiblerte_flowfeatures, especially more exotic flow items, but it does cover a large and widely shared part of what existing drivers need to do. Or, to put it in other words, the only flow items this infrastructure *doesn't* cover is things that do not lend themselves well to be parsed as a graph of protocol headers (e.g. conntrack items). Everything else should be covered or cover-able. In practice, just about all drivers will benefit from graph parsing as all but one of them implement only the protocol stack parts, which are the ones targeted by the graph helper.The second piece is a reusable flow engine framework for Intel Ethernet drivers. This is kept Intel-local because I do not feel it is even appropriate to define such a framework for all drivers to use in the first place. Even so, the intent is to establish a cleaner parser architecture with a defined interaction model, explicit memory ownership rules, locking, initialization sequence, implementations of
rte_flowAPI entry points, flow replay and memory cleanup, and engine definitions that do not block secondary-process-safe usage. It is my hope that this would serve as a model for other drivers to follow, expand on, rework, and improve, so that maybe down the line we *might* have a commonrte_flowinfrastructure for drivers to use.Most of the rest of the series is parser reimplementation, but that is mainly the vehicle for demonstrating and validating those two pieces. ixgbe and i40e are wired into the new common parsing path, and their existing parsers are migrated incrementally to the graph-based model. Besides reducing ad hoc parser code, this also makes validation more explicit and more consistent. In a few places that means invalid inputs that were previously ignored, deferred, or interpreted loosely are now rejected earlier and more strictly, without any increase in code complexity (in fact, with marked *decrease* of it!).
Quoted 12 lines
v6 -> v7:
- Validate graph nodes only once, including start node
- Stop trying new engines when context allocation fails
- Typos/copyright year changes
- Fixed ixgbe ethertype skipping over stale entries
- Fixed ixgbe ntuple to correctly handle L4 protocols when they are not zero
- Fixed ixgbe fdir to mask out impossible bits from the rule
- Fixed ixgbe security engine only deleting first SA table entry
- Reworked i40e ORT programming because these registers are global
- Fixed i40e RSS validation to handle GTP protocols correctly
- Fixed hash table names being too long in some cases
Patchset applied to dpdk-next-net-intel.
As well as the arm build issue, I also fixed a number of checkpatch issues, since there were a large number on this set. Most I kept unfixed, since I felt the exceptions were reasonable, but please check what was applied in case some issue was introduced with the checkpatch changes I made on apply.
Thanks,
/Bruce
13/10/2026 19:18, Bruce Richardson:
Quoted 6 lines
Patchset applied to dpdk-next-net-intel.
As well as the arm build issue, I also fixed a number of checkpatch issues, since there were a large number on this set. Most I kept unfixed, since I felt the exceptions were reasonable, but please check what was applied in case some issue was introduced with the checkpatch changes I made on apply.
Unfortunately it fails compiling on my FreeBSD,
because of an internal API included in a header included in testpmd.
You can make it fail reliably with Clang on Linux with this patch:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
And you can fix the problem with this patch:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
Please review them.
In the meantime I cannot pull this series in main, except the first 2 patches for ethdev API.
Quoted 14 lines · Thomas Monjalon
13/10/2026 19:18, Bruce Richardson:
Quoted 6 lines
Patchset applied to dpdk-next-net-intel.
As well as the arm build issue, I also fixed a number of checkpatch issues, since there were a large number on this set. Most I kept unfixed, since I felt the exceptions were reasonable, but please check what was applied in case some issue was introduced with the checkpatch changes I made on apply.
Unfortunately it fails compiling on my FreeBSD,
because of an internal API included in a header included in testpmd.You can make it fail reliably with Clang on Linux with this patch:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
Quoted 7 lines
And you can fix the problem with this patch:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/Please review them.
In the meantime I cannot pull this series in main, except the first 2 patches for ethdev API.
Done and done!
I wonder if some of that could've been avoided if the CI was better at applying patches on top of other trees instead of always trying main. I remember trying to do it with VFIO patchset, and I don't think I succeeded in getting it to apply/build on top of next-net even though I did the recheck requests and everything. I couldn't really get this patchset building through CI so some Arm compile issues have slipped by me as Bruce mentioned.
Signature · 2 lines
Thanks, Anatoly
Quoted 11 lines · Thomas Monjalon
13/10/2026 19:18, Bruce Richardson:
Quoted 6 lines
Patchset applied to dpdk-next-net-intel.
As well as the arm build issue, I also fixed a number of checkpatch issues, since there were a large number on this set. Most I kept unfixed, since I felt the exceptions were reasonable, but please check what was applied in case some issue was introduced with the checkpatch changes I made on apply.
Unfortunately it fails compiling on my FreeBSD,
because of an internal API included in a header included in testpmd.
How are you building for BSD to see this error? The next-net-intel tree is building fine for me on BSD, both as release and debug builds.
/Bruce
15/10/2026 13:31, Bruce Richardson:
Quoted 9 lines · Thomas Monjalon
Quoted 8 lines
13/10/2026 19:18, Bruce Richardson:
Quoted 6 lines
Patchset applied to dpdk-next-net-intel.
As well as the arm build issue, I also fixed a number of checkpatch issues, since there were a large number on this set. Most I kept unfixed, since I felt the exceptions were reasonable, but please check what was applied in case some issue was introduced with the checkpatch changes I made on apply.
Quoted 5 lines
Quoted 3 lines
Unfortunately it fails compiling on my FreeBSD,
because of an internal API included in a header included in testpmd.How are you building for BSD to see this error? The next-net-intel tree is building fine for me on BSD, both as release and debug builds.
I don't know the difference, probably I have an old FreeBSD, and it doesn't matter since my patch on __rte_internal shows that the error is real and can be exposed with any Clang.
Quoted 9 lines · Thomas Monjalon
13/10/2026 19:18, Bruce Richardson:
Quoted 6 lines
Patchset applied to dpdk-next-net-intel.
As well as the arm build issue, I also fixed a number of checkpatch issues, since there were a large number on this set. Most I kept unfixed, since I felt the exceptions were reasonable, but please check what was applied in case some issue was introduced with the checkpatch changes I made on apply.
Quoted 5 lines
Unfortunately it fails compiling on my FreeBSD,
because of an internal API included in a header included in testpmd.You can make it fail reliably with Clang on Linux with this patch:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
Merged the v2.
Signature · 1 line
David Marchand