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 94727A0A0E; Thu, 4 Feb 2021 00:08:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 52A152403F3; Thu, 4 Feb 2021 00:08:26 +0100 (CET) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150118.outbound.protection.outlook.com [40.107.15.118]) by mails.dpdk.org (Postfix) with ESMTP id 468CD240204 for ; Thu, 4 Feb 2021 00:08:25 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TEPMkGlao0s58G+4h72ry/9tbph8ULBMcPhdtvm5xe9eplRjlFaHZLkOtmiBHqpQKr1zhqFandeeAjXccQZJUOPLBXDZ65hadJevr5aLAGHBluxuGm17TD9R2dD633Zq3TfcMv8DWDBE32SXNT78a4+TQ5sbgaKdGzgN3k8RUotooEP9+Uu6/98KRhNvSc9t9prash7dLcl+OzJoh9+HvVtvOvWEIJy9ypNMsxykb0jSBaCLg8N+t63hKecc13pcJsfIfeYg2xximOAwfA53TB4gQJee1QBfN6Z8Z6AGsM6f1/aphKMNFlCQ2ow/LFvi22iL7ivp6SAhBFZxyd62dQ== 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=/h405pfFjcDvwRTgm8gOeZa/aICL2SswVxcHi17jRx4=; b=kdfYryuV6FSPaXTBd4kt6xgNg8//IMMtV0Ia8wOcbSh582GHzYBRAan1Xkl7JAK0SYys1VbhQakaQPfvb5AhUwCVpla05mLxEr9Or49g2V8o3RLRbjBSsN+5Qo6Eznit0UrocVS7s9I4fml90sUmchv2rc8V5I57GMmQKk1yR3IPOvN541V2wp8+Y3mrnUZZMucD57LYaJOpAukXiU0ivWQwHyyO/yd2awz7f1akBLHq5mnhA2B+MH5EIAvWxt4EQhlFK2ynDfMiPOcnWT0ORS8qj9OxDvMa+e07KaCVzd8bXZO3Va/lJUEaGWuKOWBDJUIQe5qaSRfrM4VPfPdp+Q== 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=/h405pfFjcDvwRTgm8gOeZa/aICL2SswVxcHi17jRx4=; b=bOw/dCaHKPqy6TbubvG7vQMIathlY5yvjqe3SCX1ImsPoetC9MhPl+IV09uu+H0+/ssjRzEty9K/dwEahC0o5GoMsvbsw27UoqF8pw0wEwCokL8LcYRIAxmFYA1svJ6DKlt3pSa6g0o8Smki33kj62tGGQiHtIeagbRsBcT3eJo= 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 DB8PR09MB2859.eurprd09.prod.outlook.com (2603:10a6:10:ad::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 3 Feb 2021 23:08:22 +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; Wed, 3 Feb 2021 23:08:22 +0000 From: Ido Goshen To: Ferruh Yigit Cc: dev@dpdk.org, Ido Goshen Date: Thu, 4 Feb 2021 01:07:50 +0200 Message-Id: <20210203230750.4499-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: VI1PR0401CA0017.eurprd04.prod.outlook.com (2603:10a6:800:4a::27) 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 VI1PR0401CA0017.eurprd04.prod.outlook.com (2603:10a6:800:4a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Wed, 3 Feb 2021 23:08:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e70f594d-36f8-414c-339b-08d8c8989a1b X-MS-TrafficTypeDiagnostic: DB8PR09MB2859: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1091; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OXxrf3dKPBkwu/lMOzYfSvLJFW4j2lE7OfPSlb/3ssaxjx2z0mI4EHwy7ZE4uWGl8I/P1zWpmvCLgPqO4EixscXg64DLMfOzxh5h2e7QZVDF18wW86DViCEVYkpl05JR3B+IbdoyyWGpAX6yRqcgyrcwWT6K7mCRcK99B9OTCX8Ey0mRcx3DG55E6yOr6LxgnRMJZ/3qpuw7atlHmGdVPd3S7SxicRU55q8YhLgMpvLbRAdu5UDKSVxJSMPBSTitRtUwN4KujX+6CP5E7IPJuz+eea7DGsydDfBsZH6Q1IeFSsOjgC8XUUrRMfKG3w5QkTEqflJnLiHaE46J6KoNk2LoK7DDdnU+glGWt4SEuOZS2xnTFLwb8+Zmxpc+7IQK2+ZeyGy9v37rWj9q0XpIEMyzYy4saZwtPqplEQm9y2Dv0LXUTgsaYG4LHSoaxzlK5+TCRnN9MzB4lTf3Dz29bjb8ecs1g4Ufi4p46MhxAm9i0Q0korGAoEPE23Prz5twbyCq+fHd32vzrlBoUfPEsg== 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:(136003)(39830400003)(376002)(396003)(366004)(346002)(8936002)(83380400001)(6506007)(66476007)(5660300002)(52116002)(66946007)(66556008)(26005)(478600001)(6486002)(316002)(36756003)(1076003)(4326008)(8676002)(6916009)(6512007)(6666004)(186003)(2906002)(86362001)(956004)(107886003)(2616005)(16526019); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?Fem5XRplPox9osJvWLdZmwbmraP0vk6VYIAQ702ffQytlQHD6yRawxHki3R9?= =?us-ascii?Q?jmvpmwADgkiTSoiJDUQxseRX3Dvbv4LZzCjFYNLMsx1spJAImp8xk4hb15G9?= =?us-ascii?Q?lkvV0wstVI48nmEcOsznXESjP/NoKRAB+Q4wVon+YCHtlpj0Y9cniXNBezAg?= =?us-ascii?Q?AXrGmuLYBgvTJP5a48lZM/pAl3bg6bS7PEEG1M8fi4VH7Ys6CRB+ntnPTX/m?= =?us-ascii?Q?k/UDoTymR5GGH2VNOMyckQIT1EMoEr9Oa7HBd9hjAqjsohkp+NAdgDDZQafO?= =?us-ascii?Q?VWiP5dB553Hcd1fFKoe+d4npOd7le+6G/lhB9qhOdKMQbzulkdm5k/UMLD0K?= =?us-ascii?Q?lFDrw6GCbrKBoLOTKfE9KCBrQRUd2PtRG4SbQWErxbPK8Gaxv1cVF5btztLP?= =?us-ascii?Q?J2i6CpA6AcA0L6+a9T6wxzKifas2XrSi85xexF4Sgb7KYZnw1sDBQtx0cazC?= =?us-ascii?Q?qmNU8+FELHQpFeX0GM5LjSKXh/br9WEkEE/mTw496yV/RXcaGdTi9A+nI0z9?= =?us-ascii?Q?oOwxzhdFxUFGYtn8HaMZvXSMoYOBv4nbSVQfkuOBgcY8Q90gt9XRprVCWE+E?= =?us-ascii?Q?sOr5nBrJ9YFx0iGH+vCV6f4Hda0/zOgicQ9XbeEVTpal8uNxn6yMKO96bMow?= =?us-ascii?Q?UwtFR318wrCPuKztMMSgGVm/POOSyMlWZzP9xQI+9RdWtHk0nSh9Y3Gwp0dI?= =?us-ascii?Q?T1zO6+x04aXlgHAlNBCt3tmxFxnP/0sxb7ecfZ0P4lHVK8GWVsnH5xzAQJU/?= =?us-ascii?Q?sH9TJtPqb9RjblOGp3j4FOhXsbH4HoWNQ5n2TweRmZteBm433FebNdSHbBbv?= =?us-ascii?Q?4VpK7QM11cFhjATu7gasfG38ShThcdmWh7hf17qQoTdJx3IyH/+VvaLcUa3y?= =?us-ascii?Q?q3QaFsINXhcSnPzgy9fgDeZmjnSLGtjJnQrIjHub4XXGNhFt6FP4As0FXto5?= =?us-ascii?Q?PcT8ft5oeOUCEnVb3Iy9sNAo5s54CsR+E6Hw4BvJEWz9BjQfm1AePvK5AdyL?= =?us-ascii?Q?Jm59QMuU/uo0SPD8qZ7eHwGZ/CK0+2w0pV6jIA+LRTyI13JQ3aKTUlpaQeVp?= =?us-ascii?Q?u2ZS2PRL?= X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: e70f594d-36f8-414c-339b-08d8c8989a1b X-MS-Exchange-CrossTenant-AuthSource: DB7PR09MB2345.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 23:08:22.4779 (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: bnUjq/gV9e3v1W/TDWGlD8SeMAx6i8kFO+C4weALZvnn/HWqIHPrObfQx6Z+HozLY7Uzt3lMjiH0dt2t85cNrU5tCQiOJmtL0aGlKtj9eKo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR09MB2859 Subject: [dpdk-dev] [PATCH v3 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 --- 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 | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index a32b1f3f3..16e8752f3 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 */ + volatile unsigned int pcap; + /* stores values lost by pcap stop or rollover */ + volatile unsigned long mnemonic; + /* value on last reset */ + volatile 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,49 @@ 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; +} + +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 +674,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 +695,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 +740,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 +751,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 +765,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 +782,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