ROFL-pipeline  v0.6.0dev
of1x_group_table.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_GROUP_TABLE_H__
6 #define __OF1X_GROUP_TABLE_H__
7 
8 #include "rofl.h"
9 #include "of1x_statistics.h"
10 #include "of1x_action.h"
11 #include "of1x_flow_entry.h"
12 #include "of1x_group_types.h"
13 #include "../../../platform/lock.h"
14 
15 #define OF1X_GROUP_MAX 0xffffff00
16 #define OF1X_GROUP_ALL 0xfffffffc /* Represents all groups for group delete commands. */
17 #define OF1X_GROUP_ANY 0xffffffff /* Wildcard group used only for flow stats */
18 
29 typedef struct of1x_bucket{
30  uint16_t weight;
31  uint32_t port;
32  uint32_t group;
33  of1x_action_group_t *actions;
35  struct of1x_bucket *next;
37 
42 typedef struct of1x_bucket_list{
43  unsigned int num_of_buckets;
44  of1x_bucket_t* head;
45  of1x_bucket_t *tail;
47 
48 struct of1x_group_table;
49 
54 typedef struct of1x_group{
55  uint32_t id;
56  of1x_group_type_t type;
57  of1x_stats_group_t stats;
58  of1x_bucket_list_t *bc_list;
59 
60  struct of1x_group_table *group_table;
61 
62  platform_rwlock_t *rwlock;
63 
64  struct of1x_group *next;
65  struct of1x_group *prev;
66 
67  unsigned int num_of_output_actions;
69 
70 //Group table configuration
71 typedef struct{
72  bitmap128_t supported_actions; /* Bitmap of (1 << OF1X_AT_* that are supported by the group table. */
74 
75 typedef struct of1x_group_table{
76 
77  //Configuration
79 
80  uint32_t num_of_entries;
81 
82  platform_mutex_t *mutex;
83  platform_rwlock_t *rwlock;
84 
85  struct of1x_group *head;
86  struct of1x_group *tail;
87 
88  //Reference back
89  struct of1x_pipeline* pipeline;
90 
92 
93 typedef enum{
94  ROFL_OF1X_GM_OK = 0, /* No error */
95  ROFL_OF1X_GM_EXISTS = 1, /* Group already exists */
96  ROFL_OF1X_GM_INVAL = 2, /* Invalid group -wrong properties- */
97  ROFL_OF1X_GM_WEIGHT = 3, /* Weights not supported */
98  ROFL_OF1X_GM_OGRUPS = 4, /* Out of groups */
99  ROFL_OF1X_GM_OBUCKETS = 5, /* Out of buckets */
100  ROFL_OF1X_GM_CHAIN = 6, /* Chaining not supported */
101  ROFL_OF1X_GM_WATCH = 7, /* Watch not supported */
102  ROFL_OF1X_GM_LOOP = 8, /* Loop in group */
103  ROFL_OF1X_GM_UNKGRP = 9, /* Unkown group */
104  ROFL_OF1X_GM_CHNGRP = 10, /* Chained group */
105  ROFL_OF1X_GM_BTYPE = 11, /* Bad type */
106  ROFL_OF1X_GM_BCOMMAND = 12, /* Bad command */
107  ROFL_OF1X_GM_BBUCKET = 13, /* Bad bucket */
108  ROFL_OF1X_GM_BWATCH = 14, /* Bad watch */
109  ROFL_OF1X_GM_EPERM = 15, /* Permissions error */
110 }rofl_of1x_gm_result_t;
111 
112 //fwd decls
113 struct of1x_pipeline;
114 
115 //C++ extern C
116 ROFL_BEGIN_DECLS
117 
118 //function declarations
119 
127 
135 
142 rofl_of1x_gm_result_t of1x_group_add(of1x_group_table_t *gt, of1x_group_type_t type, uint32_t id, of1x_bucket_list_t **buckets);
143 
150 rofl_of1x_gm_result_t of1x_group_modify(of1x_group_table_t *gt, of1x_group_type_t type, uint32_t id, of1x_bucket_list_t **buckets);
151 
158 rofl_of1x_gm_result_t of1x_group_delete( struct of1x_pipeline *pipeline, of1x_group_table_t *gt, uint32_t id);
159 
167 
175 
182 of1x_bucket_t* of1x_init_bucket(uint16_t weight, uint32_t port, uint32_t group, of1x_action_group_t* actions);
183 
189 rofl_result_t of1x_insert_bucket_in_list(of1x_bucket_list_t *bu_list,of1x_bucket_t *bucket);
190 
192 void __of12_set_group_table_defaults(of1x_group_table_t *gt);
193 void __of13_set_group_table_defaults(of1x_group_table_t *gt);
194 /*
195 * Dump group table. Not recommended to use it directly
196 *
197 * @param raw_nbo Show values in the pipeline internal byte order (NBO). Warning: some values are intentionally unaligned.
198 */
199 void of1x_dump_group_table(of1x_group_table_t *gt, bool raw_nbo);
200 
201 //C++ extern C
202 ROFL_END_DECLS
203 
204 #endif // __OF1X_GROUP_TABLE_H__
struct of1x_bucket of1x_bucket_t
Group bucket.
struct of1x_group of1x_group_t
Group structure definition.
Group structure definition.
of1x_bucket_t * of1x_init_bucket(uint16_t weight, uint32_t port, uint32_t group, of1x_action_group_t *actions)
Initializes a bucket.
Group bucket.
rofl_result_t of1x_insert_bucket_in_list(of1x_bucket_list_t *bu_list, of1x_bucket_t *bucket)
Inserts an initialized bucket in the list of buckets.
struct of1x_bucket_list of1x_bucket_list_t
Group bucket list.
rofl_of1x_gm_result_t of1x_group_modify(of1x_group_table_t *gt, of1x_group_type_t type, uint32_t id, of1x_bucket_list_t **buckets)
Modifies a group on the table.
enum of1x_group_type of1x_group_type_t
Group type.
of1x_bucket_list_t * of1x_init_bucket_list(void)
Initializes a list of buckets.
OpenFlow v1.0, 1.2 and 1.3.2 actions.
ROFL_BEGIN_DECLS of1x_group_table_t * of1x_init_group_table(struct of1x_pipeline *pipeline)
Initializes the group table.
void of1x_destroy_group_table(of1x_group_table_t *gt)
Destroys the group table.
Action group (apply-actions) structure.
Definition: of1x_action.h:303
rofl_of1x_gm_result_t of1x_group_delete(struct of1x_pipeline *pipeline, of1x_group_table_t *gt, uint32_t id)
Deletes a group of the table.
rofl_of1x_gm_result_t of1x_group_add(of1x_group_table_t *gt, of1x_group_type_t type, uint32_t id, of1x_bucket_list_t **buckets)
Adds a group to the table.
OpenFlow v1.0, 1.2 and 1.3.2 flow entry abstraction.
Group bucket list.
OpenFlow v1.0, 1.2 and 1.3.2 pipeline abstraction data structure.
Definition: of1x_pipeline.h:50
OpenFlow v1.0, 1.2 and 1.3.2 statistics subsystem.
void of1x_destroy_bucket_list(of1x_bucket_list_t *bc_list)
Destroys the bucket list.
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...