Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1 | /* |
Frank Blaschka | bbcfcdc | 2009-06-16 10:30:31 +0200 | [diff] [blame] | 2 | * Copyright IBM Corp. 2007, 2009 |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3 | * Author(s): Utz Bacher <utz.bacher@de.ibm.com>, |
| 4 | * Frank Pavlic <fpavlic@de.ibm.com>, |
| 5 | * Thomas Spatzier <tspat@de.ibm.com>, |
| 6 | * Frank Blaschka <frank.blaschka@de.ibm.com> |
| 7 | */ |
| 8 | |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 9 | #define KMSG_COMPONENT "qeth" |
| 10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 11 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 12 | #include <linux/module.h> |
| 13 | #include <linux/moduleparam.h> |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 14 | #include <linux/bitops.h> |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 15 | #include <linux/string.h> |
| 16 | #include <linux/errno.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/etherdevice.h> |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 19 | #include <linux/ip.h> |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 20 | #include <linux/ipv6.h> |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 21 | #include <linux/inetdevice.h> |
| 22 | #include <linux/igmp.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 23 | #include <linux/slab.h> |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 24 | #include <linux/if_vlan.h> |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 25 | |
| 26 | #include <net/ip.h> |
| 27 | #include <net/arp.h> |
David Miller | 87e7597 | 2012-02-01 10:49:17 +0000 | [diff] [blame] | 28 | #include <net/route.h> |
| 29 | #include <net/ip6_fib.h> |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 30 | #include <net/ip6_checksum.h> |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 31 | #include <net/iucv/af_iucv.h> |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 32 | #include <linux/hashtable.h> |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 33 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 34 | #include "qeth_l3.h" |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 35 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 36 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 37 | static int qeth_l3_set_offline(struct ccwgroup_device *); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 38 | static int qeth_l3_stop(struct net_device *); |
| 39 | static void qeth_l3_set_multicast_list(struct net_device *); |
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 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 45 | static int qeth_l3_isxdigit(char *buf) |
| 46 | { |
| 47 | while (*buf) { |
| 48 | if (!isxdigit(*buf++)) |
| 49 | return 0; |
| 50 | } |
| 51 | return 1; |
| 52 | } |
| 53 | |
Thomas Richter | 56530d6 | 2014-10-22 12:18:04 +0200 | [diff] [blame] | 54 | static void qeth_l3_ipaddr4_to_string(const __u8 *addr, char *buf) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 55 | { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 56 | sprintf(buf, "%pI4", addr); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 57 | } |
| 58 | |
Thomas Richter | 56530d6 | 2014-10-22 12:18:04 +0200 | [diff] [blame] | 59 | static int qeth_l3_string_to_ipaddr4(const char *buf, __u8 *addr) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 60 | { |
| 61 | int count = 0, rc = 0; |
Ursula Braun | a68be01 | 2014-05-28 10:22:31 +0200 | [diff] [blame] | 62 | unsigned int in[4]; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 63 | char c; |
| 64 | |
| 65 | rc = sscanf(buf, "%u.%u.%u.%u%c", |
| 66 | &in[0], &in[1], &in[2], &in[3], &c); |
| 67 | if (rc != 4 && (rc != 5 || c != '\n')) |
| 68 | return -EINVAL; |
| 69 | for (count = 0; count < 4; count++) { |
| 70 | if (in[count] > 255) |
| 71 | return -EINVAL; |
| 72 | addr[count] = in[count]; |
| 73 | } |
| 74 | return 0; |
| 75 | } |
| 76 | |
Thomas Richter | 56530d6 | 2014-10-22 12:18:04 +0200 | [diff] [blame] | 77 | static void qeth_l3_ipaddr6_to_string(const __u8 *addr, char *buf) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 78 | { |
Joe Perches | 963a9fd | 2010-09-07 21:14:40 +0000 | [diff] [blame] | 79 | sprintf(buf, "%pI6", addr); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 80 | } |
| 81 | |
Thomas Richter | 56530d6 | 2014-10-22 12:18:04 +0200 | [diff] [blame] | 82 | static int qeth_l3_string_to_ipaddr6(const char *buf, __u8 *addr) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 83 | { |
| 84 | const char *end, *end_tmp, *start; |
| 85 | __u16 *in; |
| 86 | char num[5]; |
| 87 | int num2, cnt, out, found, save_cnt; |
| 88 | unsigned short in_tmp[8] = {0, }; |
| 89 | |
| 90 | cnt = out = found = save_cnt = num2 = 0; |
| 91 | end = start = buf; |
| 92 | in = (__u16 *) addr; |
| 93 | memset(in, 0, 16); |
| 94 | while (*end) { |
| 95 | end = strchr(start, ':'); |
| 96 | if (end == NULL) { |
| 97 | end = buf + strlen(buf); |
| 98 | end_tmp = strchr(start, '\n'); |
| 99 | if (end_tmp != NULL) |
| 100 | end = end_tmp; |
| 101 | out = 1; |
| 102 | } |
| 103 | if ((end - start)) { |
| 104 | memset(num, 0, 5); |
| 105 | if ((end - start) > 4) |
| 106 | return -EINVAL; |
| 107 | memcpy(num, start, end - start); |
| 108 | if (!qeth_l3_isxdigit(num)) |
| 109 | return -EINVAL; |
| 110 | sscanf(start, "%x", &num2); |
| 111 | if (found) |
| 112 | in_tmp[save_cnt++] = num2; |
| 113 | else |
| 114 | in[cnt++] = num2; |
| 115 | if (out) |
| 116 | break; |
| 117 | } else { |
| 118 | if (found) |
| 119 | return -EINVAL; |
| 120 | found = 1; |
| 121 | } |
| 122 | start = ++end; |
| 123 | } |
| 124 | if (cnt + save_cnt > 8) |
| 125 | return -EINVAL; |
| 126 | cnt = 7; |
| 127 | while (save_cnt) |
| 128 | in[cnt--] = in_tmp[--save_cnt]; |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | void qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto, const __u8 *addr, |
| 133 | char *buf) |
| 134 | { |
| 135 | if (proto == QETH_PROT_IPV4) |
| 136 | qeth_l3_ipaddr4_to_string(addr, buf); |
| 137 | else if (proto == QETH_PROT_IPV6) |
| 138 | qeth_l3_ipaddr6_to_string(addr, buf); |
| 139 | } |
| 140 | |
| 141 | int qeth_l3_string_to_ipaddr(const char *buf, enum qeth_prot_versions proto, |
| 142 | __u8 *addr) |
| 143 | { |
| 144 | if (proto == QETH_PROT_IPV4) |
| 145 | return qeth_l3_string_to_ipaddr4(buf, addr); |
| 146 | else if (proto == QETH_PROT_IPV6) |
| 147 | return qeth_l3_string_to_ipaddr6(buf, addr); |
| 148 | else |
| 149 | return -EINVAL; |
| 150 | } |
| 151 | |
| 152 | static void qeth_l3_convert_addr_to_bits(u8 *addr, u8 *bits, int len) |
| 153 | { |
| 154 | int i, j; |
| 155 | u8 octet; |
| 156 | |
| 157 | for (i = 0; i < len; ++i) { |
| 158 | octet = addr[i]; |
| 159 | for (j = 7; j >= 0; --j) { |
| 160 | bits[i*8 + j] = octet & 1; |
| 161 | octet >>= 1; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
Klaus-Dieter Wacker | 6298263 | 2010-07-22 23:15:03 +0000 | [diff] [blame] | 166 | int qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 167 | struct qeth_ipaddr *addr) |
| 168 | { |
| 169 | struct qeth_ipato_entry *ipatoe; |
| 170 | u8 addr_bits[128] = {0, }; |
| 171 | u8 ipatoe_bits[128] = {0, }; |
| 172 | int rc = 0; |
| 173 | |
| 174 | if (!card->ipato.enabled) |
| 175 | return 0; |
| 176 | |
| 177 | qeth_l3_convert_addr_to_bits((u8 *) &addr->u, addr_bits, |
| 178 | (addr->proto == QETH_PROT_IPV4)? 4:16); |
| 179 | list_for_each_entry(ipatoe, &card->ipato.entries, entry) { |
| 180 | if (addr->proto != ipatoe->proto) |
| 181 | continue; |
| 182 | qeth_l3_convert_addr_to_bits(ipatoe->addr, ipatoe_bits, |
| 183 | (ipatoe->proto == QETH_PROT_IPV4) ? |
| 184 | 4 : 16); |
| 185 | if (addr->proto == QETH_PROT_IPV4) |
| 186 | rc = !memcmp(addr_bits, ipatoe_bits, |
| 187 | min(32, ipatoe->mask_bits)); |
| 188 | else |
| 189 | rc = !memcmp(addr_bits, ipatoe_bits, |
| 190 | min(128, ipatoe->mask_bits)); |
| 191 | if (rc) |
| 192 | break; |
| 193 | } |
| 194 | /* invert? */ |
| 195 | if ((addr->proto == QETH_PROT_IPV4) && card->ipato.invert4) |
| 196 | rc = !rc; |
| 197 | else if ((addr->proto == QETH_PROT_IPV6) && card->ipato.invert6) |
| 198 | rc = !rc; |
| 199 | |
| 200 | return rc; |
| 201 | } |
| 202 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 203 | inline int |
| 204 | qeth_l3_ipaddrs_is_equal(struct qeth_ipaddr *addr1, struct qeth_ipaddr *addr2) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 205 | { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 206 | return addr1->proto == addr2->proto && |
| 207 | !memcmp(&addr1->u, &addr2->u, sizeof(addr1->u)) && |
| 208 | !memcmp(&addr1->mac, &addr2->mac, sizeof(addr1->mac)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 209 | } |
| 210 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 211 | static struct qeth_ipaddr * |
| 212 | qeth_l3_ip_from_hash(struct qeth_card *card, struct qeth_ipaddr *tmp_addr) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 213 | { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 214 | struct qeth_ipaddr *addr; |
| 215 | |
| 216 | if (tmp_addr->is_multicast) { |
| 217 | hash_for_each_possible(card->ip_mc_htable, addr, |
| 218 | hnode, qeth_l3_ipaddr_hash(tmp_addr)) |
| 219 | if (qeth_l3_ipaddrs_is_equal(tmp_addr, addr)) |
| 220 | return addr; |
| 221 | } else { |
| 222 | hash_for_each_possible(card->ip_htable, addr, |
| 223 | hnode, qeth_l3_ipaddr_hash(tmp_addr)) |
| 224 | if (qeth_l3_ipaddrs_is_equal(tmp_addr, addr)) |
| 225 | return addr; |
| 226 | } |
| 227 | |
| 228 | return NULL; |
| 229 | } |
| 230 | |
| 231 | int qeth_l3_delete_ip(struct qeth_card *card, struct qeth_ipaddr *tmp_addr) |
| 232 | { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 233 | int rc = 0; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 234 | struct qeth_ipaddr *addr; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 235 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 236 | QETH_CARD_TEXT(card, 4, "delip"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 237 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 238 | if (tmp_addr->proto == QETH_PROT_IPV4) |
| 239 | QETH_CARD_HEX(card, 4, &tmp_addr->u.a4.addr, 4); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 240 | else { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 241 | QETH_CARD_HEX(card, 4, &tmp_addr->u.a6.addr, 8); |
| 242 | 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] | 243 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 244 | |
| 245 | addr = qeth_l3_ip_from_hash(card, tmp_addr); |
| 246 | if (!addr) |
| 247 | return -ENOENT; |
| 248 | |
| 249 | addr->ref_counter--; |
Kittipon Meesompop | cb81619 | 2017-08-15 17:02:50 +0200 | [diff] [blame] | 250 | if (addr->ref_counter > 0 && (addr->type == QETH_IP_TYPE_NORMAL || |
| 251 | addr->type == QETH_IP_TYPE_RXIP)) |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 252 | return rc; |
| 253 | if (addr->in_progress) |
| 254 | return -EINPROGRESS; |
| 255 | |
Ursula Braun | a7531c1 | 2016-09-15 14:39:23 +0200 | [diff] [blame] | 256 | if (!qeth_card_hw_is_reachable(card)) { |
| 257 | addr->disp_flag = QETH_DISP_ADDR_DELETE; |
| 258 | return 0; |
| 259 | } |
| 260 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 261 | rc = qeth_l3_deregister_addr_entry(card, addr); |
| 262 | |
| 263 | hash_del(&addr->hnode); |
| 264 | kfree(addr); |
| 265 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 266 | return rc; |
| 267 | } |
| 268 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 269 | 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] | 270 | { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 271 | int rc = 0; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 272 | struct qeth_ipaddr *addr; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 273 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 274 | QETH_CARD_TEXT(card, 4, "addip"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 275 | |
| 276 | if (tmp_addr->proto == QETH_PROT_IPV4) |
| 277 | QETH_CARD_HEX(card, 4, &tmp_addr->u.a4.addr, 4); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 278 | else { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 279 | QETH_CARD_HEX(card, 4, &tmp_addr->u.a6.addr, 8); |
| 280 | 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] | 281 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 282 | |
| 283 | addr = qeth_l3_ip_from_hash(card, tmp_addr); |
| 284 | if (!addr) { |
| 285 | addr = qeth_l3_get_addr_buffer(tmp_addr->proto); |
| 286 | if (!addr) |
| 287 | return -ENOMEM; |
| 288 | |
| 289 | memcpy(addr, tmp_addr, sizeof(struct qeth_ipaddr)); |
| 290 | addr->ref_counter = 1; |
| 291 | |
| 292 | if (addr->type == QETH_IP_TYPE_NORMAL && |
| 293 | qeth_l3_is_addr_covered_by_ipato(card, addr)) { |
| 294 | QETH_CARD_TEXT(card, 2, "tkovaddr"); |
| 295 | addr->set_flags |= QETH_IPA_SETIP_TAKEOVER_FLAG; |
| 296 | } |
| 297 | hash_add(card->ip_htable, &addr->hnode, |
| 298 | qeth_l3_ipaddr_hash(addr)); |
| 299 | |
Ursula Braun | a7531c1 | 2016-09-15 14:39:23 +0200 | [diff] [blame] | 300 | if (!qeth_card_hw_is_reachable(card)) { |
| 301 | addr->disp_flag = QETH_DISP_ADDR_ADD; |
| 302 | return 0; |
| 303 | } |
| 304 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 305 | /* qeth_l3_register_addr_entry can go to sleep |
| 306 | * if we add a IPV4 addr. It is caused by the reason |
| 307 | * that SETIP ipa cmd starts ARP staff for IPV4 addr. |
| 308 | * Thus we should unlock spinlock, and make a protection |
| 309 | * using in_progress variable to indicate that there is |
| 310 | * an hardware operation with this IPV4 address |
| 311 | */ |
| 312 | if (addr->proto == QETH_PROT_IPV4) { |
| 313 | addr->in_progress = 1; |
| 314 | spin_unlock_bh(&card->ip_lock); |
| 315 | rc = qeth_l3_register_addr_entry(card, addr); |
| 316 | spin_lock_bh(&card->ip_lock); |
| 317 | addr->in_progress = 0; |
| 318 | } else |
| 319 | rc = qeth_l3_register_addr_entry(card, addr); |
| 320 | |
| 321 | if (!rc || (rc == IPA_RC_DUPLICATE_IP_ADDRESS) || |
| 322 | (rc == IPA_RC_LAN_OFFLINE)) { |
| 323 | addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
| 324 | if (addr->ref_counter < 1) { |
| 325 | qeth_l3_delete_ip(card, addr); |
| 326 | kfree(addr); |
| 327 | } |
| 328 | } else { |
| 329 | hash_del(&addr->hnode); |
| 330 | kfree(addr); |
| 331 | } |
| 332 | } else { |
Kittipon Meesompop | cb81619 | 2017-08-15 17:02:50 +0200 | [diff] [blame] | 333 | if (addr->type == QETH_IP_TYPE_NORMAL || |
| 334 | addr->type == QETH_IP_TYPE_RXIP) |
| 335 | addr->ref_counter++; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 336 | } |
| 337 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 338 | return rc; |
| 339 | } |
| 340 | |
| 341 | |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 342 | struct qeth_ipaddr *qeth_l3_get_addr_buffer( |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 343 | enum qeth_prot_versions prot) |
| 344 | { |
| 345 | struct qeth_ipaddr *addr; |
| 346 | |
| 347 | addr = kzalloc(sizeof(struct qeth_ipaddr), GFP_ATOMIC); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 348 | if (!addr) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 349 | return NULL; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 350 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 351 | addr->type = QETH_IP_TYPE_NORMAL; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 352 | addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 353 | addr->proto = prot; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 354 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 355 | return addr; |
| 356 | } |
| 357 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 358 | 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] | 359 | { |
| 360 | struct qeth_ipaddr *addr; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 361 | struct hlist_node *tmp; |
| 362 | int i; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 363 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 364 | QETH_CARD_TEXT(card, 4, "clearip"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 365 | |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 366 | if (recover && card->options.sniffer) |
| 367 | return; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 368 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 369 | spin_lock_bh(&card->ip_lock); |
| 370 | |
| 371 | hash_for_each_safe(card->ip_htable, i, tmp, addr, hnode) { |
| 372 | if (!recover) { |
| 373 | hash_del(&addr->hnode); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 374 | kfree(addr); |
| 375 | continue; |
| 376 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 377 | addr->disp_flag = QETH_DISP_ADDR_ADD; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 378 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 379 | |
| 380 | spin_unlock_bh(&card->ip_lock); |
| 381 | |
| 382 | spin_lock_bh(&card->mclock); |
| 383 | |
| 384 | hash_for_each_safe(card->ip_mc_htable, i, tmp, addr, hnode) { |
| 385 | hash_del(&addr->hnode); |
| 386 | kfree(addr); |
| 387 | } |
| 388 | |
| 389 | spin_unlock_bh(&card->mclock); |
| 390 | |
| 391 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 392 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 393 | static void qeth_l3_recover_ip(struct qeth_card *card) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 394 | { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 395 | struct qeth_ipaddr *addr; |
| 396 | struct hlist_node *tmp; |
| 397 | int i; |
| 398 | int rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 399 | |
Ursula Braun | a7531c1 | 2016-09-15 14:39:23 +0200 | [diff] [blame] | 400 | QETH_CARD_TEXT(card, 4, "recovrip"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 401 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 402 | spin_lock_bh(&card->ip_lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 403 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 404 | hash_for_each_safe(card->ip_htable, i, tmp, addr, hnode) { |
Ursula Braun | a7531c1 | 2016-09-15 14:39:23 +0200 | [diff] [blame] | 405 | if (addr->disp_flag == QETH_DISP_ADDR_DELETE) { |
| 406 | qeth_l3_deregister_addr_entry(card, addr); |
| 407 | hash_del(&addr->hnode); |
| 408 | kfree(addr); |
| 409 | } else if (addr->disp_flag == QETH_DISP_ADDR_ADD) { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 410 | if (addr->proto == QETH_PROT_IPV4) { |
| 411 | addr->in_progress = 1; |
| 412 | spin_unlock_bh(&card->ip_lock); |
| 413 | rc = qeth_l3_register_addr_entry(card, addr); |
| 414 | spin_lock_bh(&card->ip_lock); |
| 415 | addr->in_progress = 0; |
| 416 | } else |
| 417 | rc = qeth_l3_register_addr_entry(card, addr); |
| 418 | |
| 419 | if (!rc) { |
| 420 | addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
Ursula Braun | a7531c1 | 2016-09-15 14:39:23 +0200 | [diff] [blame] | 421 | if (addr->ref_counter < 1) |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 422 | qeth_l3_delete_ip(card, addr); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 423 | } else { |
| 424 | hash_del(&addr->hnode); |
| 425 | kfree(addr); |
| 426 | } |
| 427 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 428 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 429 | |
| 430 | spin_unlock_bh(&card->ip_lock); |
| 431 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | static int qeth_l3_send_setdelmc(struct qeth_card *card, |
| 435 | struct qeth_ipaddr *addr, int ipacmd) |
| 436 | { |
| 437 | int rc; |
| 438 | struct qeth_cmd_buffer *iob; |
| 439 | struct qeth_ipa_cmd *cmd; |
| 440 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 441 | QETH_CARD_TEXT(card, 4, "setdelmc"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 442 | |
| 443 | iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 444 | if (!iob) |
| 445 | return -ENOMEM; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 446 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); |
| 447 | memcpy(&cmd->data.setdelipm.mac, addr->mac, OSA_ADDR_LEN); |
| 448 | if (addr->proto == QETH_PROT_IPV6) |
| 449 | memcpy(cmd->data.setdelipm.ip6, &addr->u.a6.addr, |
| 450 | sizeof(struct in6_addr)); |
| 451 | else |
| 452 | memcpy(&cmd->data.setdelipm.ip4, &addr->u.a4.addr, 4); |
| 453 | |
| 454 | rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); |
| 455 | |
| 456 | return rc; |
| 457 | } |
| 458 | |
| 459 | static void qeth_l3_fill_netmask(u8 *netmask, unsigned int len) |
| 460 | { |
| 461 | int i, j; |
| 462 | for (i = 0; i < 16; i++) { |
| 463 | j = (len) - (i * 8); |
| 464 | if (j >= 8) |
| 465 | netmask[i] = 0xff; |
| 466 | else if (j > 0) |
| 467 | netmask[i] = (u8)(0xFF00 >> j); |
| 468 | else |
| 469 | netmask[i] = 0; |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | static int qeth_l3_send_setdelip(struct qeth_card *card, |
| 474 | struct qeth_ipaddr *addr, int ipacmd, unsigned int flags) |
| 475 | { |
| 476 | int rc; |
| 477 | struct qeth_cmd_buffer *iob; |
| 478 | struct qeth_ipa_cmd *cmd; |
| 479 | __u8 netmask[16]; |
| 480 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 481 | QETH_CARD_TEXT(card, 4, "setdelip"); |
| 482 | QETH_CARD_TEXT_(card, 4, "flags%02X", flags); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 483 | |
| 484 | iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 485 | if (!iob) |
| 486 | return -ENOMEM; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 487 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); |
| 488 | if (addr->proto == QETH_PROT_IPV6) { |
| 489 | memcpy(cmd->data.setdelip6.ip_addr, &addr->u.a6.addr, |
| 490 | sizeof(struct in6_addr)); |
| 491 | qeth_l3_fill_netmask(netmask, addr->u.a6.pfxlen); |
| 492 | memcpy(cmd->data.setdelip6.mask, netmask, |
| 493 | sizeof(struct in6_addr)); |
| 494 | cmd->data.setdelip6.flags = flags; |
| 495 | } else { |
| 496 | memcpy(cmd->data.setdelip4.ip_addr, &addr->u.a4.addr, 4); |
| 497 | memcpy(cmd->data.setdelip4.mask, &addr->u.a4.mask, 4); |
| 498 | cmd->data.setdelip4.flags = flags; |
| 499 | } |
| 500 | |
| 501 | rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); |
| 502 | |
| 503 | return rc; |
| 504 | } |
| 505 | |
| 506 | static int qeth_l3_send_setrouting(struct qeth_card *card, |
| 507 | enum qeth_routing_types type, enum qeth_prot_versions prot) |
| 508 | { |
| 509 | int rc; |
| 510 | struct qeth_ipa_cmd *cmd; |
| 511 | struct qeth_cmd_buffer *iob; |
| 512 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 513 | QETH_CARD_TEXT(card, 4, "setroutg"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 514 | iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETRTG, prot); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 515 | if (!iob) |
| 516 | return -ENOMEM; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 517 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); |
| 518 | cmd->data.setrtg.type = (type); |
| 519 | rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); |
| 520 | |
| 521 | return rc; |
| 522 | } |
| 523 | |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 524 | static int qeth_l3_correct_routing_type(struct qeth_card *card, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 525 | enum qeth_routing_types *type, enum qeth_prot_versions prot) |
| 526 | { |
| 527 | if (card->info.type == QETH_CARD_TYPE_IQD) { |
| 528 | switch (*type) { |
| 529 | case NO_ROUTER: |
| 530 | case PRIMARY_CONNECTOR: |
| 531 | case SECONDARY_CONNECTOR: |
| 532 | case MULTICAST_ROUTER: |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 533 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 534 | default: |
| 535 | goto out_inval; |
| 536 | } |
| 537 | } else { |
| 538 | switch (*type) { |
| 539 | case NO_ROUTER: |
| 540 | case PRIMARY_ROUTER: |
| 541 | case SECONDARY_ROUTER: |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 542 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 543 | case MULTICAST_ROUTER: |
| 544 | if (qeth_is_ipafunc_supported(card, prot, |
| 545 | IPA_OSA_MC_ROUTER)) |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 546 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 547 | default: |
| 548 | goto out_inval; |
| 549 | } |
| 550 | } |
| 551 | out_inval: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 552 | *type = NO_ROUTER; |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 553 | return -EINVAL; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | int qeth_l3_setrouting_v4(struct qeth_card *card) |
| 557 | { |
| 558 | int rc; |
| 559 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 560 | QETH_CARD_TEXT(card, 3, "setrtg4"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 561 | |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 562 | rc = qeth_l3_correct_routing_type(card, &card->options.route4.type, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 563 | QETH_PROT_IPV4); |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 564 | if (rc) |
| 565 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 566 | |
| 567 | rc = qeth_l3_send_setrouting(card, card->options.route4.type, |
| 568 | QETH_PROT_IPV4); |
| 569 | if (rc) { |
| 570 | card->options.route4.type = NO_ROUTER; |
Frank Blaschka | 14cc21b | 2008-06-06 12:37:46 +0200 | [diff] [blame] | 571 | QETH_DBF_MESSAGE(2, "Error (0x%04x) while setting routing type" |
| 572 | " on %s. Type set to 'no router'.\n", rc, |
| 573 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 574 | } |
| 575 | return rc; |
| 576 | } |
| 577 | |
| 578 | int qeth_l3_setrouting_v6(struct qeth_card *card) |
| 579 | { |
| 580 | int rc = 0; |
| 581 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 582 | QETH_CARD_TEXT(card, 3, "setrtg6"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 583 | #ifdef CONFIG_QETH_IPV6 |
| 584 | |
| 585 | if (!qeth_is_supported(card, IPA_IPV6)) |
| 586 | return 0; |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 587 | rc = qeth_l3_correct_routing_type(card, &card->options.route6.type, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 588 | QETH_PROT_IPV6); |
Stefan Raspl | 82e2e78 | 2013-03-18 20:04:43 +0000 | [diff] [blame] | 589 | if (rc) |
| 590 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 591 | |
| 592 | rc = qeth_l3_send_setrouting(card, card->options.route6.type, |
| 593 | QETH_PROT_IPV6); |
| 594 | if (rc) { |
| 595 | card->options.route6.type = NO_ROUTER; |
Frank Blaschka | 14cc21b | 2008-06-06 12:37:46 +0200 | [diff] [blame] | 596 | QETH_DBF_MESSAGE(2, "Error (0x%04x) while setting routing type" |
| 597 | " on %s. Type set to 'no router'.\n", rc, |
| 598 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 599 | } |
| 600 | #endif |
| 601 | return rc; |
| 602 | } |
| 603 | |
| 604 | /* |
| 605 | * IP address takeover related functions |
| 606 | */ |
| 607 | static void qeth_l3_clear_ipato_list(struct qeth_card *card) |
| 608 | { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 609 | struct qeth_ipato_entry *ipatoe, *tmp; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 610 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 611 | spin_lock_bh(&card->ip_lock); |
| 612 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 613 | list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) { |
| 614 | list_del(&ipatoe->entry); |
| 615 | kfree(ipatoe); |
| 616 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 617 | |
| 618 | spin_unlock_bh(&card->ip_lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | int qeth_l3_add_ipato_entry(struct qeth_card *card, |
| 622 | struct qeth_ipato_entry *new) |
| 623 | { |
| 624 | struct qeth_ipato_entry *ipatoe; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 625 | int rc = 0; |
| 626 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 627 | QETH_CARD_TEXT(card, 2, "addipato"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 628 | |
| 629 | spin_lock_bh(&card->ip_lock); |
| 630 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 631 | list_for_each_entry(ipatoe, &card->ipato.entries, entry) { |
| 632 | if (ipatoe->proto != new->proto) |
| 633 | continue; |
| 634 | if (!memcmp(ipatoe->addr, new->addr, |
| 635 | (ipatoe->proto == QETH_PROT_IPV4)? 4:16) && |
| 636 | (ipatoe->mask_bits == new->mask_bits)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 637 | rc = -EEXIST; |
| 638 | break; |
| 639 | } |
| 640 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 641 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 642 | if (!rc) |
| 643 | list_add_tail(&new->entry, &card->ipato.entries); |
| 644 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 645 | spin_unlock_bh(&card->ip_lock); |
| 646 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 647 | return rc; |
| 648 | } |
| 649 | |
| 650 | void qeth_l3_del_ipato_entry(struct qeth_card *card, |
| 651 | enum qeth_prot_versions proto, u8 *addr, int mask_bits) |
| 652 | { |
| 653 | struct qeth_ipato_entry *ipatoe, *tmp; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 654 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 655 | QETH_CARD_TEXT(card, 2, "delipato"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 656 | |
| 657 | spin_lock_bh(&card->ip_lock); |
| 658 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 659 | list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) { |
| 660 | if (ipatoe->proto != proto) |
| 661 | continue; |
| 662 | if (!memcmp(ipatoe->addr, addr, |
| 663 | (proto == QETH_PROT_IPV4)? 4:16) && |
| 664 | (ipatoe->mask_bits == mask_bits)) { |
| 665 | list_del(&ipatoe->entry); |
| 666 | kfree(ipatoe); |
| 667 | } |
| 668 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 669 | |
| 670 | spin_unlock_bh(&card->ip_lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | /* |
| 674 | * VIPA related functions |
| 675 | */ |
| 676 | int qeth_l3_add_vipa(struct qeth_card *card, enum qeth_prot_versions proto, |
| 677 | const u8 *addr) |
| 678 | { |
| 679 | struct qeth_ipaddr *ipaddr; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 680 | int rc = 0; |
| 681 | |
| 682 | ipaddr = qeth_l3_get_addr_buffer(proto); |
| 683 | if (ipaddr) { |
| 684 | if (proto == QETH_PROT_IPV4) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 685 | QETH_CARD_TEXT(card, 2, "addvipa4"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 686 | memcpy(&ipaddr->u.a4.addr, addr, 4); |
| 687 | ipaddr->u.a4.mask = 0; |
| 688 | } else if (proto == QETH_PROT_IPV6) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 689 | QETH_CARD_TEXT(card, 2, "addvipa6"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 690 | memcpy(&ipaddr->u.a6.addr, addr, 16); |
| 691 | ipaddr->u.a6.pfxlen = 0; |
| 692 | } |
| 693 | ipaddr->type = QETH_IP_TYPE_VIPA; |
| 694 | ipaddr->set_flags = QETH_IPA_SETIP_VIPA_FLAG; |
| 695 | ipaddr->del_flags = QETH_IPA_DELIP_VIPA_FLAG; |
| 696 | } else |
| 697 | return -ENOMEM; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 698 | |
| 699 | spin_lock_bh(&card->ip_lock); |
| 700 | |
Thomas Richter | 732a59c | 2016-09-15 14:39:27 +0200 | [diff] [blame] | 701 | if (qeth_l3_ip_from_hash(card, ipaddr)) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 702 | rc = -EEXIST; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 703 | else |
| 704 | qeth_l3_add_ip(card, ipaddr); |
| 705 | |
| 706 | spin_unlock_bh(&card->ip_lock); |
| 707 | |
| 708 | kfree(ipaddr); |
| 709 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 710 | return rc; |
| 711 | } |
| 712 | |
| 713 | void qeth_l3_del_vipa(struct qeth_card *card, enum qeth_prot_versions proto, |
| 714 | const u8 *addr) |
| 715 | { |
| 716 | struct qeth_ipaddr *ipaddr; |
| 717 | |
| 718 | ipaddr = qeth_l3_get_addr_buffer(proto); |
| 719 | if (ipaddr) { |
| 720 | if (proto == QETH_PROT_IPV4) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 721 | QETH_CARD_TEXT(card, 2, "delvipa4"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 722 | memcpy(&ipaddr->u.a4.addr, addr, 4); |
| 723 | ipaddr->u.a4.mask = 0; |
| 724 | } else if (proto == QETH_PROT_IPV6) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 725 | QETH_CARD_TEXT(card, 2, "delvipa6"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 726 | memcpy(&ipaddr->u.a6.addr, addr, 16); |
| 727 | ipaddr->u.a6.pfxlen = 0; |
| 728 | } |
| 729 | ipaddr->type = QETH_IP_TYPE_VIPA; |
| 730 | } else |
| 731 | return; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 732 | |
| 733 | spin_lock_bh(&card->ip_lock); |
| 734 | qeth_l3_delete_ip(card, ipaddr); |
| 735 | spin_unlock_bh(&card->ip_lock); |
| 736 | |
| 737 | kfree(ipaddr); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | /* |
| 741 | * proxy ARP related functions |
| 742 | */ |
| 743 | int qeth_l3_add_rxip(struct qeth_card *card, enum qeth_prot_versions proto, |
| 744 | const u8 *addr) |
| 745 | { |
| 746 | struct qeth_ipaddr *ipaddr; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 747 | int rc = 0; |
| 748 | |
| 749 | ipaddr = qeth_l3_get_addr_buffer(proto); |
| 750 | if (ipaddr) { |
| 751 | if (proto == QETH_PROT_IPV4) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 752 | QETH_CARD_TEXT(card, 2, "addrxip4"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 753 | memcpy(&ipaddr->u.a4.addr, addr, 4); |
| 754 | ipaddr->u.a4.mask = 0; |
| 755 | } else if (proto == QETH_PROT_IPV6) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 756 | QETH_CARD_TEXT(card, 2, "addrxip6"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 757 | memcpy(&ipaddr->u.a6.addr, addr, 16); |
| 758 | ipaddr->u.a6.pfxlen = 0; |
| 759 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 760 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 761 | ipaddr->type = QETH_IP_TYPE_RXIP; |
| 762 | ipaddr->set_flags = QETH_IPA_SETIP_TAKEOVER_FLAG; |
| 763 | ipaddr->del_flags = 0; |
| 764 | } else |
| 765 | return -ENOMEM; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 766 | |
| 767 | spin_lock_bh(&card->ip_lock); |
| 768 | |
Thomas Richter | 732a59c | 2016-09-15 14:39:27 +0200 | [diff] [blame] | 769 | if (qeth_l3_ip_from_hash(card, ipaddr)) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 770 | rc = -EEXIST; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 771 | else |
| 772 | qeth_l3_add_ip(card, ipaddr); |
| 773 | |
| 774 | spin_unlock_bh(&card->ip_lock); |
| 775 | |
| 776 | kfree(ipaddr); |
| 777 | |
| 778 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 779 | } |
| 780 | |
| 781 | void qeth_l3_del_rxip(struct qeth_card *card, enum qeth_prot_versions proto, |
| 782 | const u8 *addr) |
| 783 | { |
| 784 | struct qeth_ipaddr *ipaddr; |
| 785 | |
| 786 | ipaddr = qeth_l3_get_addr_buffer(proto); |
| 787 | if (ipaddr) { |
| 788 | if (proto == QETH_PROT_IPV4) { |
Kittipon Meesompop | ea4ae35 | 2017-08-15 17:02:49 +0200 | [diff] [blame] | 789 | QETH_CARD_TEXT(card, 2, "delrxip4"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 790 | memcpy(&ipaddr->u.a4.addr, addr, 4); |
| 791 | ipaddr->u.a4.mask = 0; |
| 792 | } else if (proto == QETH_PROT_IPV6) { |
Kittipon Meesompop | ea4ae35 | 2017-08-15 17:02:49 +0200 | [diff] [blame] | 793 | QETH_CARD_TEXT(card, 2, "delrxip6"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 794 | memcpy(&ipaddr->u.a6.addr, addr, 16); |
| 795 | ipaddr->u.a6.pfxlen = 0; |
| 796 | } |
| 797 | ipaddr->type = QETH_IP_TYPE_RXIP; |
| 798 | } else |
| 799 | return; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 800 | |
| 801 | spin_lock_bh(&card->ip_lock); |
| 802 | qeth_l3_delete_ip(card, ipaddr); |
| 803 | spin_unlock_bh(&card->ip_lock); |
| 804 | |
| 805 | kfree(ipaddr); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 806 | } |
| 807 | |
| 808 | static int qeth_l3_register_addr_entry(struct qeth_card *card, |
| 809 | struct qeth_ipaddr *addr) |
| 810 | { |
| 811 | char buf[50]; |
| 812 | int rc = 0; |
| 813 | int cnt = 3; |
| 814 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 815 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 816 | if (addr->proto == QETH_PROT_IPV4) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 817 | QETH_CARD_TEXT(card, 2, "setaddr4"); |
| 818 | QETH_CARD_HEX(card, 3, &addr->u.a4.addr, sizeof(int)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 819 | } else if (addr->proto == QETH_PROT_IPV6) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 820 | QETH_CARD_TEXT(card, 2, "setaddr6"); |
| 821 | QETH_CARD_HEX(card, 3, &addr->u.a6.addr, 8); |
| 822 | QETH_CARD_HEX(card, 3, ((char *)&addr->u.a6.addr) + 8, 8); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 823 | } else { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 824 | QETH_CARD_TEXT(card, 2, "setaddr?"); |
| 825 | QETH_CARD_HEX(card, 3, addr, sizeof(struct qeth_ipaddr)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 826 | } |
| 827 | do { |
| 828 | if (addr->is_multicast) |
| 829 | rc = qeth_l3_send_setdelmc(card, addr, IPA_CMD_SETIPM); |
| 830 | else |
| 831 | rc = qeth_l3_send_setdelip(card, addr, IPA_CMD_SETIP, |
| 832 | addr->set_flags); |
| 833 | if (rc) |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 834 | QETH_CARD_TEXT(card, 2, "failed"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 835 | } while ((--cnt > 0) && rc); |
| 836 | if (rc) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 837 | QETH_CARD_TEXT(card, 2, "FAILED"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 838 | qeth_l3_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf); |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 839 | dev_warn(&card->gdev->dev, |
| 840 | "Registering IP address %s failed\n", buf); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 841 | } |
| 842 | return rc; |
| 843 | } |
| 844 | |
| 845 | static int qeth_l3_deregister_addr_entry(struct qeth_card *card, |
| 846 | struct qeth_ipaddr *addr) |
| 847 | { |
| 848 | int rc = 0; |
| 849 | |
| 850 | if (addr->proto == QETH_PROT_IPV4) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 851 | QETH_CARD_TEXT(card, 2, "deladdr4"); |
| 852 | QETH_CARD_HEX(card, 3, &addr->u.a4.addr, sizeof(int)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 853 | } else if (addr->proto == QETH_PROT_IPV6) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 854 | QETH_CARD_TEXT(card, 2, "deladdr6"); |
| 855 | QETH_CARD_HEX(card, 3, &addr->u.a6.addr, 8); |
| 856 | QETH_CARD_HEX(card, 3, ((char *)&addr->u.a6.addr) + 8, 8); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 857 | } else { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 858 | QETH_CARD_TEXT(card, 2, "deladdr?"); |
| 859 | QETH_CARD_HEX(card, 3, addr, sizeof(struct qeth_ipaddr)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 860 | } |
| 861 | if (addr->is_multicast) |
| 862 | rc = qeth_l3_send_setdelmc(card, addr, IPA_CMD_DELIPM); |
| 863 | else |
| 864 | rc = qeth_l3_send_setdelip(card, addr, IPA_CMD_DELIP, |
| 865 | addr->del_flags); |
Frank Blaschka | c4cef07 | 2008-07-14 09:59:31 +0200 | [diff] [blame] | 866 | if (rc) |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 867 | QETH_CARD_TEXT(card, 2, "failed"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 868 | |
| 869 | return rc; |
| 870 | } |
| 871 | |
Julian Wiedmann | cef6ff22 | 2017-08-15 17:02:46 +0200 | [diff] [blame] | 872 | static u8 qeth_l3_get_qeth_hdr_flags4(int cast_type) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 873 | { |
| 874 | if (cast_type == RTN_MULTICAST) |
| 875 | return QETH_CAST_MULTICAST; |
| 876 | if (cast_type == RTN_BROADCAST) |
| 877 | return QETH_CAST_BROADCAST; |
| 878 | return QETH_CAST_UNICAST; |
| 879 | } |
| 880 | |
Julian Wiedmann | cef6ff22 | 2017-08-15 17:02:46 +0200 | [diff] [blame] | 881 | static u8 qeth_l3_get_qeth_hdr_flags6(int cast_type) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 882 | { |
| 883 | u8 ct = QETH_HDR_PASSTHRU | QETH_HDR_IPV6; |
| 884 | if (cast_type == RTN_MULTICAST) |
| 885 | return ct | QETH_CAST_MULTICAST; |
| 886 | if (cast_type == RTN_ANYCAST) |
| 887 | return ct | QETH_CAST_ANYCAST; |
| 888 | if (cast_type == RTN_BROADCAST) |
| 889 | return ct | QETH_CAST_BROADCAST; |
| 890 | return ct | QETH_CAST_UNICAST; |
| 891 | } |
| 892 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 893 | static int qeth_l3_setadapter_parms(struct qeth_card *card) |
| 894 | { |
Julian Wiedmann | 699d3fe | 2017-08-15 17:02:41 +0200 | [diff] [blame] | 895 | int rc = 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 896 | |
Peter Tiedemann | d11ba0c | 2008-04-01 10:26:58 +0200 | [diff] [blame] | 897 | QETH_DBF_TEXT(SETUP, 2, "setadprm"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 898 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 899 | if (qeth_adp_supported(card, IPA_SETADP_ALTER_MAC_ADDRESS)) { |
| 900 | rc = qeth_setadpparms_change_macaddr(card); |
| 901 | if (rc) |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 902 | dev_warn(&card->gdev->dev, "Reading the adapter MAC" |
Heiko Carstens | 6ea2fde | 2009-01-04 17:36:32 -0800 | [diff] [blame] | 903 | " address failed\n"); |
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 | return rc; |
| 907 | } |
| 908 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 909 | #ifdef CONFIG_QETH_IPV6 |
| 910 | static int qeth_l3_send_simple_setassparms_ipv6(struct qeth_card *card, |
| 911 | enum qeth_ipa_funcs ipa_func, __u16 cmd_code) |
| 912 | { |
| 913 | int rc; |
| 914 | struct qeth_cmd_buffer *iob; |
| 915 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 916 | QETH_CARD_TEXT(card, 4, "simassp6"); |
Thomas Richter | b475e31 | 2015-12-11 12:27:54 +0100 | [diff] [blame] | 917 | iob = qeth_get_setassparms_cmd(card, ipa_func, cmd_code, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 918 | 0, QETH_PROT_IPV6); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 919 | if (!iob) |
| 920 | return -ENOMEM; |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 921 | rc = qeth_send_setassparms(card, iob, 0, 0, |
Thomas Richter | 8f43fb0 | 2016-06-16 16:18:59 +0200 | [diff] [blame] | 922 | qeth_setassparms_cb, NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 923 | return rc; |
| 924 | } |
| 925 | #endif |
| 926 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 927 | static int qeth_l3_start_ipa_arp_processing(struct qeth_card *card) |
| 928 | { |
| 929 | int rc; |
| 930 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 931 | QETH_CARD_TEXT(card, 3, "ipaarp"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 932 | |
| 933 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 934 | dev_info(&card->gdev->dev, |
| 935 | "ARP processing not supported on %s!\n", |
| 936 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 937 | return 0; |
| 938 | } |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 939 | rc = qeth_send_simple_setassparms(card, IPA_ARP_PROCESSING, |
| 940 | IPA_CMD_ASS_START, 0); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 941 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 942 | dev_warn(&card->gdev->dev, |
| 943 | "Starting ARP processing support for %s failed\n", |
| 944 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 945 | } |
| 946 | return rc; |
| 947 | } |
| 948 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 949 | static int qeth_l3_start_ipa_source_mac(struct qeth_card *card) |
| 950 | { |
| 951 | int rc; |
| 952 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 953 | QETH_CARD_TEXT(card, 3, "stsrcmac"); |
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 | if (!qeth_is_supported(card, IPA_SOURCE_MAC)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 956 | dev_info(&card->gdev->dev, |
Ursula Braun | fe94e2e | 2009-01-04 17:34:52 -0800 | [diff] [blame] | 957 | "Inbound source MAC-address not supported on %s\n", |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 958 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 959 | return -EOPNOTSUPP; |
| 960 | } |
| 961 | |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 962 | rc = qeth_send_simple_setassparms(card, IPA_SOURCE_MAC, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 963 | IPA_CMD_ASS_START, 0); |
| 964 | if (rc) |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 965 | dev_warn(&card->gdev->dev, |
Ursula Braun | fe94e2e | 2009-01-04 17:34:52 -0800 | [diff] [blame] | 966 | "Starting source MAC-address support for %s failed\n", |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 967 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 968 | return rc; |
| 969 | } |
| 970 | |
| 971 | static int qeth_l3_start_ipa_vlan(struct qeth_card *card) |
| 972 | { |
| 973 | int rc = 0; |
| 974 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 975 | QETH_CARD_TEXT(card, 3, "strtvlan"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 976 | |
| 977 | if (!qeth_is_supported(card, IPA_FULL_VLAN)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 978 | dev_info(&card->gdev->dev, |
| 979 | "VLAN not supported on %s\n", QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 980 | return -EOPNOTSUPP; |
| 981 | } |
| 982 | |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 983 | rc = qeth_send_simple_setassparms(card, IPA_VLAN_PRIO, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 984 | IPA_CMD_ASS_START, 0); |
| 985 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 986 | dev_warn(&card->gdev->dev, |
| 987 | "Starting VLAN support for %s failed\n", |
| 988 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 989 | } else { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 990 | dev_info(&card->gdev->dev, "VLAN enabled\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 991 | } |
| 992 | return rc; |
| 993 | } |
| 994 | |
| 995 | static int qeth_l3_start_ipa_multicast(struct qeth_card *card) |
| 996 | { |
| 997 | int rc; |
| 998 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 999 | QETH_CARD_TEXT(card, 3, "stmcast"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1000 | |
| 1001 | if (!qeth_is_supported(card, IPA_MULTICASTING)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1002 | dev_info(&card->gdev->dev, |
| 1003 | "Multicast not supported on %s\n", |
| 1004 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1005 | return -EOPNOTSUPP; |
| 1006 | } |
| 1007 | |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 1008 | rc = qeth_send_simple_setassparms(card, IPA_MULTICASTING, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1009 | IPA_CMD_ASS_START, 0); |
| 1010 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1011 | dev_warn(&card->gdev->dev, |
| 1012 | "Starting multicast support for %s failed\n", |
| 1013 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1014 | } else { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1015 | dev_info(&card->gdev->dev, "Multicast enabled\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1016 | card->dev->flags |= IFF_MULTICAST; |
| 1017 | } |
| 1018 | return rc; |
| 1019 | } |
| 1020 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1021 | #ifdef CONFIG_QETH_IPV6 |
| 1022 | static int qeth_l3_softsetup_ipv6(struct qeth_card *card) |
| 1023 | { |
| 1024 | int rc; |
| 1025 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1026 | QETH_CARD_TEXT(card, 3, "softipv6"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1027 | |
Frank Blaschka | 1da74b1 | 2011-05-12 18:45:02 +0000 | [diff] [blame] | 1028 | rc = qeth_query_ipassists(card, QETH_PROT_IPV6); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1029 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1030 | dev_err(&card->gdev->dev, |
| 1031 | "Activating IPv6 support for %s failed\n", |
| 1032 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1033 | return rc; |
| 1034 | } |
Julian Wiedmann | 2327459 | 2017-06-06 14:33:44 +0200 | [diff] [blame] | 1035 | |
| 1036 | if (card->info.type == QETH_CARD_TYPE_IQD) |
| 1037 | goto out; |
| 1038 | |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 1039 | rc = qeth_send_simple_setassparms(card, IPA_IPV6, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1040 | IPA_CMD_ASS_START, 3); |
| 1041 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1042 | dev_err(&card->gdev->dev, |
| 1043 | "Activating IPv6 support for %s failed\n", |
| 1044 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1045 | return rc; |
| 1046 | } |
| 1047 | rc = qeth_l3_send_simple_setassparms_ipv6(card, IPA_IPV6, |
| 1048 | IPA_CMD_ASS_START); |
| 1049 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1050 | dev_err(&card->gdev->dev, |
| 1051 | "Activating IPv6 support for %s failed\n", |
| 1052 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1053 | return rc; |
| 1054 | } |
| 1055 | rc = qeth_l3_send_simple_setassparms_ipv6(card, IPA_PASSTHRU, |
| 1056 | IPA_CMD_ASS_START); |
| 1057 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1058 | dev_warn(&card->gdev->dev, |
| 1059 | "Enabling the passthrough mode for %s failed\n", |
| 1060 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1061 | return rc; |
| 1062 | } |
| 1063 | out: |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1064 | dev_info(&card->gdev->dev, "IPV6 enabled\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1065 | return 0; |
| 1066 | } |
| 1067 | #endif |
| 1068 | |
| 1069 | static int qeth_l3_start_ipa_ipv6(struct qeth_card *card) |
| 1070 | { |
| 1071 | int rc = 0; |
| 1072 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1073 | QETH_CARD_TEXT(card, 3, "strtipv6"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1074 | |
| 1075 | if (!qeth_is_supported(card, IPA_IPV6)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1076 | dev_info(&card->gdev->dev, |
| 1077 | "IPv6 not supported on %s\n", QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1078 | return 0; |
| 1079 | } |
| 1080 | #ifdef CONFIG_QETH_IPV6 |
| 1081 | rc = qeth_l3_softsetup_ipv6(card); |
| 1082 | #endif |
| 1083 | return rc ; |
| 1084 | } |
| 1085 | |
| 1086 | static int qeth_l3_start_ipa_broadcast(struct qeth_card *card) |
| 1087 | { |
| 1088 | int rc; |
| 1089 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1090 | QETH_CARD_TEXT(card, 3, "stbrdcst"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1091 | card->info.broadcast_capable = 0; |
| 1092 | if (!qeth_is_supported(card, IPA_FILTERING)) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1093 | dev_info(&card->gdev->dev, |
| 1094 | "Broadcast not supported on %s\n", |
| 1095 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1096 | rc = -EOPNOTSUPP; |
| 1097 | goto out; |
| 1098 | } |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 1099 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1100 | IPA_CMD_ASS_START, 0); |
| 1101 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1102 | dev_warn(&card->gdev->dev, "Enabling broadcast filtering for " |
| 1103 | "%s failed\n", QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1104 | goto out; |
| 1105 | } |
| 1106 | |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 1107 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1108 | IPA_CMD_ASS_CONFIGURE, 1); |
| 1109 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1110 | dev_warn(&card->gdev->dev, |
| 1111 | "Setting up broadcast filtering for %s failed\n", |
| 1112 | QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1113 | goto out; |
| 1114 | } |
| 1115 | card->info.broadcast_capable = QETH_BROADCAST_WITH_ECHO; |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1116 | dev_info(&card->gdev->dev, "Broadcast enabled\n"); |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 1117 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1118 | IPA_CMD_ASS_ENABLE, 1); |
| 1119 | if (rc) { |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1120 | dev_warn(&card->gdev->dev, "Setting up broadcast echo " |
| 1121 | "filtering for %s failed\n", QETH_CARD_IFNAME(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1122 | goto out; |
| 1123 | } |
| 1124 | card->info.broadcast_capable = QETH_BROADCAST_WITHOUT_ECHO; |
| 1125 | out: |
| 1126 | if (card->info.broadcast_capable) |
| 1127 | card->dev->flags |= IFF_BROADCAST; |
| 1128 | else |
| 1129 | card->dev->flags &= ~IFF_BROADCAST; |
| 1130 | return rc; |
| 1131 | } |
| 1132 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1133 | static int qeth_l3_start_ipassists(struct qeth_card *card) |
| 1134 | { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1135 | QETH_CARD_TEXT(card, 3, "strtipas"); |
Einar Lueck | d64ecc2 | 2009-11-12 00:11:41 +0000 | [diff] [blame] | 1136 | |
Stefan Raspl | 0f54761 | 2013-01-21 02:30:20 +0000 | [diff] [blame] | 1137 | if (qeth_set_access_ctrl_online(card, 0)) |
| 1138 | return -EIO; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1139 | qeth_l3_start_ipa_arp_processing(card); /* go on*/ |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1140 | qeth_l3_start_ipa_source_mac(card); /* go on*/ |
| 1141 | qeth_l3_start_ipa_vlan(card); /* go on*/ |
| 1142 | qeth_l3_start_ipa_multicast(card); /* go on*/ |
| 1143 | qeth_l3_start_ipa_ipv6(card); /* go on*/ |
| 1144 | qeth_l3_start_ipa_broadcast(card); /* go on*/ |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1145 | return 0; |
| 1146 | } |
| 1147 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1148 | static int qeth_l3_iqd_read_initial_mac_cb(struct qeth_card *card, |
| 1149 | struct qeth_reply *reply, unsigned long data) |
| 1150 | { |
| 1151 | struct qeth_ipa_cmd *cmd; |
| 1152 | |
| 1153 | cmd = (struct qeth_ipa_cmd *) data; |
| 1154 | if (cmd->hdr.return_code == 0) |
| 1155 | memcpy(card->dev->dev_addr, |
| 1156 | cmd->data.create_destroy_addr.unique_id, ETH_ALEN); |
| 1157 | else |
Joe Perches | 1833611 | 2012-07-12 22:33:10 -0700 | [diff] [blame] | 1158 | eth_random_addr(card->dev->dev_addr); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1159 | |
| 1160 | return 0; |
| 1161 | } |
| 1162 | |
| 1163 | static int qeth_l3_iqd_read_initial_mac(struct qeth_card *card) |
| 1164 | { |
| 1165 | int rc = 0; |
| 1166 | struct qeth_cmd_buffer *iob; |
| 1167 | struct qeth_ipa_cmd *cmd; |
| 1168 | |
Peter Tiedemann | d11ba0c | 2008-04-01 10:26:58 +0200 | [diff] [blame] | 1169 | QETH_DBF_TEXT(SETUP, 2, "hsrmac"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1170 | |
| 1171 | iob = qeth_get_ipacmd_buffer(card, IPA_CMD_CREATE_ADDR, |
| 1172 | QETH_PROT_IPV6); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 1173 | if (!iob) |
| 1174 | return -ENOMEM; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1175 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); |
| 1176 | *((__u16 *) &cmd->data.create_destroy_addr.unique_id[6]) = |
| 1177 | card->info.unique_id; |
| 1178 | |
| 1179 | rc = qeth_send_ipa_cmd(card, iob, qeth_l3_iqd_read_initial_mac_cb, |
| 1180 | NULL); |
| 1181 | return rc; |
| 1182 | } |
| 1183 | |
| 1184 | static int qeth_l3_get_unique_id_cb(struct qeth_card *card, |
| 1185 | struct qeth_reply *reply, unsigned long data) |
| 1186 | { |
| 1187 | struct qeth_ipa_cmd *cmd; |
| 1188 | |
| 1189 | cmd = (struct qeth_ipa_cmd *) data; |
| 1190 | if (cmd->hdr.return_code == 0) |
| 1191 | card->info.unique_id = *((__u16 *) |
| 1192 | &cmd->data.create_destroy_addr.unique_id[6]); |
| 1193 | else { |
| 1194 | card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED | |
| 1195 | UNIQUE_ID_NOT_BY_CARD; |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 1196 | dev_warn(&card->gdev->dev, "The network adapter failed to " |
| 1197 | "generate a unique ID\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1198 | } |
| 1199 | return 0; |
| 1200 | } |
| 1201 | |
| 1202 | static int qeth_l3_get_unique_id(struct qeth_card *card) |
| 1203 | { |
| 1204 | int rc = 0; |
| 1205 | struct qeth_cmd_buffer *iob; |
| 1206 | struct qeth_ipa_cmd *cmd; |
| 1207 | |
Peter Tiedemann | d11ba0c | 2008-04-01 10:26:58 +0200 | [diff] [blame] | 1208 | QETH_DBF_TEXT(SETUP, 2, "guniqeid"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1209 | |
| 1210 | if (!qeth_is_supported(card, IPA_IPV6)) { |
| 1211 | card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED | |
| 1212 | UNIQUE_ID_NOT_BY_CARD; |
| 1213 | return 0; |
| 1214 | } |
| 1215 | |
| 1216 | iob = qeth_get_ipacmd_buffer(card, IPA_CMD_CREATE_ADDR, |
| 1217 | QETH_PROT_IPV6); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 1218 | if (!iob) |
| 1219 | return -ENOMEM; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1220 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); |
| 1221 | *((__u16 *) &cmd->data.create_destroy_addr.unique_id[6]) = |
| 1222 | card->info.unique_id; |
| 1223 | |
| 1224 | rc = qeth_send_ipa_cmd(card, iob, qeth_l3_get_unique_id_cb, NULL); |
| 1225 | return rc; |
| 1226 | } |
| 1227 | |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1228 | static int |
| 1229 | qeth_diags_trace_cb(struct qeth_card *card, struct qeth_reply *reply, |
| 1230 | unsigned long data) |
| 1231 | { |
| 1232 | struct qeth_ipa_cmd *cmd; |
| 1233 | __u16 rc; |
| 1234 | |
| 1235 | QETH_DBF_TEXT(SETUP, 2, "diastrcb"); |
| 1236 | |
| 1237 | cmd = (struct qeth_ipa_cmd *)data; |
| 1238 | rc = cmd->hdr.return_code; |
Ursula Braun | a959189 | 2010-03-08 20:36:55 +0000 | [diff] [blame] | 1239 | if (rc) |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1240 | QETH_CARD_TEXT_(card, 2, "dxter%x", rc); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1241 | switch (cmd->data.diagass.action) { |
| 1242 | case QETH_DIAGS_CMD_TRACE_QUERY: |
| 1243 | break; |
| 1244 | case QETH_DIAGS_CMD_TRACE_DISABLE: |
Ursula Braun | a959189 | 2010-03-08 20:36:55 +0000 | [diff] [blame] | 1245 | switch (rc) { |
| 1246 | case 0: |
| 1247 | case IPA_RC_INVALID_SUBCMD: |
| 1248 | card->info.promisc_mode = SET_PROMISC_MODE_OFF; |
| 1249 | dev_info(&card->gdev->dev, "The HiperSockets network " |
| 1250 | "traffic analyzer is deactivated\n"); |
| 1251 | break; |
| 1252 | default: |
| 1253 | break; |
| 1254 | } |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1255 | break; |
| 1256 | case QETH_DIAGS_CMD_TRACE_ENABLE: |
Ursula Braun | a959189 | 2010-03-08 20:36:55 +0000 | [diff] [blame] | 1257 | switch (rc) { |
| 1258 | case 0: |
| 1259 | card->info.promisc_mode = SET_PROMISC_MODE_ON; |
| 1260 | dev_info(&card->gdev->dev, "The HiperSockets network " |
| 1261 | "traffic analyzer is activated\n"); |
| 1262 | break; |
| 1263 | case IPA_RC_HARDWARE_AUTH_ERROR: |
| 1264 | dev_warn(&card->gdev->dev, "The device is not " |
| 1265 | "authorized to run as a HiperSockets network " |
| 1266 | "traffic analyzer\n"); |
| 1267 | break; |
| 1268 | case IPA_RC_TRACE_ALREADY_ACTIVE: |
| 1269 | dev_warn(&card->gdev->dev, "A HiperSockets " |
| 1270 | "network traffic analyzer is already " |
| 1271 | "active in the HiperSockets LAN\n"); |
| 1272 | break; |
| 1273 | default: |
| 1274 | break; |
| 1275 | } |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1276 | break; |
| 1277 | default: |
| 1278 | QETH_DBF_MESSAGE(2, "Unknown sniffer action (0x%04x) on %s\n", |
| 1279 | cmd->data.diagass.action, QETH_CARD_IFNAME(card)); |
| 1280 | } |
| 1281 | |
| 1282 | return 0; |
| 1283 | } |
| 1284 | |
| 1285 | static int |
| 1286 | qeth_diags_trace(struct qeth_card *card, enum qeth_diags_trace_cmds diags_cmd) |
| 1287 | { |
| 1288 | struct qeth_cmd_buffer *iob; |
| 1289 | struct qeth_ipa_cmd *cmd; |
| 1290 | |
| 1291 | QETH_DBF_TEXT(SETUP, 2, "diagtrac"); |
| 1292 | |
| 1293 | iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SET_DIAG_ASS, 0); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 1294 | if (!iob) |
| 1295 | return -ENOMEM; |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1296 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); |
| 1297 | cmd->data.diagass.subcmd_len = 16; |
| 1298 | cmd->data.diagass.subcmd = QETH_DIAGS_CMD_TRACE; |
| 1299 | cmd->data.diagass.type = QETH_DIAGS_TYPE_HIPERSOCKET; |
| 1300 | cmd->data.diagass.action = diags_cmd; |
| 1301 | return qeth_send_ipa_cmd(card, iob, qeth_diags_trace_cb, NULL); |
| 1302 | } |
| 1303 | |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 1304 | static void qeth_l3_get_mac_for_ipm(__be32 ipm, char *mac) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1305 | { |
Paul Gortmaker | 1abd229 | 2012-05-10 15:50:52 -0400 | [diff] [blame] | 1306 | ip_eth_mc_map(ipm, mac); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1307 | } |
| 1308 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1309 | static void qeth_l3_mark_all_mc_to_be_deleted(struct qeth_card *card) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1310 | { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1311 | struct qeth_ipaddr *addr; |
| 1312 | int i; |
| 1313 | |
| 1314 | hash_for_each(card->ip_mc_htable, i, addr, hnode) |
| 1315 | addr->disp_flag = QETH_DISP_ADDR_DELETE; |
| 1316 | |
| 1317 | } |
| 1318 | |
| 1319 | static void qeth_l3_add_all_new_mc(struct qeth_card *card) |
| 1320 | { |
| 1321 | struct qeth_ipaddr *addr; |
| 1322 | struct hlist_node *tmp; |
| 1323 | int i; |
| 1324 | int rc; |
| 1325 | |
| 1326 | hash_for_each_safe(card->ip_mc_htable, i, tmp, addr, hnode) { |
| 1327 | if (addr->disp_flag == QETH_DISP_ADDR_ADD) { |
| 1328 | rc = qeth_l3_register_addr_entry(card, addr); |
| 1329 | if (!rc || (rc == IPA_RC_LAN_OFFLINE)) |
| 1330 | addr->ref_counter = 1; |
| 1331 | else { |
| 1332 | hash_del(&addr->hnode); |
| 1333 | kfree(addr); |
| 1334 | } |
| 1335 | } |
| 1336 | } |
| 1337 | |
| 1338 | } |
| 1339 | |
| 1340 | static void qeth_l3_delete_nonused_mc(struct qeth_card *card) |
| 1341 | { |
| 1342 | struct qeth_ipaddr *addr; |
| 1343 | struct hlist_node *tmp; |
| 1344 | int i; |
| 1345 | int rc; |
| 1346 | |
| 1347 | hash_for_each_safe(card->ip_mc_htable, i, tmp, addr, hnode) { |
| 1348 | if (addr->disp_flag == QETH_DISP_ADDR_DELETE) { |
| 1349 | rc = qeth_l3_deregister_addr_entry(card, addr); |
| 1350 | if (!rc || (rc == IPA_RC_MC_ADDR_NOT_FOUND)) { |
| 1351 | hash_del(&addr->hnode); |
| 1352 | kfree(addr); |
| 1353 | } |
| 1354 | } |
| 1355 | } |
| 1356 | |
| 1357 | } |
| 1358 | |
| 1359 | |
| 1360 | static void |
| 1361 | qeth_l3_add_mc_to_hash(struct qeth_card *card, struct in_device *in4_dev) |
| 1362 | { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1363 | struct ip_mc_list *im4; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1364 | struct qeth_ipaddr *tmp, *ipm; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1365 | char buf[MAX_ADDR_LEN]; |
| 1366 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1367 | QETH_CARD_TEXT(card, 4, "addmc"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1368 | |
| 1369 | tmp = qeth_l3_get_addr_buffer(QETH_PROT_IPV4); |
| 1370 | if (!tmp) |
| 1371 | return; |
| 1372 | |
Sachin Sant | f3aa313 | 2010-11-26 02:41:17 +0000 | [diff] [blame] | 1373 | for (im4 = rcu_dereference(in4_dev->mc_list); im4 != NULL; |
| 1374 | im4 = rcu_dereference(im4->next_rcu)) { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1375 | qeth_l3_get_mac_for_ipm(im4->multiaddr, buf); |
| 1376 | |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 1377 | tmp->u.a4.addr = be32_to_cpu(im4->multiaddr); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1378 | memcpy(tmp->mac, buf, sizeof(tmp->mac)); |
Julian Wiedmann | bc3ab705 | 2017-12-01 10:14:49 +0100 | [diff] [blame] | 1379 | tmp->is_multicast = 1; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1380 | |
| 1381 | ipm = qeth_l3_ip_from_hash(card, tmp); |
| 1382 | if (ipm) { |
| 1383 | ipm->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
| 1384 | } else { |
| 1385 | ipm = qeth_l3_get_addr_buffer(QETH_PROT_IPV4); |
| 1386 | if (!ipm) |
| 1387 | continue; |
| 1388 | memcpy(ipm->mac, buf, sizeof(tmp->mac)); |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 1389 | ipm->u.a4.addr = be32_to_cpu(im4->multiaddr); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1390 | ipm->is_multicast = 1; |
| 1391 | ipm->disp_flag = QETH_DISP_ADDR_ADD; |
| 1392 | hash_add(card->ip_mc_htable, |
| 1393 | &ipm->hnode, qeth_l3_ipaddr_hash(ipm)); |
| 1394 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1395 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1396 | |
| 1397 | kfree(tmp); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1398 | } |
| 1399 | |
Jiri Pirko | 0347af5 | 2013-01-03 22:48:58 +0000 | [diff] [blame] | 1400 | /* called with rcu_read_lock */ |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1401 | static void qeth_l3_add_vlan_mc(struct qeth_card *card) |
| 1402 | { |
| 1403 | struct in_device *in_dev; |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1404 | u16 vid; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1405 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1406 | QETH_CARD_TEXT(card, 4, "addmcvl"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1407 | |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1408 | if (!qeth_is_supported(card, IPA_FULL_VLAN)) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1409 | return; |
| 1410 | |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1411 | for_each_set_bit(vid, card->active_vlans, VLAN_N_VID) { |
| 1412 | struct net_device *netdev; |
| 1413 | |
dingtianhong | f06c7f9f | 2014-05-09 14:58:05 +0800 | [diff] [blame] | 1414 | netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), |
Patrick McHardy | 91b1c1a | 2013-04-21 00:09:34 +0000 | [diff] [blame] | 1415 | vid); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1416 | if (netdev == NULL || |
| 1417 | !(netdev->flags & IFF_UP)) |
| 1418 | continue; |
Jiri Pirko | 0347af5 | 2013-01-03 22:48:58 +0000 | [diff] [blame] | 1419 | in_dev = __in_dev_get_rcu(netdev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1420 | if (!in_dev) |
| 1421 | continue; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1422 | qeth_l3_add_mc_to_hash(card, in_dev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1423 | } |
| 1424 | } |
| 1425 | |
| 1426 | static void qeth_l3_add_multicast_ipv4(struct qeth_card *card) |
| 1427 | { |
| 1428 | struct in_device *in4_dev; |
| 1429 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1430 | QETH_CARD_TEXT(card, 4, "chkmcv4"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1431 | |
Sachin Sant | f3aa313 | 2010-11-26 02:41:17 +0000 | [diff] [blame] | 1432 | rcu_read_lock(); |
Jiri Pirko | 0347af5 | 2013-01-03 22:48:58 +0000 | [diff] [blame] | 1433 | in4_dev = __in_dev_get_rcu(card->dev); |
| 1434 | if (in4_dev == NULL) |
| 1435 | goto unlock; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1436 | qeth_l3_add_mc_to_hash(card, in4_dev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1437 | qeth_l3_add_vlan_mc(card); |
Jiri Pirko | 0347af5 | 2013-01-03 22:48:58 +0000 | [diff] [blame] | 1438 | unlock: |
Sachin Sant | f3aa313 | 2010-11-26 02:41:17 +0000 | [diff] [blame] | 1439 | rcu_read_unlock(); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1440 | } |
| 1441 | |
| 1442 | #ifdef CONFIG_QETH_IPV6 |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1443 | static void |
| 1444 | qeth_l3_add_mc6_to_hash(struct qeth_card *card, struct inet6_dev *in6_dev) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1445 | { |
| 1446 | struct qeth_ipaddr *ipm; |
| 1447 | struct ifmcaddr6 *im6; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1448 | struct qeth_ipaddr *tmp; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1449 | char buf[MAX_ADDR_LEN]; |
| 1450 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1451 | QETH_CARD_TEXT(card, 4, "addmc6"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1452 | |
| 1453 | tmp = qeth_l3_get_addr_buffer(QETH_PROT_IPV6); |
| 1454 | if (!tmp) |
| 1455 | return; |
| 1456 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1457 | for (im6 = in6_dev->mc_list; im6 != NULL; im6 = im6->next) { |
| 1458 | ndisc_mc_map(&im6->mca_addr, buf, in6_dev->dev, 0); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1459 | |
| 1460 | memcpy(tmp->mac, buf, sizeof(tmp->mac)); |
| 1461 | memcpy(&tmp->u.a6.addr, &im6->mca_addr.s6_addr, |
| 1462 | sizeof(struct in6_addr)); |
| 1463 | tmp->is_multicast = 1; |
| 1464 | |
| 1465 | ipm = qeth_l3_ip_from_hash(card, tmp); |
| 1466 | if (ipm) { |
| 1467 | ipm->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
| 1468 | continue; |
| 1469 | } |
| 1470 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1471 | ipm = qeth_l3_get_addr_buffer(QETH_PROT_IPV6); |
| 1472 | if (!ipm) |
| 1473 | continue; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1474 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1475 | memcpy(ipm->mac, buf, OSA_ADDR_LEN); |
| 1476 | memcpy(&ipm->u.a6.addr, &im6->mca_addr.s6_addr, |
| 1477 | sizeof(struct in6_addr)); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1478 | ipm->is_multicast = 1; |
| 1479 | ipm->disp_flag = QETH_DISP_ADDR_ADD; |
| 1480 | hash_add(card->ip_mc_htable, |
| 1481 | &ipm->hnode, qeth_l3_ipaddr_hash(ipm)); |
| 1482 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1483 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1484 | kfree(tmp); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1485 | } |
| 1486 | |
Jiri Pirko | 0347af5 | 2013-01-03 22:48:58 +0000 | [diff] [blame] | 1487 | /* called with rcu_read_lock */ |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1488 | static void qeth_l3_add_vlan_mc6(struct qeth_card *card) |
| 1489 | { |
| 1490 | struct inet6_dev *in_dev; |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1491 | u16 vid; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1492 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1493 | QETH_CARD_TEXT(card, 4, "admc6vl"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1494 | |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1495 | if (!qeth_is_supported(card, IPA_FULL_VLAN)) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1496 | return; |
| 1497 | |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1498 | for_each_set_bit(vid, card->active_vlans, VLAN_N_VID) { |
| 1499 | struct net_device *netdev; |
| 1500 | |
dingtianhong | f06c7f9f | 2014-05-09 14:58:05 +0800 | [diff] [blame] | 1501 | netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), |
Patrick McHardy | 91b1c1a | 2013-04-21 00:09:34 +0000 | [diff] [blame] | 1502 | vid); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1503 | if (netdev == NULL || |
| 1504 | !(netdev->flags & IFF_UP)) |
| 1505 | continue; |
| 1506 | in_dev = in6_dev_get(netdev); |
| 1507 | if (!in_dev) |
| 1508 | continue; |
| 1509 | read_lock_bh(&in_dev->lock); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1510 | qeth_l3_add_mc6_to_hash(card, in_dev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1511 | read_unlock_bh(&in_dev->lock); |
| 1512 | in6_dev_put(in_dev); |
| 1513 | } |
| 1514 | } |
| 1515 | |
| 1516 | static void qeth_l3_add_multicast_ipv6(struct qeth_card *card) |
| 1517 | { |
| 1518 | struct inet6_dev *in6_dev; |
| 1519 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1520 | QETH_CARD_TEXT(card, 4, "chkmcv6"); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1521 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1522 | if (!qeth_is_supported(card, IPA_IPV6)) |
| 1523 | return ; |
| 1524 | in6_dev = in6_dev_get(card->dev); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1525 | if (!in6_dev) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1526 | return; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1527 | |
Jiri Pirko | 0347af5 | 2013-01-03 22:48:58 +0000 | [diff] [blame] | 1528 | rcu_read_lock(); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1529 | read_lock_bh(&in6_dev->lock); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1530 | qeth_l3_add_mc6_to_hash(card, in6_dev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1531 | qeth_l3_add_vlan_mc6(card); |
| 1532 | read_unlock_bh(&in6_dev->lock); |
Jiri Pirko | 0347af5 | 2013-01-03 22:48:58 +0000 | [diff] [blame] | 1533 | rcu_read_unlock(); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1534 | in6_dev_put(in6_dev); |
| 1535 | } |
| 1536 | #endif /* CONFIG_QETH_IPV6 */ |
| 1537 | |
| 1538 | static void qeth_l3_free_vlan_addresses4(struct qeth_card *card, |
| 1539 | unsigned short vid) |
| 1540 | { |
| 1541 | struct in_device *in_dev; |
| 1542 | struct in_ifaddr *ifa; |
| 1543 | struct qeth_ipaddr *addr; |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1544 | struct net_device *netdev; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1545 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1546 | QETH_CARD_TEXT(card, 4, "frvaddr4"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1547 | |
dingtianhong | f06c7f9f | 2014-05-09 14:58:05 +0800 | [diff] [blame] | 1548 | netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), vid); |
frank.blaschka@de.ibm.com | eabfbe6 | 2012-07-24 22:34:29 +0000 | [diff] [blame] | 1549 | if (!netdev) |
| 1550 | return; |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1551 | in_dev = in_dev_get(netdev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1552 | if (!in_dev) |
| 1553 | return; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1554 | |
| 1555 | addr = qeth_l3_get_addr_buffer(QETH_PROT_IPV4); |
| 1556 | if (!addr) |
Julian Wiedmann | 83cf79a | 2017-10-18 17:40:17 +0200 | [diff] [blame] | 1557 | goto out; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1558 | |
| 1559 | spin_lock_bh(&card->ip_lock); |
| 1560 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1561 | for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 1562 | addr->u.a4.addr = be32_to_cpu(ifa->ifa_address); |
| 1563 | addr->u.a4.mask = be32_to_cpu(ifa->ifa_mask); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1564 | addr->type = QETH_IP_TYPE_NORMAL; |
| 1565 | qeth_l3_delete_ip(card, addr); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1566 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1567 | |
| 1568 | spin_unlock_bh(&card->ip_lock); |
| 1569 | |
| 1570 | kfree(addr); |
Julian Wiedmann | 83cf79a | 2017-10-18 17:40:17 +0200 | [diff] [blame] | 1571 | out: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1572 | in_dev_put(in_dev); |
| 1573 | } |
| 1574 | |
| 1575 | static void qeth_l3_free_vlan_addresses6(struct qeth_card *card, |
| 1576 | unsigned short vid) |
| 1577 | { |
| 1578 | #ifdef CONFIG_QETH_IPV6 |
| 1579 | struct inet6_dev *in6_dev; |
| 1580 | struct inet6_ifaddr *ifa; |
| 1581 | struct qeth_ipaddr *addr; |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1582 | struct net_device *netdev; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1583 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1584 | QETH_CARD_TEXT(card, 4, "frvaddr6"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1585 | |
dingtianhong | f06c7f9f | 2014-05-09 14:58:05 +0800 | [diff] [blame] | 1586 | netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), vid); |
frank.blaschka@de.ibm.com | eabfbe6 | 2012-07-24 22:34:29 +0000 | [diff] [blame] | 1587 | if (!netdev) |
| 1588 | return; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1589 | |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1590 | in6_dev = in6_dev_get(netdev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1591 | if (!in6_dev) |
| 1592 | return; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1593 | |
| 1594 | addr = qeth_l3_get_addr_buffer(QETH_PROT_IPV6); |
| 1595 | if (!addr) |
Julian Wiedmann | 83cf79a | 2017-10-18 17:40:17 +0200 | [diff] [blame] | 1596 | goto out; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1597 | |
| 1598 | spin_lock_bh(&card->ip_lock); |
| 1599 | |
Frank Blaschka | 70f60a2 | 2010-03-22 09:59:48 -0700 | [diff] [blame] | 1600 | list_for_each_entry(ifa, &in6_dev->addr_list, if_list) { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1601 | memcpy(&addr->u.a6.addr, &ifa->addr, |
| 1602 | sizeof(struct in6_addr)); |
| 1603 | addr->u.a6.pfxlen = ifa->prefix_len; |
| 1604 | addr->type = QETH_IP_TYPE_NORMAL; |
| 1605 | qeth_l3_delete_ip(card, addr); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1606 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1607 | |
| 1608 | spin_unlock_bh(&card->ip_lock); |
| 1609 | |
| 1610 | kfree(addr); |
Julian Wiedmann | 83cf79a | 2017-10-18 17:40:17 +0200 | [diff] [blame] | 1611 | out: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1612 | in6_dev_put(in6_dev); |
| 1613 | #endif /* CONFIG_QETH_IPV6 */ |
| 1614 | } |
| 1615 | |
| 1616 | static void qeth_l3_free_vlan_addresses(struct qeth_card *card, |
| 1617 | unsigned short vid) |
| 1618 | { |
Jiri Pirko | 0347af5 | 2013-01-03 22:48:58 +0000 | [diff] [blame] | 1619 | rcu_read_lock(); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1620 | qeth_l3_free_vlan_addresses4(card, vid); |
| 1621 | qeth_l3_free_vlan_addresses6(card, vid); |
Jiri Pirko | 0347af5 | 2013-01-03 22:48:58 +0000 | [diff] [blame] | 1622 | rcu_read_unlock(); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1623 | } |
| 1624 | |
Patrick McHardy | 80d5c36 | 2013-04-19 02:04:28 +0000 | [diff] [blame] | 1625 | static int qeth_l3_vlan_rx_add_vid(struct net_device *dev, |
| 1626 | __be16 proto, u16 vid) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1627 | { |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1628 | struct qeth_card *card = dev->ml_priv; |
| 1629 | |
| 1630 | set_bit(vid, card->active_vlans); |
Jiri Pirko | 8e58613 | 2011-12-08 19:52:37 -0500 | [diff] [blame] | 1631 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1632 | } |
| 1633 | |
Patrick McHardy | 80d5c36 | 2013-04-19 02:04:28 +0000 | [diff] [blame] | 1634 | static int qeth_l3_vlan_rx_kill_vid(struct net_device *dev, |
| 1635 | __be16 proto, u16 vid) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1636 | { |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 1637 | struct qeth_card *card = dev->ml_priv; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1638 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1639 | QETH_CARD_TEXT_(card, 4, "kid:%d", vid); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1640 | |
Ursula Braun | 8e98ac4 | 2009-03-24 20:57:18 +0000 | [diff] [blame] | 1641 | if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1642 | QETH_CARD_TEXT(card, 3, "kidREC"); |
Jiri Pirko | 8e58613 | 2011-12-08 19:52:37 -0500 | [diff] [blame] | 1643 | return 0; |
Ursula Braun | 8e98ac4 | 2009-03-24 20:57:18 +0000 | [diff] [blame] | 1644 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1645 | /* unregister IP addresses of vlan device */ |
| 1646 | qeth_l3_free_vlan_addresses(card, vid); |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1647 | clear_bit(vid, card->active_vlans); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1648 | qeth_l3_set_multicast_list(card->dev); |
Jiri Pirko | 8e58613 | 2011-12-08 19:52:37 -0500 | [diff] [blame] | 1649 | return 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1650 | } |
| 1651 | |
Julian Wiedmann | d7aa9d0 | 2017-09-18 21:18:21 +0200 | [diff] [blame] | 1652 | static void qeth_l3_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, |
| 1653 | struct qeth_hdr *hdr) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1654 | { |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 1655 | __u16 prot; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1656 | struct iphdr *ip_hdr; |
| 1657 | unsigned char tg_addr[MAX_ADDR_LEN]; |
| 1658 | |
| 1659 | if (!(hdr->hdr.l3.flags & QETH_HDR_PASSTHRU)) { |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 1660 | prot = (hdr->hdr.l3.flags & QETH_HDR_IPV6) ? ETH_P_IPV6 : |
| 1661 | ETH_P_IP; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1662 | switch (hdr->hdr.l3.flags & QETH_HDR_CAST_MASK) { |
| 1663 | case QETH_CAST_MULTICAST: |
| 1664 | switch (prot) { |
| 1665 | #ifdef CONFIG_QETH_IPV6 |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 1666 | case ETH_P_IPV6: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1667 | ndisc_mc_map((struct in6_addr *) |
| 1668 | skb->data + 24, |
| 1669 | tg_addr, card->dev, 0); |
| 1670 | break; |
| 1671 | #endif |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 1672 | case ETH_P_IP: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1673 | ip_hdr = (struct iphdr *)skb->data; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1674 | ip_eth_mc_map(ip_hdr->daddr, tg_addr); |
| 1675 | break; |
| 1676 | default: |
| 1677 | memcpy(tg_addr, card->dev->broadcast, |
| 1678 | card->dev->addr_len); |
| 1679 | } |
| 1680 | card->stats.multicast++; |
| 1681 | skb->pkt_type = PACKET_MULTICAST; |
| 1682 | break; |
| 1683 | case QETH_CAST_BROADCAST: |
| 1684 | memcpy(tg_addr, card->dev->broadcast, |
| 1685 | card->dev->addr_len); |
| 1686 | card->stats.multicast++; |
| 1687 | skb->pkt_type = PACKET_BROADCAST; |
| 1688 | break; |
| 1689 | case QETH_CAST_UNICAST: |
| 1690 | case QETH_CAST_ANYCAST: |
| 1691 | case QETH_CAST_NOCAST: |
| 1692 | default: |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1693 | if (card->options.sniffer) |
| 1694 | skb->pkt_type = PACKET_OTHERHOST; |
| 1695 | else |
| 1696 | skb->pkt_type = PACKET_HOST; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1697 | memcpy(tg_addr, card->dev->dev_addr, |
| 1698 | card->dev->addr_len); |
| 1699 | } |
Ursula Braun | fe94e2e | 2009-01-04 17:34:52 -0800 | [diff] [blame] | 1700 | if (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR) |
| 1701 | card->dev->header_ops->create(skb, card->dev, prot, |
| 1702 | tg_addr, &hdr->hdr.l3.dest_addr[2], |
| 1703 | card->dev->addr_len); |
| 1704 | else |
| 1705 | card->dev->header_ops->create(skb, card->dev, prot, |
| 1706 | tg_addr, "FAKELL", card->dev->addr_len); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1707 | } |
| 1708 | |
Paul Gortmaker | 1abd229 | 2012-05-10 15:50:52 -0400 | [diff] [blame] | 1709 | skb->protocol = eth_type_trans(skb, card->dev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1710 | |
Julian Wiedmann | d7aa9d0 | 2017-09-18 21:18:21 +0200 | [diff] [blame] | 1711 | /* copy VLAN tag from hdr into skb */ |
| 1712 | if (!card->options.sniffer && |
| 1713 | (hdr->hdr.l3.ext_flags & (QETH_HDR_EXT_VLAN_FRAME | |
| 1714 | QETH_HDR_EXT_INCLUDE_VLAN_TAG))) { |
| 1715 | u16 tag = (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_VLAN_FRAME) ? |
| 1716 | hdr->hdr.l3.vlan_id : |
| 1717 | *((u16 *)&hdr->hdr.l3.dest_addr[12]); |
| 1718 | __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), tag); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1719 | } |
| 1720 | |
Frank Blaschka | c5e631a | 2011-05-12 18:45:01 +0000 | [diff] [blame] | 1721 | if (card->dev->features & NETIF_F_RXCSUM) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1722 | if ((hdr->hdr.l3.ext_flags & |
Ursula Braun | b913980 | 2009-05-19 21:38:40 +0000 | [diff] [blame] | 1723 | (QETH_HDR_EXT_CSUM_HDR_REQ | |
| 1724 | QETH_HDR_EXT_CSUM_TRANSP_REQ)) == |
| 1725 | (QETH_HDR_EXT_CSUM_HDR_REQ | |
| 1726 | QETH_HDR_EXT_CSUM_TRANSP_REQ)) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1727 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 1728 | else |
Ursula Braun | b913980 | 2009-05-19 21:38:40 +0000 | [diff] [blame] | 1729 | skb->ip_summed = CHECKSUM_NONE; |
Frank Blaschka | c5e631a | 2011-05-12 18:45:01 +0000 | [diff] [blame] | 1730 | } else |
| 1731 | skb->ip_summed = CHECKSUM_NONE; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1732 | } |
| 1733 | |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 1734 | static int qeth_l3_process_inbound_buffer(struct qeth_card *card, |
| 1735 | int budget, int *done) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1736 | { |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 1737 | int work_done = 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1738 | struct sk_buff *skb; |
| 1739 | struct qeth_hdr *hdr; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1740 | unsigned int len; |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 1741 | __u16 magic; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1742 | |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 1743 | *done = 0; |
Stefan Raspl | 18af5c1 | 2012-11-19 02:46:50 +0000 | [diff] [blame] | 1744 | WARN_ON_ONCE(!budget); |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 1745 | while (budget) { |
| 1746 | skb = qeth_core_get_next_skb(card, |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 1747 | &card->qdio.in_q->bufs[card->rx.b_index], |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 1748 | &card->rx.b_element, &card->rx.e_offset, &hdr); |
| 1749 | if (!skb) { |
| 1750 | *done = 1; |
| 1751 | break; |
| 1752 | } |
| 1753 | skb->dev = card->dev; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1754 | switch (hdr->hdr.l3.id) { |
| 1755 | case QETH_HEADER_TYPE_LAYER3: |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 1756 | magic = *(__u16 *)skb->data; |
| 1757 | if ((card->info.type == QETH_CARD_TYPE_IQD) && |
| 1758 | (magic == ETH_P_AF_IUCV)) { |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 1759 | skb->protocol = cpu_to_be16(ETH_P_AF_IUCV); |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 1760 | skb->pkt_type = PACKET_HOST; |
| 1761 | skb->mac_header = NET_SKB_PAD; |
| 1762 | skb->dev = card->dev; |
| 1763 | len = skb->len; |
| 1764 | card->dev->header_ops->create(skb, card->dev, 0, |
| 1765 | card->dev->dev_addr, "FAKELL", |
| 1766 | card->dev->addr_len); |
| 1767 | netif_receive_skb(skb); |
| 1768 | } else { |
Julian Wiedmann | d7aa9d0 | 2017-09-18 21:18:21 +0200 | [diff] [blame] | 1769 | qeth_l3_rebuild_skb(card, skb, hdr); |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 1770 | len = skb->len; |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 1771 | napi_gro_receive(&card->napi, skb); |
| 1772 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1773 | break; |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1774 | case QETH_HEADER_TYPE_LAYER2: /* for HiperSockets sniffer */ |
| 1775 | skb->pkt_type = PACKET_HOST; |
| 1776 | skb->protocol = eth_type_trans(skb, skb->dev); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1777 | len = skb->len; |
| 1778 | netif_receive_skb(skb); |
| 1779 | break; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1780 | default: |
| 1781 | dev_kfree_skb_any(skb); |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1782 | QETH_CARD_TEXT(card, 3, "inbunkno"); |
Peter Tiedemann | d11ba0c | 2008-04-01 10:26:58 +0200 | [diff] [blame] | 1783 | QETH_DBF_HEX(CTRL, 3, hdr, QETH_DBF_CTRL_LEN); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1784 | continue; |
| 1785 | } |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 1786 | work_done++; |
| 1787 | budget--; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1788 | card->stats.rx_packets++; |
| 1789 | card->stats.rx_bytes += len; |
| 1790 | } |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 1791 | return work_done; |
| 1792 | } |
| 1793 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1794 | static int qeth_l3_verify_vlan_dev(struct net_device *dev, |
| 1795 | struct qeth_card *card) |
| 1796 | { |
| 1797 | int rc = 0; |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1798 | u16 vid; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1799 | |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1800 | for_each_set_bit(vid, card->active_vlans, VLAN_N_VID) { |
| 1801 | struct net_device *netdev; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1802 | |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1803 | rcu_read_lock(); |
dingtianhong | f06c7f9f | 2014-05-09 14:58:05 +0800 | [diff] [blame] | 1804 | netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), |
Patrick McHardy | 91b1c1a | 2013-04-21 00:09:34 +0000 | [diff] [blame] | 1805 | vid); |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 1806 | rcu_read_unlock(); |
| 1807 | if (netdev == dev) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1808 | rc = QETH_VLAN_CARD; |
| 1809 | break; |
| 1810 | } |
| 1811 | } |
| 1812 | |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 1813 | if (rc && !(vlan_dev_real_dev(dev)->ml_priv == (void *)card)) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1814 | return 0; |
| 1815 | |
| 1816 | return rc; |
| 1817 | } |
| 1818 | |
| 1819 | static int qeth_l3_verify_dev(struct net_device *dev) |
| 1820 | { |
| 1821 | struct qeth_card *card; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1822 | int rc = 0; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1823 | unsigned long flags; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1824 | |
| 1825 | read_lock_irqsave(&qeth_core_card_list.rwlock, flags); |
| 1826 | list_for_each_entry(card, &qeth_core_card_list.list, list) { |
| 1827 | if (card->dev == dev) { |
| 1828 | rc = QETH_REAL_CARD; |
| 1829 | break; |
| 1830 | } |
| 1831 | rc = qeth_l3_verify_vlan_dev(dev, card); |
| 1832 | if (rc) |
| 1833 | break; |
| 1834 | } |
| 1835 | read_unlock_irqrestore(&qeth_core_card_list.rwlock, flags); |
| 1836 | |
| 1837 | return rc; |
| 1838 | } |
| 1839 | |
| 1840 | static struct qeth_card *qeth_l3_get_card_from_dev(struct net_device *dev) |
| 1841 | { |
| 1842 | struct qeth_card *card = NULL; |
| 1843 | int rc; |
| 1844 | |
| 1845 | rc = qeth_l3_verify_dev(dev); |
| 1846 | if (rc == QETH_REAL_CARD) |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 1847 | card = dev->ml_priv; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1848 | else if (rc == QETH_VLAN_CARD) |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 1849 | card = vlan_dev_real_dev(dev)->ml_priv; |
Frank Blaschka | e5bd7be | 2008-06-06 12:37:44 +0200 | [diff] [blame] | 1850 | if (card && card->options.layer2) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1851 | card = NULL; |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1852 | if (card) |
| 1853 | QETH_CARD_TEXT_(card, 4, "%d", rc); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1854 | return card ; |
| 1855 | } |
| 1856 | |
Peter Senna Tschudin | b2f4de8 | 2015-08-04 17:11:47 +0200 | [diff] [blame] | 1857 | static void qeth_l3_stop_card(struct qeth_card *card, int recovery_mode) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1858 | { |
Peter Tiedemann | d11ba0c | 2008-04-01 10:26:58 +0200 | [diff] [blame] | 1859 | QETH_DBF_TEXT(SETUP, 2, "stopcard"); |
| 1860 | QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1861 | |
| 1862 | qeth_set_allowed_threads(card, 0, 1); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1863 | if (card->options.sniffer && |
| 1864 | (card->info.promisc_mode == SET_PROMISC_MODE_ON)) |
| 1865 | qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_DISABLE); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1866 | if (card->read.state == CH_STATE_UP && |
| 1867 | card->write.state == CH_STATE_UP && |
| 1868 | (card->state == CARD_STATE_UP)) { |
| 1869 | if (recovery_mode) |
| 1870 | qeth_l3_stop(card->dev); |
Frank Blaschka | 8af7c5a | 2008-04-24 10:15:25 +0200 | [diff] [blame] | 1871 | else { |
Ursula Braun | 869da90 | 2010-03-08 20:36:56 +0000 | [diff] [blame] | 1872 | rtnl_lock(); |
| 1873 | dev_close(card->dev); |
| 1874 | rtnl_unlock(); |
Frank Blaschka | 8af7c5a | 2008-04-24 10:15:25 +0200 | [diff] [blame] | 1875 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1876 | card->state = CARD_STATE_SOFTSETUP; |
| 1877 | } |
| 1878 | if (card->state == CARD_STATE_SOFTSETUP) { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1879 | qeth_l3_clear_ip_htable(card, 1); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1880 | qeth_clear_ipacmd_list(card); |
| 1881 | card->state = CARD_STATE_HARDSETUP; |
| 1882 | } |
| 1883 | if (card->state == CARD_STATE_HARDSETUP) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1884 | qeth_qdio_clear_card(card, 0); |
| 1885 | qeth_clear_qdio_buffers(card); |
| 1886 | qeth_clear_working_pool_list(card); |
| 1887 | card->state = CARD_STATE_DOWN; |
| 1888 | } |
| 1889 | if (card->state == CARD_STATE_DOWN) { |
| 1890 | qeth_clear_cmd_buffers(&card->read); |
| 1891 | qeth_clear_cmd_buffers(&card->write); |
| 1892 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1893 | } |
| 1894 | |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1895 | /* |
| 1896 | * test for and Switch promiscuous mode (on or off) |
| 1897 | * either for guestlan or HiperSocket Sniffer |
| 1898 | */ |
| 1899 | static void |
| 1900 | qeth_l3_handle_promisc_mode(struct qeth_card *card) |
| 1901 | { |
| 1902 | struct net_device *dev = card->dev; |
| 1903 | |
| 1904 | if (((dev->flags & IFF_PROMISC) && |
| 1905 | (card->info.promisc_mode == SET_PROMISC_MODE_ON)) || |
| 1906 | (!(dev->flags & IFF_PROMISC) && |
| 1907 | (card->info.promisc_mode == SET_PROMISC_MODE_OFF))) |
| 1908 | return; |
| 1909 | |
| 1910 | if (card->info.guestlan) { /* Guestlan trace */ |
| 1911 | if (qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) |
| 1912 | qeth_setadp_promisc_mode(card); |
| 1913 | } else if (card->options.sniffer && /* HiperSockets trace */ |
| 1914 | qeth_adp_supported(card, IPA_SETADP_SET_DIAG_ASSIST)) { |
| 1915 | if (dev->flags & IFF_PROMISC) { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1916 | QETH_CARD_TEXT(card, 3, "+promisc"); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1917 | qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_ENABLE); |
| 1918 | } else { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1919 | QETH_CARD_TEXT(card, 3, "-promisc"); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1920 | qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_DISABLE); |
| 1921 | } |
| 1922 | } |
| 1923 | } |
| 1924 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1925 | static void qeth_l3_set_multicast_list(struct net_device *dev) |
| 1926 | { |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 1927 | struct qeth_card *card = dev->ml_priv; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1928 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1929 | QETH_CARD_TEXT(card, 3, "setmulti"); |
Ursula Braun | 8e98ac4 | 2009-03-24 20:57:18 +0000 | [diff] [blame] | 1930 | if (qeth_threads_running(card, QETH_RECOVER_THREAD) && |
| 1931 | (card->state != CARD_STATE_UP)) |
| 1932 | return; |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1933 | if (!card->options.sniffer) { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1934 | |
| 1935 | spin_lock_bh(&card->mclock); |
| 1936 | |
| 1937 | qeth_l3_mark_all_mc_to_be_deleted(card); |
| 1938 | |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1939 | qeth_l3_add_multicast_ipv4(card); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1940 | #ifdef CONFIG_QETH_IPV6 |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1941 | qeth_l3_add_multicast_ipv6(card); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1942 | #endif |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 1943 | qeth_l3_delete_nonused_mc(card); |
| 1944 | qeth_l3_add_all_new_mc(card); |
| 1945 | |
| 1946 | spin_unlock_bh(&card->mclock); |
| 1947 | |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 1948 | if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) |
| 1949 | return; |
| 1950 | } |
| 1951 | qeth_l3_handle_promisc_mode(card); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1952 | } |
| 1953 | |
| 1954 | static const char *qeth_l3_arp_get_error_cause(int *rc) |
| 1955 | { |
| 1956 | switch (*rc) { |
| 1957 | case QETH_IPA_ARP_RC_FAILED: |
| 1958 | *rc = -EIO; |
| 1959 | return "operation failed"; |
| 1960 | case QETH_IPA_ARP_RC_NOTSUPP: |
| 1961 | *rc = -EOPNOTSUPP; |
| 1962 | return "operation not supported"; |
| 1963 | case QETH_IPA_ARP_RC_OUT_OF_RANGE: |
| 1964 | *rc = -EINVAL; |
| 1965 | return "argument out of range"; |
| 1966 | case QETH_IPA_ARP_RC_Q_NOTSUPP: |
| 1967 | *rc = -EOPNOTSUPP; |
| 1968 | return "query operation not supported"; |
| 1969 | case QETH_IPA_ARP_RC_Q_NO_DATA: |
| 1970 | *rc = -ENOENT; |
| 1971 | return "no query data available"; |
| 1972 | default: |
| 1973 | return "unknown error"; |
| 1974 | } |
| 1975 | } |
| 1976 | |
| 1977 | static int qeth_l3_arp_set_no_entries(struct qeth_card *card, int no_entries) |
| 1978 | { |
| 1979 | int tmp; |
| 1980 | int rc; |
| 1981 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 1982 | QETH_CARD_TEXT(card, 3, "arpstnoe"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1983 | |
| 1984 | /* |
| 1985 | * currently GuestLAN only supports the ARP assist function |
| 1986 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES; |
| 1987 | * thus we say EOPNOTSUPP for this ARP function |
| 1988 | */ |
| 1989 | if (card->info.guestlan) |
| 1990 | return -EOPNOTSUPP; |
| 1991 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1992 | return -EOPNOTSUPP; |
| 1993 | } |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 1994 | rc = qeth_send_simple_setassparms(card, IPA_ARP_PROCESSING, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1995 | IPA_CMD_ASS_ARP_SET_NO_ENTRIES, |
| 1996 | no_entries); |
| 1997 | if (rc) { |
| 1998 | tmp = rc; |
Frank Blaschka | 14cc21b | 2008-06-06 12:37:46 +0200 | [diff] [blame] | 1999 | QETH_DBF_MESSAGE(2, "Could not set number of ARP entries on " |
| 2000 | "%s: %s (0x%x/%d)\n", QETH_CARD_IFNAME(card), |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2001 | qeth_l3_arp_get_error_cause(&rc), tmp, tmp); |
| 2002 | } |
| 2003 | return rc; |
| 2004 | } |
| 2005 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2006 | static __u32 get_arp_entry_size(struct qeth_card *card, |
| 2007 | struct qeth_arp_query_data *qdata, |
| 2008 | struct qeth_arp_entrytype *type, __u8 strip_entries) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2009 | { |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2010 | __u32 rc; |
| 2011 | __u8 is_hsi; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2012 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2013 | is_hsi = qdata->reply_bits == 5; |
| 2014 | if (type->ip == QETHARP_IP_ADDR_V4) { |
| 2015 | QETH_CARD_TEXT(card, 4, "arpev4"); |
| 2016 | if (strip_entries) { |
| 2017 | rc = is_hsi ? sizeof(struct qeth_arp_qi_entry5_short) : |
| 2018 | sizeof(struct qeth_arp_qi_entry7_short); |
| 2019 | } else { |
| 2020 | rc = is_hsi ? sizeof(struct qeth_arp_qi_entry5) : |
| 2021 | sizeof(struct qeth_arp_qi_entry7); |
| 2022 | } |
| 2023 | } else if (type->ip == QETHARP_IP_ADDR_V6) { |
| 2024 | QETH_CARD_TEXT(card, 4, "arpev6"); |
| 2025 | if (strip_entries) { |
| 2026 | rc = is_hsi ? |
| 2027 | sizeof(struct qeth_arp_qi_entry5_short_ipv6) : |
| 2028 | sizeof(struct qeth_arp_qi_entry7_short_ipv6); |
| 2029 | } else { |
| 2030 | rc = is_hsi ? |
| 2031 | sizeof(struct qeth_arp_qi_entry5_ipv6) : |
| 2032 | sizeof(struct qeth_arp_qi_entry7_ipv6); |
| 2033 | } |
| 2034 | } else { |
| 2035 | QETH_CARD_TEXT(card, 4, "arpinv"); |
| 2036 | rc = 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2037 | } |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2038 | |
| 2039 | return rc; |
| 2040 | } |
| 2041 | |
| 2042 | static int arpentry_matches_prot(struct qeth_arp_entrytype *type, __u16 prot) |
| 2043 | { |
| 2044 | return (type->ip == QETHARP_IP_ADDR_V4 && prot == QETH_PROT_IPV4) || |
| 2045 | (type->ip == QETHARP_IP_ADDR_V6 && prot == QETH_PROT_IPV6); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2046 | } |
| 2047 | |
| 2048 | static int qeth_l3_arp_query_cb(struct qeth_card *card, |
| 2049 | struct qeth_reply *reply, unsigned long data) |
| 2050 | { |
| 2051 | struct qeth_ipa_cmd *cmd; |
| 2052 | struct qeth_arp_query_data *qdata; |
| 2053 | struct qeth_arp_query_info *qinfo; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2054 | int i; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2055 | int e; |
| 2056 | int entrybytes_done; |
| 2057 | int stripped_bytes; |
| 2058 | __u8 do_strip_entries; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2059 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2060 | QETH_CARD_TEXT(card, 3, "arpquecb"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2061 | |
| 2062 | qinfo = (struct qeth_arp_query_info *) reply->param; |
| 2063 | cmd = (struct qeth_ipa_cmd *) data; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2064 | QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.prot_version); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2065 | if (cmd->hdr.return_code) { |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2066 | QETH_CARD_TEXT(card, 4, "arpcberr"); |
| 2067 | QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.return_code); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2068 | return 0; |
| 2069 | } |
| 2070 | if (cmd->data.setassparms.hdr.return_code) { |
| 2071 | cmd->hdr.return_code = cmd->data.setassparms.hdr.return_code; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2072 | QETH_CARD_TEXT(card, 4, "setaperr"); |
| 2073 | QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.return_code); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2074 | return 0; |
| 2075 | } |
| 2076 | qdata = &cmd->data.setassparms.data.query_arp; |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 2077 | QETH_CARD_TEXT_(card, 4, "anoen%i", qdata->no_entries); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2078 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2079 | do_strip_entries = (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES) > 0; |
| 2080 | stripped_bytes = do_strip_entries ? QETH_QARP_MEDIASPECIFIC_BYTES : 0; |
| 2081 | entrybytes_done = 0; |
| 2082 | for (e = 0; e < qdata->no_entries; ++e) { |
| 2083 | char *cur_entry; |
| 2084 | __u32 esize; |
| 2085 | struct qeth_arp_entrytype *etype; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2086 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2087 | cur_entry = &qdata->data + entrybytes_done; |
| 2088 | etype = &((struct qeth_arp_qi_entry5 *) cur_entry)->type; |
| 2089 | if (!arpentry_matches_prot(etype, cmd->hdr.prot_version)) { |
| 2090 | QETH_CARD_TEXT(card, 4, "pmis"); |
| 2091 | QETH_CARD_TEXT_(card, 4, "%i", etype->ip); |
| 2092 | break; |
| 2093 | } |
| 2094 | esize = get_arp_entry_size(card, qdata, etype, |
| 2095 | do_strip_entries); |
| 2096 | QETH_CARD_TEXT_(card, 5, "esz%i", esize); |
| 2097 | if (!esize) |
| 2098 | break; |
| 2099 | |
| 2100 | if ((qinfo->udata_len - qinfo->udata_offset) < esize) { |
| 2101 | QETH_CARD_TEXT_(card, 4, "qaer3%i", -ENOMEM); |
Ursula Braun | e0a8114 | 2012-03-07 02:06:28 +0000 | [diff] [blame] | 2102 | cmd->hdr.return_code = IPA_RC_ENOMEM; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2103 | goto out_error; |
| 2104 | } |
| 2105 | |
| 2106 | memcpy(qinfo->udata + qinfo->udata_offset, |
| 2107 | &qdata->data + entrybytes_done + stripped_bytes, |
| 2108 | esize); |
| 2109 | entrybytes_done += esize + stripped_bytes; |
| 2110 | qinfo->udata_offset += esize; |
| 2111 | ++qinfo->no_entries; |
| 2112 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2113 | /* check if all replies received ... */ |
| 2114 | if (cmd->data.setassparms.hdr.seq_no < |
| 2115 | cmd->data.setassparms.hdr.number_of_replies) |
| 2116 | return 1; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2117 | QETH_CARD_TEXT_(card, 4, "nove%i", qinfo->no_entries); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2118 | memcpy(qinfo->udata, &qinfo->no_entries, 4); |
| 2119 | /* keep STRIP_ENTRIES flag so the user program can distinguish |
| 2120 | * stripped entries from normal ones */ |
| 2121 | if (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES) |
| 2122 | qdata->reply_bits |= QETH_QARP_STRIP_ENTRIES; |
| 2123 | memcpy(qinfo->udata + QETH_QARP_MASK_OFFSET, &qdata->reply_bits, 2); |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2124 | QETH_CARD_TEXT_(card, 4, "rc%i", 0); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2125 | return 0; |
| 2126 | out_error: |
| 2127 | i = 0; |
| 2128 | memcpy(qinfo->udata, &i, 4); |
| 2129 | return 0; |
| 2130 | } |
| 2131 | |
| 2132 | static int qeth_l3_send_ipa_arp_cmd(struct qeth_card *card, |
| 2133 | struct qeth_cmd_buffer *iob, int len, |
| 2134 | int (*reply_cb)(struct qeth_card *, struct qeth_reply *, |
| 2135 | unsigned long), |
| 2136 | void *reply_param) |
| 2137 | { |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 2138 | QETH_CARD_TEXT(card, 4, "sendarp"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2139 | |
| 2140 | memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE); |
| 2141 | memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data), |
| 2142 | &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH); |
| 2143 | return qeth_send_control_data(card, IPA_PDU_HEADER_SIZE + len, iob, |
| 2144 | reply_cb, reply_param); |
| 2145 | } |
| 2146 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2147 | static int qeth_l3_query_arp_cache_info(struct qeth_card *card, |
| 2148 | enum qeth_prot_versions prot, |
| 2149 | struct qeth_arp_query_info *qinfo) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2150 | { |
| 2151 | struct qeth_cmd_buffer *iob; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2152 | struct qeth_ipa_cmd *cmd; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2153 | int tmp; |
| 2154 | int rc; |
| 2155 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2156 | QETH_CARD_TEXT_(card, 3, "qarpipv%i", prot); |
| 2157 | |
Thomas Richter | b475e31 | 2015-12-11 12:27:54 +0100 | [diff] [blame] | 2158 | iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, |
| 2159 | IPA_CMD_ASS_ARP_QUERY_INFO, |
| 2160 | sizeof(struct qeth_arp_query_data) |
| 2161 | - sizeof(char), |
| 2162 | prot); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 2163 | if (!iob) |
| 2164 | return -ENOMEM; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2165 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); |
| 2166 | cmd->data.setassparms.data.query_arp.request_bits = 0x000F; |
| 2167 | cmd->data.setassparms.data.query_arp.reply_bits = 0; |
| 2168 | cmd->data.setassparms.data.query_arp.no_entries = 0; |
| 2169 | rc = qeth_l3_send_ipa_arp_cmd(card, iob, |
| 2170 | QETH_SETASS_BASE_LEN+QETH_ARP_CMD_LEN, |
| 2171 | qeth_l3_arp_query_cb, (void *)qinfo); |
| 2172 | if (rc) { |
| 2173 | tmp = rc; |
| 2174 | QETH_DBF_MESSAGE(2, |
| 2175 | "Error while querying ARP cache on %s: %s " |
| 2176 | "(0x%x/%d)\n", QETH_CARD_IFNAME(card), |
| 2177 | qeth_l3_arp_get_error_cause(&rc), tmp, tmp); |
| 2178 | } |
| 2179 | |
| 2180 | return rc; |
| 2181 | } |
| 2182 | |
| 2183 | static int qeth_l3_arp_query(struct qeth_card *card, char __user *udata) |
| 2184 | { |
| 2185 | struct qeth_arp_query_info qinfo = {0, }; |
| 2186 | int rc; |
| 2187 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 2188 | QETH_CARD_TEXT(card, 3, "arpquery"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2189 | |
| 2190 | if (!qeth_is_supported(card,/*IPA_QUERY_ARP_ADDR_INFO*/ |
| 2191 | IPA_ARP_PROCESSING)) { |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2192 | QETH_CARD_TEXT(card, 3, "arpqnsup"); |
| 2193 | rc = -EOPNOTSUPP; |
| 2194 | goto out; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2195 | } |
| 2196 | /* get size of userspace buffer and mask_bits -> 6 bytes */ |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2197 | if (copy_from_user(&qinfo, udata, 6)) { |
| 2198 | rc = -EFAULT; |
| 2199 | goto out; |
| 2200 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2201 | qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL); |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2202 | if (!qinfo.udata) { |
| 2203 | rc = -ENOMEM; |
| 2204 | goto out; |
| 2205 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2206 | qinfo.udata_offset = QETH_QARP_ENTRIES_OFFSET; |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2207 | rc = qeth_l3_query_arp_cache_info(card, QETH_PROT_IPV4, &qinfo); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2208 | if (rc) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2209 | if (copy_to_user(udata, qinfo.udata, 4)) |
| 2210 | rc = -EFAULT; |
Sebastian Ott | 77a83ed | 2016-06-16 16:19:03 +0200 | [diff] [blame] | 2211 | goto free_and_out; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2212 | } |
Sebastian Ott | 77a83ed | 2016-06-16 16:19:03 +0200 | [diff] [blame] | 2213 | #ifdef CONFIG_QETH_IPV6 |
| 2214 | if (qinfo.mask_bits & QETH_QARP_WITH_IPV6) { |
| 2215 | /* fails in case of GuestLAN QDIO mode */ |
| 2216 | qeth_l3_query_arp_cache_info(card, QETH_PROT_IPV6, &qinfo); |
| 2217 | } |
| 2218 | #endif |
| 2219 | if (copy_to_user(udata, qinfo.udata, qinfo.udata_len)) { |
| 2220 | QETH_CARD_TEXT(card, 4, "qactf"); |
| 2221 | rc = -EFAULT; |
| 2222 | goto free_and_out; |
| 2223 | } |
| 2224 | QETH_CARD_TEXT(card, 4, "qacts"); |
| 2225 | |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2226 | free_and_out: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2227 | kfree(qinfo.udata); |
Einar Lueck | d0ddf30f | 2010-12-08 02:57:58 +0000 | [diff] [blame] | 2228 | out: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2229 | return rc; |
| 2230 | } |
| 2231 | |
| 2232 | static int qeth_l3_arp_add_entry(struct qeth_card *card, |
| 2233 | struct qeth_arp_cache_entry *entry) |
| 2234 | { |
| 2235 | struct qeth_cmd_buffer *iob; |
| 2236 | char buf[16]; |
| 2237 | int tmp; |
| 2238 | int rc; |
| 2239 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 2240 | QETH_CARD_TEXT(card, 3, "arpadent"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2241 | |
| 2242 | /* |
| 2243 | * currently GuestLAN only supports the ARP assist function |
| 2244 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY; |
| 2245 | * thus we say EOPNOTSUPP for this ARP function |
| 2246 | */ |
| 2247 | if (card->info.guestlan) |
| 2248 | return -EOPNOTSUPP; |
| 2249 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2250 | return -EOPNOTSUPP; |
| 2251 | } |
| 2252 | |
Thomas Richter | b475e31 | 2015-12-11 12:27:54 +0100 | [diff] [blame] | 2253 | iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2254 | IPA_CMD_ASS_ARP_ADD_ENTRY, |
| 2255 | sizeof(struct qeth_arp_cache_entry), |
| 2256 | QETH_PROT_IPV4); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 2257 | if (!iob) |
| 2258 | return -ENOMEM; |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 2259 | rc = qeth_send_setassparms(card, iob, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2260 | sizeof(struct qeth_arp_cache_entry), |
| 2261 | (unsigned long) entry, |
Thomas Richter | 8f43fb0 | 2016-06-16 16:18:59 +0200 | [diff] [blame] | 2262 | qeth_setassparms_cb, NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2263 | if (rc) { |
| 2264 | tmp = rc; |
| 2265 | qeth_l3_ipaddr4_to_string((u8 *)entry->ipaddr, buf); |
Frank Blaschka | 14cc21b | 2008-06-06 12:37:46 +0200 | [diff] [blame] | 2266 | QETH_DBF_MESSAGE(2, "Could not add ARP entry for address %s " |
| 2267 | "on %s: %s (0x%x/%d)\n", buf, QETH_CARD_IFNAME(card), |
| 2268 | qeth_l3_arp_get_error_cause(&rc), tmp, tmp); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2269 | } |
| 2270 | return rc; |
| 2271 | } |
| 2272 | |
| 2273 | static int qeth_l3_arp_remove_entry(struct qeth_card *card, |
| 2274 | struct qeth_arp_cache_entry *entry) |
| 2275 | { |
| 2276 | struct qeth_cmd_buffer *iob; |
| 2277 | char buf[16] = {0, }; |
| 2278 | int tmp; |
| 2279 | int rc; |
| 2280 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 2281 | QETH_CARD_TEXT(card, 3, "arprment"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2282 | |
| 2283 | /* |
| 2284 | * currently GuestLAN only supports the ARP assist function |
| 2285 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_REMOVE_ENTRY; |
| 2286 | * thus we say EOPNOTSUPP for this ARP function |
| 2287 | */ |
| 2288 | if (card->info.guestlan) |
| 2289 | return -EOPNOTSUPP; |
| 2290 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2291 | return -EOPNOTSUPP; |
| 2292 | } |
| 2293 | memcpy(buf, entry, 12); |
Thomas Richter | b475e31 | 2015-12-11 12:27:54 +0100 | [diff] [blame] | 2294 | iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2295 | IPA_CMD_ASS_ARP_REMOVE_ENTRY, |
| 2296 | 12, |
| 2297 | QETH_PROT_IPV4); |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 2298 | if (!iob) |
| 2299 | return -ENOMEM; |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 2300 | rc = qeth_send_setassparms(card, iob, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2301 | 12, (unsigned long)buf, |
Thomas Richter | 8f43fb0 | 2016-06-16 16:18:59 +0200 | [diff] [blame] | 2302 | qeth_setassparms_cb, NULL); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2303 | if (rc) { |
| 2304 | tmp = rc; |
| 2305 | memset(buf, 0, 16); |
| 2306 | qeth_l3_ipaddr4_to_string((u8 *)entry->ipaddr, buf); |
Frank Blaschka | 14cc21b | 2008-06-06 12:37:46 +0200 | [diff] [blame] | 2307 | QETH_DBF_MESSAGE(2, "Could not delete ARP entry for address %s" |
| 2308 | " on %s: %s (0x%x/%d)\n", buf, QETH_CARD_IFNAME(card), |
| 2309 | qeth_l3_arp_get_error_cause(&rc), tmp, tmp); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2310 | } |
| 2311 | return rc; |
| 2312 | } |
| 2313 | |
| 2314 | static int qeth_l3_arp_flush_cache(struct qeth_card *card) |
| 2315 | { |
| 2316 | int rc; |
| 2317 | int tmp; |
| 2318 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 2319 | QETH_CARD_TEXT(card, 3, "arpflush"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2320 | |
| 2321 | /* |
| 2322 | * currently GuestLAN only supports the ARP assist function |
| 2323 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE; |
| 2324 | * thus we say EOPNOTSUPP for this ARP function |
| 2325 | */ |
| 2326 | if (card->info.guestlan || (card->info.type == QETH_CARD_TYPE_IQD)) |
| 2327 | return -EOPNOTSUPP; |
| 2328 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2329 | return -EOPNOTSUPP; |
| 2330 | } |
Thomas Richter | 4d7def2 | 2015-09-18 16:06:51 +0200 | [diff] [blame] | 2331 | rc = qeth_send_simple_setassparms(card, IPA_ARP_PROCESSING, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2332 | IPA_CMD_ASS_ARP_FLUSH_CACHE, 0); |
| 2333 | if (rc) { |
| 2334 | tmp = rc; |
Frank Blaschka | 14cc21b | 2008-06-06 12:37:46 +0200 | [diff] [blame] | 2335 | QETH_DBF_MESSAGE(2, "Could not flush ARP cache on %s: %s " |
| 2336 | "(0x%x/%d)\n", QETH_CARD_IFNAME(card), |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2337 | qeth_l3_arp_get_error_cause(&rc), tmp, tmp); |
| 2338 | } |
| 2339 | return rc; |
| 2340 | } |
| 2341 | |
| 2342 | static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
| 2343 | { |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 2344 | struct qeth_card *card = dev->ml_priv; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2345 | struct qeth_arp_cache_entry arp_entry; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2346 | int rc = 0; |
| 2347 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2348 | switch (cmd) { |
| 2349 | case SIOC_QETH_ARP_SET_NO_ENTRIES: |
| 2350 | if (!capable(CAP_NET_ADMIN)) { |
| 2351 | rc = -EPERM; |
| 2352 | break; |
| 2353 | } |
| 2354 | rc = qeth_l3_arp_set_no_entries(card, rq->ifr_ifru.ifru_ivalue); |
| 2355 | break; |
| 2356 | case SIOC_QETH_ARP_QUERY_INFO: |
| 2357 | if (!capable(CAP_NET_ADMIN)) { |
| 2358 | rc = -EPERM; |
| 2359 | break; |
| 2360 | } |
| 2361 | rc = qeth_l3_arp_query(card, rq->ifr_ifru.ifru_data); |
| 2362 | break; |
| 2363 | case SIOC_QETH_ARP_ADD_ENTRY: |
| 2364 | if (!capable(CAP_NET_ADMIN)) { |
| 2365 | rc = -EPERM; |
| 2366 | break; |
| 2367 | } |
| 2368 | if (copy_from_user(&arp_entry, rq->ifr_ifru.ifru_data, |
| 2369 | sizeof(struct qeth_arp_cache_entry))) |
| 2370 | rc = -EFAULT; |
| 2371 | else |
| 2372 | rc = qeth_l3_arp_add_entry(card, &arp_entry); |
| 2373 | break; |
| 2374 | case SIOC_QETH_ARP_REMOVE_ENTRY: |
| 2375 | if (!capable(CAP_NET_ADMIN)) { |
| 2376 | rc = -EPERM; |
| 2377 | break; |
| 2378 | } |
| 2379 | if (copy_from_user(&arp_entry, rq->ifr_ifru.ifru_data, |
| 2380 | sizeof(struct qeth_arp_cache_entry))) |
| 2381 | rc = -EFAULT; |
| 2382 | else |
| 2383 | rc = qeth_l3_arp_remove_entry(card, &arp_entry); |
| 2384 | break; |
| 2385 | case SIOC_QETH_ARP_FLUSH_CACHE: |
| 2386 | if (!capable(CAP_NET_ADMIN)) { |
| 2387 | rc = -EPERM; |
| 2388 | break; |
| 2389 | } |
| 2390 | rc = qeth_l3_arp_flush_cache(card); |
| 2391 | break; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2392 | default: |
| 2393 | rc = -EOPNOTSUPP; |
| 2394 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2395 | return rc; |
| 2396 | } |
| 2397 | |
Julian Wiedmann | cef6ff22 | 2017-08-15 17:02:46 +0200 | [diff] [blame] | 2398 | static int qeth_l3_get_cast_type(struct qeth_card *card, struct sk_buff *skb) |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 2399 | { |
| 2400 | int cast_type = RTN_UNSPEC; |
David S. Miller | 69cce1d | 2011-07-17 23:09:49 -0700 | [diff] [blame] | 2401 | struct neighbour *n = NULL; |
| 2402 | struct dst_entry *dst; |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 2403 | |
Frank Blaschka | 1d36cb4 | 2011-11-15 02:31:15 +0000 | [diff] [blame] | 2404 | rcu_read_lock(); |
David S. Miller | 69cce1d | 2011-07-17 23:09:49 -0700 | [diff] [blame] | 2405 | dst = skb_dst(skb); |
| 2406 | if (dst) |
David S. Miller | 24db1ba | 2012-07-02 22:02:33 -0700 | [diff] [blame] | 2407 | n = dst_neigh_lookup_skb(dst, skb); |
David S. Miller | 69cce1d | 2011-07-17 23:09:49 -0700 | [diff] [blame] | 2408 | if (n) { |
| 2409 | cast_type = n->type; |
Frank Blaschka | 1d36cb4 | 2011-11-15 02:31:15 +0000 | [diff] [blame] | 2410 | rcu_read_unlock(); |
David S. Miller | 24db1ba | 2012-07-02 22:02:33 -0700 | [diff] [blame] | 2411 | neigh_release(n); |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 2412 | if ((cast_type == RTN_BROADCAST) || |
| 2413 | (cast_type == RTN_MULTICAST) || |
| 2414 | (cast_type == RTN_ANYCAST)) |
| 2415 | return cast_type; |
| 2416 | else |
| 2417 | return RTN_UNSPEC; |
| 2418 | } |
Frank Blaschka | 1d36cb4 | 2011-11-15 02:31:15 +0000 | [diff] [blame] | 2419 | rcu_read_unlock(); |
| 2420 | |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 2421 | /* try something else */ |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 2422 | if (be16_to_cpu(skb->protocol) == ETH_P_IPV6) |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 2423 | return (skb_network_header(skb)[24] == 0xff) ? |
| 2424 | RTN_MULTICAST : 0; |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 2425 | else if (be16_to_cpu(skb->protocol) == ETH_P_IP) |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 2426 | return ((skb_network_header(skb)[16] & 0xf0) == 0xe0) ? |
| 2427 | RTN_MULTICAST : 0; |
| 2428 | /* ... */ |
| 2429 | if (!memcmp(skb->data, skb->dev->broadcast, 6)) |
| 2430 | return RTN_BROADCAST; |
| 2431 | else { |
| 2432 | u16 hdr_mac; |
| 2433 | |
| 2434 | hdr_mac = *((u16 *)skb->data); |
| 2435 | /* tr multicast? */ |
| 2436 | switch (card->info.link_type) { |
| 2437 | case QETH_LINK_TYPE_HSTR: |
| 2438 | case QETH_LINK_TYPE_LANE_TR: |
| 2439 | if ((hdr_mac == QETH_TR_MAC_NC) || |
| 2440 | (hdr_mac == QETH_TR_MAC_C)) |
| 2441 | return RTN_MULTICAST; |
| 2442 | break; |
| 2443 | /* eth or so multicast? */ |
| 2444 | default: |
| 2445 | if ((hdr_mac == QETH_ETH_MAC_V4) || |
| 2446 | (hdr_mac == QETH_ETH_MAC_V6)) |
| 2447 | return RTN_MULTICAST; |
| 2448 | } |
| 2449 | } |
| 2450 | return cast_type; |
| 2451 | } |
| 2452 | |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 2453 | static void qeth_l3_fill_af_iucv_hdr(struct qeth_card *card, |
| 2454 | struct qeth_hdr *hdr, struct sk_buff *skb) |
| 2455 | { |
| 2456 | char daddr[16]; |
| 2457 | struct af_iucv_trans_hdr *iucv_hdr; |
| 2458 | |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 2459 | memset(hdr, 0, sizeof(struct qeth_hdr)); |
| 2460 | hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3; |
| 2461 | hdr->hdr.l3.ext_flags = 0; |
Julian Wiedmann | acd9776 | 2017-03-23 14:55:09 +0100 | [diff] [blame] | 2462 | hdr->hdr.l3.length = skb->len - ETH_HLEN; |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 2463 | hdr->hdr.l3.flags = QETH_HDR_IPV6 | QETH_CAST_UNICAST; |
Julian Wiedmann | acd9776 | 2017-03-23 14:55:09 +0100 | [diff] [blame] | 2464 | |
| 2465 | iucv_hdr = (struct af_iucv_trans_hdr *) (skb->data + ETH_HLEN); |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 2466 | memset(daddr, 0, sizeof(daddr)); |
| 2467 | daddr[0] = 0xfe; |
| 2468 | daddr[1] = 0x80; |
| 2469 | memcpy(&daddr[8], iucv_hdr->destUserID, 8); |
| 2470 | memcpy(hdr->hdr.l3.dest_addr, daddr, 16); |
| 2471 | } |
| 2472 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2473 | static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, |
| 2474 | struct sk_buff *skb, int ipv, int cast_type) |
| 2475 | { |
David S. Miller | 69cce1d | 2011-07-17 23:09:49 -0700 | [diff] [blame] | 2476 | struct dst_entry *dst; |
| 2477 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2478 | memset(hdr, 0, sizeof(struct qeth_hdr)); |
| 2479 | hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3; |
| 2480 | hdr->hdr.l3.ext_flags = 0; |
| 2481 | |
| 2482 | /* |
| 2483 | * before we're going to overwrite this location with next hop ip. |
| 2484 | * v6 uses passthrough, v4 sets the tag in the QDIO header. |
| 2485 | */ |
Jiri Pirko | df8a39d | 2015-01-13 17:13:44 +0100 | [diff] [blame] | 2486 | if (skb_vlan_tag_present(skb)) { |
Frank Blaschka | 213298f | 2008-04-24 10:15:22 +0200 | [diff] [blame] | 2487 | if ((ipv == 4) || (card->info.type == QETH_CARD_TYPE_IQD)) |
| 2488 | hdr->hdr.l3.ext_flags = QETH_HDR_EXT_VLAN_FRAME; |
| 2489 | else |
| 2490 | hdr->hdr.l3.ext_flags = QETH_HDR_EXT_INCLUDE_VLAN_TAG; |
Jiri Pirko | df8a39d | 2015-01-13 17:13:44 +0100 | [diff] [blame] | 2491 | hdr->hdr.l3.vlan_id = skb_vlan_tag_get(skb); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2492 | } |
| 2493 | |
| 2494 | hdr->hdr.l3.length = skb->len - sizeof(struct qeth_hdr); |
Frank Blaschka | 1d36cb4 | 2011-11-15 02:31:15 +0000 | [diff] [blame] | 2495 | |
| 2496 | rcu_read_lock(); |
David S. Miller | 69cce1d | 2011-07-17 23:09:49 -0700 | [diff] [blame] | 2497 | dst = skb_dst(skb); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2498 | if (ipv == 4) { |
David Miller | 87e7597 | 2012-02-01 10:49:17 +0000 | [diff] [blame] | 2499 | struct rtable *rt = (struct rtable *) dst; |
| 2500 | __be32 *pkey = &ip_hdr(skb)->daddr; |
| 2501 | |
Julian Wiedmann | ec2c672 | 2017-08-07 13:28:39 +0200 | [diff] [blame] | 2502 | if (rt && rt->rt_gateway) |
David Miller | 87e7597 | 2012-02-01 10:49:17 +0000 | [diff] [blame] | 2503 | pkey = &rt->rt_gateway; |
| 2504 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2505 | /* IPv4 */ |
| 2506 | hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags4(cast_type); |
| 2507 | memset(hdr->hdr.l3.dest_addr, 0, 12); |
David Miller | 87e7597 | 2012-02-01 10:49:17 +0000 | [diff] [blame] | 2508 | *((__be32 *) (&hdr->hdr.l3.dest_addr[12])) = *pkey; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2509 | } else if (ipv == 6) { |
David Miller | 87e7597 | 2012-02-01 10:49:17 +0000 | [diff] [blame] | 2510 | struct rt6_info *rt = (struct rt6_info *) dst; |
| 2511 | struct in6_addr *pkey = &ipv6_hdr(skb)->daddr; |
| 2512 | |
Julian Wiedmann | ec2c672 | 2017-08-07 13:28:39 +0200 | [diff] [blame] | 2513 | if (rt && !ipv6_addr_any(&rt->rt6i_gateway)) |
David Miller | 87e7597 | 2012-02-01 10:49:17 +0000 | [diff] [blame] | 2514 | pkey = &rt->rt6i_gateway; |
| 2515 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2516 | /* IPv6 */ |
| 2517 | hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags6(cast_type); |
| 2518 | if (card->info.type == QETH_CARD_TYPE_IQD) |
| 2519 | hdr->hdr.l3.flags &= ~QETH_HDR_PASSTHRU; |
David Miller | 87e7597 | 2012-02-01 10:49:17 +0000 | [diff] [blame] | 2520 | memcpy(hdr->hdr.l3.dest_addr, pkey, 16); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2521 | } else { |
Paul Gortmaker | 1abd229 | 2012-05-10 15:50:52 -0400 | [diff] [blame] | 2522 | if (!memcmp(skb->data + sizeof(struct qeth_hdr), |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2523 | skb->dev->broadcast, 6)) { |
| 2524 | /* broadcast? */ |
| 2525 | hdr->hdr.l3.flags = QETH_CAST_BROADCAST | |
| 2526 | QETH_HDR_PASSTHRU; |
| 2527 | } else { |
| 2528 | hdr->hdr.l3.flags = (cast_type == RTN_MULTICAST) ? |
| 2529 | QETH_CAST_MULTICAST | QETH_HDR_PASSTHRU : |
| 2530 | QETH_CAST_UNICAST | QETH_HDR_PASSTHRU; |
| 2531 | } |
| 2532 | } |
Frank Blaschka | 1d36cb4 | 2011-11-15 02:31:15 +0000 | [diff] [blame] | 2533 | rcu_read_unlock(); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2534 | } |
| 2535 | |
Julian Wiedmann | cef6ff22 | 2017-08-15 17:02:46 +0200 | [diff] [blame] | 2536 | static void qeth_l3_hdr_csum(struct qeth_card *card, struct qeth_hdr *hdr, |
| 2537 | struct sk_buff *skb) |
Frank Blaschka | f6b85b6 | 2010-05-11 19:34:45 +0000 | [diff] [blame] | 2538 | { |
| 2539 | struct iphdr *iph = ip_hdr(skb); |
| 2540 | |
| 2541 | /* tcph->check contains already the pseudo hdr checksum |
| 2542 | * so just set the header flags |
| 2543 | */ |
| 2544 | if (iph->protocol == IPPROTO_UDP) |
| 2545 | hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_UDP; |
Frank Blaschka | 16c0f93 | 2011-01-12 20:42:25 +0000 | [diff] [blame] | 2546 | hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_CSUM_TRANSP_REQ | |
| 2547 | QETH_HDR_EXT_CSUM_HDR_REQ; |
| 2548 | iph->check = 0; |
Frank Blaschka | f6b85b6 | 2010-05-11 19:34:45 +0000 | [diff] [blame] | 2549 | if (card->options.performance_stats) |
| 2550 | card->perf_stats.tx_csum++; |
| 2551 | } |
| 2552 | |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 2553 | static void qeth_tso_fill_header(struct qeth_card *card, |
| 2554 | struct qeth_hdr *qhdr, struct sk_buff *skb) |
| 2555 | { |
| 2556 | struct qeth_hdr_tso *hdr = (struct qeth_hdr_tso *)qhdr; |
| 2557 | struct tcphdr *tcph = tcp_hdr(skb); |
| 2558 | struct iphdr *iph = ip_hdr(skb); |
| 2559 | struct ipv6hdr *ip6h = ipv6_hdr(skb); |
| 2560 | |
| 2561 | /*fix header to TSO values ...*/ |
| 2562 | hdr->hdr.hdr.l3.id = QETH_HEADER_TYPE_TSO; |
Frank Blaschka | 8fa9208 | 2010-11-26 02:41:20 +0000 | [diff] [blame] | 2563 | hdr->hdr.hdr.l3.length = skb->len - sizeof(struct qeth_hdr_tso); |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 2564 | /*set values which are fix for the first approach ...*/ |
| 2565 | hdr->ext.hdr_tot_len = (__u16) sizeof(struct qeth_hdr_ext_tso); |
| 2566 | hdr->ext.imb_hdr_no = 1; |
| 2567 | hdr->ext.hdr_type = 1; |
| 2568 | hdr->ext.hdr_version = 1; |
| 2569 | hdr->ext.hdr_len = 28; |
| 2570 | /*insert non-fix values */ |
| 2571 | hdr->ext.mss = skb_shinfo(skb)->gso_size; |
Julian Wiedmann | f8eb493 | 2017-08-15 17:02:45 +0200 | [diff] [blame] | 2572 | hdr->ext.dg_hdr_len = (__u16)(ip_hdrlen(skb) + tcp_hdrlen(skb)); |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 2573 | hdr->ext.payload_len = (__u16)(skb->len - hdr->ext.dg_hdr_len - |
| 2574 | sizeof(struct qeth_hdr_tso)); |
| 2575 | tcph->check = 0; |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 2576 | if (be16_to_cpu(skb->protocol) == ETH_P_IPV6) { |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 2577 | ip6h->payload_len = 0; |
| 2578 | tcph->check = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, |
| 2579 | 0, IPPROTO_TCP, 0); |
| 2580 | } else { |
| 2581 | /*OSA want us to set these values ...*/ |
| 2582 | tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, |
| 2583 | 0, IPPROTO_TCP, 0); |
| 2584 | iph->tot_len = 0; |
| 2585 | iph->check = 0; |
| 2586 | } |
| 2587 | } |
| 2588 | |
Eugene Crosser | 2863c61 | 2016-06-16 16:18:52 +0200 | [diff] [blame] | 2589 | /** |
Eugene Crosser | 41aeed5 | 2016-06-16 16:18:53 +0200 | [diff] [blame] | 2590 | * qeth_l3_get_elements_no_tso() - find number of SBALEs for skb data for tso |
| 2591 | * @card: qeth card structure, to check max. elems. |
| 2592 | * @skb: SKB address |
| 2593 | * @extra_elems: extra elems needed, to check against max. |
Eugene Crosser | 2863c61 | 2016-06-16 16:18:52 +0200 | [diff] [blame] | 2594 | * |
| 2595 | * Returns the number of pages, and thus QDIO buffer elements, needed to cover |
| 2596 | * skb data, including linear part and fragments, but excluding TCP header. |
| 2597 | * (Exclusion of TCP header distinguishes it from qeth_get_elements_no().) |
| 2598 | * Checks if the result plus extra_elems fits under the limit for the card. |
| 2599 | * Returns 0 if it does not. |
| 2600 | * Note: extra_elems is not included in the returned result. |
| 2601 | */ |
Eugene Crosser | 41aeed5 | 2016-06-16 16:18:53 +0200 | [diff] [blame] | 2602 | static int qeth_l3_get_elements_no_tso(struct qeth_card *card, |
Eugene Crosser | 2863c61 | 2016-06-16 16:18:52 +0200 | [diff] [blame] | 2603 | struct sk_buff *skb, int extra_elems) |
Frank Blaschka | c3b4a74 | 2009-11-12 00:11:44 +0000 | [diff] [blame] | 2604 | { |
Eugene Crosser | 2863c61 | 2016-06-16 16:18:52 +0200 | [diff] [blame] | 2605 | addr_t tcpdptr = (addr_t)tcp_hdr(skb) + tcp_hdrlen(skb); |
| 2606 | int elements = qeth_get_elements_for_range( |
| 2607 | tcpdptr, |
| 2608 | (addr_t)skb->data + skb_headlen(skb)) + |
Thomas Richter | 8f43fb0 | 2016-06-16 16:18:59 +0200 | [diff] [blame] | 2609 | qeth_get_elements_for_frags(skb); |
Frank Blaschka | 271648b | 2013-03-18 20:04:44 +0000 | [diff] [blame] | 2610 | |
Eugene Crosser | 2863c61 | 2016-06-16 16:18:52 +0200 | [diff] [blame] | 2611 | if ((elements + extra_elems) > QETH_MAX_BUFFER_ELEMENTS(card)) { |
| 2612 | QETH_DBF_MESSAGE(2, |
| 2613 | "Invalid size of TSO IP packet (Number=%d / Length=%d). Discarded.\n", |
| 2614 | elements + extra_elems, skb->len); |
| 2615 | return 0; |
| 2616 | } |
Frank Blaschka | c3b4a74 | 2009-11-12 00:11:44 +0000 | [diff] [blame] | 2617 | return elements; |
| 2618 | } |
| 2619 | |
Julian Wiedmann | e38db6b | 2017-04-11 16:11:14 +0200 | [diff] [blame] | 2620 | static netdev_tx_t qeth_l3_hard_start_xmit(struct sk_buff *skb, |
| 2621 | struct net_device *dev) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2622 | { |
| 2623 | int rc; |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 2624 | __be16 *tag; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2625 | struct qeth_hdr *hdr = NULL; |
Eugene Crosser | 2863c61 | 2016-06-16 16:18:52 +0200 | [diff] [blame] | 2626 | int hdr_elements = 0; |
| 2627 | int elements; |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 2628 | struct qeth_card *card = dev->ml_priv; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2629 | struct sk_buff *new_skb = NULL; |
| 2630 | int ipv = qeth_get_ip_version(skb); |
Klaus-Dieter Wacker | ce73e10 | 2009-08-26 02:01:08 +0000 | [diff] [blame] | 2631 | int cast_type = qeth_l3_get_cast_type(card, skb); |
Stefan Raspl | 290b834 | 2014-04-28 10:05:08 +0200 | [diff] [blame] | 2632 | struct qeth_qdio_out_q *queue = |
| 2633 | card->qdio.out_qs[card->qdio.do_prio_queueing |
| 2634 | || (cast_type && card->info.is_multicast_different) ? |
| 2635 | qeth_get_priority_queue(card, skb, ipv, cast_type) : |
| 2636 | card->qdio.default_out_queue]; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2637 | int tx_bytes = skb->len; |
Julian Wiedmann | 13ddacb | 2017-08-18 10:19:06 +0200 | [diff] [blame] | 2638 | unsigned int hd_len = 0; |
Eugene Crosser | 41aeed5 | 2016-06-16 16:18:53 +0200 | [diff] [blame] | 2639 | bool use_tso; |
Frank Blaschka | 683d718 | 2008-08-01 16:39:13 +0200 | [diff] [blame] | 2640 | int data_offset = -1; |
Julian Wiedmann | 886e197 | 2017-08-15 17:02:39 +0200 | [diff] [blame] | 2641 | unsigned int nr_frags; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2642 | |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 2643 | if (((card->info.type == QETH_CARD_TYPE_IQD) && |
| 2644 | (((card->options.cq != QETH_CQ_ENABLED) && !ipv) || |
| 2645 | ((card->options.cq == QETH_CQ_ENABLED) && |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 2646 | (be16_to_cpu(skb->protocol) != ETH_P_AF_IUCV)))) || |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 2647 | card->options.sniffer) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2648 | goto tx_drop; |
| 2649 | |
| 2650 | if ((card->state != CARD_STATE_UP) || !card->lan_online) { |
| 2651 | card->stats.tx_carrier_errors++; |
| 2652 | goto tx_drop; |
| 2653 | } |
| 2654 | |
| 2655 | if ((cast_type == RTN_BROADCAST) && |
| 2656 | (card->info.broadcast_capable == 0)) |
| 2657 | goto tx_drop; |
| 2658 | |
| 2659 | if (card->options.performance_stats) { |
| 2660 | card->perf_stats.outbound_cnt++; |
| 2661 | card->perf_stats.outbound_start_time = qeth_get_micros(); |
| 2662 | } |
| 2663 | |
Eugene Crosser | 41aeed5 | 2016-06-16 16:18:53 +0200 | [diff] [blame] | 2664 | /* Ignore segment size from skb_is_gso(), 1 page is always used. */ |
| 2665 | use_tso = skb_is_gso(skb) && |
Julian Wiedmann | f8eb493 | 2017-08-15 17:02:45 +0200 | [diff] [blame] | 2666 | (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4); |
Frank Blaschka | 683d718 | 2008-08-01 16:39:13 +0200 | [diff] [blame] | 2667 | |
Julian Wiedmann | 94a9c98 | 2017-06-06 14:33:43 +0200 | [diff] [blame] | 2668 | if (card->info.type == QETH_CARD_TYPE_IQD) { |
Frank Blaschka | 683d718 | 2008-08-01 16:39:13 +0200 | [diff] [blame] | 2669 | new_skb = skb; |
Julian Wiedmann | acd9776 | 2017-03-23 14:55:09 +0100 | [diff] [blame] | 2670 | data_offset = ETH_HLEN; |
Julian Wiedmann | f158817 | 2017-08-18 10:19:08 +0200 | [diff] [blame] | 2671 | hd_len = sizeof(*hdr); |
Frank Blaschka | 683d718 | 2008-08-01 16:39:13 +0200 | [diff] [blame] | 2672 | hdr = kmem_cache_alloc(qeth_core_header_cache, GFP_ATOMIC); |
| 2673 | if (!hdr) |
| 2674 | goto tx_drop; |
Eugene Crosser | 2863c61 | 2016-06-16 16:18:52 +0200 | [diff] [blame] | 2675 | hdr_elements++; |
Frank Blaschka | 683d718 | 2008-08-01 16:39:13 +0200 | [diff] [blame] | 2676 | } else { |
| 2677 | /* create a clone with writeable headroom */ |
| 2678 | new_skb = skb_realloc_headroom(skb, sizeof(struct qeth_hdr_tso) |
| 2679 | + VLAN_HLEN); |
| 2680 | if (!new_skb) |
| 2681 | goto tx_drop; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2682 | |
Frank Blaschka | 21fde74 | 2010-03-08 20:36:54 +0000 | [diff] [blame] | 2683 | if (ipv == 4) { |
Paul Gortmaker | 1abd229 | 2012-05-10 15:50:52 -0400 | [diff] [blame] | 2684 | skb_pull(new_skb, ETH_HLEN); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2685 | } |
| 2686 | |
Jiri Pirko | df8a39d | 2015-01-13 17:13:44 +0100 | [diff] [blame] | 2687 | if (ipv != 4 && skb_vlan_tag_present(new_skb)) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2688 | skb_push(new_skb, VLAN_HLEN); |
| 2689 | skb_copy_to_linear_data(new_skb, new_skb->data + 4, 4); |
| 2690 | skb_copy_to_linear_data_offset(new_skb, 4, |
| 2691 | new_skb->data + 8, 4); |
| 2692 | skb_copy_to_linear_data_offset(new_skb, 8, |
| 2693 | new_skb->data + 12, 4); |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 2694 | tag = (__be16 *)(new_skb->data + 12); |
| 2695 | *tag = cpu_to_be16(ETH_P_8021Q); |
| 2696 | *(tag + 1) = cpu_to_be16(skb_vlan_tag_get(new_skb)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2697 | } |
| 2698 | } |
| 2699 | |
| 2700 | netif_stop_queue(dev); |
| 2701 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2702 | /* fix hardware limitation: as long as we do not have sbal |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 2703 | * chaining we can not send long frag lists |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2704 | */ |
Eugene Crosser | 41aeed5 | 2016-06-16 16:18:53 +0200 | [diff] [blame] | 2705 | if ((card->info.type != QETH_CARD_TYPE_IQD) && |
| 2706 | ((use_tso && !qeth_l3_get_elements_no_tso(card, new_skb, 1)) || |
Julian Wiedmann | 7d969d2 | 2017-03-23 14:55:08 +0100 | [diff] [blame] | 2707 | (!use_tso && !qeth_get_elements_no(card, new_skb, 0, 0)))) { |
Eugene Crosser | 6059c90 | 2016-06-16 16:18:57 +0200 | [diff] [blame] | 2708 | int lin_rc = skb_linearize(new_skb); |
| 2709 | |
| 2710 | if (card->options.performance_stats) { |
| 2711 | if (lin_rc) |
| 2712 | card->perf_stats.tx_linfail++; |
| 2713 | else |
| 2714 | card->perf_stats.tx_lin++; |
| 2715 | } |
| 2716 | if (lin_rc) |
Eugene Crosser | 41aeed5 | 2016-06-16 16:18:53 +0200 | [diff] [blame] | 2717 | goto tx_drop; |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 2718 | } |
Julian Wiedmann | 886e197 | 2017-08-15 17:02:39 +0200 | [diff] [blame] | 2719 | nr_frags = skb_shinfo(new_skb)->nr_frags; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2720 | |
Eugene Crosser | 41aeed5 | 2016-06-16 16:18:53 +0200 | [diff] [blame] | 2721 | if (use_tso) { |
Johannes Berg | d58ff35 | 2017-06-16 14:29:23 +0200 | [diff] [blame] | 2722 | hdr = skb_push(new_skb, sizeof(struct qeth_hdr_tso)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2723 | memset(hdr, 0, sizeof(struct qeth_hdr_tso)); |
| 2724 | qeth_l3_fill_header(card, hdr, new_skb, ipv, cast_type); |
| 2725 | qeth_tso_fill_header(card, hdr, new_skb); |
Eugene Crosser | 2863c61 | 2016-06-16 16:18:52 +0200 | [diff] [blame] | 2726 | hdr_elements++; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2727 | } else { |
Frank Blaschka | 683d718 | 2008-08-01 16:39:13 +0200 | [diff] [blame] | 2728 | if (data_offset < 0) { |
Johannes Berg | d58ff35 | 2017-06-16 14:29:23 +0200 | [diff] [blame] | 2729 | hdr = skb_push(new_skb, sizeof(struct qeth_hdr)); |
Frank Blaschka | 683d718 | 2008-08-01 16:39:13 +0200 | [diff] [blame] | 2730 | qeth_l3_fill_header(card, hdr, new_skb, ipv, |
| 2731 | cast_type); |
| 2732 | } else { |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 2733 | if (be16_to_cpu(new_skb->protocol) == ETH_P_AF_IUCV) |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 2734 | qeth_l3_fill_af_iucv_hdr(card, hdr, new_skb); |
| 2735 | else { |
| 2736 | qeth_l3_fill_header(card, hdr, new_skb, ipv, |
| 2737 | cast_type); |
| 2738 | hdr->hdr.l3.length = new_skb->len - data_offset; |
| 2739 | } |
Frank Blaschka | 683d718 | 2008-08-01 16:39:13 +0200 | [diff] [blame] | 2740 | } |
Frank Blaschka | f6b85b6 | 2010-05-11 19:34:45 +0000 | [diff] [blame] | 2741 | |
| 2742 | if (skb->ip_summed == CHECKSUM_PARTIAL) |
| 2743 | qeth_l3_hdr_csum(card, hdr, new_skb); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2744 | } |
| 2745 | |
Eugene Crosser | 41aeed5 | 2016-06-16 16:18:53 +0200 | [diff] [blame] | 2746 | elements = use_tso ? |
| 2747 | qeth_l3_get_elements_no_tso(card, new_skb, hdr_elements) : |
Julian Wiedmann | 7d969d2 | 2017-03-23 14:55:08 +0100 | [diff] [blame] | 2748 | qeth_get_elements_no(card, new_skb, hdr_elements, |
| 2749 | (data_offset > 0) ? data_offset : 0); |
Eugene Crosser | 2863c61 | 2016-06-16 16:18:52 +0200 | [diff] [blame] | 2750 | if (!elements) { |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 2751 | if (data_offset >= 0) |
| 2752 | kmem_cache_free(qeth_core_header_cache, hdr); |
| 2753 | goto tx_drop; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2754 | } |
Eugene Crosser | 2863c61 | 2016-06-16 16:18:52 +0200 | [diff] [blame] | 2755 | elements += hdr_elements; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2756 | |
Frank Blaschka | 51aa165 | 2010-06-21 22:57:10 +0000 | [diff] [blame] | 2757 | if (card->info.type != QETH_CARD_TYPE_IQD) { |
| 2758 | int len; |
Julian Wiedmann | 13ddacb | 2017-08-18 10:19:06 +0200 | [diff] [blame] | 2759 | if (use_tso) { |
| 2760 | hd_len = sizeof(struct qeth_hdr_tso) + |
| 2761 | ip_hdrlen(new_skb) + tcp_hdrlen(new_skb); |
| 2762 | len = hd_len; |
| 2763 | } else { |
Frank Blaschka | 51aa165 | 2010-06-21 22:57:10 +0000 | [diff] [blame] | 2764 | len = sizeof(struct qeth_hdr_layer3); |
Julian Wiedmann | 13ddacb | 2017-08-18 10:19:06 +0200 | [diff] [blame] | 2765 | } |
Frank Blaschka | 51aa165 | 2010-06-21 22:57:10 +0000 | [diff] [blame] | 2766 | |
Stefan Raspl | d4ae1f5 | 2013-04-22 01:12:29 +0000 | [diff] [blame] | 2767 | if (qeth_hdr_chk_and_bounce(new_skb, &hdr, len)) |
Frank Blaschka | 51aa165 | 2010-06-21 22:57:10 +0000 | [diff] [blame] | 2768 | goto tx_drop; |
Julian Wiedmann | 13ddacb | 2017-08-18 10:19:06 +0200 | [diff] [blame] | 2769 | rc = qeth_do_send_packet(card, queue, new_skb, hdr, hd_len, |
Julian Wiedmann | 9c3bfda | 2017-08-18 10:19:07 +0200 | [diff] [blame] | 2770 | hd_len, elements); |
Frank Blaschka | 51aa165 | 2010-06-21 22:57:10 +0000 | [diff] [blame] | 2771 | } else |
Julian Wiedmann | 7c2e9ba | 2017-09-18 21:18:18 +0200 | [diff] [blame] | 2772 | rc = qeth_do_send_packet_fast(queue, new_skb, hdr, data_offset, |
| 2773 | hd_len); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2774 | |
| 2775 | if (!rc) { |
| 2776 | card->stats.tx_packets++; |
| 2777 | card->stats.tx_bytes += tx_bytes; |
| 2778 | if (new_skb != skb) |
| 2779 | dev_kfree_skb_any(skb); |
| 2780 | if (card->options.performance_stats) { |
Eugene Crosser | 41aeed5 | 2016-06-16 16:18:53 +0200 | [diff] [blame] | 2781 | if (use_tso) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2782 | card->perf_stats.large_send_bytes += tx_bytes; |
| 2783 | card->perf_stats.large_send_cnt++; |
| 2784 | } |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 2785 | if (nr_frags) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2786 | card->perf_stats.sg_skbs_sent++; |
| 2787 | /* nr_frags + skb->data */ |
Frank Blaschka | 64ef895 | 2009-03-24 20:57:16 +0000 | [diff] [blame] | 2788 | card->perf_stats.sg_frags_sent += nr_frags + 1; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2789 | } |
| 2790 | } |
Patrick McHardy | ec634fe | 2009-07-05 19:23:38 -0700 | [diff] [blame] | 2791 | rc = NETDEV_TX_OK; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2792 | } else { |
Frank Blaschka | 683d718 | 2008-08-01 16:39:13 +0200 | [diff] [blame] | 2793 | if (data_offset >= 0) |
| 2794 | kmem_cache_free(qeth_core_header_cache, hdr); |
| 2795 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2796 | if (rc == -EBUSY) { |
| 2797 | if (new_skb != skb) |
| 2798 | dev_kfree_skb_any(new_skb); |
| 2799 | return NETDEV_TX_BUSY; |
| 2800 | } else |
| 2801 | goto tx_drop; |
| 2802 | } |
| 2803 | |
| 2804 | netif_wake_queue(dev); |
| 2805 | if (card->options.performance_stats) |
| 2806 | card->perf_stats.outbound_time += qeth_get_micros() - |
| 2807 | card->perf_stats.outbound_start_time; |
| 2808 | return rc; |
| 2809 | |
| 2810 | tx_drop: |
| 2811 | card->stats.tx_dropped++; |
| 2812 | card->stats.tx_errors++; |
| 2813 | if ((new_skb != skb) && new_skb) |
| 2814 | dev_kfree_skb_any(new_skb); |
| 2815 | dev_kfree_skb_any(skb); |
Frank Blaschka | d0ec0f5 | 2008-06-06 12:37:48 +0200 | [diff] [blame] | 2816 | netif_wake_queue(dev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2817 | return NETDEV_TX_OK; |
| 2818 | } |
| 2819 | |
Ursula Braun | 3942344 | 2011-01-12 20:42:24 +0000 | [diff] [blame] | 2820 | static int __qeth_l3_open(struct net_device *dev) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2821 | { |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 2822 | struct qeth_card *card = dev->ml_priv; |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 2823 | int rc = 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2824 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 2825 | QETH_CARD_TEXT(card, 4, "qethopen"); |
Ursula Braun | 3942344 | 2011-01-12 20:42:24 +0000 | [diff] [blame] | 2826 | if (card->state == CARD_STATE_UP) |
| 2827 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2828 | if (card->state != CARD_STATE_SOFTSETUP) |
| 2829 | return -ENODEV; |
| 2830 | card->data.state = CH_STATE_UP; |
| 2831 | card->state = CARD_STATE_UP; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2832 | netif_start_queue(dev); |
| 2833 | |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 2834 | if (qdio_stop_irq(card->data.ccwdev, 0) >= 0) { |
| 2835 | napi_enable(&card->napi); |
| 2836 | napi_schedule(&card->napi); |
| 2837 | } else |
| 2838 | rc = -EIO; |
| 2839 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2840 | } |
| 2841 | |
Ursula Braun | 3942344 | 2011-01-12 20:42:24 +0000 | [diff] [blame] | 2842 | static int qeth_l3_open(struct net_device *dev) |
| 2843 | { |
| 2844 | struct qeth_card *card = dev->ml_priv; |
| 2845 | |
| 2846 | QETH_CARD_TEXT(card, 5, "qethope_"); |
| 2847 | if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { |
| 2848 | QETH_CARD_TEXT(card, 3, "openREC"); |
| 2849 | return -ERESTARTSYS; |
| 2850 | } |
| 2851 | return __qeth_l3_open(dev); |
| 2852 | } |
| 2853 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2854 | static int qeth_l3_stop(struct net_device *dev) |
| 2855 | { |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 2856 | struct qeth_card *card = dev->ml_priv; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2857 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 2858 | QETH_CARD_TEXT(card, 4, "qethstop"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2859 | netif_tx_disable(dev); |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 2860 | if (card->state == CARD_STATE_UP) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2861 | card->state = CARD_STATE_SOFTSETUP; |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 2862 | napi_disable(&card->napi); |
| 2863 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2864 | return 0; |
| 2865 | } |
| 2866 | |
Stephen Hemminger | 0fc0b73 | 2009-09-02 01:03:33 -0700 | [diff] [blame] | 2867 | static const struct ethtool_ops qeth_l3_ethtool_ops = { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2868 | .get_link = ethtool_op_get_link, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2869 | .get_strings = qeth_core_get_strings, |
| 2870 | .get_ethtool_stats = qeth_core_get_ethtool_stats, |
Ben Hutchings | df8b4ec | 2009-10-01 11:24:32 +0000 | [diff] [blame] | 2871 | .get_sset_count = qeth_core_get_sset_count, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2872 | .get_drvinfo = qeth_core_get_drvinfo, |
Julian Wiedmann | 993e19c | 2017-04-11 16:11:17 +0200 | [diff] [blame] | 2873 | .get_link_ksettings = qeth_core_ethtool_get_link_ksettings, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2874 | }; |
| 2875 | |
| 2876 | /* |
| 2877 | * we need NOARP for IPv4 but we want neighbor solicitation for IPv6. Setting |
| 2878 | * NOARP on the netdevice is no option because it also turns off neighbor |
| 2879 | * solicitation. For IPv4 we install a neighbor_setup function. We don't want |
| 2880 | * arp resolution but we want the hard header (packet socket will work |
| 2881 | * e.g. tcpdump) |
| 2882 | */ |
| 2883 | static int qeth_l3_neigh_setup_noarp(struct neighbour *n) |
| 2884 | { |
| 2885 | n->nud_state = NUD_NOARP; |
| 2886 | memcpy(n->ha, "FAKELL", 6); |
| 2887 | n->output = n->ops->connected_output; |
| 2888 | return 0; |
| 2889 | } |
| 2890 | |
| 2891 | static int |
| 2892 | qeth_l3_neigh_setup(struct net_device *dev, struct neigh_parms *np) |
| 2893 | { |
| 2894 | if (np->tbl->family == AF_INET) |
| 2895 | np->neigh_setup = qeth_l3_neigh_setup_noarp; |
| 2896 | |
| 2897 | return 0; |
| 2898 | } |
| 2899 | |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 2900 | static const struct net_device_ops qeth_l3_netdev_ops = { |
Frank Blaschka | 8403b13 | 2009-01-08 10:50:55 -0800 | [diff] [blame] | 2901 | .ndo_open = qeth_l3_open, |
| 2902 | .ndo_stop = qeth_l3_stop, |
| 2903 | .ndo_get_stats = qeth_get_stats, |
| 2904 | .ndo_start_xmit = qeth_l3_hard_start_xmit, |
| 2905 | .ndo_validate_addr = eth_validate_addr, |
Jiri Pirko | afc4b13 | 2011-08-16 06:29:01 +0000 | [diff] [blame] | 2906 | .ndo_set_rx_mode = qeth_l3_set_multicast_list, |
Julian Wiedmann | 942d698 | 2017-04-11 16:11:10 +0200 | [diff] [blame] | 2907 | .ndo_do_ioctl = qeth_do_ioctl, |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 2908 | .ndo_change_mtu = qeth_change_mtu, |
Thomas Richter | 8f43fb0 | 2016-06-16 16:18:59 +0200 | [diff] [blame] | 2909 | .ndo_fix_features = qeth_fix_features, |
| 2910 | .ndo_set_features = qeth_set_features, |
Frank Blaschka | 8403b13 | 2009-01-08 10:50:55 -0800 | [diff] [blame] | 2911 | .ndo_vlan_rx_add_vid = qeth_l3_vlan_rx_add_vid, |
| 2912 | .ndo_vlan_rx_kill_vid = qeth_l3_vlan_rx_kill_vid, |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 2913 | .ndo_tx_timeout = qeth_tx_timeout, |
Frank Blaschka | 8403b13 | 2009-01-08 10:50:55 -0800 | [diff] [blame] | 2914 | }; |
| 2915 | |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 2916 | static const struct net_device_ops qeth_l3_osa_netdev_ops = { |
| 2917 | .ndo_open = qeth_l3_open, |
| 2918 | .ndo_stop = qeth_l3_stop, |
| 2919 | .ndo_get_stats = qeth_get_stats, |
| 2920 | .ndo_start_xmit = qeth_l3_hard_start_xmit, |
Julian Wiedmann | 6d69b1f | 2017-12-01 10:14:50 +0100 | [diff] [blame^] | 2921 | .ndo_features_check = qeth_features_check, |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 2922 | .ndo_validate_addr = eth_validate_addr, |
Jiri Pirko | afc4b13 | 2011-08-16 06:29:01 +0000 | [diff] [blame] | 2923 | .ndo_set_rx_mode = qeth_l3_set_multicast_list, |
Julian Wiedmann | 942d698 | 2017-04-11 16:11:10 +0200 | [diff] [blame] | 2924 | .ndo_do_ioctl = qeth_do_ioctl, |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 2925 | .ndo_change_mtu = qeth_change_mtu, |
Thomas Richter | 8f43fb0 | 2016-06-16 16:18:59 +0200 | [diff] [blame] | 2926 | .ndo_fix_features = qeth_fix_features, |
| 2927 | .ndo_set_features = qeth_set_features, |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 2928 | .ndo_vlan_rx_add_vid = qeth_l3_vlan_rx_add_vid, |
| 2929 | .ndo_vlan_rx_kill_vid = qeth_l3_vlan_rx_kill_vid, |
Jiri Pirko | 7ff0bcf | 2011-07-20 04:54:41 +0000 | [diff] [blame] | 2930 | .ndo_tx_timeout = qeth_tx_timeout, |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 2931 | .ndo_neigh_setup = qeth_l3_neigh_setup, |
| 2932 | }; |
| 2933 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2934 | static int qeth_l3_setup_netdev(struct qeth_card *card) |
| 2935 | { |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 2936 | int rc; |
| 2937 | |
Ursula Braun | 5113fec | 2010-05-16 21:15:14 +0000 | [diff] [blame] | 2938 | if (card->info.type == QETH_CARD_TYPE_OSD || |
| 2939 | card->info.type == QETH_CARD_TYPE_OSX) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2940 | if ((card->info.link_type == QETH_LINK_TYPE_LANE_TR) || |
| 2941 | (card->info.link_type == QETH_LINK_TYPE_HSTR)) { |
Paul Gortmaker | 1abd229 | 2012-05-10 15:50:52 -0400 | [diff] [blame] | 2942 | pr_info("qeth_l3: ignoring TR device\n"); |
| 2943 | return -ENODEV; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2944 | } else { |
| 2945 | card->dev = alloc_etherdev(0); |
| 2946 | if (!card->dev) |
| 2947 | return -ENODEV; |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 2948 | card->dev->netdev_ops = &qeth_l3_osa_netdev_ops; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2949 | |
| 2950 | /*IPv6 address autoconfiguration stuff*/ |
| 2951 | qeth_l3_get_unique_id(card); |
| 2952 | if (!(card->info.unique_id & UNIQUE_ID_NOT_BY_CARD)) |
| 2953 | card->dev->dev_id = card->info.unique_id & |
| 2954 | 0xffff; |
Frank Blaschka | c5e631a | 2011-05-12 18:45:01 +0000 | [diff] [blame] | 2955 | if (!card->info.guestlan) { |
| 2956 | card->dev->hw_features = NETIF_F_SG | |
| 2957 | NETIF_F_RXCSUM | NETIF_F_IP_CSUM | |
| 2958 | NETIF_F_TSO; |
Hans Wippel | 9bdc441 | 2016-06-16 16:19:00 +0200 | [diff] [blame] | 2959 | card->dev->vlan_features = NETIF_F_SG | |
| 2960 | NETIF_F_RXCSUM | NETIF_F_IP_CSUM | |
| 2961 | NETIF_F_TSO; |
Julian Wiedmann | 6d69b1f | 2017-12-01 10:14:50 +0100 | [diff] [blame^] | 2962 | card->dev->features |= NETIF_F_SG; |
Frank Blaschka | c5e631a | 2011-05-12 18:45:01 +0000 | [diff] [blame] | 2963 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2964 | } |
| 2965 | } else if (card->info.type == QETH_CARD_TYPE_IQD) { |
Tom Gundersen | c835a67 | 2014-07-14 16:37:24 +0200 | [diff] [blame] | 2966 | card->dev = alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN, |
| 2967 | ether_setup); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2968 | if (!card->dev) |
| 2969 | return -ENODEV; |
| 2970 | card->dev->flags |= IFF_NOARP; |
Frank Blaschka | 3d58cef | 2009-01-09 03:44:00 +0000 | [diff] [blame] | 2971 | card->dev->netdev_ops = &qeth_l3_netdev_ops; |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 2972 | rc = qeth_l3_iqd_read_initial_mac(card); |
| 2973 | if (rc) |
| 2974 | return rc; |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 2975 | if (card->options.hsuid[0]) |
| 2976 | memcpy(card->dev->perm_addr, card->options.hsuid, 9); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2977 | } else |
| 2978 | return -ENODEV; |
| 2979 | |
Heiko Carstens | 509e256 | 2008-07-26 02:24:10 -0700 | [diff] [blame] | 2980 | card->dev->ml_priv = card; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2981 | card->dev->watchdog_timeo = QETH_TX_TIMEOUT; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2982 | card->dev->mtu = card->info.initial_mtu; |
Jarod Wilson | 46b3ef4 | 2016-10-20 13:55:23 -0400 | [diff] [blame] | 2983 | card->dev->min_mtu = 64; |
| 2984 | card->dev->max_mtu = ETH_MAX_MTU; |
Wilfried Klaebe | 7ad24ea | 2014-05-11 00:12:32 +0000 | [diff] [blame] | 2985 | card->dev->ethtool_ops = &qeth_l3_ethtool_ops; |
Patrick McHardy | f646968 | 2013-04-19 02:04:27 +0000 | [diff] [blame] | 2986 | card->dev->features |= NETIF_F_HW_VLAN_CTAG_TX | |
| 2987 | NETIF_F_HW_VLAN_CTAG_RX | |
| 2988 | NETIF_F_HW_VLAN_CTAG_FILTER; |
Eric Dumazet | 0287587 | 2014-10-05 18:38:35 -0700 | [diff] [blame] | 2989 | netif_keep_dst(card->dev); |
Eugene Crosser | 8bad55f | 2016-06-16 16:18:54 +0200 | [diff] [blame] | 2990 | card->dev->gso_max_size = (QETH_MAX_BUFFER_ELEMENTS(card) - 1) * |
| 2991 | PAGE_SIZE; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2992 | |
| 2993 | SET_NETDEV_DEV(card->dev, &card->gdev->dev); |
Julian Wiedmann | d73ef32 | 2017-04-11 16:11:11 +0200 | [diff] [blame] | 2994 | netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT); |
Ursula Braun | e5ebe63 | 2015-12-11 12:27:55 +0100 | [diff] [blame] | 2995 | netif_carrier_off(card->dev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2996 | return register_netdev(card->dev); |
| 2997 | } |
| 2998 | |
Ursula Braun | 79a04e4 | 2017-06-06 14:33:49 +0200 | [diff] [blame] | 2999 | static const struct device_type qeth_l3_devtype = { |
| 3000 | .name = "qeth_layer3", |
| 3001 | .groups = qeth_l3_attr_groups, |
| 3002 | }; |
| 3003 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3004 | static int qeth_l3_probe_device(struct ccwgroup_device *gdev) |
| 3005 | { |
| 3006 | struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
Ursula Braun | 9111e78 | 2017-05-10 19:07:51 +0200 | [diff] [blame] | 3007 | int rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3008 | |
Ursula Braun | 79a04e4 | 2017-06-06 14:33:49 +0200 | [diff] [blame] | 3009 | if (gdev->dev.type == &qeth_generic_devtype) { |
| 3010 | rc = qeth_l3_create_device_attributes(&gdev->dev); |
| 3011 | if (rc) |
| 3012 | return rc; |
| 3013 | } |
Ursula Braun | ebccc739 | 2017-05-10 19:07:54 +0200 | [diff] [blame] | 3014 | hash_init(card->ip_htable); |
| 3015 | hash_init(card->ip_mc_htable); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3016 | card->options.layer2 = 0; |
Frank Blaschka | 1da74b1 | 2011-05-12 18:45:02 +0000 | [diff] [blame] | 3017 | card->info.hwtrap = 0; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3018 | return 0; |
| 3019 | } |
| 3020 | |
| 3021 | static void qeth_l3_remove_device(struct ccwgroup_device *cgdev) |
| 3022 | { |
| 3023 | struct qeth_card *card = dev_get_drvdata(&cgdev->dev); |
| 3024 | |
Ursula Braun | 79a04e4 | 2017-06-06 14:33:49 +0200 | [diff] [blame] | 3025 | if (cgdev->dev.type == &qeth_generic_devtype) |
| 3026 | qeth_l3_remove_device_attributes(&cgdev->dev); |
Ursula Braun | 9dc48cc | 2010-07-22 23:15:05 +0000 | [diff] [blame] | 3027 | |
Ursula Braun | f214856 | 2009-05-19 21:38:37 +0000 | [diff] [blame] | 3028 | qeth_set_allowed_threads(card, 0, 1); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3029 | wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); |
| 3030 | |
Ursula Braun | 70919e2 | 2011-02-26 22:41:36 -0800 | [diff] [blame] | 3031 | if (cgdev->state == CCWGROUP_ONLINE) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3032 | qeth_l3_set_offline(cgdev); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3033 | |
| 3034 | if (card->dev) { |
Ursula Braun | 7831b4f | 2016-07-04 14:07:16 +0200 | [diff] [blame] | 3035 | netif_napi_del(&card->napi); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3036 | unregister_netdev(card->dev); |
| 3037 | card->dev = NULL; |
| 3038 | } |
| 3039 | |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3040 | qeth_l3_clear_ip_htable(card, 0); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3041 | qeth_l3_clear_ipato_list(card); |
| 3042 | return; |
| 3043 | } |
| 3044 | |
| 3045 | static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode) |
| 3046 | { |
| 3047 | struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
| 3048 | int rc = 0; |
| 3049 | enum qeth_card_states recover_flag; |
| 3050 | |
Ursula Braun | 9dc48cc | 2010-07-22 23:15:05 +0000 | [diff] [blame] | 3051 | mutex_lock(&card->discipline_mutex); |
Frank Blaschka | c4949f0 | 2010-05-11 19:34:47 +0000 | [diff] [blame] | 3052 | mutex_lock(&card->conf_mutex); |
Peter Tiedemann | d11ba0c | 2008-04-01 10:26:58 +0200 | [diff] [blame] | 3053 | QETH_DBF_TEXT(SETUP, 2, "setonlin"); |
| 3054 | QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3055 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3056 | recover_flag = card->state; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3057 | rc = qeth_core_hardsetup_card(card); |
| 3058 | if (rc) { |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 3059 | QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc); |
Ursula Braun | aa90922 | 2009-11-12 00:11:43 +0000 | [diff] [blame] | 3060 | rc = -ENODEV; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3061 | goto out_remove; |
| 3062 | } |
| 3063 | |
Ursula Braun | aa90922 | 2009-11-12 00:11:43 +0000 | [diff] [blame] | 3064 | if (!card->dev && qeth_l3_setup_netdev(card)) { |
| 3065 | rc = -ENODEV; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3066 | goto out_remove; |
Ursula Braun | aa90922 | 2009-11-12 00:11:43 +0000 | [diff] [blame] | 3067 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3068 | |
Frank Blaschka | 1da74b1 | 2011-05-12 18:45:02 +0000 | [diff] [blame] | 3069 | if (qeth_is_diagass_supported(card, QETH_DIAGS_CMD_TRAP)) { |
| 3070 | if (card->info.hwtrap && |
| 3071 | qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM)) |
| 3072 | card->info.hwtrap = 0; |
| 3073 | } else |
| 3074 | card->info.hwtrap = 0; |
| 3075 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3076 | card->state = CARD_STATE_HARDSETUP; |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 3077 | memset(&card->rx, 0, sizeof(struct qeth_rx)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3078 | qeth_print_status_message(card); |
| 3079 | |
| 3080 | /* softsetup */ |
Peter Tiedemann | d11ba0c | 2008-04-01 10:26:58 +0200 | [diff] [blame] | 3081 | QETH_DBF_TEXT(SETUP, 2, "softsetp"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3082 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3083 | rc = qeth_l3_setadapter_parms(card); |
| 3084 | if (rc) |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 3085 | QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 3086 | if (!card->options.sniffer) { |
| 3087 | rc = qeth_l3_start_ipassists(card); |
Stefan Raspl | 0f54761 | 2013-01-21 02:30:20 +0000 | [diff] [blame] | 3088 | if (rc) { |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 3089 | QETH_DBF_TEXT_(SETUP, 2, "3err%d", rc); |
Stefan Raspl | 0f54761 | 2013-01-21 02:30:20 +0000 | [diff] [blame] | 3090 | goto out_remove; |
| 3091 | } |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 3092 | rc = qeth_l3_setrouting_v4(card); |
| 3093 | if (rc) |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 3094 | QETH_DBF_TEXT_(SETUP, 2, "4err%04x", rc); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 3095 | rc = qeth_l3_setrouting_v6(card); |
| 3096 | if (rc) |
Thomas Richter | 1aec42b | 2015-01-21 13:39:10 +0100 | [diff] [blame] | 3097 | QETH_DBF_TEXT_(SETUP, 2, "5err%04x", rc); |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 3098 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3099 | netif_tx_disable(card->dev); |
| 3100 | |
| 3101 | rc = qeth_init_qdio_queues(card); |
| 3102 | if (rc) { |
Peter Tiedemann | d11ba0c | 2008-04-01 10:26:58 +0200 | [diff] [blame] | 3103 | QETH_DBF_TEXT_(SETUP, 2, "6err%d", rc); |
Ursula Braun | aa90922 | 2009-11-12 00:11:43 +0000 | [diff] [blame] | 3104 | rc = -ENODEV; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3105 | goto out_remove; |
| 3106 | } |
| 3107 | card->state = CARD_STATE_SOFTSETUP; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3108 | |
| 3109 | qeth_set_allowed_threads(card, 0xffffffff, 0); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3110 | qeth_l3_recover_ip(card); |
Ursula Braun | 2b6203b | 2010-11-26 02:41:19 +0000 | [diff] [blame] | 3111 | if (card->lan_online) |
| 3112 | netif_carrier_on(card->dev); |
| 3113 | else |
| 3114 | netif_carrier_off(card->dev); |
Frank Blaschka | 8af7c5a | 2008-04-24 10:15:25 +0200 | [diff] [blame] | 3115 | if (recover_flag == CARD_STATE_RECOVER) { |
Ursula Braun | 4763b0a | 2011-12-19 22:56:32 +0000 | [diff] [blame] | 3116 | rtnl_lock(); |
Frank Blaschka | 8af7c5a | 2008-04-24 10:15:25 +0200 | [diff] [blame] | 3117 | if (recovery_mode) |
Ursula Braun | 3942344 | 2011-01-12 20:42:24 +0000 | [diff] [blame] | 3118 | __qeth_l3_open(card->dev); |
Ursula Braun | 4763b0a | 2011-12-19 22:56:32 +0000 | [diff] [blame] | 3119 | else |
Frank Blaschka | 8af7c5a | 2008-04-24 10:15:25 +0200 | [diff] [blame] | 3120 | dev_open(card->dev); |
Frank Blaschka | 8af7c5a | 2008-04-24 10:15:25 +0200 | [diff] [blame] | 3121 | qeth_l3_set_multicast_list(card->dev); |
Hans Wippel | e830baa | 2016-09-15 14:39:21 +0200 | [diff] [blame] | 3122 | qeth_recover_features(card->dev); |
Ursula Braun | 4763b0a | 2011-12-19 22:56:32 +0000 | [diff] [blame] | 3123 | rtnl_unlock(); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3124 | } |
Stefan Raspl | 82f77cf | 2013-03-18 20:04:42 +0000 | [diff] [blame] | 3125 | qeth_trace_features(card); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3126 | /* let user_space know that device is online */ |
| 3127 | kobject_uevent(&gdev->dev.kobj, KOBJ_CHANGE); |
Frank Blaschka | c4949f0 | 2010-05-11 19:34:47 +0000 | [diff] [blame] | 3128 | mutex_unlock(&card->conf_mutex); |
Ursula Braun | 9dc48cc | 2010-07-22 23:15:05 +0000 | [diff] [blame] | 3129 | mutex_unlock(&card->discipline_mutex); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3130 | return 0; |
| 3131 | out_remove: |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3132 | qeth_l3_stop_card(card, 0); |
| 3133 | ccw_device_set_offline(CARD_DDEV(card)); |
| 3134 | ccw_device_set_offline(CARD_WDEV(card)); |
| 3135 | ccw_device_set_offline(CARD_RDEV(card)); |
Ursula Braun | 22ae279 | 2014-02-24 13:12:06 +0100 | [diff] [blame] | 3136 | qdio_free(CARD_DDEV(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3137 | if (recover_flag == CARD_STATE_RECOVER) |
| 3138 | card->state = CARD_STATE_RECOVER; |
| 3139 | else |
| 3140 | card->state = CARD_STATE_DOWN; |
Frank Blaschka | c4949f0 | 2010-05-11 19:34:47 +0000 | [diff] [blame] | 3141 | mutex_unlock(&card->conf_mutex); |
Ursula Braun | 9dc48cc | 2010-07-22 23:15:05 +0000 | [diff] [blame] | 3142 | mutex_unlock(&card->discipline_mutex); |
Ursula Braun | aa90922 | 2009-11-12 00:11:43 +0000 | [diff] [blame] | 3143 | return rc; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3144 | } |
| 3145 | |
| 3146 | static int qeth_l3_set_online(struct ccwgroup_device *gdev) |
| 3147 | { |
| 3148 | return __qeth_l3_set_online(gdev, 0); |
| 3149 | } |
| 3150 | |
| 3151 | static int __qeth_l3_set_offline(struct ccwgroup_device *cgdev, |
| 3152 | int recovery_mode) |
| 3153 | { |
| 3154 | struct qeth_card *card = dev_get_drvdata(&cgdev->dev); |
| 3155 | int rc = 0, rc2 = 0, rc3 = 0; |
| 3156 | enum qeth_card_states recover_flag; |
| 3157 | |
Ursula Braun | 9dc48cc | 2010-07-22 23:15:05 +0000 | [diff] [blame] | 3158 | mutex_lock(&card->discipline_mutex); |
Frank Blaschka | c4949f0 | 2010-05-11 19:34:47 +0000 | [diff] [blame] | 3159 | mutex_lock(&card->conf_mutex); |
Peter Tiedemann | d11ba0c | 2008-04-01 10:26:58 +0200 | [diff] [blame] | 3160 | QETH_DBF_TEXT(SETUP, 3, "setoffl"); |
| 3161 | QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3162 | |
| 3163 | if (card->dev && netif_carrier_ok(card->dev)) |
| 3164 | netif_carrier_off(card->dev); |
| 3165 | recover_flag = card->state; |
Frank Blaschka | 1da74b1 | 2011-05-12 18:45:02 +0000 | [diff] [blame] | 3166 | if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) { |
| 3167 | qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); |
| 3168 | card->info.hwtrap = 1; |
| 3169 | } |
Ursula Braun | 0f5623c | 2008-10-24 11:16:52 +0200 | [diff] [blame] | 3170 | qeth_l3_stop_card(card, recovery_mode); |
Einar Lueck | 72861ae | 2011-12-19 22:56:36 +0000 | [diff] [blame] | 3171 | if ((card->options.cq == QETH_CQ_ENABLED) && card->dev) { |
| 3172 | rtnl_lock(); |
| 3173 | call_netdevice_notifiers(NETDEV_REBOOT, card->dev); |
| 3174 | rtnl_unlock(); |
| 3175 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3176 | rc = ccw_device_set_offline(CARD_DDEV(card)); |
| 3177 | rc2 = ccw_device_set_offline(CARD_WDEV(card)); |
| 3178 | rc3 = ccw_device_set_offline(CARD_RDEV(card)); |
| 3179 | if (!rc) |
| 3180 | rc = (rc2) ? rc2 : rc3; |
| 3181 | if (rc) |
Peter Tiedemann | d11ba0c | 2008-04-01 10:26:58 +0200 | [diff] [blame] | 3182 | QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc); |
Ursula Braun | 22ae279 | 2014-02-24 13:12:06 +0100 | [diff] [blame] | 3183 | qdio_free(CARD_DDEV(card)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3184 | if (recover_flag == CARD_STATE_UP) |
| 3185 | card->state = CARD_STATE_RECOVER; |
| 3186 | /* let user_space know that device is offline */ |
| 3187 | kobject_uevent(&cgdev->dev.kobj, KOBJ_CHANGE); |
Frank Blaschka | c4949f0 | 2010-05-11 19:34:47 +0000 | [diff] [blame] | 3188 | mutex_unlock(&card->conf_mutex); |
Ursula Braun | 9dc48cc | 2010-07-22 23:15:05 +0000 | [diff] [blame] | 3189 | mutex_unlock(&card->discipline_mutex); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3190 | return 0; |
| 3191 | } |
| 3192 | |
| 3193 | static int qeth_l3_set_offline(struct ccwgroup_device *cgdev) |
| 3194 | { |
| 3195 | return __qeth_l3_set_offline(cgdev, 0); |
| 3196 | } |
| 3197 | |
| 3198 | static int qeth_l3_recover(void *ptr) |
| 3199 | { |
| 3200 | struct qeth_card *card; |
| 3201 | int rc = 0; |
| 3202 | |
| 3203 | card = (struct qeth_card *) ptr; |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 3204 | QETH_CARD_TEXT(card, 2, "recover1"); |
| 3205 | QETH_CARD_HEX(card, 2, &card, sizeof(void *)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3206 | if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD)) |
| 3207 | return 0; |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 3208 | QETH_CARD_TEXT(card, 2, "recover2"); |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 3209 | dev_warn(&card->gdev->dev, |
| 3210 | "A recovery process has been started for the device\n"); |
Stefan Raspl | 65d8013 | 2013-04-07 22:19:27 +0000 | [diff] [blame] | 3211 | qeth_set_recovery_task(card); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3212 | __qeth_l3_set_offline(card->gdev, 1); |
| 3213 | rc = __qeth_l3_set_online(card->gdev, 1); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3214 | if (!rc) |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 3215 | dev_info(&card->gdev->dev, |
| 3216 | "Device successfully recovered!\n"); |
Ursula Braun | 28a7e4c | 2008-09-19 12:56:03 +0200 | [diff] [blame] | 3217 | else { |
Stefan Raspl | 0f54761 | 2013-01-21 02:30:20 +0000 | [diff] [blame] | 3218 | qeth_close_dev(card); |
| 3219 | dev_warn(&card->gdev->dev, "The qeth device driver " |
Stefan Raspl | 2efaf5f | 2012-10-15 19:21:18 +0000 | [diff] [blame] | 3220 | "failed to recover an error on the device\n"); |
Ursula Braun | 28a7e4c | 2008-09-19 12:56:03 +0200 | [diff] [blame] | 3221 | } |
Stefan Raspl | 65d8013 | 2013-04-07 22:19:27 +0000 | [diff] [blame] | 3222 | qeth_clear_recovery_task(card); |
Frank Blaschka | a1c3ed4 | 2010-09-07 21:14:42 +0000 | [diff] [blame] | 3223 | qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); |
| 3224 | qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3225 | return 0; |
| 3226 | } |
| 3227 | |
Frank Blaschka | bbcfcdc | 2009-06-16 10:30:31 +0200 | [diff] [blame] | 3228 | static int qeth_l3_pm_suspend(struct ccwgroup_device *gdev) |
| 3229 | { |
| 3230 | struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
| 3231 | |
| 3232 | if (card->dev) |
| 3233 | netif_device_detach(card->dev); |
| 3234 | qeth_set_allowed_threads(card, 0, 1); |
| 3235 | wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); |
| 3236 | if (gdev->state == CCWGROUP_OFFLINE) |
| 3237 | return 0; |
| 3238 | if (card->state == CARD_STATE_UP) { |
Frank Blaschka | 1da74b1 | 2011-05-12 18:45:02 +0000 | [diff] [blame] | 3239 | if (card->info.hwtrap) |
| 3240 | qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); |
Frank Blaschka | bbcfcdc | 2009-06-16 10:30:31 +0200 | [diff] [blame] | 3241 | __qeth_l3_set_offline(card->gdev, 1); |
| 3242 | } else |
| 3243 | __qeth_l3_set_offline(card->gdev, 0); |
| 3244 | return 0; |
| 3245 | } |
| 3246 | |
| 3247 | static int qeth_l3_pm_resume(struct ccwgroup_device *gdev) |
| 3248 | { |
| 3249 | struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
| 3250 | int rc = 0; |
| 3251 | |
| 3252 | if (gdev->state == CCWGROUP_OFFLINE) |
| 3253 | goto out; |
| 3254 | |
| 3255 | if (card->state == CARD_STATE_RECOVER) { |
| 3256 | rc = __qeth_l3_set_online(card->gdev, 1); |
| 3257 | if (rc) { |
Ursula Braun | 869da90 | 2010-03-08 20:36:56 +0000 | [diff] [blame] | 3258 | rtnl_lock(); |
| 3259 | dev_close(card->dev); |
| 3260 | rtnl_unlock(); |
Frank Blaschka | bbcfcdc | 2009-06-16 10:30:31 +0200 | [diff] [blame] | 3261 | } |
| 3262 | } else |
| 3263 | rc = __qeth_l3_set_online(card->gdev, 0); |
| 3264 | out: |
| 3265 | qeth_set_allowed_threads(card, 0xffffffff, 0); |
| 3266 | if (card->dev) |
| 3267 | netif_device_attach(card->dev); |
| 3268 | if (rc) |
| 3269 | dev_warn(&card->gdev->dev, "The qeth device driver " |
| 3270 | "failed to recover an error on the device\n"); |
| 3271 | return rc; |
| 3272 | } |
| 3273 | |
Eugene Crosser | c044dc2 | 2014-01-29 09:23:48 +0100 | [diff] [blame] | 3274 | /* Returns zero if the command is successfully "consumed" */ |
| 3275 | static int qeth_l3_control_event(struct qeth_card *card, |
| 3276 | struct qeth_ipa_cmd *cmd) |
| 3277 | { |
| 3278 | return 1; |
| 3279 | } |
| 3280 | |
Sebastian Ott | c041f2d487 | 2012-05-15 18:02:21 +0200 | [diff] [blame] | 3281 | struct qeth_discipline qeth_l3_discipline = { |
Ursula Braun | 79a04e4 | 2017-06-06 14:33:49 +0200 | [diff] [blame] | 3282 | .devtype = &qeth_l3_devtype, |
Sebastian Ott | c041f2d487 | 2012-05-15 18:02:21 +0200 | [diff] [blame] | 3283 | .start_poll = qeth_qdio_start_poll, |
| 3284 | .input_handler = (qdio_handler_t *) qeth_qdio_input_handler, |
| 3285 | .output_handler = (qdio_handler_t *) qeth_qdio_output_handler, |
Julian Wiedmann | d73ef32 | 2017-04-11 16:11:11 +0200 | [diff] [blame] | 3286 | .process_rx_buffer = qeth_l3_process_inbound_buffer, |
Sebastian Ott | c041f2d487 | 2012-05-15 18:02:21 +0200 | [diff] [blame] | 3287 | .recover = qeth_l3_recover, |
| 3288 | .setup = qeth_l3_probe_device, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3289 | .remove = qeth_l3_remove_device, |
| 3290 | .set_online = qeth_l3_set_online, |
| 3291 | .set_offline = qeth_l3_set_offline, |
Frank Blaschka | bbcfcdc | 2009-06-16 10:30:31 +0200 | [diff] [blame] | 3292 | .freeze = qeth_l3_pm_suspend, |
| 3293 | .thaw = qeth_l3_pm_resume, |
| 3294 | .restore = qeth_l3_pm_resume, |
Julian Wiedmann | 942d698 | 2017-04-11 16:11:10 +0200 | [diff] [blame] | 3295 | .do_ioctl = qeth_l3_do_ioctl, |
Eugene Crosser | c044dc2 | 2014-01-29 09:23:48 +0100 | [diff] [blame] | 3296 | .control_event_handler = qeth_l3_control_event, |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3297 | }; |
Sebastian Ott | c041f2d487 | 2012-05-15 18:02:21 +0200 | [diff] [blame] | 3298 | EXPORT_SYMBOL_GPL(qeth_l3_discipline); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3299 | |
| 3300 | static int qeth_l3_ip_event(struct notifier_block *this, |
David S. Miller | 76fef2b | 2008-03-22 18:22:42 -0700 | [diff] [blame] | 3301 | unsigned long event, void *ptr) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3302 | { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3303 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3304 | struct in_ifaddr *ifa = (struct in_ifaddr *)ptr; |
| 3305 | struct net_device *dev = (struct net_device *)ifa->ifa_dev->dev; |
| 3306 | struct qeth_ipaddr *addr; |
| 3307 | struct qeth_card *card; |
| 3308 | |
YOSHIFUJI Hideaki | c346dca | 2008-03-25 21:47:49 +0900 | [diff] [blame] | 3309 | if (dev_net(dev) != &init_net) |
David S. Miller | 76fef2b | 2008-03-22 18:22:42 -0700 | [diff] [blame] | 3310 | return NOTIFY_DONE; |
| 3311 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3312 | card = qeth_l3_get_card_from_dev(dev); |
| 3313 | if (!card) |
| 3314 | return NOTIFY_DONE; |
frank.blaschka@de.ibm.com | 6d8823d | 2012-05-16 01:28:26 +0000 | [diff] [blame] | 3315 | QETH_CARD_TEXT(card, 3, "ipevent"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3316 | |
| 3317 | addr = qeth_l3_get_addr_buffer(QETH_PROT_IPV4); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3318 | if (addr) { |
Hans Wippel | 6bee4e2 | 2017-04-07 09:15:36 +0200 | [diff] [blame] | 3319 | addr->u.a4.addr = be32_to_cpu(ifa->ifa_address); |
| 3320 | addr->u.a4.mask = be32_to_cpu(ifa->ifa_mask); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3321 | addr->type = QETH_IP_TYPE_NORMAL; |
| 3322 | } else |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3323 | return NOTIFY_DONE; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3324 | |
| 3325 | switch (event) { |
| 3326 | case NETDEV_UP: |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3327 | spin_lock_bh(&card->ip_lock); |
| 3328 | qeth_l3_add_ip(card, addr); |
| 3329 | spin_unlock_bh(&card->ip_lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3330 | break; |
| 3331 | case NETDEV_DOWN: |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3332 | spin_lock_bh(&card->ip_lock); |
| 3333 | qeth_l3_delete_ip(card, addr); |
| 3334 | spin_unlock_bh(&card->ip_lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3335 | break; |
| 3336 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3337 | |
| 3338 | kfree(addr); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3339 | return NOTIFY_DONE; |
| 3340 | } |
| 3341 | |
| 3342 | static struct notifier_block qeth_l3_ip_notifier = { |
| 3343 | qeth_l3_ip_event, |
| 3344 | NULL, |
| 3345 | }; |
| 3346 | |
| 3347 | #ifdef CONFIG_QETH_IPV6 |
| 3348 | /** |
| 3349 | * IPv6 event handler |
| 3350 | */ |
| 3351 | static int qeth_l3_ip6_event(struct notifier_block *this, |
David S. Miller | 76fef2b | 2008-03-22 18:22:42 -0700 | [diff] [blame] | 3352 | unsigned long event, void *ptr) |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3353 | { |
| 3354 | struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr; |
| 3355 | struct net_device *dev = (struct net_device *)ifa->idev->dev; |
| 3356 | struct qeth_ipaddr *addr; |
| 3357 | struct qeth_card *card; |
| 3358 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3359 | card = qeth_l3_get_card_from_dev(dev); |
| 3360 | if (!card) |
| 3361 | return NOTIFY_DONE; |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 3362 | QETH_CARD_TEXT(card, 3, "ip6event"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3363 | if (!qeth_is_supported(card, IPA_IPV6)) |
| 3364 | return NOTIFY_DONE; |
| 3365 | |
| 3366 | addr = qeth_l3_get_addr_buffer(QETH_PROT_IPV6); |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3367 | if (addr) { |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3368 | memcpy(&addr->u.a6.addr, &ifa->addr, sizeof(struct in6_addr)); |
| 3369 | addr->u.a6.pfxlen = ifa->prefix_len; |
| 3370 | addr->type = QETH_IP_TYPE_NORMAL; |
| 3371 | } else |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3372 | return NOTIFY_DONE; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3373 | |
| 3374 | switch (event) { |
| 3375 | case NETDEV_UP: |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3376 | spin_lock_bh(&card->ip_lock); |
| 3377 | qeth_l3_add_ip(card, addr); |
| 3378 | spin_unlock_bh(&card->ip_lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3379 | break; |
| 3380 | case NETDEV_DOWN: |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3381 | spin_lock_bh(&card->ip_lock); |
| 3382 | qeth_l3_delete_ip(card, addr); |
| 3383 | spin_unlock_bh(&card->ip_lock); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3384 | break; |
| 3385 | } |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 3386 | |
| 3387 | kfree(addr); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3388 | return NOTIFY_DONE; |
| 3389 | } |
| 3390 | |
| 3391 | static struct notifier_block qeth_l3_ip6_notifier = { |
| 3392 | qeth_l3_ip6_event, |
| 3393 | NULL, |
| 3394 | }; |
| 3395 | #endif |
| 3396 | |
| 3397 | static int qeth_l3_register_notifiers(void) |
| 3398 | { |
| 3399 | int rc; |
| 3400 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 3401 | QETH_DBF_TEXT(SETUP, 5, "regnotif"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3402 | rc = register_inetaddr_notifier(&qeth_l3_ip_notifier); |
| 3403 | if (rc) |
| 3404 | return rc; |
| 3405 | #ifdef CONFIG_QETH_IPV6 |
| 3406 | rc = register_inet6addr_notifier(&qeth_l3_ip6_notifier); |
| 3407 | if (rc) { |
| 3408 | unregister_inetaddr_notifier(&qeth_l3_ip_notifier); |
| 3409 | return rc; |
| 3410 | } |
| 3411 | #else |
Joe Perches | baebc70 | 2016-03-03 20:49:57 -0800 | [diff] [blame] | 3412 | pr_warn("There is no IPv6 support for the layer 3 discipline\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3413 | #endif |
| 3414 | return 0; |
| 3415 | } |
| 3416 | |
| 3417 | static void qeth_l3_unregister_notifiers(void) |
| 3418 | { |
| 3419 | |
Carsten Otte | 847a50f | 2010-06-21 22:57:05 +0000 | [diff] [blame] | 3420 | QETH_DBF_TEXT(SETUP, 5, "unregnot"); |
Stefan Raspl | 18af5c1 | 2012-11-19 02:46:50 +0000 | [diff] [blame] | 3421 | WARN_ON(unregister_inetaddr_notifier(&qeth_l3_ip_notifier)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3422 | #ifdef CONFIG_QETH_IPV6 |
Stefan Raspl | 18af5c1 | 2012-11-19 02:46:50 +0000 | [diff] [blame] | 3423 | WARN_ON(unregister_inet6addr_notifier(&qeth_l3_ip6_notifier)); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3424 | #endif /* QETH_IPV6 */ |
| 3425 | } |
| 3426 | |
| 3427 | static int __init qeth_l3_init(void) |
| 3428 | { |
| 3429 | int rc = 0; |
| 3430 | |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 3431 | pr_info("register layer 3 discipline\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3432 | rc = qeth_l3_register_notifiers(); |
| 3433 | return rc; |
| 3434 | } |
| 3435 | |
| 3436 | static void __exit qeth_l3_exit(void) |
| 3437 | { |
| 3438 | qeth_l3_unregister_notifiers(); |
Frank Blaschka | 74eacdb | 2008-12-25 13:39:49 +0100 | [diff] [blame] | 3439 | pr_info("unregister layer 3 discipline\n"); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 3440 | } |
| 3441 | |
| 3442 | module_init(qeth_l3_init); |
| 3443 | module_exit(qeth_l3_exit); |
| 3444 | MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>"); |
| 3445 | MODULE_DESCRIPTION("qeth layer 3 discipline"); |
| 3446 | MODULE_LICENSE("GPL"); |