/*
 * 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 = "4.0.0";

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

enum tap_flags {
        TAP_API_FLAG_GSO = 1, /* enable gso on the interface */
        TAP_API_FLAG_CSUM_OFFLOAD = 2, /* enable checksum offload without gso on the interface */
        TAP_API_FLAG_PERSIST = 4, /* make the interface persistence to exist in linux even vpp crash/restart */
        TAP_API_FLAG_ATTACH = 8,  /* attach to the existing persistence interface after vpp crash/restart */
        TAP_API_FLAG_TUN = 16,  /* create TUN interface instead of tap */
        TAP_API_FLAG_GRO_COALESCE = 32, /* enable packet coalescing on tx side, provided gso enabled */
        TAP_API_FLAG_PACKED = 64 [backwards_compatible], /* enable packed ring support */
        TAP_API_FLAG_IN_ORDER = 128 [backwards_compatible], /* enable in-order desc support */
};

/** \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, optional, default is 256 entries, must be power of 2
    @param rx_ring_sz - the number of entries of RX ring, optional, default is 256 entries, must be power of 2
    @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 namespace 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 [default=256];
  u16 rx_ring_sz [default=256];
  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
*/
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:
 */
