/*
 * 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.
 */

option version = "3.0.0";

import "vnet/interface_types.api";
import "vnet/ethernet/ethernet_types.api";
import "vlib/pci/pci_types.api";


/** \brief Initialize a new virtio pci interface with the given parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param pci_addr - pci address
    @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 gso_enabled - enable gso feature if available, 1 to enable
    @param checksum_offload_enabled - enable checksum feature if available, 1 to enable
    @param features - the virtio features which driver should negotiate with device
*/
define virtio_pci_create
{
  option deprecated;
  u32 client_index;
  u32 context;
  vl_api_pci_address_t pci_addr;
  bool use_random_mac;
  vl_api_mac_address_t mac_address;
  bool gso_enabled;
  bool checksum_offload_enabled;
  u64 features;
};

/** \brief Reply for virtio pci 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 virtio pci interface
*/
define virtio_pci_create_reply
{
  option deprecated;
  u32 context;
  i32 retval;
  vl_api_interface_index_t sw_if_index;
};

enum virtio_flags {
        VIRTIO_API_FLAG_GSO = 1, /* enable gso on the interface */
        VIRTIO_API_FLAG_CSUM_OFFLOAD = 2, /* enable checksum offload without gso on the interface */
        VIRTIO_API_FLAG_GRO_COALESCE = 4, /* enable packet coalescing on tx side, provided gso enabled */
        VIRTIO_API_FLAG_PACKED = 8, /* enable packed ring support, provided it is available from backend */
        VIRTIO_API_FLAG_IN_ORDER = 16, /* enable in order support, provided it is available from backend */
        VIRTIO_API_FLAG_BUFFERING = 32 [backwards_compatible], /* enable buffering to handle backend jitter/delays */
};

/** \brief Initialize a new virtio pci interface with the given parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param pci_addr - pci address
    @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 virtio_flags - feature flags to enable
    @param features - the virtio features which driver should negotiate with device
*/
define virtio_pci_create_v2
{
  u32 client_index;
  u32 context;
  vl_api_pci_address_t pci_addr;
  bool use_random_mac;
  vl_api_mac_address_t mac_address;
  vl_api_virtio_flags_t virtio_flags;
  u64 features;
};

/** \brief Reply for virtio pci 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 virtio pci interface
*/
define virtio_pci_create_v2_reply
{
  u32 context;
  i32 retval;
  vl_api_interface_index_t sw_if_index;
};

/** \brief Delete virtio pci 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 virtio pci interface
*/
autoreply define virtio_pci_delete
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
};

/** \brief Dump virtio pci interfaces request */
define sw_interface_virtio_pci_dump
{
  u32 client_index;
  u32 context;
};

/** \brief Reply for virtio pci interface dump request
    @param sw_if_index - software index of virtio pci interface
    @param pci_addr - pci address
    @param mac_addr - native virtio device mac address
    @param tx_ring_sz - the number of entries of TX ring
    @param rx_ring_sz - the number of entries of RX ring
    @param features - the virtio features which driver have negotiated with device
*/
define sw_interface_virtio_pci_details
{
  u32 context;
  vl_api_interface_index_t sw_if_index;
  vl_api_pci_address_t pci_addr;
  vl_api_mac_address_t mac_addr;
  u16 tx_ring_sz;
  u16 rx_ring_sz;
  u64 features;
};

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