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

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