10 #include "../../../platform/memory.h"
11 #include "../../../platform/likely.h"
12 #include "../../../platform/timing.h"
13 #include "../../../platform/atomic_operations.h"
14 #include "../../../util/time.h"
35 entry->stats.initial_time = now;
84 if(unlikely(msg==NULL))
89 if(unlikely(msg->inst_grp==NULL)){
96 msg->table_id = entry->table->number;
97 msg->priority = entry->priority;
98 msg->cookie = entry->cookie;
99 msg->idle_timeout = entry->timer_info.idle_timeout;
100 msg->hard_timeout = entry->timer_info.hard_timeout;
101 msg->flags = entry->flags;
104 __of1x_stats_flow_consolidate(&entry->stats, &consolidated_stats);
105 msg->byte_count = consolidated_stats.byte_count;
106 msg->packet_count = consolidated_stats.packet_count;
113 msg->matches = __of1x_copy_matches(entry->matches.head);
116 __of1x_copy_instruction_group(&entry->inst_grp,msg->inst_grp);
124 if(unlikely(msg==NULL))
128 match = msg->matches;
136 __of1x_destroy_instruction_group(msg->inst_grp);
148 if(likely(msg!=NULL))
157 for(item=msg->flows_head; item; item = next_item){
158 next_item = item->next;
159 __of1x_destroy_stats_single_flow_msg(item);
171 if(unlikely(msg==NULL))
175 msg->flows_head = sfs;
177 msg->flows_tail->next = sfs;
179 msg->flows_tail = sfs;
181 msg->num_of_entries++;
188 memset(&entry->stats.s,0,
sizeof(
union __of1x_stats_flow_tids));
196 struct timeval now, diff;
200 TIMERSUB(&now, &entry->stats.initial_time, &diff);
203 *nsec = ( (diff.tv_usec*1000)&0xFFFFFFFF00000000ULL )>>32;
252 if(likely(msg!=NULL)){
254 if(msg->bucket_stats)
269 for(it=msg;it;it=next){
282 __of1x_stats_group_consolidate(&group->stats, &c);
284 msg->group_id = group->id;
285 msg->ref_count = group->stats.ref_count;
286 msg->packet_count = c.packet_count;
287 msg->byte_count = c.byte_count;
288 msg->num_of_buckets = group->bc_list->num_of_buckets;
293 for(bu_it=group->bc_list->head;bu_it;bu_it=bu_it->next,i++){
296 __of1x_stats_bucket_consolidate(&bu_it->stats, &cc);
298 msg->bucket_stats[i].byte_count = cc.byte_count;
299 msg->bucket_stats[i].packet_count = cc.packet_count;
308 if(
id == OF1X_GROUP_ALL ){
310 for(group=pipeline->groups->head;group;group=group->next){
314 msg = __of1x_get_group_single_stats(group);
328 head = __of1x_get_group_single_stats(group);
343 for(group_it=msg; group_it; group_it=next_gr){
344 next_gr = group_it->next;
347 for(bucket_it = group_it->bucket; bucket_it; bucket_it=next_bu){
348 next_bu = bucket_it->next;
349 __of1x_destroy_bucket_desc_stats(bucket_it);
361 if ( desc_bucket == NULL ){
364 desc_bucket->group = bucket->group;
365 desc_bucket->weight = bucket->weight;
366 desc_bucket->port = bucket->port;
368 desc_bucket->actions = __of1x_copy_action_group(bucket->actions);
369 desc_bucket->next = NULL;
382 msg->group_id = group->id;
383 msg->type = group->type;
386 for( bu_it = group->bc_list->head; bu_it; bu_it=bu_it->next){
387 bu_desc = __of1x_init_bucket_desc_stats(bu_it);
394 last->next = bu_desc;
410 for(group=pipeline->groups->head;group;group=group->next){
411 msg = __of1x_init_group_desc_single_stats(group);
446 uint32_t i,tid_start, tid_end;
450 if(table_id >= pipeline->num_of_tables && table_id != OF1X_FLOW_TABLE_ALL)
454 msg = __of1x_init_stats_flow_msg();
455 if(unlikely(msg==NULL))
459 if(table_id == OF1X_FLOW_TABLE_ALL){
461 tid_end = pipeline->num_of_tables;
463 tid_start = table_id;
464 tid_end = table_id+1;
467 for(i=tid_start;i<tid_end;i++){
468 if(of1x_matching_algorithms[pipeline->tables[i].matching_algorithm].
get_flow_stats_hook(&pipeline->tables[i], cookie, cookie_mask, out_port, out_group, matches, msg) != ROFL_SUCCESS){
478 uint32_t i, tid_start, tid_end;
482 if(table_id >= pipeline->num_of_tables && table_id != OF1X_FLOW_TABLE_ALL)
486 msg = __of1x_init_stats_flow_aggregate_msg();
488 if(unlikely(msg==NULL))
492 if(table_id == OF1X_FLOW_TABLE_ALL){
494 tid_end = pipeline->num_of_tables;
496 tid_start = table_id;
497 tid_end = table_id+1;
500 for(i=tid_start;i<tid_end;i++){
501 if(of1x_matching_algorithms[pipeline->tables[i].matching_algorithm].
get_flow_aggregate_stats_hook(&pipeline->tables[i], cookie, cookie_mask, out_port, out_group, matches, msg) != ROFL_SUCCESS){
OpenFlow v1.0, 1.2 and 1.3.2 pipeline abstraction.
of1x_stats_flow_aggregate_msg_t * of1x_get_flow_aggregate_stats(struct of1x_pipeline *pipeline, uint8_t table_id, uint32_t cookie, uint32_t cookie_mask, uint32_t out_port, uint32_t out_group, struct of1x_match_group *const matches)
Retrieves aggregated flow stats.
OpenFlow v1.0, 1.2 and 1.3.2 flow table abstraction.
Group structure definition.
OpenFlow v1.0, 1.2 and 1.3.2 flow entry structure.
rofl_result_t(* get_flow_stats_hook)(struct of1x_flow_table *const table, uint64_t cookie, uint64_t cookie_mask, uint32_t out_port, uint32_t out_group, of1x_match_group_t *const matches, of1x_stats_flow_msg_t *msg)
Retrieves flow stats according to spec The operation MUST comply with the behaviour defined in the Op...
void __of1x_stats_flow_reset_counts(struct of1x_flow_entry *entry)
of1x_stats_flow_reset_counts
OpenFlow v1.X instructions.
of1x_stats_group_msg_t * of1x_get_group_stats(of1x_pipeline_t *pipeline, uint32_t id)
Retrieves the statistics of a groupReturns a structure with the statistics that needs to be freed by ...
OpenFlow v1.0, 1.2 and 1.3.2 flow table abstraction.
void of1x_destroy_action_group(of1x_action_group_t *group)
Destroy an action group.
Single flow entry stats message.
void of1x_destroy_match(of1x_match_t *match)
Destroys whichever match previously created using of1x_init_match_*()
rofl_result_t(* get_flow_aggregate_stats_hook)(struct of1x_flow_table *const table, uint64_t cookie, uint64_t cookie_mask, uint32_t out_port, uint32_t out_group, of1x_match_group_t *const matches, of1x_stats_flow_aggregate_msg_t *msg)
Retrieves aggregate flow stats according to spec The operation MUST comply with the behaviour defined...
OpenFlow v1.0, 1.2 and 1.3.2 timers subsystem.
of1x_stats_flow_msg_t * of1x_get_flow_stats(struct of1x_pipeline *pipeline, uint8_t table_id, uint32_t cookie, uint32_t cookie_mask, uint32_t out_port, uint32_t out_group, struct of1x_match_group *const matches)
Retrieves individual flow stats.
Linked list containing all the individual flow stats.
void of1x_destroy_stats_flow_aggregate_msg(of1x_stats_flow_aggregate_msg_t *msg)
Destroy aggreagated flow_stats message.
void __of1x_stats_table_destroy(struct of1x_flow_table *table)
Destroys table statistics state.
void __of1x_destroy_flow_stats(struct of1x_flow_entry *entry)
of1x_stats_flow_destroy basically destroys the mutex
void __of1x_stats_table_init(struct of1x_flow_table *table)
Initializes table statistics state.
void of1x_destroy_stats_flow_msg(of1x_stats_flow_msg_t *msg)
Destroy a flow_stats message.
of1x_stats_group_desc_msg_t * of1x_get_group_desc_stats(of1x_pipeline_t *pipeline)
Retrieves a copy of the group and bucket structure.
OpenFlow v1.0, 1.2 and 1.3.2 flow entry abstraction.
void of1x_stats_flow_get_duration(struct of1x_flow_entry *entry, uint32_t *sec, uint32_t *nsec)
of1x_stats_flow_get_duration()
ROFL_BEGIN_DECLS void __of1x_init_flow_stats(struct of1x_flow_entry *entry)
operations in statistics.c
OpenFlow v1.0, 1.2 and 1.3.2 pipeline abstraction data structure.
Aggregated flow stats message.
OpenFlow v1.0, 1.2 and 1.3.2 statistics subsystem.
void of1x_destroy_stats_group_msg(of1x_stats_group_msg_t *msg)
Frees memory of statistics messageNeeds to be called after retrieving the statistics of the groups...
of1x_group_t * __of1x_group_search(of1x_group_table_t *gt, uint32_t id)
Searches in the table for an entry with a specific id returns pointer if found or NULL if not...
OpenFlow v1.0, 1.2 and 1.3.2 group table subsystem.
void of1x_destroy_group_desc_stats(of1x_stats_group_desc_msg_t *msg)
Frees the memory for a of1x_stats_group_desc_msg_t structure.