9 #include <linux/slab.h>
13 #define QETH_DEVICE_ATTR(_id, _name, _mode, _show, _store) \
14 struct device_attribute dev_attr_##_id = __ATTR(_name, _mode, _show, _store)
19 switch (route->
type) {
21 return sprintf(buf,
"%s\n",
"primary router");
23 return sprintf(buf,
"%s\n",
"secondary router");
26 return sprintf(buf,
"%s\n",
"multicast router+");
28 return sprintf(buf,
"%s\n",
"multicast router");
31 return sprintf(buf,
"%s\n",
"primary connector+");
33 return sprintf(buf,
"%s\n",
"primary connector");
36 return sprintf(buf,
"%s\n",
"secondary connector+");
38 return sprintf(buf,
"%s\n",
"secondary connector");
40 return sprintf(buf,
"%s\n",
"no");
52 return qeth_l3_dev_route_show(card, &card->
options.route4, buf);
57 const char *buf,
size_t count)
63 tmp =
strsep((
char **) &buf,
"\n");
65 if (!
strcmp(tmp,
"no_router")) {
67 }
else if (!
strcmp(tmp,
"primary_connector")) {
69 }
else if (!
strcmp(tmp,
"secondary_connector")) {
71 }
else if (!
strcmp(tmp,
"primary_router")) {
73 }
else if (!
strcmp(tmp,
"secondary_router")) {
75 }
else if (!
strcmp(tmp,
"multicast_router")) {
83 (old_route_type != route->
type)) {
91 return rc ? rc :
count;
102 return qeth_l3_dev_route_store(card, &card->
options.route4,
106 static DEVICE_ATTR(route4, 0644, qeth_l3_dev_route4_show,
107 qeth_l3_dev_route4_store);
117 return qeth_l3_dev_route_show(card, &card->
options.route6, buf);
128 return qeth_l3_dev_route_store(card, &card->
options.route6,
132 static DEVICE_ATTR(route6, 0644, qeth_l3_dev_route6_show,
133 qeth_l3_dev_route6_store);
135 static ssize_t qeth_l3_dev_fake_broadcast_show(
struct device *dev,
146 static ssize_t qeth_l3_dev_fake_broadcast_store(
struct device *dev,
164 if ((i == 0) || (i == 1))
170 return rc ? rc :
count;
173 static DEVICE_ATTR(fake_broadcast, 0644, qeth_l3_dev_fake_broadcast_show,
174 qeth_l3_dev_fake_broadcast_store);
222 if (card->
qdio.init_pool.buf_count !=
234 return rc ? rc :
count;
237 static DEVICE_ATTR(sniffer, 0644, qeth_l3_dev_sniffer_show,
238 qeth_l3_dev_sniffer_store);
258 return sprintf(buf,
"%s\n", tmp_hsuid);
282 tmp =
strsep((
char **)&buf,
"\n");
290 addr->
u.
a6.addr.s6_addr32[0] = 0xfe800000;
291 addr->
u.
a6.addr.s6_addr32[1] = 0x00000000;
292 for (i = 8; i < 16; i++)
293 addr->
u.
a6.addr.s6_addr[i] =
295 addr->
u.
a6.pfxlen = 0;
316 for (i = 0; i < 8; i++)
326 addr->
u.
a6.addr.s6_addr32[0] = 0xfe800000;
327 addr->
u.
a6.addr.s6_addr32[1] = 0x00000000;
328 for (i = 8; i < 16; i++)
329 addr->
u.
a6.addr.s6_addr[i] = card->
options.hsuid[i - 8];
330 addr->
u.
a6.pfxlen = 0;
341 static DEVICE_ATTR(hsuid, 0644, qeth_l3_dev_hsuid_show,
342 qeth_l3_dev_hsuid_store);
345 static struct attribute *qeth_l3_device_attrs[] = {
346 &dev_attr_route4.attr,
347 &dev_attr_route6.attr,
348 &dev_attr_fake_broadcast.attr,
349 &dev_attr_sniffer.attr,
350 &dev_attr_hsuid.attr,
355 .attrs = qeth_l3_device_attrs,
358 static ssize_t qeth_l3_dev_ipato_enable_show(
struct device *dev,
369 static ssize_t qeth_l3_dev_ipato_enable_store(
struct device *dev,
387 tmp =
strsep((
char **) &buf,
"\n");
388 if (!
strcmp(tmp,
"toggle")) {
389 card->
ipato.enabled = (card->
ipato.enabled)? 0 : 1;
390 }
else if (!
strcmp(tmp,
"1")) {
391 card->
ipato.enabled = 1;
399 }
else if (!
strcmp(tmp,
"0")) {
400 card->
ipato.enabled = 0;
411 return rc ? rc :
count;
415 qeth_l3_dev_ipato_enable_show,
416 qeth_l3_dev_ipato_enable_store);
418 static ssize_t qeth_l3_dev_ipato_invert4_show(
struct device *dev,
429 static ssize_t qeth_l3_dev_ipato_invert4_store(
struct device *dev,
431 const char *buf,
size_t count)
441 tmp =
strsep((
char **) &buf,
"\n");
442 if (!
strcmp(tmp,
"toggle")) {
443 card->
ipato.invert4 = (card->
ipato.invert4)? 0 : 1;
444 }
else if (!
strcmp(tmp,
"1")) {
445 card->
ipato.invert4 = 1;
446 }
else if (!
strcmp(tmp,
"0")) {
447 card->
ipato.invert4 = 0;
451 return rc ? rc :
count;
455 qeth_l3_dev_ipato_invert4_show,
456 qeth_l3_dev_ipato_invert4_store);
458 static ssize_t qeth_l3_dev_ipato_add_show(
char *buf,
struct qeth_card *card,
472 if (ipatoe->
proto != proto)
483 spin_unlock_irqrestore(&card->
ip_lock, flags);
489 static ssize_t qeth_l3_dev_ipato_add4_show(
struct device *dev,
510 if (!end || (end - start >= 40)) {
513 strncpy(buffer, start, end - start);
527 static ssize_t qeth_l3_dev_ipato_add_store(
const char *buf,
size_t count,
536 rc = qeth_l3_parse_ipatoe(buf, proto, addr, &mask_bits);
554 return rc ? rc :
count;
557 static ssize_t qeth_l3_dev_ipato_add4_store(
struct device *dev,
565 return qeth_l3_dev_ipato_add_store(buf, count, card,
QETH_PROT_IPV4);
569 qeth_l3_dev_ipato_add4_show,
570 qeth_l3_dev_ipato_add4_store);
572 static ssize_t qeth_l3_dev_ipato_del_store(
const char *buf,
size_t count,
580 rc = qeth_l3_parse_ipatoe(buf, proto, addr, &mask_bits);
584 return rc ? rc :
count;
587 static ssize_t qeth_l3_dev_ipato_del4_store(
struct device *dev,
595 return qeth_l3_dev_ipato_del_store(buf, count, card,
QETH_PROT_IPV4);
599 qeth_l3_dev_ipato_del4_store);
601 static ssize_t qeth_l3_dev_ipato_invert6_show(
struct device *dev,
612 static ssize_t qeth_l3_dev_ipato_invert6_store(
struct device *dev,
623 tmp =
strsep((
char **) &buf,
"\n");
624 if (!
strcmp(tmp,
"toggle")) {
625 card->
ipato.invert6 = (card->
ipato.invert6)? 0 : 1;
626 }
else if (!
strcmp(tmp,
"1")) {
627 card->
ipato.invert6 = 1;
628 }
else if (!
strcmp(tmp,
"0")) {
629 card->
ipato.invert6 = 0;
633 return rc ? rc :
count;
637 qeth_l3_dev_ipato_invert6_show,
638 qeth_l3_dev_ipato_invert6_store);
641 static ssize_t qeth_l3_dev_ipato_add6_show(
struct device *dev,
652 static ssize_t qeth_l3_dev_ipato_add6_store(
struct device *dev,
660 return qeth_l3_dev_ipato_add_store(buf, count, card,
QETH_PROT_IPV6);
664 qeth_l3_dev_ipato_add6_show,
665 qeth_l3_dev_ipato_add6_store);
667 static ssize_t qeth_l3_dev_ipato_del6_store(
struct device *dev,
675 return qeth_l3_dev_ipato_del_store(buf, count, card,
QETH_PROT_IPV6);
679 qeth_l3_dev_ipato_del6_store);
681 static struct attribute *qeth_ipato_device_attrs[] = {
682 &dev_attr_ipato_enable.attr,
683 &dev_attr_ipato_invert4.attr,
684 &dev_attr_ipato_add4.attr,
685 &dev_attr_ipato_del4.attr,
686 &dev_attr_ipato_invert6.attr,
687 &dev_attr_ipato_add6.attr,
688 &dev_attr_ipato_del6.attr,
693 .name =
"ipa_takeover",
694 .attrs = qeth_ipato_device_attrs,
710 if (ipaddr->
proto != proto)
723 spin_unlock_irqrestore(&card->
ip_lock, flags);
729 static ssize_t qeth_l3_dev_vipa_add4_show(
struct device *dev,
749 static ssize_t qeth_l3_dev_vipa_add_store(
const char *buf,
size_t count,
756 rc = qeth_l3_parse_vipae(buf, proto, addr);
760 return rc ? rc :
count;
763 static ssize_t qeth_l3_dev_vipa_add4_store(
struct device *dev,
771 return qeth_l3_dev_vipa_add_store(buf, count, card,
QETH_PROT_IPV4);
775 qeth_l3_dev_vipa_add4_show,
776 qeth_l3_dev_vipa_add4_store);
778 static ssize_t qeth_l3_dev_vipa_del_store(
const char *buf,
size_t count,
785 rc = qeth_l3_parse_vipae(buf, proto, addr);
789 return rc ? rc :
count;
792 static ssize_t qeth_l3_dev_vipa_del4_store(
struct device *dev,
800 return qeth_l3_dev_vipa_del_store(buf, count, card,
QETH_PROT_IPV4);
804 qeth_l3_dev_vipa_del4_store);
806 static ssize_t qeth_l3_dev_vipa_add6_show(
struct device *dev,
817 static ssize_t qeth_l3_dev_vipa_add6_store(
struct device *dev,
825 return qeth_l3_dev_vipa_add_store(buf, count, card,
QETH_PROT_IPV6);
829 qeth_l3_dev_vipa_add6_show,
830 qeth_l3_dev_vipa_add6_store);
832 static ssize_t qeth_l3_dev_vipa_del6_store(
struct device *dev,
840 return qeth_l3_dev_vipa_del_store(buf, count, card,
QETH_PROT_IPV6);
844 qeth_l3_dev_vipa_del6_store);
846 static struct attribute *qeth_vipa_device_attrs[] = {
847 &dev_attr_vipa_add4.attr,
848 &dev_attr_vipa_del4.attr,
849 &dev_attr_vipa_add6.attr,
850 &dev_attr_vipa_del6.attr,
856 .attrs = qeth_vipa_device_attrs,
872 if (ipaddr->
proto != proto)
885 spin_unlock_irqrestore(&card->
ip_lock, flags);
891 static ssize_t qeth_l3_dev_rxip_add4_show(
struct device *dev,
911 static ssize_t qeth_l3_dev_rxip_add_store(
const char *buf,
size_t count,
918 rc = qeth_l3_parse_rxipe(buf, proto, addr);
922 return rc ? rc :
count;
925 static ssize_t qeth_l3_dev_rxip_add4_store(
struct device *dev,
933 return qeth_l3_dev_rxip_add_store(buf, count, card,
QETH_PROT_IPV4);
937 qeth_l3_dev_rxip_add4_show,
938 qeth_l3_dev_rxip_add4_store);
940 static ssize_t qeth_l3_dev_rxip_del_store(
const char *buf,
size_t count,
947 rc = qeth_l3_parse_rxipe(buf, proto, addr);
951 return rc ? rc :
count;
954 static ssize_t qeth_l3_dev_rxip_del4_store(
struct device *dev,
962 return qeth_l3_dev_rxip_del_store(buf, count, card,
QETH_PROT_IPV4);
966 qeth_l3_dev_rxip_del4_store);
968 static ssize_t qeth_l3_dev_rxip_add6_show(
struct device *dev,
979 static ssize_t qeth_l3_dev_rxip_add6_store(
struct device *dev,
987 return qeth_l3_dev_rxip_add_store(buf, count, card,
QETH_PROT_IPV6);
991 qeth_l3_dev_rxip_add6_show,
992 qeth_l3_dev_rxip_add6_store);
994 static ssize_t qeth_l3_dev_rxip_del6_store(
struct device *dev,
1002 return qeth_l3_dev_rxip_del_store(buf, count, card,
QETH_PROT_IPV6);
1006 qeth_l3_dev_rxip_del6_store);
1008 static struct attribute *qeth_rxip_device_attrs[] = {
1009 &dev_attr_rxip_add4.attr,
1010 &dev_attr_rxip_del4.attr,
1011 &dev_attr_rxip_add6.attr,
1012 &dev_attr_rxip_del6.attr,
1018 .attrs = qeth_rxip_device_attrs,