ethernetif.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-02-22 xiangxistu integrate v1.4.1 v2.0.3 and v2.1.2 porting layer
  9. */
  10. #ifndef __NETIF_ETHERNETIF_H__
  11. #define __NETIF_ETHERNETIF_H__
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include "lwip/netif.h"
  16. #include <rtthread.h>
  17. #define NIOCTL_GADDR 0x01
  18. #ifndef RT_LWIP_ETH_MTU
  19. #define ETHERNET_MTU 1500
  20. #else
  21. #define ETHERNET_MTU RT_LWIP_ETH_MTU
  22. #endif
  23. /* eth flag with auto_linkup or phy_linkup */
  24. #define ETHIF_LINK_AUTOUP 0x0000
  25. #define ETHIF_LINK_PHYUP 0x0100
  26. struct eth_device
  27. {
  28. /* inherit from rt_device */
  29. struct rt_device parent;
  30. /* network interface for lwip */
  31. struct netif *netif;
  32. rt_uint16_t flags;
  33. rt_uint8_t link_changed;
  34. rt_uint8_t link_status;
  35. rt_uint8_t rx_notice;
  36. struct rt_spinlock spinlock;
  37. /* eth device interface */
  38. struct pbuf* (*eth_rx)(rt_device_t dev);
  39. rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
  40. };
  41. int eth_system_device_init(void);
  42. void eth_device_deinit(struct eth_device *dev);
  43. rt_err_t eth_device_ready(struct eth_device* dev);
  44. rt_err_t eth_device_init(struct eth_device * dev, const char *name);
  45. rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flag);
  46. rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50. #endif /* __NETIF_ETHERNETIF_H__ */