net: ldpaa_eth: extend debug capabilities with DPMAC statistics

The ldpaa_eth driver already had a DPMAC statistics dump, this patch
extends the list of stats and adds a bit more structure to the code.

For a bit more context, the DPAA2 u-boot software architecture uses a
default network interface object - a DPNI - which, at runtime, will get
connected to the currently used DPMAC object.
Each time the .stop() eth callback is called, the DPMAC is destroyed
thus any previous counters will get lost.

As a preparation for the next patches, we add a software kept set of
DPMAC counters which will get updated before each destroy operation
takes place.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
Ioana Ciornei 2023-05-23 16:47:46 +03:00 committed by Peng Fan
parent 308d67e77d
commit 22df08d82e
3 changed files with 76 additions and 77 deletions

View File

@ -79,8 +79,33 @@ static void ldpaa_eth_add_dpni_stats(struct udevice *dev, u64 *data)
priv->dpni_stats[i] += data[i]; 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) static void ldpaa_eth_dump_dpni_stats(struct udevice *dev, u64 *data)
{ {
int i; int i;
@ -90,82 +115,13 @@ static void ldpaa_eth_dump_dpni_stats(struct udevice *dev, u64 *data)
printf(" %s: %llu\n", ldpaa_eth_dpni_stat_strings[i], data[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 i;
int err = 0;
u64 value;
err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS, printf("DPMAC counters:\n");
priv->dpmac_handle, for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++)
DPMAC_CNT_ING_BYTE, printf(" %s: %llu\n", ldpaa_eth_dpmac_stat_strings[i], data[i]);
&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);
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);
} }
#endif #endif
@ -559,9 +515,15 @@ static void ldpaa_eth_stop(struct udevice *dev)
} }
kfree(data); 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 #ifdef DEBUG
ldpaa_eth_get_dpmac_counter(dev); ldpaa_eth_dump_dpmac_stats(dev, data);
#endif #endif
}
kfree(data);
err = dprc_disconnect(dflt_mc_io, MC_CMD_NO_FLAGS, err = dprc_disconnect(dflt_mc_io, MC_CMD_NO_FLAGS,
dflt_dprc_handle, &dpmac_endpoint); dflt_dprc_handle, &dpmac_endpoint);

View File

@ -142,6 +142,39 @@ static const char ldpaa_eth_dpni_stat_strings[][ETH_GSTRING_LEN] = {
#define LDPAA_ETH_DPNI_NUM_STATS ARRAY_SIZE(ldpaa_eth_dpni_stat_strings) #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 ldpaa_eth_priv {
struct phy_device *phy; struct phy_device *phy;
int phy_mode; int phy_mode;
@ -159,6 +192,7 @@ struct ldpaa_eth_priv {
/* SW kept statistics */ /* SW kept statistics */
u64 dpni_stats[LDPAA_ETH_DPNI_NUM_STATS]; u64 dpni_stats[LDPAA_ETH_DPNI_NUM_STATS];
u64 dpmac_stats[LDPAA_ETH_DPMAC_NUM_STATS];
}; };
struct dprc_endpoint dpmac_endpoint; struct dprc_endpoint dpmac_endpoint;

View File

@ -412,6 +412,8 @@ int dpmac_set_link_state(struct fsl_mc_io *mc_io,
* @DPMAC_CNT_EGR_ERR_FRAME: counts frame transmitted with an error * @DPMAC_CNT_EGR_ERR_FRAME: counts frame transmitted with an error
* @DPMAC_CNT_ING_GOOD_FRAME: counts frame received without error, including * @DPMAC_CNT_ING_GOOD_FRAME: counts frame received without error, including
* pause frames. * pause frames.
* @DPMAC_CNT_EGR_GOOD_FRAME: counts frames transmitted without error, including
* pause frames.
*/ */
enum dpmac_counter { enum dpmac_counter {
DPMAC_CNT_ING_FRAME_64, DPMAC_CNT_ING_FRAME_64,
@ -440,7 +442,8 @@ enum dpmac_counter {
DPMAC_CNT_EGR_BCAST_FRAME, DPMAC_CNT_EGR_BCAST_FRAME,
DPMAC_CNT_EGR_UCAST_FRAME, DPMAC_CNT_EGR_UCAST_FRAME,
DPMAC_CNT_EGR_ERR_FRAME, DPMAC_CNT_EGR_ERR_FRAME,
DPMAC_CNT_ING_GOOD_FRAME DPMAC_CNT_ING_GOOD_FRAME,
DPMAC_CNT_EGR_GOOD_FRAME,
}; };
/** /**