API: Add support for type aliases
[vpp.git] / src / vnet / interface.api
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2018 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 = "2.2.0";
18
19 import "vnet/interface_types.api";
20
21 service {
22   rpc want_interface_events returns want_interface_events_reply
23     events sw_interface_event;
24 };
25
26 /** \brief Set flags on the interface
27     @param client_index - opaque cookie to identify the sender
28     @param context - sender context, to match reply w/ request
29     @param sw_if_index - index of the interface to set flags on
30     @param admin_up_down - set the admin state, 1 = up, 0 = down
31     @param link_up_down - Oper state sent on change event, not used in config.
32 */
33 autoreply define sw_interface_set_flags
34 {
35   u32 client_index;
36   u32 context;
37   u32 sw_if_index;
38   /* 1 = up, 0 = down */
39   u8 admin_up_down;
40 };
41
42 /** \brief Set interface physical MTU
43     @param client_index - opaque cookie to identify the sender
44     @param context - sender context, to match reply w/ request
45     @param sw_if_index - index of the interface to set MTU on
46     @param mtu - MTU
47 */
48 autoreply define hw_interface_set_mtu
49 {
50   u32 client_index;
51   u32 context;
52   u32 sw_if_index;
53   u16 mtu;
54 };
55
56 /** \brief Set interface L3 MTU */
57 autoreply define sw_interface_set_mtu
58 {
59   u32 client_index;
60   u32 context;
61   u32 sw_if_index;
62   /* $$$$ Replace with enum */
63   u32 mtu[4]; /* 0 - L3, 1 - IP4, 2 - IP6, 3 - MPLS */
64 };
65
66 /** \brief Set IP4 directed broadcast
67     The directed broadcast enabled a packet sent to the interface's
68     subnet address will be broadcast on the interface
69     @param sw_if_index
70     @param enable
71 */
72 autoreply define sw_interface_set_ip_directed_broadcast
73 {
74   u32 client_index;
75   u32 context;
76   u32 sw_if_index;
77   u8  enable;
78 };
79
80
81 /** \brief Interface Event generated by want_interface_events
82     @param client_index - opaque cookie to identify the sender
83     @param pid - client pid registered to receive notification
84     @param sw_if_index - index of the interface of the event
85     @param admin_up_down - The administrative state; 1 = up, 0 = down
86     @param link_up_down - The operational state; 1 = up, 0 = down
87     @param deleted - interface was deleted
88 */
89 define sw_interface_event
90 {
91   u32 client_index;
92   u32 pid;
93   u32 sw_if_index;
94   u8 admin_up_down;
95   u8 link_up_down;
96   u8 deleted;
97 };
98
99 /** \brief Register for interface events
100     @param client_index - opaque cookie to identify the sender
101     @param context - sender context, to match reply w/ request
102     @param enable_disable - 1 => register for events, 0 => cancel registration
103     @param pid - sender's pid
104 */
105 autoreply define want_interface_events
106 {
107   u32 client_index;
108   u32 context;
109   u32 enable_disable;
110   u32 pid;
111 };
112
113 /** \brief Interface details structure (fix this) 
114     @param sw_if_index - index of the interface
115     @param sup_sw_if_index - index of parent interface if any, else same as sw_if_index  
116     @param l2_address_length - length of the interface's l2 address
117     @param pid - the interface's l2 address
118     @param interface_name - name of the interface
119     @param link_duplex - 1 if half duplex, 2 if full duplex
120     @param link_speed - value in kbps
121     @param link_MTU - max. transmission unit
122     @param sub_if_id - A number 0-N to uniquely identify this subif on super if
123     @param sub_dot1ad - 0 = dot1q, 1 = dot1ad
124     @param sub_dot1ah - 1 = dot1ah, 0 = otherwise
125     @param sub_number_of_tags - Number of tags (0 - 2)
126     @param sub_outer_vlan_id
127     @param sub_inner_vlan_id
128     @param sub_exact_match
129     @param sub_default
130     @param sub_outer_vlan_id_any
131     @param sub_inner_vlan_id_any
132     @param vtr_op - vlan tag rewrite operation
133     @param vtr_push_dot1q
134     @param vtr_tag1
135     @param vtr_tag2
136     @param pbb_outer_tag - translate pbb s-tag
137     @param pbb_b_dmac[6] - B-tag remote mac address
138     @param pbb_b_smac[6] - B-tag local mac address
139     @param pbb_b_vlanid - B-tag vlanid
140     @param pbb_i_sid - I-tag service id
141 */
142 define sw_interface_details
143 {
144   u32 context;
145   u32 sw_if_index;
146
147   /* index of sup interface (e.g. hw interface).
148      equal to sw_if_index for super hw interface. */
149   u32 sup_sw_if_index;
150
151   /* Layer 2 address, if applicable */
152   u32 l2_address_length;
153   u8 l2_address[8];
154
155   /* Interface name */
156   u8 interface_name[64];
157
158   /* 1 = up, 0 = down */
159   u8 admin_up_down;
160   u8 link_up_down;
161
162   /* 1 = half duplex, 2 = full duplex */
163   u8 link_duplex;
164
165   /* link speed in kbps */
166   u32 link_speed;
167
168   /* MTU */
169   u16 link_mtu;
170
171   /* Per protocol MTUs */
172   u32 mtu[4]; /* 0 - L3, 1 - IP4, 2 - IP6, 3 - MPLS */
173
174   /* Subinterface ID. A number 0-N to uniquely identify this subinterface under the super interface */
175   u32 sub_id;
176
177   /* 0 = dot1q, 1=dot1ad */
178   u8 sub_dot1ad;
179   /* 1 = dot1h, 1=otherwise */
180   u8 sub_dot1ah;
181
182   /* Number of tags 0-2 */
183   u8 sub_number_of_tags;
184   u16 sub_outer_vlan_id;
185   u16 sub_inner_vlan_id;
186   u8 sub_exact_match;
187   u8 sub_default;
188   u8 sub_outer_vlan_id_any;
189   u8 sub_inner_vlan_id_any;
190
191   /* vlan tag rewrite state */
192   u32 vtr_op;
193   u32 vtr_push_dot1q;           // ethertype of first pushed tag is dot1q/dot1ad
194   u32 vtr_tag1;                 // first pushed tag
195   u32 vtr_tag2;                 // second pushed tag
196   u8 tag[64];
197   
198   /* pbb tag rewrite info */
199   u16 outer_tag;
200   u8  b_dmac[6];
201   u8  b_smac[6];
202   u16 b_vlanid;
203   u32 i_sid;
204 };
205
206 /* works */
207 define sw_interface_dump
208 {
209   u32 client_index;
210   u32 context;
211   u8 name_filter_valid;
212   u8 name_filter[49];
213 };
214
215 /** \brief Set or delete one or all ip addresses on a specified interface
216     @param client_index - opaque cookie to identify the sender
217     @param context - sender context, to match reply w/ request
218     @param sw_if_index - index of the interface to add/del addresses 
219     @param is_add - add address if non-zero, else delete
220     @param is_ipv6 - if non-zero the address is ipv6, else ipv4
221     @param del_all - if non-zero delete all addresses on the interface
222     @param address_length - address length in bytes, 4 for ip4, 16 for ip6
223     @param address - array of address bytes
224 */
225 autoreply define sw_interface_add_del_address
226 {
227   u32 client_index;
228   u32 context;
229   u32 sw_if_index;
230   u8 is_add;
231   u8 is_ipv6;
232   u8 del_all;
233   u8 address_length;
234   u8 address[16];
235 };
236
237 /** \brief Associate the specified interface with a fib table
238     @param client_index - opaque cookie to identify the sender
239     @param context - sender context, to match reply w/ request
240     @param sw_if_index - index of the interface
241     @param is_ipv6 - if non-zero ipv6, else ipv4
242     @param vrf_id - fib table/vrd id to associate the interface with
243 */
244 autoreply define sw_interface_set_table
245 {
246   u32 client_index;
247   u32 context;
248   u32 sw_if_index;
249   u8 is_ipv6;
250   u32 vrf_id;
251 };
252
253 /** \brief Get VRF id assigned to interface
254     @param client_index - opaque cookie to identify the sender
255     @param context - sender context, to match reply w/ request
256     @param sw_if_index - index of the interface
257 */
258 define sw_interface_get_table
259 {
260   u32 client_index;
261   u32 context;
262   u32 sw_if_index;
263   u8 is_ipv6;
264 };
265
266 /** \brief Reply to get_sw_interface_vrf
267     @param context - sender context which was passed in the request
268     @param vrf_id - VRF id assigned to the interface
269 */
270 define sw_interface_get_table_reply
271 {
272   u32 context;
273   i32 retval;
274   u32 vrf_id;
275 };
276
277 typeonly manual_print manual_endian define vlib_counter
278 {
279   u64 packets;                  /**< packet counter */
280   u64 bytes;                    /**< byte counter  */
281 };
282
283 /** \brief Combined interface counter data type for vnet_interface_combined_counters
284     @param sw_if_index - interface indexes for counters
285     @param rx_packets - received packet count
286     @param rx_bytes - received byte count
287     @param rx_unicast_packets - received unicast packet count
288     @param rx_unicast_bytes - received unicast byte count
289     @param rx_multicast_packets - received multicast packet count
290     @param rx_multicast_bytes - received multicast byte count
291     @param rx_broadcast_packets - received broadcast packet count
292     @param rx_broadcast_bytes - received broadcast byte count
293     @param tx_packets - transmitted packet count
294     @param tx_bytes - transmitted byte count
295     @param tx_unicast_packets - transmitted unicast packet count
296     @param tx_unicast_bytes - transmitted unicast byte count
297     @param tx_multicast_packets - transmitted multicast packet count
298     @param tx_multicast_bytes - transmitted multicast byte count
299     @param tx_broadcast_packets - transmitted broadcast packet count
300     @param tx_broadcast_bytes - transmitted broadcast byte count
301
302 */
303 typeonly manual_print manual_endian define vnet_combined_counter
304 {
305   u32 sw_if_index;
306   u64 rx_packets;                               /**< packet counter */
307   u64 rx_bytes;                                 /**< byte counter  */
308   u64 rx_unicast_packets;                       /**< packet counter */
309   u64 rx_unicast_bytes;                         /**< byte counter  */
310   u64 rx_multicast_packets;                     /**< packet counter */
311   u64 rx_multicast_bytes;                       /**< byte counter  */
312   u64 rx_broadcast_packets;                     /**< packet counter */
313   u64 rx_broadcast_bytes;                       /**< byte counter  */
314   u64 tx_packets;                               /**< packet counter */
315   u64 tx_bytes;                                 /**< byte counter  */
316   u64 tx_unicast_packets;                       /**< packet counter */
317   u64 tx_unicast_bytes;                         /**< byte counter  */
318   u64 tx_multicast_packets;                     /**< packet counter */
319   u64 tx_multicast_bytes;                       /**< byte counter  */
320   u64 tx_broadcast_packets;                     /**< packet counter */
321   u64 tx_broadcast_bytes;                       /**< byte counter  */
322 };
323
324 /** \brief Simple interface counter data type for vnet_interface_simple_counters
325     @param sw_if_index - interface indexes for counters
326     @param drop - RX or TX drops due to buffer starvation
327     @param punt - used with VNET "punt" disposition
328     @param rx_ip4 - received IP4 packets
329     @param rx_ip6 - received IP6 packets
330     @param rx_no_buffer - no RX buffers available
331     @param rx_miss - receive misses
332     @param rx_error - receive errors
333     @param tx_error - transmit errors
334     @param rx_mpls - received MPLS packet
335
336 */
337 typeonly manual_print manual_endian define vnet_simple_counter
338 {
339   u32 sw_if_index;
340   u64 drop;
341   u64 punt;
342   u64 rx_ip4;
343   u64 rx_ip6;
344   u64 rx_no_buffer;
345   u64 rx_miss;
346   u64 rx_error;
347   u64 tx_error;
348   u64 rx_mpls;
349 };
350
351 /** \brief Set unnumbered interface add / del request
352     @param client_index - opaque cookie to identify the sender
353     @param context - sender context, to match reply w/ request
354     @param sw_if_index - interface with an IP address
355     @param unnumbered_sw_if_index - interface which will use the address
356     @param is_add - if non-zero set the association, else unset it
357 */
358 autoreply define sw_interface_set_unnumbered
359 {
360   u32 client_index;
361   u32 context;
362   u32 sw_if_index;              /* use this intfc address */
363   u32 unnumbered_sw_if_index;   /* on this interface */
364   u8 is_add;
365 };
366
367 /** \brief Clear interface statistics
368     @param client_index - opaque cookie to identify the sender
369     @param context - sender context, to match reply w/ request
370     @param sw_if_index - index of the interface to clear statistics
371 */
372 autoreply define sw_interface_clear_stats
373 {
374   u32 client_index;
375   u32 context;
376   u32 sw_if_index;
377 };
378
379 /** \brief Set / clear software interface tag
380     @param client_index - opaque cookie to identify the sender
381     @param context - sender context, to match reply w/ request
382     @param sw_if_index - the interface
383     @param add_del - 1 = add, 0 = delete
384     @param tag - an ascii tag
385 */
386 autoreply define sw_interface_tag_add_del 
387 {
388     u32 client_index;
389     u32 context;
390     u8 is_add;
391     u32 sw_if_index;
392     u8 tag[64];
393 };
394
395 /** \brief Set an interface's MAC address
396     @param client_index - opaque cookie to identify the sender
397     @param context - sender context, to match reply w/ request
398     @param sw_if_index - the interface whose MAC will be set
399     @param mac_addr - the new MAC address
400 */
401 autoreply define sw_interface_set_mac_address
402 {
403     u32 client_index;
404     u32 context;
405     u32 sw_if_index;
406     u8 mac_address[6];
407 };
408
409 /** \brief Get interface's MAC address
410     @param client_index - opaque cookie to identify the sender
411     @param context - sender context, to match reply w/ request
412     @param sw_if_index - the interface whose MAC will be returned
413 */
414 define sw_interface_get_mac_address
415 {
416     u32 client_index;
417     u32 context;
418     u32 sw_if_index;
419 };
420
421 /** \brief Reply for get interface's MAC address request
422     @param context - returned sender context, to match reply w/ request
423     @param retval - return code
424     @param mac_addr - returned interface's MAC address
425 */
426 define sw_interface_get_mac_address_reply
427 {
428     u32 context;
429     i32 retval;
430     u8 mac_address[6];
431 };
432
433 /** \brief Set an interface's rx-mode
434     @param client_index - opaque cookie to identify the sender
435     @param context - sender context, to match reply w/ request
436     @param sw_if_index - the interface whose rx-mode will be set
437     @param queue_id_valid - 1 = the queue_id field is valid. 0 means all
438       queue_id's
439     @param queue_id - the queue number whose rx-mode will be set. Only valid
440       if queue_id_valid is 1
441     @param mode - polling=1, interrupt=2, adaptive=3
442 */
443 autoreply define sw_interface_set_rx_mode
444 {
445     u32 client_index;
446     u32 context;
447     u32 sw_if_index;
448     u8 queue_id_valid;
449     u32 queue_id;
450     u8 mode;
451 };
452
453 /** \brief Set an interface's rx-placement
454     Rx-Queue placement on specific thread is operational for only hardware
455     interface. It will not set queue - thread placement for sub-interfaces,
456     p2p and pipe interfaces.
457     @param client_index - opaque cookie to identify the sender
458     @param context - sender context, to match reply w/ request
459     @param sw_if_index - the interface whose rx-placement will be set
460     @param queue_id - the queue number whose rx-placement will be set.
461     @param worker_id - the worker number whom rx-placement will be at.
462     @param is_main - flag to set rx-placement to main thread
463 */
464 autoreply define sw_interface_set_rx_placement
465 {
466     u32 client_index;
467     u32 context;
468     u32 sw_if_index;
469     u32 queue_id;
470     u32 worker_id;
471     u8 is_main;
472 };
473
474 /** \brief dump the rx queue placement of interface(s)
475     @param sw_if_index - optional interface index for which queue placement to
476       be requested. sw_if_index = ~0 will dump placement information for all
477       interfaces. It will not dump information related to sub-interfaces, p2p
478       and pipe interfaces.
479 */
480 define sw_interface_rx_placement_dump
481 {
482   u32 client_index;
483   u32 context;
484   u32 sw_if_index;
485 };
486
487 /** \brief show the interface's queue - thread placement
488     This api is used to display the interface and queue worker
489     thread placement. One message per rx-queue per interface will
490     be sent to client.
491     Each message will contain information about rx-queue id of an
492     interface, interface index, thread on which this rx-queue is
493     placed and mode of rx-queue.
494     @param client_index - opaque cookie to identify the sender
495     @param context - sender context, to match reply w/ request
496     @param sw_if_index - the interface whose rx-placement will be dumped
497     @param queue_id - the queue id
498     @param worker_id - the worker id on which queue_id is placed,
499                        worker_id = 0 means main thread.
500     @param mode - polling=1, interrupt=2, adaptive=3
501 */
502 define sw_interface_rx_placement_details
503 {
504   u32 client_index;
505   u32 context;
506   u32 sw_if_index;
507   u32 queue_id;
508   u32 worker_id;
509   u8 mode;
510 };
511
512 /* Gross kludge, DGMS */
513 autoreply define interface_name_renumber
514 {
515   u32 client_index;
516   u32 context;
517   u32 sw_if_index;
518   u32 new_show_dev_instance;
519 };
520
521 define create_subif
522 {
523   u32 client_index;
524   u32 context;
525   u32 sw_if_index;
526   u32 sub_id;
527
528   /* These fields map directly onto the subif template */
529   u8 no_tags;
530   u8 one_tag;
531   u8 two_tags;
532   u8 dot1ad;                    // 0 = dot1q, 1=dot1ad
533   u8 exact_match;
534   u8 default_sub;
535   u8 outer_vlan_id_any;
536   u8 inner_vlan_id_any;
537   u16 outer_vlan_id;
538   u16 inner_vlan_id;
539 };
540
541 define create_subif_reply
542 {
543   u32 context;
544   i32 retval;
545   u32 sw_if_index;
546 };
547
548 /** \brief Create a new subinterface with the given vlan id
549     @param client_index - opaque cookie to identify the sender
550     @param context - sender context, to match reply w/ request
551     @param sw_if_index - software index of the new vlan's parent interface
552     @param vlan_id - vlan tag of the new interface
553 */
554 define create_vlan_subif
555 {
556   u32 client_index;
557   u32 context;
558   u32 sw_if_index;
559   u32 vlan_id;
560 };
561
562 /** \brief Reply for the vlan subinterface create request
563     @param context - returned sender context, to match reply w/ request
564     @param retval - return code
565     @param sw_if_index - software index allocated for the new subinterface
566 */
567 define create_vlan_subif_reply
568 {
569   u32 context;
570   i32 retval;
571   u32 sw_if_index;
572 };
573
574 /** \brief Delete sub interface request
575     @param client_index - opaque cookie to identify the sender
576     @param context - sender context, to match reply w/ request
577     @param sw_if_index - sw index of the interface that was created by create_subif
578 */
579 autoreply define delete_subif {
580   u32 client_index;
581   u32 context;
582   u32 sw_if_index;
583 };
584
585 /** \brief Create loopback interface request
586     @param client_index - opaque cookie to identify the sender
587     @param context - sender context, to match reply w/ request
588     @param mac_address - mac addr to assign to the interface if none-zero
589 */
590 define create_loopback
591 {
592   u32 client_index;
593   u32 context;
594   u8 mac_address[6];
595 };
596
597 /** \brief Create loopback interface response
598     @param context - sender context, to match reply w/ request
599     @param sw_if_index - sw index of the interface that was created
600     @param retval - return code for the request
601 */
602 define create_loopback_reply
603 {
604   u32 context;
605   i32 retval;
606   u32 sw_if_index;
607 };
608
609 /** \brief Create loopback interface instance request
610     @param client_index - opaque cookie to identify the sender
611     @param context - sender context, to match reply w/ request
612     @param mac_address - mac addr to assign to the interface if none-zero
613     @param is_specified - if non-0, a specific user_instance is being requested
614     @param user_instance - requested instance, ~0 => dynamically allocate
615 */
616 define create_loopback_instance
617 {
618   u32 client_index;
619   u32 context;
620   u8 mac_address[6];
621   u8 is_specified;
622   u32 user_instance;
623 };
624
625 /** \brief Create loopback interface instance response
626     @param context - sender context, to match reply w/ request
627     @param sw_if_index - sw index of the interface that was created
628     @param retval - return code for the request
629 */
630 define create_loopback_instance_reply
631 {
632   u32 context;
633   i32 retval;
634   u32 sw_if_index;
635 };
636
637 /** \brief Delete loopback interface request
638     @param client_index - opaque cookie to identify the sender
639     @param context - sender context, to match reply w/ request
640     @param sw_if_index - sw index of the interface that was created
641 */
642 autoreply define delete_loopback
643 {
644   u32 client_index;
645   u32 context;
646   u32 sw_if_index;
647 };
648
649 /** \brief Enable or disable detailed interface stats
650     @param client_index - opaque cookie to identify the sender
651     @param context - sender context, to match reply w/ request
652     @param sw_if_index - The interface to collect detail stats on. ~0 implies
653                          all interfaces.
654     @param enable_disable - set to 1 to enable, 0 to disable detailed stats
655 */
656 autoreply define collect_detailed_interface_stats
657 {
658   u32 client_index;
659   u32 context;
660   u32 sw_if_index;
661   u8  enable_disable;
662 };
663
664 /*
665  * Local Variables:
666  * eval: (c-set-style "gnu")
667  * End:
668  */