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 B906F41C35; Wed, 8 Feb 2023 03:00:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 575E742BD9; Wed, 8 Feb 2023 03:00:10 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 8033342BAC for ; Wed, 8 Feb 2023 03:00:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675821607; x=1707357607; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=MnAxG6tcUNWynErGWiS3X902UMI4g+zPely0EYHbiZk=; b=aTqGSNUkGn/YKPkj+VYnkgMzhRx+cj2jBw8gYx8rs4qNkSFBf+tb9S/v 1hr9KhD/77EIupoi569V2yFginuA1LQyyI0AmQATyOMh0U0LYSmJSuHcz xeNKfATGd1JNDBXARPCFmbmyiiXV22pYqH9KmIF+tFR24Ef01RMyiCSKM G74SrJCWZv1z4JefGWFy+ciKTdYsccFlZ62mFfBBu7Wk3n1ijnZjSxatP l199sRj+eFNXsP1sM+m9MTZ0/Vi8taLgDrSdAXP8HwAZUyNH4nrYFhK5t HNAFfL+1q8lP0nGG6ziwmApHQIuSJaSQJBvjWAT3y2bl0WznWDb9tO5fn Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="317681289" X-IronPort-AV: E=Sophos;i="5.97,279,1669104000"; d="scan'208";a="317681289" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2023 18:00:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="809765347" X-IronPort-AV: E=Sophos;i="5.97,279,1669104000"; d="scan'208";a="809765347" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga001.fm.intel.com with ESMTP; 07 Feb 2023 18:00:05 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 7 Feb 2023 18:00:02 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Tue, 7 Feb 2023 18:00:02 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Tue, 7 Feb 2023 18:00:02 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ut0YfzHsQVuprAD9NPuXhG3/47UMqzu6vTfa0+W3+qySLwWQt8OQDRSVlI0XAyocGhgFmIUJAzBZWKNFDbtZ/t94jg6GdgmpKHmYEDcaP03P5+MMAE+mo0igno2OGj+FWpeBxyNsK+X5bn8dVlWXPbiWujESulG9UKXyahDMU096v4PwFwj+gbqMIUrXyDpdjmPwgwAfPnMsyQrNJ7l8fR1tvLiNtkH8Mn/njOtIlwfQJ1BDb7zBGd8j2lxF1Xdh6aoWP8UPL8JKMhGZC69BNio0MLV0ay7KYhl7vG7QFDXt0W7BX+mZB5/Y1ORGpAo9P4Juypz755yFVboi4GxFjQ== 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=v+JGQe02Jr9PVLm7YRt63LR+05/J098aZKuGUCM7zOk=; b=k+Xi/U5aLLVvkiX0E5Cg9j4TYyaKSwVTYpVrW/VHfTUSUJbBmoRp6fsu3WXR0LBRJ8E7ECUDSRxJRDP+yO9jmypAUR+DOUmUmvEaFkdfvpJ6EpQN2zdQcNdClqD8tKnaifFlgJCygzqw8njjVnjgL71O1IqXDXCV03ZtdTG0VXISEJWMEzZrFSl0BVpOpkPskE3Y4rznHH9ro3zfFXKSdsE1KE/BBsvuqHCWiQC10ab96JqXiWapEuArTatWVHp3mI80Ok5moYbfseMMNcVOBy4odjxymBDOvcOpWvdQzNFSGQM9ytUDChrV69bRvaRX1KJJMo4ZF+wX6WWxoPl4Ug== 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 Received: from DM4PR11MB5994.namprd11.prod.outlook.com (2603:10b6:8:5d::20) by CO1PR11MB5012.namprd11.prod.outlook.com (2603:10b6:303:90::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Wed, 8 Feb 2023 02:00:00 +0000 Received: from DM4PR11MB5994.namprd11.prod.outlook.com ([fe80::eb70:80e0:1b88:3ca5]) by DM4PR11MB5994.namprd11.prod.outlook.com ([fe80::eb70:80e0:1b88:3ca5%9]) with mapi id 15.20.6064.034; Wed, 8 Feb 2023 02:00:00 +0000 From: "Zhang, Qi Z" To: "Liu, Mingxia" , "dev@dpdk.org" , "Wu, Jingjing" , "Xing, Beilei" Subject: RE: [PATCH v6 1/6] common/idpf: add hw statistics Thread-Topic: [PATCH v6 1/6] common/idpf: add hw statistics Thread-Index: AQHZOuVOBZawQt96Oki7oJW7dLZJCK7ESxfA Date: Wed, 8 Feb 2023 02:00:00 +0000 Message-ID: References: <20230207100859.2401709-2-mingxia.liu@intel.com> <20230207101650.2402452-1-mingxia.liu@intel.com> <20230207101650.2402452-2-mingxia.liu@intel.com> In-Reply-To: <20230207101650.2402452-2-mingxia.liu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM4PR11MB5994:EE_|CO1PR11MB5012:EE_ x-ms-office365-filtering-correlation-id: dfacc199-8d45-47f7-1812-08db09782fa3 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dU4zycaFSQ4b6ZTJ6amz+FQu/rVwBDh10nWgqn4ZeZGpdOGwTfSP2ldkk7aT8fLePpADK5minakrrkAHltLiUd+oKNUDs1XOQbF1SqhV95kEf9x4YCURohtvFTbXpG9+qBbicHWRotsjy6KfpAN72Mz859p4rozan9MgzKeuhDkI8Y0+MvEzBzxc0lFvixB1QBK4axBUluiPSO0avgIdXmDZPkKX3AL0qpw5JDDAO1EguXk8YYxjsBBWyv5DZ8Vd2lJV5t6sdVHFPyjn7EjtYDxowlUWldiKoLPusXQeJyKyhsTynjs/TX5+UiwAlN9GHvvwz6+uybfk5tQTpKvSRjBXAcD3YcZ7k31zMj0lS2Ot7WATqdDwOnhh0e/XBZpY+Kraz9uY8PPLLL2jZ6FQfjtv2DoMP2QarKGw6ihprY+8MJVZrPNYC8wcCoChfLLYPWC52IDVmAbWfHhlwMMZQ0/UhzscUI/bR2h4Iu4PXG3RKtpftQ9+egI+t+eFCPEMhVfEwkPK9tIqie18bpZ8hOBXlZ/aq0Si+qu1ZkMd/dQElgwq7J3O/mJ+EJF2WVo1snAucMvpxIL2q899DY9C7UKbODk7GTefRVhbgEUbygSjmzMJDiM31LwBx5ntqyyms4sMcRSeLh7T5imE815M0YWro52vOpLWwuhm9UQdOhd5Qf8Qf+TGlZOH76QoPUXERLbjA9Q2qXK6QmDCv739/w== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5994.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(346002)(396003)(376002)(366004)(39860400002)(136003)(451199018)(6636002)(53546011)(6506007)(71200400001)(38070700005)(8676002)(55016003)(186003)(9686003)(316002)(110136005)(86362001)(38100700002)(82960400001)(122000001)(7696005)(26005)(478600001)(8936002)(41300700001)(33656002)(83380400001)(52536014)(5660300002)(66946007)(76116006)(66446008)(64756008)(66476007)(66556008)(66899018)(2906002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?cH1yZKMCCwYyH6ocudaGUlpgPoqP0rJur3kqrN/JMhULxN7a2cYqHJ1AD4lQ?= =?us-ascii?Q?DbQ/1w5KNmbabLnA8vlfTqnDh6UYK5eGueap9r2gNXORFuV35Qwvo+obMBGQ?= =?us-ascii?Q?DHCgJ+DQ0lhdUE/TMm0QEBL8Bpn4Q6XR2Mq+qeakLLZAYOzct4ec700HAjb8?= =?us-ascii?Q?TxWf9rbm6aqOipXeMViJLIY+QcKOQtjfhpVDF6+CcZ/RPvWFXxB90/3ua93I?= =?us-ascii?Q?v08CEib8T/K3oi9D/uYwRGuK4DkvfV83mYPbodbyjCVSrtMxQhbxyDWbtrRc?= =?us-ascii?Q?2wzht7VeZCrln4L3VGXorlftXtzKKg0okLUjECkxMKDTtW2CVglnSjHv+/3h?= =?us-ascii?Q?dofq+GWGLNfbcgScZiB73sUev1Z8it1z73TvSZ3nI52+EHxSXSpf0tLWyiCe?= =?us-ascii?Q?rhXTWC/ACinrH+rdwdgX4MpmWC9cSOcR6i45RPCCcxAKBY9IH1IxH97486S9?= =?us-ascii?Q?jv1Y26VAsCLASQ63s8JFzzcRwFtkb5DtxiJ02FFLEfYZ+4p+Jr7haP8S7TVp?= =?us-ascii?Q?Qi+1J6EiE/jTx/v1s/jXe3j8vHf/FZAw8e0ewqv9NvPL9q2/ozUHpl6kzXcH?= =?us-ascii?Q?KsgBpNbMa0XxXAq8rfFR5RLVys6jRLQdsIKnqJrP1BHmeSABSfuaKySep/W1?= =?us-ascii?Q?XNBoaKcx5/CkdOCZSv0IcQC9GIjypTwIIzb/yoKSKDQd7iT9wtEJ1fEJzJiT?= =?us-ascii?Q?eLPC716aR/T4+ayBBI4GTSTSFv9o1oygxGoSLOVJQ8+SikpG7UKvyORxHENb?= =?us-ascii?Q?yaHr8QP/y/0dkhdj8NFxfM24MfKQR5oDIu3KzHmCqv11Df02KU+zafkmGOGH?= =?us-ascii?Q?2JGxyysMaDAvGGi4l4Tgo8gpUtdroAHFoAiicUTohimdGWlsH9clMo1GMKQh?= =?us-ascii?Q?W3ksznn1zj3OmiTzmCVzkM9IFbb3R3QzN0WpP8QVIobynUJPBf9F/eIonL4q?= =?us-ascii?Q?I2Jdg5mViuK7/vDa5vyt48Q6CIzhOUfN69MUAGKu+2e89vmnrMf9Rjat89E9?= =?us-ascii?Q?XotGzCKP/wkUd4V9sN+dJ4J/c4uVurHTvqR7ZN4GEeQmO17k9rvqSuE0nw5/?= =?us-ascii?Q?3VQOkdg1nXl80XygpeZPQGeG0ZOHV2Gc7JVRPJPpJaDuI7ljz6yadTt8Qf53?= =?us-ascii?Q?W65hEwRccVKfcTL1HqIZknJHKgvCF45mFeKwUc3CM7rC9gmfOGVAU3qeKA1q?= =?us-ascii?Q?Xrfh/pD/aNuRrwKobPknyQEnr3mCnb2lVxm85zZY8Q5dydfosLYaey3qtE43?= =?us-ascii?Q?otQEy5rPtWt6RypRcIGSV8O2cBK+md5AkqBoyJXTmtix3AK0w0lI4qkobUfe?= =?us-ascii?Q?L9ulkrK6lcwYRHiecKRvK5ZxPhaRw/eNEoCo+kmgi5i6TT9u6WlB9W+hXw7s?= =?us-ascii?Q?s9RwybkzUfBPRtbKkA269vRjLupkr6PQ/FFMG9LtOvh/x1gGWfAKdKkMw8D9?= =?us-ascii?Q?oqhlhu9KmBkZjly/y9dTWrdDbebV089/Wu+kflYHPL4qxrIWnRsJ6rt8Rv0S?= =?us-ascii?Q?DC4tr+JRnnkjXHIimeMZRou1/tQQONU9taSInzeoz6Ia7xMTYVsZHfNx79ZD?= =?us-ascii?Q?oXxDAJ5bl1I1okxsEIw1owAVFhkVrtS9T6ULEJZA?= 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: DM4PR11MB5994.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfacc199-8d45-47f7-1812-08db09782fa3 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2023 02:00:00.2844 (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: QBCroL+A0HdfCetw+KXJWIcxHCecbEufjbxavilx9xdCIaxZWD0xWvOuJyOzDNqtdHs4dsnTVWikatuhCMogug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR11MB5012 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: Liu, Mingxia > Sent: Tuesday, February 7, 2023 6:17 PM > To: dev@dpdk.org; Zhang, Qi Z ; Wu, Jingjing > ; Xing, Beilei > Cc: Liu, Mingxia > Subject: [PATCH v6 1/6] common/idpf: add hw statistics Suggest to use ./devtools/check-git-log.sh to fix any title warning if poss= ible Also the main purpose of this patch is to support stats_get /stats_reset AP= I, the prefix is more reasonable to be "net/idpf" but not "common/idpf. Please fix other patches if any similar issue.=20 >=20 > This patch add hardware packets/bytes statistics. >=20 > Signed-off-by: Mingxia Liu > --- > drivers/common/idpf/idpf_common_device.c | 17 +++++ > drivers/common/idpf/idpf_common_device.h | 4 + > drivers/common/idpf/idpf_common_virtchnl.c | 27 +++++++ > drivers/common/idpf/idpf_common_virtchnl.h | 3 + > drivers/common/idpf/version.map | 2 + > drivers/net/idpf/idpf_ethdev.c | 86 ++++++++++++++++++++++ > 6 files changed, 139 insertions(+) >=20 > diff --git a/drivers/common/idpf/idpf_common_device.c > b/drivers/common/idpf/idpf_common_device.c > index 48b3e3c0dd..5475a3e52c 100644 > --- a/drivers/common/idpf/idpf_common_device.c > +++ b/drivers/common/idpf/idpf_common_device.c > @@ -652,4 +652,21 @@ idpf_vport_info_init(struct idpf_vport *vport, > return 0; > } >=20 > +void > +idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct > +virtchnl2_vport_stats *nes) { > + nes->rx_bytes =3D nes->rx_bytes - oes->rx_bytes; > + nes->rx_unicast =3D nes->rx_unicast - oes->rx_unicast; > + nes->rx_multicast =3D nes->rx_multicast - oes->rx_multicast; > + nes->rx_broadcast =3D nes->rx_broadcast - oes->rx_broadcast; > + nes->rx_errors =3D nes->rx_errors - oes->rx_errors; > + nes->rx_discards =3D nes->rx_discards - oes->rx_discards; > + nes->tx_bytes =3D nes->tx_bytes - oes->tx_bytes; > + nes->tx_unicast =3D nes->tx_unicast - oes->tx_unicast; > + nes->tx_multicast =3D nes->tx_multicast - oes->tx_multicast; > + nes->tx_broadcast =3D nes->tx_broadcast - oes->tx_broadcast; > + nes->tx_errors =3D nes->tx_errors - oes->tx_errors; > + nes->tx_discards =3D nes->tx_discards - oes->tx_discards; } > + > RTE_LOG_REGISTER_SUFFIX(idpf_common_logtype, common, NOTICE); diff > --git a/drivers/common/idpf/idpf_common_device.h > b/drivers/common/idpf/idpf_common_device.h > index 545117df79..1d8e7d405a 100644 > --- a/drivers/common/idpf/idpf_common_device.h > +++ b/drivers/common/idpf/idpf_common_device.h > @@ -115,6 +115,8 @@ struct idpf_vport { > bool tx_vec_allowed; > bool rx_use_avx512; > bool tx_use_avx512; > + > + struct virtchnl2_vport_stats eth_stats_offset; > }; >=20 > /* Message type read in virtual channel from PF */ @@ -191,5 +193,7 @@ > int idpf_vport_irq_unmap_config(struct idpf_vport *vport, uint16_t > nb_rx_queues) __rte_internal int idpf_vport_info_init(struct idpf_vport > *vport, > struct virtchnl2_create_vport *vport_info); > +__rte_internal > +void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct > +virtchnl2_vport_stats *nes); >=20 > #endif /* _IDPF_COMMON_DEVICE_H_ */ > diff --git a/drivers/common/idpf/idpf_common_virtchnl.c > b/drivers/common/idpf/idpf_common_virtchnl.c > index 31fadefbd3..40cff34c09 100644 > --- a/drivers/common/idpf/idpf_common_virtchnl.c > +++ b/drivers/common/idpf/idpf_common_virtchnl.c > @@ -217,6 +217,7 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, > struct idpf_cmd_info *args) > case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR: > case VIRTCHNL2_OP_ALLOC_VECTORS: > case VIRTCHNL2_OP_DEALLOC_VECTORS: > + case VIRTCHNL2_OP_GET_STATS: > /* for init virtchnl ops, need to poll the response */ > err =3D idpf_vc_one_msg_read(adapter, args->ops, args- > >out_size, args->out_buffer); > clear_cmd(adapter); > @@ -806,6 +807,32 @@ idpf_vc_ptype_info_query(struct idpf_adapter > *adapter) > return err; > } >=20 > +int > +idpf_vc_stats_query(struct idpf_vport *vport, > + struct virtchnl2_vport_stats **pstats) { > + struct idpf_adapter *adapter =3D vport->adapter; > + struct virtchnl2_vport_stats vport_stats; > + struct idpf_cmd_info args; > + int err; > + > + vport_stats.vport_id =3D vport->vport_id; > + args.ops =3D VIRTCHNL2_OP_GET_STATS; > + args.in_args =3D (u8 *)&vport_stats; > + args.in_args_size =3D sizeof(vport_stats); > + args.out_buffer =3D adapter->mbx_resp; > + args.out_size =3D IDPF_DFLT_MBX_BUF_SIZE; > + > + err =3D idpf_vc_cmd_execute(adapter, &args); > + if (err) { > + DRV_LOG(ERR, "Failed to execute command of > VIRTCHNL2_OP_GET_STATS"); > + *pstats =3D NULL; > + return err; > + } > + *pstats =3D (struct virtchnl2_vport_stats *)args.out_buffer; > + return 0; > +} > + > #define IDPF_RX_BUF_STRIDE 64 > int > idpf_vc_rxq_config(struct idpf_vport *vport, struct idpf_rx_queue *rxq) = diff - > -git a/drivers/common/idpf/idpf_common_virtchnl.h > b/drivers/common/idpf/idpf_common_virtchnl.h > index c105f02836..6b94fd5b8f 100644 > --- a/drivers/common/idpf/idpf_common_virtchnl.h > +++ b/drivers/common/idpf/idpf_common_virtchnl.h > @@ -49,4 +49,7 @@ __rte_internal > int idpf_vc_rxq_config(struct idpf_vport *vport, struct idpf_rx_queue *r= xq); > __rte_internal int idpf_vc_txq_config(struct idpf_vport *vport, struct > idpf_tx_queue *txq); > +__rte_internal > +int idpf_vc_stats_query(struct idpf_vport *vport, > + struct virtchnl2_vport_stats **pstats); > #endif /* _IDPF_COMMON_VIRTCHNL_H_ */ > diff --git a/drivers/common/idpf/version.map > b/drivers/common/idpf/version.map index 8b33130bd6..e6a02828ba > 100644 > --- a/drivers/common/idpf/version.map > +++ b/drivers/common/idpf/version.map > @@ -46,6 +46,7 @@ INTERNAL { > idpf_vc_rss_key_set; > idpf_vc_rss_lut_set; > idpf_vc_rxq_config; > + idpf_vc_stats_query; > idpf_vc_txq_config; > idpf_vc_vectors_alloc; > idpf_vc_vectors_dealloc; > @@ -59,6 +60,7 @@ INTERNAL { > idpf_vport_irq_map_config; > idpf_vport_irq_unmap_config; > idpf_vport_rss_config; > + idpf_vport_stats_update; >=20 > local: *; > }; > diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethde= v.c > index 33f5e90743..02ddb0330a 100644 > --- a/drivers/net/idpf/idpf_ethdev.c > +++ b/drivers/net/idpf/idpf_ethdev.c > @@ -140,6 +140,87 @@ idpf_dev_supported_ptypes_get(struct rte_eth_dev > *dev __rte_unused) > return ptypes; > } >=20 > +static uint64_t > +idpf_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev) { > + uint64_t mbuf_alloc_failed =3D 0; > + struct idpf_rx_queue *rxq; > + int i =3D 0; > + > + for (i =3D 0; i < dev->data->nb_rx_queues; i++) { > + rxq =3D dev->data->rx_queues[i]; > + mbuf_alloc_failed +=3D __atomic_load_n(&rxq- > >rx_stats.mbuf_alloc_failed, > + __ATOMIC_RELAXED); > + } > + > + return mbuf_alloc_failed; > +} > + > +static int > +idpf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats > +*stats) { > + struct idpf_vport *vport =3D > + (struct idpf_vport *)dev->data->dev_private; > + struct virtchnl2_vport_stats *pstats =3D NULL; > + int ret; > + > + ret =3D idpf_vc_stats_query(vport, &pstats); > + if (ret =3D=3D 0) { > + uint8_t crc_stats_len =3D (dev->data- > >dev_conf.rxmode.offloads & > + RTE_ETH_RX_OFFLOAD_KEEP_CRC) ? > 0 : > + RTE_ETHER_CRC_LEN; > + > + idpf_vport_stats_update(&vport->eth_stats_offset, pstats); > + stats->ipackets =3D pstats->rx_unicast + pstats->rx_multicast + > + pstats->rx_broadcast - pstats->rx_discards; > + stats->opackets =3D pstats->tx_broadcast + pstats- > >tx_multicast + > + pstats->tx_unicast; > + stats->imissed =3D pstats->rx_discards; > + stats->oerrors =3D pstats->tx_errors + pstats->tx_discards; > + stats->ibytes =3D pstats->rx_bytes; > + stats->ibytes -=3D stats->ipackets * crc_stats_len; > + stats->obytes =3D pstats->tx_bytes; > + > + dev->data->rx_mbuf_alloc_failed =3D > idpf_get_mbuf_alloc_failed_stats(dev); > + stats->rx_nombuf =3D dev->data->rx_mbuf_alloc_failed; > + } else { > + PMD_DRV_LOG(ERR, "Get statistics failed"); > + } > + return ret; > +} > + > +static void > +idpf_reset_mbuf_alloc_failed_stats(struct rte_eth_dev *dev) { > + struct idpf_rx_queue *rxq; > + int i; > + > + for (i =3D 0; i < dev->data->nb_rx_queues; i++) { > + rxq =3D dev->data->rx_queues[i]; > + __atomic_store_n(&rxq->rx_stats.mbuf_alloc_failed, 0, > __ATOMIC_RELAXED); > + } > +} > + > +static int > +idpf_dev_stats_reset(struct rte_eth_dev *dev) { > + struct idpf_vport *vport =3D > + (struct idpf_vport *)dev->data->dev_private; > + struct virtchnl2_vport_stats *pstats =3D NULL; > + int ret; > + > + ret =3D idpf_vc_stats_query(vport, &pstats); > + if (ret !=3D 0) > + return ret; > + > + /* set stats offset base on current values */ > + vport->eth_stats_offset =3D *pstats; > + > + idpf_reset_mbuf_alloc_failed_stats(dev); > + > + return 0; > +} > + > static int > idpf_init_rss(struct idpf_vport *vport) { @@ -327,6 +408,9 @@ > idpf_dev_start(struct rte_eth_dev *dev) > goto err_vport; > } >=20 > + if (idpf_dev_stats_reset(dev)) > + PMD_DRV_LOG(ERR, "Failed to reset stats"); > + > vport->stopped =3D 0; >=20 > return 0; > @@ -606,6 +690,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops =3D = { > .tx_queue_release =3D idpf_dev_tx_queue_release, > .mtu_set =3D idpf_dev_mtu_set, > .dev_supported_ptypes_get =3D idpf_dev_supported_ptypes_get, > + .stats_get =3D idpf_dev_stats_get, > + .stats_reset =3D idpf_dev_stats_reset, > }; >=20 > static uint16_t > -- > 2.25.1