pktgen: add full reset functionality
Subsystems (2)
PATCH 1/1 pktgen: add full reset functionality
From: Jesse Brandeburg <[email protected]>
While testing pktgen, I found that sometimes my configurations from previous runs would be left over, particularly when going from a test with 8 threads down to a test with 4 threads.
This adds new functionality to pktgen where you can call pgset "reset"
and it will be just like you just insmod'ed pktgen again.
---
net/core/pktgen.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-)
net/core/pktgen.c +22 -0
@@ -422,6 +422,7 @@ static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t, const char *ifname);static int pktgen_device_event (struct notifier_block *,unsigned long ,void *);static void pktgen_run_all_threads (void ); +static void pktgen_reset_all_threads (void );static void pktgen_stop_all_threads_ifs (void );static int pktgen_stop_device (struct pktgen_dev *pkt_dev);static void pktgen_stop (struct pktgen_thread *t);
@@ -480,6 +481,9 @@ static ssize_t pgctrl_write(struct file *file, const char __user * buf,else if (!strcmp (data,"start" ))pktgen_run_all_threads (); +else if (!strcmp (data,"reset" )) +pktgen_reset_all_threads (); +else printk (KERN_WARNING "pktgen: Unknown command: %s\n" , data);
@@ -3173,6 +3177,24 @@ static void pktgen_run_all_threads(void)pktgen_wait_all_threads_run (); } +static void pktgen_reset_all_threads (void ) +{ +struct pktgen_thread *t; + +pr_debug ("pktgen: entering pktgen_reset_all_threads.\n" ); + +mutex_lock (&pktgen_thread_lock); + +list_for_each_entry (t, &pktgen_threads, th_list) + t->control |= (T_REMDEVALL ); + +mutex_unlock (&pktgen_thread_lock); + +schedule_timeout_interruptible (msecs_to_jiffies (125 ));/* Propagate thread->control */ + +pktgen_wait_all_threads_run (); +} +static void show_results (struct pktgen_dev *pkt_dev,int nr_frags) {__u64 total_us, bps, mbps, pps, idle;
PATCH 1/1 pktgen: add full reset functionality
Quoted 8 lines · Jeff Kirsher
From: Jesse Brandeburg <[email protected]>
While testing pktgen, I found that sometimes my configurations from previous runs would be left over, particularly when going from a test with 8 threads down to a test with 4 threads.
This adds new functionality to pktgen where you can call pgset "reset"
Yes thats more convenient than looping over the threads from the bash scripts.
Quoted 1 line
and it will be just like you just insmod'ed pktgen again.
For less impact I'll think you just can run pktgen_rem_all_ifs() for all threads.
void pktgen_reset_all_threads(void)
{
.
mutex_lock(&pktgen_thread_lock); list_for_each_entry(t, &pktgen_threads, th_list) pktgen_rem_all_ifs(t); mutex_unlock(&pktgen_thread_lock);
.
Quoted 3 lines
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>CC Robert Olsson <[email protected]>
Cheers
--ro
Quoted 52 lines
---
net/core/pktgen.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-)net/core/pktgen.c +22
-0@@ -422,6 +422,7 @@ static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t, const char *ifname);static int pktgen_device_event (struct notifier_block *,unsigned long ,void *);static void pktgen_run_all_threads (void ); +static void pktgen_reset_all_threads (void );static void pktgen_stop_all_threads_ifs (void );static int pktgen_stop_device (struct pktgen_dev *pkt_dev);static void pktgen_stop (struct pktgen_thread *t);@@ -480,6 +481,9 @@ static ssize_t pgctrl_write(struct file *file, const char __user * buf,else if (!strcmp (data,"start" ))pktgen_run_all_threads (); +else if (!strcmp (data,"reset" )) +pktgen_reset_all_threads (); +else printk (KERN_WARNING "pktgen: Unknown command: %s\n" , data);@@ -3173,6 +3177,24 @@ static void pktgen_run_all_threads(void)pktgen_wait_all_threads_run (); } +static void pktgen_reset_all_threads (void ) +{ +struct pktgen_thread *t; + +pr_debug ("pktgen: entering pktgen_reset_all_threads.\n" ); + +mutex_lock (&pktgen_thread_lock); + +list_for_each_entry (t, &pktgen_threads, th_list) + t->control |= (T_REMDEVALL ); + +mutex_unlock (&pktgen_thread_lock); + +schedule_timeout_interruptible (msecs_to_jiffies (125 ));/* Propagate thread->control */ + +pktgen_wait_all_threads_run (); +} +static void show_results (struct pktgen_dev *pkt_dev,int nr_frags) {__u64 total_us, bps, mbps, pps, idle;
From: Robert Olsson <[email protected]>
Date: Sat, 8 Nov 2008 11:21:52 +0100
Quoted 9 lines
Quoted 8 lines · Jeff Kirsher
From: Jesse Brandeburg <[email protected]>
While testing pktgen, I found that sometimes my configurations from previous runs would be left over, particularly when going from a test with 8 threads down to a test with 4 threads.
This adds new functionality to pktgen where you can call pgset "reset"
...
Quoted 5 lines
Quoted 3 lines
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>CC Robert Olsson <[email protected]>Signed-off-by Robert Olsson <[email protected]>
Applied, thanks everyone.