diff options
author | Robert Olsson <robert.olsson@its.uu.se> | 2008-08-07 05:23:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-08-07 05:23:01 -0400 |
commit | e6fce5b916cd7f7f79b2b3e53ba74bbfc1d7cf8b (patch) | |
tree | 24492010b882f01660bf03d64c1351ce1796e95a /net/core/pktgen.c | |
parent | 32bb93b02da8c75031e601ff1f9a25f99febbe5f (diff) |
pktgen: multiqueue etc.
Sofar far pktgen have had a restriction to only use one device per kernel
thread. With the new multiqueue architecture this is no longer adequate.
The patch below is an effort to remove this by in pktgen configuration
adding a tag to the device name a la eth0@0 etc. The tag is used for
usual device config just as before. Also a new flag is introduced to mirror
queue_map with sending threads smp_processor_id() QUEUE_MAP_CPU.
An example: We use 4 CPU's to send to one 10g interface (eth0)
and we use the new tagging to send a mix of packet sizes, 64, 576 and
1500 bytes. Also we use TX queues according to smp_processor_id()
PGDEV=/proc/net/pktgen/kpktgend_0
pgset "add_device eth0@0"
PGDEV=/proc/net/pktgen/kpktgend_1
pgset "add_device eth0@1"
PGDEV=/proc/net/pktgen/kpktgend_2
pgset "add_device eth0@2"
PGDEV=/proc/net/pktgen/kpktgend_3
pgset "add_device eth0@3"
....
PGDEV=/proc/net/pktgen/eth0@0
pgset "pkt_size 64"
pgset "flag QUEUE_MAP_CPU"
PGDEV=/proc/net/pktgen/eth0@1
pgset "pkt_size 572"
pgset "flag QUEUE_MAP_CPU"
PGDEV=/proc/net/pktgen/eth0@2
pgset "pkt_size 1496"
PGDEV=/proc/net/pktgen/eth0@3
pgset "pkt_size 1496"
pgset "flag QUEUE_MAP_CPU"
Signed-off-by: Robert Olsson <robert.olsson@its.uu.se>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/pktgen.c')
-rw-r--r-- | net/core/pktgen.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 2498cdaf8cbe..526236453908 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -168,7 +168,7 @@ | |||
168 | #include <asm/div64.h> /* do_div */ | 168 | #include <asm/div64.h> /* do_div */ |
169 | #include <asm/timex.h> | 169 | #include <asm/timex.h> |
170 | 170 | ||
171 | #define VERSION "pktgen v2.69: Packet Generator for packet performance testing.\n" | 171 | #define VERSION "pktgen v2.70: Packet Generator for packet performance testing.\n" |
172 | 172 | ||
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 */ |
@@ -189,6 +189,7 @@ | |||
189 | #define F_FLOW_SEQ (1<<11) /* Sequential flows */ | 189 | #define F_FLOW_SEQ (1<<11) /* Sequential flows */ |
190 | #define F_IPSEC_ON (1<<12) /* ipsec on for flows */ | 190 | #define F_IPSEC_ON (1<<12) /* ipsec on for flows */ |
191 | #define F_QUEUE_MAP_RND (1<<13) /* queue map Random */ | 191 | #define F_QUEUE_MAP_RND (1<<13) /* queue map Random */ |
192 | #define F_QUEUE_MAP_CPU (1<<14) /* queue map mirrors smp_processor_id() */ | ||
192 | 193 | ||
193 | /* Thread control flag bits */ | 194 | /* Thread control flag bits */ |
194 | #define T_TERMINATE (1<<0) | 195 | #define T_TERMINATE (1<<0) |
@@ -621,6 +622,9 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
621 | if (pkt_dev->flags & F_QUEUE_MAP_RND) | 622 | if (pkt_dev->flags & F_QUEUE_MAP_RND) |
622 | seq_printf(seq, "QUEUE_MAP_RND "); | 623 | seq_printf(seq, "QUEUE_MAP_RND "); |
623 | 624 | ||
625 | if (pkt_dev->flags & F_QUEUE_MAP_CPU) | ||
626 | seq_printf(seq, "QUEUE_MAP_CPU "); | ||
627 | |||
624 | if (pkt_dev->cflows) { | 628 | if (pkt_dev->cflows) { |
625 | if (pkt_dev->flags & F_FLOW_SEQ) | 629 | if (pkt_dev->flags & F_FLOW_SEQ) |
626 | seq_printf(seq, "FLOW_SEQ "); /*in sequence flows*/ | 630 | seq_printf(seq, "FLOW_SEQ "); /*in sequence flows*/ |
@@ -1134,6 +1138,12 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1134 | 1138 | ||
1135 | else if (strcmp(f, "!QUEUE_MAP_RND") == 0) | 1139 | else if (strcmp(f, "!QUEUE_MAP_RND") == 0) |
1136 | pkt_dev->flags &= ~F_QUEUE_MAP_RND; | 1140 | pkt_dev->flags &= ~F_QUEUE_MAP_RND; |
1141 | |||
1142 | else if (strcmp(f, "QUEUE_MAP_CPU") == 0) | ||
1143 | pkt_dev->flags |= F_QUEUE_MAP_CPU; | ||
1144 | |||
1145 | else if (strcmp(f, "!QUEUE_MAP_CPU") == 0) | ||
1146 | pkt_dev->flags &= ~F_QUEUE_MAP_CPU; | ||
1137 | #ifdef CONFIG_XFRM | 1147 | #ifdef CONFIG_XFRM |
1138 | else if (strcmp(f, "IPSEC") == 0) | 1148 | else if (strcmp(f, "IPSEC") == 0) |
1139 | pkt_dev->flags |= F_IPSEC_ON; | 1149 | pkt_dev->flags |= F_IPSEC_ON; |
@@ -1895,6 +1905,23 @@ static int pktgen_device_event(struct notifier_block *unused, | |||
1895 | return NOTIFY_DONE; | 1905 | return NOTIFY_DONE; |
1896 | } | 1906 | } |
1897 | 1907 | ||
1908 | static struct net_device *pktgen_dev_get_by_name(struct pktgen_dev *pkt_dev, const char *ifname) | ||
1909 | { | ||
1910 | char b[IFNAMSIZ+5]; | ||
1911 | int i = 0; | ||
1912 | |||
1913 | for(i=0; ifname[i] != '@'; i++) { | ||
1914 | if(i == IFNAMSIZ) | ||
1915 | break; | ||
1916 | |||
1917 | b[i] = ifname[i]; | ||
1918 | } | ||
1919 | b[i] = 0; | ||
1920 | |||
1921 | return dev_get_by_name(&init_net, b); | ||
1922 | } | ||
1923 | |||
1924 | |||
1898 | /* Associate pktgen_dev with a device. */ | 1925 | /* Associate pktgen_dev with a device. */ |
1899 | 1926 | ||
1900 | static int pktgen_setup_dev(struct pktgen_dev *pkt_dev, const char *ifname) | 1927 | static int pktgen_setup_dev(struct pktgen_dev *pkt_dev, const char *ifname) |
@@ -1908,7 +1935,7 @@ static int pktgen_setup_dev(struct pktgen_dev *pkt_dev, const char *ifname) | |||
1908 | pkt_dev->odev = NULL; | 1935 | pkt_dev->odev = NULL; |
1909 | } | 1936 | } |
1910 | 1937 | ||
1911 | odev = dev_get_by_name(&init_net, ifname); | 1938 | odev = pktgen_dev_get_by_name(pkt_dev, ifname); |
1912 | if (!odev) { | 1939 | if (!odev) { |
1913 | printk(KERN_ERR "pktgen: no such netdevice: \"%s\"\n", ifname); | 1940 | printk(KERN_ERR "pktgen: no such netdevice: \"%s\"\n", ifname); |
1914 | return -ENODEV; | 1941 | return -ENODEV; |
@@ -2129,7 +2156,11 @@ static void get_ipsec_sa(struct pktgen_dev *pkt_dev, int flow) | |||
2129 | #endif | 2156 | #endif |
2130 | static void set_cur_queue_map(struct pktgen_dev *pkt_dev) | 2157 | static void set_cur_queue_map(struct pktgen_dev *pkt_dev) |
2131 | { | 2158 | { |
2132 | if (pkt_dev->queue_map_min < pkt_dev->queue_map_max) { | 2159 | |
2160 | if (pkt_dev->flags & F_QUEUE_MAP_CPU) | ||
2161 | pkt_dev->cur_queue_map = smp_processor_id(); | ||
2162 | |||
2163 | else if (pkt_dev->queue_map_min < pkt_dev->queue_map_max) { | ||
2133 | __u16 t; | 2164 | __u16 t; |
2134 | if (pkt_dev->flags & F_QUEUE_MAP_RND) { | 2165 | if (pkt_dev->flags & F_QUEUE_MAP_RND) { |
2135 | t = random32() % | 2166 | t = random32() % |