blob: 5b67fd1f2b778ab68b845e722fd008163515fe12 [file] [log] [blame]
Greg Kroah-Hartmanab9953f2017-11-14 18:38:04 +01001// SPDX-License-Identifier: GPL-2.0
Frank Blaschka4a71df52008-02-15 09:19:42 +01002/*
Frank Blaschkabbcfcdc2009-06-16 10:30:31 +02003 * Copyright IBM Corp. 2007, 2009
Frank Blaschka4a71df52008-02-15 09:19:42 +01004 * 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 Blaschka74eacdb2008-12-25 13:39:49 +010010#define KMSG_COMPONENT "qeth"
11#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12
Frank Blaschka4a71df52008-02-15 09:19:42 +010013#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 Heo5a0e3ad2010-03-24 17:04:11 +090018#include <linux/slab.h>
Frank Blaschka4a71df52008-02-15 09:19:42 +010019#include <linux/etherdevice.h>
Jiri Pirkoccffad252009-05-22 23:22:17 +000020#include <linux/list.h>
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +020021#include <linux/hash.h>
22#include <linux/hashtable.h>
Julian Wiedmannec61bd22017-06-20 16:00:34 +020023#include <asm/setup.h>
Frank Blaschka4a71df52008-02-15 09:19:42 +010024#include "qeth_core.h"
Eugene Crosserb4d72c02014-01-14 15:54:11 +010025#include "qeth_l2.h"
Frank Blaschka4a71df52008-02-15 09:19:42 +010026
Frank Blaschka4a71df52008-02-15 09:19:42 +010027static int qeth_l2_set_offline(struct ccwgroup_device *);
28static int qeth_l2_stop(struct net_device *);
Eugene Crosserc044dc22014-01-29 09:23:48 +010029static void qeth_bridgeport_query_support(struct qeth_card *card);
30static void qeth_bridge_state_change(struct qeth_card *card,
31 struct qeth_ipa_cmd *cmd);
32static void qeth_bridge_host_event(struct qeth_card *card,
33 struct qeth_ipa_cmd *cmd);
Hans Wippelcaa1f0b2017-09-18 21:18:15 +020034static void qeth_l2_vnicc_set_defaults(struct qeth_card *card);
Hans Wippela45b3fa2017-09-18 21:18:14 +020035static void qeth_l2_vnicc_init(struct qeth_card *card);
Hans Wippel349d13d2017-09-18 21:18:16 +020036static bool qeth_l2_vnicc_recover_timeout(struct qeth_card *card, u32 vnicc,
37 u32 *timeout);
Frank Blaschka4a71df52008-02-15 09:19:42 +010038
Frank Blaschka4a71df52008-02-15 09:19:42 +010039static 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 Huckf06f6f32008-06-06 12:37:45 +020043 __u16 temp_dev_no;
Frank Blaschka4a71df52008-02-15 09:19:42 +010044 unsigned long flags;
Cornelia Huckf06f6f32008-06-06 12:37:45 +020045 struct ccw_dev_id read_devid;
Frank Blaschka4a71df52008-02-15 09:19:42 +010046
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 Huckf06f6f32008-06-06 12:37:45 +020051 ccw_device_get_id(CARD_RDEV(card), &read_devid);
52 if (read_devid.devno == temp_dev_no) {
Frank Blaschka4a71df52008-02-15 09:19:42 +010053 ndev = card->dev;
54 break;
55 }
56 }
57 read_unlock_irqrestore(&qeth_core_card_list.rwlock, flags);
58 return ndev;
59}
60
Julian Wiedmann2aa48672017-09-18 21:18:20 +020061static int qeth_setdelmac_makerc(struct qeth_card *card, int retcode)
Frank Blaschka4a71df52008-02-15 09:19:42 +010062{
Eugene Crosserefbbc1d2015-01-21 13:39:09 +010063 int rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +010064
Eugene Crosserefbbc1d2015-01-21 13:39:09 +010065 if (retcode)
Thomas Richter1aec42b2015-01-21 13:39:10 +010066 QETH_CARD_TEXT_(card, 2, "err%04x", retcode);
Eugene Crosserefbbc1d2015-01-21 13:39:09 +010067 switch (retcode) {
68 case IPA_RC_SUCCESS:
69 rc = 0;
70 break;
71 case IPA_RC_L2_UNSUPPORTED_CMD:
Eugene Crosserffb95252015-05-18 14:27:58 +020072 rc = -EOPNOTSUPP;
Eugene Crosserefbbc1d2015-01-21 13:39:09 +010073 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 Richter1aec42b2015-01-21 13:39:10 +010088 case -ENOMEM:
89 rc = -ENOMEM;
90 break;
Eugene Crosserefbbc1d2015-01-21 13:39:09 +010091 default:
92 rc = -EIO;
93 break;
Frank Blaschka4a71df52008-02-15 09:19:42 +010094 }
Eugene Crosserefbbc1d2015-01-21 13:39:09 +010095 return rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +010096}
97
Julian Wiedmannac988d72017-01-12 15:48:41 +010098static 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 Wiedmannff5caa72018-03-09 18:12:52 +0100108 cmd = __ipa_cmd(iob);
Julian Wiedmann99f0b852017-12-20 20:11:01 +0100109 cmd->data.setdelmac.mac_length = ETH_ALEN;
110 ether_addr_copy(cmd->data.setdelmac.mac, mac);
Julian Wiedmann2aa48672017-09-18 21:18:20 +0200111 return qeth_setdelmac_makerc(card, qeth_send_ipa_cmd(card, iob,
112 NULL, NULL));
Julian Wiedmannac988d72017-01-12 15:48:41 +0100113}
114
115static 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 Wiedmannac988d72017-01-12 15:48:41 +0100122 dev_info(&card->gdev->dev,
Julian Wiedmannbcacfcb2018-04-19 12:52:09 +0200123 "MAC address %pM successfully registered on device %s\n",
124 mac, card->dev->name);
Julian Wiedmannac988d72017-01-12 15:48:41 +0100125 } else {
Julian Wiedmannac988d72017-01-12 15:48:41 +0100126 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 Wiedmann8174aa82017-12-20 20:11:00 +0100140static int qeth_l2_write_mac(struct qeth_card *card, u8 *mac)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100141{
Vasily Gorbik9d0a58f2018-06-29 19:45:52 +0200142 enum qeth_ipa_cmds cmd = is_multicast_ether_addr(mac) ?
Julian Wiedmann8174aa82017-12-20 20:11:00 +0100143 IPA_CMD_SETGMAC : IPA_CMD_SETVMAC;
Eugene Crosserefbbc1d2015-01-21 13:39:09 +0100144 int rc;
145
Julian Wiedmann8174aa82017-12-20 20:11:00 +0100146 QETH_CARD_TEXT(card, 2, "L2Wmac");
147 rc = qeth_l2_send_setdelmac(card, mac, cmd);
Eugene Crosserefbbc1d2015-01-21 13:39:09 +0100148 if (rc == -EEXIST)
Julian Wiedmanne19e5be2018-11-02 19:04:08 +0100149 QETH_DBF_MESSAGE(2, "MAC already registered on device %x\n",
150 CARD_DEVID(card));
Eugene Crosserefbbc1d2015-01-21 13:39:09 +0100151 else if (rc)
Julian Wiedmanne19e5be2018-11-02 19:04:08 +0100152 QETH_DBF_MESSAGE(2, "Failed to register MAC on device %x: %d\n",
153 CARD_DEVID(card), rc);
Eugene Crosserefbbc1d2015-01-21 13:39:09 +0100154 return rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100155}
156
Julian Wiedmann8174aa82017-12-20 20:11:00 +0100157static int qeth_l2_remove_mac(struct qeth_card *card, u8 *mac)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100158{
Vasily Gorbik9d0a58f2018-06-29 19:45:52 +0200159 enum qeth_ipa_cmds cmd = is_multicast_ether_addr(mac) ?
Julian Wiedmann8174aa82017-12-20 20:11:00 +0100160 IPA_CMD_DELGMAC : IPA_CMD_DELVMAC;
Eugene Crosserefbbc1d2015-01-21 13:39:09 +0100161 int rc;
162
Julian Wiedmann8174aa82017-12-20 20:11:00 +0100163 QETH_CARD_TEXT(card, 2, "L2Rmac");
164 rc = qeth_l2_send_setdelmac(card, mac, cmd);
Eugene Crosserefbbc1d2015-01-21 13:39:09 +0100165 if (rc)
Julian Wiedmanne19e5be2018-11-02 19:04:08 +0100166 QETH_DBF_MESSAGE(2, "Failed to delete MAC on device %u: %d\n",
167 CARD_DEVID(card), rc);
Eugene Crosserefbbc1d2015-01-21 13:39:09 +0100168 return rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100169}
170
Julian Wiedmannc07cbf22017-01-12 15:48:37 +0100171static void qeth_l2_del_all_macs(struct qeth_card *card)
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200172{
173 struct qeth_mac *mac;
174 struct hlist_node *tmp;
175 int i;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100176
177 spin_lock_bh(&card->mclock);
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200178 hash_for_each_safe(card->mac_htable, i, tmp, mac, hnode) {
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200179 hash_del(&mac->hnode);
180 kfree(mac);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100181 }
182 spin_unlock_bh(&card->mclock);
183}
184
Julian Wiedmanncef6ff222017-08-15 17:02:46 +0200185static int qeth_l2_get_cast_type(struct qeth_card *card, struct sk_buff *skb)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100186{
Klaus-Dieter Wackerce73e102009-08-26 02:01:08 +0000187 if (card->info.type == QETH_CARD_TYPE_OSN)
Julian Wiedmann86c0cdb2018-07-11 17:42:41 +0200188 return RTN_UNICAST;
Klaus-Dieter Wackerce73e102009-08-26 02:01:08 +0000189 if (is_broadcast_ether_addr(skb->data))
190 return RTN_BROADCAST;
191 if (is_multicast_ether_addr(skb->data))
192 return RTN_MULTICAST;
Julian Wiedmann86c0cdb2018-07-11 17:42:41 +0200193 return RTN_UNICAST;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100194}
195
Julian Wiedmannfc696602018-09-17 17:35:55 +0200196static 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 Blaschka4a71df52008-02-15 09:19:42 +0100199{
Julian Wiedmann0aef8392018-10-12 17:27:15 +0200200 struct vlan_ethhdr *veth = vlan_eth_hdr(skb);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100201
Julian Wiedmannae79fe02017-08-18 10:19:05 +0200202 hdr->hdr.l2.pkt_length = data_len;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100203
Julian Wiedmann0aef8392018-10-12 17:27:15 +0200204 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 Wiedmannfc696602018-09-17 17:35:55 +0200213 }
214
Frank Blaschka4a71df52008-02-15 09:19:42 +0100215 /* 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 Wackerce73e102009-08-26 02:01:08 +0000221 hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_UNICAST;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100222
Frank Blaschka4a71df52008-02-15 09:19:42 +0100223 /* 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 Wiedmann2aa48672017-09-18 21:18:20 +0200232static int qeth_setdelvlan_makerc(struct qeth_card *card, int retcode)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100233{
Julian Wiedmann2aa48672017-09-18 21:18:20 +0200234 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
255static 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 Blaschka4a71df52008-02-15 09:19:42 +0100260
Carsten Otte847a50f2010-06-21 22:57:05 +0000261 QETH_CARD_TEXT(card, 2, "L2sdvcb");
Frank Blaschka4a71df52008-02-15 09:19:42 +0100262 if (cmd->hdr.return_code) {
Julian Wiedmanne19e5be2018-11-02 19:04:08 +0100263 QETH_DBF_MESSAGE(2, "Error in processing VLAN %u on device %x: %#x.\n",
Julian Wiedmann2aa48672017-09-18 21:18:20 +0200264 cmd->data.setdelvlan.vlan_id,
Julian Wiedmanne19e5be2018-11-02 19:04:08 +0100265 CARD_DEVID(card), cmd->hdr.return_code);
Carsten Otte847a50f2010-06-21 22:57:05 +0000266 QETH_CARD_TEXT_(card, 2, "L2VL%4x", cmd->hdr.command);
267 QETH_CARD_TEXT_(card, 2, "err%d", cmd->hdr.return_code);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100268 }
269 return 0;
270}
271
272static int qeth_l2_send_setdelvlan(struct qeth_card *card, __u16 i,
Julian Wiedmann2aa48672017-09-18 21:18:20 +0200273 enum qeth_ipa_cmds ipacmd)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100274{
275 struct qeth_ipa_cmd *cmd;
276 struct qeth_cmd_buffer *iob;
277
Carsten Otte847a50f2010-06-21 22:57:05 +0000278 QETH_CARD_TEXT_(card, 4, "L2sdv%x", ipacmd);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100279 iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4);
Thomas Richter1aec42b2015-01-21 13:39:10 +0100280 if (!iob)
281 return -ENOMEM;
Julian Wiedmannff5caa72018-03-09 18:12:52 +0100282 cmd = __ipa_cmd(iob);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100283 cmd->data.setdelvlan.vlan_id = i;
Julian Wiedmann2aa48672017-09-18 21:18:20 +0200284 return qeth_setdelvlan_makerc(card, qeth_send_ipa_cmd(card, iob,
285 qeth_l2_send_setdelvlan_cb, NULL));
Frank Blaschka4a71df52008-02-15 09:19:42 +0100286}
287
Ursula Braun70919e22011-02-26 22:41:36 -0800288static void qeth_l2_process_vlans(struct qeth_card *card)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100289{
290 struct qeth_vlan_vid *id;
Julian Wiedmannd4ac0242018-04-26 09:42:13 +0200291
Carsten Otte847a50f2010-06-21 22:57:05 +0000292 QETH_CARD_TEXT(card, 3, "L2prcvln");
Julian Wiedmannd4ac0242018-04-26 09:42:13 +0200293 mutex_lock(&card->vid_list_mutex);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100294 list_for_each_entry(id, &card->vid_list, list) {
Ursula Braun70919e22011-02-26 22:41:36 -0800295 qeth_l2_send_setdelvlan(card, id->vid, IPA_CMD_SETVLAN);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100296 }
Julian Wiedmannd4ac0242018-04-26 09:42:13 +0200297 mutex_unlock(&card->vid_list_mutex);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100298}
299
Patrick McHardy80d5c362013-04-19 02:04:28 +0000300static int qeth_l2_vlan_rx_add_vid(struct net_device *dev,
301 __be16 proto, u16 vid)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100302{
Heiko Carstens509e2562008-07-26 02:24:10 -0700303 struct qeth_card *card = dev->ml_priv;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100304 struct qeth_vlan_vid *id;
Thomas Richter1aec42b2015-01-21 13:39:10 +0100305 int rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100306
Carsten Otte847a50f2010-06-21 22:57:05 +0000307 QETH_CARD_TEXT_(card, 4, "aid:%d", vid);
Ursula Braun10651db2010-10-01 02:51:13 +0000308 if (!vid)
Jiri Pirko8e586132011-12-08 19:52:37 -0500309 return 0;
Ursula Braun8e98ac42009-03-24 20:57:18 +0000310 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
Carsten Otte847a50f2010-06-21 22:57:05 +0000311 QETH_CARD_TEXT(card, 3, "aidREC");
Jiri Pirko8e586132011-12-08 19:52:37 -0500312 return 0;
Ursula Braun8e98ac42009-03-24 20:57:18 +0000313 }
Julian Wiedmannd4ac0242018-04-26 09:42:13 +0200314 id = kmalloc(sizeof(*id), GFP_KERNEL);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100315 if (id) {
316 id->vid = vid;
Thomas Richter1aec42b2015-01-21 13:39:10 +0100317 rc = qeth_l2_send_setdelvlan(card, vid, IPA_CMD_SETVLAN);
318 if (rc) {
319 kfree(id);
320 return rc;
321 }
Julian Wiedmannd4ac0242018-04-26 09:42:13 +0200322 mutex_lock(&card->vid_list_mutex);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100323 list_add_tail(&id->list, &card->vid_list);
Julian Wiedmannd4ac0242018-04-26 09:42:13 +0200324 mutex_unlock(&card->vid_list_mutex);
Jiri Pirko8e586132011-12-08 19:52:37 -0500325 } else {
326 return -ENOMEM;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100327 }
Jiri Pirko8e586132011-12-08 19:52:37 -0500328 return 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100329}
330
Patrick McHardy80d5c362013-04-19 02:04:28 +0000331static int qeth_l2_vlan_rx_kill_vid(struct net_device *dev,
332 __be16 proto, u16 vid)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100333{
334 struct qeth_vlan_vid *id, *tmpid = NULL;
Heiko Carstens509e2562008-07-26 02:24:10 -0700335 struct qeth_card *card = dev->ml_priv;
Thomas Richter1aec42b2015-01-21 13:39:10 +0100336 int rc = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100337
Carsten Otte847a50f2010-06-21 22:57:05 +0000338 QETH_CARD_TEXT_(card, 4, "kid:%d", vid);
Ursula Braun8e98ac42009-03-24 20:57:18 +0000339 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
Carsten Otte847a50f2010-06-21 22:57:05 +0000340 QETH_CARD_TEXT(card, 3, "kidREC");
Jiri Pirko8e586132011-12-08 19:52:37 -0500341 return 0;
Ursula Braun8e98ac42009-03-24 20:57:18 +0000342 }
Julian Wiedmannd4ac0242018-04-26 09:42:13 +0200343 mutex_lock(&card->vid_list_mutex);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100344 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 Wiedmannd4ac0242018-04-26 09:42:13 +0200351 mutex_unlock(&card->vid_list_mutex);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100352 if (tmpid) {
Thomas Richter1aec42b2015-01-21 13:39:10 +0100353 rc = qeth_l2_send_setdelvlan(card, vid, IPA_CMD_DELVLAN);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100354 kfree(tmpid);
355 }
Thomas Richter1aec42b2015-01-21 13:39:10 +0100356 return rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100357}
358
Peter Senna Tschudinb2f4de82015-08-04 17:11:47 +0200359static void qeth_l2_stop_card(struct qeth_card *card, int recovery_mode)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100360{
Peter Tiedemannd11ba0c2008-04-01 10:26:58 +0200361 QETH_DBF_TEXT(SETUP , 2, "stopcard");
362 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *));
Frank Blaschka4a71df52008-02-15 09:19:42 +0100363
364 qeth_set_allowed_threads(card, 0, 1);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100365 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 Braun70919e22011-02-26 22:41:36 -0800376 card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100377 card->state = CARD_STATE_SOFTSETUP;
378 }
379 if (card->state == CARD_STATE_SOFTSETUP) {
Julian Wiedmannc07cbf22017-01-12 15:48:37 +0100380 qeth_l2_del_all_macs(card);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100381 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 Blaschka4a71df52008-02-15 09:19:42 +0100394}
395
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000396static int qeth_l2_process_inbound_buffer(struct qeth_card *card,
397 int budget, int *done)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100398{
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000399 int work_done = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100400 struct sk_buff *skb;
401 struct qeth_hdr *hdr;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100402 unsigned int len;
403
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000404 *done = 0;
Stefan Raspl18af5c12012-11-19 02:46:50 +0000405 WARN_ON_ONCE(!budget);
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000406 while (budget) {
407 skb = qeth_core_get_next_skb(card,
Frank Blaschkab3332932011-08-08 01:33:59 +0000408 &card->qdio.in_q->bufs[card->rx.b_index],
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000409 &card->rx.b_element, &card->rx.e_offset, &hdr);
410 if (!skb) {
411 *done = 1;
412 break;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100413 }
Frank Blaschka4a71df52008-02-15 09:19:42 +0100414 switch (hdr->hdr.l2.id) {
415 case QETH_HEADER_TYPE_LAYER2:
Frank Blaschka4a71df52008-02-15 09:19:42 +0100416 skb->protocol = eth_type_trans(skb, skb->dev);
Julian Wiedmann6195b932018-04-26 09:42:17 +0200417 qeth_rx_csum(card, skb, hdr->hdr.l2.flags[1]);
Ursula Braun12883722008-04-01 10:26:56 +0200418 if (skb->protocol == htons(ETH_P_802_2))
419 *((__u32 *)skb->cb) = ++card->seqno.pkt_seqno;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100420 len = skb->len;
Thomas Richter9abfa8c2015-10-06 15:12:27 +0200421 napi_gro_receive(&card->napi, skb);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100422 break;
423 case QETH_HEADER_TYPE_OSN:
Ursula Braun2d488c22008-10-24 11:16:55 +0200424 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 Blaschka4a71df52008-02-15 09:19:42 +0100427 sizeof(struct qeth_hdr));
Ursula Braun2d488c22008-10-24 11:16:55 +0200428 len = skb->len;
429 card->osn_info.data_cb(skb);
430 break;
431 }
432 /* else unknown */
Frank Blaschka4a71df52008-02-15 09:19:42 +0100433 default:
434 dev_kfree_skb_any(skb);
Carsten Otte847a50f2010-06-21 22:57:05 +0000435 QETH_CARD_TEXT(card, 3, "inbunkno");
Julian Wiedmann0ac14872018-09-12 15:31:35 +0200436 QETH_DBF_HEX(CTRL, 3, hdr, sizeof(*hdr));
Frank Blaschka4a71df52008-02-15 09:19:42 +0100437 continue;
438 }
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000439 work_done++;
440 budget--;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100441 card->stats.rx_packets++;
442 card->stats.rx_bytes += len;
443 }
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000444 return work_done;
445}
446
Frank Blaschka4a71df52008-02-15 09:19:42 +0100447static int qeth_l2_request_initial_mac(struct qeth_card *card)
448{
449 int rc = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100450
Julian Wiedmannec61bd22017-06-20 16:00:34 +0200451 QETH_DBF_TEXT(SETUP, 2, "l2reqmac");
Peter Tiedemannd11ba0c2008-04-01 10:26:58 +0200452 QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card));
Frank Blaschka4a71df52008-02-15 09:19:42 +0100453
Julian Wiedmannec61bd22017-06-20 16:00:34 +0200454 if (MACHINE_IS_VM) {
455 rc = qeth_vm_request_mac(card);
456 if (!rc)
457 goto out;
Julian Wiedmanne19e5be2018-11-02 19:04:08 +0100458 QETH_DBF_MESSAGE(2, "z/VM MAC Service failed on device %x: %#x\n",
459 CARD_DEVID(card), rc);
Julian Wiedmannec61bd22017-06-20 16:00:34 +0200460 QETH_DBF_TEXT_(SETUP, 2, "err%04x", rc);
461 /* fall back to alternative mechanism: */
462 }
463
Ursula Braun5113fec2010-05-16 21:15:14 +0000464 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 Blaschka4a71df52008-02-15 09:19:42 +0100468 rc = qeth_setadpparms_change_macaddr(card);
Julian Wiedmann21b17022018-04-26 09:42:24 +0200469 if (!rc)
470 goto out;
Julian Wiedmanne19e5be2018-11-02 19:04:08 +0100471 QETH_DBF_MESSAGE(2, "READ_MAC Assist failed on device %x: %#x\n",
472 CARD_DEVID(card), rc);
Julian Wiedmann21b17022018-04-26 09:42:24 +0200473 QETH_DBF_TEXT_(SETUP, 2, "1err%04x", rc);
474 /* fall back once more: */
Frank Blaschka4a71df52008-02-15 09:19:42 +0100475 }
Julian Wiedmann21b17022018-04-26 09:42:24 +0200476
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 Wiedmannec61bd22017-06-20 16:00:34 +0200483out:
484 QETH_DBF_HEX(SETUP, 2, card->dev->dev_addr, card->dev->addr_len);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100485 return 0;
486}
487
488static int qeth_l2_set_mac_address(struct net_device *dev, void *p)
489{
490 struct sockaddr *addr = p;
Heiko Carstens509e2562008-07-26 02:24:10 -0700491 struct qeth_card *card = dev->ml_priv;
Julian Wiedmannbcacfcb2018-04-19 12:52:09 +0200492 u8 old_addr[ETH_ALEN];
Frank Blaschka4a71df52008-02-15 09:19:42 +0100493 int rc = 0;
494
Carsten Otte847a50f2010-06-21 22:57:05 +0000495 QETH_CARD_TEXT(card, 3, "setmac");
Frank Blaschka4a71df52008-02-15 09:19:42 +0100496
Ursula Braun5113fec2010-05-16 21:15:14 +0000497 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 Otte847a50f2010-06-21 22:57:05 +0000500 QETH_CARD_TEXT(card, 3, "setmcTYP");
Frank Blaschka4a71df52008-02-15 09:19:42 +0100501 return -EOPNOTSUPP;
502 }
Julian Wiedmann99f0b852017-12-20 20:11:01 +0100503 QETH_CARD_HEX(card, 3, addr->sa_data, ETH_ALEN);
Julian Wiedmannbcacfcb2018-04-19 12:52:09 +0200504 if (!is_valid_ether_addr(addr->sa_data))
505 return -EADDRNOTAVAIL;
506
Ursula Braun8e98ac42009-03-24 20:57:18 +0000507 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
Carsten Otte847a50f2010-06-21 22:57:05 +0000508 QETH_CARD_TEXT(card, 3, "setmcREC");
Ursula Braun8e98ac42009-03-24 20:57:18 +0000509 return -ERESTARTSYS;
510 }
Julian Wiedmannbcacfcb2018-04-19 12:52:09 +0200511
Julian Wiedmann4789a212018-06-29 19:45:51 +0200512 /* avoid racing against concurrent state change: */
513 if (!mutex_trylock(&card->conf_mutex))
514 return -EAGAIN;
515
Julian Wiedmannbcacfcb2018-04-19 12:52:09 +0200516 if (!qeth_card_hw_is_reachable(card)) {
517 ether_addr_copy(dev->dev_addr, addr->sa_data);
Julian Wiedmann4789a212018-06-29 19:45:51 +0200518 goto out_unlock;
Julian Wiedmannbcacfcb2018-04-19 12:52:09 +0200519 }
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 Wiedmann4789a212018-06-29 19:45:51 +0200524 goto out_unlock;
Julian Wiedmannbcacfcb2018-04-19 12:52:09 +0200525
526 /* add the new address, switch over, drop the old */
527 rc = qeth_l2_send_setmac(card, addr->sa_data);
528 if (rc)
Julian Wiedmann4789a212018-06-29 19:45:51 +0200529 goto out_unlock;
Julian Wiedmannbcacfcb2018-04-19 12:52:09 +0200530 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 Wiedmann4789a212018-06-29 19:45:51 +0200536
537out_unlock:
538 mutex_unlock(&card->conf_mutex);
539 return rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100540}
541
Eugene Crosser0db587b2015-05-18 14:27:55 +0200542static 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 Dmitriyfe5c8022015-10-06 15:12:28 +0200573
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 Wiedmann4641b022017-12-20 20:10:59 +0100579static void qeth_l2_add_mac(struct qeth_card *card, struct netdev_hw_addr *ha)
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200580{
Julian Wiedmanncef6ff222017-08-15 17:02:46 +0200581 u32 mac_hash = get_unaligned((u32 *)(&ha->addr[2]));
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200582 struct qeth_mac *mac;
583
Julian Wiedmanncef6ff222017-08-15 17:02:46 +0200584 hash_for_each_possible(card->mac_htable, mac, hnode, mac_hash) {
Julian Wiedmann99f0b852017-12-20 20:11:01 +0100585 if (ether_addr_equal_64bits(ha->addr, mac->mac_addr)) {
Lakhvich Dmitriy5f78e292016-06-16 16:18:58 +0200586 mac->disp_flag = QETH_DISP_ADDR_DO_NOTHING;
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200587 return;
588 }
589 }
590
591 mac = kzalloc(sizeof(struct qeth_mac), GFP_ATOMIC);
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200592 if (!mac)
593 return;
594
Julian Wiedmann99f0b852017-12-20 20:11:01 +0100595 ether_addr_copy(mac->mac_addr, ha->addr);
Lakhvich Dmitriy5f78e292016-06-16 16:18:58 +0200596 mac->disp_flag = QETH_DISP_ADDR_ADD;
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200597
Julian Wiedmanncef6ff222017-08-15 17:02:46 +0200598 hash_add(card->mac_htable, &mac->hnode, mac_hash);
Eugene Crosser0db587b2015-05-18 14:27:55 +0200599}
600
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200601static void qeth_l2_set_rx_mode(struct net_device *dev)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100602{
Heiko Carstens509e2562008-07-26 02:24:10 -0700603 struct qeth_card *card = dev->ml_priv;
Jiri Pirkoccffad252009-05-22 23:22:17 +0000604 struct netdev_hw_addr *ha;
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200605 struct qeth_mac *mac;
606 struct hlist_node *tmp;
607 int i;
608 int rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100609
610 if (card->info.type == QETH_CARD_TYPE_OSN)
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200611 return;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100612
Carsten Otte847a50f2010-06-21 22:57:05 +0000613 QETH_CARD_TEXT(card, 3, "setmulti");
Ursula Braun8e98ac42009-03-24 20:57:18 +0000614 if (qeth_threads_running(card, QETH_RECOVER_THREAD) &&
615 (card->state != CARD_STATE_UP))
616 return;
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200617
Frank Blaschka4a71df52008-02-15 09:19:42 +0100618 spin_lock_bh(&card->mclock);
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200619
Jiri Pirko22bedad32010-04-01 21:22:57 +0000620 netdev_for_each_mc_addr(ha, dev)
Julian Wiedmann4641b022017-12-20 20:10:59 +0100621 qeth_l2_add_mac(card, ha);
Jiri Pirko32e7bfc2010-01-25 13:36:10 -0800622 netdev_for_each_uc_addr(ha, dev)
Julian Wiedmann4641b022017-12-20 20:10:59 +0100623 qeth_l2_add_mac(card, ha);
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200624
625 hash_for_each_safe(card->mac_htable, i, tmp, mac, hnode) {
Julian Wiedmann00c163f2017-12-20 20:11:02 +0100626 switch (mac->disp_flag) {
627 case QETH_DISP_ADDR_DELETE:
Julian Wiedmann8174aa82017-12-20 20:11:00 +0100628 qeth_l2_remove_mac(card, mac->mac_addr);
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200629 hash_del(&mac->hnode);
630 kfree(mac);
Julian Wiedmann00c163f2017-12-20 20:11:02 +0100631 break;
632 case QETH_DISP_ADDR_ADD:
Julian Wiedmann8174aa82017-12-20 20:11:00 +0100633 rc = qeth_l2_write_mac(card, mac->mac_addr);
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200634 if (rc) {
635 hash_del(&mac->hnode);
636 kfree(mac);
Julian Wiedmann00c163f2017-12-20 20:11:02 +0100637 break;
638 }
639 /* fall through */
640 default:
641 /* for next call to set_rx_mode(): */
Lakhvich Dmitriy5f78e292016-06-16 16:18:58 +0200642 mac->disp_flag = QETH_DISP_ADDR_DELETE;
Julian Wiedmann00c163f2017-12-20 20:11:02 +0100643 }
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200644 }
Frank Blaschka7db22662008-08-15 08:02:59 +0200645
Frank Blaschka4a71df52008-02-15 09:19:42 +0100646 spin_unlock_bh(&card->mclock);
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200647
Eugene Crosser0db587b2015-05-18 14:27:55 +0200648 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 Blaschka4a71df52008-02-15 09:19:42 +0100652}
653
Julian Wiedmann72863842017-08-18 10:19:04 +0200654static int qeth_l2_xmit_osn(struct qeth_card *card, struct sk_buff *skb,
655 struct qeth_qdio_out_q *queue)
656{
Julian Wiedmann69d7ce82018-09-17 17:36:04 +0200657 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 Wiedmann72863842017-08-18 10:19:04 +0200663
664 if (skb->protocol == htons(ETH_P_IPV6))
665 return -EPROTONOSUPPORT;
666
Julian Wiedmann69d7ce82018-09-17 17:36:04 +0200667 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);
685out:
686 if (rc && hd_len)
687 kmem_cache_free(qeth_core_header_cache, hdr);
688 return rc;
Julian Wiedmann72863842017-08-18 10:19:04 +0200689}
690
Julian Wiedmanne38db6b2017-04-11 16:11:14 +0200691static netdev_tx_t qeth_l2_hard_start_xmit(struct sk_buff *skb,
692 struct net_device *dev)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100693{
Heiko Carstens509e2562008-07-26 02:24:10 -0700694 struct qeth_card *card = dev->ml_priv;
Klaus-Dieter Wackerce73e102009-08-26 02:01:08 +0000695 int cast_type = qeth_l2_get_cast_type(card, skb);
Kittipon Meesompop571f9dd82018-04-26 09:42:22 +0200696 int ipv = qeth_get_ip_version(skb);
Stefan Raspl290b8342014-04-28 10:05:08 +0200697 struct qeth_qdio_out_q *queue;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100698 int tx_bytes = skb->len;
Julian Wiedmann72863842017-08-18 10:19:04 +0200699 int rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100700
Julian Wiedmann91cc98f2018-09-26 18:29:16 +0200701 if (card->state != CARD_STATE_UP) {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100702 card->stats.tx_carrier_errors++;
703 goto tx_drop;
704 }
705
Julian Wiedmann86c0cdb2018-07-11 17:42:41 +0200706 queue = qeth_get_tx_queue(card, skb, ipv, cast_type);
707
Frank Blaschka4a71df52008-02-15 09:19:42 +0100708 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 Wiedmann5f89eca2018-07-19 12:43:58 +0200714 if (IS_OSN(card))
Julian Wiedmann72863842017-08-18 10:19:04 +0200715 rc = qeth_l2_xmit_osn(card, skb, queue);
Julian Wiedmann5f89eca2018-07-19 12:43:58 +0200716 else
Julian Wiedmannfc696602018-09-17 17:35:55 +0200717 rc = qeth_xmit(card, skb, queue, ipv, cast_type,
718 qeth_l2_fill_header);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100719
Frank Blaschka4a71df52008-02-15 09:19:42 +0100720 if (!rc) {
721 card->stats.tx_packets++;
722 card->stats.tx_bytes += tx_bytes;
Julian Wiedmann72863842017-08-18 10:19:04 +0200723 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 Blaschka4a71df52008-02-15 09:19:42 +0100731
732tx_drop:
733 card->stats.tx_dropped++;
734 card->stats.tx_errors++;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100735 dev_kfree_skb_any(skb);
Frank Blaschkad0ec0f52008-06-06 12:37:48 +0200736 netif_wake_queue(dev);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100737 return NETDEV_TX_OK;
738}
739
Ursula Braun39423442011-01-12 20:42:24 +0000740static int __qeth_l2_open(struct net_device *dev)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100741{
Heiko Carstens509e2562008-07-26 02:24:10 -0700742 struct qeth_card *card = dev->ml_priv;
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000743 int rc = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100744
Carsten Otte847a50f2010-06-21 22:57:05 +0000745 QETH_CARD_TEXT(card, 4, "qethopen");
Ursula Braun39423442011-01-12 20:42:24 +0000746 if (card->state == CARD_STATE_UP)
747 return rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100748 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 Otte847a50f2010-06-21 22:57:05 +0000753 QETH_CARD_TEXT(card, 4, "nomacadr");
Frank Blaschka4a71df52008-02-15 09:19:42 +0100754 return -EPERM;
755 }
756 card->data.state = CH_STATE_UP;
757 card->state = CARD_STATE_UP;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100758 netif_start_queue(dev);
759
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000760 if (qdio_stop_irq(card->data.ccwdev, 0) >= 0) {
761 napi_enable(&card->napi);
Julian Wiedmann4d19db72018-09-17 17:36:06 +0200762 local_bh_disable();
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000763 napi_schedule(&card->napi);
Julian Wiedmann4d19db72018-09-17 17:36:06 +0200764 /* kick-start the NAPI softirq: */
765 local_bh_enable();
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000766 } else
767 rc = -EIO;
768 return rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100769}
770
Ursula Braun39423442011-01-12 20:42:24 +0000771static 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 Blaschka4a71df52008-02-15 09:19:42 +0100783static int qeth_l2_stop(struct net_device *dev)
784{
Heiko Carstens509e2562008-07-26 02:24:10 -0700785 struct qeth_card *card = dev->ml_priv;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100786
Carsten Otte847a50f2010-06-21 22:57:05 +0000787 QETH_CARD_TEXT(card, 4, "qethstop");
Frank Blaschka4a71df52008-02-15 09:19:42 +0100788 netif_tx_disable(dev);
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000789 if (card->state == CARD_STATE_UP) {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100790 card->state = CARD_STATE_SOFTSETUP;
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +0000791 napi_disable(&card->napi);
792 }
Frank Blaschka4a71df52008-02-15 09:19:42 +0100793 return 0;
794}
795
Julian Wiedmann2d2ebb32017-05-10 19:07:52 +0200796static const struct device_type qeth_l2_devtype = {
797 .name = "qeth_layer2",
798 .groups = qeth_l2_attr_groups,
799};
800
Frank Blaschka4a71df52008-02-15 09:19:42 +0100801static int qeth_l2_probe_device(struct ccwgroup_device *gdev)
802{
803 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
Ursula Braun9111e782017-05-10 19:07:51 +0200804 int rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100805
Julian Wiedmann2d2ebb32017-05-10 19:07:52 +0200806 if (gdev->dev.type == &qeth_generic_devtype) {
807 rc = qeth_l2_create_device_attributes(&gdev->dev);
808 if (rc)
809 return rc;
810 }
Frank Blaschka4a71df52008-02-15 09:19:42 +0100811 INIT_LIST_HEAD(&card->vid_list);
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200812 hash_init(card->mac_htable);
Frank Blaschka1da74b12011-05-12 18:45:02 +0000813 card->info.hwtrap = 0;
Hans Wippelcaa1f0b2017-09-18 21:18:15 +0200814 qeth_l2_vnicc_set_defaults(card);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100815 return 0;
816}
817
818static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)
819{
820 struct qeth_card *card = dev_get_drvdata(&cgdev->dev);
821
Julian Wiedmann2d2ebb32017-05-10 19:07:52 +0200822 if (cgdev->dev.type == &qeth_generic_devtype)
823 qeth_l2_remove_device_attributes(&cgdev->dev);
Ursula Braunf2148562009-05-19 21:38:37 +0000824 qeth_set_allowed_threads(card, 0, 1);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100825 wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0);
826
Ursula Braun70919e22011-02-26 22:41:36 -0800827 if (cgdev->state == CCWGROUP_ONLINE)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100828 qeth_l2_set_offline(cgdev);
Julian Wiedmannd3d1b202018-07-19 12:43:51 +0200829 unregister_netdev(card->dev);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100830}
831
Stephen Hemminger0fc0b732009-09-02 01:03:33 -0700832static const struct ethtool_ops qeth_l2_ethtool_ops = {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100833 .get_link = ethtool_op_get_link,
Frank Blaschka4a71df52008-02-15 09:19:42 +0100834 .get_strings = qeth_core_get_strings,
835 .get_ethtool_stats = qeth_core_get_ethtool_stats,
Ben Hutchingsdf8b4ec2009-10-01 11:24:32 +0000836 .get_sset_count = qeth_core_get_sset_count,
Frank Blaschka4a71df52008-02-15 09:19:42 +0100837 .get_drvinfo = qeth_core_get_drvinfo,
Julian Wiedmann993e19c2017-04-11 16:11:17 +0200838 .get_link_ksettings = qeth_core_ethtool_get_link_ksettings,
Frank Blaschka4a71df52008-02-15 09:19:42 +0100839};
840
Stephen Hemminger0fc0b732009-09-02 01:03:33 -0700841static const struct ethtool_ops qeth_l2_osn_ops = {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100842 .get_strings = qeth_core_get_strings,
843 .get_ethtool_stats = qeth_core_get_ethtool_stats,
Ben Hutchingsdf8b4ec2009-10-01 11:24:32 +0000844 .get_sset_count = qeth_core_get_sset_count,
Frank Blaschka4a71df52008-02-15 09:19:42 +0100845 .get_drvinfo = qeth_core_get_drvinfo,
846};
847
Frank Blaschka3d58cef2009-01-09 03:44:00 +0000848static const struct net_device_ops qeth_l2_netdev_ops = {
Frank Blaschka8403b132009-01-08 10:50:55 -0800849 .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 Wiedmann6d69b1f2017-12-01 10:14:50 +0100853 .ndo_features_check = qeth_features_check,
Frank Blaschka8403b132009-01-08 10:50:55 -0800854 .ndo_validate_addr = eth_validate_addr,
Lakhvich Dmitriyfe5c8022015-10-06 15:12:28 +0200855 .ndo_set_rx_mode = qeth_l2_set_rx_mode,
Julian Wiedmann942d6982017-04-11 16:11:10 +0200856 .ndo_do_ioctl = qeth_do_ioctl,
Frank Blaschka8403b132009-01-08 10:50:55 -0800857 .ndo_set_mac_address = qeth_l2_set_mac_address,
Frank Blaschka8403b132009-01-08 10:50:55 -0800858 .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 Richter8f43fb02016-06-16 16:18:59 +0200861 .ndo_fix_features = qeth_fix_features,
862 .ndo_set_features = qeth_set_features
Frank Blaschka8403b132009-01-08 10:50:55 -0800863};
864
Frank Blaschka4a71df52008-02-15 09:19:42 +0100865static int qeth_l2_setup_netdev(struct qeth_card *card)
866{
Julian Wiedmannd3d1b202018-07-19 12:43:51 +0200867 int rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100868
Julian Wiedmannd3d1b202018-07-19 12:43:51 +0200869 if (card->dev->netdev_ops)
870 return 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100871
Julian Wiedmannd3aacac2018-03-09 18:12:55 +0100872 card->dev->priv_flags |= IFF_UNICAST_FLT;
Frank Blaschka8403b132009-01-08 10:50:55 -0800873 card->dev->netdev_ops = &qeth_l2_netdev_ops;
Julian Wiedmann25e2c342017-05-10 19:07:53 +0200874 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 Wiedmann5f89eca2018-07-19 12:43:58 +0200879 card->dev->needed_headroom = sizeof(struct qeth_hdr);
Julian Wiedmann25e2c342017-05-10 19:07:53 +0200880 }
Julian Wiedmann9400c532017-10-18 17:40:20 +0200881
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 Wiedmann0f342942018-03-09 18:12:54 +0100886
Thomas Richter4d7def22015-09-18 16:06:51 +0200887 if (card->info.type == QETH_CARD_TYPE_OSD && !card->info.guestlan) {
Julian Wiedmann6d69b1f2017-12-01 10:14:50 +0100888 card->dev->features |= NETIF_F_SG;
Thomas Richter8f43fb02016-06-16 16:18:59 +0200889 /* OSA 3S and earlier has no RX/TX support */
Hans Wippel9bdc4412016-06-16 16:19:00 +0200890 if (qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) {
Thomas Richter8f43fb02016-06-16 16:18:59 +0200891 card->dev->hw_features |= NETIF_F_IP_CSUM;
Hans Wippel9bdc4412016-06-16 16:19:00 +0200892 card->dev->vlan_features |= NETIF_F_IP_CSUM;
893 }
Thomas Richter4d7def22015-09-18 16:06:51 +0200894 }
Kittipon Meesompop571f9dd82018-04-26 09:42:22 +0200895 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 Meesompopd7e6ed92018-04-26 09:42:23 +0200899 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 Wiedmann0aef8392018-10-12 17:27:15 +0200904 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 Wiedmann0d6f02d2017-08-18 10:19:10 +0200918
Frank Blaschka4a71df52008-02-15 09:19:42 +0100919 qeth_l2_request_initial_mac(card);
Julian Wiedmannd73ef322017-04-11 16:11:11 +0200920 netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT);
Julian Wiedmannd3d1b202018-07-19 12:43:51 +0200921 rc = register_netdev(card->dev);
922 if (rc)
923 card->dev->netdev_ops = NULL;
924 return rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100925}
926
Thomas Richter4d7def22015-09-18 16:06:51 +0200927static 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 Richter4d7def22015-09-18 16:06:51 +0200932 return 0;
933}
934
Julian Wiedmann521c10e2017-06-06 14:33:45 +0200935static void qeth_l2_trace_features(struct qeth_card *card)
936{
Hans Wippela45b3fa2017-09-18 21:18:14 +0200937 /* Set BridgePort features */
938 QETH_CARD_TEXT(card, 2, "featuSBP");
Julian Wiedmann521c10e2017-06-06 14:33:45 +0200939 QETH_CARD_HEX(card, 2, &card->options.sbp.supported_funcs,
940 sizeof(card->options.sbp.supported_funcs));
Hans Wippela45b3fa2017-09-18 21:18:14 +0200941 /* 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 Wiedmann521c10e2017-06-06 14:33:45 +0200945}
946
Frank Blaschka4a71df52008-02-15 09:19:42 +0100947static 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 Braun9dc48cc2010-07-22 23:15:05 +0000953 mutex_lock(&card->discipline_mutex);
Frank Blaschkac4949f02010-05-11 19:34:47 +0000954 mutex_lock(&card->conf_mutex);
Peter Tiedemannd11ba0c2008-04-01 10:26:58 +0200955 QETH_DBF_TEXT(SETUP, 2, "setonlin");
956 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *));
Frank Blaschka4a71df52008-02-15 09:19:42 +0100957
Frank Blaschka4a71df52008-02-15 09:19:42 +0100958 recover_flag = card->state;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100959 rc = qeth_core_hardsetup_card(card);
960 if (rc) {
Thomas Richter1aec42b2015-01-21 13:39:10 +0100961 QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc);
Ursula Braunaa909222009-11-12 00:11:43 +0000962 rc = -ENODEV;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100963 goto out_remove;
964 }
Eugene Crosserc044dc22014-01-29 09:23:48 +0100965 qeth_bridgeport_query_support(card);
966 if (card->options.sbp.supported_funcs)
967 dev_info(&card->gdev->dev,
Eugene Crosser9c23f4da2015-05-18 14:27:56 +0200968 "The device represents a Bridge Capable Port\n");
Frank Blaschka4a71df52008-02-15 09:19:42 +0100969
Julian Wiedmannd3d1b202018-07-19 12:43:51 +0200970 rc = qeth_l2_setup_netdev(card);
971 if (rc)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100972 goto out_remove;
973
Julian Wiedmannbcacfcb2018-04-19 12:52:09 +0200974 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 Blaschka4a71df52008-02-15 09:19:42 +0100977
Frank Blaschka1da74b12011-05-12 18:45:02 +0000978 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 Wippela45b3fa2017-09-18 21:18:14 +0200985 /* 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 Crosserb4d72c02014-01-14 15:54:11 +0100991 qeth_l2_setup_bridgeport_attrs(card);
992
Frank Blaschka4a71df52008-02-15 09:19:42 +0100993 card->state = CARD_STATE_HARDSETUP;
994 qeth_print_status_message(card);
995
996 /* softsetup */
Peter Tiedemannd11ba0c2008-04-01 10:26:58 +0200997 QETH_DBF_TEXT(SETUP, 2, "softsetp");
Frank Blaschka4a71df52008-02-15 09:19:42 +0100998
Ursula Braun5113fec2010-05-16 21:15:14 +0000999 if ((card->info.type == QETH_CARD_TYPE_OSD) ||
Stefan Raspl0f547612013-01-21 02:30:20 +00001000 (card->info.type == QETH_CARD_TYPE_OSX)) {
Thomas Richter8f43fb02016-06-16 16:18:59 +02001001 rc = qeth_l2_start_ipassists(card);
1002 if (rc)
Stefan Raspl0f547612013-01-21 02:30:20 +00001003 goto out_remove;
Stefan Raspl0f547612013-01-21 02:30:20 +00001004 }
Ursula Braun5113fec2010-05-16 21:15:14 +00001005
Julian Wiedmann9400c532017-10-18 17:40:20 +02001006 if (card->info.type != QETH_CARD_TYPE_OSN)
Ursula Braun70919e22011-02-26 22:41:36 -08001007 qeth_l2_process_vlans(card);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001008
1009 netif_tx_disable(card->dev);
1010
1011 rc = qeth_init_qdio_queues(card);
1012 if (rc) {
Peter Tiedemannd11ba0c2008-04-01 10:26:58 +02001013 QETH_DBF_TEXT_(SETUP, 2, "6err%d", rc);
Ursula Braunaa909222009-11-12 00:11:43 +00001014 rc = -ENODEV;
Frank Blaschka4a71df52008-02-15 09:19:42 +01001015 goto out_remove;
1016 }
1017 card->state = CARD_STATE_SOFTSETUP;
Frank Blaschka4a71df52008-02-15 09:19:42 +01001018
1019 qeth_set_allowed_threads(card, 0xffffffff, 0);
Julian Wiedmannd025da92018-06-29 19:45:54 +02001020
1021 qeth_enable_hw_features(card->dev);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001022 if (recover_flag == CARD_STATE_RECOVER) {
1023 if (recovery_mode &&
1024 card->info.type != QETH_CARD_TYPE_OSN) {
Ursula Braun39423442011-01-12 20:42:24 +00001025 __qeth_l2_open(card->dev);
Julian Wiedmann9aa17df2018-07-11 17:42:40 +02001026 qeth_l2_set_rx_mode(card->dev);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001027 } else {
1028 rtnl_lock();
1029 dev_open(card->dev);
1030 rtnl_unlock();
1031 }
Frank Blaschka4a71df52008-02-15 09:19:42 +01001032 }
1033 /* let user_space know that device is online */
1034 kobject_uevent(&gdev->dev.kobj, KOBJ_CHANGE);
Frank Blaschkac4949f02010-05-11 19:34:47 +00001035 mutex_unlock(&card->conf_mutex);
Ursula Braun9dc48cc2010-07-22 23:15:05 +00001036 mutex_unlock(&card->discipline_mutex);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001037 return 0;
Ursula Braunaa909222009-11-12 00:11:43 +00001038
Frank Blaschka4a71df52008-02-15 09:19:42 +01001039out_remove:
Frank Blaschka4a71df52008-02-15 09:19:42 +01001040 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 Braun22ae2792014-02-24 13:12:06 +01001044 qdio_free(CARD_DDEV(card));
Frank Blaschka4a71df52008-02-15 09:19:42 +01001045 if (recover_flag == CARD_STATE_RECOVER)
1046 card->state = CARD_STATE_RECOVER;
1047 else
1048 card->state = CARD_STATE_DOWN;
Frank Blaschkac4949f02010-05-11 19:34:47 +00001049 mutex_unlock(&card->conf_mutex);
Ursula Braun9dc48cc2010-07-22 23:15:05 +00001050 mutex_unlock(&card->discipline_mutex);
Ursula Braunaa909222009-11-12 00:11:43 +00001051 return rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +01001052}
1053
1054static int qeth_l2_set_online(struct ccwgroup_device *gdev)
1055{
1056 return __qeth_l2_set_online(gdev, 0);
1057}
1058
1059static 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 Braun9dc48cc2010-07-22 23:15:05 +00001066 mutex_lock(&card->discipline_mutex);
Frank Blaschkac4949f02010-05-11 19:34:47 +00001067 mutex_lock(&card->conf_mutex);
Peter Tiedemannd11ba0c2008-04-01 10:26:58 +02001068 QETH_DBF_TEXT(SETUP, 3, "setoffl");
1069 QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *));
Frank Blaschka4a71df52008-02-15 09:19:42 +01001070
Julian Wiedmannd3d1b202018-07-19 12:43:51 +02001071 netif_carrier_off(card->dev);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001072 recover_flag = card->state;
Frank Blaschka1da74b12011-05-12 18:45:02 +00001073 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 Braun0f5623c2008-10-24 11:16:52 +02001077 qeth_l2_stop_card(card, recovery_mode);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001078 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 Tiedemannd11ba0c2008-04-01 10:26:58 +02001084 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc);
Ursula Braun22ae2792014-02-24 13:12:06 +01001085 qdio_free(CARD_DDEV(card));
Frank Blaschka4a71df52008-02-15 09:19:42 +01001086 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 Blaschkac4949f02010-05-11 19:34:47 +00001090 mutex_unlock(&card->conf_mutex);
Ursula Braun9dc48cc2010-07-22 23:15:05 +00001091 mutex_unlock(&card->discipline_mutex);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001092 return 0;
1093}
1094
1095static int qeth_l2_set_offline(struct ccwgroup_device *cgdev)
1096{
1097 return __qeth_l2_set_offline(cgdev, 0);
1098}
1099
1100static int qeth_l2_recover(void *ptr)
1101{
1102 struct qeth_card *card;
1103 int rc = 0;
1104
1105 card = (struct qeth_card *) ptr;
Carsten Otte847a50f2010-06-21 22:57:05 +00001106 QETH_CARD_TEXT(card, 2, "recover1");
Frank Blaschka4a71df52008-02-15 09:19:42 +01001107 if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD))
1108 return 0;
Carsten Otte847a50f2010-06-21 22:57:05 +00001109 QETH_CARD_TEXT(card, 2, "recover2");
Frank Blaschka74eacdb2008-12-25 13:39:49 +01001110 dev_warn(&card->gdev->dev,
1111 "A recovery process has been started for the device\n");
Stefan Raspl65d80132013-04-07 22:19:27 +00001112 qeth_set_recovery_task(card);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001113 __qeth_l2_set_offline(card->gdev, 1);
1114 rc = __qeth_l2_set_online(card->gdev, 1);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001115 if (!rc)
Frank Blaschka74eacdb2008-12-25 13:39:49 +01001116 dev_info(&card->gdev->dev,
1117 "Device successfully recovered!\n");
Ursula Braun28a7e4c2008-09-19 12:56:03 +02001118 else {
Stefan Raspl0f547612013-01-21 02:30:20 +00001119 qeth_close_dev(card);
1120 dev_warn(&card->gdev->dev, "The qeth device driver "
Stefan Raspl2efaf5f2012-10-15 19:21:18 +00001121 "failed to recover an error on the device\n");
Ursula Braun28a7e4c2008-09-19 12:56:03 +02001122 }
Stefan Raspl65d80132013-04-07 22:19:27 +00001123 qeth_clear_recovery_task(card);
Frank Blaschkaa1c3ed42010-09-07 21:14:42 +00001124 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD);
1125 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001126 return 0;
1127}
1128
1129static int __init qeth_l2_init(void)
1130{
Frank Blaschka74eacdb2008-12-25 13:39:49 +01001131 pr_info("register layer 2 discipline\n");
Frank Blaschka4a71df52008-02-15 09:19:42 +01001132 return 0;
1133}
1134
1135static void __exit qeth_l2_exit(void)
1136{
Frank Blaschka74eacdb2008-12-25 13:39:49 +01001137 pr_info("unregister layer 2 discipline\n");
Frank Blaschka4a71df52008-02-15 09:19:42 +01001138}
1139
Frank Blaschkabbcfcdc2009-06-16 10:30:31 +02001140static int qeth_l2_pm_suspend(struct ccwgroup_device *gdev)
1141{
1142 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
1143
Julian Wiedmannd3d1b202018-07-19 12:43:51 +02001144 netif_device_detach(card->dev);
Frank Blaschkabbcfcdc2009-06-16 10:30:31 +02001145 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 Blaschka1da74b12011-05-12 18:45:02 +00001150 if (card->info.hwtrap)
1151 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
Frank Blaschkabbcfcdc2009-06-16 10:30:31 +02001152 __qeth_l2_set_offline(card->gdev, 1);
1153 } else
1154 __qeth_l2_set_offline(card->gdev, 0);
1155 return 0;
1156}
1157
1158static 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 Blaschkabbcfcdc2009-06-16 10:30:31 +02001163 if (card->state == CARD_STATE_RECOVER) {
1164 rc = __qeth_l2_set_online(card->gdev, 1);
1165 if (rc) {
Ursula Braun869da902010-03-08 20:36:56 +00001166 rtnl_lock();
1167 dev_close(card->dev);
1168 rtnl_unlock();
Frank Blaschkabbcfcdc2009-06-16 10:30:31 +02001169 }
1170 } else
1171 rc = __qeth_l2_set_online(card->gdev, 0);
Julian Wiedmann6585ac42018-09-26 18:29:12 +02001172
Frank Blaschkabbcfcdc2009-06-16 10:30:31 +02001173 qeth_set_allowed_threads(card, 0xffffffff, 0);
Julian Wiedmannd3d1b202018-07-19 12:43:51 +02001174 netif_device_attach(card->dev);
Frank Blaschkabbcfcdc2009-06-16 10:30:31 +02001175 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 Crosserc044dc22014-01-29 09:23:48 +01001181/* Returns zero if the command is successfully "consumed" */
1182static int qeth_l2_control_event(struct qeth_card *card,
1183 struct qeth_ipa_cmd *cmd)
1184{
1185 switch (cmd->hdr.command) {
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001186 case IPA_CMD_SETBRIDGEPORT_OSA:
1187 case IPA_CMD_SETBRIDGEPORT_IQD:
Eugene Crosserc044dc22014-01-29 09:23:48 +01001188 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 Ottc041f2d4872012-05-15 18:02:21 +02001202struct qeth_discipline qeth_l2_discipline = {
Julian Wiedmann2d2ebb32017-05-10 19:07:52 +02001203 .devtype = &qeth_l2_devtype,
Julian Wiedmannd73ef322017-04-11 16:11:11 +02001204 .process_rx_buffer = qeth_l2_process_inbound_buffer,
Sebastian Ottc041f2d4872012-05-15 18:02:21 +02001205 .recover = qeth_l2_recover,
1206 .setup = qeth_l2_probe_device,
Frank Blaschka4a71df52008-02-15 09:19:42 +01001207 .remove = qeth_l2_remove_device,
1208 .set_online = qeth_l2_set_online,
1209 .set_offline = qeth_l2_set_offline,
Frank Blaschkabbcfcdc2009-06-16 10:30:31 +02001210 .freeze = qeth_l2_pm_suspend,
1211 .thaw = qeth_l2_pm_resume,
1212 .restore = qeth_l2_pm_resume,
Julian Wiedmann942d6982017-04-11 16:11:10 +02001213 .do_ioctl = NULL,
Eugene Crosserc044dc22014-01-29 09:23:48 +01001214 .control_event_handler = qeth_l2_control_event,
Frank Blaschka4a71df52008-02-15 09:19:42 +01001215};
Sebastian Ottc041f2d4872012-05-15 18:02:21 +02001216EXPORT_SYMBOL_GPL(qeth_l2_discipline);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001217
1218static int qeth_osn_send_control_data(struct qeth_card *card, int len,
1219 struct qeth_cmd_buffer *iob)
1220{
Julian Wiedmann750b1622018-08-09 14:47:59 +02001221 struct qeth_channel *channel = iob->channel;
Frank Blaschka4a71df52008-02-15 09:19:42 +01001222 int rc = 0;
1223
Carsten Otte847a50f2010-06-21 22:57:05 +00001224 QETH_CARD_TEXT(card, 5, "osndctrd");
Frank Blaschka4a71df52008-02-15 09:19:42 +01001225
1226 wait_event(card->wait_q,
Julian Wiedmann750b1622018-08-09 14:47:59 +02001227 atomic_cmpxchg(&channel->irq_pending, 0, 1) == 0);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001228 qeth_prepare_control_data(card, len, iob);
Carsten Otte847a50f2010-06-21 22:57:05 +00001229 QETH_CARD_TEXT(card, 6, "osnoirqp");
Julian Wiedmanned471552018-09-17 17:36:08 +02001230 spin_lock_irq(get_ccwdev_lock(channel->ccwdev));
Julian Wiedmannf15cdaf2018-08-09 14:48:03 +02001231 rc = ccw_device_start_timeout(channel->ccwdev, channel->ccw,
Julian Wiedmanndb71bbb2018-04-19 12:52:10 +02001232 (addr_t) iob, 0, 0, QETH_IPA_TIMEOUT);
Julian Wiedmanned471552018-09-17 17:36:08 +02001233 spin_unlock_irq(get_ccwdev_lock(channel->ccwdev));
Frank Blaschka4a71df52008-02-15 09:19:42 +01001234 if (rc) {
Frank Blaschka14cc21b2008-06-06 12:37:46 +02001235 QETH_DBF_MESSAGE(2, "qeth_osn_send_control_data: "
Frank Blaschka4a71df52008-02-15 09:19:42 +01001236 "ccw_device_start rc = %i\n", rc);
Carsten Otte847a50f2010-06-21 22:57:05 +00001237 QETH_CARD_TEXT_(card, 2, " err%d", rc);
Julian Wiedmann750b1622018-08-09 14:47:59 +02001238 qeth_release_buffer(channel, iob);
1239 atomic_set(&channel->irq_pending, 0);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001240 wake_up(&card->wait_q);
1241 }
1242 return rc;
1243}
1244
1245static 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 Otte847a50f2010-06-21 22:57:05 +00001250 QETH_CARD_TEXT(card, 4, "osndipa");
Frank Blaschka4a71df52008-02-15 09:19:42 +01001251
Julian Wiedmann73657a32018-08-09 14:47:58 +02001252 qeth_prepare_ipa_cmd(card, iob);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001253 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
1262int 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 Blaschka4a71df52008-02-15 09:19:42 +01001266
Frank Blaschka4a71df52008-02-15 09:19:42 +01001267 if (!dev)
1268 return -ENODEV;
Heiko Carstens509e2562008-07-26 02:24:10 -07001269 card = dev->ml_priv;
Frank Blaschka4a71df52008-02-15 09:19:42 +01001270 if (!card)
1271 return -ENODEV;
Carsten Otte847a50f2010-06-21 22:57:05 +00001272 QETH_CARD_TEXT(card, 2, "osnsdmc");
Eugene Crosserc3521252015-01-16 14:05:47 +01001273 if (!qeth_card_hw_is_reachable(card))
Frank Blaschka4a71df52008-02-15 09:19:42 +01001274 return -ENODEV;
1275 iob = qeth_wait_for_buffer(&card->write);
Julian Wiedmannff5caa72018-03-09 18:12:52 +01001276 memcpy(__ipa_cmd(iob), data, data_len);
1277 return qeth_osn_send_ipa_cmd(card, iob, data_len);
Frank Blaschka4a71df52008-02-15 09:19:42 +01001278}
1279EXPORT_SYMBOL(qeth_osn_assist);
1280
1281int 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 Blaschka4a71df52008-02-15 09:19:42 +01001287 *dev = qeth_l2_netdev_by_devno(read_dev_no);
1288 if (*dev == NULL)
1289 return -ENODEV;
Heiko Carstens509e2562008-07-26 02:24:10 -07001290 card = (*dev)->ml_priv;
Frank Blaschka4a71df52008-02-15 09:19:42 +01001291 if (!card)
1292 return -ENODEV;
Carsten Otte847a50f2010-06-21 22:57:05 +00001293 QETH_CARD_TEXT(card, 2, "osnreg");
Frank Blaschka4a71df52008-02-15 09:19:42 +01001294 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}
1300EXPORT_SYMBOL(qeth_osn_register);
1301
1302void qeth_osn_deregister(struct net_device *dev)
1303{
1304 struct qeth_card *card;
1305
Frank Blaschka4a71df52008-02-15 09:19:42 +01001306 if (!dev)
1307 return;
Heiko Carstens509e2562008-07-26 02:24:10 -07001308 card = dev->ml_priv;
Frank Blaschka4a71df52008-02-15 09:19:42 +01001309 if (!card)
1310 return;
Carsten Otte847a50f2010-06-21 22:57:05 +00001311 QETH_CARD_TEXT(card, 2, "osndereg");
Frank Blaschka4a71df52008-02-15 09:19:42 +01001312 card->osn_info.assist_cb = NULL;
1313 card->osn_info.data_cb = NULL;
1314 return;
1315}
1316EXPORT_SYMBOL(qeth_osn_deregister);
1317
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001318/* SETBRIDGEPORT support, async notifications */
1319
Eugene Crosser9f48b9d2014-01-14 15:54:13 +01001320enum 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 */
1337static 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 Crosser9846e702015-09-18 16:06:48 +02001357 snprintf(str[i], sizeof(str[i]), "MAC=%pM",
Thomas Richter4d7def22015-09-18 16:06:51 +02001358 addr_lnid->mac);
Eugene Crosser9f48b9d2014-01-14 15:54:13 +01001359 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 Crosserb4d72c02014-01-14 15:54:11 +01001385struct qeth_bridge_state_data {
1386 struct work_struct worker;
1387 struct qeth_card *card;
1388 struct qeth_sbp_state_change qports;
1389};
1390
1391static 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 Crosserc044dc22014-01-29 09:23:48 +01001429static void qeth_bridge_state_change(struct qeth_card *card,
1430 struct qeth_ipa_cmd *cmd)
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001431{
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 Richter8a593142014-10-22 12:18:03 +02001439 QETH_CARD_TEXT_(card, 2, "BPsz%04x", qports->entry_length);
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001440 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 Crosserb4d72c02014-01-14 15:54:11 +01001455
Eugene Crosser9f48b9d2014-01-14 15:54:13 +01001456struct qeth_bridge_host_data {
1457 struct work_struct worker;
1458 struct qeth_card *card;
1459 struct qeth_ipacmd_addr_change hostevs;
1460};
1461
1462static 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 Crosser9c23f4da2015-05-18 14:27:56 +02001470"Address notification from the Bridge Port stopped %s (%s)\n",
Eugene Crosser9f48b9d2014-01-14 15:54:13 +01001471 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 Crosserc044dc22014-01-29 09:23:48 +01001494static void qeth_bridge_host_event(struct qeth_card *card,
1495 struct qeth_ipa_cmd *cmd)
Eugene Crosser9f48b9d2014-01-14 15:54:13 +01001496{
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 Crosser9f48b9d2014-01-14 15:54:13 +01001527
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001528/* SETBRIDGEPORT support; sending commands */
1529
1530struct _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 */
1550static 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 Crosser9c23f4da2015-05-18 14:27:56 +02001554 int is_iqd = (card->info.type == QETH_CARD_TYPE_IQD);
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001555
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001556 if ((is_iqd && (cbctl->ipa_rc == IPA_RC_SUCCESS)) ||
1557 (!is_iqd && (cbctl->ipa_rc == cbctl->cmd_rc)))
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001558 switch (cbctl->cmd_rc) {
Kittipon Meesompop2063a5f2017-06-20 16:00:31 +02001559 case IPA_RC_SUCCESS:
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001560 rc = 0;
1561 break;
Kittipon Meesompop2063a5f2017-06-20 16:00:31 +02001562 case IPA_RC_L2_UNSUPPORTED_CMD:
1563 case IPA_RC_UNSUPPORTED_COMMAND:
Eugene Crosserffb95252015-05-18 14:27:58 +02001564 rc = -EOPNOTSUPP;
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001565 break;
Kittipon Meesompop2063a5f2017-06-20 16:00:31 +02001566 case IPA_RC_SBP_OSA_NOT_CONFIGURED:
1567 case IPA_RC_SBP_IQD_NOT_CONFIGURED:
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001568 rc = -ENODEV; /* maybe not the best code here? */
1569 dev_err(&card->gdev->dev,
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001570 "The device is not configured as a Bridge Port\n");
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001571 break;
Kittipon Meesompop2063a5f2017-06-20 16:00:31 +02001572 case IPA_RC_SBP_OSA_OS_MISMATCH:
1573 case IPA_RC_SBP_IQD_OS_MISMATCH:
Eugene Crosser1b05cf62016-06-16 16:18:51 +02001574 rc = -EPERM;
1575 dev_err(&card->gdev->dev,
1576 "A Bridge Port is already configured by a different operating system\n");
1577 break;
Kittipon Meesompop2063a5f2017-06-20 16:00:31 +02001578 case IPA_RC_SBP_OSA_ANO_DEV_PRIMARY:
1579 case IPA_RC_SBP_IQD_ANO_DEV_PRIMARY:
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001580 switch (setcmd) {
1581 case IPA_SBP_SET_PRIMARY_BRIDGE_PORT:
1582 rc = -EEXIST;
1583 dev_err(&card->gdev->dev,
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001584 "The LAN already has a primary Bridge Port\n");
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001585 break;
1586 case IPA_SBP_SET_SECONDARY_BRIDGE_PORT:
1587 rc = -EBUSY;
1588 dev_err(&card->gdev->dev,
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001589 "The device is already a primary Bridge Port\n");
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001590 break;
1591 default:
1592 rc = -EIO;
1593 }
1594 break;
Kittipon Meesompop2063a5f2017-06-20 16:00:31 +02001595 case IPA_RC_SBP_OSA_CURRENT_SECOND:
1596 case IPA_RC_SBP_IQD_CURRENT_SECOND:
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001597 rc = -EBUSY;
1598 dev_err(&card->gdev->dev,
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001599 "The device is already a secondary Bridge Port\n");
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001600 break;
Kittipon Meesompop2063a5f2017-06-20 16:00:31 +02001601 case IPA_RC_SBP_OSA_LIMIT_SECOND:
1602 case IPA_RC_SBP_IQD_LIMIT_SECOND:
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001603 rc = -EEXIST;
1604 dev_err(&card->gdev->dev,
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001605 "The LAN cannot have more secondary Bridge Ports\n");
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001606 break;
Kittipon Meesompop2063a5f2017-06-20 16:00:31 +02001607 case IPA_RC_SBP_OSA_CURRENT_PRIMARY:
1608 case IPA_RC_SBP_IQD_CURRENT_PRIMARY:
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001609 rc = -EBUSY;
1610 dev_err(&card->gdev->dev,
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001611 "The device is already a primary Bridge Port\n");
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001612 break;
Kittipon Meesompop2063a5f2017-06-20 16:00:31 +02001613 case IPA_RC_SBP_OSA_NOT_AUTHD_BY_ZMAN:
1614 case IPA_RC_SBP_IQD_NOT_AUTHD_BY_ZMAN:
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001615 rc = -EACCES;
1616 dev_err(&card->gdev->dev,
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001617 "The device is not authorized to be a Bridge Port\n");
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001618 break;
1619 default:
1620 rc = -EIO;
1621 }
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001622 else
1623 switch (cbctl->ipa_rc) {
1624 case IPA_RC_NOTSUPP:
Eugene Crosserffb95252015-05-18 14:27:58 +02001625 rc = -EOPNOTSUPP;
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001626 break;
1627 case IPA_RC_UNSUPPORTED_COMMAND:
Eugene Crosserffb95252015-05-18 14:27:58 +02001628 rc = -EOPNOTSUPP;
Eugene Crosser9c23f4da2015-05-18 14:27:56 +02001629 break;
1630 default:
1631 rc = -EIO;
1632 }
1633
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001634 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 Wiedmannd65626a2017-08-15 17:02:47 +02001641static 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 Crosser9c23f4da2015-05-18 14:27:56 +02001644{
Julian Wiedmannd65626a2017-08-15 17:02:47 +02001645 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 Wiedmannff5caa72018-03-09 18:12:52 +01001654 cmd = __ipa_cmd(iob);
Julian Wiedmannd65626a2017-08-15 17:02:47 +02001655 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 Crosser9c23f4da2015-05-18 14:27:56 +02001661}
1662
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001663static 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 Crosserc044dc22014-01-29 09:23:48 +01001687static void qeth_bridgeport_query_support(struct qeth_card *card)
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001688{
1689 struct qeth_cmd_buffer *iob;
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001690 struct _qeth_sbp_cbctl cbctl;
1691
1692 QETH_CARD_TEXT(card, 2, "brqsuppo");
Julian Wiedmannd65626a2017-08-15 17:02:47 +02001693 iob = qeth_sbp_build_cmd(card, IPA_SBP_QUERY_COMMANDS_SUPPORTED,
1694 sizeof(struct qeth_sbp_query_cmds_supp));
Thomas Richter1aec42b2015-01-21 13:39:10 +01001695 if (!iob)
1696 return;
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001697 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 Crosserb4d72c02014-01-14 15:54:11 +01001707
1708static 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 */
1745int 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 Crosserb4d72c02014-01-14 15:54:11 +01001750 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 Wiedmannd65626a2017-08-15 17:02:47 +02001762 iob = qeth_sbp_build_cmd(card, IPA_SBP_QUERY_BRIDGE_PORTS, 0);
Thomas Richter1aec42b2015-01-21 13:39:10 +01001763 if (!iob)
1764 return -ENOMEM;
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001765 rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_ports_cb,
1766 (void *)&cbctl);
Eugene Crosserc88394e2015-05-18 14:27:53 +02001767 if (rc < 0)
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001768 return rc;
Eugene Crosserc88394e2015-05-18 14:27:53 +02001769 return qeth_bridgeport_makerc(card, &cbctl, IPA_SBP_QUERY_BRIDGE_PORTS);
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001770}
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001771
1772static 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 */
1790int 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 Crosserb4d72c02014-01-14 15:54:11 +01001795 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 Wiedmannd65626a2017-08-15 17:02:47 +02001802 cmdlength = sizeof(struct qeth_sbp_reset_role);
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001803 break;
1804 case QETH_SBP_ROLE_PRIMARY:
1805 setcmd = IPA_SBP_SET_PRIMARY_BRIDGE_PORT;
Julian Wiedmannd65626a2017-08-15 17:02:47 +02001806 cmdlength = sizeof(struct qeth_sbp_set_primary);
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001807 break;
1808 case QETH_SBP_ROLE_SECONDARY:
1809 setcmd = IPA_SBP_SET_SECONDARY_BRIDGE_PORT;
Julian Wiedmannd65626a2017-08-15 17:02:47 +02001810 cmdlength = sizeof(struct qeth_sbp_set_secondary);
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001811 break;
1812 default:
1813 return -EINVAL;
1814 }
1815 if (!(card->options.sbp.supported_funcs & setcmd))
1816 return -EOPNOTSUPP;
Julian Wiedmannd65626a2017-08-15 17:02:47 +02001817 iob = qeth_sbp_build_cmd(card, setcmd, cmdlength);
Thomas Richter1aec42b2015-01-21 13:39:10 +01001818 if (!iob)
1819 return -ENOMEM;
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001820 rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_set_cb,
1821 (void *)&cbctl);
Eugene Crosserc88394e2015-05-18 14:27:53 +02001822 if (rc < 0)
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001823 return rc;
Eugene Crosserc88394e2015-05-18 14:27:53 +02001824 return qeth_bridgeport_makerc(card, &cbctl, setcmd);
Eugene Crosserb4d72c02014-01-14 15:54:11 +01001825}
1826
Eugene Crosser9f48b9d2014-01-14 15:54:13 +01001827/**
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 */
1833static 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 Crosserffb95252015-05-18 14:27:58 +02001845 rc = -EOPNOTSUPP;
Eugene Crosser9f48b9d2014-01-14 15:54:13 +01001846 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
1865static 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 */
1896int 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 Crosser9f48b9d2014-01-14 15:54:13 +01001918
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02001919static 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 Wippela45b3fa2017-09-18 21:18:14 +02001925/* VNIC Characteristics support */
1926
1927/* handle VNICC IPA command return codes; convert to error codes */
1928static 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 */
1960struct _qeth_l2_vnicc_request_cbctl {
1961 u32 sub_cmd;
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02001962 struct {
1963 u32 vnic_char;
Hans Wippel349d13d2017-09-18 21:18:16 +02001964 u32 timeout;
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02001965 } param;
1966 struct {
Hans Wippel349d13d2017-09-18 21:18:16 +02001967 union{
1968 u32 *sup_cmds;
1969 u32 *timeout;
1970 };
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02001971 } result;
Hans Wippela45b3fa2017-09-18 21:18:14 +02001972};
1973
1974/* generic VNICC request call back */
1975static int qeth_l2_vnicc_request_cb(struct qeth_card *card,
1976 struct qeth_reply *reply,
1977 unsigned long data)
1978{
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02001979 struct _qeth_l2_vnicc_request_cbctl *cbctl =
1980 (struct _qeth_l2_vnicc_request_cbctl *) reply->param;
Hans Wippela45b3fa2017-09-18 21:18:14 +02001981 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 Wippelcaa1f0b2017-09-18 21:18:15 +02001991 if (cbctl->sub_cmd == IPA_VNICC_QUERY_CMDS)
1992 *cbctl->result.sup_cmds = rep->query_cmds.sup_cmds;
1993
Hans Wippel349d13d2017-09-18 21:18:16 +02001994 if (cbctl->sub_cmd == IPA_VNICC_GET_TIMEOUT)
1995 *cbctl->result.timeout = rep->getset_timeout.timeout;
1996
Hans Wippela45b3fa2017-09-18 21:18:14 +02001997 return 0;
1998}
1999
2000/* generic VNICC request */
2001static 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 Wiedmannff5caa72018-03-09 18:12:52 +01002017 cmd = __ipa_cmd(iob);
Hans Wippela45b3fa2017-09-18 21:18:14 +02002018 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 Wippelcaa1f0b2017-09-18 21:18:15 +02002028 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 Wippel349d13d2017-09-18 21:18:16 +02002037 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 Wippela45b3fa2017-09-18 21:18:14 +02002044 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 */
2057static 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 Wippelcaa1f0b2017-09-18 21:18:15 +02002068/* VNICC query sub commands request */
2069static 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 */
2084static 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 Wippel349d13d2017-09-18 21:18:16 +02002097/* VNICC get/set timeout for characteristic request */
2098static 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 Wippelcaa1f0b2017-09-18 21:18:15 +02002115/* set current VNICC flag state; called from sysfs store function */
2116int 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 Wippel349d13d2017-09-18 21:18:16 +02002158 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 Wippelcaa1f0b2017-09-18 21:18:15 +02002166
2167 return rc;
2168}
2169
2170/* get current VNICC flag state; called from sysfs show function */
2171int 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 Wippel349d13d2017-09-18 21:18:16 +02002193/* set VNICC timeout; called from sysfs store function. Currently, only learning
2194 * supports timeout
2195 */
2196int 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 */
2233int 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 Wippelcaa1f0b2017-09-18 21:18:15 +02002257/* check if VNICC is currently enabled */
2258bool 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 Wippel349d13d2017-09-18 21:18:16 +02002274/* recover user timeout setting */
2275static 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 Wippelcaa1f0b2017-09-18 21:18:15 +02002287/* recover user characteristic setting */
2288static 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 Wippela45b3fa2017-09-18 21:18:14 +02002302/* (re-)initialize VNICC */
2303static void qeth_l2_vnicc_init(struct qeth_card *card)
2304{
Hans Wippel349d13d2017-09-18 21:18:16 +02002305 u32 *timeout = &card->options.vnicc.learning_timeout;
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02002306 unsigned int chars_len, i;
2307 unsigned long chars_tmp;
2308 u32 sup_cmds, vnicc;
2309 bool enable, error;
2310
Hans Wippela45b3fa2017-09-18 21:18:14 +02002311 QETH_CARD_TEXT(card, 2, "vniccini");
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02002312 /* reset rx_bcast */
2313 card->options.vnicc.rx_bcast_enabled = 0;
Hans Wippela45b3fa2017-09-18 21:18:14 +02002314 /* initial query and storage of VNIC characteristics */
2315 if (qeth_l2_vnicc_query_chars(card)) {
Hans Wippel349d13d2017-09-18 21:18:16 +02002316 if (card->options.vnicc.wanted_chars != QETH_VNICC_DEFAULT ||
2317 *timeout != QETH_VNICC_DEFAULT_TIMEOUT)
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02002318 dev_err(&card->gdev->dev, "Configuring the VNIC characteristics failed\n");
2319 /* fail quietly if user didn't change the default config */
Hans Wippela45b3fa2017-09-18 21:18:14 +02002320 card->options.vnicc.sup_chars = 0;
2321 card->options.vnicc.cur_chars = 0;
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02002322 card->options.vnicc.wanted_chars = QETH_VNICC_DEFAULT;
2323 return;
Hans Wippela45b3fa2017-09-18 21:18:14 +02002324 }
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02002325 /* 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 Wippel349d13d2017-09-18 21:18:16 +02002331 if (!(sup_cmds & IPA_VNICC_SET_TIMEOUT) ||
2332 !(sup_cmds & IPA_VNICC_GET_TIMEOUT))
2333 card->options.vnicc.getset_timeout_sup &= ~vnicc;
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02002334 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 Wippel349d13d2017-09-18 21:18:16 +02002339 error = qeth_l2_vnicc_recover_timeout(card, QETH_VNICC_LEARNING,
2340 timeout);
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02002341 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 */
2354static 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 Wippel349d13d2017-09-18 21:18:16 +02002359 card->options.vnicc.learning_timeout = QETH_VNICC_DEFAULT_TIMEOUT;
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02002360 /* supported commands */
2361 card->options.vnicc.set_char_sup = QETH_VNICC_ALL;
Hans Wippel349d13d2017-09-18 21:18:16 +02002362 card->options.vnicc.getset_timeout_sup = QETH_VNICC_LEARNING;
Hans Wippelcaa1f0b2017-09-18 21:18:15 +02002363 /* settings wanted by users */
2364 card->options.vnicc.wanted_chars = QETH_VNICC_DEFAULT;
Hans Wippela45b3fa2017-09-18 21:18:14 +02002365}
2366
Frank Blaschka4a71df52008-02-15 09:19:42 +01002367module_init(qeth_l2_init);
2368module_exit(qeth_l2_exit);
2369MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
2370MODULE_DESCRIPTION("qeth layer 2 discipline");
2371MODULE_LICENSE("GPL");