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