|
13 | 13 | #include <linux/of_net.h> |
14 | 14 | #include <linux/pci.h> |
15 | 15 | #include <linux/of.h> |
| 16 | +#include <net/pkt_sched.h> |
16 | 17 | #include <net/dsa.h> |
17 | 18 | #include "felix.h" |
18 | 19 |
|
@@ -650,6 +651,27 @@ static int felix_cls_flower_stats(struct dsa_switch *ds, int port, |
650 | 651 | return ocelot_cls_flower_stats(ocelot, port, cls, ingress); |
651 | 652 | } |
652 | 653 |
|
| 654 | +static int felix_port_policer_add(struct dsa_switch *ds, int port, |
| 655 | + struct dsa_mall_policer_tc_entry *policer) |
| 656 | +{ |
| 657 | + struct ocelot *ocelot = ds->priv; |
| 658 | + struct ocelot_policer pol = { |
| 659 | + .rate = div_u64(policer->rate_bytes_per_sec, 1000) * 8, |
| 660 | + .burst = div_u64(policer->rate_bytes_per_sec * |
| 661 | + PSCHED_NS2TICKS(policer->burst), |
| 662 | + PSCHED_TICKS_PER_SEC), |
| 663 | + }; |
| 664 | + |
| 665 | + return ocelot_port_policer_add(ocelot, port, &pol); |
| 666 | +} |
| 667 | + |
| 668 | +static void felix_port_policer_del(struct dsa_switch *ds, int port) |
| 669 | +{ |
| 670 | + struct ocelot *ocelot = ds->priv; |
| 671 | + |
| 672 | + ocelot_port_policer_del(ocelot, port); |
| 673 | +} |
| 674 | + |
653 | 675 | static const struct dsa_switch_ops felix_switch_ops = { |
654 | 676 | .get_tag_protocol = felix_get_tag_protocol, |
655 | 677 | .setup = felix_setup, |
@@ -683,6 +705,8 @@ static const struct dsa_switch_ops felix_switch_ops = { |
683 | 705 | .port_txtstamp = felix_txtstamp, |
684 | 706 | .port_change_mtu = felix_change_mtu, |
685 | 707 | .port_max_mtu = felix_get_max_mtu, |
| 708 | + .port_policer_add = felix_port_policer_add, |
| 709 | + .port_policer_del = felix_port_policer_del, |
686 | 710 | .cls_flower_add = felix_cls_flower_add, |
687 | 711 | .cls_flower_del = felix_cls_flower_del, |
688 | 712 | .cls_flower_stats = felix_cls_flower_stats, |
|
0 commit comments