patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / include / net / snmp.h
1 /*
2  *
3  *              SNMP MIB entries for the IP subsystem.
4  *              
5  *              Alan Cox <gw4pts@gw4pts.ampr.org>
6  *
7  *              We don't chose to implement SNMP in the kernel (this would
8  *              be silly as SNMP is a pain in the backside in places). We do
9  *              however need to collect the MIB statistics and export them
10  *              out of /proc (eventually)
11  *
12  *              This program is free software; you can redistribute it and/or
13  *              modify it under the terms of the GNU General Public License
14  *              as published by the Free Software Foundation; either version
15  *              2 of the License, or (at your option) any later version.
16  *
17  *              $Id: snmp.h,v 1.19 2001/06/14 13:40:46 davem Exp $
18  *
19  */
20  
21 #ifndef _SNMP_H
22 #define _SNMP_H
23
24 #include <linux/cache.h>
25  
26 /*
27  *      We use all unsigned longs. Linux will soon be so reliable that even these
28  *      will rapidly get too small 8-). Seriously consider the IpInReceives count
29  *      on the 20Gb/s + networks people expect in a few years time!
30  */
31
32 /* 
33  * The rule for padding: 
34  * Best is power of two because then the right structure can be found by a simple
35  * shift. The structure should be always cache line aligned.
36  * gcc needs n=alignto(cachelinesize, popcnt(sizeof(bla_mib))) shift/add instructions
37  * to emulate multiply in case it is not power-of-two. Currently n is always <=3 for
38  * all sizes so simple cache line alignment is enough. 
39  * 
40  * The best solution would be a global CPU local area , especially on 64 and 128byte 
41  * cacheline machine it makes a *lot* of sense -AK
42  */ 
43
44 struct snmp_item {
45         char *name;
46         int offset;
47 };
48
49 #define SNMP_ITEM(mib,entry,procname)   {       \
50         .name = procname,                       \
51         .offset = offsetof(mib, entry),         \
52 }
53
54 #define SNMP_ITEM_SENTINEL {                    \
55         .name = NULL,                           \
56         .offset = 0,                            \
57 }
58
59 /*
60  * RFC 1213:  MIB-II
61  * RFC 2011 (updates 1213):  SNMPv2-MIB-IP
62  * RFC 2863:  Interfaces Group MIB
63  * RFC 2465:  IPv6 MIB: General Group
64  * draft-ietf-ipv6-rfc2011-update-10.txt: MIB for IP: IP Statistics Tables
65  */
66 struct ipstats_mib
67 {
68         unsigned long   InReceives;
69         unsigned long   InHdrErrors;
70         unsigned long   InTooBigErrors;
71         unsigned long   InNoRoutes;
72         unsigned long   InAddrErrors;
73         unsigned long   InUnknownProtos;
74         unsigned long   InTruncatedPkts;
75         unsigned long   InDiscards;
76         unsigned long   InDelivers;
77         unsigned long   OutForwDatagrams;
78         unsigned long   OutRequests;
79         unsigned long   OutDiscards;
80         unsigned long   OutNoRoutes;
81         unsigned long   ReasmTimeout;
82         unsigned long   ReasmReqds;
83         unsigned long   ReasmOKs;
84         unsigned long   ReasmFails;
85         unsigned long   FragOKs;
86         unsigned long   FragFails;
87         unsigned long   FragCreates;
88         unsigned long   InMcastPkts;
89         unsigned long   OutMcastPkts;
90         unsigned long   __pad[0]; 
91 };
92  
93 /*
94  * RFC 1213:  MIB-II ICMP Group
95  * RFC 2011 (updates 1213):  SNMPv2 MIB for IP: ICMP group
96  */
97 struct icmp_mib
98 {
99         unsigned long   IcmpInMsgs;
100         unsigned long   IcmpInErrors;
101         unsigned long   IcmpInDestUnreachs;
102         unsigned long   IcmpInTimeExcds;
103         unsigned long   IcmpInParmProbs;
104         unsigned long   IcmpInSrcQuenchs;
105         unsigned long   IcmpInRedirects;
106         unsigned long   IcmpInEchos;
107         unsigned long   IcmpInEchoReps;
108         unsigned long   IcmpInTimestamps;
109         unsigned long   IcmpInTimestampReps;
110         unsigned long   IcmpInAddrMasks;
111         unsigned long   IcmpInAddrMaskReps;
112         unsigned long   IcmpOutMsgs;
113         unsigned long   IcmpOutErrors;
114         unsigned long   IcmpOutDestUnreachs;
115         unsigned long   IcmpOutTimeExcds;
116         unsigned long   IcmpOutParmProbs;
117         unsigned long   IcmpOutSrcQuenchs;
118         unsigned long   IcmpOutRedirects;
119         unsigned long   IcmpOutEchos;
120         unsigned long   IcmpOutEchoReps;
121         unsigned long   IcmpOutTimestamps;
122         unsigned long   IcmpOutTimestampReps;
123         unsigned long   IcmpOutAddrMasks;
124         unsigned long   IcmpOutAddrMaskReps;
125         unsigned long   dummy;
126         unsigned long   __pad[0]; 
127 };
128
129 /*
130  * RFC 2466:  ICMPv6-MIB
131  */
132 struct icmpv6_mib
133 {
134         unsigned long   Icmp6InMsgs;
135         unsigned long   Icmp6InErrors;
136
137         unsigned long   Icmp6InDestUnreachs;
138         unsigned long   Icmp6InPktTooBigs;
139         unsigned long   Icmp6InTimeExcds;
140         unsigned long   Icmp6InParmProblems;
141
142         unsigned long   Icmp6InEchos;
143         unsigned long   Icmp6InEchoReplies;
144         unsigned long   Icmp6InGroupMembQueries;
145         unsigned long   Icmp6InGroupMembResponses;
146         unsigned long   Icmp6InGroupMembReductions;
147         unsigned long   Icmp6InRouterSolicits;
148         unsigned long   Icmp6InRouterAdvertisements;
149         unsigned long   Icmp6InNeighborSolicits;
150         unsigned long   Icmp6InNeighborAdvertisements;
151         unsigned long   Icmp6InRedirects;
152
153         unsigned long   Icmp6OutMsgs;
154
155         unsigned long   Icmp6OutDestUnreachs;
156         unsigned long   Icmp6OutPktTooBigs;
157         unsigned long   Icmp6OutTimeExcds;
158         unsigned long   Icmp6OutParmProblems;
159
160         unsigned long   Icmp6OutEchoReplies;
161         unsigned long   Icmp6OutRouterSolicits;
162         unsigned long   Icmp6OutNeighborSolicits;
163         unsigned long   Icmp6OutNeighborAdvertisements;
164         unsigned long   Icmp6OutRedirects;
165         unsigned long   Icmp6OutGroupMembResponses;
166         unsigned long   Icmp6OutGroupMembReductions;
167         unsigned long   __pad[0]; 
168 };
169  
170 /*
171  * RFC 1213:  MIB-II TCP group
172  * RFC 2012 (updates 1213):  SNMPv2-MIB-TCP
173  */
174 struct tcp_mib
175 {
176         unsigned long   TcpRtoAlgorithm;
177         unsigned long   TcpRtoMin;
178         unsigned long   TcpRtoMax;
179         unsigned long   TcpMaxConn;
180         unsigned long   TcpActiveOpens;
181         unsigned long   TcpPassiveOpens;
182         unsigned long   TcpAttemptFails;
183         unsigned long   TcpEstabResets;
184         unsigned long   TcpCurrEstab;
185         unsigned long   TcpInSegs;
186         unsigned long   TcpOutSegs;
187         unsigned long   TcpRetransSegs;
188         unsigned long   TcpInErrs;
189         unsigned long   TcpOutRsts;
190         unsigned long   __pad[0]; 
191 };
192  
193 /*
194  * RFC 1213:  MIB-II UDP group
195  * RFC 2013 (updates 1213):  SNMPv2-MIB-UDP
196  */
197 struct udp_mib
198 {
199         unsigned long   UdpInDatagrams;
200         unsigned long   UdpNoPorts;
201         unsigned long   UdpInErrors;
202         unsigned long   UdpOutDatagrams;
203         unsigned long   __pad[0];
204 }; 
205
206 /* draft-ietf-sigtran-sctp-mib-07.txt */
207 struct sctp_mib
208 {
209         unsigned long   SctpCurrEstab;
210         unsigned long   SctpActiveEstabs;
211         unsigned long   SctpPassiveEstabs;
212         unsigned long   SctpAborteds;
213         unsigned long   SctpShutdowns;
214         unsigned long   SctpOutOfBlues;
215         unsigned long   SctpChecksumErrors;
216         unsigned long   SctpOutCtrlChunks;
217         unsigned long   SctpOutOrderChunks;
218         unsigned long   SctpOutUnorderChunks;
219         unsigned long   SctpInCtrlChunks;
220         unsigned long   SctpInOrderChunks;
221         unsigned long   SctpInUnorderChunks;
222         unsigned long   SctpFragUsrMsgs;
223         unsigned long   SctpReasmUsrMsgs;
224         unsigned long   SctpOutSCTPPacks;
225         unsigned long   SctpInSCTPPacks;
226         unsigned long   SctpRtoAlgorithm;
227         unsigned long   SctpRtoMin;
228         unsigned long   SctpRtoMax;
229         unsigned long   SctpRtoInitial;
230         unsigned long   SctpValCookieLife;
231         unsigned long   SctpMaxInitRetr;
232         unsigned long   __pad[0];
233 };
234
235 struct linux_mib 
236 {
237         unsigned long   SyncookiesSent;
238         unsigned long   SyncookiesRecv;
239         unsigned long   SyncookiesFailed;
240         unsigned long   EmbryonicRsts;
241         unsigned long   PruneCalled; 
242         unsigned long   RcvPruned;
243         unsigned long   OfoPruned;
244         unsigned long   OutOfWindowIcmps; 
245         unsigned long   LockDroppedIcmps; 
246         unsigned long   ArpFilter;
247         unsigned long   TimeWaited; 
248         unsigned long   TimeWaitRecycled; 
249         unsigned long   TimeWaitKilled; 
250         unsigned long   PAWSPassiveRejected; 
251         unsigned long   PAWSActiveRejected; 
252         unsigned long   PAWSEstabRejected; 
253         unsigned long   DelayedACKs;
254         unsigned long   DelayedACKLocked;
255         unsigned long   DelayedACKLost;
256         unsigned long   ListenOverflows;
257         unsigned long   ListenDrops;
258         unsigned long   TCPPrequeued;
259         unsigned long   TCPDirectCopyFromBacklog;
260         unsigned long   TCPDirectCopyFromPrequeue;
261         unsigned long   TCPPrequeueDropped;
262         unsigned long   TCPHPHits;
263         unsigned long   TCPHPHitsToUser;
264         unsigned long   TCPPureAcks;
265         unsigned long   TCPHPAcks;
266         unsigned long   TCPRenoRecovery;
267         unsigned long   TCPSackRecovery;
268         unsigned long   TCPSACKReneging;
269         unsigned long   TCPFACKReorder;
270         unsigned long   TCPSACKReorder;
271         unsigned long   TCPRenoReorder;
272         unsigned long   TCPTSReorder;
273         unsigned long   TCPFullUndo;
274         unsigned long   TCPPartialUndo;
275         unsigned long   TCPDSACKUndo;
276         unsigned long   TCPLossUndo;
277         unsigned long   TCPLoss;
278         unsigned long   TCPLostRetransmit;
279         unsigned long   TCPRenoFailures;
280         unsigned long   TCPSackFailures;
281         unsigned long   TCPLossFailures;
282         unsigned long   TCPFastRetrans;
283         unsigned long   TCPForwardRetrans;
284         unsigned long   TCPSlowStartRetrans;
285         unsigned long   TCPTimeouts;
286         unsigned long   TCPRenoRecoveryFail;
287         unsigned long   TCPSackRecoveryFail;
288         unsigned long   TCPSchedulerFailed;
289         unsigned long   TCPRcvCollapsed;
290         unsigned long   TCPDSACKOldSent;
291         unsigned long   TCPDSACKOfoSent;
292         unsigned long   TCPDSACKRecv;
293         unsigned long   TCPDSACKOfoRecv;
294         unsigned long   TCPAbortOnSyn;
295         unsigned long   TCPAbortOnData;
296         unsigned long   TCPAbortOnClose;
297         unsigned long   TCPAbortOnMemory;
298         unsigned long   TCPAbortOnTimeout;
299         unsigned long   TCPAbortOnLinger;
300         unsigned long   TCPAbortFailed;
301         unsigned long   TCPMemoryPressures;
302         unsigned long   __pad[0];
303 };
304
305
306 /* 
307  * FIXME: On x86 and some other CPUs the split into user and softirq parts is not needed because 
308  * addl $1,memory is atomic against interrupts (but atomic_inc would be overkill because of the lock 
309  * cycles). Wants new nonlocked_atomic_inc() primitives -AK
310  */ 
311 #define DEFINE_SNMP_STAT(type, name)    \
312         __typeof__(type) *name[2]
313 #define DECLARE_SNMP_STAT(type, name)   \
314         extern __typeof__(type) *name[2]
315
316 #define SNMP_STAT_BHPTR(name)   (name[0])
317 #define SNMP_STAT_USRPTR(name)  (name[1])
318
319 #define SNMP_INC_STATS_BH(mib, field)   \
320         (per_cpu_ptr(mib[0], smp_processor_id())->field++)
321 #define SNMP_INC_STATS_OFFSET_BH(mib, field, offset)    \
322         ((*((&per_cpu_ptr(mib[0], smp_processor_id())->field) + (offset)))++)
323 #define SNMP_INC_STATS_USER(mib, field) \
324         (per_cpu_ptr(mib[1], smp_processor_id())->field++)
325 #define SNMP_INC_STATS(mib, field)      \
326         (per_cpu_ptr(mib[!in_softirq()], smp_processor_id())->field++)
327 #define SNMP_DEC_STATS(mib, field)      \
328         (per_cpu_ptr(mib[!in_softirq()], smp_processor_id())->field--)
329 #define SNMP_ADD_STATS_BH(mib, field, addend)   \
330         (per_cpu_ptr(mib[0], smp_processor_id())->field += addend)
331 #define SNMP_ADD_STATS_USER(mib, field, addend)         \
332         (per_cpu_ptr(mib[1], smp_processor_id())->field += addend)
333         
334 #endif