aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netconsole.c
diff options
context:
space:
mode:
authorSatyam Sharma <satyam@infradead.org>2007-08-10 18:32:14 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:48:04 -0400
commitdf180e369cf54a8ef8440667ab1d13d452fc7215 (patch)
tree5079a4b016af25f4fb2fcac4b014af8d8d891173 /drivers/net/netconsole.c
parent8d4ef88b5df1afe097e38aef8cab2ed35ca141ea (diff)
[NET] netconsole: Introduce netconsole_target
Based upon initial work by Keiichi Kii <k-keiichi@bx.jp.nec.com>. Introduce a wrapper structure over netpoll to represent logging targets configured in netconsole. This will get extended with other members in further patches. This is done independent of the (to-be-introduced) NETCONSOLE_DYNAMIC config option so that we're 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. Signed-off-by: Satyam Sharma <satyam@infradead.org> Signed-off-by: Keiichi Kii <k-keiichi@bx.jp.nec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netconsole.c')
-rw-r--r--drivers/net/netconsole.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 75cb76139ddc..be15ca6205a8 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -62,24 +62,35 @@ static int __init option_setup(char *opt)
62__setup("netconsole=", option_setup); 62__setup("netconsole=", option_setup);
63#endif /* MODULE */ 63#endif /* MODULE */
64 64
65static struct netpoll np = { 65/**
66 .name = "netconsole", 66 * struct netconsole_target - Represents a configured netconsole target.
67 .dev_name = "eth0", 67 * @np: The netpoll structure for this target.
68 .local_port = 6665, 68 */
69 .remote_port = 6666, 69struct netconsole_target {
70 .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, 70 struct netpoll np;
71};
72
73static struct netconsole_target default_target = {
74 .np = {
75 .name = "netconsole",
76 .dev_name = "eth0",
77 .local_port = 6665,
78 .remote_port = 6666,
79 .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
80 },
71}; 81};
72 82
73static void write_msg(struct console *con, const char *msg, unsigned int len) 83static void write_msg(struct console *con, const char *msg, unsigned int len)
74{ 84{
75 int frag, left; 85 int frag, left;
76 unsigned long flags; 86 unsigned long flags;
87 struct netconsole_target *nt = &default_target;
77 88
78 if (netif_running(np.dev)) { 89 if (netif_running(nt->np.dev)) {
79 local_irq_save(flags); 90 local_irq_save(flags);
80 for (left = len; left;) { 91 for (left = len; left;) {
81 frag = min(left, MAX_PRINT_CHUNK); 92 frag = min(left, MAX_PRINT_CHUNK);
82 netpoll_send_udp(&np, msg, frag); 93 netpoll_send_udp(&nt->np, msg, frag);
83 msg += frag; 94 msg += frag;
84 left -= frag; 95 left -= frag;
85 } 96 }
@@ -96,17 +107,18 @@ static struct console netconsole = {
96static int __init init_netconsole(void) 107static int __init init_netconsole(void)
97{ 108{
98 int err = 0; 109 int err = 0;
110 struct netconsole_target *nt = &default_target;
99 111
100 if (!strnlen(config, MAX_PARAM_LENGTH)) { 112 if (!strnlen(config, MAX_PARAM_LENGTH)) {
101 printk(KERN_INFO "netconsole: not configured, aborting\n"); 113 printk(KERN_INFO "netconsole: not configured, aborting\n");
102 goto out; 114 goto out;
103 } 115 }
104 116
105 err = netpoll_parse_options(&np, config); 117 err = netpoll_parse_options(&nt->np, config);
106 if (err) 118 if (err)
107 goto out; 119 goto out;
108 120
109 err = netpoll_setup(&np); 121 err = netpoll_setup(&nt->np);
110 if (err) 122 if (err)
111 goto out; 123 goto out;
112 124
@@ -119,8 +131,10 @@ out:
119 131
120static void __exit cleanup_netconsole(void) 132static void __exit cleanup_netconsole(void)
121{ 133{
134 struct netconsole_target *nt = &default_target;
135
122 unregister_console(&netconsole); 136 unregister_console(&netconsole);
123 netpoll_cleanup(&np); 137 netpoll_cleanup(&nt->np);
124} 138}
125 139
126module_init(init_netconsole); 140module_init(init_netconsole);