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