mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Satyam Sharma <ssatyam@cse.iitk.ac.in>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Matt Mackall <mpm@selenic.com>,
	Keiichi Kii <k-keiichi@bx.jp.nec.com>,
	Satyam Sharma <ssatyam@cse.iitk.ac.in>,
	Netdev <netdev@vger.kernel.org>,
	Joel Becker <joel.becker@oracle.com>,
	Stephen Hemminger <shemminger@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Miller <davem@davemloft.net>
Subject: [PATCH v2 -mm 5/9] netconsole: Introduce netconsole_target
Date: Tue, 10 Jul 2007 14:49:46 +0530	[thread overview]
Message-ID: <20070710091946.23907.96503.sendpatchset@cselinux1.cse.iitk.ac.in> (raw)
In-Reply-To: <20070710091920.23907.96483.sendpatchset@cselinux1.cse.iitk.ac.in>

From: Satyam Sharma <ssatyam@cse.iitk.ac.in>

[5/9] netconsole: Introduce netconsole_target

Introduce a wrapper structure over netpoll to represent logging targets
configured in netconsole. This will get extended with other members in
further patches.

The original patchset did this along with (and inside the #ifdef) of
CONFIG_NETCONSOLE_DYNAMIC itself. I decided otherwise, and was able to
drastically cut down on the #ifdef-complexity of final netconsole.c.
Also, struct netconsole_target would be required for multiple targets
support also, and not just dynamic reconfigurability. Previously these
two things were coupled, but I want to de-link that (more on this later).

Note that this patch in itself looks quite redundant / stupid, but it is
purposefully made this way, so further patches are more readable.

Signed-off-by: Satyam Sharma <ssatyam@cse.iitk.ac.in>
Cc: Keiichi Kii <k-keiichi@bx.jp.nec.com>

---

 drivers/net/netconsole.c |   34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

---

diff -ruNp a/drivers/net/netconsole.c b/drivers/net/netconsole.c
--- a/drivers/net/netconsole.c	2007-07-10 06:42:11.000000000 +0530
+++ b/drivers/net/netconsole.c	2007-07-10 06:50:46.000000000 +0530
@@ -62,24 +62,35 @@ static int __init option_setup(char *opt
 __setup("netconsole=", option_setup);
 #endif	/* MODULE */
 
-static struct netpoll np = {
-	.name		= "netconsole",
-	.dev_name	= "eth0",
-	.local_port	= 6665,
-	.remote_port	= 6666,
-	.remote_mac	= {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+/**
+ * struct netconsole_target - Represents a configured netconsole target.
+ * @np:		The netpoll structure for this target.
+ */
+struct netconsole_target {
+	struct netpoll		np;
+};
+
+static struct netconsole_target default_target = {
+	.np		= {
+		.name		= "netconsole",
+		.dev_name	= "eth0",
+		.local_port	= 6665,
+		.remote_port	= 6666,
+		.remote_mac	= {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+	},
 };
 
 static void write_msg(struct console *con, const char *msg, unsigned int len)
 {
 	int frag, left;
 	unsigned long flags;
+	struct netconsole_target *nt = &default_target;
 
 	local_irq_save(flags);
 
 	for (left = len; left;) {
 		frag = min(left, MAX_PRINT_CHUNK);
-		netpoll_send_udp(&np, msg, frag);
+		netpoll_send_udp(&nt->np, msg, frag);
 		msg += frag;
 		left -= frag;
 	}
@@ -96,17 +107,18 @@ static struct console netconsole = {
 static int __init init_netconsole(void)
 {
 	int err = 0;
+	struct netconsole_target *nt = &default_target;
 
 	if (!strnlen(config, MAX_PARAM_LENGTH)) {
 		printk(KERN_INFO "netconsole: not configured, aborting\n");
 		goto out;
 	}
 
-	err = netpoll_parse_options(&np, config);
+	err = netpoll_parse_options(&nt->np, config);
 	if (err)
 		goto out;
 
-	err = netpoll_setup(&np);
+	err = netpoll_setup(&nt->np);
 	if (err)
 		goto out;
 
@@ -119,8 +131,10 @@ out:
 
 static void __exit cleanup_netconsole(void)
 {
+	struct netconsole_target *nt = &default_target;
+
 	unregister_console(&netconsole);
-	netpoll_cleanup(&np);
+	netpoll_cleanup(&nt->np);
 }
 
 module_init(init_netconsole);

  parent reply	other threads:[~2007-07-10  8:59 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-10  9:19 [RFC][PATCH v2 -mm 0/9] netconsole: Multiple targets and dynamic reconfigurability Satyam Sharma
2007-07-10  9:19 ` [PATCH v2 -mm 1/9] netconsole: Cleanups, codingstyle, prettyfication Satyam Sharma
2007-07-10  9:02   ` Matt Mackall
2007-07-13 13:40   ` KII Keiichi
2007-07-10  9:19 ` [PATCH v2 -mm 2/9] netconsole: Remove bogus check Satyam Sharma
2007-07-10  9:05   ` Matt Mackall
2007-07-13 13:41   ` KII Keiichi
2007-07-10  9:19 ` [PATCH v2 -mm 3/9] netconsole: Simplify boot/module option setup logic Satyam Sharma
2007-07-10  9:23   ` Matt Mackall
2007-07-13 13:42   ` KII Keiichi
2007-07-10  9:19 ` [PATCH v2 -mm 4/9] netconsole: Add some useful tips to documentation Satyam Sharma
2007-07-10  9:41   ` Matt Mackall
2007-07-10 12:34     ` Jesper Juhl
2007-07-10 22:10       ` Satyam Sharma
2007-07-11  4:20         ` Joel Becker
2007-07-11  6:05           ` Satyam Sharma
2007-07-11 11:56             ` Jesper Juhl
2007-07-10  9:19 ` Satyam Sharma [this message]
2007-07-13 13:46   ` [PATCH v2 -mm 5/9] netconsole: Introduce netconsole_target KII Keiichi
2007-07-10  9:19 ` [PATCH v2 -mm 6/9] netconsole: Introduce netconsole_netdev_notifier Satyam Sharma
2007-07-13 13:47   ` KII Keiichi
2007-07-10  9:19 ` [PATCH v2 -mm 7/9] netconsole: Use netif_running() in write_msg() Satyam Sharma
2007-07-13 13:48   ` KII Keiichi
2007-07-10  9:20 ` [PATCH v2 -mm 8/9] netconsole: Support multiple logging targets Satyam Sharma
2007-07-10 10:23   ` Duane Griffin
2007-07-10 22:17     ` Satyam Sharma
2007-07-11  4:29       ` Joel Becker
2007-07-11  6:24         ` Satyam Sharma
2007-07-13 13:49   ` KII Keiichi
2007-07-10  9:20 ` [PATCH v2 -mm 9/9] netconsole: Support dynamic reconfiguration using configfs Satyam Sharma
2007-07-12 10:04   ` Keiichi KII
2007-07-12 17:08     ` Satyam Sharma
2007-07-13 13:50   ` KII Keiichi
2007-07-11  9:59 ` [RFC][PATCH v2 -mm 0/9] netconsole: Multiple targets and dynamic reconfigurability Keiichi KII
2007-07-13 13:39 ` KII Keiichi
2007-07-13 17:30   ` Satyam Sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070710091946.23907.96503.sendpatchset@cselinux1.cse.iitk.ac.in \
    --to=ssatyam@cse.iitk.ac.in \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=joel.becker@oracle.com \
    --cc=k-keiichi@bx.jp.nec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®