From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B963545B09; Thu, 10 Oct 2024 22:00:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A48E4402BB; Thu, 10 Oct 2024 22:00:46 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 85E914028E for ; Thu, 10 Oct 2024 22:00:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728590444; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OOa86xGqThnHFXnQwLxbErRrLO2xOubbsUVJLs0+Mdo=; b=GWcmRLJPuxu4imDhqaL7u8Y7mu6icFYmnyfMniPBJUn0bTtmYoJBAjP7bZI62R9x1/6DJF vUvd9lgvFNCvbzDy2wdj58FGD8aG1m1p9KN/hKXqfGcDCz0RfY0brgbblV/6dqpgRdSVuQ xBNOY/SQ1hs4nbCD/08wf5vRYxY/Qco= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-TlIv6YJ2MbOCwAUE04Yzcg-1; Thu, 10 Oct 2024 16:00:42 -0400 X-MC-Unique: TlIv6YJ2MbOCwAUE04Yzcg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42cb374f0cdso7441445e9.0 for ; Thu, 10 Oct 2024 13:00:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728590440; x=1729195240; h=in-reply-to:references:user-agent:to:from:subject:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=6RYWgvoLiaybzJXmb4L+t6dcrsa5QW1Qi1h33wEWQzg=; b=hALffVujJ80F7VvnPAHs01B+OWZk3r71cx7bH9gsbS/rG/uGK6VvesA3DwtediRwfn uRhCUrnf7oc3wsfyywa1JCZPAfLGdCKJyB7W74QAGlLWU+p9pYsSgW/UQgQYUjw2af34 yGWXuevQ4d/tT1Gt/v2eRNva8LMafMLUktVH7Gm6RQAL8XFmraKX1SegvzQ4uKaGZD9X OQcoeAE3edwjOk+2H8w8jVIN70XiItfB4XgFsxS7R1H41E4EhiVdNLJUALoiPf9TVA3c a/Ybq1gs4YpIgF5WMVwfuTgrAoYycfeFNArhL1tRqVmWYhGx06SBZYhRsJOtCOSWiG9G 2g1w== X-Forwarded-Encrypted: i=1; AJvYcCWAKiV3TX4EwuiloMUeweeLONOSLXKWq0a/2M2BUr7kbYp3JMSE/RKccWfmp6rq3pfoEIw=@dpdk.org X-Gm-Message-State: AOJu0Yz0DooIlaUkIGEyLg5nhVDlFASCz9uoRPWdmYsS6RraC/OLCsaQ W8tNrKHvg6PqwO5MvnpOOzwcxgimoMSYwdS9IaM1p8Gx2+wGQgQe/7Sa2TlOML/A7F4vqsAu3+3 1UUhCRlD9jJTNk8Z9HqfKDyZ7xz6uDo21EEhEZQ4m X-Received: by 2002:a5d:53cd:0:b0:37c:ca20:52a with SMTP id ffacd0b85a97d-37d551d4f7cmr229316f8f.8.1728590440624; Thu, 10 Oct 2024 13:00:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpprMEyuMDuDX/k6BFc4l26UQBH2A1eP8RUgRFIdwYLPG1k9ckyOFNAMf/Zgfyo2FZMQ9USA== X-Received: by 2002:a5d:53cd:0:b0:37c:ca20:52a with SMTP id ffacd0b85a97d-37d551d4f7cmr229297f8f.8.1728590440145; Thu, 10 Oct 2024 13:00:40 -0700 (PDT) Received: from localhost (2a01cb00025433001b9f807167cdbf20.ipv6.abo.wanadoo.fr. [2a01:cb00:254:3300:1b9f:8071:67cd:bf20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b7ef4f6sm2297756f8f.107.2024.10.10.13.00.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Oct 2024 13:00:39 -0700 (PDT) Mime-Version: 1.0 Date: Thu, 10 Oct 2024 22:00:38 +0200 Message-Id: Subject: Re: [PATCH dpdk v2 16/16] ipv6: add function to check ipv6 version From: "Robin Jarry" To: =?utf-8?q?Morten_Br=C3=B8rup?= , User-Agent: aerc/0.18.2-74-g7e4ac1a5f54c References: <20240821162516.610624-17-rjarry@redhat.com> <20241001081728.301272-1-rjarry@redhat.com> <20241001081728.301272-17-rjarry@redhat.com> <98CBD80474FA8B44BF855DF32C47DC35E9F77C@smartserver.smartshare.dk> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F77C@smartserver.smartshare.dk> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8; format=Flowed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Morten, Morten Br=C3=B8rup, Oct 06, 2024 at 11:02: > Personally, I would prefer following the convention of rte_ether function= s to return boolean (as int)... > > static inline int rte_is__ether_addr(const struct rte_ether_addr *ea) Sorry, I haven't followed your recommendation in v3, but I have a good=20 reason :) I find that functions following that naming scheme are impossible to=20 find since they all start with the same "rte_is_" prefix regardless of=20 the DPDK module in which they are defined. It it is particularly=20 annoying when using code completion with clangd or similar tools. rte_is_power_of_2 rte_is_aligned rte_is_same_ether_addr rte_is_zero_ether_addr rte_is_unicast_ether_addr rte_is_multicast_ether_addr rte_is_broadcast_ether_addr rte_is_universal_ether_addr rte_is_local_admin_ether_addr rte_is_valid_assigned_ether_addr The ethernet address functions are even more extreme as they end all=20 with the same suffix: rte___ All other public API seems to follow the inverse logic: rte___ It does not follow the natural English language but more of an inverse=20 polish notation. However, it feels more user friendly and better=20 discoverable. rte_ipv6_addr_eq rte_ipv6_addr_eq_prefix rte_ipv6_addr_is_linklocal rte_ipv6_addr_is_loopback rte_ipv6_addr_is_mcast rte_ipv6_addr_is_sitelocal rte_ipv6_addr_is_unspec rte_ipv6_addr_is_v4compat rte_ipv6_addr_is_v4mapped rte_ipv6_addr_mask rte_ipv6_llocal_from_ethernet rte_ipv6_mask_depth rte_ipv6_mc_scope rte_ipv6_solnode_from_addr I hope I'm making sense :) > static inline int rte_is_ipv6_version(const struct rte_ipv6_hdr *ip) > { > =09return ip->vtc_flow & RTE_IPV6_VTC_FLOW_VERSION_MASK =3D=3D RTE_IPV6_V= TC_FLOW_VERSION; > } > > Or, at your preference, an optimized variant: > static inline int rte_is_version_ipv6(const struct rte_ipv6_hdr *ip) > { > =09return *(const unsigned char *)ip & 0xf0 =3D=3D 0x60; > } > > The first nibble is also used for version in IPv4, so an IPv4 variant wou= ld look similar: > static inline int rte_is_version_ipv4(const struct rte_ip_hdr *ip) > { > =09return *(const unsigned char *)ip & 0xf0 =3D=3D 0x40; > } I had missed this in ipv4. I could rework it for v4 if there are other=20 remarks. Thanks for the review!