diff options
| -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() % |
