developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1 | /* |
| 2 | * switch_netlink.h: switch(netlink) set API |
| 3 | * |
| 4 | * Author: Sirui Zhao <Sirui.Zhao@mediatek.com> |
| 5 | */ |
| 6 | #ifndef MT753X_NETLINK_H |
| 7 | #define MT753X_NETLINK_H |
| 8 | |
| 9 | #define MT753X_GENL_NAME "mt753x" |
| 10 | #define MT753X_DSA_GENL_NAME "mt753x_dsa" |
| 11 | #define MT753X_GENL_VERSION 0X1 |
| 12 | |
| 13 | /*add your cmd to here*/ |
| 14 | enum { |
| 15 | MT753X_CMD_UNSPEC = 0, /*Reserved*/ |
| 16 | MT753X_CMD_REQUEST, /*user->kernelrequest/get-response*/ |
| 17 | MT753X_CMD_REPLY, /*kernel->user event*/ |
| 18 | MT753X_CMD_READ, |
| 19 | MT753X_CMD_WRITE, |
| 20 | __MT753X_CMD_MAX, |
| 21 | }; |
| 22 | #define MT753X_CMD_MAX (__MT753X_CMD_MAX - 1) |
| 23 | |
| 24 | /*define attar types */ |
| 25 | enum |
| 26 | { |
| 27 | MT753X_ATTR_TYPE_UNSPEC = 0, |
| 28 | MT753X_ATTR_TYPE_MESG, /*MT753X message*/ |
| 29 | MT753X_ATTR_TYPE_PHY, |
| 30 | MT753X_ATTR_TYPE_PHY_DEV, |
| 31 | MT753X_ATTR_TYPE_REG, |
| 32 | MT753X_ATTR_TYPE_VAL, |
| 33 | MT753X_ATTR_TYPE_DEV_NAME, |
| 34 | MT753X_ATTR_TYPE_DEV_ID, |
| 35 | __MT753X_ATTR_TYPE_MAX, |
| 36 | }; |
| 37 | #define MT753X_ATTR_TYPE_MAX (__MT753X_ATTR_TYPE_MAX - 1) |
| 38 | |
| 39 | struct mt753x_attr { |
| 40 | int port_num; |
| 41 | int phy_dev; |
| 42 | int reg; |
| 43 | int value; |
| 44 | int type; |
| 45 | char op; |
| 46 | char *dev_info; |
| 47 | int dev_name; |
| 48 | int dev_id; |
| 49 | }; |
| 50 | |
| 51 | int mt753x_netlink_init(const char *name); |
| 52 | void mt753x_netlink_free(void); |
| 53 | void mt753x_list_swdev(struct mt753x_attr *arg, int cmd); |
| 54 | int reg_read_netlink(struct mt753x_attr *arg, unsigned int offset, |
| 55 | unsigned int *value); |
| 56 | int reg_write_netlink(struct mt753x_attr *arg, unsigned int offset, |
| 57 | unsigned int value); |
| 58 | int phy_cl22_read_netlink(struct mt753x_attr *arg, unsigned int port_num, |
| 59 | unsigned int phy_addr, unsigned int *value); |
| 60 | int phy_cl22_write_netlink(struct mt753x_attr *arg, unsigned int port_num, |
| 61 | unsigned int phy_addr, unsigned int value); |
| 62 | int phy_cl45_read_netlink(struct mt753x_attr *arg, unsigned int port_num, |
| 63 | unsigned int phy_dev, unsigned int phy_addr, |
| 64 | unsigned int *value); |
| 65 | int phy_cl45_write_netlink(struct mt753x_attr *arg, unsigned int port_num, |
| 66 | unsigned int phy_dev, unsigned int phy_addr, |
| 67 | unsigned int value); |
| 68 | int phy_dump_netlink(struct mt753x_attr *arg, int phy_addr); |
| 69 | |
| 70 | #endif |