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 28F46A0545; Mon, 20 Jun 2022 10:40:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F2F94282A; Mon, 20 Jun 2022 10:40:46 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60103.outbound.protection.outlook.com [40.107.6.103]) by mails.dpdk.org (Postfix) with ESMTP id 48479427EB for ; Mon, 20 Jun 2022 10:40:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B/SuAIg6BpE2NJCrIIoJ2o43NTet+c+m/ogu80+C+NH5gkXDaZ0iWoPS5ZBy8/ZSKSAPRemDRla9gq2YgiXlM651IFwrQ3Rwlrlm17pvATRJazC+xyiLll2Kk+DxXQYiO7wWihoPTYBbsrExClTIiLAsFdq0MpOu0KhyvgdSn8M3zAbmwSp7UIN1ENlLp9ydYVZggdgxubf7PzS8eQ5fqyls85UAvF90e0rMqQp2pU9R+PoXyDw/iVosi2tuqICT/FiLCIwCNjyKvwUGG90v2Y1TWosTmkHvGo70DZcgCTbIbxEVKb0k5bNd3My9ci/Jb/G4TVdsi3RfG66hokl40w== 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=ZYRUI+xxnDrhJY3SCqww9Yhnk0HHyk+EUORPiORr1hM=; b=cOO+FT4fCh7QlFuViYPDrWXMwh3qV8eiIfsq3f7+pEa2AfMKms3Y2jG3yf75U5uccId3NbMUf+ORVsDtq0pvj5OIIDKPUkOku+KhmGr7u+g+SLgwV7bE3AZws51GM6ioRQ0B56A9X2zItNJNbotSGAZAd98D0kwAbtBeN+pricNCHqoOdTdpNq2f4vrf0pbKSEfIJYNWIjmdc/wIp5OLpZ+iTMWekNkHDzAmTLUW2B05k94B00asjTSrRvvqsJT+QUhG3u18VZ6hHUza6joFzKdtdUv2j1uEq1CthdmRbe25xImCMPGzFxVuUAMRAgltmFL2muGYGTaTstXJjS58pw== 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=ZYRUI+xxnDrhJY3SCqww9Yhnk0HHyk+EUORPiORr1hM=; b=h3Y+XRwCSpMC3atO5HkiQEJJS0UgaGvTjoref4xU5DvJkKrL0zjgAiTwxR8jWQW/SkTT8B5by2rlDAokuY6QeasvnVLHv+FI9scI/RxqVX18+4RN6AMwmI+8K78TNVUT4slsCP6U+FQaLnKJTYW4fXl0on1345q1JzEl+wMG2KA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cgstowernetworks.com; Received: from AM0PR09MB3972.eurprd09.prod.outlook.com (2603:10a6:208:195::21) by AM0PR09MB3699.eurprd09.prod.outlook.com (2603:10a6:208:189::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.13; Mon, 20 Jun 2022 08:40:41 +0000 Received: from AM0PR09MB3972.eurprd09.prod.outlook.com ([fe80::d0d6:ba99:48ac:5e72]) by AM0PR09MB3972.eurprd09.prod.outlook.com ([fe80::d0d6:ba99:48ac:5e72%8]) with mapi id 15.20.5353.022; Mon, 20 Jun 2022 08:40:41 +0000 From: Ido Goshen To: ferruh.yigit@xilinx.com, stephen@networkplumber.org Cc: dev@dpdk.org, Ido Goshen Subject: [PATCH v8 3/3] pcap: support MTU set for linux interfaces count ierrors Date: Mon, 20 Jun 2022 11:39:44 +0300 Message-Id: <20220620083944.51517-4-ido@cgstowernetworks.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220620083944.51517-1-ido@cgstowernetworks.com> References: <20220317174347.110909-1-ido@cgstowernetworks.com> <20220620083944.51517-1-ido@cgstowernetworks.com> Content-Type: text/plain X-ClientProxiedBy: VI1PR04CA0122.eurprd04.prod.outlook.com (2603:10a6:803:f0::20) To AM0PR09MB3972.eurprd09.prod.outlook.com (2603:10a6:208:195::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e4fb77fe-c79a-4ae5-f0e1-08da52988f03 X-MS-TrafficTypeDiagnostic: AM0PR09MB3699:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t9tOkEjdNxu0UC1C1dtcYqjPGiPdRmWcVThkoqWbnNczw06fZ5885fbEZ54uz3D3MgreqbRQw15S+0ZEVEuL/FtLfsXhp6qI39X8KcqL82+vYtZNPE2t7TcuVaNSb804wPTPS9D1lEveY61G2533vgMwL3awptcV5Tj8BwzIxEiK6pJ4ArD1Oh44zKP+9CnlHySArbVWUB9TiN0GJ0GKGqutMrGzT4R2DuL7iRMCKHY+Kk4GRekmYGfnvnvpBEZ73zApU3PNJawih42b5FedspDbul1uzHTpa+5ERpvBDYxxfkZT60a/Uk3DfG+ve6WyiDcLBHMiT4xsRbIaToMjpTSgU8tNoBNgxwVq/pZc8SrkSKABdChEpk7g6E7pm+jWzQjB1gLGcSBuOQ0aFy8Mdpht/BcL69LAcBHAXgOVfyWY1Yw/osElK4Dm+qZDKV/u2Aq4jpXHwpRNcwXvpqwYOaFroKpv9EUIWlLu6cvIjaJi1n5iPIfAU5g79QVGAiJOC3HQdOOgLWvstjt8m3ERmlDxD0EZT4DTMmffXgFoq8R5kXzUpV9reGn8zQjCxKLjuz8gOmWoJSvpM1NBkZdZMmbA05eP6E2bJ0rYxsI4ZlE1xsdBf0UkPxK7VLibszRK6u9ic8+5e2T2IwfZQiO8ilNtruEB4sJRtJmcIdD0RfP2HdfCw+EfDQGWRZTRPd4ub1zswbcLW5woBn/WT853CA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR09MB3972.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(39830400003)(136003)(366004)(346002)(376002)(107886003)(38350700002)(1076003)(52116002)(41300700001)(86362001)(26005)(38100700002)(2906002)(2616005)(66476007)(478600001)(6486002)(83380400001)(8936002)(316002)(66556008)(36756003)(186003)(6506007)(66946007)(8676002)(4326008)(5660300002)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?T5QxFTNHttO6sO87+neZdFTtlF6JGWzFCeW52j5E/8IHqtZwA8ZV+/HDp0Bm?= =?us-ascii?Q?92jXiE0cXHhWXaBX7fkv4+0GlOVdrGjEexhTagQaE3q/g/Pem3fKJD1oRZPM?= =?us-ascii?Q?HClbFsFLRUiaeriBbHVApN1jUC4S2EXdjOzP6K4f8DNf9wi9i7CouoKkLA8m?= =?us-ascii?Q?ZRAPIQa6IdyLHOMXl7Bz7VZ/glnG4is/crnvip8GZ1Y0Ouv/VNR/6YqaZa0O?= =?us-ascii?Q?5C+qIscEaHsB6b6K8XeThqMs53iB4AUweTL678eCvOwtAw1P0T208x850QSt?= =?us-ascii?Q?ulwuzv8rT3H5ht3hU/uaV9mhycc+1csEWC1RTprbJUAYvU7MzmVfRuPdQGhT?= =?us-ascii?Q?D+OeLAH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WoOSgrVZTYejRktms3LaaB?= =?us-ascii?Q?UYOkhOi/XPlwgPBPWzrnjJmsQi44aFxb1F+oDv3eJFi+S/Qlj7B25K1cbm4r?= =?us-ascii?Q?caRSUqtHTeIeSr1G+IMORo30yWLZ0G/bmThLuTsQdpC4B1/JW74sT8eHKYB/?= =?us-ascii?Q?lpsQWdBR3zm+7y/SErZu1NkEVoIAQRRHlwLKipAQrWSF3fs1p2v9Evc4b/y7?= =?us-ascii?Q?H0A1/L5IRSnhblAHl8cTJP/2z7tWDH3uuPrv3VbgPoH+MLbNDRlrNzez6r8c?= =?us-ascii?Q?tfIcl0za+nhY8Bql4N7bXJwjVSGRToAvJ+ywQY6+V+Rb2ntscrjrIa9qtDWE?= =?us-ascii?Q?Shypgyw539vnHAkkkLUa9dCIPZcbSmAWF1lehFoPA4XuOiC6KCX0cLXtdo2u?= =?us-ascii?Q?HsbFzMXUwUppK9hG07yYy1tp2zRRUapINjsb4iTS5UfR8cgx22Y72Uv+l5Cr?= =?us-ascii?Q?XI/0vb45KGsDbIbpSRmX9iGFIISK9a5ETK1dFxOEwoza2uFYcw6U6c2MuF+N?= =?us-ascii?Q?BMjXDlkn8RyiWSxBGCWFZ7XE8tLaW1g=3D?= X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4fb77fe-c79a-4ae5-f0e1-08da52988f03 X-MS-Exchange-CrossTenant-AuthSource: AM0PR09MB3972.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2022 08:40:41.6752 (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: IQPs6gYq8Oyy5J8rPpuIYVtY27FOU0VToCvQBllFiS/q6pylW2uguZnYO9Gy5/QRN5FQwtZo8FQ9QXAuYesxvcc2KjKIy5AOX3tYJDiYW/U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR09MB3699 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 Count oversized packets that are dropped by the interface Signed-off-by: Ido Goshen --- drivers/net/pcap/pcap_ethdev.c | 74 +++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c index ff98762058..46f18e9b10 100644 --- a/drivers/net/pcap/pcap_ethdev.c +++ b/drivers/net/pcap/pcap_ethdev.c @@ -54,7 +54,7 @@ struct queue_stat { volatile unsigned long rx_nombuf; }; -struct queue_missed_stat { +struct queue_pcap_stat { /* last value retrieved from pcap */ unsigned int pcap; /* stores values lost by pcap stop or rollover */ @@ -63,12 +63,19 @@ struct queue_missed_stat { unsigned long reset; }; +enum { + QUEUE_PCAP_STAT_FIRST = 0, + QUEUE_PCAP_STAT_MISSED = QUEUE_PCAP_STAT_FIRST, + QUEUE_PCAP_STAT_ERROR, + QUEUE_PCAP_STAT_NUM +}; + 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; + struct queue_pcap_stat queue_pcap_stat[QUEUE_PCAP_STAT_NUM]; char name[PATH_MAX]; char type[ETH_PCAP_ARG_MAXLEN]; @@ -144,54 +151,62 @@ static struct rte_eth_link pmd_link = { RTE_LOG_REGISTER_DEFAULT(eth_pcap_logtype, NOTICE); -static struct queue_missed_stat* -queue_missed_stat_update(struct rte_eth_dev *dev, unsigned int qid) +static struct queue_pcap_stat* +queue_pcap_stat_update(struct rte_eth_dev *dev, unsigned int qid, int type) { struct pmd_internals *internals = dev->data->dev_private; - struct queue_missed_stat *missed_stat = - &internals->rx_queue[qid].missed_stat; + struct queue_pcap_stat *queue_pcap_stat = + &internals->rx_queue[qid].queue_pcap_stat[type]; const struct pmd_process_private *pp = dev->process_private; pcap_t *pcap = pp->rx_pcap[qid]; struct pcap_stat stat; + u_int value; if (!pcap || (pcap_stats(pcap, &stat) != 0)) - return missed_stat; + return queue_pcap_stat; + value = (type == QUEUE_PCAP_STAT_ERROR) ? stat.ps_ifdrop : stat.ps_drop; /* 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; + if (value < queue_pcap_stat->pcap) + queue_pcap_stat->mnemonic += UINT_MAX; + queue_pcap_stat->pcap = value; - return missed_stat; + return queue_pcap_stat; } static void -queue_missed_stat_on_stop_update(struct rte_eth_dev *dev, unsigned int qid) +queue_pcap_stat_on_stop_update(struct rte_eth_dev *dev, unsigned int qid) { - struct queue_missed_stat *missed_stat = - queue_missed_stat_update(dev, qid); + int type; + struct queue_pcap_stat *queue_pcap_stat; - missed_stat->mnemonic += missed_stat->pcap; - missed_stat->pcap = 0; + for (type = QUEUE_PCAP_STAT_FIRST; type < QUEUE_PCAP_STAT_NUM; type++) { + queue_pcap_stat = queue_pcap_stat_update(dev, qid, type); + queue_pcap_stat->mnemonic += queue_pcap_stat->pcap; + queue_pcap_stat->pcap = 0; + } } static void -queue_missed_stat_reset(struct rte_eth_dev *dev, unsigned int qid) +queue_pcap_stat_reset(struct rte_eth_dev *dev, unsigned int qid) { - struct queue_missed_stat *missed_stat = - queue_missed_stat_update(dev, qid); + int type; + struct queue_pcap_stat *queue_pcap_stat; - missed_stat->reset = missed_stat->pcap; - missed_stat->mnemonic = 0; + for (type = QUEUE_PCAP_STAT_FIRST; type < QUEUE_PCAP_STAT_NUM; type++) { + queue_pcap_stat = queue_pcap_stat_update(dev, qid, type); + queue_pcap_stat->reset = queue_pcap_stat->pcap; + queue_pcap_stat->mnemonic = 0; + } } static unsigned long -queue_missed_stat_get(struct rte_eth_dev *dev, unsigned int qid) +queue_pcap_stat_get(struct rte_eth_dev *dev, unsigned int qid, int type) { - const struct queue_missed_stat *missed_stat = - queue_missed_stat_update(dev, qid); + const struct queue_pcap_stat *queue_pcap_stat = + queue_pcap_stat_update(dev, qid, type); - return missed_stat->pcap + missed_stat->mnemonic - missed_stat->reset; + return queue_pcap_stat->pcap + queue_pcap_stat->mnemonic - queue_pcap_stat->reset; } static int @@ -684,7 +699,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); + queue_pcap_stat_on_stop_update(dev, 0); if (pp->tx_pcap[0] != NULL) { pcap_close(pp->tx_pcap[0]); pp->tx_pcap[0] = NULL; @@ -707,7 +722,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); + queue_pcap_stat_on_stop_update(dev, i); pcap_close(pp->rx_pcap[i]); pp->rx_pcap[i] = NULL; } @@ -766,7 +781,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) rx_err_total += internal->rx_queue[i].rx_stat.err_pkts; rx_packets_total += stats->q_ipackets[i]; rx_bytes_total += stats->q_ibytes[i]; - rx_missed_total += queue_missed_stat_get(dev, i); + rx_missed_total += queue_pcap_stat_get(dev, i, QUEUE_PCAP_STAT_MISSED); + rx_err_total += queue_pcap_stat_get(dev, i, QUEUE_PCAP_STAT_ERROR); } for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && @@ -801,7 +817,7 @@ eth_stats_reset(struct rte_eth_dev *dev) internal->rx_queue[i].rx_stat.bytes = 0; internal->rx_queue[i].rx_stat.err_pkts = 0; internal->rx_queue[i].rx_stat.rx_nombuf = 0; - queue_missed_stat_reset(dev, i); + queue_pcap_stat_reset(dev, i); } for (i = 0; i < dev->data->nb_tx_queues; i++) { -- 2.17.1