1 #ifndef LINUX_3_5_COMPAT_H
2 #define LINUX_3_5_COMPAT_H
4 #include <linux/version.h>
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
8 #include <linux/kernel.h>
10 #include <linux/etherdevice.h>
11 #include <linux/net.h>
13 #include <linux/pkt_sched.h>
18 * From 76e3cc126bb223013a6b9a0e2a51238d1ef2e409 Mon Sep 17 00:00:00 2001
19 * From: Eric Dumazet <edumazet@google.com>
20 * Date: Thu, 10 May 2012 07:51:25 +0000
21 * Subject: [PATCH] codel: Controlled Delay AQM
26 #if !defined(CONFIG_TCA_CODEL_UNSPEC)
37 #define TCA_CODEL_MAX (__TCA_CODEL_MAX - 1)
39 #if !defined(CONFIG_TC_CODEL_XSTATS)
40 struct tc_codel_xstats {
41 __u32 maxpacket; /* largest packet we've seen so far */
42 __u32 count; /* how many drops we've done since the last time we
43 * entered dropping state
45 __u32 lastcount; /* count at entry to dropping state */
46 __u32 ldelay; /* in-queue delay seen by most recently dequeued packet */
47 __s32 drop_next; /* time to drop next packet */
48 __u32 drop_overlimit; /* number of time max qdisc packet limit was hit */
49 __u32 ecn_mark; /* number of packets we ECN marked instead of dropped */
50 __u32 dropping; /* are we in dropping state ? */
56 * commit 4b549a2ef4bef9965d97cbd992ba67930cd3e0fe
57 * Author: Eric Dumazet <edumazet@google.com>
58 * Date: Fri May 11 09:30:50 2012 +0000
59 * fq_codel: Fair Queue Codel AQM
64 #if !defined(CONFIG_TCA_FQ_CODEL_UNSPEC)
69 TCA_FQ_CODEL_INTERVAL,
77 #define TCA_FQ_CODEL_MAX (__TCA_FQ_CODEL_MAX - 1)
79 #ifndef CONFIG_TCA_FQ_CODEL_XSTATS_QDISC
81 TCA_FQ_CODEL_XSTATS_QDISC,
82 TCA_FQ_CODEL_XSTATS_CLASS,
86 #if !defined(CONFIG_TC_FQ_CODEL_QD_STATS)
87 struct tc_fq_codel_qd_stats {
88 __u32 maxpacket; /* largest packet we've seen so far */
89 __u32 drop_overlimit; /* number of time max qdisc
90 * packet limit was hit
92 __u32 ecn_mark; /* number of packets we ECN marked
93 * instead of being dropped
95 __u32 new_flow_count; /* number of time packets
96 * created a 'new flow'
98 __u32 new_flows_len; /* count of flows in new list */
99 __u32 old_flows_len; /* count of flows in old list */
103 #if !defined(CONFIG_TC_FQ_CODEL_CL_STATS)
104 struct tc_fq_codel_cl_stats {
106 __u32 ldelay; /* in-queue delay seen by most recently
116 #if !defined(CONFIG_TC_FQ_CODEL_XSTATS)
117 struct tc_fq_codel_xstats {
120 struct tc_fq_codel_qd_stats qdisc_stats;
121 struct tc_fq_codel_cl_stats class_stats;
126 #ifndef HAVE_IEEE_GET_SET_MAXRATE
127 #ifndef IEEE_8021QAZ_MAX_TCS
128 #define IEEE_8021QAZ_MAX_TCS 8
131 struct ieee_maxrate {
132 u64 tc_maxrate[IEEE_8021QAZ_MAX_TCS];
136 /* Backports tty_lock: Localise the lock */
137 #define tty_lock(__tty) tty_lock()
138 #define tty_unlock(__tty) tty_unlock()
140 #define net_ratelimited_function(function, ...) \
142 if (net_ratelimit()) \
143 function(__VA_ARGS__); \
146 #define net_emerg_ratelimited(fmt, ...) \
147 net_ratelimited_function(pr_emerg, fmt, ##__VA_ARGS__)
148 #define net_alert_ratelimited(fmt, ...) \
149 net_ratelimited_function(pr_alert, fmt, ##__VA_ARGS__)
150 #define net_crit_ratelimited(fmt, ...) \
151 net_ratelimited_function(pr_crit, fmt, ##__VA_ARGS__)
152 #define net_err_ratelimited(fmt, ...) \
153 net_ratelimited_function(pr_err, fmt, ##__VA_ARGS__)
154 #define net_notice_ratelimited(fmt, ...) \
155 net_ratelimited_function(pr_notice, fmt, ##__VA_ARGS__)
156 #define net_warn_ratelimited(fmt, ...) \
157 net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__)
158 #define net_info_ratelimited(fmt, ...) \
159 net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
160 #define net_dbg_ratelimited(fmt, ...) \
161 net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
163 static inline int net_sysctl_init(void) { return 0; }
164 static inline struct ctl_table_header *register_net_sysctl(struct net *net,
165 const char *path, struct ctl_table *table)
170 #ifndef CONFIG_COMPAT_IS_IP_TOS2PRIO
171 #define ip_tos2prio LINUX_BACKPORT(ip_tos2prio)
172 extern const __u8 ip_tos2prio[16];
175 #define dev_uc_add_excl LINUX_BACKPORT(dev_uc_add_excl)
176 #ifdef CONFIG_COMPAT_DEV_UC_MC_ADD_CONST
177 extern int dev_uc_add_excl(struct net_device *dev, const unsigned char *addr);
179 extern int dev_uc_add_excl(struct net_device *dev, unsigned char *addr);
182 #define dev_mc_add_excl LINUX_BACKPORT(dev_mc_add_excl)
183 #ifdef CONFIG_COMPAT_DEV_UC_MC_ADD_CONST
184 extern int dev_mc_add_excl(struct net_device *dev, const unsigned char *addr);
186 extern int dev_mc_add_excl(struct net_device *dev, unsigned char *addr);
189 #define SK_CAN_REUSE 1
191 #define ether_addr_equal_64bits LINUX_BACKPORT(ether_addr_equal_64bits)
192 static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
195 return !compare_ether_addr_64bits(addr1, addr2);
199 * ether_addr_equal - Compare two Ethernet addresses
200 * @addr1: Pointer to a six-byte array containing the Ethernet address
201 * @addr2: Pointer other six-byte array containing the Ethernet address
203 * Compare two ethernet addresses, returns true if equal
205 #define ether_addr_equal LINUX_BACKPORT(ether_addr_equal)
206 static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
208 return !compare_ether_addr(addr1, addr2);
211 #include <linux/skbuff.h>
213 #define skb_end_offset LINUX_BACKPORT(skb_end_offset)
214 #ifdef NET_SKBUFF_DATA_USES_OFFSET
215 static inline unsigned int skb_end_offset(const struct sk_buff *skb)
220 static inline unsigned int skb_end_offset(const struct sk_buff *skb)
222 return skb->end - skb->head;
225 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */
227 #endif /* LINUX_3_5_COMPAT_H */