diff options
Diffstat (limited to 'include/net/snmp.h')
-rw-r--r-- | include/net/snmp.h | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/include/net/snmp.h b/include/net/snmp.h index 692ee0061dc4..92456f1035f5 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h | |||
@@ -52,26 +52,11 @@ struct snmp_mib { | |||
52 | * count on the 20Gb/s + networks people expect in a few years time! | 52 | * count on the 20Gb/s + networks people expect in a few years time! |
53 | */ | 53 | */ |
54 | 54 | ||
55 | /* | ||
56 | * The rule for padding: | ||
57 | * Best is power of two because then the right structure can be found by a | ||
58 | * simple shift. The structure should be always cache line aligned. | ||
59 | * gcc needs n=alignto(cachelinesize, popcnt(sizeof(bla_mib))) shift/add | ||
60 | * instructions to emulate multiply in case it is not power-of-two. | ||
61 | * Currently n is always <=3 for all sizes so simple cache line alignment | ||
62 | * is enough. | ||
63 | * | ||
64 | * The best solution would be a global CPU local area , especially on 64 | ||
65 | * and 128byte cacheline machine it makes a *lot* of sense -AK | ||
66 | */ | ||
67 | |||
68 | #define __SNMP_MIB_ALIGN__ ____cacheline_aligned | ||
69 | |||
70 | /* IPstats */ | 55 | /* IPstats */ |
71 | #define IPSTATS_MIB_MAX __IPSTATS_MIB_MAX | 56 | #define IPSTATS_MIB_MAX __IPSTATS_MIB_MAX |
72 | struct ipstats_mib { | 57 | struct ipstats_mib { |
73 | unsigned long mibs[IPSTATS_MIB_MAX]; | 58 | unsigned long mibs[IPSTATS_MIB_MAX]; |
74 | } __SNMP_MIB_ALIGN__; | 59 | }; |
75 | 60 | ||
76 | /* ICMP */ | 61 | /* ICMP */ |
77 | #define ICMP_MIB_DUMMY __ICMP_MIB_MAX | 62 | #define ICMP_MIB_DUMMY __ICMP_MIB_MAX |
@@ -79,36 +64,36 @@ struct ipstats_mib { | |||
79 | 64 | ||
80 | struct icmp_mib { | 65 | struct icmp_mib { |
81 | unsigned long mibs[ICMP_MIB_MAX]; | 66 | unsigned long mibs[ICMP_MIB_MAX]; |
82 | } __SNMP_MIB_ALIGN__; | 67 | }; |
83 | 68 | ||
84 | #define ICMPMSG_MIB_MAX __ICMPMSG_MIB_MAX | 69 | #define ICMPMSG_MIB_MAX __ICMPMSG_MIB_MAX |
85 | struct icmpmsg_mib { | 70 | struct icmpmsg_mib { |
86 | unsigned long mibs[ICMPMSG_MIB_MAX]; | 71 | unsigned long mibs[ICMPMSG_MIB_MAX]; |
87 | } __SNMP_MIB_ALIGN__; | 72 | }; |
88 | 73 | ||
89 | /* ICMP6 (IPv6-ICMP) */ | 74 | /* ICMP6 (IPv6-ICMP) */ |
90 | #define ICMP6_MIB_MAX __ICMP6_MIB_MAX | 75 | #define ICMP6_MIB_MAX __ICMP6_MIB_MAX |
91 | struct icmpv6_mib { | 76 | struct icmpv6_mib { |
92 | unsigned long mibs[ICMP6_MIB_MAX]; | 77 | unsigned long mibs[ICMP6_MIB_MAX]; |
93 | } __SNMP_MIB_ALIGN__; | 78 | }; |
94 | 79 | ||
95 | #define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX | 80 | #define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX |
96 | struct icmpv6msg_mib { | 81 | struct icmpv6msg_mib { |
97 | unsigned long mibs[ICMP6MSG_MIB_MAX]; | 82 | unsigned long mibs[ICMP6MSG_MIB_MAX]; |
98 | } __SNMP_MIB_ALIGN__; | 83 | }; |
99 | 84 | ||
100 | 85 | ||
101 | /* TCP */ | 86 | /* TCP */ |
102 | #define TCP_MIB_MAX __TCP_MIB_MAX | 87 | #define TCP_MIB_MAX __TCP_MIB_MAX |
103 | struct tcp_mib { | 88 | struct tcp_mib { |
104 | unsigned long mibs[TCP_MIB_MAX]; | 89 | unsigned long mibs[TCP_MIB_MAX]; |
105 | } __SNMP_MIB_ALIGN__; | 90 | }; |
106 | 91 | ||
107 | /* UDP */ | 92 | /* UDP */ |
108 | #define UDP_MIB_MAX __UDP_MIB_MAX | 93 | #define UDP_MIB_MAX __UDP_MIB_MAX |
109 | struct udp_mib { | 94 | struct udp_mib { |
110 | unsigned long mibs[UDP_MIB_MAX]; | 95 | unsigned long mibs[UDP_MIB_MAX]; |
111 | } __SNMP_MIB_ALIGN__; | 96 | }; |
112 | 97 | ||
113 | /* Linux */ | 98 | /* Linux */ |
114 | #define LINUX_MIB_MAX __LINUX_MIB_MAX | 99 | #define LINUX_MIB_MAX __LINUX_MIB_MAX |
@@ -148,6 +133,8 @@ struct linux_xfrm_mib { | |||
148 | __this_cpu_add(mib[0]->mibs[field], addend) | 133 | __this_cpu_add(mib[0]->mibs[field], addend) |
149 | #define SNMP_ADD_STATS_USER(mib, field, addend) \ | 134 | #define SNMP_ADD_STATS_USER(mib, field, addend) \ |
150 | this_cpu_add(mib[1]->mibs[field], addend) | 135 | this_cpu_add(mib[1]->mibs[field], addend) |
136 | #define SNMP_ADD_STATS(mib, field, addend) \ | ||
137 | this_cpu_add(mib[0]->mibs[field], addend) | ||
151 | /* | 138 | /* |
152 | * Use "__typeof__(*mib[0]) *ptr" instead of "__typeof__(mib[0]) ptr" | 139 | * Use "__typeof__(*mib[0]) *ptr" instead of "__typeof__(mib[0]) ptr" |
153 | * to make @ptr a non-percpu pointer. | 140 | * to make @ptr a non-percpu pointer. |