Commit 12c2d0a5 authored by Horatiu Vultur's avatar Horatiu Vultur Committed by David S. Miller

net: lan966x: add ethtool configuration and statistics

This patch adds support for statistics counters for the network
interfaces. Also adds support for configuring the network interface via
ethtool like: speed, duplex etc.
Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e18aba89
......@@ -6,4 +6,4 @@
obj-$(CONFIG_LAN966X_SWITCH) += lan966x-switch.o
lan966x-switch-objs := lan966x_main.o lan966x_phylink.o lan966x_port.o \
lan966x_mac.o
lan966x_mac.o lan966x_ethtool.o
This diff is collapsed.
......@@ -373,6 +373,7 @@ static const struct net_device_ops lan966x_port_netdev_ops = {
.ndo_change_mtu = lan966x_port_change_mtu,
.ndo_set_rx_mode = lan966x_port_set_rx_mode,
.ndo_get_phys_port_name = lan966x_port_get_phys_port_name,
.ndo_get_stats64 = lan966x_stats_get,
.ndo_set_mac_address = lan966x_port_set_mac_address,
.ndo_get_port_parent_id = lan966x_port_get_parent_id,
};
......@@ -588,6 +589,7 @@ static int lan966x_probe_port(struct lan966x *lan966x, u32 p,
dev->max_mtu = ETH_MAX_MTU;
dev->netdev_ops = &lan966x_port_netdev_ops;
dev->ethtool_ops = &lan966x_ethtool_ops;
dev->needed_headroom = IFH_LEN * sizeof(u32);
eth_hw_addr_gen(dev, lan966x->base_mac, p + 1);
......@@ -875,6 +877,7 @@ static int lan966x_probe(struct platform_device *pdev)
/* init switch */
lan966x_init(lan966x);
lan966x_stats_init(lan966x);
/* go over the child nodes */
fwnode_for_each_available_child_node(ports, portnp) {
......@@ -908,6 +911,10 @@ static int lan966x_probe(struct platform_device *pdev)
lan966x_cleanup_ports(lan966x);
cancel_delayed_work_sync(&lan966x->stats_work);
destroy_workqueue(lan966x->stats_queue);
mutex_destroy(&lan966x->stats_lock);
return err;
}
......@@ -917,6 +924,10 @@ static int lan966x_remove(struct platform_device *pdev)
lan966x_cleanup_ports(lan966x);
cancel_delayed_work_sync(&lan966x->stats_work);
destroy_workqueue(lan966x->stats_queue);
mutex_destroy(&lan966x->stats_lock);
return 0;
}
......
......@@ -58,6 +58,11 @@ enum macaccess_entry_type {
struct lan966x_port;
struct lan966x_stat_layout {
u32 offset;
char name[ETH_GSTRING_LEN];
};
struct lan966x {
struct device *dev;
......@@ -70,6 +75,16 @@ struct lan966x {
u8 base_mac[ETH_ALEN];
/* stats */
const struct lan966x_stat_layout *stats_layout;
u32 num_stats;
/* workqueue for reading stats */
struct mutex stats_lock;
u64 *stats;
struct delayed_work stats_work;
struct workqueue_struct *stats_queue;
/* interrupts */
int xtr_irq;
};
......@@ -101,6 +116,11 @@ struct lan966x_port {
extern const struct phylink_mac_ops lan966x_phylink_mac_ops;
extern const struct phylink_pcs_ops lan966x_phylink_pcs_ops;
extern const struct ethtool_ops lan966x_ethtool_ops;
void lan966x_stats_get(struct net_device *dev,
struct rtnl_link_stats64 *stats);
int lan966x_stats_init(struct lan966x *lan966x);
void lan966x_port_config_down(struct lan966x_port *port);
void lan966x_port_config_up(struct lan966x_port *port);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment