Commit f0653a89 authored by Ioana Ciornei's avatar Ioana Ciornei Committed by David S. Miller

dpaa2-switch: export MAC statistics in ethtool

If a switch port is connected to a MAC, use the common dpaa2-mac support
for exporting the available MAC statistics.
Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8581362d
...@@ -142,11 +142,17 @@ dpaa2_switch_set_link_ksettings(struct net_device *netdev, ...@@ -142,11 +142,17 @@ dpaa2_switch_set_link_ksettings(struct net_device *netdev,
return err; return err;
} }
static int dpaa2_switch_ethtool_get_sset_count(struct net_device *dev, int sset) static int
dpaa2_switch_ethtool_get_sset_count(struct net_device *netdev, int sset)
{ {
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
int num_ss_stats = DPAA2_SWITCH_NUM_COUNTERS;
switch (sset) { switch (sset) {
case ETH_SS_STATS: case ETH_SS_STATS:
return DPAA2_SWITCH_NUM_COUNTERS; if (port_priv->mac)
num_ss_stats += dpaa2_mac_get_sset_count();
return num_ss_stats;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -155,14 +161,19 @@ static int dpaa2_switch_ethtool_get_sset_count(struct net_device *dev, int sset) ...@@ -155,14 +161,19 @@ static int dpaa2_switch_ethtool_get_sset_count(struct net_device *dev, int sset)
static void dpaa2_switch_ethtool_get_strings(struct net_device *netdev, static void dpaa2_switch_ethtool_get_strings(struct net_device *netdev,
u32 stringset, u8 *data) u32 stringset, u8 *data)
{ {
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
u8 *p = data;
int i; int i;
switch (stringset) { switch (stringset) {
case ETH_SS_STATS: case ETH_SS_STATS:
for (i = 0; i < DPAA2_SWITCH_NUM_COUNTERS; i++) for (i = 0; i < DPAA2_SWITCH_NUM_COUNTERS; i++) {
memcpy(data + i * ETH_GSTRING_LEN, memcpy(p, dpaa2_switch_ethtool_counters[i].name,
dpaa2_switch_ethtool_counters[i].name,
ETH_GSTRING_LEN); ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
if (port_priv->mac)
dpaa2_mac_get_strings(p);
break; break;
} }
} }
...@@ -184,6 +195,9 @@ static void dpaa2_switch_ethtool_get_stats(struct net_device *netdev, ...@@ -184,6 +195,9 @@ static void dpaa2_switch_ethtool_get_stats(struct net_device *netdev,
netdev_err(netdev, "dpsw_if_get_counter[%s] err %d\n", netdev_err(netdev, "dpsw_if_get_counter[%s] err %d\n",
dpaa2_switch_ethtool_counters[i].name, err); dpaa2_switch_ethtool_counters[i].name, err);
} }
if (port_priv->mac)
dpaa2_mac_get_ethtool_stats(port_priv->mac, data + i);
} }
const struct ethtool_ops dpaa2_switch_port_ethtool_ops = { const struct ethtool_ops dpaa2_switch_port_ethtool_ops = {
......
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