void rpc_term(void)
{
    if (workspace) {
        khrn_platform_free(workspace);
    }
    platform_mutex_destroy(&mutex);
}
示例#2
0
int novacom_usb_transport_stop(void)
{
	novacom_shutdown = 1;

	platform_waitfor_thread(findandattach_thread);
	platform_mutex_destroy(&recovery_lock);

	return 0;
}
示例#3
0
/* Destructor. Table object is freed by pipeline destructor */
rofl_result_t __of1x_destroy_table(of1x_flow_table_t* table){
	
	platform_mutex_lock(table->mutex);
	platform_rwlock_wrlock(table->rwlock);

	//Let the matching algorithm destroy its own state
	if(of1x_matching_algorithms[table->matching_algorithm].destroy_hook)
		of1x_matching_algorithms[table->matching_algorithm].destroy_hook(table);

	platform_mutex_destroy(table->mutex);
	platform_rwlock_destroy(table->rwlock);
	
	//Destroy stats
	__of1x_stats_table_destroy(table);

	//Do NOT free table, since it was allocated in a single buffer in pipeline.c	
	return ROFL_SUCCESS;
}
示例#4
0
//Destroy
void physical_switch_destroy(){
	
	unsigned int i;
	
	ROFL_PIPELINE_DEBUG("Destroying physical switch\n");

	//Serialize
	platform_mutex_lock(psw->mutex);

	//Destroy logical switches
	for(i=0;i<PHYSICAL_SWITCH_MAX_LS;i++){
		if(psw->logical_switches[i])
			of_destroy_switch(psw->logical_switches[i]);	
	}

	//Destroying ports
	for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_PHY_PORTS;i++){
		if( psw->physical_ports[i] != NULL ){ 
			switch_port_destroy(psw->physical_ports[i]);
		}
	}
	for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_VIR_PORTS;i++){
		if( psw->virtual_ports[i] != NULL ){ 
			switch_port_destroy(psw->virtual_ports[i]);
		}
	}
	for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_TUN_PORTS;i++){
		if( psw->tunnel_ports[i] != NULL ){ 
			switch_port_destroy(psw->tunnel_ports[i]);
		}
	}

	//Destroy monitoring
	__monitoring_destroy(&psw->monitoring);		
	
	//Destroy mutex
	platform_mutex_destroy(psw->mutex);
	
	//destroy physical switch
	platform_free_shared(psw);
}
示例#5
0
/* Initalizer. Table struct has been allocated by pipeline initializer. */
rofl_result_t __of1x_init_table(struct of1x_pipeline* pipeline, of1x_flow_table_t* table, const unsigned int table_index, const enum of1x_matching_algorithm_available algorithm){

	//Safety checks
	if( unlikely(pipeline==NULL) || unlikely(table==NULL) )
		return ROFL_FAILURE;	

	//Initializing mutexes
	table->mutex = platform_mutex_init(NULL);
	if( unlikely(NULL==table->mutex) )
		return ROFL_FAILURE;
	table->rwlock = platform_rwlock_init(NULL);
	if( unlikely(NULL==table->rwlock) )
		return ROFL_FAILURE;
	
	table->pipeline = pipeline;
	table->number = table_index;
	table->entries = NULL;
	table->num_of_entries = 0;
	table->max_entries = OF1X_MAX_NUMBER_OF_TABLE_ENTRIES;

	//Set name
	snprintf(table->name, OF1X_MAX_TABLE_NAME_LEN, "table%u", table_index);
	
	//Setting up the matching algorithm	
	if(! (algorithm < of1x_matching_algorithm_count)){
		platform_mutex_destroy(table->mutex);
		platform_rwlock_destroy(table->rwlock);
		return ROFL_FAILURE;
	}

	//Set algorithm
	table->matching_algorithm = algorithm;

	//Auxiliary matching algorithm structs 
	table->matching_aux[0] = NULL; 
	table->matching_aux[1] = NULL;

	//Initializing timers. NOTE does that need to be done here or somewhere else?
#if OF1X_TIMER_STATIC_ALLOCATION_SLOTS
	__of1x_timer_group_static_init(table);
#else
	table->timers = NULL;
#endif

	switch(pipeline->sw->of_ver){
		case OF_VERSION_10:
			__of10_set_table_defaults(table);
			break; 
		case OF_VERSION_12:
			__of12_set_table_defaults(table);
			break; 
		case OF_VERSION_13:
			__of13_set_table_defaults(table);
			break; 
		default:
			platform_mutex_destroy(table->mutex);
			platform_rwlock_destroy(table->rwlock);
			return ROFL_FAILURE;
	}

	//Init stats
	__of1x_stats_table_init(table);

	//Allow matching algorithms to do stuff	
	if(of1x_matching_algorithms[table->matching_algorithm].init_hook)
		return of1x_matching_algorithms[table->matching_algorithm].init_hook(table);
	
	return ROFL_SUCCESS;
}