From patchwork Tue Sep 29 20:40:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 524017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id BD003140180 for ; Wed, 30 Sep 2015 06:41:26 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id DF66B106E4; Tue, 29 Sep 2015 13:41:07 -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 D6CA9106C4 for ; Tue, 29 Sep 2015 13:41:04 -0700 (PDT) Received: from bar3.cudamail.com (bar1 [192.168.15.1]) by mx3v1.cudamail.com (Postfix) with ESMTP id 973446191FE for ; Tue, 29 Sep 2015 14:41:03 -0600 (MDT) X-ASG-Debug-ID: 1443559260-03dd7b4fa1017d0001-byXFYA Received: from mx3-pf1.cudamail.com ([192.168.14.2]) by bar3.cudamail.com with ESMTP id P3nMM9DifUAuWxGn (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 29 Sep 2015 14:41:00 -0600 (MDT) X-Barracuda-Envelope-From: joestringer@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.2 Received: from unknown (HELO mail-pa0-f52.google.com) (209.85.220.52) by mx3-pf1.cudamail.com with ESMTPS (RC4-SHA encrypted); 29 Sep 2015 20:41:00 -0000 Received-SPF: unknown (mx3-pf1.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.52 Received: by pacex6 with SMTP id ex6so16052123pac.0 for ; Tue, 29 Sep 2015 13:40:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bdj1SsUk+eoIMXqS8WbDK1FoNIzdOmE29QkitCjj8nc=; b=PwnlCjpiatrCtT1aiqOgTfqrXoRxTFaciiM8x0azYWLQulsTupa/L197ojUjOSt4kG wdX1Cq9hUQYlpqX+7eurZZZ2E1gFc/eMYcRgV9ly618eLyG5BFcJz5kMYwqo8ggDyQA0 sfwqJstJKSIH0gjrz7h1BOCOM0BKK2ZXJKg8YD7auzohQWY51cd6SGNnd5ASioLdmCP0 YcrHsBBHZMmJX1mZvt/AKZbaatNTo82ImJaFGO2rCoYtBnkUT58TSKQS/0OmtBqBNzfH ktJvPPr55apXGWiUzG9qoCzkpQnV576JDx8wdXGEc8vyQYnNQavwvD+ZGoD0LEqYTz20 SBAA== X-Gm-Message-State: ALoCoQnatXB1jFGWY22R99zuwHB/bK4vWywXQvw5/9AWIMHYVXx5MJlEyb54G09vOf8cGp26tICQ X-Received: by 10.66.55.41 with SMTP id o9mr29160pap.44.1443559259506; Tue, 29 Sep 2015 13:40:59 -0700 (PDT) Received: from localhost.localdomain ([208.91.2.4]) by smtp.gmail.com with ESMTPSA id fe8sm27450431pab.40.2015.09.29.13.40.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Sep 2015 13:40:59 -0700 (PDT) X-CudaMail-Envelope-Sender: joestringer@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.2.4 From: Joe Stringer To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V1-928069451 X-CudaMail-DTE: 092915 X-CudaMail-Originating-IP: 209.85.220.52 Date: Tue, 29 Sep 2015 13:40:26 -0700 X-ASG-Orig-Subj: [##CM-V1-928069451##][PATCHv3 03/11] types: Add big-endian 128-bit types. Message-Id: <1443559234-7330-4-git-send-email-joestringer@nicira.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443559234-7330-1-git-send-email-joestringer@nicira.com> References: <1443559234-7330-1-git-send-email-joestringer@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.14.2] X-Barracuda-Start-Time: 1443559260 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCHv3 03/11] types: Add big-endian 128-bit types. 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" These types will be used by the following patches to ensure a consistent wire format for 128-bit connection tracking labels. Signed-off-by: Joe Stringer --- include/openvswitch/types.h | 7 +++++++ lib/byte-order.h | 14 ++++++++++++++ lib/meta-flow.h | 1 + lib/util.h | 21 +++++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h index c138b9c..bb8d3ae 100644 --- a/include/openvswitch/types.h +++ b/include/openvswitch/types.h @@ -88,6 +88,13 @@ typedef union { } u64; } ovs_u128; +typedef union { + ovs_be32 be32[4]; + struct { + ovs_be64 hi, lo; + } be64; +} ovs_be128; + /* A 64-bit value, in network byte order, that is only aligned on a 32-bit * boundary. */ typedef struct { diff --git a/lib/byte-order.h b/lib/byte-order.h index 544f46f..0749ff4 100644 --- a/lib/byte-order.h +++ b/lib/byte-order.h @@ -42,6 +42,20 @@ ovs_be64 htonll(uint64_t); uint64_t ntohll(ovs_be64); #endif +static inline void +hton128(const ovs_u128 *src, ovs_be128 *dst) +{ + dst->be64.hi = htonll(src->u64.lo); + dst->be64.lo = htonll(src->u64.hi); +} + +static inline void +ntoh128(const ovs_be128 *src, ovs_u128 *dst) +{ + dst->u64.hi = ntohll(src->be64.lo); + dst->u64.lo = ntohll(src->be64.hi); +} + static inline uint32_t uint32_byteswap(uint32_t crc) { return (((crc & 0x000000ff) << 24) | diff --git a/lib/meta-flow.h b/lib/meta-flow.h index 02272ef..f9379f9 100644 --- a/lib/meta-flow.h +++ b/lib/meta-flow.h @@ -1742,6 +1742,7 @@ union mf_value { uint8_t tun_metadata[128]; struct in6_addr ipv6; struct eth_addr mac; + ovs_be128 be128; ovs_be64 be64; ovs_be32 be32; ovs_be16 be16; diff --git a/lib/util.h b/lib/util.h index 7080a0c..4c7f716 100644 --- a/lib/util.h +++ b/lib/util.h @@ -568,6 +568,27 @@ ovs_u128_equals(const ovs_u128 *a, const ovs_u128 *b) return (a->u64.hi == b->u64.hi) && (a->u64.lo == b->u64.lo); } +/* Returns true if 'val' is 0. */ +static inline bool +ovs_u128_is_zero(const ovs_u128 *val) +{ + return !(val->u64.hi || val->u64.lo); +} + +/* Returns non-zero if the parameters have equal value. */ +static inline int +ovs_be128_equals(const ovs_be128 *a, const ovs_be128 *b) +{ + return (a->be64.hi == b->be64.hi) && (a->be64.lo == b->be64.lo); +} + +/* Returns true if 'val' is 0. */ +static inline bool +ovs_be128_is_zero(const ovs_be128 *val) +{ + return !(val->be64.hi || val->be64.lo); +} + void xsleep(unsigned int seconds); #ifdef _WIN32