11 #include <linux/list.h>
12 #include <linux/netdevice.h>
23 return ds->
drv->phy_read(ds, addr, reg);
28 static int dsa_slave_phy_write(
struct mii_bus *bus,
int addr,
int reg,
u16 val)
33 return ds->
drv->phy_write(ds, addr, reg, val);
98 static int dsa_slave_close(
struct net_device *dev)
116 static void dsa_slave_change_rx_flags(
struct net_device *dev,
int change)
127 static void dsa_slave_set_rx_mode(
struct net_device *dev)
136 static int dsa_slave_set_mac_address(
struct net_device *dev,
void *
a)
143 if (!is_valid_ether_addr(addr->
sa_data))
184 err = phy_read_status(p->
phy);
203 static void dsa_slave_get_drvinfo(
struct net_device *dev,
212 static int dsa_slave_nway_reset(
struct net_device *dev)
234 static void dsa_slave_get_strings(
struct net_device *dev,
243 strncpy(data,
"tx_packets", len);
244 strncpy(data + len,
"tx_bytes", len);
245 strncpy(data + 2 * len,
"rx_packets", len);
246 strncpy(data + 3 * len,
"rx_bytes", len);
247 if (ds->
drv->get_strings !=
NULL)
248 ds->
drv->get_strings(ds, p->
port, data + 4 * len);
252 static void dsa_slave_get_ethtool_stats(
struct net_device *dev,
259 data[0] = p->
dev->stats.tx_packets;
260 data[1] = p->
dev->stats.tx_bytes;
261 data[2] = p->
dev->stats.rx_packets;
262 data[3] = p->
dev->stats.rx_bytes;
263 if (ds->
drv->get_ethtool_stats !=
NULL)
264 ds->
drv->get_ethtool_stats(ds, p->
port, data + 4);
267 static int dsa_slave_get_sset_count(
struct net_device *dev,
int sset)
276 if (ds->
drv->get_sset_count !=
NULL)
277 count += ds->
drv->get_sset_count(ds);
285 static const struct ethtool_ops dsa_slave_ethtool_ops = {
286 .get_settings = dsa_slave_get_settings,
287 .set_settings = dsa_slave_set_settings,
288 .get_drvinfo = dsa_slave_get_drvinfo,
289 .nway_reset = dsa_slave_nway_reset,
290 .get_link = dsa_slave_get_link,
291 .get_strings = dsa_slave_get_strings,
292 .get_ethtool_stats = dsa_slave_get_ethtool_stats,
293 .get_sset_count = dsa_slave_get_sset_count,
296 #ifdef CONFIG_NET_DSA_TAG_DSA
299 .ndo_open = dsa_slave_open,
300 .ndo_stop = dsa_slave_close,
302 .ndo_change_rx_flags = dsa_slave_change_rx_flags,
303 .ndo_set_rx_mode = dsa_slave_set_rx_mode,
304 .ndo_set_mac_address = dsa_slave_set_mac_address,
305 .ndo_do_ioctl = dsa_slave_ioctl,
308 #ifdef CONFIG_NET_DSA_TAG_EDSA
311 .ndo_open = dsa_slave_open,
312 .ndo_stop = dsa_slave_close,
314 .ndo_change_rx_flags = dsa_slave_change_rx_flags,
315 .ndo_set_rx_mode = dsa_slave_set_rx_mode,
316 .ndo_set_mac_address = dsa_slave_set_mac_address,
317 .ndo_do_ioctl = dsa_slave_ioctl,
320 #ifdef CONFIG_NET_DSA_TAG_TRAILER
323 .ndo_open = dsa_slave_open,
324 .ndo_stop = dsa_slave_close,
326 .ndo_change_rx_flags = dsa_slave_change_rx_flags,
327 .ndo_set_rx_mode = dsa_slave_set_rx_mode,
328 .ndo_set_mac_address = dsa_slave_set_mac_address,
329 .ndo_do_ioctl = dsa_slave_ioctl,
345 if (slave_dev ==
NULL)
353 switch (ds->
dst->tag_protocol) {
354 #ifdef CONFIG_NET_DSA_TAG_DSA
359 #ifdef CONFIG_NET_DSA_TAG_EDSA
364 #ifdef CONFIG_NET_DSA_TAG_TRAILER
376 p = netdev_priv(slave_dev);
385 master->
name, ret, slave_dev->
name);