xref: /openbmc/linux/drivers/s390/net/qeth_core_sys.c (revision 8c749ce9)
1 /*
2  *    Copyright IBM Corp. 2007
3  *    Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
4  *		 Frank Pavlic <fpavlic@de.ibm.com>,
5  *		 Thomas Spatzier <tspat@de.ibm.com>,
6  *		 Frank Blaschka <frank.blaschka@de.ibm.com>
7  */
8 
9 #define KMSG_COMPONENT "qeth"
10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11 
12 #include <linux/list.h>
13 #include <linux/rwsem.h>
14 #include <asm/ebcdic.h>
15 
16 #include "qeth_core.h"
17 
18 static ssize_t qeth_dev_state_show(struct device *dev,
19 				struct device_attribute *attr, char *buf)
20 {
21 	struct qeth_card *card = dev_get_drvdata(dev);
22 	if (!card)
23 		return -EINVAL;
24 
25 	switch (card->state) {
26 	case CARD_STATE_DOWN:
27 		return sprintf(buf, "DOWN\n");
28 	case CARD_STATE_HARDSETUP:
29 		return sprintf(buf, "HARDSETUP\n");
30 	case CARD_STATE_SOFTSETUP:
31 		return sprintf(buf, "SOFTSETUP\n");
32 	case CARD_STATE_UP:
33 		if (card->lan_online)
34 		return sprintf(buf, "UP (LAN ONLINE)\n");
35 		else
36 			return sprintf(buf, "UP (LAN OFFLINE)\n");
37 	case CARD_STATE_RECOVER:
38 		return sprintf(buf, "RECOVER\n");
39 	default:
40 		return sprintf(buf, "UNKNOWN\n");
41 	}
42 }
43 
44 static DEVICE_ATTR(state, 0444, qeth_dev_state_show, NULL);
45 
46 static ssize_t qeth_dev_chpid_show(struct device *dev,
47 				struct device_attribute *attr, char *buf)
48 {
49 	struct qeth_card *card = dev_get_drvdata(dev);
50 	if (!card)
51 		return -EINVAL;
52 
53 	return sprintf(buf, "%02X\n", card->info.chpid);
54 }
55 
56 static DEVICE_ATTR(chpid, 0444, qeth_dev_chpid_show, NULL);
57 
58 static ssize_t qeth_dev_if_name_show(struct device *dev,
59 				struct device_attribute *attr, char *buf)
60 {
61 	struct qeth_card *card = dev_get_drvdata(dev);
62 	if (!card)
63 		return -EINVAL;
64 	return sprintf(buf, "%s\n", QETH_CARD_IFNAME(card));
65 }
66 
67 static DEVICE_ATTR(if_name, 0444, qeth_dev_if_name_show, NULL);
68 
69 static ssize_t qeth_dev_card_type_show(struct device *dev,
70 				struct device_attribute *attr, char *buf)
71 {
72 	struct qeth_card *card = dev_get_drvdata(dev);
73 	if (!card)
74 		return -EINVAL;
75 
76 	return sprintf(buf, "%s\n", qeth_get_cardname_short(card));
77 }
78 
79 static DEVICE_ATTR(card_type, 0444, qeth_dev_card_type_show, NULL);
80 
81 static inline const char *qeth_get_bufsize_str(struct qeth_card *card)
82 {
83 	if (card->qdio.in_buf_size == 16384)
84 		return "16k";
85 	else if (card->qdio.in_buf_size == 24576)
86 		return "24k";
87 	else if (card->qdio.in_buf_size == 32768)
88 		return "32k";
89 	else if (card->qdio.in_buf_size == 40960)
90 		return "40k";
91 	else
92 		return "64k";
93 }
94 
95 static ssize_t qeth_dev_inbuf_size_show(struct device *dev,
96 				struct device_attribute *attr, char *buf)
97 {
98 	struct qeth_card *card = dev_get_drvdata(dev);
99 	if (!card)
100 		return -EINVAL;
101 
102 	return sprintf(buf, "%s\n", qeth_get_bufsize_str(card));
103 }
104 
105 static DEVICE_ATTR(inbuf_size, 0444, qeth_dev_inbuf_size_show, NULL);
106 
107 static ssize_t qeth_dev_portno_show(struct device *dev,
108 			struct device_attribute *attr, char *buf)
109 {
110 	struct qeth_card *card = dev_get_drvdata(dev);
111 	if (!card)
112 		return -EINVAL;
113 
114 	return sprintf(buf, "%i\n", card->info.portno);
115 }
116 
117 static ssize_t qeth_dev_portno_store(struct device *dev,
118 		struct device_attribute *attr, const char *buf, size_t count)
119 {
120 	struct qeth_card *card = dev_get_drvdata(dev);
121 	char *tmp;
122 	unsigned int portno, limit;
123 	int rc = 0;
124 
125 	if (!card)
126 		return -EINVAL;
127 
128 	mutex_lock(&card->conf_mutex);
129 	if ((card->state != CARD_STATE_DOWN) &&
130 	    (card->state != CARD_STATE_RECOVER)) {
131 		rc = -EPERM;
132 		goto out;
133 	}
134 
135 	portno = simple_strtoul(buf, &tmp, 16);
136 	if (portno > QETH_MAX_PORTNO) {
137 		rc = -EINVAL;
138 		goto out;
139 	}
140 	limit = (card->ssqd.pcnt ? card->ssqd.pcnt - 1 : card->ssqd.pcnt);
141 	if (portno > limit) {
142 		rc = -EINVAL;
143 		goto out;
144 	}
145 	card->info.portno = portno;
146 out:
147 	mutex_unlock(&card->conf_mutex);
148 	return rc ? rc : count;
149 }
150 
151 static DEVICE_ATTR(portno, 0644, qeth_dev_portno_show, qeth_dev_portno_store);
152 
153 static ssize_t qeth_dev_portname_show(struct device *dev,
154 				struct device_attribute *attr, char *buf)
155 {
156 	return sprintf(buf, "no portname required\n");
157 }
158 
159 static ssize_t qeth_dev_portname_store(struct device *dev,
160 		struct device_attribute *attr, const char *buf, size_t count)
161 {
162 	struct qeth_card *card = dev_get_drvdata(dev);
163 
164 	dev_warn_once(&card->gdev->dev,
165 		      "portname is deprecated and is ignored\n");
166 	return count;
167 }
168 
169 static DEVICE_ATTR(portname, 0644, qeth_dev_portname_show,
170 		qeth_dev_portname_store);
171 
172 static ssize_t qeth_dev_prioqing_show(struct device *dev,
173 				struct device_attribute *attr, char *buf)
174 {
175 	struct qeth_card *card = dev_get_drvdata(dev);
176 
177 	if (!card)
178 		return -EINVAL;
179 
180 	switch (card->qdio.do_prio_queueing) {
181 	case QETH_PRIO_Q_ING_PREC:
182 		return sprintf(buf, "%s\n", "by precedence");
183 	case QETH_PRIO_Q_ING_TOS:
184 		return sprintf(buf, "%s\n", "by type of service");
185 	case QETH_PRIO_Q_ING_SKB:
186 		return sprintf(buf, "%s\n", "by skb-priority");
187 	case QETH_PRIO_Q_ING_VLAN:
188 		return sprintf(buf, "%s\n", "by VLAN headers");
189 	default:
190 		return sprintf(buf, "always queue %i\n",
191 			       card->qdio.default_out_queue);
192 	}
193 }
194 
195 static ssize_t qeth_dev_prioqing_store(struct device *dev,
196 		struct device_attribute *attr, const char *buf, size_t count)
197 {
198 	struct qeth_card *card = dev_get_drvdata(dev);
199 	int rc = 0;
200 
201 	if (!card)
202 		return -EINVAL;
203 
204 	mutex_lock(&card->conf_mutex);
205 	if ((card->state != CARD_STATE_DOWN) &&
206 	    (card->state != CARD_STATE_RECOVER)) {
207 		rc = -EPERM;
208 		goto out;
209 	}
210 
211 	/* check if 1920 devices are supported ,
212 	 * if though we have to permit priority queueing
213 	 */
214 	if (card->qdio.no_out_queues == 1) {
215 		card->qdio.do_prio_queueing = QETH_PRIOQ_DEFAULT;
216 		rc = -EPERM;
217 		goto out;
218 	}
219 
220 	if (sysfs_streq(buf, "prio_queueing_prec")) {
221 		card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_PREC;
222 		card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
223 	} else if (sysfs_streq(buf, "prio_queueing_skb")) {
224 		card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_SKB;
225 		card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
226 	} else if (sysfs_streq(buf, "prio_queueing_tos")) {
227 		card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_TOS;
228 		card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
229 	} else if (sysfs_streq(buf, "prio_queueing_vlan")) {
230 		if (!card->options.layer2) {
231 			rc = -ENOTSUPP;
232 			goto out;
233 		}
234 		card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_VLAN;
235 		card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
236 	} else if (sysfs_streq(buf, "no_prio_queueing:0")) {
237 		card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING;
238 		card->qdio.default_out_queue = 0;
239 	} else if (sysfs_streq(buf, "no_prio_queueing:1")) {
240 		card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING;
241 		card->qdio.default_out_queue = 1;
242 	} else if (sysfs_streq(buf, "no_prio_queueing:2")) {
243 		card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING;
244 		card->qdio.default_out_queue = 2;
245 	} else if (sysfs_streq(buf, "no_prio_queueing:3")) {
246 		card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING;
247 		card->qdio.default_out_queue = 3;
248 	} else if (sysfs_streq(buf, "no_prio_queueing")) {
249 		card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING;
250 		card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
251 	} else
252 		rc = -EINVAL;
253 out:
254 	mutex_unlock(&card->conf_mutex);
255 	return rc ? rc : count;
256 }
257 
258 static DEVICE_ATTR(priority_queueing, 0644, qeth_dev_prioqing_show,
259 		qeth_dev_prioqing_store);
260 
261 static ssize_t qeth_dev_bufcnt_show(struct device *dev,
262 				struct device_attribute *attr, char *buf)
263 {
264 	struct qeth_card *card = dev_get_drvdata(dev);
265 
266 	if (!card)
267 		return -EINVAL;
268 
269 	return sprintf(buf, "%i\n", card->qdio.in_buf_pool.buf_count);
270 }
271 
272 static ssize_t qeth_dev_bufcnt_store(struct device *dev,
273 		struct device_attribute *attr, const char *buf, size_t count)
274 {
275 	struct qeth_card *card = dev_get_drvdata(dev);
276 	char *tmp;
277 	int cnt, old_cnt;
278 	int rc = 0;
279 
280 	if (!card)
281 		return -EINVAL;
282 
283 	mutex_lock(&card->conf_mutex);
284 	if ((card->state != CARD_STATE_DOWN) &&
285 	    (card->state != CARD_STATE_RECOVER)) {
286 		rc = -EPERM;
287 		goto out;
288 	}
289 
290 	old_cnt = card->qdio.in_buf_pool.buf_count;
291 	cnt = simple_strtoul(buf, &tmp, 10);
292 	cnt = (cnt < QETH_IN_BUF_COUNT_MIN) ? QETH_IN_BUF_COUNT_MIN :
293 		((cnt > QETH_IN_BUF_COUNT_MAX) ? QETH_IN_BUF_COUNT_MAX : cnt);
294 	if (old_cnt != cnt) {
295 		rc = qeth_realloc_buffer_pool(card, cnt);
296 	}
297 out:
298 	mutex_unlock(&card->conf_mutex);
299 	return rc ? rc : count;
300 }
301 
302 static DEVICE_ATTR(buffer_count, 0644, qeth_dev_bufcnt_show,
303 		qeth_dev_bufcnt_store);
304 
305 static ssize_t qeth_dev_recover_store(struct device *dev,
306 		struct device_attribute *attr, const char *buf, size_t count)
307 {
308 	struct qeth_card *card = dev_get_drvdata(dev);
309 	char *tmp;
310 	int i;
311 
312 	if (!card)
313 		return -EINVAL;
314 
315 	if (card->state != CARD_STATE_UP)
316 		return -EPERM;
317 
318 	i = simple_strtoul(buf, &tmp, 16);
319 	if (i == 1)
320 		qeth_schedule_recovery(card);
321 
322 	return count;
323 }
324 
325 static DEVICE_ATTR(recover, 0200, NULL, qeth_dev_recover_store);
326 
327 static ssize_t qeth_dev_performance_stats_show(struct device *dev,
328 				struct device_attribute *attr, char *buf)
329 {
330 	struct qeth_card *card = dev_get_drvdata(dev);
331 
332 	if (!card)
333 		return -EINVAL;
334 
335 	return sprintf(buf, "%i\n", card->options.performance_stats ? 1:0);
336 }
337 
338 static ssize_t qeth_dev_performance_stats_store(struct device *dev,
339 		struct device_attribute *attr, const char *buf, size_t count)
340 {
341 	struct qeth_card *card = dev_get_drvdata(dev);
342 	char *tmp;
343 	int i, rc = 0;
344 
345 	if (!card)
346 		return -EINVAL;
347 
348 	mutex_lock(&card->conf_mutex);
349 	i = simple_strtoul(buf, &tmp, 16);
350 	if ((i == 0) || (i == 1)) {
351 		if (i == card->options.performance_stats)
352 			goto out;
353 		card->options.performance_stats = i;
354 		if (i == 0)
355 			memset(&card->perf_stats, 0,
356 				sizeof(struct qeth_perf_stats));
357 		card->perf_stats.initial_rx_packets = card->stats.rx_packets;
358 		card->perf_stats.initial_tx_packets = card->stats.tx_packets;
359 	} else
360 		rc = -EINVAL;
361 out:
362 	mutex_unlock(&card->conf_mutex);
363 	return rc ? rc : count;
364 }
365 
366 static DEVICE_ATTR(performance_stats, 0644, qeth_dev_performance_stats_show,
367 		   qeth_dev_performance_stats_store);
368 
369 static ssize_t qeth_dev_layer2_show(struct device *dev,
370 		struct device_attribute *attr, char *buf)
371 {
372 	struct qeth_card *card = dev_get_drvdata(dev);
373 
374 	if (!card)
375 		return -EINVAL;
376 
377 	return sprintf(buf, "%i\n", card->options.layer2);
378 }
379 
380 static ssize_t qeth_dev_layer2_store(struct device *dev,
381 		struct device_attribute *attr, const char *buf, size_t count)
382 {
383 	struct qeth_card *card = dev_get_drvdata(dev);
384 	char *tmp;
385 	int i, rc = 0;
386 	enum qeth_discipline_id newdis;
387 
388 	if (!card)
389 		return -EINVAL;
390 
391 	mutex_lock(&card->discipline_mutex);
392 	if (card->state != CARD_STATE_DOWN) {
393 		rc = -EPERM;
394 		goto out;
395 	}
396 
397 	i = simple_strtoul(buf, &tmp, 16);
398 	switch (i) {
399 	case 0:
400 		newdis = QETH_DISCIPLINE_LAYER3;
401 		break;
402 	case 1:
403 		newdis = QETH_DISCIPLINE_LAYER2;
404 		break;
405 	default:
406 		rc = -EINVAL;
407 		goto out;
408 	}
409 
410 	if (card->options.layer2 == newdis)
411 		goto out;
412 	else {
413 		card->info.mac_bits  = 0;
414 		if (card->discipline) {
415 			card->discipline->remove(card->gdev);
416 			qeth_core_free_discipline(card);
417 		}
418 	}
419 
420 	rc = qeth_core_load_discipline(card, newdis);
421 	if (rc)
422 		goto out;
423 
424 	rc = card->discipline->setup(card->gdev);
425 out:
426 	mutex_unlock(&card->discipline_mutex);
427 	return rc ? rc : count;
428 }
429 
430 static DEVICE_ATTR(layer2, 0644, qeth_dev_layer2_show,
431 		   qeth_dev_layer2_store);
432 
433 #define ATTR_QETH_ISOLATION_NONE	("none")
434 #define ATTR_QETH_ISOLATION_FWD		("forward")
435 #define ATTR_QETH_ISOLATION_DROP	("drop")
436 
437 static ssize_t qeth_dev_isolation_show(struct device *dev,
438 				struct device_attribute *attr, char *buf)
439 {
440 	struct qeth_card *card = dev_get_drvdata(dev);
441 
442 	if (!card)
443 		return -EINVAL;
444 
445 	switch (card->options.isolation) {
446 	case ISOLATION_MODE_NONE:
447 		return snprintf(buf, 6, "%s\n", ATTR_QETH_ISOLATION_NONE);
448 	case ISOLATION_MODE_FWD:
449 		return snprintf(buf, 9, "%s\n", ATTR_QETH_ISOLATION_FWD);
450 	case ISOLATION_MODE_DROP:
451 		return snprintf(buf, 6, "%s\n", ATTR_QETH_ISOLATION_DROP);
452 	default:
453 		return snprintf(buf, 5, "%s\n", "N/A");
454 	}
455 }
456 
457 static ssize_t qeth_dev_isolation_store(struct device *dev,
458 		struct device_attribute *attr, const char *buf, size_t count)
459 {
460 	struct qeth_card *card = dev_get_drvdata(dev);
461 	enum qeth_ipa_isolation_modes isolation;
462 	int rc = 0;
463 
464 	if (!card)
465 		return -EINVAL;
466 
467 	mutex_lock(&card->conf_mutex);
468 	/* check for unknown, too, in case we do not yet know who we are */
469 	if (card->info.type != QETH_CARD_TYPE_OSD &&
470 	    card->info.type != QETH_CARD_TYPE_OSX &&
471 	    card->info.type != QETH_CARD_TYPE_UNKNOWN) {
472 		rc = -EOPNOTSUPP;
473 		dev_err(&card->gdev->dev, "Adapter does not "
474 			"support QDIO data connection isolation\n");
475 		goto out;
476 	}
477 
478 	/* parse input into isolation mode */
479 	if (sysfs_streq(buf, ATTR_QETH_ISOLATION_NONE)) {
480 		isolation = ISOLATION_MODE_NONE;
481 	} else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_FWD)) {
482 		isolation = ISOLATION_MODE_FWD;
483 	} else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_DROP)) {
484 		isolation = ISOLATION_MODE_DROP;
485 	} else {
486 		rc = -EINVAL;
487 		goto out;
488 	}
489 	rc = count;
490 
491 	/* defer IP assist if device is offline (until discipline->set_online)*/
492 	card->options.prev_isolation = card->options.isolation;
493 	card->options.isolation = isolation;
494 	if (qeth_card_hw_is_reachable(card)) {
495 		int ipa_rc = qeth_set_access_ctrl_online(card, 1);
496 		if (ipa_rc != 0)
497 			rc = ipa_rc;
498 	}
499 out:
500 	mutex_unlock(&card->conf_mutex);
501 	return rc;
502 }
503 
504 static DEVICE_ATTR(isolation, 0644, qeth_dev_isolation_show,
505 			qeth_dev_isolation_store);
506 
507 static ssize_t qeth_dev_switch_attrs_show(struct device *dev,
508 				struct device_attribute *attr, char *buf)
509 {
510 	struct qeth_card *card = dev_get_drvdata(dev);
511 	struct qeth_switch_info sw_info;
512 	int	rc = 0;
513 
514 	if (!card)
515 		return -EINVAL;
516 
517 	if (!qeth_card_hw_is_reachable(card))
518 		return sprintf(buf, "n/a\n");
519 
520 	rc = qeth_query_switch_attributes(card, &sw_info);
521 	if (rc)
522 		return rc;
523 
524 	if (!sw_info.capabilities)
525 		rc = sprintf(buf, "unknown");
526 
527 	if (sw_info.capabilities & QETH_SWITCH_FORW_802_1)
528 		rc = sprintf(buf, (sw_info.settings & QETH_SWITCH_FORW_802_1 ?
529 							"[802.1]" : "802.1"));
530 	if (sw_info.capabilities & QETH_SWITCH_FORW_REFL_RELAY)
531 		rc += sprintf(buf + rc,
532 			(sw_info.settings & QETH_SWITCH_FORW_REFL_RELAY ?
533 							" [rr]" : " rr"));
534 	rc += sprintf(buf + rc, "\n");
535 
536 	return rc;
537 }
538 
539 static DEVICE_ATTR(switch_attrs, 0444,
540 		   qeth_dev_switch_attrs_show, NULL);
541 
542 static ssize_t qeth_hw_trap_show(struct device *dev,
543 				struct device_attribute *attr, char *buf)
544 {
545 	struct qeth_card *card = dev_get_drvdata(dev);
546 
547 	if (!card)
548 		return -EINVAL;
549 	if (card->info.hwtrap)
550 		return snprintf(buf, 5, "arm\n");
551 	else
552 		return snprintf(buf, 8, "disarm\n");
553 }
554 
555 static ssize_t qeth_hw_trap_store(struct device *dev,
556 		struct device_attribute *attr, const char *buf, size_t count)
557 {
558 	struct qeth_card *card = dev_get_drvdata(dev);
559 	int rc = 0;
560 	int state = 0;
561 
562 	if (!card)
563 		return -EINVAL;
564 
565 	mutex_lock(&card->conf_mutex);
566 	if (qeth_card_hw_is_reachable(card))
567 		state = 1;
568 
569 	if (sysfs_streq(buf, "arm") && !card->info.hwtrap) {
570 		if (state) {
571 			if (qeth_is_diagass_supported(card,
572 			    QETH_DIAGS_CMD_TRAP)) {
573 				rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM);
574 				if (!rc)
575 					card->info.hwtrap = 1;
576 			} else
577 				rc = -EINVAL;
578 		} else
579 			card->info.hwtrap = 1;
580 	} else if (sysfs_streq(buf, "disarm") && card->info.hwtrap) {
581 		if (state) {
582 			rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
583 			if (!rc)
584 				card->info.hwtrap = 0;
585 		} else
586 			card->info.hwtrap = 0;
587 	} else if (sysfs_streq(buf, "trap") && state && card->info.hwtrap)
588 		rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_CAPTURE);
589 	else
590 		rc = -EINVAL;
591 
592 	mutex_unlock(&card->conf_mutex);
593 	return rc ? rc : count;
594 }
595 
596 static DEVICE_ATTR(hw_trap, 0644, qeth_hw_trap_show,
597 		   qeth_hw_trap_store);
598 
599 static ssize_t qeth_dev_blkt_show(char *buf, struct qeth_card *card, int value)
600 {
601 
602 	if (!card)
603 		return -EINVAL;
604 
605 	return sprintf(buf, "%i\n", value);
606 }
607 
608 static ssize_t qeth_dev_blkt_store(struct qeth_card *card,
609 		const char *buf, size_t count, int *value, int max_value)
610 {
611 	char *tmp;
612 	int i, rc = 0;
613 
614 	if (!card)
615 		return -EINVAL;
616 
617 	mutex_lock(&card->conf_mutex);
618 	if ((card->state != CARD_STATE_DOWN) &&
619 	    (card->state != CARD_STATE_RECOVER)) {
620 		rc = -EPERM;
621 		goto out;
622 	}
623 	i = simple_strtoul(buf, &tmp, 10);
624 	if (i <= max_value)
625 		*value = i;
626 	else
627 		rc = -EINVAL;
628 out:
629 	mutex_unlock(&card->conf_mutex);
630 	return rc ? rc : count;
631 }
632 
633 static ssize_t qeth_dev_blkt_total_show(struct device *dev,
634 				struct device_attribute *attr, char *buf)
635 {
636 	struct qeth_card *card = dev_get_drvdata(dev);
637 
638 	return qeth_dev_blkt_show(buf, card, card->info.blkt.time_total);
639 }
640 
641 static ssize_t qeth_dev_blkt_total_store(struct device *dev,
642 		struct device_attribute *attr, const char *buf, size_t count)
643 {
644 	struct qeth_card *card = dev_get_drvdata(dev);
645 
646 	return qeth_dev_blkt_store(card, buf, count,
647 				   &card->info.blkt.time_total, 5000);
648 }
649 
650 
651 
652 static DEVICE_ATTR(total, 0644, qeth_dev_blkt_total_show,
653 		   qeth_dev_blkt_total_store);
654 
655 static ssize_t qeth_dev_blkt_inter_show(struct device *dev,
656 				struct device_attribute *attr, char *buf)
657 {
658 	struct qeth_card *card = dev_get_drvdata(dev);
659 
660 	return qeth_dev_blkt_show(buf, card, card->info.blkt.inter_packet);
661 }
662 
663 static ssize_t qeth_dev_blkt_inter_store(struct device *dev,
664 		struct device_attribute *attr, const char *buf, size_t count)
665 {
666 	struct qeth_card *card = dev_get_drvdata(dev);
667 
668 	return qeth_dev_blkt_store(card, buf, count,
669 				   &card->info.blkt.inter_packet, 1000);
670 }
671 
672 static DEVICE_ATTR(inter, 0644, qeth_dev_blkt_inter_show,
673 		   qeth_dev_blkt_inter_store);
674 
675 static ssize_t qeth_dev_blkt_inter_jumbo_show(struct device *dev,
676 				struct device_attribute *attr, char *buf)
677 {
678 	struct qeth_card *card = dev_get_drvdata(dev);
679 
680 	return qeth_dev_blkt_show(buf, card,
681 				  card->info.blkt.inter_packet_jumbo);
682 }
683 
684 static ssize_t qeth_dev_blkt_inter_jumbo_store(struct device *dev,
685 		struct device_attribute *attr, const char *buf, size_t count)
686 {
687 	struct qeth_card *card = dev_get_drvdata(dev);
688 
689 	return qeth_dev_blkt_store(card, buf, count,
690 				   &card->info.blkt.inter_packet_jumbo, 1000);
691 }
692 
693 static DEVICE_ATTR(inter_jumbo, 0644, qeth_dev_blkt_inter_jumbo_show,
694 		   qeth_dev_blkt_inter_jumbo_store);
695 
696 static struct attribute *qeth_blkt_device_attrs[] = {
697 	&dev_attr_total.attr,
698 	&dev_attr_inter.attr,
699 	&dev_attr_inter_jumbo.attr,
700 	NULL,
701 };
702 static struct attribute_group qeth_device_blkt_group = {
703 	.name = "blkt",
704 	.attrs = qeth_blkt_device_attrs,
705 };
706 
707 static struct attribute *qeth_device_attrs[] = {
708 	&dev_attr_state.attr,
709 	&dev_attr_chpid.attr,
710 	&dev_attr_if_name.attr,
711 	&dev_attr_card_type.attr,
712 	&dev_attr_inbuf_size.attr,
713 	&dev_attr_portno.attr,
714 	&dev_attr_portname.attr,
715 	&dev_attr_priority_queueing.attr,
716 	&dev_attr_buffer_count.attr,
717 	&dev_attr_recover.attr,
718 	&dev_attr_performance_stats.attr,
719 	&dev_attr_layer2.attr,
720 	&dev_attr_isolation.attr,
721 	&dev_attr_hw_trap.attr,
722 	&dev_attr_switch_attrs.attr,
723 	NULL,
724 };
725 static struct attribute_group qeth_device_attr_group = {
726 	.attrs = qeth_device_attrs,
727 };
728 
729 const struct attribute_group *qeth_generic_attr_groups[] = {
730 	&qeth_device_attr_group,
731 	&qeth_device_blkt_group,
732 	NULL,
733 };
734 
735 static struct attribute *qeth_osn_device_attrs[] = {
736 	&dev_attr_state.attr,
737 	&dev_attr_chpid.attr,
738 	&dev_attr_if_name.attr,
739 	&dev_attr_card_type.attr,
740 	&dev_attr_buffer_count.attr,
741 	&dev_attr_recover.attr,
742 	NULL,
743 };
744 static struct attribute_group qeth_osn_device_attr_group = {
745 	.attrs = qeth_osn_device_attrs,
746 };
747 const struct attribute_group *qeth_osn_attr_groups[] = {
748 	&qeth_osn_device_attr_group,
749 	NULL,
750 };
751