snmp.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:8k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  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. #include <linux/cache.h>
  24.  
  25. /*
  26.  * We use all unsigned longs. Linux will soon be so reliable that even these
  27.  * will rapidly get too small 8-). Seriously consider the IpInReceives count
  28.  * on the 20Gb/s + networks people expect in a few years time!
  29.  */
  30. /* 
  31.  * The rule for padding: 
  32.  * Best is power of two because then the right structure can be found by a simple
  33.  * shift. The structure should be always cache line aligned.
  34.  * gcc needs n=alignto(cachelinesize, popcnt(sizeof(bla_mib))) shift/add instructions
  35.  * to emulate multiply in case it is not power-of-two. Currently n is always <=3 for
  36.  * all sizes so simple cache line alignment is enough. 
  37.  * 
  38.  * The best solution would be a global CPU local area , especially on 64 and 128byte 
  39.  * cacheline machine it makes a *lot* of sense -AK
  40.  */ 
  41.  
  42. struct ip_mib
  43. {
  44.   unsigned long IpInReceives;
  45.   unsigned long IpInHdrErrors;
  46.   unsigned long IpInAddrErrors;
  47.   unsigned long IpForwDatagrams;
  48.   unsigned long IpInUnknownProtos;
  49.   unsigned long IpInDiscards;
  50.   unsigned long IpInDelivers;
  51.   unsigned long IpOutRequests;
  52.   unsigned long IpOutDiscards;
  53.   unsigned long IpOutNoRoutes;
  54.   unsigned long IpReasmTimeout;
  55.   unsigned long IpReasmReqds;
  56.   unsigned long IpReasmOKs;
  57.   unsigned long IpReasmFails;
  58.   unsigned long IpFragOKs;
  59.   unsigned long IpFragFails;
  60.   unsigned long IpFragCreates;
  61. unsigned long   __pad[0]; 
  62. } ____cacheline_aligned;
  63.  
  64. struct ipv6_mib
  65. {
  66. unsigned long Ip6InReceives;
  67.   unsigned long Ip6InHdrErrors;
  68.   unsigned long Ip6InTooBigErrors;
  69.   unsigned long Ip6InNoRoutes;
  70.   unsigned long Ip6InAddrErrors;
  71.   unsigned long Ip6InUnknownProtos;
  72.   unsigned long Ip6InTruncatedPkts;
  73.   unsigned long Ip6InDiscards;
  74.   unsigned long Ip6InDelivers;
  75.   unsigned long Ip6OutForwDatagrams;
  76.   unsigned long Ip6OutRequests;
  77.   unsigned long Ip6OutDiscards;
  78.   unsigned long Ip6OutNoRoutes;
  79.   unsigned long Ip6ReasmTimeout;
  80.   unsigned long Ip6ReasmReqds;
  81.   unsigned long Ip6ReasmOKs;
  82.   unsigned long Ip6ReasmFails;
  83.   unsigned long Ip6FragOKs;
  84.   unsigned long Ip6FragFails;
  85.   unsigned long Ip6FragCreates;
  86.   unsigned long Ip6InMcastPkts;
  87.   unsigned long Ip6OutMcastPkts;
  88. unsigned long   __pad[0]; 
  89. } ____cacheline_aligned;
  90.  
  91. struct icmp_mib
  92. {
  93.   unsigned long IcmpInMsgs;
  94.   unsigned long IcmpInErrors;
  95.    unsigned long IcmpInDestUnreachs;
  96.   unsigned long IcmpInTimeExcds;
  97.   unsigned long IcmpInParmProbs;
  98.   unsigned long IcmpInSrcQuenchs;
  99.   unsigned long IcmpInRedirects;
  100.   unsigned long IcmpInEchos;
  101.   unsigned long IcmpInEchoReps;
  102.   unsigned long IcmpInTimestamps;
  103.   unsigned long IcmpInTimestampReps;
  104.   unsigned long IcmpInAddrMasks;
  105.   unsigned long IcmpInAddrMaskReps;
  106.   unsigned long IcmpOutMsgs;
  107.   unsigned long IcmpOutErrors;
  108.   unsigned long IcmpOutDestUnreachs;
  109.   unsigned long IcmpOutTimeExcds;
  110.   unsigned long IcmpOutParmProbs;
  111.   unsigned long IcmpOutSrcQuenchs;
  112.   unsigned long IcmpOutRedirects;
  113.   unsigned long IcmpOutEchos;
  114.   unsigned long IcmpOutEchoReps;
  115.   unsigned long IcmpOutTimestamps;
  116.   unsigned long IcmpOutTimestampReps;
  117.   unsigned long IcmpOutAddrMasks;
  118.   unsigned long IcmpOutAddrMaskReps;
  119. unsigned long dummy;
  120. unsigned long   __pad[0]; 
  121. } ____cacheline_aligned;
  122. struct icmpv6_mib
  123. {
  124. unsigned long Icmp6InMsgs;
  125. unsigned long Icmp6InErrors;
  126. unsigned long Icmp6InDestUnreachs;
  127. unsigned long Icmp6InPktTooBigs;
  128. unsigned long Icmp6InTimeExcds;
  129. unsigned long Icmp6InParmProblems;
  130. unsigned long Icmp6InEchos;
  131. unsigned long Icmp6InEchoReplies;
  132. unsigned long Icmp6InGroupMembQueries;
  133. unsigned long Icmp6InGroupMembResponses;
  134. unsigned long Icmp6InGroupMembReductions;
  135. unsigned long Icmp6InRouterSolicits;
  136. unsigned long Icmp6InRouterAdvertisements;
  137. unsigned long Icmp6InNeighborSolicits;
  138. unsigned long Icmp6InNeighborAdvertisements;
  139. unsigned long Icmp6InRedirects;
  140. unsigned long Icmp6OutMsgs;
  141. unsigned long Icmp6OutDestUnreachs;
  142. unsigned long Icmp6OutPktTooBigs;
  143. unsigned long Icmp6OutTimeExcds;
  144. unsigned long Icmp6OutParmProblems;
  145. unsigned long Icmp6OutEchoReplies;
  146. unsigned long Icmp6OutRouterSolicits;
  147. unsigned long Icmp6OutNeighborSolicits;
  148. unsigned long Icmp6OutNeighborAdvertisements;
  149. unsigned long Icmp6OutRedirects;
  150. unsigned long Icmp6OutGroupMembResponses;
  151. unsigned long Icmp6OutGroupMembReductions;
  152. unsigned long   __pad[0]; 
  153. } ____cacheline_aligned;
  154.  
  155. struct tcp_mib
  156. {
  157.   unsigned long TcpRtoAlgorithm;
  158.   unsigned long TcpRtoMin;
  159.   unsigned long TcpRtoMax;
  160.   unsigned long TcpMaxConn;
  161.   unsigned long TcpActiveOpens;
  162.   unsigned long TcpPassiveOpens;
  163.   unsigned long TcpAttemptFails;
  164.   unsigned long TcpEstabResets;
  165.   unsigned long TcpCurrEstab;
  166.   unsigned long TcpInSegs;
  167.   unsigned long TcpOutSegs;
  168.   unsigned long TcpRetransSegs;
  169.   unsigned long TcpInErrs;
  170.   unsigned long TcpOutRsts;
  171. unsigned long   __pad[0]; 
  172. } ____cacheline_aligned;
  173.  
  174. struct udp_mib
  175. {
  176.   unsigned long UdpInDatagrams;
  177.   unsigned long UdpNoPorts;
  178.   unsigned long UdpInErrors;
  179.   unsigned long UdpOutDatagrams;
  180. unsigned long   __pad[0];
  181. } ____cacheline_aligned; 
  182. struct linux_mib 
  183. {
  184. unsigned long SyncookiesSent;
  185. unsigned long SyncookiesRecv;
  186. unsigned long SyncookiesFailed;
  187. unsigned long EmbryonicRsts;
  188. unsigned long PruneCalled; 
  189. unsigned long RcvPruned;
  190. unsigned long OfoPruned;
  191. unsigned long OutOfWindowIcmps; 
  192. unsigned long LockDroppedIcmps; 
  193.         unsigned long   ArpFilter;
  194. unsigned long TimeWaited; 
  195. unsigned long TimeWaitRecycled; 
  196. unsigned long TimeWaitKilled; 
  197. unsigned long PAWSPassiveRejected; 
  198. unsigned long PAWSActiveRejected; 
  199. unsigned long PAWSEstabRejected; 
  200. unsigned long DelayedACKs;
  201. unsigned long DelayedACKLocked;
  202. unsigned long DelayedACKLost;
  203. unsigned long ListenOverflows;
  204. unsigned long ListenDrops;
  205. unsigned long TCPPrequeued;
  206. unsigned long TCPDirectCopyFromBacklog;
  207. unsigned long TCPDirectCopyFromPrequeue;
  208. unsigned long TCPPrequeueDropped;
  209. unsigned long TCPHPHits;
  210. unsigned long TCPHPHitsToUser;
  211. unsigned long TCPPureAcks;
  212. unsigned long TCPHPAcks;
  213. unsigned long TCPRenoRecovery;
  214. unsigned long TCPSackRecovery;
  215. unsigned long TCPSACKReneging;
  216. unsigned long TCPFACKReorder;
  217. unsigned long TCPSACKReorder;
  218. unsigned long TCPRenoReorder;
  219. unsigned long TCPTSReorder;
  220. unsigned long TCPFullUndo;
  221. unsigned long TCPPartialUndo;
  222. unsigned long TCPDSACKUndo;
  223. unsigned long TCPLossUndo;
  224. unsigned long TCPLoss;
  225. unsigned long TCPLostRetransmit;
  226. unsigned long TCPRenoFailures;
  227. unsigned long TCPSackFailures;
  228. unsigned long TCPLossFailures;
  229. unsigned long TCPFastRetrans;
  230. unsigned long TCPForwardRetrans;
  231. unsigned long TCPSlowStartRetrans;
  232. unsigned long TCPTimeouts;
  233. unsigned long TCPRenoRecoveryFail;
  234. unsigned long TCPSackRecoveryFail;
  235. unsigned long TCPSchedulerFailed;
  236. unsigned long TCPRcvCollapsed;
  237. unsigned long TCPDSACKOldSent;
  238. unsigned long TCPDSACKOfoSent;
  239. unsigned long TCPDSACKRecv;
  240. unsigned long TCPDSACKOfoRecv;
  241. unsigned long TCPAbortOnSyn;
  242. unsigned long TCPAbortOnData;
  243. unsigned long TCPAbortOnClose;
  244. unsigned long TCPAbortOnMemory;
  245. unsigned long TCPAbortOnTimeout;
  246. unsigned long TCPAbortOnLinger;
  247. unsigned long TCPAbortFailed;
  248. unsigned long TCPMemoryPressures;
  249. unsigned long   __pad[0];
  250. } ____cacheline_aligned;
  251. /* 
  252.  * FIXME: On x86 and some other CPUs the split into user and softirq parts is not needed because 
  253.  * addl $1,memory is atomic against interrupts (but atomic_inc would be overkill because of the lock 
  254.  * cycles). Wants new nonlocked_atomic_inc() primitives -AK
  255.  */ 
  256. #define SNMP_INC_STATS(mib, field) ((mib)[2*smp_processor_id()+!in_softirq()].field++)
  257. #define SNMP_INC_STATS_BH(mib, field) ((mib)[2*smp_processor_id()].field++)
  258. #define SNMP_INC_STATS_USER(mib, field) ((mib)[2*smp_processor_id()+1].field++)
  259.  
  260. #endif