| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- /*
- * Copyright (c) 2025, sakumisu
- *
- * SPDX-License-Identifier: Apache-2.0
- */
- #ifndef EC_NETDEV_H
- #define EC_NETDEV_H
- #include "phy/chry_phy.h"
- typedef struct ec_master ec_master_t;
- /** Netdev statistics.
- */
- typedef struct {
- uint64_t tx_count; /**< Number of frames sent. */
- uint64_t last_tx_count; /**< Number of frames sent of last statistics cycle. */
- uint64_t rx_count; /**< Number of frames received. */
- uint64_t last_rx_count; /**< Number of frames received of last statistics cycle. */
- uint64_t tx_bytes; /**< Number of bytes sent. */
- uint64_t last_tx_bytes; /**< Number of bytes sent of last statistics cycle. */
- uint64_t rx_bytes; /**< Number of bytes received. */
- uint64_t last_rx_bytes; /**< Number of bytes received of last statistics cycle. */
- uint64_t tx_errors; /**< Number of transmit errors. */
- uint64_t loss_count; /**< Number of lost frames. */
- int32_t tx_frame_rates[EC_RATE_COUNT]; /**< Transmit rates in frames/s for different statistics cycle periods.*/
- int32_t rx_frame_rates[EC_RATE_COUNT]; /**< Receive rates in frames/s for different statistics cycle periods.*/
- int32_t tx_byte_rates[EC_RATE_COUNT]; /**< Transmit rates in byte/s for different statistics cycle periods. */
- int32_t rx_byte_rates[EC_RATE_COUNT]; /**< Receive rates in byte/s for different statistics cycle periods. */
- int32_t loss_rates[EC_RATE_COUNT]; /**< Frame loss rates for different statistics cycle periods. */
- uint64_t last_jiffies; /**< Jiffies of last statistic cycle [ns]. */
- } ec_netdev_stats_t;
- typedef struct ec_netdev {
- ec_master_t *master;
- struct chry_phy_device phydev;
- uint8_t index;
- char name[24];
- uint8_t mac_addr[6];
- bool link_state;
- uint8_t tx_frame_index;
- ec_netdev_stats_t stats;
- } ec_netdev_t;
- void ec_netdev_update_stats(ec_netdev_t *netdev);
- ec_netdev_t *ec_netdev_init(uint8_t netdev_index);
- void ec_netdev_poll_link_state(ec_netdev_t *netdev);
- uint8_t *ec_netdev_get_txbuf(ec_netdev_t *netdev);
- int ec_netdev_send(ec_netdev_t *netdev, uint32_t size);
- void ec_netdev_receive(ec_netdev_t *netdev, uint8_t *frame, uint32_t size);
- #endif
|