From patchwork Wed Dec 4 12:11:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13893648 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A3CA1B85EC for ; Wed, 4 Dec 2024 12:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733314290; cv=none; b=lyAZj+IplTfjnvlVh65ONjOobcsyetwyYKPjApLswMYXBiuSpPGtdcjZFXmMeK34FKYfhhDZoxIq6SHK0+cHXMLNQeB0ZWv816IQE1lbdWf2+2H7dBRR2R8ZDF13DwfTKMLukX//IEQknOh9k8ezYIiRIOAZKPgDAzAhauBMP1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733314290; c=relaxed/simple; bh=7FdhGhZv7UmJ6QLMBj2IsyOMMIalmzX8AxuBf8HzoaY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UHSOma4bTzY+HftH7kxSPsGKOqz0bMM0uuxJP1qqy24nPd2qIluthfVngRgplGHhgLavWQpkVinzEIwVoaw/Lex9K+u9v1x1KwxmIPV2JjDO0Jdv2JZ17P2JCtPnsUgO84vCfKo9YDr3LGdVj3LdDVGk75HQ0r/pqpzA6LvW+Cs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Eot+NTBW; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Eot+NTBW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733314286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=z4L8JmK7KuxK0SRH8yQjr9o0sihITRATo0zsAKFs2f8=; b=Eot+NTBW3T8k4R+MuBivRqQVyJWipVSHQjdPtMfhZJxiOHHOdIxnLrdX1Tn6L/vPJlE0Yc rsI+3b9qdNVyIQaUfAqQdEUvB2m+jAnyAT5Xb3K/+NsukU48vJlNPgjvUAmv1Eanvcvr26 hLRByNZ5XTl+SFge1RJZUHssr4yjZMQ= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-vCaxrinYMea9ua7sjzPwSA-1; Wed, 04 Dec 2024 07:11:25 -0500 X-MC-Unique: vCaxrinYMea9ua7sjzPwSA-1 X-Mimecast-MFC-AGG-ID: vCaxrinYMea9ua7sjzPwSA Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3860bc1d4f1so353909f8f.2 for ; Wed, 04 Dec 2024 04:11:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733314284; x=1733919084; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=z4L8JmK7KuxK0SRH8yQjr9o0sihITRATo0zsAKFs2f8=; b=ddJT3kWVk8AUqQtoh/32WKEB1iZgxasNgHWbRyQBxDcYtUUZqQyqaFB0h1jK7P+Rrm ol9KqNms89CWTGQAJtPJKJDUZlBPZtXyb5kDrdLXEuw6ITzUt1GaNZ/1IRZX2zHAWSGN TqokJ56tiE9ziFivym4CE0U80KNxQgdfazqE+FXgTnz4T3aXjQKm2g2Sq0osILLooCFD zHpyShZaVNLtWW7Jf7uXBA9MJq7E/7NBbavBDSQcvjgPi4UVs7CVRKLm8Q8TkBk8Ho/3 EEIg6z3+hkpuN8LaQvh85MAgviArRsn8HFjwkpHxNm4HQYggiTE+9ISGJ3jzQ0ga/BLu rhvA== X-Gm-Message-State: AOJu0YyPpwfVT9XxJjhJx3AWMXpHJ1FhHcd4nf/ZoYyruLDANEb3VKKr bZOLI9n+8ecdRUF2ozV4XM6GRYbv+vqgqmU8UonYGOUIdLvPPGYy6pme3izPuu9Wtaz65EVw7U5 uopqNAgavPuSVczF1OC23KfLAgQYKCWZ5orus+XURd2y4gek1DQTtrw== X-Gm-Gg: ASbGnctC1XfIAqlsEnuuq8PkYnAmx81S/RxBR/3MnG6uQw1uhEMyAzbBSmCbTr16prw jqhiS4HBYx01rfmiTkwf2OB02zb9HsX+5fn4KxhpPcegTqmTH7b1l+oZ1iFzP5sC9oEhq6b2taa S2DDFnZ2WOjMYr/69g2omDP2sQnhxaM+AbJUflDqcG2/w5x2a89Fyi5FIARPGCa39sdZSqXHCjE IA8syRtDFUOCp7+iDkYdpYM1OmUDCSx2/qDGw2Nj1WSPajv4C6kotI0AKcbD3yrhd03E/ovG12A +1f5xiquvy9Zo1QRT+dyGuC+w+j38Q== X-Received: by 2002:a05:6000:1863:b0:381:b68f:d14b with SMTP id ffacd0b85a97d-385fd421382mr5580331f8f.45.1733314283860; Wed, 04 Dec 2024 04:11:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUlPCax5z0ukwUGxJXDgs27TwWgaDWjDHDa0gUEr1vtujuo9Zk4eVVqNiQCgt/txXQCDlMMg== X-Received: by 2002:a05:6000:1863:b0:381:b68f:d14b with SMTP id ffacd0b85a97d-385fd421382mr5580306f8f.45.1733314283461; Wed, 04 Dec 2024 04:11:23 -0800 (PST) Received: from debian (2a01cb058d23d600b242516949266d33.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:b242:5169:4926:6d33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-385ee4d932asm9847406f8f.26.2024.12.04.04.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 04:11:23 -0800 (PST) Date: Wed, 4 Dec 2024 13:11:21 +0100 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Simon Horman , David Ahern , Andrew Lunn Subject: [PATCH net-next v2 1/4] vrf: Make pcpu_dstats update functions available to other modules. Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org Currently vrf is the only module that uses NETDEV_PCPU_STAT_DSTATS. In order to make this kind of statistics available to other modules, we need to define the update functions in netdevice.h. Therefore, let's define dev_dstats_*() functions for RX and TX packet updates (packets, bytes and drops). Use these new functions in vrf.c instead of vrf_rx_stats() and the other manual counter updates. While there, update the type of the "len" variables to "unsigned int", so that there're aligned with both skb->len and the new dstats update functions. Signed-off-by: Guillaume Nault --- drivers/net/vrf.c | 49 +++++++++++---------------------------- include/linux/netdevice.h | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 35 deletions(-) diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index 67d25f4f94ef..ca81b212a246 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -122,16 +122,6 @@ struct net_vrf { int ifindex; }; -static void vrf_rx_stats(struct net_device *dev, int len) -{ - struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats); - - u64_stats_update_begin(&dstats->syncp); - u64_stats_inc(&dstats->rx_packets); - u64_stats_add(&dstats->rx_bytes, len); - u64_stats_update_end(&dstats->syncp); -} - static void vrf_tx_error(struct net_device *vrf_dev, struct sk_buff *skb) { vrf_dev->stats.tx_errors++; @@ -369,7 +359,7 @@ static bool qdisc_tx_is_default(const struct net_device *dev) static int vrf_local_xmit(struct sk_buff *skb, struct net_device *dev, struct dst_entry *dst) { - int len = skb->len; + unsigned int len = skb->len; skb_orphan(skb); @@ -382,15 +372,10 @@ static int vrf_local_xmit(struct sk_buff *skb, struct net_device *dev, skb->protocol = eth_type_trans(skb, dev); - if (likely(__netif_rx(skb) == NET_RX_SUCCESS)) { - vrf_rx_stats(dev, len); - } else { - struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats); - - u64_stats_update_begin(&dstats->syncp); - u64_stats_inc(&dstats->rx_drops); - u64_stats_update_end(&dstats->syncp); - } + if (likely(__netif_rx(skb) == NET_RX_SUCCESS)) + dev_dstats_rx_add(dev, len); + else + dev_dstats_rx_dropped(dev); return NETDEV_TX_OK; } @@ -578,20 +563,14 @@ static netdev_tx_t is_ip_tx_frame(struct sk_buff *skb, struct net_device *dev) static netdev_tx_t vrf_xmit(struct sk_buff *skb, struct net_device *dev) { - struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats); - - int len = skb->len; - netdev_tx_t ret = is_ip_tx_frame(skb, dev); - - u64_stats_update_begin(&dstats->syncp); - if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) { + unsigned int len = skb->len; + netdev_tx_t ret; - u64_stats_inc(&dstats->tx_packets); - u64_stats_add(&dstats->tx_bytes, len); - } else { - u64_stats_inc(&dstats->tx_drops); - } - u64_stats_update_end(&dstats->syncp); + ret = is_ip_tx_frame(skb, dev); + if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) + dev_dstats_tx_add(dev, len); + else + dev_dstats_tx_dropped(dev); return ret; } @@ -1364,7 +1343,7 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device *vrf_dev, if (!is_ndisc) { struct net_device *orig_dev = skb->dev; - vrf_rx_stats(vrf_dev, skb->len); + dev_dstats_rx_add(vrf_dev, skb->len); skb->dev = vrf_dev; skb->skb_iif = vrf_dev->ifindex; @@ -1420,7 +1399,7 @@ static struct sk_buff *vrf_ip_rcv(struct net_device *vrf_dev, goto out; } - vrf_rx_stats(vrf_dev, skb->len); + dev_dstats_rx_add(vrf_dev, skb->len); if (!list_empty(&vrf_dev->ptype_all)) { int err; diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ecc686409161..b49780c724d7 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2854,6 +2854,46 @@ static inline void dev_lstats_add(struct net_device *dev, unsigned int len) u64_stats_update_end(&lstats->syncp); } +static inline void dev_dstats_rx_add(struct net_device *dev, + unsigned int len) +{ + struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats); + + u64_stats_update_begin(&dstats->syncp); + u64_stats_inc(&dstats->rx_packets); + u64_stats_add(&dstats->rx_bytes, len); + u64_stats_update_end(&dstats->syncp); +} + +static inline void dev_dstats_rx_dropped(struct net_device *dev) +{ + struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats); + + u64_stats_update_begin(&dstats->syncp); + u64_stats_inc(&dstats->rx_drops); + u64_stats_update_end(&dstats->syncp); +} + +static inline void dev_dstats_tx_add(struct net_device *dev, + unsigned int len) +{ + struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats); + + u64_stats_update_begin(&dstats->syncp); + u64_stats_inc(&dstats->tx_packets); + u64_stats_add(&dstats->tx_bytes, len); + u64_stats_update_end(&dstats->syncp); +} + +static inline void dev_dstats_tx_dropped(struct net_device *dev) +{ + struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats); + + u64_stats_update_begin(&dstats->syncp); + u64_stats_inc(&dstats->tx_drops); + u64_stats_update_end(&dstats->syncp); +} + #define __netdev_alloc_pcpu_stats(type, gfp) \ ({ \ typeof(type) __percpu *pcpu_stats = alloc_percpu_gfp(type, gfp);\ From patchwork Wed Dec 4 12:11:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13893649 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 352EE1B2EEB for ; Wed, 4 Dec 2024 12:11:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733314296; cv=none; b=ezlIzKN8wEHeBAraLm/9dmNKcGVYImMm0KQymchjEiOOqiZk2D2L/3qqbLJ/ZWYuyLJy254iUCdxSi2/iwj7rWdw4+h362ZZqssw7IzXWHjH8NWWNMmOTvzFr5fkvThRgAkBcacRkIjrD31jnMa1QtNDkMg1kIU+WRyqzAGzYJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733314296; c=relaxed/simple; bh=HTBrfdKjOHKGi9tdykW1fntgZOEeePkmF6p9fnT/XTs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rvQBeJDwpeOp0WLWPy51OLmlr5f8/pwa14smdC5CoT8i3QrKB+ojTTYDvyaxt7QPZKhJSMjB9VWaRYUfAcO2hzUgKvJfN02GBMni3NTM5y17CGQ6QFEWl1wQ7mhL7yE2wpzPzv2J/QGsYgd3JQTpZn8HNx46R5D++yAskwPmH50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Il8dVSMY; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Il8dVSMY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733314293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DtdZRN8W/3KdjAF87mhMD3rsT1ZGMvzZSHBJyhDjd54=; b=Il8dVSMYEYZv9dGPmCJR3gmBqJcxEhBeZs03gf37wBsZqAl8vn/leleTBrVM1+ghmE//Ew tMolBclXoNrdoyL/IevkHxI9JqSwmbNeEECzuGfuRg+17cddwDfS9YqY8FjGXPHCk0kMRo jYyTxehEz8PxxORVqycIC/UXqZOWRqU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-17-PZ343erxOyKMEzwXHV66BQ-1; Wed, 04 Dec 2024 07:11:30 -0500 X-MC-Unique: PZ343erxOyKMEzwXHV66BQ-1 X-Mimecast-MFC-AGG-ID: PZ343erxOyKMEzwXHV66BQ Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-385d4fa8e19so3427728f8f.2 for ; Wed, 04 Dec 2024 04:11:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733314289; x=1733919089; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DtdZRN8W/3KdjAF87mhMD3rsT1ZGMvzZSHBJyhDjd54=; b=woSoEXZcWrpmo71xFQNNIHONdOI2AAWuAaDYFeH5JHiuNjfe8A2AV3r64hLr2u/qE2 +Bvr3ZF04jEUFhScGBCJbl29PCQyFhXAocKmQI7LPtWKPlhNgqKI1SUWpO6m4luTOC2g oFuaDPE51zy8NAoJu2PPbNWhYjZVkXrLub9zNnBLaa8P25E0d86MymlOjMnntRmXkVhj Mfn9kb68Q+cVPlPYQ0XwZ0mDLvuMQ+/AWBuT0/U7RatdigL+4VOot7nmJq1IHlxEqLM4 XxfC26dkignsP1lyGwxT63EL9GtdGS1gech7Z7ZqlV3Ar2Z6KujkeRK1GnlavS7Q+UNS QD1Q== X-Gm-Message-State: AOJu0YxMtAZ/7a3PSfoVK4Rhd+zENpRB/C0YZidU9CPh6b1XMWrBD0UU f0/tzOpgSO9N7DFxMqN8qIoi0qszoPaGS3d+uhaq+KUBzjF3G7h2RRuZdMME/xLOGyC5cziZgv5 XVUhUiYr7NSwuFpDlxQxDORJxo8jUYr5dh7+0xwqFYWWJeGSrh02XtA== X-Gm-Gg: ASbGncv4VZ6EUep87mIDlx2hfvF2h2s7r0WBpGw8vJpF+MHhfGIkz+qU0AxL6f4FeaB hS8EekYaYc7BY5AAGB+fb48EmkW6IaOPOGnk+SkeZeIB2tq1PeHakP6i1YKGKjOc1ZcDe2m/kEG HHiyO3YKAsfWa6bWmmtTI+tQtFXYrs4oDvsE7Gp2aEwKxFXT3zDeCuMw3eKV4e2HgeM3Z1xVJcV TaGASGViF9IvumQYe2aP8u5vJjRtxOcclSbV1IIRIZj6OatE8DeQpqCOE1L+0QmfY14YtWODLeq tJdHBiUv7vpoYjy4qtZICxH+TLfVjA== X-Received: by 2002:a5d:47cb:0:b0:385:ee59:4510 with SMTP id ffacd0b85a97d-385fd3cc9b6mr5620939f8f.9.1733314289620; Wed, 04 Dec 2024 04:11:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHiTHFswU3DzfMz035kmGtPr+sP4JGyAZXzFqzXv4ARXWeEsZld4OcqqmVC3hENaSC2tNRxwQ== X-Received: by 2002:a5d:47cb:0:b0:385:ee59:4510 with SMTP id ffacd0b85a97d-385fd3cc9b6mr5620919f8f.9.1733314289274; Wed, 04 Dec 2024 04:11:29 -0800 (PST) Received: from debian (2a01cb058d23d600b242516949266d33.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:b242:5169:4926:6d33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-385de98d618sm15561252f8f.90.2024.12.04.04.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 04:11:28 -0800 (PST) Date: Wed, 4 Dec 2024 13:11:27 +0100 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Simon Horman , David Ahern , Andrew Lunn Subject: [PATCH net-next v2 2/4] vxlan: Handle stats using NETDEV_PCPU_STAT_DSTATS. Message-ID: <145558b184b3cda77911ca5682b6eb83c3ffed8e.1733313925.git.gnault@redhat.com> References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org VXLAN uses the TSTATS infrastructure (dev_sw_netstats_*()) for RX and TX packet counters. It also uses the device core stats (dev_core_stats_*()) for RX and TX drops. Let's consolidate that using the DSTATS infrastructure, which can handle both packet counters and packet drops. Statistics that don't fit DSTATS are still updated atomically with DEV_STATS_INC(). While there, convert the "len" variable of vxlan_encap_bypass() to unsigned int, to respect the types of skb->len and dev_dstats_[rt]x_add(). Signed-off-by: Guillaume Nault --- drivers/net/vxlan/vxlan_core.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 9ea63059d52d..b46a799bd390 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1818,14 +1818,14 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) if (unlikely(!(vxlan->dev->flags & IFF_UP))) { rcu_read_unlock(); - dev_core_stats_rx_dropped_inc(vxlan->dev); + dev_dstats_rx_dropped(vxlan->dev); vxlan_vnifilter_count(vxlan, vni, vninode, VXLAN_VNI_STATS_RX_DROPS, 0); reason = SKB_DROP_REASON_DEV_READY; goto drop; } - dev_sw_netstats_rx_add(vxlan->dev, skb->len); + dev_dstats_rx_add(vxlan->dev, skb->len); vxlan_vnifilter_count(vxlan, vni, vninode, VXLAN_VNI_STATS_RX, skb->len); gro_cells_receive(&vxlan->gro_cells, skb); @@ -1880,7 +1880,7 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni) goto out; if (!pskb_may_pull(skb, arp_hdr_len(dev))) { - dev_core_stats_tx_dropped_inc(dev); + dev_dstats_tx_dropped(dev); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_DROPS, 0); goto out; @@ -1938,7 +1938,7 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni) reply->pkt_type = PACKET_HOST; if (netif_rx(reply) == NET_RX_DROP) { - dev_core_stats_rx_dropped_inc(dev); + dev_dstats_rx_dropped(dev); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_RX_DROPS, 0); } @@ -2097,7 +2097,7 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni) goto out; if (netif_rx(reply) == NET_RX_DROP) { - dev_core_stats_rx_dropped_inc(dev); + dev_dstats_rx_dropped(dev); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_RX_DROPS, 0); } @@ -2271,8 +2271,8 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan, { union vxlan_addr loopback; union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip; + unsigned int len = skb->len; struct net_device *dev; - int len = skb->len; skb->pkt_type = PACKET_HOST; skb->encapsulation = 0; @@ -2299,16 +2299,16 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan, if ((dst_vxlan->cfg.flags & VXLAN_F_LEARN) && snoop) vxlan_snoop(dev, &loopback, eth_hdr(skb)->h_source, 0, vni); - dev_sw_netstats_tx_add(src_vxlan->dev, 1, len); + dev_dstats_tx_add(src_vxlan->dev, len); vxlan_vnifilter_count(src_vxlan, vni, NULL, VXLAN_VNI_STATS_TX, len); if (__netif_rx(skb) == NET_RX_SUCCESS) { - dev_sw_netstats_rx_add(dst_vxlan->dev, len); + dev_dstats_rx_add(dst_vxlan->dev, len); vxlan_vnifilter_count(dst_vxlan, vni, NULL, VXLAN_VNI_STATS_RX, len); } else { drop: - dev_core_stats_rx_dropped_inc(dev); + dev_dstats_rx_dropped(dev); vxlan_vnifilter_count(dst_vxlan, vni, NULL, VXLAN_VNI_STATS_RX_DROPS, 0); } @@ -2621,7 +2621,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, return; drop: - dev_core_stats_tx_dropped_inc(dev); + dev_dstats_tx_dropped(dev); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_DROPS, 0); kfree_skb_reason(skb, reason); return; @@ -2666,7 +2666,7 @@ static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev, return; drop: - dev_core_stats_tx_dropped_inc(dev); + dev_dstats_tx_dropped(dev); vxlan_vnifilter_count(netdev_priv(dev), vni, NULL, VXLAN_VNI_STATS_TX_DROPS, 0); dev_kfree_skb(skb); @@ -2704,7 +2704,7 @@ static netdev_tx_t vxlan_xmit_nhid(struct sk_buff *skb, struct net_device *dev, return NETDEV_TX_OK; drop: - dev_core_stats_tx_dropped_inc(dev); + dev_dstats_tx_dropped(dev); vxlan_vnifilter_count(netdev_priv(dev), vni, NULL, VXLAN_VNI_STATS_TX_DROPS, 0); dev_kfree_skb(skb); @@ -2801,7 +2801,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) !is_multicast_ether_addr(eth->h_dest)) vxlan_fdb_miss(vxlan, eth->h_dest); - dev_core_stats_tx_dropped_inc(dev); + dev_dstats_tx_dropped(dev); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_DROPS, 0); kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_NO_REMOTE); @@ -3371,7 +3371,7 @@ static void vxlan_setup(struct net_device *dev) dev->min_mtu = ETH_MIN_MTU; dev->max_mtu = ETH_MAX_MTU; - dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; + dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS; INIT_LIST_HEAD(&vxlan->next); timer_setup(&vxlan->age_timer, vxlan_cleanup, TIMER_DEFERRABLE); From patchwork Wed Dec 4 12:11:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13893650 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3727B198A32 for ; Wed, 4 Dec 2024 12:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733314297; cv=none; b=eAaACTTtM8kdaUrUQfpmENylW1hlmDuj3bQJaALvi9I1A51kpTtCHI6awoz+Dj61LSCw9aZ2o3eSWI9yfJ5Z4aJy5fOTDYm1KP+aLAbrfbSmhvIRdfzOwsPH2hmpHntYP6VsSXzMwLlD5y20ZW4f/84nw4AQCR8AdTYMX3vCkj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733314297; c=relaxed/simple; bh=/jTbBW+dYBEfC+6AnaEjSjg7rywisc/VoKcCooARNBk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AbK2Mts8617n9Nq6OSm59M7iJT9j8jzYjfn+b3aOvz4CdgDq5MtyUGCPt0M3pOzk9pcpYCmAEY7rrzpt655ST9FdqQ2jU6PSJNR4t21X+nDN91HQkC4PEAUJM2ZzdpYZtBwo5cTwK88ax6eScjGzjoSoNbbRrmDVMAl8qMsctRc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SCDAoJaF; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SCDAoJaF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733314295; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=O4ge6cuaOCzyq6y/Mmf3pd55HRmk1F2IdM3vKurD5fA=; b=SCDAoJaF/oHlFlsaQXF4ufroRtApGxd5wMzfOildyGtXuf8gSF+7jMOipomglNjDySbs1A Ly+Gois70h3JPcJIMQZDCsJ3cmHQd37oPM49eNZA32/buD6XWR8DML5KVIJg0NoxJlo+w4 3BL8dN/LsJxwbLjoDbgjRnRm0FfU9kg= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-178-HbPrUXTUM_-InYxWufiAJQ-1; Wed, 04 Dec 2024 07:11:34 -0500 X-MC-Unique: HbPrUXTUM_-InYxWufiAJQ-1 X-Mimecast-MFC-AGG-ID: HbPrUXTUM_-InYxWufiAJQ Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-385de8e0416so2911770f8f.3 for ; Wed, 04 Dec 2024 04:11:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733314293; x=1733919093; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=O4ge6cuaOCzyq6y/Mmf3pd55HRmk1F2IdM3vKurD5fA=; b=dZ1ynhV1n4HqclyFs2TxjyvgHBYBc182LHuF8L8jn/ihUfQZRd61ElgfppsAf5h2/T T/JIlI1mEhZ8KrnuxvPZUpfir+IMqnB1kMKfanx3OdfPywsLm7R8Iyz/gPWqcmP8ruzJ e+uaexZ9MTiOh5v2PEYhnVX3wSs2J54TtFBRsSzmvIpBLpWD7P18/zi4hMrLICZoFDtM VH8GLbLpG610xFUcYWfv3pjeVj3wu6UprLvisJWf2LcVQ1AqwcAu0BZzb+ip7zVby5Th 16tKjYADdjdskd85O+oAY7v0Z40p87RNrPs6O8k8+yTDzfCPT8exFzm4gds5tDPVPxgY tt/A== X-Gm-Message-State: AOJu0YzO/k7dVXvGQiYmBwKr1ZfetIjv4p4MlYq1krfZ3DmTae4qCS3J zdBJtl06dae8wxFwTdPRs6kLbpURUVS7378MROVBNEXge6Jp0jCgAdrtuKmfUAOgE/v1KOMgGPf iwJqOiGh/GH//5nSOMHF68LmWphgB4FCkZSGtLu748HTdAJ7Odq2G+A== X-Gm-Gg: ASbGncuaCJuiJnt8HGT1PiuTMBwym2W2hJeCAH2Vq3HvscGpOipS8npu2Jk33ke5KK1 0aHIqSpprxhz84cz2MVQKr8cB5CKrhA4nQt0LqPizgWNTGqGpISe51wM+E6azWQxCAhzMcg+ico K9S+KUBofIPf/wMN2iRx7l/45HM4qLGaDtKvcJQ+QJsTenUxt4CVPD6oqXZrQpNX91vRYcx7/lC l6lfxrDciekzdxt8vxFEpxrhGbjx7ccEPw7yY7PTNMD+SVTqZtczVXhLIaidxReaWgAZ+2TTTTf UY+owAu57RZW2xoSnM50LiXSepDtaQ== X-Received: by 2002:a5d:47a6:0:b0:385:e055:a294 with SMTP id ffacd0b85a97d-385fd55f1b4mr5488954f8f.59.1733314292771; Wed, 04 Dec 2024 04:11:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJ3pRJ6SxC276FFNdDqnCVmlV0rydo+wzyfTk5Fv2D6/c80ajIxJY4Px7/U7FofHYxpBFu1Q== X-Received: by 2002:a5d:47a6:0:b0:385:e055:a294 with SMTP id ffacd0b85a97d-385fd55f1b4mr5488935f8f.59.1733314292463; Wed, 04 Dec 2024 04:11:32 -0800 (PST) Received: from debian (2a01cb058d23d600b242516949266d33.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:b242:5169:4926:6d33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-385ec6a3d8fsm10445640f8f.101.2024.12.04.04.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 04:11:31 -0800 (PST) Date: Wed, 4 Dec 2024 13:11:30 +0100 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Simon Horman , David Ahern , Andrew Lunn Subject: [PATCH net-next v2 3/4] geneve: Handle stats using NETDEV_PCPU_STAT_DSTATS. Message-ID: <7af5c09f3c26f0f231fbe383822ca5d1ce0278fa.1733313925.git.gnault@redhat.com> References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org Geneve uses the TSTATS infrastructure (dev_sw_netstats_*()) for RX packet counters. All other counters are handled using atomic increments with DEV_STATS_INC(). Let's convert packet stats handling to DSTATS, which has a per-cpu counter for packet drops too, to avoid the cost of atomic increments in these cases. Statistics that don't fit DSTATS are still updated atomically with DEV_STATS_INC(). Signed-off-by: Guillaume Nault --- drivers/net/geneve.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 2f29b1386b1c..d927737010cf 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -235,7 +235,7 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs, vni_to_tunnel_id(gnvh->vni), gnvh->opt_len * 4); if (!tun_dst) { - DEV_STATS_INC(geneve->dev, rx_dropped); + dev_dstats_rx_dropped(geneve->dev); goto drop; } /* Update tunnel dst according to Geneve options. */ @@ -322,7 +322,7 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs, len = skb->len; err = gro_cells_receive(&geneve->gro_cells, skb); if (likely(err == NET_RX_SUCCESS)) - dev_sw_netstats_rx_add(geneve->dev, len); + dev_dstats_rx_add(geneve->dev, len); return; drop: @@ -387,14 +387,14 @@ static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb) if (unlikely((!geneve->cfg.inner_proto_inherit && inner_proto != htons(ETH_P_TEB)))) { - DEV_STATS_INC(geneve->dev, rx_dropped); + dev_dstats_rx_dropped(geneve->dev); goto drop; } opts_len = geneveh->opt_len * 4; if (iptunnel_pull_header(skb, GENEVE_BASE_HLEN + opts_len, inner_proto, !net_eq(geneve->net, dev_net(geneve->dev)))) { - DEV_STATS_INC(geneve->dev, rx_dropped); + dev_dstats_rx_dropped(geneve->dev); goto drop; } @@ -1023,7 +1023,7 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev) if (unlikely(!info || !(info->mode & IP_TUNNEL_INFO_TX))) { netdev_dbg(dev, "no tunnel metadata\n"); dev_kfree_skb(skb); - DEV_STATS_INC(dev, tx_dropped); + dev_dstats_tx_dropped(dev); return NETDEV_TX_OK; } } else { @@ -1202,7 +1202,7 @@ static void geneve_setup(struct net_device *dev) dev->hw_features |= NETIF_F_RXCSUM; dev->hw_features |= NETIF_F_GSO_SOFTWARE; - dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; + dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS; /* MTU range: 68 - (something less than 65535) */ dev->min_mtu = ETH_MIN_MTU; /* The max_mtu calculation does not take account of GENEVE From patchwork Wed Dec 4 12:11:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13893651 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32CFC1B87C6 for ; Wed, 4 Dec 2024 12:11:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733314299; cv=none; b=o1ZVpBPp9DHbXHPGGsIl+EiDxO6AnDg69Ru7nq5MW+4sptEjwxlx1CMqCznW3oEnqZWX3uZcLyctQWbqwcZCmzZw6eZ1GNugIJ2YwN+HeK+Gu3z1HVzQmnlZLuqJuxKUcnxdFqdczXAJqrhjHfXATH0ylzc0AVr0FBn4ERhyMNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733314299; c=relaxed/simple; bh=8imndJXJX33hJtetZZiHeDN05pdqdgmsj6JDHEhLiCg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FrTaSNLDs6g8wYHRIe3Uk0kBZ1aXDTlZsM4CsrihAegzdNpG7CZzyToFj0/CKTRXs+3jfrlc/FpCi23zlQGLHTxJANaSsWH1YJcpwz6j/4SJyHmNluLQgBA2LAZDz9JxcFvvgT8jxxKWrjM2moeeIGj5i/uJGf2QGGjhC5IkaQg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=eqmZzBd9; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eqmZzBd9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733314297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EboEf2/84XUCd54dCRY7yzh8509sOYchgZiYAwfhqyY=; b=eqmZzBd9e9AP8a0pre/kjdpceoc0Sj4T7C8uhv+afnBH2Cc5QvWRzqBoDJ6qR6v628JfPB RCyw8Kx27jEoPfhPB2bLaXChbOH4Ogb2zJ+1EoYlMEmDp0dvoorj0DRU/OxjhPM6qAEn/v ad6DX9IbbW13t6wR6OFGJcaNE28FXu0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-407-tJmAIkOdPdSTJA34pFjW9g-1; Wed, 04 Dec 2024 07:11:36 -0500 X-MC-Unique: tJmAIkOdPdSTJA34pFjW9g-1 X-Mimecast-MFC-AGG-ID: tJmAIkOdPdSTJA34pFjW9g Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-381d0582ad3so5112684f8f.0 for ; Wed, 04 Dec 2024 04:11:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733314295; x=1733919095; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EboEf2/84XUCd54dCRY7yzh8509sOYchgZiYAwfhqyY=; b=TEWNf2VXNCbFPR1iMDcTPKHwqTJ5DMGPFBfVQjtzojyUEMhC0ti9fXgHclodctFoOv 1FrwzgtIWlxsNETEVpGfSrwFLDPb1jKbNIarP5T29tz6PA1O8DFiJ8VPalzJR8ZTpKgX Z5A+qID+EZhP8uDftwGjcD1Td+5246xw4kdXp15XsVpAfFi8M2mKVOtpdve5bxTGMPhS 2c6vI+jCHwGw87yFDcPqw9mVKW5VIm+oZWKLjZK42BRkFvpPGOJCYFP9oLbdI2VNd43j c2QQVxZ6cccGK76ZrYLCBjmzz7vOfT5/fTygVep4mz/95l7Z3K1nFBHPA/iTTagLpy90 PqdQ== X-Gm-Message-State: AOJu0Yz5Ac2QJMWfIXn9/N2CTlo7GA9LflQr7ZfdWDxFdauKEqlWm7dE vnvWVmww+UU2P/oRutIGoqtnQR1kOYIox73OkoEdIsHZ/d2xo0vu9y0N5/BOWCQH7khd3sfBZxr ONSSm6ySNV8Xs+vmJ685i8PmJYCTt9Wt/ZjozE3Z3iUEXaBE/gdmFlA== X-Gm-Gg: ASbGnct5TKgGP9AoYtIvgOIIG5Y1tJyoVl2TExZ092mcd14wLkMGmoh+Rw6WZ2S3Lfa gvmNDZiat+OueFToZGXmATIDN2drYdNcEBJESpcG6ITIaGEwfhWb3lHXJPWZ6qnT9q25yufytfE DoDFosfzhEtSdB/ezIgrAjR/cpVdZlrvHvFFt+1ycMeODfCtHQ0j8Uk5KaGcXawW00QYqU9c3hf 5VHoTeeACYzav67e5rfTIi5NMX+yDai4sVDeXxoQDZtiEIjoHcEL3Gkl/XCC1VYbpsOG0JxpWAi SSw8f9WxnXAAZeln3qNXvRybydxbzw== X-Received: by 2002:a5d:5888:0:b0:385:ded5:86ee with SMTP id ffacd0b85a97d-385fd43c326mr5438070f8f.57.1733314295373; Wed, 04 Dec 2024 04:11:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGc4hQfXi1BdXQ6I3rtpxEZvHty0dvkEiTskKqecwSD3udUXDWz/G+P1A0U2I7+zW0Q5T9UJg== X-Received: by 2002:a5d:5888:0:b0:385:ded5:86ee with SMTP id ffacd0b85a97d-385fd43c326mr5438048f8f.57.1733314295074; Wed, 04 Dec 2024 04:11:35 -0800 (PST) Received: from debian (2a01cb058d23d600b242516949266d33.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:b242:5169:4926:6d33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434d52a6aa9sm22325855e9.33.2024.12.04.04.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 04:11:34 -0800 (PST) Date: Wed, 4 Dec 2024 13:11:32 +0100 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Simon Horman , David Ahern , Andrew Lunn Subject: [PATCH net-next v2 4/4] bareudp: Handle stats using NETDEV_PCPU_STAT_DSTATS. Message-ID: <0f4f8448db3ff449ac6e939872b28cf3f8982da7.1733313925.git.gnault@redhat.com> References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org Bareudp uses the TSTATS infrastructure (dev_sw_netstats_*()) for RX packet counters. It was also recently converted to use the device core stats (dev_core_stats_*()) for RX and TX drops (see commit 788d5d655bc9 ("bareudp: Use pcpu stats to update rx_dropped counter.")). Since core stats are to be avoided in drivers, and for consistency with VXLAN and Geneve, let's convert packet stats handling to DSTATS, which can handle RX/TX stats and packet drops. Statistics that don't fit DSTATS are still updated atomically with DEV_STATS_INC(). Signed-off-by: Guillaume Nault --- drivers/net/bareudp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c index a2abfade82dd..70814303aab8 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -84,7 +84,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) if (skb_copy_bits(skb, BAREUDP_BASE_HLEN, &ipversion, sizeof(ipversion))) { - dev_core_stats_rx_dropped_inc(bareudp->dev); + dev_dstats_rx_dropped(bareudp->dev); goto drop; } ipversion >>= 4; @@ -94,7 +94,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) } else if (ipversion == 6 && bareudp->multi_proto_mode) { proto = htons(ETH_P_IPV6); } else { - dev_core_stats_rx_dropped_inc(bareudp->dev); + dev_dstats_rx_dropped(bareudp->dev); goto drop; } } else if (bareudp->ethertype == htons(ETH_P_MPLS_UC)) { @@ -108,7 +108,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) ipv4_is_multicast(tunnel_hdr->daddr)) { proto = htons(ETH_P_MPLS_MC); } else { - dev_core_stats_rx_dropped_inc(bareudp->dev); + dev_dstats_rx_dropped(bareudp->dev); goto drop; } } else { @@ -124,7 +124,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) (addr_type & IPV6_ADDR_MULTICAST)) { proto = htons(ETH_P_MPLS_MC); } else { - dev_core_stats_rx_dropped_inc(bareudp->dev); + dev_dstats_rx_dropped(bareudp->dev); goto drop; } } @@ -136,7 +136,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) proto, !net_eq(bareudp->net, dev_net(bareudp->dev)))) { - dev_core_stats_rx_dropped_inc(bareudp->dev); + dev_dstats_rx_dropped(bareudp->dev); goto drop; } @@ -144,7 +144,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) tun_dst = udp_tun_rx_dst(skb, family, key, 0, 0); if (!tun_dst) { - dev_core_stats_rx_dropped_inc(bareudp->dev); + dev_dstats_rx_dropped(bareudp->dev); goto drop; } skb_dst_set(skb, &tun_dst->dst); @@ -194,7 +194,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) len = skb->len; err = gro_cells_receive(&bareudp->gro_cells, skb); if (likely(err == NET_RX_SUCCESS)) - dev_sw_netstats_rx_add(bareudp->dev, len); + dev_dstats_rx_add(bareudp->dev, len); return 0; drop: @@ -589,7 +589,7 @@ static void bareudp_setup(struct net_device *dev) dev->priv_flags |= IFF_NO_QUEUE; dev->lltx = true; dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; - dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; + dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS; } static int bareudp_validate(struct nlattr *tb[], struct nlattr *data[],