• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 ETH_DEVICE_H
10 #define ETH_DEVICE_H
11 
12 #include "net_device.h"
13 #include "hdf_device_desc.h"
14 #include <lwip/netif.h>
15 
16 #define MAX_NAME_LENGTH 16
17 #define ETH_DEVICE_MAX 6
18 
19 #define DELAY_TIME_LONG     3000
20 #define DELAY_TIME_MEDIUM   50
21 #define DELAY_TIME_SHORT    5
22 #define SLEEP_TIME_SHORT    20
23 #define SLEEP_TIME_MEDIUM   30
24 #define SLEEP_TIME_COMMON   60
25 #define SLEEP_TIME_LONG     250
26 
27 #define MAC_ADDR_OFFSET_L8  8
28 #define MAC_ADDR_OFFSET_L16 16
29 #define MAC_ADDR_OFFSET_L24 24
30 
31 struct EthDevice {
32     struct NetDevice *netdev;
33     struct ConfigEthDevList *config;
34     const char *name;
35     void *priv;
36 };
37 
38 struct HdfConfigEthMac {
39     uint32_t regBase;
40     uint32_t irqVector;
41     uint8_t mdioFrqDiv;
42     uint8_t txBusy;
43     uint32_t iobase;
44     uint32_t regOffSize;
45 };
46 
47 struct HdfConfigEthPhy {
48     uint8_t phyMode;
49 };
50 
51 struct ConfigEthDevList {
52     uint8_t deviceInstId;
53     uint8_t isSetDefault;
54     const char *driverName;
55     uint8_t hwXmitq;
56     uint8_t qSize;
57     uint8_t port;
58     struct HdfConfigEthMac ethMac;
59     struct HdfConfigEthPhy ethPhy;
60 };
61 
62 struct EthConfig {
63     struct ConfigEthDevList deviceInst[ETH_DEVICE_MAX];
64     uint16_t deviceListSize;
65 };
66 
67 struct EthDevice *CreateEthDevice(const struct ConfigEthDevList *configEthDevList);
68 int32_t ReleaseEthDevice(struct EthDevice *ethDevice);
69 int32_t GetEthIfName(const struct ConfigEthDevList *configEthDevList, char *ifName, uint32_t ifNameSize);
70 struct EthConfig *GetEthConfig(const struct DeviceResourceNode *node);
71 
72 #endif /* ETH_DEVICE_H */
73