summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorBrian Russell <brian@graphiant.com>2021-02-15 11:49:42 +0000
committerNeale Ranns <neale@graphiant.com>2021-02-15 16:18:32 +0000
commit54be0cc044f445853fae7b8995c477605250af16 (patch)
treec0be40e818039fa620efda5bb85e7535f63ef296 /src/vnet
parent1a3e08a7197addb1c07e66c1b1da3286c9bcb140 (diff)
policer: improve policer struct
Ensure policer struct is cache aligned and fits in one cache line. Give it a simpler name to reflect its job as the representation of a policer. Type: improvement Signed-off-by: Brian Russell <brian@graphiant.com> Change-Id: If1ae4931c818b86eee20306e503f4e5d6b84bd0d
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/ip/ip_punt_drop.h2
-rw-r--r--src/vnet/policer/node_funcs.c6
-rw-r--r--src/vnet/policer/police.h9
-rw-r--r--src/vnet/policer/police_inlines.h4
-rw-r--r--src/vnet/policer/policer.c13
-rw-r--r--src/vnet/policer/policer.h4
-rw-r--r--src/vnet/policer/policer_api.c6
-rw-r--r--src/vnet/policer/xlate.c14
-rw-r--r--src/vnet/policer/xlate.h3
9 files changed, 28 insertions, 33 deletions
diff --git a/src/vnet/ip/ip_punt_drop.h b/src/vnet/ip/ip_punt_drop.h
index 6e7ac5b3c4c..046a86a0056 100644
--- a/src/vnet/ip/ip_punt_drop.h
+++ b/src/vnet/ip/ip_punt_drop.h
@@ -73,7 +73,7 @@ ip_punt_policer (vlib_main_t * vm,
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_read_response_type_st *pol = &pm->policers[policer_index];
+ policer_t *pol = &pm->policers[policer_index];
u32 pol_thread_index = pol->thread_index;
u32 this_thread_index = vm->thread_index;
diff --git a/src/vnet/policer/node_funcs.c b/src/vnet/policer/node_funcs.c
index 5ede4aca944..a2c6884aa03 100644
--- a/src/vnet/policer/node_funcs.c
+++ b/src/vnet/policer/node_funcs.c
@@ -332,8 +332,8 @@ int
test_policer_add_del (u32 rx_sw_if_index, u8 * config_name, int is_add)
{
vnet_policer_main_t *pm = &vnet_policer_main;
- policer_read_response_type_st *template;
- policer_read_response_type_st *policer;
+ policer_t *template;
+ policer_t *policer;
vnet_hw_interface_t *rxhi;
uword *p;
@@ -421,7 +421,7 @@ test_policer_command_fn (vlib_main_t * vm,
if (is_show)
{
u32 pi = pm->policer_index_by_sw_if_index[rx_sw_if_index];
- policer_read_response_type_st *policer;
+ policer_t *policer;
policer = pool_elt_at_index (pm->policers, pi);
vlib_cli_output (vm, "%U", format_policer_instance, policer);
diff --git a/src/vnet/policer/police.h b/src/vnet/policer/police.h
index 7867a2e2f33..f780bf65c50 100644
--- a/src/vnet/policer/police.h
+++ b/src/vnet/policer/police.h
@@ -71,7 +71,7 @@ typedef enum
typedef struct
{
-
+ CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
u32 lock; // for exclusive access to the struct
u32 single_rate; // 1 = single rate policer, 0 = two rate policer
@@ -97,11 +97,12 @@ typedef struct
u32 thread_index; // Tie policer to a thread, rather than lock
u32 pad32;
-} policer_read_response_type_st;
+} policer_t;
+
+STATIC_ASSERT_SIZEOF (policer_t, CLIB_CACHE_LINE_BYTES);
static inline policer_result_e
-vnet_police_packet (policer_read_response_type_st * policer,
- u32 packet_length,
+vnet_police_packet (policer_t *policer, u32 packet_length,
policer_result_e packet_color, u64 time)
{
u64 n_periods;
diff --git a/src/vnet/policer/police_inlines.h b/src/vnet/policer/police_inlines.h
index f9378c7f302..fe0c754b7d4 100644
--- a/src/vnet/policer/police_inlines.h
+++ b/src/vnet/policer/police_inlines.h
@@ -65,7 +65,7 @@ vnet_policer_police (vlib_main_t * vm,
qos_action_type_en act;
u32 len;
u32 col;
- policer_read_response_type_st *pol;
+ policer_t *pol;
vnet_policer_main_t *pm = &vnet_policer_main;
/* Speculative prefetch assuming a conform result */
@@ -107,7 +107,7 @@ policer_handoff (vlib_main_t *vm, vlib_node_runtime_t *node,
u16 thread_indices[VLIB_FRAME_SIZE], *ti;
u32 n_enq, n_left_from, *from;
vnet_policer_main_t *pm;
- policer_read_response_type_st *policer;
+ policer_t *policer;
u32 this_thread, policer_thread;
pm = &vnet_policer_main;
diff --git a/src/vnet/policer/policer.c b/src/vnet/policer/policer.c
index 8146d4bb0c3..f6a19f40020 100644
--- a/src/vnet/policer/policer.c
+++ b/src/vnet/policer/policer.c
@@ -54,8 +54,8 @@ policer_add_del (vlib_main_t *vm, u8 *name, qos_pol_cfg_params_st *cfg,
u32 *policer_index, u8 is_add)
{
vnet_policer_main_t *pm = &vnet_policer_main;
- policer_read_response_type_st test_policer;
- policer_read_response_type_st *policer;
+ policer_t test_policer;
+ policer_t *policer;
uword *p;
u32 pi;
int rv;
@@ -99,7 +99,7 @@ policer_add_del (vlib_main_t *vm, u8 *name, qos_pol_cfg_params_st *cfg,
if (rv == 0)
{
- policer_read_response_type_st *pp;
+ policer_t *pp;
qos_pol_cfg_params_st *cp;
int i;
@@ -138,7 +138,7 @@ int
policer_bind_worker (u8 *name, u32 worker, bool bind)
{
vnet_policer_main_t *pm = &vnet_policer_main;
- policer_read_response_type_st *policer;
+ policer_t *policer;
uword *p;
p = hash_get_mem (pm->policer_index_by_name, name);
@@ -168,8 +168,7 @@ policer_bind_worker (u8 *name, u32 worker, bool bind)
u8 *
format_policer_instance (u8 * s, va_list * va)
{
- policer_read_response_type_st *i
- = va_arg (*va, policer_read_response_type_st *);
+ policer_t *i = va_arg (*va, policer_t *);
uword pi = va_arg (*va, uword);
int result;
vlib_counter_t counts[NUM_POLICE_RESULTS];
@@ -533,7 +532,7 @@ show_policer_command_fn (vlib_main_t * vm,
u8 *name;
uword *pi;
qos_pol_cfg_params_st *config;
- policer_read_response_type_st *templ;
+ policer_t *templ;
(void) unformat (input, "name %s", &match_name);
diff --git a/src/vnet/policer/policer.h b/src/vnet/policer/policer.h
index 4c2c7419f20..783c0ad2f35 100644
--- a/src/vnet/policer/policer.h
+++ b/src/vnet/policer/policer.h
@@ -26,11 +26,11 @@
typedef struct
{
/* policer pool, aligned */
- policer_read_response_type_st *policers;
+ policer_t *policers;
/* config + template h/w policer instance parallel pools */
qos_pol_cfg_params_st *configs;
- policer_read_response_type_st *policer_templates;
+ policer_t *policer_templates;
/* Config by name hash */
uword *policer_config_by_name;
diff --git a/src/vnet/policer/policer_api.c b/src/vnet/policer/policer_api.c
index 17ed73790cf..eff02fbeee7 100644
--- a/src/vnet/policer/policer_api.c
+++ b/src/vnet/policer/policer_api.c
@@ -118,8 +118,8 @@ vl_api_policer_bind_t_handler (vl_api_policer_bind_t *mp)
static void
send_policer_details (u8 *name, qos_pol_cfg_params_st *config,
- policer_read_response_type_st *templ,
- vl_api_registration_t *reg, u32 context)
+ policer_t *templ, vl_api_registration_t *reg,
+ u32 context)
{
vl_api_policer_details_t *mp;
@@ -170,7 +170,7 @@ vl_api_policer_dump_t_handler (vl_api_policer_dump_t * mp)
u8 *match_name = 0;
u8 *name;
qos_pol_cfg_params_st *config;
- policer_read_response_type_st *templ;
+ policer_t *templ;
reg = vl_api_client_index_to_registration (mp->client_index);
if (!reg)
diff --git a/src/vnet/policer/xlate.c b/src/vnet/policer/xlate.c
index 92f1c4721ac..9c4d76fd990 100644
--- a/src/vnet/policer/xlate.c
+++ b/src/vnet/policer/xlate.c
@@ -946,8 +946,7 @@ compute_policer_params (u64 hz, /* CPU speed in clocks per second */
* Return: Status, success or failure code.
*/
int
-x86_pol_compute_hw_params (qos_pol_cfg_params_st *cfg,
- policer_read_response_type_st *hw)
+x86_pol_compute_hw_params (qos_pol_cfg_params_st *cfg, policer_t *hw)
{
const int BYTES_PER_KBIT = (1000 / 8);
u64 hz;
@@ -1059,13 +1058,12 @@ x86_pol_compute_hw_params (qos_pol_cfg_params_st *cfg,
* Return: Status, success or failure code.
*/
int
-pol_logical_2_physical (qos_pol_cfg_params_st *cfg,
- policer_read_response_type_st *phys)
+pol_logical_2_physical (qos_pol_cfg_params_st *cfg, policer_t *phys)
{
int rc;
qos_pol_cfg_params_st kbps_cfg;
- clib_memset (phys, 0, sizeof (policer_read_response_type_st));
+ clib_memset (phys, 0, sizeof (policer_t));
clib_memset (&kbps_cfg, 0, sizeof (qos_pol_cfg_params_st));
if (!cfg)
@@ -1131,8 +1129,7 @@ pol_logical_2_physical (qos_pol_cfg_params_st *cfg,
}
static void
-qos_convert_pol_bucket_to_hw_fmt (policer_read_response_type_st *bkt,
- qos_pol_hw_params_st *hw_fmt)
+qos_convert_pol_bucket_to_hw_fmt (policer_t *bkt, qos_pol_hw_params_st *hw_fmt)
{
clib_memset (hw_fmt, 0, sizeof (qos_pol_hw_params_st));
}
@@ -1261,8 +1258,7 @@ qos_convert_burst_bytes_to_ms (u64 burst_bytes, u32 rate_kbps)
* Return: Status, success or failure code.
*/
int
-pol_physical_2_logical (policer_read_response_type_st *phys,
- qos_pol_cfg_params_st *cfg)
+pol_physical_2_logical (policer_t *phys, qos_pol_cfg_params_st *cfg)
{
int rc;
qos_pol_hw_params_st pol_hw;
diff --git a/src/vnet/policer/xlate.h b/src/vnet/policer/xlate.h
index 46e58bd94d3..722ac2fb777 100644
--- a/src/vnet/policer/xlate.h
+++ b/src/vnet/policer/xlate.h
@@ -158,8 +158,7 @@ typedef struct qos_pol_hw_params_st_
u32 extd_bkt;
} qos_pol_hw_params_st;
-int pol_logical_2_physical (qos_pol_cfg_params_st *cfg,
- policer_read_response_type_st *phys);
+int pol_logical_2_physical (qos_pol_cfg_params_st *cfg, policer_t *phys);
#endif /* __included_xlate_h__ */