From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (unknown [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EEED6460A1; Fri, 17 Jan 2025 08:20:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77B5540E68; Fri, 17 Jan 2025 08:20:09 +0100 (CET) Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11021126.outbound.protection.outlook.com [52.101.65.126]) by mails.dpdk.org (Postfix) with ESMTP id 6D3AD4029C for ; Fri, 17 Jan 2025 08:20:07 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jvC+d8Tb4Or8EsmFnEnZpz3SOar9blqUhxE/r7vnloF/Z7JzcA7jOENgI7NxB22jF6HbFbB4ekbge4PJyv7n3WV4n6+Cj3jtHinhNuvw5pi0cUM/8i0a/XM0PnXWQUuY31oK/jOl1KU2VMnHrF3hGMG/UPGaihmaU3VGvZvBJACKj3h/byDXSmv2BTgiun9+BHpeHSwJFyoPT+1GkCVO5sWqGfoDpKcHsVEviVOJj7Ah3oTKqa8Cua1uefTdUQHHrASY8X+s//loScGZyNMcTGHV4GNhFvLdsYxkFAbHCCQWfUgnLDHOwbtsTt5gwV99W1qY2NAilTUQcNzY8LNGHw== 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=PRodSxkL/JK3TovGD5MaYFNlp7cgts+9EWnFq/9mgr0=; b=XvribHyCYOBUo9Mlj6z0zJJzyrqW+XUvxXAGM7/JL3CooWRKsr+YOlx1JBHBHSkQeoLv4WKHs9OnxeJ1psEz63JcECXsgEPdnyL76SkT4IwiKj+zz1k4CpmoreRyHEz2p4j7tdupjv/5m8qSNeHDKPEXvog8vYC8bEsNYSHpjwoH44DD7+PcnX25BYG5sTumApVOMiY32Dc0e4S7ph2Dgp2x40/uCq+VMc/IujYsHaa87RoWlr2oiZ5ZYlJ4dYPKk7WSqZAU5/V1HNVeMS/fofRhvHDo3iR4YbeaiFfaZqe6GG0GbM9IVBJTMd3fWQcXXnwwcY4Xbv+W/ES+s8IHvg== 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=PRodSxkL/JK3TovGD5MaYFNlp7cgts+9EWnFq/9mgr0=; b=HkfQNh6DNnS5zrEFhgWSklRXnOHZex1VYLDBQ6jovZEu3aswwyZ/a/LbyiCi24e2M04EeinfqtIWfe7D6mtb6BSmyOhn4eBryNYhwshYGLFmJwogJ1fVk+ay9V0rjjNgZJwmZcCL9mmG/sWQGCbXydAD3GNhjcYNC0/52gMxYqQ= Received: from AM0PR03MB6275.eurprd03.prod.outlook.com (2603:10a6:20b:154::17) by PA4PR03MB7181.eurprd03.prod.outlook.com (2603:10a6:102:103::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.14; Fri, 17 Jan 2025 07:20:05 +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.014; Fri, 17 Jan 2025 07:20:05 +0000 From: =?Windows-1252?Q?Stefan_L=E4sser?= To: Stephen Hemminger CC: "John W. Linville" , "dev@dpdk.org" Subject: RE: [PATCH] net/af_packet: provide packet drop stats Thread-Topic: [PATCH] net/af_packet: provide packet drop stats Thread-Index: AQHbaDIqRbw03p2kWUmp3ao3XsZDWLMZleeAgADvglA= Date: Fri, 17 Jan 2025 07:20:05 +0000 Message-ID: References: <20250116161703.917279-1-stefan.laesser@omicronenergy.com> <20250116082443.341e5d89@hermes.local> In-Reply-To: <20250116082443.341e5d89@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_|PA4PR03MB7181:EE_ x-ms-office365-filtering-correlation-id: 62d29f4b-6e29-4962-d745-08dd36c75dbc x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|1800799024|366016|38070700018; x-microsoft-antispam-message-info: =?Windows-1252?Q?rls+tVJhxErqXnlIciMTiUYuVaqAzGVi2ch8+I7MDIRMQlRuzLXSoIjj?= =?Windows-1252?Q?YDbZ7MMpju3BVh0F1XdJyAy6O9jlYjaTOlb4WyiEDCKICeJIi3/LZmVH?= =?Windows-1252?Q?c1YMK9nbbObq45EAUc0Y0FgKrKhm8K4MMk6sqMgDL7a/FBW3wVqzHRLK?= =?Windows-1252?Q?OCf4vm3aT8Ke0PcMT5EhSTRa7UP/7ncethS0PUYwvQngS1bAZ+AcUIs5?= =?Windows-1252?Q?fP6txw+68mxfol5JhzRu3w0Np6CtqMg7kfm7GE2CZAuh2i/jMPuF56ey?= =?Windows-1252?Q?Ec8czjzoa2hi2RrKOUWNQzf0TWZjmv5OmvyDMoskC+wEYDJGsIBW16ue?= =?Windows-1252?Q?mpC8wtli6DBmUenVPteeOwN/Iz0HKejYYHJesIk4B8fakxenesisOlWN?= =?Windows-1252?Q?rKFvqV9x4TjuhVQPyuf/D9CZOei2gRcnItb5c9sXlWoDoDy3saGU5SgJ?= =?Windows-1252?Q?YjApDHCRxKGYDE/HqkPNbcb4bNQpM4VkOuEEkssdkLfT9xQZWYXL6lhB?= =?Windows-1252?Q?3o9Zjyi6ehCCkFs/PIiGp4VZQk1/84BJxKK7GsDpUnvKlIu0ELSoppDf?= =?Windows-1252?Q?fbdU0C1hzbhQpI1l+ip9jKw1uBTMPIGRGphEsNUa/Rszx7nDj3uvG1dB?= =?Windows-1252?Q?i9x/IlVzh9j8lgvsL1SyeRfk06euOPPrpeCHS470qReB4Bh9g7tcjf7/?= =?Windows-1252?Q?xUrFBPpZ6dWd+1N1LBwt8L7QoORelAIvlNic56dgLfMdwlG+NzYnPkn7?= =?Windows-1252?Q?pCPVMcRHdPSnmG5Miq7YA/+ad49NgPpNSoS/edwLSSxKm7HYZGZLutBx?= =?Windows-1252?Q?jlhmNhqfWnkl+O1S4J9ulyu5gz9tmoJ4SAuoRr45yyIMt067g1UN1Ke4?= =?Windows-1252?Q?W7QxWzuh6UQIKMryiWbJzY4CoSxrgtlco9mEgVJkSa7/KBUuHHozOG8d?= =?Windows-1252?Q?XuGZDeK9qSZuLW2dogYEhOH4thLL2+BkkQssn56Ec5SjMNd7BGhn7jOI?= =?Windows-1252?Q?ULHCdY3PTXjDK304pJKVq9C8xkU9QTUaLzdVQClgYVMjRuO+bANfVs9z?= =?Windows-1252?Q?7f7vTbF58zXRy4bDSfoU4pZKUc8apARM4QXDd4ml55/Jho4X0rkNvRM5?= =?Windows-1252?Q?W+xaiEj4A2G6ZLFfdfHusthKUjbno1hr7tuhnv0je3FlXgrXffLMLirU?= =?Windows-1252?Q?j/JWoMCfzBQJ/jeW0TYA/pcDDyW6hYWWgeyRVBNivvPwEmuxDQy7+XUZ?= =?Windows-1252?Q?VfaFeiLJpJXUndk5IjesOE7C4YPrwTlRj1QtGvHi1Uj3EP7XPBvrcmpe?= =?Windows-1252?Q?URNCRviaAXCiSA7QspVvZ8/PZ8Iue+bPS6OpIFsTD/a6mgQx8dyhN3AA?= =?Windows-1252?Q?UQRsv2B0P+qBYD5jhzkJB6RCuqw/Jls9qSrgrRoOMad9MkrFRejJEX21?= =?Windows-1252?Q?JzKc53jA3VR4d5YTNg79DBYNSUdcOOerhXUGDXWclwvUwDLXOx5WHdUc?= =?Windows-1252?Q?JjkmmnPqVgGGyOP84AH+dgATGd7AgPVui3P/9XMnU1PgE5rqraFF4c0Y?= =?Windows-1252?Q?cYTFcwdd4JAZV60n?= 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)(376014)(1800799024)(366016)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?a4wpam5L+/qOU0VNVbbmbhmIM6EDSHVu2JdGoJj0kO7MDFl9pdhV0kWk?= =?Windows-1252?Q?1dzVdPKKaxPZGahruEsOQqf70I9XZsWPROM7qVmIcoPc8b8A1nXpuInw?= =?Windows-1252?Q?9NG9Qsl9qX50U0pFS+Wpc6k9q+ePX43d1taBR7ZqBztGw+tdYlQm8dAr?= =?Windows-1252?Q?gkXOETbvYnfLxUCIW6m/c5QWgVm+7BmJTYe3giAkTlk9U77Uptse9Avp?= =?Windows-1252?Q?1RImdg3FoP6LNp7D5rKeT0vbG4foQsZqzDn1kGFczb+8c0gt2hfldrpB?= =?Windows-1252?Q?1ouxvNjeMYYDsPmh4O5yCIwaCMoYV2Qv5PRhCoDyhkasVDK4c3fizxUK?= =?Windows-1252?Q?UZZyMV71moc4InK/tVKXS/o31CXKgTu8loPTIbeFSlXO91/4GG+gI19p?= =?Windows-1252?Q?c3cJ4suo/WvmdIae42nQOTY5erKcG3jCqrZwzHQvT6w0Q/jCkh19Km3Y?= =?Windows-1252?Q?/9r3jAqASj+rT64lfR7l/IEesJ+ojRqOlcT+mG7xx87A3utVPflJnN8M?= =?Windows-1252?Q?bFggAAqvwGNtClmmfaSLabEs/8nCfRsMCn8e12XU4bDEYNHVVgJy/umw?= =?Windows-1252?Q?7BJz+qXzFxl+QekF1WlDPq/rlVoD2xbIm1dJAOBlYAGKFfcdHpdtJlfj?= =?Windows-1252?Q?VGom8LAWHnEz6lkP8OijbwRA8jaSgj2FYzCvJhz0Tqss/iIdYVMEGopc?= =?Windows-1252?Q?3yD+fURUjCZL9AVjk2RJZvXaQsmOCnyP8ftGKH3DRop7qcjRIx2XTFbv?= =?Windows-1252?Q?ZneTIXAa+jpH1zdrAHaTfPhmQXPbqQJYtQMaogS+fXtjWiINi+nLhrUT?= =?Windows-1252?Q?np03PhUuaAwK3O8ngbBWa5m6UKpM79U41Ax88V6WTc0D4I6rDPV8ceCw?= =?Windows-1252?Q?0mcsr3Fmbd/kJIWGn/vHRh4PNaHA6OqiR7ywVnCI15wQq4oT6Q2q59E9?= =?Windows-1252?Q?ULTsBwWFWq7TmUjUm0mpNISqtleWKcOOrm4IHzRJtJVpbtFntZcB4/fU?= =?Windows-1252?Q?CsjSsBBEYcu+zQWP/DlZWYBBZXucSH00quDw6qv496ScoKxQiuZMiO0h?= =?Windows-1252?Q?HOX4MOimFoDi1sTZkUOHl0CqfYgQDpyJp2dkS14U4CYW9BSgwdXXaAqD?= =?Windows-1252?Q?Nsdn0OpfDZoB9faP/D4JgFXAjuXAP+iW6jI9cOc1LRKKH7d27fkrhuPH?= =?Windows-1252?Q?SLBHj9lCgDpxH4/yPiYIagJ8lD36IIGqk7tCwXKhYys5vaDXPPOv0oH6?= =?Windows-1252?Q?TZmUuiwn4pdRElemv8clXJdM5O2Tf8/dVTgAGw9u8owyw5QSeBFUdequ?= =?Windows-1252?Q?vo6TXzSbYS8QEfyYTpS/sFD0EnOz60/cqWT4jPR+a50IbuA6X5tbMHBk?= =?Windows-1252?Q?3FYR8QIsjYtJeIVqrLmoPYLIBUNt7wt2XXHH3AwGNB1j5W5dOtCst8SR?= =?Windows-1252?Q?mMt5o0rrRnTloreY9NGId9eEYUQW4GxxgSHo/8BcUyquxrICr0Erx7IV?= =?Windows-1252?Q?GecNe9F0R1kgyNxxnMHcY9u2XaNr9EqCSN5l2hcS24OZi0MHOSY9iV8a?= =?Windows-1252?Q?OOZ9ZeBUEdCT8kBaN9jxpeqbQzovkEBB67jHsaL0AU/yt9o6HA7s+hgP?= =?Windows-1252?Q?h/+pmJq/SGWIrBjx+z/6XNNHMCqPVgDxOUEcbSs9l7Zh7J7b6mlLz1uk?= =?Windows-1252?Q?g/5sHF2nkXAorjNy198qN0AJCqFfA2vPoIBTXDCXFFpF84U5iMMf7Q?= =?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: 62d29f4b-6e29-4962-d745-08dd36c75dbc X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2025 07:20:05.5130 (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: Y3j1+jTbPL6mpc29yxdIfTlloyScH4GGKwQ0Wmntwk8BaUog1l/Kf7VN79Lmsue7uDdA+Vnnzp/BOajds+2/PI4q2SCXyxnF26KuQT1t+D/IpWcgeBFrzzZ9BGTtmDMb X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR03MB7181 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: Thursday, January 16, 2025 5:25 PM > To: Stefan L=E4sser > Cc: John W. Linville ; dev@dpdk.org > Subject: Re: [PATCH] net/af_packet: provide packet drop stats >=20 > On Thu, 16 Jan 2025 17:17:03 +0100 > Stefan Laesser wrote: >=20 > > The Linux kernel provides the ability to query the packet drop counter > > of a socket. This information can be provided when the user requests > > stats. > > > > It is important to note that each call to getsockopt with > > PACKET_STATISTICS resets the internal counters. So the caller needs to > > keep track of the total count on its own. > > > > Next, I have added a counter for the case when mbuf couldn't be > > allocated. > > > > Signed-off-by: Stefan Laesser > > --- > > drivers/net/af_packet/rte_eth_af_packet.c | 32 > > +++++++++++++++++++++-- > > 1 file changed, 30 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/af_packet/rte_eth_af_packet.c > > b/drivers/net/af_packet/rte_eth_af_packet.c > > index ceb8d9356a..a771dd854d 100644 > > --- a/drivers/net/af_packet/rte_eth_af_packet.c > > +++ b/drivers/net/af_packet/rte_eth_af_packet.c > > @@ -58,6 +58,8 @@ struct __rte_cache_aligned pkt_rx_queue { > > > > volatile unsigned long rx_pkts; > > volatile unsigned long rx_bytes; > > + volatile unsigned long rx_nombuf; > > + volatile unsigned long rx_dropped_pkts; > > }; > > > > struct __rte_cache_aligned pkt_tx_queue { @@ -145,8 +147,10 @@ > > eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t > > nb_pkts) > > > > /* allocate the next mbuf */ > > mbuf =3D rte_pktmbuf_alloc(pkt_q->mb_pool); > > - if (unlikely(mbuf =3D=3D NULL)) > > + if (unlikely(mbuf =3D=3D NULL)) { > > + pkt_q->rx_nombuf++; > > break; > > + } > > > > /* packet will fit in the mbuf, go ahead and receive it */ > > rte_pktmbuf_pkt_len(mbuf) =3D rte_pktmbuf_data_len(mbuf) > =3D > > ppd->tp_snaplen; @@ -417,17 +421,37 @@ static int > > eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats > > *igb_stats) { > > unsigned i, imax; > > - unsigned long rx_total =3D 0, tx_total =3D 0, tx_err_total =3D 0; > > + 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; > > > > + struct tpacket_stats iface_stats; > > + socklen_t iface_stats_len =3D sizeof(struct tpacket_stats); >=20 > This declaration could be moved inside the loop. Yes, you are right - I will move it inside the loop. > > + > > 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++) { > > + /* 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; > > + } > > + > > igb_stats->q_ipackets[i] =3D internal->rx_queue[i].rx_pkts; > > igb_stats->q_ibytes[i] =3D internal->rx_queue[i].rx_bytes; > > + igb_stats->q_errors[i] =3D internal- > >rx_queue[i].rx_dropped_pkts; >=20 > Dropped packets are not errors; at least most other drivers do not report > missed packets as errors. Should be imissed statistic. The struct rte_eth_stats currently does not contain q_imissed. It only has q_ipackets, q_opackets, q_ibytes, q_obytes and q_errors. The latter is desc= ribed as "Total number of queue packets received that are dropped.". This is why I h= ave choosen q_errors because the field comment sounds like a good match to me. As there is no q_imissed, I suggest removing this line from my patch and ju= st adding the imissed total counter: igb_stats->q_ipackets[i] =3D internal->rx_queue[i].rx_pkts; igb_stats->q_ibytes[i] =3D internal->rx_queue[i].rx_bytes; - igb_stats->q_errors[i] =3D internal->rx_queue[i].rx_dropped_pkts; =20 rx_total +=3D igb_stats->q_ipackets[i]; rx_bytes_total +=3D igb_stats->q_ibytes[i]; - rx_dropped_total +=3D igb_stats->q_errors[i]; + rx_dropped_total +=3D internal->rx_queue[i].rx_dropped_pkts; rx_nombuf_total +=3D internal->rx_queue[i].rx_nombuf; Do you agree with that? > > + > > rx_total +=3D igb_stats->q_ipackets[i]; > > rx_bytes_total +=3D igb_stats->q_ibytes[i]; > > + rx_dropped_total +=3D igb_stats->q_errors[i]; > > + rx_nombuf_total +=3D internal->rx_queue[i].rx_nombuf; > > } > > > > imax =3D (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ? > > @@ -442,6 +466,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct > > rte_eth_stats *igb_stats) > > > > igb_stats->ipackets =3D rx_total; > > igb_stats->ibytes =3D rx_bytes_total; > > + igb_stats->imissed =3D rx_dropped_total; > > + igb_stats->rx_nombuf =3D rx_nombuf_total; > > igb_stats->opackets =3D tx_total; > > igb_stats->oerrors =3D tx_err_total; > > igb_stats->obytes =3D tx_bytes_total; > > @@ -457,6 +483,8 @@ eth_stats_reset(struct rte_eth_dev *dev) > > for (i =3D 0; i < internal->nb_queues; i++) { > > internal->rx_queue[i].rx_pkts =3D 0; > > internal->rx_queue[i].rx_bytes =3D 0; > > + internal->rx_queue[i].rx_nombuf =3D 0; > > + internal->rx_queue[i].rx_dropped_pkts =3D 0; > > } > > > > for (i =3D 0; i < internal->nb_queues; i++) { >=20 > What about stats reset? I'm sorry, I don't understand what you mean. The two newly added queue coun= ters are reset in the eth_stats_reset() function. Isn't that the right place to do it? Thanks for your feedback!