Lines Matching +full:invert +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0
24 if ((proto == QETH_PROT_IPV4 && !in4_pton(buf, -1, addr, -1, &end)) || in qeth_l3_string_to_ipaddr()
25 (proto == QETH_PROT_IPV6 && !in6_pton(buf, -1, addr, -1, &end))) in qeth_l3_string_to_ipaddr()
26 return -EINVAL; in qeth_l3_string_to_ipaddr()
33 switch (route->type) { in qeth_l3_dev_route_show()
39 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) in qeth_l3_dev_route_show()
44 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) in qeth_l3_dev_route_show()
49 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) in qeth_l3_dev_route_show()
63 return qeth_l3_dev_route_show(card, &card->options.route4, buf); in qeth_l3_dev_route4_show()
70 enum qeth_routing_types old_route_type = route->type; in qeth_l3_dev_route_store()
73 mutex_lock(&card->conf_mutex); in qeth_l3_dev_route_store()
75 route->type = NO_ROUTER; in qeth_l3_dev_route_store()
77 route->type = PRIMARY_CONNECTOR; in qeth_l3_dev_route_store()
79 route->type = SECONDARY_CONNECTOR; in qeth_l3_dev_route_store()
81 route->type = PRIMARY_ROUTER; in qeth_l3_dev_route_store()
83 route->type = SECONDARY_ROUTER; in qeth_l3_dev_route_store()
85 route->type = MULTICAST_ROUTER; in qeth_l3_dev_route_store()
87 rc = -EINVAL; in qeth_l3_dev_route_store()
91 (old_route_type != route->type)) { in qeth_l3_dev_route_store()
99 route->type = old_route_type; in qeth_l3_dev_route_store()
100 mutex_unlock(&card->conf_mutex); in qeth_l3_dev_route_store()
109 return qeth_l3_dev_route_store(card, &card->options.route4, in qeth_l3_dev_route4_store()
121 return qeth_l3_dev_route_show(card, &card->options.route6, buf); in qeth_l3_dev_route6_show()
129 return qeth_l3_dev_route_store(card, &card->options.route6, in qeth_l3_dev_route6_store()
141 return sprintf(buf, "%i\n", card->options.sniffer ? 1 : 0); in qeth_l3_dev_sniffer_show()
152 return -EPERM; in qeth_l3_dev_sniffer_store()
153 if (card->options.cq == QETH_CQ_ENABLED) in qeth_l3_dev_sniffer_store()
154 return -EPERM; in qeth_l3_dev_sniffer_store()
156 mutex_lock(&card->conf_mutex); in qeth_l3_dev_sniffer_store()
157 if (card->state != CARD_STATE_DOWN) { in qeth_l3_dev_sniffer_store()
158 rc = -EPERM; in qeth_l3_dev_sniffer_store()
164 rc = -EINVAL; in qeth_l3_dev_sniffer_store()
169 card->options.sniffer = i; in qeth_l3_dev_sniffer_store()
172 qdio_get_ssqd_desc(CARD_DDEV(card), &card->ssqd); in qeth_l3_dev_sniffer_store()
173 if (card->ssqd.qdioac2 & CHSC_AC2_SNIFFER_AVAILABLE) { in qeth_l3_dev_sniffer_store()
174 card->options.sniffer = i; in qeth_l3_dev_sniffer_store()
177 rc = -EPERM; in qeth_l3_dev_sniffer_store()
182 rc = -EINVAL; in qeth_l3_dev_sniffer_store()
185 mutex_unlock(&card->conf_mutex); in qeth_l3_dev_sniffer_store()
199 return -EPERM; in qeth_l3_dev_hsuid_show()
201 memcpy(tmp_hsuid, card->options.hsuid, sizeof(tmp_hsuid)); in qeth_l3_dev_hsuid_show()
214 return -EPERM; in qeth_l3_dev_hsuid_store()
216 mutex_lock(&card->conf_mutex); in qeth_l3_dev_hsuid_store()
217 if (card->state != CARD_STATE_DOWN) { in qeth_l3_dev_hsuid_store()
218 rc = -EPERM; in qeth_l3_dev_hsuid_store()
222 if (card->options.sniffer) { in qeth_l3_dev_hsuid_store()
223 rc = -EPERM; in qeth_l3_dev_hsuid_store()
227 if (card->options.cq == QETH_CQ_NOTAVAILABLE) { in qeth_l3_dev_hsuid_store()
228 rc = -EPERM; in qeth_l3_dev_hsuid_store()
234 rc = -EINVAL; in qeth_l3_dev_hsuid_store()
238 if (card->options.hsuid[0]) in qeth_l3_dev_hsuid_store()
244 card->options.hsuid[0] = '\0'; in qeth_l3_dev_hsuid_store()
245 memcpy(card->dev->perm_addr, card->options.hsuid, 9); in qeth_l3_dev_hsuid_store()
251 rc = -EPERM; in qeth_l3_dev_hsuid_store()
255 snprintf(card->options.hsuid, sizeof(card->options.hsuid), in qeth_l3_dev_hsuid_store()
256 "%-8s", tmp); in qeth_l3_dev_hsuid_store()
257 ASCEBC(card->options.hsuid, 8); in qeth_l3_dev_hsuid_store()
258 memcpy(card->dev->perm_addr, card->options.hsuid, 9); in qeth_l3_dev_hsuid_store()
263 mutex_unlock(&card->conf_mutex); in qeth_l3_dev_hsuid_store()
288 return sprintf(buf, "%u\n", card->ipato.enabled ? 1 : 0); in qeth_l3_dev_ipato_enable_show()
295 bool enable; in qeth_l3_dev_ipato_enable_store() local
298 mutex_lock(&card->conf_mutex); in qeth_l3_dev_ipato_enable_store()
299 if (card->state != CARD_STATE_DOWN) { in qeth_l3_dev_ipato_enable_store()
300 rc = -EPERM; in qeth_l3_dev_ipato_enable_store()
304 mutex_lock(&card->ip_lock); in qeth_l3_dev_ipato_enable_store()
306 enable = !card->ipato.enabled; in qeth_l3_dev_ipato_enable_store()
307 } else if (kstrtobool(buf, &enable)) { in qeth_l3_dev_ipato_enable_store()
308 rc = -EINVAL; in qeth_l3_dev_ipato_enable_store()
312 if (card->ipato.enabled != enable) { in qeth_l3_dev_ipato_enable_store()
313 card->ipato.enabled = enable; in qeth_l3_dev_ipato_enable_store()
318 mutex_unlock(&card->ip_lock); in qeth_l3_dev_ipato_enable_store()
320 mutex_unlock(&card->conf_mutex); in qeth_l3_dev_ipato_enable_store()
324 static QETH_DEVICE_ATTR(ipato_enable, enable, 0644,
333 return sprintf(buf, "%u\n", card->ipato.invert4 ? 1 : 0); in qeth_l3_dev_ipato_invert4_show()
341 bool invert; in qeth_l3_dev_ipato_invert4_store() local
344 mutex_lock(&card->ip_lock); in qeth_l3_dev_ipato_invert4_store()
346 invert = !card->ipato.invert4; in qeth_l3_dev_ipato_invert4_store()
347 } else if (kstrtobool(buf, &invert)) { in qeth_l3_dev_ipato_invert4_store()
348 rc = -EINVAL; in qeth_l3_dev_ipato_invert4_store()
352 if (card->ipato.invert4 != invert) { in qeth_l3_dev_ipato_invert4_store()
353 card->ipato.invert4 = invert; in qeth_l3_dev_ipato_invert4_store()
358 mutex_unlock(&card->ip_lock); in qeth_l3_dev_ipato_invert4_store()
372 mutex_lock(&card->ip_lock); in qeth_l3_dev_ipato_add_show()
373 list_for_each_entry(ipatoe, &card->ipato.entries, entry) { in qeth_l3_dev_ipato_add_show()
377 if (ipatoe->proto != proto) in qeth_l3_dev_ipato_add_show()
380 entry_len = qeth_l3_ipaddr_to_string(proto, ipatoe->addr, in qeth_l3_dev_ipato_add_show()
388 if (entry_len + 1 > PAGE_SIZE - str_len - 1) in qeth_l3_dev_ipato_add_show()
391 entry_len = scnprintf(buf, PAGE_SIZE - str_len, in qeth_l3_dev_ipato_add_show()
392 "%s/%i\n", addr_str, ipatoe->mask_bits); in qeth_l3_dev_ipato_add_show()
396 mutex_unlock(&card->ip_lock); in qeth_l3_dev_ipato_add_show()
418 return -EINVAL; in qeth_l3_parse_ipatoe()
420 /* Terminate the %addr sub-string, and parse it: */ in qeth_l3_parse_ipatoe()
431 return -EINVAL; in qeth_l3_parse_ipatoe()
450 return -ENOMEM; in qeth_l3_dev_ipato_add_store()
452 ipatoe->proto = proto; in qeth_l3_dev_ipato_add_store()
453 memcpy(ipatoe->addr, addr, (proto == QETH_PROT_IPV4) ? 4 : 16); in qeth_l3_dev_ipato_add_store()
454 ipatoe->mask_bits = mask_bits; in qeth_l3_dev_ipato_add_store()
504 return sprintf(buf, "%u\n", card->ipato.invert6 ? 1 : 0); in qeth_l3_dev_ipato_invert6_show()
511 bool invert; in qeth_l3_dev_ipato_invert6_store() local
514 mutex_lock(&card->ip_lock); in qeth_l3_dev_ipato_invert6_store()
516 invert = !card->ipato.invert6; in qeth_l3_dev_ipato_invert6_store()
517 } else if (kstrtobool(buf, &invert)) { in qeth_l3_dev_ipato_invert6_store()
518 rc = -EINVAL; in qeth_l3_dev_ipato_invert6_store()
522 if (card->ipato.invert6 != invert) { in qeth_l3_dev_ipato_invert6_store()
523 card->ipato.invert6 = invert; in qeth_l3_dev_ipato_invert6_store()
528 mutex_unlock(&card->ip_lock); in qeth_l3_dev_ipato_invert6_store()
593 mutex_lock(&card->ip_lock); in qeth_l3_dev_ip_add_show()
594 hash_for_each(card->ip_htable, i, ipaddr, hnode) { in qeth_l3_dev_ip_add_show()
598 if (ipaddr->proto != proto || ipaddr->type != type) in qeth_l3_dev_ip_add_show()
601 entry_len = qeth_l3_ipaddr_to_string(proto, (u8 *)&ipaddr->u, in qeth_l3_dev_ip_add_show()
607 if (entry_len + 1 > PAGE_SIZE - str_len - 1) in qeth_l3_dev_ip_add_show()
610 entry_len = scnprintf(buf, PAGE_SIZE - str_len, "%s\n", in qeth_l3_dev_ip_add_show()
615 mutex_unlock(&card->ip_lock); in qeth_l3_dev_ip_add_show()
716 return -EINVAL; in qeth_l3_parse_rxipe()
722 return -EINVAL; in qeth_l3_parse_rxipe()
728 return -EINVAL; in qeth_l3_parse_rxipe()
818 return sysfs_create_groups(&dev->kobj, qeth_l3_only_attr_groups); in qeth_l3_create_device_attributes()
823 sysfs_remove_groups(&dev->kobj, qeth_l3_only_attr_groups); in qeth_l3_remove_device_attributes()