diff options
Diffstat (limited to 'net/sched/sch_api.c')
-rw-r--r-- | net/sched/sch_api.c | 77 |
1 files changed, 2 insertions, 75 deletions
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 4a927a5e1fa6..d71bf79eb80b 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
@@ -1175,15 +1175,12 @@ reclassify: | |||
1175 | return -1; | 1175 | return -1; |
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | static int psched_us_per_tick = 1; | ||
1179 | static int psched_tick_per_us = 1; | ||
1180 | |||
1181 | #ifdef CONFIG_PROC_FS | 1178 | #ifdef CONFIG_PROC_FS |
1182 | static int psched_show(struct seq_file *seq, void *v) | 1179 | static int psched_show(struct seq_file *seq, void *v) |
1183 | { | 1180 | { |
1184 | seq_printf(seq, "%08x %08x %08x %08x\n", | 1181 | seq_printf(seq, "%08x %08x %08x %08x\n", |
1185 | psched_tick_per_us, psched_us_per_tick, | 1182 | (u32)NSEC_PER_USEC, (u32)PSCHED_US2NS(1), |
1186 | 1000000, HZ); | 1183 | 1000000, HZ); |
1187 | 1184 | ||
1188 | return 0; | 1185 | return 0; |
1189 | } | 1186 | } |
@@ -1202,80 +1199,10 @@ static const struct file_operations psched_fops = { | |||
1202 | }; | 1199 | }; |
1203 | #endif | 1200 | #endif |
1204 | 1201 | ||
1205 | #ifdef CONFIG_NET_SCH_CLK_CPU | ||
1206 | psched_tdiff_t psched_clock_per_hz; | ||
1207 | int psched_clock_scale; | ||
1208 | EXPORT_SYMBOL(psched_clock_per_hz); | ||
1209 | EXPORT_SYMBOL(psched_clock_scale); | ||
1210 | |||
1211 | psched_time_t psched_time_base; | ||
1212 | cycles_t psched_time_mark; | ||
1213 | EXPORT_SYMBOL(psched_time_mark); | ||
1214 | EXPORT_SYMBOL(psched_time_base); | ||
1215 | |||
1216 | /* | ||
1217 | * Periodically adjust psched_time_base to avoid overflow | ||
1218 | * with 32-bit get_cycles(). Safe up to 4GHz CPU. | ||
1219 | */ | ||
1220 | static void psched_tick(unsigned long); | ||
1221 | static DEFINE_TIMER(psched_timer, psched_tick, 0, 0); | ||
1222 | |||
1223 | static void psched_tick(unsigned long dummy) | ||
1224 | { | ||
1225 | if (sizeof(cycles_t) == sizeof(u32)) { | ||
1226 | psched_time_t dummy_stamp; | ||
1227 | PSCHED_GET_TIME(dummy_stamp); | ||
1228 | psched_timer.expires = jiffies + 1*HZ; | ||
1229 | add_timer(&psched_timer); | ||
1230 | } | ||
1231 | } | ||
1232 | |||
1233 | int __init psched_calibrate_clock(void) | ||
1234 | { | ||
1235 | psched_time_t stamp, stamp1; | ||
1236 | struct timeval tv, tv1; | ||
1237 | psched_tdiff_t delay; | ||
1238 | long rdelay; | ||
1239 | unsigned long stop; | ||
1240 | |||
1241 | psched_tick(0); | ||
1242 | stop = jiffies + HZ/10; | ||
1243 | PSCHED_GET_TIME(stamp); | ||
1244 | do_gettimeofday(&tv); | ||
1245 | while (time_before(jiffies, stop)) { | ||
1246 | barrier(); | ||
1247 | cpu_relax(); | ||
1248 | } | ||
1249 | PSCHED_GET_TIME(stamp1); | ||
1250 | do_gettimeofday(&tv1); | ||
1251 | |||
1252 | delay = PSCHED_TDIFF(stamp1, stamp); | ||
1253 | rdelay = tv1.tv_usec - tv.tv_usec; | ||
1254 | rdelay += (tv1.tv_sec - tv.tv_sec)*1000000; | ||
1255 | if (rdelay > delay) | ||
1256 | return -1; | ||
1257 | delay /= rdelay; | ||
1258 | psched_tick_per_us = delay; | ||
1259 | while ((delay>>=1) != 0) | ||
1260 | psched_clock_scale++; | ||
1261 | psched_us_per_tick = 1<<psched_clock_scale; | ||
1262 | psched_clock_per_hz = (psched_tick_per_us*(1000000/HZ))>>psched_clock_scale; | ||
1263 | return 0; | ||
1264 | } | ||
1265 | #endif | ||
1266 | |||
1267 | static int __init pktsched_init(void) | 1202 | static int __init pktsched_init(void) |
1268 | { | 1203 | { |
1269 | struct rtnetlink_link *link_p; | 1204 | struct rtnetlink_link *link_p; |
1270 | 1205 | ||
1271 | #ifdef CONFIG_NET_SCH_CLK_CPU | ||
1272 | if (psched_calibrate_clock() < 0) | ||
1273 | return -1; | ||
1274 | #elif defined(CONFIG_NET_SCH_CLK_JIFFIES) | ||
1275 | psched_tick_per_us = HZ<<PSCHED_JSCALE; | ||
1276 | psched_us_per_tick = 1000000; | ||
1277 | #endif | ||
1278 | |||
1279 | link_p = rtnetlink_links[PF_UNSPEC]; | 1206 | link_p = rtnetlink_links[PF_UNSPEC]; |
1280 | 1207 | ||
1281 | /* Setup rtnetlink links. It is made here to avoid | 1208 | /* Setup rtnetlink links. It is made here to avoid |