summaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
Diffstat (limited to 'include/net')
-rw-r--r--include/net/dsa.h2
-rw-r--r--include/net/flow_offload.h2
-rw-r--r--include/net/tc_act/tc_police.h32
3 files changed, 32 insertions, 4 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 50389772c597..4046ccd1945d 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -144,7 +144,7 @@ struct dsa_mall_mirror_tc_entry {
/* TC port policer entry */
struct dsa_mall_policer_tc_entry {
- s64 burst;
+ u32 burst;
u64 rate_bytes_per_sec;
};
diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 3e793ac66baf..de395498440d 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -233,7 +233,7 @@ struct flow_action_entry {
} sample;
struct { /* FLOW_ACTION_POLICE */
u32 index;
- s64 burst;
+ u32 burst;
u64 rate_bytes_ps;
u32 mtu;
} police;
diff --git a/include/net/tc_act/tc_police.h b/include/net/tc_act/tc_police.h
index cd973b10ae8c..6d1e26b709b5 100644
--- a/include/net/tc_act/tc_police.h
+++ b/include/net/tc_act/tc_police.h
@@ -59,14 +59,42 @@ static inline u64 tcf_police_rate_bytes_ps(const struct tc_action *act)
return params->rate.rate_bytes_ps;
}
-static inline s64 tcf_police_tcfp_burst(const struct tc_action *act)
+static inline u32 tcf_police_burst(const struct tc_action *act)
{
struct tcf_police *police = to_police(act);
struct tcf_police_params *params;
+ u32 burst;
params = rcu_dereference_protected(police->params,
lockdep_is_held(&police->tcf_lock));
- return params->tcfp_burst;
+
+ /*
+ * "rate" bytes "burst" nanoseconds
+ * ------------ * -------------------
+ * 1 second 2^6 ticks
+ *
+ * ------------------------------------
+ * NSEC_PER_SEC nanoseconds
+ * ------------------------
+ * 2^6 ticks
+ *
+ * "rate" bytes "burst" nanoseconds 2^6 ticks
+ * = ------------ * ------------------- * ------------------------
+ * 1 second 2^6 ticks NSEC_PER_SEC nanoseconds
+ *
+ * "rate" * "burst"
+ * = ---------------- bytes/nanosecond
+ * NSEC_PER_SEC^2
+ *
+ *
+ * "rate" * "burst"
+ * = ---------------- bytes/second
+ * NSEC_PER_SEC
+ */
+ burst = div_u64(params->tcfp_burst * params->rate.rate_bytes_ps,
+ NSEC_PER_SEC);
+
+ return burst;
}
static inline u32 tcf_police_tcfp_mtu(const struct tc_action *act)