All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] pktgen: increasing transmission granularity
@ 2010-06-02 11:49 Daniel Turull
  2010-06-09 20:50 ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Turull @ 2010-06-02 11:49 UTC (permalink / raw)
  To: netdev; +Cc: robert, jens.laas

This patch increases the granularity of the rate generated by pktgen.
The previous version of pktgen uses micro seconds (udelay) resolution when it 
was delayed causing gaps in the rates. It is changed to nanosecond (ndelay).
Now any rate is possible.

Also it allows to set, the desired rate in Mb/s or packets per second.

The documentation has been updated.

Signed-off-by: Daniel Turull <daniel.turull@gmail.com>

---
diff --git a/Documentation/networking/pktgen.txt b/Documentation/networking/pktgen.txt
index 61bb645..ac0e4ff 100644
--- a/Documentation/networking/pktgen.txt
+++ b/Documentation/networking/pktgen.txt
@@ -78,6 +78,9 @@ Examples:
 
  pgset "delay 5000"      adds delay to hard_start_xmit(). nanoseconds
 
+ pgset "rate 300M"       set rate to 300 Mb/s
+ pgset "ratep 1000000"   set rate to 1Mpps
+
  pgset "dst 10.0.0.1"    sets IP destination address
                          (BEWARE! This generator is very aggressive!)
 
@@ -200,6 +203,9 @@ debug
 frags
 delay
 
+rate
+ratep
+
 src_mac_count
 dst_mac_count
 
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 2ad68da..6428653 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -169,7 +169,7 @@
 #include <asm/dma.h>
 #include <asm/div64.h>		/* do_div */
 
-#define VERSION 	"2.73"
+#define VERSION	"2.74"
 #define IP_NAME_SZ 32
 #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */
 #define MPLS_STACK_BOTTOM htonl(0x00000100)
@@ -980,6 +980,40 @@ static ssize_t pktgen_if_write(struct file *file,
 			(unsigned long long) pkt_dev->delay);
 		return count;
 	}
+	if (!strcmp(name, "rate")) {
+		len = num_arg(&user_buffer[i], 10, &value);
+		if (len < 0)
+			return len;
+
+		i += len;
+		if (!value)
+			return len;
+		pkt_dev->delay = pkt_dev->min_pkt_size*8*NSEC_PER_USEC/value;
+		if (debug)
+			printk(KERN_INFO
+				 "pktgen: Delay set at: %llu ns\n",
+					pkt_dev->delay);
+
+		sprintf(pg_result, "OK: rate=%lu", value);
+		return count;
+	}
+	if (!strcmp(name, "ratep")) {
+		len = num_arg(&user_buffer[i], 10, &value);
+		if (len < 0)
+			return len;
+
+		i += len;
+		if (!value)
+			return len;
+		pkt_dev->delay = NSEC_PER_SEC/value;
+		if (debug)
+			printk(KERN_INFO
+				 "pktgen: Delay set at: %llu ns\n",
+					pkt_dev->delay);
+
+		sprintf(pg_result, "OK: rate=%lu", value);
+		return count;
+	}
 	if (!strcmp(name, "udp_src_min")) {
 		len = num_arg(&user_buffer[i], 10, &value);
 		if (len < 0)
@@ -2142,15 +2176,15 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
 	hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 	hrtimer_set_expires(&t.timer, spin_until);
 
-	remaining = ktime_to_us(hrtimer_expires_remaining(&t.timer));
+	remaining = ktime_to_ns(hrtimer_expires_remaining(&t.timer));
 	if (remaining <= 0) {
 		pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay);
 		return;
 	}
 
 	start_time = ktime_now();
-	if (remaining < 100)
-		udelay(remaining); 	/* really small just spin */
+	if (remaining < 100000)
+		ndelay(remaining);	/* really small just spin */
 	else {
 		/* see do_nanosleep */
 		hrtimer_init_sleeper(&t, current);
@@ -2170,7 +2204,7 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
 	end_time = ktime_now();
 
 	pkt_dev->idle_acc += ktime_to_ns(ktime_sub(end_time, start_time));
-	pkt_dev->next_tx = ktime_add_ns(end_time, pkt_dev->delay);
+	pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay);
 }
 
 static inline void set_pkt_overhead(struct pktgen_dev *pkt_dev)


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] pktgen: increasing transmission granularity
  2010-06-02 11:49 [PATCH 1/2] pktgen: increasing transmission granularity Daniel Turull
@ 2010-06-09 20:50 ` David Miller
  2010-06-10  8:44   ` Daniel Turull
  2010-06-10  8:49   ` Daniel Turull
  0 siblings, 2 replies; 8+ messages in thread
From: David Miller @ 2010-06-09 20:50 UTC (permalink / raw)
  To: daniel.turull; +Cc: netdev, robert, jens.laas

From: Daniel Turull <daniel.turull@gmail.com>
Date: Wed, 02 Jun 2010 13:49:07 +0200

> This patch increases the granularity of the rate generated by pktgen.
> The previous version of pktgen uses micro seconds (udelay) resolution when it 
> was delayed causing gaps in the rates. It is changed to nanosecond (ndelay).
> Now any rate is possible.
> 
> Also it allows to set, the desired rate in Mb/s or packets per second.
> 
> The documentation has been updated.
> 
> Signed-off-by: Daniel Turull <daniel.turull@gmail.com>

I like this, however although most of this is adding a new
feature, this part:

> @@ -2170,7 +2204,7 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
>  	end_time = ktime_now();
>  
>  	pkt_dev->idle_acc += ktime_to_ns(ktime_sub(end_time, start_time));
> -	pkt_dev->next_tx = ktime_add_ns(end_time, pkt_dev->delay);
> +	pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay);
>  }
>  
>  static inline void set_pkt_overhead(struct pktgen_dev *pkt_dev)

Is a bug fix, since it makes sure the inter-packet interval is
accurate.

Can you please submit this part seperately, so I can apply it to
net-2.6   Then you can submit the nanosecond feature parts
relative to this, which I'll apply to net-next-2.6

Thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] pktgen: increasing transmission granularity
  2010-06-09 20:50 ` David Miller
@ 2010-06-10  8:44   ` Daniel Turull
  2010-06-10 15:44     ` robert
  2010-06-10  8:49   ` Daniel Turull
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Turull @ 2010-06-10  8:44 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, robert, jens.laas

This patch correct a bug in the delay of pktgen. 
It makes sure the inter-packet interval is accurate.

Signed-off-by: Daniel Turull <daniel.turull@gmail.com>

---
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 2ad68da..1dacd7b 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2170,7 +2170,7 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
 	end_time = ktime_now();
 
 	pkt_dev->idle_acc += ktime_to_ns(ktime_sub(end_time, start_time));
-	pkt_dev->next_tx = ktime_add_ns(end_time, pkt_dev->delay);
+	pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay);
 }
 
 static inline void set_pkt_overhead(struct pktgen_dev *pkt_dev)

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] pktgen: increasing transmission granularity
  2010-06-09 20:50 ` David Miller
  2010-06-10  8:44   ` Daniel Turull
@ 2010-06-10  8:49   ` Daniel Turull
  2010-06-10 17:21     ` Robert Olsson
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Turull @ 2010-06-10  8:49 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, robert, jens.laas

This patch increases the granularity of the rate generated by pktgen.
The previous version of pktgen uses micro seconds (udelay) resolution when it 
was delayed causing gaps in the rates. It is changed to nanosecond (ndelay).
Now any rate is possible.

Also it allows to set, the desired rate in Mb/s or packets per second.

The documentation has been updated.

Signed-off-by: Daniel Turull <daniel.turull@gmail.com>

---

diff --git a/Documentation/networking/pktgen.txt b/Documentation/networking/pktgen.txt
index 61bb645..75e4fd7 100644
--- a/Documentation/networking/pktgen.txt
+++ b/Documentation/networking/pktgen.txt
@@ -151,6 +151,8 @@ Examples:
 
  pgset stop    	          aborts injection. Also, ^C aborts generator.
 
+ pgset "rate 300M"        set rate to 300 Mb/s
+ pgset "ratep 1000000"    set rate to 1Mpps
 
 Example scripts
 ===============
@@ -241,6 +243,9 @@ src6
 flows
 flowlen
 
+rate
+ratep
+
 References:
 ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/
 ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/examples/
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 1dacd7b..6428653 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -169,7 +169,7 @@
 #include <asm/dma.h>
 #include <asm/div64.h>		/* do_div */
 
-#define VERSION 	"2.73"
+#define VERSION	"2.74"
 #define IP_NAME_SZ 32
 #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */
 #define MPLS_STACK_BOTTOM htonl(0x00000100)
@@ -980,6 +980,40 @@ static ssize_t pktgen_if_write(struct file *file,
 			(unsigned long long) pkt_dev->delay);
 		return count;
 	}
+	if (!strcmp(name, "rate")) {
+		len = num_arg(&user_buffer[i], 10, &value);
+		if (len < 0)
+			return len;
+
+		i += len;
+		if (!value)
+			return len;
+		pkt_dev->delay = pkt_dev->min_pkt_size*8*NSEC_PER_USEC/value;
+		if (debug)
+			printk(KERN_INFO
+				 "pktgen: Delay set at: %llu ns\n",
+					pkt_dev->delay);
+
+		sprintf(pg_result, "OK: rate=%lu", value);
+		return count;
+	}
+	if (!strcmp(name, "ratep")) {
+		len = num_arg(&user_buffer[i], 10, &value);
+		if (len < 0)
+			return len;
+
+		i += len;
+		if (!value)
+			return len;
+		pkt_dev->delay = NSEC_PER_SEC/value;
+		if (debug)
+			printk(KERN_INFO
+				 "pktgen: Delay set at: %llu ns\n",
+					pkt_dev->delay);
+
+		sprintf(pg_result, "OK: rate=%lu", value);
+		return count;
+	}
 	if (!strcmp(name, "udp_src_min")) {
 		len = num_arg(&user_buffer[i], 10, &value);
 		if (len < 0)
@@ -2142,15 +2176,15 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
 	hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 	hrtimer_set_expires(&t.timer, spin_until);
 
-	remaining = ktime_to_us(hrtimer_expires_remaining(&t.timer));
+	remaining = ktime_to_ns(hrtimer_expires_remaining(&t.timer));
 	if (remaining <= 0) {
 		pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay);
 		return;
 	}
 
 	start_time = ktime_now();
-	if (remaining < 100)
-		udelay(remaining); 	/* really small just spin */
+	if (remaining < 100000)
+		ndelay(remaining);	/* really small just spin */
 	else {
 		/* see do_nanosleep */
 		hrtimer_init_sleeper(&t, current);

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] pktgen: increasing transmission granularity
  2010-06-10  8:44   ` Daniel Turull
@ 2010-06-10 15:44     ` robert
  2010-06-11  6:08       ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: robert @ 2010-06-10 15:44 UTC (permalink / raw)
  To: Daniel Turull; +Cc: David Miller, netdev, robert, jens.laas




Thanks,

So the scheduling of the next transmission is based on the previous
transmission rather rather than now() + delay.


Cheers
				--ro



Signed-off-by: Robert Olsson <robert.olsson@its.uu.se>


>Daniel Turull wrote: This patch correct a bug in the delay of pktgen.
>It makes sure the inter-packet interval is accurate.
>
>Signed-off-by: Daniel Turull <daniel.turull@gmail.com>
>
>---
>diff --git a/net/core/pktgen.c b/net/core/pktgen.c index
>2ad68da..1dacd7b 100644 --- a/net/core/pktgen.c +++
>b/net/core/pktgen.c @@ -2170,7 +2170,7 @@ static void spin(struct
>pktgen_dev *pkt_dev, ktime_t spin_until)
> 	end_time = ktime_now();
> 
> 	pkt_dev->idle_acc += ktime_to_ns(ktime_sub(end_time,
> start_time));
>-	pkt_dev->next_tx = ktime_add_ns(end_time, pkt_dev->delay);
>+	pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay);
> }
> 
> static inline void set_pkt_overhead(struct pktgen_dev *pkt_dev)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] pktgen: increasing transmission granularity
  2010-06-10  8:49   ` Daniel Turull
@ 2010-06-10 17:21     ` Robert Olsson
  2010-06-12  1:40       ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Olsson @ 2010-06-10 17:21 UTC (permalink / raw)
  To: Daniel Turull; +Cc: David Miller, netdev, robert, jens.laas



Thanks,

So with this improved rate control we could do RFC2544-like testing as well.

Cheers
					--ro


Signed-off-by: Robert Olsson <robert.olsson@its.uu.se>


Daniel Turull writes:
 > This patch increases the granularity of the rate generated by pktgen.
 > The previous version of pktgen uses micro seconds (udelay) resolution when it 
 > was delayed causing gaps in the rates. It is changed to nanosecond (ndelay).
 > Now any rate is possible.
 > 
 > Also it allows to set, the desired rate in Mb/s or packets per second.

 > 
 > The documentation has been updated.
 > 
 > Signed-off-by: Daniel Turull <daniel.turull@gmail.com>
 > 
 > ---
 > 
 > diff --git a/Documentation/networking/pktgen.txt b/Documentation/networking/pktgen.txt
 > index 61bb645..75e4fd7 100644
 > --- a/Documentation/networking/pktgen.txt
 > +++ b/Documentation/networking/pktgen.txt
 > @@ -151,6 +151,8 @@ Examples:
 >  
 >   pgset stop    	          aborts injection. Also, ^C aborts generator.
 >  
 > + pgset "rate 300M"        set rate to 300 Mb/s
 > + pgset "ratep 1000000"    set rate to 1Mpps
 >  
 >  Example scripts
 >  ===============
 > @@ -241,6 +243,9 @@ src6
 >  flows
 >  flowlen
 >  
 > +rate
 > +ratep
 > +
 >  References:
 >  ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/
 >  ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/examples/
 > diff --git a/net/core/pktgen.c b/net/core/pktgen.c
 > index 1dacd7b..6428653 100644
 > --- a/net/core/pktgen.c
 > +++ b/net/core/pktgen.c
 > @@ -169,7 +169,7 @@
 >  #include <asm/dma.h>
 >  #include <asm/div64.h>		/* do_div */
 >  
 > -#define VERSION 	"2.73"
 > +#define VERSION	"2.74"
 >  #define IP_NAME_SZ 32
 >  #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */
 >  #define MPLS_STACK_BOTTOM htonl(0x00000100)
 > @@ -980,6 +980,40 @@ static ssize_t pktgen_if_write(struct file *file,
 >  			(unsigned long long) pkt_dev->delay);
 >  		return count;
 >  	}
 > +	if (!strcmp(name, "rate")) {
 > +		len = num_arg(&user_buffer[i], 10, &value);
 > +		if (len < 0)
 > +			return len;
 > +
 > +		i += len;
 > +		if (!value)
 > +			return len;
 > +		pkt_dev->delay = pkt_dev->min_pkt_size*8*NSEC_PER_USEC/value;
 > +		if (debug)
 > +			printk(KERN_INFO
 > +				 "pktgen: Delay set at: %llu ns\n",
 > +					pkt_dev->delay);
 > +
 > +		sprintf(pg_result, "OK: rate=%lu", value);
 > +		return count;
 > +	}
 > +	if (!strcmp(name, "ratep")) {
 > +		len = num_arg(&user_buffer[i], 10, &value);
 > +		if (len < 0)
 > +			return len;
 > +
 > +		i += len;
 > +		if (!value)
 > +			return len;
 > +		pkt_dev->delay = NSEC_PER_SEC/value;
 > +		if (debug)
 > +			printk(KERN_INFO
 > +				 "pktgen: Delay set at: %llu ns\n",
 > +					pkt_dev->delay);
 > +
 > +		sprintf(pg_result, "OK: rate=%lu", value);
 > +		return count;
 > +	}
 >  	if (!strcmp(name, "udp_src_min")) {
 >  		len = num_arg(&user_buffer[i], 10, &value);
 >  		if (len < 0)
 > @@ -2142,15 +2176,15 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
 >  	hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 >  	hrtimer_set_expires(&t.timer, spin_until);
 >  
 > -	remaining = ktime_to_us(hrtimer_expires_remaining(&t.timer));
 > +	remaining = ktime_to_ns(hrtimer_expires_remaining(&t.timer));
 >  	if (remaining <= 0) {
 >  		pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay);
 >  		return;
 >  	}
 >  
 >  	start_time = ktime_now();
 > -	if (remaining < 100)
 > -		udelay(remaining); 	/* really small just spin */
 > +	if (remaining < 100000)
 > +		ndelay(remaining);	/* really small just spin */
 >  	else {
 >  		/* see do_nanosleep */
 >  		hrtimer_init_sleeper(&t, current);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] pktgen: increasing transmission granularity
  2010-06-10 15:44     ` robert
@ 2010-06-11  6:08       ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2010-06-11  6:08 UTC (permalink / raw)
  To: robert.olsson; +Cc: daniel.turull, netdev, robert, jens.laas

From: Robert Olsson <robert.olsson@its.uu.se>
Date: Thu, 10 Jun 2010 17:44:42 +0200

> So the scheduling of the next transmission is based on the previous
> transmission rather rather than now() + delay.
 ...
> Signed-off-by: Robert Olsson <robert.olsson@its.uu.se>
> 
> 
>>Daniel Turull wrote: This patch correct a bug in the delay of pktgen.
>>It makes sure the inter-packet interval is accurate.
>>
>>Signed-off-by: Daniel Turull <daniel.turull@gmail.com>

Applied, thanks everyone.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] pktgen: increasing transmission granularity
  2010-06-10 17:21     ` Robert Olsson
@ 2010-06-12  1:40       ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2010-06-12  1:40 UTC (permalink / raw)
  To: robert; +Cc: daniel.turull, netdev, jens.laas

From: Robert Olsson <robert@herjulf.net>
Date: Thu, 10 Jun 2010 19:21:25 +0200

> So with this improved rate control we could do RFC2544-like testing as well.
>
> Signed-off-by: Robert Olsson <robert.olsson@its.uu.se>

Applied, thanks everyone.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-06-12  1:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-02 11:49 [PATCH 1/2] pktgen: increasing transmission granularity Daniel Turull
2010-06-09 20:50 ` David Miller
2010-06-10  8:44   ` Daniel Turull
2010-06-10 15:44     ` robert
2010-06-11  6:08       ` David Miller
2010-06-10  8:49   ` Daniel Turull
2010-06-10 17:21     ` Robert Olsson
2010-06-12  1:40       ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.