Skip to content

Commit aae4e50

Browse files
vladimirolteandavem330
authored andcommitted
net: mscc: ocelot: generalize the "ACE/ACL" names
Access Control Lists (and their respective Access Control Entries) are specifically entries in the VCAP IS2, the security enforcement block, according to the documentation. Let's rename the structures and functions to something more generic, so that VCAP IS1 structures (which would otherwise have to be called Ingress Classification Entries) can reuse the same code without confusion. Some renaming that was done: struct ocelot_ace_rule -> struct ocelot_vcap_filter struct ocelot_acl_block -> struct ocelot_vcap_block enum ocelot_ace_type -> enum ocelot_vcap_key_type struct ocelot_ace_vlan -> struct ocelot_vcap_key_vlan enum ocelot_ace_action -> enum ocelot_vcap_action struct ocelot_ace_stats -> struct ocelot_vcap_stats enum ocelot_ace_type -> enum ocelot_vcap_key_type struct ocelot_ace_frame_* -> struct ocelot_vcap_key_* No functional change is intended. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3c83654 commit aae4e50

6 files changed

Lines changed: 257 additions & 251 deletions

File tree

‎drivers/net/ethernet/mscc/ocelot.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ int ocelot_init(struct ocelot *ocelot)
13921392
INIT_LIST_HEAD(&ocelot->multicast);
13931393
ocelot_mact_init(ocelot);
13941394
ocelot_vlan_init(ocelot);
1395-
ocelot_ace_init(ocelot);
1395+
ocelot_vcap_init(ocelot);
13961396

13971397
for (port = 0; port < ocelot->num_phys_ports; port++) {
13981398
/* Clear all counters (5 groups) */

‎drivers/net/ethernet/mscc/ocelot_flower.c‎

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "ocelot_vcap.h"
1010

1111
static 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

4949
static 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

203203
int 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
}
221221
EXPORT_SYMBOL_GPL(ocelot_cls_flower_replace);
222222

223223
int 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
}
233233
EXPORT_SYMBOL_GPL(ocelot_cls_flower_destroy);
234234

235235
int 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
}

‎drivers/net/ethernet/mscc/ocelot_police.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ struct qos_policer_conf {
3333
int qos_policer_conf_set(struct ocelot *ocelot, int port, u32 pol_ix,
3434
struct qos_policer_conf *conf);
3535

36-
int ocelot_ace_policer_add(struct ocelot *ocelot, u32 pol_ix,
37-
struct ocelot_policer *pol);
36+
int ocelot_vcap_policer_add(struct ocelot *ocelot, u32 pol_ix,
37+
struct ocelot_policer *pol);
3838

39-
int ocelot_ace_policer_del(struct ocelot *ocelot, u32 pol_ix);
39+
int ocelot_vcap_policer_del(struct ocelot *ocelot, u32 pol_ix);
4040

4141
#endif /* _MSCC_OCELOT_POLICE_H_ */

0 commit comments

Comments
 (0)