blob: b3f946efe8fb59936781e80c941dcf78dd505cb5 [file] [log] [blame]
developerfd40db22021-04-29 10:08:25 +08001/*
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*/
14enum {
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 */
25enum
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
39struct 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
51int mt753x_netlink_init(const char *name);
52void mt753x_netlink_free(void);
53void mt753x_list_swdev(struct mt753x_attr *arg, int cmd);
54int reg_read_netlink(struct mt753x_attr *arg, unsigned int offset,
55 unsigned int *value);
56int reg_write_netlink(struct mt753x_attr *arg, unsigned int offset,
57 unsigned int value);
58int phy_cl22_read_netlink(struct mt753x_attr *arg, unsigned int port_num,
59 unsigned int phy_addr, unsigned int *value);
60int phy_cl22_write_netlink(struct mt753x_attr *arg, unsigned int port_num,
61 unsigned int phy_addr, unsigned int value);
62int 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);
65int 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);
68int phy_dump_netlink(struct mt753x_attr *arg, int phy_addr);
69
70#endif