Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp346968rwb; Wed, 28 Sep 2022 03:39:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48hKSk1VPvM0ZjfcwEtNxKbtT+XcFlgMZxadIxKpVFpoBogUCz/wFnTpA7mEowPlzpea8Q X-Received: by 2002:a17:906:ee8e:b0:730:3646:d178 with SMTP id wt14-20020a170906ee8e00b007303646d178mr27307880ejb.426.1664361557638; Wed, 28 Sep 2022 03:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664361557; cv=none; d=google.com; s=arc-20160816; b=t7LsSVZcUrrvMyrQCN9JC5frTSGB6Gd6IYlB/YK37sB71F8rOJV4zUHxoPPUM8c53K /6HW45F7wAn7noIDgc+6jLRPtns5vEPLisa2dcCj++rdgt6SfhThiaOkfyg+6rLnzd8S hVE/Zu0OueftHgJv24uBpfwK+qVjSbldyEDTbBWt+nVZwuhW3/sq98kqGvrO1RI2MSsc QRXejFL53b7F/J0UW7CIujSyKfPvYCWqyS0E+GaqF5psYmD4R14JoHNkPp+N3HJilIVm H2EIRlV7wlT9RtJT5xKJdpvHGNCWhTsLxkV6ods9D53NJ7cWUoyHzE960k9FS+iJ0qVo mLyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qgEqcM9zLlzGsnMunDNBZ2L1/a19UKSEORTmJlm9ISs=; b=QrPicBeYWqJ8Puum/OnjKHXuZVJJbevv42Ha0SJGGPlv98cp8853IXsgvH20eNy+kz 2hs4jjZxFZdbh79C8pLoJYJPGWVLk36lKVd+10zzze4GXrzPCkZXuqp4E+UPz/oiGOLh lo2PNyNLr8ALEBcn/qpDiqtCv4eZQssK0tw1tes8YdZP2t5Pq+KPKrX6pUoYFVLvy5ce DXg5wfWsvkos//K8vZEV3bXCJiN2be1dQ6AcydBj1ZoIlCuSRQpk9YQTmC9i/al5I6RN AJBTGzwBNAXijvq6WBRX/qJ/UT0PfjqBQCewUEjaK5fXkhokauE4jyjCnMBMdj5aJswx SupQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="en/cO4Uv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf24-20020a1709077f1800b0077ffa45c01esi4646324ejc.725.2022.09.28.03.38.51; Wed, 28 Sep 2022 03:39:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="en/cO4Uv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233528AbiI1Ked (ORCPT + 99 others); Wed, 28 Sep 2022 06:34:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233070AbiI1Keb (ORCPT ); Wed, 28 Sep 2022 06:34:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A36F82D09; Wed, 28 Sep 2022 03:34:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E3592B8201E; Wed, 28 Sep 2022 10:34:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D943FC433D6; Wed, 28 Sep 2022 10:34:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664361267; bh=4LgcKsn8+MtAsKY2jQClP173ND1ry2xBaS3rhBDEoII=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=en/cO4Uvc+8haZ3id5aVmfM/F41Vi+kKuLHAWDZ9vK1iKlkWvhmb1tj/AEAJZfL50 496iYXPT5uE6XsNfI5wmq4TXCqyPWjNCeDsAm7Z2UtMD6A1j3eJnERithnutBU6LQ3 UOqFNOTgM0gxBi5dP1o5XjNM7BSzS/slt4LRpWOss4R31VL5olm/A4/0QOEOkypYY8 uwZgtWAmO/z5VGIgGrEE0Tg5/Raos6OOiYJCWcl+b3WuRIjspAClW8u4/CpeXqNqTO iuDvgx4R54CvzFJC1A3ekuDZnMw+7/IvO8F20WpvlXV4HZRsYDv669ZWBMU/jA9lPh mHTBtTyuHzbMA== Date: Wed, 28 Sep 2022 13:34:22 +0300 From: Leon Romanovsky To: Guangbin Huang Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, shenjian15@huawei.com, lanhao@huawei.com Subject: Re: [PATCH net-next 3/4] net: hns3: replace magic numbers with macro for IPv4/v6 Message-ID: References: <20220927111205.18060-1-huangguangbin2@huawei.com> <20220927111205.18060-4-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220927111205.18060-4-huangguangbin2@huawei.com> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 27, 2022 at 07:12:04PM +0800, Guangbin Huang wrote: > From: Hao Chen > > Replace 4/6 with IP_VERSION_V4/6 to improve code readability. > > Signed-off-by: Hao Chen > Signed-off-by: Guangbin Huang > --- > drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 12 ++++++------ > drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 3 +++ > 2 files changed, 9 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c > index 39b75b68474c..bf573e0c0670 100644 > --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c > @@ -1180,7 +1180,7 @@ static int hns3_set_tso(struct sk_buff *skb, u32 *paylen_fdop_ol4cs, > /* Software should clear the IPv4's checksum field when tso is > * needed. > */ > - if (l3.v4->version == 4) > + if (l3.v4->version == IP_VERSION_IPV4) > l3.v4->check = 0; > > /* tunnel packet */ > @@ -1195,7 +1195,7 @@ static int hns3_set_tso(struct sk_buff *skb, u32 *paylen_fdop_ol4cs, > /* Software should clear the IPv4's checksum field when > * tso is needed. > */ > - if (l3.v4->version == 4) > + if (l3.v4->version == IP_VERSION_IPV4) > l3.v4->check = 0; > } > > @@ -1270,13 +1270,13 @@ static int hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, > l3.hdr = skb_inner_network_header(skb); > l4_hdr = skb_inner_transport_header(skb); > > - if (l3.v6->version == 6) { > + if (l3.v6->version == IP_VERSION_IPV6) { > exthdr = l3.hdr + sizeof(*l3.v6); > l4_proto_tmp = l3.v6->nexthdr; > if (l4_hdr != exthdr) > ipv6_skip_exthdr(skb, exthdr - skb->data, > &l4_proto_tmp, &frag_off); > - } else if (l3.v4->version == 4) { > + } else if (l3.v4->version == IP_VERSION_IPV4) { > l4_proto_tmp = l3.v4->protocol; > } > > @@ -1364,7 +1364,7 @@ static void hns3_set_outer_l2l3l4(struct sk_buff *skb, u8 ol4_proto, > static void hns3_set_l3_type(struct sk_buff *skb, union l3_hdr_info l3, > u32 *type_cs_vlan_tso) > { > - if (l3.v4->version == 4) { > + if (l3.v4->version == IP_VERSION_IPV4) { > hns3_set_field(*type_cs_vlan_tso, HNS3_TXD_L3T_S, > HNS3_L3T_IPV4); > > @@ -1373,7 +1373,7 @@ static void hns3_set_l3_type(struct sk_buff *skb, union l3_hdr_info l3, > */ > if (skb_is_gso(skb)) > hns3_set_field(*type_cs_vlan_tso, HNS3_TXD_L3CS_B, 1); > - } else if (l3.v6->version == 6) { > + } else if (l3.v6->version == IP_VERSION_IPV6) { > hns3_set_field(*type_cs_vlan_tso, HNS3_TXD_L3T_S, > HNS3_L3T_IPV6); > } > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h > index 557a5fa70d0a..93041352ef19 100644 > --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h > @@ -217,6 +217,9 @@ enum hns3_nic_state { > #define HNS3_CQ_MODE_EQE 1U > #define HNS3_CQ_MODE_CQE 0U > > +#define IP_VERSION_IPV4 0x4 > +#define IP_VERSION_IPV6 0x6 The more traditional way is to use sa_family_t sa_family and AF_XXX instead of your .version variable. Thanks > + > enum hns3_pkt_l2t_type { > HNS3_L2_TYPE_UNICAST, > HNS3_L2_TYPE_MULTICAST, > -- > 2.33.0 >