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 BC595A0524; Thu, 4 Feb 2021 11:34:28 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D12D24069F; Thu, 4 Feb 2021 11:34:28 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50102.outbound.protection.outlook.com [40.107.5.102]) by mails.dpdk.org (Postfix) with ESMTP id 079E6240692 for ; Thu, 4 Feb 2021 11:34:26 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I86Jb6FSn3NMyMvfrZ8VqR98Fh23GJj8ttDNf4tGsVo/X9CCbzun8BsfRhBTRfF0DQMgbJbvJxAHQBpnp6ogIHNRDkJ9XywdVxpZzMZ0ILfCTCcobr9qckrsAfZ+3by2sre/GFUPDkWv20IPtieEfMa6pdTdr17afF+xx+82kD7IejRI2HuI2FLSjEfWDePQr+e/jUK1Vk8fl4TVzq/FwRyUlTM/Qg+ui6Fq/VBasGaO7s7Y4bv3K/fdz6PU4FbxOJCCgsjxKAiq1kFFzfKmXmN3gDKCyXxJGy5elWAjO+DYp9GfMcDsU4+APVTMAMphcb/BlAmDw/mb5z0jSxsVyA== 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=QbZ2vJWuinznk0aetI3hcuDTI4lwsMcO1Fl6ePQ1dz0=; b=hPW9LXsPvgKLvqGSauHEHV75qL4kd7P3TuqmNBBw2A6UfA3GbnpG5drdaU7PP7upmfpEhJgVrOuyygl3IbLwO06kBC5uOe3p1mKOSWF3a6RFEFMqcLR4VhPhsbEbRbgqkT9G6TsNlTkdng/MpPD9syxaZaHmBX4gZ1IlAXYOZf78m6AkaN1nNMge2P/0hDDdbt7kgE03UYMX3MF8ToNJgKomgcno+dY74q9LoIiw6m3ZtHKvHRX5pne8KogsmT7TE8+OW7YC3Sp4XWLxEXlwvsu6n8312/Pe8I3LU2VXxTQXdSHFbk6yP0G2h0c+mAjCyiPN4gmsPUraiTbAL0rZ8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cgstowernetworks.com; dmarc=pass action=none header.from=cgstowernetworks.com; dkim=pass header.d=cgstowernetworks.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cgstowernetworks.onmicrosoft.com; s=selector2-cgstowernetworks-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QbZ2vJWuinznk0aetI3hcuDTI4lwsMcO1Fl6ePQ1dz0=; b=XHwvOnIvI5c2fYCn+tZ1kmGklWvAOEGMqWLJJAg0PFiIpZT5IM7h7PaYJONw4A97ad7r8hkD1bQUjE+dZ0LtwDyLBiBiUejCt9CewL6Etl3f6sgbrwZiYaTVwDkdRW2ebOy8jMRAFtF2ZqMugsuZQr6vIIVsD4xp39pKFB1GGoY= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=cgstowernetworks.com; Received: from DB7PR09MB2345.eurprd09.prod.outlook.com (2603:10a6:10:44::10) by DB7PR09MB2347.eurprd09.prod.outlook.com (2603:10a6:10:46::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.25; Thu, 4 Feb 2021 10:34:25 +0000 Received: from DB7PR09MB2345.eurprd09.prod.outlook.com ([fe80::fc34:cf58:29e8:932a]) by DB7PR09MB2345.eurprd09.prod.outlook.com ([fe80::fc34:cf58:29e8:932a%6]) with mapi id 15.20.3805.017; Thu, 4 Feb 2021 10:34:23 +0000 From: Ido Goshen To: Ferruh Yigit Cc: dev@dpdk.org, Ido Goshen Date: Thu, 4 Feb 2021 12:33:57 +0200 Message-Id: <20210204103357.72512-1-ido@cgstowernetworks.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210201083012.28544-1-ido@cgstowernetworks.com> References: <20210201083012.28544-1-ido@cgstowernetworks.com> Content-Type: text/plain X-Originating-IP: [81.218.57.230] X-ClientProxiedBy: ZR0P278CA0027.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::14) To DB7PR09MB2345.eurprd09.prod.outlook.com (2603:10a6:10:44::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from idog-ubuntu.localdomain (81.218.57.230) by ZR0P278CA0027.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Thu, 4 Feb 2021 10:34:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a2b0cfd6-89f9-4510-dce7-08d8c8f86fbb X-MS-TrafficTypeDiagnostic: DB7PR09MB2347: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1201; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YaEBWGhuGTicrTqfP1WJAnN+9Kzfa9sRWXll2cgzCkn98zMXFdzoI7w44BMlAq6Kmn+P3ZagoIR8mULUZY7KeeK5/tOnTCfDLGVMM6QbQiU1C8TDIUy+g0W8Smh4KMrwQhixp8Q3G//r2MrZF3WmVKZqknBnW2mgv5Q8YkOTrIjjFhEGss+ZLB5Vwbz9o87ljjUDqNsADr0QPzT6IS0uUGrPe1bwxVKA2wls87hG0u4RnKJYZy+TLESOz8uHdqpNKztv+jI7RO9euiFZFuX7v9eZXBQbkDEqkVohNihBkOQXht6xm7Ue/LbSDg9Sm6HnYkYi4EtIHh56h1if4ntpprbIYxmbjEuLse+3xyISbCplBijrVC1dgFTX8GgvCfW+dhI7zb5sA+Hk/8rboBZunCH/WBYZQcPjfWaExq24si+zpNf2QtoZ7zDeQTXJvKBcmRsqvlRnlkRu0dQAIOCIPLhtrIzEXRE4AoAOqBFl3rLvzsrZQAvj++8hlqWVZcp84gzVfZXjyM/XAiS7BrVdgg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR09MB2345.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(366004)(136003)(39830400003)(346002)(396003)(107886003)(2906002)(2616005)(8676002)(83380400001)(6486002)(52116002)(956004)(86362001)(4326008)(5660300002)(1076003)(6512007)(16526019)(186003)(6916009)(6666004)(478600001)(6506007)(66476007)(66946007)(8936002)(66556008)(36756003)(26005)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?oQ6fKd6g0nYfSsuWbyFqmD8/OiyHANV3PJV0BY/kPwHUvQftAJNn4SAf9NV/?= =?us-ascii?Q?r7u84AOi0iVMthLsqBA3CqZ1DR6zh7YRFsyFcMEploEGO4PSSy3MMUie5a6D?= =?us-ascii?Q?tgviY7AeBVdhf8eR3VBR9phhWrQwa23epfSiGYQrqA7kKn1lXfhiMraDyyKj?= =?us-ascii?Q?HdfgssiKVrUjjR5CkkzjnJJCyJlFIq9E5aYwlPblyPqROOPmOlkADdJcMbpy?= =?us-ascii?Q?9u6hc3h82Qsk+jEt6iRxXkCslY/w511lTxUThwnVLg+gJYJKxxHgkC8Qz3TR?= =?us-ascii?Q?1NXshDJ+jCK6uLT+P/aWji1BWK0mEaLcJCQwEI2noZgG8lIVdB/5yscEiC/J?= =?us-ascii?Q?w6jwV+FvZINKBfHbilu7QzIaEbRLGpEUvutznJ9N8pBn2+BaKuiGp9wBzKJb?= =?us-ascii?Q?/OW9HcEE9pBIbAEg9QHzcK/ypECbq7LS8n8gj4RTcFgini0Fvi0w8nFfjV1Z?= =?us-ascii?Q?MbkHnk7oMlCUg5YfIeiJmQLALqtWnApkNAHSOhYeQzKWHBwc8Spq03kPUWNU?= =?us-ascii?Q?UFeUlN7LmVaMV0j3JJqvp6CsoQx13UcL9Z3fuwTCNy8/Dl3tq7zv6nH9U74/?= =?us-ascii?Q?na33VKlZb8Ojr/9vkgDp5l8H63kcjylYCnjkt32AkU4mGVAm2Dba9fkaVZp7?= =?us-ascii?Q?YXJm76CDHPed2fOsZCxrvb7WEiprj58Hamn+ju14oEdpXWdv4vPGnk2OZwkh?= =?us-ascii?Q?BjTheAO3s30Y0Uni+xhSV3WrW41SJDFNzr+G1KbyV6A2Z2Rb7lR4xkuBprMt?= =?us-ascii?Q?LiA3VH5I1jOgdNRPGE9eokLTYNtN7dj0CRdHnI6AgbzyPGj0kDcv4tqfbrwF?= =?us-ascii?Q?w9k14nkG9D5niSNaIwEmQjEzW0lYg0wgHfOyqv5VbuALPU4aMBtFXTZ+8oBW?= =?us-ascii?Q?2ALSf0t6kUh1vwJEYeeQQ0YoLvIhSORC7ixjvgbfKEKehmV1NIMkZgFS/m+i?= =?us-ascii?Q?1pFXdJYWtGw2hLCWeG3J48+Ou4VziM4r11TRUiQf9CyMuIH0IgW7jyg9ltvp?= =?us-ascii?Q?qoFbb4cjBg6FjhOXG87tt0qU3YJQnpGA0tjKcWc+3l6IWGBUUg1InJOp8N6W?= =?us-ascii?Q?+auMnmGc?= X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2b0cfd6-89f9-4510-dce7-08d8c8f86fbb X-MS-Exchange-CrossTenant-AuthSource: DB7PR09MB2345.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 10:34:23.3017 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fc9e9498-07e8-4b82-b4cf-365bba23cbbf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mgMbxh9GuYlj3U8QAMnxepSVmK61fUqC30uqb+JXGTYJs3yBZtg8qRvZPAwYvJAhzEXgJ/z+yL622d90HSJa0X+KdNzpIMfA7NyPVFvcG20= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR09MB2347 Subject: [dpdk-dev] [PATCH v4 1/1] net/pcap: imissed stats support 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" get value from pcap_stats.ps_drop (see man pcap_stats) the value is adjusted in this cases: - port stop - pcap is closed and will lose count - stats reset - pcap doesn't provide reset api - rollover - pcap counter size is u_32 only Signed-off-by: Ido Goshen --- v4: * remove volatile * line spacing * set missed_stat.pcap to 0 on stop v3: * code cleanup by dedicated struct and functions extraction * multi stop support by menmonic+= accumulation * rollover fixup v2: * sum all queues (rx_missed_total += fix) * null pcap protection * inter stop/start persistancy (counter won't reset on stop) drivers/net/pcap/rte_eth_pcap.c | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index a32b1f3f3..fe4c6cd12 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -60,11 +60,21 @@ struct queue_stat { volatile unsigned long err_pkts; }; +struct queue_missed_stat { + /* last value retrieved from pcap */ + unsigned int pcap; + /* stores values lost by pcap stop or rollover */ + unsigned long mnemonic; + /* value on last reset */ + unsigned long reset; +}; + struct pcap_rx_queue { uint16_t port_id; uint16_t queue_id; struct rte_mempool *mb_pool; struct queue_stat rx_stat; + struct queue_missed_stat missed_stat; char name[PATH_MAX]; char type[ETH_PCAP_ARG_MAXLEN]; @@ -144,6 +154,56 @@ RTE_LOG_REGISTER(eth_pcap_logtype, pmd.net.pcap, NOTICE); rte_log(RTE_LOG_ ## level, eth_pcap_logtype, \ "%s(): " fmt "\n", __func__, ##args) +static struct queue_missed_stat* +queue_missed_stat_update(struct rte_eth_dev *dev, unsigned int qid) +{ + struct pmd_internals *internals = dev->data->dev_private; + struct queue_missed_stat *missed_stat = + &internals->rx_queue[qid].missed_stat; + const struct pmd_process_private *pp = dev->process_private; + pcap_t *pcap = pp->rx_pcap[qid]; + struct pcap_stat stat; + + if (!pcap || (pcap_stats(pcap, &stat) != 0)) + return missed_stat; + + /* rollover check - best effort fixup assuming single rollover */ + if (stat.ps_drop < missed_stat->pcap) + missed_stat->mnemonic += UINT_MAX; + missed_stat->pcap = stat.ps_drop; + + return missed_stat; +} + +static void +queue_missed_stat_on_stop_update(struct rte_eth_dev *dev, unsigned int qid) +{ + struct queue_missed_stat *missed_stat = + queue_missed_stat_update(dev, qid); + + missed_stat->mnemonic += missed_stat->pcap; + missed_stat->pcap = 0; +} + +static void +queue_missed_stat_reset(struct rte_eth_dev *dev, unsigned int qid) +{ + struct queue_missed_stat *missed_stat = + queue_missed_stat_update(dev, qid); + + missed_stat->reset = missed_stat->pcap; + missed_stat->mnemonic = 0; +} + +static unsigned long +queue_missed_stat_get(struct rte_eth_dev *dev, unsigned int qid) +{ + const struct queue_missed_stat *missed_stat = + queue_missed_stat_update(dev, qid); + + return missed_stat->pcap + missed_stat->mnemonic - missed_stat->reset; +} + static int eth_pcap_rx_jumbo(struct rte_mempool *mb_pool, struct rte_mbuf *mbuf, const u_char *data, uint16_t data_len) @@ -621,6 +681,7 @@ eth_dev_stop(struct rte_eth_dev *dev) /* Special iface case. Single pcap is open and shared between tx/rx. */ if (internals->single_iface) { + queue_missed_stat_on_stop_update(dev, 0); pcap_close(pp->tx_pcap[0]); pp->tx_pcap[0] = NULL; pp->rx_pcap[0] = NULL; @@ -641,6 +702,7 @@ eth_dev_stop(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_rx_queues; i++) { if (pp->rx_pcap[i] != NULL) { + queue_missed_stat_on_stop_update(dev, i); pcap_close(pp->rx_pcap[i]); pp->rx_pcap[i] = NULL; } @@ -685,6 +747,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned int i; unsigned long rx_packets_total = 0, rx_bytes_total = 0; + unsigned long rx_missed_total = 0; unsigned long tx_packets_total = 0, tx_bytes_total = 0; unsigned long tx_packets_err_total = 0; const struct pmd_internals *internal = dev->data->dev_private; @@ -695,6 +758,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->q_ibytes[i] = internal->rx_queue[i].rx_stat.bytes; rx_packets_total += stats->q_ipackets[i]; rx_bytes_total += stats->q_ibytes[i]; + rx_missed_total += queue_missed_stat_get(dev, i); } for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && @@ -708,6 +772,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->ipackets = rx_packets_total; stats->ibytes = rx_bytes_total; + stats->imissed = rx_missed_total; stats->opackets = tx_packets_total; stats->obytes = tx_bytes_total; stats->oerrors = tx_packets_err_total; @@ -724,6 +789,7 @@ eth_stats_reset(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_rx_queues; i++) { internal->rx_queue[i].rx_stat.pkts = 0; internal->rx_queue[i].rx_stat.bytes = 0; + queue_missed_stat_reset(dev, i); } for (i = 0; i < dev->data->nb_tx_queues; i++) { -- 2.17.1