aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/policer/policer.c
diff options
context:
space:
mode:
authorBrian Russell <brian@graphiant.com>2021-02-10 13:53:42 +0000
committerNeale Ranns <neale@graphiant.com>2021-02-15 12:15:32 +0000
commit48e26367cfe731d31472e18c1e0f6fe94bc4e9c3 (patch)
tree02216ea7b487311f7c947e7d3e15cebb5e3144f1 /src/vnet/policer/policer.c
parentfd0b399ff6dc246ce989cb592cf27d0015497711 (diff)
policer: add api to bind policer to worker
Add a new api to allow a policer to be bound to a specific worker thread for thread handoff. Type: improvement Signed-off-by: Brian Russell <brian@graphiant.com> Change-Id: I2623a6827843c3d93c0d7b4ad7c2e13611ec1696
Diffstat (limited to 'src/vnet/policer/policer.c')
-rw-r--r--src/vnet/policer/policer.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/vnet/policer/policer.c b/src/vnet/policer/policer.c
index 2c05ae21515..8146d4bb0c3 100644
--- a/src/vnet/policer/policer.c
+++ b/src/vnet/policer/policer.c
@@ -13,6 +13,7 @@
* limitations under the License.
*/
#include <stdint.h>
+#include <stdbool.h>
#include <vnet/policer/policer.h>
#include <vnet/policer/police_inlines.h>
#include <vnet/classify/vnet_classify.h>
@@ -133,6 +134,37 @@ policer_add_del (vlib_main_t *vm, u8 *name, qos_pol_cfg_params_st *cfg,
return 0;
}
+int
+policer_bind_worker (u8 *name, u32 worker, bool bind)
+{
+ vnet_policer_main_t *pm = &vnet_policer_main;
+ policer_read_response_type_st *policer;
+ uword *p;
+
+ p = hash_get_mem (pm->policer_index_by_name, name);
+ if (p == 0)
+ {
+ return VNET_API_ERROR_NO_SUCH_ENTRY;
+ }
+
+ policer = &pm->policers[p[0]];
+
+ if (bind)
+ {
+ if (worker >= vlib_num_workers ())
+ {
+ return VNET_API_ERROR_INVALID_WORKER;
+ }
+
+ policer->thread_index = vlib_get_worker_thread_index (worker);
+ }
+ else
+ {
+ policer->thread_index = ~0;
+ }
+ return 0;
+}
+
u8 *
format_policer_instance (u8 * s, va_list * va)
{