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 11 #ifndef __NETIF_ETHERNETIF_H__ 12 #define __NETIF_ETHERNETIF_H__ 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 #include "lwip/netif.h" 19 #include <rtthread.h> 20 21 #define NIOCTL_GADDR 0x01 22 #ifndef RT_LWIP_ETH_MTU 23 #define ETHERNET_MTU 1500 24 #else 25 #define ETHERNET_MTU RT_LWIP_ETH_MTU 26 #endif 27 28 /* eth flag with auto_linkup or phy_linkup */ 29 #define ETHIF_LINK_AUTOUP 0x0000 30 #define ETHIF_LINK_PHYUP 0x0100 31 32 struct eth_device 33 { 34 /* inherit from rt_device */ 35 struct rt_device parent; 36 37 /* network interface for lwip */ 38 struct netif *netif; 39 40 rt_uint16_t flags; 41 rt_uint8_t link_changed; 42 rt_uint8_t link_status; 43 rt_uint8_t rx_notice; 44 45 struct rt_spinlock spinlock; 46 47 /* eth device interface */ 48 struct pbuf* (*eth_rx)(rt_device_t dev); 49 rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p); 50 }; 51 52 int eth_system_device_init(void); 53 void eth_device_deinit(struct eth_device *dev); 54 rt_err_t eth_device_ready(struct eth_device* dev); 55 rt_err_t eth_device_init(struct eth_device * dev, const char *name); 56 rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flag); 57 rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up); 58 59 #ifdef __cplusplus 60 } 61 #endif 62 63 #endif /* __NETIF_ETHERNETIF_H__ */ 64