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