From patchwork Wed Sep 9 07:43:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: saloni.jain12@gmail.com X-Patchwork-Id: 515735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 4FFEF140663 for ; Wed, 9 Sep 2015 17:43:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=c9Rib2Qn; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 6AC411091C; Wed, 9 Sep 2015 00:43:55 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v1.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 63E7C10919 for ; Wed, 9 Sep 2015 00:43:54 -0700 (PDT) Received: from bar3.cudamail.com (bar1 [192.168.15.1]) by mx3v1.cudamail.com (Postfix) with ESMTP id E14B361914C for ; Wed, 9 Sep 2015 01:43:53 -0600 (MDT) X-ASG-Debug-ID: 1441784630-03dd7b725c00e50001-byXFYA Received: from mx3-pf1.cudamail.com ([192.168.14.2]) by bar3.cudamail.com with ESMTP id lFjjnboaAppl9DOm (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 09 Sep 2015 01:43:50 -0600 (MDT) X-Barracuda-Envelope-From: saloni.jain12@gmail.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.2 Received: from unknown (HELO mail-pa0-f53.google.com) (209.85.220.53) by mx3-pf1.cudamail.com with ESMTPS (RC4-SHA encrypted); 9 Sep 2015 07:43:44 -0000 Received-SPF: pass (mx3-pf1.cudamail.com: SPF record at _netblocks.google.com designates 209.85.220.53 as permitted sender) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.53 Received: by padhk3 with SMTP id hk3so2338747pad.3 for ; Wed, 09 Sep 2015 00:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=ei68wyvHRyoUCRAL8k2EhpCji0PAoXEBEyO41Fh8VW0=; b=c9Rib2QnVt8BUyg70EDhBxRudpCd+8Gkr6xV3aUcYJYOFKXmz0XNszz9NsH9R4Ae3r 0OigADT94AdKvDZssKYIX4FIXtgc4eXaxVZgmzM+3B8Ul3zWRKKfMRxPsSV03LfsI0Mu u2sxAZKl0CSAJBnMc5Ty/x3dNoN2vAWTb7mNfo6m8L7rPes3ojMhLGForl1yy1R2vqPD W8PSzYp237QTUIXc60ysUywJ4ymXLdpy+DLzasMNemOdiYHm0iTgIxb6+eb4X9JRWf2B aCh6OaskSP18obFTIdQfTp5UJVXLfw0YfMMiPQEfTW5UqFPD+27NOYHE4EpIqs4MfvKQ q7ew== X-Received: by 10.66.186.141 with SMTP id fk13mr58272147pac.7.1441784623795; Wed, 09 Sep 2015 00:43:43 -0700 (PDT) Received: from localhost.localdomain ([117.247.166.121]) by smtp.gmail.com with ESMTPSA id hz5sm5934114pbb.39.2015.09.09.00.43.40 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Sep 2015 00:43:42 -0700 (PDT) X-CudaMail-Envelope-Sender: saloni.jain12@gmail.com X-Barracuda-Apparent-Source-IP: 117.247.166.121 From: saloni.jain12@gmail.com X-Google-Original-From: saloni.jain@tcs.com To: dev@openvswitch.org X-CudaMail-MID: CM-V1-908001722 X-CudaMail-DTE: 090915 X-CudaMail-Originating-IP: 209.85.220.53 Date: Wed, 9 Sep 2015 13:13:22 +0530 X-ASG-Orig-Subj: [##CM-V1-908001722##][PATCH v4 2/3] Implement Vacancy Events for OFPMP_TABLE_DESC. Message-Id: <1441784602-8073-1-git-send-email-saloni.jain@tcs.com> X-Mailer: git-send-email 1.7.9.5 X-GBUdb-Analysis: 0, 209.85.220.53, Ugly c=0.486243 p=-0.357143 Source Normal X-MessageSniffer-Rules: 0-0-0-15513-c X-Barracuda-Connect: UNKNOWN[192.168.14.2] X-Barracuda-Start-Time: 1441784630 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=3.0 tests=BSF_SC5_MJ1963, DKIM_SIGNED, NO_REAL_NAME, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.22365 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 NO_REAL_NAME From: does not include a real name 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Cc: deepankar.gupta@tcs.com, partha.datta@tcs.com, Hiteshi Kalra Subject: [ovs-dev] [PATCH v4 2/3] Implement Vacancy Events for OFPMP_TABLE_DESC. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" From: Saloni Jain This patch adds support for vacancy events in table-desc. ovs-ofctl -O OpenFlow14 dump-tables-desc -This command is enhanced to display the Vacancy Event configuration of the tables on a , which is set using the mod-table command. Signed-off-by: Saloni Jain Co-authored-by: Hiteshi Kalra Signed-off-by: Hiteshi Kalra --- Difference between v3->v4 - Rebased with latest master. - Added Co-authored-by tag in commit message. 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 9fe05bd..14b2ba3 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -1054,6 +1054,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 6c181f8..199da44 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -4887,6 +4887,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_* @@ -4928,6 +4944,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) { @@ -4945,6 +4962,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; @@ -4997,6 +5018,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 64f3a96..a569d55 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 e3f08a8..04df388 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -1727,7 +1727,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 @@ -1740,6 +1741,13 @@ mv expout orig-expout sed -e '2s/eviction=off/eviction=on/' 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%/' expout +AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d +/^OFPST_TABLE_DESC/d'], [0], [expout]) OVS_VSWITCHD_STOP AT_CLEANUP