Skip to content

Commit af42192

Browse files
ffainellidavem330
authored andcommitted
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>
1 parent 1eb5944 commit af42192

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

net/dsa/dsa_priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
5858
/* slave.c */
5959
extern const struct dsa_device_ops notag_netdev_ops;
6060
void dsa_slave_mii_bus_init(struct dsa_switch *ds);
61+
void dsa_cpu_port_ethtool_init(struct ethtool_ops *ops);
6162
int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
6263
int port, const char *name);
6364
void dsa_slave_destroy(struct net_device *slave_dev);

net/dsa/slave.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,13 @@ static void dsa_slave_poll_controller(struct net_device *dev)
865865
}
866866
#endif
867867

868+
void 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+
868875
static const struct ethtool_ops dsa_slave_ethtool_ops = {
869876
.get_settings = dsa_slave_get_settings,
870877
.set_settings = dsa_slave_set_settings,
@@ -1124,12 +1131,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
11241131
sizeof(struct ethtool_ops));
11251132
memcpy(&dsa_cpu_port_ethtool_ops, &dst->master_ethtool_ops,
11261133
sizeof(struct ethtool_ops));
1127-
dsa_cpu_port_ethtool_ops.get_sset_count =
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;
1134+
dsa_cpu_port_ethtool_init(&dsa_cpu_port_ethtool_ops);
11331135
master->ethtool_ops = &dsa_cpu_port_ethtool_ops;
11341136
}
11351137
eth_hw_addr_inherit(slave_dev, master);

0 commit comments

Comments
 (0)