ROFL-pipeline  v0.6.0dev
of1x_loop_ma_pp.h
1 #ifndef __OF1X_LOOP_MATCH_PP_H__
2 #define __OF1X_LOOP_MATCH_PP_H__
3 
4 #include "rofl.h"
5 #include "../../of1x_pipeline.h"
6 #include "../../of1x_flow_table.h"
7 #include "../../of1x_flow_entry.h"
8 #include "../../of1x_match_pp.h"
9 #include "../../of1x_group_table.h"
10 #include "../../of1x_instruction_pp.h"
11 #include "../../../of1x_async_events_hooks.h"
12 #include "../../../../../platform/lock.h"
13 #include "../../../../../platform/likely.h"
14 #include "../../../../../platform/memory.h"
15 #include "of1x_loop_ma.h"
16 
17 //C++ extern C
18 ROFL_BEGIN_DECLS
19 
20 /* FLOW entry lookup entry point */
21 static inline of1x_flow_entry_t* of1x_find_best_match_loop_ma(of1x_flow_table_t *const table, datapacket_t *const pkt){
22 
23  of1x_match_t* it;
24  of1x_flow_entry_t *entry;
25 
26 #ifndef ROFL_PIPELINE_LOCKLESS
27  //Prevent writers to change structure during matching
28  platform_rwlock_rdlock(table->rwlock);
29 #endif
30 
31  //Table is sorted out by nÂș of hits and priority N. First full match => best_match
32  for(entry = table->entries;entry!=NULL;entry = entry->next){
33  bool matched = true;
34 
35  for( it=entry->matches.head ; it ; it=it->next ){
36  if(!__of1x_check_match(pkt, it)){
37  matched = false;
38  break;
39  }
40  }
41 
42  if(matched){
43 #ifndef ROFL_PIPELINE_LOCKLESS
44  //Lock writers to modify the entry while packet processing. WARNING!!!! this must be released by the pipeline, once packet is processed!
45  platform_rwlock_rdlock(entry->rwlock);
46 
47  //Green light for writers
48  platform_rwlock_rdunlock(table->rwlock);
49 #endif
50  return entry;
51  }
52  }
53 
54 #ifndef ROFL_PIPELINE_LOCKLESS
55  //No match
56  //Green light for writers
57  platform_rwlock_rdunlock(table->rwlock);
58 #endif
59  return NULL;
60 }
61 
62 //C++ extern C
63 ROFL_END_DECLS
64 
65 #endif //OF1X_LOOP_MATCH_PP
void platform_rwlock_rdlock(platform_rwlock_t *rwlock)
Performs a read-lock over the platform_rwlock_t mutex platform_mutex_init().
void platform_rwlock_rdunlock(platform_rwlock_t *rwlock)
Performs a read-unlock over the platform_rwlock_t mutex platform_mutex_init().
OpenFlow v1.0, 1.2 and 1.3.2 flow entry structure.
OpenFlow v1.0, 1.2 and 1.3.2 flow table abstraction.
of1x_flow_entry_t * entries
This pointer may or may not be used depending on the matching algorithm.
Data packet abstraction.
Definition: datapacket.h:49