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

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