From patchwork Fri Dec 16 15:25:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Igor_Maravi=C4=87?= X-Patchwork-Id: 131835 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 580D51007D7 for ; Sat, 17 Dec 2011 02:27:18 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760022Ab1LPP0Y (ORCPT ); Fri, 16 Dec 2011 10:26:24 -0500 Received: from mx2.etf.rs ([147.91.14.170]:35805 "EHLO mx2.etf.bg.ac.rs" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759977Ab1LPP0T (ORCPT ); Fri, 16 Dec 2011 10:26:19 -0500 Received: from localhost (avs2.etf.rs [147.91.14.173]) by mx2.etf.bg.ac.rs (Postfix) with ESMTP id C97996015E; Fri, 16 Dec 2011 16:26:17 +0100 (CET) X-Virus-Scanned: amavisd-new at etf.rs Received: from mx1.etf.bg.ac.rs ([147.91.14.169]) by localhost (avs2.etf.rs [147.91.14.171]) (amavisd-new, port 10026) with ESMTP id zQ5qXN8OVu43; Fri, 16 Dec 2011 16:26:12 +0100 (CET) Received: from igor-PC.etf.bg.ac.rs (dhcp19.etf.bg.ac.rs [147.91.9.148]) by mx1.etf.bg.ac.rs (Postfix) with ESMTP id 9348912014C; Fri, 16 Dec 2011 16:26:11 +0100 (CET) From: igorm@etf.rs To: netdev@vger.kernel.org Cc: davem@davemloft.net, Igor Maravic Subject: [PATCH 02/10 net-next] include: net: snmp: Create icmp per device counters and add macros for per device stats Date: Fri, 16 Dec 2011 16:25:55 +0100 Message-Id: <1324049163-11207-3-git-send-email-igorm@etf.rs> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1324049163-11207-1-git-send-email-igorm@etf.rs> References: <1324049163-11207-1-git-send-email-igorm@etf.rs> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Igor Maravic Added per device counters for ipv4 icmp statistics. Moved _DEV* macros here, from include/net/ipv6.h. Also, made them more generic, by adding new argument - type. Because of that, they can be used for in_device stats accounting in the same way as for inet6_dev. Signed-off-by: Igor Maravic --- include/net/snmp.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/include/net/snmp.h b/include/net/snmp.h index 2f65e16..65f4052 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h @@ -61,14 +61,24 @@ struct ipstats_mib { /* ICMP */ #define ICMP_MIB_MAX __ICMP_MIB_MAX +/* per network ns counters */ struct icmp_mib { unsigned long mibs[ICMP_MIB_MAX]; }; +/*per device counters, (shared on all cpus) */ +struct icmp_mib_dev { + atomic_long_t mibs[ICMP_MIB_MAX]; +}; #define ICMPMSG_MIB_MAX __ICMPMSG_MIB_MAX +/* per network ns counters */ struct icmpmsg_mib { atomic_long_t mibs[ICMPMSG_MIB_MAX]; }; +/* per device counters, (shared on all cpus) */ +struct icmpmsg_mib_dev { + atomic_long_t mibs[ICMPMSG_MIB_MAX]; +}; /* ICMP6 (IPv6-ICMP) */ #define ICMP6_MIB_MAX __ICMP6_MIB_MAX @@ -214,4 +224,49 @@ struct linux_xfrm_mib { #define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) SNMP_UPD_PO_STATS_BH(mib, basefield, addend) #endif +/* Macros for enabling per device statistics */ + +#define _DEVINC(net, statname, modifier, type, idev, field) \ +({ \ + __typeof__(type) *_idev = (idev); \ + if (likely(_idev)) \ + SNMP_INC_STATS##modifier((_idev)->stats.statname, (field)); \ + SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field)); \ +}) + +/* per device counters are atomic_long_t */ +#define _DEVINCATOMIC(net, statname, modifier, type, idev, field) \ +({ \ + __typeof__(type) *_idev = (idev); \ + if (likely(_idev)) \ + SNMP_INC_STATS_ATOMIC_LONG((_idev)->stats.statname##dev, (field)); \ + SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field)); \ +}) + +/* per device and per net counters are atomic_long_t */ + +#define _DEVINC_ATOMIC_ATOMIC(net, statname, type, idev, field) \ +({ \ + __typeof__(type) *_idev = (idev); \ + if (likely(_idev)) \ + SNMP_INC_STATS_ATOMIC_LONG((_idev)->stats.statname##dev, (field)); \ + SNMP_INC_STATS_ATOMIC_LONG((net)->mib.statname##_statistics, (field)); \ +}) + +#define _DEVADD(net, statname, modifier, type, idev, field, val) \ +({ \ + __typeof__(type) *_idev = (idev); \ + if (likely(_idev)) \ + SNMP_ADD_STATS##modifier((_idev)->stats.statname, (field), (val)); \ + SNMP_ADD_STATS##modifier((net)->mib.statname##_statistics, (field), (val)); \ +}) + +#define _DEVUPD(net, statname, modifier, type, idev, field, val) \ +({ \ + __typeof__(type) *_idev = (idev); \ + if (likely(_idev)) \ + SNMP_UPD_PO_STATS##modifier((_idev)->stats.statname, field, (val)); \ + SNMP_UPD_PO_STATS##modifier((net)->mib.statname##_statistics, field, (val)); \ +}) + #endif