diff options
author | Frank Pavlic <pavlic@de.ibm.com> | 2005-05-12 14:36:47 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-05-15 18:06:16 -0400 |
commit | 7394c928c849fe2ea5c20b6d73cbe7f220810d94 (patch) | |
tree | 1d126b50a776aa79b2d93878bf814bf7286dcc1d /drivers/s390/net/ctcmain.c | |
parent | 7f81947b46c3efacc084ac5033f3fed702e46532 (diff) |
[PATCH] s390: ctc code cleanup
[patch 5/10] s390: ctc code cleanup.
From: Peter Tiedemann <ptiedem@de.ibm.com>
ctc network driver changes:
- Some code cleanup.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/net/ctcmain.c')
-rw-r--r-- | drivers/s390/net/ctcmain.c | 616 |
1 files changed, 206 insertions, 410 deletions
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c index 7266bf5ea659..ff3e95e07e89 100644 --- a/drivers/s390/net/ctcmain.c +++ b/drivers/s390/net/ctcmain.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: ctcmain.c,v 1.72 2005/03/17 10:51:52 ptiedem Exp $ | 2 | * $Id: ctcmain.c,v 1.74 2005/03/24 09:04:17 mschwide Exp $ |
3 | * | 3 | * |
4 | * CTC / ESCON network driver | 4 | * CTC / ESCON network driver |
5 | * | 5 | * |
@@ -37,12 +37,11 @@ | |||
37 | * along with this program; if not, write to the Free Software | 37 | * along with this program; if not, write to the Free Software |
38 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 38 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
39 | * | 39 | * |
40 | * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.72 $ | 40 | * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.74 $ |
41 | * | 41 | * |
42 | */ | 42 | */ |
43 | 43 | ||
44 | #undef DEBUG | 44 | #undef DEBUG |
45 | |||
46 | #include <linux/module.h> | 45 | #include <linux/module.h> |
47 | #include <linux/init.h> | 46 | #include <linux/init.h> |
48 | #include <linux/kernel.h> | 47 | #include <linux/kernel.h> |
@@ -74,288 +73,13 @@ | |||
74 | #include "ctctty.h" | 73 | #include "ctctty.h" |
75 | #include "fsm.h" | 74 | #include "fsm.h" |
76 | #include "cu3088.h" | 75 | #include "cu3088.h" |
76 | |||
77 | #include "ctcdbug.h" | 77 | #include "ctcdbug.h" |
78 | #include "ctcmain.h" | ||
78 | 79 | ||
79 | MODULE_AUTHOR("(C) 2000 IBM Corp. by Fritz Elfert (felfert@millenux.com)"); | 80 | MODULE_AUTHOR("(C) 2000 IBM Corp. by Fritz Elfert (felfert@millenux.com)"); |
80 | MODULE_DESCRIPTION("Linux for S/390 CTC/Escon Driver"); | 81 | MODULE_DESCRIPTION("Linux for S/390 CTC/Escon Driver"); |
81 | MODULE_LICENSE("GPL"); | 82 | MODULE_LICENSE("GPL"); |
82 | |||
83 | /** | ||
84 | * CCW commands, used in this driver. | ||
85 | */ | ||
86 | #define CCW_CMD_WRITE 0x01 | ||
87 | #define CCW_CMD_READ 0x02 | ||
88 | #define CCW_CMD_SET_EXTENDED 0xc3 | ||
89 | #define CCW_CMD_PREPARE 0xe3 | ||
90 | |||
91 | #define CTC_PROTO_S390 0 | ||
92 | #define CTC_PROTO_LINUX 1 | ||
93 | #define CTC_PROTO_LINUX_TTY 2 | ||
94 | #define CTC_PROTO_OS390 3 | ||
95 | #define CTC_PROTO_MAX 3 | ||
96 | |||
97 | #define CTC_BUFSIZE_LIMIT 65535 | ||
98 | #define CTC_BUFSIZE_DEFAULT 32768 | ||
99 | |||
100 | #define CTC_TIMEOUT_5SEC 5000 | ||
101 | |||
102 | #define CTC_INITIAL_BLOCKLEN 2 | ||
103 | |||
104 | #define READ 0 | ||
105 | #define WRITE 1 | ||
106 | |||
107 | #define CTC_ID_SIZE BUS_ID_SIZE+3 | ||
108 | |||
109 | |||
110 | struct ctc_profile { | ||
111 | unsigned long maxmulti; | ||
112 | unsigned long maxcqueue; | ||
113 | unsigned long doios_single; | ||
114 | unsigned long doios_multi; | ||
115 | unsigned long txlen; | ||
116 | unsigned long tx_time; | ||
117 | struct timespec send_stamp; | ||
118 | }; | ||
119 | |||
120 | /** | ||
121 | * Definition of one channel | ||
122 | */ | ||
123 | struct channel { | ||
124 | |||
125 | /** | ||
126 | * Pointer to next channel in list. | ||
127 | */ | ||
128 | struct channel *next; | ||
129 | char id[CTC_ID_SIZE]; | ||
130 | struct ccw_device *cdev; | ||
131 | |||
132 | /** | ||
133 | * Type of this channel. | ||
134 | * CTC/A or Escon for valid channels. | ||
135 | */ | ||
136 | enum channel_types type; | ||
137 | |||
138 | /** | ||
139 | * Misc. flags. See CHANNEL_FLAGS_... below | ||
140 | */ | ||
141 | __u32 flags; | ||
142 | |||
143 | /** | ||
144 | * The protocol of this channel | ||
145 | */ | ||
146 | __u16 protocol; | ||
147 | |||
148 | /** | ||
149 | * I/O and irq related stuff | ||
150 | */ | ||
151 | struct ccw1 *ccw; | ||
152 | struct irb *irb; | ||
153 | |||
154 | /** | ||
155 | * RX/TX buffer size | ||
156 | */ | ||
157 | int max_bufsize; | ||
158 | |||
159 | /** | ||
160 | * Transmit/Receive buffer. | ||
161 | */ | ||
162 | struct sk_buff *trans_skb; | ||
163 | |||
164 | /** | ||
165 | * Universal I/O queue. | ||
166 | */ | ||
167 | struct sk_buff_head io_queue; | ||
168 | |||
169 | /** | ||
170 | * TX queue for collecting skb's during busy. | ||
171 | */ | ||
172 | struct sk_buff_head collect_queue; | ||
173 | |||
174 | /** | ||
175 | * Amount of data in collect_queue. | ||
176 | */ | ||
177 | int collect_len; | ||
178 | |||
179 | /** | ||
180 | * spinlock for collect_queue and collect_len | ||
181 | */ | ||
182 | spinlock_t collect_lock; | ||
183 | |||
184 | /** | ||
185 | * Timer for detecting unresposive | ||
186 | * I/O operations. | ||
187 | */ | ||
188 | fsm_timer timer; | ||
189 | |||
190 | /** | ||
191 | * Retry counter for misc. operations. | ||
192 | */ | ||
193 | int retry; | ||
194 | |||
195 | /** | ||
196 | * The finite state machine of this channel | ||
197 | */ | ||
198 | fsm_instance *fsm; | ||
199 | |||
200 | /** | ||
201 | * The corresponding net_device this channel | ||
202 | * belongs to. | ||
203 | */ | ||
204 | struct net_device *netdev; | ||
205 | |||
206 | struct ctc_profile prof; | ||
207 | |||
208 | unsigned char *trans_skb_data; | ||
209 | |||
210 | __u16 logflags; | ||
211 | }; | ||
212 | |||
213 | #define CHANNEL_FLAGS_READ 0 | ||
214 | #define CHANNEL_FLAGS_WRITE 1 | ||
215 | #define CHANNEL_FLAGS_INUSE 2 | ||
216 | #define CHANNEL_FLAGS_BUFSIZE_CHANGED 4 | ||
217 | #define CHANNEL_FLAGS_FAILED 8 | ||
218 | #define CHANNEL_FLAGS_WAITIRQ 16 | ||
219 | #define CHANNEL_FLAGS_RWMASK 1 | ||
220 | #define CHANNEL_DIRECTION(f) (f & CHANNEL_FLAGS_RWMASK) | ||
221 | |||
222 | #define LOG_FLAG_ILLEGALPKT 1 | ||
223 | #define LOG_FLAG_ILLEGALSIZE 2 | ||
224 | #define LOG_FLAG_OVERRUN 4 | ||
225 | #define LOG_FLAG_NOMEM 8 | ||
226 | |||
227 | #define CTC_LOGLEVEL_INFO 1 | ||
228 | #define CTC_LOGLEVEL_NOTICE 2 | ||
229 | #define CTC_LOGLEVEL_WARN 4 | ||
230 | #define CTC_LOGLEVEL_EMERG 8 | ||
231 | #define CTC_LOGLEVEL_ERR 16 | ||
232 | #define CTC_LOGLEVEL_DEBUG 32 | ||
233 | #define CTC_LOGLEVEL_CRIT 64 | ||
234 | |||
235 | #define CTC_LOGLEVEL_DEFAULT \ | ||
236 | (CTC_LOGLEVEL_INFO | CTC_LOGLEVEL_NOTICE | CTC_LOGLEVEL_WARN | CTC_LOGLEVEL_CRIT) | ||
237 | |||
238 | #define CTC_LOGLEVEL_MAX ((CTC_LOGLEVEL_CRIT<<1)-1) | ||
239 | |||
240 | static int loglevel = CTC_LOGLEVEL_DEFAULT; | ||
241 | |||
242 | #define ctc_pr_debug(fmt, arg...) \ | ||
243 | do { if (loglevel & CTC_LOGLEVEL_DEBUG) printk(KERN_DEBUG fmt,##arg); } while (0) | ||
244 | |||
245 | #define ctc_pr_info(fmt, arg...) \ | ||
246 | do { if (loglevel & CTC_LOGLEVEL_INFO) printk(KERN_INFO fmt,##arg); } while (0) | ||
247 | |||
248 | #define ctc_pr_notice(fmt, arg...) \ | ||
249 | do { if (loglevel & CTC_LOGLEVEL_NOTICE) printk(KERN_NOTICE fmt,##arg); } while (0) | ||
250 | |||
251 | #define ctc_pr_warn(fmt, arg...) \ | ||
252 | do { if (loglevel & CTC_LOGLEVEL_WARN) printk(KERN_WARNING fmt,##arg); } while (0) | ||
253 | |||
254 | #define ctc_pr_emerg(fmt, arg...) \ | ||
255 | do { if (loglevel & CTC_LOGLEVEL_EMERG) printk(KERN_EMERG fmt,##arg); } while (0) | ||
256 | |||
257 | #define ctc_pr_err(fmt, arg...) \ | ||
258 | do { if (loglevel & CTC_LOGLEVEL_ERR) printk(KERN_ERR fmt,##arg); } while (0) | ||
259 | |||
260 | #define ctc_pr_crit(fmt, arg...) \ | ||
261 | do { if (loglevel & CTC_LOGLEVEL_CRIT) printk(KERN_CRIT fmt,##arg); } while (0) | ||
262 | |||
263 | /** | ||
264 | * Linked list of all detected channels. | ||
265 | */ | ||
266 | static struct channel *channels = NULL; | ||
267 | |||
268 | struct ctc_priv { | ||
269 | struct net_device_stats stats; | ||
270 | unsigned long tbusy; | ||
271 | /** | ||
272 | * The finite state machine of this interface. | ||
273 | */ | ||
274 | fsm_instance *fsm; | ||
275 | /** | ||
276 | * The protocol of this device | ||
277 | */ | ||
278 | __u16 protocol; | ||
279 | /** | ||
280 | * Timer for restarting after I/O Errors | ||
281 | */ | ||
282 | fsm_timer restart_timer; | ||
283 | |||
284 | int buffer_size; | ||
285 | |||
286 | struct channel *channel[2]; | ||
287 | }; | ||
288 | |||
289 | /** | ||
290 | * Definition of our link level header. | ||
291 | */ | ||
292 | struct ll_header { | ||
293 | __u16 length; | ||
294 | __u16 type; | ||
295 | __u16 unused; | ||
296 | }; | ||
297 | #define LL_HEADER_LENGTH (sizeof(struct ll_header)) | ||
298 | |||
299 | /** | ||
300 | * Compatibility macros for busy handling | ||
301 | * of network devices. | ||
302 | */ | ||
303 | static __inline__ void | ||
304 | ctc_clear_busy(struct net_device * dev) | ||
305 | { | ||
306 | clear_bit(0, &(((struct ctc_priv *) dev->priv)->tbusy)); | ||
307 | if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY) | ||
308 | netif_wake_queue(dev); | ||
309 | } | ||
310 | |||
311 | static __inline__ int | ||
312 | ctc_test_and_set_busy(struct net_device * dev) | ||
313 | { | ||
314 | if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY) | ||
315 | netif_stop_queue(dev); | ||
316 | return test_and_set_bit(0, &((struct ctc_priv *) dev->priv)->tbusy); | ||
317 | } | ||
318 | |||
319 | /** | ||
320 | * Print Banner. | ||
321 | */ | ||
322 | static void | ||
323 | print_banner(void) | ||
324 | { | ||
325 | static int printed = 0; | ||
326 | char vbuf[] = "$Revision: 1.72 $"; | ||
327 | char *version = vbuf; | ||
328 | |||
329 | if (printed) | ||
330 | return; | ||
331 | if ((version = strchr(version, ':'))) { | ||
332 | char *p = strchr(version + 1, '$'); | ||
333 | if (p) | ||
334 | *p = '\0'; | ||
335 | } else | ||
336 | version = " ??? "; | ||
337 | printk(KERN_INFO "CTC driver Version%s" | ||
338 | #ifdef DEBUG | ||
339 | " (DEBUG-VERSION, " __DATE__ __TIME__ ")" | ||
340 | #endif | ||
341 | " initialized\n", version); | ||
342 | printed = 1; | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Return type of a detected device. | ||
347 | */ | ||
348 | static enum channel_types | ||
349 | get_channel_type(struct ccw_device_id *id) | ||
350 | { | ||
351 | enum channel_types type = (enum channel_types) id->driver_info; | ||
352 | |||
353 | if (type == channel_type_ficon) | ||
354 | type = channel_type_escon; | ||
355 | |||
356 | return type; | ||
357 | } | ||
358 | |||
359 | /** | 83 | /** |
360 | * States of the interface statemachine. | 84 | * States of the interface statemachine. |
361 | */ | 85 | */ |
@@ -371,7 +95,7 @@ enum dev_states { | |||
371 | /** | 95 | /** |
372 | * MUST be always the last element!! | 96 | * MUST be always the last element!! |
373 | */ | 97 | */ |
374 | NR_DEV_STATES | 98 | CTC_NR_DEV_STATES |
375 | }; | 99 | }; |
376 | 100 | ||
377 | static const char *dev_state_names[] = { | 101 | static const char *dev_state_names[] = { |
@@ -399,7 +123,7 @@ enum dev_events { | |||
399 | /** | 123 | /** |
400 | * MUST be always the last element!! | 124 | * MUST be always the last element!! |
401 | */ | 125 | */ |
402 | NR_DEV_EVENTS | 126 | CTC_NR_DEV_EVENTS |
403 | }; | 127 | }; |
404 | 128 | ||
405 | static const char *dev_event_names[] = { | 129 | static const char *dev_event_names[] = { |
@@ -476,40 +200,6 @@ enum ch_events { | |||
476 | NR_CH_EVENTS, | 200 | NR_CH_EVENTS, |
477 | }; | 201 | }; |
478 | 202 | ||
479 | static const char *ch_event_names[] = { | ||
480 | "ccw_device success", | ||
481 | "ccw_device busy", | ||
482 | "ccw_device enodev", | ||
483 | "ccw_device ioerr", | ||
484 | "ccw_device unknown", | ||
485 | |||
486 | "Status ATTN & BUSY", | ||
487 | "Status ATTN", | ||
488 | "Status BUSY", | ||
489 | |||
490 | "Unit check remote reset", | ||
491 | "Unit check remote system reset", | ||
492 | "Unit check TX timeout", | ||
493 | "Unit check TX parity", | ||
494 | "Unit check Hardware failure", | ||
495 | "Unit check RX parity", | ||
496 | "Unit check ZERO", | ||
497 | "Unit check Unknown", | ||
498 | |||
499 | "SubChannel check Unknown", | ||
500 | |||
501 | "Machine check failure", | ||
502 | "Machine check operational", | ||
503 | |||
504 | "IRQ normal", | ||
505 | "IRQ final", | ||
506 | |||
507 | "Timer", | ||
508 | |||
509 | "Start", | ||
510 | "Stop", | ||
511 | }; | ||
512 | |||
513 | /** | 203 | /** |
514 | * States of the channel statemachine. | 204 | * States of the channel statemachine. |
515 | */ | 205 | */ |
@@ -545,6 +235,87 @@ enum ch_states { | |||
545 | NR_CH_STATES, | 235 | NR_CH_STATES, |
546 | }; | 236 | }; |
547 | 237 | ||
238 | static int loglevel = CTC_LOGLEVEL_DEFAULT; | ||
239 | |||
240 | /** | ||
241 | * Linked list of all detected channels. | ||
242 | */ | ||
243 | static struct channel *channels = NULL; | ||
244 | |||
245 | /** | ||
246 | * Print Banner. | ||
247 | */ | ||
248 | static void | ||
249 | print_banner(void) | ||
250 | { | ||
251 | static int printed = 0; | ||
252 | char vbuf[] = "$Revision: 1.74 $"; | ||
253 | char *version = vbuf; | ||
254 | |||
255 | if (printed) | ||
256 | return; | ||
257 | if ((version = strchr(version, ':'))) { | ||
258 | char *p = strchr(version + 1, '$'); | ||
259 | if (p) | ||
260 | *p = '\0'; | ||
261 | } else | ||
262 | version = " ??? "; | ||
263 | printk(KERN_INFO "CTC driver Version%s" | ||
264 | #ifdef DEBUG | ||
265 | " (DEBUG-VERSION, " __DATE__ __TIME__ ")" | ||
266 | #endif | ||
267 | " initialized\n", version); | ||
268 | printed = 1; | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * Return type of a detected device. | ||
273 | */ | ||
274 | static enum channel_types | ||
275 | get_channel_type(struct ccw_device_id *id) | ||
276 | { | ||
277 | enum channel_types type = (enum channel_types) id->driver_info; | ||
278 | |||
279 | if (type == channel_type_ficon) | ||
280 | type = channel_type_escon; | ||
281 | |||
282 | return type; | ||
283 | } | ||
284 | |||
285 | static const char *ch_event_names[] = { | ||
286 | "ccw_device success", | ||
287 | "ccw_device busy", | ||
288 | "ccw_device enodev", | ||
289 | "ccw_device ioerr", | ||
290 | "ccw_device unknown", | ||
291 | |||
292 | "Status ATTN & BUSY", | ||
293 | "Status ATTN", | ||
294 | "Status BUSY", | ||
295 | |||
296 | "Unit check remote reset", | ||
297 | "Unit check remote system reset", | ||
298 | "Unit check TX timeout", | ||
299 | "Unit check TX parity", | ||
300 | "Unit check Hardware failure", | ||
301 | "Unit check RX parity", | ||
302 | "Unit check ZERO", | ||
303 | "Unit check Unknown", | ||
304 | |||
305 | "SubChannel check Unknown", | ||
306 | |||
307 | "Machine check failure", | ||
308 | "Machine check operational", | ||
309 | |||
310 | "IRQ normal", | ||
311 | "IRQ final", | ||
312 | |||
313 | "Timer", | ||
314 | |||
315 | "Start", | ||
316 | "Stop", | ||
317 | }; | ||
318 | |||
548 | static const char *ch_state_names[] = { | 319 | static const char *ch_state_names[] = { |
549 | "Idle", | 320 | "Idle", |
550 | "Stopped", | 321 | "Stopped", |
@@ -1934,7 +1705,6 @@ add_channel(struct ccw_device *cdev, enum channel_types type) | |||
1934 | ch->cdev = cdev; | 1705 | ch->cdev = cdev; |
1935 | snprintf(ch->id, CTC_ID_SIZE, "ch-%s", cdev->dev.bus_id); | 1706 | snprintf(ch->id, CTC_ID_SIZE, "ch-%s", cdev->dev.bus_id); |
1936 | ch->type = type; | 1707 | ch->type = type; |
1937 | loglevel = CTC_LOGLEVEL_DEFAULT; | ||
1938 | ch->fsm = init_fsm(ch->id, ch_state_names, | 1708 | ch->fsm = init_fsm(ch->id, ch_state_names, |
1939 | ch_event_names, NR_CH_STATES, NR_CH_EVENTS, | 1709 | ch_event_names, NR_CH_STATES, NR_CH_EVENTS, |
1940 | ch_fsm, CH_FSM_LEN, GFP_KERNEL); | 1710 | ch_fsm, CH_FSM_LEN, GFP_KERNEL); |
@@ -2697,6 +2467,7 @@ ctc_stats(struct net_device * dev) | |||
2697 | /* | 2467 | /* |
2698 | * sysfs attributes | 2468 | * sysfs attributes |
2699 | */ | 2469 | */ |
2470 | |||
2700 | static ssize_t | 2471 | static ssize_t |
2701 | buffer_show(struct device *dev, char *buf) | 2472 | buffer_show(struct device *dev, char *buf) |
2702 | { | 2473 | { |
@@ -2715,57 +2486,61 @@ buffer_write(struct device *dev, const char *buf, size_t count) | |||
2715 | struct ctc_priv *priv; | 2486 | struct ctc_priv *priv; |
2716 | struct net_device *ndev; | 2487 | struct net_device *ndev; |
2717 | int bs1; | 2488 | int bs1; |
2489 | char buffer[16]; | ||
2718 | 2490 | ||
2719 | DBF_TEXT(trace, 3, __FUNCTION__); | 2491 | DBF_TEXT(trace, 3, __FUNCTION__); |
2492 | DBF_TEXT(trace, 3, buf); | ||
2720 | priv = dev->driver_data; | 2493 | priv = dev->driver_data; |
2721 | if (!priv) | 2494 | if (!priv) { |
2495 | DBF_TEXT(trace, 3, "bfnopriv"); | ||
2722 | return -ENODEV; | 2496 | return -ENODEV; |
2497 | } | ||
2498 | |||
2499 | sscanf(buf, "%u", &bs1); | ||
2500 | if (bs1 > CTC_BUFSIZE_LIMIT) | ||
2501 | goto einval; | ||
2502 | if (bs1 < (576 + LL_HEADER_LENGTH + 2)) | ||
2503 | goto einval; | ||
2504 | priv->buffer_size = bs1; // just to overwrite the default | ||
2505 | |||
2723 | ndev = priv->channel[READ]->netdev; | 2506 | ndev = priv->channel[READ]->netdev; |
2724 | if (!ndev) | 2507 | if (!ndev) { |
2508 | DBF_TEXT(trace, 3, "bfnondev"); | ||
2725 | return -ENODEV; | 2509 | return -ENODEV; |
2726 | sscanf(buf, "%u", &bs1); | 2510 | } |
2727 | 2511 | ||
2728 | if (bs1 > CTC_BUFSIZE_LIMIT) | ||
2729 | return -EINVAL; | ||
2730 | if ((ndev->flags & IFF_RUNNING) && | 2512 | if ((ndev->flags & IFF_RUNNING) && |
2731 | (bs1 < (ndev->mtu + LL_HEADER_LENGTH + 2))) | 2513 | (bs1 < (ndev->mtu + LL_HEADER_LENGTH + 2))) |
2732 | return -EINVAL; | 2514 | goto einval; |
2733 | if (bs1 < (576 + LL_HEADER_LENGTH + 2)) | ||
2734 | return -EINVAL; | ||
2735 | 2515 | ||
2736 | priv->buffer_size = bs1; | 2516 | priv->channel[READ]->max_bufsize = bs1; |
2737 | priv->channel[READ]->max_bufsize = | 2517 | priv->channel[WRITE]->max_bufsize = bs1; |
2738 | priv->channel[WRITE]->max_bufsize = bs1; | ||
2739 | if (!(ndev->flags & IFF_RUNNING)) | 2518 | if (!(ndev->flags & IFF_RUNNING)) |
2740 | ndev->mtu = bs1 - LL_HEADER_LENGTH - 2; | 2519 | ndev->mtu = bs1 - LL_HEADER_LENGTH - 2; |
2741 | priv->channel[READ]->flags |= CHANNEL_FLAGS_BUFSIZE_CHANGED; | 2520 | priv->channel[READ]->flags |= CHANNEL_FLAGS_BUFSIZE_CHANGED; |
2742 | priv->channel[WRITE]->flags |= CHANNEL_FLAGS_BUFSIZE_CHANGED; | 2521 | priv->channel[WRITE]->flags |= CHANNEL_FLAGS_BUFSIZE_CHANGED; |
2743 | 2522 | ||
2523 | sprintf(buffer, "%d",priv->buffer_size); | ||
2524 | DBF_TEXT(trace, 3, buffer); | ||
2744 | return count; | 2525 | return count; |
2745 | 2526 | ||
2527 | einval: | ||
2528 | DBF_TEXT(trace, 3, "buff_err"); | ||
2529 | return -EINVAL; | ||
2746 | } | 2530 | } |
2747 | 2531 | ||
2748 | static ssize_t | 2532 | static ssize_t |
2749 | loglevel_show(struct device *dev, char *buf) | 2533 | loglevel_show(struct device *dev, char *buf) |
2750 | { | 2534 | { |
2751 | struct ctc_priv *priv; | ||
2752 | |||
2753 | priv = dev->driver_data; | ||
2754 | if (!priv) | ||
2755 | return -ENODEV; | ||
2756 | return sprintf(buf, "%d\n", loglevel); | 2535 | return sprintf(buf, "%d\n", loglevel); |
2757 | } | 2536 | } |
2758 | 2537 | ||
2759 | static ssize_t | 2538 | static ssize_t |
2760 | loglevel_write(struct device *dev, const char *buf, size_t count) | 2539 | loglevel_write(struct device *dev, const char *buf, size_t count) |
2761 | { | 2540 | { |
2762 | struct ctc_priv *priv; | ||
2763 | int ll1; | 2541 | int ll1; |
2764 | 2542 | ||
2765 | DBF_TEXT(trace, 5, __FUNCTION__); | 2543 | DBF_TEXT(trace, 5, __FUNCTION__); |
2766 | priv = dev->driver_data; | ||
2767 | if (!priv) | ||
2768 | return -ENODEV; | ||
2769 | sscanf(buf, "%i", &ll1); | 2544 | sscanf(buf, "%i", &ll1); |
2770 | 2545 | ||
2771 | if ((ll1 > CTC_LOGLEVEL_MAX) || (ll1 < 0)) | 2546 | if ((ll1 > CTC_LOGLEVEL_MAX) || (ll1 < 0)) |
@@ -2835,27 +2610,6 @@ stats_write(struct device *dev, const char *buf, size_t count) | |||
2835 | return count; | 2610 | return count; |
2836 | } | 2611 | } |
2837 | 2612 | ||
2838 | static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write); | ||
2839 | static DEVICE_ATTR(loglevel, 0644, loglevel_show, loglevel_write); | ||
2840 | static DEVICE_ATTR(stats, 0644, stats_show, stats_write); | ||
2841 | |||
2842 | static int | ||
2843 | ctc_add_attributes(struct device *dev) | ||
2844 | { | ||
2845 | // device_create_file(dev, &dev_attr_buffer); | ||
2846 | device_create_file(dev, &dev_attr_loglevel); | ||
2847 | device_create_file(dev, &dev_attr_stats); | ||
2848 | return 0; | ||
2849 | } | ||
2850 | |||
2851 | static void | ||
2852 | ctc_remove_attributes(struct device *dev) | ||
2853 | { | ||
2854 | device_remove_file(dev, &dev_attr_stats); | ||
2855 | device_remove_file(dev, &dev_attr_loglevel); | ||
2856 | // device_remove_file(dev, &dev_attr_buffer); | ||
2857 | } | ||
2858 | |||
2859 | 2613 | ||
2860 | static void | 2614 | static void |
2861 | ctc_netdev_unregister(struct net_device * dev) | 2615 | ctc_netdev_unregister(struct net_device * dev) |
@@ -2899,52 +2653,6 @@ ctc_free_netdevice(struct net_device * dev, int free_dev) | |||
2899 | #endif | 2653 | #endif |
2900 | } | 2654 | } |
2901 | 2655 | ||
2902 | /** | ||
2903 | * Initialize everything of the net device except the name and the | ||
2904 | * channel structs. | ||
2905 | */ | ||
2906 | static struct net_device * | ||
2907 | ctc_init_netdevice(struct net_device * dev, int alloc_device, | ||
2908 | struct ctc_priv *privptr) | ||
2909 | { | ||
2910 | if (!privptr) | ||
2911 | return NULL; | ||
2912 | |||
2913 | DBF_TEXT(setup, 3, __FUNCTION__); | ||
2914 | if (alloc_device) { | ||
2915 | dev = kmalloc(sizeof (struct net_device), GFP_KERNEL); | ||
2916 | if (!dev) | ||
2917 | return NULL; | ||
2918 | memset(dev, 0, sizeof (struct net_device)); | ||
2919 | } | ||
2920 | |||
2921 | dev->priv = privptr; | ||
2922 | privptr->fsm = init_fsm("ctcdev", dev_state_names, | ||
2923 | dev_event_names, NR_DEV_STATES, NR_DEV_EVENTS, | ||
2924 | dev_fsm, DEV_FSM_LEN, GFP_KERNEL); | ||
2925 | if (privptr->fsm == NULL) { | ||
2926 | if (alloc_device) | ||
2927 | kfree(dev); | ||
2928 | return NULL; | ||
2929 | } | ||
2930 | fsm_newstate(privptr->fsm, DEV_STATE_STOPPED); | ||
2931 | fsm_settimer(privptr->fsm, &privptr->restart_timer); | ||
2932 | if (dev->mtu == 0) | ||
2933 | dev->mtu = CTC_BUFSIZE_DEFAULT - LL_HEADER_LENGTH - 2; | ||
2934 | dev->hard_start_xmit = ctc_tx; | ||
2935 | dev->open = ctc_open; | ||
2936 | dev->stop = ctc_close; | ||
2937 | dev->get_stats = ctc_stats; | ||
2938 | dev->change_mtu = ctc_change_mtu; | ||
2939 | dev->hard_header_len = LL_HEADER_LENGTH + 2; | ||
2940 | dev->addr_len = 0; | ||
2941 | dev->type = ARPHRD_SLIP; | ||
2942 | dev->tx_queue_len = 100; | ||
2943 | dev->flags = IFF_POINTOPOINT | IFF_NOARP; | ||
2944 | SET_MODULE_OWNER(dev); | ||
2945 | return dev; | ||
2946 | } | ||
2947 | |||
2948 | static ssize_t | 2656 | static ssize_t |
2949 | ctc_proto_show(struct device *dev, char *buf) | 2657 | ctc_proto_show(struct device *dev, char *buf) |
2950 | { | 2658 | { |
@@ -2977,7 +2685,6 @@ ctc_proto_store(struct device *dev, const char *buf, size_t count) | |||
2977 | return count; | 2685 | return count; |
2978 | } | 2686 | } |
2979 | 2687 | ||
2980 | static DEVICE_ATTR(protocol, 0644, ctc_proto_show, ctc_proto_store); | ||
2981 | 2688 | ||
2982 | static ssize_t | 2689 | static ssize_t |
2983 | ctc_type_show(struct device *dev, char *buf) | 2690 | ctc_type_show(struct device *dev, char *buf) |
@@ -2991,8 +2698,13 @@ ctc_type_show(struct device *dev, char *buf) | |||
2991 | return sprintf(buf, "%s\n", cu3088_type[cgdev->cdev[0]->id.driver_info]); | 2698 | return sprintf(buf, "%s\n", cu3088_type[cgdev->cdev[0]->id.driver_info]); |
2992 | } | 2699 | } |
2993 | 2700 | ||
2701 | static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write); | ||
2702 | static DEVICE_ATTR(protocol, 0644, ctc_proto_show, ctc_proto_store); | ||
2994 | static DEVICE_ATTR(type, 0444, ctc_type_show, NULL); | 2703 | static DEVICE_ATTR(type, 0444, ctc_type_show, NULL); |
2995 | 2704 | ||
2705 | static DEVICE_ATTR(loglevel, 0644, loglevel_show, loglevel_write); | ||
2706 | static DEVICE_ATTR(stats, 0644, stats_show, stats_write); | ||
2707 | |||
2996 | static struct attribute *ctc_attr[] = { | 2708 | static struct attribute *ctc_attr[] = { |
2997 | &dev_attr_protocol.attr, | 2709 | &dev_attr_protocol.attr, |
2998 | &dev_attr_type.attr, | 2710 | &dev_attr_type.attr, |
@@ -3005,6 +2717,21 @@ static struct attribute_group ctc_attr_group = { | |||
3005 | }; | 2717 | }; |
3006 | 2718 | ||
3007 | static int | 2719 | static int |
2720 | ctc_add_attributes(struct device *dev) | ||
2721 | { | ||
2722 | device_create_file(dev, &dev_attr_loglevel); | ||
2723 | device_create_file(dev, &dev_attr_stats); | ||
2724 | return 0; | ||
2725 | } | ||
2726 | |||
2727 | static void | ||
2728 | ctc_remove_attributes(struct device *dev) | ||
2729 | { | ||
2730 | device_remove_file(dev, &dev_attr_stats); | ||
2731 | device_remove_file(dev, &dev_attr_loglevel); | ||
2732 | } | ||
2733 | |||
2734 | static int | ||
3008 | ctc_add_files(struct device *dev) | 2735 | ctc_add_files(struct device *dev) |
3009 | { | 2736 | { |
3010 | pr_debug("%s() called\n", __FUNCTION__); | 2737 | pr_debug("%s() called\n", __FUNCTION__); |
@@ -3028,15 +2755,15 @@ ctc_remove_files(struct device *dev) | |||
3028 | * | 2755 | * |
3029 | * @returns 0 on success, !0 on failure. | 2756 | * @returns 0 on success, !0 on failure. |
3030 | */ | 2757 | */ |
3031 | |||
3032 | static int | 2758 | static int |
3033 | ctc_probe_device(struct ccwgroup_device *cgdev) | 2759 | ctc_probe_device(struct ccwgroup_device *cgdev) |
3034 | { | 2760 | { |
3035 | struct ctc_priv *priv; | 2761 | struct ctc_priv *priv; |
3036 | int rc; | 2762 | int rc; |
2763 | char buffer[16]; | ||
3037 | 2764 | ||
3038 | pr_debug("%s() called\n", __FUNCTION__); | 2765 | pr_debug("%s() called\n", __FUNCTION__); |
3039 | DBF_TEXT(trace, 3, __FUNCTION__); | 2766 | DBF_TEXT(setup, 3, __FUNCTION__); |
3040 | 2767 | ||
3041 | if (!get_device(&cgdev->dev)) | 2768 | if (!get_device(&cgdev->dev)) |
3042 | return -ENODEV; | 2769 | return -ENODEV; |
@@ -3060,10 +2787,70 @@ ctc_probe_device(struct ccwgroup_device *cgdev) | |||
3060 | cgdev->cdev[1]->handler = ctc_irq_handler; | 2787 | cgdev->cdev[1]->handler = ctc_irq_handler; |
3061 | cgdev->dev.driver_data = priv; | 2788 | cgdev->dev.driver_data = priv; |
3062 | 2789 | ||
2790 | sprintf(buffer, "%p", priv); | ||
2791 | DBF_TEXT(data, 3, buffer); | ||
2792 | |||
2793 | sprintf(buffer, "%u", (unsigned int)sizeof(struct ctc_priv)); | ||
2794 | DBF_TEXT(data, 3, buffer); | ||
2795 | |||
2796 | sprintf(buffer, "%p", &channels); | ||
2797 | DBF_TEXT(data, 3, buffer); | ||
2798 | |||
2799 | sprintf(buffer, "%u", (unsigned int)sizeof(struct channel)); | ||
2800 | DBF_TEXT(data, 3, buffer); | ||
2801 | |||
3063 | return 0; | 2802 | return 0; |
3064 | } | 2803 | } |
3065 | 2804 | ||
3066 | /** | 2805 | /** |
2806 | * Initialize everything of the net device except the name and the | ||
2807 | * channel structs. | ||
2808 | */ | ||
2809 | static struct net_device * | ||
2810 | ctc_init_netdevice(struct net_device * dev, int alloc_device, | ||
2811 | struct ctc_priv *privptr) | ||
2812 | { | ||
2813 | if (!privptr) | ||
2814 | return NULL; | ||
2815 | |||
2816 | DBF_TEXT(setup, 3, __FUNCTION__); | ||
2817 | |||
2818 | if (alloc_device) { | ||
2819 | dev = kmalloc(sizeof (struct net_device), GFP_KERNEL); | ||
2820 | if (!dev) | ||
2821 | return NULL; | ||
2822 | memset(dev, 0, sizeof (struct net_device)); | ||
2823 | } | ||
2824 | |||
2825 | dev->priv = privptr; | ||
2826 | privptr->fsm = init_fsm("ctcdev", dev_state_names, | ||
2827 | dev_event_names, CTC_NR_DEV_STATES, CTC_NR_DEV_EVENTS, | ||
2828 | dev_fsm, DEV_FSM_LEN, GFP_KERNEL); | ||
2829 | if (privptr->fsm == NULL) { | ||
2830 | if (alloc_device) | ||
2831 | kfree(dev); | ||
2832 | return NULL; | ||
2833 | } | ||
2834 | fsm_newstate(privptr->fsm, DEV_STATE_STOPPED); | ||
2835 | fsm_settimer(privptr->fsm, &privptr->restart_timer); | ||
2836 | if (dev->mtu == 0) | ||
2837 | dev->mtu = CTC_BUFSIZE_DEFAULT - LL_HEADER_LENGTH - 2; | ||
2838 | dev->hard_start_xmit = ctc_tx; | ||
2839 | dev->open = ctc_open; | ||
2840 | dev->stop = ctc_close; | ||
2841 | dev->get_stats = ctc_stats; | ||
2842 | dev->change_mtu = ctc_change_mtu; | ||
2843 | dev->hard_header_len = LL_HEADER_LENGTH + 2; | ||
2844 | dev->addr_len = 0; | ||
2845 | dev->type = ARPHRD_SLIP; | ||
2846 | dev->tx_queue_len = 100; | ||
2847 | dev->flags = IFF_POINTOPOINT | IFF_NOARP; | ||
2848 | SET_MODULE_OWNER(dev); | ||
2849 | return dev; | ||
2850 | } | ||
2851 | |||
2852 | |||
2853 | /** | ||
3067 | * | 2854 | * |
3068 | * Setup an interface. | 2855 | * Setup an interface. |
3069 | * | 2856 | * |
@@ -3081,6 +2868,7 @@ ctc_new_device(struct ccwgroup_device *cgdev) | |||
3081 | struct ctc_priv *privptr; | 2868 | struct ctc_priv *privptr; |
3082 | struct net_device *dev; | 2869 | struct net_device *dev; |
3083 | int ret; | 2870 | int ret; |
2871 | char buffer[16]; | ||
3084 | 2872 | ||
3085 | pr_debug("%s() called\n", __FUNCTION__); | 2873 | pr_debug("%s() called\n", __FUNCTION__); |
3086 | DBF_TEXT(setup, 3, __FUNCTION__); | 2874 | DBF_TEXT(setup, 3, __FUNCTION__); |
@@ -3089,6 +2877,9 @@ ctc_new_device(struct ccwgroup_device *cgdev) | |||
3089 | if (!privptr) | 2877 | if (!privptr) |
3090 | return -ENODEV; | 2878 | return -ENODEV; |
3091 | 2879 | ||
2880 | sprintf(buffer, "%d", privptr->buffer_size); | ||
2881 | DBF_TEXT(setup, 3, buffer); | ||
2882 | |||
3092 | type = get_channel_type(&cgdev->cdev[0]->id); | 2883 | type = get_channel_type(&cgdev->cdev[0]->id); |
3093 | 2884 | ||
3094 | snprintf(read_id, CTC_ID_SIZE, "ch-%s", cgdev->cdev[0]->dev.bus_id); | 2885 | snprintf(read_id, CTC_ID_SIZE, "ch-%s", cgdev->cdev[0]->dev.bus_id); |
@@ -3177,9 +2968,10 @@ ctc_shutdown_device(struct ccwgroup_device *cgdev) | |||
3177 | struct ctc_priv *priv; | 2968 | struct ctc_priv *priv; |
3178 | struct net_device *ndev; | 2969 | struct net_device *ndev; |
3179 | 2970 | ||
3180 | DBF_TEXT(trace, 3, __FUNCTION__); | 2971 | DBF_TEXT(setup, 3, __FUNCTION__); |
3181 | pr_debug("%s() called\n", __FUNCTION__); | 2972 | pr_debug("%s() called\n", __FUNCTION__); |
3182 | 2973 | ||
2974 | |||
3183 | priv = cgdev->dev.driver_data; | 2975 | priv = cgdev->dev.driver_data; |
3184 | ndev = NULL; | 2976 | ndev = NULL; |
3185 | if (!priv) | 2977 | if (!priv) |
@@ -3215,7 +3007,6 @@ ctc_shutdown_device(struct ccwgroup_device *cgdev) | |||
3215 | channel_remove(priv->channel[READ]); | 3007 | channel_remove(priv->channel[READ]); |
3216 | if (priv->channel[WRITE]) | 3008 | if (priv->channel[WRITE]) |
3217 | channel_remove(priv->channel[WRITE]); | 3009 | channel_remove(priv->channel[WRITE]); |
3218 | |||
3219 | priv->channel[READ] = priv->channel[WRITE] = NULL; | 3010 | priv->channel[READ] = priv->channel[WRITE] = NULL; |
3220 | 3011 | ||
3221 | return 0; | 3012 | return 0; |
@@ -3228,7 +3019,7 @@ ctc_remove_device(struct ccwgroup_device *cgdev) | |||
3228 | struct ctc_priv *priv; | 3019 | struct ctc_priv *priv; |
3229 | 3020 | ||
3230 | pr_debug("%s() called\n", __FUNCTION__); | 3021 | pr_debug("%s() called\n", __FUNCTION__); |
3231 | DBF_TEXT(trace, 3, __FUNCTION__); | 3022 | DBF_TEXT(setup, 3, __FUNCTION__); |
3232 | 3023 | ||
3233 | priv = cgdev->dev.driver_data; | 3024 | priv = cgdev->dev.driver_data; |
3234 | if (!priv) | 3025 | if (!priv) |
@@ -3265,6 +3056,7 @@ static struct ccwgroup_driver ctc_group_driver = { | |||
3265 | static void __exit | 3056 | static void __exit |
3266 | ctc_exit(void) | 3057 | ctc_exit(void) |
3267 | { | 3058 | { |
3059 | DBF_TEXT(setup, 3, __FUNCTION__); | ||
3268 | unregister_cu3088_discipline(&ctc_group_driver); | 3060 | unregister_cu3088_discipline(&ctc_group_driver); |
3269 | ctc_tty_cleanup(); | 3061 | ctc_tty_cleanup(); |
3270 | ctc_unregister_dbf_views(); | 3062 | ctc_unregister_dbf_views(); |
@@ -3282,6 +3074,10 @@ ctc_init(void) | |||
3282 | { | 3074 | { |
3283 | int ret = 0; | 3075 | int ret = 0; |
3284 | 3076 | ||
3077 | loglevel = CTC_LOGLEVEL_DEFAULT; | ||
3078 | |||
3079 | DBF_TEXT(setup, 3, __FUNCTION__); | ||
3080 | |||
3285 | print_banner(); | 3081 | print_banner(); |
3286 | 3082 | ||
3287 | ret = ctc_register_dbf_views(); | 3083 | ret = ctc_register_dbf_views(); |