aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-10-01 12:29:45 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-01 12:29:45 -0400
commit417bc4b855f04dd4ad27a7cabe3e7996a7b78ddb (patch)
tree75752bd8823f98b27957d02ea95ae582ff1e6a84
parenta00d2102ce01df5f0a8892814ecd26d130d47e7d (diff)
pktgen: Fix delay handling
After last pktgen changes, delay handling is wrong. pktgen actually sends packets at full line speed. Fix is to update pkt_dev->next_tx even if spin() returns early, so that next spin() calls have a chance to see a positive delay. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/core/pktgen.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 4d11c28ca8ca..b69455217ed6 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2105,15 +2105,17 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
2105static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until) 2105static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
2106{ 2106{
2107 ktime_t start_time, end_time; 2107 ktime_t start_time, end_time;
2108 s32 remaining; 2108 s64 remaining;
2109 struct hrtimer_sleeper t; 2109 struct hrtimer_sleeper t;
2110 2110
2111 hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); 2111 hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
2112 hrtimer_set_expires(&t.timer, spin_until); 2112 hrtimer_set_expires(&t.timer, spin_until);
2113 2113
2114 remaining = ktime_to_us(hrtimer_expires_remaining(&t.timer)); 2114 remaining = ktime_to_us(hrtimer_expires_remaining(&t.timer));
2115 if (remaining <= 0) 2115 if (remaining <= 0) {
2116 pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay);
2116 return; 2117 return;
2118 }
2117 2119
2118 start_time = ktime_now(); 2120 start_time = ktime_now();
2119 if (remaining < 100) 2121 if (remaining < 100)