aboutsummaryrefslogtreecommitdiffstats
path: root/vpp
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2016-05-18 23:40:37 -0700
committerMatus Fabian <matfabia@cisco.com>2016-05-20 01:15:32 -0700
commite855480acd9bbb75e39047144500df03485fcfa1 (patch)
treec1f3b38b03ac30133b0f7556c38dc5f91fd45c71 /vpp
parent270b6dee8c1f7686ee4c13d55d3aa2cd6c788c3f (diff)
Add policer dump API
JIRA: VPP-67 Change-Id: I8fced60a884f1585b1f51002832d47631eea9571 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'vpp')
-rw-r--r--vpp/api/api.c79
-rw-r--r--vpp/api/vpe.api58
2 files changed, 137 insertions, 0 deletions
diff --git a/vpp/api/api.c b/vpp/api/api.c
index 39ea0aa4..493b249a 100644
--- a/vpp/api/api.c
+++ b/vpp/api/api.c
@@ -339,6 +339,7 @@ _(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del) \
_(AF_PACKET_CREATE, af_packet_create) \
_(AF_PACKET_DELETE, af_packet_delete) \
_(POLICER_ADD_DEL, policer_add_del) \
+_(POLICER_DUMP, policer_dump) \
_(NETMAP_CREATE, netmap_create) \
_(NETMAP_DELETE, netmap_delete)
@@ -5968,6 +5969,84 @@ vl_api_policer_add_del_t_handler
}
static void
+send_policer_details (u8 *name,
+ sse2_qos_pol_cfg_params_st *config,
+ policer_read_response_type_st *templ,
+ unix_shared_memory_queue_t *q,
+ u32 context)
+{
+ vl_api_policer_details_t * mp;
+
+ mp = vl_msg_api_alloc (sizeof (*mp));
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = ntohs (VL_API_POLICER_DETAILS);
+ mp->context = context;
+ mp->cir = htonl(config->rb.kbps.cir_kbps);
+ mp->eir = htonl(config->rb.kbps.eir_kbps);
+ mp->cb = htonl(config->rb.kbps.cb_bytes);
+ mp->eb = htonl(config->rb.kbps.eb_bytes);
+ mp->rate_type = config->rate_type;
+ mp->round_type = config->rnd_type;
+ mp->type = config->rfc;
+ mp->single_rate = templ->single_rate ? 1 : 0;
+ mp->color_aware = templ->color_aware ? 1 : 0;
+ mp->scale = htonl(templ->scale);
+ mp->cir_tokens_per_period = htonl(templ->cir_tokens_per_period);
+ mp->pir_tokens_per_period = htonl(templ->pir_tokens_per_period);
+ mp->current_limit = htonl(templ->current_limit);
+ mp->current_bucket = htonl(templ->current_bucket);
+ mp->extended_limit = htonl(templ->extended_limit);
+ mp->extended_bucket = htonl(templ->extended_bucket);
+ mp->last_update_time = clib_host_to_net_u64(templ->last_update_time);
+
+ strncpy ((char *) mp->name, (char *) name, ARRAY_LEN(mp->name) - 1);
+
+ vl_msg_api_send_shmem (q, (u8 *)&mp);
+}
+
+static void
+vl_api_policer_dump_t_handler
+(vl_api_policer_dump_t *mp)
+{
+ unix_shared_memory_queue_t * q;
+ vnet_policer_main_t * pm = &vnet_policer_main;
+ hash_pair_t * hp;
+ uword * p;
+ u32 pool_index;
+ u8 * match_name = 0;
+ u8 * name;
+ sse2_qos_pol_cfg_params_st *config;
+ policer_read_response_type_st *templ;
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0)
+ return;
+
+ if (mp->match_name_valid) {
+ match_name = format(0, "%s%c", mp->match_name, 0);
+ }
+
+ if (mp->match_name_valid) {
+ p = hash_get_mem (pm->policer_config_by_name, match_name);
+ if (p) {
+ pool_index = p[0];
+ config = pool_elt_at_index (pm->configs, pool_index);
+ templ = pool_elt_at_index (pm->policer_templates, pool_index);
+ send_policer_details(match_name, config, templ, q, mp->context);
+ }
+ } else {
+ hash_foreach_pair (hp, pm->policer_config_by_name,
+ ({
+ name = (u8 *) hp->key;
+ pool_index = hp->value[0];
+ config = pool_elt_at_index (pm->configs, pool_index);
+ templ = pool_elt_at_index (pm->policer_templates, pool_index);
+ send_policer_details(name, config, templ, q, mp->context);
+ }));
+ }
+}
+
+static void
vl_api_netmap_create_t_handler
(vl_api_netmap_create_t *mp)
{
diff --git a/vpp/api/vpe.api b/vpp/api/vpe.api
index e2d23594..5b7af7f0 100644
--- a/vpp/api/vpe.api
+++ b/vpp/api/vpe.api
@@ -3461,6 +3461,64 @@ define policer_add_del_reply {
i32 retval;
};
+/** \brief Get list of policers
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param match_name_valid - if 0 request all policers otherwise use match_name
+ @param match_name - policer name
+*/
+define policer_dump {
+ u32 client_index;
+ u32 context;
+
+ u8 match_name_valid;
+ u8 match_name[64];
+};
+
+/** \brief Policer operational state response.
+ @param context - sender context, to match reply w/ request
+ @param name - policer name
+ @param cir - CIR
+ @param eir - EIR
+ @param cb - Committed Burst
+ @param eb - Excess or Peak Burst
+ @param rate_type - rate type
+ @param round_type - rounding type
+ @param type - policer algorithm
+ @param single_rate - 1 = single rate policer, 0 = two rate policer
+ @param color_aware - for hierarchical policing
+ @param scale - power-of-2 shift amount for lower rates
+ @param cir_tokens_per_period - number of tokens for each period
+ @param pir_tokens_per_period - number of tokens for each period for 2-rate policer
+ @param current_limit - current limit
+ @param current_bucket - current bucket
+ @param extended_limit - extended limit
+ @param extended_bucket - extended bucket
+ @param last_update_time - last update time
+*/
+manual_java define policer_details {
+ u32 context;
+
+ u8 name[64];
+ u32 cir;
+ u32 eir;
+ u64 cb;
+ u64 eb;
+ u8 rate_type;
+ u8 round_type;
+ u8 type;
+ u8 single_rate;
+ u8 color_aware;
+ u32 scale;
+ u32 cir_tokens_per_period;
+ u32 pir_tokens_per_period;
+ u32 current_limit;
+ u32 current_bucket;
+ u32 extended_limit;
+ u32 extended_bucket;
+ u64 last_update_time;
+};
+
/** \brief Create netmap
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request