aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip_punt_drop.h
diff options
context:
space:
mode:
authorBrian Russell <brian@graphiant.com>2021-02-18 10:25:23 +0000
committerNeale Ranns <neale@graphiant.com>2021-02-19 10:53:15 +0000
commitfce88656cc1b0da8731a71c4a6efa759e0df3fa8 (patch)
tree52d58afa787b5d6b0ffcabc70f99e8313c4875df /src/vnet/ip/ip_punt_drop.h
parent6e6920d4e096bd158a0057ce0f8dd8a08cbabf72 (diff)
policer: move handoff checks into policer code
The IP punt policer currently checks if it needs to do worker thread handoff based on the thread index stored in the policer. Move this functionality into the policer code so it can be common for all users of the policer. Type: improvement Signed-off-by: Brian Russell <brian@graphiant.com> Change-Id: Ia8d11e62898a58b19d7b27b296f8369baa3e5aa1
Diffstat (limited to 'src/vnet/ip/ip_punt_drop.h')
-rw-r--r--src/vnet/ip/ip_punt_drop.h42
1 files changed, 12 insertions, 30 deletions
diff --git a/src/vnet/ip/ip_punt_drop.h b/src/vnet/ip/ip_punt_drop.h
index 046a86a0056..16d46ba190e 100644
--- a/src/vnet/ip/ip_punt_drop.h
+++ b/src/vnet/ip/ip_punt_drop.h
@@ -72,10 +72,6 @@ ip_punt_policer (vlib_main_t * vm,
u64 time_in_policer_periods;
vnet_feature_main_t *fm = &feature_main;
vnet_feature_config_main_t *cm = &fm->feature_config_mains[arc_index];
- vnet_policer_main_t *pm = &vnet_policer_main;
- policer_t *pol = &pm->policers[policer_index];
- u32 pol_thread_index = pol->thread_index;
- u32 this_thread_index = vm->thread_index;
time_in_policer_periods =
clib_cpu_time_now () >> POLICER_TICKS_PER_PERIOD_SHIFT;
@@ -84,20 +80,6 @@ ip_punt_policer (vlib_main_t * vm,
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
- if (PREDICT_FALSE (pol_thread_index == ~0))
- {
- /*
- * This is the first packet to use this policer. Set the
- * thread index in the policer to this thread and any
- * packets seen by this node on other threads will
- * be handed off to this one.
- *
- * This could happen simultaneously on another thread.
- */
- clib_atomic_cmp_and_swap (&pol->thread_index, ~0, this_thread_index);
- pol_thread_index = this_thread_index;
- }
-
while (n_left_from > 0)
{
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
@@ -121,7 +103,14 @@ ip_punt_policer (vlib_main_t * vm,
b0 = vlib_get_buffer (vm, bi0);
b1 = vlib_get_buffer (vm, bi1);
- if (PREDICT_FALSE (this_thread_index != pol_thread_index))
+ act0 = vnet_policer_police (vm, b0, policer_index,
+ time_in_policer_periods, POLICE_CONFORM,
+ true);
+ act1 = vnet_policer_police (vm, b1, policer_index,
+ time_in_policer_periods, POLICE_CONFORM,
+ true);
+
+ if (PREDICT_FALSE (act0 == QOS_ACTION_HANDOFF))
{
next0 = next1 = IP_PUNT_POLICER_NEXT_HANDOFF;
}
@@ -133,13 +122,6 @@ ip_punt_policer (vlib_main_t * vm,
vnet_get_config_data (&cm->config_main,
&b1->current_config_index, &next1, 0);
- act0 =
- vnet_policer_police (vm, b0, policer_index,
- time_in_policer_periods, POLICE_CONFORM);
- act1 =
- vnet_policer_police (vm, b1, policer_index,
- time_in_policer_periods, POLICE_CONFORM);
-
if (PREDICT_FALSE (act0 == QOS_ACTION_DROP))
{
next0 = IP_PUNT_POLICER_NEXT_DROP;
@@ -188,7 +170,10 @@ ip_punt_policer (vlib_main_t * vm,
b0 = vlib_get_buffer (vm, bi0);
- if (PREDICT_FALSE (this_thread_index != pol_thread_index))
+ act0 = vnet_policer_police (vm, b0, policer_index,
+ time_in_policer_periods, POLICE_CONFORM,
+ true);
+ if (PREDICT_FALSE (act0 == QOS_ACTION_HANDOFF))
{
next0 = IP_PUNT_POLICER_NEXT_HANDOFF;
}
@@ -197,9 +182,6 @@ ip_punt_policer (vlib_main_t * vm,
vnet_get_config_data (&cm->config_main,
&b0->current_config_index, &next0, 0);
- act0 =
- vnet_policer_police (vm, b0, policer_index,
- time_in_policer_periods, POLICE_CONFORM);
if (PREDICT_FALSE (act0 == QOS_ACTION_DROP))
{
next0 = IP_PUNT_POLICER_NEXT_DROP;