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