blob: 96c73965eb6850512a89074521a04864e4e17d0a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Frank Blaschka4a71df52008-02-15 09:19:42 +01002/*
Frank Blaschka4a71df52008-02-15 09:19:42 +01003 * Copyright IBM Corp. 2007
4 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
5 * Frank Pavlic <fpavlic@de.ibm.com>,
6 * Thomas Spatzier <tspat@de.ibm.com>,
7 * Frank Blaschka <frank.blaschka@de.ibm.com>
8 */
9
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090010#include <linux/slab.h>
Frank Blaschkab3332932011-08-08 01:33:59 +000011#include <asm/ebcdic.h>
Lakhvich Dmitriy5f78e292016-06-16 16:18:58 +020012#include <linux/hashtable.h>
Julian Wiedmann556fd272017-12-20 20:11:09 +010013#include <linux/inet.h>
Frank Blaschka4a71df52008-02-15 09:19:42 +010014#include "qeth_l3.h"
15
16#define QETH_DEVICE_ATTR(_id, _name, _mode, _show, _store) \
17struct device_attribute dev_attr_##_id = __ATTR(_name, _mode, _show, _store)
18
Julian Wiedmann556fd272017-12-20 20:11:09 +010019static int qeth_l3_string_to_ipaddr(const char *buf,
20 enum qeth_prot_versions proto, u8 *addr)
21{
22 const char *end;
23
24 if ((proto == QETH_PROT_IPV4 && !in4_pton(buf, -1, addr, -1, &end)) ||
25 (proto == QETH_PROT_IPV6 && !in6_pton(buf, -1, addr, -1, &end)))
26 return -EINVAL;
27 return 0;
28}
29
Frank Blaschka4a71df52008-02-15 09:19:42 +010030static ssize_t qeth_l3_dev_route_show(struct qeth_card *card,
31 struct qeth_routing_info *route, char *buf)
32{
33 switch (route->type) {
34 case PRIMARY_ROUTER:
35 return sprintf(buf, "%s\n", "primary router");
36 case SECONDARY_ROUTER:
37 return sprintf(buf, "%s\n", "secondary router");
38 case MULTICAST_ROUTER:
39 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
40 return sprintf(buf, "%s\n", "multicast router+");
41 else
42 return sprintf(buf, "%s\n", "multicast router");
43 case PRIMARY_CONNECTOR:
44 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
45 return sprintf(buf, "%s\n", "primary connector+");
46 else
47 return sprintf(buf, "%s\n", "primary connector");
48 case SECONDARY_CONNECTOR:
49 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
50 return sprintf(buf, "%s\n", "secondary connector+");
51 else
52 return sprintf(buf, "%s\n", "secondary connector");
53 default:
54 return sprintf(buf, "%s\n", "no");
55 }
56}
57
58static ssize_t qeth_l3_dev_route4_show(struct device *dev,
59 struct device_attribute *attr, char *buf)
60{
61 struct qeth_card *card = dev_get_drvdata(dev);
62
Frank Blaschka4a71df52008-02-15 09:19:42 +010063 return qeth_l3_dev_route_show(card, &card->options.route4, buf);
64}
65
66static ssize_t qeth_l3_dev_route_store(struct qeth_card *card,
67 struct qeth_routing_info *route, enum qeth_prot_versions prot,
68 const char *buf, size_t count)
69{
70 enum qeth_routing_types old_route_type = route->type;
Frank Blaschkac4949f02010-05-11 19:34:47 +000071 int rc = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +010072
Frank Blaschkac4949f02010-05-11 19:34:47 +000073 mutex_lock(&card->conf_mutex);
Eugene Crosser7e846d6b2015-01-16 14:05:48 +010074 if (sysfs_streq(buf, "no_router")) {
Frank Blaschka4a71df52008-02-15 09:19:42 +010075 route->type = NO_ROUTER;
Eugene Crosser7e846d6b2015-01-16 14:05:48 +010076 } else if (sysfs_streq(buf, "primary_connector")) {
Frank Blaschka4a71df52008-02-15 09:19:42 +010077 route->type = PRIMARY_CONNECTOR;
Eugene Crosser7e846d6b2015-01-16 14:05:48 +010078 } else if (sysfs_streq(buf, "secondary_connector")) {
Frank Blaschka4a71df52008-02-15 09:19:42 +010079 route->type = SECONDARY_CONNECTOR;
Eugene Crosser7e846d6b2015-01-16 14:05:48 +010080 } else if (sysfs_streq(buf, "primary_router")) {
Frank Blaschka4a71df52008-02-15 09:19:42 +010081 route->type = PRIMARY_ROUTER;
Eugene Crosser7e846d6b2015-01-16 14:05:48 +010082 } else if (sysfs_streq(buf, "secondary_router")) {
Frank Blaschka4a71df52008-02-15 09:19:42 +010083 route->type = SECONDARY_ROUTER;
Eugene Crosser7e846d6b2015-01-16 14:05:48 +010084 } else if (sysfs_streq(buf, "multicast_router")) {
Frank Blaschka4a71df52008-02-15 09:19:42 +010085 route->type = MULTICAST_ROUTER;
86 } else {
Frank Blaschkac4949f02010-05-11 19:34:47 +000087 rc = -EINVAL;
88 goto out;
Frank Blaschka4a71df52008-02-15 09:19:42 +010089 }
Eugene Crosserc3521252015-01-16 14:05:47 +010090 if (qeth_card_hw_is_reachable(card) &&
Frank Blaschka4a71df52008-02-15 09:19:42 +010091 (old_route_type != route->type)) {
92 if (prot == QETH_PROT_IPV4)
93 rc = qeth_l3_setrouting_v4(card);
94 else if (prot == QETH_PROT_IPV6)
95 rc = qeth_l3_setrouting_v6(card);
96 }
Frank Blaschkac4949f02010-05-11 19:34:47 +000097out:
Stefan Raspl82e2e782013-03-18 20:04:43 +000098 if (rc)
99 route->type = old_route_type;
Frank Blaschkac4949f02010-05-11 19:34:47 +0000100 mutex_unlock(&card->conf_mutex);
101 return rc ? rc : count;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100102}
103
104static ssize_t qeth_l3_dev_route4_store(struct device *dev,
105 struct device_attribute *attr, const char *buf, size_t count)
106{
107 struct qeth_card *card = dev_get_drvdata(dev);
108
Frank Blaschka4a71df52008-02-15 09:19:42 +0100109 return qeth_l3_dev_route_store(card, &card->options.route4,
110 QETH_PROT_IPV4, buf, count);
111}
112
113static DEVICE_ATTR(route4, 0644, qeth_l3_dev_route4_show,
114 qeth_l3_dev_route4_store);
115
116static ssize_t qeth_l3_dev_route6_show(struct device *dev,
117 struct device_attribute *attr, char *buf)
118{
119 struct qeth_card *card = dev_get_drvdata(dev);
120
Frank Blaschka4a71df52008-02-15 09:19:42 +0100121 return qeth_l3_dev_route_show(card, &card->options.route6, buf);
122}
123
124static ssize_t qeth_l3_dev_route6_store(struct device *dev,
125 struct device_attribute *attr, const char *buf, size_t count)
126{
127 struct qeth_card *card = dev_get_drvdata(dev);
128
Frank Blaschka4a71df52008-02-15 09:19:42 +0100129 return qeth_l3_dev_route_store(card, &card->options.route6,
130 QETH_PROT_IPV6, buf, count);
131}
132
133static DEVICE_ATTR(route6, 0644, qeth_l3_dev_route6_show,
134 qeth_l3_dev_route6_store);
135
136static ssize_t qeth_l3_dev_fake_broadcast_show(struct device *dev,
137 struct device_attribute *attr, char *buf)
138{
139 struct qeth_card *card = dev_get_drvdata(dev);
140
Frank Blaschka4a71df52008-02-15 09:19:42 +0100141 return sprintf(buf, "%i\n", card->options.fake_broadcast? 1:0);
142}
143
144static ssize_t qeth_l3_dev_fake_broadcast_store(struct device *dev,
145 struct device_attribute *attr, const char *buf, size_t count)
146{
147 struct qeth_card *card = dev_get_drvdata(dev);
148 char *tmp;
Frank Blaschkac4949f02010-05-11 19:34:47 +0000149 int i, rc = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100150
Frank Blaschkac4949f02010-05-11 19:34:47 +0000151 mutex_lock(&card->conf_mutex);
Julian Wiedmannd7d543f2019-02-28 18:59:36 +0100152 if (card->state != CARD_STATE_DOWN) {
Frank Blaschkac4949f02010-05-11 19:34:47 +0000153 rc = -EPERM;
154 goto out;
155 }
Frank Blaschka4a71df52008-02-15 09:19:42 +0100156
157 i = simple_strtoul(buf, &tmp, 16);
158 if ((i == 0) || (i == 1))
159 card->options.fake_broadcast = i;
Frank Blaschkac4949f02010-05-11 19:34:47 +0000160 else
161 rc = -EINVAL;
162out:
163 mutex_unlock(&card->conf_mutex);
164 return rc ? rc : count;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100165}
166
167static DEVICE_ATTR(fake_broadcast, 0644, qeth_l3_dev_fake_broadcast_show,
168 qeth_l3_dev_fake_broadcast_store);
169
Ursula Braun76b11f82010-01-11 02:50:50 +0000170static ssize_t qeth_l3_dev_sniffer_show(struct device *dev,
171 struct device_attribute *attr, char *buf)
172{
173 struct qeth_card *card = dev_get_drvdata(dev);
174
Ursula Braun76b11f82010-01-11 02:50:50 +0000175 return sprintf(buf, "%i\n", card->options.sniffer ? 1 : 0);
176}
177
178static ssize_t qeth_l3_dev_sniffer_store(struct device *dev,
179 struct device_attribute *attr, const char *buf, size_t count)
180{
181 struct qeth_card *card = dev_get_drvdata(dev);
Frank Blaschkac4949f02010-05-11 19:34:47 +0000182 int rc = 0;
Ursula Braun76b11f82010-01-11 02:50:50 +0000183 unsigned long i;
184
Julian Wiedmann379ac992019-04-25 18:25:57 +0200185 if (!IS_IQD(card))
Ursula Braun76b11f82010-01-11 02:50:50 +0000186 return -EPERM;
Frank Blaschkab3332932011-08-08 01:33:59 +0000187 if (card->options.cq == QETH_CQ_ENABLED)
188 return -EPERM;
Ursula Braun76b11f82010-01-11 02:50:50 +0000189
Frank Blaschkac4949f02010-05-11 19:34:47 +0000190 mutex_lock(&card->conf_mutex);
Julian Wiedmannd7d543f2019-02-28 18:59:36 +0100191 if (card->state != CARD_STATE_DOWN) {
Frank Blaschkac4949f02010-05-11 19:34:47 +0000192 rc = -EPERM;
193 goto out;
194 }
Ursula Braun76b11f82010-01-11 02:50:50 +0000195
Jingoo Han01787222013-07-22 10:18:15 +0900196 rc = kstrtoul(buf, 16, &i);
Frank Blaschkac4949f02010-05-11 19:34:47 +0000197 if (rc) {
198 rc = -EINVAL;
199 goto out;
200 }
Ursula Braun76b11f82010-01-11 02:50:50 +0000201 switch (i) {
202 case 0:
203 card->options.sniffer = i;
204 break;
205 case 1:
Frank Blaschkac4949f02010-05-11 19:34:47 +0000206 qdio_get_ssqd_desc(CARD_DDEV(card), &card->ssqd);
Julian Wiedmann1917b472019-10-23 10:03:23 +0200207 if (card->ssqd.qdioac2 & CHSC_AC2_SNIFFER_AVAILABLE) {
Ursula Braun76b11f82010-01-11 02:50:50 +0000208 card->options.sniffer = i;
209 if (card->qdio.init_pool.buf_count !=
210 QETH_IN_BUF_COUNT_MAX)
211 qeth_realloc_buffer_pool(card,
212 QETH_IN_BUF_COUNT_MAX);
Ursula Braun76b11f82010-01-11 02:50:50 +0000213 } else
Frank Blaschkac4949f02010-05-11 19:34:47 +0000214 rc = -EPERM;
Ursula Braun6cc31d02011-11-15 02:31:12 +0000215 break;
216 default:
Frank Blaschkac4949f02010-05-11 19:34:47 +0000217 rc = -EINVAL;
Ursula Braun76b11f82010-01-11 02:50:50 +0000218 }
Frank Blaschkac4949f02010-05-11 19:34:47 +0000219out:
220 mutex_unlock(&card->conf_mutex);
221 return rc ? rc : count;
Ursula Braun76b11f82010-01-11 02:50:50 +0000222}
223
224static DEVICE_ATTR(sniffer, 0644, qeth_l3_dev_sniffer_show,
225 qeth_l3_dev_sniffer_store);
226
Frank Blaschkab3332932011-08-08 01:33:59 +0000227static ssize_t qeth_l3_dev_hsuid_show(struct device *dev,
228 struct device_attribute *attr, char *buf)
229{
230 struct qeth_card *card = dev_get_drvdata(dev);
231 char tmp_hsuid[9];
232
Julian Wiedmann379ac992019-04-25 18:25:57 +0200233 if (!IS_IQD(card))
Frank Blaschkab3332932011-08-08 01:33:59 +0000234 return -EPERM;
235
Frank Blaschkab3332932011-08-08 01:33:59 +0000236 memcpy(tmp_hsuid, card->options.hsuid, sizeof(tmp_hsuid));
237 EBCASC(tmp_hsuid, 8);
238 return sprintf(buf, "%s\n", tmp_hsuid);
239}
240
241static ssize_t qeth_l3_dev_hsuid_store(struct device *dev,
242 struct device_attribute *attr, const char *buf, size_t count)
243{
244 struct qeth_card *card = dev_get_drvdata(dev);
Frank Blaschkab3332932011-08-08 01:33:59 +0000245 char *tmp;
Julian Wiedmann1617dae2018-03-09 18:13:02 +0100246 int rc;
Frank Blaschkab3332932011-08-08 01:33:59 +0000247
Julian Wiedmann379ac992019-04-25 18:25:57 +0200248 if (!IS_IQD(card))
Frank Blaschkab3332932011-08-08 01:33:59 +0000249 return -EPERM;
Julian Wiedmannd7d543f2019-02-28 18:59:36 +0100250 if (card->state != CARD_STATE_DOWN)
Frank Blaschkab3332932011-08-08 01:33:59 +0000251 return -EPERM;
252 if (card->options.sniffer)
253 return -EPERM;
254 if (card->options.cq == QETH_CQ_NOTAVAILABLE)
255 return -EPERM;
256
257 tmp = strsep((char **)&buf, "\n");
258 if (strlen(tmp) > 8)
259 return -EINVAL;
260
Julian Wiedmann1617dae2018-03-09 18:13:02 +0100261 if (card->options.hsuid[0])
Frank Blaschkab3332932011-08-08 01:33:59 +0000262 /* delete old ip address */
Julian Wiedmann1617dae2018-03-09 18:13:02 +0100263 qeth_l3_modify_hsuid(card, false);
Frank Blaschkab3332932011-08-08 01:33:59 +0000264
265 if (strlen(tmp) == 0) {
266 /* delete ip address only */
267 card->options.hsuid[0] = '\0';
Julian Wiedmannd3d1b202018-07-19 12:43:51 +0200268 memcpy(card->dev->perm_addr, card->options.hsuid, 9);
Frank Blaschkab3332932011-08-08 01:33:59 +0000269 qeth_configure_cq(card, QETH_CQ_DISABLED);
270 return count;
271 }
272
273 if (qeth_configure_cq(card, QETH_CQ_ENABLED))
274 return -EPERM;
275
Kees Cook096a8aa2013-07-03 15:04:55 -0700276 snprintf(card->options.hsuid, sizeof(card->options.hsuid),
277 "%-8s", tmp);
Frank Blaschkab3332932011-08-08 01:33:59 +0000278 ASCEBC(card->options.hsuid, 8);
Julian Wiedmannd3d1b202018-07-19 12:43:51 +0200279 memcpy(card->dev->perm_addr, card->options.hsuid, 9);
Frank Blaschkab3332932011-08-08 01:33:59 +0000280
Julian Wiedmann1617dae2018-03-09 18:13:02 +0100281 rc = qeth_l3_modify_hsuid(card, true);
Frank Blaschkab3332932011-08-08 01:33:59 +0000282
Julian Wiedmannb9ea5252017-12-27 17:44:28 +0100283 return rc ? rc : count;
Frank Blaschkab3332932011-08-08 01:33:59 +0000284}
285
286static DEVICE_ATTR(hsuid, 0644, qeth_l3_dev_hsuid_show,
287 qeth_l3_dev_hsuid_store);
288
289
Frank Blaschka4a71df52008-02-15 09:19:42 +0100290static struct attribute *qeth_l3_device_attrs[] = {
291 &dev_attr_route4.attr,
292 &dev_attr_route6.attr,
293 &dev_attr_fake_broadcast.attr,
Ursula Braun76b11f82010-01-11 02:50:50 +0000294 &dev_attr_sniffer.attr,
Frank Blaschkab3332932011-08-08 01:33:59 +0000295 &dev_attr_hsuid.attr,
Frank Blaschka4a71df52008-02-15 09:19:42 +0100296 NULL,
297};
298
Arvind Yadavcfe9a042017-07-19 12:39:14 +0530299static const struct attribute_group qeth_l3_device_attr_group = {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100300 .attrs = qeth_l3_device_attrs,
301};
302
303static ssize_t qeth_l3_dev_ipato_enable_show(struct device *dev,
304 struct device_attribute *attr, char *buf)
305{
306 struct qeth_card *card = dev_get_drvdata(dev);
307
Frank Blaschka4a71df52008-02-15 09:19:42 +0100308 return sprintf(buf, "%i\n", card->ipato.enabled? 1:0);
309}
310
311static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
312 struct device_attribute *attr, const char *buf, size_t count)
313{
314 struct qeth_card *card = dev_get_drvdata(dev);
Julian Wiedmann7fbd9492017-12-13 18:56:29 +0100315 bool enable;
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100316 int rc = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100317
Frank Blaschkac4949f02010-05-11 19:34:47 +0000318 mutex_lock(&card->conf_mutex);
Julian Wiedmannd7d543f2019-02-28 18:59:36 +0100319 if (card->state != CARD_STATE_DOWN) {
Frank Blaschkac4949f02010-05-11 19:34:47 +0000320 rc = -EPERM;
321 goto out;
322 }
Frank Blaschka4a71df52008-02-15 09:19:42 +0100323
Eugene Crosser7e846d6b2015-01-16 14:05:48 +0100324 if (sysfs_streq(buf, "toggle")) {
Julian Wiedmann7fbd9492017-12-13 18:56:29 +0100325 enable = !card->ipato.enabled;
326 } else if (kstrtobool(buf, &enable)) {
Frank Blaschkac4949f02010-05-11 19:34:47 +0000327 rc = -EINVAL;
Julian Wiedmann7fbd9492017-12-13 18:56:29 +0100328 goto out;
329 }
330
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100331 if (card->ipato.enabled != enable) {
332 card->ipato.enabled = enable;
Julian Wiedmanndf2a2a52019-03-28 16:39:23 +0100333 mutex_lock(&card->ip_lock);
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100334 qeth_l3_update_ipato(card);
Julian Wiedmanndf2a2a52019-03-28 16:39:23 +0100335 mutex_unlock(&card->ip_lock);
Julian Wiedmann7fbd9492017-12-13 18:56:29 +0100336 }
Frank Blaschkac4949f02010-05-11 19:34:47 +0000337out:
338 mutex_unlock(&card->conf_mutex);
339 return rc ? rc : count;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100340}
341
342static QETH_DEVICE_ATTR(ipato_enable, enable, 0644,
343 qeth_l3_dev_ipato_enable_show,
344 qeth_l3_dev_ipato_enable_store);
345
346static ssize_t qeth_l3_dev_ipato_invert4_show(struct device *dev,
347 struct device_attribute *attr, char *buf)
348{
349 struct qeth_card *card = dev_get_drvdata(dev);
350
Frank Blaschka4a71df52008-02-15 09:19:42 +0100351 return sprintf(buf, "%i\n", card->ipato.invert4? 1:0);
352}
353
354static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev,
355 struct device_attribute *attr,
356 const char *buf, size_t count)
357{
358 struct qeth_card *card = dev_get_drvdata(dev);
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100359 bool invert;
Frank Blaschkac4949f02010-05-11 19:34:47 +0000360 int rc = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100361
Frank Blaschkac4949f02010-05-11 19:34:47 +0000362 mutex_lock(&card->conf_mutex);
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100363 if (sysfs_streq(buf, "toggle")) {
364 invert = !card->ipato.invert4;
365 } else if (kstrtobool(buf, &invert)) {
Frank Blaschkac4949f02010-05-11 19:34:47 +0000366 rc = -EINVAL;
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100367 goto out;
368 }
369
370 if (card->ipato.invert4 != invert) {
371 card->ipato.invert4 = invert;
Julian Wiedmanndf2a2a52019-03-28 16:39:23 +0100372 mutex_lock(&card->ip_lock);
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100373 qeth_l3_update_ipato(card);
Julian Wiedmanndf2a2a52019-03-28 16:39:23 +0100374 mutex_unlock(&card->ip_lock);
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100375 }
376out:
Frank Blaschkac4949f02010-05-11 19:34:47 +0000377 mutex_unlock(&card->conf_mutex);
378 return rc ? rc : count;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100379}
380
381static QETH_DEVICE_ATTR(ipato_invert4, invert4, 0644,
382 qeth_l3_dev_ipato_invert4_show,
383 qeth_l3_dev_ipato_invert4_store);
384
385static ssize_t qeth_l3_dev_ipato_add_show(char *buf, struct qeth_card *card,
386 enum qeth_prot_versions proto)
387{
388 struct qeth_ipato_entry *ipatoe;
Julian Wiedmanne6b1b7d2019-12-18 17:34:44 +0100389 int str_len = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100390
Julian Wiedmanndf2a2a52019-03-28 16:39:23 +0100391 mutex_lock(&card->ip_lock);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100392 list_for_each_entry(ipatoe, &card->ipato.entries, entry) {
Julian Wiedmanne6b1b7d2019-12-18 17:34:44 +0100393 char addr_str[40];
394 int entry_len;
395
Frank Blaschka4a71df52008-02-15 09:19:42 +0100396 if (ipatoe->proto != proto)
397 continue;
Julian Wiedmanne6b1b7d2019-12-18 17:34:44 +0100398
399 entry_len = qeth_l3_ipaddr_to_string(proto, ipatoe->addr,
400 addr_str);
401 if (entry_len < 0)
402 continue;
403
404 /* Append /%mask to the entry: */
405 entry_len += 1 + ((proto == QETH_PROT_IPV4) ? 2 : 3);
406 /* Enough room to format %entry\n into null terminated page? */
407 if (entry_len + 1 > PAGE_SIZE - str_len - 1)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100408 break;
Julian Wiedmanne6b1b7d2019-12-18 17:34:44 +0100409
410 entry_len = scnprintf(buf, PAGE_SIZE - str_len,
411 "%s/%i\n", addr_str, ipatoe->mask_bits);
412 str_len += entry_len;
413 buf += entry_len;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100414 }
Julian Wiedmanndf2a2a52019-03-28 16:39:23 +0100415 mutex_unlock(&card->ip_lock);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100416
Julian Wiedmanne6b1b7d2019-12-18 17:34:44 +0100417 return str_len ? str_len : scnprintf(buf, PAGE_SIZE, "\n");
Frank Blaschka4a71df52008-02-15 09:19:42 +0100418}
419
420static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev,
421 struct device_attribute *attr, char *buf)
422{
423 struct qeth_card *card = dev_get_drvdata(dev);
424
Frank Blaschka4a71df52008-02-15 09:19:42 +0100425 return qeth_l3_dev_ipato_add_show(buf, card, QETH_PROT_IPV4);
426}
427
428static int qeth_l3_parse_ipatoe(const char *buf, enum qeth_prot_versions proto,
429 u8 *addr, int *mask_bits)
430{
431 const char *start, *end;
432 char *tmp;
433 char buffer[40] = {0, };
434
435 start = buf;
436 /* get address string */
437 end = strchr(start, '/');
438 if (!end || (end - start >= 40)) {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100439 return -EINVAL;
440 }
441 strncpy(buffer, start, end - start);
442 if (qeth_l3_string_to_ipaddr(buffer, proto, addr)) {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100443 return -EINVAL;
444 }
445 start = end + 1;
446 *mask_bits = simple_strtoul(start, &tmp, 10);
447 if (!strlen(start) ||
448 (tmp == start) ||
449 (*mask_bits > ((proto == QETH_PROT_IPV4) ? 32 : 128))) {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100450 return -EINVAL;
451 }
452 return 0;
453}
454
455static ssize_t qeth_l3_dev_ipato_add_store(const char *buf, size_t count,
456 struct qeth_card *card, enum qeth_prot_versions proto)
457{
458 struct qeth_ipato_entry *ipatoe;
459 u8 addr[16];
460 int mask_bits;
Frank Blaschkac4949f02010-05-11 19:34:47 +0000461 int rc = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100462
463 rc = qeth_l3_parse_ipatoe(buf, proto, addr, &mask_bits);
464 if (rc)
Julian Wiedmann23901662019-12-18 17:34:45 +0100465 return rc;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100466
467 ipatoe = kzalloc(sizeof(struct qeth_ipato_entry), GFP_KERNEL);
Julian Wiedmann23901662019-12-18 17:34:45 +0100468 if (!ipatoe)
469 return -ENOMEM;
470
Frank Blaschka4a71df52008-02-15 09:19:42 +0100471 ipatoe->proto = proto;
472 memcpy(ipatoe->addr, addr, (proto == QETH_PROT_IPV4)? 4:16);
473 ipatoe->mask_bits = mask_bits;
474
475 rc = qeth_l3_add_ipato_entry(card, ipatoe);
Frank Blaschkac4949f02010-05-11 19:34:47 +0000476 if (rc)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100477 kfree(ipatoe);
Julian Wiedmann23901662019-12-18 17:34:45 +0100478
Frank Blaschkac4949f02010-05-11 19:34:47 +0000479 return rc ? rc : count;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100480}
481
482static ssize_t qeth_l3_dev_ipato_add4_store(struct device *dev,
483 struct device_attribute *attr, const char *buf, size_t count)
484{
485 struct qeth_card *card = dev_get_drvdata(dev);
486
Frank Blaschka4a71df52008-02-15 09:19:42 +0100487 return qeth_l3_dev_ipato_add_store(buf, count, card, QETH_PROT_IPV4);
488}
489
490static QETH_DEVICE_ATTR(ipato_add4, add4, 0644,
491 qeth_l3_dev_ipato_add4_show,
492 qeth_l3_dev_ipato_add4_store);
493
494static ssize_t qeth_l3_dev_ipato_del_store(const char *buf, size_t count,
495 struct qeth_card *card, enum qeth_prot_versions proto)
496{
497 u8 addr[16];
498 int mask_bits;
Frank Blaschkac4949f02010-05-11 19:34:47 +0000499 int rc = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100500
501 rc = qeth_l3_parse_ipatoe(buf, proto, addr, &mask_bits);
Frank Blaschkac4949f02010-05-11 19:34:47 +0000502 if (!rc)
Julian Wiedmannb9ea5252017-12-27 17:44:28 +0100503 rc = qeth_l3_del_ipato_entry(card, proto, addr, mask_bits);
Frank Blaschkac4949f02010-05-11 19:34:47 +0000504 return rc ? rc : count;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100505}
506
507static ssize_t qeth_l3_dev_ipato_del4_store(struct device *dev,
508 struct device_attribute *attr, const char *buf, size_t count)
509{
510 struct qeth_card *card = dev_get_drvdata(dev);
511
Frank Blaschka4a71df52008-02-15 09:19:42 +0100512 return qeth_l3_dev_ipato_del_store(buf, count, card, QETH_PROT_IPV4);
513}
514
515static QETH_DEVICE_ATTR(ipato_del4, del4, 0200, NULL,
516 qeth_l3_dev_ipato_del4_store);
517
518static ssize_t qeth_l3_dev_ipato_invert6_show(struct device *dev,
519 struct device_attribute *attr, char *buf)
520{
521 struct qeth_card *card = dev_get_drvdata(dev);
522
Frank Blaschka4a71df52008-02-15 09:19:42 +0100523 return sprintf(buf, "%i\n", card->ipato.invert6? 1:0);
524}
525
526static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev,
527 struct device_attribute *attr, const char *buf, size_t count)
528{
529 struct qeth_card *card = dev_get_drvdata(dev);
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100530 bool invert;
Frank Blaschkac4949f02010-05-11 19:34:47 +0000531 int rc = 0;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100532
Frank Blaschkac4949f02010-05-11 19:34:47 +0000533 mutex_lock(&card->conf_mutex);
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100534 if (sysfs_streq(buf, "toggle")) {
535 invert = !card->ipato.invert6;
536 } else if (kstrtobool(buf, &invert)) {
Frank Blaschkac4949f02010-05-11 19:34:47 +0000537 rc = -EINVAL;
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100538 goto out;
539 }
540
541 if (card->ipato.invert6 != invert) {
542 card->ipato.invert6 = invert;
Julian Wiedmanndf2a2a52019-03-28 16:39:23 +0100543 mutex_lock(&card->ip_lock);
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100544 qeth_l3_update_ipato(card);
Julian Wiedmanndf2a2a52019-03-28 16:39:23 +0100545 mutex_unlock(&card->ip_lock);
Julian Wiedmann02f510f2017-12-13 18:56:32 +0100546 }
547out:
Frank Blaschkac4949f02010-05-11 19:34:47 +0000548 mutex_unlock(&card->conf_mutex);
549 return rc ? rc : count;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100550}
551
552static QETH_DEVICE_ATTR(ipato_invert6, invert6, 0644,
553 qeth_l3_dev_ipato_invert6_show,
554 qeth_l3_dev_ipato_invert6_store);
555
556
557static ssize_t qeth_l3_dev_ipato_add6_show(struct device *dev,
558 struct device_attribute *attr, char *buf)
559{
560 struct qeth_card *card = dev_get_drvdata(dev);
561
Frank Blaschka4a71df52008-02-15 09:19:42 +0100562 return qeth_l3_dev_ipato_add_show(buf, card, QETH_PROT_IPV6);
563}
564
565static ssize_t qeth_l3_dev_ipato_add6_store(struct device *dev,
566 struct device_attribute *attr, const char *buf, size_t count)
567{
568 struct qeth_card *card = dev_get_drvdata(dev);
569
Frank Blaschka4a71df52008-02-15 09:19:42 +0100570 return qeth_l3_dev_ipato_add_store(buf, count, card, QETH_PROT_IPV6);
571}
572
573static QETH_DEVICE_ATTR(ipato_add6, add6, 0644,
574 qeth_l3_dev_ipato_add6_show,
575 qeth_l3_dev_ipato_add6_store);
576
577static ssize_t qeth_l3_dev_ipato_del6_store(struct device *dev,
578 struct device_attribute *attr, const char *buf, size_t count)
579{
580 struct qeth_card *card = dev_get_drvdata(dev);
581
Frank Blaschka4a71df52008-02-15 09:19:42 +0100582 return qeth_l3_dev_ipato_del_store(buf, count, card, QETH_PROT_IPV6);
583}
584
585static QETH_DEVICE_ATTR(ipato_del6, del6, 0200, NULL,
586 qeth_l3_dev_ipato_del6_store);
587
588static struct attribute *qeth_ipato_device_attrs[] = {
589 &dev_attr_ipato_enable.attr,
590 &dev_attr_ipato_invert4.attr,
591 &dev_attr_ipato_add4.attr,
592 &dev_attr_ipato_del4.attr,
593 &dev_attr_ipato_invert6.attr,
594 &dev_attr_ipato_add6.attr,
595 &dev_attr_ipato_del6.attr,
596 NULL,
597};
598
Arvind Yadavcfe9a042017-07-19 12:39:14 +0530599static const struct attribute_group qeth_device_ipato_group = {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100600 .name = "ipa_takeover",
601 .attrs = qeth_ipato_device_attrs,
602};
603
Julian Wiedmannd2073ef2017-12-27 17:44:29 +0100604static ssize_t qeth_l3_dev_ip_add_show(struct device *dev, char *buf,
605 enum qeth_prot_versions proto,
606 enum qeth_ip_types type)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100607{
Julian Wiedmannd2073ef2017-12-27 17:44:29 +0100608 struct qeth_card *card = dev_get_drvdata(dev);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100609 struct qeth_ipaddr *ipaddr;
Ursula Braune48b9ea2017-01-12 15:48:43 +0100610 int str_len = 0;
Ursula Braune48b9ea2017-01-12 15:48:43 +0100611 int i;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100612
Julian Wiedmanndf2a2a52019-03-28 16:39:23 +0100613 mutex_lock(&card->ip_lock);
Ursula Braune48b9ea2017-01-12 15:48:43 +0100614 hash_for_each(card->ip_htable, i, ipaddr, hnode) {
Julian Wiedmanne6b1b7d2019-12-18 17:34:44 +0100615 char addr_str[40];
616 int entry_len;
617
Julian Wiedmannd2073ef2017-12-27 17:44:29 +0100618 if (ipaddr->proto != proto || ipaddr->type != type)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100619 continue;
Julian Wiedmanne6b1b7d2019-12-18 17:34:44 +0100620
621 entry_len = qeth_l3_ipaddr_to_string(proto, (u8 *)&ipaddr->u,
622 addr_str);
623 if (entry_len < 0)
624 continue;
625
626 /* Enough room to format %addr\n into null terminated page? */
627 if (entry_len + 1 > PAGE_SIZE - str_len - 1)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100628 break;
Julian Wiedmanne6b1b7d2019-12-18 17:34:44 +0100629
630 entry_len = scnprintf(buf, PAGE_SIZE - str_len, "%s\n",
631 addr_str);
632 str_len += entry_len;
633 buf += entry_len;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100634 }
Julian Wiedmanndf2a2a52019-03-28 16:39:23 +0100635 mutex_unlock(&card->ip_lock);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100636
Julian Wiedmanne6b1b7d2019-12-18 17:34:44 +0100637 return str_len ? str_len : scnprintf(buf, PAGE_SIZE, "\n");
Frank Blaschka4a71df52008-02-15 09:19:42 +0100638}
639
640static ssize_t qeth_l3_dev_vipa_add4_show(struct device *dev,
Julian Wiedmannd2073ef2017-12-27 17:44:29 +0100641 struct device_attribute *attr,
642 char *buf)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100643{
Julian Wiedmannd2073ef2017-12-27 17:44:29 +0100644 return qeth_l3_dev_ip_add_show(dev, buf, QETH_PROT_IPV4,
645 QETH_IP_TYPE_VIPA);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100646}
647
Julian Wiedmann23901662019-12-18 17:34:45 +0100648static ssize_t qeth_l3_vipa_store(struct device *dev, const char *buf, bool add,
649 size_t count, enum qeth_prot_versions proto)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100650{
Julian Wiedmann23901662019-12-18 17:34:45 +0100651 struct qeth_card *card = dev_get_drvdata(dev);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100652 u8 addr[16] = {0, };
653 int rc;
654
Julian Wiedmann23901662019-12-18 17:34:45 +0100655 rc = qeth_l3_string_to_ipaddr(buf, proto, addr);
Frank Blaschkac4949f02010-05-11 19:34:47 +0000656 if (!rc)
Julian Wiedmann23901662019-12-18 17:34:45 +0100657 rc = qeth_l3_modify_rxip_vipa(card, add, addr,
Julian Wiedmann1617dae2018-03-09 18:13:02 +0100658 QETH_IP_TYPE_VIPA, proto);
Frank Blaschkac4949f02010-05-11 19:34:47 +0000659 return rc ? rc : count;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100660}
661
662static ssize_t qeth_l3_dev_vipa_add4_store(struct device *dev,
663 struct device_attribute *attr, const char *buf, size_t count)
664{
Julian Wiedmann23901662019-12-18 17:34:45 +0100665 return qeth_l3_vipa_store(dev, buf, true, count, QETH_PROT_IPV4);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100666}
667
668static QETH_DEVICE_ATTR(vipa_add4, add4, 0644,
669 qeth_l3_dev_vipa_add4_show,
670 qeth_l3_dev_vipa_add4_store);
671
Frank Blaschka4a71df52008-02-15 09:19:42 +0100672static ssize_t qeth_l3_dev_vipa_del4_store(struct device *dev,
673 struct device_attribute *attr, const char *buf, size_t count)
674{
Julian Wiedmann23901662019-12-18 17:34:45 +0100675 return qeth_l3_vipa_store(dev, buf, true, count, QETH_PROT_IPV4);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100676}
677
678static QETH_DEVICE_ATTR(vipa_del4, del4, 0200, NULL,
679 qeth_l3_dev_vipa_del4_store);
680
681static ssize_t qeth_l3_dev_vipa_add6_show(struct device *dev,
Julian Wiedmannd2073ef2017-12-27 17:44:29 +0100682 struct device_attribute *attr,
683 char *buf)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100684{
Julian Wiedmannd2073ef2017-12-27 17:44:29 +0100685 return qeth_l3_dev_ip_add_show(dev, buf, QETH_PROT_IPV6,
686 QETH_IP_TYPE_VIPA);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100687}
688
689static ssize_t qeth_l3_dev_vipa_add6_store(struct device *dev,
690 struct device_attribute *attr, const char *buf, size_t count)
691{
Julian Wiedmann23901662019-12-18 17:34:45 +0100692 return qeth_l3_vipa_store(dev, buf, true, count, QETH_PROT_IPV6);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100693}
694
695static QETH_DEVICE_ATTR(vipa_add6, add6, 0644,
696 qeth_l3_dev_vipa_add6_show,
697 qeth_l3_dev_vipa_add6_store);
698
699static ssize_t qeth_l3_dev_vipa_del6_store(struct device *dev,
700 struct device_attribute *attr, const char *buf, size_t count)
701{
Julian Wiedmann23901662019-12-18 17:34:45 +0100702 return qeth_l3_vipa_store(dev, buf, false, count, QETH_PROT_IPV6);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100703}
704
705static QETH_DEVICE_ATTR(vipa_del6, del6, 0200, NULL,
706 qeth_l3_dev_vipa_del6_store);
707
708static struct attribute *qeth_vipa_device_attrs[] = {
709 &dev_attr_vipa_add4.attr,
710 &dev_attr_vipa_del4.attr,
711 &dev_attr_vipa_add6.attr,
712 &dev_attr_vipa_del6.attr,
713 NULL,
714};
715
Arvind Yadavcfe9a042017-07-19 12:39:14 +0530716static const struct attribute_group qeth_device_vipa_group = {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100717 .name = "vipa",
718 .attrs = qeth_vipa_device_attrs,
719};
720
Frank Blaschka4a71df52008-02-15 09:19:42 +0100721static ssize_t qeth_l3_dev_rxip_add4_show(struct device *dev,
Julian Wiedmannd2073ef2017-12-27 17:44:29 +0100722 struct device_attribute *attr,
723 char *buf)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100724{
Julian Wiedmannd2073ef2017-12-27 17:44:29 +0100725 return qeth_l3_dev_ip_add_show(dev, buf, QETH_PROT_IPV4,
726 QETH_IP_TYPE_RXIP);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100727}
728
729static int qeth_l3_parse_rxipe(const char *buf, enum qeth_prot_versions proto,
730 u8 *addr)
731{
Kittipon Meesompopaa9bea02017-08-15 17:02:48 +0200732 __be32 ipv4_addr;
733 struct in6_addr ipv6_addr;
734
Frank Blaschka4a71df52008-02-15 09:19:42 +0100735 if (qeth_l3_string_to_ipaddr(buf, proto, addr)) {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100736 return -EINVAL;
737 }
Kittipon Meesompopaa9bea02017-08-15 17:02:48 +0200738 if (proto == QETH_PROT_IPV4) {
739 memcpy(&ipv4_addr, addr, sizeof(ipv4_addr));
740 if (ipv4_is_multicast(ipv4_addr)) {
741 QETH_DBF_MESSAGE(2, "multicast rxip not supported.\n");
742 return -EINVAL;
743 }
744 } else if (proto == QETH_PROT_IPV6) {
745 memcpy(&ipv6_addr, addr, sizeof(ipv6_addr));
746 if (ipv6_addr_is_multicast(&ipv6_addr)) {
747 QETH_DBF_MESSAGE(2, "multicast rxip not supported.\n");
748 return -EINVAL;
749 }
750 }
751
Frank Blaschka4a71df52008-02-15 09:19:42 +0100752 return 0;
753}
754
Julian Wiedmann23901662019-12-18 17:34:45 +0100755static ssize_t qeth_l3_rxip_store(struct device *dev, const char *buf, bool add,
756 size_t count, enum qeth_prot_versions proto)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100757{
Julian Wiedmann23901662019-12-18 17:34:45 +0100758 struct qeth_card *card = dev_get_drvdata(dev);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100759 u8 addr[16] = {0, };
760 int rc;
761
762 rc = qeth_l3_parse_rxipe(buf, proto, addr);
Frank Blaschkac4949f02010-05-11 19:34:47 +0000763 if (!rc)
Julian Wiedmann23901662019-12-18 17:34:45 +0100764 rc = qeth_l3_modify_rxip_vipa(card, add, addr,
Julian Wiedmann1617dae2018-03-09 18:13:02 +0100765 QETH_IP_TYPE_RXIP, proto);
Frank Blaschkac4949f02010-05-11 19:34:47 +0000766 return rc ? rc : count;
Frank Blaschka4a71df52008-02-15 09:19:42 +0100767}
768
769static ssize_t qeth_l3_dev_rxip_add4_store(struct device *dev,
770 struct device_attribute *attr, const char *buf, size_t count)
771{
Julian Wiedmann23901662019-12-18 17:34:45 +0100772 return qeth_l3_rxip_store(dev, buf, true, count, QETH_PROT_IPV4);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100773}
774
775static QETH_DEVICE_ATTR(rxip_add4, add4, 0644,
776 qeth_l3_dev_rxip_add4_show,
777 qeth_l3_dev_rxip_add4_store);
778
Frank Blaschka4a71df52008-02-15 09:19:42 +0100779static ssize_t qeth_l3_dev_rxip_del4_store(struct device *dev,
780 struct device_attribute *attr, const char *buf, size_t count)
781{
Julian Wiedmann23901662019-12-18 17:34:45 +0100782 return qeth_l3_rxip_store(dev, buf, false, count, QETH_PROT_IPV4);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100783}
784
785static QETH_DEVICE_ATTR(rxip_del4, del4, 0200, NULL,
786 qeth_l3_dev_rxip_del4_store);
787
788static ssize_t qeth_l3_dev_rxip_add6_show(struct device *dev,
Julian Wiedmannd2073ef2017-12-27 17:44:29 +0100789 struct device_attribute *attr,
790 char *buf)
Frank Blaschka4a71df52008-02-15 09:19:42 +0100791{
Julian Wiedmannd2073ef2017-12-27 17:44:29 +0100792 return qeth_l3_dev_ip_add_show(dev, buf, QETH_PROT_IPV6,
793 QETH_IP_TYPE_RXIP);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100794}
795
796static ssize_t qeth_l3_dev_rxip_add6_store(struct device *dev,
797 struct device_attribute *attr, const char *buf, size_t count)
798{
Julian Wiedmann23901662019-12-18 17:34:45 +0100799 return qeth_l3_rxip_store(dev, buf, true, count, QETH_PROT_IPV6);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100800}
801
802static QETH_DEVICE_ATTR(rxip_add6, add6, 0644,
803 qeth_l3_dev_rxip_add6_show,
804 qeth_l3_dev_rxip_add6_store);
805
806static ssize_t qeth_l3_dev_rxip_del6_store(struct device *dev,
807 struct device_attribute *attr, const char *buf, size_t count)
808{
Julian Wiedmann23901662019-12-18 17:34:45 +0100809 return qeth_l3_rxip_store(dev, buf, false, count, QETH_PROT_IPV6);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100810}
811
812static QETH_DEVICE_ATTR(rxip_del6, del6, 0200, NULL,
813 qeth_l3_dev_rxip_del6_store);
814
815static struct attribute *qeth_rxip_device_attrs[] = {
816 &dev_attr_rxip_add4.attr,
817 &dev_attr_rxip_del4.attr,
818 &dev_attr_rxip_add6.attr,
819 &dev_attr_rxip_del6.attr,
820 NULL,
821};
822
Arvind Yadavcfe9a042017-07-19 12:39:14 +0530823static const struct attribute_group qeth_device_rxip_group = {
Frank Blaschka4a71df52008-02-15 09:19:42 +0100824 .name = "rxip",
825 .attrs = qeth_rxip_device_attrs,
826};
827
Julian Wiedmannab25a502017-09-18 21:18:19 +0200828static const struct attribute_group *qeth_l3_only_attr_groups[] = {
829 &qeth_l3_device_attr_group,
830 &qeth_device_ipato_group,
831 &qeth_device_vipa_group,
832 &qeth_device_rxip_group,
833 NULL,
834};
835
Frank Blaschka4a71df52008-02-15 09:19:42 +0100836int qeth_l3_create_device_attributes(struct device *dev)
837{
Julian Wiedmannab25a502017-09-18 21:18:19 +0200838 return sysfs_create_groups(&dev->kobj, qeth_l3_only_attr_groups);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100839}
840
841void qeth_l3_remove_device_attributes(struct device *dev)
842{
Julian Wiedmannab25a502017-09-18 21:18:19 +0200843 sysfs_remove_groups(&dev->kobj, qeth_l3_only_attr_groups);
Frank Blaschka4a71df52008-02-15 09:19:42 +0100844}
Ursula Braun79a04e42017-06-06 14:33:49 +0200845
846const struct attribute_group *qeth_l3_attr_groups[] = {
847 &qeth_device_attr_group,
848 &qeth_device_blkt_group,
Julian Wiedmannab25a502017-09-18 21:18:19 +0200849 /* l3 specific, see qeth_l3_only_attr_groups: */
Ursula Braun79a04e42017-06-06 14:33:49 +0200850 &qeth_l3_device_attr_group,
851 &qeth_device_ipato_group,
852 &qeth_device_vipa_group,
853 &qeth_device_rxip_group,
Julian Wiedmannab25a502017-09-18 21:18:19 +0200854 NULL,
Ursula Braun79a04e42017-06-06 14:33:49 +0200855};