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

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

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

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

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;
    u8 data[0];
};

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

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

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

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

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

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

/*
 * Delete a client registration 
 */
define sockclnt_delete {
    u32 index;                  /* index, used e.g. by API trace replay */
    u64 handle;               	/* handle by which vlib knows this client */
};

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

/*
 * Ask vpp for a memfd shared segment
 */
define memfd_segment_create {
    u32 client_index;
    u32 context;
    u64 requested_size;
};

/*
 * Reply
 */
define memfd_segment_create_reply 
{
  u32 context;
  i32 retval;
  u32 master_fd;
};

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