From 67761761a4a49f8af7d04b0e3dd9ae9b0534540c Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Mon, 16 Dec 2013 17:53:22 +0900 Subject: [PATCH] ofproto: Add table config to struct ofproto 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 Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- ofproto/ofproto-provider.h | 3 +++ ofproto/ofproto.c | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h index 77553f61c..bc08189ae 100644 --- a/ofproto/ofproto-provider.h +++ b/ofproto/ofproto-provider.h @@ -260,6 +260,9 @@ 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; }; /* Assigns TABLE to each oftable, in turn, in OFPROTO. diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 363c05001..ef444a24a 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -5772,9 +5772,32 @@ 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; @@ -5788,8 +5811,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 @@ -6622,6 +6644,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. -- 2.45.2