/* Hey Emacs use -*- mode: C -*- */
/*
 * Copyright (c) 2018 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.
 */

/**
 * @file
 * This file defines QoS record, store and mark API messages which are generally
 *    called through a shared memory interface.
 *
 * Definitions of verbs:
 *  store: write a QoS value into the buffer meta-data
 *  record: Extract a QoS value from a packet header and store it.
 *  mark: Make a change to the content of a packet header by writing a stored
 *        QoS value
 */
option version = "1.1.0";

import "vnet/ip/ip_types.api";

enum qos_source : u8
{
  QOS_API_SOURCE_EXT = 0,
  QOS_API_SOURCE_VLAN = 1,
  QOS_API_SOURCE_MPLS = 2,
  QOS_API_SOURCE_IP = 3,
};

/**
 * QoS store.
 * @param sw_if_index - The interface on which store is enabled.
 * @param input_source - The input source/layer at which the QoS bits are stored
 *                       See qos_source_t. This determines what packets have a
 *                       value stored. i.e. If IP is seleted this affects on IP
 *                       packets.
 * @param value - The value to store.
 */
typedef qos_store
{
  u32 sw_if_index;
  vl_api_qos_source_t input_source;
  u8 value;
};

/**
 * Enable/Disable QoS storing
 * The QoS bits from the packet at the specified input layer are copied
 * into the packet. Storeing should be used in conjunction with marking
 * @param enable - enable=1 or disable the feature
 * @param store - Store configuration
 */
autoreply define qos_store_enable_disable
{
  u32 client_index;
  u32 context;
  u8 enable;
  vl_api_qos_store_t store;
};

/**
 * Dump the QoS store configs
 */
define qos_store_dump
{
  u32 client_index;
  u32 context;
};

/**
 * Details of QoS recording configs
 */
define qos_store_details
{
  u32 context;
  vl_api_qos_store_t store;
};

/**
 * QoS recording.
 * @param sw_if_index - The interface on which recording is enabled.
 * @param input_source - The input source/layer at which the QoS bits
                         are copied from the packet. See qos_source_t.
 */
typedef qos_record
{
  u32 sw_if_index;
  vl_api_qos_source_t input_source;
};

/**
 * Enable/Disable QoS recording
 * The QoS bits from the packet at the specified input layer are copied
 * into the packet. Recording should be used in conjunction with marking
 * @param enable - enable=1 or disable the feature
 * @param record - Recording configuration
 */
autoreply define qos_record_enable_disable
{
  u32 client_index;
  u32 context;
  u8 enable;
  vl_api_qos_record_t record;
};

/**
 * Dump the QoS record configs
 */
define qos_record_dump
{
  u32 client_index;
  u32 context;
};

/**
 * Details of QoS recording configs
 */
define qos_record_details
{
  u32 context;
  vl_api_qos_record_t record;
};

/**
 * @brief A row within a QoS map
 *  Each value translates from an input value to an output.
 */
typedef qos_egress_map_row
{
  u8 outputs[256];
};

/**
 * QoS Translation Map
 *
 * @param id - client provided identifier for the map
 * @param rows - one row (per-input source) of output values
 */
typedef qos_egress_map
{
  u32 id;
  vl_api_qos_egress_map_row_t rows[4];
};

/**
 *  @brief Update a QoS Map
 *   A QoS map, translates from the QoS value in the packet set by the 'record'
 *   feature, to the value used for output in the 'mark' feature.
 *   There is one row in the map for each input/record source.
 *   The MAP is then applied to the egress interface at for a given output source
 * @param map - The Map
 */
autoreply define qos_egress_map_update
{
  u32 client_index;
  u32 context;
  vl_api_qos_egress_map_t map;
};

/**
 * @brief Delete a Qos Map
 * @param map_id - ID of the map to delete
 */
autoreply define qos_egress_map_delete
{
  u32 client_index;
  u32 context;
  u32 id;
};

/**
 * Dump the QoS egress maps
 */
define qos_egress_map_dump
{
  u32 client_index;
  u32 context;
};

/**
 * QoS map details
 */
define qos_egress_map_details
{
  u32 context;
  vl_api_qos_egress_map_t map;
};

/**
 * QoS marking Cponfiguration
 * The QoS bits from the buffer are mapped (using the desired egress map)
 * into the header of the 'output-source'. Marking should be used in
 * conjunction with recording
 * @param sw_if_index - The interface on which recording is enabled.
 * @param output_source - The output source/layer at which the QoS bits
 *                        are written into the packet. See qos_source_t.
 * @param map_id - The ID of the MAP in which the translation from input
 *                 to output is performed.
 */
typedef qos_mark
{
  u32 sw_if_index;
  u32 map_id;
  vl_api_qos_source_t output_source;
};

/**
 * @brief Enable/Disable QoS marking
 * @param enable - enable=1 or disable the feature
 * @param mark - Marking config
 */
autoreply define qos_mark_enable_disable
{
  u32 client_index;
  u32 context;
  u8 enable;
  vl_api_qos_mark_t mark;
};

/**
 * Dump QoS marking configs
 */
define qos_mark_dump
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
};

/**
 * QoS marking details
 */
autoreply define qos_mark_details
{
  u32 context;
  vl_api_qos_mark_t mark;
};

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