OFDPE get_table_stats( table_stats **stats, uint8_t *n_tables ) { assert( stats != NULL ); assert( n_tables != NULL ); if ( !lock_pipeline() ) { return ERROR_LOCK; } *stats = xmalloc( sizeof( table_stats ) * N_FLOW_TABLES ); memset( *stats, 0, sizeof( table_stats ) * N_FLOW_TABLES ); *n_tables = 0; table_stats *stat = *stats; for ( uint8_t i = 0; i <= FLOW_TABLE_ID_MAX; i++ ) { stat->table_id = i; stat->active_count = get_active_count( i ); stat->lookup_count = get_lookup_count( i ); stat->matched_count = get_matched_count( i ); stat++; ( *n_tables )++; } if ( !unlock_pipeline() ) { return ERROR_UNLOCK; } return OFDPE_SUCCESS; }
OFDPE add_flow_entry( const uint8_t table_id, flow_entry *entry, const uint16_t flags ) { if ( !valid_table_id( table_id ) ) { return ERROR_OFDPE_FLOW_MOD_FAILED_BAD_TABLE_ID; } if ( entry == NULL ) { return ERROR_INVALID_PARAMETER; } if ( !lock_pipeline() ) { return ERROR_LOCK; } flow_table *table = get_flow_table( table_id ); if ( table == NULL ) { return ERROR_OFDPE_FLOW_MOD_FAILED_BAD_TABLE_ID; } if ( table->features.max_entries <= get_active_count( table_id ) ) { return ERROR_OFDPE_FLOW_MOD_FAILED_TABLE_FULL; } OFDPE ret = validate_instruction_set( entry->instructions, table->features.metadata_write ); if ( ret == OFDPE_SUCCESS ) { entry->table_id = table_id; ret = insert_flow_entry( table, entry, flags ); if ( ret == OFDPE_SUCCESS ) { increment_reference_counters_in_groups( entry->instructions ); } } if ( !unlock_pipeline() ) { return ERROR_UNLOCK; } return ret; }
bool locked() { return get_active_count()>=lock_flag_value; }