Release 4.14 net/dsa/slave.c
/*
* net/dsa/slave.c - Slave device handling
* Copyright (c) 2008-2009 Marvell Semiconductor
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <linux/list.h>
#include <linux/etherdevice.h>
#include <linux/netdevice.h>
#include <linux/phy.h>
#include <linux/phy_fixed.h>
#include <linux/of_net.h>
#include <linux/of_mdio.h>
#include <linux/mdio.h>
#include <linux/list.h>
#include <net/rtnetlink.h>
#include <net/pkt_cls.h>
#include <net/tc_act/tc_mirred.h>
#include <linux/if_bridge.h>
#include <linux/netpoll.h>
#include "dsa_priv.h"
static bool dsa_slave_dev_check(struct net_device *dev);
/* slave mii_bus handling ***************************************************/
static int dsa_slave_phy_read(struct mii_bus *bus, int addr, int reg)
{
struct dsa_switch *ds = bus->priv;
if (ds->phys_mii_mask & (1 << addr))
return ds->ops->phy_read(ds, addr, reg);
return 0xffff;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 53 | 96.36% | 1 | 33.33% |
Florian Fainelli | 1 | 1.82% | 1 | 33.33% |
Vivien Didelot | 1 | 1.82% | 1 | 33.33% |
Total | 55 | 100.00% | 3 | 100.00% |
static int dsa_slave_phy_write(struct mii_bus *bus, int addr, int reg, u16 val)
{
struct dsa_switch *ds = bus->priv;
if (ds->phys_mii_mask & (1 << addr))
return ds->ops->phy_write(ds, addr, reg, val);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 58 | 96.67% | 1 | 33.33% |
Florian Fainelli | 1 | 1.67% | 1 | 33.33% |
Vivien Didelot | 1 | 1.67% | 1 | 33.33% |
Total | 60 | 100.00% | 3 | 100.00% |
void dsa_slave_mii_bus_init(struct dsa_switch *ds)
{
ds->slave_mii_bus->priv = (void *)ds;
ds->slave_mii_bus->name = "dsa slave smi";
ds->slave_mii_bus->read = dsa_slave_phy_read;
ds->slave_mii_bus->write = dsa_slave_phy_write;
snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "dsa-%d.%d",
ds->dst->tree, ds->index);
ds->slave_mii_bus->parent = ds->dev;
ds->slave_mii_bus->phy_mask = ~ds->phys_mii_mask;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 70 | 77.78% | 1 | 20.00% |
Vivien Didelot | 11 | 12.22% | 1 | 20.00% |
Florian Fainelli | 8 | 8.89% | 2 | 40.00% |
Andrew Lunn | 1 | 1.11% | 1 | 20.00% |
Total | 90 | 100.00% | 5 | 100.00% |
/* slave device handling ****************************************************/
static int dsa_slave_get_iflink(const struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
return dsa_master_netdev(p)->ifindex;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 24 | 80.00% | 1 | 33.33% |
Nicolas Dichtel | 3 | 10.00% | 1 | 33.33% |
Florian Fainelli | 3 | 10.00% | 1 | 33.33% |
Total | 30 | 100.00% | 3 | 100.00% |
static int dsa_slave_open(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
struct dsa_switch *ds = dp->ds;
struct net_device *master = dsa_master_netdev(p);
u8 stp_state = dp->bridge_dev ? BR_STATE_BLOCKING : BR_STATE_FORWARDING;
int err;
if (!(master->flags & IFF_UP))
return -ENETDOWN;
if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) {
err = dev_uc_add(master, dev->dev_addr);
if (err < 0)
goto out;
}
if (dev->flags & IFF_ALLMULTI) {
err = dev_set_allmulti(master, 1);
if (err < 0)
goto del_unicast;
}
if (dev->flags & IFF_PROMISC) {
err = dev_set_promiscuity(master, 1);
if (err < 0)
goto clear_allmulti;
}
if (ds->ops->port_enable) {
err = ds->ops->port_enable(ds, p->dp->index, p->phy);
if (err)
goto clear_promisc;
}
dsa_port_set_state_now(p->dp, stp_state);
if (p->phy)
phy_start(p->phy);
return 0;
clear_promisc:
if (dev->flags & IFF_PROMISC)
dev_set_promiscuity(master, -1);
clear_allmulti:
if (dev->flags & IFF_ALLMULTI)
dev_set_allmulti(master, -1);
del_unicast:
if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
dev_uc_del(master, dev->dev_addr);
out:
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 182 | 60.87% | 2 | 14.29% |
Florian Fainelli | 85 | 28.43% | 4 | 28.57% |
Vivien Didelot | 24 | 8.03% | 5 | 35.71% |
Joe Perches | 4 | 1.34% | 1 | 7.14% |
Gilad Ben-Yossef | 2 | 0.67% | 1 | 7.14% |
Jiri Pirko | 2 | 0.67% | 1 | 7.14% |
Total | 299 | 100.00% | 14 | 100.00% |
static int dsa_slave_close(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = dsa_master_netdev(p);
struct dsa_switch *ds = p->dp->ds;
if (p->phy)
phy_stop(p->phy);
dev_mc_unsync(master, dev);
dev_uc_unsync(master, dev);
if (dev->flags & IFF_ALLMULTI)
dev_set_allmulti(master, -1);
if (dev->flags & IFF_PROMISC)
dev_set_promiscuity(master, -1);
if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
dev_uc_del(master, dev->dev_addr);
if (ds->ops->port_disable)
ds->ops->port_disable(ds, p->dp->index, p->phy);
dsa_port_set_state_now(p->dp, BR_STATE_DISABLED);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 96 | 58.90% | 2 | 18.18% |
Florian Fainelli | 51 | 31.29% | 4 | 36.36% |
Vivien Didelot | 12 | 7.36% | 3 | 27.27% |
Jiri Pirko | 2 | 1.23% | 1 | 9.09% |
Joe Perches | 2 | 1.23% | 1 | 9.09% |
Total | 163 | 100.00% | 11 | 100.00% |
static void dsa_slave_change_rx_flags(struct net_device *dev, int change)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = dsa_master_netdev(p);
if (change & IFF_ALLMULTI)
dev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1);
if (change & IFF_PROMISC)
dev_set_promiscuity(master, dev->flags & IFF_PROMISC ? 1 : -1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 75 | 96.15% | 1 | 50.00% |
Florian Fainelli | 3 | 3.85% | 1 | 50.00% |
Total | 78 | 100.00% | 2 | 100.00% |
static void dsa_slave_set_rx_mode(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = dsa_master_netdev(p);
dev_mc_sync(master, dev);
dev_uc_sync(master, dev);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 41 | 91.11% | 1 | 33.33% |
Florian Fainelli | 3 | 6.67% | 1 | 33.33% |
Jiri Pirko | 1 | 2.22% | 1 | 33.33% |
Total | 45 | 100.00% | 3 | 100.00% |
static int dsa_slave_set_mac_address(struct net_device *dev, void *a)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = dsa_master_netdev(p);
struct sockaddr *addr = a;
int err;
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
if (!(dev->flags & IFF_UP))
goto out;
if (!ether_addr_equal(addr->sa_data, master->dev_addr)) {
err = dev_uc_add(master, addr->sa_data);
if (err < 0)
return err;
}
if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
dev_uc_del(master, dev->dev_addr);
out:
ether_addr_copy(dev->dev_addr, addr->sa_data);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 94 | 63.51% | 2 | 33.33% |
Florian Fainelli | 51 | 34.46% | 2 | 33.33% |
Joe Perches | 2 | 1.35% | 1 | 16.67% |
Jiri Pirko | 1 | 0.68% | 1 | 16.67% |
Total | 148 | 100.00% | 6 | 100.00% |
struct dsa_slave_dump_ctx {
struct net_device *dev;
struct sk_buff *skb;
struct netlink_callback *cb;
int idx;
};
static int
dsa_slave_port_fdb_do_dump(const unsigned char *addr, u16 vid,
bool is_static, void *data)
{
struct dsa_slave_dump_ctx *dump = data;
u32 portid = NETLINK_CB(dump->cb->skb).portid;
u32 seq = dump->cb->nlh->nlmsg_seq;
struct nlmsghdr *nlh;
struct ndmsg *ndm;
if (dump->idx < dump->cb->args[2])
goto skip;
nlh = nlmsg_put(dump->skb, portid, seq, RTM_NEWNEIGH,
sizeof(*ndm), NLM_F_MULTI);
if (!nlh)
return -EMSGSIZE;
ndm = nlmsg_data(nlh);
ndm->ndm_family = AF_BRIDGE;
ndm->ndm_pad1 = 0;
ndm->ndm_pad2 = 0;
ndm->ndm_flags = NTF_SELF;
ndm->ndm_type = 0;
ndm->ndm_ifindex = dump->dev->ifindex;
ndm->ndm_state = is_static ? NUD_NOARP : NUD_REACHABLE;
if (nla_put(dump->skb, NDA_LLADDR, ETH_ALEN, addr))
goto nla_put_failure;
if (vid && nla_put_u16(dump->skb, NDA_VLAN, vid))
goto nla_put_failure;
nlmsg_end(dump->skb, nlh);
skip:
dump->idx++;
return 0;
nla_put_failure:
nlmsg_cancel(dump->skb, nlh);
return -EMSGSIZE;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arkadi Sharshevsky | 241 | 100.00% | 1 | 100.00% |
Total | 241 | 100.00% | 1 | 100.00% |
static int
dsa_slave_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
struct net_device *dev, struct net_device *filter_dev,
int *idx)
{
struct dsa_slave_dump_ctx dump = {
.dev = dev,
.skb = skb,
.cb = cb,
.idx = *idx,
};
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
struct dsa_switch *ds = dp->ds;
int err;
if (!ds->ops->port_fdb_dump)
return -EOPNOTSUPP;
err = ds->ops->port_fdb_dump(ds, dp->index,
dsa_slave_port_fdb_do_dump,
&dump);
*idx = dump.idx;
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arkadi Sharshevsky | 131 | 100.00% | 1 | 100.00% |
Total | 131 | 100.00% | 1 | 100.00% |
static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
struct dsa_slave_priv *p = netdev_priv(dev);
if (p->phy != NULL)
return phy_mii_ioctl(p->phy, ifr, cmd);
return -EOPNOTSUPP;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David S. Miller | 31 | 58.49% | 1 | 50.00% |
Florian Fainelli | 22 | 41.51% | 1 | 50.00% |
Total | 53 | 100.00% | 2 | 100.00% |
static int dsa_slave_port_attr_set(struct net_device *dev,
const struct switchdev_attr *attr,
struct switchdev_trans *trans)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
int ret;
switch (attr->id) {
case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
ret = dsa_port_set_state(dp, attr->u.stp_state, trans);
break;
case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
ret = dsa_port_vlan_filtering(dp, attr->u.vlan_filtering,
trans);
break;
case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
ret = dsa_port_ageing_time(dp, attr->u.ageing_time, trans);
break;
default:
ret = -EOPNOTSUPP;
break;
}
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vivien Didelot | 67 | 56.30% | 7 | 58.33% |
Scott Feldman | 37 | 31.09% | 1 | 8.33% |
David S. Miller | 8 | 6.72% | 1 | 8.33% |
Jiri Pirko | 7 | 5.88% | 3 | 25.00% |
Total | 119 | 100.00% | 12 | 100.00% |
static int dsa_slave_port_obj_add(struct net_device *dev,
const struct switchdev_obj *obj,
struct switchdev_trans *trans)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
int err;
/* For the prepare phase, ensure the full set of changes is feasable in
* one go in order to signal a failure properly. If an operation is not
* supported, return -EOPNOTSUPP.
*/
switch (obj->id) {
case SWITCHDEV_OBJ_ID_PORT_MDB:
err = dsa_port_mdb_add(dp, SWITCHDEV_OBJ_PORT_MDB(obj), trans);
break;
case SWITCHDEV_OBJ_ID_PORT_VLAN:
err = dsa_port_vlan_add(dp, SWITCHDEV_OBJ_PORT_VLAN(obj),
trans);
break;
default:
err = -EOPNOTSUPP;
break;
}
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vivien Didelot | 84 | 84.85% | 7 | 58.33% |
Jiri Pirko | 15 | 15.15% | 5 | 41.67% |
Total | 99 | 100.00% | 12 | 100.00% |
static int dsa_slave_port_obj_del(struct net_device *dev,
const struct switchdev_obj *obj)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
int err;
switch (obj->id) {
case SWITCHDEV_OBJ_ID_PORT_MDB:
err = dsa_port_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj));
break;
case SWITCHDEV_OBJ_ID_PORT_VLAN:
err = dsa_port_vlan_del(dp, SWITCHDEV_OBJ_PORT_VLAN(obj));
break;
default:
err = -EOPNOTSUPP;
break;
}
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vivien Didelot | 81 | 91.01% | 7 | 70.00% |
Jiri Pirko | 8 | 8.99% | 3 | 30.00% |
Total | 89 | 100.00% | 10 | 100.00% |
static int dsa_slave_port_attr_get(struct net_device *dev,
struct switchdev_attr *attr)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
switch (attr->id) {
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
attr->u.ppid.id_len = sizeof(ds->index);
memcpy(&attr->u.ppid.id, &ds->index, attr->u.ppid.id_len);
break;
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
attr->u.brport_flags_support = 0;
break;
default:
return -EOPNOTSUPP;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Scott Feldman | 34 | 31.19% | 2 | 28.57% |
Lennert Buytenhek | 32 | 29.36% | 1 | 14.29% |
Florian Fainelli | 27 | 24.77% | 1 | 14.29% |
Arkadi Sharshevsky | 12 | 11.01% | 1 | 14.29% |
Vivien Didelot | 3 | 2.75% | 1 | 14.29% |
Jiri Pirko | 1 | 0.92% | 1 | 14.29% |
Total | 109 | 100.00% | 7 | 100.00% |
static inline netdev_tx_t dsa_netpoll_send_skb(struct dsa_slave_priv *p,
struct sk_buff *skb)
{
#ifdef CONFIG_NET_POLL_CONTROLLER
if (p->netpoll)
netpoll_send_skb(p->netpoll, skb);
#else
BUG();
#endif
return NETDEV_TX_OK;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 45 | 100.00% | 1 | 100.00% |
Total | 45 | 100.00% | 1 | 100.00% |
static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct pcpu_sw_netstats *s;
struct sk_buff *nskb;
s = this_cpu_ptr(p->stats64);
u64_stats_update_begin(&s->syncp);
s->tx_packets++;
s->tx_bytes += skb->len;
u64_stats_update_end(&s->syncp);
/* Transmit function may have to reallocate the original SKB,
* in which case it must have freed it. Only free it here on error.
*/
nskb = p->xmit(skb, dev);
if (!nskb) {
kfree_skb(skb);
return NETDEV_TX_OK;
}
/* SKB for netpoll still need to be mangled with the protocol-specific
* tag to be successfully transmitted
*/
if (unlikely(netpoll_tx_running(dev)))
return dsa_netpoll_send_skb(p, nskb);
/* Queue the SKB for transmission on the parent interface, but
* do not modify its EtherType
*/
nskb->dev = dsa_master_netdev(p);
dev_queue_xmit(nskb);
return NETDEV_TX_OK;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 129 | 93.48% | 6 | 75.00% |
Vivien Didelot | 8 | 5.80% | 1 | 12.50% |
Alexander Duyck | 1 | 0.72% | 1 | 12.50% |
Total | 138 | 100.00% | 8 | 100.00% |
/* ethtool operations *******************************************************/
static int
dsa_slave_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{
struct dsa_slave_priv *p = netdev_priv(dev);
if (!p->phy)
return -EOPNOTSUPP;
phy_ethtool_ksettings_get(p->phy, cmd);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 40 | 81.63% | 1 | 33.33% |
Yuval Shaia | 6 | 12.24% | 1 | 33.33% |
Philippe Reynes | 3 | 6.12% | 1 | 33.33% |
Total | 49 | 100.00% | 3 | 100.00% |
static int
dsa_slave_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{
struct dsa_slave_priv *p = netdev_priv(dev);
if (p->phy != NULL)
return phy_ethtool_ksettings_set(p->phy, cmd);
return -EOPNOTSUPP;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 45 | 91.84% | 1 | 50.00% |
Philippe Reynes | 4 | 8.16% | 1 | 50.00% |
Total | 49 | 100.00% | 2 | 100.00% |
static void dsa_slave_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *drvinfo)
{
strlcpy(drvinfo->driver, "dsa", sizeof(drvinfo->driver));
strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
strlcpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 43 | 67.19% | 1 | 50.00% |
Jiri Pirko | 21 | 32.81% | 1 | 50.00% |
Total | 64 | 100.00% | 2 | 100.00% |
static int dsa_slave_get_regs_len(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
if (ds->ops->get_regs_len)
return ds->ops->get_regs_len(ds, p->dp->index);
return -EOPNOTSUPP;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Guenter Roeck | 52 | 86.67% | 1 | 33.33% |
Vivien Didelot | 8 | 13.33% | 2 | 66.67% |
Total | 60 | 100.00% | 3 | 100.00% |
static void
dsa_slave_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *_p)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
if (ds->ops->get_regs)
ds->ops->get_regs(ds, p->dp->index, regs, _p);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Guenter Roeck | 60 | 88.24% | 1 | 33.33% |
Vivien Didelot | 8 | 11.76% | 2 | 66.67% |
Total | 68 | 100.00% | 3 | 100.00% |
static int dsa_slave_nway_reset(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
if (p->phy != NULL)
return genphy_restart_aneg(p->phy);
return -EOPNOTSUPP;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 41 | 100.00% | 1 | 100.00% |
Total | 41 | 100.00% | 1 | 100.00% |
static u32 dsa_slave_get_link(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
if (p->phy != NULL) {
genphy_update_link(p->phy);
return p->phy->link;
}
return -EOPNOTSUPP;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 49 | 100.00% | 1 | 100.00% |
Total | 49 | 100.00% | 1 | 100.00% |
static int dsa_slave_get_eeprom_len(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
if (ds->cd && ds->cd->eeprom_len)
return ds->cd->eeprom_len;
if (ds->ops->get_eeprom_len)
return ds->ops->get_eeprom_len(ds);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Guenter Roeck | 61 | 84.72% | 1 | 20.00% |
Andrew Lunn | 6 | 8.33% | 2 | 40.00% |
Vivien Didelot | 5 | 6.94% | 2 | 40.00% |
Total | 72 | 100.00% | 5 | 100.00% |
static int dsa_slave_get_eeprom(struct net_device *dev,
struct ethtool_eeprom *eeprom, u8 *data)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
if (ds->ops->get_eeprom)
return ds->ops->get_eeprom(ds, eeprom, data);
return -EOPNOTSUPP;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Guenter Roeck | 62 | 92.54% | 1 | 33.33% |
Vivien Didelot | 5 | 7.46% | 2 | 66.67% |
Total | 67 | 100.00% | 3 | 100.00% |
static int dsa_slave_set_eeprom(struct net_device *dev,
struct ethtool_eeprom *eeprom, u8 *data)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
if (ds->ops->set_eeprom)
return ds->ops->set_eeprom(ds, eeprom, data);
return -EOPNOTSUPP;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Guenter Roeck | 62 | 92.54% | 1 | 33.33% |
Vivien Didelot | 5 | 7.46% | 2 | 66.67% |
Total | 67 | 100.00% | 3 | 100.00% |
static void dsa_slave_get_strings(struct net_device *dev,
uint32_t stringset, uint8_t *data)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
if (stringset == ETH_SS_STATS) {
int len = ETH_GSTRING_LEN;
strncpy(data, "tx_packets", len);
strncpy(data + len, "tx_bytes", len);
strncpy(data + 2 * len, "rx_packets", len);
strncpy(data + 3 * len, "rx_bytes", len);
if (ds->ops->get_strings)
ds->ops->get_strings(ds, p->dp->index, data + 4 * len);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 119 | 93.70% | 1 | 33.33% |
Vivien Didelot | 8 | 6.30% | 2 | 66.67% |
Total | 127 | 100.00% | 3 | 100.00% |
static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats,
uint64_t *data)
{
struct dsa_switch_tree *dst = dev->dsa_ptr;
struct dsa_port *cpu_dp = dsa_get_cpu_port(dst);
struct dsa_switch *ds = cpu_dp->ds;
s8 cpu_port = cpu_dp->index;
int count = 0;
if (cpu_dp->ethtool_ops.get_sset_count) {
count = cpu_dp->ethtool_ops.get_sset_count(dev, ETH_SS_STATS);
cpu_dp->ethtool_ops.get_ethtool_stats(dev, stats, data);
}
if (ds->ops->get_ethtool_stats)
ds->ops->get_ethtool_stats(ds, cpu_port, data + count);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 111 | 93.28% | 3 | 60.00% |
Vivien Didelot | 8 | 6.72% | 2 | 40.00% |
Total | 119 | 100.00% | 5 | 100.00% |
static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset)
{
struct dsa_switch_tree *dst = dev->dsa_ptr;
struct dsa_port *cpu_dp = dsa_get_cpu_port(dst);
struct dsa_switch *ds = cpu_dp->ds;
int count = 0;
if (cpu_dp->ethtool_ops.get_sset_count)
count += cpu_dp->ethtool_ops.get_sset_count(dev, sset);
if (sset == ETH_SS_STATS && ds->ops->get_sset_count)
count += ds->ops->get_sset_count(ds);
return count;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 89 | 94.68% | 3 | 60.00% |
Vivien Didelot | 5 | 5.32% | 2 | 40.00% |
Total | 94 | 100.00% | 5 | 100.00% |
static void dsa_cpu_port_get_strings(struct net_device *dev,
uint32_t stringset, uint8_t *data)
{
struct dsa_switch_tree *dst = dev->dsa_ptr;
struct dsa_port *cpu_dp = dsa_get_cpu_port(dst);
struct dsa_switch *ds = cpu_dp->ds;
s8 cpu_port = cpu_dp->index;
int len = ETH_GSTRING_LEN;
int mcount = 0, count;
unsigned int i;
uint8_t pfx[4];
uint8_t *ndata;
snprintf(pfx, sizeof(pfx), "p%.2d", cpu_port);
/* We do not want to be NULL-terminated, since this is a prefix */
pfx[sizeof(pfx) - 1] = '_';
if (cpu_dp->ethtool_ops.get_sset_count) {
mcount = cpu_dp->ethtool_ops.get_sset_count(dev, ETH_SS_STATS);
cpu_dp->ethtool_ops.get_strings(dev, stringset, data);
}
if (stringset == ETH_SS_STATS && ds->ops->get_strings) {
ndata = data + mcount * len;
/* This function copies ETH_GSTRINGS_LEN bytes, we will mangle
* the output after to prepend our CPU port prefix we
* constructed earlier
*/
ds->ops->get_strings(ds, cpu_port, ndata);
count = ds->ops->get_sset_count(ds);
for (i = 0; i < count; i++) {
memmove(ndata + (i * len + sizeof(pfx)),
ndata + i * len, len - sizeof(pfx));
memcpy(ndata + i * len, pfx, sizeof(pfx));
}
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 240 | 96.39% | 3 | 60.00% |
Vivien Didelot | 9 | 3.61% | 2 | 40.00% |
Total | 249 | 100.00% | 5 | 100.00% |
static void dsa_slave_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats,
uint64_t *data)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
struct pcpu_sw_netstats *s;
unsigned int start;
int i;
for_each_possible_cpu(i) {
u64 tx_packets, tx_bytes, rx_packets, rx_bytes;
s = per_cpu_ptr(p->stats64, i);
do {
start = u64_stats_fetch_begin_irq(&s->syncp);
tx_packets = s->tx_packets;
tx_bytes = s->tx_bytes;
rx_packets = s->rx_packets;
rx_bytes = s->rx_bytes;
} while (u64_stats_fetch_retry_irq(&s->syncp, start));
data[0] += tx_packets;
data[1] += tx_bytes;
data[2] += rx_packets;
data[3] += rx_bytes;
}
if (ds->ops->get_ethtool_stats)
ds->ops->get_ethtool_stats(ds, p->dp->index, data + 4);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 100 | 54.35% | 2 | 40.00% |
Lennert Buytenhek | 76 | 41.30% | 1 | 20.00% |
Vivien Didelot | 8 | 4.35% | 2 | 40.00% |
Total | 184 | 100.00% | 5 | 100.00% |
static int dsa_slave_get_sset_count(struct net_device *dev, int sset)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
if (sset == ETH_SS_STATS) {
int count;
count = 4;
if (ds->ops->get_sset_count)
count += ds->ops->get_sset_count(ds);
return count;
}
return -EOPNOTSUPP;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 71 | 93.42% | 1 | 33.33% |
Vivien Didelot | 5 | 6.58% | 2 | 66.67% |
Total | 76 | 100.00% | 3 | 100.00% |
static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
if (ds->ops->get_wol)
ds->ops->get_wol(ds, p->dp->index, w);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 54 | 87.10% | 1 | 33.33% |
Vivien Didelot | 8 | 12.90% | 2 | 66.67% |
Total | 62 | 100.00% | 3 | 100.00% |
static int dsa_slave_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
int ret = -EOPNOTSUPP;
if (ds->ops->set_wol)
ret = ds->ops->set_wol(ds, p->dp->index, w);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 65 | 89.04% | 1 | 33.33% |
Vivien Didelot | 8 | 10.96% | 2 | 66.67% |
Total | 73 | 100.00% | 3 | 100.00% |
static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
int ret;
/* Port's PHY and MAC both need to be EEE capable */
if (!p->phy)
return -ENODEV;
if (!ds->ops->set_mac_eee)
return -EOPNOTSUPP;
ret = ds->ops->set_mac_eee(ds, p->dp->index, e);
if (ret)
return ret;
if (e->eee_enabled) {
ret = phy_init_eee(p->phy, 0);
if (ret)
return ret;
}
return phy_ethtool_set_eee(p->phy, e);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 78 | 61.42% | 1 | 16.67% |
Vivien Didelot | 49 | 38.58% | 5 | 83.33% |
Total | 127 | 100.00% | 6 | 100.00% |
static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
int ret;
/* Port's PHY and MAC both need to be EEE capable */
if (!p->phy)
return -ENODEV;
if (!ds->ops->get_mac_eee)
return -EOPNOTSUPP;
ret = ds->ops->get_mac_eee(ds, p->dp->index, e);
if (ret)
return ret;
return phy_ethtool_get_eee(p->phy, e);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 78 | 77.23% | 1 | 20.00% |
Vivien Didelot | 23 | 22.77% | 4 | 80.00% |
Total | 101 | 100.00% | 5 | 100.00% |
#ifdef CONFIG_NET_POLL_CONTROLLER
static int dsa_slave_netpoll_setup(struct net_device *dev,
struct netpoll_info *ni)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = dsa_master_netdev(p);
struct netpoll *netpoll;
int err = 0;
netpoll = kzalloc(sizeof(*netpoll), GFP_KERNEL);
if (!netpoll)
return -ENOMEM;
err = __netpoll_setup(netpoll, master);
if (err) {
kfree(netpoll);
goto out;
}
p->netpoll = netpoll;
out:
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 102 | 100.00% | 2 | 100.00% |
Total | 102 | 100.00% | 2 | 100.00% |
static void dsa_slave_netpoll_cleanup(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct netpoll *netpoll = p->netpoll;
if (!netpoll)
return;
p->netpoll = NULL;
__netpoll_free_async(netpoll);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 47 | 100.00% | 1 | 100.00% |
Total | 47 | 100.00% | 1 | 100.00% |
static void dsa_slave_poll_controller(struct net_device *dev)
{
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 10 | 100.00% | 1 | 100.00% |
Total | 10 | 100.00% | 1 | 100.00% |
#endif
static int dsa_slave_get_phys_port_name(struct net_device *dev,
char *name, size_t len)
{
struct dsa_slave_priv *p = netdev_priv(dev);
if (snprintf(name, len, "p%d", p->dp->index) >= len)
return -EINVAL;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 51 | 94.44% | 2 | 66.67% |
Vivien Didelot | 3 | 5.56% | 1 | 33.33% |
Total | 54 | 100.00% | 3 | 100.00% |
static struct dsa_mall_tc_entry *
dsa_slave_mall_tc_entry_find(struct dsa_slave_priv *p,
unsigned long cookie)
{
struct dsa_mall_tc_entry *mall_tc_entry;
list_for_each_entry(mall_tc_entry, &p->mall_tc_list, list)
if (mall_tc_entry->cookie == cookie)
return mall_tc_entry;
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 44 | 100.00% | 1 | 100.00% |
Total | 44 | 100.00% | 1 | 100.00% |
static int dsa_slave_add_cls_matchall(struct net_device *dev,
struct tc_cls_matchall_offload *cls,
bool ingress)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_mall_tc_entry *mall_tc_entry;
__be16 protocol = cls->common.protocol;
struct dsa_switch *ds = p->dp->ds;
struct net *net = dev_net(dev);
struct dsa_slave_priv *to_p;
struct net_device *to_dev;
const struct tc_action *a;
int err = -EOPNOTSUPP;
LIST_HEAD(actions);
int ifindex;
if (!ds->ops->port_mirror_add)
return err;
if (!tcf_exts_has_one_action(cls->exts))
return err;
tcf_exts_to_list(cls->exts, &actions);
a = list_first_entry(&actions, struct tc_action, list);
if (is_tcf_mirred_egress_mirror(a) && protocol == htons(ETH_P_ALL)) {
struct dsa_mall_mirror_tc_entry *mirror;
ifindex = tcf_mirred_ifindex(a);
to_dev = __dev_get_by_index(net, ifindex);
if (!to_dev)
return -EINVAL;
if (!dsa_slave_dev_check(to_dev))
return -EOPNOTSUPP;
mall_tc_entry = kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL);
if (!mall_tc_entry)
return -ENOMEM;
mall_tc_entry->cookie = cls->cookie;
mall_tc_entry->type = DSA_PORT_MALL_MIRROR;
mirror = &mall_tc_entry->mirror;
to_p = netdev_priv(to_dev);
mirror->to_local_port = to_p->dp->index;
mirror->ingress = ingress;
err = ds->ops->port_mirror_add(ds, p->dp->index, mirror,
ingress);
if (err) {
kfree(mall_tc_entry);
return err;
}
list_add_tail(&mall_tc_entry->list, &p->mall_tc_list);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 307 | 96.85% | 1 | 33.33% |
Jiri Pirko | 10 | 3.15% | 2 | 66.67% |
Total | 317 | 100.00% | 3 | 100.00% |
static void dsa_slave_del_cls_matchall(struct net_device *dev,
struct tc_cls_matchall_offload *cls)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_mall_tc_entry *mall_tc_entry;
struct dsa_switch *ds = p->dp->ds;
if (!ds->ops->port_mirror_del)
return;
mall_tc_entry = dsa_slave_mall_tc_entry_find(p, cls->cookie);
if (!mall_tc_entry)
return;
list_del(&mall_tc_entry->list);
switch (mall_tc_entry->type) {
case DSA_PORT_MALL_MIRROR:
ds->ops->port_mirror_del(ds, p->dp->index,
&mall_tc_entry->mirror);
break;
default:
WARN_ON(1);
}
kfree(mall_tc_entry);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 120 | 100.00% | 1 | 100.00% |
Total | 120 | 100.00% | 1 | 100.00% |
static int dsa_slave_setup_tc_cls_matchall(struct net_device *dev,
struct tc_cls_matchall_offload *cls)
{
bool ingress;
if (is_classid_clsact_ingress(cls->common.classid))
ingress = true;
else if (is_classid_clsact_egress(cls->common.classid))
ingress = false;
else
return -EOPNOTSUPP;
if (cls->common.chain_index)
return -EOPNOTSUPP;
switch (cls->command) {
case TC_CLSMATCHALL_REPLACE:
return dsa_slave_add_cls_matchall(dev, cls, ingress);
case TC_CLSMATCHALL_DESTROY:
dsa_slave_del_cls_matchall(dev, cls);
return 0;
default:
return -EOPNOTSUPP;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jiri Pirko | 55 | 51.89% | 4 | 80.00% |
Florian Fainelli | 51 | 48.11% | 1 | 20.00% |
Total | 106 | 100.00% | 5 | 100.00% |
static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
void *type_data)
{
switch (type) {
case TC_SETUP_CLSMATCHALL:
return dsa_slave_setup_tc_cls_matchall(dev, type_data);
default:
return -EOPNOTSUPP;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jiri Pirko | 37 | 90.24% | 3 | 75.00% |
Florian Fainelli | 4 | 9.76% | 1 | 25.00% |
Total | 41 | 100.00% | 4 | 100.00% |
static void dsa_slave_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *stats)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct pcpu_sw_netstats *s;
unsigned int start;
int i;
netdev_stats_to_stats64(stats, &dev->stats);
for_each_possible_cpu(i) {
u64 tx_packets, tx_bytes, rx_packets, rx_bytes;
s = per_cpu_ptr(p->stats64, i);
do {
start = u64_stats_fetch_begin_irq(&s->syncp);
tx_packets = s->tx_packets;
tx_bytes = s->tx_bytes;
rx_packets = s->rx_packets;
rx_bytes = s->rx_bytes;
} while (u64_stats_fetch_retry_irq(&s->syncp, start));
stats->tx_packets += tx_packets;
stats->tx_bytes += tx_bytes;
stats->rx_packets += rx_packets;
stats->rx_bytes += rx_bytes;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 148 | 100.00% | 2 | 100.00% |
Total | 148 | 100.00% | 2 | 100.00% |
void dsa_cpu_port_ethtool_init(struct ethtool_ops *ops)
{
ops->get_sset_count = dsa_cpu_port_get_sset_count;
ops->get_ethtool_stats = dsa_cpu_port_get_ethtool_stats;
ops->get_strings = dsa_cpu_port_get_strings;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 28 | 100.00% | 1 | 100.00% |
Total | 28 | 100.00% | 1 | 100.00% |
static int dsa_slave_get_rxnfc(struct net_device *dev,
struct ethtool_rxnfc *nfc, u32 *rule_locs)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
if (!ds->ops->get_rxnfc)
return -EOPNOTSUPP;
return ds->ops->get_rxnfc(ds, p->dp->index, nfc, rule_locs);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 74 | 100.00% | 1 | 100.00% |
Total | 74 | 100.00% | 1 | 100.00% |
static int dsa_slave_set_rxnfc(struct net_device *dev,
struct ethtool_rxnfc *nfc)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
if (!ds->ops->set_rxnfc)
return -EOPNOTSUPP;
return ds->ops->set_rxnfc(ds, p->dp->index, nfc);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 68 | 100.00% | 1 | 100.00% |
Total | 68 | 100.00% | 1 | 100.00% |
static const struct ethtool_ops dsa_slave_ethtool_ops = {
.get_drvinfo = dsa_slave_get_drvinfo,
.get_regs_len = dsa_slave_get_regs_len,
.get_regs = dsa_slave_get_regs,
.nway_reset = dsa_slave_nway_reset,
.get_link = dsa_slave_get_link,
.get_eeprom_len = dsa_slave_get_eeprom_len,
.get_eeprom = dsa_slave_get_eeprom,
.set_eeprom = dsa_slave_set_eeprom,
.get_strings = dsa_slave_get_strings,
.get_ethtool_stats = dsa_slave_get_ethtool_stats,
.get_sset_count = dsa_slave_get_sset_count,
.set_wol = dsa_slave_set_wol,
.get_wol = dsa_slave_get_wol,
.set_eee = dsa_slave_set_eee,
.get_eee = dsa_slave_get_eee,
.get_link_ksettings = dsa_slave_get_link_ksettings,
.set_link_ksettings = dsa_slave_set_link_ksettings,
.get_rxnfc = dsa_slave_get_rxnfc,
.set_rxnfc = dsa_slave_set_rxnfc,
};
static const struct net_device_ops dsa_slave_netdev_ops = {
.ndo_open = dsa_slave_open,
.ndo_stop = dsa_slave_close,
.ndo_start_xmit = dsa_slave_xmit,
.ndo_change_rx_flags = dsa_slave_change_rx_flags,
.ndo_set_rx_mode = dsa_slave_set_rx_mode,
.ndo_set_mac_address = dsa_slave_set_mac_address,
.ndo_fdb_add = dsa_legacy_fdb_add,
.ndo_fdb_del = dsa_legacy_fdb_del,
.ndo_fdb_dump = dsa_slave_fdb_dump,
.ndo_do_ioctl = dsa_slave_ioctl,
.ndo_get_iflink = dsa_slave_get_iflink,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_netpoll_setup = dsa_slave_netpoll_setup,
.ndo_netpoll_cleanup = dsa_slave_netpoll_cleanup,
.ndo_poll_controller = dsa_slave_poll_controller,
#endif
.ndo_get_phys_port_name = dsa_slave_get_phys_port_name,
.ndo_setup_tc = dsa_slave_setup_tc,
.ndo_get_stats64 = dsa_slave_get_stats64,
};
static const struct switchdev_ops dsa_slave_switchdev_ops = {
.switchdev_port_attr_get = dsa_slave_port_attr_get,
.switchdev_port_attr_set = dsa_slave_port_attr_set,
.switchdev_port_obj_add = dsa_slave_port_obj_add,
.switchdev_port_obj_del = dsa_slave_port_obj_del,
};
static struct device_type dsa_type = {
.name = "dsa",
};
static void dsa_slave_adjust_link(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
unsigned int status_changed = 0;
if (p->old_link != p->phy->link) {
status_changed = 1;
p->old_link = p->phy->link;
}
if (p->old_duplex != p->phy->duplex) {
status_changed = 1;
p->old_duplex = p->phy->duplex;
}
if (p->old_pause != p->phy->pause) {
status_changed = 1;
p->old_pause = p->phy->pause;
}
if (ds->ops->adjust_link && status_changed)
ds->ops->adjust_link(ds, p->dp->index, p->phy);
if (status_changed)
phy_print_status(p->phy);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 154 | 95.06% | 2 | 50.00% |
Vivien Didelot | 8 | 4.94% | 2 | 50.00% |
Total | 162 | 100.00% | 4 | 100.00% |
static int dsa_slave_fixed_link_update(struct net_device *dev,
struct fixed_phy_status *status)
{
struct dsa_slave_priv *p;
struct dsa_switch *ds;
if (dev) {
p = netdev_priv(dev);
ds = p->dp->ds;
if (ds->ops->fixed_link_update)
ds->ops->fixed_link_update(ds, p->dp->index, status);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 50 | 66.67% | 1 | 25.00% |
Andrew Lunn | 17 | 22.67% | 1 | 25.00% |
Vivien Didelot | 8 | 10.67% | 2 | 50.00% |
Total | 75 | 100.00% | 4 | 100.00% |
/* slave device setup *******************************************************/
static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
struct net_device *slave_dev,
int addr)
{
struct dsa_switch *ds = p->dp->ds;
p->phy = mdiobus_get_phy(ds->slave_mii_bus, addr);
if (!p->phy) {
netdev_err(slave_dev, "no phy at %d\n", addr);
return -ENODEV;
}
/* Use already configured phy mode */
if (p->phy_interface == PHY_INTERFACE_MODE_NA)
p->phy_interface = p->phy->interface;
return phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
p->phy_interface);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 82 | 82.00% | 4 | 57.14% |
Russell King | 11 | 11.00% | 1 | 14.29% |
Andrew Lunn | 4 | 4.00% | 1 | 14.29% |
Vivien Didelot | 3 | 3.00% | 1 | 14.29% |
Total | 100 | 100.00% | 7 | 100.00% |
static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
struct net_device *slave_dev)
{
struct dsa_switch *ds = p->dp->ds;
struct device_node *phy_dn, *port_dn;
bool phy_is_fixed = false;
u32 phy_flags = 0;
int mode, ret;
port_dn = p->dp->dn;
mode = of_get_phy_mode(port_dn);
if (mode < 0)
mode = PHY_INTERFACE_MODE_NA;
p->phy_interface = mode;
phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
if (!phy_dn && of_phy_is_fixed_link(port_dn)) {
/* In the case of a fixed PHY, the DT node associated
* to the fixed PHY is the Port DT node
*/
ret = of_phy_register_fixed_link(port_dn);
if (ret) {
netdev_err(slave_dev, "failed to register fixed PHY: %d\n", ret);
return ret;
}
phy_is_fixed = true;
phy_dn = of_node_get(port_dn);
}
if (ds->ops->get_phy_flags)
phy_flags = ds->ops->get_phy_flags(ds, p->dp->index);
if (phy_dn) {
int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn);
/* If this PHY address is part of phys_mii_mask, which means
* that we need to divert reads and writes to/from it, then we
* want to bind this device using the slave MII bus created by
* DSA to make that happen.
*/
if (!phy_is_fixed && phy_id >= 0 &&
(ds->phys_mii_mask & (1 << phy_id))) {
ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
if (ret) {
netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret);
of_node_put(phy_dn);
return ret;
}
} else {
p->phy = of_phy_connect(slave_dev, phy_dn,
dsa_slave_adjust_link,
phy_flags,
p->phy_interface);
}
of_node_put(phy_dn);
}
if (p->phy && phy_is_fixed)
fixed_phy_set_link_update(p->phy, dsa_slave_fixed_link_update);
/* We could not connect to a designated PHY, so use the switch internal
* MDIO bus instead
*/
if (!p->phy) {
ret = dsa_slave_phy_connect(p, slave_dev, p->dp->index);
if (ret) {
netdev_err(slave_dev, "failed to connect to port %d: %d\n",
p->dp->index, ret);
if (phy_is_fixed)
of_phy_deregister_fixed_link(port_dn);
return ret;
}
}
phy_attached_info(p->phy);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 252 | 70.59% | 8 | 44.44% |
Russell King | 37 | 10.36% | 1 | 5.56% |
Johan Hovold | 25 | 7.00% | 2 | 11.11% |
Guenter Roeck | 19 | 5.32% | 1 | 5.56% |
Vivien Didelot | 16 | 4.48% | 2 | 11.11% |
Andrew Lunn | 5 | 1.40% | 3 | 16.67% |
Joe Perches | 3 | 0.84% | 1 | 5.56% |
Total | 357 | 100.00% | 18 | 100.00% |
static struct lock_class_key dsa_slave_netdev_xmit_lock_key;
static void dsa_slave_set_lockdep_class_one(struct net_device *dev,
struct netdev_queue *txq,
void *_unused)
{
lockdep_set_class(&txq->_xmit_lock,
&dsa_slave_netdev_xmit_lock_key);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Lunn | 31 | 100.00% | 1 | 100.00% |
Total | 31 | 100.00% | 1 | 100.00% |
int dsa_slave_suspend(struct net_device *slave_dev)
{
struct dsa_slave_priv *p = netdev_priv(slave_dev);
netif_device_detach(slave_dev);
if (p->phy) {
phy_stop(p->phy);
p->old_pause = -1;
p->old_link = -1;
p->old_duplex = -1;
phy_suspend(p->phy);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 71 | 100.00% | 2 | 100.00% |
Total | 71 | 100.00% | 2 | 100.00% |
int dsa_slave_resume(struct net_device *slave_dev)
{
struct dsa_slave_priv *p = netdev_priv(slave_dev);
netif_device_attach(slave_dev);
if (p->phy) {
phy_resume(p->phy);
phy_start(p->phy);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 50 | 100.00% | 1 | 100.00% |
Total | 50 | 100.00% | 1 | 100.00% |
int dsa_slave_create(struct dsa_port *port, const char *name)
{
struct dsa_switch *ds = port->ds;
struct dsa_switch_tree *dst = ds->dst;
struct net_device *master;
struct net_device *slave_dev;
struct dsa_slave_priv *p;
struct dsa_port *cpu_dp;
int ret;
cpu_dp = ds->dst->cpu_dp;
master = cpu_dp->netdev;
if (!ds->num_tx_queues)
ds->num_tx_queues = 1;
slave_dev = alloc_netdev_mqs(sizeof(struct dsa_slave_priv), name,
NET_NAME_UNKNOWN, ether_setup,
ds->num_tx_queues, 1);
if (slave_dev == NULL)
return -ENOMEM;
slave_dev->features = master->vlan_features | NETIF_F_HW_TC;
slave_dev->hw_features |= NETIF_F_HW_TC;
slave_dev->ethtool_ops = &dsa_slave_ethtool_ops;
eth_hw_addr_inherit(slave_dev, master);
slave_dev->priv_flags |= IFF_NO_QUEUE;
slave_dev->netdev_ops = &dsa_slave_netdev_ops;
slave_dev->switchdev_ops = &dsa_slave_switchdev_ops;
slave_dev->min_mtu = 0;
slave_dev->max_mtu = ETH_MAX_MTU;
SET_NETDEV_DEVTYPE(slave_dev, &dsa_type);
netdev_for_each_tx_queue(slave_dev, dsa_slave_set_lockdep_class_one,
NULL);
SET_NETDEV_DEV(slave_dev, port->ds->dev);
slave_dev->dev.of_node = port->dn;
slave_dev->vlan_features = master->vlan_features;
p = netdev_priv(slave_dev);
p->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
if (!p->stats64) {
free_netdev(slave_dev);
return -ENOMEM;
}
p->dp = port;
INIT_LIST_HEAD(&p->mall_tc_list);
p->xmit = dst->tag_ops->xmit;
p->old_pause = -1;
p->old_link = -1;
p->old_duplex = -1;
port->netdev = slave_dev;
netif_carrier_off(slave_dev);
ret = dsa_slave_phy_setup(p, slave_dev);
if (ret) {
netdev_err(master, "error %d setting up slave phy\n", ret);
goto out_free;
}
ret = register_netdev(slave_dev);
if (ret) {
netdev_err(master, "error %d registering interface %s\n",
ret, slave_dev->name);
goto out_phy;
}
return 0;
out_phy:
phy_disconnect(p->phy);
if (of_phy_is_fixed_link(p->dp->dn))
of_phy_deregister_fixed_link(p->dp->dn);
out_free:
free_percpu(p->stats64);
free_netdev(slave_dev);
port->netdev = NULL;
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 182 | 42.72% | 14 | 40.00% |
Lennert Buytenhek | 99 | 23.24% | 3 | 8.57% |
Andrew Lunn | 53 | 12.44% | 6 | 17.14% |
Alexander Duyck | 37 | 8.69% | 1 | 2.86% |
Vivien Didelot | 18 | 4.23% | 2 | 5.71% |
Jarod Wilson | 12 | 2.82% | 1 | 2.86% |
Guenter Roeck | 7 | 1.64% | 1 | 2.86% |
Scott Feldman | 5 | 1.17% | 1 | 2.86% |
Wilfried Klaebe | 3 | 0.70% | 1 | 2.86% |
Phil Sutter | 3 | 0.70% | 1 | 2.86% |
Joe Perches | 2 | 0.47% | 1 | 2.86% |
Tom Gundersen | 2 | 0.47% | 1 | 2.86% |
Jiri Pirko | 2 | 0.47% | 1 | 2.86% |
Björn Mork | 1 | 0.23% | 1 | 2.86% |
Total | 426 | 100.00% | 35 | 100.00% |
void dsa_slave_destroy(struct net_device *slave_dev)
{
struct dsa_slave_priv *p = netdev_priv(slave_dev);
struct device_node *port_dn;
port_dn = p->dp->dn;
netif_carrier_off(slave_dev);
if (p->phy) {
phy_disconnect(p->phy);
if (of_phy_is_fixed_link(port_dn))
of_phy_deregister_fixed_link(port_dn);
}
unregister_netdev(slave_dev);
free_percpu(p->stats64);
free_netdev(slave_dev);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Armstrong | 48 | 58.54% | 1 | 25.00% |
Johan Hovold | 25 | 30.49% | 1 | 25.00% |
Florian Fainelli | 7 | 8.54% | 1 | 25.00% |
Vivien Didelot | 2 | 2.44% | 1 | 25.00% |
Total | 82 | 100.00% | 4 | 100.00% |
static bool dsa_slave_dev_check(struct net_device *dev)
{
return dev->netdev_ops == &dsa_slave_netdev_ops;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 19 | 100.00% | 1 | 100.00% |
Total | 19 | 100.00% | 1 | 100.00% |
static int dsa_slave_changeupper(struct net_device *dev,
struct netdev_notifier_changeupper_info *info)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
int err = NOTIFY_DONE;
if (netif_is_bridge_master(info->upper_dev)) {
if (info->linking) {
err = dsa_port_bridge_join(dp, info->upper_dev);
err = notifier_from_errno(err);
} else {
dsa_port_bridge_leave(dp, info->upper_dev);
err = NOTIFY_OK;
}
}
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vivien Didelot | 69 | 71.88% | 3 | 75.00% |
Florian Fainelli | 27 | 28.12% | 1 | 25.00% |
Total | 96 | 100.00% | 4 | 100.00% |
static int dsa_slave_netdevice_event(struct notifier_block *nb,
unsigned long event, void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
if (dev->netdev_ops != &dsa_slave_netdev_ops)
return NOTIFY_DONE;
if (event == NETDEV_CHANGEUPPER)
return dsa_slave_changeupper(dev, ptr);
return NOTIFY_DONE;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vivien Didelot | 42 | 72.41% | 3 | 75.00% |
Florian Fainelli | 16 | 27.59% | 1 | 25.00% |
Total | 58 | 100.00% | 4 | 100.00% |
struct dsa_switchdev_event_work {
struct work_struct work;
struct switchdev_notifier_fdb_info fdb_info;
struct net_device *dev;
unsigned long event;
};
static void dsa_slave_switchdev_event_work(struct work_struct *work)
{
struct dsa_switchdev_event_work *switchdev_work =
container_of(work, struct dsa_switchdev_event_work, work);
struct net_device *dev = switchdev_work->dev;
struct switchdev_notifier_fdb_info *fdb_info;
struct dsa_slave_priv *p = netdev_priv(dev);
int err;
rtnl_lock();
switch (switchdev_work->event) {
case SWITCHDEV_FDB_ADD_TO_DEVICE:
fdb_info = &switchdev_work->fdb_info;
err = dsa_port_fdb_add(p->dp, fdb_info->addr, fdb_info->vid);
if (err) {
netdev_dbg(dev, "fdb add failed err=%d\n", err);
break;
}
call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, dev,
&fdb_info->info);
break;
case SWITCHDEV_FDB_DEL_TO_DEVICE:
fdb_info = &switchdev_work->fdb_info;
err = dsa_port_fdb_del(p->dp, fdb_info->addr, fdb_info->vid);
if (err) {
netdev_dbg(dev, "fdb del failed err=%d\n", err);
dev_close(dev);
}
break;
}
rtnl_unlock();
kfree(switchdev_work->fdb_info.addr);
kfree(switchdev_work);
dev_put(dev);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arkadi Sharshevsky | 190 | 100.00% | 1 | 100.00% |
Total | 190 | 100.00% | 1 | 100.00% |
static int
dsa_slave_switchdev_fdb_work_init(struct dsa_switchdev_event_work *
switchdev_work,
const struct switchdev_notifier_fdb_info *
fdb_info)
{
memcpy(&switchdev_work->fdb_info, fdb_info,
sizeof(switchdev_work->fdb_info));
switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC);
if (!switchdev_work->fdb_info.addr)
return -ENOMEM;
ether_addr_copy((u8 *)switchdev_work->fdb_info.addr,
fdb_info->addr);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arkadi Sharshevsky | 80 | 100.00% | 1 | 100.00% |
Total | 80 | 100.00% | 1 | 100.00% |
/* Called under rcu_read_lock() */
static int dsa_slave_switchdev_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
struct dsa_switchdev_event_work *switchdev_work;
if (!dsa_slave_dev_check(dev))
return NOTIFY_DONE;
switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC);
if (!switchdev_work)
return NOTIFY_BAD;
INIT_WORK(&switchdev_work->work,
dsa_slave_switchdev_event_work);
switchdev_work->dev = dev;
switchdev_work->event = event;
switch (event) {
case SWITCHDEV_FDB_ADD_TO_DEVICE: /* fall through */
case SWITCHDEV_FDB_DEL_TO_DEVICE:
if (dsa_slave_switchdev_fdb_work_init(switchdev_work,
ptr))
goto err_fdb_work_init;
dev_hold(dev);
break;
default:
kfree(switchdev_work);
return NOTIFY_DONE;
}
dsa_schedule_work(&switchdev_work->work);
return NOTIFY_OK;
err_fdb_work_init:
kfree(switchdev_work);
return NOTIFY_BAD;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arkadi Sharshevsky | 149 | 100.00% | 1 | 100.00% |
Total | 149 | 100.00% | 1 | 100.00% |
static struct notifier_block dsa_slave_nb __read_mostly = {
.notifier_call = dsa_slave_netdevice_event,
};
static struct notifier_block dsa_slave_switchdev_notifier = {
.notifier_call = dsa_slave_switchdev_event,
};
int dsa_slave_register_notifier(void)
{
int err;
err = register_netdevice_notifier(&dsa_slave_nb);
if (err)
return err;
err = register_switchdev_notifier(&dsa_slave_switchdev_notifier);
if (err)
goto err_switchdev_nb;
return 0;
err_switchdev_nb:
unregister_netdevice_notifier(&dsa_slave_nb);
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arkadi Sharshevsky | 41 | 75.93% | 1 | 50.00% |
Vivien Didelot | 13 | 24.07% | 1 | 50.00% |
Total | 54 | 100.00% | 2 | 100.00% |
void dsa_slave_unregister_notifier(void)
{
int err;
err = unregister_switchdev_notifier(&dsa_slave_switchdev_notifier);
if (err)
pr_err("DSA: failed to unregister switchdev notifier (%d)\n", err);
err = unregister_netdevice_notifier(&dsa_slave_nb);
if (err)
pr_err("DSA: failed to unregister slave notifier (%d)\n", err);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vivien Didelot | 29 | 60.42% | 1 | 50.00% |
Arkadi Sharshevsky | 19 | 39.58% | 1 | 50.00% |
Total | 48 | 100.00% | 2 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Fainelli | 3336 | 45.21% | 42 | 30.88% |
Lennert Buytenhek | 1363 | 18.47% | 5 | 3.68% |
Arkadi Sharshevsky | 924 | 12.52% | 4 | 2.94% |
Vivien Didelot | 690 | 9.35% | 29 | 21.32% |
Guenter Roeck | 360 | 4.88% | 5 | 3.68% |
Jiri Pirko | 164 | 2.22% | 16 | 11.76% |
Andrew Lunn | 125 | 1.69% | 13 | 9.56% |
Scott Feldman | 86 | 1.17% | 4 | 2.94% |
Johan Hovold | 50 | 0.68% | 2 | 1.47% |
Russell King | 48 | 0.65% | 1 | 0.74% |
Neil Armstrong | 48 | 0.65% | 1 | 0.74% |
Stephen Hemminger | 41 | 0.56% | 1 | 0.74% |
David S. Miller | 39 | 0.53% | 1 | 0.74% |
Alexander Duyck | 38 | 0.51% | 1 | 0.74% |
Philippe Reynes | 17 | 0.23% | 1 | 0.74% |
Joe Perches | 13 | 0.18% | 2 | 1.47% |
Jarod Wilson | 12 | 0.16% | 1 | 0.74% |
Nicolas Dichtel | 8 | 0.11% | 1 | 0.74% |
Yuval Shaia | 6 | 0.08% | 1 | 0.74% |
Phil Sutter | 3 | 0.04% | 1 | 0.74% |
Wilfried Klaebe | 3 | 0.04% | 1 | 0.74% |
Tom Gundersen | 2 | 0.03% | 1 | 0.74% |
Gilad Ben-Yossef | 2 | 0.03% | 1 | 0.74% |
Björn Mork | 1 | 0.01% | 1 | 0.74% |
Total | 7379 | 100.00% | 136 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.