From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1D7D6A04B5; Thu, 10 Sep 2020 04:18:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 363A31B9B7; Thu, 10 Sep 2020 04:18:35 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 95741255; Thu, 10 Sep 2020 04:18:33 +0200 (CEST) IronPort-SDR: 74B56h2lJpUv139fEr5UK6ApaGVss52QFrkPUw+aBXXOxKeiTY2CqgkQkarM+/+K0DTC9t96oi o4RenQYgJnHQ== X-IronPort-AV: E=McAfee;i="6000,8403,9739"; a="155855402" X-IronPort-AV: E=Sophos;i="5.76,411,1592895600"; d="scan'208";a="155855402" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2020 19:18:32 -0700 IronPort-SDR: iWJ3ZYi5I/QpQz2YEI4YuAp0NTO9aF8eXmnWp0yPKQxKw9i47oSSesb2fuhPrFdcb1oFgs0TX4 d/Sj6GrMXo9w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,411,1592895600"; d="scan'208";a="480700461" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga005.jf.intel.com with ESMTP; 09 Sep 2020 19:18:31 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 9 Sep 2020 19:18:29 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 9 Sep 2020 19:18:29 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 9 Sep 2020 19:18:29 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.175) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Wed, 9 Sep 2020 19:18:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fv4iBE9fwI96DRam7t8mai/IrqXdJA0HqHv/b35PUtGC2VavoxPf36KBJlUh7ET0OpL1wiZLtxA2uivfeBJpo7NbwNNHmohRsxBdAKkhBAWXfApEB+JkbC+flxewbKdTOZNpl+gPP8ggnHOeHCOsomI2yDgzVIq07YIK8Rkj81ld3dzt/GqKwotEDzh7IGlpT8Xrc0qZoTcsOQ6OgAOAqsHWhMv1oChd4lW7LuQeMR4RBf/W6dWYgmKzWaTEqk8AFiuzun+9/Un4wDQSmaGxzWPb8qtHDMY1Eskx0FjQVsdbv9IsLhMdRRdiCFHsLF82nyhbHrNXfTY69fKxVU0ayQ== 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-SenderADCheck; bh=AFnwWK+17/EvhIWZjW6AlWLFXDSxow6KtuwRBmPdkz4=; b=n71EoXpIHWquMmfs16zldgVLj7ci9xIbrl5GlvxlDXlPUkM8/9Z5uMFs0v/67k1bj0zrTQz3eb1RP14XSmu2nxEJrHDID4Q5KCpHa8Oup5FdJbtKfY3hAMu59KK+XXuyPKYvYJrDVR/YbuAudgGJTN8W+eKqQ25sy6AaNoaPGWYWJYj9aLYAPXURl2EPB3P3i0jx5hADZjSxCCBbCAmqVz56Y+5fUvOfI/bEMcMXpulq+3h37soRP1Suv3wx+9gixzTmTnzcldMvfTIJsSwRyjV6OzPPCQJqZ/cqrCBOqBqofSBjfvgRpbR1Vc7KL2tE5u/EUE0UxGzXBM4PUk2ZoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AFnwWK+17/EvhIWZjW6AlWLFXDSxow6KtuwRBmPdkz4=; b=kNLQkusXy3U7XkhF9C0DooZbp9/CICHRILWXn1Ys35f8LGod9KYnadq9NOSuUy1M6cA04/rqc0rQK3CDl7kYLCM3cvYmFv7JUkdLTe/atV/aRcGX58IA7hpYkUmw6F++yml5d9qmvFUHTBu8NizBTuFp5OzEdcBCohq8Y2XpB3M= Received: from BN7PR11MB2818.namprd11.prod.outlook.com (2603:10b6:406:ad::23) by BN6PR11MB3970.namprd11.prod.outlook.com (2603:10b6:405:7a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.16; Thu, 10 Sep 2020 02:18:25 +0000 Received: from BN7PR11MB2818.namprd11.prod.outlook.com ([fe80::c95:a0c7:afc8:a602]) by BN7PR11MB2818.namprd11.prod.outlook.com ([fe80::c95:a0c7:afc8:a602%6]) with mapi id 15.20.3370.016; Thu, 10 Sep 2020 02:18:25 +0000 From: "Han, YingyaX" To: "Jiang, JunyuX" , "dev@dpdk.org" CC: "Guo, Jia" , "Xing, Beilei" , "Jiang, JunyuX" , "stable@dpdk.org" Thread-Topic: [dpdk-stable] [PATCH] net/i40e: fix incorrect byte counters Thread-Index: AQHWhxa3Bs4G3jhc0k+AGxjBVqXlcKlhIl8w Date: Thu, 10 Sep 2020 02:18:25 +0000 Message-ID: References: <20200910015426.3140-1-junyux.jiang@intel.com> In-Reply-To: <20200910015426.3140-1-junyux.jiang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.193] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 95340a18-0086-4a70-1085-08d8552fcc77 x-ms-traffictypediagnostic: BN6PR11MB3970: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1247; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6Ui/KQ8Z4MJS3cqLK6k70QRx9W6xPi9/iWh2NsBAZzI0Ga8KJSdynHQu05aI1Te7foypbveohwGxyYZY+Eu5aFc3wZktMFsUck0xClyy9k6ZZ2jLkHtDUe0Zo+kyHe3PT6iPL7ldGLh75ZS7fMLbwQVDWU3wkRkdglrj1Ea59RBm/xkxjphpGRYoAaCL1C7Pc7s3ibrot4DaZX4/b3jZH7DDBk+lGtCs+7/9ePwYRYDJ6vv/IimgcjEaaFGRIaX+jC/YQ1dcwNi+DjJ9HeCPX+I1L03NZ8GK53/1/mrNDYZwEvZlcagIhcU4iCMHFmgMNdp5fWm9MeV1A5f3qmWmWQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN7PR11MB2818.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(346002)(366004)(396003)(39860400002)(52536014)(83380400001)(33656002)(53546011)(6506007)(86362001)(5660300002)(4326008)(55016002)(54906003)(110136005)(450100002)(2906002)(26005)(7696005)(9686003)(76116006)(316002)(186003)(64756008)(8936002)(66946007)(66476007)(66556008)(8676002)(71200400001)(478600001)(66446008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: IvoEMKmS4pJhtHdNqj25YJRrsmRJqTdWjV36KGHXpcatd9dr9yzCx4gHCzhSoCSvGY/Tg2sOVPGMScxNppjntTg0t8UnQ+vDEt/06ULUTUL+VXdssFsNDTnpe/1sNKLJdKCykx6DYGgsXkC5cd/oQln7Kt5toKfwt2AqFZiELocrA6gqZYmmGDf6a5PT0emFPAUN72J5BapXNVZgH1I44sgibnLITLROKoeM83exEz2iqajxnNgqihO6nltIDwXzB9RySJK7Qs/xA2LI0gLL7rYkqqiWbc5zwHsiWEQak6Ztiy8dFgmk/E2pGOnDwo1uglGE/L/LVxBKEVA6segIxoF7+3wGEAxR6OQKLocXirwFC/lm/J7Ub4UVjB9/Yr0vQsSAM3XNhxLOFssYcGKX/GCR7dqG+ZpmQqk5mDUE9xSF20x8GaK7tDSW556RrsVtOeeG8UOS0H2ubFoRlS2sOnD+hFzzwr5taNvrgX+XJqdhBLyCSICazGEFrsXvfH0kvwTm/r/L53xOJFSn7Z9zFi5AMtsQIG5RKr7IEOSGIarj7emADKrbyEMt24X8Gt8Nv8DyajibQIQX2jwX+02ueCQE3ZuVsW7Ir2POCwKEMnfd6Lh76GZFwlIkRrg2pssHGTGwrvJ1ekUZALkvBpU1xA== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN7PR11MB2818.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95340a18-0086-4a70-1085-08d8552fcc77 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Sep 2020 02:18:25.1506 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: G5C4PpAYYbQhFe94R60tSbicOrZWU452txGyI6E592lj7JWsheMJm5b6iUXZlZNSKPPqigPM4OWCZGg21H+2ZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB3970 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] net/i40e: fix incorrect byte counters X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Tested-by: Yingya Han -----Original Message----- From: stable On Behalf Of Junyu Jiang Sent: Thursday, September 10, 2020 9:54 AM To: dev@dpdk.org Cc: Guo, Jia ; Xing, Beilei ; Jia= ng, JunyuX ; stable@dpdk.org Subject: [dpdk-stable] [PATCH] net/i40e: fix incorrect byte counters This patch fixed the issue that rx/tx bytes overflowed on 48 bit limitation= by enlarging the limitation. Fixes: 4861cde46116 ("i40e: new poll mode driver") Cc: stable@dpdk.org Signed-off-by: Junyu Jiang --- drivers/net/i40e/i40e_ethdev.c | 47 ++++++++++++++++++++++++++++++++++ drivers/net/i40e/i40e_ethdev.h | 9 +++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.= c index 11c02b188..e3d4b7f4f 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -3070,6 +3070,13 @@ i40e_update_vsi_stats(struct i40e_vsi *vsi) i40e_stat_update_48(hw, I40E_GLV_BPRCH(idx), I40E_GLV_BPRCL(idx), vsi->offset_loaded, &oes->rx_broadcast, &nes->rx_broadcast); + /* enlarge the limitation when rx_bytes overflowed */ + if (vsi->offset_loaded) { + if (I40E_RXTX_BYTES_LOW(vsi->old_rx_bytes) > nes->rx_bytes) + nes->rx_bytes +=3D (uint64_t)1 << I40E_48_BIT_WIDTH; + nes->rx_bytes +=3D I40E_RXTX_BYTES_HIGH(vsi->old_rx_bytes); + } + vsi->old_rx_bytes =3D nes->rx_bytes; /* exclude CRC bytes */ nes->rx_bytes -=3D (nes->rx_unicast + nes->rx_multicast + nes->rx_broadcast) * RTE_ETHER_CRC_LEN; @@ -3096,6 +3103,13 @@ i40e_upda= te_vsi_stats(struct i40e_vsi *vsi) /* GLV_TDPC not supported */ i40e_stat_update_32(hw, I40E_GLV_TEPC(idx), vsi->offset_loaded, &oes->tx_errors, &nes->tx_errors); + /* enlarge the limitation when tx_bytes overflowed */ + if (vsi->offset_loaded) { + if (I40E_RXTX_BYTES_LOW(vsi->old_tx_bytes) > nes->tx_bytes) + nes->tx_bytes +=3D (uint64_t)1 << I40E_48_BIT_WIDTH; + nes->tx_bytes +=3D I40E_RXTX_BYTES_HIGH(vsi->old_tx_bytes); + } + vsi->old_rx_bytes =3D nes->rx_bytes; vsi->offset_loaded =3D true; =20 PMD_DRV_LOG(DEBUG, "***************** VSI[%u] stats start ***************= ****", @@ -3168,6 +3182,24 @@ i40e_read_stats_registers(struct i40e_pf *pf,= struct i40e_hw *hw) pf->offset_loaded, &pf->internal_stats_offset.tx_broadcast, &pf->internal_stats.tx_broadcast); + /* enlarge the limitation when internal rx/tx bytes overflowed */ + if (pf->offset_loaded) { + if (I40E_RXTX_BYTES_LOW(pf->internal_old_rx_bytes) > + pf->internal_stats.rx_bytes) + pf->internal_stats.rx_bytes +=3D + (uint64_t)1 << I40E_48_BIT_WIDTH; + pf->internal_stats.rx_bytes +=3D + I40E_RXTX_BYTES_HIGH(pf->internal_old_rx_bytes); + + if (I40E_RXTX_BYTES_LOW(pf->internal_old_tx_bytes) > + pf->internal_stats.tx_bytes) + pf->internal_stats.tx_bytes +=3D + (uint64_t)1 << I40E_48_BIT_WIDTH; + pf->internal_stats.tx_bytes +=3D + I40E_RXTX_BYTES_HIGH(pf->internal_old_tx_bytes); + } + pf->internal_old_rx_bytes =3D pf->internal_stats.rx_bytes; + pf->internal_old_tx_bytes =3D pf->internal_stats.tx_bytes; =20 /* exclude CRC size */ pf->internal_stats.rx_bytes -=3D (pf->internal_stats.rx_unicast + @@ -319= 1,6 +3223,14 @@ i40e_read_stats_registers(struct i40e_pf *pf, struct i40e_h= w *hw) I40E_GLPRT_BPRCL(hw->port), pf->offset_loaded, &os->eth.rx_broadcast, &ns->eth.rx_broadcast); + /* enlarge the limitation when rx_bytes overflowed */ + if (pf->offset_loaded) { + if (I40E_RXTX_BYTES_LOW(pf->old_rx_bytes) > ns->eth.rx_bytes) + ns->eth.rx_bytes +=3D (uint64_t)1 << I40E_48_BIT_WIDTH; + ns->eth.rx_bytes +=3D I40E_RXTX_BYTES_HIGH(pf->old_rx_bytes); + } + pf->old_rx_bytes =3D ns->eth.rx_bytes; + /* Workaround: CRC size should not be included in byte statistics, * so subtract RTE_ETHER_CRC_LEN from the byte counter for each rx * packet. @@ -3249,6 +3289,13 @@ i40e_read_stats_registers(struct i40e_pf *pf, struct= i40e_hw *hw) I40E_GLPRT_BPTCL(hw->port), pf->offset_loaded, &os->eth.tx_broadcast, &ns->eth.tx_broadcast); + /* enlarge the limitation when tx_bytes overflowed */ + if (pf->offset_loaded) { + if (I40E_RXTX_BYTES_LOW(pf->old_tx_bytes) > ns->eth.tx_bytes) + ns->eth.tx_bytes +=3D (uint64_t)1 << I40E_48_BIT_WIDTH; + ns->eth.tx_bytes +=3D I40E_RXTX_BYTES_HIGH(pf->old_tx_bytes); + } + pf->old_tx_bytes =3D ns->eth.tx_bytes; ns->eth.tx_bytes -=3D (ns->eth.tx_unicast + ns->eth.tx_multicast + ns->eth.tx_broadcast) * RTE_ETHER_CRC_LEN; =20 diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.= h index 19f821829..5d17be1f0 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -282,6 +282,9 @@ struct rte_flow { #define I40E_ETH_OVERHEAD \ (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE * 2) =20 +#define I40E_RXTX_BYTES_HIGH(bytes) ((bytes) & ~I40E_48_BIT_MASK)=20 +#define I40E_RXTX_BYTES_LOW(bytes) ((bytes) & I40E_48_BIT_MASK) + struct i40e_adapter; struct rte_pci_driver; =20 @@ -399,6 +402,8 @@ struct i40e_vsi { uint8_t vlan_anti_spoof_on; /* The VLAN anti-spoofing enabled */ uint8_t vlan_filter_on; /* The VLAN filter enabled */ struct i40e_bw_info bw_info; /* VSI bandwidth information */ + uint64_t old_rx_bytes; + uint64_t old_tx_bytes; }; =20 struct pool_entry { @@ -1156,6 +1161,10 @@ struct i40e_pf { uint16_t switch_domain_id; =20 struct i40e_vf_msg_cfg vf_msg_cfg; + uint64_t old_rx_bytes; + uint64_t old_tx_bytes; + uint64_t internal_old_rx_bytes; + uint64_t internal_old_tx_bytes; }; =20 enum pending_msg { -- 2.17.1