3 * linux/drivers/s390/net/qeth_sys.c
5 * Linux on zSeries OSA Express and HiperSockets support
6 * This file contains code related to sysfs.
8 * Copyright 2000,2003 IBM Corporation
10 * Author(s): Thomas Spatzier <tspat@de.ibm.com>
11 * Frank Pavlic <fpavlic@de.ibm.com>
14 #include <linux/list.h>
15 #include <linux/rwsem.h>
17 #include <asm/ebcdic.h>
23 /*****************************************************************************/
25 /* /sys-fs stuff UNDER DEVELOPMENT !!! */
27 /*****************************************************************************/
31 qeth_dev_state_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
33 struct qeth_card
*card
= dev
->driver_data
;
37 switch (card
->state
) {
39 return sprintf(buf
, "DOWN\n");
40 case CARD_STATE_HARDSETUP
:
41 return sprintf(buf
, "HARDSETUP\n");
42 case CARD_STATE_SOFTSETUP
:
43 return sprintf(buf
, "SOFTSETUP\n");
46 return sprintf(buf
, "UP (LAN ONLINE)\n");
48 return sprintf(buf
, "UP (LAN OFFLINE)\n");
49 case CARD_STATE_RECOVER
:
50 return sprintf(buf
, "RECOVER\n");
52 return sprintf(buf
, "UNKNOWN\n");
56 static DEVICE_ATTR(state
, 0444, qeth_dev_state_show
, NULL
);
59 qeth_dev_chpid_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
61 struct qeth_card
*card
= dev
->driver_data
;
65 return sprintf(buf
, "%02X\n", card
->info
.chpid
);
68 static DEVICE_ATTR(chpid
, 0444, qeth_dev_chpid_show
, NULL
);
71 qeth_dev_if_name_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
73 struct qeth_card
*card
= dev
->driver_data
;
76 return sprintf(buf
, "%s\n", QETH_CARD_IFNAME(card
));
79 static DEVICE_ATTR(if_name
, 0444, qeth_dev_if_name_show
, NULL
);
82 qeth_dev_card_type_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
84 struct qeth_card
*card
= dev
->driver_data
;
88 return sprintf(buf
, "%s\n", qeth_get_cardname_short(card
));
91 static DEVICE_ATTR(card_type
, 0444, qeth_dev_card_type_show
, NULL
);
94 qeth_dev_portno_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
96 struct qeth_card
*card
= dev
->driver_data
;
100 return sprintf(buf
, "%i\n", card
->info
.portno
);
104 qeth_dev_portno_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
106 struct qeth_card
*card
= dev
->driver_data
;
113 if ((card
->state
!= CARD_STATE_DOWN
) &&
114 (card
->state
!= CARD_STATE_RECOVER
))
117 portno
= simple_strtoul(buf
, &tmp
, 16);
118 if (portno
> MAX_PORTNO
){
119 PRINT_WARN("portno 0x%X is out of range\n", portno
);
123 card
->info
.portno
= portno
;
127 static DEVICE_ATTR(portno
, 0644, qeth_dev_portno_show
, qeth_dev_portno_store
);
130 qeth_dev_portname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
132 struct qeth_card
*card
= dev
->driver_data
;
133 char portname
[9] = {0, };
138 if (card
->info
.portname_required
) {
139 memcpy(portname
, card
->info
.portname
+ 1, 8);
141 return sprintf(buf
, "%s\n", portname
);
143 return sprintf(buf
, "no portname required\n");
147 qeth_dev_portname_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
149 struct qeth_card
*card
= dev
->driver_data
;
156 if ((card
->state
!= CARD_STATE_DOWN
) &&
157 (card
->state
!= CARD_STATE_RECOVER
))
160 tmp
= strsep((char **) &buf
, "\n");
161 if ((strlen(tmp
) > 8) || (strlen(tmp
) == 0))
164 card
->info
.portname
[0] = strlen(tmp
);
165 /* for beauty reasons */
166 for (i
= 1; i
< 9; i
++)
167 card
->info
.portname
[i
] = ' ';
168 strcpy(card
->info
.portname
+ 1, tmp
);
169 ASCEBC(card
->info
.portname
+ 1, 8);
174 static DEVICE_ATTR(portname
, 0644, qeth_dev_portname_show
,
175 qeth_dev_portname_store
);
178 qeth_dev_checksum_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
180 struct qeth_card
*card
= dev
->driver_data
;
185 return sprintf(buf
, "%s checksumming\n", qeth_get_checksum_str(card
));
189 qeth_dev_checksum_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
191 struct qeth_card
*card
= dev
->driver_data
;
197 if ((card
->state
!= CARD_STATE_DOWN
) &&
198 (card
->state
!= CARD_STATE_RECOVER
))
201 tmp
= strsep((char **) &buf
, "\n");
202 if (!strcmp(tmp
, "sw_checksumming"))
203 card
->options
.checksum_type
= SW_CHECKSUMMING
;
204 else if (!strcmp(tmp
, "hw_checksumming"))
205 card
->options
.checksum_type
= HW_CHECKSUMMING
;
206 else if (!strcmp(tmp
, "no_checksumming"))
207 card
->options
.checksum_type
= NO_CHECKSUMMING
;
209 PRINT_WARN("Unknown checksumming type '%s'\n", tmp
);
215 static DEVICE_ATTR(checksumming
, 0644, qeth_dev_checksum_show
,
216 qeth_dev_checksum_store
);
219 qeth_dev_prioqing_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
221 struct qeth_card
*card
= dev
->driver_data
;
226 switch (card
->qdio
.do_prio_queueing
) {
227 case QETH_PRIO_Q_ING_PREC
:
228 return sprintf(buf
, "%s\n", "by precedence");
229 case QETH_PRIO_Q_ING_TOS
:
230 return sprintf(buf
, "%s\n", "by type of service");
232 return sprintf(buf
, "always queue %i\n",
233 card
->qdio
.default_out_queue
);
238 qeth_dev_prioqing_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
240 struct qeth_card
*card
= dev
->driver_data
;
246 if ((card
->state
!= CARD_STATE_DOWN
) &&
247 (card
->state
!= CARD_STATE_RECOVER
))
250 /* check if 1920 devices are supported ,
251 * if though we have to permit priority queueing
253 if (card
->qdio
.no_out_queues
== 1) {
254 PRINT_WARN("Priority queueing disabled due "
255 "to hardware limitations!\n");
256 card
->qdio
.do_prio_queueing
= QETH_PRIOQ_DEFAULT
;
260 tmp
= strsep((char **) &buf
, "\n");
261 if (!strcmp(tmp
, "prio_queueing_prec"))
262 card
->qdio
.do_prio_queueing
= QETH_PRIO_Q_ING_PREC
;
263 else if (!strcmp(tmp
, "prio_queueing_tos"))
264 card
->qdio
.do_prio_queueing
= QETH_PRIO_Q_ING_TOS
;
265 else if (!strcmp(tmp
, "no_prio_queueing:0")) {
266 card
->qdio
.do_prio_queueing
= QETH_NO_PRIO_QUEUEING
;
267 card
->qdio
.default_out_queue
= 0;
268 } else if (!strcmp(tmp
, "no_prio_queueing:1")) {
269 card
->qdio
.do_prio_queueing
= QETH_NO_PRIO_QUEUEING
;
270 card
->qdio
.default_out_queue
= 1;
271 } else if (!strcmp(tmp
, "no_prio_queueing:2")) {
272 card
->qdio
.do_prio_queueing
= QETH_NO_PRIO_QUEUEING
;
273 card
->qdio
.default_out_queue
= 2;
274 } else if (!strcmp(tmp
, "no_prio_queueing:3")) {
275 card
->qdio
.do_prio_queueing
= QETH_NO_PRIO_QUEUEING
;
276 card
->qdio
.default_out_queue
= 3;
277 } else if (!strcmp(tmp
, "no_prio_queueing")) {
278 card
->qdio
.do_prio_queueing
= QETH_NO_PRIO_QUEUEING
;
279 card
->qdio
.default_out_queue
= QETH_DEFAULT_QUEUE
;
281 PRINT_WARN("Unknown queueing type '%s'\n", tmp
);
287 static DEVICE_ATTR(priority_queueing
, 0644, qeth_dev_prioqing_show
,
288 qeth_dev_prioqing_store
);
291 qeth_dev_bufcnt_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
293 struct qeth_card
*card
= dev
->driver_data
;
298 return sprintf(buf
, "%i\n", card
->qdio
.in_buf_pool
.buf_count
);
302 qeth_dev_bufcnt_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
304 struct qeth_card
*card
= dev
->driver_data
;
312 if ((card
->state
!= CARD_STATE_DOWN
) &&
313 (card
->state
!= CARD_STATE_RECOVER
))
316 old_cnt
= card
->qdio
.in_buf_pool
.buf_count
;
317 cnt
= simple_strtoul(buf
, &tmp
, 10);
318 cnt
= (cnt
< QETH_IN_BUF_COUNT_MIN
) ? QETH_IN_BUF_COUNT_MIN
:
319 ((cnt
> QETH_IN_BUF_COUNT_MAX
) ? QETH_IN_BUF_COUNT_MAX
: cnt
);
320 if (old_cnt
!= cnt
) {
321 if ((rc
= qeth_realloc_buffer_pool(card
, cnt
)))
322 PRINT_WARN("Error (%d) while setting "
323 "buffer count.\n", rc
);
328 static DEVICE_ATTR(buffer_count
, 0644, qeth_dev_bufcnt_show
,
329 qeth_dev_bufcnt_store
);
332 qeth_dev_route_show(struct qeth_card
*card
, struct qeth_routing_info
*route
,
335 switch (route
->type
) {
337 return sprintf(buf
, "%s\n", "primary router");
338 case SECONDARY_ROUTER
:
339 return sprintf(buf
, "%s\n", "secondary router");
340 case MULTICAST_ROUTER
:
341 if (card
->info
.broadcast_capable
== QETH_BROADCAST_WITHOUT_ECHO
)
342 return sprintf(buf
, "%s\n", "multicast router+");
344 return sprintf(buf
, "%s\n", "multicast router");
345 case PRIMARY_CONNECTOR
:
346 if (card
->info
.broadcast_capable
== QETH_BROADCAST_WITHOUT_ECHO
)
347 return sprintf(buf
, "%s\n", "primary connector+");
349 return sprintf(buf
, "%s\n", "primary connector");
350 case SECONDARY_CONNECTOR
:
351 if (card
->info
.broadcast_capable
== QETH_BROADCAST_WITHOUT_ECHO
)
352 return sprintf(buf
, "%s\n", "secondary connector+");
354 return sprintf(buf
, "%s\n", "secondary connector");
356 return sprintf(buf
, "%s\n", "no");
361 qeth_dev_route4_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
363 struct qeth_card
*card
= dev
->driver_data
;
368 return qeth_dev_route_show(card
, &card
->options
.route4
, buf
);
372 qeth_dev_route_store(struct qeth_card
*card
, struct qeth_routing_info
*route
,
373 enum qeth_prot_versions prot
, const char *buf
, size_t count
)
375 enum qeth_routing_types old_route_type
= route
->type
;
379 tmp
= strsep((char **) &buf
, "\n");
381 if (!strcmp(tmp
, "no_router")){
382 route
->type
= NO_ROUTER
;
383 } else if (!strcmp(tmp
, "primary_connector")) {
384 route
->type
= PRIMARY_CONNECTOR
;
385 } else if (!strcmp(tmp
, "secondary_connector")) {
386 route
->type
= SECONDARY_CONNECTOR
;
387 } else if (!strcmp(tmp
, "multicast_router")) {
388 route
->type
= MULTICAST_ROUTER
;
389 } else if (!strcmp(tmp
, "primary_router")) {
390 route
->type
= PRIMARY_ROUTER
;
391 } else if (!strcmp(tmp
, "secondary_router")) {
392 route
->type
= SECONDARY_ROUTER
;
393 } else if (!strcmp(tmp
, "multicast_router")) {
394 route
->type
= MULTICAST_ROUTER
;
396 PRINT_WARN("Invalid routing type '%s'.\n", tmp
);
399 if (((card
->state
== CARD_STATE_SOFTSETUP
) ||
400 (card
->state
== CARD_STATE_UP
)) &&
401 (old_route_type
!= route
->type
)){
402 if (prot
== QETH_PROT_IPV4
)
403 rc
= qeth_setrouting_v4(card
);
404 else if (prot
== QETH_PROT_IPV6
)
405 rc
= qeth_setrouting_v6(card
);
411 qeth_dev_route4_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
413 struct qeth_card
*card
= dev
->driver_data
;
418 return qeth_dev_route_store(card
, &card
->options
.route4
,
419 QETH_PROT_IPV4
, buf
, count
);
422 static DEVICE_ATTR(route4
, 0644, qeth_dev_route4_show
, qeth_dev_route4_store
);
424 #ifdef CONFIG_QETH_IPV6
426 qeth_dev_route6_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
428 struct qeth_card
*card
= dev
->driver_data
;
433 if (!qeth_is_supported(card
, IPA_IPV6
))
434 return sprintf(buf
, "%s\n", "n/a");
436 return qeth_dev_route_show(card
, &card
->options
.route6
, buf
);
440 qeth_dev_route6_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
442 struct qeth_card
*card
= dev
->driver_data
;
447 if (!qeth_is_supported(card
, IPA_IPV6
)){
448 PRINT_WARN("IPv6 not supported for interface %s.\n"
449 "Routing status no changed.\n",
450 QETH_CARD_IFNAME(card
));
454 return qeth_dev_route_store(card
, &card
->options
.route6
,
455 QETH_PROT_IPV6
, buf
, count
);
458 static DEVICE_ATTR(route6
, 0644, qeth_dev_route6_show
, qeth_dev_route6_store
);
462 qeth_dev_add_hhlen_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
464 struct qeth_card
*card
= dev
->driver_data
;
469 return sprintf(buf
, "%i\n", card
->options
.add_hhlen
);
473 qeth_dev_add_hhlen_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
475 struct qeth_card
*card
= dev
->driver_data
;
482 if ((card
->state
!= CARD_STATE_DOWN
) &&
483 (card
->state
!= CARD_STATE_RECOVER
))
486 i
= simple_strtoul(buf
, &tmp
, 10);
487 if ((i
< 0) || (i
> MAX_ADD_HHLEN
)) {
488 PRINT_WARN("add_hhlen out of range\n");
491 card
->options
.add_hhlen
= i
;
496 static DEVICE_ATTR(add_hhlen
, 0644, qeth_dev_add_hhlen_show
,
497 qeth_dev_add_hhlen_store
);
500 qeth_dev_fake_ll_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
502 struct qeth_card
*card
= dev
->driver_data
;
507 return sprintf(buf
, "%i\n", card
->options
.fake_ll
? 1:0);
511 qeth_dev_fake_ll_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
513 struct qeth_card
*card
= dev
->driver_data
;
520 if ((card
->state
!= CARD_STATE_DOWN
) &&
521 (card
->state
!= CARD_STATE_RECOVER
))
524 i
= simple_strtoul(buf
, &tmp
, 16);
525 if ((i
!= 0) && (i
!= 1)) {
526 PRINT_WARN("fake_ll: write 0 or 1 to this file!\n");
529 card
->options
.fake_ll
= i
;
533 static DEVICE_ATTR(fake_ll
, 0644, qeth_dev_fake_ll_show
,
534 qeth_dev_fake_ll_store
);
537 qeth_dev_fake_broadcast_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
539 struct qeth_card
*card
= dev
->driver_data
;
544 return sprintf(buf
, "%i\n", card
->options
.fake_broadcast
? 1:0);
548 qeth_dev_fake_broadcast_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
550 struct qeth_card
*card
= dev
->driver_data
;
557 if ((card
->state
!= CARD_STATE_DOWN
) &&
558 (card
->state
!= CARD_STATE_RECOVER
))
561 i
= simple_strtoul(buf
, &tmp
, 16);
562 if ((i
== 0) || (i
== 1))
563 card
->options
.fake_broadcast
= i
;
565 PRINT_WARN("fake_broadcast: write 0 or 1 to this file!\n");
571 static DEVICE_ATTR(fake_broadcast
, 0644, qeth_dev_fake_broadcast_show
,
572 qeth_dev_fake_broadcast_store
);
575 qeth_dev_recover_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
577 struct qeth_card
*card
= dev
->driver_data
;
584 if (card
->state
!= CARD_STATE_UP
)
587 i
= simple_strtoul(buf
, &tmp
, 16);
589 qeth_schedule_recovery(card
);
594 static DEVICE_ATTR(recover
, 0200, NULL
, qeth_dev_recover_store
);
597 qeth_dev_broadcast_mode_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
599 struct qeth_card
*card
= dev
->driver_data
;
604 if (!((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
605 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
)))
606 return sprintf(buf
, "n/a\n");
608 return sprintf(buf
, "%s\n", (card
->options
.broadcast_mode
==
609 QETH_TR_BROADCAST_ALLRINGS
)?
610 "all rings":"local");
614 qeth_dev_broadcast_mode_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
616 struct qeth_card
*card
= dev
->driver_data
;
622 if ((card
->state
!= CARD_STATE_DOWN
) &&
623 (card
->state
!= CARD_STATE_RECOVER
))
626 if (!((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
627 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
))){
628 PRINT_WARN("Device is not a tokenring device!\n");
632 tmp
= strsep((char **) &buf
, "\n");
634 if (!strcmp(tmp
, "local")){
635 card
->options
.broadcast_mode
= QETH_TR_BROADCAST_LOCAL
;
637 } else if (!strcmp(tmp
, "all_rings")) {
638 card
->options
.broadcast_mode
= QETH_TR_BROADCAST_ALLRINGS
;
641 PRINT_WARN("broadcast_mode: invalid mode %s!\n",
648 static DEVICE_ATTR(broadcast_mode
, 0644, qeth_dev_broadcast_mode_show
,
649 qeth_dev_broadcast_mode_store
);
652 qeth_dev_canonical_macaddr_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
654 struct qeth_card
*card
= dev
->driver_data
;
659 if (!((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
660 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
)))
661 return sprintf(buf
, "n/a\n");
663 return sprintf(buf
, "%i\n", (card
->options
.macaddr_mode
==
664 QETH_TR_MACADDR_CANONICAL
)? 1:0);
668 qeth_dev_canonical_macaddr_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
,
671 struct qeth_card
*card
= dev
->driver_data
;
678 if ((card
->state
!= CARD_STATE_DOWN
) &&
679 (card
->state
!= CARD_STATE_RECOVER
))
682 if (!((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
683 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
))){
684 PRINT_WARN("Device is not a tokenring device!\n");
688 i
= simple_strtoul(buf
, &tmp
, 16);
689 if ((i
== 0) || (i
== 1))
690 card
->options
.macaddr_mode
= i
?
691 QETH_TR_MACADDR_CANONICAL
:
692 QETH_TR_MACADDR_NONCANONICAL
;
694 PRINT_WARN("canonical_macaddr: write 0 or 1 to this file!\n");
700 static DEVICE_ATTR(canonical_macaddr
, 0644, qeth_dev_canonical_macaddr_show
,
701 qeth_dev_canonical_macaddr_store
);
704 qeth_dev_layer2_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
706 struct qeth_card
*card
= dev
->driver_data
;
711 return sprintf(buf
, "%i\n", card
->options
.layer2
? 1:0);
715 qeth_dev_layer2_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
717 struct qeth_card
*card
= dev
->driver_data
;
723 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
724 PRINT_WARN("Layer2 on Hipersockets is not supported! \n");
728 if (((card
->state
!= CARD_STATE_DOWN
) &&
729 (card
->state
!= CARD_STATE_RECOVER
)))
732 i
= simple_strtoul(buf
, &tmp
, 16);
733 if ((i
== 0) || (i
== 1))
734 card
->options
.layer2
= i
;
736 PRINT_WARN("layer2: write 0 or 1 to this file!\n");
742 static DEVICE_ATTR(layer2
, 0644, qeth_dev_layer2_show
,
743 qeth_dev_layer2_store
);
746 qeth_dev_performance_stats_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
748 struct qeth_card
*card
= dev
->driver_data
;
753 return sprintf(buf
, "%i\n", card
->options
.performance_stats
? 1:0);
757 qeth_dev_performance_stats_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
759 struct qeth_card
*card
= dev
->driver_data
;
766 i
= simple_strtoul(buf
, &tmp
, 16);
767 if ((i
== 0) || (i
== 1)) {
768 if (i
== card
->options
.performance_stats
)
770 card
->options
.performance_stats
= i
;
772 memset(&card
->perf_stats
, 0,
773 sizeof(struct qeth_perf_stats
));
774 card
->perf_stats
.initial_rx_packets
= card
->stats
.rx_packets
;
775 card
->perf_stats
.initial_tx_packets
= card
->stats
.tx_packets
;
777 PRINT_WARN("performance_stats: write 0 or 1 to this file!\n");
783 static DEVICE_ATTR(performance_stats
, 0644, qeth_dev_performance_stats_show
,
784 qeth_dev_performance_stats_store
);
787 qeth_dev_large_send_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
789 struct qeth_card
*card
= dev
->driver_data
;
794 switch (card
->options
.large_send
) {
795 case QETH_LARGE_SEND_NO
:
796 return sprintf(buf
, "%s\n", "no");
797 case QETH_LARGE_SEND_EDDP
:
798 return sprintf(buf
, "%s\n", "EDDP");
799 case QETH_LARGE_SEND_TSO
:
800 return sprintf(buf
, "%s\n", "TSO");
802 return sprintf(buf
, "%s\n", "N/A");
807 qeth_dev_large_send_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
809 struct qeth_card
*card
= dev
->driver_data
;
810 enum qeth_large_send_types type
;
816 tmp
= strsep((char **) &buf
, "\n");
817 if (!strcmp(tmp
, "no")){
818 type
= QETH_LARGE_SEND_NO
;
819 } else if (!strcmp(tmp
, "EDDP")) {
820 type
= QETH_LARGE_SEND_EDDP
;
821 } else if (!strcmp(tmp
, "TSO")) {
822 type
= QETH_LARGE_SEND_TSO
;
824 PRINT_WARN("large_send: invalid mode %s!\n", tmp
);
827 if (card
->options
.large_send
== type
)
829 if ((rc
= qeth_set_large_send(card
, type
)))
834 static DEVICE_ATTR(large_send
, 0644, qeth_dev_large_send_show
,
835 qeth_dev_large_send_store
);
838 qeth_dev_blkt_show(char *buf
, struct qeth_card
*card
, int value
)
844 return sprintf(buf
, "%i\n", value
);
848 qeth_dev_blkt_store(struct qeth_card
*card
, const char *buf
, size_t count
,
849 int *value
, int max_value
)
857 if ((card
->state
!= CARD_STATE_DOWN
) &&
858 (card
->state
!= CARD_STATE_RECOVER
))
861 i
= simple_strtoul(buf
, &tmp
, 10);
862 if (i
<= max_value
) {
865 PRINT_WARN("blkt total time: write values between"
866 " 0 and %d to this file!\n", max_value
);
873 qeth_dev_blkt_total_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
875 struct qeth_card
*card
= dev
->driver_data
;
877 return qeth_dev_blkt_show(buf
, card
, card
->info
.blkt
.time_total
);
882 qeth_dev_blkt_total_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
884 struct qeth_card
*card
= dev
->driver_data
;
886 return qeth_dev_blkt_store(card
, buf
, count
,
887 &card
->info
.blkt
.time_total
,1000);
892 static DEVICE_ATTR(total
, 0644, qeth_dev_blkt_total_show
,
893 qeth_dev_blkt_total_store
);
896 qeth_dev_blkt_inter_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
898 struct qeth_card
*card
= dev
->driver_data
;
900 return qeth_dev_blkt_show(buf
, card
, card
->info
.blkt
.inter_packet
);
905 qeth_dev_blkt_inter_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
907 struct qeth_card
*card
= dev
->driver_data
;
909 return qeth_dev_blkt_store(card
, buf
, count
,
910 &card
->info
.blkt
.inter_packet
,100);
913 static DEVICE_ATTR(inter
, 0644, qeth_dev_blkt_inter_show
,
914 qeth_dev_blkt_inter_store
);
917 qeth_dev_blkt_inter_jumbo_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
919 struct qeth_card
*card
= dev
->driver_data
;
921 return qeth_dev_blkt_show(buf
, card
,
922 card
->info
.blkt
.inter_packet_jumbo
);
927 qeth_dev_blkt_inter_jumbo_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
929 struct qeth_card
*card
= dev
->driver_data
;
931 return qeth_dev_blkt_store(card
, buf
, count
,
932 &card
->info
.blkt
.inter_packet_jumbo
,100);
935 static DEVICE_ATTR(inter_jumbo
, 0644, qeth_dev_blkt_inter_jumbo_show
,
936 qeth_dev_blkt_inter_jumbo_store
);
938 static struct device_attribute
* qeth_blkt_device_attrs
[] = {
941 &dev_attr_inter_jumbo
,
945 static struct attribute_group qeth_device_blkt_group
= {
947 .attrs
= (struct attribute
**)qeth_blkt_device_attrs
,
950 static struct device_attribute
* qeth_device_attrs
[] = {
957 &dev_attr_checksumming
,
958 &dev_attr_priority_queueing
,
959 &dev_attr_buffer_count
,
961 #ifdef CONFIG_QETH_IPV6
966 &dev_attr_fake_broadcast
,
968 &dev_attr_broadcast_mode
,
969 &dev_attr_canonical_macaddr
,
971 &dev_attr_large_send
,
972 &dev_attr_performance_stats
,
976 static struct attribute_group qeth_device_attr_group
= {
977 .attrs
= (struct attribute
**)qeth_device_attrs
,
980 static struct device_attribute
* qeth_osn_device_attrs
[] = {
985 &dev_attr_buffer_count
,
990 static struct attribute_group qeth_osn_device_attr_group
= {
991 .attrs
= (struct attribute
**)qeth_osn_device_attrs
,
994 #define QETH_DEVICE_ATTR(_id,_name,_mode,_show,_store) \
995 struct device_attribute dev_attr_##_id = { \
996 .attr = {.name=__stringify(_name), .mode=_mode, .owner=THIS_MODULE },\
1002 qeth_check_layer2(struct qeth_card
*card
)
1004 if (card
->options
.layer2
)
1011 qeth_dev_ipato_enable_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
1013 struct qeth_card
*card
= dev
->driver_data
;
1018 if (qeth_check_layer2(card
))
1020 return sprintf(buf
, "%i\n", card
->ipato
.enabled
? 1:0);
1024 qeth_dev_ipato_enable_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1026 struct qeth_card
*card
= dev
->driver_data
;
1032 if ((card
->state
!= CARD_STATE_DOWN
) &&
1033 (card
->state
!= CARD_STATE_RECOVER
))
1036 if (qeth_check_layer2(card
))
1039 tmp
= strsep((char **) &buf
, "\n");
1040 if (!strcmp(tmp
, "toggle")){
1041 card
->ipato
.enabled
= (card
->ipato
.enabled
)? 0 : 1;
1042 } else if (!strcmp(tmp
, "1")){
1043 card
->ipato
.enabled
= 1;
1044 } else if (!strcmp(tmp
, "0")){
1045 card
->ipato
.enabled
= 0;
1047 PRINT_WARN("ipato_enable: write 0, 1 or 'toggle' to "
1054 static QETH_DEVICE_ATTR(ipato_enable
, enable
, 0644,
1055 qeth_dev_ipato_enable_show
,
1056 qeth_dev_ipato_enable_store
);
1059 qeth_dev_ipato_invert4_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
1061 struct qeth_card
*card
= dev
->driver_data
;
1066 if (qeth_check_layer2(card
))
1069 return sprintf(buf
, "%i\n", card
->ipato
.invert4
? 1:0);
1073 qeth_dev_ipato_invert4_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1075 struct qeth_card
*card
= dev
->driver_data
;
1081 if (qeth_check_layer2(card
))
1084 tmp
= strsep((char **) &buf
, "\n");
1085 if (!strcmp(tmp
, "toggle")){
1086 card
->ipato
.invert4
= (card
->ipato
.invert4
)? 0 : 1;
1087 } else if (!strcmp(tmp
, "1")){
1088 card
->ipato
.invert4
= 1;
1089 } else if (!strcmp(tmp
, "0")){
1090 card
->ipato
.invert4
= 0;
1092 PRINT_WARN("ipato_invert4: write 0, 1 or 'toggle' to "
1099 static QETH_DEVICE_ATTR(ipato_invert4
, invert4
, 0644,
1100 qeth_dev_ipato_invert4_show
,
1101 qeth_dev_ipato_invert4_store
);
1104 qeth_dev_ipato_add_show(char *buf
, struct qeth_card
*card
,
1105 enum qeth_prot_versions proto
)
1107 struct qeth_ipato_entry
*ipatoe
;
1108 unsigned long flags
;
1110 int entry_len
; /* length of 1 entry string, differs between v4 and v6 */
1113 if (qeth_check_layer2(card
))
1116 entry_len
= (proto
== QETH_PROT_IPV4
)? 12 : 40;
1117 /* add strlen for "/<mask>\n" */
1118 entry_len
+= (proto
== QETH_PROT_IPV4
)? 5 : 6;
1119 spin_lock_irqsave(&card
->ip_lock
, flags
);
1120 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
){
1121 if (ipatoe
->proto
!= proto
)
1123 /* String must not be longer than PAGE_SIZE. So we check if
1124 * string length gets near PAGE_SIZE. Then we can savely display
1125 * the next IPv6 address (worst case, compared to IPv4) */
1126 if ((PAGE_SIZE
- i
) <= entry_len
)
1128 qeth_ipaddr_to_string(proto
, ipatoe
->addr
, addr_str
);
1129 i
+= snprintf(buf
+ i
, PAGE_SIZE
- i
,
1130 "%s/%i\n", addr_str
, ipatoe
->mask_bits
);
1132 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
1133 i
+= snprintf(buf
+ i
, PAGE_SIZE
- i
, "\n");
1139 qeth_dev_ipato_add4_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
1141 struct qeth_card
*card
= dev
->driver_data
;
1146 return qeth_dev_ipato_add_show(buf
, card
, QETH_PROT_IPV4
);
1150 qeth_parse_ipatoe(const char* buf
, enum qeth_prot_versions proto
,
1151 u8
*addr
, int *mask_bits
)
1153 const char *start
, *end
;
1155 char buffer
[40] = {0, };
1158 /* get address string */
1159 end
= strchr(start
, '/');
1160 if (!end
|| (end
- start
>= 40)){
1161 PRINT_WARN("Invalid format for ipato_addx/delx. "
1162 "Use <ip addr>/<mask bits>\n");
1165 strncpy(buffer
, start
, end
- start
);
1166 if (qeth_string_to_ipaddr(buffer
, proto
, addr
)){
1167 PRINT_WARN("Invalid IP address format!\n");
1171 *mask_bits
= simple_strtoul(start
, &tmp
, 10);
1172 if (!strlen(start
) ||
1174 (*mask_bits
> ((proto
== QETH_PROT_IPV4
) ? 32 : 128))) {
1175 PRINT_WARN("Invalid mask bits for ipato_addx/delx !\n");
1182 qeth_dev_ipato_add_store(const char *buf
, size_t count
,
1183 struct qeth_card
*card
, enum qeth_prot_versions proto
)
1185 struct qeth_ipato_entry
*ipatoe
;
1190 if (qeth_check_layer2(card
))
1192 if ((rc
= qeth_parse_ipatoe(buf
, proto
, addr
, &mask_bits
)))
1195 if (!(ipatoe
= kzalloc(sizeof(struct qeth_ipato_entry
), GFP_KERNEL
))){
1196 PRINT_WARN("No memory to allocate ipato entry\n");
1199 ipatoe
->proto
= proto
;
1200 memcpy(ipatoe
->addr
, addr
, (proto
== QETH_PROT_IPV4
)? 4:16);
1201 ipatoe
->mask_bits
= mask_bits
;
1203 if ((rc
= qeth_add_ipato_entry(card
, ipatoe
))){
1212 qeth_dev_ipato_add4_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1214 struct qeth_card
*card
= dev
->driver_data
;
1219 return qeth_dev_ipato_add_store(buf
, count
, card
, QETH_PROT_IPV4
);
1222 static QETH_DEVICE_ATTR(ipato_add4
, add4
, 0644,
1223 qeth_dev_ipato_add4_show
,
1224 qeth_dev_ipato_add4_store
);
1227 qeth_dev_ipato_del_store(const char *buf
, size_t count
,
1228 struct qeth_card
*card
, enum qeth_prot_versions proto
)
1234 if (qeth_check_layer2(card
))
1236 if ((rc
= qeth_parse_ipatoe(buf
, proto
, addr
, &mask_bits
)))
1239 qeth_del_ipato_entry(card
, proto
, addr
, mask_bits
);
1245 qeth_dev_ipato_del4_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1247 struct qeth_card
*card
= dev
->driver_data
;
1252 return qeth_dev_ipato_del_store(buf
, count
, card
, QETH_PROT_IPV4
);
1255 static QETH_DEVICE_ATTR(ipato_del4
, del4
, 0200, NULL
,
1256 qeth_dev_ipato_del4_store
);
1258 #ifdef CONFIG_QETH_IPV6
1260 qeth_dev_ipato_invert6_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
1262 struct qeth_card
*card
= dev
->driver_data
;
1267 if (qeth_check_layer2(card
))
1270 return sprintf(buf
, "%i\n", card
->ipato
.invert6
? 1:0);
1274 qeth_dev_ipato_invert6_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1276 struct qeth_card
*card
= dev
->driver_data
;
1282 if (qeth_check_layer2(card
))
1285 tmp
= strsep((char **) &buf
, "\n");
1286 if (!strcmp(tmp
, "toggle")){
1287 card
->ipato
.invert6
= (card
->ipato
.invert6
)? 0 : 1;
1288 } else if (!strcmp(tmp
, "1")){
1289 card
->ipato
.invert6
= 1;
1290 } else if (!strcmp(tmp
, "0")){
1291 card
->ipato
.invert6
= 0;
1293 PRINT_WARN("ipato_invert6: write 0, 1 or 'toggle' to "
1300 static QETH_DEVICE_ATTR(ipato_invert6
, invert6
, 0644,
1301 qeth_dev_ipato_invert6_show
,
1302 qeth_dev_ipato_invert6_store
);
1306 qeth_dev_ipato_add6_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
1308 struct qeth_card
*card
= dev
->driver_data
;
1313 return qeth_dev_ipato_add_show(buf
, card
, QETH_PROT_IPV6
);
1317 qeth_dev_ipato_add6_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1319 struct qeth_card
*card
= dev
->driver_data
;
1324 return qeth_dev_ipato_add_store(buf
, count
, card
, QETH_PROT_IPV6
);
1327 static QETH_DEVICE_ATTR(ipato_add6
, add6
, 0644,
1328 qeth_dev_ipato_add6_show
,
1329 qeth_dev_ipato_add6_store
);
1332 qeth_dev_ipato_del6_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1334 struct qeth_card
*card
= dev
->driver_data
;
1339 return qeth_dev_ipato_del_store(buf
, count
, card
, QETH_PROT_IPV6
);
1342 static QETH_DEVICE_ATTR(ipato_del6
, del6
, 0200, NULL
,
1343 qeth_dev_ipato_del6_store
);
1344 #endif /* CONFIG_QETH_IPV6 */
1346 static struct device_attribute
* qeth_ipato_device_attrs
[] = {
1347 &dev_attr_ipato_enable
,
1348 &dev_attr_ipato_invert4
,
1349 &dev_attr_ipato_add4
,
1350 &dev_attr_ipato_del4
,
1351 #ifdef CONFIG_QETH_IPV6
1352 &dev_attr_ipato_invert6
,
1353 &dev_attr_ipato_add6
,
1354 &dev_attr_ipato_del6
,
1359 static struct attribute_group qeth_device_ipato_group
= {
1360 .name
= "ipa_takeover",
1361 .attrs
= (struct attribute
**)qeth_ipato_device_attrs
,
1365 qeth_dev_vipa_add_show(char *buf
, struct qeth_card
*card
,
1366 enum qeth_prot_versions proto
)
1368 struct qeth_ipaddr
*ipaddr
;
1370 int entry_len
; /* length of 1 entry string, differs between v4 and v6 */
1371 unsigned long flags
;
1374 if (qeth_check_layer2(card
))
1377 entry_len
= (proto
== QETH_PROT_IPV4
)? 12 : 40;
1378 entry_len
+= 2; /* \n + terminator */
1379 spin_lock_irqsave(&card
->ip_lock
, flags
);
1380 list_for_each_entry(ipaddr
, &card
->ip_list
, entry
){
1381 if (ipaddr
->proto
!= proto
)
1383 if (ipaddr
->type
!= QETH_IP_TYPE_VIPA
)
1385 /* String must not be longer than PAGE_SIZE. So we check if
1386 * string length gets near PAGE_SIZE. Then we can savely display
1387 * the next IPv6 address (worst case, compared to IPv4) */
1388 if ((PAGE_SIZE
- i
) <= entry_len
)
1390 qeth_ipaddr_to_string(proto
, (const u8
*)&ipaddr
->u
, addr_str
);
1391 i
+= snprintf(buf
+ i
, PAGE_SIZE
- i
, "%s\n", addr_str
);
1393 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
1394 i
+= snprintf(buf
+ i
, PAGE_SIZE
- i
, "\n");
1400 qeth_dev_vipa_add4_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
1402 struct qeth_card
*card
= dev
->driver_data
;
1407 return qeth_dev_vipa_add_show(buf
, card
, QETH_PROT_IPV4
);
1411 qeth_parse_vipae(const char* buf
, enum qeth_prot_versions proto
,
1414 if (qeth_string_to_ipaddr(buf
, proto
, addr
)){
1415 PRINT_WARN("Invalid IP address format!\n");
1422 qeth_dev_vipa_add_store(const char *buf
, size_t count
,
1423 struct qeth_card
*card
, enum qeth_prot_versions proto
)
1425 u8 addr
[16] = {0, };
1428 if (qeth_check_layer2(card
))
1430 if ((rc
= qeth_parse_vipae(buf
, proto
, addr
)))
1433 if ((rc
= qeth_add_vipa(card
, proto
, addr
)))
1440 qeth_dev_vipa_add4_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1442 struct qeth_card
*card
= dev
->driver_data
;
1447 return qeth_dev_vipa_add_store(buf
, count
, card
, QETH_PROT_IPV4
);
1450 static QETH_DEVICE_ATTR(vipa_add4
, add4
, 0644,
1451 qeth_dev_vipa_add4_show
,
1452 qeth_dev_vipa_add4_store
);
1455 qeth_dev_vipa_del_store(const char *buf
, size_t count
,
1456 struct qeth_card
*card
, enum qeth_prot_versions proto
)
1461 if (qeth_check_layer2(card
))
1463 if ((rc
= qeth_parse_vipae(buf
, proto
, addr
)))
1466 qeth_del_vipa(card
, proto
, addr
);
1472 qeth_dev_vipa_del4_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1474 struct qeth_card
*card
= dev
->driver_data
;
1479 return qeth_dev_vipa_del_store(buf
, count
, card
, QETH_PROT_IPV4
);
1482 static QETH_DEVICE_ATTR(vipa_del4
, del4
, 0200, NULL
,
1483 qeth_dev_vipa_del4_store
);
1485 #ifdef CONFIG_QETH_IPV6
1487 qeth_dev_vipa_add6_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
1489 struct qeth_card
*card
= dev
->driver_data
;
1494 return qeth_dev_vipa_add_show(buf
, card
, QETH_PROT_IPV6
);
1498 qeth_dev_vipa_add6_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1500 struct qeth_card
*card
= dev
->driver_data
;
1505 return qeth_dev_vipa_add_store(buf
, count
, card
, QETH_PROT_IPV6
);
1508 static QETH_DEVICE_ATTR(vipa_add6
, add6
, 0644,
1509 qeth_dev_vipa_add6_show
,
1510 qeth_dev_vipa_add6_store
);
1513 qeth_dev_vipa_del6_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1515 struct qeth_card
*card
= dev
->driver_data
;
1520 if (qeth_check_layer2(card
))
1523 return qeth_dev_vipa_del_store(buf
, count
, card
, QETH_PROT_IPV6
);
1526 static QETH_DEVICE_ATTR(vipa_del6
, del6
, 0200, NULL
,
1527 qeth_dev_vipa_del6_store
);
1528 #endif /* CONFIG_QETH_IPV6 */
1530 static struct device_attribute
* qeth_vipa_device_attrs
[] = {
1531 &dev_attr_vipa_add4
,
1532 &dev_attr_vipa_del4
,
1533 #ifdef CONFIG_QETH_IPV6
1534 &dev_attr_vipa_add6
,
1535 &dev_attr_vipa_del6
,
1540 static struct attribute_group qeth_device_vipa_group
= {
1542 .attrs
= (struct attribute
**)qeth_vipa_device_attrs
,
1546 qeth_dev_rxip_add_show(char *buf
, struct qeth_card
*card
,
1547 enum qeth_prot_versions proto
)
1549 struct qeth_ipaddr
*ipaddr
;
1551 int entry_len
; /* length of 1 entry string, differs between v4 and v6 */
1552 unsigned long flags
;
1555 if (qeth_check_layer2(card
))
1558 entry_len
= (proto
== QETH_PROT_IPV4
)? 12 : 40;
1559 entry_len
+= 2; /* \n + terminator */
1560 spin_lock_irqsave(&card
->ip_lock
, flags
);
1561 list_for_each_entry(ipaddr
, &card
->ip_list
, entry
){
1562 if (ipaddr
->proto
!= proto
)
1564 if (ipaddr
->type
!= QETH_IP_TYPE_RXIP
)
1566 /* String must not be longer than PAGE_SIZE. So we check if
1567 * string length gets near PAGE_SIZE. Then we can savely display
1568 * the next IPv6 address (worst case, compared to IPv4) */
1569 if ((PAGE_SIZE
- i
) <= entry_len
)
1571 qeth_ipaddr_to_string(proto
, (const u8
*)&ipaddr
->u
, addr_str
);
1572 i
+= snprintf(buf
+ i
, PAGE_SIZE
- i
, "%s\n", addr_str
);
1574 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
1575 i
+= snprintf(buf
+ i
, PAGE_SIZE
- i
, "\n");
1581 qeth_dev_rxip_add4_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
1583 struct qeth_card
*card
= dev
->driver_data
;
1588 return qeth_dev_rxip_add_show(buf
, card
, QETH_PROT_IPV4
);
1592 qeth_parse_rxipe(const char* buf
, enum qeth_prot_versions proto
,
1595 if (qeth_string_to_ipaddr(buf
, proto
, addr
)){
1596 PRINT_WARN("Invalid IP address format!\n");
1603 qeth_dev_rxip_add_store(const char *buf
, size_t count
,
1604 struct qeth_card
*card
, enum qeth_prot_versions proto
)
1606 u8 addr
[16] = {0, };
1609 if (qeth_check_layer2(card
))
1611 if ((rc
= qeth_parse_rxipe(buf
, proto
, addr
)))
1614 if ((rc
= qeth_add_rxip(card
, proto
, addr
)))
1621 qeth_dev_rxip_add4_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1623 struct qeth_card
*card
= dev
->driver_data
;
1628 return qeth_dev_rxip_add_store(buf
, count
, card
, QETH_PROT_IPV4
);
1631 static QETH_DEVICE_ATTR(rxip_add4
, add4
, 0644,
1632 qeth_dev_rxip_add4_show
,
1633 qeth_dev_rxip_add4_store
);
1636 qeth_dev_rxip_del_store(const char *buf
, size_t count
,
1637 struct qeth_card
*card
, enum qeth_prot_versions proto
)
1642 if (qeth_check_layer2(card
))
1644 if ((rc
= qeth_parse_rxipe(buf
, proto
, addr
)))
1647 qeth_del_rxip(card
, proto
, addr
);
1653 qeth_dev_rxip_del4_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1655 struct qeth_card
*card
= dev
->driver_data
;
1660 return qeth_dev_rxip_del_store(buf
, count
, card
, QETH_PROT_IPV4
);
1663 static QETH_DEVICE_ATTR(rxip_del4
, del4
, 0200, NULL
,
1664 qeth_dev_rxip_del4_store
);
1666 #ifdef CONFIG_QETH_IPV6
1668 qeth_dev_rxip_add6_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
1670 struct qeth_card
*card
= dev
->driver_data
;
1675 return qeth_dev_rxip_add_show(buf
, card
, QETH_PROT_IPV6
);
1679 qeth_dev_rxip_add6_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1681 struct qeth_card
*card
= dev
->driver_data
;
1686 return qeth_dev_rxip_add_store(buf
, count
, card
, QETH_PROT_IPV6
);
1689 static QETH_DEVICE_ATTR(rxip_add6
, add6
, 0644,
1690 qeth_dev_rxip_add6_show
,
1691 qeth_dev_rxip_add6_store
);
1694 qeth_dev_rxip_del6_store(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
1696 struct qeth_card
*card
= dev
->driver_data
;
1701 return qeth_dev_rxip_del_store(buf
, count
, card
, QETH_PROT_IPV6
);
1704 static QETH_DEVICE_ATTR(rxip_del6
, del6
, 0200, NULL
,
1705 qeth_dev_rxip_del6_store
);
1706 #endif /* CONFIG_QETH_IPV6 */
1708 static struct device_attribute
* qeth_rxip_device_attrs
[] = {
1709 &dev_attr_rxip_add4
,
1710 &dev_attr_rxip_del4
,
1711 #ifdef CONFIG_QETH_IPV6
1712 &dev_attr_rxip_add6
,
1713 &dev_attr_rxip_del6
,
1718 static struct attribute_group qeth_device_rxip_group
= {
1720 .attrs
= (struct attribute
**)qeth_rxip_device_attrs
,
1724 qeth_create_device_attributes(struct device
*dev
)
1727 struct qeth_card
*card
= dev
->driver_data
;
1729 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
1730 return sysfs_create_group(&dev
->kobj
,
1731 &qeth_osn_device_attr_group
);
1733 if ((ret
= sysfs_create_group(&dev
->kobj
, &qeth_device_attr_group
)))
1735 if ((ret
= sysfs_create_group(&dev
->kobj
, &qeth_device_ipato_group
))){
1736 sysfs_remove_group(&dev
->kobj
, &qeth_device_attr_group
);
1739 if ((ret
= sysfs_create_group(&dev
->kobj
, &qeth_device_vipa_group
))){
1740 sysfs_remove_group(&dev
->kobj
, &qeth_device_attr_group
);
1741 sysfs_remove_group(&dev
->kobj
, &qeth_device_ipato_group
);
1744 if ((ret
= sysfs_create_group(&dev
->kobj
, &qeth_device_rxip_group
))){
1745 sysfs_remove_group(&dev
->kobj
, &qeth_device_attr_group
);
1746 sysfs_remove_group(&dev
->kobj
, &qeth_device_ipato_group
);
1747 sysfs_remove_group(&dev
->kobj
, &qeth_device_vipa_group
);
1750 if ((ret
= sysfs_create_group(&dev
->kobj
, &qeth_device_blkt_group
))){
1751 sysfs_remove_group(&dev
->kobj
, &qeth_device_attr_group
);
1752 sysfs_remove_group(&dev
->kobj
, &qeth_device_ipato_group
);
1753 sysfs_remove_group(&dev
->kobj
, &qeth_device_vipa_group
);
1754 sysfs_remove_group(&dev
->kobj
, &qeth_device_rxip_group
);
1761 qeth_remove_device_attributes(struct device
*dev
)
1763 struct qeth_card
*card
= dev
->driver_data
;
1765 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
1766 return sysfs_remove_group(&dev
->kobj
,
1767 &qeth_osn_device_attr_group
);
1769 sysfs_remove_group(&dev
->kobj
, &qeth_device_attr_group
);
1770 sysfs_remove_group(&dev
->kobj
, &qeth_device_ipato_group
);
1771 sysfs_remove_group(&dev
->kobj
, &qeth_device_vipa_group
);
1772 sysfs_remove_group(&dev
->kobj
, &qeth_device_rxip_group
);
1773 sysfs_remove_group(&dev
->kobj
, &qeth_device_blkt_group
);
1776 /**********************/
1777 /* DRIVER ATTRIBUTES */
1778 /**********************/
1780 qeth_driver_group_store(struct device_driver
*ddrv
, const char *buf
,
1783 const char *start
, *end
;
1784 char bus_ids
[3][BUS_ID_SIZE
], *argv
[3];
1789 for (i
= 0; i
< 3; i
++) {
1790 static const char delim
[] = { ',', ',', '\n' };
1793 if (!(end
= strchr(start
, delim
[i
])))
1795 len
= min_t(ptrdiff_t, BUS_ID_SIZE
, end
- start
);
1796 strncpy(bus_ids
[i
], start
, len
);
1797 bus_ids
[i
][len
] = '\0';
1799 argv
[i
] = bus_ids
[i
];
1801 err
= ccwgroup_create(qeth_root_dev
, qeth_ccwgroup_driver
.driver_id
,
1802 &qeth_ccw_driver
, 3, argv
);
1810 static DRIVER_ATTR(group
, 0200, NULL
, qeth_driver_group_store
);
1813 qeth_driver_notifier_register_store(struct device_driver
*ddrv
, const char *buf
,
1820 tmp
= strsep((char **) &buf
, "\n");
1821 if (!strncmp(tmp
, "unregister", 10)){
1822 if ((rc
= qeth_notifier_unregister(current
)))
1827 signum
= simple_strtoul(tmp
, &tmp2
, 10);
1828 if ((signum
< 0) || (signum
> 32)){
1829 PRINT_WARN("Signal number %d is out of range\n", signum
);
1832 if ((rc
= qeth_notifier_register(current
, signum
)))
1838 static DRIVER_ATTR(notifier_register
, 0200, NULL
,
1839 qeth_driver_notifier_register_store
);
1842 qeth_create_driver_attributes(void)
1846 if ((rc
= driver_create_file(&qeth_ccwgroup_driver
.driver
,
1847 &driver_attr_group
)))
1849 return driver_create_file(&qeth_ccwgroup_driver
.driver
,
1850 &driver_attr_notifier_register
);
1854 qeth_remove_driver_attributes(void)
1856 driver_remove_file(&qeth_ccwgroup_driver
.driver
,
1857 &driver_attr_group
);
1858 driver_remove_file(&qeth_ccwgroup_driver
.driver
,
1859 &driver_attr_notifier_register
);