From: Saloni Jain <saloni.j...@tcs.com> This patch adds support for vacancy events in table-desc.
ovs-ofctl -O OpenFlow14 dump-tables-desc <switch> -This command is enhanced to display the Vacancy Event configuration of the tables on a <switch>, which is set using the mod-table command. Signed-off-by: Saloni Jain <saloni.j...@tcs.com> --- lib/ofp-print.c | 11 +++++++++++ lib/ofp-util.c | 31 +++++++++++++++++++++++++++++++ ofproto/ofproto.c | 26 +++++++++++++++++++++----- tests/ofproto.at | 10 +++++++++- 4 files changed, 72 insertions(+), 6 deletions(-) diff --git a/lib/ofp-print.c b/lib/ofp-print.c index cf35aa6..0c3b8a9 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -1057,6 +1057,17 @@ ofp_print_table_desc(struct ds *string, const struct ofputil_table_desc *td) ofputil_table_eviction_to_string(td->eviction)); ofputil_put_eviction_flags(string, td->eviction_flags); ds_put_char(string, '\n'); + ds_put_format(string, " vacancy=%s", + ofputil_table_vacancy_to_string(td->vacancy)); + if (td->vacancy == OFPUTIL_TABLE_VACANCY_ON) { + ds_put_format(string, " vacancy_down=%"PRIu8"%%", + td->table_vacancy.vacancy_down); + ds_put_format(string, " vacancy_up=%"PRIu8"%%", + td->table_vacancy.vacancy_up); + ds_put_format(string, " vacancy=%"PRIu8"%%", + td->table_vacancy.vacancy); + } + ds_put_char(string, '\n'); } static void diff --git a/lib/ofp-util.c b/lib/ofp-util.c index e2e90ff..6446d33 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -4903,6 +4903,22 @@ parse_table_desc_eviction_property(struct ofpbuf *property, return 0; } +static enum ofperr +parse_table_desc_vacancy_property(struct ofpbuf *property, + struct ofputil_table_desc *td) +{ + struct ofp14_table_mod_prop_vacancy *otv = property->data; + + if (property->size != sizeof *otv) { + return OFPERR_OFPBPC_BAD_LEN; + } + + td->table_vacancy.vacancy_down = otv->vacancy_down; + td->table_vacancy.vacancy_up = otv->vacancy_up; + td->table_vacancy.vacancy = otv->vacancy; + return 0; +} + /* Decodes the next OpenFlow "table desc" message (of possibly several) from * 'msg' into an abstract form in '*td'. Returns 0 if successful, EOF if the * last "table desc" in 'msg' was already decoded, otherwise an OFPERR_* @@ -4944,6 +4960,7 @@ ofputil_decode_table_desc(struct ofpbuf *msg, ofpbuf_use_const(&properties, ofpbuf_pull(msg, length), length); td->eviction = ofputil_decode_table_eviction(otd->config, version); + td->vacancy = ofputil_decode_table_vacancy(otd->config, version); td->eviction_flags = UINT32_MAX; while (properties.size > 0) { @@ -4961,6 +4978,10 @@ ofputil_decode_table_desc(struct ofpbuf *msg, error = parse_table_desc_eviction_property(&payload, td); break; + case OFPTMPT14_VACANCY: + error = parse_table_desc_vacancy_property(&payload, td); + break; + default: log_property(true, "unknown table_desc property %"PRIu16, type); error = 0; @@ -5013,6 +5034,16 @@ ofputil_append_table_desc_reply(const struct ofputil_table_desc *td, ote->length = htons(sizeof *ote); ote->flags = htonl(td->eviction_flags); } + if (td->vacancy == OFPUTIL_TABLE_VACANCY_ON) { + struct ofp14_table_mod_prop_vacancy *otv; + + otv = ofpbuf_put_zeros(reply, sizeof *otv); + otv->type = htons(OFPTMPT14_VACANCY); + otv->length = htons(sizeof *otv); + otv->vacancy_down = td->table_vacancy.vacancy_down; + otv->vacancy_up = td->table_vacancy.vacancy_up; + otv->vacancy = td->table_vacancy.vacancy; + } otd = ofpbuf_at_assert(reply, start_otd, sizeof *otd); otd->length = htons(reply->size - start_otd); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 176ff10..86e21e2 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -3576,6 +3576,26 @@ handle_table_features_request(struct ofconn *ofconn, return 0; } +static void +query_table_desc__(struct ofputil_table_desc *td, + struct ofproto *ofproto, uint8_t table_id) +{ + unsigned int count = ofproto->tables[table_id].n_flows; + unsigned int max_flows = ofproto->tables[table_id].max_flows; + + td->table_id = table_id; + td->eviction = (ofproto->tables[table_id].eviction & EVICTION_OPENFLOW + ? OFPUTIL_TABLE_EVICTION_ON + : OFPUTIL_TABLE_EVICTION_OFF); + td->eviction_flags = OFPROTO_EVICTION_FLAGS; + td->vacancy = (ofproto->tables[table_id].vacancy & OFPTC14_VACANCY_EVENTS + ? OFPUTIL_TABLE_VACANCY_ON + : OFPUTIL_TABLE_VACANCY_OFF); + td->table_vacancy.vacancy_down = ofproto->tables[table_id].vacancy_down; + td->table_vacancy.vacancy_up = ofproto->tables[table_id].vacancy_up; + td->table_vacancy.vacancy = (count * 100) / max_flows; +} + /* This function queries the database for dumping table-desc. */ static void query_tables_desc(struct ofproto *ofproto, struct ofputil_table_desc **descp) @@ -3586,11 +3606,7 @@ query_tables_desc(struct ofproto *ofproto, struct ofputil_table_desc **descp) table_desc = *descp = xcalloc(ofproto->n_tables, sizeof *table_desc); for (i = 0; i < ofproto->n_tables; i++) { struct ofputil_table_desc *td = &table_desc[i]; - td->table_id = i; - td->eviction = (ofproto->tables[i].eviction & EVICTION_OPENFLOW - ? OFPUTIL_TABLE_EVICTION_ON - : OFPUTIL_TABLE_EVICTION_OFF); - td->eviction_flags = OFPROTO_EVICTION_FLAGS; + query_table_desc__(td, ofproto, i); } } diff --git a/tests/ofproto.at b/tests/ofproto.at index cf5ab9f..4e1bd5e 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -1671,7 +1671,8 @@ OVS_VSWITCHD_START while test $x -lt 254; do y=`expr $x + 1` echo " table $x: - eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME" + eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME + vacancy=off" x=$y done) > expout AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d @@ -1684,6 +1685,13 @@ mv expout orig-expout sed -e '2s/eviction=off/eviction=on/' <orig-expout > expout AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d /^OFPST_TABLE_DESC/d'], [0], [expout]) + +AT_CHECK([ovs-ofctl -O Openflow14 mod-table br0 0 vacancy-20..80]) +# Check that the configuration was updated. +mv expout orig-expout +sed -e '3s/vacancy=off/vacancy=on vacancy_down=20% vacancy_up=80% vacancy=0%/' <orig-expout > expout +AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d +/^OFPST_TABLE_DESC/d'], [0], [expout]) OVS_VSWITCHD_STOP AT_CLEANUP -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev