99#include "ocelot_vcap.h"
1010
1111static int ocelot_flower_parse_action (struct flow_cls_offload * f ,
12- struct ocelot_ace_rule * ace )
12+ struct ocelot_vcap_filter * filter )
1313{
1414 const struct flow_action_entry * a ;
1515 s64 burst ;
@@ -26,17 +26,17 @@ static int ocelot_flower_parse_action(struct flow_cls_offload *f,
2626 flow_action_for_each (i , a , & f -> rule -> action ) {
2727 switch (a -> id ) {
2828 case FLOW_ACTION_DROP :
29- ace -> action = OCELOT_ACL_ACTION_DROP ;
29+ filter -> action = OCELOT_VCAP_ACTION_DROP ;
3030 break ;
3131 case FLOW_ACTION_TRAP :
32- ace -> action = OCELOT_ACL_ACTION_TRAP ;
32+ filter -> action = OCELOT_VCAP_ACTION_TRAP ;
3333 break ;
3434 case FLOW_ACTION_POLICE :
35- ace -> action = OCELOT_ACL_ACTION_POLICE ;
35+ filter -> action = OCELOT_VCAP_ACTION_POLICE ;
3636 rate = a -> police .rate_bytes_ps ;
37- ace -> pol .rate = div_u64 (rate , 1000 ) * 8 ;
37+ filter -> pol .rate = div_u64 (rate , 1000 ) * 8 ;
3838 burst = rate * PSCHED_NS2TICKS (a -> police .burst );
39- ace -> pol .burst = div_u64 (burst , PSCHED_TICKS_PER_SEC );
39+ filter -> pol .burst = div_u64 (burst , PSCHED_TICKS_PER_SEC );
4040 break ;
4141 default :
4242 return - EOPNOTSUPP ;
@@ -47,7 +47,7 @@ static int ocelot_flower_parse_action(struct flow_cls_offload *f,
4747}
4848
4949static int ocelot_flower_parse (struct flow_cls_offload * f ,
50- struct ocelot_ace_rule * ace )
50+ struct ocelot_vcap_filter * filter )
5151{
5252 struct flow_rule * rule = flow_cls_offload_flow_rule (f );
5353 struct flow_dissector * dissector = rule -> match .dissector ;
@@ -88,14 +88,14 @@ static int ocelot_flower_parse(struct flow_cls_offload *f,
8888 return - EOPNOTSUPP ;
8989
9090 flow_rule_match_eth_addrs (rule , & match );
91- ace -> type = OCELOT_ACE_TYPE_ETYPE ;
92- ether_addr_copy (ace -> frame .etype .dmac .value ,
91+ filter -> key_type = OCELOT_VCAP_KEY_ETYPE ;
92+ ether_addr_copy (filter -> key .etype .dmac .value ,
9393 match .key -> dst );
94- ether_addr_copy (ace -> frame .etype .smac .value ,
94+ ether_addr_copy (filter -> key .etype .smac .value ,
9595 match .key -> src );
96- ether_addr_copy (ace -> frame .etype .dmac .mask ,
96+ ether_addr_copy (filter -> key .etype .dmac .mask ,
9797 match .mask -> dst );
98- ether_addr_copy (ace -> frame .etype .smac .mask ,
98+ ether_addr_copy (filter -> key .etype .smac .mask ,
9999 match .mask -> src );
100100 goto finished_key_parsing ;
101101 }
@@ -105,18 +105,18 @@ static int ocelot_flower_parse(struct flow_cls_offload *f,
105105
106106 flow_rule_match_basic (rule , & match );
107107 if (ntohs (match .key -> n_proto ) == ETH_P_IP ) {
108- ace -> type = OCELOT_ACE_TYPE_IPV4 ;
109- ace -> frame .ipv4 .proto .value [0 ] =
108+ filter -> key_type = OCELOT_VCAP_KEY_IPV4 ;
109+ filter -> key .ipv4 .proto .value [0 ] =
110110 match .key -> ip_proto ;
111- ace -> frame .ipv4 .proto .mask [0 ] =
111+ filter -> key .ipv4 .proto .mask [0 ] =
112112 match .mask -> ip_proto ;
113113 match_protocol = false;
114114 }
115115 if (ntohs (match .key -> n_proto ) == ETH_P_IPV6 ) {
116- ace -> type = OCELOT_ACE_TYPE_IPV6 ;
117- ace -> frame .ipv6 .proto .value [0 ] =
116+ filter -> key_type = OCELOT_VCAP_KEY_IPV6 ;
117+ filter -> key .ipv6 .proto .value [0 ] =
118118 match .key -> ip_proto ;
119- ace -> frame .ipv6 .proto .mask [0 ] =
119+ filter -> key .ipv6 .proto .mask [0 ] =
120120 match .mask -> ip_proto ;
121121 match_protocol = false;
122122 }
@@ -128,16 +128,16 @@ static int ocelot_flower_parse(struct flow_cls_offload *f,
128128 u8 * tmp ;
129129
130130 flow_rule_match_ipv4_addrs (rule , & match );
131- tmp = & ace -> frame .ipv4 .sip .value .addr [0 ];
131+ tmp = & filter -> key .ipv4 .sip .value .addr [0 ];
132132 memcpy (tmp , & match .key -> src , 4 );
133133
134- tmp = & ace -> frame .ipv4 .sip .mask .addr [0 ];
134+ tmp = & filter -> key .ipv4 .sip .mask .addr [0 ];
135135 memcpy (tmp , & match .mask -> src , 4 );
136136
137- tmp = & ace -> frame .ipv4 .dip .value .addr [0 ];
137+ tmp = & filter -> key .ipv4 .dip .value .addr [0 ];
138138 memcpy (tmp , & match .key -> dst , 4 );
139139
140- tmp = & ace -> frame .ipv4 .dip .mask .addr [0 ];
140+ tmp = & filter -> key .ipv4 .dip .mask .addr [0 ];
141141 memcpy (tmp , & match .mask -> dst , 4 );
142142 match_protocol = false;
143143 }
@@ -151,22 +151,22 @@ static int ocelot_flower_parse(struct flow_cls_offload *f,
151151 struct flow_match_ports match ;
152152
153153 flow_rule_match_ports (rule , & match );
154- ace -> frame .ipv4 .sport .value = ntohs (match .key -> src );
155- ace -> frame .ipv4 .sport .mask = ntohs (match .mask -> src );
156- ace -> frame .ipv4 .dport .value = ntohs (match .key -> dst );
157- ace -> frame .ipv4 .dport .mask = ntohs (match .mask -> dst );
154+ filter -> key .ipv4 .sport .value = ntohs (match .key -> src );
155+ filter -> key .ipv4 .sport .mask = ntohs (match .mask -> src );
156+ filter -> key .ipv4 .dport .value = ntohs (match .key -> dst );
157+ filter -> key .ipv4 .dport .mask = ntohs (match .mask -> dst );
158158 match_protocol = false;
159159 }
160160
161161 if (flow_rule_match_key (rule , FLOW_DISSECTOR_KEY_VLAN )) {
162162 struct flow_match_vlan match ;
163163
164164 flow_rule_match_vlan (rule , & match );
165- ace -> type = OCELOT_ACE_TYPE_ANY ;
166- ace -> vlan .vid .value = match .key -> vlan_id ;
167- ace -> vlan .vid .mask = match .mask -> vlan_id ;
168- ace -> vlan .pcp .value [0 ] = match .key -> vlan_priority ;
169- ace -> vlan .pcp .mask [0 ] = match .mask -> vlan_priority ;
165+ filter -> key_type = OCELOT_VCAP_KEY_ANY ;
166+ filter -> vlan .vid .value = match .key -> vlan_id ;
167+ filter -> vlan .vid .mask = match .mask -> vlan_id ;
168+ filter -> vlan .pcp .value [0 ] = match .key -> vlan_priority ;
169+ filter -> vlan .pcp .mask [0 ] = match .mask -> vlan_priority ;
170170 match_protocol = false;
171171 }
172172
@@ -175,76 +175,76 @@ static int ocelot_flower_parse(struct flow_cls_offload *f,
175175 /* TODO: support SNAP, LLC etc */
176176 if (proto < ETH_P_802_3_MIN )
177177 return - EOPNOTSUPP ;
178- ace -> type = OCELOT_ACE_TYPE_ETYPE ;
179- * (__be16 * )ace -> frame .etype .etype .value = htons (proto );
180- * (__be16 * )ace -> frame .etype .etype .mask = htons (0xffff );
178+ filter -> key_type = OCELOT_VCAP_KEY_ETYPE ;
179+ * (__be16 * )filter -> key .etype .etype .value = htons (proto );
180+ * (__be16 * )filter -> key .etype .etype .mask = htons (0xffff );
181181 }
182- /* else, a rule of type OCELOT_ACE_TYPE_ANY is implicitly added */
182+ /* else, a filter of type OCELOT_VCAP_KEY_ANY is implicitly added */
183183
184- ace -> prio = f -> common .prio ;
185- ace -> id = f -> cookie ;
186- return ocelot_flower_parse_action (f , ace );
184+ filter -> prio = f -> common .prio ;
185+ filter -> id = f -> cookie ;
186+ return ocelot_flower_parse_action (f , filter );
187187}
188188
189- static
190- struct ocelot_ace_rule * ocelot_ace_rule_create (struct ocelot * ocelot , int port ,
191- struct flow_cls_offload * f )
189+ static struct ocelot_vcap_filter
190+ * ocelot_vcap_filter_create (struct ocelot * ocelot , int port ,
191+ struct flow_cls_offload * f )
192192{
193- struct ocelot_ace_rule * ace ;
193+ struct ocelot_vcap_filter * filter ;
194194
195- ace = kzalloc (sizeof (* ace ), GFP_KERNEL );
196- if (!ace )
195+ filter = kzalloc (sizeof (* filter ), GFP_KERNEL );
196+ if (!filter )
197197 return NULL ;
198198
199- ace -> ingress_port_mask = BIT (port );
200- return ace ;
199+ filter -> ingress_port_mask = BIT (port );
200+ return filter ;
201201}
202202
203203int ocelot_cls_flower_replace (struct ocelot * ocelot , int port ,
204204 struct flow_cls_offload * f , bool ingress )
205205{
206- struct ocelot_ace_rule * ace ;
206+ struct ocelot_vcap_filter * filter ;
207207 int ret ;
208208
209- ace = ocelot_ace_rule_create (ocelot , port , f );
210- if (!ace )
209+ filter = ocelot_vcap_filter_create (ocelot , port , f );
210+ if (!filter )
211211 return - ENOMEM ;
212212
213- ret = ocelot_flower_parse (f , ace );
213+ ret = ocelot_flower_parse (f , filter );
214214 if (ret ) {
215- kfree (ace );
215+ kfree (filter );
216216 return ret ;
217217 }
218218
219- return ocelot_ace_rule_offload_add (ocelot , ace , f -> common .extack );
219+ return ocelot_vcap_filter_add (ocelot , filter , f -> common .extack );
220220}
221221EXPORT_SYMBOL_GPL (ocelot_cls_flower_replace );
222222
223223int ocelot_cls_flower_destroy (struct ocelot * ocelot , int port ,
224224 struct flow_cls_offload * f , bool ingress )
225225{
226- struct ocelot_ace_rule ace ;
226+ struct ocelot_vcap_filter filter ;
227227
228- ace .prio = f -> common .prio ;
229- ace .id = f -> cookie ;
228+ filter .prio = f -> common .prio ;
229+ filter .id = f -> cookie ;
230230
231- return ocelot_ace_rule_offload_del (ocelot , & ace );
231+ return ocelot_vcap_filter_del (ocelot , & filter );
232232}
233233EXPORT_SYMBOL_GPL (ocelot_cls_flower_destroy );
234234
235235int ocelot_cls_flower_stats (struct ocelot * ocelot , int port ,
236236 struct flow_cls_offload * f , bool ingress )
237237{
238- struct ocelot_ace_rule ace ;
238+ struct ocelot_vcap_filter filter ;
239239 int ret ;
240240
241- ace .prio = f -> common .prio ;
242- ace .id = f -> cookie ;
243- ret = ocelot_ace_rule_stats_update (ocelot , & ace );
241+ filter .prio = f -> common .prio ;
242+ filter .id = f -> cookie ;
243+ ret = ocelot_vcap_filter_stats_update (ocelot , & filter );
244244 if (ret )
245245 return ret ;
246246
247- flow_stats_update (& f -> stats , 0x0 , ace .stats .pkts , 0 , 0x0 ,
247+ flow_stats_update (& f -> stats , 0x0 , filter .stats .pkts , 0 , 0x0 ,
248248 FLOW_ACTION_HW_STATS_IMMEDIATE );
249249 return 0 ;
250250}
0 commit comments