Commit af42192c authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

net: dsa: Add initialization helper for CPU port ethtool_ops

Add a helper function: dsa_cpu_port_ethtool_init() which initializes a
custom ethtool_ops structure with custom DSA ethtool operations for CPU
ports. This is a preliminary change to move the initialization outside
of net/dsa/slave.c.
Reviewed-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1eb59443
...@@ -58,6 +58,7 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol); ...@@ -58,6 +58,7 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
/* slave.c */ /* slave.c */
extern const struct dsa_device_ops notag_netdev_ops; extern const struct dsa_device_ops notag_netdev_ops;
void dsa_slave_mii_bus_init(struct dsa_switch *ds); void dsa_slave_mii_bus_init(struct dsa_switch *ds);
void dsa_cpu_port_ethtool_init(struct ethtool_ops *ops);
int dsa_slave_create(struct dsa_switch *ds, struct device *parent, int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
int port, const char *name); int port, const char *name);
void dsa_slave_destroy(struct net_device *slave_dev); void dsa_slave_destroy(struct net_device *slave_dev);
......
...@@ -865,6 +865,13 @@ static void dsa_slave_poll_controller(struct net_device *dev) ...@@ -865,6 +865,13 @@ static void dsa_slave_poll_controller(struct net_device *dev)
} }
#endif #endif
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;
}
static const struct ethtool_ops dsa_slave_ethtool_ops = { static const struct ethtool_ops dsa_slave_ethtool_ops = {
.get_settings = dsa_slave_get_settings, .get_settings = dsa_slave_get_settings,
.set_settings = dsa_slave_set_settings, .set_settings = dsa_slave_set_settings,
...@@ -1124,12 +1131,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, ...@@ -1124,12 +1131,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
sizeof(struct ethtool_ops)); sizeof(struct ethtool_ops));
memcpy(&dsa_cpu_port_ethtool_ops, &dst->master_ethtool_ops, memcpy(&dsa_cpu_port_ethtool_ops, &dst->master_ethtool_ops,
sizeof(struct ethtool_ops)); sizeof(struct ethtool_ops));
dsa_cpu_port_ethtool_ops.get_sset_count = dsa_cpu_port_ethtool_init(&dsa_cpu_port_ethtool_ops);
dsa_cpu_port_get_sset_count;
dsa_cpu_port_ethtool_ops.get_ethtool_stats =
dsa_cpu_port_get_ethtool_stats;
dsa_cpu_port_ethtool_ops.get_strings =
dsa_cpu_port_get_strings;
master->ethtool_ops = &dsa_cpu_port_ethtool_ops; master->ethtool_ops = &dsa_cpu_port_ethtool_ops;
} }
eth_hw_addr_inherit(slave_dev, master); eth_hw_addr_inherit(slave_dev, master);
......
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