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 5A083A00BE; Tue, 3 May 2022 21:05:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4DD7E40E2D; Tue, 3 May 2022 21:05:18 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2084.outbound.protection.outlook.com [40.107.237.84]) by mails.dpdk.org (Postfix) with ESMTP id A546340691 for ; Tue, 3 May 2022 21:05:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LNCBtFQwHhE35D0KVPDUUFzUzmrBc8ZuY6USEBwMp1LAUtVJu87AcB2hVE5lI4lRG8eI9r9fIKKZFSYgYQBM+bXN+381Wz3AZtX+I8jyFBbJKCqK/fTrPu2Xum5uFtbx4yiKCJqe3H8OKycG1AXpf8SNcfw8BWi1tKRiWQ4KQMTkMqryyu8bc/53rI74mPbk8OG720A+X/9tlnINmM49oLqjpLQysq3zkbkbD8qcL9HFTTX9/tS0GaLv40hDuHbV0dLPq1sZ5j7ZZgzZSioJ6s1U9Fg+xdy5mLEnxwQn9Aro/7kyYxxqnit3jGgH4jhq7aOKmmt7tABrEc0uFV/AKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ov2RrNUx0fxweF6XUMhWNoUfQ6Cr+2yYEu8u2ICWrbk=; b=LdMYGUtlgF8XGBtcqbU5MnYoVcgbX+7viRcfH2nI7pnEBdEwJeO/v4hEzt5/kUr/WrdJ00ov30cnwgtEiRN3rJtolGpZZk6dezPZfZW7YYON+rAPahn+vEpRPn4Zv6h2/NZl8MhC2tRBGrzEeZ8gvCT0WdzVKxM4UBhStmSRvhBPPXzwrZ+QwNBJt9UVKuXUC4IlkYShBHXGZLeyIr6U2j0rPDWl2oFiVhpL2bT1Z3XJkuclPVLHixgfaK6xJQjD2/pyWGh4xL+kkYsgH2f5NGBLF9sCXuZnoMj/qnOAPX6M1FKkg6JsocviyhmYI6bCP/iptfCMojDim0OYblM1eQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.80.198) smtp.rcpttodomain=huawei.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ov2RrNUx0fxweF6XUMhWNoUfQ6Cr+2yYEu8u2ICWrbk=; b=jDwnhweF3hGQNOpg1+4bxOGt3hS3xPcLgmfVDfemTLpzS82mnKPdbfNcfRJU7F/awlRtnWgqos3dS/EsbYlckIrfFTbCfpFf6snf2OATVqs8Sehr7t39Nram7CV36SMr792eOUPwesdVYctHqu3AyM0WunFenJaVrGZtX+/pfAQ= Received: from BN0PR04CA0165.namprd04.prod.outlook.com (2603:10b6:408:eb::20) by BN6PR02MB2627.namprd02.prod.outlook.com (2603:10b6:404:55::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.13; Tue, 3 May 2022 19:05:16 +0000 Received: from BN1NAM02FT057.eop-nam02.prod.protection.outlook.com (2603:10b6:408:eb:cafe::f7) by BN0PR04CA0165.outlook.office365.com (2603:10b6:408:eb::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24 via Frontend Transport; Tue, 3 May 2022 19:05:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.80.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.80.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.80.198; helo=xir-pvapexch02.xlnx.xilinx.com; Received: from xir-pvapexch02.xlnx.xilinx.com (149.199.80.198) by BN1NAM02FT057.mail.protection.outlook.com (10.13.2.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Tue, 3 May 2022 19:05:15 +0000 Received: from xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) by xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Tue, 3 May 2022 20:05:14 +0100 Received: from smtp.xilinx.com (172.21.105.198) by xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 3 May 2022 20:05:14 +0100 Envelope-to: humin29@huawei.com, dev@dpdk.org, ferruh.yigit@intel.com, thomas@monjalon.net Received: from [10.71.119.91] (port=62052) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nlxpi-0000zh-7V; Tue, 03 May 2022 20:05:14 +0100 Message-ID: <23022ec8-6908-252c-cb47-e8dd5531c677@xilinx.com> Date: Tue, 3 May 2022 20:05:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH 2/7] net/hns3: fix MAC and queues HW statistics reversion Content-Language: en-US To: "Min Hu (Connor)" , CC: , References: <20220406092240.52900-1-humin29@huawei.com> <20220406092240.52900-3-humin29@huawei.com> From: Ferruh Yigit In-Reply-To: <20220406092240.52900-3-humin29@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7fec87bb-aa02-4099-7b26-08da2d37db95 X-MS-TrafficTypeDiagnostic: BN6PR02MB2627:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LohPS+IUSjdRGRAV3zwap9bPo76gVQ2QsYOkccaBfV/bztCiJ6ubzW1KauOF1lp38NwzgEHUEbexKDDeso0GIMvCxT5x1/Ge2UX6zYXN8dwv5GfbzRzcOxA43Q8of2vRpPQQmgtXR7nooWj1qTuNNbwHl2PCrgNylg7nhunw4/j3Exa3jvslZE/OSV+azWLB8oiBSw7yqJ149ovUsNwSenmoUUSsQd3ttJWxwcN9Y3AxLyZWw/qkk5tquJn9wrKEAXc5847eytAbxRAtWssxjDccG3GisiMJDxHdgqbmbDXsTtmlJUH3n40Ukdwr8BR9dzui91ehW91MdmGIaiz/nk02Demwet+FXi4qhKgzeJLcV74eThZZUYibJ8THYp6UEqx6R7YaPtbabHpXtxlakV8MbQ03ulNp5VCoZ+Q/XiyicsnJSSmIHHk110l5ZEqU/+bvv0c6ouuWg29w6PmJcITwHJoCIdFV4K4+zX1icV+EFfIdUOnzaoFs/ssmCal6o4bp66bcIelFO9bsX5EY9Ls3pZFBfUu4TN0cX2qBhrcpYrLLit2ld0N3g61cofzDEF3ZKtC28CDVDLU0yEyak0CBU+fIYBMPFHAcKLCsLn0b1QVciis1jMldcA8YonMq3lmxdcXhmp5Kcz+eqzjPywOjEj3t/Ny9D3IUS0xAlJNPdNNvTfDOC+U4mslkWUPtdjdT9k3Q5RdpF3y9Q6/i8RwHh3i3+fpMqfgR0xeG7IU= X-Forefront-Antispam-Report: CIP:149.199.80.198; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:xir-pvapexch02.xlnx.xilinx.com; PTR:unknown-80-198.xilinx.com; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(40460700003)(8936002)(9786002)(4326008)(508600001)(426003)(47076005)(70586007)(70206006)(336012)(8676002)(53546011)(83380400001)(7636003)(26005)(82310400005)(54906003)(110136005)(186003)(356005)(316002)(36756003)(2616005)(31696002)(2906002)(31686004)(44832011)(36860700001)(5660300002)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2022 19:05:15.5085 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fec87bb-aa02-4099-7b26-08da2d37db95 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.80.198]; Helo=[xir-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT057.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR02MB2627 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 On 4/6/2022 10:22 AM, Min Hu (Connor) wrote: > From: Huisong Li > > The MAC and queues statistics aren't 64-bit registers in hardware. If > hardware statistics are not obtained for a long time, these statistics will > be reversed. I think using 'overflow' instead of 'reversed' is more clear. As far as I can see from code, these are 32 bit values, can be good to mention in the commit log. > So PF and VF driver have to periodically obtain and save these > statistics. Since the periodical task and the stats API are in different > threads, we introduce a statistics lock to protect the statistics. > > Fixes: 8839c5e202f3 ("net/hns3: support device stats") > Cc: stable@dpdk.org > > Signed-off-by: Huisong Li > Signed-off-by: Min Hu (Connor) <...> > @@ -604,16 +626,15 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) > struct hns3_tqp_stats *stats = &hw->tqp_stats; > struct hns3_rx_queue *rxq; > struct hns3_tx_queue *txq; > - uint64_t cnt; > uint16_t i; > int ret; > > + rte_spinlock_lock(&hw->stats_lock); The lock covers most of the 'stats_get()' function, but only Rx/Tx queue stats needs to be protected, you may consider reducing the scope of the lock. Same for below functions. <...> > @@ -1453,6 +1464,7 @@ int > hns3_dev_xstats_reset(struct rte_eth_dev *dev) > { > struct hns3_adapter *hns = dev->data->dev_private; > + struct hns3_hw *hw = &hns->hw; > int ret; > > /* Clear tqp stats */ > @@ -1460,20 +1472,22 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev) > if (ret) > return ret; > > + rte_spinlock_unlock(&hw->stats_lock); I guess this should be 'rte_spinlock_lock()'