master.c (42a62da0ae660e71c280bd8b287b994c1af1352c) master.c (022bba63c3ca02fc074c68b4e7b949bddcf320d6)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Handling of a master device, switching frames via its switch fabric CPU port
4 *
5 * Copyright (c) 2017 Savoir-faire Linux Inc.
6 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
7 */
8
9#include "dsa_priv.h"
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Handling of a master device, switching frames via its switch fabric CPU port
4 *
5 * Copyright (c) 2017 Savoir-faire Linux Inc.
6 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
7 */
8
9#include "dsa_priv.h"
10#include "port.h"
10
11static int dsa_master_get_regs_len(struct net_device *dev)
12{
13 struct dsa_port *cpu_dp = dev->dsa_ptr;
14 const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops;
15 struct dsa_switch *ds = cpu_dp->ds;
16 int port = cpu_dp->index;
17 int ret = 0;

--- 276 unchanged lines hidden (view full) ---

294 return sprintf(buf, "%s\n",
295 dsa_tag_protocol_to_str(cpu_dp->tag_ops));
296}
297
298static ssize_t tagging_store(struct device *d, struct device_attribute *attr,
299 const char *buf, size_t count)
300{
301 const struct dsa_device_ops *new_tag_ops, *old_tag_ops;
11
12static int dsa_master_get_regs_len(struct net_device *dev)
13{
14 struct dsa_port *cpu_dp = dev->dsa_ptr;
15 const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops;
16 struct dsa_switch *ds = cpu_dp->ds;
17 int port = cpu_dp->index;
18 int ret = 0;

--- 276 unchanged lines hidden (view full) ---

295 return sprintf(buf, "%s\n",
296 dsa_tag_protocol_to_str(cpu_dp->tag_ops));
297}
298
299static ssize_t tagging_store(struct device *d, struct device_attribute *attr,
300 const char *buf, size_t count)
301{
302 const struct dsa_device_ops *new_tag_ops, *old_tag_ops;
303 const char *end = strchrnul(buf, '\n'), *name;
302 struct net_device *dev = to_net_dev(d);
303 struct dsa_port *cpu_dp = dev->dsa_ptr;
304 struct net_device *dev = to_net_dev(d);
305 struct dsa_port *cpu_dp = dev->dsa_ptr;
306 size_t len = end - buf;
304 int err;
305
307 int err;
308
309 /* Empty string passed */
310 if (!len)
311 return -ENOPROTOOPT;
312
313 name = kstrndup(buf, len, GFP_KERNEL);
314 if (!name)
315 return -ENOMEM;
316
306 old_tag_ops = cpu_dp->tag_ops;
317 old_tag_ops = cpu_dp->tag_ops;
307 new_tag_ops = dsa_find_tagger_by_name(buf);
308 /* Bad tagger name, or module is not loaded? */
318 new_tag_ops = dsa_tag_driver_get_by_name(name);
319 kfree(name);
320 /* Bad tagger name? */
309 if (IS_ERR(new_tag_ops))
310 return PTR_ERR(new_tag_ops);
311
312 if (new_tag_ops == old_tag_ops)
313 /* Drop the temporarily held duplicate reference, since
314 * the DSA switch tree uses this tagger.
315 */
316 goto out;

--- 162 unchanged lines hidden ---
321 if (IS_ERR(new_tag_ops))
322 return PTR_ERR(new_tag_ops);
323
324 if (new_tag_ops == old_tag_ops)
325 /* Drop the temporarily held duplicate reference, since
326 * the DSA switch tree uses this tagger.
327 */
328 goto out;

--- 162 unchanged lines hidden ---