ROFL-pipeline  v0.6.0dev
of1x_instruction.h
Go to the documentation of this file.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef __OF1X_INSTRUCTION_H__
6 #define __OF1X_INSTRUCTION_H__
7 
8 #include <inttypes.h>
9 #include <stdbool.h>
10 #include "rofl.h"
11 #include "of1x_action.h"
12 #include "../../../common/datapacket.h"
13 
58 typedef enum {
59  OF1X_IT_NO_INSTRUCTION = 0, /* Setup the metadata field for use later in pipeline */
60  OF1X_IT_APPLY_ACTIONS = 1, /* Applies the action(s) immediately */
61  OF1X_IT_CLEAR_ACTIONS = 2, /* Clears all actions from the datapath action set */
62  OF1X_IT_WRITE_ACTIONS = 3, /* Write the action(s) onto the datapath action set */
63  OF1X_IT_WRITE_METADATA = 4, /* Setup the metadata field for use later in pipeline */
64 
65  OF1X_IT_EXPERIMENTER = 5, /* Experimenter instruction */
66  OF1X_IT_METER = 6, /* Meters */
67  OF1X_IT_GOTO_TABLE = 7, /* Setup the next table in the lookup pipeline: MUST BE the last one */
69 
70 #define OF1X_IT_MAX OF1X_IT_GOTO_TABLE+1
71 
72 //Write metadata instruction
73 typedef struct of1x_write_metadata{
74  uint64_t metadata;
75  uint64_t metadata_mask;
77 
78 
79 /* Instruction abstraction data structure */
80 typedef struct of1x_instruction{
81  //Type and value(for set fields and push)
83 
84  //Action group for APPLY_ACTIONS type only
85  of1x_action_group_t* apply_actions;
86 
87  //WRITE_ACTIONS type only actions
88  of1x_write_actions_t* write_actions;
89 
90  //WRITE_METADATA type only metadata
91  of1x_write_metadata_t write_metadata;
92 
93  //GO-TO-TABLE
94  unsigned int go_to_table;
96 
97 /* Instruction group, using a double-linked-list */
98 typedef struct of1x_instruction_group{
99  //Number of actions in the list
100  unsigned int num_of_instructions;
101 
102  of1x_instruction_t instructions[OF1X_IT_MAX]; //Latest must ALWAYS be MAX
103 
104  //Flag indicating that there are multiple
105  //outputs in several instructions/in an apply
106  //actions group.
107  //Note: this does NOT reflect the exact number of output
108  //actions when groups are used
109  unsigned int num_of_outputs;
110 
112 
113 //Fwd declaration
114 struct of1x_switch;
115 struct of1x_pipeline;
116 struct of1x_flow_entry;
117 struct of1x_group_table;
118 
119 /*
120 *
121 * Function prototypes
122 *
123 */
124 
125 //C++ extern C
126 ROFL_BEGIN_DECLS
127 
128 //Instruction group
129 
130 void __of1x_init_instruction_group(of1x_instruction_group_t* group);
131 void __of1x_destroy_instruction_group(of1x_instruction_group_t* group);
132 
133 //Add/remove instructions to/from group
142 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);
150 
151 //Update instructions
152 rofl_result_t __of1x_update_instructions(of1x_instruction_group_t* group, of1x_instruction_group_t* new_group);
153 
154 //Check whether instructions contain group
155 bool __of1x_instructions_contain_group(struct of1x_flow_entry *const entry, const unsigned int group_id);
156 
157 //Copy (clone) instructions: TODO evaluate if is necessary to check for errors
158 void __of1x_copy_instruction_group(of1x_instruction_group_t* origin, of1x_instruction_group_t* dest);
159 
161 
162 rofl_result_t __of1x_validate_instructions(of1x_instruction_group_t* inst_grp, struct of1x_pipeline* pipeline, unsigned int table_id);
163 
164 //Dump
165 void __of1x_dump_instructions(of1x_instruction_group_t group, bool raw_nbo);
166 
167 //C++ extern C
168 ROFL_END_DECLS
169 
170 #endif //OF1X_INSTRUCTION
of1x_packet_action_type_t
Actions over a packet as per defined in OF10, OF12, OF13.
Definition: of1x_action.h:89
bool __of1x_instruction_has(of1x_instruction_group_t *inst_grp, of1x_packet_action_type_t type, uint64_t value)
OpenFlow-enabled v1.0, 1.2 and 1.3.2 switch abstraction.
Definition: of1x_switch.h:28
OpenFlow v1.0, 1.2 and 1.3.2 flow entry structure.
Write actions structure.
Definition: of1x_action.h:330
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.
OpenFlow v1.0, 1.2 and 1.3.2 actions.
Action group (apply-actions) structure.
Definition: of1x_action.h:303
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.
Definition: of1x_pipeline.h:50
of1x_instruction_type_t
Instruction type.