Broadcom SDK and wireless driver: another attempt to update to ver. 5.10.147.0
[tomato.git] / release / src-rt / emf / igs / igsc.c
blob3a011d9d661b222059074a4abbd58ecf95502ec6
1 /*
2 * IGMP Snooping Layer: IGMP Snooping module runs at layer 2. IGMP
3 * Snooping layer uses the multicast information in the IGMP messages
4 * exchanged between the participating hosts and multicast routers to
5 * update the multicast forwarding database. This file contains the
6 * common code routines of IGS module.
8 * Copyright (C) 2009, Broadcom Corporation
9 * All Rights Reserved.
11 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
12 * the contents of this file may not be disclosed to third parties, copied
13 * or duplicated in any form, in whole or in part, without the prior
14 * written permission of Broadcom Corporation.
16 * $Id: igsc.c,v 1.4 2008/11/19 01:36:25 Exp $
19 #include <typedefs.h>
20 #include <bcmdefs.h>
21 #include <bcmendian.h>
22 #include <proto/bcmip.h>
23 #include <osl.h>
24 #include <bcmnvram.h>
25 #include <clist.h>
26 #if defined(linux)
27 #include <osl_linux.h>
28 #else /* defined(osl_xx) */
29 #error "Unsupported osl"
30 #endif /* defined(osl_xx) */
31 #include "igs_cfg.h"
32 #include "emfc_export.h"
33 #include "igs_export.h"
34 #include "igsc_export.h"
35 #include "igsc.h"
36 #include "igsc_sdb.h"
38 static mc_grp_spl_t mc_addr_rsvd[] =
40 { 0xe0000001, 0xffffffff }, /* All hosts */
41 { 0xe0000002, 0xffffffff }, /* All routers */
42 { 0xe0000004, 0xffffffff }, /* DVMRP routers */
43 { 0xe0000005, 0xffffffff }, /* OSPF1 routers */
44 { 0xe0000006, 0xffffffff }, /* OSPF2 routers */
45 { 0xe0000009, 0xffffffff }, /* RIP v2 routers */
46 { 0xe000000d, 0xffffffff }, /* PIMd routers */
47 { 0xe0000010, 0xffffffff }, /* IGMP v3 routers */
48 { 0xe00000fb, 0xffffffff }, /* Reserved */
49 { 0xe000ff87, 0xffffffff }, /* Reserved */
50 { 0xeffffffa, 0xffffffff }, /* UPnP */
53 static bool
54 igsc_is_reserved(uint32 addr)
56 int32 i;
58 for (i = 0; i < sizeof(mc_addr_rsvd)/sizeof(mc_grp_spl_t); i++)
60 if ((addr & mc_addr_rsvd[i].mask) ==
61 (mc_addr_rsvd[i].addr & mc_addr_rsvd[i].mask))
63 return (TRUE);
67 return (FALSE);
71 * Description: This function is called if the snooper doesn't receive
72 * membership query from a router for timeout interval.
73 * It deletes the router port entry from the list. If this
74 * is the last router on the interface then the EMF router
75 * port entry is also deleted.
77 * Input: rtlist_ptr - Multicast router interface/port entry
79 void
80 igsc_rtlist_timer(igsc_rtlist_t *rtlist_ptr)
82 clist_head_t *ptr;
83 igsc_rtlist_t *rtl_ptr;
84 bool mr_port_found = FALSE;
85 igsc_info_t *igsc_info;
87 igsc_info = rtlist_ptr->igsc_info;
89 /* Delete the expired router port entry */
90 clist_delete(&rtlist_ptr->list);
92 /* Check if there are more routers on this port/interface */
93 for (ptr = igsc_info->rtlist_head.next;
94 ptr != &igsc_info->rtlist_head; ptr = ptr->next)
96 rtl_ptr = clist_entry(ptr, igsc_rtlist_t, list);
97 if (rtl_ptr->ifp == rtlist_ptr->ifp)
99 mr_port_found = TRUE;
100 break;
104 /* Last multicast router on this port/interface */
105 if (!mr_port_found)
107 IGS_DEBUG("Delete the router port %p in the EMF\n",
108 rtlist_ptr->ifp);
109 emfc_rtport_del(igsc_info->emf_handle, rtlist_ptr->ifp);
112 MFREE(igsc_info->osh, rtlist_ptr, sizeof(igsc_rtlist_t));
114 return;
118 * Description: This function is called to find the entry in the router
119 * port list given the IP Address and the interface pointer.
121 * Input: igsc_info - IGSC Global Instance handle
122 * ifp - Interface pointer
123 * mr_ip - IP address of the router
125 * Return: Pointer to the entry found or NULL otherwise
127 static igsc_rtlist_t *
128 igsc_rtlist_find(igsc_info_t *igsc_info, void *ifp, uint32 mr_ip)
130 clist_head_t *ptr;
131 igsc_rtlist_t *rtl_ptr;
133 OSL_LOCK(igsc_info->rtlist_lock);
135 for (ptr = igsc_info->rtlist_head.next;
136 ptr != &igsc_info->rtlist_head; ptr = ptr->next)
138 rtl_ptr = clist_entry(ptr, igsc_rtlist_t, list);
140 if ((rtl_ptr->ifp == ifp) && (rtl_ptr->mr_ip == mr_ip))
142 OSL_UNLOCK(igsc_info->rtlist_lock);
143 IGS_DEBUG("Router port entry %x %p found\n",
144 mr_ip, ifp);
145 return (rtl_ptr);
149 OSL_UNLOCK(igsc_info->rtlist_lock);
151 return (NULL);
155 * Description: This function is called when the snooper receives IGMP
156 * membership query on one of the ports. It adds an entry
157 * to the multicast router port list. Each entry of the
158 * list contains the IP address of the multicast router
159 * and the interface/port on which it is present. It calls
160 * the EMF function to add a router port entry to the list
161 * maintained by EMF.
163 * Input: igsc_info - IGSC Global Instance handle
164 * ifp - Interface pointer
165 * mr_ip - IP address of the router
167 * Return: SUCCESS/FAILURE
169 int32
170 igsc_rtlist_add(igsc_info_t *igsc_info, void *ifp, uint32 mr_ip)
172 igsc_rtlist_t *rtlist_ptr;
174 /* If the router port list entry exists already then refresh the
175 * timer for this entry.
177 if ((rtlist_ptr = igsc_rtlist_find(igsc_info, ifp, mr_ip)) != NULL)
179 osl_timer_update(rtlist_ptr->rtlist_timer, igsc_info->query_intv,
180 FALSE);
181 IGS_DEBUG("Duplicate router port entry %x %p\n", mr_ip, ifp);
182 return (FAILURE);
185 /* Allocate and intialize the entry */
186 rtlist_ptr = MALLOC(igsc_info->osh, sizeof(igsc_rtlist_t));
187 if (rtlist_ptr == NULL)
189 IGS_ERROR("Failed to allocate memory size %d for rtport list\n",
190 sizeof(igsc_rtlist_t));
191 return (FAILURE);
194 rtlist_ptr->ifp = ifp;
195 rtlist_ptr->mr_ip = mr_ip;
196 rtlist_ptr->igsc_info = igsc_info;
198 OSL_LOCK(igsc_info->rtlist_lock);
200 /* Add the entry to the EMF router port list */
201 if (emfc_rtport_add(igsc_info->emf_handle, ifp) != SUCCESS)
203 OSL_UNLOCK(igsc_info->rtlist_lock);
204 MFREE(igsc_info->osh, rtlist_ptr, sizeof(igsc_rtlist_t));
205 IGS_ERROR("Failed to add EMF rtport entry for %p\n", ifp);
206 return (FAILURE);
209 /* Add timer to delete the entry on igmp query timeout */
210 rtlist_ptr->rtlist_timer = osl_timer_init("MR_PORT_LIST_TIMER",
211 (void (*)(void *))igsc_rtlist_timer,
212 (void *)rtlist_ptr);
214 if (rtlist_ptr->rtlist_timer == NULL)
216 OSL_UNLOCK(igsc_info->rtlist_lock);
217 emfc_rtport_del(igsc_info->emf_handle, ifp);
218 MFREE(igsc_info->osh, rtlist_ptr, sizeof(igsc_rtlist_t));
219 IGS_ERROR("Failed to allocate memory size %d for timer\n",
220 sizeof(osl_timer_t));
221 return (FAILURE);
224 osl_timer_add(rtlist_ptr->rtlist_timer, igsc_info->query_intv, FALSE);
226 /* Add the entry to IGS router port list */
227 clist_add_head(&igsc_info->rtlist_head, &rtlist_ptr->list);
229 OSL_UNLOCK(igsc_info->rtlist_lock);
231 return (SUCCESS);
235 * Description: This function is called to clear the IGSC router port list.
236 * It also call the API to delete the corresponding EMF router
237 * port entry.
239 * Input: igsc_info - IGSC Global Instance handle
241 static void
242 igsc_rtlist_clear(igsc_info_t *igsc_info)
244 clist_head_t *ptr;
245 igsc_rtlist_t *rtl_ptr;
247 OSL_LOCK(igsc_info->rtlist_lock);
249 for (ptr = igsc_info->rtlist_head.next;
250 ptr != &igsc_info->rtlist_head; ptr = ptr->next)
252 rtl_ptr = clist_entry(ptr, igsc_rtlist_t, list);
253 osl_timer_del(rtl_ptr->rtlist_timer);
254 emfc_rtport_del(igsc_info->emf_handle, rtl_ptr->ifp);
255 clist_delete(ptr);
256 MFREE(igsc_info->osh, rtl_ptr, sizeof(igsc_rtlist_t));
259 OSL_UNLOCK(igsc_info->rtlist_lock);
261 return;
265 * Description: This function is called by EMFL when an IGMP frame
266 * is received. Based on the IGMP packet type it either
267 * adds, deletes or refreshes the MFDB entry.
269 * Input: s - Snooper global instance data cookie
270 * ifp - Pointer to interface the frame arrived on.
271 * iph - Points to start of IP header in the packet.
272 * igmph - Points to start of IGMP header in the packet.
273 * from_rp - TRUE when received from router port.
275 * Return: EMF_FLOOD - Flood the frame.
276 * EMF_SENDUP - Deliver the packet to IP layer.
278 static int32
279 igsc_input(emfc_snooper_t *s, void *ifp, uint8 *iph, uint8 *igmph, bool from_rp)
281 int32 ret = FAILURE;
282 igsc_info_t *igsc_info;
283 uint32 mgrp_ip, mh_ip, dest_ip;
285 ASSERT(s != NULL);
287 igsc_info = IGSC_INFO(s);
289 IGSC_STATS_INCR(igsc_info, igmp_packets);
291 if (from_rp)
293 IGS_DEBUG("Ignoring IGMP frame from router port\n");
294 IGSC_STATS_INCR(igsc_info, igmp_not_handled);
295 return (EMF_FLOOD);
298 mgrp_ip = ntoh32(*((uint32 *)(igmph + IGMPV2_GRP_ADDR_OFFSET)));
299 mh_ip = ntoh32(*((uint32 *)(iph + IPV4_SRC_IP_OFFSET)));
301 switch (igmph[IGMPV2_TYPE_OFFSET])
303 case IGMPV2_HOST_NEW_MEMBERSHIP_REPORT:
304 /* Ignore frames received with reserved addresses */
305 dest_ip = ntoh32(*((uint32 *)(iph + IPV4_DEST_IP_OFFSET)));
306 if (igsc_is_reserved(dest_ip))
308 IGSC_STATS_INCR(igsc_info, igmp_not_handled);
309 IGS_DEBUG("Reserved multicast address %x frame\n",
310 dest_ip);
311 return (EMF_FLOOD);
314 /* When a host membership report is received add/refresh the
315 * entry for the host.
317 IGSC_STATS_INCR(igsc_info, igmp_v2reports);
318 ret = igsc_sdb_member_add(igsc_info, ifp, mgrp_ip, mh_ip);
320 return ((ret == SUCCESS) ? EMF_FORWARD : EMF_FLOOD);
322 case IGMPV2_LEAVE_GROUP_MESSAGE:
323 /* Remove group entry for the host when a leave message is
324 * received.
326 IGSC_STATS_INCR(igsc_info, igmp_leaves);
327 ret = igsc_sdb_member_del(igsc_info, ifp, mgrp_ip, mh_ip);
329 if (ret != SUCCESS)
330 IGS_WARN("Deleting unknown member with grp %x host %x if %p",
331 mgrp_ip, mh_ip, ifp);
332 break;
334 case IGMPV2_HOST_MEMBERSHIP_REPORT:
335 IGSC_STATS_INCR(igsc_info, igmp_reports);
336 break;
338 case IGMPV2_HOST_MEMBERSHIP_QUERY:
339 IGSC_STATS_INCR(igsc_info, igmp_queries);
341 /* Update the multicast router port list */
342 if (mh_ip != 0)
344 IGS_DEBUG("Updating router port list with %x %p\n",
345 mh_ip, ifp);
346 igsc_rtlist_add(igsc_info, ifp, mh_ip);
348 break;
350 default:
351 IGS_WARN("IGMP type %d not handled\n", igmph[IGMPV2_TYPE_OFFSET]);
352 IGSC_STATS_INCR(igsc_info, igmp_not_handled);
353 break;
356 return (EMF_FLOOD);
360 * Internet checksum routine
362 static uint16
363 inet_cksum(uint8 *buf, int32 len)
365 uint32 sum = 0;
366 uint16 val;
368 while (len > 1)
370 val = *buf++ << 8;
371 val |= *buf++;
372 sum += val;
373 len -= 2;
376 if (len > 0)
378 sum += (*buf) << 8;
381 while (sum >> 16)
383 sum = (sum & 0xffff) + (sum >> 16);
386 return (hton16(~sum));
390 * Description: This function adds the IP header, IGMP header and data.
392 static void
393 igsc_igmp_pkt_encap(uint8 *ip, uint32 src_ip, uint32 dest_ip,
394 uint8 igmp_type, uint8 max_rsp, uint32 grp_addr)
396 uint8 *igmp;
398 /* Prepare the IP header */
399 ip[IP_VER_OFFSET] = ((IP_VER_4 << 4) | (IPV4_MIN_HLEN >> 2));
400 ip[IPV4_TOS_OFFSET] = 0xc0;
401 *((uint16 *)(ip + IPV4_LEN_OFFSET)) = hton16(IPV4_MIN_HLEN + IGMP_HLEN);
402 *((uint16 *)(ip + IPV4_ID_OFFSET)) = 0;
403 *((uint16 *)(ip + IPV4_FRAG_OFFSET)) = 0;
404 ip[IPV4_TTL_OFFSET] = 1;
405 ip[IPV4_PROT_OFFSET] = IP_PROT_IGMP;
406 *((uint16 *)(ip + IPV4_CHKSUM_OFFSET)) = 0;
407 *((uint32 *)(ip + IPV4_SRC_IP_OFFSET)) = src_ip;
408 *((uint32 *)(ip + IPV4_DEST_IP_OFFSET)) = dest_ip;
409 *((uint16 *)(ip + IPV4_CHKSUM_OFFSET)) = inet_cksum(ip, IPV4_MIN_HLEN);
411 /* Fill the IGMP header fields */
412 igmp = ip + IPV4_MIN_HLEN;
413 igmp[IGMPV2_TYPE_OFFSET] = igmp_type;
414 igmp[IGMPV2_MAXRSP_TIME_OFFSET] = max_rsp;
415 *((uint16 *)(igmp + IGMPV2_CHECKSUM_OFFSET)) = 0;
416 *((uint32 *)(igmp + IGMPV2_GRP_ADDR_OFFSET)) = grp_addr;
417 *((uint16 *)(igmp + IGMPV2_CHECKSUM_OFFSET)) = inet_cksum(ip,
418 IGMP_HLEN + IPV4_MIN_HLEN);
420 return;
424 * Description: This functions generates an IGMP Query. It is used to
425 * quickly determine the group members on the attached bridge
426 * ports.
428 * Return: SUCCESS or FAILURE
430 static int32
431 igsc_igmp_query_send(igsc_info_t *igsc_info)
433 uint32 ip[64];
434 uint32 lan_ip = 0;
436 /* Build the IGMP Query packet */
437 igsc_igmp_pkt_encap((uint8 *)ip, lan_ip, hton32(IPV4_MCADDR_ALLHOSTS),
438 IGMPV2_HOST_MEMBERSHIP_QUERY, IGMPV2_MAXRSP_TIME / 100, 0);
440 IGS_DEBUG("Forwarding IGMP Query on to bridge ports\n");
442 return (igsc_info->wrapper.igs_broadcast(igsc_info->igs_info, (uint8 *)ip,
443 IGMP_HLEN + IPV4_MIN_HLEN,
444 IPV4_MCADDR_ALLHOSTS));
448 * Description: This function is called by the EMFL when forwarding
449 * is enabled.
451 * Input: snooper - Snooper gloabl instance data.
453 * Return: SUCCESS or FAILURE
455 static int32
456 igsc_emf_enabled(emfc_snooper_t *snooper)
458 IGS_INFO("EMF enable callback called\n");
460 /* Send an IGMP Query packet to quickly learn the members present
461 * in the network.
463 if (igsc_igmp_query_send(IGSC_INFO(snooper)) != SUCCESS)
465 IGS_ERROR("IGMP Query send failed\n");
466 return (FAILURE);
469 return (SUCCESS);
473 * Description: This function is called by the EMFL when forwarding
474 * is disabled.
476 * Input: snooper - Snooper gloabl instance data.
478 * Return: SUCCESS or FAILURE
480 static int32
481 igsc_emf_disabled(emfc_snooper_t *snooper)
483 IGS_INFO("EMF disable callback\n");
484 igsc_sdb_clear(IGSC_INFO(snooper));
485 igsc_rtlist_clear(IGSC_INFO(snooper));
486 return (SUCCESS);
490 * IGSL Packet Counters/Statistics Function
492 int32
493 igsc_stats_get(igsc_info_t *igsc_info, igs_stats_t *stats, uint32 size)
495 if (igsc_info == NULL)
497 IGS_ERROR("Invalid IGSC handle passed\n");
498 return (FAILURE);
501 if (stats == NULL)
503 IGS_ERROR("Invalid buffer input\n");
504 return (FAILURE);
507 if (size < sizeof(igs_stats_t))
509 IGS_ERROR("Insufficient buffer size %d\n", size);
510 return (FAILURE);
513 *stats = igsc_info->stats;
515 return (SUCCESS);
519 * RTPORT Interface Listing
521 static int32
522 igsc_rtport_list(igsc_info_t *igsc, igs_cfg_rtport_list_t *list, uint32 size)
524 int32 index = 0, bytes = 0;
525 clist_head_t *ptr;
526 igsc_rtlist_t *rtl_ptr;
528 for (ptr = igsc->rtlist_head.next; ptr != &igsc->rtlist_head; ptr = ptr->next)
530 rtl_ptr = clist_entry(ptr, igsc_rtlist_t, list);
532 bytes += sizeof(igs_cfg_rtport_list_t);
533 if (bytes > size)
534 return (FAILURE);
536 list->rtport_entry[index].mr_ip = rtl_ptr->mr_ip;
537 strncpy(list->rtport_entry[index].if_name, DEV_IFNAME(rtl_ptr->ifp), 16);
538 index++;
541 /* Update the total number of entries */
542 list->num_entries = index;
544 return (SUCCESS);
547 void
548 igsc_cfg_request_process(igsc_info_t *igsc_info, igs_cfg_request_t *cfg)
550 IGS_DEBUG("IGS command identifier: %d\n", cfg->command_id);
552 switch (cfg->command_id)
554 case IGSCFG_CMD_IGS_STATS:
555 if (igsc_stats_get(igsc_info, (igs_stats_t *)cfg->arg,
556 cfg->size) != SUCCESS)
558 cfg->status = IGSCFG_STATUS_FAILURE;
559 cfg->size = sprintf(cfg->arg, "IGS stats get failed\n");
560 break;
562 cfg->status = IGSCFG_STATUS_SUCCESS;
563 break;
565 case IGSCFG_CMD_IGSDB_LIST:
566 if (igsc_sdb_list(igsc_info, (igs_cfg_sdb_list_t *)cfg->arg,
567 cfg->size) != SUCCESS)
569 cfg->status = IGSCFG_STATUS_FAILURE;
570 cfg->size = sprintf(cfg->arg, "IGSDB listing failed\n");
571 break;
573 cfg->status = IGSCFG_STATUS_SUCCESS;
574 break;
576 case IGSCFG_CMD_RTPORT_LIST:
577 if (igsc_rtport_list(igsc_info, (igs_cfg_rtport_list_t *)cfg->arg,
578 cfg->size) != SUCCESS)
580 cfg->status = EMFCFG_STATUS_FAILURE;
581 cfg->size = sprintf(cfg->arg, "RTPORT list get failed\n");
582 break;
584 cfg->status = EMFCFG_STATUS_SUCCESS;
585 break;
587 default:
588 cfg->status = IGSCFG_STATUS_CMD_UNKNOWN;
589 cfg->size = sprintf(cfg->arg, "Unknown command id %d\n",
590 cfg->command_id);
591 break;
596 * Description: This function is called from the OS specific module
597 * init routine to initialize the IGSL. This function
598 * primarily initializes the IGSL global data and IGSDB.
600 * Input: inst_id - IGS instance identifier.
601 * igs_info - IGSL OS Specific global data handle
602 * osh - OS abstraction layer handle
603 * wrapper - wrapper specific info
605 * Return: igsc_info - IGSL Common code global data handle
607 void *
608 igsc_init(int8 *inst_id, void *igs_info, osl_t *osh, igsc_wrapper_t *wrapper)
610 igsc_info_t *igsc_info;
612 if (inst_id == NULL)
614 IGS_ERROR("Instance identifier NULL\n");
615 return (NULL);
618 if (wrapper == NULL)
620 IGS_ERROR("wrapper info NULL\n");
621 return (NULL);
624 IGS_DEBUG("Initializing IGMP Snooping Layer\n");
626 /* Allocate memory */
627 igsc_info = MALLOC(osh, sizeof(igsc_info_t));
628 if (igsc_info == NULL)
630 IGS_ERROR("Failed to allocated memory size %d for MFL\n",
631 sizeof(igsc_info_t));
632 return (NULL);
635 IGS_DEBUG("Allocated memory for IGSC info\n");
637 /* Initialize the IGS global data */
638 bzero(igsc_info, sizeof(igsc_info_t));
639 igsc_info->osh = osh;
640 igsc_info->igs_info = igs_info;
641 igsc_info->grp_mem_intv = IGMPV2_GRP_MEM_INTV;
642 igsc_info->query_intv = IGMPV2_QUERY_INTV;
644 /* Fill in the wrapper specific data */
645 igsc_info->wrapper.igs_broadcast = wrapper->igs_broadcast;
647 /* Initialize the IGSDB */
648 igsc_sdb_init(igsc_info);
650 igsc_info->sdb_lock = OSL_LOCK_CREATE("SDB Lock");
652 if (igsc_info->sdb_lock == NULL)
654 igsc_sdb_clear(igsc_info);
655 MFREE(osh, igsc_info, sizeof(igsc_info_t));
656 return (NULL);
659 /* Register IGMP v2 Snooper with EMFL */
660 igsc_info->snooper.input_fn = igsc_input;
661 igsc_info->snooper.emf_enable_fn = igsc_emf_enabled;
662 igsc_info->snooper.emf_disable_fn = igsc_emf_disabled;
664 if (emfc_igmp_snooper_register(inst_id, &igsc_info->emf_handle,
665 &igsc_info->snooper) != SUCCESS)
667 IGS_ERROR("IGMP Snooper couldn't register with EMF\n");
668 igsc_sdb_clear(igsc_info);
669 OSL_LOCK_DESTROY(igsc_info->sdb_lock);
670 MFREE(osh, igsc_info, sizeof(igsc_info_t));
671 return (NULL);
674 /* Initialize router port list head */
675 clist_init_head(&igsc_info->rtlist_head);
677 igsc_info->rtlist_lock = OSL_LOCK_CREATE("Router List Lock");
679 if (igsc_info->rtlist_lock == NULL)
681 emfc_igmp_snooper_unregister(igsc_info->emf_handle);
682 igsc_sdb_clear(igsc_info);
683 OSL_LOCK_DESTROY(igsc_info->sdb_lock);
684 MFREE(osh, igsc_info, sizeof(igsc_info_t));
685 return (NULL);
688 IGS_DEBUG("Initialized IGSDB\n");
690 return (igsc_info);
694 * Description: This function is called from OS specific module cleanup
695 * routine. This routine primarily stops the group interval
696 * timers and cleans up the IGSDB entries.
698 void
699 igsc_exit(igsc_info_t *igsc_info)
701 emfc_igmp_snooper_unregister(igsc_info->emf_handle);
703 /* Cleanup the IGS router port list entries */
704 igsc_rtlist_clear(igsc_info);
705 OSL_LOCK_DESTROY(igsc_info->rtlist_lock);
707 /* Cleanup the IGSDB */
708 igsc_sdb_clear(igsc_info);
709 OSL_LOCK_DESTROY(igsc_info->sdb_lock);
711 MFREE(igsc_info->osh, igsc_info, sizeof(igsc_info_t));
713 IGS_DEBUG("Cleaned up IGSL, exiting common code\n");
715 return;
720 * Description: This function is called to delete the IGSDB
721 * rtport entries on an interface
723 * Input: igsc_info - igsc info pointer
724 * ifp - interface pointer
726 * Return: SUCCESS or FAILURE
728 int32
729 igsc_interface_rtport_del(igsc_info_t *igsc_info, void *ifp)
731 clist_head_t *ptr, *tmp;
732 igsc_rtlist_t *rtl_ptr;
734 OSL_LOCK(igsc_info->rtlist_lock);
736 for (ptr = igsc_info->rtlist_head.next;
737 ptr != &igsc_info->rtlist_head; ptr = tmp)
739 rtl_ptr = clist_entry(ptr, igsc_rtlist_t, list);
741 tmp = ptr->next;
742 if (rtl_ptr->ifp == (igsc_rtlist_t *)ifp)
744 IGS_DEBUG("Router port entry %p found\n");
745 emfc_rtport_del(igsc_info->emf_handle, rtl_ptr->ifp);
746 clist_delete(ptr);
747 MFREE(igsc_info->osh, rtl_ptr, sizeof(igsc_rtlist_t));
751 OSL_UNLOCK(igsc_info->rtlist_lock);
753 return SUCCESS;