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 95F5DA0032; Tue, 28 Sep 2021 13:16:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5EDDE410DF; Tue, 28 Sep 2021 13:16:51 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 0569A40E3C; Tue, 28 Sep 2021 13:16:48 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10120"; a="224743044" X-IronPort-AV: E=Sophos;i="5.85,329,1624345200"; d="scan'208";a="224743044" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2021 04:16:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,329,1624345200"; d="scan'208";a="538118333" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga004.fm.intel.com with ESMTP; 28 Sep 2021 04:16:47 -0700 Received: from shsmsx604.ccr.corp.intel.com (10.109.6.214) 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.2242.12; Tue, 28 Sep 2021 04:16:46 -0700 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by SHSMSX604.ccr.corp.intel.com (10.109.6.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Tue, 28 Sep 2021 19:16:45 +0800 Received: from shsmsx601.ccr.corp.intel.com ([10.109.6.141]) by SHSMSX601.ccr.corp.intel.com ([10.109.6.141]) with mapi id 15.01.2242.012; Tue, 28 Sep 2021 19:16:45 +0800 From: "Zhang, Qi Z" To: "Zhang, AlvinX" , "Xing, Beilei" , "Guo, Junfeng" , "ktraynor@redhat.com" CC: "dev@dpdk.org" , "Zhang, AlvinX" , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2] net/i40e: fix Rx packet statistics Thread-Index: AQHXtBgnHdSvoJ54HU65fXevo1bz0Ku5TD7g Date: Tue, 28 Sep 2021 11:16:45 +0000 Message-ID: References: <20210926075757.15116-1-alvinx.zhang@intel.com> <20210928032239.17756-1-alvinx.zhang@intel.com> In-Reply-To: <20210928032239.17756-1-alvinx.zhang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.6.200.16 dlp-product: dlpe-windows x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix Rx packet statistics 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 Sender: "dev" > -----Original Message----- > From: dev On Behalf Of Alvin Zhang > Sent: Tuesday, September 28, 2021 11:23 AM > To: Xing, Beilei ; Guo, Junfeng > ; ktraynor@redhat.com > Cc: dev@dpdk.org; Zhang, AlvinX ; stable@dpdk.org > Subject: [dpdk-dev] [PATCH v2] net/i40e: fix Rx packet statistics >=20 > Some packets are discarded by the NIC because they are larger than the MT= U, > these packets should be counted as "RX error" instead of "RX packet", for > example: >=20 > pkt1 =3D Ether()/IP()/Raw('x' * 1400) > pkt2 =3D Ether()/IP()/Raw('x' * 1500) >=20 > ---------------- Forward statistics for port 0 ----------------- > RX-packets: 2 RX-dropped: 0 RX-total: 2 > TX-packets: 1 TX-dropped: 0 TX-total: 1 > ---------------------------------------------------------------- >=20 > Here the packet pkt2 has been discarded, but still was counted > by "RX-packets" >=20 > The register 'GL_RXERR1' can count above discarded packets. > This patch adds reading and calculation of the 'GL_RXERR1' counter when > reporting DPDK statistics. >=20 > Fixes: f4a91c38b4ad ("i40e: add extended stats") > Cc: stable@dpdk.org >=20 > Signed-off-by: Alvin Zhang > --- > drivers/net/i40e/i40e_ethdev.c | 16 +++++++++++++--- > drivers/net/i40e/i40e_ethdev.h | 10 ++++++++++ > 2 files changed, 23 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethde= v.c > index 7a2a828..7a207b2 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -532,7 +532,7 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_p= f > *pf, > /* store statistics names and its offset in stats structure */ struct > rte_i40e_xstats_name_off { > char name[RTE_ETH_XSTATS_NAME_SIZE]; > - unsigned offset; > + int offset; > }; >=20 > static const struct rte_i40e_xstats_name_off rte_i40e_stats_strings[] = =3D { @@ > -542,6 +542,8 @@ struct rte_i40e_xstats_name_off { > {"rx_dropped_packets", offsetof(struct i40e_eth_stats, rx_discards)}, > {"rx_unknown_protocol_packets", offsetof(struct i40e_eth_stats, > rx_unknown_protocol)}, > + {"rx_size_error_packets", offsetof(struct i40e_pf, rx_err1) - > + offsetof(struct i40e_pf, stats)}, > {"tx_unicast_packets", offsetof(struct i40e_eth_stats, tx_unicast)}, > {"tx_multicast_packets", offsetof(struct i40e_eth_stats, tx_multicast)}= , > {"tx_broadcast_packets", offsetof(struct i40e_eth_stats, tx_broadcast)}= , > @@ -3238,6 +3240,10 @@ void i40e_flex_payload_reg_set_default(struct > i40e_hw *hw) > pf->offset_loaded, > &os->eth.rx_unknown_protocol, > &ns->eth.rx_unknown_protocol); > + i40e_stat_update_48(hw, I40E_GL_RXERR1_H(hw->pf_id + > I40E_MAX_VF), > + I40E_GL_RXERR1_L(hw->pf_id + I40E_MAX_VF), > + pf->offset_loaded, &pf->rx_err1_offset, > + &pf->rx_err1); > i40e_stat_update_48_in_64(hw, I40E_GLPRT_GOTCH(hw->port), > I40E_GLPRT_GOTCL(hw->port), > pf->offset_loaded, &os->eth.tx_bytes, @@ -3437,7 > +3443,8 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) > stats->ipackets =3D pf->main_vsi->eth_stats.rx_unicast + > pf->main_vsi->eth_stats.rx_multicast + > pf->main_vsi->eth_stats.rx_broadcast - > - pf->main_vsi->eth_stats.rx_discards; > + pf->main_vsi->eth_stats.rx_discards - > + pf->rx_err1; > stats->opackets =3D ns->eth.tx_unicast + > ns->eth.tx_multicast + > ns->eth.tx_broadcast; > @@ -3451,7 +3458,8 @@ void i40e_flex_payload_reg_set_default(struct > i40e_hw *hw) > pf->main_vsi->eth_stats.rx_discards; > stats->ierrors =3D ns->crc_errors + > ns->rx_length_errors + ns->rx_undersize + > - ns->rx_oversize + ns->rx_fragments + ns->rx_jabber; > + ns->rx_oversize + ns->rx_fragments + ns->rx_jabber + > + pf->rx_err1; >=20 > if (pf->vfs) { > for (i =3D 0; i < pf->vf_num; i++) { > @@ -6232,6 +6240,8 @@ struct i40e_vsi * > memset(&pf->stats_offset, 0, sizeof(struct i40e_hw_port_stats)); > memset(&pf->internal_stats, 0, sizeof(struct i40e_eth_stats)); > memset(&pf->internal_stats_offset, 0, sizeof(struct i40e_eth_stats)); > + pf->rx_err1 =3D 0; > + pf->rx_err1_offset =3D 0; >=20 > ret =3D i40e_pf_get_switch_config(pf); > if (ret !=3D I40E_SUCCESS) { > diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethde= v.h > index cd6deab..846c8d4 100644 > --- a/drivers/net/i40e/i40e_ethdev.h > +++ b/drivers/net/i40e/i40e_ethdev.h > @@ -19,6 +19,13 @@ > #include "base/i40e_type.h" > #include "base/virtchnl.h" >=20 > +#define I40E_GL_RXERR1_H(_i) (0x00318004 + ((_i) * 8)) > +/** > + * _i=3D0...143, > + * counters 0-127 are for the 128 VFs, > + * counters 128-143 are for the 16 PFs > + */ I assume above comment is for I40E_GL_RXERR1_H, so it should above it?=20 > + > #define I40E_VLAN_TAG_SIZE 4 >=20 > #define I40E_AQ_LEN 32 > @@ -1134,6 +1141,9 @@ struct i40e_pf { >=20 > struct i40e_hw_port_stats stats_offset; > struct i40e_hw_port_stats stats; > + u64 rx_err1; /* rxerr1 */ > + u64 rx_err1_offset; > + > /* internal packet statistics, it should be excluded from the total */ > struct i40e_eth_stats internal_stats_offset; > struct i40e_eth_stats internal_stats; > -- > 1.8.3.1