/*
 * Copyright (c) 2017 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 vpe control-plane API messages for
    the Linux kernel TAP device driver
*/

option version = "3.0.0";

import "vnet/interface_types.api";
import "vnet/ethernet/ethernet_types.api";
import "vnet/ip/ip_types.api";

enum tap_flags {
        TAP_FLAG_GSO = 1,
        TAP_FLAG_CSUM_OFFLOAD = 2,
};

/** \brief Initialize a new tap interface with the given parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param id - interface id, 0xffffffff means auto
    @param use_random_mac - let the system generate a unique mac address
    @param mac_address - mac addr to assign to the interface if use_random not set
    @param num_rx_queues - number of rx queues
    @param tx_ring_sz - the number of entries of TX ring
    @param rx_ring_sz - the number of entries of RX ring
    @param host_mtu_set - host MTU should be set
    @param host_mtu_size - host MTU size
    @param host_mac_addr_set - host side interface mac address should be set
    @param host_mac_addr - host side interface mac address
    @param host_ip4_prefix_set - host IPv4 ip address should be set
    @param host_ip4_prefix - host IPv4 ip address
    @param host_ip6_prefix_set - host IPv6 ip address should be set
    @param host_ip6_prefix - host IPv6 ip address
    @param host_ip4_gw_set - host IPv4 default gateway should be set
    @param host_ip4_gw - host IPv4 default gateway
    @param host_ip6_gw_set - host IPv6 default gateway should be set
    @param host_ip6_gw - host IPv6 default gateway
    @param tap_flags - flags for the TAP interface creation
    @param host_if_name_set - host side interface name should be set
    @param host_if_name - host side interface name
    @param host_namespace_set - host namespece should be set
    @param host_namespace - host namespace to attach interface to
    @param host_bridge_set - host bridge should be set
    @param host_bridge - host bridge to attach interface to
    @param tag - tag
*/
define tap_create_v2
{
  u32 client_index;
  u32 context;
  u32 id [default=0xffffffff];
  bool use_random_mac [default=true];
  vl_api_mac_address_t mac_address;
  u8 num_rx_queues [default=1];
  u16 tx_ring_sz; /* optional, default is 256 entries, must be power of 2 */
  u16 rx_ring_sz; /* optional, default is 256 entries, must be power of 2 */
  bool host_mtu_set;
  u32 host_mtu_size;
  bool host_mac_addr_set;
  vl_api_mac_address_t host_mac_addr;
  bool host_ip4_prefix_set;
  vl_api_ip4_address_with_prefix_t host_ip4_prefix;
  bool host_ip6_prefix_set;
  vl_api_ip6_address_with_prefix_t host_ip6_prefix;
  bool host_ip4_gw_set;
  vl_api_ip4_address_t host_ip4_gw;
  bool host_ip6_gw_set;
  vl_api_ip6_address_t host_ip6_gw;
  vl_api_tap_flags_t tap_flags;
  bool host_namespace_set;
  string host_namespace[64];
  bool host_if_name_set;
  string host_if_name[64];
  bool host_bridge_set;
  string host_bridge[64];
  string tag[];
};

/** \brief Reply for tap create reply
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
    @param sw_if_index - software index allocated for the new tap interface
*/
define tap_create_v2_reply
{
  u32 context;
  i32 retval;
  vl_api_interface_index_t sw_if_index;
};

/** \brief Delete tap interface
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - interface index of existing tap interface
*/
autoreply define tap_delete_v2
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
};

/** \brief Dump tap interfaces request
    @param sw_if_index - filter by sw_if_index UNIMPLEMENTED
*/
define sw_interface_tap_v2_dump
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index [default=0xffffffff];
};

/** \brief Reply for tap dump request
    @param sw_if_index - software index of tap interface
    @param id - interface id
    @param tx_ring_sz - the number of entries of TX ring
    @param rx_ring_sz - the number of entries of RX ring
    @param host_mtu_size - host mtu size
    @param host_mac_addr - mac address assigned to the host side of the interface
    @param host_ip4_prefix - host IPv4 ip address
    @param host_ip6_prefix - host IPv6 ip address
    @param tap_flags - flags for the TAP interface creation
    @param dev_name - Linux tap device name
    @param host_if_name - host side interface name
    @param host_namespace - host namespace the interface is attached into
    @param host_bridge - host bridge the interface is attached into
*/
define sw_interface_tap_v2_details
{
  u32 context;
  u32 sw_if_index;
  u32 id;
  u16 tx_ring_sz;
  u16 rx_ring_sz;
  u32 host_mtu_size;
  vl_api_mac_address_t host_mac_addr;
  vl_api_ip4_address_with_prefix_t host_ip4_prefix;
  vl_api_ip6_address_with_prefix_t host_ip6_prefix;
  vl_api_tap_flags_t tap_flags;
  string dev_name[64];
  string host_if_name[64];
  string host_namespace[64];
  string host_bridge[64];
};

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