l2: add per bridge domain learn limit
[vpp.git] / src / vnet / l2 / l2.api
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2016 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.0.0";
18
19 import "vnet/ip/ip_types.api";
20 import "vnet/ethernet/ethernet_types.api";
21 import "vnet/interface_types.api";
22
23 /** \brief Reply to l2_xconnect_dump
24     @param context - sender context which was passed in the request
25     @param rx_sw_if_index - Receive interface index
26     @param tx_sw_if_index - Transmit interface index
27  */
28 define l2_xconnect_details
29 {
30   u32 context;
31   vl_api_interface_index_t rx_sw_if_index;
32   vl_api_interface_index_t tx_sw_if_index;
33 };
34
35 /** \brief Dump L2 XConnects
36     @param client_index - opaque cookie to identify the sender
37     @param context - sender context, to match reply w/ request
38 */
39 define l2_xconnect_dump
40 {
41   u32 client_index;
42   u32 context;
43 };
44
45 /** \brief l2 fib table details structure
46     @param bd_id - the l2 fib / bridge domain table id
47     @param mac - the entry's mac address
48     @param sw_if_index - index of the interface
49     @param static_mac - the entry is statically configured.
50     @param filter_mac - the entry is a mac filter entry.
51     @param bvi_mac - the mac address is a bridge virtual interface
52 */
53 define l2_fib_table_details
54 {
55   u32 context;
56   u32 bd_id;
57   vl_api_mac_address_t mac;
58   vl_api_interface_index_t sw_if_index;
59   bool static_mac;
60   bool filter_mac;
61   bool bvi_mac;
62 };
63
64 /** \brief Dump l2 fib (aka bridge domain) table
65     @param client_index - opaque cookie to identify the sender
66     @param bd_id - the l2 fib / bridge domain table identifier
67 */
68 define l2_fib_table_dump
69 {
70   u32 client_index;
71   u32 context;
72   u32 bd_id;
73 };
74
75 /** \brief L2 fib clear table request, clear all mac entries in the l2 fib
76     @param client_index - opaque cookie to identify the sender
77     @param context - sender context, to match reply w/ request
78 */
79 autoreply define l2_fib_clear_table
80 {
81   u32 client_index;
82   u32 context;
83 };
84
85 /** \brief L2 FIB flush all  entries
86     @param client_index - opaque cookie to identify the sender
87     @param context - sender context, to match reply w/ request
88 */
89 autoreply define l2fib_flush_all
90 {
91   u32 client_index;
92   u32 context;
93 };
94
95 /** \brief L2 FIB flush bridge domain entries
96     @param client_index - opaque cookie to identify the sender
97     @param context - sender context, to match reply w/ request
98     @param bd_id - the entry's bridge domain id
99 */
100 autoreply define l2fib_flush_bd
101 {
102   u32 client_index;
103   u32 context;
104   u32 bd_id;
105 };
106
107 /** \brief L2 FIB flush interface entries
108     @param client_index - opaque cookie to identify the sender
109     @param context - sender context, to match reply w/ request
110     @param bd_id - the entry's bridge domain id
111 */
112 autoreply define l2fib_flush_int
113 {
114   u32 client_index;
115   u32 context;
116   vl_api_interface_index_t sw_if_index;
117 };
118
119 /** \brief L2 FIB add entry request
120     @param client_index - opaque cookie to identify the sender
121     @param context - sender context, to match reply w/ request
122     @param mac - the entry's mac address
123     @param bd_id - the entry's bridge domain id
124     @param sw_if_index - the interface
125     @param is_add - If non zero add the entry, else delete it
126     @param static_mac -
127     @param filter_mac -
128     @param bvi_mac -
129 */
130 autoreply define l2fib_add_del
131 {
132   u32 client_index;
133   u32 context;
134   vl_api_mac_address_t mac;
135   u32 bd_id;
136   vl_api_interface_index_t sw_if_index;
137   bool is_add [default=true];
138   bool static_mac;
139   bool filter_mac;
140   bool bvi_mac;
141 };
142
143 /** \brief Register to receive L2 MAC events for learned and aged MAC
144     @param client_index - opaque cookie to identify the sender
145     @param context - sender context, to match reply w/ request
146     @param learn_limit - MAC learn limit
147     @param scan_delay - event scan delay in 10 msec unit
148     @param max_macs_in_event - in units of 10 mac entries
149     @param enable_disable - 1 => register for MAC events, 0 => cancel registration
150     @param pid - sender's pid
151 */
152 autoreply define want_l2_macs_events
153 {
154   u32 client_index;
155   u32 context;
156   u32 learn_limit [default=1000];
157   u8  scan_delay [default=10];
158   u8  max_macs_in_event [default=10];
159   bool enable_disable [default=true];
160   u32 pid;
161 };
162
163 enum mac_event_action
164 {
165         MAC_EVENT_ACTION_API_ADD = 0,
166         MAC_EVENT_ACTION_API_DELETE = 1,
167         MAC_EVENT_ACTION_API_MOVE = 2,
168 };
169
170 /** \brief Entry for learned or aged MAC in L2 MAC Events
171     @param sw_if_index - sw_if_index in the domain
172     @param mac_addr - mac_address
173     @param action - 0 => newly learned MAC, 1 => MAC deleted by ager
174                     2 => MAC move (sw_if_index changed)
175     @param flags - flag bits to provide other info, not yet used
176 */
177 typedef mac_entry
178 {
179   vl_api_interface_index_t sw_if_index;
180   vl_api_mac_address_t mac_addr;
181   vl_api_mac_event_action_t action;
182   u8 flags;
183 };
184
185 /** \brief L2 MAC event for a list of learned or aged MACs
186     @param client_index - opaque cookie to identify the sender
187     @param pid - client pid registered to receive notification
188     @param n_macs - number of learned/aged MAC entries
189     @param mac - array of learned/aged MAC entries
190 */
191 define l2_macs_event
192 {
193   u32 client_index;
194   u32 pid;
195   u32 n_macs;
196   vl_api_mac_entry_t mac[n_macs];
197 };
198
199 service {
200   rpc want_l2_macs_events returns want_l2_macs_events_reply
201     events l2_macs_event;
202 };
203
204 /** \brief Set interface L2 flags (such as L2_LEARN, L2_FWD,
205     L2_FLOOD, L2_UU_FLOOD, or L2_ARP_TERM bits). This can be used
206     to disable one or more of the features represented by the
207     flag bits on an interface to override what is set as default
208     for all interfaces in the bridge domain
209     @param client_index - opaque cookie to identify the sender
210     @param context - sender context, to match reply w/ request
211     @param sw_if_index - interface
212     @param is_set - if non-zero, set the bits, else clear them
213     @param feature_bitmap - non-zero bits (as above) to set or clear
214 */
215 define l2_flags
216 {
217   u32 client_index;
218   u32 context;
219   vl_api_interface_index_t sw_if_index;
220   bool is_set;
221   u32 feature_bitmap;
222 };
223
224 /** \brief Set interface L2 flags response
225     @param context - sender context, to match reply w/ request
226     @param retval - return code for the set l2 bits request
227     @param resulting_feature_bitmap - the internal l2 feature bitmap after the request is implemented
228 */
229 define l2_flags_reply
230 {
231   u32 context;
232   i32 retval;
233   u32 resulting_feature_bitmap;
234 };
235
236 /** \brief L2 bridge domain set mac age
237     @param client_index - opaque cookie to identify the sender
238     @param context - sender context, to match reply w/ request
239     @param bd_id - the bridge domain to create
240     @param mac_age - mac aging time in min, 0 for disabled
241 */
242 autoreply define bridge_domain_set_mac_age
243 {
244   u32 client_index;
245   u32 context;
246   u32 bd_id;
247   u8 mac_age;
248 };
249
250 /** \brief L2 bridge domain set default learn limit
251     @param client_index - opaque cookie to identify the sender
252     @param context - sender context, to match reply w/ request
253     @param learn limit - maximum number of entries by default for bridge domains
254 */
255 autoreply define bridge_domain_set_default_learn_limit
256 {
257   u32 client_index;
258   u32 context;
259   u32 learn_limit;
260 };
261
262
263 /** \brief L2 bridge domain set learn limit
264     @param client_index - opaque cookie to identify the sender
265     @param context - sender context, to match reply w/ request
266     @param bd_id - the bridge domain idenntifier
267     @param learn limit - maximum number of entries for this bd
268 */
269 autoreply define bridge_domain_set_learn_limit
270 {
271   u32 client_index;
272   u32 context;
273   u32 bd_id;
274   u32 learn_limit;
275 };
276
277 /** \brief L2 bridge domain add or delete request
278     @param client_index - opaque cookie to identify the sender
279     @param context - sender context, to match reply w/ request
280     @param bd_id - the bridge domain to create
281     @param flood - enable/disable bcast/mcast flooding in the bd
282     @param uu_flood - enable/disable unknown unicast flood in the bd
283     @param forward - enable/disable forwarding on all interfaces in the bd
284     @param learn - enable/disable learning on all interfaces in the bd
285     @param arp_term - enable/disable arp termination in the bd
286     @param arp_ufwd - enable/disable arp unicast forwarding in the bd
287     @param mac_age - mac aging time in min, 0 for disabled
288     @param is_add - add or delete flag
289 */
290 autoreply define bridge_domain_add_del
291 {
292   u32 client_index;
293   u32 context;
294   u32 bd_id;
295   bool flood;
296   bool uu_flood;
297   bool forward;
298   bool learn;
299   bool arp_term;
300   bool arp_ufwd;
301   u8 mac_age;
302   string bd_tag[64];
303   bool is_add [default=true];
304 };
305
306 /** \brief L2 bridge domain request operational state details
307     @param client_index - opaque cookie to identify the sender
308     @param context - sender context, to match reply w/ request
309     @param bd_id - the bridge domain id desired or ~0 to request all bds
310     @param sw_if_index - filter by sw_if_index UNIMPLEMENTED
311 */
312 define bridge_domain_dump
313 {
314   u32 client_index;
315   u32 context;
316   u32 bd_id [default=0xffffffff];
317   vl_api_interface_index_t sw_if_index [default=0xffffffff];
318 };
319
320 /** \brief L2 bridge domain sw interface operational state response
321     @param bd_id - the bridge domain id
322     @param sw_if_index - sw_if_index in the domain
323     @param shg - split horizon group for the interface
324 */
325 typedef bridge_domain_sw_if
326 {
327   u32 context;
328   vl_api_interface_index_t sw_if_index;
329   /* FIXME: set_int_l2_mode() u32/ api u8 */
330   u8 shg;
331 };
332
333 /** \brief L2 bridge domain operational state response
334     @param bd_id - the bridge domain id
335     @param flood - bcast/mcast flooding state on all interfaces in the bd
336     @param uu_flood - unknown unicast flooding state on all interfaces in the bd
337     @param forward - forwarding state on all interfaces in the bd
338     @param learn - learning state on all interfaces in the bd
339     @param arp_term - arp termination state on all interfaces in the bd
340     @param arp_ufwd - arp unicast forwarding state on all interfaces in the bd
341     @param mac_age - mac aging time in min, 0 for disabled
342     @param bd_tag - optional textual tag for the bridge domain
343     @param n_sw_ifs - number of sw_if_index's in the domain
344 */
345 define bridge_domain_details
346 {
347   u32 context;
348   u32 bd_id;
349   bool flood;
350   bool uu_flood;
351   bool forward;
352   bool learn;
353   bool arp_term;
354   bool arp_ufwd;
355   u8 mac_age;
356   string bd_tag[64];
357   vl_api_interface_index_t bvi_sw_if_index;
358   vl_api_interface_index_t uu_fwd_sw_if_index;
359   u32 n_sw_ifs;
360   vl_api_bridge_domain_sw_if_t sw_if_details[n_sw_ifs];
361 };
362
363 /** \brief Flags that can be changed on a bridge domain */
364 enum bd_flags
365 {
366   BRIDGE_API_FLAG_NONE = 0x0,
367   BRIDGE_API_FLAG_LEARN = 0x1,
368   BRIDGE_API_FLAG_FWD = 0x2,
369   BRIDGE_API_FLAG_FLOOD = 0x4,
370   BRIDGE_API_FLAG_UU_FLOOD = 0x8,
371   BRIDGE_API_FLAG_ARP_TERM = 0x10,
372   BRIDGE_API_FLAG_ARP_UFWD = 0x20,
373 };
374
375 /** \brief Set bridge flags request
376     @param client_index - opaque cookie to identify the sender
377     @param context - sender context, to match reply w/ request
378     @param bd_id - the bridge domain to set the flags for
379     @param is_set - if non-zero, set the flags, else clear them
380     @param flags - flags that are non-zero to set or clear
381 */
382 define bridge_flags
383 {
384   u32 client_index;
385   u32 context;
386   u32 bd_id;
387   bool is_set;
388   vl_api_bd_flags_t flags;
389 };
390
391 /** \brief Set bridge flags response
392     @param context - sender context, to match reply w/ request
393     @param retval - return code for the set bridge flags request
394     @param resulting_feature_bitmap - the internal L2 feature bitmap after the request is implemented
395 */
396 define bridge_flags_reply
397 {
398   u32 context;
399   i32 retval;
400   u32 resulting_feature_bitmap;
401 };
402
403 /** \brief L2 interface vlan tag rewrite configure request
404     @param client_index - opaque cookie to identify the sender
405     @param context - sender context, to match reply w/ request
406     @param sw_if_index - interface the operation is applied to
407     @param vtr_op - Choose from l2_vtr_op_t enum values
408     @param push_dot1q - first pushed flag dot1q id set, else dot1ad
409     @param tag1 - Needed for any push or translate vtr op
410     @param tag2 - Needed for any push 2 or translate x-2 vtr ops
411 */
412 autoreply define l2_interface_vlan_tag_rewrite
413 {
414   u32 client_index;
415   u32 context;
416   vl_api_interface_index_t sw_if_index;
417   u32 vtr_op;
418   u32 push_dot1q;               // ethertype of first pushed tag is dot1q/dot1ad
419   u32 tag1;                     // first pushed tag
420   u32 tag2;                     // second pushed tag
421 };
422
423 /** \brief L2 interface pbb tag rewrite configure request
424     @param client_index - opaque cookie to identify the sender
425     @param context - sender context, to match reply w/ request
426     @param sw_if_index - interface the operation is applied to
427     @param vtr_op - Choose from l2_vtr_op_t enum values
428     @param inner_tag - needed for translate_qinq vtr op only
429     @param outer_tag - needed for translate_qinq vtr op only
430     @param b_dmac - B-tag remote mac address, needed for any push or translate_qinq vtr op
431     @param b_smac - B-tag local mac address, needed for any push or translate qinq vtr op
432     @param b_vlanid - B-tag vlanid, needed for any push or translate qinq vtr op
433     @param i_sid - I-tag service id, needed for any push or translate qinq vtr op
434 */
435 autoreply define l2_interface_pbb_tag_rewrite
436 {
437   u32 client_index;
438   u32 context;
439   vl_api_interface_index_t sw_if_index;
440   u32 vtr_op;
441   u16 outer_tag;
442   vl_api_mac_address_t b_dmac;
443   vl_api_mac_address_t b_smac;
444   u16 b_vlanid;
445   u32 i_sid;
446 };
447
448 /** \brief L2 interface patch add / del request
449     @param client_index - opaque cookie to identify the sender
450     @param context - sender context, to match reply w/ request
451     @param rx_sw_if_index - receive side interface
452     @param tx_sw_if_index - transmit side interface
453     @param is_add - if non-zero set up the interface patch, else remove it
454 */
455 autoreply define l2_patch_add_del
456 {
457   u32 client_index;
458   u32 context;
459   vl_api_interface_index_t rx_sw_if_index;
460   vl_api_interface_index_t tx_sw_if_index;
461   bool is_add [default=true];
462 };
463
464 /** \brief Set L2 XConnect between two interfaces request
465     @param client_index - opaque cookie to identify the sender
466     @param context - sender context, to match reply w/ request
467     @param rx_sw_if_index - Receive interface index
468     @param tx_sw_if_index - Transmit interface index
469     @param enable - enable xconnect if not 0, else set to L3 mode
470 */
471 autoreply define sw_interface_set_l2_xconnect
472 {
473   u32 client_index;
474   u32 context;
475   vl_api_interface_index_t rx_sw_if_index;
476   vl_api_interface_index_t tx_sw_if_index;
477   bool enable [default=true];
478 };
479
480 /**
481  * @brief An enumeration of the type of ports that can be added
482  *        to a bridge domain
483  */
484 enum l2_port_type
485 {
486   /* a 'normal' interface, i.e. not BVI or UU-Flood */
487   L2_API_PORT_TYPE_NORMAL = 0,
488   /* a BVI interface in the BD */
489   L2_API_PORT_TYPE_BVI = 1,
490   /* The interface on which to forward unknown unicast packets
491    * If this is not set for a BD then UU is flooded */
492   L2_API_PORT_TYPE_UU_FWD = 2,
493 };
494
495 /** \brief Interface bridge mode request
496     @param client_index - opaque cookie to identify the sender
497     @param context - sender context, to match reply w/ request
498     @param rx_sw_if_index - the interface
499     @param bd_id - bridge domain id
500     @param port_type - port_mode, see #l2_port_type
501     @param shg - Split horizon group, for bridge mode only
502     @param enable - Enable beige mode if not 0, else set to L3 mode
503 */
504
505 autoreply define sw_interface_set_l2_bridge
506 {
507   u32 client_index;
508   u32 context;
509   vl_api_interface_index_t rx_sw_if_index;
510   u32 bd_id;
511   vl_api_l2_port_type_t port_type;
512   u8 shg;
513   bool enable [default=true];
514 };
515
516 /** \brief Set bridge domain ip to mac entry request
517     @param client_index - opaque cookie to identify the sender
518     @param context - sender context, to match reply w/ request
519     @param bd_id - the bridge domain to set the flags for
520     @param is_add - if non-zero, add the entry, else clear it
521     @param ip - ipv4 or ipv6 address
522     @param mac - MAC address
523 */
524
525 typedef bd_ip_mac
526 {
527   u32 bd_id;
528   vl_api_address_t ip;
529   vl_api_mac_address_t mac;
530 };
531
532 autoreply define bd_ip_mac_add_del
533 {
534   u32 client_index;
535   u32 context;
536   bool is_add [default=true];
537   vl_api_bd_ip_mac_t entry;
538 };
539
540 /** \brief Flush bridge domain IP to MAC entries
541     @param client_index - opaque cookie to identify the sender
542     @param bd_id - bridge domain identifier
543 */
544 autoreply define bd_ip_mac_flush
545 {
546   u32 client_index;
547   u32 context;
548   u32 bd_id;
549 };
550
551 /** \brief bridge domain IP to MAC entry details structure
552     @param bd_id - bridge domain table id
553     @param is_ipv6 - if non-zero, ipv6 address, else ipv4 address
554     @param ip_address - ipv4 or ipv6 address
555     @param mac_address - MAC address
556 */
557 define bd_ip_mac_details
558 {
559   u32 context;
560   vl_api_bd_ip_mac_t entry;
561 };
562
563 /** \brief Dump bridge domain IP to MAC entries
564     @param client_index - opaque cookie to identify the sender
565     @param bd_id - bridge domain identifier
566 */
567 define bd_ip_mac_dump
568 {
569   u32 client_index;
570   u32 context;
571   u32 bd_id;
572 };
573
574 /** \brief L2 interface ethernet flow point filtering enable/disable 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 - interface to enable/disable filtering on
578     @param enable_disable - if non-zero enable filtering, else disable
579 */
580 autoreply define l2_interface_efp_filter
581 {
582   u32 client_index;
583   u32 context;
584   vl_api_interface_index_t sw_if_index;
585   bool enable_disable [default=true];
586 };
587
588 /** \brief Interface set vpath request
589     @param client_index - opaque cookie to identify the sender
590     @param context - sender context, to match reply w/ request
591     @param sw_if_index - interface used to reach neighbor
592     @param enable - if non-zero enable, else disable
593 */
594 autoreply define sw_interface_set_vpath
595 {
596   u32 client_index;
597   u32 context;
598   vl_api_interface_index_t sw_if_index;
599   bool enable [default=0xffffffff];
600 };
601
602 /** \brief Create BVI interface instance request
603     @param client_index - opaque cookie to identify the sender
604     @param context - sender context, to match reply w/ request
605     @param mac_address - mac addr to assign to the interface if none-zero
606     @param user_instance - requested instance, ~0 => dynamically allocate
607 */
608 define bvi_create
609 {
610   u32 client_index;
611   u32 context;
612   vl_api_mac_address_t mac;
613   u32 user_instance [default=0xffffffff];
614 };
615
616 /** \brief Create BVI interface instance response
617     @param context - sender context, to match reply w/ request
618     @param sw_if_index - sw index of the interface that was created
619     @param retval - return code for the request
620 */
621 define bvi_create_reply
622 {
623   u32 context;
624   i32 retval;
625   vl_api_interface_index_t sw_if_index;
626 };
627
628 /** \brief Delete BVI interface request
629     @param client_index - opaque cookie to identify the sender
630     @param context - sender context, to match reply w/ request
631     @param sw_if_index - sw index of the interface that was created
632 */
633 autoreply define bvi_delete
634 {
635   u32 client_index;
636   u32 context;
637   vl_api_interface_index_t sw_if_index;
638 };
639
640 /** \brief Register for IP4 ARP resolution event on receiving ARP reply or
641            MAC/IP info from ARP requests in L2 BDs
642     @param client_index - opaque cookie to identify the sender
643     @param context - sender context, to match reply w/ request
644     @param enable - 1 => register for events, 0 => cancel registration
645     @param pid - sender's pid
646 */
647 autoreply define want_l2_arp_term_events
648 {
649   u32 client_index;
650   u32 context;
651   bool enable;
652   u32 pid;
653 };
654
655 /** \brief Tell client about an IP4 ARP resolution event or
656            MAC/IP info from ARP requests in L2 BDs
657     @param client_index - opaque cookie to identify the sender
658     @param pid - client pid registered to receive notification
659     @param ip - IP address of new ARP term entry
660     @param sw_if_index - interface of new ARP term entry
661     @param mac - MAC address of new ARP term entry
662 */
663 define l2_arp_term_event
664 {
665   u32 client_index;
666   u32 pid;
667   vl_api_address_t ip;
668   vl_api_interface_index_t sw_if_index;
669   vl_api_mac_address_t mac;
670 };
671
672 service {
673   rpc want_l2_arp_term_events returns want_l2_arp_term_events_reply
674     events l2_arp_term_event;
675 };
676
677 /*
678  * Local Variables:
679  * eval: (c-set-style "gnu")
680  * End:
681  */