/*
 * 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.0";

/** \brief Initialize a new pipe interface with the given paramters
    @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;
  u8 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 parent_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;
  u32 parent_sw_if_index;
  u32 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 parnet_sw_if_index - interface index of existing pipe interface
*/
autoreply define pipe_delete
{
  u32 client_index;
  u32 context;
  u32 parent_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 parent_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;
  u32 parent_sw_if_index;
  u32 pipe_sw_if_index[2];
  u32 instance;
};

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