1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef HDF_NET_DEVICE_IMPL_MODULE_H 10 #define HDF_NET_DEVICE_IMPL_MODULE_H 11 12 #include "net_device.h" 13 #if defined(CONFIG_DRIVERS_HDF_IMX8MM_ETHERNET) 14 #include <linux/phy.h> 15 #endif 16 17 #define MAX_NETDEVICE_COUNT 20 18 19 struct NetDeviceImpl { 20 struct NetDevice *netDevice; 21 struct NetDeviceImplOp *interFace; 22 void *osPrivate; 23 }; 24 typedef enum { 25 NO_IN_INTERRUPT, 26 IN_INTERRUPT, 27 MAX_RECEIVE_FLAG 28 } ReceiveFlag; 29 30 struct NetDeviceImplOp { 31 int32_t (*init)(struct NetDeviceImpl *netDevice); 32 int32_t (*deInit)(struct NetDeviceImpl *netDevice); 33 int32_t (*add)(struct NetDeviceImpl *netDevice); 34 int32_t (*delete)(struct NetDeviceImpl *netDevice); 35 int32_t (*setStatus)(struct NetDeviceImpl *netDevice, NetIfStatus status); 36 int32_t (*setLinkStatus)(struct NetDeviceImpl *netDevice, NetIfLinkStatus status); 37 int32_t (*getLinkStatus)(struct NetDeviceImpl *netDevice, NetIfLinkStatus *status); 38 int32_t (*receive)(struct NetDeviceImpl *netDevice, NetBuf *buff, ReceiveFlag flag); 39 int32_t (*setIpAddr)(struct NetDeviceImpl *netDevice, const IpV4Addr *ipAddr, const IpV4Addr *netMask, 40 const IpV4Addr *gw); 41 int32_t (*dhcpsStart)(struct NetDeviceImpl *netDevice, char *ip, uint16_t ipNum); 42 int32_t (*dhcpsStop)(struct NetDeviceImpl *netDevice); 43 int32_t (*dhcpStart)(struct NetDeviceImpl *netDevice); 44 int32_t (*dhcpStop)(struct NetDeviceImpl *netDevice); 45 int32_t (*dhcpIsBound)(struct NetDeviceImpl *netDevice); 46 int32_t (*changeMacAddr)(struct NetDeviceImpl *netDevice); 47 #if defined(CONFIG_DRIVERS_HDF_IMX8MM_ETHERNET) 48 void (*netif_napi_add)(struct NetDeviceImpl *impl, struct napi_struct *napi, 49 int (*poll)(struct napi_struct *, int), int weight); 50 struct netdev_queue *(*get_tx_queue)(struct NetDeviceImpl *impl, unsigned int queue); 51 __be16 (*type_trans)(struct NetDeviceImpl *impl, struct sk_buff *skb); 52 struct sk_buff* (*alloc_buf)(struct NetDeviceImpl *impl, uint32_t length); 53 void (*start_queue)(struct NetDeviceImpl *impl); 54 void (*disable_tx)(struct NetDeviceImpl *impl); 55 void (*set_dev)(struct NetDeviceImpl *impl, struct device *dev); 56 void (*wake_queue)(struct NetDeviceImpl *impl); 57 struct phy_device *(*of_phyconnect)(struct NetDeviceImpl *impl, 58 struct device_node *phy_np, 59 void (*hndlr)(struct net_device *), u32 flags, 60 phy_interface_t iface); 61 #endif 62 }; 63 64 #endif /* HDF_NET_DEVICE_IMPL_MODULE_H */