Skip to content

Commit f0653a8

Browse files
IoanaCiorneidavem330
authored andcommitted
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: Ioana Ciornei <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8581362 commit f0653a8

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-ethtool.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,17 @@ dpaa2_switch_set_link_ksettings(struct net_device *netdev,
142142
return err;
143143
}
144144

145-
static int dpaa2_switch_ethtool_get_sset_count(struct net_device *dev, int sset)
145+
static int
146+
dpaa2_switch_ethtool_get_sset_count(struct net_device *netdev, int sset)
146147
{
148+
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
149+
int num_ss_stats = DPAA2_SWITCH_NUM_COUNTERS;
150+
147151
switch (sset) {
148152
case ETH_SS_STATS:
149-
return DPAA2_SWITCH_NUM_COUNTERS;
153+
if (port_priv->mac)
154+
num_ss_stats += dpaa2_mac_get_sset_count();
155+
return num_ss_stats;
150156
default:
151157
return -EOPNOTSUPP;
152158
}
@@ -155,14 +161,19 @@ static int dpaa2_switch_ethtool_get_sset_count(struct net_device *dev, int sset)
155161
static void dpaa2_switch_ethtool_get_strings(struct net_device *netdev,
156162
u32 stringset, u8 *data)
157163
{
164+
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
165+
u8 *p = data;
158166
int i;
159167

160168
switch (stringset) {
161169
case ETH_SS_STATS:
162-
for (i = 0; i < DPAA2_SWITCH_NUM_COUNTERS; i++)
163-
memcpy(data + i * ETH_GSTRING_LEN,
164-
dpaa2_switch_ethtool_counters[i].name,
170+
for (i = 0; i < DPAA2_SWITCH_NUM_COUNTERS; i++) {
171+
memcpy(p, dpaa2_switch_ethtool_counters[i].name,
165172
ETH_GSTRING_LEN);
173+
p += ETH_GSTRING_LEN;
174+
}
175+
if (port_priv->mac)
176+
dpaa2_mac_get_strings(p);
166177
break;
167178
}
168179
}
@@ -184,6 +195,9 @@ static void dpaa2_switch_ethtool_get_stats(struct net_device *netdev,
184195
netdev_err(netdev, "dpsw_if_get_counter[%s] err %d\n",
185196
dpaa2_switch_ethtool_counters[i].name, err);
186197
}
198+
199+
if (port_priv->mac)
200+
dpaa2_mac_get_ethtool_stats(port_priv->mac, data + i);
187201
}
188202

189203
const struct ethtool_ops dpaa2_switch_port_ethtool_ops = {

0 commit comments

Comments
 (0)