EoE rate statistics.

This commit is contained in:
Florian Pose 2006-08-04 15:31:12 +00:00
parent 577de08992
commit 337d7f763b
3 changed files with 33 additions and 0 deletions

View File

@ -101,6 +101,12 @@ int ec_eoe_init(ec_eoe_t *eoe /**< EoE handler */)
eoe->tx_frame_number = 0xFF;
memset(&eoe->stats, 0, sizeof(struct net_device_stats));
eoe->rx_counter = 0;
eoe->tx_counter = 0;
eoe->rx_rate = 0;
eoe->tx_rate = 0;
eoe->t_last = 0;
if (!(eoe->dev =
alloc_netdev(sizeof(ec_eoe_t *), "eoe%d", ether_setup))) {
EC_ERR("Unable to allocate net_device for EoE handler!\n");
@ -272,10 +278,22 @@ int ec_eoe_send(ec_eoe_t *eoe /**< EoE handler */)
void ec_eoe_run(ec_eoe_t *eoe /**< EoE handler */)
{
cycles_t t_now;
if (!eoe->opened) return;
// call state function
eoe->state(eoe);
// update statistics
t_now = get_cycles();
if ((u32) (t_now - eoe->t_last) > cpu_khz * 1000) {
eoe->rx_rate = eoe->rx_counter * 8;
eoe->tx_rate = eoe->tx_counter * 8;
eoe->rx_counter = 0;
eoe->tx_counter = 0;
eoe->t_last = t_now;
}
}
/*****************************************************************************/
@ -452,6 +470,7 @@ void ec_eoe_state_rx_fetch(ec_eoe_t *eoe /**< EoE handler */)
// update statistics
eoe->stats.rx_packets++;
eoe->stats.rx_bytes += eoe->rx_skb->len;
eoe->rx_counter += eoe->rx_skb->len;
#if EOE_DEBUG_LEVEL > 0
EC_DBG("EoE RX frame completed with %u octets.\n",
@ -568,6 +587,7 @@ void ec_eoe_state_tx_sent(ec_eoe_t *eoe /**< EoE handler */)
if (eoe->tx_offset >= eoe->tx_frame->skb->len) {
eoe->stats.tx_packets++;
eoe->stats.tx_bytes += eoe->tx_frame->skb->len;
eoe->tx_counter += eoe->tx_frame->skb->len;
dev_kfree_skb(eoe->tx_frame->skb);
kfree(eoe->tx_frame);
eoe->tx_frame = NULL;

View File

@ -90,6 +90,11 @@ struct ec_eoe
uint8_t tx_frame_number; /**< number of the transmitted frame */
uint8_t tx_fragment_number; /**< number of the fragment */
size_t tx_offset; /**< number of octets sent */
uint32_t rx_counter; /**< octets received during last second */
uint32_t tx_counter; /**< octets transmitted during last second */
uint32_t rx_rate; /**< receive rate (bps) */
uint32_t tx_rate; /**< transmit rate (bps) */
cycles_t t_last; /**< time of last output */
};
/*****************************************************************************/

View File

@ -707,6 +707,7 @@ ssize_t ec_master_info(ec_master_t *master, /**< EtherCAT master */
)
{
off_t off = 0;
ec_eoe_t *eoe;
uint32_t cur, sum, min, max, pos, i;
off += sprintf(buffer + off, "\nMode: ");
@ -753,6 +754,13 @@ ssize_t ec_master_info(ec_master_t *master, /**< EtherCAT master */
off += sprintf(buffer + off, " EoE cycle: %u / %u.%u / %u\n",
min, sum / HZ, (sum * 100 / HZ) % 100, max);
if (!list_empty(&master->eoe_handlers))
off += sprintf(buffer + off, "\nEoE Statistics (RX/TX) [bps]:");
list_for_each_entry(eoe, &master->eoe_handlers, list) {
off += sprintf(buffer + off, " %s: %u / %u\n",
eoe->dev->name, eoe->rx_rate, eoe->tx_rate);
}
off += sprintf(buffer + off, "\n");
return off;