/* Hey Emacs use -*- mode: C -*- */
/*
 * Copyright (c) 2015 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 = "2.1.0";

/*
 * Define services not following the normal conventions here
 */
service {
  rpc memclnt_rx_thread_suspend returns null;
  rpc memclnt_read_timeout returns null;
  rpc rx_thread_exit returns null;
  rpc trace_plugin_msg_ids returns null;
};

/*
 * Create a client registration 
 */
define memclnt_create {
    u32 context;                /* opaque value to be returned in the reply */
    i32 ctx_quota;              /* requested punt context quota */
    u64 input_queue;            /* client's queue */
    string name[64];            /* for show, find by name, whatever */
    u32 api_versions[8];        /* client-server pairs use as desired */
};

define memclnt_create_reply {
    u32 context;                /* opaque value from the create request */
    i32 response;               /* Non-negative = success */
    u64 handle;                 /* handle by which vlib knows this client */
    u32 index;                  /* index, used e.g. by API trace replay */
    u64 message_table;          /* serialized message table in shmem */
};

/*
 * Delete a client registration 
 */
define memclnt_delete {
    u32 index;                  /* index, used e.g. by API trace replay */
    u64 handle;               /* handle by which vlib knows this client */
    bool do_cleanup;		/* vlib to cleanup the registration */
};

define memclnt_delete_reply {
    i32 response;               /* Non-negative = success */
    u64 handle;               /* in case the client wonders */
};

/*
 * Client RX thread exit
 */
define rx_thread_exit {
    u8 dummy;
};

/*
 * Client RX thread suspend
 */
define memclnt_rx_thread_suspend {
    u8 dummy;
};

/*
 * Client read timeout
 */
define memclnt_read_timeout {
    u8 dummy;
};

/*
 * RPC
 */
autoreply define rpc_call {
    u32 client_index;
    u32 context;
    u64 function;
    u8 multicast;
    u8 need_barrier_sync;
    u8 send_reply;
    u32 data_len;
    u8 data[data_len];
};

/*
 * Lookup message-ID base by name
 */
define get_first_msg_id {
    u32 client_index;
    u32 context;
    string name[64];
};

define get_first_msg_id_reply {
    u32 context;
    i32 retval;
    u16 first_msg_id;
};

/*
 * Get API version table (includes built-in and plugins)
 */
typedef module_version {
  u32 major;
  u32 minor;
  u32 patch;
  string name[64];
};
define api_versions {
  u32 client_index;
  u32 context;
};
define api_versions_reply {
  u32 context;
  i32 retval;
  u32 count;
  vl_api_module_version_t api_versions[count];
};

/*
 * Trace the plugin message-id allocator
 * so we stand a chance of dealing with different sets of plugins
 * at api trace replay time
 */

define trace_plugin_msg_ids
{
    u32 client_index;
    u32 context;
    string plugin_name[128];
    u16 first_msg_id;
    u16 last_msg_id;
};

typedef message_table_entry
{
  u16 index;
  string name[64];
};

/*
 * Create a socket client registration. 
 */
define sockclnt_create {
    u32 context;                /* opaque value to be returned in the reply */
    string name[64];                /* for show, find by name, whatever */
};

define sockclnt_create_reply {
    u32 client_index;
    u32 context;                /* opaque value from the create request */
    i32 response;               /* Non-negative = success */
    u32 index;                  /* index, used e.g. by API trace replay */
    u16 count;
    vl_api_message_table_entry_t message_table[count];
};

/*
 * Delete a client registration 
 */
define sockclnt_delete {
    u32 client_index;
    u32 context;
    u32 index;                  /* index, used e.g. by API trace replay */
};

define sockclnt_delete_reply {
    u32 context;
    i32 response;               /* Non-negative = success */
};

/*
 * Initialize shm api over socket api
 */
autoreply define sock_init_shm {
    u32 client_index;
    u32 context;
    u32 requested_size;
    u8 nitems;
    u64 configs[nitems];
};

/* define sock_init_shm_reply {
    u32 client_index;
    u32 context;
    i32 retval;
}; */

/*
 * Memory client ping / response
 * Only sent on inactive connections
 */
autoreply define memclnt_keepalive
{
  u32 client_index;
  u32 context;
};

/** \brief Control ping from client to api server request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
*/
define control_ping
{
  u32 client_index;
  u32 context;
};

/** \brief Control ping from the client to the server response
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param retval - return code for the request
    @param vpe_pid - the pid of the vpe, returned by the server
*/
define control_ping_reply
{
  u32 context;
  i32 retval;
  u32 client_index;
  u32 vpe_pid;
};

