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 C8AC1460DF; Wed, 22 Jan 2025 08:03:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5A310402A9; Wed, 22 Jan 2025 08:03:16 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2103.outbound.protection.outlook.com [40.107.105.103]) by mails.dpdk.org (Postfix) with ESMTP id 1C79A402A4 for ; Wed, 22 Jan 2025 08:03:15 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TNH9+eHIRORNfQHQJAIML8NpHp5SadyUDU2HzS2MAA54R7JQaMAFN8NhppMvj7q4uGOtE6rk8ut644rEHXpY9C6Rst0BqaD1w/vicgUD8jxl3JgqUK3L35Ig82IHg2Hxv6t/7WnP41ATw357C3k4CbzaNYVXXhURw8e/uxLlHwWU811DwlUtiYiJC7tcQx3pzUT/VVB6hwpIDkwna6aJXdPyN5ktFMFTgWNNRbOn/Bpp9+Xv7srbUGNN5e7Hxck1pMWpOegxPm/+GTYmbXqlG90VKc8HqEVA9lZlpPMsblpHaLWUAG3YY/KhQydIf2kPEAXKWIQU0ilFEjigcQlXKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=WQ9Yw7YXcrC7TYLbIwuHgwpWLTW9dm7c158dnom0BLE=; b=IV98Cy6VNdF0YkfMr72qdyEewDinvi6OqzNH3Erixm37PWkTNh1JpGBTIK9P9pz/Et6wkdGrzTcCJYQRiy8r7qpMFCDyQydiYmqtML62KIckepuGNTRu+0UYVPV5zLGVSxfuwGlfI/nMAkxAHILvXkXwaeqow8JinY8N4OTT4VocK7seKebqdNMJJMTlG5rj4d9UDSJN8rovIsiJFbxv2ykk5q8bxCOyu+cIPrknfOIKLodiSKtEBVTrotsdtuVvsqhetDWWlCuhigRxv85qj9lb+vxVJYU4lSzqy7xTIVANvJginQfoj/TP9UiOR7NQxIfcRjJKiMSLrKv7+VEPiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=omicronenergy.com; dmarc=pass action=none header.from=omicronenergy.com; dkim=pass header.d=omicronenergy.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omicronenergy.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WQ9Yw7YXcrC7TYLbIwuHgwpWLTW9dm7c158dnom0BLE=; b=V1e2b58Y9mirqhIruSpOk1fSg8hKEd6b9oTs3SUFWpVi1N7g3iSwsm4FmYqKvVpdT65yF7O39HZ4Di9iV1Q/d1nuOeGTwhD2zQlWZQ/cS8ifvYmN7OJ0/CO8sFU9ANE3MhIXtgU0/ciNTn2eZHd0/vg0nO/b+8qTNOAIAbHd2CQ= Received: from AM0PR03MB6275.eurprd03.prod.outlook.com (2603:10a6:20b:154::17) by AS8PR03MB8666.eurprd03.prod.outlook.com (2603:10a6:20b:54c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Wed, 22 Jan 2025 07:03:12 +0000 Received: from AM0PR03MB6275.eurprd03.prod.outlook.com ([fe80::7ab2:814:12eb:1c8d]) by AM0PR03MB6275.eurprd03.prod.outlook.com ([fe80::7ab2:814:12eb:1c8d%7]) with mapi id 15.20.8356.020; Wed, 22 Jan 2025 07:03:12 +0000 From: =?Windows-1252?Q?Stefan_L=E4sser?= To: Stephen Hemminger CC: "dev@dpdk.org" Subject: RE: [PATCH v2] net/af_packet: provide packet drop stats Thread-Topic: [PATCH v2] net/af_packet: provide packet drop stats Thread-Index: AQHbbAAQO3CeChRCokGiaZ1IBpPZ67MhX8OAgAD/esA= Date: Wed, 22 Jan 2025 07:03:12 +0000 Message-ID: References: <20250116161703.917279-1-stefan.laesser@omicronenergy.com> <20250121122616.301666-1-stefan.laesser@omicronenergy.com> <20250121074815.536fbaf9@hermes.local> In-Reply-To: <20250121074815.536fbaf9@hermes.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=omicronenergy.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM0PR03MB6275:EE_|AS8PR03MB8666:EE_ x-ms-office365-filtering-correlation-id: b92c7a4d-6fb5-45a2-ce9c-08dd3ab2d5c5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|376014|366016|38070700018; x-microsoft-antispam-message-info: =?Windows-1252?Q?4NPbf383WYAQEomWRM6sE42B8hVrCw6Q437INtWSxLU0phYXyl+JdbYj?= =?Windows-1252?Q?nA7p1QMvfV7wO8cmnsyGBbeBMBshFYyx6KK4on9KqIagT3+TlOnxpzNZ?= =?Windows-1252?Q?29tYab2DdgMX5I2bZkwyHH/eQksYihzWyk12QIc/n0LgvxlI6N3B7K55?= =?Windows-1252?Q?cES2WohQ2YESEVuRdx07ZqI0wvNzS6m5xjYJ+/SHnDbhxhUm0qnWHwT9?= =?Windows-1252?Q?9gl+QkG+n7if0Gt6rrVxIY+HJDkevsfqUIjzfzr8xvkw46zb01C73LHo?= =?Windows-1252?Q?LGX+3XTe/Etp0363cW1TE4ho34I3wuPGMJ8b6fSK1cQwW8WjjfYzXGan?= =?Windows-1252?Q?Ga9TFE9L8Yjt+lz1fP8QA3m6qo68uYxenE2mjK3npjfIDn9JDHMcZvQY?= =?Windows-1252?Q?yT+JZgR4aGtaoJMGUZZCLbTmC14KgnZUUshnIPTELkFs0D2YjtxMgaWQ?= =?Windows-1252?Q?twpsam4DObF3piNwD63ayDIrFSBblTZQU5qYY2CQgiDpW0uriDplqQWu?= =?Windows-1252?Q?q4U8oGMlKkk0T78LTT0uxW5dEuHOyJS4MpOrtF7FqO063L1VsNpAUJPz?= =?Windows-1252?Q?RuNHwNJum5d4ULeSAOp7AkZ4fOdsin1B5vH6K1R4gFbVtl0hkYElJz/X?= =?Windows-1252?Q?a42gBVT6yidJwxEVhazMst0NQQ+1vbwfwEsGCnDI5tGpDNVFFyHvfu02?= =?Windows-1252?Q?k+1Kz2O60FI8C4FRt3T0TPH7Ey5rDX5sUncjps8k1eGLcBuTuWwwi0Ma?= =?Windows-1252?Q?S2UKQCVt1wFQZ9gY27s8Zb5MgR5zERNzUtBelU1bx7Izg4m1w/IOQAps?= =?Windows-1252?Q?MH572NAg2xRFhH8cKj+BxgOvLHkNvZ6J8Hk7pacL21DYNfu5qi3qCgkK?= =?Windows-1252?Q?f9nSPWpg3B174qo/PoaG6sM5gCYwFY+zxgveT4jvRVWGRDe5rpw1qX/H?= =?Windows-1252?Q?bhhyU2iAk70pNovH+NeumEipC2N2FmHQVHz5L/kDBfy02OQWLWNiCQep?= =?Windows-1252?Q?wtPijzl1pbiD4wxQoYTSnT5AUBgCZsRtWyhFJe+p5Mo4tdNIoVRTOGqi?= =?Windows-1252?Q?awPD2lVQzAVI6o2ppeQFFr5tmoZYUN8X+aBWpunMP+m4wfCxejfOM/7j?= =?Windows-1252?Q?AnIn2pdltRuIASvrw5gqH/6f0qPVJJmQwXsib2Kn5EJVvoGsFiwpBn0r?= =?Windows-1252?Q?0/8VOMtOvR1724B4d1qXjWZ5bRR3COImR6ttBLTCrXd/nqi/roMtwL2w?= =?Windows-1252?Q?VlqliV93PW6oixI4MuRdU4lvryKF6jZXnMJTfiTrvWmap0iuvn462v8F?= =?Windows-1252?Q?iXn5L4hg2ZzDxIufm0vDYaKVDTTWehNTKQ1goIWC+TRwysq6pMkHt7r5?= =?Windows-1252?Q?JCkAAq4XS1VKBzP+SaWQPlTdVjjMWLZXQ2TBMvLx5PqXHksBcc1B244K?= =?Windows-1252?Q?+8FZGeMtx69necP84dAq7wA9EyhdCtD4LcqG0cm3EM7fTiHgJN5q9p/K?= =?Windows-1252?Q?ClSHUoqm7vDXUAAqbJHhhdQ3xYGVVju0+A3Mw3AD2Y3HeFpfRxDkqX7d?= =?Windows-1252?Q?D3ucWOFDx74gK/ga?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR03MB6275.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(366016)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?/NKfqGhh9ynq9tviNB2NQVhDNeamoInk9MndlTeWqYtLCJtMB5HFvQBd?= =?Windows-1252?Q?fUlwo1go8pxsJxb7I1TaWmB0EKvX1+/oa6/iLSbI/83OGjyb8r6sZMN4?= =?Windows-1252?Q?OR1EQnSBM7IN/rrVhbx04DsCMWIQHvdOXoO0gi+/PS8/BYVEQpnk/hz+?= =?Windows-1252?Q?7a82n059KzcRmh6Q8KAbIyELI/sJbEicOx+b0Au1q0Pb8UwG5uI7tGAZ?= =?Windows-1252?Q?4nL0cfnhN28vFbjroRjgJTDUn2KHh2hF9ZtOhR/MCeHbOnZhmmFXcsU+?= =?Windows-1252?Q?mvEO+4sHvMBFY+/oZtKRIBUqCtM7QyZvX8B05tLiGgTMzE9X6YukDB1m?= =?Windows-1252?Q?X/dDf1kDp4DD29N4Yl4yU4F16PMpi8yel+Bz/vOPSjOY2LsDvTegTIma?= =?Windows-1252?Q?bYufD4vxtowxMAneXvWz3xCGHdFFqyp1xVnVe4snlXAxF+MZ0un2y1xJ?= =?Windows-1252?Q?IpeVX4MNg9erjO65gXfJgNe4v//5LJHkPepDXDu8aBaax7nqTVvU6dVZ?= =?Windows-1252?Q?Ngv9/escwD+3EBtUy3TUWP3iVacNLaPzl1I10WVhPeJHNLeRcguJFhIV?= =?Windows-1252?Q?tkXVJyX/2c1pCu0hqDn3dSWkn0g9L8+OhEZzFEASJbpcq2qWPn6IWBbL?= =?Windows-1252?Q?KLz/zP02XeirTyUPCFaxAg9priX8uVC8OBcAdTIc/x67O5/Vp9UzbNuN?= =?Windows-1252?Q?spL+wS3WEWjlEqe6UFbwQkvytn0qfkAMmUDMOyFFmmftJ2tzNQ+l6Om9?= =?Windows-1252?Q?U8LTNkxIvPWEZg+Fl2of8x9HWjVYLUP4qNlgowvMkNH8wcq/QTRsTrlg?= =?Windows-1252?Q?lQ/ri0VMHnnmfxCUWynew2qwRbYs3HkRl9cvZ7Ozizj+YoB1zdDAb3Dg?= =?Windows-1252?Q?ebBYCJOQYyDmpFqLqrzzfbkIXczLg/YKRo5UzSkxI+SjXy5q1lv+Iq0m?= =?Windows-1252?Q?XQhda4kn45EGa9sDN1DBDqyu4bZVmk56PNyd5Dt+TocbPPS4Zk3JEonM?= =?Windows-1252?Q?NbKXnTPBRB8vLd5r3mbIy+qK8w9VafA+/5Pb1hp+CeBVDq8QJT/NOOBk?= =?Windows-1252?Q?TujRnaEL0ekjjyYzZgVSeXAGL0dR8yTQ9lOo6va4NQT2bYHHOH5cr7W4?= =?Windows-1252?Q?UHJ1jJDMDyskx2hJe3hssrG+naMabiNPOrizAJSuRVzlhFNHAPbnErYn?= =?Windows-1252?Q?P6ryuzlSbETAxX+hZART9qXe8/AkvgVgaVG/oRV9nplwlJtGnEydKoT8?= =?Windows-1252?Q?4SLaqKMOjsFFWtHng/33/rBd1kRd4vUO27tzeL0uypVrd/LOB0zzdmOs?= =?Windows-1252?Q?8lvUFE3mtrUjspp5zpMxolz6FN4dXAAJ7fU+ZA3oskUu1WbZoW+VE2w6?= =?Windows-1252?Q?CdUanbdDyN1QY76l9z+HH6C9QWTdTkWSuOgy9nG80kg4cflhrVbPT/Jy?= =?Windows-1252?Q?sbVzAbCQlBhgQwZMquPvvZErzoYxceJ6Pp0/QIyQhjSAIGnBATobIQmD?= =?Windows-1252?Q?e3ZwyJlCqQcVDS8TIgyAiF2OtKDseta9eTTBax3QVCYBEy3ZxoOI7VJk?= =?Windows-1252?Q?BeRnS3C57FqE5oyIuUl3a5NxPDbKYKeorrdxuPqHadan0YprF6xyirwR?= =?Windows-1252?Q?Hhy3T/te1Yh/oaHeahUEShtq1MLdxcRKjhEWfeuVrXs2qfPUx2YmjPuS?= =?Windows-1252?Q?p14KF0OHJiRB1s//O5osNRTXCAYhkX5ELnYRAaN1TrSIOfyl4dytSQ?= =?Windows-1252?Q?=3D=3D?= Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: omicronenergy.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM0PR03MB6275.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b92c7a4d-6fb5-45a2-ce9c-08dd3ab2d5c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jan 2025 07:03:12.1373 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 1357ca9e-a1a5-404b-bb16-554d5d05c5c9 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: HX8y3PyD4CGbBuLhnznRWFBaIV8dR8fNmhqvs87gpKUF3ss1Z0Xku2yzO4BkyGrSEPWvgK3oxNRmj23Jcj397+fdLteRbN0TgzR+KB3MXITDaMmOYYgj5NE1h20wAILh X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB8666 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 > -----Original Message----- > From: Stephen Hemminger > Sent: Tuesday, January 21, 2025 4:48 PM > To: Stefan L=E4sser > Cc: dev@dpdk.org > Subject: Re: [PATCH v2] net/af_packet: provide packet drop stats >=20 > On Tue, 21 Jan 2025 13:26:16 +0100 > Stefan Laesser wrote: >=20 > > + /* query dropped packets counter from socket */ > > + if (internal->rx_queue[i].sockfd !=3D -1 && > > + getsockopt(internal->rx_queue[i].sockfd, SOL_PACKET, > > + PACKET_STATISTICS, > &iface_stats, > > + &iface_stats_len) > -1) { > > + /* > > + * keep total because each call to getsocketopt with > PACKET_STATISTICS > > + * reset the counter of the socket > > + */ > > + internal->rx_queue[i].rx_dropped_pkts +=3D > iface_stats.tp_drops; > > + } >=20 > Since reading the value clears it, maybe stats_reset should call as well? >=20 > Also, queues greater that the RTE_ETHDEV_STAT_CNTRS should still count > against the total. And the two loops could be combined. >=20 > Maybe something like this? That looks very reasonable - I will update my patch.=20 >=20 > diff --git a/drivers/net/af_packet/rte_eth_af_packet.c > b/drivers/net/af_packet/rte_eth_af_packet.c > index 7033910df8..af08e893f1 100644 > --- a/drivers/net/af_packet/rte_eth_af_packet.c > +++ b/drivers/net/af_packet/rte_eth_af_packet.c > @@ -417,50 +417,51 @@ eth_dev_info(struct rte_eth_dev *dev, struct > rte_eth_dev_info *dev_info) > return 0; > } >=20 > +/* query dropped packets counter from socket */ static unsigned int > +packet_drop_count(int sockfd) { > + struct tpacket_stats pkt_stats; > + socklen_t pkt_stats_len =3D sizeof(struct tpacket_stats); > + > + if (sockfd =3D=3D -1) > + return 0; > + > + if (getsockopt(sockfd, SOL_PACKET, PACKET_STATISTICS, &pkt_stats, > &pkt_stats_len) < -1) > + return 0; > + > + return pkt_stats.tp_drops; > +} > + > static int > eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { > - unsigned i, imax; > + unsigned int i; > unsigned long rx_total =3D 0, rx_dropped_total =3D 0, rx_nombuf_total = =3D 0; > unsigned long tx_total =3D 0, tx_err_total =3D 0; > unsigned long rx_bytes_total =3D 0, tx_bytes_total =3D 0; > const struct pmd_internals *internal =3D dev->data->dev_private; >=20 > - imax =3D (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ? > - internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS); > - for (i =3D 0; i < imax; i++) { > - struct tpacket_stats iface_stats; > - socklen_t iface_stats_len =3D sizeof(struct tpacket_stats); > - > - /* query dropped packets counter from socket */ > - if (internal->rx_queue[i].sockfd !=3D -1 && > - getsockopt(internal->rx_queue[i].sockfd, SOL_PACKET, > - PACKET_STATISTICS, > &iface_stats, > - &iface_stats_len) > -1) { > - /* > - * keep total because each call to getsocketopt with > PACKET_STATISTICS > - * reset the counter of the socket > - */ > - internal->rx_queue[i].rx_dropped_pkts +=3D > iface_stats.tp_drops; > - } > - > - stats->q_ipackets[i] =3D internal->rx_queue[i].rx_pkts; > - stats->q_ibytes[i] =3D internal->rx_queue[i].rx_bytes; > + for (i =3D 0; i < internal->nb_queues; i++) { > + /* reading drop count clears the value */ > + internal->rx_queue[i].rx_dropped_pkts +=3D > + packet_drop_count(internal->rx_queue[i].sockfd); >=20 > rx_total +=3D stats->q_ipackets[i]; > rx_bytes_total +=3D stats->q_ibytes[i]; > rx_dropped_total +=3D internal->rx_queue[i].rx_dropped_pkts; > rx_nombuf_total +=3D internal->rx_queue[i].rx_nombuf; > - } >=20 > - imax =3D (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ? > - internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS); > - for (i =3D 0; i < imax; i++) { > - stats->q_opackets[i] =3D internal->tx_queue[i].tx_pkts; > - stats->q_obytes[i] =3D internal->tx_queue[i].tx_bytes; > tx_total +=3D stats->q_opackets[i]; > tx_err_total +=3D internal->tx_queue[i].err_pkts; > tx_bytes_total +=3D stats->q_obytes[i]; > + > + if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) { > + stats->q_ipackets[i] =3D internal->rx_queue[i].rx_pkts; > + stats->q_ibytes[i] =3D internal->rx_queue[i].rx_bytes; > + stats->q_opackets[i] =3D internal->tx_queue[i].tx_pkts; > + stats->q_obytes[i] =3D internal->tx_queue[i].tx_bytes; > + } > } >=20 > stats->ipackets =3D rx_total; > @@ -480,6 +481,7 @@ eth_stats_reset(struct rte_eth_dev *dev) > struct pmd_internals *internal =3D dev->data->dev_private; >=20 > for (i =3D 0; i < internal->nb_queues; i++) { > + packet_drop_count(internal->rx_queue[i].sockfd); > internal->rx_queue[i].rx_pkts =3D 0; > internal->rx_queue[i].rx_bytes =3D 0; > internal->rx_queue[i].rx_nombuf =3D 0;