OpenNSL API Guide and Reference Manual
l2.h
Go to the documentation of this file.
1 
4 /*****************************************************************************
5  *
6  * (C) Copyright Broadcom Corporation 2013-2016
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  *
11  * You may obtain a copy of the License at
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  ***************************************************************************/
24 #ifndef __OPENNSL_L2_H__
25 #define __OPENNSL_L2_H__
26 
27 #include <opennsl/types.h>
28 
29 #define OPENNSL_L2_DISCARD_SRC 0x00000002
30 #define OPENNSL_L2_DISCARD_DST 0x00000004
31 #define OPENNSL_L2_COPY_TO_CPU 0x00000008
32 #define OPENNSL_L2_L3LOOKUP 0x00000010
33 #define OPENNSL_L2_STATIC 0x00000020
34 #define OPENNSL_L2_HIT 0x00000040
35 #define OPENNSL_L2_TRUNK_MEMBER 0x00000080
36 #define OPENNSL_L2_MCAST 0x00000100
37 #define OPENNSL_L2_SRC_HIT 0x00000400
38 #define OPENNSL_L2_DES_HIT 0x00000800
39 #define OPENNSL_L2_MOVE_PORT 0x00100000
40 #define OPENNSL_L2_LOCAL_CPU 0x00200000
42 #define OPENNSL_L2_CALLBACK_DELETE 0
43 #define OPENNSL_L2_CALLBACK_ADD 1
44 #define OPENNSL_L2_CALLBACK_REPORT 2
45 #define OPENNSL_L2_CALLBACK_LEARN_EVENT 3
46 #define OPENNSL_L2_CALLBACK_AGE_EVENT 4
47 #define OPENNSL_L2_CALLBACK_MOVE_EVENT 5
48 
49 typedef struct opennsl_l2_addr_s {
55  int port;
56  int modid;
64  int reserved7;
65  int reserved8;
67  int reserved10;
68  int reserved11;
79 /* __doxy_func_body_end__ */
80 
81 #define OPENNSL_L2_CACHE_CPU 0x00000001
82 #define OPENNSL_L2_CACHE_DISCARD 0x00000002
83 #define OPENNSL_L2_CACHE_BPDU 0x00000010
85 typedef struct opennsl_l2_cache_addr_s {
92  opennsl_port_t src_port;
94  opennsl_port_t src_port_mask;
99  int prio;
100  opennsl_pbmp_t dest_ports;
109 /* __doxy_func_body_end__ */
110 
111 /***************************************************************************/
126 extern void opennsl_l2_addr_t_init(
127  opennsl_l2_addr_t *l2addr,
128  const opennsl_mac_t mac_addr,
130 
131 #ifndef OPENNSL_HIDE_DISPATCHABLE
132 
133 /***************************************************************************/
148 extern int opennsl_l2_addr_add(
149  int unit,
151 
152 #endif /* OPENNSL_HIDE_DISPATCHABLE */
153 
154 #define OPENNSL_L2_DELETE_STATIC 0x00000001
155 #define OPENNSL_L2_DELETE_PENDING 0x00000002
156 #define OPENNSL_L2_DELETE_NO_CALLBACKS 0x00000004
157 #ifndef OPENNSL_HIDE_DISPATCHABLE
158 
159 /***************************************************************************/
176 extern int opennsl_l2_addr_delete(
177  int unit,
178  opennsl_mac_t mac,
180 
181 /***************************************************************************/
217  int unit,
218  opennsl_module_t mod,
220  uint32 flags) LIB_DLL_EXPORTED ;
221 
222 /***************************************************************************/
251  int unit,
252  opennsl_mac_t mac,
253  uint32 flags) LIB_DLL_EXPORTED ;
254 
255 /***************************************************************************/
289  int unit,
290  opennsl_vlan_t vid,
291  uint32 flags) LIB_DLL_EXPORTED ;
292 
293 /***************************************************************************/
327  int unit,
328  opennsl_trunk_t tid,
329  uint32 flags) LIB_DLL_EXPORTED ;
330 
331 /***************************************************************************/
364  int unit,
365  opennsl_mac_t mac,
366  opennsl_module_t mod,
368  uint32 flags) LIB_DLL_EXPORTED ;
369 
370 /***************************************************************************/
408  int unit,
409  opennsl_vlan_t vid,
410  opennsl_module_t mod,
412  uint32 flags) LIB_DLL_EXPORTED ;
413 
414 /***************************************************************************/
450  int unit,
451  opennsl_vlan_t vid,
452  opennsl_trunk_t tid,
453  uint32 flags) LIB_DLL_EXPORTED ;
454 
455 /***************************************************************************/
468 extern int opennsl_l2_addr_get(
469  int unit,
470  opennsl_mac_t mac_addr,
471  opennsl_vlan_t vid,
473 
474 #endif /* OPENNSL_HIDE_DISPATCHABLE */
475 
483  int unit,
484  opennsl_l2_addr_t *l2addr,
485  int operation,
486  void *userdata);
487 
488 #ifndef OPENNSL_HIDE_DISPATCHABLE
489 
490 /***************************************************************************/
506 extern int opennsl_l2_addr_register(
507  int unit,
508  opennsl_l2_addr_callback_t callback,
509  void *userdata) LIB_DLL_EXPORTED ;
510 
511 /***************************************************************************/
527 extern int opennsl_l2_addr_unregister(
528  int unit,
529  opennsl_l2_addr_callback_t callback,
530  void *userdata) LIB_DLL_EXPORTED ;
531 
532 /***************************************************************************/
555 extern int opennsl_l2_age_timer_set(
556  int unit,
557  int age_seconds) LIB_DLL_EXPORTED ;
558 
559 /***************************************************************************/
582 extern int opennsl_l2_age_timer_get(
583  int unit,
584  int *age_seconds) LIB_DLL_EXPORTED ;
585 
586 #endif /* OPENNSL_HIDE_DISPATCHABLE */
587 
588 #ifndef OPENNSL_HIDE_DISPATCHABLE
589 
590 /***************************************************************************/
612 extern int opennsl_l2_addr_freeze(
613  int unit) LIB_DLL_EXPORTED ;
614 
615 /***************************************************************************/
637 extern int opennsl_l2_addr_thaw(
638  int unit) LIB_DLL_EXPORTED ;
639 
640 /***************************************************************************/
651 extern int opennsl_l2_cache_init(
652  int unit) LIB_DLL_EXPORTED ;
653 
654 #endif /* OPENNSL_HIDE_DISPATCHABLE */
655 
656 /***************************************************************************/
666 extern void opennsl_l2_cache_addr_t_init(
668 
669 #ifndef OPENNSL_HIDE_DISPATCHABLE
670 
671 /***************************************************************************/
681 extern int opennsl_l2_cache_size_get(
682  int unit,
683  int *size) LIB_DLL_EXPORTED ;
684 
685 /***************************************************************************/
709 extern int opennsl_l2_cache_set(
710  int unit,
711  int index,
713  int *index_used) LIB_DLL_EXPORTED ;
714 
715 /***************************************************************************/
728 extern int opennsl_l2_cache_get(
729  int unit,
730  int index,
732 
733 /***************************************************************************/
743 extern int opennsl_l2_cache_delete(
744  int unit,
745  int index) LIB_DLL_EXPORTED ;
746 
747 /***************************************************************************/
756 extern int opennsl_l2_cache_delete_all(
757  int unit) LIB_DLL_EXPORTED ;
758 
759 #endif /* OPENNSL_HIDE_DISPATCHABLE */
760 
761 #ifndef OPENNSL_HIDE_DISPATCHABLE
762 
763 /***************************************************************************/
776 extern int opennsl_l2_tunnel_add(
777  int unit,
778  opennsl_mac_t mac,
780 
781 #endif /* OPENNSL_HIDE_DISPATCHABLE */
782 
783 #ifndef OPENNSL_HIDE_DISPATCHABLE
784 
785 #endif /* OPENNSL_HIDE_DISPATCHABLE */
786 
787 typedef int (*opennsl_l2_traverse_cb)(
788  int unit,
789  opennsl_l2_addr_t *info,
790  void *user_data);
791 
792 #ifndef OPENNSL_HIDE_DISPATCHABLE
793 
794 /***************************************************************************/
809 extern int opennsl_l2_traverse(
810  int unit,
811  opennsl_l2_traverse_cb trav_fn,
812  void *user_data) LIB_DLL_EXPORTED ;
813 
814 #endif /* OPENNSL_HIDE_DISPATCHABLE */
815 
816 #define OPENNSL_L2_REPLACE_MATCH_STATIC 0x00000001
817 #define OPENNSL_L2_REPLACE_MATCH_MAC 0x00000002
819 #define OPENNSL_L2_REPLACE_MATCH_VLAN 0x00000004
821 #define OPENNSL_L2_REPLACE_MATCH_DEST 0x00000008
824 #define OPENNSL_L2_REPLACE_DELETE 0x00000100
828 #define OPENNSL_L2_REPLACE_NO_CALLBACKS 0x00000800
830 #ifndef OPENNSL_HIDE_DISPATCHABLE
831 
832 /***************************************************************************/
871 extern int opennsl_l2_replace(
872  int unit,
873  uint32 flags,
874  opennsl_l2_addr_t *match_addr,
875  opennsl_module_t new_module,
876  opennsl_port_t new_port,
877  opennsl_trunk_t new_trunk) LIB_DLL_EXPORTED ;
878 
879 #endif /* OPENNSL_HIDE_DISPATCHABLE */
880 
882 typedef struct opennsl_l2_station_s {
891 /* __doxy_func_body_end__ */
892 
893 #define OPENNSL_L2_STATION_WITH_ID (1 << 0)
894 #define OPENNSL_L2_STATION_IPV4 (1 << 2)
896 #define OPENNSL_L2_STATION_IPV6 (1 << 3)
898 #define OPENNSL_L2_STATION_ARP_RARP (1 << 4)
900 /***************************************************************************/
910 extern void opennsl_l2_station_t_init(
912 
913 #ifndef OPENNSL_HIDE_DISPATCHABLE
914 
915 /***************************************************************************/
949 extern int opennsl_l2_station_add(
950  int unit,
951  int *station_id,
953 
954 /***************************************************************************/
964 extern int opennsl_l2_station_delete(
965  int unit,
966  int station_id) LIB_DLL_EXPORTED ;
967 
968 /***************************************************************************/
979 extern int opennsl_l2_station_get(
980  int unit,
981  int station_id,
983 
984 #endif /* OPENNSL_HIDE_DISPATCHABLE */
985 
986 #include <opennsl/l2X.h>
987 #endif /* __OPENNSL_L2_H__ */
988