1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright IBM Corp. 2007, 2009 4 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>, 5 * Frank Pavlic <fpavlic@de.ibm.com>, 6 * Thomas Spatzier <tspat@de.ibm.com>, 7 * Frank Blaschka <frank.blaschka@de.ibm.com> 8 */ 9 10 #define KMSG_COMPONENT "qeth" 11 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 12 13 #include <linux/module.h> 14 #include <linux/moduleparam.h> 15 #include <linux/string.h> 16 #include <linux/errno.h> 17 #include <linux/kernel.h> 18 #include <linux/slab.h> 19 #include <linux/etherdevice.h> 20 #include <linux/list.h> 21 #include <linux/hash.h> 22 #include <linux/hashtable.h> 23 #include <asm/setup.h> 24 #include "qeth_core.h" 25 #include "qeth_l2.h" 26 27 static int qeth_l2_set_offline(struct ccwgroup_device *); 28 static int qeth_l2_stop(struct net_device *); 29 static void qeth_bridgeport_query_support(struct qeth_card *card); 30 static void qeth_bridge_state_change(struct qeth_card *card, 31 struct qeth_ipa_cmd *cmd); 32 static void qeth_bridge_host_event(struct qeth_card *card, 33 struct qeth_ipa_cmd *cmd); 34 static void qeth_l2_vnicc_set_defaults(struct qeth_card *card); 35 static void qeth_l2_vnicc_init(struct qeth_card *card); 36 static bool qeth_l2_vnicc_recover_timeout(struct qeth_card *card, u32 vnicc, 37 u32 *timeout); 38 39 static int qeth_setdelmac_makerc(struct qeth_card *card, int retcode) 40 { 41 int rc; 42 43 if (retcode) 44 QETH_CARD_TEXT_(card, 2, "err%04x", retcode); 45 switch (retcode) { 46 case IPA_RC_SUCCESS: 47 rc = 0; 48 break; 49 case IPA_RC_L2_UNSUPPORTED_CMD: 50 rc = -EOPNOTSUPP; 51 break; 52 case IPA_RC_L2_ADDR_TABLE_FULL: 53 rc = -ENOSPC; 54 break; 55 case IPA_RC_L2_DUP_MAC: 56 case IPA_RC_L2_DUP_LAYER3_MAC: 57 rc = -EEXIST; 58 break; 59 case IPA_RC_L2_MAC_NOT_AUTH_BY_HYP: 60 case IPA_RC_L2_MAC_NOT_AUTH_BY_ADP: 61 rc = -EPERM; 62 break; 63 case IPA_RC_L2_MAC_NOT_FOUND: 64 rc = -ENOENT; 65 break; 66 case -ENOMEM: 67 rc = -ENOMEM; 68 break; 69 default: 70 rc = -EIO; 71 break; 72 } 73 return rc; 74 } 75 76 static int qeth_l2_send_setdelmac(struct qeth_card *card, __u8 *mac, 77 enum qeth_ipa_cmds ipacmd) 78 { 79 struct qeth_ipa_cmd *cmd; 80 struct qeth_cmd_buffer *iob; 81 82 QETH_CARD_TEXT(card, 2, "L2sdmac"); 83 iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4); 84 if (!iob) 85 return -ENOMEM; 86 cmd = __ipa_cmd(iob); 87 cmd->data.setdelmac.mac_length = ETH_ALEN; 88 ether_addr_copy(cmd->data.setdelmac.mac, mac); 89 return qeth_setdelmac_makerc(card, qeth_send_ipa_cmd(card, iob, 90 NULL, NULL)); 91 } 92 93 static int qeth_l2_send_setmac(struct qeth_card *card, __u8 *mac) 94 { 95 int rc; 96 97 QETH_CARD_TEXT(card, 2, "L2Setmac"); 98 rc = qeth_l2_send_setdelmac(card, mac, IPA_CMD_SETVMAC); 99 if (rc == 0) { 100 dev_info(&card->gdev->dev, 101 "MAC address %pM successfully registered on device %s\n", 102 mac, card->dev->name); 103 } else { 104 switch (rc) { 105 case -EEXIST: 106 dev_warn(&card->gdev->dev, 107 "MAC address %pM already exists\n", mac); 108 break; 109 case -EPERM: 110 dev_warn(&card->gdev->dev, 111 "MAC address %pM is not authorized\n", mac); 112 break; 113 } 114 } 115 return rc; 116 } 117 118 static int qeth_l2_write_mac(struct qeth_card *card, u8 *mac) 119 { 120 enum qeth_ipa_cmds cmd = is_multicast_ether_addr(mac) ? 121 IPA_CMD_SETGMAC : IPA_CMD_SETVMAC; 122 int rc; 123 124 QETH_CARD_TEXT(card, 2, "L2Wmac"); 125 rc = qeth_l2_send_setdelmac(card, mac, cmd); 126 if (rc == -EEXIST) 127 QETH_DBF_MESSAGE(2, "MAC already registered on device %x\n", 128 CARD_DEVID(card)); 129 else if (rc) 130 QETH_DBF_MESSAGE(2, "Failed to register MAC on device %x: %d\n", 131 CARD_DEVID(card), rc); 132 return rc; 133 } 134 135 static int qeth_l2_remove_mac(struct qeth_card *card, u8 *mac) 136 { 137 enum qeth_ipa_cmds cmd = is_multicast_ether_addr(mac) ? 138 IPA_CMD_DELGMAC : IPA_CMD_DELVMAC; 139 int rc; 140 141 QETH_CARD_TEXT(card, 2, "L2Rmac"); 142 rc = qeth_l2_send_setdelmac(card, mac, cmd); 143 if (rc) 144 QETH_DBF_MESSAGE(2, "Failed to delete MAC on device %u: %d\n", 145 CARD_DEVID(card), rc); 146 return rc; 147 } 148 149 static void qeth_l2_del_all_macs(struct qeth_card *card) 150 { 151 struct qeth_mac *mac; 152 struct hlist_node *tmp; 153 int i; 154 155 spin_lock_bh(&card->mclock); 156 hash_for_each_safe(card->mac_htable, i, tmp, mac, hnode) { 157 hash_del(&mac->hnode); 158 kfree(mac); 159 } 160 spin_unlock_bh(&card->mclock); 161 } 162 163 static int qeth_l2_get_cast_type(struct qeth_card *card, struct sk_buff *skb) 164 { 165 if (card->info.type == QETH_CARD_TYPE_OSN) 166 return RTN_UNICAST; 167 if (is_broadcast_ether_addr(skb->data)) 168 return RTN_BROADCAST; 169 if (is_multicast_ether_addr(skb->data)) 170 return RTN_MULTICAST; 171 return RTN_UNICAST; 172 } 173 174 static void qeth_l2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, 175 struct sk_buff *skb, int ipv, int cast_type, 176 unsigned int data_len) 177 { 178 struct vlan_ethhdr *veth = vlan_eth_hdr(skb); 179 180 hdr->hdr.l2.pkt_length = data_len; 181 182 if (skb_is_gso(skb)) { 183 hdr->hdr.l2.id = QETH_HEADER_TYPE_L2_TSO; 184 } else { 185 hdr->hdr.l2.id = QETH_HEADER_TYPE_LAYER2; 186 if (skb->ip_summed == CHECKSUM_PARTIAL) { 187 qeth_tx_csum(skb, &hdr->hdr.l2.flags[1], ipv); 188 if (card->options.performance_stats) 189 card->perf_stats.tx_csum++; 190 } 191 } 192 193 /* set byte byte 3 to casting flags */ 194 if (cast_type == RTN_MULTICAST) 195 hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_MULTICAST; 196 else if (cast_type == RTN_BROADCAST) 197 hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_BROADCAST; 198 else 199 hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_UNICAST; 200 201 /* VSWITCH relies on the VLAN 202 * information to be present in 203 * the QDIO header */ 204 if (veth->h_vlan_proto == __constant_htons(ETH_P_8021Q)) { 205 hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_VLAN; 206 hdr->hdr.l2.vlan_id = ntohs(veth->h_vlan_TCI); 207 } 208 } 209 210 static int qeth_setdelvlan_makerc(struct qeth_card *card, int retcode) 211 { 212 if (retcode) 213 QETH_CARD_TEXT_(card, 2, "err%04x", retcode); 214 215 switch (retcode) { 216 case IPA_RC_SUCCESS: 217 return 0; 218 case IPA_RC_L2_INVALID_VLAN_ID: 219 return -EINVAL; 220 case IPA_RC_L2_DUP_VLAN_ID: 221 return -EEXIST; 222 case IPA_RC_L2_VLAN_ID_NOT_FOUND: 223 return -ENOENT; 224 case IPA_RC_L2_VLAN_ID_NOT_ALLOWED: 225 return -EPERM; 226 case -ENOMEM: 227 return -ENOMEM; 228 default: 229 return -EIO; 230 } 231 } 232 233 static int qeth_l2_send_setdelvlan_cb(struct qeth_card *card, 234 struct qeth_reply *reply, 235 unsigned long data) 236 { 237 struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; 238 239 QETH_CARD_TEXT(card, 2, "L2sdvcb"); 240 if (cmd->hdr.return_code) { 241 QETH_DBF_MESSAGE(2, "Error in processing VLAN %u on device %x: %#x.\n", 242 cmd->data.setdelvlan.vlan_id, 243 CARD_DEVID(card), cmd->hdr.return_code); 244 QETH_CARD_TEXT_(card, 2, "L2VL%4x", cmd->hdr.command); 245 QETH_CARD_TEXT_(card, 2, "err%d", cmd->hdr.return_code); 246 } 247 return 0; 248 } 249 250 static int qeth_l2_send_setdelvlan(struct qeth_card *card, __u16 i, 251 enum qeth_ipa_cmds ipacmd) 252 { 253 struct qeth_ipa_cmd *cmd; 254 struct qeth_cmd_buffer *iob; 255 256 QETH_CARD_TEXT_(card, 4, "L2sdv%x", ipacmd); 257 iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4); 258 if (!iob) 259 return -ENOMEM; 260 cmd = __ipa_cmd(iob); 261 cmd->data.setdelvlan.vlan_id = i; 262 return qeth_setdelvlan_makerc(card, qeth_send_ipa_cmd(card, iob, 263 qeth_l2_send_setdelvlan_cb, NULL)); 264 } 265 266 static void qeth_l2_process_vlans(struct qeth_card *card) 267 { 268 struct qeth_vlan_vid *id; 269 270 QETH_CARD_TEXT(card, 3, "L2prcvln"); 271 mutex_lock(&card->vid_list_mutex); 272 list_for_each_entry(id, &card->vid_list, list) { 273 qeth_l2_send_setdelvlan(card, id->vid, IPA_CMD_SETVLAN); 274 } 275 mutex_unlock(&card->vid_list_mutex); 276 } 277 278 static int qeth_l2_vlan_rx_add_vid(struct net_device *dev, 279 __be16 proto, u16 vid) 280 { 281 struct qeth_card *card = dev->ml_priv; 282 struct qeth_vlan_vid *id; 283 int rc; 284 285 QETH_CARD_TEXT_(card, 4, "aid:%d", vid); 286 if (!vid) 287 return 0; 288 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { 289 QETH_CARD_TEXT(card, 3, "aidREC"); 290 return 0; 291 } 292 id = kmalloc(sizeof(*id), GFP_KERNEL); 293 if (id) { 294 id->vid = vid; 295 rc = qeth_l2_send_setdelvlan(card, vid, IPA_CMD_SETVLAN); 296 if (rc) { 297 kfree(id); 298 return rc; 299 } 300 mutex_lock(&card->vid_list_mutex); 301 list_add_tail(&id->list, &card->vid_list); 302 mutex_unlock(&card->vid_list_mutex); 303 } else { 304 return -ENOMEM; 305 } 306 return 0; 307 } 308 309 static int qeth_l2_vlan_rx_kill_vid(struct net_device *dev, 310 __be16 proto, u16 vid) 311 { 312 struct qeth_vlan_vid *id, *tmpid = NULL; 313 struct qeth_card *card = dev->ml_priv; 314 int rc = 0; 315 316 QETH_CARD_TEXT_(card, 4, "kid:%d", vid); 317 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { 318 QETH_CARD_TEXT(card, 3, "kidREC"); 319 return 0; 320 } 321 mutex_lock(&card->vid_list_mutex); 322 list_for_each_entry(id, &card->vid_list, list) { 323 if (id->vid == vid) { 324 list_del(&id->list); 325 tmpid = id; 326 break; 327 } 328 } 329 mutex_unlock(&card->vid_list_mutex); 330 if (tmpid) { 331 rc = qeth_l2_send_setdelvlan(card, vid, IPA_CMD_DELVLAN); 332 kfree(tmpid); 333 } 334 return rc; 335 } 336 337 static void qeth_l2_stop_card(struct qeth_card *card, int recovery_mode) 338 { 339 QETH_DBF_TEXT(SETUP , 2, "stopcard"); 340 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); 341 342 qeth_set_allowed_threads(card, 0, 1); 343 if (card->read.state == CH_STATE_UP && 344 card->write.state == CH_STATE_UP && 345 (card->state == CARD_STATE_UP)) { 346 if (recovery_mode && 347 card->info.type != QETH_CARD_TYPE_OSN) { 348 qeth_l2_stop(card->dev); 349 } else { 350 rtnl_lock(); 351 dev_close(card->dev); 352 rtnl_unlock(); 353 } 354 card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED; 355 card->state = CARD_STATE_SOFTSETUP; 356 } 357 if (card->state == CARD_STATE_SOFTSETUP) { 358 qeth_l2_del_all_macs(card); 359 qeth_clear_ipacmd_list(card); 360 card->state = CARD_STATE_HARDSETUP; 361 } 362 if (card->state == CARD_STATE_HARDSETUP) { 363 qeth_qdio_clear_card(card, 0); 364 qeth_clear_qdio_buffers(card); 365 qeth_clear_working_pool_list(card); 366 card->state = CARD_STATE_DOWN; 367 } 368 if (card->state == CARD_STATE_DOWN) { 369 qeth_clear_cmd_buffers(&card->read); 370 qeth_clear_cmd_buffers(&card->write); 371 } 372 } 373 374 static int qeth_l2_process_inbound_buffer(struct qeth_card *card, 375 int budget, int *done) 376 { 377 int work_done = 0; 378 struct sk_buff *skb; 379 struct qeth_hdr *hdr; 380 unsigned int len; 381 382 *done = 0; 383 WARN_ON_ONCE(!budget); 384 while (budget) { 385 skb = qeth_core_get_next_skb(card, 386 &card->qdio.in_q->bufs[card->rx.b_index], 387 &card->rx.b_element, &card->rx.e_offset, &hdr); 388 if (!skb) { 389 *done = 1; 390 break; 391 } 392 switch (hdr->hdr.l2.id) { 393 case QETH_HEADER_TYPE_LAYER2: 394 skb->protocol = eth_type_trans(skb, skb->dev); 395 qeth_rx_csum(card, skb, hdr->hdr.l2.flags[1]); 396 if (skb->protocol == htons(ETH_P_802_2)) 397 *((__u32 *)skb->cb) = ++card->seqno.pkt_seqno; 398 len = skb->len; 399 napi_gro_receive(&card->napi, skb); 400 break; 401 case QETH_HEADER_TYPE_OSN: 402 if (card->info.type == QETH_CARD_TYPE_OSN) { 403 skb_push(skb, sizeof(struct qeth_hdr)); 404 skb_copy_to_linear_data(skb, hdr, 405 sizeof(struct qeth_hdr)); 406 len = skb->len; 407 card->osn_info.data_cb(skb); 408 break; 409 } 410 /* else unknown */ 411 default: 412 dev_kfree_skb_any(skb); 413 QETH_CARD_TEXT(card, 3, "inbunkno"); 414 QETH_DBF_HEX(CTRL, 3, hdr, sizeof(*hdr)); 415 continue; 416 } 417 work_done++; 418 budget--; 419 card->stats.rx_packets++; 420 card->stats.rx_bytes += len; 421 } 422 return work_done; 423 } 424 425 static int qeth_l2_request_initial_mac(struct qeth_card *card) 426 { 427 int rc = 0; 428 429 QETH_DBF_TEXT(SETUP, 2, "l2reqmac"); 430 QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card)); 431 432 if (MACHINE_IS_VM) { 433 rc = qeth_vm_request_mac(card); 434 if (!rc) 435 goto out; 436 QETH_DBF_MESSAGE(2, "z/VM MAC Service failed on device %x: %#x\n", 437 CARD_DEVID(card), rc); 438 QETH_DBF_TEXT_(SETUP, 2, "err%04x", rc); 439 /* fall back to alternative mechanism: */ 440 } 441 442 if (!IS_OSN(card)) { 443 rc = qeth_setadpparms_change_macaddr(card); 444 if (!rc && is_valid_ether_addr(card->dev->dev_addr)) 445 goto out; 446 QETH_DBF_MESSAGE(2, "READ_MAC Assist failed on device %x: %#x\n", 447 CARD_DEVID(card), rc); 448 QETH_DBF_TEXT_(SETUP, 2, "1err%04x", rc); 449 /* fall back once more: */ 450 } 451 452 /* some devices don't support a custom MAC address: */ 453 if (card->info.type == QETH_CARD_TYPE_OSM || 454 card->info.type == QETH_CARD_TYPE_OSX) 455 return (rc) ? rc : -EADDRNOTAVAIL; 456 eth_hw_addr_random(card->dev); 457 458 out: 459 QETH_DBF_HEX(SETUP, 2, card->dev->dev_addr, card->dev->addr_len); 460 return 0; 461 } 462 463 static int qeth_l2_set_mac_address(struct net_device *dev, void *p) 464 { 465 struct sockaddr *addr = p; 466 struct qeth_card *card = dev->ml_priv; 467 u8 old_addr[ETH_ALEN]; 468 int rc = 0; 469 470 QETH_CARD_TEXT(card, 3, "setmac"); 471 472 if (card->info.type == QETH_CARD_TYPE_OSN || 473 card->info.type == QETH_CARD_TYPE_OSM || 474 card->info.type == QETH_CARD_TYPE_OSX) { 475 QETH_CARD_TEXT(card, 3, "setmcTYP"); 476 return -EOPNOTSUPP; 477 } 478 QETH_CARD_HEX(card, 3, addr->sa_data, ETH_ALEN); 479 if (!is_valid_ether_addr(addr->sa_data)) 480 return -EADDRNOTAVAIL; 481 482 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { 483 QETH_CARD_TEXT(card, 3, "setmcREC"); 484 return -ERESTARTSYS; 485 } 486 487 /* avoid racing against concurrent state change: */ 488 if (!mutex_trylock(&card->conf_mutex)) 489 return -EAGAIN; 490 491 if (!qeth_card_hw_is_reachable(card)) { 492 ether_addr_copy(dev->dev_addr, addr->sa_data); 493 goto out_unlock; 494 } 495 496 /* don't register the same address twice */ 497 if (ether_addr_equal_64bits(dev->dev_addr, addr->sa_data) && 498 (card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED)) 499 goto out_unlock; 500 501 /* add the new address, switch over, drop the old */ 502 rc = qeth_l2_send_setmac(card, addr->sa_data); 503 if (rc) 504 goto out_unlock; 505 ether_addr_copy(old_addr, dev->dev_addr); 506 ether_addr_copy(dev->dev_addr, addr->sa_data); 507 508 if (card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED) 509 qeth_l2_remove_mac(card, old_addr); 510 card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED; 511 512 out_unlock: 513 mutex_unlock(&card->conf_mutex); 514 return rc; 515 } 516 517 static void qeth_promisc_to_bridge(struct qeth_card *card) 518 { 519 struct net_device *dev = card->dev; 520 enum qeth_ipa_promisc_modes promisc_mode; 521 int role; 522 int rc; 523 524 QETH_CARD_TEXT(card, 3, "pmisc2br"); 525 526 if (!card->options.sbp.reflect_promisc) 527 return; 528 promisc_mode = (dev->flags & IFF_PROMISC) ? SET_PROMISC_MODE_ON 529 : SET_PROMISC_MODE_OFF; 530 if (promisc_mode == card->info.promisc_mode) 531 return; 532 533 if (promisc_mode == SET_PROMISC_MODE_ON) { 534 if (card->options.sbp.reflect_promisc_primary) 535 role = QETH_SBP_ROLE_PRIMARY; 536 else 537 role = QETH_SBP_ROLE_SECONDARY; 538 } else 539 role = QETH_SBP_ROLE_NONE; 540 541 rc = qeth_bridgeport_setrole(card, role); 542 QETH_DBF_TEXT_(SETUP, 2, "bpm%c%04x", 543 (promisc_mode == SET_PROMISC_MODE_ON) ? '+' : '-', rc); 544 if (!rc) { 545 card->options.sbp.role = role; 546 card->info.promisc_mode = promisc_mode; 547 } 548 549 } 550 /* New MAC address is added to the hash table and marked to be written on card 551 * only if there is not in the hash table storage already 552 * 553 */ 554 static void qeth_l2_add_mac(struct qeth_card *card, struct netdev_hw_addr *ha) 555 { 556 u32 mac_hash = get_unaligned((u32 *)(&ha->addr[2])); 557 struct qeth_mac *mac; 558 559 hash_for_each_possible(card->mac_htable, mac, hnode, mac_hash) { 560 if (ether_addr_equal_64bits(ha->addr, mac->mac_addr)) { 561 mac->disp_flag = QETH_DISP_ADDR_DO_NOTHING; 562 return; 563 } 564 } 565 566 mac = kzalloc(sizeof(struct qeth_mac), GFP_ATOMIC); 567 if (!mac) 568 return; 569 570 ether_addr_copy(mac->mac_addr, ha->addr); 571 mac->disp_flag = QETH_DISP_ADDR_ADD; 572 573 hash_add(card->mac_htable, &mac->hnode, mac_hash); 574 } 575 576 static void qeth_l2_set_rx_mode(struct net_device *dev) 577 { 578 struct qeth_card *card = dev->ml_priv; 579 struct netdev_hw_addr *ha; 580 struct qeth_mac *mac; 581 struct hlist_node *tmp; 582 int i; 583 int rc; 584 585 if (card->info.type == QETH_CARD_TYPE_OSN) 586 return; 587 588 QETH_CARD_TEXT(card, 3, "setmulti"); 589 if (qeth_threads_running(card, QETH_RECOVER_THREAD) && 590 (card->state != CARD_STATE_UP)) 591 return; 592 593 spin_lock_bh(&card->mclock); 594 595 netdev_for_each_mc_addr(ha, dev) 596 qeth_l2_add_mac(card, ha); 597 netdev_for_each_uc_addr(ha, dev) 598 qeth_l2_add_mac(card, ha); 599 600 hash_for_each_safe(card->mac_htable, i, tmp, mac, hnode) { 601 switch (mac->disp_flag) { 602 case QETH_DISP_ADDR_DELETE: 603 qeth_l2_remove_mac(card, mac->mac_addr); 604 hash_del(&mac->hnode); 605 kfree(mac); 606 break; 607 case QETH_DISP_ADDR_ADD: 608 rc = qeth_l2_write_mac(card, mac->mac_addr); 609 if (rc) { 610 hash_del(&mac->hnode); 611 kfree(mac); 612 break; 613 } 614 /* fall through */ 615 default: 616 /* for next call to set_rx_mode(): */ 617 mac->disp_flag = QETH_DISP_ADDR_DELETE; 618 } 619 } 620 621 spin_unlock_bh(&card->mclock); 622 623 if (qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) 624 qeth_setadp_promisc_mode(card); 625 else 626 qeth_promisc_to_bridge(card); 627 } 628 629 static int qeth_l2_xmit_osn(struct qeth_card *card, struct sk_buff *skb, 630 struct qeth_qdio_out_q *queue) 631 { 632 struct qeth_hdr *hdr = (struct qeth_hdr *)skb->data; 633 addr_t end = (addr_t)(skb->data + sizeof(*hdr)); 634 addr_t start = (addr_t)skb->data; 635 unsigned int elements = 0; 636 unsigned int hd_len = 0; 637 int rc; 638 639 if (skb->protocol == htons(ETH_P_IPV6)) 640 return -EPROTONOSUPPORT; 641 642 if (qeth_get_elements_for_range(start, end) > 1) { 643 /* Misaligned HW header, move it to its own buffer element. */ 644 hdr = kmem_cache_alloc(qeth_core_header_cache, GFP_ATOMIC); 645 if (!hdr) 646 return -ENOMEM; 647 hd_len = sizeof(*hdr); 648 skb_copy_from_linear_data(skb, (char *)hdr, hd_len); 649 elements++; 650 } 651 652 elements += qeth_count_elements(skb, hd_len); 653 if (elements > QETH_MAX_BUFFER_ELEMENTS(card)) { 654 rc = -E2BIG; 655 goto out; 656 } 657 658 rc = qeth_do_send_packet(card, queue, skb, hdr, hd_len, hd_len, 659 elements); 660 out: 661 if (rc && hd_len) 662 kmem_cache_free(qeth_core_header_cache, hdr); 663 return rc; 664 } 665 666 static netdev_tx_t qeth_l2_hard_start_xmit(struct sk_buff *skb, 667 struct net_device *dev) 668 { 669 struct qeth_card *card = dev->ml_priv; 670 int cast_type = qeth_l2_get_cast_type(card, skb); 671 int ipv = qeth_get_ip_version(skb); 672 struct qeth_qdio_out_q *queue; 673 int tx_bytes = skb->len; 674 int rc; 675 676 if (card->state != CARD_STATE_UP) { 677 card->stats.tx_carrier_errors++; 678 goto tx_drop; 679 } 680 681 queue = qeth_get_tx_queue(card, skb, ipv, cast_type); 682 683 if (card->options.performance_stats) { 684 card->perf_stats.outbound_cnt++; 685 card->perf_stats.outbound_start_time = qeth_get_micros(); 686 } 687 netif_stop_queue(dev); 688 689 if (IS_OSN(card)) 690 rc = qeth_l2_xmit_osn(card, skb, queue); 691 else 692 rc = qeth_xmit(card, skb, queue, ipv, cast_type, 693 qeth_l2_fill_header); 694 695 if (!rc) { 696 card->stats.tx_packets++; 697 card->stats.tx_bytes += tx_bytes; 698 if (card->options.performance_stats) 699 card->perf_stats.outbound_time += qeth_get_micros() - 700 card->perf_stats.outbound_start_time; 701 netif_wake_queue(dev); 702 return NETDEV_TX_OK; 703 } else if (rc == -EBUSY) { 704 return NETDEV_TX_BUSY; 705 } /* else fall through */ 706 707 tx_drop: 708 card->stats.tx_dropped++; 709 card->stats.tx_errors++; 710 dev_kfree_skb_any(skb); 711 netif_wake_queue(dev); 712 return NETDEV_TX_OK; 713 } 714 715 static int __qeth_l2_open(struct net_device *dev) 716 { 717 struct qeth_card *card = dev->ml_priv; 718 int rc = 0; 719 720 QETH_CARD_TEXT(card, 4, "qethopen"); 721 if (card->state == CARD_STATE_UP) 722 return rc; 723 if (card->state != CARD_STATE_SOFTSETUP) 724 return -ENODEV; 725 726 if ((card->info.type != QETH_CARD_TYPE_OSN) && 727 (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))) { 728 QETH_CARD_TEXT(card, 4, "nomacadr"); 729 return -EPERM; 730 } 731 card->data.state = CH_STATE_UP; 732 card->state = CARD_STATE_UP; 733 netif_start_queue(dev); 734 735 if (qdio_stop_irq(card->data.ccwdev, 0) >= 0) { 736 napi_enable(&card->napi); 737 local_bh_disable(); 738 napi_schedule(&card->napi); 739 /* kick-start the NAPI softirq: */ 740 local_bh_enable(); 741 } else 742 rc = -EIO; 743 return rc; 744 } 745 746 static int qeth_l2_open(struct net_device *dev) 747 { 748 struct qeth_card *card = dev->ml_priv; 749 750 QETH_CARD_TEXT(card, 5, "qethope_"); 751 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { 752 QETH_CARD_TEXT(card, 3, "openREC"); 753 return -ERESTARTSYS; 754 } 755 return __qeth_l2_open(dev); 756 } 757 758 static int qeth_l2_stop(struct net_device *dev) 759 { 760 struct qeth_card *card = dev->ml_priv; 761 762 QETH_CARD_TEXT(card, 4, "qethstop"); 763 netif_tx_disable(dev); 764 if (card->state == CARD_STATE_UP) { 765 card->state = CARD_STATE_SOFTSETUP; 766 napi_disable(&card->napi); 767 } 768 return 0; 769 } 770 771 static const struct device_type qeth_l2_devtype = { 772 .name = "qeth_layer2", 773 .groups = qeth_l2_attr_groups, 774 }; 775 776 static int qeth_l2_probe_device(struct ccwgroup_device *gdev) 777 { 778 struct qeth_card *card = dev_get_drvdata(&gdev->dev); 779 int rc; 780 781 if (gdev->dev.type == &qeth_generic_devtype) { 782 rc = qeth_l2_create_device_attributes(&gdev->dev); 783 if (rc) 784 return rc; 785 } 786 INIT_LIST_HEAD(&card->vid_list); 787 hash_init(card->mac_htable); 788 card->info.hwtrap = 0; 789 qeth_l2_vnicc_set_defaults(card); 790 return 0; 791 } 792 793 static void qeth_l2_remove_device(struct ccwgroup_device *cgdev) 794 { 795 struct qeth_card *card = dev_get_drvdata(&cgdev->dev); 796 797 if (cgdev->dev.type == &qeth_generic_devtype) 798 qeth_l2_remove_device_attributes(&cgdev->dev); 799 qeth_set_allowed_threads(card, 0, 1); 800 wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); 801 802 if (cgdev->state == CCWGROUP_ONLINE) 803 qeth_l2_set_offline(cgdev); 804 if (qeth_netdev_is_registered(card->dev)) 805 unregister_netdev(card->dev); 806 } 807 808 static const struct ethtool_ops qeth_l2_ethtool_ops = { 809 .get_link = ethtool_op_get_link, 810 .get_strings = qeth_core_get_strings, 811 .get_ethtool_stats = qeth_core_get_ethtool_stats, 812 .get_sset_count = qeth_core_get_sset_count, 813 .get_drvinfo = qeth_core_get_drvinfo, 814 .get_link_ksettings = qeth_core_ethtool_get_link_ksettings, 815 }; 816 817 static const struct ethtool_ops qeth_l2_osn_ops = { 818 .get_strings = qeth_core_get_strings, 819 .get_ethtool_stats = qeth_core_get_ethtool_stats, 820 .get_sset_count = qeth_core_get_sset_count, 821 .get_drvinfo = qeth_core_get_drvinfo, 822 }; 823 824 static const struct net_device_ops qeth_l2_netdev_ops = { 825 .ndo_open = qeth_l2_open, 826 .ndo_stop = qeth_l2_stop, 827 .ndo_get_stats = qeth_get_stats, 828 .ndo_start_xmit = qeth_l2_hard_start_xmit, 829 .ndo_features_check = qeth_features_check, 830 .ndo_validate_addr = eth_validate_addr, 831 .ndo_set_rx_mode = qeth_l2_set_rx_mode, 832 .ndo_do_ioctl = qeth_do_ioctl, 833 .ndo_set_mac_address = qeth_l2_set_mac_address, 834 .ndo_vlan_rx_add_vid = qeth_l2_vlan_rx_add_vid, 835 .ndo_vlan_rx_kill_vid = qeth_l2_vlan_rx_kill_vid, 836 .ndo_tx_timeout = qeth_tx_timeout, 837 .ndo_fix_features = qeth_fix_features, 838 .ndo_set_features = qeth_set_features 839 }; 840 841 static int qeth_l2_setup_netdev(struct qeth_card *card, bool carrier_ok) 842 { 843 int rc; 844 845 if (qeth_netdev_is_registered(card->dev)) 846 return 0; 847 848 card->dev->priv_flags |= IFF_UNICAST_FLT; 849 card->dev->netdev_ops = &qeth_l2_netdev_ops; 850 if (card->info.type == QETH_CARD_TYPE_OSN) { 851 card->dev->ethtool_ops = &qeth_l2_osn_ops; 852 card->dev->flags |= IFF_NOARP; 853 } else { 854 card->dev->ethtool_ops = &qeth_l2_ethtool_ops; 855 card->dev->needed_headroom = sizeof(struct qeth_hdr); 856 } 857 858 if (card->info.type == QETH_CARD_TYPE_OSM) 859 card->dev->features |= NETIF_F_VLAN_CHALLENGED; 860 else 861 card->dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; 862 863 if (card->info.type == QETH_CARD_TYPE_OSD && !card->info.guestlan) { 864 card->dev->features |= NETIF_F_SG; 865 /* OSA 3S and earlier has no RX/TX support */ 866 if (qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) { 867 card->dev->hw_features |= NETIF_F_IP_CSUM; 868 card->dev->vlan_features |= NETIF_F_IP_CSUM; 869 } 870 } 871 if (qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) { 872 card->dev->hw_features |= NETIF_F_IPV6_CSUM; 873 card->dev->vlan_features |= NETIF_F_IPV6_CSUM; 874 } 875 if (qeth_is_supported(card, IPA_INBOUND_CHECKSUM) || 876 qeth_is_supported6(card, IPA_INBOUND_CHECKSUM_V6)) { 877 card->dev->hw_features |= NETIF_F_RXCSUM; 878 card->dev->vlan_features |= NETIF_F_RXCSUM; 879 } 880 if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) { 881 card->dev->hw_features |= NETIF_F_TSO; 882 card->dev->vlan_features |= NETIF_F_TSO; 883 } 884 if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) { 885 card->dev->hw_features |= NETIF_F_TSO6; 886 card->dev->vlan_features |= NETIF_F_TSO6; 887 } 888 889 if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6)) { 890 card->dev->needed_headroom = sizeof(struct qeth_hdr_tso); 891 netif_set_gso_max_size(card->dev, 892 PAGE_SIZE * (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)); 893 } 894 895 if (!is_valid_ether_addr(card->dev->dev_addr)) 896 qeth_l2_request_initial_mac(card); 897 netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT); 898 rc = register_netdev(card->dev); 899 if (!rc && carrier_ok) 900 netif_carrier_on(card->dev); 901 902 if (rc) 903 card->dev->netdev_ops = NULL; 904 return rc; 905 } 906 907 static int qeth_l2_start_ipassists(struct qeth_card *card) 908 { 909 /* configure isolation level */ 910 if (qeth_set_access_ctrl_online(card, 0)) 911 return -ENODEV; 912 return 0; 913 } 914 915 static void qeth_l2_trace_features(struct qeth_card *card) 916 { 917 /* Set BridgePort features */ 918 QETH_CARD_TEXT(card, 2, "featuSBP"); 919 QETH_CARD_HEX(card, 2, &card->options.sbp.supported_funcs, 920 sizeof(card->options.sbp.supported_funcs)); 921 /* VNIC Characteristics features */ 922 QETH_CARD_TEXT(card, 2, "feaVNICC"); 923 QETH_CARD_HEX(card, 2, &card->options.vnicc.sup_chars, 924 sizeof(card->options.vnicc.sup_chars)); 925 } 926 927 static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode) 928 { 929 struct qeth_card *card = dev_get_drvdata(&gdev->dev); 930 int rc = 0; 931 enum qeth_card_states recover_flag; 932 bool carrier_ok; 933 934 mutex_lock(&card->discipline_mutex); 935 mutex_lock(&card->conf_mutex); 936 QETH_DBF_TEXT(SETUP, 2, "setonlin"); 937 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); 938 939 recover_flag = card->state; 940 rc = qeth_core_hardsetup_card(card, &carrier_ok); 941 if (rc) { 942 QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc); 943 rc = -ENODEV; 944 goto out_remove; 945 } 946 qeth_bridgeport_query_support(card); 947 if (card->options.sbp.supported_funcs) 948 dev_info(&card->gdev->dev, 949 "The device represents a Bridge Capable Port\n"); 950 951 rc = qeth_l2_setup_netdev(card, carrier_ok); 952 if (rc) 953 goto out_remove; 954 955 if (card->info.type != QETH_CARD_TYPE_OSN && 956 !qeth_l2_send_setmac(card, card->dev->dev_addr)) 957 card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED; 958 959 if (qeth_is_diagass_supported(card, QETH_DIAGS_CMD_TRAP)) { 960 if (card->info.hwtrap && 961 qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM)) 962 card->info.hwtrap = 0; 963 } else 964 card->info.hwtrap = 0; 965 966 /* for the rx_bcast characteristic, init VNICC after setmac */ 967 qeth_l2_vnicc_init(card); 968 969 qeth_trace_features(card); 970 qeth_l2_trace_features(card); 971 972 qeth_l2_setup_bridgeport_attrs(card); 973 974 card->state = CARD_STATE_HARDSETUP; 975 qeth_print_status_message(card); 976 977 /* softsetup */ 978 QETH_DBF_TEXT(SETUP, 2, "softsetp"); 979 980 if ((card->info.type == QETH_CARD_TYPE_OSD) || 981 (card->info.type == QETH_CARD_TYPE_OSX)) { 982 rc = qeth_l2_start_ipassists(card); 983 if (rc) 984 goto out_remove; 985 } 986 987 if (card->info.type != QETH_CARD_TYPE_OSN) 988 qeth_l2_process_vlans(card); 989 990 netif_tx_disable(card->dev); 991 992 rc = qeth_init_qdio_queues(card); 993 if (rc) { 994 QETH_DBF_TEXT_(SETUP, 2, "6err%d", rc); 995 rc = -ENODEV; 996 goto out_remove; 997 } 998 card->state = CARD_STATE_SOFTSETUP; 999 1000 qeth_set_allowed_threads(card, 0xffffffff, 0); 1001 1002 qeth_enable_hw_features(card->dev); 1003 if (recover_flag == CARD_STATE_RECOVER) { 1004 if (recovery_mode && 1005 card->info.type != QETH_CARD_TYPE_OSN) { 1006 __qeth_l2_open(card->dev); 1007 qeth_l2_set_rx_mode(card->dev); 1008 } else { 1009 rtnl_lock(); 1010 dev_open(card->dev, NULL); 1011 rtnl_unlock(); 1012 } 1013 } 1014 /* let user_space know that device is online */ 1015 kobject_uevent(&gdev->dev.kobj, KOBJ_CHANGE); 1016 mutex_unlock(&card->conf_mutex); 1017 mutex_unlock(&card->discipline_mutex); 1018 return 0; 1019 1020 out_remove: 1021 qeth_l2_stop_card(card, 0); 1022 ccw_device_set_offline(CARD_DDEV(card)); 1023 ccw_device_set_offline(CARD_WDEV(card)); 1024 ccw_device_set_offline(CARD_RDEV(card)); 1025 qdio_free(CARD_DDEV(card)); 1026 if (recover_flag == CARD_STATE_RECOVER) 1027 card->state = CARD_STATE_RECOVER; 1028 else 1029 card->state = CARD_STATE_DOWN; 1030 mutex_unlock(&card->conf_mutex); 1031 mutex_unlock(&card->discipline_mutex); 1032 return rc; 1033 } 1034 1035 static int qeth_l2_set_online(struct ccwgroup_device *gdev) 1036 { 1037 return __qeth_l2_set_online(gdev, 0); 1038 } 1039 1040 static int __qeth_l2_set_offline(struct ccwgroup_device *cgdev, 1041 int recovery_mode) 1042 { 1043 struct qeth_card *card = dev_get_drvdata(&cgdev->dev); 1044 int rc = 0, rc2 = 0, rc3 = 0; 1045 enum qeth_card_states recover_flag; 1046 1047 mutex_lock(&card->discipline_mutex); 1048 mutex_lock(&card->conf_mutex); 1049 QETH_DBF_TEXT(SETUP, 3, "setoffl"); 1050 QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *)); 1051 1052 netif_carrier_off(card->dev); 1053 recover_flag = card->state; 1054 if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) { 1055 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); 1056 card->info.hwtrap = 1; 1057 } 1058 qeth_l2_stop_card(card, recovery_mode); 1059 rc = ccw_device_set_offline(CARD_DDEV(card)); 1060 rc2 = ccw_device_set_offline(CARD_WDEV(card)); 1061 rc3 = ccw_device_set_offline(CARD_RDEV(card)); 1062 if (!rc) 1063 rc = (rc2) ? rc2 : rc3; 1064 if (rc) 1065 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc); 1066 qdio_free(CARD_DDEV(card)); 1067 if (recover_flag == CARD_STATE_UP) 1068 card->state = CARD_STATE_RECOVER; 1069 /* let user_space know that device is offline */ 1070 kobject_uevent(&cgdev->dev.kobj, KOBJ_CHANGE); 1071 mutex_unlock(&card->conf_mutex); 1072 mutex_unlock(&card->discipline_mutex); 1073 return 0; 1074 } 1075 1076 static int qeth_l2_set_offline(struct ccwgroup_device *cgdev) 1077 { 1078 return __qeth_l2_set_offline(cgdev, 0); 1079 } 1080 1081 static int qeth_l2_recover(void *ptr) 1082 { 1083 struct qeth_card *card; 1084 int rc = 0; 1085 1086 card = (struct qeth_card *) ptr; 1087 QETH_CARD_TEXT(card, 2, "recover1"); 1088 if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD)) 1089 return 0; 1090 QETH_CARD_TEXT(card, 2, "recover2"); 1091 dev_warn(&card->gdev->dev, 1092 "A recovery process has been started for the device\n"); 1093 qeth_set_recovery_task(card); 1094 __qeth_l2_set_offline(card->gdev, 1); 1095 rc = __qeth_l2_set_online(card->gdev, 1); 1096 if (!rc) 1097 dev_info(&card->gdev->dev, 1098 "Device successfully recovered!\n"); 1099 else { 1100 qeth_close_dev(card); 1101 dev_warn(&card->gdev->dev, "The qeth device driver " 1102 "failed to recover an error on the device\n"); 1103 } 1104 qeth_clear_recovery_task(card); 1105 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); 1106 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD); 1107 return 0; 1108 } 1109 1110 static int __init qeth_l2_init(void) 1111 { 1112 pr_info("register layer 2 discipline\n"); 1113 return 0; 1114 } 1115 1116 static void __exit qeth_l2_exit(void) 1117 { 1118 pr_info("unregister layer 2 discipline\n"); 1119 } 1120 1121 static int qeth_l2_pm_suspend(struct ccwgroup_device *gdev) 1122 { 1123 struct qeth_card *card = dev_get_drvdata(&gdev->dev); 1124 1125 netif_device_detach(card->dev); 1126 qeth_set_allowed_threads(card, 0, 1); 1127 wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); 1128 if (gdev->state == CCWGROUP_OFFLINE) 1129 return 0; 1130 if (card->state == CARD_STATE_UP) { 1131 if (card->info.hwtrap) 1132 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); 1133 __qeth_l2_set_offline(card->gdev, 1); 1134 } else 1135 __qeth_l2_set_offline(card->gdev, 0); 1136 return 0; 1137 } 1138 1139 static int qeth_l2_pm_resume(struct ccwgroup_device *gdev) 1140 { 1141 struct qeth_card *card = dev_get_drvdata(&gdev->dev); 1142 int rc = 0; 1143 1144 if (card->state == CARD_STATE_RECOVER) { 1145 rc = __qeth_l2_set_online(card->gdev, 1); 1146 if (rc) { 1147 rtnl_lock(); 1148 dev_close(card->dev); 1149 rtnl_unlock(); 1150 } 1151 } else 1152 rc = __qeth_l2_set_online(card->gdev, 0); 1153 1154 qeth_set_allowed_threads(card, 0xffffffff, 0); 1155 netif_device_attach(card->dev); 1156 if (rc) 1157 dev_warn(&card->gdev->dev, "The qeth device driver " 1158 "failed to recover an error on the device\n"); 1159 return rc; 1160 } 1161 1162 /* Returns zero if the command is successfully "consumed" */ 1163 static int qeth_l2_control_event(struct qeth_card *card, 1164 struct qeth_ipa_cmd *cmd) 1165 { 1166 switch (cmd->hdr.command) { 1167 case IPA_CMD_SETBRIDGEPORT_OSA: 1168 case IPA_CMD_SETBRIDGEPORT_IQD: 1169 if (cmd->data.sbp.hdr.command_code == 1170 IPA_SBP_BRIDGE_PORT_STATE_CHANGE) { 1171 qeth_bridge_state_change(card, cmd); 1172 return 0; 1173 } else 1174 return 1; 1175 case IPA_CMD_ADDRESS_CHANGE_NOTIF: 1176 qeth_bridge_host_event(card, cmd); 1177 return 0; 1178 default: 1179 return 1; 1180 } 1181 } 1182 1183 struct qeth_discipline qeth_l2_discipline = { 1184 .devtype = &qeth_l2_devtype, 1185 .process_rx_buffer = qeth_l2_process_inbound_buffer, 1186 .recover = qeth_l2_recover, 1187 .setup = qeth_l2_probe_device, 1188 .remove = qeth_l2_remove_device, 1189 .set_online = qeth_l2_set_online, 1190 .set_offline = qeth_l2_set_offline, 1191 .freeze = qeth_l2_pm_suspend, 1192 .thaw = qeth_l2_pm_resume, 1193 .restore = qeth_l2_pm_resume, 1194 .do_ioctl = NULL, 1195 .control_event_handler = qeth_l2_control_event, 1196 }; 1197 EXPORT_SYMBOL_GPL(qeth_l2_discipline); 1198 1199 static int qeth_osn_send_control_data(struct qeth_card *card, int len, 1200 struct qeth_cmd_buffer *iob) 1201 { 1202 struct qeth_channel *channel = iob->channel; 1203 int rc = 0; 1204 1205 QETH_CARD_TEXT(card, 5, "osndctrd"); 1206 1207 wait_event(card->wait_q, 1208 atomic_cmpxchg(&channel->irq_pending, 0, 1) == 0); 1209 qeth_prepare_control_data(card, len, iob); 1210 QETH_CARD_TEXT(card, 6, "osnoirqp"); 1211 spin_lock_irq(get_ccwdev_lock(channel->ccwdev)); 1212 rc = ccw_device_start_timeout(channel->ccwdev, channel->ccw, 1213 (addr_t) iob, 0, 0, QETH_IPA_TIMEOUT); 1214 spin_unlock_irq(get_ccwdev_lock(channel->ccwdev)); 1215 if (rc) { 1216 QETH_DBF_MESSAGE(2, "qeth_osn_send_control_data: " 1217 "ccw_device_start rc = %i\n", rc); 1218 QETH_CARD_TEXT_(card, 2, " err%d", rc); 1219 qeth_release_buffer(channel, iob); 1220 atomic_set(&channel->irq_pending, 0); 1221 wake_up(&card->wait_q); 1222 } 1223 return rc; 1224 } 1225 1226 static int qeth_osn_send_ipa_cmd(struct qeth_card *card, 1227 struct qeth_cmd_buffer *iob, int data_len) 1228 { 1229 u16 s1, s2; 1230 1231 QETH_CARD_TEXT(card, 4, "osndipa"); 1232 1233 qeth_prepare_ipa_cmd(card, iob); 1234 s1 = (u16)(IPA_PDU_HEADER_SIZE + data_len); 1235 s2 = (u16)data_len; 1236 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob->data), &s1, 2); 1237 memcpy(QETH_IPA_PDU_LEN_PDU1(iob->data), &s2, 2); 1238 memcpy(QETH_IPA_PDU_LEN_PDU2(iob->data), &s2, 2); 1239 memcpy(QETH_IPA_PDU_LEN_PDU3(iob->data), &s2, 2); 1240 return qeth_osn_send_control_data(card, s1, iob); 1241 } 1242 1243 int qeth_osn_assist(struct net_device *dev, void *data, int data_len) 1244 { 1245 struct qeth_cmd_buffer *iob; 1246 struct qeth_card *card; 1247 1248 if (!dev) 1249 return -ENODEV; 1250 card = dev->ml_priv; 1251 if (!card) 1252 return -ENODEV; 1253 QETH_CARD_TEXT(card, 2, "osnsdmc"); 1254 if (!qeth_card_hw_is_reachable(card)) 1255 return -ENODEV; 1256 iob = qeth_wait_for_buffer(&card->write); 1257 memcpy(__ipa_cmd(iob), data, data_len); 1258 return qeth_osn_send_ipa_cmd(card, iob, data_len); 1259 } 1260 EXPORT_SYMBOL(qeth_osn_assist); 1261 1262 int qeth_osn_register(unsigned char *read_dev_no, struct net_device **dev, 1263 int (*assist_cb)(struct net_device *, void *), 1264 int (*data_cb)(struct sk_buff *)) 1265 { 1266 struct qeth_card *card; 1267 char bus_id[16]; 1268 u16 devno; 1269 1270 memcpy(&devno, read_dev_no, 2); 1271 sprintf(bus_id, "0.0.%04x", devno); 1272 card = qeth_get_card_by_busid(bus_id); 1273 if (!card || !IS_OSN(card)) 1274 return -ENODEV; 1275 *dev = card->dev; 1276 1277 QETH_CARD_TEXT(card, 2, "osnreg"); 1278 if ((assist_cb == NULL) || (data_cb == NULL)) 1279 return -EINVAL; 1280 card->osn_info.assist_cb = assist_cb; 1281 card->osn_info.data_cb = data_cb; 1282 return 0; 1283 } 1284 EXPORT_SYMBOL(qeth_osn_register); 1285 1286 void qeth_osn_deregister(struct net_device *dev) 1287 { 1288 struct qeth_card *card; 1289 1290 if (!dev) 1291 return; 1292 card = dev->ml_priv; 1293 if (!card) 1294 return; 1295 QETH_CARD_TEXT(card, 2, "osndereg"); 1296 card->osn_info.assist_cb = NULL; 1297 card->osn_info.data_cb = NULL; 1298 return; 1299 } 1300 EXPORT_SYMBOL(qeth_osn_deregister); 1301 1302 /* SETBRIDGEPORT support, async notifications */ 1303 1304 enum qeth_an_event_type {anev_reg_unreg, anev_abort, anev_reset}; 1305 1306 /** 1307 * qeth_bridge_emit_host_event() - bridgeport address change notification 1308 * @card: qeth_card structure pointer, for udev events. 1309 * @evtype: "normal" register/unregister, or abort, or reset. For abort 1310 * and reset token and addr_lnid are unused and may be NULL. 1311 * @code: event bitmask: high order bit 0x80 value 1 means removal of an 1312 * object, 0 - addition of an object. 1313 * 0x01 - VLAN, 0x02 - MAC, 0x03 - VLAN and MAC. 1314 * @token: "network token" structure identifying physical address of the port. 1315 * @addr_lnid: pointer to structure with MAC address and VLAN ID. 1316 * 1317 * This function is called when registrations and deregistrations are 1318 * reported by the hardware, and also when notifications are enabled - 1319 * for all currently registered addresses. 1320 */ 1321 static void qeth_bridge_emit_host_event(struct qeth_card *card, 1322 enum qeth_an_event_type evtype, 1323 u8 code, struct net_if_token *token, struct mac_addr_lnid *addr_lnid) 1324 { 1325 char str[7][32]; 1326 char *env[8]; 1327 int i = 0; 1328 1329 switch (evtype) { 1330 case anev_reg_unreg: 1331 snprintf(str[i], sizeof(str[i]), "BRIDGEDHOST=%s", 1332 (code & IPA_ADDR_CHANGE_CODE_REMOVAL) 1333 ? "deregister" : "register"); 1334 env[i] = str[i]; i++; 1335 if (code & IPA_ADDR_CHANGE_CODE_VLANID) { 1336 snprintf(str[i], sizeof(str[i]), "VLAN=%d", 1337 addr_lnid->lnid); 1338 env[i] = str[i]; i++; 1339 } 1340 if (code & IPA_ADDR_CHANGE_CODE_MACADDR) { 1341 snprintf(str[i], sizeof(str[i]), "MAC=%pM", 1342 addr_lnid->mac); 1343 env[i] = str[i]; i++; 1344 } 1345 snprintf(str[i], sizeof(str[i]), "NTOK_BUSID=%x.%x.%04x", 1346 token->cssid, token->ssid, token->devnum); 1347 env[i] = str[i]; i++; 1348 snprintf(str[i], sizeof(str[i]), "NTOK_IID=%02x", token->iid); 1349 env[i] = str[i]; i++; 1350 snprintf(str[i], sizeof(str[i]), "NTOK_CHPID=%02x", 1351 token->chpid); 1352 env[i] = str[i]; i++; 1353 snprintf(str[i], sizeof(str[i]), "NTOK_CHID=%04x", token->chid); 1354 env[i] = str[i]; i++; 1355 break; 1356 case anev_abort: 1357 snprintf(str[i], sizeof(str[i]), "BRIDGEDHOST=abort"); 1358 env[i] = str[i]; i++; 1359 break; 1360 case anev_reset: 1361 snprintf(str[i], sizeof(str[i]), "BRIDGEDHOST=reset"); 1362 env[i] = str[i]; i++; 1363 break; 1364 } 1365 env[i] = NULL; 1366 kobject_uevent_env(&card->gdev->dev.kobj, KOBJ_CHANGE, env); 1367 } 1368 1369 struct qeth_bridge_state_data { 1370 struct work_struct worker; 1371 struct qeth_card *card; 1372 struct qeth_sbp_state_change qports; 1373 }; 1374 1375 static void qeth_bridge_state_change_worker(struct work_struct *work) 1376 { 1377 struct qeth_bridge_state_data *data = 1378 container_of(work, struct qeth_bridge_state_data, worker); 1379 /* We are only interested in the first entry - local port */ 1380 struct qeth_sbp_port_entry *entry = &data->qports.entry[0]; 1381 char env_locrem[32]; 1382 char env_role[32]; 1383 char env_state[32]; 1384 char *env[] = { 1385 env_locrem, 1386 env_role, 1387 env_state, 1388 NULL 1389 }; 1390 1391 /* Role should not change by itself, but if it did, */ 1392 /* information from the hardware is authoritative. */ 1393 mutex_lock(&data->card->conf_mutex); 1394 data->card->options.sbp.role = entry->role; 1395 mutex_unlock(&data->card->conf_mutex); 1396 1397 snprintf(env_locrem, sizeof(env_locrem), "BRIDGEPORT=statechange"); 1398 snprintf(env_role, sizeof(env_role), "ROLE=%s", 1399 (entry->role == QETH_SBP_ROLE_NONE) ? "none" : 1400 (entry->role == QETH_SBP_ROLE_PRIMARY) ? "primary" : 1401 (entry->role == QETH_SBP_ROLE_SECONDARY) ? "secondary" : 1402 "<INVALID>"); 1403 snprintf(env_state, sizeof(env_state), "STATE=%s", 1404 (entry->state == QETH_SBP_STATE_INACTIVE) ? "inactive" : 1405 (entry->state == QETH_SBP_STATE_STANDBY) ? "standby" : 1406 (entry->state == QETH_SBP_STATE_ACTIVE) ? "active" : 1407 "<INVALID>"); 1408 kobject_uevent_env(&data->card->gdev->dev.kobj, 1409 KOBJ_CHANGE, env); 1410 kfree(data); 1411 } 1412 1413 static void qeth_bridge_state_change(struct qeth_card *card, 1414 struct qeth_ipa_cmd *cmd) 1415 { 1416 struct qeth_sbp_state_change *qports = 1417 &cmd->data.sbp.data.state_change; 1418 struct qeth_bridge_state_data *data; 1419 int extrasize; 1420 1421 QETH_CARD_TEXT(card, 2, "brstchng"); 1422 if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) { 1423 QETH_CARD_TEXT_(card, 2, "BPsz%04x", qports->entry_length); 1424 return; 1425 } 1426 extrasize = sizeof(struct qeth_sbp_port_entry) * qports->num_entries; 1427 data = kzalloc(sizeof(struct qeth_bridge_state_data) + extrasize, 1428 GFP_ATOMIC); 1429 if (!data) { 1430 QETH_CARD_TEXT(card, 2, "BPSalloc"); 1431 return; 1432 } 1433 INIT_WORK(&data->worker, qeth_bridge_state_change_worker); 1434 data->card = card; 1435 memcpy(&data->qports, qports, 1436 sizeof(struct qeth_sbp_state_change) + extrasize); 1437 queue_work(qeth_wq, &data->worker); 1438 } 1439 1440 struct qeth_bridge_host_data { 1441 struct work_struct worker; 1442 struct qeth_card *card; 1443 struct qeth_ipacmd_addr_change hostevs; 1444 }; 1445 1446 static void qeth_bridge_host_event_worker(struct work_struct *work) 1447 { 1448 struct qeth_bridge_host_data *data = 1449 container_of(work, struct qeth_bridge_host_data, worker); 1450 int i; 1451 1452 if (data->hostevs.lost_event_mask) { 1453 dev_info(&data->card->gdev->dev, 1454 "Address notification from the Bridge Port stopped %s (%s)\n", 1455 data->card->dev->name, 1456 (data->hostevs.lost_event_mask == 0x01) 1457 ? "Overflow" 1458 : (data->hostevs.lost_event_mask == 0x02) 1459 ? "Bridge port state change" 1460 : "Unknown reason"); 1461 mutex_lock(&data->card->conf_mutex); 1462 data->card->options.sbp.hostnotification = 0; 1463 mutex_unlock(&data->card->conf_mutex); 1464 qeth_bridge_emit_host_event(data->card, anev_abort, 1465 0, NULL, NULL); 1466 } else 1467 for (i = 0; i < data->hostevs.num_entries; i++) { 1468 struct qeth_ipacmd_addr_change_entry *entry = 1469 &data->hostevs.entry[i]; 1470 qeth_bridge_emit_host_event(data->card, 1471 anev_reg_unreg, 1472 entry->change_code, 1473 &entry->token, &entry->addr_lnid); 1474 } 1475 kfree(data); 1476 } 1477 1478 static void qeth_bridge_host_event(struct qeth_card *card, 1479 struct qeth_ipa_cmd *cmd) 1480 { 1481 struct qeth_ipacmd_addr_change *hostevs = 1482 &cmd->data.addrchange; 1483 struct qeth_bridge_host_data *data; 1484 int extrasize; 1485 1486 QETH_CARD_TEXT(card, 2, "brhostev"); 1487 if (cmd->hdr.return_code != 0x0000) { 1488 if (cmd->hdr.return_code == 0x0010) { 1489 if (hostevs->lost_event_mask == 0x00) 1490 hostevs->lost_event_mask = 0xff; 1491 } else { 1492 QETH_CARD_TEXT_(card, 2, "BPHe%04x", 1493 cmd->hdr.return_code); 1494 return; 1495 } 1496 } 1497 extrasize = sizeof(struct qeth_ipacmd_addr_change_entry) * 1498 hostevs->num_entries; 1499 data = kzalloc(sizeof(struct qeth_bridge_host_data) + extrasize, 1500 GFP_ATOMIC); 1501 if (!data) { 1502 QETH_CARD_TEXT(card, 2, "BPHalloc"); 1503 return; 1504 } 1505 INIT_WORK(&data->worker, qeth_bridge_host_event_worker); 1506 data->card = card; 1507 memcpy(&data->hostevs, hostevs, 1508 sizeof(struct qeth_ipacmd_addr_change) + extrasize); 1509 queue_work(qeth_wq, &data->worker); 1510 } 1511 1512 /* SETBRIDGEPORT support; sending commands */ 1513 1514 struct _qeth_sbp_cbctl { 1515 u16 ipa_rc; 1516 u16 cmd_rc; 1517 union { 1518 u32 supported; 1519 struct { 1520 enum qeth_sbp_roles *role; 1521 enum qeth_sbp_states *state; 1522 } qports; 1523 } data; 1524 }; 1525 1526 /** 1527 * qeth_bridgeport_makerc() - derive "traditional" error from hardware codes. 1528 * @card: qeth_card structure pointer, for debug messages. 1529 * @cbctl: state structure with hardware return codes. 1530 * @setcmd: IPA command code 1531 * 1532 * Returns negative errno-compatible error indication or 0 on success. 1533 */ 1534 static int qeth_bridgeport_makerc(struct qeth_card *card, 1535 struct _qeth_sbp_cbctl *cbctl, enum qeth_ipa_sbp_cmd setcmd) 1536 { 1537 int rc; 1538 int is_iqd = (card->info.type == QETH_CARD_TYPE_IQD); 1539 1540 if ((is_iqd && (cbctl->ipa_rc == IPA_RC_SUCCESS)) || 1541 (!is_iqd && (cbctl->ipa_rc == cbctl->cmd_rc))) 1542 switch (cbctl->cmd_rc) { 1543 case IPA_RC_SUCCESS: 1544 rc = 0; 1545 break; 1546 case IPA_RC_L2_UNSUPPORTED_CMD: 1547 case IPA_RC_UNSUPPORTED_COMMAND: 1548 rc = -EOPNOTSUPP; 1549 break; 1550 case IPA_RC_SBP_OSA_NOT_CONFIGURED: 1551 case IPA_RC_SBP_IQD_NOT_CONFIGURED: 1552 rc = -ENODEV; /* maybe not the best code here? */ 1553 dev_err(&card->gdev->dev, 1554 "The device is not configured as a Bridge Port\n"); 1555 break; 1556 case IPA_RC_SBP_OSA_OS_MISMATCH: 1557 case IPA_RC_SBP_IQD_OS_MISMATCH: 1558 rc = -EPERM; 1559 dev_err(&card->gdev->dev, 1560 "A Bridge Port is already configured by a different operating system\n"); 1561 break; 1562 case IPA_RC_SBP_OSA_ANO_DEV_PRIMARY: 1563 case IPA_RC_SBP_IQD_ANO_DEV_PRIMARY: 1564 switch (setcmd) { 1565 case IPA_SBP_SET_PRIMARY_BRIDGE_PORT: 1566 rc = -EEXIST; 1567 dev_err(&card->gdev->dev, 1568 "The LAN already has a primary Bridge Port\n"); 1569 break; 1570 case IPA_SBP_SET_SECONDARY_BRIDGE_PORT: 1571 rc = -EBUSY; 1572 dev_err(&card->gdev->dev, 1573 "The device is already a primary Bridge Port\n"); 1574 break; 1575 default: 1576 rc = -EIO; 1577 } 1578 break; 1579 case IPA_RC_SBP_OSA_CURRENT_SECOND: 1580 case IPA_RC_SBP_IQD_CURRENT_SECOND: 1581 rc = -EBUSY; 1582 dev_err(&card->gdev->dev, 1583 "The device is already a secondary Bridge Port\n"); 1584 break; 1585 case IPA_RC_SBP_OSA_LIMIT_SECOND: 1586 case IPA_RC_SBP_IQD_LIMIT_SECOND: 1587 rc = -EEXIST; 1588 dev_err(&card->gdev->dev, 1589 "The LAN cannot have more secondary Bridge Ports\n"); 1590 break; 1591 case IPA_RC_SBP_OSA_CURRENT_PRIMARY: 1592 case IPA_RC_SBP_IQD_CURRENT_PRIMARY: 1593 rc = -EBUSY; 1594 dev_err(&card->gdev->dev, 1595 "The device is already a primary Bridge Port\n"); 1596 break; 1597 case IPA_RC_SBP_OSA_NOT_AUTHD_BY_ZMAN: 1598 case IPA_RC_SBP_IQD_NOT_AUTHD_BY_ZMAN: 1599 rc = -EACCES; 1600 dev_err(&card->gdev->dev, 1601 "The device is not authorized to be a Bridge Port\n"); 1602 break; 1603 default: 1604 rc = -EIO; 1605 } 1606 else 1607 switch (cbctl->ipa_rc) { 1608 case IPA_RC_NOTSUPP: 1609 rc = -EOPNOTSUPP; 1610 break; 1611 case IPA_RC_UNSUPPORTED_COMMAND: 1612 rc = -EOPNOTSUPP; 1613 break; 1614 default: 1615 rc = -EIO; 1616 } 1617 1618 if (rc) { 1619 QETH_CARD_TEXT_(card, 2, "SBPi%04x", cbctl->ipa_rc); 1620 QETH_CARD_TEXT_(card, 2, "SBPc%04x", cbctl->cmd_rc); 1621 } 1622 return rc; 1623 } 1624 1625 static struct qeth_cmd_buffer *qeth_sbp_build_cmd(struct qeth_card *card, 1626 enum qeth_ipa_sbp_cmd sbp_cmd, 1627 unsigned int cmd_length) 1628 { 1629 enum qeth_ipa_cmds ipa_cmd = (card->info.type == QETH_CARD_TYPE_IQD) ? 1630 IPA_CMD_SETBRIDGEPORT_IQD : 1631 IPA_CMD_SETBRIDGEPORT_OSA; 1632 struct qeth_cmd_buffer *iob; 1633 struct qeth_ipa_cmd *cmd; 1634 1635 iob = qeth_get_ipacmd_buffer(card, ipa_cmd, 0); 1636 if (!iob) 1637 return iob; 1638 cmd = __ipa_cmd(iob); 1639 cmd->data.sbp.hdr.cmdlength = sizeof(struct qeth_ipacmd_sbp_hdr) + 1640 cmd_length; 1641 cmd->data.sbp.hdr.command_code = sbp_cmd; 1642 cmd->data.sbp.hdr.used_total = 1; 1643 cmd->data.sbp.hdr.seq_no = 1; 1644 return iob; 1645 } 1646 1647 static int qeth_bridgeport_query_support_cb(struct qeth_card *card, 1648 struct qeth_reply *reply, unsigned long data) 1649 { 1650 struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; 1651 struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param; 1652 QETH_CARD_TEXT(card, 2, "brqsupcb"); 1653 cbctl->ipa_rc = cmd->hdr.return_code; 1654 cbctl->cmd_rc = cmd->data.sbp.hdr.return_code; 1655 if ((cbctl->ipa_rc == 0) && (cbctl->cmd_rc == 0)) { 1656 cbctl->data.supported = 1657 cmd->data.sbp.data.query_cmds_supp.supported_cmds; 1658 } else { 1659 cbctl->data.supported = 0; 1660 } 1661 return 0; 1662 } 1663 1664 /** 1665 * qeth_bridgeport_query_support() - store bitmask of supported subfunctions. 1666 * @card: qeth_card structure pointer. 1667 * 1668 * Sets bitmask of supported setbridgeport subfunctions in the qeth_card 1669 * strucutre: card->options.sbp.supported_funcs. 1670 */ 1671 static void qeth_bridgeport_query_support(struct qeth_card *card) 1672 { 1673 struct qeth_cmd_buffer *iob; 1674 struct _qeth_sbp_cbctl cbctl; 1675 1676 QETH_CARD_TEXT(card, 2, "brqsuppo"); 1677 iob = qeth_sbp_build_cmd(card, IPA_SBP_QUERY_COMMANDS_SUPPORTED, 1678 sizeof(struct qeth_sbp_query_cmds_supp)); 1679 if (!iob) 1680 return; 1681 if (qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_support_cb, 1682 (void *)&cbctl) || 1683 qeth_bridgeport_makerc(card, &cbctl, 1684 IPA_SBP_QUERY_COMMANDS_SUPPORTED)) { 1685 /* non-zero makerc signifies failure, and produce messages */ 1686 card->options.sbp.role = QETH_SBP_ROLE_NONE; 1687 return; 1688 } 1689 card->options.sbp.supported_funcs = cbctl.data.supported; 1690 } 1691 1692 static int qeth_bridgeport_query_ports_cb(struct qeth_card *card, 1693 struct qeth_reply *reply, unsigned long data) 1694 { 1695 struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; 1696 struct qeth_sbp_query_ports *qports = &cmd->data.sbp.data.query_ports; 1697 struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param; 1698 1699 QETH_CARD_TEXT(card, 2, "brqprtcb"); 1700 cbctl->ipa_rc = cmd->hdr.return_code; 1701 cbctl->cmd_rc = cmd->data.sbp.hdr.return_code; 1702 if ((cbctl->ipa_rc != 0) || (cbctl->cmd_rc != 0)) 1703 return 0; 1704 if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) { 1705 cbctl->cmd_rc = 0xffff; 1706 QETH_CARD_TEXT_(card, 2, "SBPs%04x", qports->entry_length); 1707 return 0; 1708 } 1709 /* first entry contains the state of the local port */ 1710 if (qports->num_entries > 0) { 1711 if (cbctl->data.qports.role) 1712 *cbctl->data.qports.role = qports->entry[0].role; 1713 if (cbctl->data.qports.state) 1714 *cbctl->data.qports.state = qports->entry[0].state; 1715 } 1716 return 0; 1717 } 1718 1719 /** 1720 * qeth_bridgeport_query_ports() - query local bridgeport status. 1721 * @card: qeth_card structure pointer. 1722 * @role: Role of the port: 0-none, 1-primary, 2-secondary. 1723 * @state: State of the port: 0-inactive, 1-standby, 2-active. 1724 * 1725 * Returns negative errno-compatible error indication or 0 on success. 1726 * 1727 * 'role' and 'state' are not updated in case of hardware operation failure. 1728 */ 1729 int qeth_bridgeport_query_ports(struct qeth_card *card, 1730 enum qeth_sbp_roles *role, enum qeth_sbp_states *state) 1731 { 1732 int rc = 0; 1733 struct qeth_cmd_buffer *iob; 1734 struct _qeth_sbp_cbctl cbctl = { 1735 .data = { 1736 .qports = { 1737 .role = role, 1738 .state = state, 1739 }, 1740 }, 1741 }; 1742 1743 QETH_CARD_TEXT(card, 2, "brqports"); 1744 if (!(card->options.sbp.supported_funcs & IPA_SBP_QUERY_BRIDGE_PORTS)) 1745 return -EOPNOTSUPP; 1746 iob = qeth_sbp_build_cmd(card, IPA_SBP_QUERY_BRIDGE_PORTS, 0); 1747 if (!iob) 1748 return -ENOMEM; 1749 rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_ports_cb, 1750 (void *)&cbctl); 1751 if (rc < 0) 1752 return rc; 1753 return qeth_bridgeport_makerc(card, &cbctl, IPA_SBP_QUERY_BRIDGE_PORTS); 1754 } 1755 1756 static int qeth_bridgeport_set_cb(struct qeth_card *card, 1757 struct qeth_reply *reply, unsigned long data) 1758 { 1759 struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *)data; 1760 struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param; 1761 QETH_CARD_TEXT(card, 2, "brsetrcb"); 1762 cbctl->ipa_rc = cmd->hdr.return_code; 1763 cbctl->cmd_rc = cmd->data.sbp.hdr.return_code; 1764 return 0; 1765 } 1766 1767 /** 1768 * qeth_bridgeport_setrole() - Assign primary role to the port. 1769 * @card: qeth_card structure pointer. 1770 * @role: Role to assign. 1771 * 1772 * Returns negative errno-compatible error indication or 0 on success. 1773 */ 1774 int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role) 1775 { 1776 int rc = 0; 1777 int cmdlength; 1778 struct qeth_cmd_buffer *iob; 1779 struct _qeth_sbp_cbctl cbctl; 1780 enum qeth_ipa_sbp_cmd setcmd; 1781 1782 QETH_CARD_TEXT(card, 2, "brsetrol"); 1783 switch (role) { 1784 case QETH_SBP_ROLE_NONE: 1785 setcmd = IPA_SBP_RESET_BRIDGE_PORT_ROLE; 1786 cmdlength = sizeof(struct qeth_sbp_reset_role); 1787 break; 1788 case QETH_SBP_ROLE_PRIMARY: 1789 setcmd = IPA_SBP_SET_PRIMARY_BRIDGE_PORT; 1790 cmdlength = sizeof(struct qeth_sbp_set_primary); 1791 break; 1792 case QETH_SBP_ROLE_SECONDARY: 1793 setcmd = IPA_SBP_SET_SECONDARY_BRIDGE_PORT; 1794 cmdlength = sizeof(struct qeth_sbp_set_secondary); 1795 break; 1796 default: 1797 return -EINVAL; 1798 } 1799 if (!(card->options.sbp.supported_funcs & setcmd)) 1800 return -EOPNOTSUPP; 1801 iob = qeth_sbp_build_cmd(card, setcmd, cmdlength); 1802 if (!iob) 1803 return -ENOMEM; 1804 rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_set_cb, 1805 (void *)&cbctl); 1806 if (rc < 0) 1807 return rc; 1808 return qeth_bridgeport_makerc(card, &cbctl, setcmd); 1809 } 1810 1811 /** 1812 * qeth_anset_makerc() - derive "traditional" error from hardware codes. 1813 * @card: qeth_card structure pointer, for debug messages. 1814 * 1815 * Returns negative errno-compatible error indication or 0 on success. 1816 */ 1817 static int qeth_anset_makerc(struct qeth_card *card, int pnso_rc, u16 response) 1818 { 1819 int rc; 1820 1821 if (pnso_rc == 0) 1822 switch (response) { 1823 case 0x0001: 1824 rc = 0; 1825 break; 1826 case 0x0004: 1827 case 0x0100: 1828 case 0x0106: 1829 rc = -EOPNOTSUPP; 1830 dev_err(&card->gdev->dev, 1831 "Setting address notification failed\n"); 1832 break; 1833 case 0x0107: 1834 rc = -EAGAIN; 1835 break; 1836 default: 1837 rc = -EIO; 1838 } 1839 else 1840 rc = -EIO; 1841 1842 if (rc) { 1843 QETH_CARD_TEXT_(card, 2, "SBPp%04x", pnso_rc); 1844 QETH_CARD_TEXT_(card, 2, "SBPr%04x", response); 1845 } 1846 return rc; 1847 } 1848 1849 static void qeth_bridgeport_an_set_cb(void *priv, 1850 enum qdio_brinfo_entry_type type, void *entry) 1851 { 1852 struct qeth_card *card = (struct qeth_card *)priv; 1853 struct qdio_brinfo_entry_l2 *l2entry; 1854 u8 code; 1855 1856 if (type != l2_addr_lnid) { 1857 WARN_ON_ONCE(1); 1858 return; 1859 } 1860 1861 l2entry = (struct qdio_brinfo_entry_l2 *)entry; 1862 code = IPA_ADDR_CHANGE_CODE_MACADDR; 1863 if (l2entry->addr_lnid.lnid) 1864 code |= IPA_ADDR_CHANGE_CODE_VLANID; 1865 qeth_bridge_emit_host_event(card, anev_reg_unreg, code, 1866 (struct net_if_token *)&l2entry->nit, 1867 (struct mac_addr_lnid *)&l2entry->addr_lnid); 1868 } 1869 1870 /** 1871 * qeth_bridgeport_an_set() - Enable or disable bridgeport address notification 1872 * @card: qeth_card structure pointer. 1873 * @enable: 0 - disable, non-zero - enable notifications 1874 * 1875 * Returns negative errno-compatible error indication or 0 on success. 1876 * 1877 * On enable, emits a series of address notifications udev events for all 1878 * currently registered hosts. 1879 */ 1880 int qeth_bridgeport_an_set(struct qeth_card *card, int enable) 1881 { 1882 int rc; 1883 u16 response; 1884 struct ccw_device *ddev; 1885 struct subchannel_id schid; 1886 1887 if (!card) 1888 return -EINVAL; 1889 if (!card->options.sbp.supported_funcs) 1890 return -EOPNOTSUPP; 1891 ddev = CARD_DDEV(card); 1892 ccw_device_get_schid(ddev, &schid); 1893 1894 if (enable) { 1895 qeth_bridge_emit_host_event(card, anev_reset, 0, NULL, NULL); 1896 rc = qdio_pnso_brinfo(schid, 1, &response, 1897 qeth_bridgeport_an_set_cb, card); 1898 } else 1899 rc = qdio_pnso_brinfo(schid, 0, &response, NULL, NULL); 1900 return qeth_anset_makerc(card, rc, response); 1901 } 1902 1903 static bool qeth_bridgeport_is_in_use(struct qeth_card *card) 1904 { 1905 return (card->options.sbp.role || card->options.sbp.reflect_promisc || 1906 card->options.sbp.hostnotification); 1907 } 1908 1909 /* VNIC Characteristics support */ 1910 1911 /* handle VNICC IPA command return codes; convert to error codes */ 1912 static int qeth_l2_vnicc_makerc(struct qeth_card *card, int ipa_rc) 1913 { 1914 int rc; 1915 1916 switch (ipa_rc) { 1917 case IPA_RC_SUCCESS: 1918 return ipa_rc; 1919 case IPA_RC_L2_UNSUPPORTED_CMD: 1920 case IPA_RC_NOTSUPP: 1921 rc = -EOPNOTSUPP; 1922 break; 1923 case IPA_RC_VNICC_OOSEQ: 1924 rc = -EALREADY; 1925 break; 1926 case IPA_RC_VNICC_VNICBP: 1927 rc = -EBUSY; 1928 break; 1929 case IPA_RC_L2_ADDR_TABLE_FULL: 1930 rc = -ENOSPC; 1931 break; 1932 case IPA_RC_L2_MAC_NOT_AUTH_BY_ADP: 1933 rc = -EACCES; 1934 break; 1935 default: 1936 rc = -EIO; 1937 } 1938 1939 QETH_CARD_TEXT_(card, 2, "err%04x", ipa_rc); 1940 return rc; 1941 } 1942 1943 /* generic VNICC request call back control */ 1944 struct _qeth_l2_vnicc_request_cbctl { 1945 u32 sub_cmd; 1946 struct { 1947 u32 vnic_char; 1948 u32 timeout; 1949 } param; 1950 struct { 1951 union{ 1952 u32 *sup_cmds; 1953 u32 *timeout; 1954 }; 1955 } result; 1956 }; 1957 1958 /* generic VNICC request call back */ 1959 static int qeth_l2_vnicc_request_cb(struct qeth_card *card, 1960 struct qeth_reply *reply, 1961 unsigned long data) 1962 { 1963 struct _qeth_l2_vnicc_request_cbctl *cbctl = 1964 (struct _qeth_l2_vnicc_request_cbctl *) reply->param; 1965 struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; 1966 struct qeth_ipacmd_vnicc *rep = &cmd->data.vnicc; 1967 1968 QETH_CARD_TEXT(card, 2, "vniccrcb"); 1969 if (cmd->hdr.return_code) 1970 return 0; 1971 /* return results to caller */ 1972 card->options.vnicc.sup_chars = rep->hdr.sup; 1973 card->options.vnicc.cur_chars = rep->hdr.cur; 1974 1975 if (cbctl->sub_cmd == IPA_VNICC_QUERY_CMDS) 1976 *cbctl->result.sup_cmds = rep->query_cmds.sup_cmds; 1977 1978 if (cbctl->sub_cmd == IPA_VNICC_GET_TIMEOUT) 1979 *cbctl->result.timeout = rep->getset_timeout.timeout; 1980 1981 return 0; 1982 } 1983 1984 /* generic VNICC request */ 1985 static int qeth_l2_vnicc_request(struct qeth_card *card, 1986 struct _qeth_l2_vnicc_request_cbctl *cbctl) 1987 { 1988 struct qeth_ipacmd_vnicc *req; 1989 struct qeth_cmd_buffer *iob; 1990 struct qeth_ipa_cmd *cmd; 1991 int rc; 1992 1993 QETH_CARD_TEXT(card, 2, "vniccreq"); 1994 1995 /* get new buffer for request */ 1996 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_VNICC, 0); 1997 if (!iob) 1998 return -ENOMEM; 1999 2000 /* create header for request */ 2001 cmd = __ipa_cmd(iob); 2002 req = &cmd->data.vnicc; 2003 2004 /* create sub command header for request */ 2005 req->sub_hdr.data_length = sizeof(req->sub_hdr); 2006 req->sub_hdr.sub_command = cbctl->sub_cmd; 2007 2008 /* create sub command specific request fields */ 2009 switch (cbctl->sub_cmd) { 2010 case IPA_VNICC_QUERY_CHARS: 2011 break; 2012 case IPA_VNICC_QUERY_CMDS: 2013 req->sub_hdr.data_length += sizeof(req->query_cmds); 2014 req->query_cmds.vnic_char = cbctl->param.vnic_char; 2015 break; 2016 case IPA_VNICC_ENABLE: 2017 case IPA_VNICC_DISABLE: 2018 req->sub_hdr.data_length += sizeof(req->set_char); 2019 req->set_char.vnic_char = cbctl->param.vnic_char; 2020 break; 2021 case IPA_VNICC_SET_TIMEOUT: 2022 req->getset_timeout.timeout = cbctl->param.timeout; 2023 /* fallthrough */ 2024 case IPA_VNICC_GET_TIMEOUT: 2025 req->sub_hdr.data_length += sizeof(req->getset_timeout); 2026 req->getset_timeout.vnic_char = cbctl->param.vnic_char; 2027 break; 2028 default: 2029 qeth_release_buffer(iob->channel, iob); 2030 return -EOPNOTSUPP; 2031 } 2032 2033 /* send request */ 2034 rc = qeth_send_ipa_cmd(card, iob, qeth_l2_vnicc_request_cb, 2035 (void *) cbctl); 2036 2037 return qeth_l2_vnicc_makerc(card, rc); 2038 } 2039 2040 /* VNICC query VNIC characteristics request */ 2041 static int qeth_l2_vnicc_query_chars(struct qeth_card *card) 2042 { 2043 struct _qeth_l2_vnicc_request_cbctl cbctl; 2044 2045 /* prepare callback control */ 2046 cbctl.sub_cmd = IPA_VNICC_QUERY_CHARS; 2047 2048 QETH_CARD_TEXT(card, 2, "vniccqch"); 2049 return qeth_l2_vnicc_request(card, &cbctl); 2050 } 2051 2052 /* VNICC query sub commands request */ 2053 static int qeth_l2_vnicc_query_cmds(struct qeth_card *card, u32 vnic_char, 2054 u32 *sup_cmds) 2055 { 2056 struct _qeth_l2_vnicc_request_cbctl cbctl; 2057 2058 /* prepare callback control */ 2059 cbctl.sub_cmd = IPA_VNICC_QUERY_CMDS; 2060 cbctl.param.vnic_char = vnic_char; 2061 cbctl.result.sup_cmds = sup_cmds; 2062 2063 QETH_CARD_TEXT(card, 2, "vniccqcm"); 2064 return qeth_l2_vnicc_request(card, &cbctl); 2065 } 2066 2067 /* VNICC enable/disable characteristic request */ 2068 static int qeth_l2_vnicc_set_char(struct qeth_card *card, u32 vnic_char, 2069 u32 cmd) 2070 { 2071 struct _qeth_l2_vnicc_request_cbctl cbctl; 2072 2073 /* prepare callback control */ 2074 cbctl.sub_cmd = cmd; 2075 cbctl.param.vnic_char = vnic_char; 2076 2077 QETH_CARD_TEXT(card, 2, "vniccedc"); 2078 return qeth_l2_vnicc_request(card, &cbctl); 2079 } 2080 2081 /* VNICC get/set timeout for characteristic request */ 2082 static int qeth_l2_vnicc_getset_timeout(struct qeth_card *card, u32 vnicc, 2083 u32 cmd, u32 *timeout) 2084 { 2085 struct _qeth_l2_vnicc_request_cbctl cbctl; 2086 2087 /* prepare callback control */ 2088 cbctl.sub_cmd = cmd; 2089 cbctl.param.vnic_char = vnicc; 2090 if (cmd == IPA_VNICC_SET_TIMEOUT) 2091 cbctl.param.timeout = *timeout; 2092 if (cmd == IPA_VNICC_GET_TIMEOUT) 2093 cbctl.result.timeout = timeout; 2094 2095 QETH_CARD_TEXT(card, 2, "vniccgst"); 2096 return qeth_l2_vnicc_request(card, &cbctl); 2097 } 2098 2099 /* set current VNICC flag state; called from sysfs store function */ 2100 int qeth_l2_vnicc_set_state(struct qeth_card *card, u32 vnicc, bool state) 2101 { 2102 int rc = 0; 2103 u32 cmd; 2104 2105 QETH_CARD_TEXT(card, 2, "vniccsch"); 2106 2107 /* do not change anything if BridgePort is enabled */ 2108 if (qeth_bridgeport_is_in_use(card)) 2109 return -EBUSY; 2110 2111 /* check if characteristic and enable/disable are supported */ 2112 if (!(card->options.vnicc.sup_chars & vnicc) || 2113 !(card->options.vnicc.set_char_sup & vnicc)) 2114 return -EOPNOTSUPP; 2115 2116 /* set enable/disable command and store wanted characteristic */ 2117 if (state) { 2118 cmd = IPA_VNICC_ENABLE; 2119 card->options.vnicc.wanted_chars |= vnicc; 2120 } else { 2121 cmd = IPA_VNICC_DISABLE; 2122 card->options.vnicc.wanted_chars &= ~vnicc; 2123 } 2124 2125 /* do we need to do anything? */ 2126 if (card->options.vnicc.cur_chars == card->options.vnicc.wanted_chars) 2127 return rc; 2128 2129 /* if card is not ready, simply stop here */ 2130 if (!qeth_card_hw_is_reachable(card)) { 2131 if (state) 2132 card->options.vnicc.cur_chars |= vnicc; 2133 else 2134 card->options.vnicc.cur_chars &= ~vnicc; 2135 return rc; 2136 } 2137 2138 rc = qeth_l2_vnicc_set_char(card, vnicc, cmd); 2139 if (rc) 2140 card->options.vnicc.wanted_chars = 2141 card->options.vnicc.cur_chars; 2142 else { 2143 /* successful online VNICC change; handle special cases */ 2144 if (state && vnicc == QETH_VNICC_RX_BCAST) 2145 card->options.vnicc.rx_bcast_enabled = true; 2146 if (!state && vnicc == QETH_VNICC_LEARNING) 2147 qeth_l2_vnicc_recover_timeout(card, vnicc, 2148 &card->options.vnicc.learning_timeout); 2149 } 2150 2151 return rc; 2152 } 2153 2154 /* get current VNICC flag state; called from sysfs show function */ 2155 int qeth_l2_vnicc_get_state(struct qeth_card *card, u32 vnicc, bool *state) 2156 { 2157 int rc = 0; 2158 2159 QETH_CARD_TEXT(card, 2, "vniccgch"); 2160 2161 /* do not get anything if BridgePort is enabled */ 2162 if (qeth_bridgeport_is_in_use(card)) 2163 return -EBUSY; 2164 2165 /* check if characteristic is supported */ 2166 if (!(card->options.vnicc.sup_chars & vnicc)) 2167 return -EOPNOTSUPP; 2168 2169 /* if card is ready, query current VNICC state */ 2170 if (qeth_card_hw_is_reachable(card)) 2171 rc = qeth_l2_vnicc_query_chars(card); 2172 2173 *state = (card->options.vnicc.cur_chars & vnicc) ? true : false; 2174 return rc; 2175 } 2176 2177 /* set VNICC timeout; called from sysfs store function. Currently, only learning 2178 * supports timeout 2179 */ 2180 int qeth_l2_vnicc_set_timeout(struct qeth_card *card, u32 timeout) 2181 { 2182 int rc = 0; 2183 2184 QETH_CARD_TEXT(card, 2, "vniccsto"); 2185 2186 /* do not change anything if BridgePort is enabled */ 2187 if (qeth_bridgeport_is_in_use(card)) 2188 return -EBUSY; 2189 2190 /* check if characteristic and set_timeout are supported */ 2191 if (!(card->options.vnicc.sup_chars & QETH_VNICC_LEARNING) || 2192 !(card->options.vnicc.getset_timeout_sup & QETH_VNICC_LEARNING)) 2193 return -EOPNOTSUPP; 2194 2195 /* do we need to do anything? */ 2196 if (card->options.vnicc.learning_timeout == timeout) 2197 return rc; 2198 2199 /* if card is not ready, simply store the value internally and return */ 2200 if (!qeth_card_hw_is_reachable(card)) { 2201 card->options.vnicc.learning_timeout = timeout; 2202 return rc; 2203 } 2204 2205 /* send timeout value to card; if successful, store value internally */ 2206 rc = qeth_l2_vnicc_getset_timeout(card, QETH_VNICC_LEARNING, 2207 IPA_VNICC_SET_TIMEOUT, &timeout); 2208 if (!rc) 2209 card->options.vnicc.learning_timeout = timeout; 2210 2211 return rc; 2212 } 2213 2214 /* get current VNICC timeout; called from sysfs show function. Currently, only 2215 * learning supports timeout 2216 */ 2217 int qeth_l2_vnicc_get_timeout(struct qeth_card *card, u32 *timeout) 2218 { 2219 int rc = 0; 2220 2221 QETH_CARD_TEXT(card, 2, "vniccgto"); 2222 2223 /* do not get anything if BridgePort is enabled */ 2224 if (qeth_bridgeport_is_in_use(card)) 2225 return -EBUSY; 2226 2227 /* check if characteristic and get_timeout are supported */ 2228 if (!(card->options.vnicc.sup_chars & QETH_VNICC_LEARNING) || 2229 !(card->options.vnicc.getset_timeout_sup & QETH_VNICC_LEARNING)) 2230 return -EOPNOTSUPP; 2231 /* if card is ready, get timeout. Otherwise, just return stored value */ 2232 *timeout = card->options.vnicc.learning_timeout; 2233 if (qeth_card_hw_is_reachable(card)) 2234 rc = qeth_l2_vnicc_getset_timeout(card, QETH_VNICC_LEARNING, 2235 IPA_VNICC_GET_TIMEOUT, 2236 timeout); 2237 2238 return rc; 2239 } 2240 2241 /* check if VNICC is currently enabled */ 2242 bool qeth_l2_vnicc_is_in_use(struct qeth_card *card) 2243 { 2244 /* if everything is turned off, VNICC is not active */ 2245 if (!card->options.vnicc.cur_chars) 2246 return false; 2247 /* default values are only OK if rx_bcast was not enabled by user 2248 * or the card is offline. 2249 */ 2250 if (card->options.vnicc.cur_chars == QETH_VNICC_DEFAULT) { 2251 if (!card->options.vnicc.rx_bcast_enabled || 2252 !qeth_card_hw_is_reachable(card)) 2253 return false; 2254 } 2255 return true; 2256 } 2257 2258 /* recover user timeout setting */ 2259 static bool qeth_l2_vnicc_recover_timeout(struct qeth_card *card, u32 vnicc, 2260 u32 *timeout) 2261 { 2262 if (card->options.vnicc.sup_chars & vnicc && 2263 card->options.vnicc.getset_timeout_sup & vnicc && 2264 !qeth_l2_vnicc_getset_timeout(card, vnicc, IPA_VNICC_SET_TIMEOUT, 2265 timeout)) 2266 return false; 2267 *timeout = QETH_VNICC_DEFAULT_TIMEOUT; 2268 return true; 2269 } 2270 2271 /* recover user characteristic setting */ 2272 static bool qeth_l2_vnicc_recover_char(struct qeth_card *card, u32 vnicc, 2273 bool enable) 2274 { 2275 u32 cmd = enable ? IPA_VNICC_ENABLE : IPA_VNICC_DISABLE; 2276 2277 if (card->options.vnicc.sup_chars & vnicc && 2278 card->options.vnicc.set_char_sup & vnicc && 2279 !qeth_l2_vnicc_set_char(card, vnicc, cmd)) 2280 return false; 2281 card->options.vnicc.wanted_chars &= ~vnicc; 2282 card->options.vnicc.wanted_chars |= QETH_VNICC_DEFAULT & vnicc; 2283 return true; 2284 } 2285 2286 /* (re-)initialize VNICC */ 2287 static void qeth_l2_vnicc_init(struct qeth_card *card) 2288 { 2289 u32 *timeout = &card->options.vnicc.learning_timeout; 2290 unsigned int chars_len, i; 2291 unsigned long chars_tmp; 2292 u32 sup_cmds, vnicc; 2293 bool enable, error; 2294 2295 QETH_CARD_TEXT(card, 2, "vniccini"); 2296 /* reset rx_bcast */ 2297 card->options.vnicc.rx_bcast_enabled = 0; 2298 /* initial query and storage of VNIC characteristics */ 2299 if (qeth_l2_vnicc_query_chars(card)) { 2300 if (card->options.vnicc.wanted_chars != QETH_VNICC_DEFAULT || 2301 *timeout != QETH_VNICC_DEFAULT_TIMEOUT) 2302 dev_err(&card->gdev->dev, "Configuring the VNIC characteristics failed\n"); 2303 /* fail quietly if user didn't change the default config */ 2304 card->options.vnicc.sup_chars = 0; 2305 card->options.vnicc.cur_chars = 0; 2306 card->options.vnicc.wanted_chars = QETH_VNICC_DEFAULT; 2307 return; 2308 } 2309 /* get supported commands for each supported characteristic */ 2310 chars_tmp = card->options.vnicc.sup_chars; 2311 chars_len = sizeof(card->options.vnicc.sup_chars) * BITS_PER_BYTE; 2312 for_each_set_bit(i, &chars_tmp, chars_len) { 2313 vnicc = BIT(i); 2314 qeth_l2_vnicc_query_cmds(card, vnicc, &sup_cmds); 2315 if (!(sup_cmds & IPA_VNICC_SET_TIMEOUT) || 2316 !(sup_cmds & IPA_VNICC_GET_TIMEOUT)) 2317 card->options.vnicc.getset_timeout_sup &= ~vnicc; 2318 if (!(sup_cmds & IPA_VNICC_ENABLE) || 2319 !(sup_cmds & IPA_VNICC_DISABLE)) 2320 card->options.vnicc.set_char_sup &= ~vnicc; 2321 } 2322 /* enforce assumed default values and recover settings, if changed */ 2323 error = qeth_l2_vnicc_recover_timeout(card, QETH_VNICC_LEARNING, 2324 timeout); 2325 chars_tmp = card->options.vnicc.wanted_chars ^ QETH_VNICC_DEFAULT; 2326 chars_tmp |= QETH_VNICC_BRIDGE_INVISIBLE; 2327 chars_len = sizeof(card->options.vnicc.wanted_chars) * BITS_PER_BYTE; 2328 for_each_set_bit(i, &chars_tmp, chars_len) { 2329 vnicc = BIT(i); 2330 enable = card->options.vnicc.wanted_chars & vnicc; 2331 error |= qeth_l2_vnicc_recover_char(card, vnicc, enable); 2332 } 2333 if (error) 2334 dev_err(&card->gdev->dev, "Configuring the VNIC characteristics failed\n"); 2335 } 2336 2337 /* configure default values of VNIC characteristics */ 2338 static void qeth_l2_vnicc_set_defaults(struct qeth_card *card) 2339 { 2340 /* characteristics values */ 2341 card->options.vnicc.sup_chars = QETH_VNICC_ALL; 2342 card->options.vnicc.cur_chars = QETH_VNICC_DEFAULT; 2343 card->options.vnicc.learning_timeout = QETH_VNICC_DEFAULT_TIMEOUT; 2344 /* supported commands */ 2345 card->options.vnicc.set_char_sup = QETH_VNICC_ALL; 2346 card->options.vnicc.getset_timeout_sup = QETH_VNICC_LEARNING; 2347 /* settings wanted by users */ 2348 card->options.vnicc.wanted_chars = QETH_VNICC_DEFAULT; 2349 } 2350 2351 module_init(qeth_l2_init); 2352 module_exit(qeth_l2_exit); 2353 MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>"); 2354 MODULE_DESCRIPTION("qeth layer 2 discipline"); 2355 MODULE_LICENSE("GPL"); 2356