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