Click
Loading...
Searching...
No Matches
Public Member Functions | List of all members
FlowRuleCache Class Reference

#include <flowrulecache.hh>

Public Member Functions

 FlowRuleCache (portid_t port_id, bool verbose, bool debug_mode, ErrorHandler *errh)
 
portid_t get_port_id ()
 
String get_device_address ()
 
bool has_rules ()
 
bool global_rule_id_exists (const uint32_t &rule_id)
 
bool internal_rule_id_exists (const uint32_t &int_rule_id)
 
uint32_t global_from_internal_rule_id (const uint32_t &int_rule_id)
 
int32_t internal_from_global_rule_id (const uint32_t &rule_id)
 
template<typename T >
void sort_rule_ids_inc (Vector< T > &rule_ids_vec)
 
template<typename T >
void sort_rule_ids_dec (Vector< T > &rule_ids_vec)
 
Vector< uint32_t > global_rule_ids (const bool increasing=true)
 
Vector< uint32_t > internal_rule_ids (const bool increasing=true)
 
Vector< uint32_t > internal_rule_ids_counters (const bool increasing=true)
 
HashMap< uint32_t, String > * rules_map_by_core_id (const int &core_id)
 
Vector< String > rules_list_by_core_id (const int &core_id)
 
Vector< int > cores_with_rules ()
 
String get_rule_by_global_id (const uint32_t &rule_id)
 
String get_rule_by_internal_id (const uint32_t &int_rule_id)
 
int32_t currently_max_internal_rule_id ()
 
uint32_t next_internal_rule_id ()
 
void set_next_internal_rule_id (uint32_t next_id)
 
int insert_rule_in_flow_cache (const int &core_id, const uint32_t &rule_id, const uint32_t &int_rule_id, const String rule)
 
bool update_rule_in_flow_cache (const int &core_id, const uint32_t &rule_id, const uint32_t &int_rule_id, String rule)
 
int32_t delete_rule_by_global_id (const uint32_t &rule_id)
 
String delete_rules_by_internal_id (const uint32_t *int_rule_ids, const uint32_t &rules_nb)
 
String delete_rules_by_internal_id (const Vector< String > &rules_vec)
 
int32_t flush_rules_from_cache ()
 
void set_matched_packets (const uint32_t &int_rule_id, uint64_t value)
 
uint64_t get_matched_packets (const uint32_t &int_rule_id)
 
void set_matched_bytes (const uint32_t &int_rule_id, uint64_t value)
 
uint64_t get_matched_bytes (const uint32_t &int_rule_id)
 
uint32_t get_rule_counter ()
 
void initialize_rule_counters (uint32_t *int_rule_ids, const uint32_t &rules_nb)
 
void delete_rule_counters (uint32_t *int_rule_ids, const uint32_t &rules_nb)
 
void cache_consistency_check (const int32_t &target_number_of_rules)
 
void correlate_candidate_id_with_cache (int32_t &candidate)
 
void flush_rule_counters ()
 

Detailed Description

Flow Rule Cache API.

Member Function Documentation

◆ get_port_id()

portid_t FlowRuleCache::get_port_id ( )

Flow Rule Cache implementation. Return the NIC port ID associated with this flow rule cache.

Returns
port ID of the NIC associated with this cache

◆ get_device_address()

String FlowRuleCache::get_device_address ( )

Return the NIC device's adress suitable to use as a FromDPDKDevice reference.

Returns
port address of the NIC associated with this cache

◆ has_rules()

bool FlowRuleCache::has_rules ( )

Checks whether this flow rule cache contains any flow rules or not.

Returns
true if at least one flow rule is in the cache, otherwise false

◆ global_rule_id_exists()

bool FlowRuleCache::global_rule_id_exists ( const uint32_t &  rule_id)

Checks whether a given global flow rule ID is present or not.

@args rule_id: a global flow rule ID to find

Returns
true if rule_id exists, otherwise false

◆ internal_rule_id_exists()

bool FlowRuleCache::internal_rule_id_exists ( const uint32_t &  int_rule_id)

Checks whether an internal flow rule ID is present or not.

@args int_rule_id: an internal flow rule ID to find

Returns
true if int_rule_id exists, otherwise false

◆ global_from_internal_rule_id()

uint32_t FlowRuleCache::global_from_internal_rule_id ( const uint32_t &  int_rule_id)

Traverses the map of global flow rule IDs to internal NIC IDs, and checks whether an internal flow rule ID is present or not.

@args int_rule_id: an internal flow rule ID to find

Returns
the global flow rule ID mapped to the input internal flow rule ID upon success, otherwise a negative integer

◆ internal_from_global_rule_id()

int32_t FlowRuleCache::internal_from_global_rule_id ( const uint32_t &  rule_id)

Queries the map of global flow rule IDs to internal NIC IDs, and checks whether a global flow rule ID is present or not.

@args rule_id: a global flow rule ID to find

Returns
the internal flow rule ID mapped to the input global flow rule ID upon success, otherwise a negative integer

◆ sort_rule_ids_inc()

template<typename T >
void FlowRuleCache::sort_rule_ids_inc ( Vector< T > &  rule_ids_vec)

Sorts a list of flow rule IDs by increasing order.

  • rule_ids_vec: a list of rule IDs to sort

◆ sort_rule_ids_dec()

template<typename T >
void FlowRuleCache::sort_rule_ids_dec ( Vector< T > &  rule_ids_vec)

Sorts a a list of flow rule IDs by decreasing order.

  • rule_ids_vec: a list of rule IDs to sort

◆ global_rule_ids()

Vector< uint32_t > FlowRuleCache::global_rule_ids ( const bool  increasing = true)

Returns the list of global flow rules IDs in this flow rule cache.

  • increasing: boolean flag that indicates the order of rule IDs (defaults to true)
    Returns
    list of global flow rules IDs

◆ internal_rule_ids()

Vector< uint32_t > FlowRuleCache::internal_rule_ids ( const bool  increasing = true)

Returns the list of internal flow rules IDs in this flow rule cache.

  • increasing: boolean flag that indicates the order of rule IDs (defaults to true)
    Returns
    list of internal flow rules IDs

◆ internal_rule_ids_counters()

Vector< uint32_t > FlowRuleCache::internal_rule_ids_counters ( const bool  increasing = true)

Returns the list of internal flow rules IDs with counters.

  • increasing: boolean flag that indicates the order of rule IDs (defaults to true)
    Returns
    list of internal flow rules IDs with counters

◆ rules_map_by_core_id()

HashMap< uint32_t, String > * FlowRuleCache::rules_map_by_core_id ( const int &  core_id)

Returns a map of flow rule IDs to flow rules.

@args core_id: a CPU core ID

Returns
a map of flow rule IDs to flow rules associated with this core

◆ rules_list_by_core_id()

Vector< String > FlowRuleCache::rules_list_by_core_id ( const int &  core_id)

Returns a list of flow rules associated with a CPU core.

@args core_id: a CPU core ID

Returns
a list of flow rules associated with this core

◆ cores_with_rules()

Vector< int > FlowRuleCache::cores_with_rules ( )

Returns the number of CPU cores that have at least one flow rule each.

Returns
a list CPU cores that have associated flow rules

◆ get_rule_by_global_id()

String FlowRuleCache::get_rule_by_global_id ( const uint32_t &  rule_id)

Returns a flow rule by its global flow rule ID.

  • rule_id: the global flow rule ID of the rule to retrieve
    Returns
    a rule upon success, otherwise empty string

◆ get_rule_by_internal_id()

String FlowRuleCache::get_rule_by_internal_id ( const uint32_t &  int_rule_id)

Returns a flow rule by its global flow rule ID.

  • int_rule_id: the internal flow rule ID of the rule to retrieve
    Returns
    a rule upon success, otherwise empty string

◆ currently_max_internal_rule_id()

int32_t FlowRuleCache::currently_max_internal_rule_id ( )

Returns the currently maximum internal flow rule ID.

Returns
currently maximum internal flow rule ID

◆ next_internal_rule_id()

uint32_t FlowRuleCache::next_internal_rule_id ( )

Returns the next internal flow rule ID to use for insertion.

Returns
next available internal flow rule ID

◆ set_next_internal_rule_id()

void FlowRuleCache::set_next_internal_rule_id ( uint32_t  next_id)

Sets the next internal flow rule ID to use for insertion.

  • next_id: next available internal flow rule ID

◆ insert_rule_in_flow_cache()

int FlowRuleCache::insert_rule_in_flow_cache ( const int &  core_id,
const uint32_t &  rule_id,
const uint32_t &  int_rule_id,
const String  rule 
)

Adds a new flow rule to this flow rule cache.

@args core_id: a CPU core ID associated with the flow rule @args rule_id: a global rule ID associated with the flow rule @args int_rule_id: an internal flow rule ID associated with the flow rule @args rule: the actual flow rule

Returns
0 upon success, otherwise a negative integer

◆ update_rule_in_flow_cache()

bool FlowRuleCache::update_rule_in_flow_cache ( const int &  core_id,
const uint32_t &  rule_id,
const uint32_t &  int_rule_id,
String  rule 
)

Updates a flow rule using a two-phase commit. First checks if flow rule exists and if so deletes it. Then, inserts the new flow rule.

@args core_id: a new CPU core ID associated with this flow rule @args rule_id: the global flow rule ID of the flow rule to be updated @args int_rule_id: a new internal flow rule ID to be associated with this flow rule @args rule: the actual flow rule to be updated

Returns
true upon success, otherwise false

◆ delete_rule_by_global_id()

int32_t FlowRuleCache::delete_rule_by_global_id ( const uint32_t &  rule_id)

Deletes a flow rule from this flow rule cache using its global ID as an index.

@args rule_id: the global flow rule ID of the flow rule to be deleted

Returns
the internal flow rule ID being deleted upon success, otherwise a negative integer

◆ delete_rules_by_internal_id() [1/2]

String FlowRuleCache::delete_rules_by_internal_id ( const uint32_t *  int_rule_ids,
const uint32_t &  rules_nb 
)

Deletes a list of flow ules from this flow rule cache.

@args int_rule_ids: an array of internal flow rule IDs to be deleted @args rules_nb: the number of flow rule IDs to be deleted

Returns
a space-separated list of deleted internal flow rule IDs upon success, otherwise an empty string

◆ delete_rules_by_internal_id() [2/2]

String FlowRuleCache::delete_rules_by_internal_id ( const Vector< String > &  rules_vec)

Deletes a list of flow rules from this flow rule cache.

@args rules_vec: a vector of flow rule IDs to be deleted

Returns
a space-separated list of deleted internal flow rule IDs upon success, otherwise an empty string

◆ flush_rules_from_cache()

int32_t FlowRuleCache::flush_rules_from_cache ( )

Deletes all flow rules from this flow rule cache.

Returns
the number of flushed flow rules upon success, otherwise a negative integer

◆ set_matched_packets()

void FlowRuleCache::set_matched_packets ( const uint32_t &  int_rule_id,
uint64_t  value 
)

Sets a flow rule's packet counter.

@args int_rule_id: an internal flow rule ID @args value: a value to set the counter

◆ get_matched_packets()

uint64_t FlowRuleCache::get_matched_packets ( const uint32_t &  int_rule_id)

Gets the packet counter of a flow rule.

@args int_rule_id: an internal flow rule ID

Returns
packet counter of flow rule

◆ set_matched_bytes()

void FlowRuleCache::set_matched_bytes ( const uint32_t &  int_rule_id,
uint64_t  value 
)

Sets a flow rule's byte counter.

@args int_rule_id: an internal flow rule ID @args value: a value to set the counter

◆ get_matched_bytes()

uint64_t FlowRuleCache::get_matched_bytes ( const uint32_t &  int_rule_id)

Gets the byte counter of a flow rule.

@args int_rule_id: an internal flow rule ID

Returns
byte counter of flow rule

◆ initialize_rule_counters()

void FlowRuleCache::initialize_rule_counters ( uint32_t *  int_rule_ids,
const uint32_t &  rules_nb 
)

Initializes a set of flow rules in the packet and byte counters' memory, increments the flow rule counter and the next flow rule ID accordingly.

@args int_rule_ids: an array of internal flow rule IDs to be initialized @args rules_nb: the number of flow rules to be initialized

◆ delete_rule_counters()

void FlowRuleCache::delete_rule_counters ( uint32_t *  int_rule_ids,
const uint32_t &  rules_nb 
)

Deletes a set of flow rules from the packet and byte counters' memory and decrements the flow rule counter accordingly.

@args int_rule_ids: an array of internal flow rule IDs to be removed @args rules_nb: the number of flow rules to be removed

◆ cache_consistency_check()

void FlowRuleCache::cache_consistency_check ( const int32_t &  target_number_of_rules)

Performs a run-time consistency check with respect to the desired occupancy of the flow rule cache.

@args target_number_of_rules: desired flow rule occupancy @args int_vec: list of internal rule IDs to insert @args glb_vec: list of global rule IDs to insert

◆ correlate_candidate_id_with_cache()

void FlowRuleCache::correlate_candidate_id_with_cache ( int32_t &  candidate)

Correlates a given candidate max internal rule ID with the flow rule cache and updates it (if needed). For example: Cache: 4 5 6 9 21 24 25 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 47 50 56 60 63 64 65 66 Sorted Cache: 66 65 64 63 60 56 50 47 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 25 24 21 9 6 5 4 Delete: 66 65 64 63 50 47 Candidate max IDs: 66 65 64 63 Normal candidate: 63 (the least of the candidate max IDs) Real candidate: 61 (60 is the new maximum in the cache after the deletion, therefore the next ID is 60+1)

     Cache: 4  5  6  9  21 24 25 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 47 50 56 60 63 64 65 66

Sorted Cache: 66 65 64 63 60 56 50 47 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 25 24 21 9 6 5 4 Delete: 66 64 63 62 50 47 Candidate max IDs: 66 Normal candidate: 66 (the least of the candidate max IDs) Real candidate: 61 (60 is the new maximum in the cache after the deletion, therefore the next ID is 60+1)

  • candidate: candidate internal rule ID

◆ flush_rule_counters()

void FlowRuleCache::flush_rule_counters ( )

Resets the flow rule counters of this flow rule cache.


The documentation for this class was generated from the following files: