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

/** \file

    This file defines vpe control-plane API messages for
    the Linux kernel PIPE device driver
*/

option version = "1.0.1";

import "vnet/interface_types.api";

/** \brief Initialize a new pipe interface with the given parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_specified - if non-0, a specific user_instance is being requested
    @param user_instance - requested instance, ~0 => dynamically allocate
*/
define pipe_create
{
  u32 client_index;
  u32 context;
  bool is_specified;
  u32 user_instance;
};

/** \brief Reply for pipe 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 pipe parent interface
                         Use the parent interface for link up/down and to delete
    @param pipe_sw_if_index - the two SW indicies that form the ends of the pipe.
*/
define pipe_create_reply
{
  u32 context;
  i32 retval;
  vl_api_interface_index_t sw_if_index;
  vl_api_interface_index_t pipe_sw_if_index[2];
};

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

/** \brief Dump pipe interfaces request */
define pipe_dump
{
  u32 client_index;
  u32 context;
};

/** \brief Reply for pipe dump request
    @param sw_if_index - software index of pipe interface
    @param sw_if_index - software index allocated for the pipe parent interface
    @param pipe_sw_if_index - the two SW indicies that form the ends of the pipe.
    @param instance - instance allocated
*/
define pipe_details
{
  u32 context;
  vl_api_interface_index_t sw_if_index;
  vl_api_interface_index_t pipe_sw_if_index[2];
  u32 instance;
};

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