via UNDI API and also by ifstat command; may be useful for debugging.
const uint8_t *ll_broadcast;
};
+/**
+ * Network device statistics
+ *
+ */
+struct net_device_stats {
+ /** Count of successfully completed transmissions */
+ unsigned int tx_count;
+ /** Count of successfully received packets */
+ unsigned int rx_count;
+};
+
/**
* A network device
*
struct list_head tx_queue;
/** RX packet queue */
struct list_head rx_queue;
+ /** Device statistics */
+ struct net_device_stats stats;
/** Driver private data */
void *priv;
/* PXENV_UNDI_GET_STATISTICS
*
- * Status: won't implement (would require driver API changes for no
- * real benefit)
+ * Status: working
*/
PXENV_EXIT_t pxenv_undi_get_statistics ( struct s_PXENV_UNDI_GET_STATISTICS
*undi_get_statistics ) {
DBG ( "PXENV_UNDI_GET_STATISTICS" );
- undi_get_statistics->Status = PXENV_STATUS_UNSUPPORTED;
- return PXENV_EXIT_FAILURE;
+ undi_get_statistics->XmtGoodFrames = pxe_netdev->stats.tx_count;
+ undi_get_statistics->RcvGoodFrames = pxe_netdev->stats.rx_count;
+ undi_get_statistics->RcvCRCErrors = 0;
+ undi_get_statistics->RcvResourceErrors = 0;
+
+ undi_get_statistics->Status = PXENV_STATUS_SUCCESS;
+ return PXENV_EXIT_SUCCESS;
}
/* PXENV_UNDI_CLEAR_STATISTICS
*
- * Status: won't implement (would require driver API changes for no
- * real benefit)
+ * Status: working
*/
PXENV_EXIT_t pxenv_undi_clear_statistics ( struct s_PXENV_UNDI_CLEAR_STATISTICS
*undi_clear_statistics ) {
DBG ( "PXENV_UNDI_CLEAR_STATISTICS" );
- undi_clear_statistics->Status = PXENV_STATUS_UNSUPPORTED;
- return PXENV_EXIT_FAILURE;
+ memset ( &pxe_netdev->stats, 0, sizeof ( pxe_netdev->stats ) );
+
+ undi_clear_statistics->Status = PXENV_STATUS_SUCCESS;
+ return PXENV_EXIT_SUCCESS;
}
/* PXENV_UNDI_INITIATE_DIAGS
assert ( iobuf->list.next != NULL );
assert ( iobuf->list.prev != NULL );
+ /* Dequeue and free I/O buffer */
list_del ( &iobuf->list );
free_iob ( iobuf );
+
+ /* Update statistics counter */
+ netdev->stats.tx_count++;
}
/**
void netdev_rx ( struct net_device *netdev, struct io_buffer *iobuf ) {
DBGC ( netdev, "NETDEV %p received %p (%p+%zx)\n",
netdev, iobuf, iobuf->data, iob_len ( iobuf ) );
+
+ /* Enqueue packet */
list_add_tail ( &iobuf->list, &netdev->rx_queue );
+
+ /* Update statistics counter */
+ netdev->stats.rx_count++;
}
/**
* @v netdev Network device
*/
void ifstat ( struct net_device *netdev ) {
- printf ( "%s: %s on %s (%s)\n",
+ printf ( "%s: %s on %s (%s) TX:%d RX:%d\n",
netdev->name, netdev_hwaddr ( netdev ), netdev->dev->name,
- ( ( netdev->state & NETDEV_OPEN ) ? "open" : "closed" ) );
+ ( ( netdev->state & NETDEV_OPEN ) ? "open" : "closed" ),
+ netdev->stats.tx_count, netdev->stats.rx_count );
}