GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / include / emf / emf / emfc_export.h
blobd4781242d857d49aeef74416583a20254cae74fe
1 /*
2 * Copyright (C) 2012, Broadcom Corporation
3 * All Rights Reserved.
4 *
5 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
6 * the contents of this file may not be disclosed to third parties, copied
7 * or duplicated in any form, in whole or in part, without the prior
8 * written permission of Broadcom Corporation.
10 * $Id: emfc_export.h 246051 2011-03-12 03:30:44Z $
13 #ifndef _EMFC_EXPORT_H_
14 #define _EMFC_EXPORT_H_
16 #include <emf/emf/emf_cfg.h>
18 #define SUCCESS 0
19 #define FAILURE -1
21 #define EMF_DROP 0
22 #define EMF_FORWARD 1
23 #define EMF_NOP 1
24 #define EMF_TAKEN 2
25 #define EMF_FLOOD 10
26 #define EMF_SENDUP 11
27 #define EMF_CONVERT_QUERY 12
29 #ifdef EMFDBG
31 #define EMF_LOG_DEBUG (1 << 0)
32 #define EMF_LOG_ERROR (1 << 1)
33 #define EMF_LOG_WARN (1 << 2)
34 #define EMF_LOG_INFO (1 << 3)
35 #define EMF_LOG_MFDB (1 << 4)
37 #define EMF_LOG_LVL (EMF_LOG_ERROR | \
38 EMF_LOG_WARN | \
39 EMF_LOG_DEBUG | \
40 EMF_LOG_INFO | \
41 EMF_LOG_MFDB)
43 #if (EMF_LOG_LVL & EMF_LOG_DEBUG)
44 #define EMF_DEBUG(fmt, args...) printf("EMF_DEBUG: " fmt, ##args)
45 #else /* EMF_LOG_LVL & EMF_LOG_DEBUG */
46 #define EMF_DEBUG(fmt, args...)
47 #endif /* EMF_LOG_LVL & EMF_LOG_DEBUG */
49 #if (EMF_LOG_LVL & EMF_LOG_ERROR)
50 #define EMF_ERROR(fmt, args...) printf("EMF_ERROR: " fmt, ##args)
51 #else /* EMF_LOG_LVL & EMF_LOG_ERROR */
52 #define EMF_ERROR(fmt, args...)
53 #endif /* EMF_LOG_LVL & EMF_LOG_ERROR */
55 #if (EMF_LOG_LVL & EMF_LOG_WARN)
56 #define EMF_WARN(fmt, args...) printf("EMF_WARN.: " fmt, ##args)
57 #else /* EMF_LOG_LVL & EMF_LOG_WARN */
58 #define EMF_WARN(fmt, args...)
59 #endif /* EMF_LOG_LVL & EMF_LOG_WARN */
61 #if (EMF_LOG_LVL & EMF_LOG_INFO)
62 #define EMF_INFO(fmt, args...) printf("EMF_INFO.: " fmt, ##args)
63 #else /* EMF_LOG_LVL & EMF_LOG_INFO */
64 #define EMF_INFO(fmt, args...)
65 #endif /* EMF_LOG_LVL & EMF_LOG_INFO */
67 #if (EMF_LOG_LVL & EMF_LOG_MFDB)
68 #define EMF_MFDB(fmt, args...) printf("EMF_MFDB.: " fmt, ##args)
69 #else /* EMF_LOG_LVL & EMF_LOG_MFDB */
70 #define EMF_MFDB(fmt, args...)
71 #endif /* EMF_LOG_LVL & EMF_LOG_MFDB */
73 #else /* EMFDBG */
75 #define EMF_DEBUG(fmt, args...)
76 #define EMF_ERROR(fmt, args...) printf(fmt, ##args)
77 #define EMF_WARN(fmt, args...)
78 #define EMF_INFO(fmt, args...)
79 #define EMF_MFDB(fmt, args...)
81 #endif /* EMFDBG */
83 /* Function pointer declarations */
84 typedef int32 (*forward_fn_ptr)(void *, void *, uint32, void *, bool);
85 typedef void (*sendup_fn_ptr)(void *, void *);
86 typedef int32 (*hooks_register_fn_ptr)(void *);
87 typedef int32 (*hooks_unregister_fn_ptr)(void *);
90 * Snooper
92 typedef struct emfc_snooper
94 /* Input function called when an IGMP packet is received by
95 * EMFL.
97 int32 (*input_fn)(struct emfc_snooper *snooper, void *ifp,
98 uint8 *iph, uint8 *igmph, bool rt_port);
100 /* Function called when EMF is enabled */
101 int32 (*emf_enable_fn)(struct emfc_snooper *snooper);
103 /* Function called when EMF is disabled */
104 int32 (*emf_disable_fn)(struct emfc_snooper *snooper);
105 } emfc_snooper_t;
108 * Wrapper specific functions
110 typedef struct emfc_wrapper
112 /* Function called to forward frames on a specific interface */
113 int32 (*forward_fn)(void *wrapper, void *p, uint32 mgrp_ip,
114 void *txif, bool rt_port);
116 /* Function called to send packet up the stack */
117 void (*sendup_fn)(void *wrapper, void *p);
119 /* Function called to register hooks into the bridge */
120 int32 (*hooks_register_fn)(void *wrapper);
122 /* Function called to unregister hooks into the bridge */
123 int32 (*hooks_unregister_fn)(void *wrapper);
124 } emfc_wrapper_t;
126 struct emfc_info;
129 * Description: This function is called from the OS specific module init
130 * routine to initialize the EMFL. This function primarily
131 * initializes the EMFL global data and MFDB.
133 * Input: inst_id - Instance identier used to associate EMF and
134 * IGMP snooper instances.
135 * emfi - EMFL OS Specific global data handle
136 * osh - OS abstraction layer handle
137 * wrapper - Wrapper specific info
139 * Return: emfc - EMFL Common code global instance handle
141 extern struct emfc_info * emfc_init(int8 *inst_id, void *emfi, osl_t *osh, emfc_wrapper_t *wrapper);
144 * Description: This function is called from OS specific module exit
145 * routine. This routine primarily clears the MFDB and
146 * frees the EMF instance data.
148 * Input: emfc - EMFL Common code global instance handle
150 extern void emfc_exit(struct emfc_info *emfc);
153 * Description: This function is called by the OS specific EMFL code
154 * for every frame seen at the bridge pre and ip post hook
155 * points. It calls the registered snooper input function
156 * if the received frame type is an IGMP frame. For multicast
157 * data frames it handles the frame forwarding. The frame
158 * forwarding is done based on the information stored in
159 * the MFDB. MFDB is updated by IGMP snooper module.
161 * Input: emfc - EMFL Common code Global instance handle
162 * sdu - Pointer to packet buffer.
163 * ifp - Interface on which the packet arrived.
164 * iph - Pointer to start of IP header. When IGMP
165 * frame is input, it is assumed that the IP
166 * header and IGMP header are contiguos.
167 * rt_port - TRUE when the packet is received from IP
168 * Stack, FALSE otherwise.
170 * Return: EMF_NOP - No processing needed by EMF, just return
171 * the packet back.
172 * EMF_TAKEN - EMF has taken the ownership of the packet.
173 * EMF_DROP - Indicates the packet should be dropped.
175 extern uint32 emfc_input(struct emfc_info *emfc, void *sdu, void *ifp,
176 uint8 *iph, bool rt_port);
179 * Description: This function is called to add MFDB entry. Each MFDB entry
180 * contains the multicast group address and list of interfaces
181 * that has participating group members. The caller of the
182 * function needs to make sure to delete the entry as many
183 * times as add is done.
185 * Input: emfc - EMFL Common code global instance handle
186 * mgrp_ip - Multicast group IP address of the entry.
187 * ifp - Pointer to the interface on which the member
188 * is present.
190 * Return: SUCCESS or FAILURE
192 extern int32 emfc_mfdb_membership_add(struct emfc_info *emfc, uint32 mgrp_ip, void *ifp);
195 * Description: This function is called by the IGMP snooper layer to delete
196 * the MFDB entry. It deletes the group entry also if the
197 * interface entry is last in the group.
199 * Input: Same as above function.
201 * Return: SUCCESS or FAILURE
203 extern int32 emfc_mfdb_membership_del(struct emfc_info *emfc, uint32 mgrp_ip, void *ifp);
206 * Description: This function is called by the IGMP snooper layer to
207 * register snooper instance with EMFL.
209 * Input: inst_id - Instance identier used to associate EMF
210 * and IGMP snooper instances.
211 * emfc - EMFL Common code global instance handle
212 * snooper - Contains snooper specific parameters and
213 * event callback functions. These functions
214 * are called by EMFL on events like IGMP
215 * packet receive, EMF enable and disable.
216 * The snooper parameter needs to global.
218 * Return: SUCCESS or FAILURE
220 extern int32 emfc_igmp_snooper_register(int8 *inst_id, struct emfc_info **emfc,
221 emfc_snooper_t *snooper);
224 * Description: This function is called by the IGMP snooper layer to
225 * unregister snooper instance.
227 * Input: handle - Handle returned during registration.
228 * snooper - Same as above.
230 extern void emfc_igmp_snooper_unregister(struct emfc_info *emfc);
233 * Description: This function is called from the OS Specific layer when
234 * user issues a configuration command.
236 * Input: emfc - EMFL Common code global instance handle
238 * Input/Output: cfg - Pointer to configuration request data. It
239 * contains the command id, operation type,
240 * corresponding arguments and output status.
242 extern void emfc_cfg_request_process(struct emfc_info *emfc, emf_cfg_request_t *cfg);
245 * Description: This function is called from OS specific module init
246 * routine. It allocates global resources required by the
247 * common code.
249 * Return: SUCCESS or FAILURE
251 extern int32 emfc_module_init(void);
254 * Description: This function is called from OS specific module cleanup
255 * routine. It frees all the global resources.
257 extern void emfc_module_exit(void);
260 * Description: This function is called by the IGMP Snooper to add a Router
261 * Port. Router Port is the interface on which the IGMP Snooper
262 * determines that a multicast router is present. We set a bit
263 * in the flag field of the interface list entry to mark it as
264 * router port.
266 * Input: emfc - EMFC Global Instance handle
267 * ifp - Interface pointer
269 * Return: SUCCESS or FAILURE
271 extern int32 emfc_rtport_add(struct emfc_info *emfc, void *ifp);
274 * Description: This function is called by the IGMP Snooper to delete a
275 * Router Port. We clear the corresponding bit in the flags
276 * field to mark the port as non-router port.
278 * Input: emfc - EMFC Global Instance handle
279 * ifp - Interface pointer
281 * Return: SUCCESS or FAILURE
283 extern int32 emfc_rtport_del(struct emfc_info *emfc, void *ifp);
286 * Description: This function is called by OS Specific layer when user issues
287 * configuration command to add an interface. It adds an entry to
288 * the global interface list maintained by EMFC.
290 * Input: emfc - EMFC Global Instance handle
291 * ifp - Interface pointer
293 extern int32 emfc_iflist_add(struct emfc_info *emfc, void *ifp);
296 * Description: This function is called by OS Specific layer when user issues
297 * configuration command to delete an interface. It removes an
298 * entry from the global interface list maintained by EMFC.
300 * Input: emfc - EMFC Global Instance handle
301 * ifp - Interface pointer
303 extern int32 emfc_iflist_del(struct emfc_info *emfc, void *ifp);
305 #endif /* _EMFC_EXPORT_H_ */