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 0A328A034C; Sun, 19 Jun 2022 11:31:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E32094280B; Sun, 19 Jun 2022 11:31:40 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2117.outbound.protection.outlook.com [40.107.104.117]) by mails.dpdk.org (Postfix) with ESMTP id 43F214281B for ; Sun, 19 Jun 2022 11:31:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sn0l3mqF82GoCk6oyIRGMd+TgA5trNPXtF/wHvgsmx0EolmbvXJ+1UtlQeQ7c5kzZr3w2YY1gVJqkY6Zr0FmvHbv4/nVKrtyWxZQ4GGgHWNOfdEimkrrSFz3tvW8mVqia/qCJAF2iS0hJbO45oHeq1F3iVqFwgGQTSi+t2gUJeej1Nu/rCYfiuEFkkJAJa+sLDdCM5W4IsMOn5apaQtx6PjGWaODkTKlp9aLcs2heZeH9HcFa2EL2IJLLi040KvBvIzZGkv1UWyLmFYw906XO7Kmvo5PsaCIgSrw7njMPVWYKT3KnyuVuO52TpdO3udm/GKpj4wJNyfhAHKu/+cchA== 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=XSistsFD6Fur6AlVCWYdlMfNN4g8Ud7nzloBPu0ZgJuHTGpBzZNHiFHJEtufBxuv7dxmbCBv9h8izSIY3NouPk2zfnK8gXjV+LZHn+qd21aiWab7LjEXNRjM92FOxlIKvu6AHBK3ok67lKMclTVpv8WXIaKkd2B6L6/qmpfetwha8jcOf8pLsc70NGvKaOoTqtA2yHj86TvphBl3baqPb9Kco8ZmufOlLI1WuMJV4WqS/sb74BmtoLS4qHvRO4Yhdu7dPZ0o07XbhTXTJlbtE9WPraAm84iIlkXyR/fDzSs69GXgDVQsbFSzUJbka2FS9rHIu4Cz3mM4JX+S2jVrMA== 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=cgg8vz/mahCwIPgqj9OGe75JOaAK4ICuszSidSfise3mz+U1u+q4/bUIJ4lLb5WuUVx1BdeHUqvTFSGIYDxIrA3+Z+/ZVBx/HRJkj2SVdTtQZ6z7baq85ISC5mq5M+GJsPSkOot3DJC+YChLH0K0hrlkOJoOrumZaF0YonEINDw= 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 PAXPR09MB5056.eurprd09.prod.outlook.com (2603:10a6:102:15e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.14; Sun, 19 Jun 2022 09:31:38 +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.020; Sun, 19 Jun 2022 09:31:38 +0000 From: Ido Goshen To: ferruh.yigit@xilinx.com, stephen@networkplumber.org Cc: dev@dpdk.org, Ido Goshen Subject: [PATCH v7 3/3] pcap: support MTU set for linux interfaces count ierrors Date: Sun, 19 Jun 2022 12:30:34 +0300 Message-Id: <20220619093034.26891-4-ido@cgstowernetworks.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220619093034.26891-1-ido@cgstowernetworks.com> References: <20220317174347.110909-1-ido@cgstowernetworks.com> <20220619093034.26891-1-ido@cgstowernetworks.com> Content-Type: text/plain X-ClientProxiedBy: VI1PR0901CA0095.eurprd09.prod.outlook.com (2603:10a6:800:7e::21) 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: 2df0f48d-bd7d-4a40-3a29-08da51d682be X-MS-TrafficTypeDiagnostic: PAXPR09MB5056: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: CTfldcWxo0uSJzB3ULmDlXcx8vc7ujEZbItnFgUdmb5TxXXMSP+vduHSmvjTzqdSie3WSxw3yJcO4ymEue3lecZZ7FHjuXfFtTuqqwY1pTZvqjarvLSHQQvZmQ+YZMdK426J9eqWuqJDUE3uTl60yqdKjsrYT9TswzDFyzgDl3h+bZ+PpVC1qJgQN6iyEKicJGb8LksFI5lgNPgfJfJsvE4bZ7Y8ogtEcehyTIJKyDmgw0GH6U2AFvi48jzJp/un265l3GE5XxRyz9exeDnIf0952fZ0pSoGlWNX+9j1yEDLmowP+2UuKiqv3cXdCjYmMpbZ2lA2/AYwvkh92qS4UlvNZtZEa4NINz9Zz0PYLEmrEXFwOzSoJXvvF3zDMk0EejeKYvoCLivbbAuRtIYuxLgqkjmd6LMjUPzvHzlicM7MJmi8Bo1rkcek2bYC1EeyyKZIYXuIqJ779goKuGZF0da+ZUVA/BzQkbEmQmyXSH6eMJgJbS6a+ZioVy+wv2Aq6tqB7mwOMBlP31S1UUT6II7mk2xs/a9MtdoFCeFapldX0DHoPDePqDgt/hjw2UcPh5phF8ZK+Jk6G5Zc0Qe269+qyJSbxcThctWy0ToLQQRNj/9swauawCFJb4PwHkyGvMGK0K4tPKe1Euh8bTqg8BjFTeQu7ZiUh4SWg4D1ehyA38+qkJNRi0OfJbZ7e11GJD9py5PMmiAO4IZNhWMaqA== 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)(346002)(396003)(39830400003)(366004)(136003)(26005)(107886003)(41300700001)(6512007)(38100700002)(83380400001)(86362001)(508600001)(2906002)(6506007)(8936002)(6486002)(66556008)(38350700002)(52116002)(186003)(6666004)(1076003)(36756003)(316002)(66946007)(66476007)(4326008)(2616005)(5660300002)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?wpqh0U8PvYEETbjsj32NrSo87ow34wBIKLUfelU6nDn+8tNB2MO9DNyNCZ8O?= =?us-ascii?Q?xz9cH/27hFLZxGTjELKviLd4A9wHpPoKKs5KPKR8m2AmJlFnkUQ92Mgdb6H5?= =?us-ascii?Q?W7OArXKs3i+2T6EtMtbzXP1SwUdpsFMz6mqGvnb8vQ65xAmqmNaMXa3EaQcD?= =?us-ascii?Q?VDGuGUZCgwqMozF2FNgE2xIiTQ2z1tAuvGXF3PgrVOPXMJHnZQyNTeSYSa00?= =?us-ascii?Q?5K/iLl63vz7kD+yEzbVqPlTwhCF9sLSzKDuDYJWddGCnepYvWQHkoFIACHXx?= =?us-ascii?Q?XjLe9bgEVmxgxM28Z79Z6M26fEiJhmdM7B2JkSpaM915NXcXXU7Qq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4zw4SILe6rXkkT3scUB9wwYc3ipRO8C55ANP0T9qd/wLuP?= =?us-ascii?Q?rYhzc4NT7NwPaJloYUkMTP3zqJVur446PCHsV5+R6vOJxg846KgWupwev4DR?= =?us-ascii?Q?SdtjjfTrlZo3Hyj+GpsJStdOSNM9bmX7LTUemxem8tz/PrIYc6c6kwYX24JV?= =?us-ascii?Q?fuKVsySmx3lFhLVs3l4vsTvHRd+RLEwBdhBt7IwZmax/tTc8hDnrUDBbkuad?= =?us-ascii?Q?7IGmkFnD0TdkwNM7d4YdEqeXpnvGcF91ePdVvIafk5lgW9xvsD/EAJCQ6ODW?= =?us-ascii?Q?NDFyM7XntZWKKXif9D3Ffx29akuXRz0CNd1jv5ZnB+GYocCHrfY+O7wPDAxb?= =?us-ascii?Q?KIka08+nhpXywBVu2Ce3+wr4yDwAi3ADJkrUQylWvqwvw2aNXVZPK4w2PiBl?= =?us-ascii?Q?ZEgm0p3gkFK21t1wSa5YEdpDT0+T6ZqKunvYMFU2UYYRcok9KN2dhnjc/eOA?= =?us-ascii?Q?+M/39h8QOaZfLrhnvXm1nhkBeVgga4olNXw3wzK+1CeANLPMM40Qm+q2K984?= =?us-ascii?Q?FIXaKvBUEaUOrlR5Wwd9fBfegY7FQbM=3D?= X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2df0f48d-bd7d-4a40-3a29-08da51d682be X-MS-Exchange-CrossTenant-AuthSource: AM0PR09MB3972.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2022 09:31:38.5795 (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: Q/xI7lanUipbuAtZWJHPdpJ15Qm7P7vBVZYVCfE9YfAR4m8YL4OJ0nR7RmXCBlketqVpuG8OngcKR3nKWIEkwes8xK5Q2HKLC370815Y9pE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR09MB5056 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