priv->dpni_stats[i] += data[i];
}
-#ifdef DEBUG
+static void ldpaa_eth_collect_dpmac_stats(struct udevice *dev, u64 *data)
+{
+ struct ldpaa_eth_priv *priv = dev_get_priv(dev);
+ int err, i;
+ u64 value;
+ for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++) {
+ err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
+ priv->dpmac_handle, i,
+ &value);
+ if (err)
+ printf("dpmac_get_counter(%d) failed\n", i);
+
+ *(data + i) = value;
+ }
+}
+
+static void ldpaa_eth_add_dpmac_stats(struct udevice *dev, u64 *data)
+{
+ struct ldpaa_eth_priv *priv = dev_get_priv(dev);
+ int i;
+
+ for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++)
+ priv->dpmac_stats[i] += data[i];
+}
+
+#ifdef DEBUG
static void ldpaa_eth_dump_dpni_stats(struct udevice *dev, u64 *data)
{
int i;
printf(" %s: %llu\n", ldpaa_eth_dpni_stat_strings[i], data[i]);
}
-static void ldpaa_eth_get_dpmac_counter(struct udevice *dev)
+static void ldpaa_eth_dump_dpmac_stats(struct udevice *dev, u64 *data)
{
- struct ldpaa_eth_priv *priv = dev_get_priv(dev);
- int err = 0;
- u64 value;
-
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_ING_BYTE,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_ING_BYTE failed\n");
- return;
- }
- printf("\nDPMAC counters ..\n");
- printf("DPMAC_CNT_ING_BYTE=%lld\n", value);
-
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_ING_FRAME_DISCARD,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_ING_FRAME_DISCARD failed\n");
- return;
- }
- printf("DPMAC_CNT_ING_FRAME_DISCARD=%lld\n", value);
-
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_ING_ALIGN_ERR,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_ING_ALIGN_ERR failed\n");
- return;
- }
- printf("DPMAC_CNT_ING_ALIGN_ERR =%lld\n", value);
-
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_ING_BYTE,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_ING_BYTE failed\n");
- return;
- }
- printf("DPMAC_CNT_ING_BYTE=%lld\n", value);
-
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_ING_ERR_FRAME,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_ING_ERR_FRAME failed\n");
- return;
- }
- printf("DPMAC_CNT_ING_ERR_FRAME=%lld\n", value);
-
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_EGR_BYTE ,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_EGR_BYTE failed\n");
- return;
- }
- printf("DPMAC_CNT_EGR_BYTE =%lld\n", value);
+ int i;
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_EGR_ERR_FRAME ,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_EGR_ERR_FRAME failed\n");
- return;
- }
- printf("DPMAC_CNT_EGR_ERR_FRAME =%lld\n", value);
+ printf("DPMAC counters:\n");
+ for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++)
+ printf(" %s: %llu\n", ldpaa_eth_dpmac_stat_strings[i], data[i]);
}
#endif
}
kfree(data);
+ data = kzalloc(sizeof(u64) * LDPAA_ETH_DPMAC_NUM_STATS, GFP_KERNEL);
+ if (data) {
+ ldpaa_eth_collect_dpmac_stats(dev, data);
+ ldpaa_eth_add_dpmac_stats(dev, data);
#ifdef DEBUG
- ldpaa_eth_get_dpmac_counter(dev);
+ ldpaa_eth_dump_dpmac_stats(dev, data);
#endif
+ }
+ kfree(data);
err = dprc_disconnect(dflt_mc_io, MC_CMD_NO_FLAGS,
dflt_dprc_handle, &dpmac_endpoint);
#define LDPAA_ETH_DPNI_NUM_STATS ARRAY_SIZE(ldpaa_eth_dpni_stat_strings)
+static const char ldpaa_eth_dpmac_stat_strings[][ETH_GSTRING_LEN] = {
+ [DPMAC_CNT_ING_ALL_FRAME] = "[mac] rx all frames",
+ [DPMAC_CNT_ING_GOOD_FRAME] = "[mac] rx frames ok",
+ [DPMAC_CNT_ING_ERR_FRAME] = "[mac] rx frame errors",
+ [DPMAC_CNT_ING_FRAME_DISCARD] = "[mac] rx frame discards",
+ [DPMAC_CNT_ING_UCAST_FRAME] = "[mac] rx u-cast",
+ [DPMAC_CNT_ING_BCAST_FRAME] = "[mac] rx b-cast",
+ [DPMAC_CNT_ING_MCAST_FRAME] = "[mac] rx m-cast",
+ [DPMAC_CNT_ING_FRAME_64] = "[mac] rx 64 bytes",
+ [DPMAC_CNT_ING_FRAME_127] = "[mac] rx 65-127 bytes",
+ [DPMAC_CNT_ING_FRAME_255] = "[mac] rx 128-255 bytes",
+ [DPMAC_CNT_ING_FRAME_511] = "[mac] rx 256-511 bytes",
+ [DPMAC_CNT_ING_FRAME_1023] = "[mac] rx 512-1023 bytes",
+ [DPMAC_CNT_ING_FRAME_1518] = "[mac] rx 1024-1518 bytes",
+ [DPMAC_CNT_ING_FRAME_1519_MAX] = "[mac] rx 1519-max bytes",
+ [DPMAC_CNT_ING_FRAG] = "[mac] rx frags",
+ [DPMAC_CNT_ING_JABBER] = "[mac] rx jabber",
+ [DPMAC_CNT_ING_ALIGN_ERR] = "[mac] rx align errors",
+ [DPMAC_CNT_ING_OVERSIZED] = "[mac] rx oversized",
+ [DPMAC_CNT_ING_VALID_PAUSE_FRAME] = "[mac] rx pause",
+ [DPMAC_CNT_ING_BYTE] = "[mac] rx bytes",
+ [DPMAC_CNT_EGR_GOOD_FRAME] = "[mac] tx frames ok",
+ [DPMAC_CNT_EGR_UCAST_FRAME] = "[mac] tx u-cast",
+ [DPMAC_CNT_EGR_MCAST_FRAME] = "[mac] tx m-cast",
+ [DPMAC_CNT_EGR_BCAST_FRAME] = "[mac] tx b-cast",
+ [DPMAC_CNT_EGR_ERR_FRAME] = "[mac] tx frame errors",
+ [DPMAC_CNT_EGR_UNDERSIZED] = "[mac] tx undersized",
+ [DPMAC_CNT_EGR_VALID_PAUSE_FRAME] = "[mac] tx b-pause",
+ [DPMAC_CNT_EGR_BYTE] = "[mac] tx bytes",
+};
+
+#define LDPAA_ETH_DPMAC_NUM_STATS ARRAY_SIZE(ldpaa_eth_dpmac_stat_strings)
+
struct ldpaa_eth_priv {
struct phy_device *phy;
int phy_mode;
/* SW kept statistics */
u64 dpni_stats[LDPAA_ETH_DPNI_NUM_STATS];
+ u64 dpmac_stats[LDPAA_ETH_DPMAC_NUM_STATS];
};
struct dprc_endpoint dpmac_endpoint;