int sal_config_file_set(const char *fname, const char *tname) { if (sal_config_file_name != NULL) { sal_free(sal_config_file_name); sal_config_file_name = NULL; } if (sal_config_temp_name != NULL) { sal_free(sal_config_temp_name); sal_config_temp_name = NULL; } if (fname != NULL) { sal_config_file_name = sal_strdup(fname); if (fname[0] != 0) { if (tname == NULL || tname[0] == 0) { return -1; } sal_config_temp_name = sal_strdup(tname); } } return 0; }
/* * Function: * soc_robo_dos_monitor_init (internal) * Purpose: * dos monitor init * Parameters: * unit - unit number. * interval - time between resynchronization passes * Returns: * SOC_E_INTERNAL if can't create threads. */ int soc_robo_dos_monitor_init(int unit) { drv_robo_dos_monitor_t *dm; if (drv_dm_control[unit] != NULL){ SOC_IF_ERROR_RETURN(soc_robo_dos_monitor_deinit(unit)); } if ((dm = sal_alloc(sizeof(drv_robo_dos_monitor_t), "dos_monitor")) == NULL){ return SOC_E_MEMORY; } /* allocate dm and set init value */ sal_memset(dm, 0, sizeof (drv_robo_dos_monitor_t)); dm->dm_lock = sal_mutex_create("soc_dos_monitor_lock"); if (dm->dm_lock == NULL){ sal_free(dm); return SOC_E_MEMORY; } dm->dm_sema = sal_sem_create("robo_HWDOS_MONITOR_SLEEP", sal_sem_BINARY, 0); if (dm->dm_sema == NULL) { sal_mutex_destroy(dm->dm_lock); sal_free(dm); return SOC_E_MEMORY; } dm->dm_thread = NULL; drv_dm_control[unit] = dm; return SOC_E_NONE; }
int soc_mmu_error_init(int unit) { soc_control_t *soc = SOC_CONTROL(unit); soc_mmu_error_t *mmu_errors; soc_port_t port; uint32 regval; int rv; /* Don't want any interrupts from MMU until initialized */ /* This will be turned on by soc_mmu_init in drv.c */ soc_pci_write(unit, CMIC_MMUIRQ_MASK, 0); /* Free if allocated ... */ if (soc->mmu_errors) { sal_free(soc->mmu_errors); } mmu_errors = sal_alloc(sizeof(soc_mmu_error_t) * SOC_MAX_NUM_PORTS, "MMU error counters"); if (mmu_errors == NULL) { return SOC_E_MEMORY; } sal_memset(mmu_errors, 0, sizeof(soc_mmu_error_t) * SOC_MAX_NUM_PORTS); PBMP_ALL_ITER(unit, port) { mmu_errors[port].xq_parity = 0; mmu_errors[port].lla_parity = 0; mmu_errors[port].upk_parity = 0; mmu_errors[port].ing_parity = 0; mmu_errors[port].egr_parity = 0; if ((rv = READ_MMU_PP_SBE_CNTr(unit, port, ®val)) < 0) { sal_free(mmu_errors); return rv; } mmu_errors[port].pp_sbe_blocks = mmu_errors[port].pp_sbe_blocks_init = soc_reg_field_get(unit, MMU_PP_SBE_CNTr, regval, BLOCKCOUNTf); mmu_errors[port].pp_sbe_cells = mmu_errors[port].pp_sbe_cells_init = soc_reg_field_get(unit, MMU_PP_SBE_CNTr, regval, CELLCOUNTf); if ((rv = READ_MMU_PP_DBE_CNTr(unit, port, ®val)) < 0) { sal_free(mmu_errors); return rv; } mmu_errors[port].pp_dbe_blocks = mmu_errors[port].pp_dbe_blocks_init = soc_reg_field_get(unit, MMU_PP_DBE_CNTr, regval, BLOCKCOUNTf); mmu_errors[port].pp_dbe_cells = mmu_errors[port].pp_dbe_cells_init = soc_reg_field_get(unit, MMU_PP_DBE_CNTr, regval, CELLCOUNTf); }
/* Free hash memory. You may call hash_clean before call this function. */ void ctclib_hash_free (ctclib_hash_t *hash) { sal_free (hash->index); sal_free (hash); return; }
int bcm_pkt_clear(int unit, bcm_pkt_t *pkt, bcm_pkt_blk_t *blks, int blk_count, uint32 flags, bcm_pkt_t **pkt_buf) { int rv, i; int bytes = 0; int local_alloc = FALSE; UNIT_VALID(unit); if (pkt == NULL) { /* Allocate new packet */ local_alloc = TRUE; if ((pkt = sal_alloc(sizeof(bcm_pkt_t), "pkt_setup")) == NULL) { *pkt_buf = NULL; return BCM_E_MEMORY; } } sal_memset(pkt, 0, sizeof(bcm_pkt_t)); pkt->unit = unit; if (blk_count == 0) { /* * Permit allocation of an empty packet structure. * A single buffer can be added alter using the * BCM_PKT_ONE_BUF_SETUP macro. */ bcm_pkt_flags_init(unit, pkt, flags); } else { for (i = 0; i < blk_count; i++) { bytes += blks[i].len; } if (bytes < BCM_PKT_ALLOC_MIN) { *pkt_buf = NULL; if (local_alloc) { sal_free(pkt); } return BCM_E_MEMORY; } pkt->pkt_data = blks; pkt->blk_count = blk_count; rv = bcm_pkt_flags_len_setup(unit, pkt, bytes, -1, flags); if (BCM_FAILURE(rv)) { *pkt_buf = NULL; if (local_alloc) { sal_free(pkt); } return rv; } } *pkt_buf = pkt; return BCM_E_NONE; }
cmd_result_t test_parameters(int u, args_t *a) /* * Function: test_parameters * Purpose: Set the parameters for the specified tests. * Parameters: u - unit number * a - arguments, expects tuples of the form: * [Test name/#] Arguments. * if arguments is null string ("") then previously * set arguments are discarded and defaults used. * Returns: cmd_result_t. */ { char *tid, *p; /* Testid, parameters */ test_t *t; /* Test pointer */ COMPILER_REFERENCE(u); if (0 == ARG_CNT(a)) { return(CMD_USAGE); } while (NULL != (tid = ARG_GET(a))) { p = ARG_GET(a); /* Parameter */ t = test_find(tid); if (NULL == t) { cli_out("%s: Error: Unable to find test: %s\n", ARG_CMD(a), tid); return(CMD_FAIL); } if (!p || !*p) { /* Clear parameter */ if (!t->t_override_string) { cli_out("%s: Warning: No arguments to clear for test: %s\n", ARG_CMD(a), t->t_name); continue; } sal_free(t->t_override_string); t->t_override_string = NULL; } else { /* Set Arguments */ if (t->t_override_string) { sal_free(t->t_override_string); } if (!(t->t_override_string = (char *)sal_alloc(strlen(p) + 1, "test_parm"))) { cli_out("%s: Error: Out of memory\n", ARG_CMD(a)); return(CMD_FAIL); } sal_strcpy(t->t_override_string, p); cli_out("%s: Parameter set: %s(\"%s\")\n", ARG_CMD(a), t->t_name, t->t_override_string); } } return(CMD_OK); }
STATIC void txrx_pkt_free(int unit, bcm_pkt_t *pkt) { int i; for (i = 0; i < pkt->blk_count; i++) { soc_cm_sfree(unit, pkt->pkt_data[i].data); } if (pkt->pkt_data != &pkt->_pkt_data) { sal_free(pkt->pkt_data); } sal_free(pkt); }
Contact* fetion_contact_list_find_by_sipuri(Contact* contactlist , const char* sipuri) { Contact *cl_cur; char *sid , *sid1; foreach_contactlist(contactlist , cl_cur){ sid = fetion_sip_get_sid_by_sipuri(cl_cur->sipuri); sid1 = fetion_sip_get_sid_by_sipuri(sipuri); if(strcmp(sid , sid1) == 0){ sal_free(sid); sal_free(sid1); return cl_cur; } sal_free(sid); sal_free(sid1); }
int bcm_pkt_blk_alloc(int unit, int count, int size, uint32 flags, bcm_pkt_t ***packet_array) { bcm_pkt_t **p_array; int i, j; UNIT_VALID(unit); if (!(p_array = sal_alloc(count * sizeof(bcm_pkt_t *), "pkt_blk"))) { *packet_array = NULL; return (BCM_E_MEMORY); } for (i = 0; i < count; i++) { if (BCM_FAILURE(bcm_pkt_alloc(unit, size, flags, p_array + i))) { for (j = 0; j < i; j++) { bcm_pkt_free(unit, p_array[j]); } sal_free(p_array); *packet_array = NULL; return (BCM_E_MEMORY); } } *packet_array = p_array; return BCM_E_NONE; }
int bcm_pkt_alloc(int unit, int size, uint32 flags, bcm_pkt_t **pkt_buf) { bcm_pkt_t *pkt; int rv = BCM_E_INTERNAL; UNIT_VALID(unit); pkt = sal_alloc(sizeof(bcm_pkt_t), "bcm_pkt_alloc"); if (!pkt) { *pkt_buf = NULL; return BCM_E_MEMORY; } sal_memset(pkt, 0, sizeof(bcm_pkt_t)); pkt->pkt_data = &pkt->_pkt_data; pkt->blk_count = 1; rv = _bcm_pkt_data_alloc(unit, size, pkt->pkt_data); if (BCM_FAILURE(rv)) { sal_free(pkt); *pkt_buf = NULL; return rv; } bcm_pkt_flags_init(unit, pkt, flags); *pkt_buf = pkt; return BCM_E_NONE; }
/* * Allocate mac control block and attach the MAC driver. */ phy_mac_ctrl_t* phy_mac_driver_attach(blmi_dev_addr_t dev_addr, phy_mactype_t mac_type, blmi_dev_io_f mmi_cbf) { phy_mac_ctrl_t *mmc; mmc = sal_alloc(sizeof(phy_mac_ctrl_t), "bmac_driver"); if (mmc == NULL) { return NULL; } if (mac_type == PHY_MAC_CORE_UNIMAC) { sal_memcpy(&mmc->mac_drv, &phy_unimac_drv, sizeof(phy_mac_drv_t)); #if 0 } else if (mac_type == PHY_MAC_CORE_BIGMAC) { sal_memcpy(&mmc->mac_drv, &phy_bigmac_drv, sizeof(phy_mac_drv_t)); #endif } else if (mac_type == PHY_MAC_CORE_XMAC) { sal_memcpy(&mmc->mac_drv, &phy_xmac_drv, sizeof(phy_mac_drv_t)); } else { sal_free(mmc); mmc = NULL; } if (mmc) { mmc->devio_f = mmi_cbf; mmc->dev_addr = dev_addr; mmc->flag = 0; } return mmc; }
/* Allocate a new hash. */ static ctclib_hash_t * _ctclib_hash_create_size (uint32 size, hash_mem_type_t type, uint32 (*hash_key) (), bool (*hash_cmp) ()) { ctclib_hash_t *hash; hash = sal_malloc (sizeof (ctclib_hash_t)); if (NULL == hash) return NULL; #ifdef _USER_KERNEL_SHM_ if(CTCLIB_HASH_SYS_MEM == type) hash->index = XCALLOC (CTCLLB_MEM_HASH_MODULE, sizeof (ctclib_hash_backet_t *) * size); else hash->index = XCALLOC_SHM (CTCLLB_MEM_HASH_MODULE, sizeof (ctclib_hash_backet_t *) * size); #else hash->index = sal_calloc (sizeof (ctclib_hash_backet_t *) * size); #endif if (NULL == hash->index) { sal_free(hash); return NULL; } hash->size = size; hash->hash_key = hash_key; hash->hash_cmp = hash_cmp; hash->count = 0; return hash; }
/* This function release registered value from specified hash. When release is successfully finished, return the data pointer in the hash bucket. */ void * ctclib_hash_release (ctclib_hash_t *hash, void *data) { void *ret; uint32 key; uint32 index; ctclib_hash_backet_t *backet; ctclib_hash_backet_t *pp; key = (*hash->hash_key) (data); index = key % hash->size; for (backet = pp = hash->index[index]; backet; backet = backet->next) { if (backet->key == key && (*hash->hash_cmp) (backet->data, data) == TRUE) { if (backet == pp) { hash->index[index] = backet->next; } else { pp->next = backet->next; } ret = backet->data; sal_free (backet); hash->count--; return ret; } pp = backet; } return NULL; }
STATIC int _auth_field_install_all(int unit, int port) { auth_mac_t **list=&auth_cntl[unit][port].macList; auth_mac_p entry = NULL; int rv = BCM_E_NONE; bcm_mac_t mac_zero = {0}; if (auth_cntl[unit][port].mac_set) { return BCM_E_EXISTS; } /* No accepted MAC addresses, drop all for default */ if (*list == NULL) { rv = _auth_field_install(unit, port, mac_zero); if (rv < 0) { return rv; } } while (*list != NULL) { rv = _auth_field_install(unit, port, (*list)->mac); if (rv < 0) { _auth_maclist_remove(list, (*list)->mac, &entry); sal_free(entry); } else { list = &(*list)->next; } } auth_cntl[unit][port].mac_set = TRUE; return rv; }
void socend_send_done(int unit, bcm_pkt_t *pkt, void *cookie) /* * Function: socend_send_done * Purpose: Process a completion of a send request * Parameters: unit - unit # * pkt - The tx packet structure * cookie - pointer to mBlk structure to free * If null, assume we free the cluster directly. * Returns: Nothing * Notes: * Assumption: This function is called from a non-interrupt context. */ { LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "Socend send done, in. pkt %p. ck %p. "), (void *)pkt->_pkt_data.data, (void *)cookie)); if (NULL == cookie) { if (SOC_IS_ESW(unit)) { socend_packet_free(unit, pkt->_pkt_data.data); } else { soc_cm_sfree(unit, pkt->_pkt_data.data); } } else { netMblkClChainFree(cookie); /* Free MBLK */ } sal_free(pkt); LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "out.\n"))); }
int ces_test_done(int u, void *p) { int rv = 0; /* * Clear ge0 loopback */ #if 0 ces_test_ge0_loopback_set(u, FALSE); #else printk("<<<< GE0 LOOPBACK STILL ON >>>>\n"); #endif #if 0 /* * Reset CES */ bcm_ces_services_init(u); #else printk("<<<< CES NOT CLEANED UP >>>>\n"); #endif if (p != NULL) sal_free(p); if (rv < 0) { test_error(u, "Post-CES reset failed: %s\n", soc_errmsg(rv)); return -1; } return 0; }
int bcm_pkt_rx_alloc(int unit, int len, bcm_pkt_t **pkt_buf) { bcm_pkt_t *pkt; uint8 *buf; int rv; UNIT_VALID(unit); buf = NULL; pkt = sal_alloc(sizeof(bcm_pkt_t), "pkt_rx_alloc"); if (pkt == NULL) { *pkt_buf = NULL; return BCM_E_MEMORY; } sal_memset(pkt, 0, sizeof(bcm_pkt_t)); if (len > 0) { rv = bcm_rx_alloc(unit, len, 0, (void*)&buf); if (rv != BCM_E_NONE) { sal_free(pkt); return rv; } pkt->_pkt_data.data = buf; pkt->_pkt_data.len = len; pkt->pkt_len = len; pkt->pkt_data = &pkt->_pkt_data; pkt->blk_count = 1; } /* Set up flags here if possible */ *pkt_buf = pkt; return BCM_E_NONE; }
int shr_mem_avl_destroy(shr_mem_avl_t *mem_avl) { int status, rv = 0; shr_mem_avl_entry_pt entry; shr_mem_avl_entry_pt next; /* destroy the avl tree. Frees the space for datum's also. */ status = shr_avl_destroy(mem_avl->tree); if (status != 0) { rv = -1; } mem_avl->tree = NULL; /* * Now walk the dll and free each entry */ entry = mem_avl->mem_list; while (NULL != entry) { next = entry->next; sal_free(entry); entry = next; } mem_avl->mem_list = NULL; return rv; }
/* * soc_robo_dos_monitor_deinit * Purpose: * dos monitor de-init * Parameters: * unit - unit number. * Returns: * */ int soc_robo_dos_monitor_deinit(int unit) { drv_robo_dos_monitor_t *dm = drv_dm_control[unit]; /* check if dm is null and dm thread running status */ if (dm != NULL){ SOC_IF_ERROR_RETURN(soc_robo_dos_monitor_enable_set(unit, 0)); if (dm->dm_thread != NULL){ soc_cm_debug(DK_ERR, "HW DOS monitor disabled but still exist!,thread(%p)\n", (void *)dm->dm_thread); } if (dm->dm_sema != NULL) { sal_sem_destroy(dm->dm_sema); dm->dm_sema = NULL; } if (dm->dm_lock != NULL) { sal_mutex_destroy(dm->dm_lock); dm->dm_lock = NULL; } /* free dm */ drv_dm_control[unit] = NULL; sal_free(dm); } return SOC_E_NONE; }
int fetion_conversation_send_sms_to_myself_with_reply(Conversation* conversation, const char* message) { SipHeader *toheader = NULL; SipHeader *eheader = NULL; char *res = NULL; char rep[1024]; int code; FetionSip *sip = conversation->currentUser->sip; fetion_sip_set_type(sip , SIP_MESSAGE); toheader = fetion_sip_header_new("T" , conversation->currentUser->sipuri); eheader = fetion_sip_event_header_new(SIP_EVENT_SENDCATMESSAGE); fetion_sip_add_header(sip , toheader); fetion_sip_add_header(sip , eheader); res = fetion_sip_to_string(sip , message); debug_info("Sent a message to myself" , conversation->currentContact->sipuri); tcp_connection_send(sip->tcp , res , strlen(res)); sal_free(res); memset(rep, 0, sizeof(rep)); tcp_connection_recv(sip->tcp , rep , sizeof(rep)); code = fetion_sip_get_code(rep); if(code == 200 || code == 280){ return 1; }else{ return -1; } }
/* * Function: * wildcard_search * Purpose: * search for "*" in name and save prefix as wildcard * * Returns: * wildcard returns prefix of name * length returns length of wildcard */ char* wildcard_search(const char *name, char *wildcard, int *length) { int len, index = 0; const char *m = name; len = strlen(name); wildcard = sal_alloc(len + 1, "wildcard"); while (index < len) { if (*m == '*') { *(wildcard+index) = 0; *length = index; return wildcard; } else { *(wildcard+index) = *m; m++; index++; } } /* no '*' found */ sal_free(wildcard); return NULL; }
int bcm_esw_auth_mac_delete(int unit, int port, bcm_mac_t mac) { auth_mac_p entry = NULL; int rv; AUTH_INIT(unit); BCM_IF_ERROR_RETURN(_bcm_esw_port_gport_validate(unit, port, &port)); AUTH_PORT(unit, port); rv = _auth_maclist_remove(&auth_cntl[unit][port].macList, mac, &entry); if (rv < 0) { return rv; } if (auth_cntl[unit][port].mac_set) { if (soc_feature(unit, soc_feature_field)) { BCM_IF_ERROR_RETURN(_auth_field_remove(unit, port, mac)); } } sal_free(entry); return BCM_E_NONE; }
int bcm_esw_auth_mac_add(int unit, int port, bcm_mac_t mac) { bcm_mac_t mac_zero = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; bcm_mac_t mac_resv = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x03}; pbmp_t pbm; #if defined(BCM_FIELD_SUPPORT) auth_mac_p entry = NULL; int rv; bcm_port_t p; #endif /* BCM_FIELD_SUPPORT */ AUTH_INIT(unit); if ((!sal_memcmp(mac, mac_zero, sizeof(bcm_mac_t))) || (!sal_memcmp(mac, mac_resv, sizeof(bcm_mac_t)))) { return BCM_E_PARAM; } if (port < 0) { BCM_PBMP_ASSIGN(pbm, PBMP_E_ALL(unit)); #ifdef BCM_KATANA2_SUPPORT if (soc_feature(unit, soc_feature_linkphy_coe) || soc_feature(unit, soc_feature_subtag_coe)) { _bcm_kt2_subport_pbmp_update(unit, &pbm); } #endif } else { /* port >= 0 */ BCM_IF_ERROR_RETURN(_bcm_esw_port_gport_validate(unit, port, &port)); AUTH_PORT(unit, port); BCM_PBMP_PORT_SET(pbm, port); } #if defined(BCM_FIELD_SUPPORT) BCM_PBMP_ITER(pbm, p) { if ((rv = _auth_maclist_insert(&auth_cntl[unit][p].macList, mac, &entry)) < 0) { return rv; } if (auth_cntl[unit][p].mac_set) { if (soc_feature(unit, soc_feature_field)) { #ifdef BCM_FIELD_SUPPORT if ((rv = _auth_field_install(unit, p, mac)) < 0) { _auth_maclist_remove(&auth_cntl[unit][p].macList, mac, &entry); sal_free(entry); return rv; } #endif /* BCM_FIELD_SUPPORT */ } } } return BCM_E_NONE; #else /* !BCM_FIELD_SUPPORT */ return BCM_E_UNAVAIL; #endif /* !BCM_FIELD_SUPPORT */ }
int bcm_compat530_l2_conflict_get( int unit, bcm_compat530_l2_addr_t *addr, bcm_compat530_l2_addr_t *cf_array, int cf_max, int *cf_count) { int rv, i; bcm_l2_addr_t naddr; bcm_l2_addr_t *ncf_array; if (addr == NULL || cf_array == NULL) { return BCM_E_PARAM; } ncf_array = sal_alloc(sizeof(bcm_l2_addr_t) * cf_max, "compat530_l2_conflict_get"); if (ncf_array == NULL) { return BCM_E_MEMORY; } _bcm_compat530in_l2_addr_add_t(addr, &naddr); rv = bcm_l2_conflict_get(unit, &naddr, ncf_array, cf_max, cf_count); if (rv >= 0) { for (i = 0; i < *cf_count; i++) { _bcm_compat530out_l2_addr_add_t(&ncf_array[i], &cf_array[i]); } } sal_free(ncf_array); return rv; }
/* * Function: * shr_htb_create * Purpose: * Create and initialize a hash table. * Parameters: * (out) ht - hash table to operate * (in) max_num_entries - maximum number of hash table entries, power of 2 * (in) key_size - size of keys used in hash function * (in) tbl_name - name of table * Returns: * BCM_E_NONE upon success * BCM_E_* on failure * Notes: * */ int shr_htb_create(shr_htb_hash_table_t *ht, int max_num_entries, int key_size, char* tbl_name) { int rv = _SHR_E_NONE; int table_mem_size; shr_htb_hash_table_t prv_ht; /* table size must be a power of 2 */ if((max_num_entries & (max_num_entries - 1)) != 0) { return _SHR_E_PARAM; } prv_ht = sal_alloc(sizeof(struct hash_table_s), "_hash_tbl_"); if (prv_ht == NULL) { return _SHR_E_MEMORY; } sal_memset(prv_ht, 0, sizeof(struct hash_table_s)); prv_ht->lock = sal_mutex_create(tbl_name); if (prv_ht->lock == NULL) { sal_free(prv_ht); return _SHR_E_RESOURCE; } prv_ht->max_num_entries = max_num_entries; prv_ht->key_size = key_size; prv_ht->alloc_blk_cnt = HTB_DEFAULT_ALLOC_BLK_CNT; prv_ht->hash_f = htb_default_hash_f; prv_ht->key_cmp_f = htb_default_key_cmp_f; prv_ht->cast_key_f = htb_default_cast_key_f; /* hash table is an array of pointers */ table_mem_size = max_num_entries * sizeof(_hash_entry_t*); prv_ht->table = sal_alloc(table_mem_size, tbl_name); if (prv_ht->table == NULL) { sal_mutex_destroy(prv_ht->lock); sal_free(prv_ht); return _SHR_E_MEMORY; } sal_memset(prv_ht->table, 0, table_mem_size); *ht = prv_ht; return rv; }
/* * Function: * shr_htb_destroy * Purpose: * destroy a hash table and all associated entries. * Parameters: * (in/out) ht - hash table to operate * (in) cb - callback function for each valid hash entry freed * may be NULL. * Returns: * BCM_E_NONE upon success * BCM_E_* on failure * Notes: * The CALLER is responsible for freeing all memory associated with data by * supplying a callback function. The callback is called for all entries * found in the hash table. * */ int shr_htb_destroy(shr_htb_hash_table_t *ht, shr_htb_data_free_f cb) { int i; int rv = _SHR_E_NONE; _hash_entry_t *entry, *next; shr_htb_hash_table_t prv_ht = *ht; /* for each entry in the table, * for each entry in the collision chain, * call supplied callback * return the entry to the free list */ HTBL_LOCK(prv_ht); for (i=0; i < prv_ht->max_num_entries; i++) { entry = prv_ht->table[i]; while (entry) { if (cb) { cb(entry->data); } next = entry->next; _htb_entry_free(prv_ht, &entry); entry = next; } } /* free the free list */ for (i=0; i < prv_ht->num_free; i++) { entry = _htb_free_list_pop(prv_ht); /* shouldn't happen. free list accounting error if does */ if (entry == NULL) { rv = _SHR_E_INTERNAL; } else { sal_free(entry); } } HTBL_UNLOCK(prv_ht); sal_mutex_destroy(prv_ht->lock); sal_free(prv_ht->table); sal_free(prv_ht); *ht = NULL; return rv; }
/* * Function : soc_robo_regaddrlist_free * * Purpose : * Free the register info structure. * * Parameters : * addrlist : pointer of the registers list * * Return : * SOC_E_NONE : success. * * Note : * * */ int soc_robo_regaddrlist_free(soc_regaddrlist_t *addrlist) { if (addrlist->ainfo) { sal_free(addrlist->ainfo); } return SOC_E_NONE; }
void _bcm_tr2_port_vpd_bitmap_free(int unit) { if (vpd_bitmap[unit]) { sal_free(vpd_bitmap[unit]); } vpd_bitmap[unit] = NULL; return; }
STATIC int _auth_field_remove(int unit, int port, bcm_mac_t mac) { #ifdef BCM_FIELD_SUPPORT pbmp_t pbm; bcm_field_qset_t qset0; auth_mac_p entry = NULL; bcm_pbmp_t pbmp_mask; BCM_PBMP_CLEAR(pbmp_mask); BCM_PBMP_ASSIGN (pbmp_mask, PBMP_E_ALL(unit)); #ifdef BCM_KATANA2_SUPPORT if (soc_feature(unit, soc_feature_linkphy_coe) || soc_feature(unit, soc_feature_subtag_coe)) { _bcm_kt2_subport_pbmp_update(unit, &pbmp_mask); } #endif if (_auth_maclist_lookup(&fp_cntl[unit].macList, mac, &entry) > 0) { BCM_FIELD_QSET_INIT(qset0); BCM_FIELD_QSET_ADD(qset0, bcmFieldQualifyInPorts); pbm = entry->pbmp; BCM_PBMP_PORT_REMOVE(pbm, port); if (BCM_PBMP_IS_NULL(pbm)) { BCM_IF_ERROR_RETURN (bcm_esw_field_entry_remove(unit, entry->entry)); BCM_IF_ERROR_RETURN (bcm_esw_field_entry_destroy(unit, entry->entry)); fp_cntl[unit].count--; _auth_maclist_remove(&fp_cntl[unit].macList, mac, &entry); sal_free(entry); } else { bcm_esw_field_qualify_InPorts(unit, entry->entry, pbm, pbmp_mask); BCM_IF_ERROR_RETURN( bcm_esw_field_entry_reinstall(unit, entry->entry)); entry->pbmp = pbm; } } if ((fp_cntl[unit].count==0) && (fp_cntl[unit].inited)) { BCM_IF_ERROR_RETURN (bcm_esw_field_entry_remove(unit, fp_cntl[unit].entry2)); BCM_IF_ERROR_RETURN (bcm_esw_field_entry_destroy(unit, fp_cntl[unit].entry2)); BCM_IF_ERROR_RETURN (bcm_esw_field_group_destroy(unit, fp_cntl[unit].group0)); BCM_IF_ERROR_RETURN (bcm_esw_field_group_destroy(unit, fp_cntl[unit].group2)); _auth_maclist_destroy(&fp_cntl[unit].macList); fp_cntl[unit].inited = FALSE; } return BCM_E_NONE; #else /* !BCM_FIELD_SUPPORT */ return BCM_E_UNAVAIL; #endif /* !BCM_FIELD_SUPPORT */ }
int shr_res_tag_bitmap_destroy(shr_res_tag_bitmap_handle_t handle) { if (handle) { sal_free(handle); return BCM_E_NONE; } else { RES_ERR((RES_MSG1("unable to free NULL handle\n"))); return BCM_E_PARAM; } }