diff options
-rw-r--r-- | Documentation/networking/pktgen.txt | 5 | ||||
-rw-r--r-- | net/core/pktgen.c | 42 |
2 files changed, 43 insertions, 4 deletions
diff --git a/Documentation/networking/pktgen.txt b/Documentation/networking/pktgen.txt index 61bb645d50e0..75e4fd708ccb 100644 --- a/Documentation/networking/pktgen.txt +++ b/Documentation/networking/pktgen.txt | |||
@@ -151,6 +151,8 @@ Examples: | |||
151 | 151 | ||
152 | pgset stop aborts injection. Also, ^C aborts generator. | 152 | pgset stop aborts injection. Also, ^C aborts generator. |
153 | 153 | ||
154 | pgset "rate 300M" set rate to 300 Mb/s | ||
155 | pgset "ratep 1000000" set rate to 1Mpps | ||
154 | 156 | ||
155 | Example scripts | 157 | Example scripts |
156 | =============== | 158 | =============== |
@@ -241,6 +243,9 @@ src6 | |||
241 | flows | 243 | flows |
242 | flowlen | 244 | flowlen |
243 | 245 | ||
246 | rate | ||
247 | ratep | ||
248 | |||
244 | References: | 249 | References: |
245 | ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/ | 250 | ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/ |
246 | ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/examples/ | 251 | ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/examples/ |
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 1dacd7ba8dbb..6428653e9498 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -169,7 +169,7 @@ | |||
169 | #include <asm/dma.h> | 169 | #include <asm/dma.h> |
170 | #include <asm/div64.h> /* do_div */ | 170 | #include <asm/div64.h> /* do_div */ |
171 | 171 | ||
172 | #define VERSION "2.73" | 172 | #define VERSION "2.74" |
173 | #define IP_NAME_SZ 32 | 173 | #define IP_NAME_SZ 32 |
174 | #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */ | 174 | #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */ |
175 | #define MPLS_STACK_BOTTOM htonl(0x00000100) | 175 | #define MPLS_STACK_BOTTOM htonl(0x00000100) |
@@ -980,6 +980,40 @@ static ssize_t pktgen_if_write(struct file *file, | |||
980 | (unsigned long long) pkt_dev->delay); | 980 | (unsigned long long) pkt_dev->delay); |
981 | return count; | 981 | return count; |
982 | } | 982 | } |
983 | if (!strcmp(name, "rate")) { | ||
984 | len = num_arg(&user_buffer[i], 10, &value); | ||
985 | if (len < 0) | ||
986 | return len; | ||
987 | |||
988 | i += len; | ||
989 | if (!value) | ||
990 | return len; | ||
991 | pkt_dev->delay = pkt_dev->min_pkt_size*8*NSEC_PER_USEC/value; | ||
992 | if (debug) | ||
993 | printk(KERN_INFO | ||
994 | "pktgen: Delay set at: %llu ns\n", | ||
995 | pkt_dev->delay); | ||
996 | |||
997 | sprintf(pg_result, "OK: rate=%lu", value); | ||
998 | return count; | ||
999 | } | ||
1000 | if (!strcmp(name, "ratep")) { | ||
1001 | len = num_arg(&user_buffer[i], 10, &value); | ||
1002 | if (len < 0) | ||
1003 | return len; | ||
1004 | |||
1005 | i += len; | ||
1006 | if (!value) | ||
1007 | return len; | ||
1008 | pkt_dev->delay = NSEC_PER_SEC/value; | ||
1009 | if (debug) | ||
1010 | printk(KERN_INFO | ||
1011 | "pktgen: Delay set at: %llu ns\n", | ||
1012 | pkt_dev->delay); | ||
1013 | |||
1014 | sprintf(pg_result, "OK: rate=%lu", value); | ||
1015 | return count; | ||
1016 | } | ||
983 | if (!strcmp(name, "udp_src_min")) { | 1017 | if (!strcmp(name, "udp_src_min")) { |
984 | len = num_arg(&user_buffer[i], 10, &value); | 1018 | len = num_arg(&user_buffer[i], 10, &value); |
985 | if (len < 0) | 1019 | if (len < 0) |
@@ -2142,15 +2176,15 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until) | |||
2142 | hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); | 2176 | hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); |
2143 | hrtimer_set_expires(&t.timer, spin_until); | 2177 | hrtimer_set_expires(&t.timer, spin_until); |
2144 | 2178 | ||
2145 | remaining = ktime_to_us(hrtimer_expires_remaining(&t.timer)); | 2179 | remaining = ktime_to_ns(hrtimer_expires_remaining(&t.timer)); |
2146 | if (remaining <= 0) { | 2180 | if (remaining <= 0) { |
2147 | pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay); | 2181 | pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay); |
2148 | return; | 2182 | return; |
2149 | } | 2183 | } |
2150 | 2184 | ||
2151 | start_time = ktime_now(); | 2185 | start_time = ktime_now(); |
2152 | if (remaining < 100) | 2186 | if (remaining < 100000) |
2153 | udelay(remaining); /* really small just spin */ | 2187 | ndelay(remaining); /* really small just spin */ |
2154 | else { | 2188 | else { |
2155 | /* see do_nanosleep */ | 2189 | /* see do_nanosleep */ |
2156 | hrtimer_init_sleeper(&t, current); | 2190 | hrtimer_init_sleeper(&t, current); |