1111#include "sparx5_main.h"
1212#include "sparx5_vcap_impl.h"
1313
14+ static struct sparx5_mall_entry *
15+ sparx5_tc_matchall_entry_find (struct list_head * entries , unsigned long cookie )
16+ {
17+ struct sparx5_mall_entry * entry ;
18+
19+ list_for_each_entry (entry , entries , list ) {
20+ if (entry -> cookie == cookie )
21+ return entry ;
22+ }
23+
24+ return NULL ;
25+ }
26+
27+ static void sparx5_tc_matchall_parse_action (struct sparx5_port * port ,
28+ struct sparx5_mall_entry * entry ,
29+ struct flow_action_entry * action ,
30+ bool ingress ,
31+ unsigned long cookie )
32+ {
33+ entry -> port = port ;
34+ entry -> type = action -> id ;
35+ entry -> ingress = ingress ;
36+ entry -> cookie = cookie ;
37+ }
38+
1439static int sparx5_tc_matchall_replace (struct net_device * ndev ,
1540 struct tc_cls_matchall_offload * tmo ,
1641 bool ingress )
1742{
1843 struct sparx5_port * port = netdev_priv (ndev );
44+ struct sparx5_mall_entry * mall_entry ;
1945 struct flow_action_entry * action ;
2046 struct sparx5 * sparx5 ;
2147 int err ;
@@ -27,6 +53,16 @@ static int sparx5_tc_matchall_replace(struct net_device *ndev,
2753 }
2854 action = & tmo -> rule -> action .entries [0 ];
2955
56+ mall_entry = kzalloc (sizeof (* mall_entry ), GFP_KERNEL );
57+ if (!mall_entry )
58+ return - ENOMEM ;
59+
60+ sparx5_tc_matchall_parse_action (port ,
61+ mall_entry ,
62+ action ,
63+ ingress ,
64+ tmo -> cookie );
65+
3066 sparx5 = port -> sparx5 ;
3167 switch (action -> id ) {
3268 case FLOW_ACTION_GOTO :
@@ -59,6 +95,9 @@ static int sparx5_tc_matchall_replace(struct net_device *ndev,
5995 NL_SET_ERR_MSG_MOD (tmo -> common .extack , "Unsupported action" );
6096 return - EOPNOTSUPP ;
6197 }
98+
99+ list_add_tail (& mall_entry -> list , & sparx5 -> mall_entries );
100+
62101 return 0 ;
63102}
64103
@@ -67,19 +106,26 @@ static int sparx5_tc_matchall_destroy(struct net_device *ndev,
67106 bool ingress )
68107{
69108 struct sparx5_port * port = netdev_priv (ndev );
70- struct sparx5 * sparx5 ;
109+ struct sparx5 * sparx5 = port -> sparx5 ;
110+ struct sparx5_mall_entry * entry ;
71111 int err ;
72112
73- sparx5 = port -> sparx5 ;
74- if (!tmo -> rule && tmo -> cookie ) {
113+ entry = sparx5_tc_matchall_entry_find (& sparx5 -> mall_entries ,
114+ tmo -> cookie );
115+ if (!entry )
116+ return - ENOENT ;
117+
118+ if (entry -> type == FLOW_ACTION_GOTO ) {
75119 err = vcap_enable_lookups (sparx5 -> vcap_ctrl , ndev ,
76120 0 , 0 , tmo -> cookie , false);
77- if ( err )
78- return err ;
79- return 0 ;
121+ } else {
122+ NL_SET_ERR_MSG_MOD ( tmo -> common . extack , "Unsupported action" ) ;
123+ err = - EOPNOTSUPP ;
80124 }
81- NL_SET_ERR_MSG_MOD (tmo -> common .extack , "Unsupported action" );
82- return - EOPNOTSUPP ;
125+
126+ list_del (& entry -> list );
127+
128+ return err ;
83129}
84130
85131int sparx5_tc_matchall (struct net_device * ndev ,
0 commit comments