Greg Kroah-Hartman | ab9953f | 2017-11-14 18:38:04 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2 | /* |
Frank Blaschka | bbcfcdc | 2009-06-16 10:30:31 +0200 | [diff] [blame] | 3 | * Copyright IBM Corp. 2007, 2009 |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 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 | |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 10 | #define KMSG_COMPONENT "qeth" |
| 11 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 12 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 13 | #include <linux/module.h> |
| 14 | #include <linux/moduleparam.h> |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 15 | #include <linux/bitops.h> |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 16 | #include <linux/string.h> |
| 17 | #include <linux/errno.h> |
| 18 | #include <linux/kernel.h> |
| 19 | #include <linux/etherdevice.h> |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 20 | #include <linux/ip.h> |
Julian Wiedmann | 1f97912 | 2017-12-20 20:11:04 +0100 | [diff] [blame] | 21 | #include <linux/in.h> |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 22 | #include <linux/ipv6.h> |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 23 | #include <linux/inetdevice.h> |
| 24 | #include <linux/igmp.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 25 | #include <linux/slab.h> |
Julian Wiedmann | 910a0a8 | 2017-12-20 20:11:07 +0100 | [diff] [blame] | 26 | #include <linux/if_ether.h> |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 27 | #include <linux/if_vlan.h> |
Julian Wiedmann | 910a0a8 | 2017-12-20 20:11:07 +0100 | [diff] [blame] | 28 | #include <linux/skbuff.h> |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 29 | |
| 30 | #include <net/ip.h> |
| 31 | #include <net/arp.h> |
David Miller | 87e7597 | 2012-02-01 10:49:17 +0000 | [diff] [blame] | 32 | #include <net/route.h> |
Julian Wiedmann | 1f97912 | 2017-12-20 20:11:04 +0100 | [diff] [blame] | 33 | #include <net/ipv6.h> |
Julian Wiedmann | 910a0a8 | 2017-12-20 20:11:07 +0100 | [diff] [blame] | 34 | #include <net/ip6_route.h> |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 35 | #include <net/iucv/af_iucv.h> |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 36 | #include <linux/hashtable.h> |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 37 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 38 | #include "qeth_l3.h" |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 39 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 40 | static int qeth_l3_register_addr_entry(struct qeth_card *, |
| 41 | struct qeth_ipaddr *); |
| 42 | static int qeth_l3_deregister_addr_entry(struct qeth_card *, |
| 43 | struct qeth_ipaddr *); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 44 | |
Julian Wiedmann | e6b1b7d | 2019-12-18 17:34:44 +0100 | [diff] [blame] | 45 | int qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto, const u8 *addr, |
| 46 | char *buf) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 47 | { |
| 48 | if (proto == QETH_PROT_IPV4) |
Julian Wiedmann | e6b1b7d | 2019-12-18 17:34:44 +0100 | [diff] [blame] | 49 | return sprintf(buf, "%pI4", addr); |
| 50 | else |
| 51 | return sprintf(buf, "%pI6", addr); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 52 | } |
| 53 | |
Julian Wiedmann | c5c48c5 | 2018-02-27 18:58:16 +0100 | [diff] [blame] | 54 | static struct qeth_ipaddr *qeth_l3_find_addr_by_ip(struct qeth_card *card, |
| 55 | struct qeth_ipaddr *query) |
| 56 | { |
Julian Wiedmann | 1b40d4b | 2019-10-31 13:42:20 +0100 | [diff] [blame] | 57 | u32 key = qeth_l3_ipaddr_hash(query); |
Julian Wiedmann | c5c48c5 | 2018-02-27 18:58:16 +0100 | [diff] [blame] | 58 | struct qeth_ipaddr *addr; |
| 59 | |
| 60 | if (query->is_multicast) { |
Julian Wiedmann | 0973292 | 2020-07-14 16:23:04 +0200 | [diff] [blame] | 61 | hash_for_each_possible(card->rx_mode_addrs, addr, hnode, key) |
Julian Wiedmann | c5c48c5 | 2018-02-27 18:58:16 +0100 | [diff] [blame] | 62 | if (qeth_l3_addr_match_ip(addr, query)) |
| 63 | return addr; |
| 64 | } else { |
| 65 | hash_for_each_possible(card->ip_htable, addr, hnode, key) |
| 66 | if (qeth_l3_addr_match_ip(addr, query)) |
| 67 | return addr; |
| 68 | } |
| 69 | return NULL; |
| 70 | } |
| 71 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 72 | static void qeth_l3_convert_addr_to_bits(u8 *addr, u8 *bits, int len) |
| 73 | { |
| 74 | int i, j; |
| 75 | u8 octet; |
| 76 | |
| 77 | for (i = 0; i < len; ++i) { |
| 78 | octet = addr[i]; |
| 79 | for (j = 7; j >= 0; --j) { |
| 80 | bits[i*8 + j] = octet & 1; |
| 81 | octet >>= 1; |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
Julian Wiedmann | 02f510f | 2017-12-13 18:56:32 +0100 | [diff] [blame] | 86 | static bool qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card, |
| 87 | struct qeth_ipaddr *addr) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 88 | { |
| 89 | struct qeth_ipato_entry *ipatoe; |
| 90 | u8 addr_bits[128] = {0, }; |
| 91 | u8 ipatoe_bits[128] = {0, }; |
| 92 | int rc = 0; |
| 93 | |
| 94 | if (!card->ipato.enabled) |
Gustavo A. R. Silva | 1a363b0 | 2018-08-09 14:48:04 +0200 | [diff] [blame] | 95 | return false; |
Julian Wiedmann | b22d73d6 | 2017-12-13 18:56:30 +0100 | [diff] [blame] | 96 | if (addr->type != QETH_IP_TYPE_NORMAL) |
Gustavo A. R. Silva | 1a363b0 | 2018-08-09 14:48:04 +0200 | [diff] [blame] | 97 | return false; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 98 | |
| 99 | qeth_l3_convert_addr_to_bits((u8 *) &addr->u, addr_bits, |
| 100 | (addr->proto == QETH_PROT_IPV4)? 4:16); |
| 101 | list_for_each_entry(ipatoe, &card->ipato.entries, entry) { |
| 102 | if (addr->proto != ipatoe->proto) |
| 103 | continue; |
| 104 | qeth_l3_convert_addr_to_bits(ipatoe->addr, ipatoe_bits, |
| 105 | (ipatoe->proto == QETH_PROT_IPV4) ? |
| 106 | 4 : 16); |
| 107 | if (addr->proto == QETH_PROT_IPV4) |
Julian Wiedmann | ab29c48 | 2020-09-23 10:36:55 +0200 | [diff] [blame] | 108 | rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 109 | else |
Julian Wiedmann | ab29c48 | 2020-09-23 10:36:55 +0200 | [diff] [blame] | 110 | rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 111 | if (rc) |
| 112 | break; |
| 113 | } |
| 114 | /* invert? */ |
| 115 | if ((addr->proto == QETH_PROT_IPV4) && card->ipato.invert4) |
| 116 | rc = !rc; |
| 117 | else if ((addr->proto == QETH_PROT_IPV6) && card->ipato.invert6) |
| 118 | rc = !rc; |
| 119 | |
| 120 | return rc; |
| 121 | } |
| 122 | |
Julian Wiedmann | 1617dae | 2018-03-09 18:13:02 +0100 | [diff] [blame] | 123 | static int qeth_l3_delete_ip(struct qeth_card *card, |
| 124 | struct qeth_ipaddr *tmp_addr) |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 125 | { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 126 | int rc = 0; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 127 | struct qeth_ipaddr *addr; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 128 | |
Julian Wiedmann | 1617dae | 2018-03-09 18:13:02 +0100 | [diff] [blame] | 129 | if (tmp_addr->type == QETH_IP_TYPE_RXIP) |
| 130 | QETH_CARD_TEXT(card, 2, "delrxip"); |
| 131 | else if (tmp_addr->type == QETH_IP_TYPE_VIPA) |
| 132 | QETH_CARD_TEXT(card, 2, "delvipa"); |
| 133 | else |
| 134 | QETH_CARD_TEXT(card, 2, "delip"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 135 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 136 | if (tmp_addr->proto == QETH_PROT_IPV4) |
| 137 | QETH_CARD_HEX(card, 4, &tmp_addr->u.a4.addr, 4); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 138 | else { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 139 | QETH_CARD_HEX(card, 4, &tmp_addr->u.a6.addr, 8); |
| 140 | QETH_CARD_HEX(card, 4, ((char *)&tmp_addr->u.a6.addr) + 8, 8); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 141 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 142 | |
Julian Wiedmann | c5c48c5 | 2018-02-27 18:58:16 +0100 | [diff] [blame] | 143 | addr = qeth_l3_find_addr_by_ip(card, tmp_addr); |
| 144 | if (!addr || !qeth_l3_addr_match_all(addr, tmp_addr)) |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 145 | return -ENOENT; |
| 146 | |
| 147 | addr->ref_counter--; |
Julian Wiedmann | 4964c66 | 2018-02-27 18:58:15 +0100 | [diff] [blame] | 148 | if (addr->type == QETH_IP_TYPE_NORMAL && addr->ref_counter > 0) |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 149 | return rc; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 150 | |
Julian Wiedmann | 98d823a | 2018-02-27 18:58:13 +0100 | [diff] [blame] | 151 | if (qeth_card_hw_is_reachable(card)) |
| 152 | rc = qeth_l3_deregister_addr_entry(card, addr); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 153 | |
| 154 | hash_del(&addr->hnode); |
| 155 | kfree(addr); |
| 156 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 157 | return rc; |
| 158 | } |
| 159 | |
Julian Wiedmann | 1617dae | 2018-03-09 18:13:02 +0100 | [diff] [blame] | 160 | static int qeth_l3_add_ip(struct qeth_card *card, struct qeth_ipaddr *tmp_addr) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 161 | { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 162 | int rc = 0; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 163 | struct qeth_ipaddr *addr; |
Julian Wiedmann | c5c48c5 | 2018-02-27 18:58:16 +0100 | [diff] [blame] | 164 | char buf[40]; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 165 | |
Julian Wiedmann | 1617dae | 2018-03-09 18:13:02 +0100 | [diff] [blame] | 166 | if (tmp_addr->type == QETH_IP_TYPE_RXIP) |
| 167 | QETH_CARD_TEXT(card, 2, "addrxip"); |
| 168 | else if (tmp_addr->type == QETH_IP_TYPE_VIPA) |
| 169 | QETH_CARD_TEXT(card, 2, "addvipa"); |
| 170 | else |
| 171 | QETH_CARD_TEXT(card, 2, "addip"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 172 | |
| 173 | if (tmp_addr->proto == QETH_PROT_IPV4) |
| 174 | QETH_CARD_HEX(card, 4, &tmp_addr->u.a4.addr, 4); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 175 | else { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 176 | QETH_CARD_HEX(card, 4, &tmp_addr->u.a6.addr, 8); |
| 177 | QETH_CARD_HEX(card, 4, ((char *)&tmp_addr->u.a6.addr) + 8, 8); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 178 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 179 | |
Julian Wiedmann | c5c48c5 | 2018-02-27 18:58:16 +0100 | [diff] [blame] | 180 | addr = qeth_l3_find_addr_by_ip(card, tmp_addr); |
| 181 | if (addr) { |
| 182 | if (tmp_addr->type != QETH_IP_TYPE_NORMAL) |
| 183 | return -EADDRINUSE; |
| 184 | if (qeth_l3_addr_match_all(addr, tmp_addr)) { |
| 185 | addr->ref_counter++; |
| 186 | return 0; |
| 187 | } |
| 188 | qeth_l3_ipaddr_to_string(tmp_addr->proto, (u8 *)&tmp_addr->u, |
| 189 | buf); |
| 190 | dev_warn(&card->gdev->dev, |
| 191 | "Registering IP address %s failed\n", buf); |
| 192 | return -EADDRINUSE; |
| 193 | } else { |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 194 | addr = kmemdup(tmp_addr, sizeof(*tmp_addr), GFP_KERNEL); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 195 | if (!addr) |
| 196 | return -ENOMEM; |
| 197 | |
Julian Wiedmann | b22d73d6 | 2017-12-13 18:56:30 +0100 | [diff] [blame] | 198 | if (qeth_l3_is_addr_covered_by_ipato(card, addr)) { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 199 | QETH_CARD_TEXT(card, 2, "tkovaddr"); |
Julian Wiedmann | b1d5e36 | 2018-03-09 18:13:03 +0100 | [diff] [blame] | 200 | addr->ipato = 1; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 201 | } |
| 202 | hash_add(card->ip_htable, &addr->hnode, |
| 203 | qeth_l3_ipaddr_hash(addr)); |
| 204 | |
Ursula Braun | a7531c1 | 2016-09-15 14:39:23 +0200 | [diff] [blame] | 205 | if (!qeth_card_hw_is_reachable(card)) { |
| 206 | addr->disp_flag = QETH_DISP_ADDR_ADD; |
| 207 | return 0; |
| 208 | } |
| 209 | |
Julian Wiedmann | adee259 | 2019-12-18 17:34:48 +0100 | [diff] [blame] | 210 | rc = qeth_l3_register_addr_entry(card, addr); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 211 | |
Julian Wiedmann | 4b7ae12 | 2019-02-12 18:33:23 +0100 | [diff] [blame] | 212 | if (!rc || rc == -EADDRINUSE || rc == -ENETDOWN) { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 213 | addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 214 | } else { |
| 215 | hash_del(&addr->hnode); |
| 216 | kfree(addr); |
| 217 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 218 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 219 | return rc; |
| 220 | } |
| 221 | |
Julian Wiedmann | 05a1785 | 2019-03-28 16:39:21 +0100 | [diff] [blame] | 222 | static int qeth_l3_modify_ip(struct qeth_card *card, struct qeth_ipaddr *addr, |
| 223 | bool add) |
| 224 | { |
| 225 | int rc; |
| 226 | |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 227 | mutex_lock(&card->ip_lock); |
Julian Wiedmann | 05a1785 | 2019-03-28 16:39:21 +0100 | [diff] [blame] | 228 | rc = add ? qeth_l3_add_ip(card, addr) : qeth_l3_delete_ip(card, addr); |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 229 | mutex_unlock(&card->ip_lock); |
Julian Wiedmann | 05a1785 | 2019-03-28 16:39:21 +0100 | [diff] [blame] | 230 | |
| 231 | return rc; |
| 232 | } |
| 233 | |
Julian Wiedmann | d0c7482 | 2019-03-28 16:39:19 +0100 | [diff] [blame] | 234 | static void qeth_l3_drain_rx_mode_cache(struct qeth_card *card) |
| 235 | { |
| 236 | struct qeth_ipaddr *addr; |
| 237 | struct hlist_node *tmp; |
| 238 | int i; |
| 239 | |
Julian Wiedmann | 0973292 | 2020-07-14 16:23:04 +0200 | [diff] [blame] | 240 | hash_for_each_safe(card->rx_mode_addrs, i, tmp, addr, hnode) { |
Julian Wiedmann | d0c7482 | 2019-03-28 16:39:19 +0100 | [diff] [blame] | 241 | hash_del(&addr->hnode); |
| 242 | kfree(addr); |
| 243 | } |
Julian Wiedmann | d0c7482 | 2019-03-28 16:39:19 +0100 | [diff] [blame] | 244 | } |
| 245 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 246 | static void qeth_l3_clear_ip_htable(struct qeth_card *card, int recover) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 247 | { |
| 248 | struct qeth_ipaddr *addr; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 249 | struct hlist_node *tmp; |
| 250 | int i; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 251 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 252 | QETH_CARD_TEXT(card, 4, "clearip"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 253 | |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 254 | mutex_lock(&card->ip_lock); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 255 | |
| 256 | hash_for_each_safe(card->ip_htable, i, tmp, addr, hnode) { |
| 257 | if (!recover) { |
| 258 | hash_del(&addr->hnode); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 259 | kfree(addr); |
| 260 | continue; |
| 261 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 262 | addr->disp_flag = QETH_DISP_ADDR_ADD; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 263 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 264 | |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 265 | mutex_unlock(&card->ip_lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 266 | } |
Julian Wiedmann | d0c7482 | 2019-03-28 16:39:19 +0100 | [diff] [blame] | 267 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 268 | static void qeth_l3_recover_ip(struct qeth_card *card) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 269 | { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 270 | struct qeth_ipaddr *addr; |
| 271 | struct hlist_node *tmp; |
| 272 | int i; |
| 273 | int rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 274 | |
Ursula Braun | a7531c1 | 2016-09-15 14:39:23 +0200 | [diff] [blame] | 275 | QETH_CARD_TEXT(card, 4, "recovrip"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 276 | |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 277 | mutex_lock(&card->ip_lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 278 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 279 | hash_for_each_safe(card->ip_htable, i, tmp, addr, hnode) { |
Julian Wiedmann | 98d823a | 2018-02-27 18:58:13 +0100 | [diff] [blame] | 280 | if (addr->disp_flag == QETH_DISP_ADDR_ADD) { |
Julian Wiedmann | adee259 | 2019-12-18 17:34:48 +0100 | [diff] [blame] | 281 | rc = qeth_l3_register_addr_entry(card, addr); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 282 | |
| 283 | if (!rc) { |
| 284 | addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 285 | } else { |
| 286 | hash_del(&addr->hnode); |
| 287 | kfree(addr); |
| 288 | } |
| 289 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 290 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 291 | |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 292 | mutex_unlock(&card->ip_lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 293 | } |
| 294 | |
Julian Wiedmann | 4b7ae12 | 2019-02-12 18:33:23 +0100 | [diff] [blame] | 295 | static int qeth_l3_setdelip_cb(struct qeth_card *card, struct qeth_reply *reply, |
| 296 | unsigned long data) |
| 297 | { |
| 298 | struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
| 299 | |
| 300 | switch (cmd->hdr.return_code) { |
| 301 | case IPA_RC_SUCCESS: |
| 302 | return 0; |
| 303 | case IPA_RC_DUPLICATE_IP_ADDRESS: |
| 304 | return -EADDRINUSE; |
| 305 | case IPA_RC_MC_ADDR_NOT_FOUND: |
| 306 | return -ENOENT; |
| 307 | case IPA_RC_LAN_OFFLINE: |
| 308 | return -ENETDOWN; |
| 309 | default: |
| 310 | return -EIO; |
| 311 | } |
| 312 | } |
| 313 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 314 | static int qeth_l3_send_setdelmc(struct qeth_card *card, |
Julian Wiedmann | b14912e | 2020-08-27 10:16:58 +0200 | [diff] [blame] | 315 | struct qeth_ipaddr *addr, |
| 316 | enum qeth_ipa_cmds ipacmd) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 317 | { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 318 | struct qeth_cmd_buffer *iob; |
| 319 | struct qeth_ipa_cmd *cmd; |
| 320 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 321 | QETH_CARD_TEXT(card, 4, "setdelmc"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 322 | |
Julian Wiedmann | a59d121 | 2019-06-27 17:01:22 +0200 | [diff] [blame] | 323 | iob = qeth_ipa_alloc_cmd(card, ipacmd, addr->proto, |
| 324 | IPA_DATA_SIZEOF(setdelipm)); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 325 | if (!iob) |
| 326 | return -ENOMEM; |
Julian Wiedmann | ff5caa7 | 2018-03-09 18:12:52 +0100 | [diff] [blame] | 327 | cmd = __ipa_cmd(iob); |
Julian Wiedmann | 8bf70b6 | 2019-10-31 13:42:21 +0100 | [diff] [blame] | 328 | if (addr->proto == QETH_PROT_IPV6) { |
| 329 | cmd->data.setdelipm.ip = addr->u.a6.addr; |
| 330 | ipv6_eth_mc_map(&addr->u.a6.addr, cmd->data.setdelipm.mac); |
| 331 | } else { |
| 332 | cmd->data.setdelipm.ip.s6_addr32[3] = addr->u.a4.addr; |
| 333 | ip_eth_mc_map(addr->u.a4.addr, cmd->data.setdelipm.mac); |
| 334 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 335 | |
Julian Wiedmann | 4b7ae12 | 2019-02-12 18:33:23 +0100 | [diff] [blame] | 336 | return qeth_send_ipa_cmd(card, iob, qeth_l3_setdelip_cb, NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 337 | } |
| 338 | |
Julian Wiedmann | 490df97 | 2019-12-18 17:34:46 +0100 | [diff] [blame] | 339 | static void qeth_l3_set_ipv6_prefix(struct in6_addr *prefix, unsigned int len) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 340 | { |
Julian Wiedmann | 490df97 | 2019-12-18 17:34:46 +0100 | [diff] [blame] | 341 | unsigned int i = 0; |
| 342 | |
| 343 | while (len && i < 4) { |
| 344 | int mask_len = min_t(int, len, 32); |
| 345 | |
| 346 | prefix->s6_addr32[i] = inet_make_mask(mask_len); |
| 347 | len -= mask_len; |
| 348 | i++; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 349 | } |
| 350 | } |
| 351 | |
Julian Wiedmann | b1d5e36 | 2018-03-09 18:13:03 +0100 | [diff] [blame] | 352 | static u32 qeth_l3_get_setdelip_flags(struct qeth_ipaddr *addr, bool set) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 353 | { |
Julian Wiedmann | b1d5e36 | 2018-03-09 18:13:03 +0100 | [diff] [blame] | 354 | switch (addr->type) { |
| 355 | case QETH_IP_TYPE_RXIP: |
| 356 | return (set) ? QETH_IPA_SETIP_TAKEOVER_FLAG : 0; |
| 357 | case QETH_IP_TYPE_VIPA: |
| 358 | return (set) ? QETH_IPA_SETIP_VIPA_FLAG : |
| 359 | QETH_IPA_DELIP_VIPA_FLAG; |
| 360 | default: |
| 361 | return (set && addr->ipato) ? QETH_IPA_SETIP_TAKEOVER_FLAG : 0; |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | static int qeth_l3_send_setdelip(struct qeth_card *card, |
| 366 | struct qeth_ipaddr *addr, |
| 367 | enum qeth_ipa_cmds ipacmd) |
| 368 | { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 369 | struct qeth_cmd_buffer *iob; |
| 370 | struct qeth_ipa_cmd *cmd; |
Julian Wiedmann | b1d5e36 | 2018-03-09 18:13:03 +0100 | [diff] [blame] | 371 | u32 flags; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 372 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 373 | QETH_CARD_TEXT(card, 4, "setdelip"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 374 | |
Julian Wiedmann | a59d121 | 2019-06-27 17:01:22 +0200 | [diff] [blame] | 375 | iob = qeth_ipa_alloc_cmd(card, ipacmd, addr->proto, |
| 376 | IPA_DATA_SIZEOF(setdelip6)); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 377 | if (!iob) |
| 378 | return -ENOMEM; |
Julian Wiedmann | ff5caa7 | 2018-03-09 18:12:52 +0100 | [diff] [blame] | 379 | cmd = __ipa_cmd(iob); |
Julian Wiedmann | b1d5e36 | 2018-03-09 18:13:03 +0100 | [diff] [blame] | 380 | |
| 381 | flags = qeth_l3_get_setdelip_flags(addr, ipacmd == IPA_CMD_SETIP); |
| 382 | QETH_CARD_TEXT_(card, 4, "flags%02X", flags); |
| 383 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 384 | if (addr->proto == QETH_PROT_IPV6) { |
Julian Wiedmann | 490df97 | 2019-12-18 17:34:46 +0100 | [diff] [blame] | 385 | cmd->data.setdelip6.addr = addr->u.a6.addr; |
| 386 | qeth_l3_set_ipv6_prefix(&cmd->data.setdelip6.prefix, |
| 387 | addr->u.a6.pfxlen); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 388 | cmd->data.setdelip6.flags = flags; |
| 389 | } else { |
Julian Wiedmann | 490df97 | 2019-12-18 17:34:46 +0100 | [diff] [blame] | 390 | cmd->data.setdelip4.addr = addr->u.a4.addr; |
| 391 | cmd->data.setdelip4.mask = addr->u.a4.mask; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 392 | cmd->data.setdelip4.flags = flags; |
| 393 | } |
| 394 | |
Julian Wiedmann | 4b7ae12 | 2019-02-12 18:33:23 +0100 | [diff] [blame] | 395 | return qeth_send_ipa_cmd(card, iob, qeth_l3_setdelip_cb, NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | static int qeth_l3_send_setrouting(struct qeth_card *card, |
| 399 | enum qeth_routing_types type, enum qeth_prot_versions prot) |
| 400 | { |
| 401 | int rc; |
| 402 | struct qeth_ipa_cmd *cmd; |
| 403 | struct qeth_cmd_buffer *iob; |
| 404 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 405 | QETH_CARD_TEXT(card, 4, "setroutg"); |
Julian Wiedmann | a59d121 | 2019-06-27 17:01:22 +0200 | [diff] [blame] | 406 | iob = qeth_ipa_alloc_cmd(card, IPA_CMD_SETRTG, prot, |
| 407 | IPA_DATA_SIZEOF(setrtg)); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 408 | if (!iob) |
| 409 | return -ENOMEM; |
Julian Wiedmann | ff5caa7 | 2018-03-09 18:12:52 +0100 | [diff] [blame] | 410 | cmd = __ipa_cmd(iob); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 411 | cmd->data.setrtg.type = (type); |
| 412 | rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); |
| 413 | |
| 414 | return rc; |
| 415 | } |
| 416 | |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 417 | static int qeth_l3_correct_routing_type(struct qeth_card *card, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 418 | enum qeth_routing_types *type, enum qeth_prot_versions prot) |
| 419 | { |
Julian Wiedmann | 379ac99 | 2019-04-25 18:25:57 +0200 | [diff] [blame] | 420 | if (IS_IQD(card)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 421 | switch (*type) { |
| 422 | case NO_ROUTER: |
| 423 | case PRIMARY_CONNECTOR: |
| 424 | case SECONDARY_CONNECTOR: |
| 425 | case MULTICAST_ROUTER: |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 426 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 427 | default: |
| 428 | goto out_inval; |
| 429 | } |
| 430 | } else { |
| 431 | switch (*type) { |
| 432 | case NO_ROUTER: |
| 433 | case PRIMARY_ROUTER: |
| 434 | case SECONDARY_ROUTER: |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 435 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 436 | case MULTICAST_ROUTER: |
| 437 | if (qeth_is_ipafunc_supported(card, prot, |
| 438 | IPA_OSA_MC_ROUTER)) |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 439 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 440 | default: |
| 441 | goto out_inval; |
| 442 | } |
| 443 | } |
| 444 | out_inval: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 445 | *type = NO_ROUTER; |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 446 | return -EINVAL; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | int qeth_l3_setrouting_v4(struct qeth_card *card) |
| 450 | { |
| 451 | int rc; |
| 452 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 453 | QETH_CARD_TEXT(card, 3, "setrtg4"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 454 | |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 455 | rc = qeth_l3_correct_routing_type(card, &card->options.route4.type, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 456 | QETH_PROT_IPV4); |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 457 | if (rc) |
| 458 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 459 | |
| 460 | rc = qeth_l3_send_setrouting(card, card->options.route4.type, |
| 461 | QETH_PROT_IPV4); |
| 462 | if (rc) { |
| 463 | card->options.route4.type = NO_ROUTER; |
Julian Wiedmann | e19e5be | 2018-11-02 19:04:08 +0100 | [diff] [blame] | 464 | QETH_DBF_MESSAGE(2, "Error (%#06x) while setting routing type on device %x. Type set to 'no router'.\n", |
| 465 | rc, CARD_DEVID(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 466 | } |
| 467 | return rc; |
| 468 | } |
| 469 | |
| 470 | int qeth_l3_setrouting_v6(struct qeth_card *card) |
| 471 | { |
| 472 | int rc = 0; |
| 473 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 474 | QETH_CARD_TEXT(card, 3, "setrtg6"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 475 | |
| 476 | if (!qeth_is_supported(card, IPA_IPV6)) |
| 477 | return 0; |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 478 | rc = qeth_l3_correct_routing_type(card, &card->options.route6.type, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 479 | QETH_PROT_IPV6); |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 480 | if (rc) |
| 481 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 482 | |
| 483 | rc = qeth_l3_send_setrouting(card, card->options.route6.type, |
| 484 | QETH_PROT_IPV6); |
| 485 | if (rc) { |
| 486 | card->options.route6.type = NO_ROUTER; |
Julian Wiedmann | e19e5be | 2018-11-02 19:04:08 +0100 | [diff] [blame] | 487 | QETH_DBF_MESSAGE(2, "Error (%#06x) while setting routing type on device %x. Type set to 'no router'.\n", |
| 488 | rc, CARD_DEVID(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 489 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 490 | return rc; |
| 491 | } |
| 492 | |
| 493 | /* |
| 494 | * IP address takeover related functions |
| 495 | */ |
Julian Wiedmann | 02f510f | 2017-12-13 18:56:32 +0100 | [diff] [blame] | 496 | |
| 497 | /** |
| 498 | * qeth_l3_update_ipato() - Update 'takeover' property, for all NORMAL IPs. |
| 499 | * |
| 500 | * Caller must hold ip_lock. |
| 501 | */ |
| 502 | void qeth_l3_update_ipato(struct qeth_card *card) |
| 503 | { |
| 504 | struct qeth_ipaddr *addr; |
| 505 | unsigned int i; |
| 506 | |
| 507 | hash_for_each(card->ip_htable, i, addr, hnode) { |
| 508 | if (addr->type != QETH_IP_TYPE_NORMAL) |
| 509 | continue; |
Julian Wiedmann | b1d5e36 | 2018-03-09 18:13:03 +0100 | [diff] [blame] | 510 | addr->ipato = qeth_l3_is_addr_covered_by_ipato(card, addr); |
Julian Wiedmann | 02f510f | 2017-12-13 18:56:32 +0100 | [diff] [blame] | 511 | } |
| 512 | } |
| 513 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 514 | static void qeth_l3_clear_ipato_list(struct qeth_card *card) |
| 515 | { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 516 | struct qeth_ipato_entry *ipatoe, *tmp; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 517 | |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 518 | mutex_lock(&card->ip_lock); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 519 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 520 | list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) { |
| 521 | list_del(&ipatoe->entry); |
| 522 | kfree(ipatoe); |
| 523 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 524 | |
Julian Wiedmann | 02f510f | 2017-12-13 18:56:32 +0100 | [diff] [blame] | 525 | qeth_l3_update_ipato(card); |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 526 | mutex_unlock(&card->ip_lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | int qeth_l3_add_ipato_entry(struct qeth_card *card, |
| 530 | struct qeth_ipato_entry *new) |
| 531 | { |
| 532 | struct qeth_ipato_entry *ipatoe; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 533 | int rc = 0; |
| 534 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 535 | QETH_CARD_TEXT(card, 2, "addipato"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 536 | |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 537 | mutex_lock(&card->ip_lock); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 538 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 539 | list_for_each_entry(ipatoe, &card->ipato.entries, entry) { |
| 540 | if (ipatoe->proto != new->proto) |
| 541 | continue; |
| 542 | if (!memcmp(ipatoe->addr, new->addr, |
| 543 | (ipatoe->proto == QETH_PROT_IPV4)? 4:16) && |
| 544 | (ipatoe->mask_bits == new->mask_bits)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 545 | rc = -EEXIST; |
| 546 | break; |
| 547 | } |
| 548 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 549 | |
Julian Wiedmann | 02f510f | 2017-12-13 18:56:32 +0100 | [diff] [blame] | 550 | if (!rc) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 551 | list_add_tail(&new->entry, &card->ipato.entries); |
Julian Wiedmann | 02f510f | 2017-12-13 18:56:32 +0100 | [diff] [blame] | 552 | qeth_l3_update_ipato(card); |
| 553 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 554 | |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 555 | mutex_unlock(&card->ip_lock); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 556 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 557 | return rc; |
| 558 | } |
| 559 | |
Julian Wiedmann | b9ea525 | 2017-12-27 17:44:28 +0100 | [diff] [blame] | 560 | int qeth_l3_del_ipato_entry(struct qeth_card *card, |
| 561 | enum qeth_prot_versions proto, u8 *addr, |
Julian Wiedmann | ab29c48 | 2020-09-23 10:36:55 +0200 | [diff] [blame] | 562 | unsigned int mask_bits) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 563 | { |
| 564 | struct qeth_ipato_entry *ipatoe, *tmp; |
Julian Wiedmann | b9ea525 | 2017-12-27 17:44:28 +0100 | [diff] [blame] | 565 | int rc = -ENOENT; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 566 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 567 | QETH_CARD_TEXT(card, 2, "delipato"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 568 | |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 569 | mutex_lock(&card->ip_lock); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 570 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 571 | list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) { |
| 572 | if (ipatoe->proto != proto) |
| 573 | continue; |
| 574 | if (!memcmp(ipatoe->addr, addr, |
| 575 | (proto == QETH_PROT_IPV4)? 4:16) && |
| 576 | (ipatoe->mask_bits == mask_bits)) { |
| 577 | list_del(&ipatoe->entry); |
Julian Wiedmann | 02f510f | 2017-12-13 18:56:32 +0100 | [diff] [blame] | 578 | qeth_l3_update_ipato(card); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 579 | kfree(ipatoe); |
Julian Wiedmann | b9ea525 | 2017-12-27 17:44:28 +0100 | [diff] [blame] | 580 | rc = 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 581 | } |
| 582 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 583 | |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 584 | mutex_unlock(&card->ip_lock); |
Julian Wiedmann | 2390166 | 2019-12-18 17:34:45 +0100 | [diff] [blame] | 585 | |
Julian Wiedmann | b9ea525 | 2017-12-27 17:44:28 +0100 | [diff] [blame] | 586 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 587 | } |
| 588 | |
Julian Wiedmann | 1617dae | 2018-03-09 18:13:02 +0100 | [diff] [blame] | 589 | int qeth_l3_modify_rxip_vipa(struct qeth_card *card, bool add, const u8 *ip, |
| 590 | enum qeth_ip_types type, |
| 591 | enum qeth_prot_versions proto) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 592 | { |
Julian Wiedmann | 1617dae | 2018-03-09 18:13:02 +0100 | [diff] [blame] | 593 | struct qeth_ipaddr addr; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 594 | |
Julian Wiedmann | 1617dae | 2018-03-09 18:13:02 +0100 | [diff] [blame] | 595 | qeth_l3_init_ipaddr(&addr, type, proto); |
| 596 | if (proto == QETH_PROT_IPV4) |
| 597 | memcpy(&addr.u.a4.addr, ip, 4); |
| 598 | else |
| 599 | memcpy(&addr.u.a6.addr, ip, 16); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 600 | |
Julian Wiedmann | f3380b1 | 2020-09-23 10:36:56 +0200 | [diff] [blame] | 601 | return qeth_l3_modify_ip(card, &addr, add); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 602 | } |
| 603 | |
Julian Wiedmann | 1617dae | 2018-03-09 18:13:02 +0100 | [diff] [blame] | 604 | int qeth_l3_modify_hsuid(struct qeth_card *card, bool add) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 605 | { |
Julian Wiedmann | 1617dae | 2018-03-09 18:13:02 +0100 | [diff] [blame] | 606 | struct qeth_ipaddr addr; |
Julian Wiedmann | 05a1785 | 2019-03-28 16:39:21 +0100 | [diff] [blame] | 607 | unsigned int i; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 608 | |
Julian Wiedmann | 1617dae | 2018-03-09 18:13:02 +0100 | [diff] [blame] | 609 | qeth_l3_init_ipaddr(&addr, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV6); |
| 610 | addr.u.a6.addr.s6_addr[0] = 0xfe; |
| 611 | addr.u.a6.addr.s6_addr[1] = 0x80; |
| 612 | for (i = 0; i < 8; i++) |
| 613 | addr.u.a6.addr.s6_addr[8+i] = card->options.hsuid[i]; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 614 | |
Julian Wiedmann | 05a1785 | 2019-03-28 16:39:21 +0100 | [diff] [blame] | 615 | return qeth_l3_modify_ip(card, &addr, add); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | static int qeth_l3_register_addr_entry(struct qeth_card *card, |
| 619 | struct qeth_ipaddr *addr) |
| 620 | { |
| 621 | char buf[50]; |
| 622 | int rc = 0; |
| 623 | int cnt = 3; |
| 624 | |
Julian Wiedmann | bd74a7f | 2018-11-02 19:04:09 +0100 | [diff] [blame] | 625 | if (card->options.sniffer) |
| 626 | return 0; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 627 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 628 | if (addr->proto == QETH_PROT_IPV4) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 629 | QETH_CARD_TEXT(card, 2, "setaddr4"); |
| 630 | QETH_CARD_HEX(card, 3, &addr->u.a4.addr, sizeof(int)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 631 | } else if (addr->proto == QETH_PROT_IPV6) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 632 | QETH_CARD_TEXT(card, 2, "setaddr6"); |
| 633 | QETH_CARD_HEX(card, 3, &addr->u.a6.addr, 8); |
| 634 | QETH_CARD_HEX(card, 3, ((char *)&addr->u.a6.addr) + 8, 8); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 635 | } else { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 636 | QETH_CARD_TEXT(card, 2, "setaddr?"); |
| 637 | QETH_CARD_HEX(card, 3, addr, sizeof(struct qeth_ipaddr)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 638 | } |
| 639 | do { |
| 640 | if (addr->is_multicast) |
| 641 | rc = qeth_l3_send_setdelmc(card, addr, IPA_CMD_SETIPM); |
| 642 | else |
Julian Wiedmann | b1d5e36 | 2018-03-09 18:13:03 +0100 | [diff] [blame] | 643 | rc = qeth_l3_send_setdelip(card, addr, IPA_CMD_SETIP); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 644 | if (rc) |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 645 | QETH_CARD_TEXT(card, 2, "failed"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 646 | } while ((--cnt > 0) && rc); |
| 647 | if (rc) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 648 | QETH_CARD_TEXT(card, 2, "FAILED"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 649 | qeth_l3_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf); |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 650 | dev_warn(&card->gdev->dev, |
| 651 | "Registering IP address %s failed\n", buf); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 652 | } |
| 653 | return rc; |
| 654 | } |
| 655 | |
| 656 | static int qeth_l3_deregister_addr_entry(struct qeth_card *card, |
| 657 | struct qeth_ipaddr *addr) |
| 658 | { |
| 659 | int rc = 0; |
| 660 | |
Julian Wiedmann | bd74a7f | 2018-11-02 19:04:09 +0100 | [diff] [blame] | 661 | if (card->options.sniffer) |
| 662 | return 0; |
| 663 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 664 | if (addr->proto == QETH_PROT_IPV4) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 665 | QETH_CARD_TEXT(card, 2, "deladdr4"); |
| 666 | QETH_CARD_HEX(card, 3, &addr->u.a4.addr, sizeof(int)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 667 | } else if (addr->proto == QETH_PROT_IPV6) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 668 | QETH_CARD_TEXT(card, 2, "deladdr6"); |
| 669 | QETH_CARD_HEX(card, 3, &addr->u.a6.addr, 8); |
| 670 | QETH_CARD_HEX(card, 3, ((char *)&addr->u.a6.addr) + 8, 8); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 671 | } else { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 672 | QETH_CARD_TEXT(card, 2, "deladdr?"); |
| 673 | QETH_CARD_HEX(card, 3, addr, sizeof(struct qeth_ipaddr)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 674 | } |
| 675 | if (addr->is_multicast) |
| 676 | rc = qeth_l3_send_setdelmc(card, addr, IPA_CMD_DELIPM); |
| 677 | else |
Julian Wiedmann | b1d5e36 | 2018-03-09 18:13:03 +0100 | [diff] [blame] | 678 | rc = qeth_l3_send_setdelip(card, addr, IPA_CMD_DELIP); |
Frank Blaschka | c4cef07 | 2008-07-14 09:59:31 +0200 | [diff] [blame] | 679 | if (rc) |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 680 | QETH_CARD_TEXT(card, 2, "failed"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 681 | |
| 682 | return rc; |
| 683 | } |
| 684 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 685 | static int qeth_l3_setadapter_parms(struct qeth_card *card) |
| 686 | { |
Julian Wiedmann | 699d3fe | 2017-08-15 17:02:41 +0200 | [diff] [blame] | 687 | int rc = 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 688 | |
Julian Wiedmann | 57a688aa | 2019-06-11 18:37:55 +0200 | [diff] [blame] | 689 | QETH_CARD_TEXT(card, 2, "setadprm"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 690 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 691 | if (qeth_adp_supported(card, IPA_SETADP_ALTER_MAC_ADDRESS)) { |
| 692 | rc = qeth_setadpparms_change_macaddr(card); |
| 693 | if (rc) |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 694 | dev_warn(&card->gdev->dev, "Reading the adapter MAC" |
Heiko Carstens | 6ea2fde | 2009-01-04 17:36:32 -0800 | [diff] [blame] | 695 | " address failed\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 696 | } |
| 697 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 698 | return rc; |
| 699 | } |
| 700 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 701 | static int qeth_l3_start_ipa_arp_processing(struct qeth_card *card) |
| 702 | { |
| 703 | int rc; |
| 704 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 705 | QETH_CARD_TEXT(card, 3, "ipaarp"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 706 | |
| 707 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 708 | dev_info(&card->gdev->dev, |
| 709 | "ARP processing not supported on %s!\n", |
| 710 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 711 | return 0; |
| 712 | } |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 713 | rc = qeth_send_simple_setassparms(card, IPA_ARP_PROCESSING, |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 714 | IPA_CMD_ASS_START, NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 715 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 716 | dev_warn(&card->gdev->dev, |
| 717 | "Starting ARP processing support for %s failed\n", |
| 718 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 719 | } |
| 720 | return rc; |
| 721 | } |
| 722 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 723 | static int qeth_l3_start_ipa_source_mac(struct qeth_card *card) |
| 724 | { |
| 725 | int rc; |
| 726 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 727 | QETH_CARD_TEXT(card, 3, "stsrcmac"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 728 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 729 | if (!qeth_is_supported(card, IPA_SOURCE_MAC)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 730 | dev_info(&card->gdev->dev, |
Ursula Braun | fe94e2e | 2009-01-04 17:34:52 -0800 | [diff] [blame] | 731 | "Inbound source MAC-address not supported on %s\n", |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 732 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 733 | return -EOPNOTSUPP; |
| 734 | } |
| 735 | |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 736 | rc = qeth_send_simple_setassparms(card, IPA_SOURCE_MAC, |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 737 | IPA_CMD_ASS_START, NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 738 | if (rc) |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 739 | dev_warn(&card->gdev->dev, |
Ursula Braun | fe94e2e | 2009-01-04 17:34:52 -0800 | [diff] [blame] | 740 | "Starting source MAC-address support for %s failed\n", |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 741 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 742 | return rc; |
| 743 | } |
| 744 | |
| 745 | static int qeth_l3_start_ipa_vlan(struct qeth_card *card) |
| 746 | { |
| 747 | int rc = 0; |
| 748 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 749 | QETH_CARD_TEXT(card, 3, "strtvlan"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 750 | |
| 751 | if (!qeth_is_supported(card, IPA_FULL_VLAN)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 752 | dev_info(&card->gdev->dev, |
| 753 | "VLAN not supported on %s\n", QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 754 | return -EOPNOTSUPP; |
| 755 | } |
| 756 | |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 757 | rc = qeth_send_simple_setassparms(card, IPA_VLAN_PRIO, |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 758 | IPA_CMD_ASS_START, NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 759 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 760 | dev_warn(&card->gdev->dev, |
| 761 | "Starting VLAN support for %s failed\n", |
| 762 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 763 | } else { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 764 | dev_info(&card->gdev->dev, "VLAN enabled\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 765 | } |
| 766 | return rc; |
| 767 | } |
| 768 | |
| 769 | static int qeth_l3_start_ipa_multicast(struct qeth_card *card) |
| 770 | { |
| 771 | int rc; |
| 772 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 773 | QETH_CARD_TEXT(card, 3, "stmcast"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 774 | |
| 775 | if (!qeth_is_supported(card, IPA_MULTICASTING)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 776 | dev_info(&card->gdev->dev, |
| 777 | "Multicast not supported on %s\n", |
| 778 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 779 | return -EOPNOTSUPP; |
| 780 | } |
| 781 | |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 782 | rc = qeth_send_simple_setassparms(card, IPA_MULTICASTING, |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 783 | IPA_CMD_ASS_START, NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 784 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 785 | dev_warn(&card->gdev->dev, |
| 786 | "Starting multicast support for %s failed\n", |
| 787 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 788 | } else { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 789 | dev_info(&card->gdev->dev, "Multicast enabled\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 790 | card->dev->flags |= IFF_MULTICAST; |
| 791 | } |
| 792 | return rc; |
| 793 | } |
| 794 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 795 | static int qeth_l3_softsetup_ipv6(struct qeth_card *card) |
| 796 | { |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 797 | u32 ipv6_data = 3; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 798 | int rc; |
| 799 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 800 | QETH_CARD_TEXT(card, 3, "softipv6"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 801 | |
Julian Wiedmann | 379ac99 | 2019-04-25 18:25:57 +0200 | [diff] [blame] | 802 | if (IS_IQD(card)) |
Julian Wiedmann | 2327459 | 2017-06-06 14:33:44 +0200 | [diff] [blame] | 803 | goto out; |
| 804 | |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 805 | rc = qeth_send_simple_setassparms(card, IPA_IPV6, IPA_CMD_ASS_START, |
| 806 | &ipv6_data); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 807 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 808 | dev_err(&card->gdev->dev, |
| 809 | "Activating IPv6 support for %s failed\n", |
| 810 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 811 | return rc; |
| 812 | } |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 813 | rc = qeth_send_simple_setassparms_v6(card, IPA_IPV6, IPA_CMD_ASS_START, |
| 814 | NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 815 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 816 | dev_err(&card->gdev->dev, |
| 817 | "Activating IPv6 support for %s failed\n", |
| 818 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 819 | return rc; |
| 820 | } |
Kittipon Meesompop | a8155b0 | 2018-04-26 09:42:21 +0200 | [diff] [blame] | 821 | rc = qeth_send_simple_setassparms_v6(card, IPA_PASSTHRU, |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 822 | IPA_CMD_ASS_START, NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 823 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 824 | dev_warn(&card->gdev->dev, |
| 825 | "Enabling the passthrough mode for %s failed\n", |
| 826 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 827 | return rc; |
| 828 | } |
| 829 | out: |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 830 | dev_info(&card->gdev->dev, "IPV6 enabled\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 831 | return 0; |
| 832 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 833 | |
| 834 | static int qeth_l3_start_ipa_ipv6(struct qeth_card *card) |
| 835 | { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 836 | QETH_CARD_TEXT(card, 3, "strtipv6"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 837 | |
| 838 | if (!qeth_is_supported(card, IPA_IPV6)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 839 | dev_info(&card->gdev->dev, |
| 840 | "IPv6 not supported on %s\n", QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 841 | return 0; |
| 842 | } |
Julian Wiedmann | c062204 | 2017-12-20 20:10:58 +0100 | [diff] [blame] | 843 | return qeth_l3_softsetup_ipv6(card); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 844 | } |
| 845 | |
| 846 | static int qeth_l3_start_ipa_broadcast(struct qeth_card *card) |
| 847 | { |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 848 | u32 filter_data = 1; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 849 | int rc; |
| 850 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 851 | QETH_CARD_TEXT(card, 3, "stbrdcst"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 852 | card->info.broadcast_capable = 0; |
| 853 | if (!qeth_is_supported(card, IPA_FILTERING)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 854 | dev_info(&card->gdev->dev, |
| 855 | "Broadcast not supported on %s\n", |
| 856 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 857 | rc = -EOPNOTSUPP; |
| 858 | goto out; |
| 859 | } |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 860 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 861 | IPA_CMD_ASS_START, NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 862 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 863 | dev_warn(&card->gdev->dev, "Enabling broadcast filtering for " |
| 864 | "%s failed\n", QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 865 | goto out; |
| 866 | } |
| 867 | |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 868 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 869 | IPA_CMD_ASS_CONFIGURE, &filter_data); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 870 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 871 | dev_warn(&card->gdev->dev, |
| 872 | "Setting up broadcast filtering for %s failed\n", |
| 873 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 874 | goto out; |
| 875 | } |
| 876 | card->info.broadcast_capable = QETH_BROADCAST_WITH_ECHO; |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 877 | dev_info(&card->gdev->dev, "Broadcast enabled\n"); |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 878 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, |
Julian Wiedmann | 1c696c89 | 2019-06-27 17:01:23 +0200 | [diff] [blame] | 879 | IPA_CMD_ASS_ENABLE, &filter_data); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 880 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 881 | dev_warn(&card->gdev->dev, "Setting up broadcast echo " |
| 882 | "filtering for %s failed\n", QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 883 | goto out; |
| 884 | } |
| 885 | card->info.broadcast_capable = QETH_BROADCAST_WITHOUT_ECHO; |
| 886 | out: |
| 887 | if (card->info.broadcast_capable) |
| 888 | card->dev->flags |= IFF_BROADCAST; |
| 889 | else |
| 890 | card->dev->flags &= ~IFF_BROADCAST; |
| 891 | return rc; |
| 892 | } |
| 893 | |
Julian Wiedmann | 17d9723 | 2020-01-25 16:53:03 +0100 | [diff] [blame] | 894 | static void qeth_l3_start_ipassists(struct qeth_card *card) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 895 | { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 896 | QETH_CARD_TEXT(card, 3, "strtipas"); |
Einar Lueck | d64ecc2 | 2009-11-12 00:11:41 +0000 | [diff] [blame] | 897 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 898 | qeth_l3_start_ipa_arp_processing(card); /* go on*/ |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 899 | qeth_l3_start_ipa_source_mac(card); /* go on*/ |
| 900 | qeth_l3_start_ipa_vlan(card); /* go on*/ |
| 901 | qeth_l3_start_ipa_multicast(card); /* go on*/ |
| 902 | qeth_l3_start_ipa_ipv6(card); /* go on*/ |
| 903 | qeth_l3_start_ipa_broadcast(card); /* go on*/ |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 904 | } |
| 905 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 906 | static int qeth_l3_iqd_read_initial_mac_cb(struct qeth_card *card, |
| 907 | struct qeth_reply *reply, unsigned long data) |
| 908 | { |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 909 | struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 910 | |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 911 | if (cmd->hdr.return_code) |
| 912 | return -EIO; |
Julian Wiedmann | 13bf8295 | 2020-02-27 18:08:11 +0100 | [diff] [blame] | 913 | if (!is_valid_ether_addr(cmd->data.create_destroy_addr.mac_addr)) |
| 914 | return -EADDRNOTAVAIL; |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 915 | |
| 916 | ether_addr_copy(card->dev->dev_addr, |
Julian Wiedmann | 9c6dc7a | 2020-02-27 18:08:10 +0100 | [diff] [blame] | 917 | cmd->data.create_destroy_addr.mac_addr); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 918 | return 0; |
| 919 | } |
| 920 | |
| 921 | static int qeth_l3_iqd_read_initial_mac(struct qeth_card *card) |
| 922 | { |
| 923 | int rc = 0; |
| 924 | struct qeth_cmd_buffer *iob; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 925 | |
Julian Wiedmann | 57a688aa | 2019-06-11 18:37:55 +0200 | [diff] [blame] | 926 | QETH_CARD_TEXT(card, 2, "hsrmac"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 927 | |
Julian Wiedmann | a59d121 | 2019-06-27 17:01:22 +0200 | [diff] [blame] | 928 | iob = qeth_ipa_alloc_cmd(card, IPA_CMD_CREATE_ADDR, QETH_PROT_IPV6, |
| 929 | IPA_DATA_SIZEOF(create_destroy_addr)); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 930 | if (!iob) |
| 931 | return -ENOMEM; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 932 | |
| 933 | rc = qeth_send_ipa_cmd(card, iob, qeth_l3_iqd_read_initial_mac_cb, |
| 934 | NULL); |
| 935 | return rc; |
| 936 | } |
| 937 | |
| 938 | static int qeth_l3_get_unique_id_cb(struct qeth_card *card, |
| 939 | struct qeth_reply *reply, unsigned long data) |
| 940 | { |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 941 | struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
Julian Wiedmann | 8ec1e24 | 2020-03-25 10:35:01 +0100 | [diff] [blame] | 942 | u16 *uid = reply->param; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 943 | |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 944 | if (cmd->hdr.return_code == 0) { |
Julian Wiedmann | 8ec1e24 | 2020-03-25 10:35:01 +0100 | [diff] [blame] | 945 | *uid = cmd->data.create_destroy_addr.uid; |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 946 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 947 | } |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 948 | |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 949 | dev_warn(&card->gdev->dev, "The network adapter failed to generate a unique ID\n"); |
| 950 | return -EIO; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 951 | } |
| 952 | |
Julian Wiedmann | 8ec1e24 | 2020-03-25 10:35:01 +0100 | [diff] [blame] | 953 | static u16 qeth_l3_get_unique_id(struct qeth_card *card, u16 uid) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 954 | { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 955 | struct qeth_cmd_buffer *iob; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 956 | |
Julian Wiedmann | 57a688aa | 2019-06-11 18:37:55 +0200 | [diff] [blame] | 957 | QETH_CARD_TEXT(card, 2, "guniqeid"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 958 | |
Julian Wiedmann | 8ec1e24 | 2020-03-25 10:35:01 +0100 | [diff] [blame] | 959 | if (!qeth_is_supported(card, IPA_IPV6)) |
| 960 | goto out; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 961 | |
Julian Wiedmann | a59d121 | 2019-06-27 17:01:22 +0200 | [diff] [blame] | 962 | iob = qeth_ipa_alloc_cmd(card, IPA_CMD_CREATE_ADDR, QETH_PROT_IPV6, |
| 963 | IPA_DATA_SIZEOF(create_destroy_addr)); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 964 | if (!iob) |
Julian Wiedmann | 8ec1e24 | 2020-03-25 10:35:01 +0100 | [diff] [blame] | 965 | goto out; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 966 | |
Julian Wiedmann | 8ec1e24 | 2020-03-25 10:35:01 +0100 | [diff] [blame] | 967 | __ipa_cmd(iob)->data.create_destroy_addr.uid = uid; |
| 968 | qeth_send_ipa_cmd(card, iob, qeth_l3_get_unique_id_cb, &uid); |
| 969 | |
| 970 | out: |
| 971 | return uid; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 972 | } |
| 973 | |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 974 | static int |
| 975 | qeth_diags_trace_cb(struct qeth_card *card, struct qeth_reply *reply, |
| 976 | unsigned long data) |
| 977 | { |
| 978 | struct qeth_ipa_cmd *cmd; |
| 979 | __u16 rc; |
| 980 | |
Julian Wiedmann | 57a688aa | 2019-06-11 18:37:55 +0200 | [diff] [blame] | 981 | QETH_CARD_TEXT(card, 2, "diastrcb"); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 982 | |
| 983 | cmd = (struct qeth_ipa_cmd *)data; |
| 984 | rc = cmd->hdr.return_code; |
Ursula Braun | a959189 | 2010-03-08 20:36:55 +0000 | [diff] [blame] | 985 | if (rc) |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 986 | QETH_CARD_TEXT_(card, 2, "dxter%x", rc); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 987 | switch (cmd->data.diagass.action) { |
| 988 | case QETH_DIAGS_CMD_TRACE_QUERY: |
| 989 | break; |
| 990 | case QETH_DIAGS_CMD_TRACE_DISABLE: |
Ursula Braun | a959189 | 2010-03-08 20:36:55 +0000 | [diff] [blame] | 991 | switch (rc) { |
| 992 | case 0: |
| 993 | case IPA_RC_INVALID_SUBCMD: |
| 994 | card->info.promisc_mode = SET_PROMISC_MODE_OFF; |
| 995 | dev_info(&card->gdev->dev, "The HiperSockets network " |
| 996 | "traffic analyzer is deactivated\n"); |
| 997 | break; |
| 998 | default: |
| 999 | break; |
| 1000 | } |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1001 | break; |
| 1002 | case QETH_DIAGS_CMD_TRACE_ENABLE: |
Ursula Braun | a959189 | 2010-03-08 20:36:55 +0000 | [diff] [blame] | 1003 | switch (rc) { |
| 1004 | case 0: |
| 1005 | card->info.promisc_mode = SET_PROMISC_MODE_ON; |
| 1006 | dev_info(&card->gdev->dev, "The HiperSockets network " |
| 1007 | "traffic analyzer is activated\n"); |
| 1008 | break; |
| 1009 | case IPA_RC_HARDWARE_AUTH_ERROR: |
| 1010 | dev_warn(&card->gdev->dev, "The device is not " |
| 1011 | "authorized to run as a HiperSockets network " |
| 1012 | "traffic analyzer\n"); |
| 1013 | break; |
| 1014 | case IPA_RC_TRACE_ALREADY_ACTIVE: |
| 1015 | dev_warn(&card->gdev->dev, "A HiperSockets " |
| 1016 | "network traffic analyzer is already " |
| 1017 | "active in the HiperSockets LAN\n"); |
| 1018 | break; |
| 1019 | default: |
| 1020 | break; |
| 1021 | } |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1022 | break; |
| 1023 | default: |
Julian Wiedmann | e19e5be | 2018-11-02 19:04:08 +0100 | [diff] [blame] | 1024 | QETH_DBF_MESSAGE(2, "Unknown sniffer action (%#06x) on device %x\n", |
| 1025 | cmd->data.diagass.action, CARD_DEVID(card)); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1026 | } |
| 1027 | |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1028 | return rc ? -EIO : 0; |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1029 | } |
| 1030 | |
| 1031 | static int |
| 1032 | qeth_diags_trace(struct qeth_card *card, enum qeth_diags_trace_cmds diags_cmd) |
| 1033 | { |
| 1034 | struct qeth_cmd_buffer *iob; |
| 1035 | struct qeth_ipa_cmd *cmd; |
| 1036 | |
Julian Wiedmann | 57a688aa | 2019-06-11 18:37:55 +0200 | [diff] [blame] | 1037 | QETH_CARD_TEXT(card, 2, "diagtrac"); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1038 | |
Julian Wiedmann | 5cfbe10 | 2019-06-27 17:01:25 +0200 | [diff] [blame] | 1039 | iob = qeth_get_diag_cmd(card, QETH_DIAGS_CMD_TRACE, 0); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 1040 | if (!iob) |
| 1041 | return -ENOMEM; |
Julian Wiedmann | ff5caa7 | 2018-03-09 18:12:52 +0100 | [diff] [blame] | 1042 | cmd = __ipa_cmd(iob); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1043 | cmd->data.diagass.type = QETH_DIAGS_TYPE_HIPERSOCKET; |
| 1044 | cmd->data.diagass.action = diags_cmd; |
| 1045 | return qeth_send_ipa_cmd(card, iob, qeth_diags_trace_cb, NULL); |
| 1046 | } |
| 1047 | |
Julian Wiedmann | 8659c18 | 2019-11-14 11:19:22 +0100 | [diff] [blame] | 1048 | static int qeth_l3_add_mcast_rtnl(struct net_device *dev, int vid, void *arg) |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1049 | { |
Julian Wiedmann | 8659c18 | 2019-11-14 11:19:22 +0100 | [diff] [blame] | 1050 | struct qeth_card *card = arg; |
Julian Wiedmann | 611abe5 | 2019-11-14 11:19:21 +0100 | [diff] [blame] | 1051 | struct inet6_dev *in6_dev; |
| 1052 | struct in_device *in4_dev; |
| 1053 | struct qeth_ipaddr *ipm; |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 1054 | struct qeth_ipaddr tmp; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1055 | struct ip_mc_list *im4; |
Julian Wiedmann | 611abe5 | 2019-11-14 11:19:21 +0100 | [diff] [blame] | 1056 | struct ifmcaddr6 *im6; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1057 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1058 | QETH_CARD_TEXT(card, 4, "addmc"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1059 | |
Julian Wiedmann | 611abe5 | 2019-11-14 11:19:21 +0100 | [diff] [blame] | 1060 | if (!dev || !(dev->flags & IFF_UP)) |
| 1061 | goto out; |
| 1062 | |
Julian Wiedmann | 8659c18 | 2019-11-14 11:19:22 +0100 | [diff] [blame] | 1063 | in4_dev = __in_dev_get_rtnl(dev); |
Julian Wiedmann | 611abe5 | 2019-11-14 11:19:21 +0100 | [diff] [blame] | 1064 | if (!in4_dev) |
| 1065 | goto walk_ipv6; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1066 | |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 1067 | qeth_l3_init_ipaddr(&tmp, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV4); |
| 1068 | tmp.disp_flag = QETH_DISP_ADDR_ADD; |
| 1069 | tmp.is_multicast = 1; |
| 1070 | |
Julian Wiedmann | 8659c18 | 2019-11-14 11:19:22 +0100 | [diff] [blame] | 1071 | for (im4 = rtnl_dereference(in4_dev->mc_list); im4 != NULL; |
| 1072 | im4 = rtnl_dereference(im4->next_rcu)) { |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 1073 | tmp.u.a4.addr = im4->multiaddr; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1074 | |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 1075 | ipm = qeth_l3_find_addr_by_ip(card, &tmp); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1076 | if (ipm) { |
Julian Wiedmann | c5c48c5 | 2018-02-27 18:58:16 +0100 | [diff] [blame] | 1077 | /* for mcast, by-IP match means full match */ |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1078 | ipm->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 1079 | continue; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1080 | } |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 1081 | |
| 1082 | ipm = kmemdup(&tmp, sizeof(tmp), GFP_KERNEL); |
| 1083 | if (!ipm) |
| 1084 | continue; |
| 1085 | |
Julian Wiedmann | 0973292 | 2020-07-14 16:23:04 +0200 | [diff] [blame] | 1086 | hash_add(card->rx_mode_addrs, &ipm->hnode, |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 1087 | qeth_l3_ipaddr_hash(ipm)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1088 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1089 | |
Julian Wiedmann | 611abe5 | 2019-11-14 11:19:21 +0100 | [diff] [blame] | 1090 | walk_ipv6: |
| 1091 | if (!qeth_is_supported(card, IPA_IPV6)) |
| 1092 | goto out; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1093 | |
Julian Wiedmann | 611abe5 | 2019-11-14 11:19:21 +0100 | [diff] [blame] | 1094 | in6_dev = __in6_dev_get(dev); |
| 1095 | if (!in6_dev) |
| 1096 | goto out; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1097 | |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 1098 | qeth_l3_init_ipaddr(&tmp, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV6); |
| 1099 | tmp.disp_flag = QETH_DISP_ADDR_ADD; |
| 1100 | tmp.is_multicast = 1; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1101 | |
Julian Wiedmann | ddf2810 | 2019-11-14 11:19:19 +0100 | [diff] [blame] | 1102 | read_lock_bh(&in6_dev->lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1103 | for (im6 = in6_dev->mc_list; im6 != NULL; im6 = im6->next) { |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 1104 | tmp.u.a6.addr = im6->mca_addr; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1105 | |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 1106 | ipm = qeth_l3_find_addr_by_ip(card, &tmp); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1107 | if (ipm) { |
Julian Wiedmann | c5c48c5 | 2018-02-27 18:58:16 +0100 | [diff] [blame] | 1108 | /* for mcast, by-IP match means full match */ |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1109 | ipm->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
| 1110 | continue; |
| 1111 | } |
| 1112 | |
Julian Wiedmann | b80c08a | 2019-11-14 11:19:23 +0100 | [diff] [blame] | 1113 | ipm = kmemdup(&tmp, sizeof(tmp), GFP_ATOMIC); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1114 | if (!ipm) |
| 1115 | continue; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1116 | |
Julian Wiedmann | 0973292 | 2020-07-14 16:23:04 +0200 | [diff] [blame] | 1117 | hash_add(card->rx_mode_addrs, &ipm->hnode, |
| 1118 | qeth_l3_ipaddr_hash(ipm)); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1119 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1120 | } |
Julian Wiedmann | ddf2810 | 2019-11-14 11:19:19 +0100 | [diff] [blame] | 1121 | read_unlock_bh(&in6_dev->lock); |
| 1122 | |
Julian Wiedmann | 611abe5 | 2019-11-14 11:19:21 +0100 | [diff] [blame] | 1123 | out: |
Julian Wiedmann | 8659c18 | 2019-11-14 11:19:22 +0100 | [diff] [blame] | 1124 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1125 | } |
| 1126 | |
Patrick McHardy | 80d5c36 | 2013-04-19 02:04:28 +0000 | [diff] [blame] | 1127 | static int qeth_l3_vlan_rx_add_vid(struct net_device *dev, |
| 1128 | __be16 proto, u16 vid) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1129 | { |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1130 | struct qeth_card *card = dev->ml_priv; |
| 1131 | |
Julian Wiedmann | 8659c18 | 2019-11-14 11:19:22 +0100 | [diff] [blame] | 1132 | QETH_CARD_TEXT_(card, 4, "aid:%d", vid); |
Jiri Pirko | 8e58613 | 2011-12-08 19:52:37 -0500 | [diff] [blame] | 1133 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1134 | } |
| 1135 | |
Patrick McHardy | 80d5c36 | 2013-04-19 02:04:28 +0000 | [diff] [blame] | 1136 | static int qeth_l3_vlan_rx_kill_vid(struct net_device *dev, |
| 1137 | __be16 proto, u16 vid) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1138 | { |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 1139 | struct qeth_card *card = dev->ml_priv; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1140 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1141 | QETH_CARD_TEXT_(card, 4, "kid:%d", vid); |
Jiri Pirko | 8e58613 | 2011-12-08 19:52:37 -0500 | [diff] [blame] | 1142 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1143 | } |
| 1144 | |
Julian Wiedmann | 59b757a | 2019-08-20 16:46:41 +0200 | [diff] [blame] | 1145 | static void qeth_l3_set_promisc_mode(struct qeth_card *card) |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1146 | { |
Julian Wiedmann | 59b757a | 2019-08-20 16:46:41 +0200 | [diff] [blame] | 1147 | bool enable = card->dev->flags & IFF_PROMISC; |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1148 | |
Julian Wiedmann | 59b757a | 2019-08-20 16:46:41 +0200 | [diff] [blame] | 1149 | if (card->info.promisc_mode == enable) |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1150 | return; |
| 1151 | |
Julian Wiedmann | 379ac99 | 2019-04-25 18:25:57 +0200 | [diff] [blame] | 1152 | if (IS_VM_NIC(card)) { /* Guestlan trace */ |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1153 | if (qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) |
Julian Wiedmann | 59b757a | 2019-08-20 16:46:41 +0200 | [diff] [blame] | 1154 | qeth_setadp_promisc_mode(card, enable); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1155 | } else if (card->options.sniffer && /* HiperSockets trace */ |
| 1156 | qeth_adp_supported(card, IPA_SETADP_SET_DIAG_ASSIST)) { |
Julian Wiedmann | 59b757a | 2019-08-20 16:46:41 +0200 | [diff] [blame] | 1157 | if (enable) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1158 | QETH_CARD_TEXT(card, 3, "+promisc"); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1159 | qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_ENABLE); |
| 1160 | } else { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1161 | QETH_CARD_TEXT(card, 3, "-promisc"); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1162 | qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_DISABLE); |
| 1163 | } |
| 1164 | } |
| 1165 | } |
| 1166 | |
Julian Wiedmann | d0c7482 | 2019-03-28 16:39:19 +0100 | [diff] [blame] | 1167 | static void qeth_l3_rx_mode_work(struct work_struct *work) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1168 | { |
Julian Wiedmann | d0c7482 | 2019-03-28 16:39:19 +0100 | [diff] [blame] | 1169 | struct qeth_card *card = container_of(work, struct qeth_card, |
| 1170 | rx_mode_work); |
Julian Wiedmann | 00c163f | 2017-12-20 20:11:02 +0100 | [diff] [blame] | 1171 | struct qeth_ipaddr *addr; |
| 1172 | struct hlist_node *tmp; |
| 1173 | int i, rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1174 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1175 | QETH_CARD_TEXT(card, 3, "setmulti"); |
Julian Wiedmann | e6e771b | 2019-01-25 15:44:22 +0100 | [diff] [blame] | 1176 | |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1177 | if (!card->options.sniffer) { |
Julian Wiedmann | 8659c18 | 2019-11-14 11:19:22 +0100 | [diff] [blame] | 1178 | rtnl_lock(); |
| 1179 | qeth_l3_add_mcast_rtnl(card->dev, 0, card); |
Julian Wiedmann | 611abe5 | 2019-11-14 11:19:21 +0100 | [diff] [blame] | 1180 | if (qeth_is_supported(card, IPA_FULL_VLAN)) |
Julian Wiedmann | 8659c18 | 2019-11-14 11:19:22 +0100 | [diff] [blame] | 1181 | vlan_for_each(card->dev, qeth_l3_add_mcast_rtnl, card); |
| 1182 | rtnl_unlock(); |
Julian Wiedmann | 00c163f | 2017-12-20 20:11:02 +0100 | [diff] [blame] | 1183 | |
Julian Wiedmann | 0973292 | 2020-07-14 16:23:04 +0200 | [diff] [blame] | 1184 | hash_for_each_safe(card->rx_mode_addrs, i, tmp, addr, hnode) { |
Julian Wiedmann | 00c163f | 2017-12-20 20:11:02 +0100 | [diff] [blame] | 1185 | switch (addr->disp_flag) { |
| 1186 | case QETH_DISP_ADDR_DELETE: |
| 1187 | rc = qeth_l3_deregister_addr_entry(card, addr); |
Julian Wiedmann | 4b7ae12 | 2019-02-12 18:33:23 +0100 | [diff] [blame] | 1188 | if (!rc || rc == -ENOENT) { |
Julian Wiedmann | 00c163f | 2017-12-20 20:11:02 +0100 | [diff] [blame] | 1189 | hash_del(&addr->hnode); |
| 1190 | kfree(addr); |
| 1191 | } |
| 1192 | break; |
| 1193 | case QETH_DISP_ADDR_ADD: |
| 1194 | rc = qeth_l3_register_addr_entry(card, addr); |
Julian Wiedmann | 4b7ae12 | 2019-02-12 18:33:23 +0100 | [diff] [blame] | 1195 | if (rc && rc != -ENETDOWN) { |
Julian Wiedmann | 00c163f | 2017-12-20 20:11:02 +0100 | [diff] [blame] | 1196 | hash_del(&addr->hnode); |
| 1197 | kfree(addr); |
| 1198 | break; |
| 1199 | } |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 1200 | fallthrough; |
Julian Wiedmann | 00c163f | 2017-12-20 20:11:02 +0100 | [diff] [blame] | 1201 | default: |
| 1202 | /* for next call to set_rx_mode(): */ |
| 1203 | addr->disp_flag = QETH_DISP_ADDR_DELETE; |
| 1204 | } |
| 1205 | } |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1206 | } |
Julian Wiedmann | 59b757a | 2019-08-20 16:46:41 +0200 | [diff] [blame] | 1207 | |
| 1208 | qeth_l3_set_promisc_mode(card); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1209 | } |
| 1210 | |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1211 | static int qeth_l3_arp_makerc(u16 rc) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1212 | { |
Julian Wiedmann | e19e5be | 2018-11-02 19:04:08 +0100 | [diff] [blame] | 1213 | switch (rc) { |
| 1214 | case IPA_RC_SUCCESS: |
| 1215 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1216 | case QETH_IPA_ARP_RC_NOTSUPP: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1217 | case QETH_IPA_ARP_RC_Q_NOTSUPP: |
Julian Wiedmann | e19e5be | 2018-11-02 19:04:08 +0100 | [diff] [blame] | 1218 | return -EOPNOTSUPP; |
| 1219 | case QETH_IPA_ARP_RC_OUT_OF_RANGE: |
| 1220 | return -EINVAL; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1221 | case QETH_IPA_ARP_RC_Q_NO_DATA: |
Julian Wiedmann | e19e5be | 2018-11-02 19:04:08 +0100 | [diff] [blame] | 1222 | return -ENOENT; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1223 | default: |
Julian Wiedmann | e19e5be | 2018-11-02 19:04:08 +0100 | [diff] [blame] | 1224 | return -EIO; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1225 | } |
| 1226 | } |
| 1227 | |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1228 | static int qeth_l3_arp_cmd_cb(struct qeth_card *card, struct qeth_reply *reply, |
| 1229 | unsigned long data) |
| 1230 | { |
| 1231 | struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
| 1232 | |
| 1233 | qeth_setassparms_cb(card, reply, data); |
| 1234 | return qeth_l3_arp_makerc(cmd->hdr.return_code); |
| 1235 | } |
| 1236 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1237 | static int qeth_l3_arp_set_no_entries(struct qeth_card *card, int no_entries) |
| 1238 | { |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1239 | struct qeth_cmd_buffer *iob; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1240 | int rc; |
| 1241 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1242 | QETH_CARD_TEXT(card, 3, "arpstnoe"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1243 | |
| 1244 | /* |
| 1245 | * currently GuestLAN only supports the ARP assist function |
| 1246 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES; |
| 1247 | * thus we say EOPNOTSUPP for this ARP function |
| 1248 | */ |
Julian Wiedmann | 379ac99 | 2019-04-25 18:25:57 +0200 | [diff] [blame] | 1249 | if (IS_VM_NIC(card)) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1250 | return -EOPNOTSUPP; |
| 1251 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1252 | return -EOPNOTSUPP; |
| 1253 | } |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1254 | |
| 1255 | iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, |
Julian Wiedmann | b915046 | 2019-06-27 17:01:24 +0200 | [diff] [blame] | 1256 | IPA_CMD_ASS_ARP_SET_NO_ENTRIES, |
| 1257 | SETASS_DATA_SIZEOF(flags_32bit), |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1258 | QETH_PROT_IPV4); |
| 1259 | if (!iob) |
| 1260 | return -ENOMEM; |
| 1261 | |
| 1262 | __ipa_cmd(iob)->data.setassparms.data.flags_32bit = (u32) no_entries; |
| 1263 | rc = qeth_send_ipa_cmd(card, iob, qeth_l3_arp_cmd_cb, NULL); |
Julian Wiedmann | e19e5be | 2018-11-02 19:04:08 +0100 | [diff] [blame] | 1264 | if (rc) |
| 1265 | QETH_DBF_MESSAGE(2, "Could not set number of ARP entries on device %x: %#x\n", |
| 1266 | CARD_DEVID(card), rc); |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1267 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1268 | } |
| 1269 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1270 | static __u32 get_arp_entry_size(struct qeth_card *card, |
| 1271 | struct qeth_arp_query_data *qdata, |
| 1272 | struct qeth_arp_entrytype *type, __u8 strip_entries) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1273 | { |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1274 | __u32 rc; |
| 1275 | __u8 is_hsi; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1276 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1277 | is_hsi = qdata->reply_bits == 5; |
| 1278 | if (type->ip == QETHARP_IP_ADDR_V4) { |
| 1279 | QETH_CARD_TEXT(card, 4, "arpev4"); |
| 1280 | if (strip_entries) { |
| 1281 | rc = is_hsi ? sizeof(struct qeth_arp_qi_entry5_short) : |
| 1282 | sizeof(struct qeth_arp_qi_entry7_short); |
| 1283 | } else { |
| 1284 | rc = is_hsi ? sizeof(struct qeth_arp_qi_entry5) : |
| 1285 | sizeof(struct qeth_arp_qi_entry7); |
| 1286 | } |
| 1287 | } else if (type->ip == QETHARP_IP_ADDR_V6) { |
| 1288 | QETH_CARD_TEXT(card, 4, "arpev6"); |
| 1289 | if (strip_entries) { |
| 1290 | rc = is_hsi ? |
| 1291 | sizeof(struct qeth_arp_qi_entry5_short_ipv6) : |
| 1292 | sizeof(struct qeth_arp_qi_entry7_short_ipv6); |
| 1293 | } else { |
| 1294 | rc = is_hsi ? |
| 1295 | sizeof(struct qeth_arp_qi_entry5_ipv6) : |
| 1296 | sizeof(struct qeth_arp_qi_entry7_ipv6); |
| 1297 | } |
| 1298 | } else { |
| 1299 | QETH_CARD_TEXT(card, 4, "arpinv"); |
| 1300 | rc = 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1301 | } |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1302 | |
| 1303 | return rc; |
| 1304 | } |
| 1305 | |
| 1306 | static int arpentry_matches_prot(struct qeth_arp_entrytype *type, __u16 prot) |
| 1307 | { |
| 1308 | return (type->ip == QETHARP_IP_ADDR_V4 && prot == QETH_PROT_IPV4) || |
| 1309 | (type->ip == QETHARP_IP_ADDR_V6 && prot == QETH_PROT_IPV6); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1310 | } |
| 1311 | |
| 1312 | static int qeth_l3_arp_query_cb(struct qeth_card *card, |
| 1313 | struct qeth_reply *reply, unsigned long data) |
| 1314 | { |
| 1315 | struct qeth_ipa_cmd *cmd; |
| 1316 | struct qeth_arp_query_data *qdata; |
| 1317 | struct qeth_arp_query_info *qinfo; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1318 | int e; |
| 1319 | int entrybytes_done; |
| 1320 | int stripped_bytes; |
| 1321 | __u8 do_strip_entries; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1322 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1323 | QETH_CARD_TEXT(card, 3, "arpquecb"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1324 | |
| 1325 | qinfo = (struct qeth_arp_query_info *) reply->param; |
| 1326 | cmd = (struct qeth_ipa_cmd *) data; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1327 | QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.prot_version); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1328 | if (cmd->hdr.return_code) { |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1329 | QETH_CARD_TEXT(card, 4, "arpcberr"); |
| 1330 | QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.return_code); |
Julian Wiedmann | 4b7ae12 | 2019-02-12 18:33:23 +0100 | [diff] [blame] | 1331 | return qeth_l3_arp_makerc(cmd->hdr.return_code); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1332 | } |
| 1333 | if (cmd->data.setassparms.hdr.return_code) { |
| 1334 | cmd->hdr.return_code = cmd->data.setassparms.hdr.return_code; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1335 | QETH_CARD_TEXT(card, 4, "setaperr"); |
| 1336 | QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.return_code); |
Julian Wiedmann | 4b7ae12 | 2019-02-12 18:33:23 +0100 | [diff] [blame] | 1337 | return qeth_l3_arp_makerc(cmd->hdr.return_code); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1338 | } |
| 1339 | qdata = &cmd->data.setassparms.data.query_arp; |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1340 | QETH_CARD_TEXT_(card, 4, "anoen%i", qdata->no_entries); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1341 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1342 | do_strip_entries = (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES) > 0; |
| 1343 | stripped_bytes = do_strip_entries ? QETH_QARP_MEDIASPECIFIC_BYTES : 0; |
| 1344 | entrybytes_done = 0; |
| 1345 | for (e = 0; e < qdata->no_entries; ++e) { |
| 1346 | char *cur_entry; |
| 1347 | __u32 esize; |
| 1348 | struct qeth_arp_entrytype *etype; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1349 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1350 | cur_entry = &qdata->data + entrybytes_done; |
| 1351 | etype = &((struct qeth_arp_qi_entry5 *) cur_entry)->type; |
| 1352 | if (!arpentry_matches_prot(etype, cmd->hdr.prot_version)) { |
| 1353 | QETH_CARD_TEXT(card, 4, "pmis"); |
| 1354 | QETH_CARD_TEXT_(card, 4, "%i", etype->ip); |
| 1355 | break; |
| 1356 | } |
| 1357 | esize = get_arp_entry_size(card, qdata, etype, |
| 1358 | do_strip_entries); |
| 1359 | QETH_CARD_TEXT_(card, 5, "esz%i", esize); |
| 1360 | if (!esize) |
| 1361 | break; |
| 1362 | |
| 1363 | if ((qinfo->udata_len - qinfo->udata_offset) < esize) { |
Julian Wiedmann | 4b7ae12 | 2019-02-12 18:33:23 +0100 | [diff] [blame] | 1364 | QETH_CARD_TEXT_(card, 4, "qaer3%i", -ENOSPC); |
| 1365 | memset(qinfo->udata, 0, 4); |
| 1366 | return -ENOSPC; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1367 | } |
| 1368 | |
| 1369 | memcpy(qinfo->udata + qinfo->udata_offset, |
| 1370 | &qdata->data + entrybytes_done + stripped_bytes, |
| 1371 | esize); |
| 1372 | entrybytes_done += esize + stripped_bytes; |
| 1373 | qinfo->udata_offset += esize; |
| 1374 | ++qinfo->no_entries; |
| 1375 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1376 | /* check if all replies received ... */ |
| 1377 | if (cmd->data.setassparms.hdr.seq_no < |
| 1378 | cmd->data.setassparms.hdr.number_of_replies) |
| 1379 | return 1; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1380 | QETH_CARD_TEXT_(card, 4, "nove%i", qinfo->no_entries); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1381 | memcpy(qinfo->udata, &qinfo->no_entries, 4); |
| 1382 | /* keep STRIP_ENTRIES flag so the user program can distinguish |
| 1383 | * stripped entries from normal ones */ |
| 1384 | if (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES) |
| 1385 | qdata->reply_bits |= QETH_QARP_STRIP_ENTRIES; |
| 1386 | memcpy(qinfo->udata + QETH_QARP_MASK_OFFSET, &qdata->reply_bits, 2); |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1387 | QETH_CARD_TEXT_(card, 4, "rc%i", 0); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1388 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1389 | } |
| 1390 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1391 | static int qeth_l3_query_arp_cache_info(struct qeth_card *card, |
| 1392 | enum qeth_prot_versions prot, |
| 1393 | struct qeth_arp_query_info *qinfo) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1394 | { |
| 1395 | struct qeth_cmd_buffer *iob; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1396 | struct qeth_ipa_cmd *cmd; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1397 | int rc; |
| 1398 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1399 | QETH_CARD_TEXT_(card, 3, "qarpipv%i", prot); |
| 1400 | |
Thomas Richter | b475e31 | 2015-12-11 12:27:54 +0100 | [diff] [blame] | 1401 | iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, |
| 1402 | IPA_CMD_ASS_ARP_QUERY_INFO, |
Julian Wiedmann | b915046 | 2019-06-27 17:01:24 +0200 | [diff] [blame] | 1403 | SETASS_DATA_SIZEOF(query_arp), prot); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 1404 | if (!iob) |
| 1405 | return -ENOMEM; |
Julian Wiedmann | ff5caa7 | 2018-03-09 18:12:52 +0100 | [diff] [blame] | 1406 | cmd = __ipa_cmd(iob); |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1407 | cmd->data.setassparms.data.query_arp.request_bits = 0x000F; |
Julian Wiedmann | 84dbea4 | 2019-02-12 18:33:16 +0100 | [diff] [blame] | 1408 | rc = qeth_send_ipa_cmd(card, iob, qeth_l3_arp_query_cb, qinfo); |
Julian Wiedmann | e19e5be | 2018-11-02 19:04:08 +0100 | [diff] [blame] | 1409 | if (rc) |
| 1410 | QETH_DBF_MESSAGE(2, "Error while querying ARP cache on device %x: %#x\n", |
| 1411 | CARD_DEVID(card), rc); |
Julian Wiedmann | 4b7ae12 | 2019-02-12 18:33:23 +0100 | [diff] [blame] | 1412 | return rc; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1413 | } |
| 1414 | |
| 1415 | static int qeth_l3_arp_query(struct qeth_card *card, char __user *udata) |
| 1416 | { |
| 1417 | struct qeth_arp_query_info qinfo = {0, }; |
| 1418 | int rc; |
| 1419 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1420 | QETH_CARD_TEXT(card, 3, "arpquery"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1421 | |
| 1422 | if (!qeth_is_supported(card,/*IPA_QUERY_ARP_ADDR_INFO*/ |
| 1423 | IPA_ARP_PROCESSING)) { |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1424 | QETH_CARD_TEXT(card, 3, "arpqnsup"); |
| 1425 | rc = -EOPNOTSUPP; |
| 1426 | goto out; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1427 | } |
| 1428 | /* get size of userspace buffer and mask_bits -> 6 bytes */ |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1429 | if (copy_from_user(&qinfo, udata, 6)) { |
| 1430 | rc = -EFAULT; |
| 1431 | goto out; |
| 1432 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1433 | qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL); |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1434 | if (!qinfo.udata) { |
| 1435 | rc = -ENOMEM; |
| 1436 | goto out; |
| 1437 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1438 | qinfo.udata_offset = QETH_QARP_ENTRIES_OFFSET; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1439 | rc = qeth_l3_query_arp_cache_info(card, QETH_PROT_IPV4, &qinfo); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1440 | if (rc) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1441 | if (copy_to_user(udata, qinfo.udata, 4)) |
| 1442 | rc = -EFAULT; |
Sebastian Ott | 77a83ed | 2016-06-16 16:19:03 +0200 | [diff] [blame] | 1443 | goto free_and_out; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1444 | } |
Sebastian Ott | 77a83ed | 2016-06-16 16:19:03 +0200 | [diff] [blame] | 1445 | if (qinfo.mask_bits & QETH_QARP_WITH_IPV6) { |
| 1446 | /* fails in case of GuestLAN QDIO mode */ |
| 1447 | qeth_l3_query_arp_cache_info(card, QETH_PROT_IPV6, &qinfo); |
| 1448 | } |
Sebastian Ott | 77a83ed | 2016-06-16 16:19:03 +0200 | [diff] [blame] | 1449 | if (copy_to_user(udata, qinfo.udata, qinfo.udata_len)) { |
| 1450 | QETH_CARD_TEXT(card, 4, "qactf"); |
| 1451 | rc = -EFAULT; |
| 1452 | goto free_and_out; |
| 1453 | } |
| 1454 | QETH_CARD_TEXT(card, 4, "qacts"); |
| 1455 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1456 | free_and_out: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1457 | kfree(qinfo.udata); |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 1458 | out: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1459 | return rc; |
| 1460 | } |
| 1461 | |
Julian Wiedmann | 125d7d3 | 2018-11-02 19:04:12 +0100 | [diff] [blame] | 1462 | static int qeth_l3_arp_modify_entry(struct qeth_card *card, |
| 1463 | struct qeth_arp_cache_entry *entry, |
| 1464 | enum qeth_arp_process_subcmds arp_cmd) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1465 | { |
Julian Wiedmann | 125d7d3 | 2018-11-02 19:04:12 +0100 | [diff] [blame] | 1466 | struct qeth_arp_cache_entry *cmd_entry; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1467 | struct qeth_cmd_buffer *iob; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1468 | int rc; |
| 1469 | |
Julian Wiedmann | 125d7d3 | 2018-11-02 19:04:12 +0100 | [diff] [blame] | 1470 | if (arp_cmd == IPA_CMD_ASS_ARP_ADD_ENTRY) |
| 1471 | QETH_CARD_TEXT(card, 3, "arpadd"); |
| 1472 | else |
| 1473 | QETH_CARD_TEXT(card, 3, "arpdel"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1474 | |
| 1475 | /* |
| 1476 | * currently GuestLAN only supports the ARP assist function |
| 1477 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY; |
| 1478 | * thus we say EOPNOTSUPP for this ARP function |
| 1479 | */ |
Julian Wiedmann | 379ac99 | 2019-04-25 18:25:57 +0200 | [diff] [blame] | 1480 | if (IS_VM_NIC(card)) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1481 | return -EOPNOTSUPP; |
| 1482 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1483 | return -EOPNOTSUPP; |
| 1484 | } |
| 1485 | |
Julian Wiedmann | 125d7d3 | 2018-11-02 19:04:12 +0100 | [diff] [blame] | 1486 | iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, arp_cmd, |
Julian Wiedmann | b915046 | 2019-06-27 17:01:24 +0200 | [diff] [blame] | 1487 | SETASS_DATA_SIZEOF(arp_entry), |
| 1488 | QETH_PROT_IPV4); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 1489 | if (!iob) |
| 1490 | return -ENOMEM; |
Julian Wiedmann | 125d7d3 | 2018-11-02 19:04:12 +0100 | [diff] [blame] | 1491 | |
| 1492 | cmd_entry = &__ipa_cmd(iob)->data.setassparms.data.arp_entry; |
| 1493 | ether_addr_copy(cmd_entry->macaddr, entry->macaddr); |
| 1494 | memcpy(cmd_entry->ipaddr, entry->ipaddr, 4); |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1495 | rc = qeth_send_ipa_cmd(card, iob, qeth_l3_arp_cmd_cb, NULL); |
Julian Wiedmann | e19e5be | 2018-11-02 19:04:08 +0100 | [diff] [blame] | 1496 | if (rc) |
Julian Wiedmann | 125d7d3 | 2018-11-02 19:04:12 +0100 | [diff] [blame] | 1497 | QETH_DBF_MESSAGE(2, "Could not modify (cmd: %#x) ARP entry on device %x: %#x\n", |
| 1498 | arp_cmd, CARD_DEVID(card), rc); |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1499 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1500 | } |
| 1501 | |
| 1502 | static int qeth_l3_arp_flush_cache(struct qeth_card *card) |
| 1503 | { |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1504 | struct qeth_cmd_buffer *iob; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1505 | int rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1506 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1507 | QETH_CARD_TEXT(card, 3, "arpflush"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1508 | |
| 1509 | /* |
| 1510 | * currently GuestLAN only supports the ARP assist function |
| 1511 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE; |
| 1512 | * thus we say EOPNOTSUPP for this ARP function |
| 1513 | */ |
Julian Wiedmann | 379ac99 | 2019-04-25 18:25:57 +0200 | [diff] [blame] | 1514 | if (IS_VM_NIC(card) || IS_IQD(card)) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1515 | return -EOPNOTSUPP; |
| 1516 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1517 | return -EOPNOTSUPP; |
| 1518 | } |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1519 | |
| 1520 | iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, |
| 1521 | IPA_CMD_ASS_ARP_FLUSH_CACHE, 0, |
| 1522 | QETH_PROT_IPV4); |
| 1523 | if (!iob) |
| 1524 | return -ENOMEM; |
| 1525 | |
| 1526 | rc = qeth_send_ipa_cmd(card, iob, qeth_l3_arp_cmd_cb, NULL); |
Julian Wiedmann | e19e5be | 2018-11-02 19:04:08 +0100 | [diff] [blame] | 1527 | if (rc) |
| 1528 | QETH_DBF_MESSAGE(2, "Could not flush ARP cache on device %x: %#x\n", |
| 1529 | CARD_DEVID(card), rc); |
Julian Wiedmann | 742d4d4 | 2019-02-12 18:33:25 +0100 | [diff] [blame] | 1530 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1531 | } |
| 1532 | |
| 1533 | static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
| 1534 | { |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 1535 | struct qeth_card *card = dev->ml_priv; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1536 | struct qeth_arp_cache_entry arp_entry; |
Julian Wiedmann | 125d7d3 | 2018-11-02 19:04:12 +0100 | [diff] [blame] | 1537 | enum qeth_arp_process_subcmds arp_cmd; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1538 | int rc = 0; |
| 1539 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1540 | switch (cmd) { |
| 1541 | case SIOC_QETH_ARP_SET_NO_ENTRIES: |
| 1542 | if (!capable(CAP_NET_ADMIN)) { |
| 1543 | rc = -EPERM; |
| 1544 | break; |
| 1545 | } |
| 1546 | rc = qeth_l3_arp_set_no_entries(card, rq->ifr_ifru.ifru_ivalue); |
| 1547 | break; |
| 1548 | case SIOC_QETH_ARP_QUERY_INFO: |
| 1549 | if (!capable(CAP_NET_ADMIN)) { |
| 1550 | rc = -EPERM; |
| 1551 | break; |
| 1552 | } |
| 1553 | rc = qeth_l3_arp_query(card, rq->ifr_ifru.ifru_data); |
| 1554 | break; |
| 1555 | case SIOC_QETH_ARP_ADD_ENTRY: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1556 | case SIOC_QETH_ARP_REMOVE_ENTRY: |
Julian Wiedmann | 125d7d3 | 2018-11-02 19:04:12 +0100 | [diff] [blame] | 1557 | if (!capable(CAP_NET_ADMIN)) |
| 1558 | return -EPERM; |
| 1559 | if (copy_from_user(&arp_entry, rq->ifr_data, sizeof(arp_entry))) |
| 1560 | return -EFAULT; |
| 1561 | |
| 1562 | arp_cmd = (cmd == SIOC_QETH_ARP_ADD_ENTRY) ? |
| 1563 | IPA_CMD_ASS_ARP_ADD_ENTRY : |
| 1564 | IPA_CMD_ASS_ARP_REMOVE_ENTRY; |
| 1565 | return qeth_l3_arp_modify_entry(card, &arp_entry, arp_cmd); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1566 | case SIOC_QETH_ARP_FLUSH_CACHE: |
| 1567 | if (!capable(CAP_NET_ADMIN)) { |
| 1568 | rc = -EPERM; |
| 1569 | break; |
| 1570 | } |
| 1571 | rc = qeth_l3_arp_flush_cache(card); |
| 1572 | break; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1573 | default: |
| 1574 | rc = -EOPNOTSUPP; |
| 1575 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1576 | return rc; |
| 1577 | } |
| 1578 | |
Julian Wiedmann | 980f456 | 2019-06-27 17:01:32 +0200 | [diff] [blame] | 1579 | static int qeth_l3_get_cast_type_rcu(struct sk_buff *skb, struct dst_entry *dst, |
| 1580 | int ipv) |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 1581 | { |
David S. Miller | 69cce1d | 2011-07-17 23:09:49 -0700 | [diff] [blame] | 1582 | struct neighbour *n = NULL; |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 1583 | |
Julian Wiedmann | 980f456 | 2019-06-27 17:01:32 +0200 | [diff] [blame] | 1584 | if (dst) |
| 1585 | n = dst_neigh_lookup_skb(dst, skb); |
Julian Wiedmann | 0cd6783d3 | 2019-06-05 13:48:49 +0200 | [diff] [blame] | 1586 | |
David S. Miller | 69cce1d | 2011-07-17 23:09:49 -0700 | [diff] [blame] | 1587 | if (n) { |
Julian Wiedmann | 1f97912 | 2017-12-20 20:11:04 +0100 | [diff] [blame] | 1588 | int cast_type = n->type; |
| 1589 | |
David S. Miller | 24db1ba | 2012-07-02 22:02:33 -0700 | [diff] [blame] | 1590 | neigh_release(n); |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 1591 | if ((cast_type == RTN_BROADCAST) || |
| 1592 | (cast_type == RTN_MULTICAST) || |
| 1593 | (cast_type == RTN_ANYCAST)) |
| 1594 | return cast_type; |
Julian Wiedmann | 86c0cdb | 2018-07-11 17:42:41 +0200 | [diff] [blame] | 1595 | return RTN_UNICAST; |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 1596 | } |
Frank Blaschka | 1d36cb4 | 2011-11-15 02:31:15 +0000 | [diff] [blame] | 1597 | |
Julian Wiedmann | 1f97912 | 2017-12-20 20:11:04 +0100 | [diff] [blame] | 1598 | /* no neighbour (eg AF_PACKET), fall back to target's IP address ... */ |
Julian Wiedmann | 0cd6783d3 | 2019-06-05 13:48:49 +0200 | [diff] [blame] | 1599 | switch (ipv) { |
Julian Wiedmann | f13ade1 | 2018-09-17 17:35:56 +0200 | [diff] [blame] | 1600 | case 4: |
Julian Wiedmann | 72c8797 | 2019-06-05 13:48:48 +0200 | [diff] [blame] | 1601 | if (ipv4_is_lbcast(ip_hdr(skb)->daddr)) |
| 1602 | return RTN_BROADCAST; |
Julian Wiedmann | 1f97912 | 2017-12-20 20:11:04 +0100 | [diff] [blame] | 1603 | return ipv4_is_multicast(ip_hdr(skb)->daddr) ? |
Julian Wiedmann | 86c0cdb | 2018-07-11 17:42:41 +0200 | [diff] [blame] | 1604 | RTN_MULTICAST : RTN_UNICAST; |
Julian Wiedmann | f13ade1 | 2018-09-17 17:35:56 +0200 | [diff] [blame] | 1605 | case 6: |
| 1606 | return ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) ? |
| 1607 | RTN_MULTICAST : RTN_UNICAST; |
| 1608 | default: |
| 1609 | /* ... and MAC address */ |
Julian Wiedmann | 58aa249 | 2019-04-25 18:26:00 +0200 | [diff] [blame] | 1610 | return qeth_get_ether_cast_type(skb); |
Julian Wiedmann | f13ade1 | 2018-09-17 17:35:56 +0200 | [diff] [blame] | 1611 | } |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 1612 | } |
| 1613 | |
Julian Wiedmann | 980f456 | 2019-06-27 17:01:32 +0200 | [diff] [blame] | 1614 | static int qeth_l3_get_cast_type(struct sk_buff *skb) |
| 1615 | { |
| 1616 | int ipv = qeth_get_ip_version(skb); |
| 1617 | struct dst_entry *dst; |
| 1618 | int cast_type; |
| 1619 | |
| 1620 | rcu_read_lock(); |
| 1621 | dst = qeth_dst_check_rcu(skb, ipv); |
| 1622 | cast_type = qeth_l3_get_cast_type_rcu(skb, dst, ipv); |
| 1623 | rcu_read_unlock(); |
| 1624 | |
| 1625 | return cast_type; |
| 1626 | } |
| 1627 | |
Julian Wiedmann | 910a0a8 | 2017-12-20 20:11:07 +0100 | [diff] [blame] | 1628 | static u8 qeth_l3_cast_type_to_flag(int cast_type) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1629 | { |
Julian Wiedmann | 910a0a8 | 2017-12-20 20:11:07 +0100 | [diff] [blame] | 1630 | if (cast_type == RTN_MULTICAST) |
| 1631 | return QETH_CAST_MULTICAST; |
| 1632 | if (cast_type == RTN_ANYCAST) |
| 1633 | return QETH_CAST_ANYCAST; |
| 1634 | if (cast_type == RTN_BROADCAST) |
| 1635 | return QETH_CAST_BROADCAST; |
| 1636 | return QETH_CAST_UNICAST; |
| 1637 | } |
David S. Miller | 69cce1d | 2011-07-17 23:09:49 -0700 | [diff] [blame] | 1638 | |
Julian Wiedmann | b0abc4f | 2019-02-15 19:22:29 +0100 | [diff] [blame] | 1639 | static void qeth_l3_fill_header(struct qeth_qdio_out_q *queue, |
| 1640 | struct qeth_hdr *hdr, struct sk_buff *skb, |
Julian Wiedmann | eca1d5c | 2019-06-27 17:01:33 +0200 | [diff] [blame] | 1641 | int ipv, unsigned int data_len) |
Julian Wiedmann | 910a0a8 | 2017-12-20 20:11:07 +0100 | [diff] [blame] | 1642 | { |
Julian Wiedmann | 5a541f6 | 2018-11-08 15:06:16 +0100 | [diff] [blame] | 1643 | struct qeth_hdr_layer3 *l3_hdr = &hdr->hdr.l3; |
Julian Wiedmann | f13ade1 | 2018-09-17 17:35:56 +0200 | [diff] [blame] | 1644 | struct vlan_ethhdr *veth = vlan_eth_hdr(skb); |
Julian Wiedmann | b0abc4f | 2019-02-15 19:22:29 +0100 | [diff] [blame] | 1645 | struct qeth_card *card = queue->card; |
Julian Wiedmann | 0cd6783d3 | 2019-06-05 13:48:49 +0200 | [diff] [blame] | 1646 | struct dst_entry *dst; |
Julian Wiedmann | eca1d5c | 2019-06-27 17:01:33 +0200 | [diff] [blame] | 1647 | int cast_type; |
Julian Wiedmann | f13ade1 | 2018-09-17 17:35:56 +0200 | [diff] [blame] | 1648 | |
Julian Wiedmann | f6c1314 | 2017-12-20 20:11:08 +0100 | [diff] [blame] | 1649 | hdr->hdr.l3.length = data_len; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1650 | |
Julian Wiedmann | e517b64 | 2018-09-17 17:36:02 +0200 | [diff] [blame] | 1651 | if (skb_is_gso(skb)) { |
Julian Wiedmann | 0aef839 | 2018-10-12 17:27:15 +0200 | [diff] [blame] | 1652 | hdr->hdr.l3.id = QETH_HEADER_TYPE_L3_TSO; |
Julian Wiedmann | e517b64 | 2018-09-17 17:36:02 +0200 | [diff] [blame] | 1653 | } else { |
| 1654 | hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3; |
Julian Wiedmann | 5a541f6 | 2018-11-08 15:06:16 +0100 | [diff] [blame] | 1655 | |
| 1656 | if (skb->protocol == htons(ETH_P_AF_IUCV)) { |
| 1657 | l3_hdr->flags = QETH_HDR_IPV6 | QETH_CAST_UNICAST; |
Julian Wiedmann | 1d38c2e | 2020-05-06 10:09:43 +0200 | [diff] [blame] | 1658 | l3_hdr->next_hop.addr.s6_addr16[0] = htons(0xfe80); |
| 1659 | memcpy(&l3_hdr->next_hop.addr.s6_addr32[2], |
Julian Wiedmann | 5a541f6 | 2018-11-08 15:06:16 +0100 | [diff] [blame] | 1660 | iucv_trans_hdr(skb)->destUserID, 8); |
| 1661 | return; |
| 1662 | } |
| 1663 | |
Julian Wiedmann | e517b64 | 2018-09-17 17:36:02 +0200 | [diff] [blame] | 1664 | if (skb->ip_summed == CHECKSUM_PARTIAL) { |
| 1665 | qeth_tx_csum(skb, &hdr->hdr.l3.ext_flags, ipv); |
| 1666 | /* some HW requires combined L3+L4 csum offload: */ |
| 1667 | if (ipv == 4) |
| 1668 | hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_CSUM_HDR_REQ; |
Julian Wiedmann | e517b64 | 2018-09-17 17:36:02 +0200 | [diff] [blame] | 1669 | } |
| 1670 | } |
| 1671 | |
Julian Wiedmann | f13ade1 | 2018-09-17 17:35:56 +0200 | [diff] [blame] | 1672 | if (ipv == 4 || IS_IQD(card)) { |
| 1673 | /* NETIF_F_HW_VLAN_CTAG_TX */ |
| 1674 | if (skb_vlan_tag_present(skb)) { |
| 1675 | hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_VLAN_FRAME; |
| 1676 | hdr->hdr.l3.vlan_id = skb_vlan_tag_get(skb); |
| 1677 | } |
| 1678 | } else if (veth->h_vlan_proto == htons(ETH_P_8021Q)) { |
| 1679 | hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_INCLUDE_VLAN_TAG; |
| 1680 | hdr->hdr.l3.vlan_id = ntohs(veth->h_vlan_TCI); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1681 | } |
| 1682 | |
Frank Blaschka | 1d36cb4 | 2011-11-15 02:31:15 +0000 | [diff] [blame] | 1683 | rcu_read_lock(); |
Julian Wiedmann | 980f456 | 2019-06-27 17:01:32 +0200 | [diff] [blame] | 1684 | dst = qeth_dst_check_rcu(skb, ipv); |
Julian Wiedmann | 0cd6783d3 | 2019-06-05 13:48:49 +0200 | [diff] [blame] | 1685 | |
Julian Wiedmann | eca1d5c | 2019-06-27 17:01:33 +0200 | [diff] [blame] | 1686 | if (IS_IQD(card) && skb_get_queue_mapping(skb) != QETH_IQD_MCAST_TXQ) |
| 1687 | cast_type = RTN_UNICAST; |
| 1688 | else |
| 1689 | cast_type = qeth_l3_get_cast_type_rcu(skb, dst, ipv); |
| 1690 | l3_hdr->flags |= qeth_l3_cast_type_to_flag(cast_type); |
| 1691 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1692 | if (ipv == 4) { |
Julian Wiedmann | 1d38c2e | 2020-05-06 10:09:43 +0200 | [diff] [blame] | 1693 | l3_hdr->next_hop.addr.s6_addr32[3] = |
| 1694 | qeth_next_hop_v4_rcu(skb, dst); |
Julian Wiedmann | eca1d5c | 2019-06-27 17:01:33 +0200 | [diff] [blame] | 1695 | } else if (ipv == 6) { |
Julian Wiedmann | 1d38c2e | 2020-05-06 10:09:43 +0200 | [diff] [blame] | 1696 | l3_hdr->next_hop.addr = *qeth_next_hop_v6_rcu(skb, dst); |
David Miller | 87e7597 | 2012-02-01 10:49:17 +0000 | [diff] [blame] | 1697 | |
Julian Wiedmann | 910a0a8 | 2017-12-20 20:11:07 +0100 | [diff] [blame] | 1698 | hdr->hdr.l3.flags |= QETH_HDR_IPV6; |
Julian Wiedmann | 379ac99 | 2019-04-25 18:25:57 +0200 | [diff] [blame] | 1699 | if (!IS_IQD(card)) |
Julian Wiedmann | 910a0a8 | 2017-12-20 20:11:07 +0100 | [diff] [blame] | 1700 | hdr->hdr.l3.flags |= QETH_HDR_PASSTHRU; |
Julian Wiedmann | eca1d5c | 2019-06-27 17:01:33 +0200 | [diff] [blame] | 1701 | } else { |
| 1702 | /* OSA only: */ |
| 1703 | l3_hdr->flags |= QETH_HDR_PASSTHRU; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1704 | } |
Frank Blaschka | 1d36cb4 | 2011-11-15 02:31:15 +0000 | [diff] [blame] | 1705 | rcu_read_unlock(); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1706 | } |
| 1707 | |
Julian Wiedmann | 2d3986d | 2018-09-17 17:36:00 +0200 | [diff] [blame] | 1708 | static void qeth_l3_fixup_headers(struct sk_buff *skb) |
| 1709 | { |
| 1710 | struct iphdr *iph = ip_hdr(skb); |
| 1711 | |
| 1712 | /* this is safe, IPv6 traffic takes a different path */ |
| 1713 | if (skb->ip_summed == CHECKSUM_PARTIAL) |
| 1714 | iph->check = 0; |
Julian Wiedmann | e517b64 | 2018-09-17 17:36:02 +0200 | [diff] [blame] | 1715 | if (skb_is_gso(skb)) { |
| 1716 | iph->tot_len = 0; |
| 1717 | tcp_hdr(skb)->check = ~tcp_v4_check(0, iph->saddr, |
| 1718 | iph->daddr, 0); |
| 1719 | } |
Julian Wiedmann | 2d3986d | 2018-09-17 17:36:00 +0200 | [diff] [blame] | 1720 | } |
| 1721 | |
Julian Wiedmann | 356156b | 2018-09-17 17:36:03 +0200 | [diff] [blame] | 1722 | static int qeth_l3_xmit(struct qeth_card *card, struct sk_buff *skb, |
Julian Wiedmann | eca1d5c | 2019-06-27 17:01:33 +0200 | [diff] [blame] | 1723 | struct qeth_qdio_out_q *queue, int ipv) |
Julian Wiedmann | a647a02 | 2018-07-11 17:42:46 +0200 | [diff] [blame] | 1724 | { |
Julian Wiedmann | 81ec543 | 2018-11-08 15:06:17 +0100 | [diff] [blame] | 1725 | unsigned int hw_hdr_len; |
| 1726 | int rc; |
Julian Wiedmann | e517b64 | 2018-09-17 17:36:02 +0200 | [diff] [blame] | 1727 | |
Julian Wiedmann | a647a02 | 2018-07-11 17:42:46 +0200 | [diff] [blame] | 1728 | /* re-use the L2 header area for the HW header: */ |
Julian Wiedmann | 81ec543 | 2018-11-08 15:06:17 +0100 | [diff] [blame] | 1729 | hw_hdr_len = skb_is_gso(skb) ? sizeof(struct qeth_hdr_tso) : |
| 1730 | sizeof(struct qeth_hdr); |
Julian Wiedmann | a647a02 | 2018-07-11 17:42:46 +0200 | [diff] [blame] | 1731 | rc = skb_cow_head(skb, hw_hdr_len - ETH_HLEN); |
| 1732 | if (rc) |
| 1733 | return rc; |
Julian Wiedmann | a647a02 | 2018-07-11 17:42:46 +0200 | [diff] [blame] | 1734 | skb_pull(skb, ETH_HLEN); |
Julian Wiedmann | a647a02 | 2018-07-11 17:42:46 +0200 | [diff] [blame] | 1735 | |
Julian Wiedmann | 2d3986d | 2018-09-17 17:36:00 +0200 | [diff] [blame] | 1736 | qeth_l3_fixup_headers(skb); |
Julian Wiedmann | eca1d5c | 2019-06-27 17:01:33 +0200 | [diff] [blame] | 1737 | return qeth_xmit(card, skb, queue, ipv, qeth_l3_fill_header); |
Julian Wiedmann | a647a02 | 2018-07-11 17:42:46 +0200 | [diff] [blame] | 1738 | } |
| 1739 | |
Julian Wiedmann | ea1d4a0 | 2018-07-11 17:42:45 +0200 | [diff] [blame] | 1740 | static netdev_tx_t qeth_l3_hard_start_xmit(struct sk_buff *skb, |
| 1741 | struct net_device *dev) |
| 1742 | { |
Julian Wiedmann | ea1d4a0 | 2018-07-11 17:42:45 +0200 | [diff] [blame] | 1743 | struct qeth_card *card = dev->ml_priv; |
Julian Wiedmann | 3a18d75 | 2019-04-17 18:17:32 +0200 | [diff] [blame] | 1744 | u16 txq = skb_get_queue_mapping(skb); |
Julian Wiedmann | ea1d4a0 | 2018-07-11 17:42:45 +0200 | [diff] [blame] | 1745 | int ipv = qeth_get_ip_version(skb); |
| 1746 | struct qeth_qdio_out_q *queue; |
Julian Wiedmann | eca1d5c | 2019-06-27 17:01:33 +0200 | [diff] [blame] | 1747 | int rc; |
Julian Wiedmann | b0abc4f | 2019-02-15 19:22:29 +0100 | [diff] [blame] | 1748 | |
Julian Wiedmann | eeac0e2 | 2019-08-23 11:48:49 +0200 | [diff] [blame] | 1749 | if (!skb_is_gso(skb)) |
| 1750 | qdisc_skb_cb(skb)->pkt_len = skb->len; |
Julian Wiedmann | ea1d4a0 | 2018-07-11 17:42:45 +0200 | [diff] [blame] | 1751 | if (IS_IQD(card)) { |
Julian Wiedmann | 3a18d75 | 2019-04-17 18:17:32 +0200 | [diff] [blame] | 1752 | queue = card->qdio.out_qs[qeth_iqd_translate_txq(dev, txq)]; |
| 1753 | |
Julian Wiedmann | ea1d4a0 | 2018-07-11 17:42:45 +0200 | [diff] [blame] | 1754 | if (card->options.sniffer) |
| 1755 | goto tx_drop; |
| 1756 | if ((card->options.cq != QETH_CQ_ENABLED && !ipv) || |
| 1757 | (card->options.cq == QETH_CQ_ENABLED && |
| 1758 | skb->protocol != htons(ETH_P_AF_IUCV))) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1759 | goto tx_drop; |
Julian Wiedmann | 3a18d75 | 2019-04-17 18:17:32 +0200 | [diff] [blame] | 1760 | } else { |
Julian Wiedmann | 73dc2da | 2019-04-17 18:17:33 +0200 | [diff] [blame] | 1761 | queue = card->qdio.out_qs[txq]; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1762 | } |
| 1763 | |
Julian Wiedmann | eca1d5c | 2019-06-27 17:01:33 +0200 | [diff] [blame] | 1764 | if (!(dev->flags & IFF_BROADCAST) && |
| 1765 | qeth_l3_get_cast_type(skb) == RTN_BROADCAST) |
Julian Wiedmann | ea1d4a0 | 2018-07-11 17:42:45 +0200 | [diff] [blame] | 1766 | goto tx_drop; |
| 1767 | |
Julian Wiedmann | 356156b | 2018-09-17 17:36:03 +0200 | [diff] [blame] | 1768 | if (ipv == 4 || IS_IQD(card)) |
Julian Wiedmann | eca1d5c | 2019-06-27 17:01:33 +0200 | [diff] [blame] | 1769 | rc = qeth_l3_xmit(card, skb, queue, ipv); |
Julian Wiedmann | f13ade1 | 2018-09-17 17:35:56 +0200 | [diff] [blame] | 1770 | else |
Julian Wiedmann | eca1d5c | 2019-06-27 17:01:33 +0200 | [diff] [blame] | 1771 | rc = qeth_xmit(card, skb, queue, ipv, qeth_l3_fill_header); |
Julian Wiedmann | ea1d4a0 | 2018-07-11 17:42:45 +0200 | [diff] [blame] | 1772 | |
Julian Wiedmann | eeac0e2 | 2019-08-23 11:48:49 +0200 | [diff] [blame] | 1773 | if (!rc) |
Julian Wiedmann | ea1d4a0 | 2018-07-11 17:42:45 +0200 | [diff] [blame] | 1774 | return NETDEV_TX_OK; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1775 | |
| 1776 | tx_drop: |
Julian Wiedmann | b0abc4f | 2019-02-15 19:22:29 +0100 | [diff] [blame] | 1777 | QETH_TXQ_STAT_INC(queue, tx_dropped); |
Julian Wiedmann | 104b485 | 2019-03-18 16:40:56 +0100 | [diff] [blame] | 1778 | kfree_skb(skb); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1779 | return NETDEV_TX_OK; |
| 1780 | } |
| 1781 | |
Julian Wiedmann | d0c7482 | 2019-03-28 16:39:19 +0100 | [diff] [blame] | 1782 | static void qeth_l3_set_rx_mode(struct net_device *dev) |
| 1783 | { |
| 1784 | struct qeth_card *card = dev->ml_priv; |
| 1785 | |
| 1786 | schedule_work(&card->rx_mode_work); |
| 1787 | } |
| 1788 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1789 | /* |
| 1790 | * we need NOARP for IPv4 but we want neighbor solicitation for IPv6. Setting |
| 1791 | * NOARP on the netdevice is no option because it also turns off neighbor |
| 1792 | * solicitation. For IPv4 we install a neighbor_setup function. We don't want |
| 1793 | * arp resolution but we want the hard header (packet socket will work |
| 1794 | * e.g. tcpdump) |
| 1795 | */ |
| 1796 | static int qeth_l3_neigh_setup_noarp(struct neighbour *n) |
| 1797 | { |
| 1798 | n->nud_state = NUD_NOARP; |
| 1799 | memcpy(n->ha, "FAKELL", 6); |
| 1800 | n->output = n->ops->connected_output; |
| 1801 | return 0; |
| 1802 | } |
| 1803 | |
| 1804 | static int |
| 1805 | qeth_l3_neigh_setup(struct net_device *dev, struct neigh_parms *np) |
| 1806 | { |
| 1807 | if (np->tbl->family == AF_INET) |
| 1808 | np->neigh_setup = qeth_l3_neigh_setup_noarp; |
| 1809 | |
| 1810 | return 0; |
| 1811 | } |
| 1812 | |
Julian Wiedmann | f13ade1 | 2018-09-17 17:35:56 +0200 | [diff] [blame] | 1813 | static netdev_features_t qeth_l3_osa_features_check(struct sk_buff *skb, |
| 1814 | struct net_device *dev, |
| 1815 | netdev_features_t features) |
| 1816 | { |
| 1817 | if (qeth_get_ip_version(skb) != 4) |
| 1818 | features &= ~NETIF_F_HW_VLAN_CTAG_TX; |
| 1819 | return qeth_features_check(skb, dev, features); |
| 1820 | } |
| 1821 | |
Julian Wiedmann | 3a18d75 | 2019-04-17 18:17:32 +0200 | [diff] [blame] | 1822 | static u16 qeth_l3_iqd_select_queue(struct net_device *dev, struct sk_buff *skb, |
| 1823 | struct net_device *sb_dev) |
| 1824 | { |
| 1825 | return qeth_iqd_select_queue(dev, skb, qeth_l3_get_cast_type(skb), |
| 1826 | sb_dev); |
| 1827 | } |
| 1828 | |
Julian Wiedmann | 73dc2da | 2019-04-17 18:17:33 +0200 | [diff] [blame] | 1829 | static u16 qeth_l3_osa_select_queue(struct net_device *dev, struct sk_buff *skb, |
| 1830 | struct net_device *sb_dev) |
| 1831 | { |
| 1832 | struct qeth_card *card = dev->ml_priv; |
| 1833 | |
Julian Wiedmann | 1c103cf | 2020-03-18 13:54:47 +0100 | [diff] [blame] | 1834 | return IS_VM_NIC(card) ? netdev_pick_tx(dev, skb, sb_dev) : |
| 1835 | qeth_get_priority_queue(card, skb); |
Julian Wiedmann | 73dc2da | 2019-04-17 18:17:33 +0200 | [diff] [blame] | 1836 | } |
| 1837 | |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 1838 | static const struct net_device_ops qeth_l3_netdev_ops = { |
Julian Wiedmann | e22355e | 2019-01-25 15:44:18 +0100 | [diff] [blame] | 1839 | .ndo_open = qeth_open, |
| 1840 | .ndo_stop = qeth_stop, |
Julian Wiedmann | b0abc4f | 2019-02-15 19:22:29 +0100 | [diff] [blame] | 1841 | .ndo_get_stats64 = qeth_get_stats64, |
Frank Blaschka | 8403b13 | 2009-01-08 10:50:55 -0800 | [diff] [blame] | 1842 | .ndo_start_xmit = qeth_l3_hard_start_xmit, |
Julian Wiedmann | 3a18d75 | 2019-04-17 18:17:32 +0200 | [diff] [blame] | 1843 | .ndo_select_queue = qeth_l3_iqd_select_queue, |
Frank Blaschka | 8403b13 | 2009-01-08 10:50:55 -0800 | [diff] [blame] | 1844 | .ndo_validate_addr = eth_validate_addr, |
Julian Wiedmann | 00c163f | 2017-12-20 20:11:02 +0100 | [diff] [blame] | 1845 | .ndo_set_rx_mode = qeth_l3_set_rx_mode, |
Julian Wiedmann | 942d698 | 2017-04-11 16:11:10 +0200 | [diff] [blame] | 1846 | .ndo_do_ioctl = qeth_do_ioctl, |
Thomas Richter | 8f43fb0 | 2016-06-16 16:18:59 +0200 | [diff] [blame] | 1847 | .ndo_fix_features = qeth_fix_features, |
| 1848 | .ndo_set_features = qeth_set_features, |
Frank Blaschka | 8403b13 | 2009-01-08 10:50:55 -0800 | [diff] [blame] | 1849 | .ndo_vlan_rx_add_vid = qeth_l3_vlan_rx_add_vid, |
| 1850 | .ndo_vlan_rx_kill_vid = qeth_l3_vlan_rx_kill_vid, |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1851 | .ndo_tx_timeout = qeth_tx_timeout, |
Frank Blaschka | 8403b13 | 2009-01-08 10:50:55 -0800 | [diff] [blame] | 1852 | }; |
| 1853 | |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 1854 | static const struct net_device_ops qeth_l3_osa_netdev_ops = { |
Julian Wiedmann | e22355e | 2019-01-25 15:44:18 +0100 | [diff] [blame] | 1855 | .ndo_open = qeth_open, |
| 1856 | .ndo_stop = qeth_stop, |
Julian Wiedmann | b0abc4f | 2019-02-15 19:22:29 +0100 | [diff] [blame] | 1857 | .ndo_get_stats64 = qeth_get_stats64, |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 1858 | .ndo_start_xmit = qeth_l3_hard_start_xmit, |
Julian Wiedmann | f13ade1 | 2018-09-17 17:35:56 +0200 | [diff] [blame] | 1859 | .ndo_features_check = qeth_l3_osa_features_check, |
Julian Wiedmann | 73dc2da | 2019-04-17 18:17:33 +0200 | [diff] [blame] | 1860 | .ndo_select_queue = qeth_l3_osa_select_queue, |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 1861 | .ndo_validate_addr = eth_validate_addr, |
Julian Wiedmann | 00c163f | 2017-12-20 20:11:02 +0100 | [diff] [blame] | 1862 | .ndo_set_rx_mode = qeth_l3_set_rx_mode, |
Julian Wiedmann | 942d698 | 2017-04-11 16:11:10 +0200 | [diff] [blame] | 1863 | .ndo_do_ioctl = qeth_do_ioctl, |
Thomas Richter | 8f43fb0 | 2016-06-16 16:18:59 +0200 | [diff] [blame] | 1864 | .ndo_fix_features = qeth_fix_features, |
| 1865 | .ndo_set_features = qeth_set_features, |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 1866 | .ndo_vlan_rx_add_vid = qeth_l3_vlan_rx_add_vid, |
| 1867 | .ndo_vlan_rx_kill_vid = qeth_l3_vlan_rx_kill_vid, |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1868 | .ndo_tx_timeout = qeth_tx_timeout, |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 1869 | .ndo_neigh_setup = qeth_l3_neigh_setup, |
| 1870 | }; |
| 1871 | |
Julian Wiedmann | cd652be | 2020-03-18 13:54:55 +0100 | [diff] [blame] | 1872 | static int qeth_l3_setup_netdev(struct qeth_card *card) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1873 | { |
Julian Wiedmann | 8ec1e24 | 2020-03-25 10:35:01 +0100 | [diff] [blame] | 1874 | struct net_device *dev = card->dev; |
Julian Wiedmann | 82bf5c0 | 2018-10-12 17:27:14 +0200 | [diff] [blame] | 1875 | unsigned int headroom; |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 1876 | int rc; |
| 1877 | |
Julian Wiedmann | 1c103cf | 2020-03-18 13:54:47 +0100 | [diff] [blame] | 1878 | rc = qeth_setup_netdev(card); |
| 1879 | if (rc) |
| 1880 | return rc; |
| 1881 | |
Julian Wiedmann | 379ac99 | 2019-04-25 18:25:57 +0200 | [diff] [blame] | 1882 | if (IS_OSD(card) || IS_OSX(card)) { |
Kittipon Meesompop | 1b81143 | 2018-04-26 09:42:16 +0200 | [diff] [blame] | 1883 | card->dev->netdev_ops = &qeth_l3_osa_netdev_ops; |
Julian Wiedmann | 0f34294 | 2018-03-09 18:12:54 +0100 | [diff] [blame] | 1884 | |
Kittipon Meesompop | 1b81143 | 2018-04-26 09:42:16 +0200 | [diff] [blame] | 1885 | /*IPv6 address autoconfiguration stuff*/ |
Julian Wiedmann | 8ec1e24 | 2020-03-25 10:35:01 +0100 | [diff] [blame] | 1886 | dev->dev_id = qeth_l3_get_unique_id(card, dev->dev_id); |
Julian Wiedmann | 0f34294 | 2018-03-09 18:12:54 +0100 | [diff] [blame] | 1887 | |
Julian Wiedmann | 379ac99 | 2019-04-25 18:25:57 +0200 | [diff] [blame] | 1888 | if (!IS_VM_NIC(card)) { |
Kittipon Meesompop | 1b81143 | 2018-04-26 09:42:16 +0200 | [diff] [blame] | 1889 | card->dev->features |= NETIF_F_SG; |
| 1890 | card->dev->hw_features |= NETIF_F_TSO | |
| 1891 | NETIF_F_RXCSUM | NETIF_F_IP_CSUM; |
| 1892 | card->dev->vlan_features |= NETIF_F_TSO | |
| 1893 | NETIF_F_RXCSUM | NETIF_F_IP_CSUM; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1894 | } |
Kittipon Meesompop | 571f9dd8 | 2018-04-26 09:42:22 +0200 | [diff] [blame] | 1895 | |
| 1896 | if (qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) { |
| 1897 | card->dev->hw_features |= NETIF_F_IPV6_CSUM; |
| 1898 | card->dev->vlan_features |= NETIF_F_IPV6_CSUM; |
| 1899 | } |
Julian Wiedmann | 82bf5c0 | 2018-10-12 17:27:14 +0200 | [diff] [blame] | 1900 | if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) { |
| 1901 | card->dev->hw_features |= NETIF_F_TSO6; |
| 1902 | card->dev->vlan_features |= NETIF_F_TSO6; |
| 1903 | } |
| 1904 | |
| 1905 | /* allow for de-acceleration of NETIF_F_HW_VLAN_CTAG_TX: */ |
| 1906 | if (card->dev->hw_features & NETIF_F_TSO6) |
| 1907 | headroom = sizeof(struct qeth_hdr_tso) + VLAN_HLEN; |
| 1908 | else if (card->dev->hw_features & NETIF_F_TSO) |
| 1909 | headroom = sizeof(struct qeth_hdr_tso); |
| 1910 | else |
| 1911 | headroom = sizeof(struct qeth_hdr) + VLAN_HLEN; |
Julian Wiedmann | 379ac99 | 2019-04-25 18:25:57 +0200 | [diff] [blame] | 1912 | } else if (IS_IQD(card)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1913 | card->dev->flags |= IFF_NOARP; |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 1914 | card->dev->netdev_ops = &qeth_l3_netdev_ops; |
Julian Wiedmann | 82bf5c0 | 2018-10-12 17:27:14 +0200 | [diff] [blame] | 1915 | headroom = sizeof(struct qeth_hdr) - ETH_HLEN; |
Julian Wiedmann | a647a02 | 2018-07-11 17:42:46 +0200 | [diff] [blame] | 1916 | |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 1917 | rc = qeth_l3_iqd_read_initial_mac(card); |
| 1918 | if (rc) |
Julian Wiedmann | cd652be | 2020-03-18 13:54:55 +0100 | [diff] [blame] | 1919 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1920 | } else |
| 1921 | return -ENODEV; |
| 1922 | |
Julian Wiedmann | 82bf5c0 | 2018-10-12 17:27:14 +0200 | [diff] [blame] | 1923 | card->dev->needed_headroom = headroom; |
Patrick McHardy | f646968 | 2013-04-19 02:04:27 +0000 | [diff] [blame] | 1924 | card->dev->features |= NETIF_F_HW_VLAN_CTAG_TX | |
| 1925 | NETIF_F_HW_VLAN_CTAG_RX | |
| 1926 | NETIF_F_HW_VLAN_CTAG_FILTER; |
Julian Wiedmann | a647a02 | 2018-07-11 17:42:46 +0200 | [diff] [blame] | 1927 | |
Eric Dumazet | 0287587 | 2014-10-05 18:38:35 -0700 | [diff] [blame] | 1928 | netif_keep_dst(card->dev); |
Julian Wiedmann | 82bf5c0 | 2018-10-12 17:27:14 +0200 | [diff] [blame] | 1929 | if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6)) |
Julian Wiedmann | 371a1e7 | 2018-07-11 17:42:44 +0200 | [diff] [blame] | 1930 | netif_set_gso_max_size(card->dev, |
| 1931 | PAGE_SIZE * (QETH_MAX_BUFFER_ELEMENTS(card) - 1)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1932 | |
Julian Wiedmann | d73ef32 | 2017-04-11 16:11:11 +0200 | [diff] [blame] | 1933 | netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT); |
Julian Wiedmann | cd652be | 2020-03-18 13:54:55 +0100 | [diff] [blame] | 1934 | return register_netdev(card->dev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1935 | } |
| 1936 | |
Ursula Braun | 79a04e4 | 2017-06-06 14:33:49 +0200 | [diff] [blame] | 1937 | static const struct device_type qeth_l3_devtype = { |
| 1938 | .name = "qeth_layer3", |
| 1939 | .groups = qeth_l3_attr_groups, |
| 1940 | }; |
| 1941 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1942 | static int qeth_l3_probe_device(struct ccwgroup_device *gdev) |
| 1943 | { |
| 1944 | struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
Ursula Braun | 9111e78 | 2017-05-10 19:07:51 +0200 | [diff] [blame] | 1945 | int rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1946 | |
Julian Wiedmann | 7221b72 | 2019-03-18 16:40:55 +0100 | [diff] [blame] | 1947 | hash_init(card->ip_htable); |
Julian Wiedmann | df2a2a5 | 2019-03-28 16:39:23 +0100 | [diff] [blame] | 1948 | mutex_init(&card->ip_lock); |
Julian Wiedmann | 7686e4b | 2019-03-28 16:39:22 +0100 | [diff] [blame] | 1949 | card->cmd_wq = alloc_ordered_workqueue("%s_cmd", 0, |
| 1950 | dev_name(&gdev->dev)); |
| 1951 | if (!card->cmd_wq) |
| 1952 | return -ENOMEM; |
Julian Wiedmann | 7221b72 | 2019-03-18 16:40:55 +0100 | [diff] [blame] | 1953 | |
Ursula Braun | 79a04e4 | 2017-06-06 14:33:49 +0200 | [diff] [blame] | 1954 | if (gdev->dev.type == &qeth_generic_devtype) { |
| 1955 | rc = qeth_l3_create_device_attributes(&gdev->dev); |
Julian Wiedmann | 7686e4b | 2019-03-28 16:39:22 +0100 | [diff] [blame] | 1956 | if (rc) { |
| 1957 | destroy_workqueue(card->cmd_wq); |
Ursula Braun | 79a04e4 | 2017-06-06 14:33:49 +0200 | [diff] [blame] | 1958 | return rc; |
Julian Wiedmann | 7686e4b | 2019-03-28 16:39:22 +0100 | [diff] [blame] | 1959 | } |
Ursula Braun | 79a04e4 | 2017-06-06 14:33:49 +0200 | [diff] [blame] | 1960 | } |
Julian Wiedmann | 7221b72 | 2019-03-18 16:40:55 +0100 | [diff] [blame] | 1961 | |
Julian Wiedmann | d0c7482 | 2019-03-28 16:39:19 +0100 | [diff] [blame] | 1962 | INIT_WORK(&card->rx_mode_work, qeth_l3_rx_mode_work); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1963 | return 0; |
| 1964 | } |
| 1965 | |
| 1966 | static void qeth_l3_remove_device(struct ccwgroup_device *cgdev) |
| 1967 | { |
| 1968 | struct qeth_card *card = dev_get_drvdata(&cgdev->dev); |
| 1969 | |
Ursula Braun | 79a04e4 | 2017-06-06 14:33:49 +0200 | [diff] [blame] | 1970 | if (cgdev->dev.type == &qeth_generic_devtype) |
| 1971 | qeth_l3_remove_device_attributes(&cgdev->dev); |
Ursula Braun | 9dc48cc | 2010-07-22 23:15:05 +0000 | [diff] [blame] | 1972 | |
Ursula Braun | f214856 | 2009-05-19 21:38:37 +0000 | [diff] [blame] | 1973 | qeth_set_allowed_threads(card, 0, 1); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1974 | wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); |
| 1975 | |
Ursula Braun | 70919e2 | 2011-02-26 22:41:36 -0800 | [diff] [blame] | 1976 | if (cgdev->state == CCWGROUP_ONLINE) |
Julian Wiedmann | 91003f3 | 2020-01-25 16:53:01 +0100 | [diff] [blame] | 1977 | qeth_set_offline(card, false); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1978 | |
Julian Wiedmann | c2780c1 | 2019-02-04 17:40:08 +0100 | [diff] [blame] | 1979 | cancel_work_sync(&card->close_dev_work); |
Julian Wiedmann | cd652be | 2020-03-18 13:54:55 +0100 | [diff] [blame] | 1980 | if (card->dev->reg_state == NETREG_REGISTERED) |
Julian Wiedmann | 30356d0 | 2018-11-02 19:04:10 +0100 | [diff] [blame] | 1981 | unregister_netdev(card->dev); |
Julian Wiedmann | 7686e4b | 2019-03-28 16:39:22 +0100 | [diff] [blame] | 1982 | |
| 1983 | flush_workqueue(card->cmd_wq); |
| 1984 | destroy_workqueue(card->cmd_wq); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1985 | qeth_l3_clear_ip_htable(card, 0); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1986 | qeth_l3_clear_ipato_list(card); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1987 | } |
| 1988 | |
Julian Wiedmann | b7ea041 | 2020-09-23 10:36:58 +0200 | [diff] [blame] | 1989 | static int qeth_l3_set_online(struct qeth_card *card, bool carrier_ok) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1990 | { |
Julian Wiedmann | fa3d2e6 | 2019-01-25 15:44:21 +0100 | [diff] [blame] | 1991 | struct net_device *dev = card->dev; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1992 | int rc = 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1993 | |
| 1994 | /* softsetup */ |
Julian Wiedmann | 57a688aa | 2019-06-11 18:37:55 +0200 | [diff] [blame] | 1995 | QETH_CARD_TEXT(card, 2, "softsetp"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1996 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1997 | rc = qeth_l3_setadapter_parms(card); |
| 1998 | if (rc) |
Julian Wiedmann | 57a688aa | 2019-06-11 18:37:55 +0200 | [diff] [blame] | 1999 | QETH_CARD_TEXT_(card, 2, "2err%04x", rc); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 2000 | if (!card->options.sniffer) { |
Julian Wiedmann | 17d9723 | 2020-01-25 16:53:03 +0100 | [diff] [blame] | 2001 | qeth_l3_start_ipassists(card); |
| 2002 | |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 2003 | rc = qeth_l3_setrouting_v4(card); |
| 2004 | if (rc) |
Julian Wiedmann | 57a688aa | 2019-06-11 18:37:55 +0200 | [diff] [blame] | 2005 | QETH_CARD_TEXT_(card, 2, "4err%04x", rc); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 2006 | rc = qeth_l3_setrouting_v6(card); |
| 2007 | if (rc) |
Julian Wiedmann | 57a688aa | 2019-06-11 18:37:55 +0200 | [diff] [blame] | 2008 | QETH_CARD_TEXT_(card, 2, "5err%04x", rc); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 2009 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2010 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2011 | card->state = CARD_STATE_SOFTSETUP; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2012 | |
| 2013 | qeth_set_allowed_threads(card, 0xffffffff, 0); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 2014 | qeth_l3_recover_ip(card); |
Julian Wiedmann | d025da9 | 2018-06-29 19:45:54 +0200 | [diff] [blame] | 2015 | |
Julian Wiedmann | cd652be | 2020-03-18 13:54:55 +0100 | [diff] [blame] | 2016 | if (dev->reg_state != NETREG_REGISTERED) { |
| 2017 | rc = qeth_l3_setup_netdev(card); |
Julian Wiedmann | fa3d2e6 | 2019-01-25 15:44:21 +0100 | [diff] [blame] | 2018 | if (rc) |
Julian Wiedmann | f2bcf9d | 2020-09-23 10:36:59 +0200 | [diff] [blame^] | 2019 | goto err_setup; |
Julian Wiedmann | cd652be | 2020-03-18 13:54:55 +0100 | [diff] [blame] | 2020 | |
| 2021 | if (carrier_ok) |
| 2022 | netif_carrier_on(dev); |
Julian Wiedmann | fa3d2e6 | 2019-01-25 15:44:21 +0100 | [diff] [blame] | 2023 | } else { |
Ursula Braun | 4763b0a | 2011-12-19 22:56:32 +0000 | [diff] [blame] | 2024 | rtnl_lock(); |
Julian Wiedmann | fa3d2e6 | 2019-01-25 15:44:21 +0100 | [diff] [blame] | 2025 | if (carrier_ok) |
| 2026 | netif_carrier_on(dev); |
| 2027 | else |
| 2028 | netif_carrier_off(dev); |
| 2029 | |
Julian Wiedmann | e6e771b | 2019-01-25 15:44:22 +0100 | [diff] [blame] | 2030 | netif_device_attach(dev); |
Julian Wiedmann | fa3d2e6 | 2019-01-25 15:44:21 +0100 | [diff] [blame] | 2031 | qeth_enable_hw_features(dev); |
| 2032 | |
Julian Wiedmann | d7d543f | 2019-02-28 18:59:36 +0100 | [diff] [blame] | 2033 | if (card->info.open_when_online) { |
| 2034 | card->info.open_when_online = 0; |
Julian Wiedmann | d456015 | 2019-02-28 18:59:39 +0100 | [diff] [blame] | 2035 | dev_open(dev, NULL); |
Julian Wiedmann | 9aa17df | 2018-07-11 17:42:40 +0200 | [diff] [blame] | 2036 | } |
Ursula Braun | 4763b0a | 2011-12-19 22:56:32 +0000 | [diff] [blame] | 2037 | rtnl_unlock(); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2038 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2039 | return 0; |
Julian Wiedmann | b7ea041 | 2020-09-23 10:36:58 +0200 | [diff] [blame] | 2040 | |
Julian Wiedmann | f2bcf9d | 2020-09-23 10:36:59 +0200 | [diff] [blame^] | 2041 | err_setup: |
| 2042 | qeth_set_allowed_threads(card, 0, 1); |
| 2043 | card->state = CARD_STATE_DOWN; |
| 2044 | qeth_l3_clear_ip_htable(card, 1); |
Ursula Braun | aa90922 | 2009-11-12 00:11:43 +0000 | [diff] [blame] | 2045 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2046 | } |
| 2047 | |
Julian Wiedmann | 91003f3 | 2020-01-25 16:53:01 +0100 | [diff] [blame] | 2048 | static void qeth_l3_set_offline(struct qeth_card *card) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2049 | { |
Julian Wiedmann | f2bcf9d | 2020-09-23 10:36:59 +0200 | [diff] [blame^] | 2050 | qeth_set_allowed_threads(card, 0, 1); |
| 2051 | qeth_l3_drain_rx_mode_cache(card); |
| 2052 | |
| 2053 | if (card->options.sniffer && |
| 2054 | (card->info.promisc_mode == SET_PROMISC_MODE_ON)) |
| 2055 | qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_DISABLE); |
| 2056 | |
| 2057 | if (card->state == CARD_STATE_SOFTSETUP) { |
| 2058 | card->state = CARD_STATE_DOWN; |
| 2059 | qeth_l3_clear_ip_htable(card, 1); |
| 2060 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2061 | } |
| 2062 | |
Eugene Crosser | c044dc2 | 2014-01-29 09:23:48 +0100 | [diff] [blame] | 2063 | /* Returns zero if the command is successfully "consumed" */ |
| 2064 | static int qeth_l3_control_event(struct qeth_card *card, |
| 2065 | struct qeth_ipa_cmd *cmd) |
| 2066 | { |
| 2067 | return 1; |
| 2068 | } |
| 2069 | |
Sebastian Ott | c041f2d487 | 2012-05-15 18:02:21 +0200 | [diff] [blame] | 2070 | struct qeth_discipline qeth_l3_discipline = { |
Ursula Braun | 79a04e4 | 2017-06-06 14:33:49 +0200 | [diff] [blame] | 2071 | .devtype = &qeth_l3_devtype, |
Sebastian Ott | c041f2d487 | 2012-05-15 18:02:21 +0200 | [diff] [blame] | 2072 | .setup = qeth_l3_probe_device, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2073 | .remove = qeth_l3_remove_device, |
| 2074 | .set_online = qeth_l3_set_online, |
| 2075 | .set_offline = qeth_l3_set_offline, |
Julian Wiedmann | 942d698 | 2017-04-11 16:11:10 +0200 | [diff] [blame] | 2076 | .do_ioctl = qeth_l3_do_ioctl, |
Eugene Crosser | c044dc2 | 2014-01-29 09:23:48 +0100 | [diff] [blame] | 2077 | .control_event_handler = qeth_l3_control_event, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2078 | }; |
Sebastian Ott | c041f2d487 | 2012-05-15 18:02:21 +0200 | [diff] [blame] | 2079 | EXPORT_SYMBOL_GPL(qeth_l3_discipline); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2080 | |
Julian Wiedmann | d66b1c0 | 2018-03-09 18:13:00 +0100 | [diff] [blame] | 2081 | static int qeth_l3_handle_ip_event(struct qeth_card *card, |
| 2082 | struct qeth_ipaddr *addr, |
| 2083 | unsigned long event) |
| 2084 | { |
| 2085 | switch (event) { |
| 2086 | case NETDEV_UP: |
Julian Wiedmann | 05a1785 | 2019-03-28 16:39:21 +0100 | [diff] [blame] | 2087 | qeth_l3_modify_ip(card, addr, true); |
Julian Wiedmann | d66b1c0 | 2018-03-09 18:13:00 +0100 | [diff] [blame] | 2088 | return NOTIFY_OK; |
| 2089 | case NETDEV_DOWN: |
Julian Wiedmann | 05a1785 | 2019-03-28 16:39:21 +0100 | [diff] [blame] | 2090 | qeth_l3_modify_ip(card, addr, false); |
Julian Wiedmann | d66b1c0 | 2018-03-09 18:13:00 +0100 | [diff] [blame] | 2091 | return NOTIFY_OK; |
| 2092 | default: |
| 2093 | return NOTIFY_DONE; |
| 2094 | } |
| 2095 | } |
| 2096 | |
Julian Wiedmann | 7686e4b | 2019-03-28 16:39:22 +0100 | [diff] [blame] | 2097 | struct qeth_l3_ip_event_work { |
| 2098 | struct work_struct work; |
| 2099 | struct qeth_card *card; |
| 2100 | struct qeth_ipaddr addr; |
| 2101 | }; |
| 2102 | |
| 2103 | #define to_ip_work(w) container_of((w), struct qeth_l3_ip_event_work, work) |
| 2104 | |
| 2105 | static void qeth_l3_add_ip_worker(struct work_struct *work) |
| 2106 | { |
| 2107 | struct qeth_l3_ip_event_work *ip_work = to_ip_work(work); |
| 2108 | |
| 2109 | qeth_l3_modify_ip(ip_work->card, &ip_work->addr, true); |
| 2110 | kfree(work); |
| 2111 | } |
| 2112 | |
| 2113 | static void qeth_l3_delete_ip_worker(struct work_struct *work) |
| 2114 | { |
| 2115 | struct qeth_l3_ip_event_work *ip_work = to_ip_work(work); |
| 2116 | |
| 2117 | qeth_l3_modify_ip(ip_work->card, &ip_work->addr, false); |
| 2118 | kfree(work); |
| 2119 | } |
| 2120 | |
Julian Wiedmann | b9caa98 | 2018-03-09 18:13:01 +0100 | [diff] [blame] | 2121 | static struct qeth_card *qeth_l3_get_card_from_dev(struct net_device *dev) |
| 2122 | { |
| 2123 | if (is_vlan_dev(dev)) |
| 2124 | dev = vlan_dev_real_dev(dev); |
| 2125 | if (dev->netdev_ops == &qeth_l3_osa_netdev_ops || |
| 2126 | dev->netdev_ops == &qeth_l3_netdev_ops) |
| 2127 | return (struct qeth_card *) dev->ml_priv; |
| 2128 | return NULL; |
| 2129 | } |
| 2130 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2131 | static int qeth_l3_ip_event(struct notifier_block *this, |
David S. Miller | 76fef2b | 2008-03-22 18:22:42 -0700 | [diff] [blame] | 2132 | unsigned long event, void *ptr) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2133 | { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 2134 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2135 | struct in_ifaddr *ifa = (struct in_ifaddr *)ptr; |
Julian Wiedmann | b9caa98 | 2018-03-09 18:13:01 +0100 | [diff] [blame] | 2136 | struct net_device *dev = ifa->ifa_dev->dev; |
Julian Wiedmann | d66b1c0 | 2018-03-09 18:13:00 +0100 | [diff] [blame] | 2137 | struct qeth_ipaddr addr; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2138 | struct qeth_card *card; |
| 2139 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2140 | card = qeth_l3_get_card_from_dev(dev); |
| 2141 | if (!card) |
| 2142 | return NOTIFY_DONE; |
frank.blaschka@de.ibm.com | 6d8823d | 2012-05-16 01:28:26 +0000 | [diff] [blame] | 2143 | QETH_CARD_TEXT(card, 3, "ipevent"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2144 | |
Julian Wiedmann | d66b1c0 | 2018-03-09 18:13:00 +0100 | [diff] [blame] | 2145 | qeth_l3_init_ipaddr(&addr, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV4); |
Julian Wiedmann | 1b40d4b | 2019-10-31 13:42:20 +0100 | [diff] [blame] | 2146 | addr.u.a4.addr = ifa->ifa_address; |
Julian Wiedmann | 490df97 | 2019-12-18 17:34:46 +0100 | [diff] [blame] | 2147 | addr.u.a4.mask = ifa->ifa_mask; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2148 | |
Julian Wiedmann | d66b1c0 | 2018-03-09 18:13:00 +0100 | [diff] [blame] | 2149 | return qeth_l3_handle_ip_event(card, &addr, event); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2150 | } |
| 2151 | |
| 2152 | static struct notifier_block qeth_l3_ip_notifier = { |
| 2153 | qeth_l3_ip_event, |
| 2154 | NULL, |
| 2155 | }; |
| 2156 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2157 | static int qeth_l3_ip6_event(struct notifier_block *this, |
David S. Miller | 76fef2b | 2008-03-22 18:22:42 -0700 | [diff] [blame] | 2158 | unsigned long event, void *ptr) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2159 | { |
| 2160 | struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr; |
Julian Wiedmann | b9caa98 | 2018-03-09 18:13:01 +0100 | [diff] [blame] | 2161 | struct net_device *dev = ifa->idev->dev; |
Julian Wiedmann | 7686e4b | 2019-03-28 16:39:22 +0100 | [diff] [blame] | 2162 | struct qeth_l3_ip_event_work *ip_work; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2163 | struct qeth_card *card; |
| 2164 | |
Julian Wiedmann | 7686e4b | 2019-03-28 16:39:22 +0100 | [diff] [blame] | 2165 | if (event != NETDEV_UP && event != NETDEV_DOWN) |
| 2166 | return NOTIFY_DONE; |
| 2167 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2168 | card = qeth_l3_get_card_from_dev(dev); |
| 2169 | if (!card) |
| 2170 | return NOTIFY_DONE; |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 2171 | QETH_CARD_TEXT(card, 3, "ip6event"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2172 | if (!qeth_is_supported(card, IPA_IPV6)) |
| 2173 | return NOTIFY_DONE; |
| 2174 | |
Julian Wiedmann | 7686e4b | 2019-03-28 16:39:22 +0100 | [diff] [blame] | 2175 | ip_work = kmalloc(sizeof(*ip_work), GFP_ATOMIC); |
| 2176 | if (!ip_work) |
| 2177 | return NOTIFY_DONE; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2178 | |
Julian Wiedmann | 7686e4b | 2019-03-28 16:39:22 +0100 | [diff] [blame] | 2179 | if (event == NETDEV_UP) |
| 2180 | INIT_WORK(&ip_work->work, qeth_l3_add_ip_worker); |
| 2181 | else |
| 2182 | INIT_WORK(&ip_work->work, qeth_l3_delete_ip_worker); |
| 2183 | |
| 2184 | ip_work->card = card; |
| 2185 | qeth_l3_init_ipaddr(&ip_work->addr, QETH_IP_TYPE_NORMAL, |
| 2186 | QETH_PROT_IPV6); |
| 2187 | ip_work->addr.u.a6.addr = ifa->addr; |
| 2188 | ip_work->addr.u.a6.pfxlen = ifa->prefix_len; |
| 2189 | |
| 2190 | queue_work(card->cmd_wq, &ip_work->work); |
| 2191 | return NOTIFY_OK; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2192 | } |
| 2193 | |
| 2194 | static struct notifier_block qeth_l3_ip6_notifier = { |
| 2195 | qeth_l3_ip6_event, |
| 2196 | NULL, |
| 2197 | }; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2198 | |
| 2199 | static int qeth_l3_register_notifiers(void) |
| 2200 | { |
| 2201 | int rc; |
| 2202 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 2203 | QETH_DBF_TEXT(SETUP, 5, "regnotif"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2204 | rc = register_inetaddr_notifier(&qeth_l3_ip_notifier); |
| 2205 | if (rc) |
| 2206 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2207 | rc = register_inet6addr_notifier(&qeth_l3_ip6_notifier); |
| 2208 | if (rc) { |
| 2209 | unregister_inetaddr_notifier(&qeth_l3_ip_notifier); |
| 2210 | return rc; |
| 2211 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2212 | return 0; |
| 2213 | } |
| 2214 | |
| 2215 | static void qeth_l3_unregister_notifiers(void) |
| 2216 | { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 2217 | QETH_DBF_TEXT(SETUP, 5, "unregnot"); |
Stefan Raspl | 18af5c1 | 2012-11-19 02:46:50 +0000 | [diff] [blame] | 2218 | WARN_ON(unregister_inetaddr_notifier(&qeth_l3_ip_notifier)); |
Stefan Raspl | 18af5c1 | 2012-11-19 02:46:50 +0000 | [diff] [blame] | 2219 | WARN_ON(unregister_inet6addr_notifier(&qeth_l3_ip6_notifier)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2220 | } |
| 2221 | |
| 2222 | static int __init qeth_l3_init(void) |
| 2223 | { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 2224 | pr_info("register layer 3 discipline\n"); |
Julian Wiedmann | c062204 | 2017-12-20 20:10:58 +0100 | [diff] [blame] | 2225 | return qeth_l3_register_notifiers(); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2226 | } |
| 2227 | |
| 2228 | static void __exit qeth_l3_exit(void) |
| 2229 | { |
| 2230 | qeth_l3_unregister_notifiers(); |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 2231 | pr_info("unregister layer 3 discipline\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2232 | } |
| 2233 | |
| 2234 | module_init(qeth_l3_init); |
| 2235 | module_exit(qeth_l3_exit); |
| 2236 | MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>"); |
| 2237 | MODULE_DESCRIPTION("qeth layer 3 discipline"); |
| 2238 | MODULE_LICENSE("GPL"); |