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
This commit is contained in:

committed by
Neale Ranns

parent
1a3e08a719
commit
54be0cc044
@@ -27,7 +27,7 @@ policer_test (vlib_main_t *vm, unformat_input_t *input,
|
||||
policer_result_e result, input_colour = POLICE_CONFORM;
|
||||
uint64_t policer_time;
|
||||
|
||||
policer_read_response_type_st *pol;
|
||||
policer_t *pol;
|
||||
vnet_policer_main_t *pm = &vnet_policer_main;
|
||||
|
||||
unformat (input, "index %d", &policer_index); /* policer to use */
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
|
@@ -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__ */
|
||||
|
||||
|
Reference in New Issue
Block a user