Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp820205rwb; Tue, 27 Sep 2022 05:14:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4rP9gNCr4A6cQn5ssPFrw+syfo74Ru/QLS/5ha86Muz1uMlzY0q6OEWVE+JdcyrMQkqD0J X-Received: by 2002:a17:906:8454:b0:772:7b02:70b5 with SMTP id e20-20020a170906845400b007727b0270b5mr22779665ejy.114.1664280866251; Tue, 27 Sep 2022 05:14:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664280866; cv=none; d=google.com; s=arc-20160816; b=Vwnx7T0o/FE7lxIiZJu0S7yfUKO0EsZvlwiMWVDBD7aqKaOkUEhSb3nWnUL5IoXntj 81dnor3VIRYdvQXklEuOyPHp8XKsnDl+PfeCvGYu0bu2pK6VGochNJoGsPId4r6UYgcM TZp6FhTB8dIaioAw/NLkKAv2r6nq7yzUeIf0Dnfmfg5KuT8rE2zoeK3eRXVBdBhsapTG lc8n7XCtmAdt0yOQ+EmwkF+Myb49XWwmVg9bJWofn6+nDJmKtxz8KJmcrmyn8r5s4Ry0 ktNE5ol7swTy0jXjcIObGmjvzq3qk3ml7lmZWbqHBsGpqjtophkST+A6AR3yeBpVqyux PoSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yUAIlQVMa9WA5d6OfCsU2npLR3U+1som3Y76l90/Pxo=; b=z7PrCd6lLB0BHUyWkF3cWcB4Zbv1lXFPwCoblJWWZxQPl2wb4+dj7bD4TsWQFv8N/c ROAL/YWyPkOdBNDTscXmMIOEnHXhQwoq7ZyDZ//6F++AmdYNAycRXmNxy3ozIcBL48aK NeApu1oarNFQiA2SFx8Udfyb4Hjxm5VHB6XPaib+C2YPa0XV8I12Iku5xuoMowRjMEQ2 KEU/NrQ46LfCd2b4sNOI/KSLjR/pSdigYneHU3fVelF2nZyfZDlpXu/SdeJk9OM7Dc/h 7y2AQeBffI2mrted0a5fQuYI73Hlf0Xna8NCqRpnJ3aDLUFOQVuYrGbu8oMOEVac0s0R fwug== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz3-20020a1709072ce300b007834df1bcf9si936679ejc.875.2022.09.27.05.13.58; Tue, 27 Sep 2022 05:14:26 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232043AbiI0LPm (ORCPT + 99 others); Tue, 27 Sep 2022 07:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231960AbiI0LPC (ORCPT ); Tue, 27 Sep 2022 07:15:02 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F4714BD08; Tue, 27 Sep 2022 04:14:58 -0700 (PDT) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4McH3j4wnDzlX4d; Tue, 27 Sep 2022 19:10:41 +0800 (CST) Received: from kwepemm600016.china.huawei.com (7.193.23.20) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 19:14:56 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600016.china.huawei.com (7.193.23.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 19:14:56 +0800 From: Guangbin Huang To: , CC: , , , , , , Subject: [PATCH net-next 3/4] net: hns3: replace magic numbers with macro for IPv4/v6 Date: Tue, 27 Sep 2022 19:12:04 +0800 Message-ID: <20220927111205.18060-4-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220927111205.18060-1-huangguangbin2@huawei.com> References: <20220927111205.18060-1-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600016.china.huawei.com (7.193.23.20) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 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 + enum hns3_pkt_l2t_type { HNS3_L2_TYPE_UNICAST, HNS3_L2_TYPE_MULTICAST, -- 2.33.0