diff options
Diffstat (limited to 'drivers/s390/net/qeth_sys.c')
-rw-r--r-- | drivers/s390/net/qeth_sys.c | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c index 001497bbea16..5836737ac58f 100644 --- a/drivers/s390/net/qeth_sys.c +++ b/drivers/s390/net/qeth_sys.c | |||
@@ -743,6 +743,47 @@ static DEVICE_ATTR(layer2, 0644, qeth_dev_layer2_show, | |||
743 | qeth_dev_layer2_store); | 743 | qeth_dev_layer2_store); |
744 | 744 | ||
745 | static ssize_t | 745 | static ssize_t |
746 | qeth_dev_performance_stats_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
747 | { | ||
748 | struct qeth_card *card = dev->driver_data; | ||
749 | |||
750 | if (!card) | ||
751 | return -EINVAL; | ||
752 | |||
753 | return sprintf(buf, "%i\n", card->options.performance_stats ? 1:0); | ||
754 | } | ||
755 | |||
756 | static ssize_t | ||
757 | qeth_dev_performance_stats_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
758 | { | ||
759 | struct qeth_card *card = dev->driver_data; | ||
760 | char *tmp; | ||
761 | int i; | ||
762 | |||
763 | if (!card) | ||
764 | return -EINVAL; | ||
765 | |||
766 | i = simple_strtoul(buf, &tmp, 16); | ||
767 | if ((i == 0) || (i == 1)) { | ||
768 | if (i == card->options.performance_stats) | ||
769 | return count; | ||
770 | card->options.performance_stats = i; | ||
771 | if (i == 0) | ||
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; | ||
776 | } else { | ||
777 | PRINT_WARN("performance_stats: write 0 or 1 to this file!\n"); | ||
778 | return -EINVAL; | ||
779 | } | ||
780 | return count; | ||
781 | } | ||
782 | |||
783 | static DEVICE_ATTR(performance_stats, 0644, qeth_dev_performance_stats_show, | ||
784 | qeth_dev_performance_stats_store); | ||
785 | |||
786 | static ssize_t | ||
746 | qeth_dev_large_send_show(struct device *dev, struct device_attribute *attr, char *buf) | 787 | qeth_dev_large_send_show(struct device *dev, struct device_attribute *attr, char *buf) |
747 | { | 788 | { |
748 | struct qeth_card *card = dev->driver_data; | 789 | struct qeth_card *card = dev->driver_data; |
@@ -928,6 +969,7 @@ static struct device_attribute * qeth_device_attrs[] = { | |||
928 | &dev_attr_canonical_macaddr, | 969 | &dev_attr_canonical_macaddr, |
929 | &dev_attr_layer2, | 970 | &dev_attr_layer2, |
930 | &dev_attr_large_send, | 971 | &dev_attr_large_send, |
972 | &dev_attr_performance_stats, | ||
931 | NULL, | 973 | NULL, |
932 | }; | 974 | }; |
933 | 975 | ||
@@ -1110,12 +1152,12 @@ qeth_parse_ipatoe(const char* buf, enum qeth_prot_versions proto, | |||
1110 | { | 1152 | { |
1111 | const char *start, *end; | 1153 | const char *start, *end; |
1112 | char *tmp; | 1154 | char *tmp; |
1113 | char buffer[49] = {0, }; | 1155 | char buffer[40] = {0, }; |
1114 | 1156 | ||
1115 | start = buf; | 1157 | start = buf; |
1116 | /* get address string */ | 1158 | /* get address string */ |
1117 | end = strchr(start, '/'); | 1159 | end = strchr(start, '/'); |
1118 | if (!end || (end-start >= 49)){ | 1160 | if (!end || (end - start >= 40)){ |
1119 | PRINT_WARN("Invalid format for ipato_addx/delx. " | 1161 | PRINT_WARN("Invalid format for ipato_addx/delx. " |
1120 | "Use <ip addr>/<mask bits>\n"); | 1162 | "Use <ip addr>/<mask bits>\n"); |
1121 | return -EINVAL; | 1163 | return -EINVAL; |
@@ -1127,7 +1169,12 @@ qeth_parse_ipatoe(const char* buf, enum qeth_prot_versions proto, | |||
1127 | } | 1169 | } |
1128 | start = end + 1; | 1170 | start = end + 1; |
1129 | *mask_bits = simple_strtoul(start, &tmp, 10); | 1171 | *mask_bits = simple_strtoul(start, &tmp, 10); |
1130 | 1172 | if (!strlen(start) || | |
1173 | (tmp == start) || | ||
1174 | (*mask_bits > ((proto == QETH_PROT_IPV4) ? 32 : 128))) { | ||
1175 | PRINT_WARN("Invalid mask bits for ipato_addx/delx !\n"); | ||
1176 | return -EINVAL; | ||
1177 | } | ||
1131 | return 0; | 1178 | return 0; |
1132 | } | 1179 | } |
1133 | 1180 | ||
@@ -1698,11 +1745,16 @@ qeth_create_device_attributes(struct device *dev) | |||
1698 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); | 1745 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); |
1699 | sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); | 1746 | sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); |
1700 | sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); | 1747 | sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); |
1748 | return ret; | ||
1701 | } | 1749 | } |
1702 | if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_blkt_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); | ||
1703 | return ret; | 1755 | return ret; |
1704 | 1756 | } | |
1705 | return ret; | 1757 | return 0; |
1706 | } | 1758 | } |
1707 | 1759 | ||
1708 | void | 1760 | void |