2019-05-31 14:16:57 +07:00
|
|
|
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
|
|
|
|
/* Microsemi Ocelot Switch driver
|
|
|
|
* Copyright (c) 2019 Microsemi Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <net/pkt_cls.h>
|
|
|
|
#include <net/tc_act/tc_gact.h>
|
|
|
|
|
|
|
|
#include "ocelot_ace.h"
|
|
|
|
|
2019-07-10 03:55:49 +07:00
|
|
|
static int ocelot_flower_parse_action(struct flow_cls_offload *f,
|
2020-02-29 21:31:07 +07:00
|
|
|
struct ocelot_ace_rule *ace)
|
2019-05-31 14:16:57 +07:00
|
|
|
{
|
|
|
|
const struct flow_action_entry *a;
|
2020-03-29 18:51:57 +07:00
|
|
|
s64 burst;
|
|
|
|
u64 rate;
|
2019-05-31 14:16:57 +07:00
|
|
|
int i;
|
|
|
|
|
2020-03-07 18:40:12 +07:00
|
|
|
if (!flow_offload_has_one_action(&f->rule->action))
|
2019-05-31 14:16:57 +07:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2020-03-17 08:42:11 +07:00
|
|
|
if (!flow_action_basic_hw_stats_check(&f->rule->action,
|
|
|
|
f->common.extack))
|
2020-03-07 18:40:13 +07:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2019-05-31 14:16:57 +07:00
|
|
|
flow_action_for_each(i, a, &f->rule->action) {
|
|
|
|
switch (a->id) {
|
|
|
|
case FLOW_ACTION_DROP:
|
2020-02-29 21:31:07 +07:00
|
|
|
ace->action = OCELOT_ACL_ACTION_DROP;
|
2019-05-31 14:16:57 +07:00
|
|
|
break;
|
|
|
|
case FLOW_ACTION_TRAP:
|
2020-02-29 21:31:07 +07:00
|
|
|
ace->action = OCELOT_ACL_ACTION_TRAP;
|
2019-05-31 14:16:57 +07:00
|
|
|
break;
|
2020-03-29 18:51:57 +07:00
|
|
|
case FLOW_ACTION_POLICE:
|
|
|
|
ace->action = OCELOT_ACL_ACTION_POLICE;
|
|
|
|
rate = a->police.rate_bytes_ps;
|
|
|
|
ace->pol.rate = div_u64(rate, 1000) * 8;
|
|
|
|
burst = rate * PSCHED_NS2TICKS(a->police.burst);
|
|
|
|
ace->pol.burst = div_u64(burst, PSCHED_TICKS_PER_SEC);
|
|
|
|
break;
|
2019-05-31 14:16:57 +07:00
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-07-10 03:55:49 +07:00
|
|
|
static int ocelot_flower_parse(struct flow_cls_offload *f,
|
2020-02-29 21:31:07 +07:00
|
|
|
struct ocelot_ace_rule *ace)
|
2019-05-31 14:16:57 +07:00
|
|
|
{
|
2019-07-10 03:55:49 +07:00
|
|
|
struct flow_rule *rule = flow_cls_offload_flow_rule(f);
|
2019-05-31 14:16:57 +07:00
|
|
|
struct flow_dissector *dissector = rule->match.dissector;
|
2020-04-20 23:27:41 +07:00
|
|
|
u16 proto = ntohs(f->common.protocol);
|
|
|
|
bool match_protocol = true;
|
2019-05-31 14:16:57 +07:00
|
|
|
|
|
|
|
if (dissector->used_keys &
|
|
|
|
~(BIT(FLOW_DISSECTOR_KEY_CONTROL) |
|
|
|
|
BIT(FLOW_DISSECTOR_KEY_BASIC) |
|
|
|
|
BIT(FLOW_DISSECTOR_KEY_PORTS) |
|
|
|
|
BIT(FLOW_DISSECTOR_KEY_VLAN) |
|
|
|
|
BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) |
|
|
|
|
BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) |
|
|
|
|
BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS))) {
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL)) {
|
|
|
|
struct flow_match_control match;
|
|
|
|
|
|
|
|
flow_rule_match_control(rule, &match);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
|
|
|
|
struct flow_match_eth_addrs match;
|
|
|
|
|
|
|
|
/* The hw support mac matches only for MAC_ETYPE key,
|
|
|
|
* therefore if other matches(port, tcp flags, etc) are added
|
|
|
|
* then just bail out
|
|
|
|
*/
|
|
|
|
if ((dissector->used_keys &
|
|
|
|
(BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) |
|
|
|
|
BIT(FLOW_DISSECTOR_KEY_BASIC) |
|
|
|
|
BIT(FLOW_DISSECTOR_KEY_CONTROL))) !=
|
|
|
|
(BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) |
|
|
|
|
BIT(FLOW_DISSECTOR_KEY_BASIC) |
|
|
|
|
BIT(FLOW_DISSECTOR_KEY_CONTROL)))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
flow_rule_match_eth_addrs(rule, &match);
|
2020-02-29 21:31:07 +07:00
|
|
|
ace->type = OCELOT_ACE_TYPE_ETYPE;
|
|
|
|
ether_addr_copy(ace->frame.etype.dmac.value,
|
2019-05-31 14:16:57 +07:00
|
|
|
match.key->dst);
|
2020-02-29 21:31:07 +07:00
|
|
|
ether_addr_copy(ace->frame.etype.smac.value,
|
2019-05-31 14:16:57 +07:00
|
|
|
match.key->src);
|
2020-02-29 21:31:07 +07:00
|
|
|
ether_addr_copy(ace->frame.etype.dmac.mask,
|
2019-05-31 14:16:57 +07:00
|
|
|
match.mask->dst);
|
2020-02-29 21:31:07 +07:00
|
|
|
ether_addr_copy(ace->frame.etype.smac.mask,
|
2019-05-31 14:16:57 +07:00
|
|
|
match.mask->src);
|
|
|
|
goto finished_key_parsing;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
|
|
|
|
struct flow_match_basic match;
|
|
|
|
|
|
|
|
flow_rule_match_basic(rule, &match);
|
|
|
|
if (ntohs(match.key->n_proto) == ETH_P_IP) {
|
2020-02-29 21:31:07 +07:00
|
|
|
ace->type = OCELOT_ACE_TYPE_IPV4;
|
|
|
|
ace->frame.ipv4.proto.value[0] =
|
2019-05-31 14:16:57 +07:00
|
|
|
match.key->ip_proto;
|
2020-02-29 21:31:07 +07:00
|
|
|
ace->frame.ipv4.proto.mask[0] =
|
2019-05-31 14:16:57 +07:00
|
|
|
match.mask->ip_proto;
|
2020-04-20 23:27:41 +07:00
|
|
|
match_protocol = false;
|
2019-05-31 14:16:57 +07:00
|
|
|
}
|
|
|
|
if (ntohs(match.key->n_proto) == ETH_P_IPV6) {
|
2020-02-29 21:31:07 +07:00
|
|
|
ace->type = OCELOT_ACE_TYPE_IPV6;
|
|
|
|
ace->frame.ipv6.proto.value[0] =
|
2019-05-31 14:16:57 +07:00
|
|
|
match.key->ip_proto;
|
2020-02-29 21:31:07 +07:00
|
|
|
ace->frame.ipv6.proto.mask[0] =
|
2019-05-31 14:16:57 +07:00
|
|
|
match.mask->ip_proto;
|
2020-04-20 23:27:41 +07:00
|
|
|
match_protocol = false;
|
2019-05-31 14:16:57 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS) &&
|
2020-04-20 23:27:41 +07:00
|
|
|
proto == ETH_P_IP) {
|
2019-05-31 14:16:57 +07:00
|
|
|
struct flow_match_ipv4_addrs match;
|
|
|
|
u8 *tmp;
|
|
|
|
|
|
|
|
flow_rule_match_ipv4_addrs(rule, &match);
|
2020-02-29 21:31:07 +07:00
|
|
|
tmp = &ace->frame.ipv4.sip.value.addr[0];
|
2019-05-31 14:16:57 +07:00
|
|
|
memcpy(tmp, &match.key->src, 4);
|
|
|
|
|
2020-02-29 21:31:07 +07:00
|
|
|
tmp = &ace->frame.ipv4.sip.mask.addr[0];
|
2019-05-31 14:16:57 +07:00
|
|
|
memcpy(tmp, &match.mask->src, 4);
|
|
|
|
|
2020-02-29 21:31:07 +07:00
|
|
|
tmp = &ace->frame.ipv4.dip.value.addr[0];
|
2019-05-31 14:16:57 +07:00
|
|
|
memcpy(tmp, &match.key->dst, 4);
|
|
|
|
|
2020-02-29 21:31:07 +07:00
|
|
|
tmp = &ace->frame.ipv4.dip.mask.addr[0];
|
2019-05-31 14:16:57 +07:00
|
|
|
memcpy(tmp, &match.mask->dst, 4);
|
2020-04-20 23:27:41 +07:00
|
|
|
match_protocol = false;
|
2019-05-31 14:16:57 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV6_ADDRS) &&
|
2020-04-20 23:27:41 +07:00
|
|
|
proto == ETH_P_IPV6) {
|
2019-05-31 14:16:57 +07:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) {
|
|
|
|
struct flow_match_ports match;
|
|
|
|
|
|
|
|
flow_rule_match_ports(rule, &match);
|
2020-02-29 21:31:07 +07:00
|
|
|
ace->frame.ipv4.sport.value = ntohs(match.key->src);
|
|
|
|
ace->frame.ipv4.sport.mask = ntohs(match.mask->src);
|
|
|
|
ace->frame.ipv4.dport.value = ntohs(match.key->dst);
|
|
|
|
ace->frame.ipv4.dport.mask = ntohs(match.mask->dst);
|
2020-04-20 23:27:41 +07:00
|
|
|
match_protocol = false;
|
2019-05-31 14:16:57 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) {
|
|
|
|
struct flow_match_vlan match;
|
|
|
|
|
|
|
|
flow_rule_match_vlan(rule, &match);
|
2020-02-29 21:31:07 +07:00
|
|
|
ace->type = OCELOT_ACE_TYPE_ANY;
|
|
|
|
ace->vlan.vid.value = match.key->vlan_id;
|
|
|
|
ace->vlan.vid.mask = match.mask->vlan_id;
|
|
|
|
ace->vlan.pcp.value[0] = match.key->vlan_priority;
|
|
|
|
ace->vlan.pcp.mask[0] = match.mask->vlan_priority;
|
2020-04-20 23:27:41 +07:00
|
|
|
match_protocol = false;
|
2019-05-31 14:16:57 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
finished_key_parsing:
|
2020-04-20 23:27:41 +07:00
|
|
|
if (match_protocol && proto != ETH_P_ALL) {
|
|
|
|
/* TODO: support SNAP, LLC etc */
|
|
|
|
if (proto < ETH_P_802_3_MIN)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
ace->type = OCELOT_ACE_TYPE_ETYPE;
|
2020-06-20 22:43:38 +07:00
|
|
|
*(__be16 *)ace->frame.etype.etype.value = htons(proto);
|
|
|
|
*(__be16 *)ace->frame.etype.etype.mask = htons(0xffff);
|
2020-04-20 23:27:41 +07:00
|
|
|
}
|
|
|
|
/* else, a rule of type OCELOT_ACE_TYPE_ANY is implicitly added */
|
|
|
|
|
2020-02-29 21:31:07 +07:00
|
|
|
ace->prio = f->common.prio;
|
|
|
|
ace->id = f->cookie;
|
|
|
|
return ocelot_flower_parse_action(f, ace);
|
2019-05-31 14:16:57 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
struct ocelot_ace_rule *ocelot_ace_rule_create(struct ocelot *ocelot, int port,
|
|
|
|
struct flow_cls_offload *f)
|
2019-05-31 14:16:57 +07:00
|
|
|
{
|
2020-02-29 21:31:07 +07:00
|
|
|
struct ocelot_ace_rule *ace;
|
2019-05-31 14:16:57 +07:00
|
|
|
|
2020-02-29 21:31:07 +07:00
|
|
|
ace = kzalloc(sizeof(*ace), GFP_KERNEL);
|
|
|
|
if (!ace)
|
2019-05-31 14:16:57 +07:00
|
|
|
return NULL;
|
|
|
|
|
2020-02-29 21:31:07 +07:00
|
|
|
ace->ingress_port_mask = BIT(port);
|
|
|
|
return ace;
|
2019-05-31 14:16:57 +07:00
|
|
|
}
|
|
|
|
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
int ocelot_cls_flower_replace(struct ocelot *ocelot, int port,
|
|
|
|
struct flow_cls_offload *f, bool ingress)
|
2019-05-31 14:16:57 +07:00
|
|
|
{
|
2020-02-29 21:31:07 +07:00
|
|
|
struct ocelot_ace_rule *ace;
|
2019-05-31 14:16:57 +07:00
|
|
|
int ret;
|
|
|
|
|
2020-02-29 21:31:07 +07:00
|
|
|
ace = ocelot_ace_rule_create(ocelot, port, f);
|
|
|
|
if (!ace)
|
2019-05-31 14:16:57 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2020-02-29 21:31:07 +07:00
|
|
|
ret = ocelot_flower_parse(f, ace);
|
2019-05-31 14:16:57 +07:00
|
|
|
if (ret) {
|
2020-02-29 21:31:07 +07:00
|
|
|
kfree(ace);
|
2019-05-31 14:16:57 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-04-18 02:03:08 +07:00
|
|
|
return ocelot_ace_rule_offload_add(ocelot, ace, f->common.extack);
|
2019-05-31 14:16:57 +07:00
|
|
|
}
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
EXPORT_SYMBOL_GPL(ocelot_cls_flower_replace);
|
2019-05-31 14:16:57 +07:00
|
|
|
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port,
|
|
|
|
struct flow_cls_offload *f, bool ingress)
|
2019-05-31 14:16:57 +07:00
|
|
|
{
|
2020-02-29 21:31:07 +07:00
|
|
|
struct ocelot_ace_rule ace;
|
2019-05-31 14:16:57 +07:00
|
|
|
|
2020-02-29 21:31:07 +07:00
|
|
|
ace.prio = f->common.prio;
|
|
|
|
ace.id = f->cookie;
|
2019-05-31 14:16:57 +07:00
|
|
|
|
2020-02-29 21:31:08 +07:00
|
|
|
return ocelot_ace_rule_offload_del(ocelot, &ace);
|
2019-05-31 14:16:57 +07:00
|
|
|
}
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
EXPORT_SYMBOL_GPL(ocelot_cls_flower_destroy);
|
2019-05-31 14:16:57 +07:00
|
|
|
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
int ocelot_cls_flower_stats(struct ocelot *ocelot, int port,
|
|
|
|
struct flow_cls_offload *f, bool ingress)
|
2019-05-31 14:16:57 +07:00
|
|
|
{
|
2020-02-29 21:31:07 +07:00
|
|
|
struct ocelot_ace_rule ace;
|
2019-05-31 14:16:57 +07:00
|
|
|
int ret;
|
|
|
|
|
2020-02-29 21:31:07 +07:00
|
|
|
ace.prio = f->common.prio;
|
|
|
|
ace.id = f->cookie;
|
|
|
|
ret = ocelot_ace_rule_stats_update(ocelot, &ace);
|
2019-05-31 14:16:57 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2020-06-19 13:01:07 +07:00
|
|
|
flow_stats_update(&f->stats, 0x0, ace.stats.pkts, 0, 0x0,
|
2020-03-28 22:37:43 +07:00
|
|
|
FLOW_ACTION_HW_STATS_IMMEDIATE);
|
2019-05-31 14:16:57 +07:00
|
|
|
return 0;
|
|
|
|
}
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
EXPORT_SYMBOL_GPL(ocelot_cls_flower_stats);
|
2019-05-31 14:16:57 +07:00
|
|
|
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
int ocelot_setup_tc_cls_flower(struct ocelot_port_private *priv,
|
|
|
|
struct flow_cls_offload *f,
|
|
|
|
bool ingress)
|
2019-05-31 14:16:57 +07:00
|
|
|
{
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
struct ocelot *ocelot = priv->port.ocelot;
|
|
|
|
int port = priv->chip_port;
|
|
|
|
|
|
|
|
if (!ingress)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2019-05-31 14:16:57 +07:00
|
|
|
switch (f->command) {
|
2019-07-10 03:55:49 +07:00
|
|
|
case FLOW_CLS_REPLACE:
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
return ocelot_cls_flower_replace(ocelot, port, f, ingress);
|
2019-07-10 03:55:49 +07:00
|
|
|
case FLOW_CLS_DESTROY:
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
return ocelot_cls_flower_destroy(ocelot, port, f, ingress);
|
2019-07-10 03:55:49 +07:00
|
|
|
case FLOW_CLS_STATS:
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
return ocelot_cls_flower_stats(ocelot, port, f, ingress);
|
2019-05-31 14:16:57 +07:00
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|