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 D048CA04C7; Wed, 16 Sep 2020 04:39:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B7BB51C0CF; Wed, 16 Sep 2020 04:39:43 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id AC6B81C0CF; Wed, 16 Sep 2020 04:39:41 +0200 (CEST) IronPort-SDR: nAPwqujytn6bmerbmKTji9/GLC3WErxU9OLiEbM3Y8EsQ0ZErjrcJAKuUAEWcxnSoq3DPRBzJ4 JgXQr3vNiiwQ== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="177460347" X-IronPort-AV: E=Sophos;i="5.76,430,1592895600"; d="scan'208";a="177460347" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2020 19:39:40 -0700 IronPort-SDR: c50Z2KjLKp0SyEZ8/tdBcri4Ac0ih0uMN+unnoQQ7cbNSlga83TtlLNbzRR/g276flNLS9/FwY WXzGwtcztd9A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,430,1592895600"; d="scan'208";a="380018808" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga001.jf.intel.com with ESMTP; 15 Sep 2020 19:39:40 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 15 Sep 2020 19:39:40 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 15 Sep 2020 19:39:39 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.36.51) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Tue, 15 Sep 2020 19:39:38 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fa6vw+GDWgUmKqk7+8+jruX0LAWbY7JnjQli6Qm0jq8asQOW8bEyYeBgKSi88ks1Vzvm7Jv7AXATIjAxVOnhNf6gl8PEQYYPMmlTAZJIxCCyTQoYEke4dOc0eOVnrbB0DlOC1FvgwMVpa03CMeDXKF/8UjeRRFKuAEC4N+I3+PkGqe84Kh24jS0qzY6+qBTX/Cdl8WKjed3yCA3DcvlDoXEdlL5sT5LrTw5jwXExufe7vhu/Na0wipFhRHe5OulbLu59AFz+W5RoMYJbwDxlPmmhRAzAO6xZPGsgVckhZw0xDsBp6GdxH91oErNPEpiJbnCPrpyfJHiCbbW0RMIoNQ== 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=XCgrrCXbLI/j72t03hKph/OZ+F8GEnNUez+bOG9L2yQ=; b=LdBFoLkKMUEA8T42nw7poIQkXRZnLuaY7uWAD7FegV1qltYT0gI0fJtnNqE2QeWRCPLkP2+pwk1TCVGJSrjzkMk+kVcCyKgHRhS2OeRF0A1leEuuTTOcaCiLBlNlLbEWARD5LB0Xw8WDavW7vT3coQ5t4eEh7ClgSAV6cy5jUPY2FzAdKhyF4CQ4qur7jo6dDKp/GvzZuPKKHJnjbQVWMFaV+MScmqXii6Xn0j0QYzjo1QK81FjjwNZs4Au2AVKzFtzHTqp82KCn/SeBWD2auGxvdXeZFzpd2yL/mQjmJeZISjqGAY2yfaeMzrppj4tANYr7WMesXh2rbIkKDTNWLw== 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=XCgrrCXbLI/j72t03hKph/OZ+F8GEnNUez+bOG9L2yQ=; b=ZuqYBOvgG6uo/JfQ+oQP0pQ5BcWZ8WqN6KWocUPYj0XuZEq4oDPzvLxeQ+jFKzoUgKOKxPfRwBXST1QnYRIpczJMtNFK9TxH2UZ6zCRB//p10/CPJB2t+urucNbU58SwFgekdVVhSCDwsS8S8cZhzHDVowGgORaQIjIQxn4NQLA= Received: from BN7PR11MB2818.namprd11.prod.outlook.com (2603:10b6:406:ad::23) by BN7PR11MB2674.namprd11.prod.outlook.com (2603:10b6:406:b2::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 16 Sep 2020 02:39:35 +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.019; Wed, 16 Sep 2020 02:39:35 +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 v2] net/i40e: fix incorrect byte counters Thread-Index: AQHWi8+XX+3IH7dK80WX3X9Xs/ZC76lqjZDg Date: Wed, 16 Sep 2020 02:39:35 +0000 Message-ID: References: <20200910015426.3140-1-junyux.jiang@intel.com> <20200916015105.39815-1-junyux.jiang@intel.com> In-Reply-To: <20200916015105.39815-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: 735c7de2-9b8e-46b1-d550-08d859e9bffe x-ms-traffictypediagnostic: BN7PR11MB2674: 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: iQhQCTqcF642EnOUxGd/ywufMp+TyT/yCC3Yo5hXMejKmWAIKQWJc1bc/9jgGUjU0SZWu+T0ewOSY+a4wkINd3zweTEZZkChonxxL4VD1xMhZL+3rrUYG7nABIallwx6IDmur4f0W9UzQN0Ogh6zFE1lL7A6/wpYF1c+1HGJgKt4s2jfXIrAWwWa06w0P9Dg/+15AQLS79kdVTviH49m9zEJmGdEq5iDp2gHlNjKaqkGhhZhYTkjBCcpWCSs+EG3GraMwn++PDFoquiPCYXJMV3sVG2uFQQUgvOxbXwhGwWBXnd7Z1POMnSnssCPOL92XnyYtMIyAi5AtDbuBK10SQ== 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)(39860400002)(366004)(346002)(376002)(396003)(136003)(83380400001)(71200400001)(2906002)(8936002)(9686003)(186003)(8676002)(53546011)(316002)(86362001)(478600001)(52536014)(4326008)(26005)(55016002)(7696005)(450100002)(76116006)(5660300002)(6506007)(66476007)(66446008)(110136005)(33656002)(66946007)(64756008)(66556008)(54906003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: FhzjtLxj2vAGMmwlBfzBYwNJIEzBeW5PcvhFcO3WH5orGkAIOZcNPsdDBo+sqTtdEsvAkd/G0rcNE6PuBCzBh+Tw5qP/Be62fC+Yg2mzCmtGq5slU2e8Z6YjAgLys+NLNFkNhq1GuZXqIBvKc7+fEFPbcdqwb9mwXVQea5QbEhkMKn4d4cK7Rc0nSRs7qwS1wruV0JM2oo8yefKgHU20ed4MJ3k5k6vIuLzAiVoSi22J1jyNF/F8nGXRkYLCjDb+ByN+Z7RDdXt2JiojAkw12f2dqkE0NhqAp5OC3r9wfNVPNuURWPWQuX9MB/2dfBLHjbzFtGitM3O33FdVulpDUGaqgU4tNfAmcE055LTGBakKZjy1lkbYJLXW/OyIzyp+YV6HiAwBxCr8My+knjZEVtRvEwBcMWizKp7iaNrV1LxhF0FTS8OYu9xZB96Nf5Q0lb8DWQDj8+DGSxNWPghxxznKFcyR6sOnqj4y8zH0gT5YAwAKvckePn5+80MHXMYuyyXL7YXw2s0AcwrNQksYA2vDqLREZcTGqVgzDF/Dx3J05tjymZJ/RhDcsQS2T9ae6fOmoiR7P5QzvUPWcZdi27nlI7rhCKzFPYU7anvQE/jDsYUYjt9jCPf0SEVZTpLQ6pf6LNbLaVVdd4FB/U0zCg== 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: 735c7de2-9b8e-46b1-d550-08d859e9bffe X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Sep 2020 02:39:35.4647 (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: mav5NKbe5oOuUEXIk4NZR4nOIISbj5QGp5o80ErCAKJ6ebTlnvMIXVE8LZCMPxjOhA3vDapma3Vg5gKK7RjwLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR11MB2674 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v2] 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: Wednesday, September 16, 2020 9:51 AM To: dev@dpdk.org Cc: Guo, Jia ; Xing, Beilei ; Jia= ng, JunyuX ; stable@dpdk.org Subject: [dpdk-stable] [PATCH v2] 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 563f21d9d..4d4ea9861 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -3073,6 +3073,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; @@ -3099,6 +3106,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_tx_bytes =3D nes->tx_bytes; vsi->offset_loaded =3D true; =20 PMD_DRV_LOG(DEBUG, "***************** VSI[%u] stats start ***************= ****", @@ -3171,6 +3185,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= 4,6 +3226,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. @@ -3252,6 +3292,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