diff options
author | Matus Fabian <matfabia@cisco.com> | 2016-05-13 05:44:48 -0700 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2016-05-16 13:30:40 +0000 |
commit | 65fcd4d7372718d353143c4deec65fe8b8e36577 (patch) | |
tree | 0358a6ac42188b39c14e567154e29bc967bbc95e /vpp/api | |
parent | 6b70c213ee0b53ab9cbd4a9a3768b2d64f63109d (diff) |
Add configure policer API
JIRA: VPP-67
Change-Id: I04560d78e2eb131cd6cc31472b70b3d3e8fdd79a
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'vpp/api')
-rw-r--r-- | vpp/api/api.c | 34 | ||||
-rw-r--r-- | vpp/api/vpe.api | 37 |
2 files changed, 70 insertions, 1 deletions
diff --git a/vpp/api/api.c b/vpp/api/api.c index 0d5f2241..f81b9c98 100644 --- a/vpp/api/api.c +++ b/vpp/api/api.c @@ -74,6 +74,7 @@ #include <vnet/cop/cop.h> #include <vnet/ip/ip6_hop_by_hop.h> #include <vnet/devices/af_packet/af_packet.h> +#include <vnet/policer/policer.h> #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 df3b2af0..a61c2601 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; +}; |