From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50120.outbound.protection.outlook.com [40.107.5.120]) by dpdk.org (Postfix) with ESMTP id 61B802B92 for ; Wed, 22 Aug 2018 09:38:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cgstowernetworks.onmicrosoft.com; s=selector1-cgstowernetworks-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WjJdgVKqF5QaScdmbgXY7BzIr1RAaPfZKHyxfzqh2gs=; b=iBSHzTM2V9WQCzkqezBDQQi25/1XJnriIF1XXgu4tm8q3zsA4KRbMobm/BrKjfz76bUuvGBM4dKVy9W/VBTSLqW4qTgET/7w2/luJFtTJ2FwBThV5C21wdYzFA5kF1WpiFO++18Nkb0tW6mQip+hiRdvzklwNvpK5w73fTMMuOQ= Received: from ubuntu.cgs.com (5.144.48.231) by DB6PR0902MB1829.eurprd09.prod.outlook.com (2603:10a6:4:b1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.24; Wed, 22 Aug 2018 07:38:13 +0000 From: yogev ch To: Yong Wang Cc: dev@dpdk.org, yogev@cgstowernetworks.com Date: Wed, 22 Aug 2018 10:40:17 +0300 Message-Id: <1534923617-55302-1-git-send-email-yogev@cgstowernetworks.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [5.144.48.231] X-ClientProxiedBy: VI1PR03CA0051.eurprd03.prod.outlook.com (2603:10a6:803:50::22) To DB6PR0902MB1829.eurprd09.prod.outlook.com (2603:10a6:4:b1::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5e8acf4-cc90-4fc6-0756-08d60802380d X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989137)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990107)(7048125)(7024125)(7027125)(7028125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:DB6PR0902MB1829; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0902MB1829; 3:cXccrJcKxp4rq2oXNvXGTqSPZv6VyaZL2GFunnYqEYvJxpg3i5moLYQG654XkltZ2TOcZUfUwGVe/3OY4amnIWQFH1q2riff4hLjXkWhpFR/33nSEm21VCh3OtwrJ0JTAJoGHAbcg6eaUtIcEsEnyU+DPG9Yw7+c9ZYq8iLDPdd0w8KWfR8UcYQwz3Frlv/x2Tixc/Mk15TUP807cAJsk7GykTbuClyOZ9WR77SCktMYUKwVbOwd1ceDE5n+wsc/; 25:AQUY293+QCCjlKZ4aVknYvgX7pkXfIOo4sdFrOGqYzxpbquguqsRPa0+dX/Ue0R+MKp6Qdbt/zgEOQZwSO6OSHsJnoKmGN67ZF9CpXkQQSWceF0iC61GP997kl8A8IPfkC1ssqlurL8s0vYCjQs3Yzo6d9lVo93qDS3nXZ7J4IKNteCubUgJvfDCrB6bPNuAKkoCKjhsdEAiwmwGMbow48k/qUQIHS2orOmIohu56ii+jnu1AqXSsdXnH48997UXjLMQ3gqLynIN4N5V//jThnW8J0aUrTK+QcLaujVIK6R6TOSJdrB9xsFRaOaelRmqyjn+wrGB0+VWnKcOYGhNEw==; 31:S4KoggNVo/66wLi8YoiZnyRFU76YjwBBT0keFInZurNVVbUCqj0XgBpHhNa+BOokMaC/Cvm2HhQQ3Og8uKpMz+fWfkRXGvoBUFmzct0zi5VbBIeP2nJgUe1cba6NmaNJ++bRh2JiIzlf0t1xr8sTfl1/zjarneQ//kcStxcyIWKstmBPpFQHkz13RWRnwLUbO4slhbUsdo1WU5LBCSQ6zdFsih61LTz1T2ma6h11mvM= X-MS-TrafficTypeDiagnostic: DB6PR0902MB1829: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123560045)(2016111802025)(20161123558120)(6043046)(201708071742011)(7699016); SRVR:DB6PR0902MB1829; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0902MB1829; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0902MB1829; 4:0CHsrgbuyRrOjatPqTvawCQLqqFn9rSVuc4W4hx2urcSd++JHFzygOuHnQDyxf0bxQdbz8T6WsvQ+QNTIwk1IdjugNAHxoKIaFC/FVRJRkMsc0m828Msm9EvBh/cuO4tvqUtfhKByeTEp70+oIKL67dENQRefR8XVnTX/q0HWpKIgDiH7TL5mL33kJc9i3xLVbMEAXAHw3dfRu5M8yuPuo1iSmbvLPyLVBXhl7wFJobK5dhVJF45Hsfh3Q619CcnlelVR3E41xGBYw+z2idDxg== X-Forefront-PRVS: 0772E5DAD5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(346002)(366004)(376002)(136003)(39830400003)(396003)(199004)(189003)(478600001)(48376002)(68736007)(25786009)(4326008)(14444005)(386003)(1857600001)(105586002)(5660300001)(956004)(37156001)(2616005)(8936002)(81166006)(16586007)(52116002)(81156014)(186003)(476003)(316002)(53936002)(71446004)(7736002)(50226002)(97736004)(26005)(486006)(51416003)(6506007)(2906002)(8676002)(107886003)(6486002)(66066001)(86362001)(53416004)(6916009)(16526019)(3846002)(36756003)(6512007)(305945005)(47776003)(106356001)(6116002)(86152003)(6346003)(50466002); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0902MB1829; H:ubuntu.cgs.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cgstowernetworks.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yogev@cgstowernetworks.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0902MB1829; 23:U1TGd5exc7sbeLdIVfxPmJJnLdx9m4wl8FpT6i0?= =?us-ascii?Q?+dHVt1kXo4F4QLd6LaMwNT0YSWvHiI7D4GMjA1jRAGgAS9ya2HU7YzFMUWGb?= =?us-ascii?Q?HxqNsGvDEaTXvtrwYGXy5cc3Lc0EkWei56yzfkGuXsoT9WZ9oSbTYcJL+p9U?= =?us-ascii?Q?RK+O39vZXcqmZM/jc1SqLNJNT7mCR8L0GKgKz9tfCWEtg5WLiFzoKoQkWfqO?= =?us-ascii?Q?JSIq669h1rf8jnDIj91lJMY4iixC6muOo7xTqWB5JFNc/KT11nt5zX8PD+nF?= =?us-ascii?Q?EoJ+CZU/g1CCoH6/z7+sMFWdCYDiOEmivuqFZwH0VxufmKlMICtaN51kzN3C?= =?us-ascii?Q?ok9DHL87HWCE7yQKqAdCojfhkj/Pksqd0CeHhgkF4n9BUhBLP/uHNYvEXdEB?= =?us-ascii?Q?MiNASRQhOAeo1GuTTE58rIqbJXMB5or7btgu10PQyIfdZfKU02HWyahfmOAd?= =?us-ascii?Q?5NwLzblNeSfvEVwhR2OdKkYf7AT/cZFgHkgBxBL7HwTndXMWAH40VmWiLjuY?= =?us-ascii?Q?xHJDdb/LqxuxfywpL/RlcgDIti09WHYYi1Bq895zte3SfN/bRZgiaO554EKT?= =?us-ascii?Q?CjteciLTHkwwnELpX8chl5StxKr1EfrtvCFy3PRQtuOGfmPwDepe88DQrIbk?= =?us-ascii?Q?bM9LO5O+16UFNvlRXiie6xqbR/IT+bKYWUTXFWggVRXlUY1y0ZIAjbeDCc/g?= =?us-ascii?Q?55bbDdmiqzsXw2Am1rht4KMYQmKmc1NdGVmH/sTFxzpCUTPGmCQLF3Rnb9Ad?= =?us-ascii?Q?g7wi4IhlhePXMdeD9Y64zBkJ+G00ZeBAih7iiOHD2H6Wh5YI1wctnIdQC+yN?= =?us-ascii?Q?pFSj126altEIug5lF6vE0DPaEeCqBeYhm3EHvt/gdX9v8/9denn1XgEKsfFr?= =?us-ascii?Q?PewDhu/D3fMqTMg8Bk9j4i93iIDQsPrjuh9DyFKQI/hiK+5cXv2McOzuKSL8?= =?us-ascii?Q?1VG+4encRksJiqyPqo3T1qt7grqO4cOsUzdcqFz4M2fnO1wIJKILRH/7sf7z?= =?us-ascii?Q?cl890sBIvn2nmAwOAjxZi7vzG/+Rh7MaPEuynX2UX08xCSv6PGpp13Giffia?= =?us-ascii?Q?nNupfJCpT+FLfDnHj2inEF1YYGSYJ7pb7f/lD0d+glNi/qD6Pt7SDO56nint?= =?us-ascii?Q?JdZHZeHBTzKZneEcjQALdjO1yOkmgUY16Xop9m90uGuylm3LOe/a6fWUmJ4F?= =?us-ascii?Q?jKGIk57JpvZVMDRKIplyIKUkXO3ma2f2o78EqcA/QU3nLXTt4slXnz5Nl6my?= =?us-ascii?Q?244L+ptNIUsEsi0wXqS2sjnceYIW5KlHn/9v+R3+w?= X-Microsoft-Antispam-Message-Info: WZT7x1jvbDJiSni3BxNG/DeZv4+aZP1WHGAwspb0+mAB+AB28guIj016ZwHpDT1rKFyEdSkb6fwCmMBh7ZaBE3AqyrCnTytHjVrirk6yNmdhiyG7hMPFCCt+2hZgEXt7820z+wPHQ/ov0HNAe1dcxhKmvakvnfgl4D7wAhdB9NZ0OyP6AlO/E6fO5YNyZbIyYvyvYuhm41D3COCNSqqWOWi0EUgk4cugwXq/E8MhRwFRXDbJHqP5LswB+lschayTIGLjQSno1z14wUzJsNPh+N3zsjkvd252rMmxkKctcls3Qc5i+fFbH2v1VZ9+0HKdadbncf7lzHdWktTE+cRPuGV5xQfF8XxiOrkNLpK+8no= X-Microsoft-Exchange-Diagnostics: 1; DB6PR0902MB1829; 6:l7yF0aBKTV/ve9xMZFO0Yob/Uqf8/5BVZjjjSWdaWQDHJuc1RJBxo9HTmJ7/+oRTmBoNR4LliY2fdxojTgzHUGutchyY2s0ZhljMIeHEVCBVkg+4zlEG/Jfon6/rAeT8k97jwTSRhJZI9Zfer8eR5+1C9iP7fv37GYmfGhhm2aIC3D/B03XapZ9sw+gpfa4dhvLi1oUJppAaRkW4lCJEYoid28eYa3tjia6yYg2XC9rGk+exIevOWlA5aohNNhHJwVgMosFF6lSbpQ6Oc6vyxv6gvc2DgLtByTcmDTyFckCpRYpdwW44HcqOgxqivXz04yR2hQUY3hH+t+TFOfk/jecagTv3N8gRS2A8PyVcUWuGC17e/GshTrZ+UWkCewtkC/P6iKYKt+/bgOmZs7VedDLEBU4SCuvdTstz/toSqbqpZgYh/p0PSOxvWogWYTkpIgL6eDuHvbdT3STXvy4T1Q==; 5:VBTxf8hg2C1sW081fKsdmV+e9XHfNTXe/epFJDqO+75boC9I7jrFQkthZexFN2TRYLKWP+74H2MIvE40loxg3xcKNPrVKL9pfWoEErsUD8fH3wpj2S6tC4unbQpX7H1SYgoXaJ0HQkolWZlW+waZy4WynH2ijhwDY8P2MpHtPC0=; 7:G0gTPFut0hqNmk7Bh/t871HumammirDqVemoQgoHaXXn7IAAcVyppTpEtI3vEe6ZsHeEaRfT8rDE/KW60L41iGluSWRZZG5L+xJgHDx8ZvlUBKbgPe4Qcz6XwVZ7aUU8rc971NN0tZn3MYZTsFcY865iUa3pjRMj69i8UPQm6rDYlApbDLWH79ex+Ygi7iBJVZ+N26/mrHELbdZWSJFyjdO6uTC8ANN4nZBJ2fkBVYi0KK4kkKSaNbqx2xqD9bBb SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2018 07:38:13.7526 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5e8acf4-cc90-4fc6-0756-08d60802380d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fc9e9498-07e8-4b82-b4cf-365bba23cbbf X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0902MB1829 Subject: [dpdk-dev] [PATCH] vmxnet3: stats_reset implementation 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: , X-List-Received-Date: Wed, 22 Aug 2018 07:38:16 -0000 Signed-off-by: yogev ch --- drivers/net/vmxnet3/vmxnet3_ethdev.c | 78 ++++++++++++++++++++++++++++++++++-- drivers/net/vmxnet3/vmxnet3_ethdev.h | 3 ++ 2 files changed, 78 insertions(+), 3 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 2613cd1..2348300 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -78,6 +78,7 @@ static int vmxnet3_dev_link_update(struct rte_eth_dev *dev, static void vmxnet3_hw_stats_save(struct vmxnet3_hw *hw); static int vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); +static void vmxnet3_dev_stats_reset(struct rte_eth_dev *dev); static int vmxnet3_dev_xstats_get_names(struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats, unsigned int n); @@ -120,6 +121,7 @@ static int vmxnet3_mac_addr_set(struct rte_eth_dev *dev, .stats_get = vmxnet3_dev_stats_get, .xstats_get_names = vmxnet3_dev_xstats_get_names, .xstats_get = vmxnet3_dev_xstats_get, + .stats_reset = vmxnet3_dev_stats_reset, .mac_addr_set = vmxnet3_mac_addr_set, .dev_infos_get = vmxnet3_dev_info_get, .dev_supported_ptypes_get = vmxnet3_dev_supported_ptypes_get, @@ -335,6 +337,10 @@ struct vmxnet3_xstats_name_off { memset(hw->saved_tx_stats, 0, sizeof(hw->saved_tx_stats)); memset(hw->saved_rx_stats, 0, sizeof(hw->saved_rx_stats)); + /* clear snapshot stats */ + memset(hw->snapshot_tx_stats, 0, sizeof(hw->snapshot_tx_stats)); + memset(hw->snapshot_rx_stats, 0, sizeof(hw->snapshot_rx_stats)); + /* set the initial link status */ memset(&link, 0, sizeof(link)); link.link_duplex = ETH_LINK_FULL_DUPLEX; @@ -890,7 +896,49 @@ static int eth_vmxnet3_pci_remove(struct rte_pci_device *pci_dev) VMXNET3_UPDATE_RX_STAT(hw, q, pktsRxError, res); VMXNET3_UPDATE_RX_STAT(hw, q, pktsRxOutOfBuf, res); -#undef VMXNET3_UPDATE_RX_STATS +#undef VMXNET3_UPDATE_RX_STAT +} + +static void +vmxnet3_tx_stats_get(struct vmxnet3_hw *hw, unsigned int q, + struct UPT1_TxStats *res) +{ + vmxnet3_hw_tx_stats_get(hw, q, res); + +#define VMXNET3_REDUCE_SNAPSHOT_TX_STAT(h, i, f, r) \ + ((r)->f -= (h)->snapshot_tx_stats[(i)].f) + + VMXNET3_REDUCE_SNAPSHOT_TX_STAT(hw, q, ucastPktsTxOK, res); + VMXNET3_REDUCE_SNAPSHOT_TX_STAT(hw, q, mcastPktsTxOK, res); + VMXNET3_REDUCE_SNAPSHOT_TX_STAT(hw, q, bcastPktsTxOK, res); + VMXNET3_REDUCE_SNAPSHOT_TX_STAT(hw, q, ucastBytesTxOK, res); + VMXNET3_REDUCE_SNAPSHOT_TX_STAT(hw, q, mcastBytesTxOK, res); + VMXNET3_REDUCE_SNAPSHOT_TX_STAT(hw, q, bcastBytesTxOK, res); + VMXNET3_REDUCE_SNAPSHOT_TX_STAT(hw, q, pktsTxError, res); + VMXNET3_REDUCE_SNAPSHOT_TX_STAT(hw, q, pktsTxDiscard, res); + +#undef VMXNET3_REDUCE_SNAPSHOT_TX_STAT +} + +static void +vmxnet3_rx_stats_get(struct vmxnet3_hw *hw, unsigned int q, + struct UPT1_RxStats *res) +{ + vmxnet3_hw_rx_stats_get(hw, q, res); + +#define VMXNET3_REDUCE_SNAPSHOT_RX_STAT(h, i, f, r) \ + ((r)->f -= (h)->snapshot_rx_stats[(i)].f) + + VMXNET3_REDUCE_SNAPSHOT_RX_STAT(hw, q, ucastPktsRxOK, res); + VMXNET3_REDUCE_SNAPSHOT_RX_STAT(hw, q, mcastPktsRxOK, res); + VMXNET3_REDUCE_SNAPSHOT_RX_STAT(hw, q, bcastPktsRxOK, res); + VMXNET3_REDUCE_SNAPSHOT_RX_STAT(hw, q, ucastBytesRxOK, res); + VMXNET3_REDUCE_SNAPSHOT_RX_STAT(hw, q, mcastBytesRxOK, res); + VMXNET3_REDUCE_SNAPSHOT_RX_STAT(hw, q, bcastBytesRxOK, res); + VMXNET3_REDUCE_SNAPSHOT_RX_STAT(hw, q, pktsRxError, res); + VMXNET3_REDUCE_SNAPSHOT_RX_STAT(hw, q, pktsRxOutOfBuf, res); + +#undef VMXNET3_REDUCE_SNAPSHOT_RX_STAT } static void @@ -1005,7 +1053,7 @@ static int eth_vmxnet3_pci_remove(struct rte_pci_device *pci_dev) RTE_BUILD_BUG_ON(RTE_ETHDEV_QUEUE_STAT_CNTRS < VMXNET3_MAX_TX_QUEUES); for (i = 0; i < hw->num_tx_queues; i++) { - vmxnet3_hw_tx_stats_get(hw, i, &txStats); + vmxnet3_tx_stats_get(hw, i, &txStats); stats->q_opackets[i] = txStats.ucastPktsTxOK + txStats.mcastPktsTxOK + @@ -1022,7 +1070,7 @@ static int eth_vmxnet3_pci_remove(struct rte_pci_device *pci_dev) RTE_BUILD_BUG_ON(RTE_ETHDEV_QUEUE_STAT_CNTRS < VMXNET3_MAX_RX_QUEUES); for (i = 0; i < hw->num_rx_queues; i++) { - vmxnet3_hw_rx_stats_get(hw, i, &rxStats); + vmxnet3_rx_stats_get(hw, i, &rxStats); stats->q_ipackets[i] = rxStats.ucastPktsRxOK + rxStats.mcastPktsRxOK + @@ -1044,6 +1092,30 @@ static int eth_vmxnet3_pci_remove(struct rte_pci_device *pci_dev) } static void +vmxnet3_dev_stats_reset(struct rte_eth_dev *dev) +{ + unsigned int i; + struct vmxnet3_hw *hw = dev->data->dev_private; + struct UPT1_TxStats txStats; + struct UPT1_RxStats rxStats; + + VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS); + + RTE_BUILD_BUG_ON(RTE_ETHDEV_QUEUE_STAT_CNTRS < VMXNET3_MAX_TX_QUEUES); + + for (i = 0; i < hw->num_tx_queues; i++) { + vmxnet3_hw_tx_stats_get(hw, i, &txStats); + memcpy(&hw->snapshot_tx_stats[i], &txStats, + sizeof(hw->snapshot_tx_stats[0])); + } + for (i = 0; i < hw->num_rx_queues; i++) { + vmxnet3_hw_rx_stats_get(hw, i, &rxStats); + memcpy(&hw->snapshot_rx_stats[i], &rxStats, + sizeof(hw->snapshot_rx_stats[0])); + } +} + +static void vmxnet3_dev_info_get(struct rte_eth_dev *dev __rte_unused, struct rte_eth_dev_info *dev_info) { diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.h b/drivers/net/vmxnet3/vmxnet3_ethdev.h index d3f2b35..5bc3a84 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.h +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.h @@ -98,6 +98,9 @@ struct vmxnet3_hw { #define VMXNET3_VFT_TABLE_SIZE (VMXNET3_VFT_SIZE * sizeof(uint32_t)) UPT1_TxStats saved_tx_stats[VMXNET3_MAX_TX_QUEUES]; UPT1_RxStats saved_rx_stats[VMXNET3_MAX_RX_QUEUES]; + + UPT1_TxStats snapshot_tx_stats[VMXNET3_MAX_TX_QUEUES]; + UPT1_RxStats snapshot_rx_stats[VMXNET3_MAX_RX_QUEUES]; }; #define VMXNET3_REV_3 2 /* Vmxnet3 Rev. 3 */ -- 1.9.1