Merge tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-microblaze.git] / net / sched / act_police.c
index 2b8581f..6173194 100644 (file)
 #include <net/act_api.h>
 #include <net/netlink.h>
 #include <net/pkt_cls.h>
-
-struct tcf_police_params {
-       int                     tcfp_result;
-       u32                     tcfp_ewma_rate;
-       s64                     tcfp_burst;
-       u32                     tcfp_mtu;
-       s64                     tcfp_mtu_ptoks;
-       struct psched_ratecfg   rate;
-       bool                    rate_present;
-       struct psched_ratecfg   peak;
-       bool                    peak_present;
-       struct rcu_head rcu;
-};
-
-struct tcf_police {
-       struct tc_action        common;
-       struct tcf_police_params __rcu *params;
-
-       spinlock_t              tcfp_lock ____cacheline_aligned_in_smp;
-       s64                     tcfp_toks;
-       s64                     tcfp_ptoks;
-       s64                     tcfp_t_c;
-};
-
-#define to_police(pc) ((struct tcf_police *)pc)
-
-/* old policer structure from before tc actions */
-struct tc_police_compat {
-       u32                     index;
-       int                     action;
-       u32                     limit;
-       u32                     burst;
-       u32                     mtu;
-       struct tc_ratespec      rate;
-       struct tc_ratespec      peakrate;
-};
+#include <net/tc_act/tc_police.h>
 
 /* Each policer is serialized by its individual spinlock */
 
@@ -100,7 +65,8 @@ static int tcf_police_init(struct net *net, struct nlattr *nla,
        if (nla == NULL)
                return -EINVAL;
 
-       err = nla_parse_nested(tb, TCA_POLICE_MAX, nla, police_policy, NULL);
+       err = nla_parse_nested_deprecated(tb, TCA_POLICE_MAX, nla,
+                                         police_policy, NULL);
        if (err < 0)
                return err;
 
@@ -316,6 +282,20 @@ static void tcf_police_cleanup(struct tc_action *a)
                kfree_rcu(p, rcu);
 }
 
+static void tcf_police_stats_update(struct tc_action *a,
+                                   u64 bytes, u32 packets,
+                                   u64 lastuse, bool hw)
+{
+       struct tcf_police *police = to_police(a);
+       struct tcf_t *tm = &police->tcf_tm;
+
+       _bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), bytes, packets);
+       if (hw)
+               _bstats_cpu_update(this_cpu_ptr(a->cpu_bstats_hw),
+                                  bytes, packets);
+       tm->lastuse = max_t(u64, tm->lastuse, lastuse);
+}
+
 static int tcf_police_dump(struct sk_buff *skb, struct tc_action *a,
                               int bind, int ref)
 {
@@ -379,6 +359,7 @@ static struct tc_action_ops act_police_ops = {
        .kind           =       "police",
        .id             =       TCA_ID_POLICE,
        .owner          =       THIS_MODULE,
+       .stats_update   =       tcf_police_stats_update,
        .act            =       tcf_police_act,
        .dump           =       tcf_police_dump,
        .init           =       tcf_police_init,