@@ -310,14 +310,14 @@ nfp_check_mask_add(struct nfp_flow_priv *priv,
310310 ret = nfp_mask_table_add (priv , mask_data , mask_len , mask_id );
311311 if (ret != 0 )
312312 return false;
313-
314- * meta_flags |= NFP_FL_META_FLAG_MANAGE_MASK ;
315313 } else {
316314 /* mask entry already exist */
317315 mask_entry -> ref_cnt ++ ;
318316 * mask_id = mask_entry -> mask_id ;
319317 }
320318
319+ * meta_flags |= NFP_FL_META_FLAG_MANAGE_MASK ;
320+
321321 return true;
322322}
323323
@@ -349,7 +349,7 @@ nfp_check_mask_remove(struct nfp_flow_priv *priv,
349349 return true;
350350}
351351
352- int
352+ static int
353353nfp_flow_table_add (struct nfp_flow_priv * priv ,
354354 struct rte_flow * nfp_flow )
355355{
@@ -396,6 +396,48 @@ nfp_flow_table_search(struct nfp_flow_priv *priv,
396396 return flow_find ;
397397}
398398
399+ int
400+ nfp_flow_table_add_merge (struct nfp_flow_priv * priv ,
401+ struct rte_flow * nfp_flow )
402+ {
403+ struct rte_flow * flow_find ;
404+
405+ flow_find = nfp_flow_table_search (priv , nfp_flow );
406+ if (flow_find != NULL ) {
407+ if (nfp_flow -> merge_flag || flow_find -> merge_flag ) {
408+ flow_find -> merge_flag = true;
409+ flow_find -> ref_cnt ++ ;
410+ return 0 ;
411+ }
412+
413+ PMD_DRV_LOG (ERR , "Add to flow table failed." );
414+ return - EINVAL ;
415+ }
416+
417+ return nfp_flow_table_add (priv , nfp_flow );
418+ }
419+
420+ static int
421+ nfp_flow_table_delete_merge (struct nfp_flow_priv * priv ,
422+ struct rte_flow * nfp_flow )
423+ {
424+ struct rte_flow * flow_find ;
425+
426+ flow_find = nfp_flow_table_search (priv , nfp_flow );
427+ if (flow_find == NULL ) {
428+ PMD_DRV_LOG (ERR , "Can't delete a non-existing flow." );
429+ return - EINVAL ;
430+ }
431+
432+ if (nfp_flow -> merge_flag || flow_find -> merge_flag ) {
433+ flow_find -> ref_cnt -- ;
434+ if (flow_find -> ref_cnt > 0 )
435+ return 0 ;
436+ }
437+
438+ return nfp_flow_table_delete (priv , nfp_flow );
439+ }
440+
399441static struct rte_flow *
400442nfp_flow_alloc (struct nfp_fl_key_ls * key_layer , uint32_t port_id )
401443{
@@ -1082,6 +1124,9 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
10821124 return - ENOTSUP ;
10831125 }
10841126 break ;
1127+ case RTE_FLOW_ACTION_TYPE_CONNTRACK :
1128+ PMD_DRV_LOG (DEBUG , "RTE_FLOW_ACTION_TYPE_CONNTRACK detected" );
1129+ break ;
10851130 default :
10861131 PMD_DRV_LOG (ERR , "Action type %d not supported." , action -> type );
10871132 return - ENOTSUP ;
@@ -3626,6 +3671,9 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
36263671 return - EINVAL ;
36273672 position += sizeof (struct nfp_fl_act_meter );
36283673 break ;
3674+ case RTE_FLOW_ACTION_TYPE_CONNTRACK :
3675+ PMD_DRV_LOG (DEBUG , "Process RTE_FLOW_ACTION_TYPE_CONNTRACK" );
3676+ break ;
36293677 default :
36303678 PMD_DRV_LOG (ERR , "Unsupported action type: %d" , action -> type );
36313679 return - ENOTSUP ;
@@ -3647,7 +3695,8 @@ nfp_flow_process(struct nfp_flower_representor *representor,
36473695 const struct rte_flow_action actions [],
36483696 bool validate_flag ,
36493697 uint64_t cookie ,
3650- bool install_flag )
3698+ bool install_flag ,
3699+ bool merge_flag )
36513700{
36523701 int ret ;
36533702 char * hash_data ;
@@ -3684,6 +3733,7 @@ nfp_flow_process(struct nfp_flower_representor *representor,
36843733 }
36853734
36863735 nfp_flow -> install_flag = install_flag ;
3736+ nfp_flow -> merge_flag = merge_flag ;
36873737
36883738 nfp_flow_compile_metadata (priv , nfp_flow , & key_layer , stats_ctx , cookie );
36893739
@@ -3717,7 +3767,7 @@ nfp_flow_process(struct nfp_flower_representor *representor,
37173767
37183768 /* Find the flow in hash table */
37193769 flow_find = nfp_flow_table_search (priv , nfp_flow );
3720- if (flow_find != NULL ) {
3770+ if (flow_find != NULL && ! nfp_flow -> merge_flag && ! flow_find -> merge_flag ) {
37213771 PMD_DRV_LOG (ERR , "This flow is already exist." );
37223772 if (!nfp_check_mask_remove (priv , mask_data , mask_len ,
37233773 & nfp_flow_meta -> flags )) {
@@ -3774,7 +3824,7 @@ nfp_flow_setup(struct nfp_flower_representor *representor,
37743824 return nfp_ct_flow_setup (representor , items , actions ,
37753825 ct_item , validate_flag , cookie );
37763826
3777- return nfp_flow_process (representor , items , actions , validate_flag , cookie , true);
3827+ return nfp_flow_process (representor , items , actions , validate_flag , cookie , true, false );
37783828}
37793829
37803830int
@@ -3877,7 +3927,7 @@ nfp_flow_create(struct rte_eth_dev *dev,
38773927 }
38783928
38793929 /* Add the flow to flow hash table */
3880- ret = nfp_flow_table_add (priv , nfp_flow );
3930+ ret = nfp_flow_table_add_merge (priv , nfp_flow );
38813931 if (ret != 0 ) {
38823932 rte_flow_error_set (error , EINVAL , RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,
38833933 NULL , "Add flow to the flow table failed." );
@@ -3988,7 +4038,7 @@ nfp_flow_destroy(struct rte_eth_dev *dev,
39884038 }
39894039
39904040 /* Delete the flow from flow hash table */
3991- ret = nfp_flow_table_delete (priv , nfp_flow );
4041+ ret = nfp_flow_table_delete_merge (priv , nfp_flow );
39924042 if (ret != 0 ) {
39934043 rte_flow_error_set (error , EINVAL , RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,
39944044 NULL , "Delete flow from the flow table failed." );
@@ -4047,10 +4097,12 @@ nfp_flow_stats_get(struct rte_eth_dev *dev,
40474097 void * data )
40484098{
40494099 bool reset ;
4100+ uint64_t cookie ;
40504101 uint32_t ctx_id ;
40514102 struct rte_flow * flow ;
40524103 struct nfp_flow_priv * priv ;
40534104 struct nfp_fl_stats * stats ;
4105+ struct nfp_ct_map_entry * me ;
40544106 struct rte_flow_query_count * query ;
40554107
40564108 priv = nfp_flow_dev_to_priv (dev );
@@ -4064,8 +4116,15 @@ nfp_flow_stats_get(struct rte_eth_dev *dev,
40644116 reset = query -> reset ;
40654117 memset (query , 0 , sizeof (* query ));
40664118
4067- ctx_id = rte_be_to_cpu_32 (nfp_flow -> payload .meta -> host_ctx_id );
4068- stats = & priv -> stats [ctx_id ];
4119+ /* Find the flow in ct_map_table */
4120+ cookie = rte_be_to_cpu_64 (nfp_flow -> payload .meta -> host_cookie );
4121+ me = nfp_ct_map_table_search (priv , (char * )& cookie , sizeof (uint64_t ));
4122+ if (me != NULL ) {
4123+ stats = nfp_ct_flow_stats_get (priv , me );
4124+ } else {
4125+ ctx_id = rte_be_to_cpu_32 (nfp_flow -> payload .meta -> host_ctx_id );
4126+ stats = & priv -> stats [ctx_id ];
4127+ }
40694128
40704129 rte_spinlock_lock (& priv -> stats_lock );
40714130 if (stats -> pkts != 0 && stats -> bytes != 0 ) {
0 commit comments