#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/wait.h>
+#include <linux/completion.h>
#include <linux/etherdevice.h>
#include <net/checksum.h>
#include <net/ipv6.h>
#define MAX_CFLOWS 65536
+struct pktgen_thread_info {
+ struct pktgen_thread *t;
+ struct completion *c;
+};
+
struct flow_state
{
__u32 cur_daddr;
* Main loop of the thread goes here
*/
-static void pktgen_thread_worker(struct pktgen_thread *t)
+static void pktgen_thread_worker(struct pktgen_thread_info *info)
{
DEFINE_WAIT(wait);
struct pktgen_dev *pkt_dev = NULL;
+ struct pktgen_thread *t = info->t;
int cpu = t->cpu;
sigset_t tmpsig;
u32 max_before_softirq;
__set_current_state(TASK_INTERRUPTIBLE);
mb();
+ complete(info->c);
+
while (1) {
__set_current_state(TASK_RUNNING);
static int __init pktgen_create_thread(const char* name, int cpu)
{
+ struct pktgen_thread_info info;
+ struct completion started;
struct pktgen_thread *t = NULL;
struct proc_dir_entry *pe;
t->next = pktgen_threads;
pktgen_threads = t;
- if (kernel_thread((void *) pktgen_thread_worker, (void *) t,
+ init_completion(&started);
+ info.t = t;
+ info.c = &started;
+
+ if (kernel_thread((void *) pktgen_thread_worker, (void *)&info,
CLONE_FS | CLONE_FILES | CLONE_SIGHAND) < 0)
printk("pktgen: kernel_thread() failed for cpu %d\n", t->cpu);
+ wait_for_completion(&started);
return 0;
}