summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorBrian Russell <brian@graphiant.com>2021-01-19 16:46:08 +0000
committerNeale Ranns <neale@graphiant.com>2021-01-28 10:25:41 +0000
commit89cd74427277692f77f2d38e79495592ad440a68 (patch)
tree8bc08249b3cbefe58e67b2609ad7cbe7ea081f3a /src/vnet
parent3d5f08a825a978cd6853989a5df8c9b9811e7fb8 (diff)
policer: add thread index to policer
Add a thread index field to the policer structure. The policer is not thread safe. The thread index will be used to tie it to one worker thread and other workers can use thread handoff. Type: improvement Signed-off-by: Brian Russell <brian@graphiant.com> Change-Id: I650e983a9ed800bf660d6f06368717484c4a83bf
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/policer/police.h10
-rw-r--r--src/vnet/policer/policer.c1
2 files changed, 8 insertions, 3 deletions
diff --git a/src/vnet/policer/police.h b/src/vnet/policer/police.h
index 7065adb6e30..1005a620ccd 100644
--- a/src/vnet/policer/police.h
+++ b/src/vnet/policer/police.h
@@ -50,9 +50,12 @@ typedef enum
// computes the shift amount be the largest possible that still supports the
// burst size. This makes the rate accuracy as high as possible.
//
-// The 64-bit last_update_time supports a 4Ghz CPU without rollover for 100 years
+// The 64-bit last_update_time supports a 4Ghz CPU without rollover for 100
+// years
//
-// The lock field should be used for a spin-lock on the struct.
+// The lock field should be used for a spin-lock on the struct. Alternatively,
+// a thread index field is provided so that policed packets may be handed
+// off to a single worker thread.
#define POLICER_TICKS_PER_PERIOD_SHIFT 17
#define POLICER_TICKS_PER_PERIOD (1 << POLICER_TICKS_PER_PERIOD_SHIFT)
@@ -82,7 +85,8 @@ typedef struct
u32 extended_bucket; // MOD
u64 last_update_time; // MOD
- u64 pad64;
+ u32 thread_index; // Tie policer to a thread, rather than lock
+ u32 pad32;
} policer_read_response_type_st;
diff --git a/src/vnet/policer/policer.c b/src/vnet/policer/policer.c
index 9611fe0fa4e..7ad87a6ebdf 100644
--- a/src/vnet/policer/policer.c
+++ b/src/vnet/policer/policer.c
@@ -87,6 +87,7 @@ policer_add_del (vlib_main_t * vm,
pi = policer - pm->policers;
hash_set_mem (pm->policer_index_by_name, name, pi);
*policer_index = pi;
+ policer->thread_index = ~0;
}
else
{