From patchwork Fri Nov 7 22:01:40 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirsher, Jeffrey T" X-Patchwork-Id: 7778 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 0D05BDDF5D for ; Sat, 8 Nov 2008 09:02:10 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751565AbYKGWCF (ORCPT ); Fri, 7 Nov 2008 17:02:05 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751521AbYKGWCD (ORCPT ); Fri, 7 Nov 2008 17:02:03 -0500 Received: from qmta09.westchester.pa.mail.comcast.net ([76.96.62.96]:34017 "EHLO QMTA09.westchester.pa.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751530AbYKGWCC (ORCPT ); Fri, 7 Nov 2008 17:02:02 -0500 Received: from OMTA14.westchester.pa.mail.comcast.net ([76.96.62.60]) by QMTA09.westchester.pa.mail.comcast.net with comcast id cHBL1a0081HzFnQ59N202S; Fri, 07 Nov 2008 22:02:00 +0000 Received: from gitlost.lost ([63.64.152.142]) by OMTA14.westchester.pa.mail.comcast.net with comcast id cN1a1a00E34bfcX3aN1cpn; Fri, 07 Nov 2008 22:01:51 +0000 X-Authority-Analysis: v=1.0 c=1 a=u_K34Tch41MA:10 a=fIbl_oDtFesA:10 a=Xw5iifeij1iB0XaAbwIA:9 a=j4zVObB6IoxQH4AS5ZkA:7 a=1WCkF5oDEfC7RnlCHHob7vOztGQA:4 a=dGJ0OcVc7YAA:10 a=iYlkOlhu7C0A:10 From: Jeff Kirsher Subject: [NET-NEXT PATCH] pktgen: add full reset functionality To: davem@davemloft.net Cc: netdev@vger.kernel.org, jeff@garzik.org, Jesse Brandeburg , Jeff Kirsher , Robert Olsson Date: Fri, 07 Nov 2008 14:01:40 -0800 Message-ID: <20081107220140.8528.21932.stgit@gitlost.lost> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jesse Brandeburg 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. Signed-off-by: Jesse Brandeburg Signed-off-by: Jeff Kirsher CC: Robert Olsson Signed-off-by: Robert Olsson --- net/core/pktgen.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/core/pktgen.c b/net/core/pktgen.c index fa4973b..a4f5ad1 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -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;