Add table config to to struct ofproto and set it when a table mod message is received.
This is in preparation for changing the behaviour of the switch based on table config. Cc: Andy Zhou <az...@nicira.com> Signed-off-by: Simon Horman <ho...@verge.net.au> --- v3 * As suggested by Ben Pfaff + Use atomic type for config field of struct oftable rather than guarding it using a rwlock + Check that table_id is within the usable range * Rename table_set_config as oftable_set_config as it operates on a struct oftable. * Use enum ofp_table_config as type of config parameter of oftable_set_config * Only updated configuration for supported table_mod config values. Currently there are no such values. v2 * Add OVS_EXCLUDED annotation to table_set_config(). This was mistakenly done in a subsequent patch. atomic table->config --- ofproto/ofproto-provider.h | 15 ++++++++++++++- ofproto/ofproto.c | 27 +++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h index 77553f6..dbcc254 100644 --- a/ofproto/ofproto-provider.h +++ b/ofproto/ofproto-provider.h @@ -213,6 +213,8 @@ enum oftable_flags { * Thread-safety * ============= * + * cls + * --- * A cls->rwlock read-lock holder prevents rules from being added or deleted. * * Adding or removing rules requires holding ofproto_mutex AND the cls->rwlock @@ -229,7 +231,12 @@ enum oftable_flags { * removing the rule from the classifier, release a ref_count from the rule * ('cls''s reference to the rule). * - * Refer to the thread-safety notes on struct rule for more information.*/ + * Refer to the thread-safety notes on struct rule for more information. + * + * config + * ------ + * config is guarded by config_rwlock. + */ struct oftable { enum oftable_flags flags; struct classifier cls; /* Contains "struct rule"s. */ @@ -260,8 +267,14 @@ struct oftable { uint32_t eviction_group_id_basis; struct hmap eviction_groups_by_id; struct heap eviction_groups_by_size; + + /* Table config: contains enum ofp_table_config; accessed atomically. */ + atomic_uint config; }; +BUILD_ASSERT_DECL(sizeof(unsigned int) >= sizeof(enum ofp_table_config)); + + /* Assigns TABLE to each oftable, in turn, in OFPROTO. * * All parameters are evaluated multiple times. */ diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 78a6a9a..3e643c6 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -5770,8 +5770,31 @@ handle_group_mod(struct ofconn *ofconn, const struct ofp_header *oh) } static enum ofperr +table_mod(struct ofproto *ofproto, const struct ofputil_table_mod *tm) +{ + /* XXX Reject all configurations because none are currently supported */ + return OFPERR_OFPTMFC_BAD_CONFIG; + + if (tm->table_id == OFPTT_ALL) { + int i; + for (i = 0; i < ofproto->n_tables; i++) { + atomic_store(&ofproto->tables[i].config, + (unsigned int)tm->config); + } + } else if (!check_table_id(ofproto, tm->table_id)) { + return OFPERR_OFPTMFC_BAD_TABLE; + } else { + atomic_store(&ofproto->tables[tm->table_id].config, + (unsigned int)tm->config); + } + + return 0; +} + +static enum ofperr handle_table_mod(struct ofconn *ofconn, const struct ofp_header *oh) { + struct ofproto *ofproto = ofconn_get_ofproto(ofconn); struct ofputil_table_mod tm; enum ofperr error; @@ -5785,8 +5808,7 @@ handle_table_mod(struct ofconn *ofconn, const struct ofp_header *oh) return error; } - /* XXX Actual table mod support is not implemented yet. */ - return 0; + return table_mod(ofproto, &tm); } static enum ofperr @@ -6619,6 +6641,7 @@ oftable_init(struct oftable *table) memset(table, 0, sizeof *table); classifier_init(&table->cls, flow_segment_u32s); table->max_flows = UINT_MAX; + atomic_init(&table->config, (unsigned int)OFPTC11_TABLE_MISS_CONTROLLER); } /* Destroys 'table', including its classifier and eviction groups. -- 1.8.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev