From patchwork Fri Aug 18 11:31:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 110381 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp787792qge; Fri, 18 Aug 2017 04:33:45 -0700 (PDT) X-Received: by 10.84.217.206 with SMTP id d14mr2906485plj.319.1503056025239; Fri, 18 Aug 2017 04:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503056025; cv=none; d=google.com; s=arc-20160816; b=bz1rhEnNr8Y7tcku8HDi2d2eDWeR6K3Y6iaZU+QaGuunqc2OVW4WrsgseYK6lfkiTC UzLu9IPYlcE2C4Uw6tEJqY2s1KKvPy4nLvEs0p0VofTKRWfhk9NNiC8fs3L3v2ojNrfo f7y1lFOiFIxDT3Clh4L7oNldqZ7WaSV8158Uxme/AyDO2pDBrqqwXam6dkFXxFxxYp4x PdH0padq++SBMk5gz+0Tnzv3KXrI2T7cjHU7UGlhNjHgZc+JEZA+FGUaNf7tziuYzUL3 9Yc23+BED1ArIpbUJsoPZUjSy+3DQ0H4eRyxAvug4WhMCnn8b+wRRCCEr+herbciG8+H Gauw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=dPtcwKIBLS7U+mJfllDthgcaMm02MtPRxTGRe6Fzzk0=; b=MCEfubaOsrOLC6eAc/Y7c4ZWn09qlckubun33TerqZkUfob3mljYxGVL29IDm7KERz c1q+q2h7Mzv+eU0T9Ozkz3wZYxS6gSCyRwozZHvMC85CO63crVvjQiVw74xQ1f1H+8eu /0tD2zH3f25m6JfHNG58Kie6DJh7Ikb3gIKebqjlbEJTIPYZX8onUBGMRh7lR6lTQ608 vzlPNRdcMLAULXeOUtNaGb0xRaWshladv4s+QT83FVLsIaBdyYzwwW2iUQGLuqlbWyh7 xCBjVFIqhqhriK/guKuYrYGmJr+/eh/2N/+E2Y0/G9AZjbzq+fJkDIw7n34GshXtLj2Q t2aw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q15si329346pgc.932.2017.08.18.04.33.44; Fri, 18 Aug 2017 04:33:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752216AbdHRLdm (ORCPT + 26 others); Fri, 18 Aug 2017 07:33:42 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4071 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881AbdHRLca (ORCPT ); Fri, 18 Aug 2017 07:32:30 -0400 Received: from 172.30.72.59 (EHLO DGGEMS414-HUB.china.huawei.com) ([172.30.72.59]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DFM57981; Fri, 18 Aug 2017 19:32:27 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.203.181.151) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.301.0; Fri, 18 Aug 2017 19:32:15 +0800 From: Salil Mehta To: CC: , , , , , , , , Subject: [PATCH net-next 1/3] net: hns3: Fixes the missing u64_stats_fetch_begin_irq in 64-bit stats fetch Date: Fri, 18 Aug 2017 12:31:37 +0100 Message-ID: <20170818113139.153200-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20170818113139.153200-1-salil.mehta@huawei.com> References: <20170818113139.153200-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.203.181.151] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.5996D04B.00BD, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: b994b4c4bf1af27004b0ad2713b79b17 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fixes the missing u64_stats_fetch_begin_irq() while trying to atomically do 64-bit RX/TX fetch. We did not get any error during test as our SoC is 64-bit so all of these seq/lock operations results in NOOP. As such, this seq lock supports has been added for the sake of completion if this code ever runs on 32-bit platform and we are trying to do 64-bit stats fetch. Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Reported-by: Dan Carpenter Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c index 9589b7e..b12730a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c @@ -1054,6 +1054,7 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) /* fetch the tx stats */ ring = priv->ring_data[idx].ring; do { + start = u64_stats_fetch_begin_irq(&ring->syncp); tx_bytes += ring->stats.tx_bytes; tx_pkts += ring->stats.tx_pkts; } while (u64_stats_fetch_retry_irq(&ring->syncp, start)); @@ -1061,6 +1062,7 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) /* fetch the rx stats */ ring = priv->ring_data[idx + queue_num].ring; do { + start = u64_stats_fetch_begin_irq(&ring->syncp); rx_bytes += ring->stats.rx_bytes; rx_pkts += ring->stats.rx_pkts; } while (u64_stats_fetch_retry_irq(&ring->syncp, start)); From patchwork Fri Aug 18 11:31:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 110380 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp787387qge; Fri, 18 Aug 2017 04:33:21 -0700 (PDT) X-Received: by 10.99.122.71 with SMTP id j7mr2055481pgn.332.1503056001401; Fri, 18 Aug 2017 04:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503056001; cv=none; d=google.com; s=arc-20160816; b=k5pFco1ASmnnPdnJlJFJE/37WcQAFHRicYsAlEzWeNQ1gTnnHZit7QzahGx8AxlWrs O9tjW/wEcRfZ/9D83HAsXjkBfza2etofwubGYpfymwzukk2k19sAzUdfSwvcSpNaVyjy UYa4xVPvoeMs+Jc2icWIGscS08ys7PDVEWA7PKKnf60Srj+F1KEs/3GzuQv2My7/2kt6 oA8AnpyQ0wwaYqwV9PavzxGZIVFjb7drK9ev++HHonvTJG32XBIsVWjfZWDRm3TnnfC/ qIWC7Ch1M3PxCKuH6z8bVwVg3Ep5NQU+mALE0EkPuBN/Etsiw4WnKKYU33uWYn5KQfEC Goxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=Q/NEk5pBkCtBiRRfV9kdjvVmrSCh9nMRQ8EO29D7710=; b=xRqiiVk7TGWL7MVZaQbz/txMruSyPakiJXMqm884syjCJMpC5n3zqYNBKWyHPgwtuP 9To3iAnFWKcxL6yEhmmayJM79yxNucSCNTLOdL1gOierRO0DoqngtQXRoZBnZEEvPccv scK9PFEmgbRkVco8pFJGvJw9nFwnEw/q30qMERiGy7GGkY6Po8hKF/B1E+Y9ryXskBqR rDumjTVLNivkiTZhfRWa2epPBk6wsvHWZPiFfZL7r6cpXagMxXzP96D/QZ0XIAF7zwOb yLKia0lmrijnwlv4SafmgnDI7auqWMmFdW9PRgLL0Z/+XAw8dSjw8kdbhdkmgrZopMWx S+EQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si3765591plk.239.2017.08.18.04.33.21; Fri, 18 Aug 2017 04:33:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752038AbdHRLdS (ORCPT + 26 others); Fri, 18 Aug 2017 07:33:18 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4070 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750940AbdHRLca (ORCPT ); Fri, 18 Aug 2017 07:32:30 -0400 Received: from 172.30.72.59 (EHLO DGGEMS414-HUB.china.huawei.com) ([172.30.72.59]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DFM57982; Fri, 18 Aug 2017 19:32:27 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.203.181.151) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.301.0; Fri, 18 Aug 2017 19:32:18 +0800 From: Salil Mehta To: CC: , , , , , , , , Subject: [PATCH net-next 2/3] net: hns3: Fixes the static checker error warning in hns3_get_link_ksettings() Date: Fri, 18 Aug 2017 12:31:38 +0100 Message-ID: <20170818113139.153200-3-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20170818113139.153200-1-salil.mehta@huawei.com> References: <20170818113139.153200-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.203.181.151] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.5996D04B.0158, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 5817d6d995407945beb393065ad01d9a Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fixes the static check error warning in hns3_get_link_ksettings() function by re-arranging the code. Fixes: 496d03e960ae ("net: hns3: Add Ethtool support to HNS3 Driver") Reported-by: Dan Carpenter Signed-off-by: Salil Mehta --- .../ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 85 ++++++++++++---------- 1 file changed, 48 insertions(+), 37 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c index 0ad65e4..ffc837b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c @@ -313,7 +313,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev, if (!h->ae_algo || !h->ae_algo->ops) return -EOPNOTSUPP; - /* 1.auto_neg&speed&duplex from cmd */ + /* 1.auto_neg & speed & duplex from cmd */ if (h->ae_algo->ops->get_ksettings_an_result) { h->ae_algo->ops->get_ksettings_an_result(h, &auto_neg, &speed, &duplex); @@ -329,50 +329,61 @@ static int hns3_get_link_ksettings(struct net_device *netdev, } /* 2.media_type get from bios parameter block */ - if (h->ae_algo->ops->get_media_type) + if (h->ae_algo->ops->get_media_type) { h->ae_algo->ops->get_media_type(h, &media_type); - switch (media_type) { - case HNAE3_MEDIA_TYPE_FIBER: - cmd->base.port = PORT_FIBRE; - supported_caps = HNS3_LM_FIBRE_BIT | HNS3_LM_AUTONEG_BIT | - HNS3_LM_PAUSE_BIT | HNS3_LM_1000BASET_FULL_BIT; + switch (media_type) { + case HNAE3_MEDIA_TYPE_FIBER: + cmd->base.port = PORT_FIBRE; + supported_caps = HNS3_LM_FIBRE_BIT | + HNS3_LM_AUTONEG_BIT | + HNS3_LM_PAUSE_BIT | + HNS3_LM_1000BASET_FULL_BIT; + + advertised_caps = supported_caps; + break; + case HNAE3_MEDIA_TYPE_COPPER: + cmd->base.port = PORT_TP; + supported_caps = HNS3_LM_TP_BIT | + HNS3_LM_AUTONEG_BIT | + HNS3_LM_PAUSE_BIT | + HNS3_LM_1000BASET_FULL_BIT | + HNS3_LM_100BASET_FULL_BIT | + HNS3_LM_100BASET_HALF_BIT | + HNS3_LM_10BASET_FULL_BIT | + HNS3_LM_10BASET_HALF_BIT; + advertised_caps = supported_caps; + break; + case HNAE3_MEDIA_TYPE_BACKPLANE: + cmd->base.port = PORT_NONE; + supported_caps = HNS3_LM_BACKPLANE_BIT | + HNS3_LM_PAUSE_BIT | + HNS3_LM_AUTONEG_BIT | + HNS3_LM_1000BASET_FULL_BIT | + HNS3_LM_100BASET_FULL_BIT | + HNS3_LM_100BASET_HALF_BIT | + HNS3_LM_10BASET_FULL_BIT | + HNS3_LM_10BASET_HALF_BIT; + + advertised_caps = supported_caps; + break; + case HNAE3_MEDIA_TYPE_UNKNOWN: + default: + cmd->base.port = PORT_OTHER; + supported_caps = 0; + advertised_caps = 0; + break; + } - advertised_caps = supported_caps; - break; - case HNAE3_MEDIA_TYPE_COPPER: - cmd->base.port = PORT_TP; - supported_caps = HNS3_LM_TP_BIT | HNS3_LM_AUTONEG_BIT | - HNS3_LM_PAUSE_BIT | HNS3_LM_1000BASET_FULL_BIT | - HNS3_LM_100BASET_FULL_BIT | HNS3_LM_100BASET_HALF_BIT | - HNS3_LM_10BASET_FULL_BIT | HNS3_LM_10BASET_HALF_BIT; - advertised_caps = supported_caps; - break; - case HNAE3_MEDIA_TYPE_BACKPLANE: - cmd->base.port = PORT_NONE; - supported_caps = HNS3_LM_BACKPLANE_BIT | HNS3_LM_PAUSE_BIT | - HNS3_LM_AUTONEG_BIT | HNS3_LM_1000BASET_FULL_BIT | - HNS3_LM_100BASET_FULL_BIT | HNS3_LM_100BASET_HALF_BIT | - HNS3_LM_10BASET_FULL_BIT | HNS3_LM_10BASET_HALF_BIT; - - advertised_caps = supported_caps; - break; - case HNAE3_MEDIA_TYPE_UNKNOWN: - default: - cmd->base.port = PORT_OTHER; - supported_caps = 0; - advertised_caps = 0; - break; + /* now, map driver link modes to ethtool link modes */ + hns3_driv_to_eth_caps(supported_caps, cmd, false); + hns3_driv_to_eth_caps(advertised_caps, cmd, true); } - /* now, map driver link modes to ethtool link modes */ - hns3_driv_to_eth_caps(supported_caps, cmd, false); - hns3_driv_to_eth_caps(advertised_caps, cmd, true); - /* 3.mdix_ctrl&mdix get from phy reg */ if (h->ae_algo->ops->get_mdix_mode) h->ae_algo->ops->get_mdix_mode(h, &cmd->base.eth_tp_mdix_ctrl, - &cmd->base.eth_tp_mdix); + &cmd->base.eth_tp_mdix); /* 4.mdio_support */ cmd->base.mdio_support = ETH_MDIO_SUPPORTS_C22; From patchwork Fri Aug 18 11:31:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 110379 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp786705qge; Fri, 18 Aug 2017 04:32:41 -0700 (PDT) X-Received: by 10.84.231.203 with SMTP id g11mr9423864pln.199.1503055960963; Fri, 18 Aug 2017 04:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503055960; cv=none; d=google.com; s=arc-20160816; b=q/W4AqcI/CjxYQIToo75+3Xd4KfYWxjy9rdQ0iAtrxiNoB7W+G9QZiXjc4XwTK/CSg GWVxOFc6NeXGHOJ03CmXw/67Odi91EC5cn5fXW6xoo0IfddEcdJEKbPw6jWoJu5AUYEA lo68+oU88+w1LHnB/tbKTiGHyqd0nl1gi3Xcgrb/TmWS55T1lBUMeyso2uR2GBibmH66 DSGzTGHUlZXTCuzaQY0E0lJCmh/Pas5NhogM95R6zjdOiHDbDS5s3hxS30cKODwcAS0V EHE6RzkX03p+dW9LooDJIpuLLZLYcLiLW4lhbkHkzYh9jBC2zSBLLHLwkadecz+LiFEm lDcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=foiEBnjs9IOdUAwlR38glVuaXGsc12rtdVLchq77o+A=; b=S3zot524n+CTo+VwTLsMTp/WiRK+3SqD9Hq6pGYr/3NWH1AYKrW0zF/9Zvh6VvNmGS LMBL1DNBFDrX4F2ECjfSi6MPwyO/3npP5SaAILw+HMLpk2riWjL4Rj8oRfIX79P6S26n OZelt5IuoDjP0CK+bAXapWakmzMx+NcJJ4eKxlc32tqp65olrnbU681QwcndlntNBnGP TIAE6YL66d+KZOoECL1j8Sf8OUcacLyAcR8Zdq3QssCeypevpnl3MdMt7DxQSWqpIG7I E7CbcXII2o6H0yk8obvRAObc4hTWs0ZemNWuhOXifazgsqVruxfhFq8gYH7d//M/58My RRwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si3778643pld.308.2017.08.18.04.32.40; Fri, 18 Aug 2017 04:32:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751660AbdHRLcj (ORCPT + 26 others); Fri, 18 Aug 2017 07:32:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4072 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751267AbdHRLce (ORCPT ); Fri, 18 Aug 2017 07:32:34 -0400 Received: from 172.30.72.59 (EHLO DGGEMS414-HUB.china.huawei.com) ([172.30.72.59]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DFM57993; Fri, 18 Aug 2017 19:32:32 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.203.181.151) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.301.0; Fri, 18 Aug 2017 19:32:22 +0800 From: Salil Mehta To: CC: , , , , , , , , Subject: [PATCH net-next 3/3] net: hns3: Fixes the static check warning due to missing unsupp L3 proto check Date: Fri, 18 Aug 2017 12:31:39 +0100 Message-ID: <20170818113139.153200-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20170818113139.153200-1-salil.mehta@huawei.com> References: <20170818113139.153200-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.203.181.151] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.5996D050.00B2, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d8c602129fe403ab9bf2056459c2544d Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fixes the static check warning due to missing handling leg of unsupported L3 protocol type in the hns3_get_l4_protocol() function. Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Reported-by: Dan Carpenter Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c index b12730a..e731f87 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c @@ -436,8 +436,8 @@ static int hns3_set_tso(struct sk_buff *skb, u32 *paylen, return 0; } -static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, - u8 *il4_proto) +static int hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, + u8 *il4_proto) { union { struct iphdr *v4; @@ -461,6 +461,8 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, &l4_proto_tmp, &frag_off); } else if (skb->protocol == htons(ETH_P_IP)) { l4_proto_tmp = l3.v4->protocol; + } else { + return -EINVAL; } *ol4_proto = l4_proto_tmp; @@ -468,7 +470,7 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, /* tunnel packet */ if (!skb->encapsulation) { *il4_proto = 0; - return; + return 0; } /* find inner header point */ @@ -486,6 +488,8 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, } *il4_proto = l4_proto_tmp; + + return 0; } static void hns3_set_l2l3l4_len(struct sk_buff *skb, u8 ol4_proto, @@ -757,7 +761,9 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv, protocol = vlan_get_protocol(skb); skb->protocol = protocol; } - hns3_get_l4_protocol(skb, &ol4_proto, &il4_proto); + ret = hns3_get_l4_protocol(skb, &ol4_proto, &il4_proto); + if (ret) + return ret; hns3_set_l2l3l4_len(skb, ol4_proto, il4_proto, &type_cs_vlan_tso, &ol_type_vlan_len_msec);