From patchwork Wed Jul 25 00:59:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 948969 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jirlUPIC"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41Zxj56vgPz9s0R for ; Wed, 25 Jul 2018 11:00:09 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9FDEEDAC; Wed, 25 Jul 2018 00:59:41 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 6AE74480 for ; Wed, 25 Jul 2018 00:59:39 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl0-f68.google.com (mail-pl0-f68.google.com [209.85.160.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 99A9D709 for ; Wed, 25 Jul 2018 00:59:37 +0000 (UTC) Received: by mail-pl0-f68.google.com with SMTP id 6-v6so2510912plb.0 for ; Tue, 24 Jul 2018 17:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zw4EuHXpJQ3XMr5/+QXCBbxUkGEtMDD2krHedXhR/Vo=; b=jirlUPICk1f6rF7SVBEEYrn7kHvUZ14XN9UnZbVKtZYuhH7P+11t56wvEpl7sT09n7 g4MuVCaFRTM3E+xqc3SX5cVSdcZswo1ZpXDix7xiq0NcBau//XozEoouO05JzfnLxMnj iN2uuBgajMtOQlr+4oCVok67QxoHnUihYc2ZiDePT14S6Pnk8zxm7596nDQA9oVnGJza fMUJamlyk6bXiQUsWVEH9zVuoEIk16/PMiblNM2gRe7mCAcPQSgnzNXG3vTNyuHpxsRn 6mvXmyouB66Y9qdZ2iesPXWs3OKd/xLvfgOeUZ/ASxK74HG5S72xbfChXtpwqlFnBlJd Sz2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zw4EuHXpJQ3XMr5/+QXCBbxUkGEtMDD2krHedXhR/Vo=; b=EzUXHt7LZlvEaV7G/OOqP7JnNnDx7BRGXCLv9nLnszPJCr986qKDpaR9tfmmfSt2Vy nh4K4xxgiHjnGKA/C14QqdIKaQXPDYTz8IR5OQn9QdIZnTVoNVq8zr3JzjITCcvhd7Ya hqfCDz8kuKdC0AXFVSXE0Ni7IoKZ4VvT5rmSfeqYzq99s5UaFF4FlabLyYlv4TH1cZ7P h74qE8txA9LR2BSfBn4RAXBFQ6rPr164Cv/BkgAvMTcVJGRL0vCvdGKsWDXOyMJVKyoI /T2znEvuC0vnrTT1NKxPv1V/BGvI1h5eLWXlvcjCMbydQr5lMcdW3Z+Z3VDdGbKWuY2w oULA== X-Gm-Message-State: AOUpUlGgjfeWpM/klTr37n12ZzT4/ZWTmK188eqhvv5WQ4SJnbLholBX iwjfXLdnAlxpdzqaBrxwr9j8GM4P X-Google-Smtp-Source: AAOMgpcNXVBgpfLaxrepn1IqEXd6tbCs6B4CFCtsK39uZRcSfvhWKkkFiCaNTLO3/zTwIx3RsWUnPA== X-Received: by 2002:a17:902:8d91:: with SMTP id v17-v6mr19255131plo.9.1532480377065; Tue, 24 Jul 2018 17:59:37 -0700 (PDT) Received: from localhost.localdomain.localdomain ([216.113.160.71]) by smtp.gmail.com with ESMTPSA id g11-v6sm18798424pgi.90.2018.07.24.17.59.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jul 2018 17:59:36 -0700 (PDT) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Tue, 24 Jul 2018 17:59:27 -0700 Message-Id: <1532480380-97578-2-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1532480380-97578-1-git-send-email-hzhou8@ebay.com> References: <1532480380-97578-1-git-send-email-hzhou8@ebay.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [RFC 01/14] ovsdb-idlc.in: Support more interfaces for passing pointers of individual tables. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This is a follow-up patch for commit 0eb1e37c, to add more interfaces that supports passing around pointers of individual tables, which will be used in incremental processing. Signed-off-by: Han Zhou --- ovsdb/ovsdb-idlc.in | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index ee655f7..1c9483c 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -251,6 +251,7 @@ const struct %(s)s *%(s)s_table_first(const struct %(s)s_table *); (ROW) = (NEXT)) const struct %(s)s *%(s)s_get_for_uuid(const struct ovsdb_idl *, const struct uuid *); +const struct %(s)s *%(s)s_table_get_for_uuid(const struct %(s)s_table *, const struct uuid *); const struct %(s)s *%(s)s_first(const struct ovsdb_idl *); const struct %(s)s *%(s)s_next(const struct %(s)s *); #define %(S)s_FOR_EACH(ROW, IDL) \\ @@ -271,6 +272,13 @@ const struct %(s)s *%(s)s_track_get_next(const struct %(s)s *); (ROW); \\ (ROW) = %(s)s_track_get_next(ROW)) +const struct %(s)s *%(s)s_table_track_get_first(const struct %(s)s_table *); +#define %(S)s_TABLE_FOR_EACH_TRACKED(ROW, TABLE) \\ + for ((ROW) = %(s)s_table_track_get_first(TABLE); \\ + (ROW); \\ + (ROW) = %(s)s_track_get_next(ROW)) + + /* Returns true if 'row' was inserted since the last change tracking reset. */ static inline bool %(s)s_is_new(const struct %(s)s *row) { @@ -479,6 +487,14 @@ const struct %(s)s * const struct ovsdb_idl *idl = (const struct ovsdb_idl *) table; return %(s)s_first(idl); } + + +const struct %(s)s * +%(s)s_table_track_get_first(const struct %(s)s_table *table) +{ + const struct ovsdb_idl *idl = (const struct ovsdb_idl *) table; + return %(s)s_track_get_first(idl); +} ''' % {'s': structName}) # Parse functions. @@ -655,6 +671,15 @@ const struct %(s)s * return %(s)s_cast(ovsdb_idl_get_row_for_uuid(idl, &%(p)stable_%(tl)s, uuid)); } +/* Searches table "%(t)s" for a row with UUID 'uuid'. Returns + * a pointer to the row if there is one, otherwise a null pointer. */ +const struct %(s)s * +%(s)s_table_get_for_uuid(const struct %(s)s_table *table, const struct uuid *uuid) +{ + const struct ovsdb_idl *idl = (const struct ovsdb_idl *) table; + return %(s)s_get_for_uuid(idl, uuid); +} + /* Returns a row in table "%(t)s" in 'idl', or a null pointer if that * table is empty. *