diff options
Diffstat (limited to 'drivers/net/ethernet/mscc/ocelot_net.c')
-rw-r--r-- | drivers/net/ethernet/mscc/ocelot_net.c | 95 |
1 files changed, 55 insertions, 40 deletions
diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 330d30841cdc..50858cc10fef 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -20,6 +20,13 @@ #define OCELOT_MAC_QUIRKS OCELOT_QUIRK_QSGMII_PORTS_MUST_BE_UP +struct ocelot_dump_ctx { + struct net_device *dev; + struct sk_buff *skb; + struct netlink_callback *cb; + int idx; +}; + static bool ocelot_netdevice_dev_check(const struct net_device *dev); static struct ocelot *devlink_port_to_ocelot(struct devlink_port *dlp) @@ -725,42 +732,8 @@ static void ocelot_get_stats64(struct net_device *dev, struct ocelot_port_private *priv = netdev_priv(dev); struct ocelot *ocelot = priv->port.ocelot; int port = priv->port.index; - u64 *s; - - spin_lock(&ocelot->stats_lock); - - s = &ocelot->stats[port * OCELOT_NUM_STATS]; - - /* Get Rx stats */ - stats->rx_bytes = s[OCELOT_STAT_RX_OCTETS]; - stats->rx_packets = s[OCELOT_STAT_RX_SHORTS] + - s[OCELOT_STAT_RX_FRAGMENTS] + - s[OCELOT_STAT_RX_JABBERS] + - s[OCELOT_STAT_RX_LONGS] + - s[OCELOT_STAT_RX_64] + - s[OCELOT_STAT_RX_65_127] + - s[OCELOT_STAT_RX_128_255] + - s[OCELOT_STAT_RX_256_511] + - s[OCELOT_STAT_RX_512_1023] + - s[OCELOT_STAT_RX_1024_1526] + - s[OCELOT_STAT_RX_1527_MAX]; - stats->multicast = s[OCELOT_STAT_RX_MULTICAST]; - stats->rx_dropped = dev->stats.rx_dropped; - - /* Get Tx stats */ - stats->tx_bytes = s[OCELOT_STAT_TX_OCTETS]; - stats->tx_packets = s[OCELOT_STAT_TX_64] + - s[OCELOT_STAT_TX_65_127] + - s[OCELOT_STAT_TX_128_255] + - s[OCELOT_STAT_TX_256_511] + - s[OCELOT_STAT_TX_512_1023] + - s[OCELOT_STAT_TX_1024_1526] + - s[OCELOT_STAT_TX_1527_MAX]; - stats->tx_dropped = s[OCELOT_STAT_TX_DROPS] + - s[OCELOT_STAT_TX_AGED]; - stats->collisions = s[OCELOT_STAT_TX_COLLISION]; - - spin_unlock(&ocelot->stats_lock); + + return ocelot_port_get_stats64(ocelot, port, stats); } static int ocelot_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], @@ -790,6 +763,49 @@ static int ocelot_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], return ocelot_fdb_del(ocelot, port, addr, vid, ocelot_port->bridge); } +static int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid, + bool is_static, void *data) +{ + struct ocelot_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; +} + static int ocelot_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, struct net_device *dev, @@ -1396,11 +1412,10 @@ static int ocelot_netdevice_lag_join(struct net_device *dev, int port = priv->port.index; int err; - err = ocelot_port_lag_join(ocelot, port, bond, info); - if (err == -EOPNOTSUPP) { - NL_SET_ERR_MSG_MOD(extack, "Offloading not supported"); + err = ocelot_port_lag_join(ocelot, port, bond, info, extack); + if (err == -EOPNOTSUPP) + /* Offloading not supported, fall back to software LAG */ return 0; - } bridge_dev = netdev_master_upper_dev_get(bond); if (!bridge_dev || !netif_is_bridge_master(bridge_dev)) |