| .. | .. |
|---|
| 32 | 32 | #include <net/route.h> |
|---|
| 33 | 33 | #include <net/ipv6.h> |
|---|
| 34 | 34 | #include <net/ip6_route.h> |
|---|
| 35 | | -#include <net/ip6_fib.h> |
|---|
| 36 | | -#include <net/ip6_checksum.h> |
|---|
| 37 | 35 | #include <net/iucv/af_iucv.h> |
|---|
| 38 | 36 | #include <linux/hashtable.h> |
|---|
| 39 | 37 | |
|---|
| 40 | 38 | #include "qeth_l3.h" |
|---|
| 41 | 39 | |
|---|
| 42 | | - |
|---|
| 43 | | -static int qeth_l3_set_offline(struct ccwgroup_device *); |
|---|
| 44 | | -static int qeth_l3_stop(struct net_device *); |
|---|
| 45 | | -static void qeth_l3_set_rx_mode(struct net_device *dev); |
|---|
| 46 | 40 | static int qeth_l3_register_addr_entry(struct qeth_card *, |
|---|
| 47 | 41 | struct qeth_ipaddr *); |
|---|
| 48 | 42 | static int qeth_l3_deregister_addr_entry(struct qeth_card *, |
|---|
| 49 | 43 | struct qeth_ipaddr *); |
|---|
| 50 | 44 | |
|---|
| 51 | | -static void qeth_l3_ipaddr4_to_string(const __u8 *addr, char *buf) |
|---|
| 52 | | -{ |
|---|
| 53 | | - sprintf(buf, "%pI4", addr); |
|---|
| 54 | | -} |
|---|
| 55 | | - |
|---|
| 56 | | -static void qeth_l3_ipaddr6_to_string(const __u8 *addr, char *buf) |
|---|
| 57 | | -{ |
|---|
| 58 | | - sprintf(buf, "%pI6", addr); |
|---|
| 59 | | -} |
|---|
| 60 | | - |
|---|
| 61 | | -void qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto, const __u8 *addr, |
|---|
| 62 | | - char *buf) |
|---|
| 45 | +int qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto, const u8 *addr, |
|---|
| 46 | + char *buf) |
|---|
| 63 | 47 | { |
|---|
| 64 | 48 | if (proto == QETH_PROT_IPV4) |
|---|
| 65 | | - qeth_l3_ipaddr4_to_string(addr, buf); |
|---|
| 66 | | - else if (proto == QETH_PROT_IPV6) |
|---|
| 67 | | - qeth_l3_ipaddr6_to_string(addr, buf); |
|---|
| 68 | | -} |
|---|
| 69 | | - |
|---|
| 70 | | -static struct qeth_ipaddr *qeth_l3_get_addr_buffer(enum qeth_prot_versions prot) |
|---|
| 71 | | -{ |
|---|
| 72 | | - struct qeth_ipaddr *addr = kmalloc(sizeof(*addr), GFP_ATOMIC); |
|---|
| 73 | | - |
|---|
| 74 | | - if (addr) |
|---|
| 75 | | - qeth_l3_init_ipaddr(addr, QETH_IP_TYPE_NORMAL, prot); |
|---|
| 76 | | - return addr; |
|---|
| 49 | + return sprintf(buf, "%pI4", addr); |
|---|
| 50 | + else |
|---|
| 51 | + return sprintf(buf, "%pI6", addr); |
|---|
| 77 | 52 | } |
|---|
| 78 | 53 | |
|---|
| 79 | 54 | static struct qeth_ipaddr *qeth_l3_find_addr_by_ip(struct qeth_card *card, |
|---|
| 80 | 55 | struct qeth_ipaddr *query) |
|---|
| 81 | 56 | { |
|---|
| 82 | | - u64 key = qeth_l3_ipaddr_hash(query); |
|---|
| 57 | + u32 key = qeth_l3_ipaddr_hash(query); |
|---|
| 83 | 58 | struct qeth_ipaddr *addr; |
|---|
| 84 | 59 | |
|---|
| 85 | 60 | if (query->is_multicast) { |
|---|
| 86 | | - hash_for_each_possible(card->ip_mc_htable, addr, hnode, key) |
|---|
| 61 | + hash_for_each_possible(card->rx_mode_addrs, addr, hnode, key) |
|---|
| 87 | 62 | if (qeth_l3_addr_match_ip(addr, query)) |
|---|
| 88 | 63 | return addr; |
|---|
| 89 | 64 | } else { |
|---|
| .. | .. |
|---|
| 122 | 97 | return false; |
|---|
| 123 | 98 | |
|---|
| 124 | 99 | qeth_l3_convert_addr_to_bits((u8 *) &addr->u, addr_bits, |
|---|
| 125 | | - (addr->proto == QETH_PROT_IPV4)? 4:16); |
|---|
| 100 | + (addr->proto == QETH_PROT_IPV4) ? 4 : 16); |
|---|
| 126 | 101 | list_for_each_entry(ipatoe, &card->ipato.entries, entry) { |
|---|
| 127 | 102 | if (addr->proto != ipatoe->proto) |
|---|
| 128 | 103 | continue; |
|---|
| .. | .. |
|---|
| 130 | 105 | (ipatoe->proto == QETH_PROT_IPV4) ? |
|---|
| 131 | 106 | 4 : 16); |
|---|
| 132 | 107 | if (addr->proto == QETH_PROT_IPV4) |
|---|
| 133 | | - rc = !memcmp(addr_bits, ipatoe_bits, |
|---|
| 134 | | - min(32, ipatoe->mask_bits)); |
|---|
| 108 | + rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits); |
|---|
| 135 | 109 | else |
|---|
| 136 | | - rc = !memcmp(addr_bits, ipatoe_bits, |
|---|
| 137 | | - min(128, ipatoe->mask_bits)); |
|---|
| 110 | + rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits); |
|---|
| 138 | 111 | if (rc) |
|---|
| 139 | 112 | break; |
|---|
| 140 | 113 | } |
|---|
| .. | .. |
|---|
| 174 | 147 | addr->ref_counter--; |
|---|
| 175 | 148 | if (addr->type == QETH_IP_TYPE_NORMAL && addr->ref_counter > 0) |
|---|
| 176 | 149 | return rc; |
|---|
| 177 | | - if (addr->in_progress) |
|---|
| 178 | | - return -EINPROGRESS; |
|---|
| 179 | 150 | |
|---|
| 180 | 151 | if (qeth_card_hw_is_reachable(card)) |
|---|
| 181 | 152 | rc = qeth_l3_deregister_addr_entry(card, addr); |
|---|
| .. | .. |
|---|
| 220 | 191 | "Registering IP address %s failed\n", buf); |
|---|
| 221 | 192 | return -EADDRINUSE; |
|---|
| 222 | 193 | } else { |
|---|
| 223 | | - addr = qeth_l3_get_addr_buffer(tmp_addr->proto); |
|---|
| 194 | + addr = kmemdup(tmp_addr, sizeof(*tmp_addr), GFP_KERNEL); |
|---|
| 224 | 195 | if (!addr) |
|---|
| 225 | 196 | return -ENOMEM; |
|---|
| 226 | | - |
|---|
| 227 | | - memcpy(addr, tmp_addr, sizeof(struct qeth_ipaddr)); |
|---|
| 228 | | - addr->ref_counter = 1; |
|---|
| 229 | 197 | |
|---|
| 230 | 198 | if (qeth_l3_is_addr_covered_by_ipato(card, addr)) { |
|---|
| 231 | 199 | QETH_CARD_TEXT(card, 2, "tkovaddr"); |
|---|
| .. | .. |
|---|
| 239 | 207 | return 0; |
|---|
| 240 | 208 | } |
|---|
| 241 | 209 | |
|---|
| 242 | | - /* qeth_l3_register_addr_entry can go to sleep |
|---|
| 243 | | - * if we add a IPV4 addr. It is caused by the reason |
|---|
| 244 | | - * that SETIP ipa cmd starts ARP staff for IPV4 addr. |
|---|
| 245 | | - * Thus we should unlock spinlock, and make a protection |
|---|
| 246 | | - * using in_progress variable to indicate that there is |
|---|
| 247 | | - * an hardware operation with this IPV4 address |
|---|
| 248 | | - */ |
|---|
| 249 | | - if (addr->proto == QETH_PROT_IPV4) { |
|---|
| 250 | | - addr->in_progress = 1; |
|---|
| 251 | | - spin_unlock_bh(&card->ip_lock); |
|---|
| 252 | | - rc = qeth_l3_register_addr_entry(card, addr); |
|---|
| 253 | | - spin_lock_bh(&card->ip_lock); |
|---|
| 254 | | - addr->in_progress = 0; |
|---|
| 255 | | - } else |
|---|
| 256 | | - rc = qeth_l3_register_addr_entry(card, addr); |
|---|
| 210 | + rc = qeth_l3_register_addr_entry(card, addr); |
|---|
| 257 | 211 | |
|---|
| 258 | | - if (!rc || (rc == IPA_RC_DUPLICATE_IP_ADDRESS) || |
|---|
| 259 | | - (rc == IPA_RC_LAN_OFFLINE)) { |
|---|
| 212 | + if (!rc || rc == -EADDRINUSE || rc == -ENETDOWN) { |
|---|
| 260 | 213 | addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
|---|
| 261 | | - if (addr->ref_counter < 1) { |
|---|
| 262 | | - qeth_l3_deregister_addr_entry(card, addr); |
|---|
| 263 | | - hash_del(&addr->hnode); |
|---|
| 264 | | - kfree(addr); |
|---|
| 265 | | - } |
|---|
| 266 | 214 | } else { |
|---|
| 267 | 215 | hash_del(&addr->hnode); |
|---|
| 268 | 216 | kfree(addr); |
|---|
| 269 | 217 | } |
|---|
| 270 | 218 | } |
|---|
| 271 | 219 | return rc; |
|---|
| 220 | +} |
|---|
| 221 | + |
|---|
| 222 | +static int qeth_l3_modify_ip(struct qeth_card *card, struct qeth_ipaddr *addr, |
|---|
| 223 | + bool add) |
|---|
| 224 | +{ |
|---|
| 225 | + int rc; |
|---|
| 226 | + |
|---|
| 227 | + mutex_lock(&card->ip_lock); |
|---|
| 228 | + rc = add ? qeth_l3_add_ip(card, addr) : qeth_l3_delete_ip(card, addr); |
|---|
| 229 | + mutex_unlock(&card->ip_lock); |
|---|
| 230 | + |
|---|
| 231 | + return rc; |
|---|
| 232 | +} |
|---|
| 233 | + |
|---|
| 234 | +static void qeth_l3_drain_rx_mode_cache(struct qeth_card *card) |
|---|
| 235 | +{ |
|---|
| 236 | + struct qeth_ipaddr *addr; |
|---|
| 237 | + struct hlist_node *tmp; |
|---|
| 238 | + int i; |
|---|
| 239 | + |
|---|
| 240 | + hash_for_each_safe(card->rx_mode_addrs, i, tmp, addr, hnode) { |
|---|
| 241 | + hash_del(&addr->hnode); |
|---|
| 242 | + kfree(addr); |
|---|
| 243 | + } |
|---|
| 272 | 244 | } |
|---|
| 273 | 245 | |
|---|
| 274 | 246 | static void qeth_l3_clear_ip_htable(struct qeth_card *card, int recover) |
|---|
| .. | .. |
|---|
| 279 | 251 | |
|---|
| 280 | 252 | QETH_CARD_TEXT(card, 4, "clearip"); |
|---|
| 281 | 253 | |
|---|
| 282 | | - spin_lock_bh(&card->ip_lock); |
|---|
| 254 | + mutex_lock(&card->ip_lock); |
|---|
| 283 | 255 | |
|---|
| 284 | 256 | hash_for_each_safe(card->ip_htable, i, tmp, addr, hnode) { |
|---|
| 285 | 257 | if (!recover) { |
|---|
| .. | .. |
|---|
| 290 | 262 | addr->disp_flag = QETH_DISP_ADDR_ADD; |
|---|
| 291 | 263 | } |
|---|
| 292 | 264 | |
|---|
| 293 | | - spin_unlock_bh(&card->ip_lock); |
|---|
| 294 | | - |
|---|
| 295 | | - spin_lock_bh(&card->mclock); |
|---|
| 296 | | - |
|---|
| 297 | | - hash_for_each_safe(card->ip_mc_htable, i, tmp, addr, hnode) { |
|---|
| 298 | | - hash_del(&addr->hnode); |
|---|
| 299 | | - kfree(addr); |
|---|
| 300 | | - } |
|---|
| 301 | | - |
|---|
| 302 | | - spin_unlock_bh(&card->mclock); |
|---|
| 303 | | - |
|---|
| 304 | | - |
|---|
| 265 | + mutex_unlock(&card->ip_lock); |
|---|
| 305 | 266 | } |
|---|
| 267 | + |
|---|
| 306 | 268 | static void qeth_l3_recover_ip(struct qeth_card *card) |
|---|
| 307 | 269 | { |
|---|
| 308 | 270 | struct qeth_ipaddr *addr; |
|---|
| .. | .. |
|---|
| 312 | 274 | |
|---|
| 313 | 275 | QETH_CARD_TEXT(card, 4, "recovrip"); |
|---|
| 314 | 276 | |
|---|
| 315 | | - spin_lock_bh(&card->ip_lock); |
|---|
| 277 | + mutex_lock(&card->ip_lock); |
|---|
| 316 | 278 | |
|---|
| 317 | 279 | hash_for_each_safe(card->ip_htable, i, tmp, addr, hnode) { |
|---|
| 318 | 280 | if (addr->disp_flag == QETH_DISP_ADDR_ADD) { |
|---|
| 319 | | - if (addr->proto == QETH_PROT_IPV4) { |
|---|
| 320 | | - addr->in_progress = 1; |
|---|
| 321 | | - spin_unlock_bh(&card->ip_lock); |
|---|
| 322 | | - rc = qeth_l3_register_addr_entry(card, addr); |
|---|
| 323 | | - spin_lock_bh(&card->ip_lock); |
|---|
| 324 | | - addr->in_progress = 0; |
|---|
| 325 | | - } else |
|---|
| 326 | | - rc = qeth_l3_register_addr_entry(card, addr); |
|---|
| 281 | + rc = qeth_l3_register_addr_entry(card, addr); |
|---|
| 327 | 282 | |
|---|
| 328 | 283 | if (!rc) { |
|---|
| 329 | 284 | addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
|---|
| 330 | | - if (addr->ref_counter < 1) |
|---|
| 331 | | - qeth_l3_delete_ip(card, addr); |
|---|
| 332 | 285 | } else { |
|---|
| 333 | 286 | hash_del(&addr->hnode); |
|---|
| 334 | 287 | kfree(addr); |
|---|
| .. | .. |
|---|
| 336 | 289 | } |
|---|
| 337 | 290 | } |
|---|
| 338 | 291 | |
|---|
| 339 | | - spin_unlock_bh(&card->ip_lock); |
|---|
| 292 | + mutex_unlock(&card->ip_lock); |
|---|
| 293 | +} |
|---|
| 340 | 294 | |
|---|
| 295 | +static int qeth_l3_setdelip_cb(struct qeth_card *card, struct qeth_reply *reply, |
|---|
| 296 | + unsigned long data) |
|---|
| 297 | +{ |
|---|
| 298 | + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
|---|
| 299 | + |
|---|
| 300 | + switch (cmd->hdr.return_code) { |
|---|
| 301 | + case IPA_RC_SUCCESS: |
|---|
| 302 | + return 0; |
|---|
| 303 | + case IPA_RC_DUPLICATE_IP_ADDRESS: |
|---|
| 304 | + return -EADDRINUSE; |
|---|
| 305 | + case IPA_RC_MC_ADDR_NOT_FOUND: |
|---|
| 306 | + return -ENOENT; |
|---|
| 307 | + case IPA_RC_LAN_OFFLINE: |
|---|
| 308 | + return -ENETDOWN; |
|---|
| 309 | + default: |
|---|
| 310 | + return -EIO; |
|---|
| 311 | + } |
|---|
| 341 | 312 | } |
|---|
| 342 | 313 | |
|---|
| 343 | 314 | static int qeth_l3_send_setdelmc(struct qeth_card *card, |
|---|
| 344 | | - struct qeth_ipaddr *addr, int ipacmd) |
|---|
| 315 | + struct qeth_ipaddr *addr, |
|---|
| 316 | + enum qeth_ipa_cmds ipacmd) |
|---|
| 345 | 317 | { |
|---|
| 346 | | - int rc; |
|---|
| 347 | 318 | struct qeth_cmd_buffer *iob; |
|---|
| 348 | 319 | struct qeth_ipa_cmd *cmd; |
|---|
| 349 | 320 | |
|---|
| 350 | 321 | QETH_CARD_TEXT(card, 4, "setdelmc"); |
|---|
| 351 | 322 | |
|---|
| 352 | | - iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto); |
|---|
| 323 | + iob = qeth_ipa_alloc_cmd(card, ipacmd, addr->proto, |
|---|
| 324 | + IPA_DATA_SIZEOF(setdelipm)); |
|---|
| 353 | 325 | if (!iob) |
|---|
| 354 | 326 | return -ENOMEM; |
|---|
| 355 | 327 | cmd = __ipa_cmd(iob); |
|---|
| 356 | | - ether_addr_copy(cmd->data.setdelipm.mac, addr->mac); |
|---|
| 357 | | - if (addr->proto == QETH_PROT_IPV6) |
|---|
| 358 | | - memcpy(cmd->data.setdelipm.ip6, &addr->u.a6.addr, |
|---|
| 359 | | - sizeof(struct in6_addr)); |
|---|
| 360 | | - else |
|---|
| 361 | | - memcpy(&cmd->data.setdelipm.ip4, &addr->u.a4.addr, 4); |
|---|
| 328 | + if (addr->proto == QETH_PROT_IPV6) { |
|---|
| 329 | + cmd->data.setdelipm.ip = addr->u.a6.addr; |
|---|
| 330 | + ipv6_eth_mc_map(&addr->u.a6.addr, cmd->data.setdelipm.mac); |
|---|
| 331 | + } else { |
|---|
| 332 | + cmd->data.setdelipm.ip.s6_addr32[3] = addr->u.a4.addr; |
|---|
| 333 | + ip_eth_mc_map(addr->u.a4.addr, cmd->data.setdelipm.mac); |
|---|
| 334 | + } |
|---|
| 362 | 335 | |
|---|
| 363 | | - rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); |
|---|
| 364 | | - |
|---|
| 365 | | - return rc; |
|---|
| 336 | + return qeth_send_ipa_cmd(card, iob, qeth_l3_setdelip_cb, NULL); |
|---|
| 366 | 337 | } |
|---|
| 367 | 338 | |
|---|
| 368 | | -static void qeth_l3_fill_netmask(u8 *netmask, unsigned int len) |
|---|
| 339 | +static void qeth_l3_set_ipv6_prefix(struct in6_addr *prefix, unsigned int len) |
|---|
| 369 | 340 | { |
|---|
| 370 | | - int i, j; |
|---|
| 371 | | - for (i = 0; i < 16; i++) { |
|---|
| 372 | | - j = (len) - (i * 8); |
|---|
| 373 | | - if (j >= 8) |
|---|
| 374 | | - netmask[i] = 0xff; |
|---|
| 375 | | - else if (j > 0) |
|---|
| 376 | | - netmask[i] = (u8)(0xFF00 >> j); |
|---|
| 377 | | - else |
|---|
| 378 | | - netmask[i] = 0; |
|---|
| 341 | + unsigned int i = 0; |
|---|
| 342 | + |
|---|
| 343 | + while (len && i < 4) { |
|---|
| 344 | + int mask_len = min_t(int, len, 32); |
|---|
| 345 | + |
|---|
| 346 | + prefix->s6_addr32[i] = inet_make_mask(mask_len); |
|---|
| 347 | + len -= mask_len; |
|---|
| 348 | + i++; |
|---|
| 379 | 349 | } |
|---|
| 380 | 350 | } |
|---|
| 381 | 351 | |
|---|
| .. | .. |
|---|
| 398 | 368 | { |
|---|
| 399 | 369 | struct qeth_cmd_buffer *iob; |
|---|
| 400 | 370 | struct qeth_ipa_cmd *cmd; |
|---|
| 401 | | - __u8 netmask[16]; |
|---|
| 402 | 371 | u32 flags; |
|---|
| 403 | 372 | |
|---|
| 404 | 373 | QETH_CARD_TEXT(card, 4, "setdelip"); |
|---|
| 405 | 374 | |
|---|
| 406 | | - iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto); |
|---|
| 375 | + iob = qeth_ipa_alloc_cmd(card, ipacmd, addr->proto, |
|---|
| 376 | + IPA_DATA_SIZEOF(setdelip6)); |
|---|
| 407 | 377 | if (!iob) |
|---|
| 408 | 378 | return -ENOMEM; |
|---|
| 409 | 379 | cmd = __ipa_cmd(iob); |
|---|
| .. | .. |
|---|
| 412 | 382 | QETH_CARD_TEXT_(card, 4, "flags%02X", flags); |
|---|
| 413 | 383 | |
|---|
| 414 | 384 | if (addr->proto == QETH_PROT_IPV6) { |
|---|
| 415 | | - memcpy(cmd->data.setdelip6.ip_addr, &addr->u.a6.addr, |
|---|
| 416 | | - sizeof(struct in6_addr)); |
|---|
| 417 | | - qeth_l3_fill_netmask(netmask, addr->u.a6.pfxlen); |
|---|
| 418 | | - memcpy(cmd->data.setdelip6.mask, netmask, |
|---|
| 419 | | - sizeof(struct in6_addr)); |
|---|
| 385 | + cmd->data.setdelip6.addr = addr->u.a6.addr; |
|---|
| 386 | + qeth_l3_set_ipv6_prefix(&cmd->data.setdelip6.prefix, |
|---|
| 387 | + addr->u.a6.pfxlen); |
|---|
| 420 | 388 | cmd->data.setdelip6.flags = flags; |
|---|
| 421 | 389 | } else { |
|---|
| 422 | | - memcpy(cmd->data.setdelip4.ip_addr, &addr->u.a4.addr, 4); |
|---|
| 423 | | - memcpy(cmd->data.setdelip4.mask, &addr->u.a4.mask, 4); |
|---|
| 390 | + cmd->data.setdelip4.addr = addr->u.a4.addr; |
|---|
| 391 | + cmd->data.setdelip4.mask = addr->u.a4.mask; |
|---|
| 424 | 392 | cmd->data.setdelip4.flags = flags; |
|---|
| 425 | 393 | } |
|---|
| 426 | 394 | |
|---|
| 427 | | - return qeth_send_ipa_cmd(card, iob, NULL, NULL); |
|---|
| 395 | + return qeth_send_ipa_cmd(card, iob, qeth_l3_setdelip_cb, NULL); |
|---|
| 428 | 396 | } |
|---|
| 429 | 397 | |
|---|
| 430 | 398 | static int qeth_l3_send_setrouting(struct qeth_card *card, |
|---|
| .. | .. |
|---|
| 435 | 403 | struct qeth_cmd_buffer *iob; |
|---|
| 436 | 404 | |
|---|
| 437 | 405 | QETH_CARD_TEXT(card, 4, "setroutg"); |
|---|
| 438 | | - iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETRTG, prot); |
|---|
| 406 | + iob = qeth_ipa_alloc_cmd(card, IPA_CMD_SETRTG, prot, |
|---|
| 407 | + IPA_DATA_SIZEOF(setrtg)); |
|---|
| 439 | 408 | if (!iob) |
|---|
| 440 | 409 | return -ENOMEM; |
|---|
| 441 | 410 | cmd = __ipa_cmd(iob); |
|---|
| .. | .. |
|---|
| 448 | 417 | static int qeth_l3_correct_routing_type(struct qeth_card *card, |
|---|
| 449 | 418 | enum qeth_routing_types *type, enum qeth_prot_versions prot) |
|---|
| 450 | 419 | { |
|---|
| 451 | | - if (card->info.type == QETH_CARD_TYPE_IQD) { |
|---|
| 420 | + if (IS_IQD(card)) { |
|---|
| 452 | 421 | switch (*type) { |
|---|
| 453 | 422 | case NO_ROUTER: |
|---|
| 454 | 423 | case PRIMARY_CONNECTOR: |
|---|
| .. | .. |
|---|
| 492 | 461 | QETH_PROT_IPV4); |
|---|
| 493 | 462 | if (rc) { |
|---|
| 494 | 463 | card->options.route4.type = NO_ROUTER; |
|---|
| 495 | | - QETH_DBF_MESSAGE(2, "Error (0x%04x) while setting routing type" |
|---|
| 496 | | - " on %s. Type set to 'no router'.\n", rc, |
|---|
| 497 | | - QETH_CARD_IFNAME(card)); |
|---|
| 464 | + QETH_DBF_MESSAGE(2, "Error (%#06x) while setting routing type on device %x. Type set to 'no router'.\n", |
|---|
| 465 | + rc, CARD_DEVID(card)); |
|---|
| 498 | 466 | } |
|---|
| 499 | 467 | return rc; |
|---|
| 500 | 468 | } |
|---|
| .. | .. |
|---|
| 516 | 484 | QETH_PROT_IPV6); |
|---|
| 517 | 485 | if (rc) { |
|---|
| 518 | 486 | card->options.route6.type = NO_ROUTER; |
|---|
| 519 | | - QETH_DBF_MESSAGE(2, "Error (0x%04x) while setting routing type" |
|---|
| 520 | | - " on %s. Type set to 'no router'.\n", rc, |
|---|
| 521 | | - QETH_CARD_IFNAME(card)); |
|---|
| 487 | + QETH_DBF_MESSAGE(2, "Error (%#06x) while setting routing type on device %x. Type set to 'no router'.\n", |
|---|
| 488 | + rc, CARD_DEVID(card)); |
|---|
| 522 | 489 | } |
|---|
| 523 | 490 | return rc; |
|---|
| 524 | 491 | } |
|---|
| .. | .. |
|---|
| 548 | 515 | { |
|---|
| 549 | 516 | struct qeth_ipato_entry *ipatoe, *tmp; |
|---|
| 550 | 517 | |
|---|
| 551 | | - spin_lock_bh(&card->ip_lock); |
|---|
| 518 | + mutex_lock(&card->ip_lock); |
|---|
| 552 | 519 | |
|---|
| 553 | 520 | list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) { |
|---|
| 554 | 521 | list_del(&ipatoe->entry); |
|---|
| .. | .. |
|---|
| 556 | 523 | } |
|---|
| 557 | 524 | |
|---|
| 558 | 525 | qeth_l3_update_ipato(card); |
|---|
| 559 | | - spin_unlock_bh(&card->ip_lock); |
|---|
| 526 | + mutex_unlock(&card->ip_lock); |
|---|
| 560 | 527 | } |
|---|
| 561 | 528 | |
|---|
| 562 | 529 | int qeth_l3_add_ipato_entry(struct qeth_card *card, |
|---|
| .. | .. |
|---|
| 567 | 534 | |
|---|
| 568 | 535 | QETH_CARD_TEXT(card, 2, "addipato"); |
|---|
| 569 | 536 | |
|---|
| 570 | | - spin_lock_bh(&card->ip_lock); |
|---|
| 537 | + mutex_lock(&card->ip_lock); |
|---|
| 571 | 538 | |
|---|
| 572 | 539 | list_for_each_entry(ipatoe, &card->ipato.entries, entry) { |
|---|
| 573 | 540 | if (ipatoe->proto != new->proto) |
|---|
| 574 | 541 | continue; |
|---|
| 575 | 542 | if (!memcmp(ipatoe->addr, new->addr, |
|---|
| 576 | | - (ipatoe->proto == QETH_PROT_IPV4)? 4:16) && |
|---|
| 543 | + (ipatoe->proto == QETH_PROT_IPV4) ? 4 : 16) && |
|---|
| 577 | 544 | (ipatoe->mask_bits == new->mask_bits)) { |
|---|
| 578 | 545 | rc = -EEXIST; |
|---|
| 579 | 546 | break; |
|---|
| .. | .. |
|---|
| 585 | 552 | qeth_l3_update_ipato(card); |
|---|
| 586 | 553 | } |
|---|
| 587 | 554 | |
|---|
| 588 | | - spin_unlock_bh(&card->ip_lock); |
|---|
| 555 | + mutex_unlock(&card->ip_lock); |
|---|
| 589 | 556 | |
|---|
| 590 | 557 | return rc; |
|---|
| 591 | 558 | } |
|---|
| 592 | 559 | |
|---|
| 593 | 560 | int qeth_l3_del_ipato_entry(struct qeth_card *card, |
|---|
| 594 | 561 | enum qeth_prot_versions proto, u8 *addr, |
|---|
| 595 | | - int mask_bits) |
|---|
| 562 | + unsigned int mask_bits) |
|---|
| 596 | 563 | { |
|---|
| 597 | 564 | struct qeth_ipato_entry *ipatoe, *tmp; |
|---|
| 598 | 565 | int rc = -ENOENT; |
|---|
| 599 | 566 | |
|---|
| 600 | 567 | QETH_CARD_TEXT(card, 2, "delipato"); |
|---|
| 601 | 568 | |
|---|
| 602 | | - spin_lock_bh(&card->ip_lock); |
|---|
| 569 | + mutex_lock(&card->ip_lock); |
|---|
| 603 | 570 | |
|---|
| 604 | 571 | list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) { |
|---|
| 605 | 572 | if (ipatoe->proto != proto) |
|---|
| 606 | 573 | continue; |
|---|
| 607 | 574 | if (!memcmp(ipatoe->addr, addr, |
|---|
| 608 | | - (proto == QETH_PROT_IPV4)? 4:16) && |
|---|
| 575 | + (proto == QETH_PROT_IPV4) ? 4 : 16) && |
|---|
| 609 | 576 | (ipatoe->mask_bits == mask_bits)) { |
|---|
| 610 | 577 | list_del(&ipatoe->entry); |
|---|
| 611 | 578 | qeth_l3_update_ipato(card); |
|---|
| .. | .. |
|---|
| 614 | 581 | } |
|---|
| 615 | 582 | } |
|---|
| 616 | 583 | |
|---|
| 617 | | - spin_unlock_bh(&card->ip_lock); |
|---|
| 584 | + mutex_unlock(&card->ip_lock); |
|---|
| 585 | + |
|---|
| 618 | 586 | return rc; |
|---|
| 619 | 587 | } |
|---|
| 620 | 588 | |
|---|
| .. | .. |
|---|
| 623 | 591 | enum qeth_prot_versions proto) |
|---|
| 624 | 592 | { |
|---|
| 625 | 593 | struct qeth_ipaddr addr; |
|---|
| 626 | | - int rc; |
|---|
| 627 | 594 | |
|---|
| 628 | 595 | qeth_l3_init_ipaddr(&addr, type, proto); |
|---|
| 629 | 596 | if (proto == QETH_PROT_IPV4) |
|---|
| .. | .. |
|---|
| 631 | 598 | else |
|---|
| 632 | 599 | memcpy(&addr.u.a6.addr, ip, 16); |
|---|
| 633 | 600 | |
|---|
| 634 | | - spin_lock_bh(&card->ip_lock); |
|---|
| 635 | | - rc = add ? qeth_l3_add_ip(card, &addr) : qeth_l3_delete_ip(card, &addr); |
|---|
| 636 | | - spin_unlock_bh(&card->ip_lock); |
|---|
| 637 | | - return rc; |
|---|
| 601 | + return qeth_l3_modify_ip(card, &addr, add); |
|---|
| 638 | 602 | } |
|---|
| 639 | 603 | |
|---|
| 640 | 604 | int qeth_l3_modify_hsuid(struct qeth_card *card, bool add) |
|---|
| 641 | 605 | { |
|---|
| 642 | 606 | struct qeth_ipaddr addr; |
|---|
| 643 | | - int rc, i; |
|---|
| 607 | + unsigned int i; |
|---|
| 644 | 608 | |
|---|
| 645 | 609 | qeth_l3_init_ipaddr(&addr, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV6); |
|---|
| 646 | 610 | addr.u.a6.addr.s6_addr[0] = 0xfe; |
|---|
| .. | .. |
|---|
| 648 | 612 | for (i = 0; i < 8; i++) |
|---|
| 649 | 613 | addr.u.a6.addr.s6_addr[8+i] = card->options.hsuid[i]; |
|---|
| 650 | 614 | |
|---|
| 651 | | - spin_lock_bh(&card->ip_lock); |
|---|
| 652 | | - rc = add ? qeth_l3_add_ip(card, &addr) : qeth_l3_delete_ip(card, &addr); |
|---|
| 653 | | - spin_unlock_bh(&card->ip_lock); |
|---|
| 654 | | - return rc; |
|---|
| 615 | + return qeth_l3_modify_ip(card, &addr, add); |
|---|
| 655 | 616 | } |
|---|
| 656 | 617 | |
|---|
| 657 | 618 | static int qeth_l3_register_addr_entry(struct qeth_card *card, |
|---|
| .. | .. |
|---|
| 725 | 686 | { |
|---|
| 726 | 687 | int rc = 0; |
|---|
| 727 | 688 | |
|---|
| 728 | | - QETH_DBF_TEXT(SETUP, 2, "setadprm"); |
|---|
| 689 | + QETH_CARD_TEXT(card, 2, "setadprm"); |
|---|
| 729 | 690 | |
|---|
| 730 | 691 | if (qeth_adp_supported(card, IPA_SETADP_ALTER_MAC_ADDRESS)) { |
|---|
| 731 | 692 | rc = qeth_setadpparms_change_macaddr(card); |
|---|
| .. | .. |
|---|
| 745 | 706 | |
|---|
| 746 | 707 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
|---|
| 747 | 708 | dev_info(&card->gdev->dev, |
|---|
| 748 | | - "ARP processing not supported on %s!\n", |
|---|
| 749 | | - QETH_CARD_IFNAME(card)); |
|---|
| 709 | + "ARP processing not supported on %s!\n", |
|---|
| 710 | + netdev_name(card->dev)); |
|---|
| 750 | 711 | return 0; |
|---|
| 751 | 712 | } |
|---|
| 752 | 713 | rc = qeth_send_simple_setassparms(card, IPA_ARP_PROCESSING, |
|---|
| 753 | | - IPA_CMD_ASS_START, 0); |
|---|
| 714 | + IPA_CMD_ASS_START, NULL); |
|---|
| 754 | 715 | if (rc) { |
|---|
| 755 | 716 | dev_warn(&card->gdev->dev, |
|---|
| 756 | | - "Starting ARP processing support for %s failed\n", |
|---|
| 757 | | - QETH_CARD_IFNAME(card)); |
|---|
| 717 | + "Starting ARP processing support for %s failed\n", |
|---|
| 718 | + netdev_name(card->dev)); |
|---|
| 758 | 719 | } |
|---|
| 759 | 720 | return rc; |
|---|
| 760 | 721 | } |
|---|
| .. | .. |
|---|
| 767 | 728 | |
|---|
| 768 | 729 | if (!qeth_is_supported(card, IPA_SOURCE_MAC)) { |
|---|
| 769 | 730 | dev_info(&card->gdev->dev, |
|---|
| 770 | | - "Inbound source MAC-address not supported on %s\n", |
|---|
| 771 | | - QETH_CARD_IFNAME(card)); |
|---|
| 731 | + "Inbound source MAC-address not supported on %s\n", |
|---|
| 732 | + netdev_name(card->dev)); |
|---|
| 772 | 733 | return -EOPNOTSUPP; |
|---|
| 773 | 734 | } |
|---|
| 774 | 735 | |
|---|
| 775 | 736 | rc = qeth_send_simple_setassparms(card, IPA_SOURCE_MAC, |
|---|
| 776 | | - IPA_CMD_ASS_START, 0); |
|---|
| 737 | + IPA_CMD_ASS_START, NULL); |
|---|
| 777 | 738 | if (rc) |
|---|
| 778 | 739 | dev_warn(&card->gdev->dev, |
|---|
| 779 | | - "Starting source MAC-address support for %s failed\n", |
|---|
| 780 | | - QETH_CARD_IFNAME(card)); |
|---|
| 740 | + "Starting source MAC-address support for %s failed\n", |
|---|
| 741 | + netdev_name(card->dev)); |
|---|
| 781 | 742 | return rc; |
|---|
| 782 | 743 | } |
|---|
| 783 | 744 | |
|---|
| .. | .. |
|---|
| 789 | 750 | |
|---|
| 790 | 751 | if (!qeth_is_supported(card, IPA_FULL_VLAN)) { |
|---|
| 791 | 752 | dev_info(&card->gdev->dev, |
|---|
| 792 | | - "VLAN not supported on %s\n", QETH_CARD_IFNAME(card)); |
|---|
| 753 | + "VLAN not supported on %s\n", netdev_name(card->dev)); |
|---|
| 793 | 754 | return -EOPNOTSUPP; |
|---|
| 794 | 755 | } |
|---|
| 795 | 756 | |
|---|
| 796 | 757 | rc = qeth_send_simple_setassparms(card, IPA_VLAN_PRIO, |
|---|
| 797 | | - IPA_CMD_ASS_START, 0); |
|---|
| 758 | + IPA_CMD_ASS_START, NULL); |
|---|
| 798 | 759 | if (rc) { |
|---|
| 799 | 760 | dev_warn(&card->gdev->dev, |
|---|
| 800 | | - "Starting VLAN support for %s failed\n", |
|---|
| 801 | | - QETH_CARD_IFNAME(card)); |
|---|
| 761 | + "Starting VLAN support for %s failed\n", |
|---|
| 762 | + netdev_name(card->dev)); |
|---|
| 802 | 763 | } else { |
|---|
| 803 | 764 | dev_info(&card->gdev->dev, "VLAN enabled\n"); |
|---|
| 804 | 765 | } |
|---|
| .. | .. |
|---|
| 813 | 774 | |
|---|
| 814 | 775 | if (!qeth_is_supported(card, IPA_MULTICASTING)) { |
|---|
| 815 | 776 | dev_info(&card->gdev->dev, |
|---|
| 816 | | - "Multicast not supported on %s\n", |
|---|
| 817 | | - QETH_CARD_IFNAME(card)); |
|---|
| 777 | + "Multicast not supported on %s\n", |
|---|
| 778 | + netdev_name(card->dev)); |
|---|
| 818 | 779 | return -EOPNOTSUPP; |
|---|
| 819 | 780 | } |
|---|
| 820 | 781 | |
|---|
| 821 | 782 | rc = qeth_send_simple_setassparms(card, IPA_MULTICASTING, |
|---|
| 822 | | - IPA_CMD_ASS_START, 0); |
|---|
| 783 | + IPA_CMD_ASS_START, NULL); |
|---|
| 823 | 784 | if (rc) { |
|---|
| 824 | 785 | dev_warn(&card->gdev->dev, |
|---|
| 825 | | - "Starting multicast support for %s failed\n", |
|---|
| 826 | | - QETH_CARD_IFNAME(card)); |
|---|
| 786 | + "Starting multicast support for %s failed\n", |
|---|
| 787 | + netdev_name(card->dev)); |
|---|
| 827 | 788 | } else { |
|---|
| 828 | 789 | dev_info(&card->gdev->dev, "Multicast enabled\n"); |
|---|
| 829 | 790 | card->dev->flags |= IFF_MULTICAST; |
|---|
| .. | .. |
|---|
| 833 | 794 | |
|---|
| 834 | 795 | static int qeth_l3_softsetup_ipv6(struct qeth_card *card) |
|---|
| 835 | 796 | { |
|---|
| 797 | + u32 ipv6_data = 3; |
|---|
| 836 | 798 | int rc; |
|---|
| 837 | 799 | |
|---|
| 838 | 800 | QETH_CARD_TEXT(card, 3, "softipv6"); |
|---|
| 839 | 801 | |
|---|
| 840 | | - if (card->info.type == QETH_CARD_TYPE_IQD) |
|---|
| 802 | + if (IS_IQD(card)) |
|---|
| 841 | 803 | goto out; |
|---|
| 842 | 804 | |
|---|
| 843 | | - rc = qeth_send_simple_setassparms(card, IPA_IPV6, |
|---|
| 844 | | - IPA_CMD_ASS_START, 3); |
|---|
| 805 | + rc = qeth_send_simple_setassparms(card, IPA_IPV6, IPA_CMD_ASS_START, |
|---|
| 806 | + &ipv6_data); |
|---|
| 845 | 807 | if (rc) { |
|---|
| 846 | 808 | dev_err(&card->gdev->dev, |
|---|
| 847 | 809 | "Activating IPv6 support for %s failed\n", |
|---|
| 848 | | - QETH_CARD_IFNAME(card)); |
|---|
| 810 | + netdev_name(card->dev)); |
|---|
| 849 | 811 | return rc; |
|---|
| 850 | 812 | } |
|---|
| 851 | | - rc = qeth_send_simple_setassparms_v6(card, IPA_IPV6, |
|---|
| 852 | | - IPA_CMD_ASS_START, 0); |
|---|
| 813 | + rc = qeth_send_simple_setassparms_v6(card, IPA_IPV6, IPA_CMD_ASS_START, |
|---|
| 814 | + NULL); |
|---|
| 853 | 815 | if (rc) { |
|---|
| 854 | 816 | dev_err(&card->gdev->dev, |
|---|
| 855 | 817 | "Activating IPv6 support for %s failed\n", |
|---|
| 856 | | - QETH_CARD_IFNAME(card)); |
|---|
| 818 | + netdev_name(card->dev)); |
|---|
| 857 | 819 | return rc; |
|---|
| 858 | 820 | } |
|---|
| 859 | 821 | rc = qeth_send_simple_setassparms_v6(card, IPA_PASSTHRU, |
|---|
| 860 | | - IPA_CMD_ASS_START, 0); |
|---|
| 822 | + IPA_CMD_ASS_START, NULL); |
|---|
| 861 | 823 | if (rc) { |
|---|
| 862 | 824 | dev_warn(&card->gdev->dev, |
|---|
| 863 | | - "Enabling the passthrough mode for %s failed\n", |
|---|
| 864 | | - QETH_CARD_IFNAME(card)); |
|---|
| 825 | + "Enabling the passthrough mode for %s failed\n", |
|---|
| 826 | + netdev_name(card->dev)); |
|---|
| 865 | 827 | return rc; |
|---|
| 866 | 828 | } |
|---|
| 867 | 829 | out: |
|---|
| .. | .. |
|---|
| 875 | 837 | |
|---|
| 876 | 838 | if (!qeth_is_supported(card, IPA_IPV6)) { |
|---|
| 877 | 839 | dev_info(&card->gdev->dev, |
|---|
| 878 | | - "IPv6 not supported on %s\n", QETH_CARD_IFNAME(card)); |
|---|
| 840 | + "IPv6 not supported on %s\n", netdev_name(card->dev)); |
|---|
| 879 | 841 | return 0; |
|---|
| 880 | 842 | } |
|---|
| 881 | 843 | return qeth_l3_softsetup_ipv6(card); |
|---|
| .. | .. |
|---|
| 883 | 845 | |
|---|
| 884 | 846 | static int qeth_l3_start_ipa_broadcast(struct qeth_card *card) |
|---|
| 885 | 847 | { |
|---|
| 848 | + u32 filter_data = 1; |
|---|
| 886 | 849 | int rc; |
|---|
| 887 | 850 | |
|---|
| 888 | 851 | QETH_CARD_TEXT(card, 3, "stbrdcst"); |
|---|
| 889 | 852 | card->info.broadcast_capable = 0; |
|---|
| 890 | 853 | if (!qeth_is_supported(card, IPA_FILTERING)) { |
|---|
| 891 | 854 | dev_info(&card->gdev->dev, |
|---|
| 892 | | - "Broadcast not supported on %s\n", |
|---|
| 893 | | - QETH_CARD_IFNAME(card)); |
|---|
| 855 | + "Broadcast not supported on %s\n", |
|---|
| 856 | + netdev_name(card->dev)); |
|---|
| 894 | 857 | rc = -EOPNOTSUPP; |
|---|
| 895 | 858 | goto out; |
|---|
| 896 | 859 | } |
|---|
| 897 | 860 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, |
|---|
| 898 | | - IPA_CMD_ASS_START, 0); |
|---|
| 861 | + IPA_CMD_ASS_START, NULL); |
|---|
| 899 | 862 | if (rc) { |
|---|
| 900 | | - dev_warn(&card->gdev->dev, "Enabling broadcast filtering for " |
|---|
| 901 | | - "%s failed\n", QETH_CARD_IFNAME(card)); |
|---|
| 863 | + dev_warn(&card->gdev->dev, |
|---|
| 864 | + "Enabling broadcast filtering for %s failed\n", |
|---|
| 865 | + netdev_name(card->dev)); |
|---|
| 902 | 866 | goto out; |
|---|
| 903 | 867 | } |
|---|
| 904 | 868 | |
|---|
| 905 | 869 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, |
|---|
| 906 | | - IPA_CMD_ASS_CONFIGURE, 1); |
|---|
| 870 | + IPA_CMD_ASS_CONFIGURE, &filter_data); |
|---|
| 907 | 871 | if (rc) { |
|---|
| 908 | 872 | dev_warn(&card->gdev->dev, |
|---|
| 909 | | - "Setting up broadcast filtering for %s failed\n", |
|---|
| 910 | | - QETH_CARD_IFNAME(card)); |
|---|
| 873 | + "Setting up broadcast filtering for %s failed\n", |
|---|
| 874 | + netdev_name(card->dev)); |
|---|
| 911 | 875 | goto out; |
|---|
| 912 | 876 | } |
|---|
| 913 | 877 | card->info.broadcast_capable = QETH_BROADCAST_WITH_ECHO; |
|---|
| 914 | 878 | dev_info(&card->gdev->dev, "Broadcast enabled\n"); |
|---|
| 915 | 879 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, |
|---|
| 916 | | - IPA_CMD_ASS_ENABLE, 1); |
|---|
| 880 | + IPA_CMD_ASS_ENABLE, &filter_data); |
|---|
| 917 | 881 | if (rc) { |
|---|
| 918 | | - dev_warn(&card->gdev->dev, "Setting up broadcast echo " |
|---|
| 919 | | - "filtering for %s failed\n", QETH_CARD_IFNAME(card)); |
|---|
| 882 | + dev_warn(&card->gdev->dev, |
|---|
| 883 | + "Setting up broadcast echo filtering for %s failed\n", |
|---|
| 884 | + netdev_name(card->dev)); |
|---|
| 920 | 885 | goto out; |
|---|
| 921 | 886 | } |
|---|
| 922 | 887 | card->info.broadcast_capable = QETH_BROADCAST_WITHOUT_ECHO; |
|---|
| .. | .. |
|---|
| 928 | 893 | return rc; |
|---|
| 929 | 894 | } |
|---|
| 930 | 895 | |
|---|
| 931 | | -static int qeth_l3_start_ipassists(struct qeth_card *card) |
|---|
| 896 | +static void qeth_l3_start_ipassists(struct qeth_card *card) |
|---|
| 932 | 897 | { |
|---|
| 933 | 898 | QETH_CARD_TEXT(card, 3, "strtipas"); |
|---|
| 934 | 899 | |
|---|
| 935 | | - if (qeth_set_access_ctrl_online(card, 0)) |
|---|
| 936 | | - return -EIO; |
|---|
| 937 | 900 | qeth_l3_start_ipa_arp_processing(card); /* go on*/ |
|---|
| 938 | 901 | qeth_l3_start_ipa_source_mac(card); /* go on*/ |
|---|
| 939 | 902 | qeth_l3_start_ipa_vlan(card); /* go on*/ |
|---|
| 940 | 903 | qeth_l3_start_ipa_multicast(card); /* go on*/ |
|---|
| 941 | 904 | qeth_l3_start_ipa_ipv6(card); /* go on*/ |
|---|
| 942 | 905 | qeth_l3_start_ipa_broadcast(card); /* go on*/ |
|---|
| 943 | | - return 0; |
|---|
| 944 | 906 | } |
|---|
| 945 | 907 | |
|---|
| 946 | 908 | static int qeth_l3_iqd_read_initial_mac_cb(struct qeth_card *card, |
|---|
| 947 | 909 | struct qeth_reply *reply, unsigned long data) |
|---|
| 948 | 910 | { |
|---|
| 949 | | - struct qeth_ipa_cmd *cmd; |
|---|
| 911 | + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
|---|
| 950 | 912 | |
|---|
| 951 | | - cmd = (struct qeth_ipa_cmd *) data; |
|---|
| 952 | | - if (cmd->hdr.return_code == 0) |
|---|
| 953 | | - ether_addr_copy(card->dev->dev_addr, |
|---|
| 954 | | - cmd->data.create_destroy_addr.unique_id); |
|---|
| 955 | | - else |
|---|
| 956 | | - eth_random_addr(card->dev->dev_addr); |
|---|
| 913 | + if (cmd->hdr.return_code) |
|---|
| 914 | + return -EIO; |
|---|
| 915 | + if (!is_valid_ether_addr(cmd->data.create_destroy_addr.mac_addr)) |
|---|
| 916 | + return -EADDRNOTAVAIL; |
|---|
| 957 | 917 | |
|---|
| 918 | + ether_addr_copy(card->dev->dev_addr, |
|---|
| 919 | + cmd->data.create_destroy_addr.mac_addr); |
|---|
| 958 | 920 | return 0; |
|---|
| 959 | 921 | } |
|---|
| 960 | 922 | |
|---|
| .. | .. |
|---|
| 962 | 924 | { |
|---|
| 963 | 925 | int rc = 0; |
|---|
| 964 | 926 | struct qeth_cmd_buffer *iob; |
|---|
| 965 | | - struct qeth_ipa_cmd *cmd; |
|---|
| 966 | 927 | |
|---|
| 967 | | - QETH_DBF_TEXT(SETUP, 2, "hsrmac"); |
|---|
| 928 | + QETH_CARD_TEXT(card, 2, "hsrmac"); |
|---|
| 968 | 929 | |
|---|
| 969 | | - iob = qeth_get_ipacmd_buffer(card, IPA_CMD_CREATE_ADDR, |
|---|
| 970 | | - QETH_PROT_IPV6); |
|---|
| 930 | + iob = qeth_ipa_alloc_cmd(card, IPA_CMD_CREATE_ADDR, QETH_PROT_IPV6, |
|---|
| 931 | + IPA_DATA_SIZEOF(create_destroy_addr)); |
|---|
| 971 | 932 | if (!iob) |
|---|
| 972 | 933 | return -ENOMEM; |
|---|
| 973 | | - cmd = __ipa_cmd(iob); |
|---|
| 974 | | - *((__u16 *) &cmd->data.create_destroy_addr.unique_id[6]) = |
|---|
| 975 | | - card->info.unique_id; |
|---|
| 976 | 934 | |
|---|
| 977 | 935 | rc = qeth_send_ipa_cmd(card, iob, qeth_l3_iqd_read_initial_mac_cb, |
|---|
| 978 | 936 | NULL); |
|---|
| .. | .. |
|---|
| 982 | 940 | static int qeth_l3_get_unique_id_cb(struct qeth_card *card, |
|---|
| 983 | 941 | struct qeth_reply *reply, unsigned long data) |
|---|
| 984 | 942 | { |
|---|
| 985 | | - struct qeth_ipa_cmd *cmd; |
|---|
| 943 | + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
|---|
| 944 | + u16 *uid = reply->param; |
|---|
| 986 | 945 | |
|---|
| 987 | | - cmd = (struct qeth_ipa_cmd *) data; |
|---|
| 988 | | - if (cmd->hdr.return_code == 0) |
|---|
| 989 | | - card->info.unique_id = *((__u16 *) |
|---|
| 990 | | - &cmd->data.create_destroy_addr.unique_id[6]); |
|---|
| 991 | | - else { |
|---|
| 992 | | - card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED | |
|---|
| 993 | | - UNIQUE_ID_NOT_BY_CARD; |
|---|
| 994 | | - dev_warn(&card->gdev->dev, "The network adapter failed to " |
|---|
| 995 | | - "generate a unique ID\n"); |
|---|
| 996 | | - } |
|---|
| 997 | | - return 0; |
|---|
| 998 | | -} |
|---|
| 999 | | - |
|---|
| 1000 | | -static int qeth_l3_get_unique_id(struct qeth_card *card) |
|---|
| 1001 | | -{ |
|---|
| 1002 | | - int rc = 0; |
|---|
| 1003 | | - struct qeth_cmd_buffer *iob; |
|---|
| 1004 | | - struct qeth_ipa_cmd *cmd; |
|---|
| 1005 | | - |
|---|
| 1006 | | - QETH_DBF_TEXT(SETUP, 2, "guniqeid"); |
|---|
| 1007 | | - |
|---|
| 1008 | | - if (!qeth_is_supported(card, IPA_IPV6)) { |
|---|
| 1009 | | - card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED | |
|---|
| 1010 | | - UNIQUE_ID_NOT_BY_CARD; |
|---|
| 946 | + if (cmd->hdr.return_code == 0) { |
|---|
| 947 | + *uid = cmd->data.create_destroy_addr.uid; |
|---|
| 1011 | 948 | return 0; |
|---|
| 1012 | 949 | } |
|---|
| 1013 | 950 | |
|---|
| 1014 | | - iob = qeth_get_ipacmd_buffer(card, IPA_CMD_CREATE_ADDR, |
|---|
| 1015 | | - QETH_PROT_IPV6); |
|---|
| 1016 | | - if (!iob) |
|---|
| 1017 | | - return -ENOMEM; |
|---|
| 1018 | | - cmd = __ipa_cmd(iob); |
|---|
| 1019 | | - *((__u16 *) &cmd->data.create_destroy_addr.unique_id[6]) = |
|---|
| 1020 | | - card->info.unique_id; |
|---|
| 951 | + dev_warn(&card->gdev->dev, "The network adapter failed to generate a unique ID\n"); |
|---|
| 952 | + return -EIO; |
|---|
| 953 | +} |
|---|
| 1021 | 954 | |
|---|
| 1022 | | - rc = qeth_send_ipa_cmd(card, iob, qeth_l3_get_unique_id_cb, NULL); |
|---|
| 1023 | | - return rc; |
|---|
| 955 | +static u16 qeth_l3_get_unique_id(struct qeth_card *card, u16 uid) |
|---|
| 956 | +{ |
|---|
| 957 | + struct qeth_cmd_buffer *iob; |
|---|
| 958 | + |
|---|
| 959 | + QETH_CARD_TEXT(card, 2, "guniqeid"); |
|---|
| 960 | + |
|---|
| 961 | + if (!qeth_is_supported(card, IPA_IPV6)) |
|---|
| 962 | + goto out; |
|---|
| 963 | + |
|---|
| 964 | + iob = qeth_ipa_alloc_cmd(card, IPA_CMD_CREATE_ADDR, QETH_PROT_IPV6, |
|---|
| 965 | + IPA_DATA_SIZEOF(create_destroy_addr)); |
|---|
| 966 | + if (!iob) |
|---|
| 967 | + goto out; |
|---|
| 968 | + |
|---|
| 969 | + __ipa_cmd(iob)->data.create_destroy_addr.uid = uid; |
|---|
| 970 | + qeth_send_ipa_cmd(card, iob, qeth_l3_get_unique_id_cb, &uid); |
|---|
| 971 | + |
|---|
| 972 | +out: |
|---|
| 973 | + return uid; |
|---|
| 1024 | 974 | } |
|---|
| 1025 | 975 | |
|---|
| 1026 | 976 | static int |
|---|
| .. | .. |
|---|
| 1030 | 980 | struct qeth_ipa_cmd *cmd; |
|---|
| 1031 | 981 | __u16 rc; |
|---|
| 1032 | 982 | |
|---|
| 1033 | | - QETH_DBF_TEXT(SETUP, 2, "diastrcb"); |
|---|
| 983 | + QETH_CARD_TEXT(card, 2, "diastrcb"); |
|---|
| 1034 | 984 | |
|---|
| 1035 | 985 | cmd = (struct qeth_ipa_cmd *)data; |
|---|
| 1036 | 986 | rc = cmd->hdr.return_code; |
|---|
| .. | .. |
|---|
| 1073 | 1023 | } |
|---|
| 1074 | 1024 | break; |
|---|
| 1075 | 1025 | default: |
|---|
| 1076 | | - QETH_DBF_MESSAGE(2, "Unknown sniffer action (0x%04x) on %s\n", |
|---|
| 1077 | | - cmd->data.diagass.action, QETH_CARD_IFNAME(card)); |
|---|
| 1026 | + QETH_DBF_MESSAGE(2, "Unknown sniffer action (%#06x) on device %x\n", |
|---|
| 1027 | + cmd->data.diagass.action, CARD_DEVID(card)); |
|---|
| 1078 | 1028 | } |
|---|
| 1079 | 1029 | |
|---|
| 1080 | | - return 0; |
|---|
| 1030 | + return rc ? -EIO : 0; |
|---|
| 1081 | 1031 | } |
|---|
| 1082 | 1032 | |
|---|
| 1083 | 1033 | static int |
|---|
| .. | .. |
|---|
| 1086 | 1036 | struct qeth_cmd_buffer *iob; |
|---|
| 1087 | 1037 | struct qeth_ipa_cmd *cmd; |
|---|
| 1088 | 1038 | |
|---|
| 1089 | | - QETH_DBF_TEXT(SETUP, 2, "diagtrac"); |
|---|
| 1039 | + QETH_CARD_TEXT(card, 2, "diagtrac"); |
|---|
| 1090 | 1040 | |
|---|
| 1091 | | - iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SET_DIAG_ASS, 0); |
|---|
| 1041 | + iob = qeth_get_diag_cmd(card, QETH_DIAGS_CMD_TRACE, 0); |
|---|
| 1092 | 1042 | if (!iob) |
|---|
| 1093 | 1043 | return -ENOMEM; |
|---|
| 1094 | 1044 | cmd = __ipa_cmd(iob); |
|---|
| 1095 | | - cmd->data.diagass.subcmd_len = 16; |
|---|
| 1096 | | - cmd->data.diagass.subcmd = QETH_DIAGS_CMD_TRACE; |
|---|
| 1097 | 1045 | cmd->data.diagass.type = QETH_DIAGS_TYPE_HIPERSOCKET; |
|---|
| 1098 | 1046 | cmd->data.diagass.action = diags_cmd; |
|---|
| 1099 | 1047 | return qeth_send_ipa_cmd(card, iob, qeth_diags_trace_cb, NULL); |
|---|
| 1100 | 1048 | } |
|---|
| 1101 | 1049 | |
|---|
| 1102 | | -static void |
|---|
| 1103 | | -qeth_l3_add_mc_to_hash(struct qeth_card *card, struct in_device *in4_dev) |
|---|
| 1050 | +static int qeth_l3_add_mcast_rtnl(struct net_device *dev, int vid, void *arg) |
|---|
| 1104 | 1051 | { |
|---|
| 1052 | + struct qeth_card *card = arg; |
|---|
| 1053 | + struct inet6_dev *in6_dev; |
|---|
| 1054 | + struct in_device *in4_dev; |
|---|
| 1055 | + struct qeth_ipaddr *ipm; |
|---|
| 1056 | + struct qeth_ipaddr tmp; |
|---|
| 1105 | 1057 | struct ip_mc_list *im4; |
|---|
| 1106 | | - struct qeth_ipaddr *tmp, *ipm; |
|---|
| 1058 | + struct ifmcaddr6 *im6; |
|---|
| 1107 | 1059 | |
|---|
| 1108 | 1060 | QETH_CARD_TEXT(card, 4, "addmc"); |
|---|
| 1109 | 1061 | |
|---|
| 1110 | | - tmp = qeth_l3_get_addr_buffer(QETH_PROT_IPV4); |
|---|
| 1111 | | - if (!tmp) |
|---|
| 1112 | | - return; |
|---|
| 1062 | + if (!dev || !(dev->flags & IFF_UP)) |
|---|
| 1063 | + goto out; |
|---|
| 1113 | 1064 | |
|---|
| 1114 | | - for (im4 = rcu_dereference(in4_dev->mc_list); im4 != NULL; |
|---|
| 1115 | | - im4 = rcu_dereference(im4->next_rcu)) { |
|---|
| 1116 | | - ip_eth_mc_map(im4->multiaddr, tmp->mac); |
|---|
| 1117 | | - tmp->u.a4.addr = be32_to_cpu(im4->multiaddr); |
|---|
| 1118 | | - tmp->is_multicast = 1; |
|---|
| 1065 | + in4_dev = __in_dev_get_rtnl(dev); |
|---|
| 1066 | + if (!in4_dev) |
|---|
| 1067 | + goto walk_ipv6; |
|---|
| 1119 | 1068 | |
|---|
| 1120 | | - ipm = qeth_l3_find_addr_by_ip(card, tmp); |
|---|
| 1121 | | - if (ipm) { |
|---|
| 1122 | | - /* for mcast, by-IP match means full match */ |
|---|
| 1123 | | - ipm->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
|---|
| 1124 | | - } else { |
|---|
| 1125 | | - ipm = qeth_l3_get_addr_buffer(QETH_PROT_IPV4); |
|---|
| 1126 | | - if (!ipm) |
|---|
| 1127 | | - continue; |
|---|
| 1128 | | - ether_addr_copy(ipm->mac, tmp->mac); |
|---|
| 1129 | | - ipm->u.a4.addr = be32_to_cpu(im4->multiaddr); |
|---|
| 1130 | | - ipm->is_multicast = 1; |
|---|
| 1131 | | - ipm->disp_flag = QETH_DISP_ADDR_ADD; |
|---|
| 1132 | | - hash_add(card->ip_mc_htable, |
|---|
| 1133 | | - &ipm->hnode, qeth_l3_ipaddr_hash(ipm)); |
|---|
| 1134 | | - } |
|---|
| 1135 | | - } |
|---|
| 1069 | + qeth_l3_init_ipaddr(&tmp, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV4); |
|---|
| 1070 | + tmp.disp_flag = QETH_DISP_ADDR_ADD; |
|---|
| 1071 | + tmp.is_multicast = 1; |
|---|
| 1136 | 1072 | |
|---|
| 1137 | | - kfree(tmp); |
|---|
| 1138 | | -} |
|---|
| 1073 | + for (im4 = rtnl_dereference(in4_dev->mc_list); im4 != NULL; |
|---|
| 1074 | + im4 = rtnl_dereference(im4->next_rcu)) { |
|---|
| 1075 | + tmp.u.a4.addr = im4->multiaddr; |
|---|
| 1139 | 1076 | |
|---|
| 1140 | | -/* called with rcu_read_lock */ |
|---|
| 1141 | | -static void qeth_l3_add_vlan_mc(struct qeth_card *card) |
|---|
| 1142 | | -{ |
|---|
| 1143 | | - struct in_device *in_dev; |
|---|
| 1144 | | - u16 vid; |
|---|
| 1145 | | - |
|---|
| 1146 | | - QETH_CARD_TEXT(card, 4, "addmcvl"); |
|---|
| 1147 | | - |
|---|
| 1148 | | - if (!qeth_is_supported(card, IPA_FULL_VLAN)) |
|---|
| 1149 | | - return; |
|---|
| 1150 | | - |
|---|
| 1151 | | - for_each_set_bit(vid, card->active_vlans, VLAN_N_VID) { |
|---|
| 1152 | | - struct net_device *netdev; |
|---|
| 1153 | | - |
|---|
| 1154 | | - netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), |
|---|
| 1155 | | - vid); |
|---|
| 1156 | | - if (netdev == NULL || |
|---|
| 1157 | | - !(netdev->flags & IFF_UP)) |
|---|
| 1158 | | - continue; |
|---|
| 1159 | | - in_dev = __in_dev_get_rcu(netdev); |
|---|
| 1160 | | - if (!in_dev) |
|---|
| 1161 | | - continue; |
|---|
| 1162 | | - qeth_l3_add_mc_to_hash(card, in_dev); |
|---|
| 1163 | | - } |
|---|
| 1164 | | -} |
|---|
| 1165 | | - |
|---|
| 1166 | | -static void qeth_l3_add_multicast_ipv4(struct qeth_card *card) |
|---|
| 1167 | | -{ |
|---|
| 1168 | | - struct in_device *in4_dev; |
|---|
| 1169 | | - |
|---|
| 1170 | | - QETH_CARD_TEXT(card, 4, "chkmcv4"); |
|---|
| 1171 | | - |
|---|
| 1172 | | - rcu_read_lock(); |
|---|
| 1173 | | - in4_dev = __in_dev_get_rcu(card->dev); |
|---|
| 1174 | | - if (in4_dev == NULL) |
|---|
| 1175 | | - goto unlock; |
|---|
| 1176 | | - qeth_l3_add_mc_to_hash(card, in4_dev); |
|---|
| 1177 | | - qeth_l3_add_vlan_mc(card); |
|---|
| 1178 | | -unlock: |
|---|
| 1179 | | - rcu_read_unlock(); |
|---|
| 1180 | | -} |
|---|
| 1181 | | - |
|---|
| 1182 | | -static void qeth_l3_add_mc6_to_hash(struct qeth_card *card, |
|---|
| 1183 | | - struct inet6_dev *in6_dev) |
|---|
| 1184 | | -{ |
|---|
| 1185 | | - struct qeth_ipaddr *ipm; |
|---|
| 1186 | | - struct ifmcaddr6 *im6; |
|---|
| 1187 | | - struct qeth_ipaddr *tmp; |
|---|
| 1188 | | - |
|---|
| 1189 | | - QETH_CARD_TEXT(card, 4, "addmc6"); |
|---|
| 1190 | | - |
|---|
| 1191 | | - tmp = qeth_l3_get_addr_buffer(QETH_PROT_IPV6); |
|---|
| 1192 | | - if (!tmp) |
|---|
| 1193 | | - return; |
|---|
| 1194 | | - |
|---|
| 1195 | | - for (im6 = in6_dev->mc_list; im6 != NULL; im6 = im6->next) { |
|---|
| 1196 | | - ipv6_eth_mc_map(&im6->mca_addr, tmp->mac); |
|---|
| 1197 | | - memcpy(&tmp->u.a6.addr, &im6->mca_addr.s6_addr, |
|---|
| 1198 | | - sizeof(struct in6_addr)); |
|---|
| 1199 | | - tmp->is_multicast = 1; |
|---|
| 1200 | | - |
|---|
| 1201 | | - ipm = qeth_l3_find_addr_by_ip(card, tmp); |
|---|
| 1077 | + ipm = qeth_l3_find_addr_by_ip(card, &tmp); |
|---|
| 1202 | 1078 | if (ipm) { |
|---|
| 1203 | 1079 | /* for mcast, by-IP match means full match */ |
|---|
| 1204 | 1080 | ipm->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
|---|
| 1205 | 1081 | continue; |
|---|
| 1206 | 1082 | } |
|---|
| 1207 | 1083 | |
|---|
| 1208 | | - ipm = qeth_l3_get_addr_buffer(QETH_PROT_IPV6); |
|---|
| 1084 | + ipm = kmemdup(&tmp, sizeof(tmp), GFP_KERNEL); |
|---|
| 1209 | 1085 | if (!ipm) |
|---|
| 1210 | 1086 | continue; |
|---|
| 1211 | 1087 | |
|---|
| 1212 | | - ether_addr_copy(ipm->mac, tmp->mac); |
|---|
| 1213 | | - memcpy(&ipm->u.a6.addr, &im6->mca_addr.s6_addr, |
|---|
| 1214 | | - sizeof(struct in6_addr)); |
|---|
| 1215 | | - ipm->is_multicast = 1; |
|---|
| 1216 | | - ipm->disp_flag = QETH_DISP_ADDR_ADD; |
|---|
| 1217 | | - hash_add(card->ip_mc_htable, |
|---|
| 1218 | | - &ipm->hnode, qeth_l3_ipaddr_hash(ipm)); |
|---|
| 1219 | | - |
|---|
| 1088 | + hash_add(card->rx_mode_addrs, &ipm->hnode, |
|---|
| 1089 | + qeth_l3_ipaddr_hash(ipm)); |
|---|
| 1220 | 1090 | } |
|---|
| 1221 | | - kfree(tmp); |
|---|
| 1222 | | -} |
|---|
| 1223 | 1091 | |
|---|
| 1224 | | -/* called with rcu_read_lock */ |
|---|
| 1225 | | -static void qeth_l3_add_vlan_mc6(struct qeth_card *card) |
|---|
| 1226 | | -{ |
|---|
| 1227 | | - struct inet6_dev *in_dev; |
|---|
| 1228 | | - u16 vid; |
|---|
| 1229 | | - |
|---|
| 1230 | | - QETH_CARD_TEXT(card, 4, "admc6vl"); |
|---|
| 1231 | | - |
|---|
| 1232 | | - if (!qeth_is_supported(card, IPA_FULL_VLAN)) |
|---|
| 1233 | | - return; |
|---|
| 1234 | | - |
|---|
| 1235 | | - for_each_set_bit(vid, card->active_vlans, VLAN_N_VID) { |
|---|
| 1236 | | - struct net_device *netdev; |
|---|
| 1237 | | - |
|---|
| 1238 | | - netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), |
|---|
| 1239 | | - vid); |
|---|
| 1240 | | - if (netdev == NULL || |
|---|
| 1241 | | - !(netdev->flags & IFF_UP)) |
|---|
| 1242 | | - continue; |
|---|
| 1243 | | - in_dev = in6_dev_get(netdev); |
|---|
| 1244 | | - if (!in_dev) |
|---|
| 1245 | | - continue; |
|---|
| 1246 | | - read_lock_bh(&in_dev->lock); |
|---|
| 1247 | | - qeth_l3_add_mc6_to_hash(card, in_dev); |
|---|
| 1248 | | - read_unlock_bh(&in_dev->lock); |
|---|
| 1249 | | - in6_dev_put(in_dev); |
|---|
| 1250 | | - } |
|---|
| 1251 | | -} |
|---|
| 1252 | | - |
|---|
| 1253 | | -static void qeth_l3_add_multicast_ipv6(struct qeth_card *card) |
|---|
| 1254 | | -{ |
|---|
| 1255 | | - struct inet6_dev *in6_dev; |
|---|
| 1256 | | - |
|---|
| 1257 | | - QETH_CARD_TEXT(card, 4, "chkmcv6"); |
|---|
| 1258 | | - |
|---|
| 1092 | +walk_ipv6: |
|---|
| 1259 | 1093 | if (!qeth_is_supported(card, IPA_IPV6)) |
|---|
| 1260 | | - return ; |
|---|
| 1261 | | - in6_dev = in6_dev_get(card->dev); |
|---|
| 1262 | | - if (!in6_dev) |
|---|
| 1263 | | - return; |
|---|
| 1094 | + goto out; |
|---|
| 1264 | 1095 | |
|---|
| 1265 | | - rcu_read_lock(); |
|---|
| 1096 | + in6_dev = __in6_dev_get(dev); |
|---|
| 1097 | + if (!in6_dev) |
|---|
| 1098 | + goto out; |
|---|
| 1099 | + |
|---|
| 1100 | + qeth_l3_init_ipaddr(&tmp, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV6); |
|---|
| 1101 | + tmp.disp_flag = QETH_DISP_ADDR_ADD; |
|---|
| 1102 | + tmp.is_multicast = 1; |
|---|
| 1103 | + |
|---|
| 1266 | 1104 | read_lock_bh(&in6_dev->lock); |
|---|
| 1267 | | - qeth_l3_add_mc6_to_hash(card, in6_dev); |
|---|
| 1268 | | - qeth_l3_add_vlan_mc6(card); |
|---|
| 1105 | + for (im6 = in6_dev->mc_list; im6 != NULL; im6 = im6->next) { |
|---|
| 1106 | + tmp.u.a6.addr = im6->mca_addr; |
|---|
| 1107 | + |
|---|
| 1108 | + ipm = qeth_l3_find_addr_by_ip(card, &tmp); |
|---|
| 1109 | + if (ipm) { |
|---|
| 1110 | + /* for mcast, by-IP match means full match */ |
|---|
| 1111 | + ipm->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
|---|
| 1112 | + continue; |
|---|
| 1113 | + } |
|---|
| 1114 | + |
|---|
| 1115 | + ipm = kmemdup(&tmp, sizeof(tmp), GFP_ATOMIC); |
|---|
| 1116 | + if (!ipm) |
|---|
| 1117 | + continue; |
|---|
| 1118 | + |
|---|
| 1119 | + hash_add(card->rx_mode_addrs, &ipm->hnode, |
|---|
| 1120 | + qeth_l3_ipaddr_hash(ipm)); |
|---|
| 1121 | + |
|---|
| 1122 | + } |
|---|
| 1269 | 1123 | read_unlock_bh(&in6_dev->lock); |
|---|
| 1270 | | - rcu_read_unlock(); |
|---|
| 1271 | | - in6_dev_put(in6_dev); |
|---|
| 1124 | + |
|---|
| 1125 | +out: |
|---|
| 1126 | + return 0; |
|---|
| 1272 | 1127 | } |
|---|
| 1273 | 1128 | |
|---|
| 1274 | 1129 | static int qeth_l3_vlan_rx_add_vid(struct net_device *dev, |
|---|
| .. | .. |
|---|
| 1276 | 1131 | { |
|---|
| 1277 | 1132 | struct qeth_card *card = dev->ml_priv; |
|---|
| 1278 | 1133 | |
|---|
| 1279 | | - set_bit(vid, card->active_vlans); |
|---|
| 1134 | + QETH_CARD_TEXT_(card, 4, "aid:%d", vid); |
|---|
| 1280 | 1135 | return 0; |
|---|
| 1281 | 1136 | } |
|---|
| 1282 | 1137 | |
|---|
| .. | .. |
|---|
| 1286 | 1141 | struct qeth_card *card = dev->ml_priv; |
|---|
| 1287 | 1142 | |
|---|
| 1288 | 1143 | QETH_CARD_TEXT_(card, 4, "kid:%d", vid); |
|---|
| 1289 | | - |
|---|
| 1290 | | - if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { |
|---|
| 1291 | | - QETH_CARD_TEXT(card, 3, "kidREC"); |
|---|
| 1292 | | - return 0; |
|---|
| 1293 | | - } |
|---|
| 1294 | | - clear_bit(vid, card->active_vlans); |
|---|
| 1295 | | - qeth_l3_set_rx_mode(dev); |
|---|
| 1296 | 1144 | return 0; |
|---|
| 1297 | 1145 | } |
|---|
| 1298 | 1146 | |
|---|
| 1299 | | -static void qeth_l3_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, |
|---|
| 1300 | | - struct qeth_hdr *hdr) |
|---|
| 1147 | +static void qeth_l3_set_promisc_mode(struct qeth_card *card) |
|---|
| 1301 | 1148 | { |
|---|
| 1302 | | - if (!(hdr->hdr.l3.flags & QETH_HDR_PASSTHRU)) { |
|---|
| 1303 | | - u16 prot = (hdr->hdr.l3.flags & QETH_HDR_IPV6) ? ETH_P_IPV6 : |
|---|
| 1304 | | - ETH_P_IP; |
|---|
| 1305 | | - unsigned char tg_addr[ETH_ALEN]; |
|---|
| 1149 | + bool enable = card->dev->flags & IFF_PROMISC; |
|---|
| 1306 | 1150 | |
|---|
| 1307 | | - skb_reset_network_header(skb); |
|---|
| 1308 | | - switch (hdr->hdr.l3.flags & QETH_HDR_CAST_MASK) { |
|---|
| 1309 | | - case QETH_CAST_MULTICAST: |
|---|
| 1310 | | - if (prot == ETH_P_IP) |
|---|
| 1311 | | - ip_eth_mc_map(ip_hdr(skb)->daddr, tg_addr); |
|---|
| 1312 | | - else |
|---|
| 1313 | | - ipv6_eth_mc_map(&ipv6_hdr(skb)->daddr, tg_addr); |
|---|
| 1314 | | - |
|---|
| 1315 | | - card->stats.multicast++; |
|---|
| 1316 | | - break; |
|---|
| 1317 | | - case QETH_CAST_BROADCAST: |
|---|
| 1318 | | - ether_addr_copy(tg_addr, card->dev->broadcast); |
|---|
| 1319 | | - card->stats.multicast++; |
|---|
| 1320 | | - break; |
|---|
| 1321 | | - default: |
|---|
| 1322 | | - if (card->options.sniffer) |
|---|
| 1323 | | - skb->pkt_type = PACKET_OTHERHOST; |
|---|
| 1324 | | - ether_addr_copy(tg_addr, card->dev->dev_addr); |
|---|
| 1325 | | - } |
|---|
| 1326 | | - |
|---|
| 1327 | | - if (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR) |
|---|
| 1328 | | - card->dev->header_ops->create(skb, card->dev, prot, |
|---|
| 1329 | | - tg_addr, &hdr->hdr.l3.next_hop.rx.src_mac, |
|---|
| 1330 | | - skb->len); |
|---|
| 1331 | | - else |
|---|
| 1332 | | - card->dev->header_ops->create(skb, card->dev, prot, |
|---|
| 1333 | | - tg_addr, "FAKELL", skb->len); |
|---|
| 1334 | | - } |
|---|
| 1335 | | - |
|---|
| 1336 | | - skb->protocol = eth_type_trans(skb, card->dev); |
|---|
| 1337 | | - |
|---|
| 1338 | | - /* copy VLAN tag from hdr into skb */ |
|---|
| 1339 | | - if (!card->options.sniffer && |
|---|
| 1340 | | - (hdr->hdr.l3.ext_flags & (QETH_HDR_EXT_VLAN_FRAME | |
|---|
| 1341 | | - QETH_HDR_EXT_INCLUDE_VLAN_TAG))) { |
|---|
| 1342 | | - u16 tag = (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_VLAN_FRAME) ? |
|---|
| 1343 | | - hdr->hdr.l3.vlan_id : |
|---|
| 1344 | | - hdr->hdr.l3.next_hop.rx.vlan_id; |
|---|
| 1345 | | - __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), tag); |
|---|
| 1346 | | - } |
|---|
| 1347 | | - |
|---|
| 1348 | | - qeth_rx_csum(card, skb, hdr->hdr.l3.ext_flags); |
|---|
| 1349 | | -} |
|---|
| 1350 | | - |
|---|
| 1351 | | -static int qeth_l3_process_inbound_buffer(struct qeth_card *card, |
|---|
| 1352 | | - int budget, int *done) |
|---|
| 1353 | | -{ |
|---|
| 1354 | | - int work_done = 0; |
|---|
| 1355 | | - struct sk_buff *skb; |
|---|
| 1356 | | - struct qeth_hdr *hdr; |
|---|
| 1357 | | - unsigned int len; |
|---|
| 1358 | | - __u16 magic; |
|---|
| 1359 | | - |
|---|
| 1360 | | - *done = 0; |
|---|
| 1361 | | - WARN_ON_ONCE(!budget); |
|---|
| 1362 | | - while (budget) { |
|---|
| 1363 | | - skb = qeth_core_get_next_skb(card, |
|---|
| 1364 | | - &card->qdio.in_q->bufs[card->rx.b_index], |
|---|
| 1365 | | - &card->rx.b_element, &card->rx.e_offset, &hdr); |
|---|
| 1366 | | - if (!skb) { |
|---|
| 1367 | | - *done = 1; |
|---|
| 1368 | | - break; |
|---|
| 1369 | | - } |
|---|
| 1370 | | - switch (hdr->hdr.l3.id) { |
|---|
| 1371 | | - case QETH_HEADER_TYPE_LAYER3: |
|---|
| 1372 | | - magic = *(__u16 *)skb->data; |
|---|
| 1373 | | - if ((card->info.type == QETH_CARD_TYPE_IQD) && |
|---|
| 1374 | | - (magic == ETH_P_AF_IUCV)) { |
|---|
| 1375 | | - skb->protocol = cpu_to_be16(ETH_P_AF_IUCV); |
|---|
| 1376 | | - len = skb->len; |
|---|
| 1377 | | - card->dev->header_ops->create(skb, card->dev, 0, |
|---|
| 1378 | | - card->dev->dev_addr, "FAKELL", len); |
|---|
| 1379 | | - skb_reset_mac_header(skb); |
|---|
| 1380 | | - netif_receive_skb(skb); |
|---|
| 1381 | | - } else { |
|---|
| 1382 | | - qeth_l3_rebuild_skb(card, skb, hdr); |
|---|
| 1383 | | - len = skb->len; |
|---|
| 1384 | | - napi_gro_receive(&card->napi, skb); |
|---|
| 1385 | | - } |
|---|
| 1386 | | - break; |
|---|
| 1387 | | - case QETH_HEADER_TYPE_LAYER2: /* for HiperSockets sniffer */ |
|---|
| 1388 | | - skb->protocol = eth_type_trans(skb, skb->dev); |
|---|
| 1389 | | - len = skb->len; |
|---|
| 1390 | | - netif_receive_skb(skb); |
|---|
| 1391 | | - break; |
|---|
| 1392 | | - default: |
|---|
| 1393 | | - dev_kfree_skb_any(skb); |
|---|
| 1394 | | - QETH_CARD_TEXT(card, 3, "inbunkno"); |
|---|
| 1395 | | - QETH_DBF_HEX(CTRL, 3, hdr, sizeof(*hdr)); |
|---|
| 1396 | | - continue; |
|---|
| 1397 | | - } |
|---|
| 1398 | | - work_done++; |
|---|
| 1399 | | - budget--; |
|---|
| 1400 | | - card->stats.rx_packets++; |
|---|
| 1401 | | - card->stats.rx_bytes += len; |
|---|
| 1402 | | - } |
|---|
| 1403 | | - return work_done; |
|---|
| 1404 | | -} |
|---|
| 1405 | | - |
|---|
| 1406 | | -static void qeth_l3_stop_card(struct qeth_card *card, int recovery_mode) |
|---|
| 1407 | | -{ |
|---|
| 1408 | | - QETH_DBF_TEXT(SETUP, 2, "stopcard"); |
|---|
| 1409 | | - QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); |
|---|
| 1410 | | - |
|---|
| 1411 | | - qeth_set_allowed_threads(card, 0, 1); |
|---|
| 1412 | | - if (card->options.sniffer && |
|---|
| 1413 | | - (card->info.promisc_mode == SET_PROMISC_MODE_ON)) |
|---|
| 1414 | | - qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_DISABLE); |
|---|
| 1415 | | - if (card->read.state == CH_STATE_UP && |
|---|
| 1416 | | - card->write.state == CH_STATE_UP && |
|---|
| 1417 | | - (card->state == CARD_STATE_UP)) { |
|---|
| 1418 | | - if (recovery_mode) |
|---|
| 1419 | | - qeth_l3_stop(card->dev); |
|---|
| 1420 | | - else { |
|---|
| 1421 | | - rtnl_lock(); |
|---|
| 1422 | | - dev_close(card->dev); |
|---|
| 1423 | | - rtnl_unlock(); |
|---|
| 1424 | | - } |
|---|
| 1425 | | - card->state = CARD_STATE_SOFTSETUP; |
|---|
| 1426 | | - } |
|---|
| 1427 | | - if (card->state == CARD_STATE_SOFTSETUP) { |
|---|
| 1428 | | - qeth_l3_clear_ip_htable(card, 1); |
|---|
| 1429 | | - qeth_clear_ipacmd_list(card); |
|---|
| 1430 | | - card->state = CARD_STATE_HARDSETUP; |
|---|
| 1431 | | - } |
|---|
| 1432 | | - if (card->state == CARD_STATE_HARDSETUP) { |
|---|
| 1433 | | - qeth_qdio_clear_card(card, 0); |
|---|
| 1434 | | - qeth_clear_qdio_buffers(card); |
|---|
| 1435 | | - qeth_clear_working_pool_list(card); |
|---|
| 1436 | | - card->state = CARD_STATE_DOWN; |
|---|
| 1437 | | - } |
|---|
| 1438 | | - if (card->state == CARD_STATE_DOWN) { |
|---|
| 1439 | | - qeth_clear_cmd_buffers(&card->read); |
|---|
| 1440 | | - qeth_clear_cmd_buffers(&card->write); |
|---|
| 1441 | | - } |
|---|
| 1442 | | -} |
|---|
| 1443 | | - |
|---|
| 1444 | | -/* |
|---|
| 1445 | | - * test for and Switch promiscuous mode (on or off) |
|---|
| 1446 | | - * either for guestlan or HiperSocket Sniffer |
|---|
| 1447 | | - */ |
|---|
| 1448 | | -static void |
|---|
| 1449 | | -qeth_l3_handle_promisc_mode(struct qeth_card *card) |
|---|
| 1450 | | -{ |
|---|
| 1451 | | - struct net_device *dev = card->dev; |
|---|
| 1452 | | - |
|---|
| 1453 | | - if (((dev->flags & IFF_PROMISC) && |
|---|
| 1454 | | - (card->info.promisc_mode == SET_PROMISC_MODE_ON)) || |
|---|
| 1455 | | - (!(dev->flags & IFF_PROMISC) && |
|---|
| 1456 | | - (card->info.promisc_mode == SET_PROMISC_MODE_OFF))) |
|---|
| 1151 | + if (card->info.promisc_mode == enable) |
|---|
| 1457 | 1152 | return; |
|---|
| 1458 | 1153 | |
|---|
| 1459 | | - if (card->info.guestlan) { /* Guestlan trace */ |
|---|
| 1154 | + if (IS_VM_NIC(card)) { /* Guestlan trace */ |
|---|
| 1460 | 1155 | if (qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) |
|---|
| 1461 | | - qeth_setadp_promisc_mode(card); |
|---|
| 1156 | + qeth_setadp_promisc_mode(card, enable); |
|---|
| 1462 | 1157 | } else if (card->options.sniffer && /* HiperSockets trace */ |
|---|
| 1463 | 1158 | qeth_adp_supported(card, IPA_SETADP_SET_DIAG_ASSIST)) { |
|---|
| 1464 | | - if (dev->flags & IFF_PROMISC) { |
|---|
| 1159 | + if (enable) { |
|---|
| 1465 | 1160 | QETH_CARD_TEXT(card, 3, "+promisc"); |
|---|
| 1466 | 1161 | qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_ENABLE); |
|---|
| 1467 | 1162 | } else { |
|---|
| .. | .. |
|---|
| 1471 | 1166 | } |
|---|
| 1472 | 1167 | } |
|---|
| 1473 | 1168 | |
|---|
| 1474 | | -static void qeth_l3_set_rx_mode(struct net_device *dev) |
|---|
| 1169 | +static void qeth_l3_rx_mode_work(struct work_struct *work) |
|---|
| 1475 | 1170 | { |
|---|
| 1476 | | - struct qeth_card *card = dev->ml_priv; |
|---|
| 1171 | + struct qeth_card *card = container_of(work, struct qeth_card, |
|---|
| 1172 | + rx_mode_work); |
|---|
| 1477 | 1173 | struct qeth_ipaddr *addr; |
|---|
| 1478 | 1174 | struct hlist_node *tmp; |
|---|
| 1479 | 1175 | int i, rc; |
|---|
| 1480 | 1176 | |
|---|
| 1481 | 1177 | QETH_CARD_TEXT(card, 3, "setmulti"); |
|---|
| 1482 | | - if (qeth_threads_running(card, QETH_RECOVER_THREAD) && |
|---|
| 1483 | | - (card->state != CARD_STATE_UP)) |
|---|
| 1484 | | - return; |
|---|
| 1178 | + |
|---|
| 1485 | 1179 | if (!card->options.sniffer) { |
|---|
| 1486 | | - spin_lock_bh(&card->mclock); |
|---|
| 1180 | + rtnl_lock(); |
|---|
| 1181 | + qeth_l3_add_mcast_rtnl(card->dev, 0, card); |
|---|
| 1182 | + if (qeth_is_supported(card, IPA_FULL_VLAN)) |
|---|
| 1183 | + vlan_for_each(card->dev, qeth_l3_add_mcast_rtnl, card); |
|---|
| 1184 | + rtnl_unlock(); |
|---|
| 1487 | 1185 | |
|---|
| 1488 | | - qeth_l3_add_multicast_ipv4(card); |
|---|
| 1489 | | - qeth_l3_add_multicast_ipv6(card); |
|---|
| 1490 | | - |
|---|
| 1491 | | - hash_for_each_safe(card->ip_mc_htable, i, tmp, addr, hnode) { |
|---|
| 1186 | + hash_for_each_safe(card->rx_mode_addrs, i, tmp, addr, hnode) { |
|---|
| 1492 | 1187 | switch (addr->disp_flag) { |
|---|
| 1493 | 1188 | case QETH_DISP_ADDR_DELETE: |
|---|
| 1494 | 1189 | rc = qeth_l3_deregister_addr_entry(card, addr); |
|---|
| 1495 | | - if (!rc || rc == IPA_RC_MC_ADDR_NOT_FOUND) { |
|---|
| 1190 | + if (!rc || rc == -ENOENT) { |
|---|
| 1496 | 1191 | hash_del(&addr->hnode); |
|---|
| 1497 | 1192 | kfree(addr); |
|---|
| 1498 | 1193 | } |
|---|
| 1499 | 1194 | break; |
|---|
| 1500 | 1195 | case QETH_DISP_ADDR_ADD: |
|---|
| 1501 | 1196 | rc = qeth_l3_register_addr_entry(card, addr); |
|---|
| 1502 | | - if (rc && rc != IPA_RC_LAN_OFFLINE) { |
|---|
| 1197 | + if (rc && rc != -ENETDOWN) { |
|---|
| 1503 | 1198 | hash_del(&addr->hnode); |
|---|
| 1504 | 1199 | kfree(addr); |
|---|
| 1505 | 1200 | break; |
|---|
| 1506 | 1201 | } |
|---|
| 1507 | | - addr->ref_counter = 1; |
|---|
| 1508 | | - /* fall through */ |
|---|
| 1202 | + fallthrough; |
|---|
| 1509 | 1203 | default: |
|---|
| 1510 | 1204 | /* for next call to set_rx_mode(): */ |
|---|
| 1511 | 1205 | addr->disp_flag = QETH_DISP_ADDR_DELETE; |
|---|
| 1512 | 1206 | } |
|---|
| 1513 | 1207 | } |
|---|
| 1514 | | - |
|---|
| 1515 | | - spin_unlock_bh(&card->mclock); |
|---|
| 1516 | | - |
|---|
| 1517 | | - if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) |
|---|
| 1518 | | - return; |
|---|
| 1519 | 1208 | } |
|---|
| 1520 | | - qeth_l3_handle_promisc_mode(card); |
|---|
| 1209 | + |
|---|
| 1210 | + qeth_l3_set_promisc_mode(card); |
|---|
| 1521 | 1211 | } |
|---|
| 1522 | 1212 | |
|---|
| 1523 | | -static const char *qeth_l3_arp_get_error_cause(int *rc) |
|---|
| 1213 | +static int qeth_l3_arp_makerc(u16 rc) |
|---|
| 1524 | 1214 | { |
|---|
| 1525 | | - switch (*rc) { |
|---|
| 1526 | | - case QETH_IPA_ARP_RC_FAILED: |
|---|
| 1527 | | - *rc = -EIO; |
|---|
| 1528 | | - return "operation failed"; |
|---|
| 1215 | + switch (rc) { |
|---|
| 1216 | + case IPA_RC_SUCCESS: |
|---|
| 1217 | + return 0; |
|---|
| 1529 | 1218 | case QETH_IPA_ARP_RC_NOTSUPP: |
|---|
| 1530 | | - *rc = -EOPNOTSUPP; |
|---|
| 1531 | | - return "operation not supported"; |
|---|
| 1532 | | - case QETH_IPA_ARP_RC_OUT_OF_RANGE: |
|---|
| 1533 | | - *rc = -EINVAL; |
|---|
| 1534 | | - return "argument out of range"; |
|---|
| 1535 | 1219 | case QETH_IPA_ARP_RC_Q_NOTSUPP: |
|---|
| 1536 | | - *rc = -EOPNOTSUPP; |
|---|
| 1537 | | - return "query operation not supported"; |
|---|
| 1220 | + return -EOPNOTSUPP; |
|---|
| 1221 | + case QETH_IPA_ARP_RC_OUT_OF_RANGE: |
|---|
| 1222 | + return -EINVAL; |
|---|
| 1538 | 1223 | case QETH_IPA_ARP_RC_Q_NO_DATA: |
|---|
| 1539 | | - *rc = -ENOENT; |
|---|
| 1540 | | - return "no query data available"; |
|---|
| 1224 | + return -ENOENT; |
|---|
| 1541 | 1225 | default: |
|---|
| 1542 | | - return "unknown error"; |
|---|
| 1226 | + return -EIO; |
|---|
| 1543 | 1227 | } |
|---|
| 1228 | +} |
|---|
| 1229 | + |
|---|
| 1230 | +static int qeth_l3_arp_cmd_cb(struct qeth_card *card, struct qeth_reply *reply, |
|---|
| 1231 | + unsigned long data) |
|---|
| 1232 | +{ |
|---|
| 1233 | + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
|---|
| 1234 | + |
|---|
| 1235 | + qeth_setassparms_cb(card, reply, data); |
|---|
| 1236 | + return qeth_l3_arp_makerc(cmd->hdr.return_code); |
|---|
| 1544 | 1237 | } |
|---|
| 1545 | 1238 | |
|---|
| 1546 | 1239 | static int qeth_l3_arp_set_no_entries(struct qeth_card *card, int no_entries) |
|---|
| 1547 | 1240 | { |
|---|
| 1548 | | - int tmp; |
|---|
| 1241 | + struct qeth_cmd_buffer *iob; |
|---|
| 1549 | 1242 | int rc; |
|---|
| 1550 | 1243 | |
|---|
| 1551 | 1244 | QETH_CARD_TEXT(card, 3, "arpstnoe"); |
|---|
| .. | .. |
|---|
| 1555 | 1248 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES; |
|---|
| 1556 | 1249 | * thus we say EOPNOTSUPP for this ARP function |
|---|
| 1557 | 1250 | */ |
|---|
| 1558 | | - if (card->info.guestlan) |
|---|
| 1251 | + if (IS_VM_NIC(card)) |
|---|
| 1559 | 1252 | return -EOPNOTSUPP; |
|---|
| 1560 | 1253 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
|---|
| 1561 | 1254 | return -EOPNOTSUPP; |
|---|
| 1562 | 1255 | } |
|---|
| 1563 | | - rc = qeth_send_simple_setassparms(card, IPA_ARP_PROCESSING, |
|---|
| 1564 | | - IPA_CMD_ASS_ARP_SET_NO_ENTRIES, |
|---|
| 1565 | | - no_entries); |
|---|
| 1566 | | - if (rc) { |
|---|
| 1567 | | - tmp = rc; |
|---|
| 1568 | | - QETH_DBF_MESSAGE(2, "Could not set number of ARP entries on " |
|---|
| 1569 | | - "%s: %s (0x%x/%d)\n", QETH_CARD_IFNAME(card), |
|---|
| 1570 | | - qeth_l3_arp_get_error_cause(&rc), tmp, tmp); |
|---|
| 1571 | | - } |
|---|
| 1256 | + |
|---|
| 1257 | + iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, |
|---|
| 1258 | + IPA_CMD_ASS_ARP_SET_NO_ENTRIES, |
|---|
| 1259 | + SETASS_DATA_SIZEOF(flags_32bit), |
|---|
| 1260 | + QETH_PROT_IPV4); |
|---|
| 1261 | + if (!iob) |
|---|
| 1262 | + return -ENOMEM; |
|---|
| 1263 | + |
|---|
| 1264 | + __ipa_cmd(iob)->data.setassparms.data.flags_32bit = (u32) no_entries; |
|---|
| 1265 | + rc = qeth_send_ipa_cmd(card, iob, qeth_l3_arp_cmd_cb, NULL); |
|---|
| 1266 | + if (rc) |
|---|
| 1267 | + QETH_DBF_MESSAGE(2, "Could not set number of ARP entries on device %x: %#x\n", |
|---|
| 1268 | + CARD_DEVID(card), rc); |
|---|
| 1572 | 1269 | return rc; |
|---|
| 1573 | 1270 | } |
|---|
| 1574 | 1271 | |
|---|
| .. | .. |
|---|
| 1620 | 1317 | struct qeth_ipa_cmd *cmd; |
|---|
| 1621 | 1318 | struct qeth_arp_query_data *qdata; |
|---|
| 1622 | 1319 | struct qeth_arp_query_info *qinfo; |
|---|
| 1623 | | - int i; |
|---|
| 1624 | 1320 | int e; |
|---|
| 1625 | 1321 | int entrybytes_done; |
|---|
| 1626 | 1322 | int stripped_bytes; |
|---|
| .. | .. |
|---|
| 1634 | 1330 | if (cmd->hdr.return_code) { |
|---|
| 1635 | 1331 | QETH_CARD_TEXT(card, 4, "arpcberr"); |
|---|
| 1636 | 1332 | QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.return_code); |
|---|
| 1637 | | - return 0; |
|---|
| 1333 | + return qeth_l3_arp_makerc(cmd->hdr.return_code); |
|---|
| 1638 | 1334 | } |
|---|
| 1639 | 1335 | if (cmd->data.setassparms.hdr.return_code) { |
|---|
| 1640 | 1336 | cmd->hdr.return_code = cmd->data.setassparms.hdr.return_code; |
|---|
| 1641 | 1337 | QETH_CARD_TEXT(card, 4, "setaperr"); |
|---|
| 1642 | 1338 | QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.return_code); |
|---|
| 1643 | | - return 0; |
|---|
| 1339 | + return qeth_l3_arp_makerc(cmd->hdr.return_code); |
|---|
| 1644 | 1340 | } |
|---|
| 1645 | 1341 | qdata = &cmd->data.setassparms.data.query_arp; |
|---|
| 1646 | 1342 | QETH_CARD_TEXT_(card, 4, "anoen%i", qdata->no_entries); |
|---|
| .. | .. |
|---|
| 1667 | 1363 | break; |
|---|
| 1668 | 1364 | |
|---|
| 1669 | 1365 | if ((qinfo->udata_len - qinfo->udata_offset) < esize) { |
|---|
| 1670 | | - QETH_CARD_TEXT_(card, 4, "qaer3%i", -ENOMEM); |
|---|
| 1671 | | - cmd->hdr.return_code = IPA_RC_ENOMEM; |
|---|
| 1672 | | - goto out_error; |
|---|
| 1366 | + QETH_CARD_TEXT_(card, 4, "qaer3%i", -ENOSPC); |
|---|
| 1367 | + memset(qinfo->udata, 0, 4); |
|---|
| 1368 | + return -ENOSPC; |
|---|
| 1673 | 1369 | } |
|---|
| 1674 | 1370 | |
|---|
| 1675 | 1371 | memcpy(qinfo->udata + qinfo->udata_offset, |
|---|
| .. | .. |
|---|
| 1692 | 1388 | memcpy(qinfo->udata + QETH_QARP_MASK_OFFSET, &qdata->reply_bits, 2); |
|---|
| 1693 | 1389 | QETH_CARD_TEXT_(card, 4, "rc%i", 0); |
|---|
| 1694 | 1390 | return 0; |
|---|
| 1695 | | -out_error: |
|---|
| 1696 | | - i = 0; |
|---|
| 1697 | | - memcpy(qinfo->udata, &i, 4); |
|---|
| 1698 | | - return 0; |
|---|
| 1699 | | -} |
|---|
| 1700 | | - |
|---|
| 1701 | | -static int qeth_l3_send_ipa_arp_cmd(struct qeth_card *card, |
|---|
| 1702 | | - struct qeth_cmd_buffer *iob, int len, |
|---|
| 1703 | | - int (*reply_cb)(struct qeth_card *, struct qeth_reply *, |
|---|
| 1704 | | - unsigned long), |
|---|
| 1705 | | - void *reply_param) |
|---|
| 1706 | | -{ |
|---|
| 1707 | | - QETH_CARD_TEXT(card, 4, "sendarp"); |
|---|
| 1708 | | - |
|---|
| 1709 | | - memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE); |
|---|
| 1710 | | - memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data), |
|---|
| 1711 | | - &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH); |
|---|
| 1712 | | - return qeth_send_control_data(card, IPA_PDU_HEADER_SIZE + len, iob, |
|---|
| 1713 | | - reply_cb, reply_param); |
|---|
| 1714 | 1391 | } |
|---|
| 1715 | 1392 | |
|---|
| 1716 | 1393 | static int qeth_l3_query_arp_cache_info(struct qeth_card *card, |
|---|
| .. | .. |
|---|
| 1719 | 1396 | { |
|---|
| 1720 | 1397 | struct qeth_cmd_buffer *iob; |
|---|
| 1721 | 1398 | struct qeth_ipa_cmd *cmd; |
|---|
| 1722 | | - int tmp; |
|---|
| 1723 | 1399 | int rc; |
|---|
| 1724 | 1400 | |
|---|
| 1725 | 1401 | QETH_CARD_TEXT_(card, 3, "qarpipv%i", prot); |
|---|
| 1726 | 1402 | |
|---|
| 1727 | 1403 | iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, |
|---|
| 1728 | 1404 | IPA_CMD_ASS_ARP_QUERY_INFO, |
|---|
| 1729 | | - sizeof(struct qeth_arp_query_data) |
|---|
| 1730 | | - - sizeof(char), |
|---|
| 1731 | | - prot); |
|---|
| 1405 | + SETASS_DATA_SIZEOF(query_arp), prot); |
|---|
| 1732 | 1406 | if (!iob) |
|---|
| 1733 | 1407 | return -ENOMEM; |
|---|
| 1734 | 1408 | cmd = __ipa_cmd(iob); |
|---|
| 1735 | 1409 | cmd->data.setassparms.data.query_arp.request_bits = 0x000F; |
|---|
| 1736 | | - cmd->data.setassparms.data.query_arp.reply_bits = 0; |
|---|
| 1737 | | - cmd->data.setassparms.data.query_arp.no_entries = 0; |
|---|
| 1738 | | - rc = qeth_l3_send_ipa_arp_cmd(card, iob, |
|---|
| 1739 | | - QETH_SETASS_BASE_LEN+QETH_ARP_CMD_LEN, |
|---|
| 1740 | | - qeth_l3_arp_query_cb, (void *)qinfo); |
|---|
| 1741 | | - if (rc) { |
|---|
| 1742 | | - tmp = rc; |
|---|
| 1743 | | - QETH_DBF_MESSAGE(2, |
|---|
| 1744 | | - "Error while querying ARP cache on %s: %s " |
|---|
| 1745 | | - "(0x%x/%d)\n", QETH_CARD_IFNAME(card), |
|---|
| 1746 | | - qeth_l3_arp_get_error_cause(&rc), tmp, tmp); |
|---|
| 1747 | | - } |
|---|
| 1748 | | - |
|---|
| 1410 | + rc = qeth_send_ipa_cmd(card, iob, qeth_l3_arp_query_cb, qinfo); |
|---|
| 1411 | + if (rc) |
|---|
| 1412 | + QETH_DBF_MESSAGE(2, "Error while querying ARP cache on device %x: %#x\n", |
|---|
| 1413 | + CARD_DEVID(card), rc); |
|---|
| 1749 | 1414 | return rc; |
|---|
| 1750 | 1415 | } |
|---|
| 1751 | 1416 | |
|---|
| .. | .. |
|---|
| 1796 | 1461 | return rc; |
|---|
| 1797 | 1462 | } |
|---|
| 1798 | 1463 | |
|---|
| 1799 | | -static int qeth_l3_arp_add_entry(struct qeth_card *card, |
|---|
| 1800 | | - struct qeth_arp_cache_entry *entry) |
|---|
| 1464 | +static int qeth_l3_arp_modify_entry(struct qeth_card *card, |
|---|
| 1465 | + struct qeth_arp_cache_entry *entry, |
|---|
| 1466 | + enum qeth_arp_process_subcmds arp_cmd) |
|---|
| 1801 | 1467 | { |
|---|
| 1468 | + struct qeth_arp_cache_entry *cmd_entry; |
|---|
| 1802 | 1469 | struct qeth_cmd_buffer *iob; |
|---|
| 1803 | | - char buf[16]; |
|---|
| 1804 | | - int tmp; |
|---|
| 1805 | 1470 | int rc; |
|---|
| 1806 | 1471 | |
|---|
| 1807 | | - QETH_CARD_TEXT(card, 3, "arpadent"); |
|---|
| 1472 | + if (arp_cmd == IPA_CMD_ASS_ARP_ADD_ENTRY) |
|---|
| 1473 | + QETH_CARD_TEXT(card, 3, "arpadd"); |
|---|
| 1474 | + else |
|---|
| 1475 | + QETH_CARD_TEXT(card, 3, "arpdel"); |
|---|
| 1808 | 1476 | |
|---|
| 1809 | 1477 | /* |
|---|
| 1810 | 1478 | * currently GuestLAN only supports the ARP assist function |
|---|
| 1811 | 1479 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY; |
|---|
| 1812 | 1480 | * thus we say EOPNOTSUPP for this ARP function |
|---|
| 1813 | 1481 | */ |
|---|
| 1814 | | - if (card->info.guestlan) |
|---|
| 1482 | + if (IS_VM_NIC(card)) |
|---|
| 1815 | 1483 | return -EOPNOTSUPP; |
|---|
| 1816 | 1484 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
|---|
| 1817 | 1485 | return -EOPNOTSUPP; |
|---|
| 1818 | 1486 | } |
|---|
| 1819 | 1487 | |
|---|
| 1820 | | - iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, |
|---|
| 1821 | | - IPA_CMD_ASS_ARP_ADD_ENTRY, |
|---|
| 1822 | | - sizeof(struct qeth_arp_cache_entry), |
|---|
| 1488 | + iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, arp_cmd, |
|---|
| 1489 | + SETASS_DATA_SIZEOF(arp_entry), |
|---|
| 1823 | 1490 | QETH_PROT_IPV4); |
|---|
| 1824 | 1491 | if (!iob) |
|---|
| 1825 | 1492 | return -ENOMEM; |
|---|
| 1826 | | - rc = qeth_send_setassparms(card, iob, |
|---|
| 1827 | | - sizeof(struct qeth_arp_cache_entry), |
|---|
| 1828 | | - (unsigned long) entry, |
|---|
| 1829 | | - qeth_setassparms_cb, NULL); |
|---|
| 1830 | | - if (rc) { |
|---|
| 1831 | | - tmp = rc; |
|---|
| 1832 | | - qeth_l3_ipaddr4_to_string((u8 *)entry->ipaddr, buf); |
|---|
| 1833 | | - QETH_DBF_MESSAGE(2, "Could not add ARP entry for address %s " |
|---|
| 1834 | | - "on %s: %s (0x%x/%d)\n", buf, QETH_CARD_IFNAME(card), |
|---|
| 1835 | | - qeth_l3_arp_get_error_cause(&rc), tmp, tmp); |
|---|
| 1836 | | - } |
|---|
| 1837 | | - return rc; |
|---|
| 1838 | | -} |
|---|
| 1839 | 1493 | |
|---|
| 1840 | | -static int qeth_l3_arp_remove_entry(struct qeth_card *card, |
|---|
| 1841 | | - struct qeth_arp_cache_entry *entry) |
|---|
| 1842 | | -{ |
|---|
| 1843 | | - struct qeth_cmd_buffer *iob; |
|---|
| 1844 | | - char buf[16] = {0, }; |
|---|
| 1845 | | - int tmp; |
|---|
| 1846 | | - int rc; |
|---|
| 1847 | | - |
|---|
| 1848 | | - QETH_CARD_TEXT(card, 3, "arprment"); |
|---|
| 1849 | | - |
|---|
| 1850 | | - /* |
|---|
| 1851 | | - * currently GuestLAN only supports the ARP assist function |
|---|
| 1852 | | - * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_REMOVE_ENTRY; |
|---|
| 1853 | | - * thus we say EOPNOTSUPP for this ARP function |
|---|
| 1854 | | - */ |
|---|
| 1855 | | - if (card->info.guestlan) |
|---|
| 1856 | | - return -EOPNOTSUPP; |
|---|
| 1857 | | - if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
|---|
| 1858 | | - return -EOPNOTSUPP; |
|---|
| 1859 | | - } |
|---|
| 1860 | | - memcpy(buf, entry, 12); |
|---|
| 1861 | | - iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, |
|---|
| 1862 | | - IPA_CMD_ASS_ARP_REMOVE_ENTRY, |
|---|
| 1863 | | - 12, |
|---|
| 1864 | | - QETH_PROT_IPV4); |
|---|
| 1865 | | - if (!iob) |
|---|
| 1866 | | - return -ENOMEM; |
|---|
| 1867 | | - rc = qeth_send_setassparms(card, iob, |
|---|
| 1868 | | - 12, (unsigned long)buf, |
|---|
| 1869 | | - qeth_setassparms_cb, NULL); |
|---|
| 1870 | | - if (rc) { |
|---|
| 1871 | | - tmp = rc; |
|---|
| 1872 | | - memset(buf, 0, 16); |
|---|
| 1873 | | - qeth_l3_ipaddr4_to_string((u8 *)entry->ipaddr, buf); |
|---|
| 1874 | | - QETH_DBF_MESSAGE(2, "Could not delete ARP entry for address %s" |
|---|
| 1875 | | - " on %s: %s (0x%x/%d)\n", buf, QETH_CARD_IFNAME(card), |
|---|
| 1876 | | - qeth_l3_arp_get_error_cause(&rc), tmp, tmp); |
|---|
| 1877 | | - } |
|---|
| 1494 | + cmd_entry = &__ipa_cmd(iob)->data.setassparms.data.arp_entry; |
|---|
| 1495 | + ether_addr_copy(cmd_entry->macaddr, entry->macaddr); |
|---|
| 1496 | + memcpy(cmd_entry->ipaddr, entry->ipaddr, 4); |
|---|
| 1497 | + rc = qeth_send_ipa_cmd(card, iob, qeth_l3_arp_cmd_cb, NULL); |
|---|
| 1498 | + if (rc) |
|---|
| 1499 | + QETH_DBF_MESSAGE(2, "Could not modify (cmd: %#x) ARP entry on device %x: %#x\n", |
|---|
| 1500 | + arp_cmd, CARD_DEVID(card), rc); |
|---|
| 1878 | 1501 | return rc; |
|---|
| 1879 | 1502 | } |
|---|
| 1880 | 1503 | |
|---|
| 1881 | 1504 | static int qeth_l3_arp_flush_cache(struct qeth_card *card) |
|---|
| 1882 | 1505 | { |
|---|
| 1506 | + struct qeth_cmd_buffer *iob; |
|---|
| 1883 | 1507 | int rc; |
|---|
| 1884 | | - int tmp; |
|---|
| 1885 | 1508 | |
|---|
| 1886 | 1509 | QETH_CARD_TEXT(card, 3, "arpflush"); |
|---|
| 1887 | 1510 | |
|---|
| .. | .. |
|---|
| 1890 | 1513 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE; |
|---|
| 1891 | 1514 | * thus we say EOPNOTSUPP for this ARP function |
|---|
| 1892 | 1515 | */ |
|---|
| 1893 | | - if (card->info.guestlan || (card->info.type == QETH_CARD_TYPE_IQD)) |
|---|
| 1516 | + if (IS_VM_NIC(card) || IS_IQD(card)) |
|---|
| 1894 | 1517 | return -EOPNOTSUPP; |
|---|
| 1895 | 1518 | if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { |
|---|
| 1896 | 1519 | return -EOPNOTSUPP; |
|---|
| 1897 | 1520 | } |
|---|
| 1898 | | - rc = qeth_send_simple_setassparms(card, IPA_ARP_PROCESSING, |
|---|
| 1899 | | - IPA_CMD_ASS_ARP_FLUSH_CACHE, 0); |
|---|
| 1900 | | - if (rc) { |
|---|
| 1901 | | - tmp = rc; |
|---|
| 1902 | | - QETH_DBF_MESSAGE(2, "Could not flush ARP cache on %s: %s " |
|---|
| 1903 | | - "(0x%x/%d)\n", QETH_CARD_IFNAME(card), |
|---|
| 1904 | | - qeth_l3_arp_get_error_cause(&rc), tmp, tmp); |
|---|
| 1905 | | - } |
|---|
| 1521 | + |
|---|
| 1522 | + iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, |
|---|
| 1523 | + IPA_CMD_ASS_ARP_FLUSH_CACHE, 0, |
|---|
| 1524 | + QETH_PROT_IPV4); |
|---|
| 1525 | + if (!iob) |
|---|
| 1526 | + return -ENOMEM; |
|---|
| 1527 | + |
|---|
| 1528 | + rc = qeth_send_ipa_cmd(card, iob, qeth_l3_arp_cmd_cb, NULL); |
|---|
| 1529 | + if (rc) |
|---|
| 1530 | + QETH_DBF_MESSAGE(2, "Could not flush ARP cache on device %x: %#x\n", |
|---|
| 1531 | + CARD_DEVID(card), rc); |
|---|
| 1906 | 1532 | return rc; |
|---|
| 1907 | 1533 | } |
|---|
| 1908 | 1534 | |
|---|
| .. | .. |
|---|
| 1910 | 1536 | { |
|---|
| 1911 | 1537 | struct qeth_card *card = dev->ml_priv; |
|---|
| 1912 | 1538 | struct qeth_arp_cache_entry arp_entry; |
|---|
| 1539 | + enum qeth_arp_process_subcmds arp_cmd; |
|---|
| 1913 | 1540 | int rc = 0; |
|---|
| 1914 | 1541 | |
|---|
| 1915 | 1542 | switch (cmd) { |
|---|
| .. | .. |
|---|
| 1928 | 1555 | rc = qeth_l3_arp_query(card, rq->ifr_ifru.ifru_data); |
|---|
| 1929 | 1556 | break; |
|---|
| 1930 | 1557 | case SIOC_QETH_ARP_ADD_ENTRY: |
|---|
| 1931 | | - if (!capable(CAP_NET_ADMIN)) { |
|---|
| 1932 | | - rc = -EPERM; |
|---|
| 1933 | | - break; |
|---|
| 1934 | | - } |
|---|
| 1935 | | - if (copy_from_user(&arp_entry, rq->ifr_ifru.ifru_data, |
|---|
| 1936 | | - sizeof(struct qeth_arp_cache_entry))) |
|---|
| 1937 | | - rc = -EFAULT; |
|---|
| 1938 | | - else |
|---|
| 1939 | | - rc = qeth_l3_arp_add_entry(card, &arp_entry); |
|---|
| 1940 | | - break; |
|---|
| 1941 | 1558 | case SIOC_QETH_ARP_REMOVE_ENTRY: |
|---|
| 1942 | | - if (!capable(CAP_NET_ADMIN)) { |
|---|
| 1943 | | - rc = -EPERM; |
|---|
| 1944 | | - break; |
|---|
| 1945 | | - } |
|---|
| 1946 | | - if (copy_from_user(&arp_entry, rq->ifr_ifru.ifru_data, |
|---|
| 1947 | | - sizeof(struct qeth_arp_cache_entry))) |
|---|
| 1948 | | - rc = -EFAULT; |
|---|
| 1949 | | - else |
|---|
| 1950 | | - rc = qeth_l3_arp_remove_entry(card, &arp_entry); |
|---|
| 1951 | | - break; |
|---|
| 1559 | + if (!capable(CAP_NET_ADMIN)) |
|---|
| 1560 | + return -EPERM; |
|---|
| 1561 | + if (copy_from_user(&arp_entry, rq->ifr_data, sizeof(arp_entry))) |
|---|
| 1562 | + return -EFAULT; |
|---|
| 1563 | + |
|---|
| 1564 | + arp_cmd = (cmd == SIOC_QETH_ARP_ADD_ENTRY) ? |
|---|
| 1565 | + IPA_CMD_ASS_ARP_ADD_ENTRY : |
|---|
| 1566 | + IPA_CMD_ASS_ARP_REMOVE_ENTRY; |
|---|
| 1567 | + return qeth_l3_arp_modify_entry(card, &arp_entry, arp_cmd); |
|---|
| 1952 | 1568 | case SIOC_QETH_ARP_FLUSH_CACHE: |
|---|
| 1953 | 1569 | if (!capable(CAP_NET_ADMIN)) { |
|---|
| 1954 | 1570 | rc = -EPERM; |
|---|
| .. | .. |
|---|
| 1962 | 1578 | return rc; |
|---|
| 1963 | 1579 | } |
|---|
| 1964 | 1580 | |
|---|
| 1965 | | -static int qeth_l3_get_cast_type(struct sk_buff *skb) |
|---|
| 1581 | +static int qeth_l3_get_cast_type_rcu(struct sk_buff *skb, struct dst_entry *dst, |
|---|
| 1582 | + int ipv) |
|---|
| 1966 | 1583 | { |
|---|
| 1967 | 1584 | struct neighbour *n = NULL; |
|---|
| 1968 | | - struct dst_entry *dst; |
|---|
| 1969 | 1585 | |
|---|
| 1970 | | - rcu_read_lock(); |
|---|
| 1971 | | - dst = skb_dst(skb); |
|---|
| 1972 | 1586 | if (dst) |
|---|
| 1973 | 1587 | n = dst_neigh_lookup_skb(dst, skb); |
|---|
| 1588 | + |
|---|
| 1974 | 1589 | if (n) { |
|---|
| 1975 | 1590 | int cast_type = n->type; |
|---|
| 1976 | 1591 | |
|---|
| 1977 | | - rcu_read_unlock(); |
|---|
| 1978 | 1592 | neigh_release(n); |
|---|
| 1979 | 1593 | if ((cast_type == RTN_BROADCAST) || |
|---|
| 1980 | 1594 | (cast_type == RTN_MULTICAST) || |
|---|
| .. | .. |
|---|
| 1982 | 1596 | return cast_type; |
|---|
| 1983 | 1597 | return RTN_UNICAST; |
|---|
| 1984 | 1598 | } |
|---|
| 1985 | | - rcu_read_unlock(); |
|---|
| 1986 | 1599 | |
|---|
| 1987 | 1600 | /* no neighbour (eg AF_PACKET), fall back to target's IP address ... */ |
|---|
| 1988 | | - if (be16_to_cpu(skb->protocol) == ETH_P_IPV6) |
|---|
| 1989 | | - return ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) ? |
|---|
| 1990 | | - RTN_MULTICAST : RTN_UNICAST; |
|---|
| 1991 | | - else if (be16_to_cpu(skb->protocol) == ETH_P_IP) |
|---|
| 1601 | + switch (ipv) { |
|---|
| 1602 | + case 4: |
|---|
| 1603 | + if (ipv4_is_lbcast(ip_hdr(skb)->daddr)) |
|---|
| 1604 | + return RTN_BROADCAST; |
|---|
| 1992 | 1605 | return ipv4_is_multicast(ip_hdr(skb)->daddr) ? |
|---|
| 1993 | 1606 | RTN_MULTICAST : RTN_UNICAST; |
|---|
| 1994 | | - |
|---|
| 1995 | | - /* ... and MAC address */ |
|---|
| 1996 | | - if (ether_addr_equal_64bits(eth_hdr(skb)->h_dest, skb->dev->broadcast)) |
|---|
| 1997 | | - return RTN_BROADCAST; |
|---|
| 1998 | | - if (is_multicast_ether_addr(eth_hdr(skb)->h_dest)) |
|---|
| 1999 | | - return RTN_MULTICAST; |
|---|
| 2000 | | - |
|---|
| 2001 | | - /* default to unicast */ |
|---|
| 2002 | | - return RTN_UNICAST; |
|---|
| 1607 | + case 6: |
|---|
| 1608 | + return ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) ? |
|---|
| 1609 | + RTN_MULTICAST : RTN_UNICAST; |
|---|
| 1610 | + default: |
|---|
| 1611 | + /* ... and MAC address */ |
|---|
| 1612 | + return qeth_get_ether_cast_type(skb); |
|---|
| 1613 | + } |
|---|
| 2003 | 1614 | } |
|---|
| 2004 | 1615 | |
|---|
| 2005 | | -static void qeth_l3_fill_af_iucv_hdr(struct qeth_hdr *hdr, struct sk_buff *skb, |
|---|
| 2006 | | - unsigned int data_len) |
|---|
| 1616 | +static int qeth_l3_get_cast_type(struct sk_buff *skb) |
|---|
| 2007 | 1617 | { |
|---|
| 2008 | | - char daddr[16]; |
|---|
| 2009 | | - struct af_iucv_trans_hdr *iucv_hdr; |
|---|
| 1618 | + int ipv = qeth_get_ip_version(skb); |
|---|
| 1619 | + struct dst_entry *dst; |
|---|
| 1620 | + int cast_type; |
|---|
| 2010 | 1621 | |
|---|
| 2011 | | - memset(hdr, 0, sizeof(struct qeth_hdr)); |
|---|
| 2012 | | - hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3; |
|---|
| 2013 | | - hdr->hdr.l3.length = data_len; |
|---|
| 2014 | | - hdr->hdr.l3.flags = QETH_HDR_IPV6 | QETH_CAST_UNICAST; |
|---|
| 1622 | + rcu_read_lock(); |
|---|
| 1623 | + dst = qeth_dst_check_rcu(skb, ipv); |
|---|
| 1624 | + cast_type = qeth_l3_get_cast_type_rcu(skb, dst, ipv); |
|---|
| 1625 | + rcu_read_unlock(); |
|---|
| 2015 | 1626 | |
|---|
| 2016 | | - iucv_hdr = (struct af_iucv_trans_hdr *)(skb_mac_header(skb) + ETH_HLEN); |
|---|
| 2017 | | - memset(daddr, 0, sizeof(daddr)); |
|---|
| 2018 | | - daddr[0] = 0xfe; |
|---|
| 2019 | | - daddr[1] = 0x80; |
|---|
| 2020 | | - memcpy(&daddr[8], iucv_hdr->destUserID, 8); |
|---|
| 2021 | | - memcpy(hdr->hdr.l3.next_hop.ipv6_addr, daddr, 16); |
|---|
| 1627 | + return cast_type; |
|---|
| 2022 | 1628 | } |
|---|
| 2023 | 1629 | |
|---|
| 2024 | 1630 | static u8 qeth_l3_cast_type_to_flag(int cast_type) |
|---|
| .. | .. |
|---|
| 2032 | 1638 | return QETH_CAST_UNICAST; |
|---|
| 2033 | 1639 | } |
|---|
| 2034 | 1640 | |
|---|
| 2035 | | -static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, |
|---|
| 2036 | | - struct sk_buff *skb, int ipv, int cast_type, |
|---|
| 2037 | | - unsigned int data_len) |
|---|
| 1641 | +static void qeth_l3_fill_header(struct qeth_qdio_out_q *queue, |
|---|
| 1642 | + struct qeth_hdr *hdr, struct sk_buff *skb, |
|---|
| 1643 | + int ipv, unsigned int data_len) |
|---|
| 2038 | 1644 | { |
|---|
| 2039 | | - memset(hdr, 0, sizeof(struct qeth_hdr)); |
|---|
| 2040 | | - hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3; |
|---|
| 1645 | + struct qeth_hdr_layer3 *l3_hdr = &hdr->hdr.l3; |
|---|
| 1646 | + struct vlan_ethhdr *veth = vlan_eth_hdr(skb); |
|---|
| 1647 | + struct qeth_card *card = queue->card; |
|---|
| 1648 | + struct dst_entry *dst; |
|---|
| 1649 | + int cast_type; |
|---|
| 1650 | + |
|---|
| 2041 | 1651 | hdr->hdr.l3.length = data_len; |
|---|
| 2042 | 1652 | |
|---|
| 2043 | | - /* |
|---|
| 2044 | | - * before we're going to overwrite this location with next hop ip. |
|---|
| 2045 | | - * v6 uses passthrough, v4 sets the tag in the QDIO header. |
|---|
| 2046 | | - */ |
|---|
| 2047 | | - if (skb_vlan_tag_present(skb)) { |
|---|
| 2048 | | - if ((ipv == 4) || (card->info.type == QETH_CARD_TYPE_IQD)) |
|---|
| 2049 | | - hdr->hdr.l3.ext_flags = QETH_HDR_EXT_VLAN_FRAME; |
|---|
| 2050 | | - else |
|---|
| 2051 | | - hdr->hdr.l3.ext_flags = QETH_HDR_EXT_INCLUDE_VLAN_TAG; |
|---|
| 2052 | | - hdr->hdr.l3.vlan_id = skb_vlan_tag_get(skb); |
|---|
| 2053 | | - } |
|---|
| 2054 | | - |
|---|
| 2055 | | - if (!skb_is_gso(skb) && skb->ip_summed == CHECKSUM_PARTIAL) { |
|---|
| 2056 | | - qeth_tx_csum(skb, &hdr->hdr.l3.ext_flags, ipv); |
|---|
| 2057 | | - if (card->options.performance_stats) |
|---|
| 2058 | | - card->perf_stats.tx_csum++; |
|---|
| 2059 | | - } |
|---|
| 2060 | | - |
|---|
| 2061 | | - /* OSA only: */ |
|---|
| 2062 | | - if (!ipv) { |
|---|
| 2063 | | - hdr->hdr.l3.flags = QETH_HDR_PASSTHRU; |
|---|
| 2064 | | - if (ether_addr_equal_64bits(eth_hdr(skb)->h_dest, |
|---|
| 2065 | | - skb->dev->broadcast)) |
|---|
| 2066 | | - hdr->hdr.l3.flags |= QETH_CAST_BROADCAST; |
|---|
| 2067 | | - else |
|---|
| 2068 | | - hdr->hdr.l3.flags |= (cast_type == RTN_MULTICAST) ? |
|---|
| 2069 | | - QETH_CAST_MULTICAST : QETH_CAST_UNICAST; |
|---|
| 2070 | | - return; |
|---|
| 2071 | | - } |
|---|
| 2072 | | - |
|---|
| 2073 | | - hdr->hdr.l3.flags = qeth_l3_cast_type_to_flag(cast_type); |
|---|
| 2074 | | - rcu_read_lock(); |
|---|
| 2075 | | - if (ipv == 4) { |
|---|
| 2076 | | - struct rtable *rt = skb_rtable(skb); |
|---|
| 2077 | | - |
|---|
| 2078 | | - *((__be32 *) &hdr->hdr.l3.next_hop.ipv4.addr) = (rt) ? |
|---|
| 2079 | | - rt_nexthop(rt, ip_hdr(skb)->daddr) : |
|---|
| 2080 | | - ip_hdr(skb)->daddr; |
|---|
| 1653 | + if (skb_is_gso(skb)) { |
|---|
| 1654 | + hdr->hdr.l3.id = QETH_HEADER_TYPE_L3_TSO; |
|---|
| 2081 | 1655 | } else { |
|---|
| 2082 | | - /* IPv6 */ |
|---|
| 2083 | | - const struct rt6_info *rt = skb_rt6_info(skb); |
|---|
| 2084 | | - const struct in6_addr *next_hop; |
|---|
| 1656 | + hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3; |
|---|
| 2085 | 1657 | |
|---|
| 2086 | | - if (rt && !ipv6_addr_any(&rt->rt6i_gateway)) |
|---|
| 2087 | | - next_hop = &rt->rt6i_gateway; |
|---|
| 2088 | | - else |
|---|
| 2089 | | - next_hop = &ipv6_hdr(skb)->daddr; |
|---|
| 2090 | | - memcpy(hdr->hdr.l3.next_hop.ipv6_addr, next_hop, 16); |
|---|
| 1658 | + if (skb->protocol == htons(ETH_P_AF_IUCV)) { |
|---|
| 1659 | + l3_hdr->flags = QETH_HDR_IPV6 | QETH_CAST_UNICAST; |
|---|
| 1660 | + l3_hdr->next_hop.addr.s6_addr16[0] = htons(0xfe80); |
|---|
| 1661 | + memcpy(&l3_hdr->next_hop.addr.s6_addr32[2], |
|---|
| 1662 | + iucv_trans_hdr(skb)->destUserID, 8); |
|---|
| 1663 | + return; |
|---|
| 1664 | + } |
|---|
| 1665 | + |
|---|
| 1666 | + if (skb->ip_summed == CHECKSUM_PARTIAL) { |
|---|
| 1667 | + qeth_tx_csum(skb, &hdr->hdr.l3.ext_flags, ipv); |
|---|
| 1668 | + /* some HW requires combined L3+L4 csum offload: */ |
|---|
| 1669 | + if (ipv == 4) |
|---|
| 1670 | + hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_CSUM_HDR_REQ; |
|---|
| 1671 | + } |
|---|
| 1672 | + } |
|---|
| 1673 | + |
|---|
| 1674 | + if (ipv == 4 || IS_IQD(card)) { |
|---|
| 1675 | + /* NETIF_F_HW_VLAN_CTAG_TX */ |
|---|
| 1676 | + if (skb_vlan_tag_present(skb)) { |
|---|
| 1677 | + hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_VLAN_FRAME; |
|---|
| 1678 | + hdr->hdr.l3.vlan_id = skb_vlan_tag_get(skb); |
|---|
| 1679 | + } |
|---|
| 1680 | + } else if (veth->h_vlan_proto == htons(ETH_P_8021Q)) { |
|---|
| 1681 | + hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_INCLUDE_VLAN_TAG; |
|---|
| 1682 | + hdr->hdr.l3.vlan_id = ntohs(veth->h_vlan_TCI); |
|---|
| 1683 | + } |
|---|
| 1684 | + |
|---|
| 1685 | + rcu_read_lock(); |
|---|
| 1686 | + dst = qeth_dst_check_rcu(skb, ipv); |
|---|
| 1687 | + |
|---|
| 1688 | + if (IS_IQD(card) && skb_get_queue_mapping(skb) != QETH_IQD_MCAST_TXQ) |
|---|
| 1689 | + cast_type = RTN_UNICAST; |
|---|
| 1690 | + else |
|---|
| 1691 | + cast_type = qeth_l3_get_cast_type_rcu(skb, dst, ipv); |
|---|
| 1692 | + l3_hdr->flags |= qeth_l3_cast_type_to_flag(cast_type); |
|---|
| 1693 | + |
|---|
| 1694 | + if (ipv == 4) { |
|---|
| 1695 | + l3_hdr->next_hop.addr.s6_addr32[3] = |
|---|
| 1696 | + qeth_next_hop_v4_rcu(skb, dst); |
|---|
| 1697 | + } else if (ipv == 6) { |
|---|
| 1698 | + l3_hdr->next_hop.addr = *qeth_next_hop_v6_rcu(skb, dst); |
|---|
| 2091 | 1699 | |
|---|
| 2092 | 1700 | hdr->hdr.l3.flags |= QETH_HDR_IPV6; |
|---|
| 2093 | | - if (card->info.type != QETH_CARD_TYPE_IQD) |
|---|
| 1701 | + if (!IS_IQD(card)) |
|---|
| 2094 | 1702 | hdr->hdr.l3.flags |= QETH_HDR_PASSTHRU; |
|---|
| 1703 | + } else { |
|---|
| 1704 | + /* OSA only: */ |
|---|
| 1705 | + l3_hdr->flags |= QETH_HDR_PASSTHRU; |
|---|
| 2095 | 1706 | } |
|---|
| 2096 | 1707 | rcu_read_unlock(); |
|---|
| 2097 | 1708 | } |
|---|
| 2098 | 1709 | |
|---|
| 2099 | | -static void qeth_tso_fill_header(struct qeth_card *card, |
|---|
| 2100 | | - struct qeth_hdr *qhdr, struct sk_buff *skb) |
|---|
| 1710 | +static void qeth_l3_fixup_headers(struct sk_buff *skb) |
|---|
| 2101 | 1711 | { |
|---|
| 2102 | | - struct qeth_hdr_tso *hdr = (struct qeth_hdr_tso *)qhdr; |
|---|
| 2103 | | - struct tcphdr *tcph = tcp_hdr(skb); |
|---|
| 2104 | 1712 | struct iphdr *iph = ip_hdr(skb); |
|---|
| 2105 | | - struct ipv6hdr *ip6h = ipv6_hdr(skb); |
|---|
| 2106 | 1713 | |
|---|
| 2107 | | - /*fix header to TSO values ...*/ |
|---|
| 2108 | | - hdr->hdr.hdr.l3.id = QETH_HEADER_TYPE_TSO; |
|---|
| 2109 | | - /*set values which are fix for the first approach ...*/ |
|---|
| 2110 | | - hdr->ext.hdr_tot_len = (__u16) sizeof(struct qeth_hdr_ext_tso); |
|---|
| 2111 | | - hdr->ext.imb_hdr_no = 1; |
|---|
| 2112 | | - hdr->ext.hdr_type = 1; |
|---|
| 2113 | | - hdr->ext.hdr_version = 1; |
|---|
| 2114 | | - hdr->ext.hdr_len = 28; |
|---|
| 2115 | | - /*insert non-fix values */ |
|---|
| 2116 | | - hdr->ext.mss = skb_shinfo(skb)->gso_size; |
|---|
| 2117 | | - hdr->ext.dg_hdr_len = (__u16)(ip_hdrlen(skb) + tcp_hdrlen(skb)); |
|---|
| 2118 | | - hdr->ext.payload_len = (__u16)(skb->len - hdr->ext.dg_hdr_len - |
|---|
| 2119 | | - sizeof(struct qeth_hdr_tso)); |
|---|
| 2120 | | - tcph->check = 0; |
|---|
| 2121 | | - if (be16_to_cpu(skb->protocol) == ETH_P_IPV6) { |
|---|
| 2122 | | - ip6h->payload_len = 0; |
|---|
| 2123 | | - tcph->check = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, |
|---|
| 2124 | | - 0, IPPROTO_TCP, 0); |
|---|
| 2125 | | - } else { |
|---|
| 2126 | | - /*OSA want us to set these values ...*/ |
|---|
| 2127 | | - tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, |
|---|
| 2128 | | - 0, IPPROTO_TCP, 0); |
|---|
| 2129 | | - iph->tot_len = 0; |
|---|
| 1714 | + /* this is safe, IPv6 traffic takes a different path */ |
|---|
| 1715 | + if (skb->ip_summed == CHECKSUM_PARTIAL) |
|---|
| 2130 | 1716 | iph->check = 0; |
|---|
| 1717 | + if (skb_is_gso(skb)) { |
|---|
| 1718 | + iph->tot_len = 0; |
|---|
| 1719 | + tcp_hdr(skb)->check = ~tcp_v4_check(0, iph->saddr, |
|---|
| 1720 | + iph->daddr, 0); |
|---|
| 2131 | 1721 | } |
|---|
| 2132 | | -} |
|---|
| 2133 | | - |
|---|
| 2134 | | -/** |
|---|
| 2135 | | - * qeth_l3_get_elements_no_tso() - find number of SBALEs for skb data for tso |
|---|
| 2136 | | - * @card: qeth card structure, to check max. elems. |
|---|
| 2137 | | - * @skb: SKB address |
|---|
| 2138 | | - * @extra_elems: extra elems needed, to check against max. |
|---|
| 2139 | | - * |
|---|
| 2140 | | - * Returns the number of pages, and thus QDIO buffer elements, needed to cover |
|---|
| 2141 | | - * skb data, including linear part and fragments, but excluding TCP header. |
|---|
| 2142 | | - * (Exclusion of TCP header distinguishes it from qeth_get_elements_no().) |
|---|
| 2143 | | - * Checks if the result plus extra_elems fits under the limit for the card. |
|---|
| 2144 | | - * Returns 0 if it does not. |
|---|
| 2145 | | - * Note: extra_elems is not included in the returned result. |
|---|
| 2146 | | - */ |
|---|
| 2147 | | -static int qeth_l3_get_elements_no_tso(struct qeth_card *card, |
|---|
| 2148 | | - struct sk_buff *skb, int extra_elems) |
|---|
| 2149 | | -{ |
|---|
| 2150 | | - addr_t start = (addr_t)tcp_hdr(skb) + tcp_hdrlen(skb); |
|---|
| 2151 | | - addr_t end = (addr_t)skb->data + skb_headlen(skb); |
|---|
| 2152 | | - int elements = qeth_get_elements_for_frags(skb); |
|---|
| 2153 | | - |
|---|
| 2154 | | - if (start != end) |
|---|
| 2155 | | - elements += qeth_get_elements_for_range(start, end); |
|---|
| 2156 | | - |
|---|
| 2157 | | - if ((elements + extra_elems) > QETH_MAX_BUFFER_ELEMENTS(card)) { |
|---|
| 2158 | | - QETH_DBF_MESSAGE(2, |
|---|
| 2159 | | - "Invalid size of TSO IP packet (Number=%d / Length=%d). Discarded.\n", |
|---|
| 2160 | | - elements + extra_elems, skb->len); |
|---|
| 2161 | | - return 0; |
|---|
| 2162 | | - } |
|---|
| 2163 | | - return elements; |
|---|
| 2164 | | -} |
|---|
| 2165 | | - |
|---|
| 2166 | | -static int qeth_l3_xmit_offload(struct qeth_card *card, struct sk_buff *skb, |
|---|
| 2167 | | - struct qeth_qdio_out_q *queue, int ipv, |
|---|
| 2168 | | - int cast_type) |
|---|
| 2169 | | -{ |
|---|
| 2170 | | - const unsigned int hw_hdr_len = sizeof(struct qeth_hdr); |
|---|
| 2171 | | - unsigned int frame_len, elements; |
|---|
| 2172 | | - unsigned char eth_hdr[ETH_HLEN]; |
|---|
| 2173 | | - struct qeth_hdr *hdr = NULL; |
|---|
| 2174 | | - unsigned int hd_len = 0; |
|---|
| 2175 | | - int push_len, rc; |
|---|
| 2176 | | - bool is_sg; |
|---|
| 2177 | | - |
|---|
| 2178 | | - /* re-use the L2 header area for the HW header: */ |
|---|
| 2179 | | - rc = skb_cow_head(skb, hw_hdr_len - ETH_HLEN); |
|---|
| 2180 | | - if (rc) |
|---|
| 2181 | | - return rc; |
|---|
| 2182 | | - skb_copy_from_linear_data(skb, eth_hdr, ETH_HLEN); |
|---|
| 2183 | | - skb_pull(skb, ETH_HLEN); |
|---|
| 2184 | | - frame_len = skb->len; |
|---|
| 2185 | | - |
|---|
| 2186 | | - push_len = qeth_add_hw_header(card, skb, &hdr, hw_hdr_len, 0, |
|---|
| 2187 | | - &elements); |
|---|
| 2188 | | - if (push_len < 0) |
|---|
| 2189 | | - return push_len; |
|---|
| 2190 | | - if (!push_len) { |
|---|
| 2191 | | - /* hdr was added discontiguous from skb->data */ |
|---|
| 2192 | | - hd_len = hw_hdr_len; |
|---|
| 2193 | | - } |
|---|
| 2194 | | - |
|---|
| 2195 | | - if (skb->protocol == htons(ETH_P_AF_IUCV)) |
|---|
| 2196 | | - qeth_l3_fill_af_iucv_hdr(hdr, skb, frame_len); |
|---|
| 2197 | | - else |
|---|
| 2198 | | - qeth_l3_fill_header(card, hdr, skb, ipv, cast_type, frame_len); |
|---|
| 2199 | | - |
|---|
| 2200 | | - is_sg = skb_is_nonlinear(skb); |
|---|
| 2201 | | - if (IS_IQD(card)) { |
|---|
| 2202 | | - rc = qeth_do_send_packet_fast(queue, skb, hdr, 0, hd_len); |
|---|
| 2203 | | - } else { |
|---|
| 2204 | | - /* TODO: drop skb_orphan() once TX completion is fast enough */ |
|---|
| 2205 | | - skb_orphan(skb); |
|---|
| 2206 | | - rc = qeth_do_send_packet(card, queue, skb, hdr, 0, hd_len, |
|---|
| 2207 | | - elements); |
|---|
| 2208 | | - } |
|---|
| 2209 | | - |
|---|
| 2210 | | - if (!rc) { |
|---|
| 2211 | | - if (card->options.performance_stats) { |
|---|
| 2212 | | - card->perf_stats.buf_elements_sent += elements; |
|---|
| 2213 | | - if (is_sg) |
|---|
| 2214 | | - card->perf_stats.sg_skbs_sent++; |
|---|
| 2215 | | - } |
|---|
| 2216 | | - } else { |
|---|
| 2217 | | - if (!push_len) |
|---|
| 2218 | | - kmem_cache_free(qeth_core_header_cache, hdr); |
|---|
| 2219 | | - if (rc == -EBUSY) { |
|---|
| 2220 | | - /* roll back to ETH header */ |
|---|
| 2221 | | - skb_pull(skb, push_len); |
|---|
| 2222 | | - skb_push(skb, ETH_HLEN); |
|---|
| 2223 | | - skb_copy_to_linear_data(skb, eth_hdr, ETH_HLEN); |
|---|
| 2224 | | - } |
|---|
| 2225 | | - } |
|---|
| 2226 | | - return rc; |
|---|
| 2227 | 1722 | } |
|---|
| 2228 | 1723 | |
|---|
| 2229 | 1724 | static int qeth_l3_xmit(struct qeth_card *card, struct sk_buff *skb, |
|---|
| 2230 | | - struct qeth_qdio_out_q *queue, int ipv, int cast_type) |
|---|
| 1725 | + struct qeth_qdio_out_q *queue, int ipv) |
|---|
| 2231 | 1726 | { |
|---|
| 2232 | | - int elements, len, rc; |
|---|
| 2233 | | - __be16 *tag; |
|---|
| 2234 | | - struct qeth_hdr *hdr = NULL; |
|---|
| 2235 | | - int hdr_elements = 0; |
|---|
| 2236 | | - struct sk_buff *new_skb = NULL; |
|---|
| 2237 | | - int tx_bytes = skb->len; |
|---|
| 2238 | | - unsigned int hd_len; |
|---|
| 2239 | | - bool use_tso, is_sg; |
|---|
| 1727 | + unsigned int hw_hdr_len; |
|---|
| 1728 | + int rc; |
|---|
| 2240 | 1729 | |
|---|
| 2241 | | - /* Ignore segment size from skb_is_gso(), 1 page is always used. */ |
|---|
| 2242 | | - use_tso = skb_is_gso(skb) && |
|---|
| 2243 | | - (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4); |
|---|
| 1730 | + /* re-use the L2 header area for the HW header: */ |
|---|
| 1731 | + hw_hdr_len = skb_is_gso(skb) ? sizeof(struct qeth_hdr_tso) : |
|---|
| 1732 | + sizeof(struct qeth_hdr); |
|---|
| 1733 | + rc = skb_cow_head(skb, hw_hdr_len - ETH_HLEN); |
|---|
| 1734 | + if (rc) |
|---|
| 1735 | + return rc; |
|---|
| 1736 | + skb_pull(skb, ETH_HLEN); |
|---|
| 2244 | 1737 | |
|---|
| 2245 | | - /* create a clone with writeable headroom */ |
|---|
| 2246 | | - new_skb = skb_realloc_headroom(skb, sizeof(struct qeth_hdr_tso) + |
|---|
| 2247 | | - VLAN_HLEN); |
|---|
| 2248 | | - if (!new_skb) |
|---|
| 2249 | | - return -ENOMEM; |
|---|
| 2250 | | - |
|---|
| 2251 | | - if (ipv == 4) { |
|---|
| 2252 | | - skb_pull(new_skb, ETH_HLEN); |
|---|
| 2253 | | - } else if (skb_vlan_tag_present(new_skb)) { |
|---|
| 2254 | | - skb_push(new_skb, VLAN_HLEN); |
|---|
| 2255 | | - skb_copy_to_linear_data(new_skb, new_skb->data + 4, 4); |
|---|
| 2256 | | - skb_copy_to_linear_data_offset(new_skb, 4, |
|---|
| 2257 | | - new_skb->data + 8, 4); |
|---|
| 2258 | | - skb_copy_to_linear_data_offset(new_skb, 8, |
|---|
| 2259 | | - new_skb->data + 12, 4); |
|---|
| 2260 | | - tag = (__be16 *)(new_skb->data + 12); |
|---|
| 2261 | | - *tag = cpu_to_be16(ETH_P_8021Q); |
|---|
| 2262 | | - *(tag + 1) = cpu_to_be16(skb_vlan_tag_get(new_skb)); |
|---|
| 2263 | | - } |
|---|
| 2264 | | - |
|---|
| 2265 | | - /* fix hardware limitation: as long as we do not have sbal |
|---|
| 2266 | | - * chaining we can not send long frag lists |
|---|
| 2267 | | - */ |
|---|
| 2268 | | - if ((use_tso && !qeth_l3_get_elements_no_tso(card, new_skb, 1)) || |
|---|
| 2269 | | - (!use_tso && !qeth_get_elements_no(card, new_skb, 0, 0))) { |
|---|
| 2270 | | - rc = skb_linearize(new_skb); |
|---|
| 2271 | | - |
|---|
| 2272 | | - if (card->options.performance_stats) { |
|---|
| 2273 | | - if (rc) |
|---|
| 2274 | | - card->perf_stats.tx_linfail++; |
|---|
| 2275 | | - else |
|---|
| 2276 | | - card->perf_stats.tx_lin++; |
|---|
| 2277 | | - } |
|---|
| 2278 | | - if (rc) |
|---|
| 2279 | | - goto out; |
|---|
| 2280 | | - } |
|---|
| 2281 | | - |
|---|
| 2282 | | - if (use_tso) { |
|---|
| 2283 | | - hdr = skb_push(new_skb, sizeof(struct qeth_hdr_tso)); |
|---|
| 2284 | | - memset(hdr, 0, sizeof(struct qeth_hdr_tso)); |
|---|
| 2285 | | - qeth_l3_fill_header(card, hdr, new_skb, ipv, cast_type, |
|---|
| 2286 | | - new_skb->len - sizeof(struct qeth_hdr_tso)); |
|---|
| 2287 | | - qeth_tso_fill_header(card, hdr, new_skb); |
|---|
| 2288 | | - hdr_elements++; |
|---|
| 2289 | | - } else { |
|---|
| 2290 | | - hdr = skb_push(new_skb, sizeof(struct qeth_hdr)); |
|---|
| 2291 | | - qeth_l3_fill_header(card, hdr, new_skb, ipv, cast_type, |
|---|
| 2292 | | - new_skb->len - sizeof(struct qeth_hdr)); |
|---|
| 2293 | | - } |
|---|
| 2294 | | - |
|---|
| 2295 | | - elements = use_tso ? |
|---|
| 2296 | | - qeth_l3_get_elements_no_tso(card, new_skb, hdr_elements) : |
|---|
| 2297 | | - qeth_get_elements_no(card, new_skb, hdr_elements, 0); |
|---|
| 2298 | | - if (!elements) { |
|---|
| 2299 | | - rc = -E2BIG; |
|---|
| 2300 | | - goto out; |
|---|
| 2301 | | - } |
|---|
| 2302 | | - elements += hdr_elements; |
|---|
| 2303 | | - |
|---|
| 2304 | | - if (use_tso) { |
|---|
| 2305 | | - hd_len = sizeof(struct qeth_hdr_tso) + |
|---|
| 2306 | | - ip_hdrlen(new_skb) + tcp_hdrlen(new_skb); |
|---|
| 2307 | | - len = hd_len; |
|---|
| 2308 | | - } else { |
|---|
| 2309 | | - hd_len = 0; |
|---|
| 2310 | | - len = sizeof(struct qeth_hdr_layer3); |
|---|
| 2311 | | - } |
|---|
| 2312 | | - |
|---|
| 2313 | | - if (qeth_hdr_chk_and_bounce(new_skb, &hdr, len)) { |
|---|
| 2314 | | - rc = -EINVAL; |
|---|
| 2315 | | - goto out; |
|---|
| 2316 | | - } |
|---|
| 2317 | | - |
|---|
| 2318 | | - is_sg = skb_is_nonlinear(new_skb); |
|---|
| 2319 | | - rc = qeth_do_send_packet(card, queue, new_skb, hdr, hd_len, hd_len, |
|---|
| 2320 | | - elements); |
|---|
| 2321 | | -out: |
|---|
| 2322 | | - if (!rc) { |
|---|
| 2323 | | - if (new_skb != skb) |
|---|
| 2324 | | - dev_kfree_skb_any(skb); |
|---|
| 2325 | | - if (card->options.performance_stats) { |
|---|
| 2326 | | - card->perf_stats.buf_elements_sent += elements; |
|---|
| 2327 | | - if (is_sg) |
|---|
| 2328 | | - card->perf_stats.sg_skbs_sent++; |
|---|
| 2329 | | - if (use_tso) { |
|---|
| 2330 | | - card->perf_stats.large_send_bytes += tx_bytes; |
|---|
| 2331 | | - card->perf_stats.large_send_cnt++; |
|---|
| 2332 | | - } |
|---|
| 2333 | | - } |
|---|
| 2334 | | - } else { |
|---|
| 2335 | | - if (new_skb != skb) |
|---|
| 2336 | | - dev_kfree_skb_any(new_skb); |
|---|
| 2337 | | - } |
|---|
| 2338 | | - return rc; |
|---|
| 1738 | + qeth_l3_fixup_headers(skb); |
|---|
| 1739 | + return qeth_xmit(card, skb, queue, ipv, qeth_l3_fill_header); |
|---|
| 2339 | 1740 | } |
|---|
| 2340 | 1741 | |
|---|
| 2341 | 1742 | static netdev_tx_t qeth_l3_hard_start_xmit(struct sk_buff *skb, |
|---|
| 2342 | 1743 | struct net_device *dev) |
|---|
| 2343 | 1744 | { |
|---|
| 2344 | | - int cast_type = qeth_l3_get_cast_type(skb); |
|---|
| 2345 | 1745 | struct qeth_card *card = dev->ml_priv; |
|---|
| 1746 | + u16 txq = skb_get_queue_mapping(skb); |
|---|
| 2346 | 1747 | int ipv = qeth_get_ip_version(skb); |
|---|
| 2347 | 1748 | struct qeth_qdio_out_q *queue; |
|---|
| 2348 | | - int tx_bytes = skb->len; |
|---|
| 2349 | 1749 | int rc; |
|---|
| 2350 | 1750 | |
|---|
| 1751 | + if (!skb_is_gso(skb)) |
|---|
| 1752 | + qdisc_skb_cb(skb)->pkt_len = skb->len; |
|---|
| 2351 | 1753 | if (IS_IQD(card)) { |
|---|
| 1754 | + queue = card->qdio.out_qs[qeth_iqd_translate_txq(dev, txq)]; |
|---|
| 1755 | + |
|---|
| 2352 | 1756 | if (card->options.sniffer) |
|---|
| 2353 | 1757 | goto tx_drop; |
|---|
| 2354 | 1758 | if ((card->options.cq != QETH_CQ_ENABLED && !ipv) || |
|---|
| 2355 | 1759 | (card->options.cq == QETH_CQ_ENABLED && |
|---|
| 2356 | 1760 | skb->protocol != htons(ETH_P_AF_IUCV))) |
|---|
| 2357 | 1761 | goto tx_drop; |
|---|
| 1762 | + } else { |
|---|
| 1763 | + queue = card->qdio.out_qs[txq]; |
|---|
| 2358 | 1764 | } |
|---|
| 2359 | 1765 | |
|---|
| 2360 | | - if (card->state != CARD_STATE_UP || !card->lan_online) { |
|---|
| 2361 | | - card->stats.tx_carrier_errors++; |
|---|
| 2362 | | - goto tx_drop; |
|---|
| 2363 | | - } |
|---|
| 2364 | | - |
|---|
| 2365 | | - if (cast_type == RTN_BROADCAST && !card->info.broadcast_capable) |
|---|
| 1766 | + if (!(dev->flags & IFF_BROADCAST) && |
|---|
| 1767 | + qeth_l3_get_cast_type(skb) == RTN_BROADCAST) |
|---|
| 2366 | 1768 | goto tx_drop; |
|---|
| 2367 | 1769 | |
|---|
| 2368 | | - queue = qeth_get_tx_queue(card, skb, ipv, cast_type); |
|---|
| 2369 | | - |
|---|
| 2370 | | - if (card->options.performance_stats) { |
|---|
| 2371 | | - card->perf_stats.outbound_cnt++; |
|---|
| 2372 | | - card->perf_stats.outbound_start_time = qeth_get_micros(); |
|---|
| 2373 | | - } |
|---|
| 2374 | | - netif_stop_queue(dev); |
|---|
| 2375 | | - |
|---|
| 2376 | | - if (IS_IQD(card) || (!skb_is_gso(skb) && ipv == 4)) |
|---|
| 2377 | | - rc = qeth_l3_xmit_offload(card, skb, queue, ipv, cast_type); |
|---|
| 1770 | + if (ipv == 4 || IS_IQD(card)) |
|---|
| 1771 | + rc = qeth_l3_xmit(card, skb, queue, ipv); |
|---|
| 2378 | 1772 | else |
|---|
| 2379 | | - rc = qeth_l3_xmit(card, skb, queue, ipv, cast_type); |
|---|
| 1773 | + rc = qeth_xmit(card, skb, queue, ipv, qeth_l3_fill_header); |
|---|
| 2380 | 1774 | |
|---|
| 2381 | | - if (!rc) { |
|---|
| 2382 | | - card->stats.tx_packets++; |
|---|
| 2383 | | - card->stats.tx_bytes += tx_bytes; |
|---|
| 2384 | | - if (card->options.performance_stats) |
|---|
| 2385 | | - card->perf_stats.outbound_time += qeth_get_micros() - |
|---|
| 2386 | | - card->perf_stats.outbound_start_time; |
|---|
| 2387 | | - netif_wake_queue(dev); |
|---|
| 1775 | + if (!rc) |
|---|
| 2388 | 1776 | return NETDEV_TX_OK; |
|---|
| 2389 | | - } else if (rc == -EBUSY) { |
|---|
| 2390 | | - return NETDEV_TX_BUSY; |
|---|
| 2391 | | - } /* else fall through */ |
|---|
| 2392 | 1777 | |
|---|
| 2393 | 1778 | tx_drop: |
|---|
| 2394 | | - card->stats.tx_dropped++; |
|---|
| 2395 | | - card->stats.tx_errors++; |
|---|
| 2396 | | - dev_kfree_skb_any(skb); |
|---|
| 2397 | | - netif_wake_queue(dev); |
|---|
| 1779 | + QETH_TXQ_STAT_INC(queue, tx_dropped); |
|---|
| 1780 | + kfree_skb(skb); |
|---|
| 2398 | 1781 | return NETDEV_TX_OK; |
|---|
| 2399 | 1782 | } |
|---|
| 2400 | 1783 | |
|---|
| 2401 | | -static int __qeth_l3_open(struct net_device *dev) |
|---|
| 2402 | | -{ |
|---|
| 2403 | | - struct qeth_card *card = dev->ml_priv; |
|---|
| 2404 | | - int rc = 0; |
|---|
| 2405 | | - |
|---|
| 2406 | | - QETH_CARD_TEXT(card, 4, "qethopen"); |
|---|
| 2407 | | - if (card->state == CARD_STATE_UP) |
|---|
| 2408 | | - return rc; |
|---|
| 2409 | | - if (card->state != CARD_STATE_SOFTSETUP) |
|---|
| 2410 | | - return -ENODEV; |
|---|
| 2411 | | - card->data.state = CH_STATE_UP; |
|---|
| 2412 | | - card->state = CARD_STATE_UP; |
|---|
| 2413 | | - netif_start_queue(dev); |
|---|
| 2414 | | - |
|---|
| 2415 | | - if (qdio_stop_irq(card->data.ccwdev, 0) >= 0) { |
|---|
| 2416 | | - napi_enable(&card->napi); |
|---|
| 2417 | | - local_bh_disable(); |
|---|
| 2418 | | - napi_schedule(&card->napi); |
|---|
| 2419 | | - /* kick-start the NAPI softirq: */ |
|---|
| 2420 | | - local_bh_enable(); |
|---|
| 2421 | | - } else |
|---|
| 2422 | | - rc = -EIO; |
|---|
| 2423 | | - return rc; |
|---|
| 2424 | | -} |
|---|
| 2425 | | - |
|---|
| 2426 | | -static int qeth_l3_open(struct net_device *dev) |
|---|
| 1784 | +static void qeth_l3_set_rx_mode(struct net_device *dev) |
|---|
| 2427 | 1785 | { |
|---|
| 2428 | 1786 | struct qeth_card *card = dev->ml_priv; |
|---|
| 2429 | 1787 | |
|---|
| 2430 | | - QETH_CARD_TEXT(card, 5, "qethope_"); |
|---|
| 2431 | | - if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { |
|---|
| 2432 | | - QETH_CARD_TEXT(card, 3, "openREC"); |
|---|
| 2433 | | - return -ERESTARTSYS; |
|---|
| 2434 | | - } |
|---|
| 2435 | | - return __qeth_l3_open(dev); |
|---|
| 1788 | + schedule_work(&card->rx_mode_work); |
|---|
| 2436 | 1789 | } |
|---|
| 2437 | | - |
|---|
| 2438 | | -static int qeth_l3_stop(struct net_device *dev) |
|---|
| 2439 | | -{ |
|---|
| 2440 | | - struct qeth_card *card = dev->ml_priv; |
|---|
| 2441 | | - |
|---|
| 2442 | | - QETH_CARD_TEXT(card, 4, "qethstop"); |
|---|
| 2443 | | - netif_tx_disable(dev); |
|---|
| 2444 | | - if (card->state == CARD_STATE_UP) { |
|---|
| 2445 | | - card->state = CARD_STATE_SOFTSETUP; |
|---|
| 2446 | | - napi_disable(&card->napi); |
|---|
| 2447 | | - } |
|---|
| 2448 | | - return 0; |
|---|
| 2449 | | -} |
|---|
| 2450 | | - |
|---|
| 2451 | | -static const struct ethtool_ops qeth_l3_ethtool_ops = { |
|---|
| 2452 | | - .get_link = ethtool_op_get_link, |
|---|
| 2453 | | - .get_strings = qeth_core_get_strings, |
|---|
| 2454 | | - .get_ethtool_stats = qeth_core_get_ethtool_stats, |
|---|
| 2455 | | - .get_sset_count = qeth_core_get_sset_count, |
|---|
| 2456 | | - .get_drvinfo = qeth_core_get_drvinfo, |
|---|
| 2457 | | - .get_link_ksettings = qeth_core_ethtool_get_link_ksettings, |
|---|
| 2458 | | -}; |
|---|
| 2459 | 1790 | |
|---|
| 2460 | 1791 | /* |
|---|
| 2461 | 1792 | * we need NOARP for IPv4 but we want neighbor solicitation for IPv6. Setting |
|---|
| .. | .. |
|---|
| 2481 | 1812 | return 0; |
|---|
| 2482 | 1813 | } |
|---|
| 2483 | 1814 | |
|---|
| 1815 | +static netdev_features_t qeth_l3_osa_features_check(struct sk_buff *skb, |
|---|
| 1816 | + struct net_device *dev, |
|---|
| 1817 | + netdev_features_t features) |
|---|
| 1818 | +{ |
|---|
| 1819 | + if (vlan_get_protocol(skb) != htons(ETH_P_IP)) |
|---|
| 1820 | + features &= ~NETIF_F_HW_VLAN_CTAG_TX; |
|---|
| 1821 | + return qeth_features_check(skb, dev, features); |
|---|
| 1822 | +} |
|---|
| 1823 | + |
|---|
| 1824 | +static u16 qeth_l3_iqd_select_queue(struct net_device *dev, struct sk_buff *skb, |
|---|
| 1825 | + struct net_device *sb_dev) |
|---|
| 1826 | +{ |
|---|
| 1827 | + return qeth_iqd_select_queue(dev, skb, qeth_l3_get_cast_type(skb), |
|---|
| 1828 | + sb_dev); |
|---|
| 1829 | +} |
|---|
| 1830 | + |
|---|
| 1831 | +static u16 qeth_l3_osa_select_queue(struct net_device *dev, struct sk_buff *skb, |
|---|
| 1832 | + struct net_device *sb_dev) |
|---|
| 1833 | +{ |
|---|
| 1834 | + struct qeth_card *card = dev->ml_priv; |
|---|
| 1835 | + |
|---|
| 1836 | + if (qeth_uses_tx_prio_queueing(card)) |
|---|
| 1837 | + return qeth_get_priority_queue(card, skb); |
|---|
| 1838 | + |
|---|
| 1839 | + return netdev_pick_tx(dev, skb, sb_dev); |
|---|
| 1840 | +} |
|---|
| 1841 | + |
|---|
| 2484 | 1842 | static const struct net_device_ops qeth_l3_netdev_ops = { |
|---|
| 2485 | | - .ndo_open = qeth_l3_open, |
|---|
| 2486 | | - .ndo_stop = qeth_l3_stop, |
|---|
| 2487 | | - .ndo_get_stats = qeth_get_stats, |
|---|
| 1843 | + .ndo_open = qeth_open, |
|---|
| 1844 | + .ndo_stop = qeth_stop, |
|---|
| 1845 | + .ndo_get_stats64 = qeth_get_stats64, |
|---|
| 2488 | 1846 | .ndo_start_xmit = qeth_l3_hard_start_xmit, |
|---|
| 1847 | + .ndo_select_queue = qeth_l3_iqd_select_queue, |
|---|
| 2489 | 1848 | .ndo_validate_addr = eth_validate_addr, |
|---|
| 2490 | 1849 | .ndo_set_rx_mode = qeth_l3_set_rx_mode, |
|---|
| 2491 | 1850 | .ndo_do_ioctl = qeth_do_ioctl, |
|---|
| .. | .. |
|---|
| 2497 | 1856 | }; |
|---|
| 2498 | 1857 | |
|---|
| 2499 | 1858 | static const struct net_device_ops qeth_l3_osa_netdev_ops = { |
|---|
| 2500 | | - .ndo_open = qeth_l3_open, |
|---|
| 2501 | | - .ndo_stop = qeth_l3_stop, |
|---|
| 2502 | | - .ndo_get_stats = qeth_get_stats, |
|---|
| 1859 | + .ndo_open = qeth_open, |
|---|
| 1860 | + .ndo_stop = qeth_stop, |
|---|
| 1861 | + .ndo_get_stats64 = qeth_get_stats64, |
|---|
| 2503 | 1862 | .ndo_start_xmit = qeth_l3_hard_start_xmit, |
|---|
| 2504 | | - .ndo_features_check = qeth_features_check, |
|---|
| 1863 | + .ndo_features_check = qeth_l3_osa_features_check, |
|---|
| 1864 | + .ndo_select_queue = qeth_l3_osa_select_queue, |
|---|
| 2505 | 1865 | .ndo_validate_addr = eth_validate_addr, |
|---|
| 2506 | 1866 | .ndo_set_rx_mode = qeth_l3_set_rx_mode, |
|---|
| 2507 | 1867 | .ndo_do_ioctl = qeth_do_ioctl, |
|---|
| .. | .. |
|---|
| 2515 | 1875 | |
|---|
| 2516 | 1876 | static int qeth_l3_setup_netdev(struct qeth_card *card) |
|---|
| 2517 | 1877 | { |
|---|
| 1878 | + struct net_device *dev = card->dev; |
|---|
| 1879 | + unsigned int headroom; |
|---|
| 2518 | 1880 | int rc; |
|---|
| 2519 | 1881 | |
|---|
| 2520 | | - if (qeth_netdev_is_registered(card->dev)) |
|---|
| 2521 | | - return 0; |
|---|
| 2522 | | - |
|---|
| 2523 | | - if (card->info.type == QETH_CARD_TYPE_OSD || |
|---|
| 2524 | | - card->info.type == QETH_CARD_TYPE_OSX) { |
|---|
| 2525 | | - if ((card->info.link_type == QETH_LINK_TYPE_LANE_TR) || |
|---|
| 2526 | | - (card->info.link_type == QETH_LINK_TYPE_HSTR)) { |
|---|
| 2527 | | - pr_info("qeth_l3: ignoring TR device\n"); |
|---|
| 2528 | | - return -ENODEV; |
|---|
| 2529 | | - } |
|---|
| 2530 | | - |
|---|
| 1882 | + if (IS_OSD(card) || IS_OSX(card)) { |
|---|
| 2531 | 1883 | card->dev->netdev_ops = &qeth_l3_osa_netdev_ops; |
|---|
| 2532 | 1884 | |
|---|
| 2533 | 1885 | /*IPv6 address autoconfiguration stuff*/ |
|---|
| 2534 | | - qeth_l3_get_unique_id(card); |
|---|
| 2535 | | - if (!(card->info.unique_id & UNIQUE_ID_NOT_BY_CARD)) |
|---|
| 2536 | | - card->dev->dev_id = card->info.unique_id & 0xffff; |
|---|
| 1886 | + dev->dev_id = qeth_l3_get_unique_id(card, dev->dev_id); |
|---|
| 2537 | 1887 | |
|---|
| 2538 | | - if (!card->info.guestlan) { |
|---|
| 1888 | + if (!IS_VM_NIC(card)) { |
|---|
| 2539 | 1889 | card->dev->features |= NETIF_F_SG; |
|---|
| 2540 | 1890 | card->dev->hw_features |= NETIF_F_TSO | |
|---|
| 2541 | 1891 | NETIF_F_RXCSUM | NETIF_F_IP_CSUM; |
|---|
| .. | .. |
|---|
| 2547 | 1897 | card->dev->hw_features |= NETIF_F_IPV6_CSUM; |
|---|
| 2548 | 1898 | card->dev->vlan_features |= NETIF_F_IPV6_CSUM; |
|---|
| 2549 | 1899 | } |
|---|
| 2550 | | - } else if (card->info.type == QETH_CARD_TYPE_IQD) { |
|---|
| 1900 | + if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) { |
|---|
| 1901 | + card->dev->hw_features |= NETIF_F_TSO6; |
|---|
| 1902 | + card->dev->vlan_features |= NETIF_F_TSO6; |
|---|
| 1903 | + } |
|---|
| 1904 | + |
|---|
| 1905 | + /* allow for de-acceleration of NETIF_F_HW_VLAN_CTAG_TX: */ |
|---|
| 1906 | + if (card->dev->hw_features & NETIF_F_TSO6) |
|---|
| 1907 | + headroom = sizeof(struct qeth_hdr_tso) + VLAN_HLEN; |
|---|
| 1908 | + else if (card->dev->hw_features & NETIF_F_TSO) |
|---|
| 1909 | + headroom = sizeof(struct qeth_hdr_tso); |
|---|
| 1910 | + else |
|---|
| 1911 | + headroom = sizeof(struct qeth_hdr) + VLAN_HLEN; |
|---|
| 1912 | + } else if (IS_IQD(card)) { |
|---|
| 2551 | 1913 | card->dev->flags |= IFF_NOARP; |
|---|
| 2552 | 1914 | card->dev->netdev_ops = &qeth_l3_netdev_ops; |
|---|
| 1915 | + headroom = sizeof(struct qeth_hdr) - ETH_HLEN; |
|---|
| 2553 | 1916 | |
|---|
| 2554 | 1917 | rc = qeth_l3_iqd_read_initial_mac(card); |
|---|
| 2555 | 1918 | if (rc) |
|---|
| 2556 | | - goto out; |
|---|
| 2557 | | - |
|---|
| 2558 | | - if (card->options.hsuid[0]) |
|---|
| 2559 | | - memcpy(card->dev->perm_addr, card->options.hsuid, 9); |
|---|
| 1919 | + return rc; |
|---|
| 2560 | 1920 | } else |
|---|
| 2561 | 1921 | return -ENODEV; |
|---|
| 2562 | 1922 | |
|---|
| 2563 | | - card->dev->ethtool_ops = &qeth_l3_ethtool_ops; |
|---|
| 2564 | | - card->dev->needed_headroom = sizeof(struct qeth_hdr) - ETH_HLEN; |
|---|
| 1923 | + card->dev->needed_headroom = headroom; |
|---|
| 2565 | 1924 | card->dev->features |= NETIF_F_HW_VLAN_CTAG_TX | |
|---|
| 2566 | 1925 | NETIF_F_HW_VLAN_CTAG_RX | |
|---|
| 2567 | 1926 | NETIF_F_HW_VLAN_CTAG_FILTER; |
|---|
| 2568 | 1927 | |
|---|
| 2569 | 1928 | netif_keep_dst(card->dev); |
|---|
| 2570 | | - if (card->dev->hw_features & NETIF_F_TSO) |
|---|
| 1929 | + if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6)) |
|---|
| 2571 | 1930 | netif_set_gso_max_size(card->dev, |
|---|
| 2572 | 1931 | PAGE_SIZE * (QETH_MAX_BUFFER_ELEMENTS(card) - 1)); |
|---|
| 2573 | 1932 | |
|---|
| 2574 | 1933 | netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT); |
|---|
| 2575 | | - rc = register_netdev(card->dev); |
|---|
| 2576 | | -out: |
|---|
| 2577 | | - if (rc) |
|---|
| 2578 | | - card->dev->netdev_ops = NULL; |
|---|
| 2579 | | - return rc; |
|---|
| 1934 | + return register_netdev(card->dev); |
|---|
| 2580 | 1935 | } |
|---|
| 2581 | 1936 | |
|---|
| 2582 | 1937 | static const struct device_type qeth_l3_devtype = { |
|---|
| .. | .. |
|---|
| 2590 | 1945 | int rc; |
|---|
| 2591 | 1946 | |
|---|
| 2592 | 1947 | hash_init(card->ip_htable); |
|---|
| 1948 | + mutex_init(&card->ip_lock); |
|---|
| 1949 | + card->cmd_wq = alloc_ordered_workqueue("%s_cmd", 0, |
|---|
| 1950 | + dev_name(&gdev->dev)); |
|---|
| 1951 | + if (!card->cmd_wq) |
|---|
| 1952 | + return -ENOMEM; |
|---|
| 2593 | 1953 | |
|---|
| 2594 | 1954 | if (gdev->dev.type == &qeth_generic_devtype) { |
|---|
| 2595 | 1955 | rc = qeth_l3_create_device_attributes(&gdev->dev); |
|---|
| 2596 | | - if (rc) |
|---|
| 1956 | + if (rc) { |
|---|
| 1957 | + destroy_workqueue(card->cmd_wq); |
|---|
| 2597 | 1958 | return rc; |
|---|
| 1959 | + } |
|---|
| 2598 | 1960 | } |
|---|
| 2599 | 1961 | |
|---|
| 2600 | | - hash_init(card->ip_mc_htable); |
|---|
| 2601 | | - card->options.layer2 = 0; |
|---|
| 2602 | | - card->info.hwtrap = 0; |
|---|
| 1962 | + INIT_WORK(&card->rx_mode_work, qeth_l3_rx_mode_work); |
|---|
| 2603 | 1963 | return 0; |
|---|
| 2604 | 1964 | } |
|---|
| 2605 | 1965 | |
|---|
| .. | .. |
|---|
| 2614 | 1974 | wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); |
|---|
| 2615 | 1975 | |
|---|
| 2616 | 1976 | if (cgdev->state == CCWGROUP_ONLINE) |
|---|
| 2617 | | - qeth_l3_set_offline(cgdev); |
|---|
| 1977 | + qeth_set_offline(card, card->discipline, false); |
|---|
| 2618 | 1978 | |
|---|
| 2619 | 1979 | cancel_work_sync(&card->close_dev_work); |
|---|
| 2620 | | - if (qeth_netdev_is_registered(card->dev)) |
|---|
| 1980 | + if (card->dev->reg_state == NETREG_REGISTERED) |
|---|
| 2621 | 1981 | unregister_netdev(card->dev); |
|---|
| 1982 | + |
|---|
| 1983 | + flush_workqueue(card->cmd_wq); |
|---|
| 1984 | + destroy_workqueue(card->cmd_wq); |
|---|
| 2622 | 1985 | qeth_l3_clear_ip_htable(card, 0); |
|---|
| 2623 | 1986 | qeth_l3_clear_ipato_list(card); |
|---|
| 2624 | 1987 | } |
|---|
| 2625 | 1988 | |
|---|
| 2626 | | -static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode) |
|---|
| 1989 | +static int qeth_l3_set_online(struct qeth_card *card, bool carrier_ok) |
|---|
| 2627 | 1990 | { |
|---|
| 2628 | | - struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
|---|
| 1991 | + struct net_device *dev = card->dev; |
|---|
| 2629 | 1992 | int rc = 0; |
|---|
| 2630 | | - enum qeth_card_states recover_flag; |
|---|
| 2631 | | - |
|---|
| 2632 | | - mutex_lock(&card->discipline_mutex); |
|---|
| 2633 | | - mutex_lock(&card->conf_mutex); |
|---|
| 2634 | | - QETH_DBF_TEXT(SETUP, 2, "setonlin"); |
|---|
| 2635 | | - QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); |
|---|
| 2636 | | - |
|---|
| 2637 | | - recover_flag = card->state; |
|---|
| 2638 | | - rc = qeth_core_hardsetup_card(card); |
|---|
| 2639 | | - if (rc) { |
|---|
| 2640 | | - QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc); |
|---|
| 2641 | | - rc = -ENODEV; |
|---|
| 2642 | | - goto out_remove; |
|---|
| 2643 | | - } |
|---|
| 2644 | | - |
|---|
| 2645 | | - rc = qeth_l3_setup_netdev(card); |
|---|
| 2646 | | - if (rc) |
|---|
| 2647 | | - goto out_remove; |
|---|
| 2648 | | - |
|---|
| 2649 | | - if (qeth_is_diagass_supported(card, QETH_DIAGS_CMD_TRAP)) { |
|---|
| 2650 | | - if (card->info.hwtrap && |
|---|
| 2651 | | - qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM)) |
|---|
| 2652 | | - card->info.hwtrap = 0; |
|---|
| 2653 | | - } else |
|---|
| 2654 | | - card->info.hwtrap = 0; |
|---|
| 2655 | | - |
|---|
| 2656 | | - card->state = CARD_STATE_HARDSETUP; |
|---|
| 2657 | | - qeth_print_status_message(card); |
|---|
| 2658 | 1993 | |
|---|
| 2659 | 1994 | /* softsetup */ |
|---|
| 2660 | | - QETH_DBF_TEXT(SETUP, 2, "softsetp"); |
|---|
| 1995 | + QETH_CARD_TEXT(card, 2, "softsetp"); |
|---|
| 2661 | 1996 | |
|---|
| 2662 | 1997 | rc = qeth_l3_setadapter_parms(card); |
|---|
| 2663 | 1998 | if (rc) |
|---|
| 2664 | | - QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc); |
|---|
| 1999 | + QETH_CARD_TEXT_(card, 2, "2err%04x", rc); |
|---|
| 2665 | 2000 | if (!card->options.sniffer) { |
|---|
| 2666 | | - rc = qeth_l3_start_ipassists(card); |
|---|
| 2667 | | - if (rc) { |
|---|
| 2668 | | - QETH_DBF_TEXT_(SETUP, 2, "3err%d", rc); |
|---|
| 2669 | | - goto out_remove; |
|---|
| 2670 | | - } |
|---|
| 2001 | + qeth_l3_start_ipassists(card); |
|---|
| 2002 | + |
|---|
| 2671 | 2003 | rc = qeth_l3_setrouting_v4(card); |
|---|
| 2672 | 2004 | if (rc) |
|---|
| 2673 | | - QETH_DBF_TEXT_(SETUP, 2, "4err%04x", rc); |
|---|
| 2005 | + QETH_CARD_TEXT_(card, 2, "4err%04x", rc); |
|---|
| 2674 | 2006 | rc = qeth_l3_setrouting_v6(card); |
|---|
| 2675 | 2007 | if (rc) |
|---|
| 2676 | | - QETH_DBF_TEXT_(SETUP, 2, "5err%04x", rc); |
|---|
| 2008 | + QETH_CARD_TEXT_(card, 2, "5err%04x", rc); |
|---|
| 2677 | 2009 | } |
|---|
| 2678 | | - netif_tx_disable(card->dev); |
|---|
| 2679 | 2010 | |
|---|
| 2680 | | - rc = qeth_init_qdio_queues(card); |
|---|
| 2681 | | - if (rc) { |
|---|
| 2682 | | - QETH_DBF_TEXT_(SETUP, 2, "6err%d", rc); |
|---|
| 2683 | | - rc = -ENODEV; |
|---|
| 2684 | | - goto out_remove; |
|---|
| 2685 | | - } |
|---|
| 2686 | 2011 | card->state = CARD_STATE_SOFTSETUP; |
|---|
| 2687 | 2012 | |
|---|
| 2688 | 2013 | qeth_set_allowed_threads(card, 0xffffffff, 0); |
|---|
| 2689 | 2014 | qeth_l3_recover_ip(card); |
|---|
| 2690 | | - if (card->lan_online) |
|---|
| 2691 | | - netif_carrier_on(card->dev); |
|---|
| 2692 | | - else |
|---|
| 2693 | | - netif_carrier_off(card->dev); |
|---|
| 2694 | 2015 | |
|---|
| 2695 | | - qeth_enable_hw_features(card->dev); |
|---|
| 2696 | | - if (recover_flag == CARD_STATE_RECOVER) { |
|---|
| 2016 | + if (dev->reg_state != NETREG_REGISTERED) { |
|---|
| 2017 | + rc = qeth_l3_setup_netdev(card); |
|---|
| 2018 | + if (rc) |
|---|
| 2019 | + goto err_setup; |
|---|
| 2020 | + |
|---|
| 2021 | + if (carrier_ok) |
|---|
| 2022 | + netif_carrier_on(dev); |
|---|
| 2023 | + } else { |
|---|
| 2697 | 2024 | rtnl_lock(); |
|---|
| 2698 | | - if (recovery_mode) { |
|---|
| 2699 | | - __qeth_l3_open(card->dev); |
|---|
| 2700 | | - qeth_l3_set_rx_mode(card->dev); |
|---|
| 2701 | | - } else { |
|---|
| 2702 | | - dev_open(card->dev); |
|---|
| 2703 | | - } |
|---|
| 2704 | | - rtnl_unlock(); |
|---|
| 2705 | | - } |
|---|
| 2706 | | - qeth_trace_features(card); |
|---|
| 2707 | | - /* let user_space know that device is online */ |
|---|
| 2708 | | - kobject_uevent(&gdev->dev.kobj, KOBJ_CHANGE); |
|---|
| 2709 | | - mutex_unlock(&card->conf_mutex); |
|---|
| 2710 | | - mutex_unlock(&card->discipline_mutex); |
|---|
| 2711 | | - return 0; |
|---|
| 2712 | | -out_remove: |
|---|
| 2713 | | - qeth_l3_stop_card(card, 0); |
|---|
| 2714 | | - ccw_device_set_offline(CARD_DDEV(card)); |
|---|
| 2715 | | - ccw_device_set_offline(CARD_WDEV(card)); |
|---|
| 2716 | | - ccw_device_set_offline(CARD_RDEV(card)); |
|---|
| 2717 | | - qdio_free(CARD_DDEV(card)); |
|---|
| 2718 | | - if (recover_flag == CARD_STATE_RECOVER) |
|---|
| 2719 | | - card->state = CARD_STATE_RECOVER; |
|---|
| 2720 | | - else |
|---|
| 2721 | | - card->state = CARD_STATE_DOWN; |
|---|
| 2722 | | - mutex_unlock(&card->conf_mutex); |
|---|
| 2723 | | - mutex_unlock(&card->discipline_mutex); |
|---|
| 2724 | | - return rc; |
|---|
| 2725 | | -} |
|---|
| 2726 | | - |
|---|
| 2727 | | -static int qeth_l3_set_online(struct ccwgroup_device *gdev) |
|---|
| 2728 | | -{ |
|---|
| 2729 | | - return __qeth_l3_set_online(gdev, 0); |
|---|
| 2730 | | -} |
|---|
| 2731 | | - |
|---|
| 2732 | | -static int __qeth_l3_set_offline(struct ccwgroup_device *cgdev, |
|---|
| 2733 | | - int recovery_mode) |
|---|
| 2734 | | -{ |
|---|
| 2735 | | - struct qeth_card *card = dev_get_drvdata(&cgdev->dev); |
|---|
| 2736 | | - int rc = 0, rc2 = 0, rc3 = 0; |
|---|
| 2737 | | - enum qeth_card_states recover_flag; |
|---|
| 2738 | | - |
|---|
| 2739 | | - mutex_lock(&card->discipline_mutex); |
|---|
| 2740 | | - mutex_lock(&card->conf_mutex); |
|---|
| 2741 | | - QETH_DBF_TEXT(SETUP, 3, "setoffl"); |
|---|
| 2742 | | - QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *)); |
|---|
| 2743 | | - |
|---|
| 2744 | | - netif_carrier_off(card->dev); |
|---|
| 2745 | | - recover_flag = card->state; |
|---|
| 2746 | | - if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) { |
|---|
| 2747 | | - qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); |
|---|
| 2748 | | - card->info.hwtrap = 1; |
|---|
| 2749 | | - } |
|---|
| 2750 | | - qeth_l3_stop_card(card, recovery_mode); |
|---|
| 2751 | | - if ((card->options.cq == QETH_CQ_ENABLED) && card->dev) { |
|---|
| 2752 | | - rtnl_lock(); |
|---|
| 2753 | | - call_netdevice_notifiers(NETDEV_REBOOT, card->dev); |
|---|
| 2754 | | - rtnl_unlock(); |
|---|
| 2755 | | - } |
|---|
| 2756 | | - rc = ccw_device_set_offline(CARD_DDEV(card)); |
|---|
| 2757 | | - rc2 = ccw_device_set_offline(CARD_WDEV(card)); |
|---|
| 2758 | | - rc3 = ccw_device_set_offline(CARD_RDEV(card)); |
|---|
| 2759 | | - if (!rc) |
|---|
| 2760 | | - rc = (rc2) ? rc2 : rc3; |
|---|
| 2761 | | - if (rc) |
|---|
| 2762 | | - QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc); |
|---|
| 2763 | | - qdio_free(CARD_DDEV(card)); |
|---|
| 2764 | | - if (recover_flag == CARD_STATE_UP) |
|---|
| 2765 | | - card->state = CARD_STATE_RECOVER; |
|---|
| 2766 | | - /* let user_space know that device is offline */ |
|---|
| 2767 | | - kobject_uevent(&cgdev->dev.kobj, KOBJ_CHANGE); |
|---|
| 2768 | | - mutex_unlock(&card->conf_mutex); |
|---|
| 2769 | | - mutex_unlock(&card->discipline_mutex); |
|---|
| 2770 | | - return 0; |
|---|
| 2771 | | -} |
|---|
| 2772 | | - |
|---|
| 2773 | | -static int qeth_l3_set_offline(struct ccwgroup_device *cgdev) |
|---|
| 2774 | | -{ |
|---|
| 2775 | | - return __qeth_l3_set_offline(cgdev, 0); |
|---|
| 2776 | | -} |
|---|
| 2777 | | - |
|---|
| 2778 | | -static int qeth_l3_recover(void *ptr) |
|---|
| 2779 | | -{ |
|---|
| 2780 | | - struct qeth_card *card; |
|---|
| 2781 | | - int rc = 0; |
|---|
| 2782 | | - |
|---|
| 2783 | | - card = (struct qeth_card *) ptr; |
|---|
| 2784 | | - QETH_CARD_TEXT(card, 2, "recover1"); |
|---|
| 2785 | | - QETH_CARD_HEX(card, 2, &card, sizeof(void *)); |
|---|
| 2786 | | - if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD)) |
|---|
| 2787 | | - return 0; |
|---|
| 2788 | | - QETH_CARD_TEXT(card, 2, "recover2"); |
|---|
| 2789 | | - dev_warn(&card->gdev->dev, |
|---|
| 2790 | | - "A recovery process has been started for the device\n"); |
|---|
| 2791 | | - qeth_set_recovery_task(card); |
|---|
| 2792 | | - __qeth_l3_set_offline(card->gdev, 1); |
|---|
| 2793 | | - rc = __qeth_l3_set_online(card->gdev, 1); |
|---|
| 2794 | | - if (!rc) |
|---|
| 2795 | | - dev_info(&card->gdev->dev, |
|---|
| 2796 | | - "Device successfully recovered!\n"); |
|---|
| 2797 | | - else { |
|---|
| 2798 | | - qeth_close_dev(card); |
|---|
| 2799 | | - dev_warn(&card->gdev->dev, "The qeth device driver " |
|---|
| 2800 | | - "failed to recover an error on the device\n"); |
|---|
| 2801 | | - } |
|---|
| 2802 | | - qeth_clear_recovery_task(card); |
|---|
| 2803 | | - qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); |
|---|
| 2804 | | - qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD); |
|---|
| 2805 | | - return 0; |
|---|
| 2806 | | -} |
|---|
| 2807 | | - |
|---|
| 2808 | | -static int qeth_l3_pm_suspend(struct ccwgroup_device *gdev) |
|---|
| 2809 | | -{ |
|---|
| 2810 | | - struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
|---|
| 2811 | | - |
|---|
| 2812 | | - netif_device_detach(card->dev); |
|---|
| 2813 | | - qeth_set_allowed_threads(card, 0, 1); |
|---|
| 2814 | | - wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); |
|---|
| 2815 | | - if (gdev->state == CCWGROUP_OFFLINE) |
|---|
| 2816 | | - return 0; |
|---|
| 2817 | | - if (card->state == CARD_STATE_UP) { |
|---|
| 2818 | | - if (card->info.hwtrap) |
|---|
| 2819 | | - qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); |
|---|
| 2820 | | - __qeth_l3_set_offline(card->gdev, 1); |
|---|
| 2821 | | - } else |
|---|
| 2822 | | - __qeth_l3_set_offline(card->gdev, 0); |
|---|
| 2823 | | - return 0; |
|---|
| 2824 | | -} |
|---|
| 2825 | | - |
|---|
| 2826 | | -static int qeth_l3_pm_resume(struct ccwgroup_device *gdev) |
|---|
| 2827 | | -{ |
|---|
| 2828 | | - struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
|---|
| 2829 | | - int rc = 0; |
|---|
| 2830 | | - |
|---|
| 2831 | | - if (gdev->state == CCWGROUP_OFFLINE) |
|---|
| 2832 | | - goto out; |
|---|
| 2833 | | - |
|---|
| 2834 | | - if (card->state == CARD_STATE_RECOVER) { |
|---|
| 2835 | | - rc = __qeth_l3_set_online(card->gdev, 1); |
|---|
| 2025 | + rc = qeth_set_real_num_tx_queues(card, |
|---|
| 2026 | + qeth_tx_actual_queues(card)); |
|---|
| 2836 | 2027 | if (rc) { |
|---|
| 2837 | | - rtnl_lock(); |
|---|
| 2838 | | - dev_close(card->dev); |
|---|
| 2839 | 2028 | rtnl_unlock(); |
|---|
| 2029 | + goto err_set_queues; |
|---|
| 2840 | 2030 | } |
|---|
| 2841 | | - } else |
|---|
| 2842 | | - rc = __qeth_l3_set_online(card->gdev, 0); |
|---|
| 2843 | | -out: |
|---|
| 2844 | | - qeth_set_allowed_threads(card, 0xffffffff, 0); |
|---|
| 2845 | | - netif_device_attach(card->dev); |
|---|
| 2846 | | - if (rc) |
|---|
| 2847 | | - dev_warn(&card->gdev->dev, "The qeth device driver " |
|---|
| 2848 | | - "failed to recover an error on the device\n"); |
|---|
| 2031 | + |
|---|
| 2032 | + if (carrier_ok) |
|---|
| 2033 | + netif_carrier_on(dev); |
|---|
| 2034 | + else |
|---|
| 2035 | + netif_carrier_off(dev); |
|---|
| 2036 | + |
|---|
| 2037 | + netif_device_attach(dev); |
|---|
| 2038 | + qeth_enable_hw_features(dev); |
|---|
| 2039 | + |
|---|
| 2040 | + if (card->info.open_when_online) { |
|---|
| 2041 | + card->info.open_when_online = 0; |
|---|
| 2042 | + dev_open(dev, NULL); |
|---|
| 2043 | + } |
|---|
| 2044 | + rtnl_unlock(); |
|---|
| 2045 | + } |
|---|
| 2046 | + return 0; |
|---|
| 2047 | + |
|---|
| 2048 | +err_set_queues: |
|---|
| 2049 | +err_setup: |
|---|
| 2050 | + qeth_set_allowed_threads(card, 0, 1); |
|---|
| 2051 | + card->state = CARD_STATE_DOWN; |
|---|
| 2052 | + qeth_l3_clear_ip_htable(card, 1); |
|---|
| 2849 | 2053 | return rc; |
|---|
| 2054 | +} |
|---|
| 2055 | + |
|---|
| 2056 | +static void qeth_l3_set_offline(struct qeth_card *card) |
|---|
| 2057 | +{ |
|---|
| 2058 | + qeth_set_allowed_threads(card, 0, 1); |
|---|
| 2059 | + qeth_l3_drain_rx_mode_cache(card); |
|---|
| 2060 | + |
|---|
| 2061 | + if (card->options.sniffer && |
|---|
| 2062 | + (card->info.promisc_mode == SET_PROMISC_MODE_ON)) |
|---|
| 2063 | + qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_DISABLE); |
|---|
| 2064 | + |
|---|
| 2065 | + if (card->state == CARD_STATE_SOFTSETUP) { |
|---|
| 2066 | + card->state = CARD_STATE_DOWN; |
|---|
| 2067 | + qeth_l3_clear_ip_htable(card, 1); |
|---|
| 2068 | + } |
|---|
| 2850 | 2069 | } |
|---|
| 2851 | 2070 | |
|---|
| 2852 | 2071 | /* Returns zero if the command is successfully "consumed" */ |
|---|
| .. | .. |
|---|
| 2856 | 2075 | return 1; |
|---|
| 2857 | 2076 | } |
|---|
| 2858 | 2077 | |
|---|
| 2859 | | -struct qeth_discipline qeth_l3_discipline = { |
|---|
| 2078 | +const struct qeth_discipline qeth_l3_discipline = { |
|---|
| 2860 | 2079 | .devtype = &qeth_l3_devtype, |
|---|
| 2861 | | - .process_rx_buffer = qeth_l3_process_inbound_buffer, |
|---|
| 2862 | | - .recover = qeth_l3_recover, |
|---|
| 2863 | 2080 | .setup = qeth_l3_probe_device, |
|---|
| 2864 | 2081 | .remove = qeth_l3_remove_device, |
|---|
| 2865 | 2082 | .set_online = qeth_l3_set_online, |
|---|
| 2866 | 2083 | .set_offline = qeth_l3_set_offline, |
|---|
| 2867 | | - .freeze = qeth_l3_pm_suspend, |
|---|
| 2868 | | - .thaw = qeth_l3_pm_resume, |
|---|
| 2869 | | - .restore = qeth_l3_pm_resume, |
|---|
| 2870 | 2084 | .do_ioctl = qeth_l3_do_ioctl, |
|---|
| 2871 | 2085 | .control_event_handler = qeth_l3_control_event, |
|---|
| 2872 | 2086 | }; |
|---|
| .. | .. |
|---|
| 2878 | 2092 | { |
|---|
| 2879 | 2093 | switch (event) { |
|---|
| 2880 | 2094 | case NETDEV_UP: |
|---|
| 2881 | | - spin_lock_bh(&card->ip_lock); |
|---|
| 2882 | | - qeth_l3_add_ip(card, addr); |
|---|
| 2883 | | - spin_unlock_bh(&card->ip_lock); |
|---|
| 2095 | + qeth_l3_modify_ip(card, addr, true); |
|---|
| 2884 | 2096 | return NOTIFY_OK; |
|---|
| 2885 | 2097 | case NETDEV_DOWN: |
|---|
| 2886 | | - spin_lock_bh(&card->ip_lock); |
|---|
| 2887 | | - qeth_l3_delete_ip(card, addr); |
|---|
| 2888 | | - spin_unlock_bh(&card->ip_lock); |
|---|
| 2098 | + qeth_l3_modify_ip(card, addr, false); |
|---|
| 2889 | 2099 | return NOTIFY_OK; |
|---|
| 2890 | 2100 | default: |
|---|
| 2891 | 2101 | return NOTIFY_DONE; |
|---|
| 2892 | 2102 | } |
|---|
| 2103 | +} |
|---|
| 2104 | + |
|---|
| 2105 | +struct qeth_l3_ip_event_work { |
|---|
| 2106 | + struct work_struct work; |
|---|
| 2107 | + struct qeth_card *card; |
|---|
| 2108 | + struct qeth_ipaddr addr; |
|---|
| 2109 | +}; |
|---|
| 2110 | + |
|---|
| 2111 | +#define to_ip_work(w) container_of((w), struct qeth_l3_ip_event_work, work) |
|---|
| 2112 | + |
|---|
| 2113 | +static void qeth_l3_add_ip_worker(struct work_struct *work) |
|---|
| 2114 | +{ |
|---|
| 2115 | + struct qeth_l3_ip_event_work *ip_work = to_ip_work(work); |
|---|
| 2116 | + |
|---|
| 2117 | + qeth_l3_modify_ip(ip_work->card, &ip_work->addr, true); |
|---|
| 2118 | + kfree(work); |
|---|
| 2119 | +} |
|---|
| 2120 | + |
|---|
| 2121 | +static void qeth_l3_delete_ip_worker(struct work_struct *work) |
|---|
| 2122 | +{ |
|---|
| 2123 | + struct qeth_l3_ip_event_work *ip_work = to_ip_work(work); |
|---|
| 2124 | + |
|---|
| 2125 | + qeth_l3_modify_ip(ip_work->card, &ip_work->addr, false); |
|---|
| 2126 | + kfree(work); |
|---|
| 2893 | 2127 | } |
|---|
| 2894 | 2128 | |
|---|
| 2895 | 2129 | static struct qeth_card *qeth_l3_get_card_from_dev(struct net_device *dev) |
|---|
| .. | .. |
|---|
| 2905 | 2139 | static int qeth_l3_ip_event(struct notifier_block *this, |
|---|
| 2906 | 2140 | unsigned long event, void *ptr) |
|---|
| 2907 | 2141 | { |
|---|
| 2908 | | - |
|---|
| 2909 | 2142 | struct in_ifaddr *ifa = (struct in_ifaddr *)ptr; |
|---|
| 2910 | 2143 | struct net_device *dev = ifa->ifa_dev->dev; |
|---|
| 2911 | 2144 | struct qeth_ipaddr addr; |
|---|
| 2912 | 2145 | struct qeth_card *card; |
|---|
| 2913 | | - |
|---|
| 2914 | | - if (dev_net(dev) != &init_net) |
|---|
| 2915 | | - return NOTIFY_DONE; |
|---|
| 2916 | 2146 | |
|---|
| 2917 | 2147 | card = qeth_l3_get_card_from_dev(dev); |
|---|
| 2918 | 2148 | if (!card) |
|---|
| .. | .. |
|---|
| 2920 | 2150 | QETH_CARD_TEXT(card, 3, "ipevent"); |
|---|
| 2921 | 2151 | |
|---|
| 2922 | 2152 | qeth_l3_init_ipaddr(&addr, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV4); |
|---|
| 2923 | | - addr.u.a4.addr = be32_to_cpu(ifa->ifa_address); |
|---|
| 2924 | | - addr.u.a4.mask = be32_to_cpu(ifa->ifa_mask); |
|---|
| 2153 | + addr.u.a4.addr = ifa->ifa_address; |
|---|
| 2154 | + addr.u.a4.mask = ifa->ifa_mask; |
|---|
| 2925 | 2155 | |
|---|
| 2926 | 2156 | return qeth_l3_handle_ip_event(card, &addr, event); |
|---|
| 2927 | 2157 | } |
|---|
| .. | .. |
|---|
| 2936 | 2166 | { |
|---|
| 2937 | 2167 | struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr; |
|---|
| 2938 | 2168 | struct net_device *dev = ifa->idev->dev; |
|---|
| 2939 | | - struct qeth_ipaddr addr; |
|---|
| 2169 | + struct qeth_l3_ip_event_work *ip_work; |
|---|
| 2940 | 2170 | struct qeth_card *card; |
|---|
| 2171 | + |
|---|
| 2172 | + if (event != NETDEV_UP && event != NETDEV_DOWN) |
|---|
| 2173 | + return NOTIFY_DONE; |
|---|
| 2941 | 2174 | |
|---|
| 2942 | 2175 | card = qeth_l3_get_card_from_dev(dev); |
|---|
| 2943 | 2176 | if (!card) |
|---|
| .. | .. |
|---|
| 2946 | 2179 | if (!qeth_is_supported(card, IPA_IPV6)) |
|---|
| 2947 | 2180 | return NOTIFY_DONE; |
|---|
| 2948 | 2181 | |
|---|
| 2949 | | - qeth_l3_init_ipaddr(&addr, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV6); |
|---|
| 2950 | | - addr.u.a6.addr = ifa->addr; |
|---|
| 2951 | | - addr.u.a6.pfxlen = ifa->prefix_len; |
|---|
| 2182 | + ip_work = kmalloc(sizeof(*ip_work), GFP_ATOMIC); |
|---|
| 2183 | + if (!ip_work) |
|---|
| 2184 | + return NOTIFY_DONE; |
|---|
| 2952 | 2185 | |
|---|
| 2953 | | - return qeth_l3_handle_ip_event(card, &addr, event); |
|---|
| 2186 | + if (event == NETDEV_UP) |
|---|
| 2187 | + INIT_WORK(&ip_work->work, qeth_l3_add_ip_worker); |
|---|
| 2188 | + else |
|---|
| 2189 | + INIT_WORK(&ip_work->work, qeth_l3_delete_ip_worker); |
|---|
| 2190 | + |
|---|
| 2191 | + ip_work->card = card; |
|---|
| 2192 | + qeth_l3_init_ipaddr(&ip_work->addr, QETH_IP_TYPE_NORMAL, |
|---|
| 2193 | + QETH_PROT_IPV6); |
|---|
| 2194 | + ip_work->addr.u.a6.addr = ifa->addr; |
|---|
| 2195 | + ip_work->addr.u.a6.pfxlen = ifa->prefix_len; |
|---|
| 2196 | + |
|---|
| 2197 | + queue_work(card->cmd_wq, &ip_work->work); |
|---|
| 2198 | + return NOTIFY_OK; |
|---|
| 2954 | 2199 | } |
|---|
| 2955 | 2200 | |
|---|
| 2956 | 2201 | static struct notifier_block qeth_l3_ip6_notifier = { |
|---|