/*
 * Copyright (c) 2015-2020 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

option version = "2.0.0";

import "vnet/interface_types.api";
import "vnet/policer/policer_types.api";

/** \brief policer bind: Associate/disassociate a policer with a worker thread.
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param name - policer name to bind
    @param worker_index - the worker thread to bind to
    @param bind_enable - Associate/disassociate
*/
autoreply define policer_bind
{
  u32 client_index;
  u32 context;

  string name[64];
  u32 worker_index;
  bool bind_enable;
};

/** \brief policer input: Apply policer as an input feature.
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param name - policer name
    @param sw_if_index - interface to apply the policer
    @param apply - Apply/remove
*/
autoreply define policer_input
{
  u32 client_index;
  u32 context;

  string name[64];
  vl_api_interface_index_t sw_if_index;
  bool apply;
};

/** \brief policer output: Apply policer as an output feature.
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param name - policer name
    @param sw_if_index - interface to apply the policer
    @param apply - Apply/remove
*/
autoreply define policer_output
{
  u32 client_index;
  u32 context;

  string name[64];
  vl_api_interface_index_t sw_if_index;
  bool apply;
};

/** \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
    @param color_aware - 0=color-blind, 1=color-aware
    @param conform_action - conform action
    @param exceed_action - exceed action type
    @param violate_action - violate action type
*/
define policer_add_del
{
  u32 client_index;
  u32 context;

  bool is_add;
  string name[64];
  u32 cir;
  u32 eir;
  u64 cb;
  u64 eb;
  vl_api_sse2_qos_rate_type_t rate_type;
  vl_api_sse2_qos_round_type_t round_type;
  vl_api_sse2_qos_policer_type_t type;
  bool color_aware;
  vl_api_sse2_qos_action_t conform_action;
  vl_api_sse2_qos_action_t exceed_action;
  vl_api_sse2_qos_action_t violate_action;
};

/** \brief Add/del policer response
    @param context - sender context, to match reply w/ request
    @param retval - return value for request
    @param policer_index - for add, returned index of the new policer
*/
define policer_add_del_reply
{
  u32 context;
  i32 retval;
  u32 policer_index;
};

/** \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;

  bool match_name_valid;
  string 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 conform_action - conform action
    @param exceed_action - exceed action
    @param violate_action - violate action
    @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
*/
define policer_details
{
  u32 context;

  string name[64];
  u32 cir;
  u32 eir;
  u64 cb;
  u64 eb;
  vl_api_sse2_qos_rate_type_t rate_type;
  vl_api_sse2_qos_round_type_t round_type;
  vl_api_sse2_qos_policer_type_t type;
  vl_api_sse2_qos_action_t conform_action;
  vl_api_sse2_qos_action_t exceed_action;
  vl_api_sse2_qos_action_t violate_action;
  bool single_rate;
  bool 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;
};

/*
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
