• 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_CHIP_DRIVER_H
10 #define ETH_CHIP_DRIVER_H
11 
12 #include "eth_device.h"
13 #include "net_device.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #define MAX_CHIPDRIVER_COUNT 16
20 
21 struct EthMacOps {
22     void (*MacInit)(void);
23     int32_t (*PortReset)(struct EthDevice *ethDevice);
24     int32_t (*PortInit)(struct EthDevice *ethDevice);
25 };
26 
27 struct HdfEthMacChipDriver {
28     struct EthMacOps *ethMacOps;  /**< Ethernet Mac some basic methods */
29 };
30 
31 struct HdfEthNetDeviceData {
32     struct HdfEthMacChipDriver *macChipDriver;   /**< Mac ChipDriver */
33 };
34 
35 struct HdfEthNetDeviceData *GetEthNetDeviceData(const struct NetDevice *netDev);
36 
37 struct HdfEthChipDriverFactory {
38     const char *driverName;
39     int32_t (*InitEthDriver)(struct EthDevice *ethDevice);
40     int32_t (*DeinitEthDriver)(struct EthDevice *ethDevice);
41     struct HdfEthMacChipDriver *(*BuildMacDriver)(void);
42     void (*ReleaseMacDriver)(struct HdfEthMacChipDriver *chipDriver);
43     void (*GetMacAddr)(unsigned char *addr, int len);
44 };
45 
46 struct HdfEthChipDriverManager {
47     struct HdfEthChipDriverFactory **chipFactoryInsts;
48     int32_t (*RegChipDriver)(struct HdfEthChipDriverFactory *factoryInst);
49     struct HdfEthChipDriverFactory *(*GetEthChipDriverByName)(const char *name);
50 };
51 
52 struct HdfEthChipDriverManager *HdfEthGetChipDriverMgr(void);
53 
54 #ifdef __cplusplus
55 }
56 #endif
57 
58 #endif /* ETH_CHIP_DRIVER_H */
59