summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c9
-rw-r--r--src/vnet/policer/police.h9
-rw-r--r--src/vnet/policer/police_inlines.h2
-rw-r--r--src/vnet/policer/policer_api.c12
-rw-r--r--src/vnet/policer/xlate.c24
-rw-r--r--src/vnet/policer/xlate.h25
6 files changed, 37 insertions, 44 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index b16f664f52c..a59544a09c5 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -11652,11 +11652,14 @@ api_policer_add_del (vat_main_t * vam)
mp->rate_type = rate_type;
mp->round_type = round_type;
mp->type = type;
- mp->conform_action.type = conform_action.action_type;
+ mp->conform_action.type =
+ (vl_api_sse2_qos_action_type_t) conform_action.action_type;
mp->conform_action.dscp = conform_action.dscp;
- mp->exceed_action.type = exceed_action.action_type;
+ mp->exceed_action.type =
+ (vl_api_sse2_qos_action_type_t) exceed_action.action_type;
mp->exceed_action.dscp = exceed_action.dscp;
- mp->violate_action.type = violate_action.action_type;
+ mp->violate_action.type =
+ (vl_api_sse2_qos_action_type_t) violate_action.action_type;
mp->violate_action.dscp = violate_action.dscp;
mp->color_aware = color_aware;
diff --git a/src/vnet/policer/police.h b/src/vnet/policer/police.h
index 602784504b2..7867a2e2f33 100644
--- a/src/vnet/policer/police.h
+++ b/src/vnet/policer/police.h
@@ -24,6 +24,13 @@ typedef enum
#define NUM_POLICE_RESULTS 3
+typedef enum
+{
+ QOS_ACTION_DROP = 0,
+ QOS_ACTION_TRANSMIT,
+ QOS_ACTION_MARK_AND_TRANSMIT
+} __clib_packed qos_action_type_en;
+
// This is the hardware representation of the policer.
// To be multithread-safe, the policer is accessed through a spin-lock
// on the lock field. (For a policer update operation, 24B needs to be
@@ -70,7 +77,7 @@ typedef struct
u32 single_rate; // 1 = single rate policer, 0 = two rate policer
u32 color_aware; // for hierarchical policing
u32 scale; // power-of-2 shift amount for lower rates
- u8 action[3];
+ qos_action_type_en action[3];
ip_dscp_t mark_dscp[3];
u8 pad[2];
diff --git a/src/vnet/policer/police_inlines.h b/src/vnet/policer/police_inlines.h
index f0b871af856..f9378c7f302 100644
--- a/src/vnet/policer/police_inlines.h
+++ b/src/vnet/policer/police_inlines.h
@@ -62,7 +62,7 @@ vnet_policer_police (vlib_main_t * vm,
u64 time_in_policer_periods,
policer_result_e packet_color)
{
- u8 act;
+ qos_action_type_en act;
u32 len;
u32 col;
policer_read_response_type_st *pol;
diff --git a/src/vnet/policer/policer_api.c b/src/vnet/policer/policer_api.c
index 855ebad69e9..fb66667504c 100644
--- a/src/vnet/policer/policer_api.c
+++ b/src/vnet/policer/policer_api.c
@@ -61,9 +61,9 @@ vl_api_policer_add_del_t_handler (vl_api_policer_add_del_t * mp)
vec_terminate_c_string (name);
clib_memset (&cfg, 0, sizeof (cfg));
- cfg.rfc = mp->type;
- cfg.rnd_type = mp->round_type;
- cfg.rate_type = mp->rate_type;
+ cfg.rfc = (qos_policer_type_en) mp->type;
+ cfg.rnd_type = (qos_round_type_en) mp->round_type;
+ cfg.rate_type = (qos_rate_type_en) mp->rate_type;
cfg.rb.kbps.cir_kbps = ntohl (mp->cir);
cfg.rb.kbps.eir_kbps = ntohl (mp->eir);
cfg.rb.kbps.cb_bytes = clib_net_to_host_u64 (mp->cb);
@@ -110,9 +110,9 @@ send_policer_details (u8 *name, qos_pol_cfg_params_st *config,
mp->eir = htonl (config->rb.kbps.eir_kbps);
mp->cb = clib_host_to_net_u64 (config->rb.kbps.cb_bytes);
mp->eb = clib_host_to_net_u64 (config->rb.kbps.eb_bytes);
- mp->rate_type = config->rate_type;
- mp->round_type = config->rnd_type;
- mp->type = config->rfc;
+ mp->rate_type = (vl_api_sse2_qos_rate_type_t) config->rate_type;
+ mp->round_type = (vl_api_sse2_qos_round_type_t) config->rnd_type;
+ mp->type = (vl_api_sse2_qos_policer_type_t) config->rfc;
mp->conform_action.type =
(vl_api_sse2_qos_action_type_t) config->conform_action.action_type;
mp->conform_action.dscp = config->conform_action.dscp;
diff --git a/src/vnet/policer/xlate.c b/src/vnet/policer/xlate.c
index 2ef99225017..1b6015d51a6 100644
--- a/src/vnet/policer/xlate.c
+++ b/src/vnet/policer/xlate.c
@@ -256,8 +256,7 @@ pol_validate_cfg_params (qos_pol_cfg_params_st *cfg)
*/
numer = (u64) (cfg->rb.kbps.cir_kbps);
denom = (u64) (8 * QOS_POL_TICKS_PER_SEC) / 1000;
- rc = qos_pol_round (numer, denom, &rnd_value,
- (qos_round_type_en) cfg->rnd_type);
+ rc = qos_pol_round (numer, denom, &rnd_value, cfg->rnd_type);
if (rc != 0)
{
QOS_DEBUG_ERROR ("Unable to convert CIR to bytes/tick format");
@@ -267,8 +266,7 @@ pol_validate_cfg_params (qos_pol_cfg_params_st *cfg)
cir_hw = (u32) rnd_value;
numer = (u64) (cfg->rb.kbps.eir_kbps);
- rc = qos_pol_round (numer, denom, &rnd_value,
- (qos_round_type_en) cfg->rnd_type);
+ rc = qos_pol_round (numer, denom, &rnd_value, cfg->rnd_type);
if (rc != 0)
{
QOS_DEBUG_ERROR ("Unable to convert EIR to bytes/tick format");
@@ -390,8 +388,7 @@ pol_convert_cfg_rates_to_hw (qos_pol_cfg_params_st *cfg,
*/
denom = (u64) ((QOS_POL_TICKS_PER_SEC * 8) / 1000);
numer = (u64) (cfg->rb.kbps.cir_kbps);
- rc = qos_pol_round (numer, denom, &rnd_value,
- (qos_round_type_en) cfg->rnd_type);
+ rc = qos_pol_round (numer, denom, &rnd_value, cfg->rnd_type);
if (rc != 0)
{
QOS_DEBUG_ERROR ("Rounding error, rate: %d kbps, rounding_type: %d",
@@ -427,8 +424,7 @@ pol_convert_cfg_rates_to_hw (qos_pol_cfg_params_st *cfg,
}
numer = (u64) eir_kbps;
- rc = qos_pol_round (numer, denom, &rnd_value,
- (qos_round_type_en) cfg->rnd_type);
+ rc = qos_pol_round (numer, denom, &rnd_value, cfg->rnd_type);
if (rc != 0)
{
QOS_DEBUG_ERROR ("Rounding error, rate: %d kbps, rounding_type: %d",
@@ -471,24 +467,22 @@ pol_convert_cfg_rates_to_hw (qos_pol_cfg_params_st *cfg,
}
else
{
- qos_convert_value_to_exp_mant_fmt (
- hi_rate, (u16) QOS_POL_RATE_EXP_MAX, (u16) QOS_POL_AVG_RATE_MANT_MAX,
- (qos_round_type_en) cfg->rnd_type, &exp, &hi_mant);
+ qos_convert_value_to_exp_mant_fmt (hi_rate, (u16) QOS_POL_RATE_EXP_MAX,
+ (u16) QOS_POL_AVG_RATE_MANT_MAX,
+ cfg->rnd_type, &exp, &hi_mant);
}
denom = (1ULL << exp);
if (hi_rate == eir_hw)
{
hw->peak_rate_man = (u16) hi_mant;
- rc = qos_pol_round ((u64) cir_hw, denom, &rnd_value,
- (qos_round_type_en) cfg->rnd_type);
+ rc = qos_pol_round ((u64) cir_hw, denom, &rnd_value, cfg->rnd_type);
hw->avg_rate_man = (u16) rnd_value;
}
else
{
hw->avg_rate_man = (u16) hi_mant;
- rc = qos_pol_round ((u64) eir_hw, denom, &rnd_value,
- (qos_round_type_en) cfg->rnd_type);
+ rc = qos_pol_round ((u64) eir_hw, denom, &rnd_value, cfg->rnd_type);
hw->peak_rate_man = (u16) rnd_value;
}
if (rc != 0)
diff --git a/src/vnet/policer/xlate.h b/src/vnet/policer/xlate.h
index 101c07074f2..46e58bd94d3 100644
--- a/src/vnet/policer/xlate.h
+++ b/src/vnet/policer/xlate.h
@@ -35,7 +35,7 @@ typedef enum qos_policer_type_en_
QOS_POLICER_TYPE_2R3C_RFC_4115 = 3,
QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1 = 4,
QOS_POLICER_TYPE_MAX
-} qos_policer_type_en;
+} __clib_packed qos_policer_type_en;
/*
* edt: * enum
@@ -47,7 +47,7 @@ typedef enum
QOS_ROUND_TO_UP,
QOS_ROUND_TO_DOWN,
QOS_ROUND_INVALID
-} qos_round_type_en;
+} __clib_packed qos_round_type_en;
/*
* edt: * enum
@@ -64,18 +64,7 @@ typedef enum
QOS_RATE_KBPS = 0,
QOS_RATE_PPS,
QOS_RATE_INVALID
-} qos_rate_type_en;
-
-/*
- * edt: * enum
- * Defines type of policer actions.
- */
-typedef enum
-{
- QOS_ACTION_DROP = 0,
- QOS_ACTION_TRANSMIT,
- QOS_ACTION_MARK_AND_TRANSMIT
-} qos_action_type_en;
+} __clib_packed qos_rate_type_en;
/*
* edt * struct qos_pol_action_params_st
@@ -88,7 +77,7 @@ typedef enum
*/
typedef struct qos_pol_action_params_st_
{
- u8 action_type;
+ qos_action_type_en action_type;
ip_dscp_t dscp;
} qos_pol_action_params_st;
@@ -142,9 +131,9 @@ typedef struct qos_pol_cfg_params_st_
u64 eb_ms;
} pps;
} rb; /* rate burst config */
- u8 rate_type; /* qos_rate_type_en */
- u8 rnd_type; /* qos_round_type_en */
- u8 rfc; /* qos_policer_type_en */
+ qos_rate_type_en rate_type;
+ qos_round_type_en rnd_type;
+ qos_policer_type_en rfc;
u8 color_aware;
u8 overwrite_bucket; /* for debugging purposes */
u32 current_bucket; /* for debugging purposes */