3 #include "../of1x_switch.h"
8 #include "../../../util/logging.h"
9 #include "../../../platform/likely.h"
10 #include "../../../platform/memory.h"
15 if( unlikely(type==OF1X_IT_NO_INSTRUCTION) )
20 inst->apply_actions = apply_actions;
21 inst->write_actions = write_actions;
24 inst->write_metadata = *write_metadata;
26 if(type == OF1X_IT_GOTO_TABLE)
27 inst->go_to_table = go_to_table;
33 if(inst->type == OF1X_IT_NO_INSTRUCTION)
36 if(inst->apply_actions)
39 if(inst->write_actions)
40 __of1x_destroy_write_actions(inst->write_actions);
53 for(i=0;i<OF1X_IT_MAX;i++)
54 __of1x_destroy_instruction(&group->instructions[i]);
56 group->num_of_instructions=0;
62 __of1x_destroy_instruction(&group->instructions[type]);
63 group->num_of_instructions--;
69 if(group->instructions[type].type != OF1X_IT_NO_INSTRUCTION)
72 __of1x_init_instruction(&group->instructions[type], type, apply_actions, write_actions, write_metadata, go_to_table);
73 group->num_of_instructions++;
87 if(__of1x_update_apply_actions(&group->instructions[OF1X_IT_APPLY_ACTIONS].apply_actions, new_group->instructions[OF1X_IT_APPLY_ACTIONS].apply_actions)!=ROFL_SUCCESS)
94 if(__of1x_update_write_actions(&group->instructions[OF1X_IT_WRITE_ACTIONS].write_actions, new_group->instructions[OF1X_IT_WRITE_ACTIONS].write_actions) != ROFL_SUCCESS)
105 group->instructions[OF1X_IT_CLEAR_ACTIONS] = new_group->instructions[OF1X_IT_CLEAR_ACTIONS];
106 group->instructions[OF1X_IT_GOTO_TABLE] = new_group->instructions[OF1X_IT_GOTO_TABLE];
110 group->num_of_instructions = new_group->num_of_instructions;
116 bool __of1x_instructions_contain_group(
of1x_flow_entry_t *
const entry,
const unsigned int group_id){
118 return __of1x_write_actions_has(entry->inst_grp.instructions[OF1X_IT_WRITE_ACTIONS].write_actions,OF1X_AT_GROUP,group_id)
119 || __of1x_apply_actions_has(entry->inst_grp.instructions[OF1X_IT_APPLY_ACTIONS].apply_actions,OF1X_AT_GROUP,group_id);
128 for(i=0;i<OF1X_IT_MAX;i++){
131 switch(origin->instructions[i].type){
133 case OF1X_IT_CLEAR_ACTIONS:
134 case OF1X_IT_EXPERIMENTER:
135 case OF1X_IT_WRITE_METADATA:
136 case OF1X_IT_GOTO_TABLE:
137 dest->instructions[i] = origin->instructions[i];
140 case OF1X_IT_APPLY_ACTIONS:
141 dest->instructions[i] = origin->instructions[i];
142 dest->instructions[i].apply_actions = __of1x_copy_action_group(origin->instructions[i].apply_actions);
144 case OF1X_IT_WRITE_ACTIONS:
145 dest->instructions[i] = origin->instructions[i];
146 dest->instructions[i].write_actions = __of1x_copy_write_actions(origin->instructions[i].write_actions);
150 dest->instructions[i] = origin->instructions[i];
160 unsigned int i,has_write_actions=0, has_apply_actions=0;
162 ROFL_PIPELINE_INFO(
"\t\tInst->> ");
164 for(i=0;i<OF1X_IT_MAX;i++){
167 switch(group.instructions[i].type){
168 case OF1X_IT_APPLY_ACTIONS:
169 ROFL_PIPELINE_INFO_NO_PREFIX(
" APPLY, ");
172 case OF1X_IT_CLEAR_ACTIONS:
173 ROFL_PIPELINE_INFO_NO_PREFIX(
" CLEAR, ");
175 case OF1X_IT_WRITE_ACTIONS:
176 ROFL_PIPELINE_INFO_NO_PREFIX(
" WRITE, ");
179 case OF1X_IT_WRITE_METADATA:
180 ROFL_PIPELINE_INFO_NO_PREFIX(
" WRITE-META(0x%"PRIx64
":0x%"PRIx64
"), ", group.instructions[i].write_metadata.metadata, group.instructions[i].write_metadata.metadata_mask);
182 case OF1X_IT_EXPERIMENTER:
183 ROFL_PIPELINE_INFO_NO_PREFIX(
" EXP, ");
185 case OF1X_IT_GOTO_TABLE:
186 ROFL_PIPELINE_INFO_NO_PREFIX(
" GOTO(%u), ",group.instructions[i].go_to_table);
193 case OF1X_IT_NO_INSTRUCTION:
197 ROFL_PIPELINE_INFO_NO_PREFIX(
"\n");
198 if( has_apply_actions ){
199 ROFL_PIPELINE_INFO(
"\t\t\tAPP.ACTIONs:");
200 __of1x_dump_action_group(group.instructions[OF1X_IT_APPLY_ACTIONS].apply_actions, raw_nbo);
201 ROFL_PIPELINE_INFO_NO_PREFIX(
"\n");
203 if( has_write_actions ){
204 ROFL_PIPELINE_INFO(
"\t\t\tWR.ACTIONs:");
205 __of1x_dump_write_actions(group.instructions[OF1X_IT_WRITE_ACTIONS].write_actions, raw_nbo);
206 ROFL_PIPELINE_INFO_NO_PREFIX(
"\n");
213 return ( __of1x_write_actions_has(inst_grp->instructions[OF1X_IT_WRITE_ACTIONS].write_actions, type, value) ||
214 __of1x_apply_actions_has(inst_grp->instructions[OF1X_IT_APPLY_ACTIONS].apply_actions, type, value) );
218 int i, num_of_output_actions=0;
220 of_version_t version = pipeline->sw->of_ver;
224 for(i=0;i<OF1X_IT_MAX;i++){
225 switch(inst_grp->instructions[i].type){
226 case OF1X_IT_NO_INSTRUCTION:
230 case OF1X_IT_APPLY_ACTIONS:
231 if(__of1x_validate_action_group(&table->config.apply_actions, inst_grp->instructions[i].apply_actions, gt,
false) != ROFL_SUCCESS)
233 num_of_output_actions+=inst_grp->instructions[i].apply_actions->num_of_output_actions;
234 if( (version < inst_grp->instructions[i].apply_actions->ver_req.min_ver) ||
235 (version > inst_grp->instructions[i].apply_actions->ver_req.max_ver) )
240 case OF1X_IT_WRITE_ACTIONS:
242 if( (version < OF_VERSION_12))
245 if(__of1x_validate_write_actions(&table->config.write_actions, inst_grp->instructions[i].write_actions, gt) != ROFL_SUCCESS)
248 num_of_output_actions+=inst_grp->instructions[i].write_actions->num_of_output_actions;
249 if( (version < inst_grp->instructions[i].write_actions->ver_req.min_ver) ||
250 (version > inst_grp->instructions[i].write_actions->ver_req.max_ver) )
255 case OF1X_IT_GOTO_TABLE:
257 case OF1X_IT_WRITE_METADATA:
258 case OF1X_IT_CLEAR_ACTIONS:
259 case OF1X_IT_EXPERIMENTER:
261 if( (version < OF_VERSION_12))
267 if( (version < OF_VERSION_13))
276 inst_grp->num_of_outputs = num_of_output_actions;
of1x_packet_action_type_t
Actions over a packet as per defined in OF10, OF12, OF13.
OpenFlow v1.0, 1.2 and 1.3.2 pipeline abstraction.
bool __of1x_instruction_has(of1x_instruction_group_t *inst_grp, of1x_packet_action_type_t type, uint64_t value)
OpenFlow v1.0, 1.2 and 1.3.2 flow entry structure.
OpenFlow v1.X instructions.
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.
void of1x_add_instruction_to_group(of1x_instruction_group_t *group, of1x_instruction_type_t type, of1x_action_group_t *apply_actions, of1x_write_actions_t *write_actions, of1x_write_metadata_t *write_metadata, unsigned int go_to_table)
Adds an instruction of the group.
Action group (apply-actions) structure.
OpenFlow v1.0, 1.2 and 1.3.2 flow entry abstraction.
void of1x_remove_instruction_from_the_group(of1x_instruction_group_t *group, of1x_instruction_type_t type)
Remove an instruction of the group.
OpenFlow v1.0, 1.2 and 1.3.2 pipeline abstraction data structure.
OpenFlow v1.0, 1.2 and 1.3.2 group table subsystem.
of1x_instruction_type_t
Instruction type.