From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E446C282C4 for ; Mon, 4 Feb 2019 19:41:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 50F382175B for ; Mon, 4 Feb 2019 19:41:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AVc3muur" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726261AbfBDTle (ORCPT ); Mon, 4 Feb 2019 14:41:34 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46707 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbfBDTld (ORCPT ); Mon, 4 Feb 2019 14:41:33 -0500 Received: by mail-pg1-f194.google.com with SMTP id w7so356381pgp.13 for ; Mon, 04 Feb 2019 11:41:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=pc9Kd/zKbNipdPPH4mPG7l+gIpXi/vim58A/FUhBwco=; b=AVc3muur0luQq/T/rqwTsXYqc4JjdaBj9m0IYUyT5UK/SN+poNbxqjDV6k6ozks6li zBd/uTgL8aQR4ATBYxYpyl/J0Pog93eRM0W2n5e1vz70HClVdz7bGGfs+1wAUyZx/BvP HhxrPhjnuvhdRdVGib1UtqeHQs+N9fv0grB6riqQjPpmhhtCfo8Zylp+Tw7yikAtQEvY SvuudbiZdKvhetWj26ys+MYhoRMDwboD3q9XWO2bvh3GCCffAEY2cPclgtMxU58i8hQx cly4mN5KVEadQjEMYikvYY+NFBIbHO0emm5/UrFZY9qD3M1l2/Z5bMYkRg6aBR7c5K/Z rmxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=pc9Kd/zKbNipdPPH4mPG7l+gIpXi/vim58A/FUhBwco=; b=TlkH93YeKbGO3XQEqJvR7jsePxYqaGQseaTdLvwre4/Oe5fdfY7VTwgauHSNGUEUWn Amrf7CQ3alrI/X6F08lQM4w3nSBbNg1ysI4/GOeNtQt8xzgV8C+mfLbdsP33QH/dTK7H pOBQRt6RENWbYjIh68kccgiGxwZwA6m3efW6hQ63ZJie5mZ8z4CSQvte0TNz/bVlViiv xaaGPp1V/9c/kwGaBdnxN3nRfmjrFpadFNhzUSHnYvGUL8tjKI9F0CJIvxMMvH8sIpvR ydDj5K2dOKVPsZaoCS5aHsnP+tI5KXS5gv3Ti2b9aD2yRfU70dddGdLLByN8lBtlz9Fw uBaA== X-Gm-Message-State: AHQUAuYPsNMZQttb9kJ0zQsdOhlDeQ8GmUudV7G9K4Z4DP3mL7smMXP+ cLrBsGpybqN3pocGZeWQnLg= X-Google-Smtp-Source: AHgI3IYgF+urpz5eDY6tqh6HM6kFEqUyx86j8KlDZHGtAZru8tvg7JMpAXh5JlYBhswtHzp6dovzEw== X-Received: by 2002:a63:f74f:: with SMTP id f15mr832557pgk.190.1549309292563; Mon, 04 Feb 2019 11:41:32 -0800 (PST) Received: from [192.168.0.16] ([97.115.131.42]) by smtp.gmail.com with ESMTPSA id z14sm963736pgv.47.2019.02.04.11.41.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Feb 2019 11:41:31 -0800 (PST) Subject: Re: [ovs-dev] [PATCH net-next V2 1/1] openvswitch: Declare ovs key structures using macros To: Eli Britstein , Pravin B Shelar Cc: dev@openvswitch.org, netdev@vger.kernel.org, Simon Horman , "David S. Miller" References: <20190203091217.8459-1-elibr@mellanox.com> From: Gregory Rose Message-ID: <0bbab6ba-5892-e0c3-8290-6d844414ca2e@gmail.com> Date: Mon, 4 Feb 2019 11:41:29 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190203091217.8459-1-elibr@mellanox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2/3/2019 1:12 AM, Eli Britstein wrote: > Declare ovs key structures using macros as a pre-step towards to > enable retrieving fields information, as a work done in proposed > commit in the OVS tree https://patchwork.ozlabs.org/patch/1023406/ > ("odp-util: Do not rewrite fields with the same values as matched"), > with no functional change. > > Signed-off-by: Eli Britstein > Reviewed-by: Roi Dayan Obscuring the structures with these macros is awful.  I'm opposed but I see it has already been accepted upstream so I guess that's that. Ugh... - Greg > --- > include/uapi/linux/openvswitch.h | 102 ++++++++++++++++++++++++++------------- > 1 file changed, 69 insertions(+), 33 deletions(-) > > diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h > index dbe0cbe4f1b7..dc8246f871fd 100644 > --- a/include/uapi/linux/openvswitch.h > +++ b/include/uapi/linux/openvswitch.h > @@ -387,73 +387,109 @@ enum ovs_frag_type { > > #define OVS_FRAG_TYPE_MAX (__OVS_FRAG_TYPE_MAX - 1) > > +#define OVS_KEY_FIELD_ARR(type, name, elements) type name[elements]; > +#define OVS_KEY_FIELD(type, name) type name; > + > +#define OVS_KEY_ETHERNET_FIELDS \ > + OVS_KEY_FIELD_ARR(__u8, eth_src, ETH_ALEN) \ > + OVS_KEY_FIELD_ARR(__u8, eth_dst, ETH_ALEN) > + > struct ovs_key_ethernet { > - __u8 eth_src[ETH_ALEN]; > - __u8 eth_dst[ETH_ALEN]; > + OVS_KEY_ETHERNET_FIELDS > }; > > struct ovs_key_mpls { > __be32 mpls_lse; > }; > > +#define OVS_KEY_IPV4_FIELDS \ > + OVS_KEY_FIELD(__be32, ipv4_src) \ > + OVS_KEY_FIELD(__be32, ipv4_dst) \ > + OVS_KEY_FIELD(__u8, ipv4_proto) \ > + OVS_KEY_FIELD(__u8, ipv4_tos) \ > + OVS_KEY_FIELD(__u8, ipv4_ttl) \ > + OVS_KEY_FIELD(__u8, ipv4_frag /* One of OVS_FRAG_TYPE_*. */) > + > struct ovs_key_ipv4 { > - __be32 ipv4_src; > - __be32 ipv4_dst; > - __u8 ipv4_proto; > - __u8 ipv4_tos; > - __u8 ipv4_ttl; > - __u8 ipv4_frag; /* One of OVS_FRAG_TYPE_*. */ > + OVS_KEY_IPV4_FIELDS > }; > > +#define OVS_KEY_IPV6_FIELDS \ > + OVS_KEY_FIELD_ARR(__be32, ipv6_src, 4) \ > + OVS_KEY_FIELD_ARR(__be32, ipv6_dst, 4) \ > + OVS_KEY_FIELD(__be32, ipv6_label /* 20-bits in least-significant bits. */) \ > + OVS_KEY_FIELD(__u8, ipv6_proto) \ > + OVS_KEY_FIELD(__u8, ipv6_tclass) \ > + OVS_KEY_FIELD(__u8, ipv6_hlimit) \ > + OVS_KEY_FIELD(__u8, ipv6_frag /* One of OVS_FRAG_TYPE_*. */) > + > struct ovs_key_ipv6 { > - __be32 ipv6_src[4]; > - __be32 ipv6_dst[4]; > - __be32 ipv6_label; /* 20-bits in least-significant bits. */ > - __u8 ipv6_proto; > - __u8 ipv6_tclass; > - __u8 ipv6_hlimit; > - __u8 ipv6_frag; /* One of OVS_FRAG_TYPE_*. */ > + OVS_KEY_IPV6_FIELDS > }; > > +#define OVS_KEY_TCP_FIELDS \ > + OVS_KEY_FIELD(__be16, tcp_src) \ > + OVS_KEY_FIELD(__be16, tcp_dst) > + > struct ovs_key_tcp { > - __be16 tcp_src; > - __be16 tcp_dst; > + OVS_KEY_TCP_FIELDS > }; > > +#define OVS_KEY_UDP_FIELDS \ > + OVS_KEY_FIELD(__be16, udp_src) \ > + OVS_KEY_FIELD(__be16, udp_dst) > + > struct ovs_key_udp { > - __be16 udp_src; > - __be16 udp_dst; > + OVS_KEY_UDP_FIELDS > }; > > +#define OVS_KEY_SCTP_FIELDS \ > + OVS_KEY_FIELD(__be16, sctp_src) \ > + OVS_KEY_FIELD(__be16, sctp_dst) > + > struct ovs_key_sctp { > - __be16 sctp_src; > - __be16 sctp_dst; > + OVS_KEY_SCTP_FIELDS > }; > > +#define OVS_KEY_ICMP_FIELDS \ > + OVS_KEY_FIELD(__u8, icmp_type) \ > + OVS_KEY_FIELD(__u8, icmp_code) > + > struct ovs_key_icmp { > - __u8 icmp_type; > - __u8 icmp_code; > + OVS_KEY_ICMP_FIELDS > }; > > +#define OVS_KEY_ICMPV6_FIELDS \ > + OVS_KEY_FIELD(__u8, icmpv6_type) \ > + OVS_KEY_FIELD(__u8, icmpv6_code) > + > struct ovs_key_icmpv6 { > - __u8 icmpv6_type; > - __u8 icmpv6_code; > + OVS_KEY_ICMPV6_FIELDS > }; > > +#define OVS_KEY_ARP_FIELDS \ > + OVS_KEY_FIELD(__be32, arp_sip) \ > + OVS_KEY_FIELD(__be32, arp_tip) \ > + OVS_KEY_FIELD(__be16, arp_op) \ > + OVS_KEY_FIELD_ARR(__u8, arp_sha, ETH_ALEN) \ > + OVS_KEY_FIELD_ARR(__u8, arp_tha, ETH_ALEN) > + > struct ovs_key_arp { > - __be32 arp_sip; > - __be32 arp_tip; > - __be16 arp_op; > - __u8 arp_sha[ETH_ALEN]; > - __u8 arp_tha[ETH_ALEN]; > + OVS_KEY_ARP_FIELDS > }; > > +#define OVS_KEY_ND_FIELDS \ > + OVS_KEY_FIELD_ARR(__be32, nd_target, 4) \ > + OVS_KEY_FIELD_ARR(__u8, nd_sll, ETH_ALEN) \ > + OVS_KEY_FIELD_ARR(__u8, nd_tll, ETH_ALEN) > + > struct ovs_key_nd { > - __be32 nd_target[4]; > - __u8 nd_sll[ETH_ALEN]; > - __u8 nd_tll[ETH_ALEN]; > + OVS_KEY_ND_FIELDS > }; > > +#undef OVS_KEY_FIELD_ARR > +#undef OVS_KEY_FIELD > + > #define OVS_CT_LABELS_LEN_32 4 > #define OVS_CT_LABELS_LEN (OVS_CT_LABELS_LEN_32 * sizeof(__u32)) > struct ovs_key_ct_labels {