ethernetif.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /* eth device interface */
  37. struct pbuf* (*eth_rx)(rt_device_t dev);
  38. rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
  39. };
  40. int eth_system_device_init(void);
  41. void eth_device_deinit(struct eth_device *dev);
  42. rt_err_t eth_device_ready(struct eth_device* dev);
  43. rt_err_t eth_device_init(struct eth_device * dev, const char *name);
  44. rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flag);
  45. rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
  46. #ifdef __cplusplus
  47. }
  48. #endif
  49. #endif /* __NETIF_ETHERNETIF_H__ */