aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2016-06-07 19:32:41 -0400
committerDavid S. Miller <davem@davemloft.net>2016-06-08 14:23:42 -0400
commitaf42192c47c41ec132bda736a78d6d5e0d2999a9 (patch)
treef70a2550705174b35a899047d2b4f4b4c62cb933 /net/dsa
parent1eb59443e72c69edbb836626f9f7f7e82427eeac (diff)
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: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa_priv.h1
-rw-r--r--net/dsa/slave.c14
2 files changed, 9 insertions, 6 deletions
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index b42f1a5f95f3..106a9f067f94 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -58,6 +58,7 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
58/* slave.c */ 58/* slave.c */
59extern const struct dsa_device_ops notag_netdev_ops; 59extern const struct dsa_device_ops notag_netdev_ops;
60void dsa_slave_mii_bus_init(struct dsa_switch *ds); 60void dsa_slave_mii_bus_init(struct dsa_switch *ds);
61void dsa_cpu_port_ethtool_init(struct ethtool_ops *ops);
61int dsa_slave_create(struct dsa_switch *ds, struct device *parent, 62int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
62 int port, const char *name); 63 int port, const char *name);
63void dsa_slave_destroy(struct net_device *slave_dev); 64void dsa_slave_destroy(struct net_device *slave_dev);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index a51dfedf0014..8d159932e082 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -865,6 +865,13 @@ static void dsa_slave_poll_controller(struct net_device *dev)
865} 865}
866#endif 866#endif
867 867
868void dsa_cpu_port_ethtool_init(struct ethtool_ops *ops)
869{
870 ops->get_sset_count = dsa_cpu_port_get_sset_count;
871 ops->get_ethtool_stats = dsa_cpu_port_get_ethtool_stats;
872 ops->get_strings = dsa_cpu_port_get_strings;
873}
874
868static const struct ethtool_ops dsa_slave_ethtool_ops = { 875static const struct ethtool_ops dsa_slave_ethtool_ops = {
869 .get_settings = dsa_slave_get_settings, 876 .get_settings = dsa_slave_get_settings,
870 .set_settings = dsa_slave_set_settings, 877 .set_settings = dsa_slave_set_settings,
@@ -1124,12 +1131,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
1124 sizeof(struct ethtool_ops)); 1131 sizeof(struct ethtool_ops));
1125 memcpy(&dsa_cpu_port_ethtool_ops, &dst->master_ethtool_ops, 1132 memcpy(&dsa_cpu_port_ethtool_ops, &dst->master_ethtool_ops,
1126 sizeof(struct ethtool_ops)); 1133 sizeof(struct ethtool_ops));
1127 dsa_cpu_port_ethtool_ops.get_sset_count = 1134 dsa_cpu_port_ethtool_init(&dsa_cpu_port_ethtool_ops);
1128 dsa_cpu_port_get_sset_count;
1129 dsa_cpu_port_ethtool_ops.get_ethtool_stats =
1130 dsa_cpu_port_get_ethtool_stats;
1131 dsa_cpu_port_ethtool_ops.get_strings =
1132 dsa_cpu_port_get_strings;
1133 master->ethtool_ops = &dsa_cpu_port_ethtool_ops; 1135 master->ethtool_ops = &dsa_cpu_port_ethtool_ops;
1134 } 1136 }
1135 eth_hw_addr_inherit(slave_dev, master); 1137 eth_hw_addr_inherit(slave_dev, master);