/*
 * 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 = "3.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;
};

autoreply define policer_bind_v2
{
  u32 client_index;
  u32 context;

  u32 policer_index;
  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;
};

autoreply define policer_input_v2
{
  u32 client_index;
  u32 context;

  u32 policer_index;
  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;
};

autoreply define policer_output_v2
{
  u32 client_index;
  u32 context;

  u32 policer_index;
  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;
};

define policer_add
{
  u32 client_index;
  u32 context;

  string name[64];
  vl_api_policer_config_t infos;
};

autoreply define policer_del
{
  u32 client_index;
  u32 context;

  u32 policer_index;
};

autoreply define policer_update
{
  u32 client_index;
  u32 context;

  u32 policer_index;
  vl_api_policer_config_t infos;
};

autoreply define policer_reset
{
  u32 client_index;
  u32 context;

  u32 policer_index;
};

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

define policer_add_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 Get list of policers
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param policer_index - index of policer in the pool, ~0 to request all
*/
define policer_dump_v2
{
  u32 client_index;
  u32 context;

  u32 policer_index;
};

service {
  rpc policer_dump_v2 returns stream policer_details;
};

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