From 65fcd4d7372718d353143c4deec65fe8b8e36577 Mon Sep 17 00:00:00 2001 From: Matus Fabian Date: Fri, 13 May 2016 05:44:48 -0700 Subject: Add configure policer API JIRA: VPP-67 Change-Id: I04560d78e2eb131cd6cc31472b70b3d3e8fdd79a Signed-off-by: Matus Fabian --- vpp/api/api.c | 34 +++++++++++++++++++++++++++++++++- vpp/api/vpe.api | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) (limited to 'vpp') diff --git a/vpp/api/api.c b/vpp/api/api.c index 0d5f224118e..f81b9c98af3 100644 --- a/vpp/api/api.c +++ b/vpp/api/api.c @@ -74,6 +74,7 @@ #include #include #include +#include #undef BIHASH_TYPE #undef __included_bihash_template_h__ @@ -335,7 +336,8 @@ _(LISP_ENABLE_DISABLE_STATUS_DUMP, \ lisp_enable_disable_status_dump) \ _(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del) \ _(AF_PACKET_CREATE, af_packet_create) \ -_(AF_PACKET_DELETE, af_packet_delete) +_(AF_PACKET_DELETE, af_packet_delete) \ +_(POLICER_ADD_DEL, policer_add_del) #define QUOTE_(x) #x #define QUOTE(x) QUOTE_(x) @@ -5932,6 +5934,36 @@ vl_api_af_packet_delete_t_handler REPLY_MACRO(VL_API_AF_PACKET_DELETE_REPLY); } +static void +vl_api_policer_add_del_t_handler +(vl_api_policer_add_del_t *mp) +{ + vlib_main_t * vm = vlib_get_main(); + vl_api_policer_add_del_reply_t *rmp; + int rv = 0; + u8 *name = NULL; + sse2_qos_pol_cfg_params_st cfg; + clib_error_t * error; + + name = format(0, "%s", mp->name); + + memset (&cfg, 0, sizeof (cfg)); + cfg.rfc = mp->type; + cfg.rnd_type = mp->round_type; + cfg.rate_type = mp->rate_type; + cfg.rb.kbps.cir_kbps = mp->cir; + cfg.rb.kbps.eir_kbps = mp->eir; + cfg.rb.kbps.cb_bytes = mp->cb; + cfg.rb.kbps.eb_bytes = mp->eb; + + error = policer_add_del(vm, name, &cfg, mp->is_add); + + if (error) + rv = VNET_API_ERROR_UNSPECIFIED; + + REPLY_MACRO(VL_API_POLICER_ADD_DEL_REPLY); +} + #define BOUNCE_HANDLER(nn) \ static void vl_api_##nn##_t_handler ( \ vl_api_##nn##_t *mp) \ diff --git a/vpp/api/vpe.api b/vpp/api/vpe.api index df3b2af0e3c..a61c26011f6 100644 --- a/vpp/api/vpe.api +++ b/vpp/api/vpe.api @@ -3475,3 +3475,40 @@ define af_packet_delete_reply { u32 context; i32 retval; }; + +/** \brief Add/del policer + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param is_add - add policer if non-zero, else delete + @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 +*/ +define policer_add_del { + u32 client_index; + u32 context; + + u8 is_add; + u8 name[64]; + u32 cir; + u32 eir; + u64 cb; + u64 eb; + u8 rate_type; + u8 round_type; + u8 type; +}; + +/** \brief Add/del policer response + @param context - sender context, to match reply w/ request + @param retval - return value for request +*/ +define policer_add_del_reply { + u32 context; + i32 retval; +}; -- cgit 1.2.3-korg