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 DA07943FB3; Fri, 10 May 2024 14:36:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4036402C4; Fri, 10 May 2024 14:36:56 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 885E0402BB for ; Fri, 10 May 2024 14:36:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715344614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mNN2wMyalJEp4fO5L61V3OTpYUz1fT0vxwtrCWLXA9o=; b=Z7jGzgyGmrBJbM596YKsxd5/4PKgrTHqSGB7WCk14mpgcJDlO5QwV57RsV1vpPIH1a6WdA bVLgpvovAo25/b6L5gJqP59nTi7yfvE8w7AvYZr2kviDY5/khivE2wSrFegp4kiSurvVXu ciCGLpSk2tmKIovIP6rCbhuHOa8eW7M= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-130-b7CJzzPWOiWGWLycCBi5FQ-1; Fri, 10 May 2024 08:36:47 -0400 X-MC-Unique: b7CJzzPWOiWGWLycCBi5FQ-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-51faceb0569so1575727e87.0 for ; Fri, 10 May 2024 05:36:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715344606; x=1715949406; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mNN2wMyalJEp4fO5L61V3OTpYUz1fT0vxwtrCWLXA9o=; b=cex4wwCFYnD9bE2bW+PaXlju22pfqSKIS0CaRjnakuvWeBAl8GFQP+PIM5sSCzMrk3 KH7dGLg7ilXRMcR/VUUrT9nWbH7MM+m4oDvAZ98QElOiA7x12pt3+0A/t9a9nUEIfifd NlbKpzQwFzarAi3/yQkGL5vyRCIesyObiZEo1bg3m3/xJ5ljGQM+TMH2ptdQPrl8BxJS TbglbI8nweXsBCNzy0ppBvFnMISOivzlW8BTJBTh8k8fpnbXSXMXDeNJpwsGxtYAB252 2q+r4QutPo9XlWoqf5Xz2vIWW5sWRPMvEXNF3lEgWPl9gPH9nKlq+JlLFaVB2YbHKMe6 t5VQ== X-Gm-Message-State: AOJu0Yyjr7qGq8RvnSnUs8Fhxav0TvT2kJVa8Th3eIwjjHNWHxKGFHBI Wnj3MZFRoxJQQFtVFizoGOo/KVEdWlXPb0T6EoLguThjDCibBiXb+mWP6eaCLiZFgWIBmf+zosp DDG0BTNSXHRIxXWDRxD0qkJgnlX24BHlsghDPVfQsFUuoCJvWhK8w1wfmRR3rVSXD6KM40uyxbQ tNYp8P8gByKdRqFtG6EG31rc8= X-Received: by 2002:a19:6a05:0:b0:51b:5c40:da74 with SMTP id 2adb3069b0e04-5220fb698a4mr1513881e87.1.1715344606084; Fri, 10 May 2024 05:36:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExQg1Kr7hL1jT3nFw8sl9B/YNWHFZ4Oj+Eq/f2Y7pUAA+WLnUmnBTcnwHnakhxmY8KpAVKNA== X-Received: by 2002:a19:6a05:0:b0:51b:5c40:da74 with SMTP id 2adb3069b0e04-5220fb698a4mr1513869e87.1.1715344605501; Fri, 10 May 2024 05:36:45 -0700 (PDT) Received: from [192.168.0.12] ([78.18.17.228]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35045583669sm2846065f8f.106.2024.05.10.05.36.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 May 2024 05:36:45 -0700 (PDT) Message-ID: <48b5e232-5c23-4deb-9ceb-aa634e48a24d@redhat.com> Date: Fri, 10 May 2024 13:36:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] net/af_xdp: Fix stats reset To: dev@dpdk.org References: <20240510100358.18815-1-ciara.loftus@intel.com> <20240510100358.18815-3-ciara.loftus@intel.com> From: Maryam Tahhan In-Reply-To: <20240510100358.18815-3-ciara.loftus@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 10/05/2024 11:03, Ciara Loftus wrote: > The imissed statistic was not properly reset because it was > read directly from the kernel statistics. To fix this, take note > of the kernel statistic when the stats are reset and deduct this > value from the kernel statistic read during statistics get. > > Bugzilla ID: 1430 > Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD") > cc: stable@dpdk.og > > Reported-by: Stephen Hemminger > Signed-off-by: Ciara Loftus > --- > drivers/net/af_xdp/rte_eth_af_xdp.c | 19 +++++++++++++++++-- > 1 file changed, 17 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c > index 968bbf6d45..8f25134003 100644 > --- a/drivers/net/af_xdp/rte_eth_af_xdp.c > +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c > @@ -125,6 +125,8 @@ struct rx_stats { > uint64_t rx_bytes; > uint64_t rx_dropped; > uint64_t alloc_failed; > + > + uint64_t imissed_offset; > }; Minor nit (sorry) probably don't need the empty line between the `uint64_t alloc_failed` and `uint64_t imissed_offset` otherwise LGTM Acked-by: Maryam Tahhan > > struct pkt_rx_queue { > @@ -884,7 +886,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) > AF_XDP_LOG(ERR, "getsockopt() failed for XDP_STATISTICS.\n"); > return -1; > } > - stats->imissed += xdp_stats.rx_dropped; > + stats->imissed += > + (xdp_stats.rx_dropped - internals->rx_queues[i].stats.imissed_offset); > > stats->opackets += stats->q_opackets[i]; > stats->obytes += stats->q_obytes[i]; > @@ -897,13 +900,25 @@ static int > eth_stats_reset(struct rte_eth_dev *dev) > { > struct pmd_internals *internals = dev->data->dev_private; > - int i; > + struct pmd_process_private *process_private = dev->process_private; > + struct xdp_statistics xdp_stats; > + socklen_t optlen; > + int i, ret, fd; > > for (i = 0; i < internals->queue_cnt; i++) { > memset(&internals->rx_queues[i].stats, 0, > sizeof(struct rx_stats)); > memset(&internals->tx_queues[i].stats, 0, > sizeof(struct tx_stats)); > + fd = process_private->rxq_xsk_fds[i]; > + optlen = sizeof(struct xdp_statistics); > + ret = fd >= 0 ? getsockopt(fd, SOL_XDP, XDP_STATISTICS, > + &xdp_stats, &optlen) : -1; > + if (ret != 0) { > + AF_XDP_LOG(ERR, "getsockopt() failed for XDP_STATISTICS.\n"); > + return -1; > + } > + internals->rx_queues[i].stats.imissed_offset = xdp_stats.rx_dropped; > } > > return 0;