b800bfa651717b2b1dcc90aee3f4b2d5a8ce68ae
[vpp.git] / src / plugins / memif / memif.api
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2017 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 option version = "3.1.0";
18
19 import "vnet/interface_types.api";
20 import "vnet/ethernet/ethernet_types.api";
21
22 enum memif_role
23 {
24   MEMIF_ROLE_API_MASTER = 0,
25   MEMIF_ROLE_API_SLAVE = 1,
26 };
27
28 enum memif_mode
29 {
30   MEMIF_MODE_API_ETHERNET = 0,
31   MEMIF_MODE_API_IP = 1,
32   MEMIF_MODE_API_PUNT_INJECT = 2,
33 };
34
35 /** \brief Create or remove named socket file for memif interfaces
36     @param client_index - opaque cookie to identify the sender
37     @param context - sender context, to match reply w/ request
38     @param is_add - 0 = remove, 1 = add association
39     @param socket_id - non-0 32-bit integer used to identify a socket file
40     @param socket_filename - filename of the socket to be used for connection
41            establishment; id 0 always maps to default "/var/vpp/memif.sock";
42            no socket filename needed when is_add == 0.
43 */
44 autoreply define memif_socket_filename_add_del
45 {
46   u32 client_index;
47   u32 context;
48   bool is_add;          /* 0 = remove, 1 = add association */
49   u32 socket_id;        /* unique non-0 id for given socket file name */
50   string socket_filename[108];  /* NUL terminated filename */
51   option vat_help = "[add|del] id <id> filename <file>";
52 };
53
54 /** \brief Create or remove named socket file for memif interfaces
55     @param client_index - opaque cookie to identify the sender
56     @param context - sender context, to match reply w/ request
57     @param is_add - 0 = remove, 1 = add association
58     @param socket_id - non-0 32-bit integer used to identify a socket file
59           ~0 means autogenerate
60     @param socket_filename - filename of the socket to be used for connection
61            establishment; id 0 always maps to default "/var/vpp/memif.sock";
62            no socket filename needed when is_add == 0.
63            socket_filename starting with '@' will create an abstract socket
64            in the given namespace
65 */
66 define memif_socket_filename_add_del_v2
67 {
68   u32 client_index;
69   u32 context;
70   bool is_add;                          /* 0 = remove, 1 = add association */
71   u32 socket_id [default=0xffffffff];   /* unique non-0 id for given socket file name */
72   string socket_filename[];             /* NUL terminated filename */
73   option vat_help = "[add|del] id <id> filename <file>";
74 };
75
76 /** \brief Create memory interface socket file response
77     @param context - sender context, to match reply w/ request
78     @param retval - return value for request
79     @param socket_id - non-0 32-bit integer used to identify a socket file
80 */
81 define memif_socket_filename_add_del_v2_reply
82 {
83   u32 context;
84   i32 retval;
85   u32 socket_id;
86 };
87
88 /** \brief Create memory interface
89     @param client_index - opaque cookie to identify the sender
90     @param context - sender context, to match reply w/ request
91     @param role - role of the interface in the connection (master/slave)
92     @param mode - interface mode
93     @param rx_queues - number of rx queues (only valid for slave)
94     @param tx_queues - number of tx queues (only valid for slave)
95     @param id - 32bit integer used to authenticate and match opposite sides
96            of the connection
97     @param socket_id - socket filename id to be used for connection
98            establishment
99     @param ring_size - the number of entries of RX/TX rings
100     @param buffer_size - size of the buffer allocated for each ring entry
101     @param no_zero_copy - if true, disable zero copy
102     @param hw_addr - interface MAC address
103     @param secret - optional, default is "", max length 24
104 */
105 define memif_create
106 {
107   u32 client_index;
108   u32 context;
109
110   vl_api_memif_role_t role; /* 0 = master, 1 = slave */
111   vl_api_memif_mode_t mode; /* 0 = ethernet, 1 = ip, 2 = punt/inject */
112   u8 rx_queues; /* optional, default is 1 */
113   u8 tx_queues; /* optional, default is 1 */
114   u32 id; /* optional, default is 0 */
115   u32 socket_id; /* optional, default is 0, "/var/vpp/memif.sock" */
116   u32 ring_size; /* optional, default is 1024 entries, must be power of 2 */
117   u16 buffer_size; /* optional, default is 2048 bytes */
118   bool no_zero_copy; /* disable zero copy */
119   vl_api_mac_address_t hw_addr; /* optional, randomly generated if zero */
120   string secret[24]; /* optional, default is "", max length 24 */
121   option vat_help = "[id <id>] [socket-id <id>] [ring_size <size>] [buffer_size <size>] [hw_addr <mac_address>] [secret <string>] [mode ip] <master|slave>";
122 };
123
124 /** \brief Create memory interface response
125     @param context - sender context, to match reply w/ request
126     @param retval - return value for request
127     @param sw_if_index - software index of the newly created interface
128 */
129 define memif_create_reply
130 {
131   u32 context;
132   i32 retval;
133   vl_api_interface_index_t sw_if_index;
134 };
135
136 /** \brief Create memory interface
137     @param client_index - opaque cookie to identify the sender
138     @param context - sender context, to match reply w/ request
139     @param role - role of the interface in the connection (master/slave)
140     @param mode - interface mode
141     @param rx_queues - number of rx queues (only valid for slave)
142     @param tx_queues - number of tx queues (only valid for slave)
143     @param id - 32bit integer used to authenticate and match opposite sides
144            of the connection
145     @param socket_id - socket filename id to be used for connection
146            establishment
147     @param ring_size - the number of entries of RX/TX rings
148     @param buffer_size - size of the buffer allocated for each ring entry
149     @param no_zero_copy - if true, disable zero copy
150     @param use_dma - if true, use dma accelerate memory copy
151     @param hw_addr - interface MAC address
152     @param secret - optional, default is "", max length 24
153 */
154 define memif_create_v2
155 {
156   u32 client_index;
157   u32 context;
158
159   vl_api_memif_role_t role; /* 0 = master, 1 = slave */
160   vl_api_memif_mode_t mode; /* 0 = ethernet, 1 = ip, 2 = punt/inject */
161   u8 rx_queues; /* optional, default is 1 */
162   u8 tx_queues; /* optional, default is 1 */
163   u32 id; /* optional, default is 0 */
164   u32 socket_id; /* optional, default is 0, "/var/vpp/memif.sock" */
165   u32 ring_size; /* optional, default is 1024 entries, must be power of 2 */
166   u16 buffer_size; /* optional, default is 2048 bytes */
167   bool no_zero_copy; /* disable zero copy */
168   bool use_dma; /* use dma acceleration */
169   vl_api_mac_address_t hw_addr; /* optional, randomly generated if zero */
170   string secret[24]; /* optional, default is "", max length 24 */
171   option vat_help = "[id <id>] [socket-id <id>] [ring_size <size>] [buffer_size <size>] [hw_addr <mac_address>] [secret <string>] [mode ip] <master|slave>";
172 };
173
174 /** \brief Create memory interface response
175     @param context - sender context, to match reply w/ request
176     @param retval - return value for request
177     @param sw_if_index - software index of the newly created interface
178 */
179 define memif_create_v2_reply
180 {
181   u32 context;
182   i32 retval;
183   vl_api_interface_index_t sw_if_index;
184 };
185
186 /** \brief Delete memory interface
187     @param client_index - opaque cookie to identify the sender
188     @param context - sender context, to match reply w/ request
189     @param sw_if_index - software index of the interface to delete
190 */
191 autoreply define memif_delete
192 {
193   u32 client_index;
194   u32 context;
195
196   vl_api_interface_index_t sw_if_index;
197   option vat_help = "<sw_if_index>";
198 };
199
200 /** \brief Memory interface details structure
201     @param context - sender context, to match reply w/ request
202     @param socket_id - u32 used to identify the given socket filename
203     @param socket_filename - corresponding NUL terminated socket filename
204 */
205 define memif_socket_filename_details
206 {
207   u32 context;
208   u32 socket_id;
209   string socket_filename[108];
210 };
211
212 /** \brief Dump the table of socket ids and corresponding filenames
213     @param client_index - opaque cookie to identify the sender
214     @param context - sender context, to match reply w/ request
215 */
216 define memif_socket_filename_dump
217 {
218   u32 client_index;
219   u32 context;
220 };
221
222 /** \brief Memory interface details structure
223     @param context - sender context, to match reply w/ request (memif_dump)
224     @param sw_if_index - index of the interface
225     @param hw_addr - interface MAC address
226     @param id - id associated with the interface
227     @param role - role of the interface in the connection (master/slave)
228     @param mode - interface mode
229     @param zero_copy - zero copy flag present
230     @param socket_id - id of the socket filename used by this interface
231            to establish new connections
232     @param ring_size - the number of entries of RX/TX rings
233     @param buffer_size - size of the buffer allocated for each ring entry
234     @param flags - interface_status flags
235     @param if_name - name of the interface
236
237 */
238 define memif_details
239 {
240   u32 context;
241
242   vl_api_interface_index_t sw_if_index;
243   vl_api_mac_address_t hw_addr;
244
245   /* memif specific parameters */
246   u32 id;
247   vl_api_memif_role_t role; /* 0 = master, 1 = slave */
248   vl_api_memif_mode_t mode; /* 0 = ethernet, 1 = ip, 2 = punt/inject */
249   bool zero_copy;
250   u32 socket_id;
251   u32 ring_size;
252   u16 buffer_size; /* optional, default is 2048 bytes */
253
254   vl_api_if_status_flags_t flags;
255
256   string if_name[64];
257 };
258
259 /** \brief Dump all memory interfaces
260     @param client_index - opaque cookie to identify the sender
261     @param context - sender context, to match reply w/ request
262 */
263 define memif_dump
264 {
265   u32 client_index;
266   u32 context;
267 };
268
269 /*
270  * Local Variables:
271  * eval: (c-set-style "gnu")
272  * End:
273  */