Go to the documentation of this file.
39 #define SNMP_MIB_ITEM(_name,_entry) { \
44 #define SNMP_MIB_SENTINEL { \
55 #define IPSTATS_MIB_MAX __IPSTATS_MIB_MAX
63 #define ICMP_MIB_MAX __ICMP_MIB_MAX
68 #define ICMPMSG_MIB_MAX __ICMPMSG_MIB_MAX
74 #define ICMP6_MIB_MAX __ICMP6_MIB_MAX
84 #define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX
96 #define TCP_MIB_MAX __TCP_MIB_MAX
102 #define UDP_MIB_MAX __UDP_MIB_MAX
108 #define LINUX_MIB_MAX __LINUX_MIB_MAX
114 #define LINUX_MIB_XFRMMAX __LINUX_MIB_XFRMMAX
119 #define SNMP_ARRAY_SZ 1
121 #define DEFINE_SNMP_STAT(type, name) \
122 __typeof__(type) __percpu *name[SNMP_ARRAY_SZ]
123 #define DEFINE_SNMP_STAT_ATOMIC(type, name) \
124 __typeof__(type) *name
125 #define DECLARE_SNMP_STAT(type, name) \
126 extern __typeof__(type) __percpu *name[SNMP_ARRAY_SZ]
128 #define SNMP_INC_STATS_BH(mib, field) \
129 __this_cpu_inc(mib[0]->mibs[field])
131 #define SNMP_INC_STATS_USER(mib, field) \
132 this_cpu_inc(mib[0]->mibs[field])
134 #define SNMP_INC_STATS_ATOMIC_LONG(mib, field) \
135 atomic_long_inc(&mib->mibs[field])
137 #define SNMP_INC_STATS(mib, field) \
138 this_cpu_inc(mib[0]->mibs[field])
140 #define SNMP_DEC_STATS(mib, field) \
141 this_cpu_dec(mib[0]->mibs[field])
143 #define SNMP_ADD_STATS_BH(mib, field, addend) \
144 __this_cpu_add(mib[0]->mibs[field], addend)
146 #define SNMP_ADD_STATS_USER(mib, field, addend) \
147 this_cpu_add(mib[0]->mibs[field], addend)
149 #define SNMP_ADD_STATS(mib, field, addend) \
150 this_cpu_add(mib[0]->mibs[field], addend)
155 #define SNMP_UPD_PO_STATS(mib, basefield, addend) \
157 __typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs; \
158 this_cpu_inc(ptr[basefield##PKTS]); \
159 this_cpu_add(ptr[basefield##OCTETS], addend); \
161 #define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
163 __typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs; \
164 __this_cpu_inc(ptr[basefield##PKTS]); \
165 __this_cpu_add(ptr[basefield##OCTETS], addend); \
169 #if BITS_PER_LONG==32
171 #define SNMP_ADD_STATS64_BH(mib, field, addend) \
173 __typeof__(*mib[0]) *ptr = __this_cpu_ptr((mib)[0]); \
174 u64_stats_update_begin(&ptr->syncp); \
175 ptr->mibs[field] += addend; \
176 u64_stats_update_end(&ptr->syncp); \
179 #define SNMP_ADD_STATS64_USER(mib, field, addend) \
181 local_bh_disable(); \
182 SNMP_ADD_STATS64_BH(mib, field, addend); \
186 #define SNMP_ADD_STATS64(mib, field, addend) \
187 SNMP_ADD_STATS64_USER(mib, field, addend)
189 #define SNMP_INC_STATS64_BH(mib, field) SNMP_ADD_STATS64_BH(mib, field, 1)
190 #define SNMP_INC_STATS64_USER(mib, field) SNMP_ADD_STATS64_USER(mib, field, 1)
191 #define SNMP_INC_STATS64(mib, field) SNMP_ADD_STATS64(mib, field, 1)
192 #define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) \
194 __typeof__(*mib[0]) *ptr; \
195 ptr = __this_cpu_ptr((mib)[0]); \
196 u64_stats_update_begin(&ptr->syncp); \
197 ptr->mibs[basefield##PKTS]++; \
198 ptr->mibs[basefield##OCTETS] += addend; \
199 u64_stats_update_end(&ptr->syncp); \
201 #define SNMP_UPD_PO_STATS64(mib, basefield, addend) \
203 local_bh_disable(); \
204 SNMP_UPD_PO_STATS64_BH(mib, basefield, addend); \
208 #define SNMP_INC_STATS64_BH(mib, field) SNMP_INC_STATS_BH(mib, field)
209 #define SNMP_INC_STATS64_USER(mib, field) SNMP_INC_STATS_USER(mib, field)
210 #define SNMP_INC_STATS64(mib, field) SNMP_INC_STATS(mib, field)
211 #define SNMP_DEC_STATS64(mib, field) SNMP_DEC_STATS(mib, field)
212 #define SNMP_ADD_STATS64_BH(mib, field, addend) SNMP_ADD_STATS_BH(mib, field, addend)
213 #define SNMP_ADD_STATS64_USER(mib, field, addend) SNMP_ADD_STATS_USER(mib, field, addend)
214 #define SNMP_ADD_STATS64(mib, field, addend) SNMP_ADD_STATS(mib, field, addend)
215 #define SNMP_UPD_PO_STATS64(mib, basefield, addend) SNMP_UPD_PO_STATS(mib, basefield, addend)
216 #define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) SNMP_UPD_PO_STATS_BH(mib, basefield, addend)