From patchwork Sat Apr 30 00:02:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aymerich, Edward" X-Patchwork-Id: 617004 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3qxW3C5Pcqz9t5Y for ; Sat, 30 Apr 2016 10:02:31 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id BF220102D3; Fri, 29 Apr 2016 17:02:30 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 9923B10170 for ; Fri, 29 Apr 2016 17:02:29 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 1DE6E42044D for ; Fri, 29 Apr 2016 18:02:29 -0600 (MDT) X-ASG-Debug-ID: 1461974548-09eadd135d68d70001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar5.cudamail.com with ESMTP id pAkgledtLNNv8Q7U (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 29 Apr 2016 18:02:28 -0600 (MDT) X-Barracuda-Envelope-From: edward.aymerich@hpe.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO na01-by2-obe.outbound.protection.outlook.com) (207.46.100.114) by mx3-pf3.cudamail.com with ESMTPS (AES256-SHA encrypted); 30 Apr 2016 00:02:27 -0000 Received-SPF: none (mx3-pf3.cudamail.com: domain at hpe.com does not designate permitted sender hosts) X-Barracuda-Apparent-Source-IP: 207.46.100.114 X-Barracuda-RBL-IP: 207.46.100.114 Received: from TU4PR84MB0142.NAMPRD84.PROD.OUTLOOK.COM (10.162.187.148) by TU4PR84MB0142.NAMPRD84.PROD.OUTLOOK.COM (10.162.187.148) with Microsoft SMTP Server (TLS) id 15.1.477.8; Sat, 30 Apr 2016 00:02:26 +0000 Received: from TU4PR84MB0142.NAMPRD84.PROD.OUTLOOK.COM ([10.162.187.148]) by TU4PR84MB0142.NAMPRD84.PROD.OUTLOOK.COM ([10.162.187.148]) with mapi id 15.01.0477.014; Sat, 30 Apr 2016 00:02:26 +0000 X-CudaMail-Envelope-Sender: edward.aymerich@hpe.com From: "Aymerich, Edward" To: "' (dev@openvswitch.org)'" X-CudaMail-MID: CM-V3-428054561 X-CudaMail-DTE: 042916 X-CudaMail-Originating-IP: 207.46.100.114 Thread-Topic: [PATCH 2/3] ovsdb-idlc.in: Autogenerate Partial Map Updates functions X-ASG-Orig-Subj: [##CM-V3-428054561##][PATCH 2/3] ovsdb-idlc.in: Autogenerate Partial Map Updates functions Thread-Index: AdGic1MdhYtqZ2yzSUeZSbTZ7l4AKg== Date: Sat, 30 Apr 2016 00:02:25 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: openvswitch.org; dkim=none (message not signed) header.d=none; openvswitch.org; dmarc=none action=none header.from=hpe.com; x-originating-ip: [201.195.119.46] x-ms-office365-filtering-correlation-id: a34c47a4-7293-4f11-901c-08d3708ab6a0 x-microsoft-exchange-diagnostics: 1; TU4PR84MB0142; 5:Jhldp6Ew6Ax5SMJvxWY7+0zgXIpFTYD0/qbgyvt0KJyDyk1qyY29EobpOwXv/RQ7Kt+GMewWJ4AUl9f7V5ljdJNe9uzqXkScwFfgoo2mlT7gaGqRAu82PD2Cw9peP9FZ6grvOn3AzI5kmBAk7wp7wQ==; 24:jEJC9EgKPtcecx/zpVRAuzzxSDUq/+z9HeEFsPIb18An9wcawDOySON9avKFM5AIxXOMrL9Ro34k0tKS1PmdXU4Z1RggruJ2CNLtv4j5Yns=; 7:EqTFzPrg5Tg136MdTDRtOva5ka9A6DG7iGI2LEMGKY3wXJO3w8/fb9nuJ0Q1UE4zbEf1FOa42n5MsSVF4bZWNft2v6fN3iUpoS/UvDdm36Ket/quLDv4LchnSx2JFHBPLl5jnK/RFsbyJ/oAENiJ6sH8E0qmtnWmGQfdXVRKsTA5O7pOXjv/b8691IFPIlUW x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:TU4PR84MB0142; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(9101521072)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:TU4PR84MB0142; BCL:0; PCL:0; RULEID:; SRVR:TU4PR84MB0142; x-forefront-prvs: 0928072091 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(86362001)(54356999)(99286002)(15650500001)(189998001)(586003)(450100001)(9686002)(107886002)(110136002)(229853001)(33656002)(19580395003)(19580405001)(5008740100001)(575784001)(1096002)(5002640100001)(1220700001)(50986999)(66066001)(3846002)(81166005)(5003600100002)(2906002)(5004730100002)(122556002)(102836003)(87936001)(15975445007)(92566002)(3660700001)(77096005)(10400500002)(2900100001)(3280700002)(11100500001); DIR:OUT; SFP:1102; SCL:1; SRVR:TU4PR84MB0142; H:TU4PR84MB0142.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Apr 2016 00:02:26.0051 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: TU4PR84MB0142 X-GBUdb-Analysis: 0, 207.46.100.114, Ugly c=0.303425 p=-0.263158 Source Normal X-MessageSniffer-Rules: 0-0-0-12418-c X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1461974548 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.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_RULE7568M, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.29165 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS Subject: [ovs-dev] [PATCH 2/3] ovsdb-idlc.in: Autogenerate Partial Map Updates functions 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: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" Code inserted that autogenerates corresponding map functions to set and delete elements in map columns. Inserts description to the functions that are autogenerated. Signed-off-by: Edward Aymerich Signed-off-by: Arnoldo Lutz Co-authored-by: Arnoldo Lutz --- The corresponding pull request is available here: https://github.com/openvswitch/ovs/pull/121 ovsdb/ovsdb-idlc.in | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) -- 2.1.4 diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 26b0de4..19a86dc 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -216,6 +216,13 @@ bool %(s)s_is_updated(const struct %(s)s *, enum %(s)s_column_id); print '%s);' % ', '.join(args) print + for columnName, column in sorted(table.columns.iteritems()): + if column.type.is_map(): + print 'void %(s)s_update_%(c)s_setkey(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, + print '%(coltype)s, %(valtype)s);' % {'coltype':column.type.key.toCType(prefix), 'valtype':column.type.value.toCType(prefix)} + print 'void %(s)s_update_%(c)s_delkey(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, + print '%(coltype)s);' % {'coltype':column.type.key.toCType(prefix)} + print # Table indexes. printEnum("%stable_id" % prefix.lower(), ["%sTABLE_%s" % (prefix.upper(), tableName.upper()) for tableName in sorted(schema.tables)] + ["%sN_TABLES" % prefix.upper()]) @@ -746,6 +753,68 @@ const struct ovsdb_datum * 'S': structName.upper(), 'C': columnName.upper()} print "}" + # Update/Delete of partial map column functions + for columnName, column in sorted(table.columns.iteritems()): + type = column.type + if type.is_map(): + print ''' +/* Sets an element of the "%(c)s" map column from the "%(t)s" table in 'row' + * to 'new_value' given the key value 'new_key'. + * + */ +void +%(s)s_update_%(c)s_setkey(const struct %(s)s *row, %(coltype)snew_key, %(valtype)snew_value) +{ + struct ovsdb_datum *datum; + + ovs_assert(inited); + + datum = xmalloc(sizeof *datum); + datum->n = 1; + datum->keys = xmalloc(datum->n * sizeof *datum->keys); + datum->values = xmalloc(datum->n * sizeof *datum->values); +''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), + 'valtype':column.type.value.toCType(prefix), 'S': structName.upper(), + 'C': columnName.upper(), 't': tableName} + + print " "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "new_key") + print " "+ type.value.copyCValue("datum->values[0].%s" % type.value.type.to_string(), "new_value") + print ''' + ovsdb_idl_txn_write_partial_map(&row->header_, + &%(s)s_columns[%(S)s_COL_%(C)s], + datum); +}''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), + 'valtype':column.type.value.toCType(prefix), 'S': structName.upper(), + 'C': columnName.upper()} + print ''' +/* Deletes an element of the "%(c)s" map column from the "%(t)s" table in 'row' + * given the key value 'delete_key'. + * + */ +void +%(s)s_update_%(c)s_delkey(const struct %(s)s *row, %(coltype)sdelete_key) +{ + struct ovsdb_datum *datum; + + ovs_assert(inited); + + datum = xmalloc(sizeof *datum); + datum->n = 1; + datum->keys = xmalloc(datum->n * sizeof *datum->keys); + datum->values = NULL; +''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), + 'valtype':column.type.value.toCType(prefix), 'S': structName.upper(), + 'C': columnName.upper(), 't': tableName} + + print " "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "delete_key") + print ''' + ovsdb_idl_txn_delete_partial_map(&row->header_, + &%(s)s_columns[%(S)s_COL_%(C)s], + datum); +}''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), + 'valtype':column.type.value.toCType(prefix), 'S': structName.upper(), + 'C': columnName.upper()} + # End Update/Delete of partial maps # Table columns. print "\nstruct ovsdb_idl_column %s_columns[%s_N_COLUMNS];" % (