/*
 * 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 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 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 sw_if_index - interface index of existing pipe interface
*/
autoreply define pipe_delete
{
  u32 client_index;
  u32 context;
  u32 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;
  u32 sw_if_index;
  u32 pipe_sw_if_index[2];
  u32 instance;
};

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