]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - net/dsa/dsa_priv.h
net: dsa: add MDB notifier
[mirror_ubuntu-bionic-kernel.git] / net / dsa / dsa_priv.h
1 /*
2 * net/dsa/dsa_priv.h - Hardware switch handling
3 * Copyright (c) 2008-2009 Marvell Semiconductor
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
10
11 #ifndef __DSA_PRIV_H
12 #define __DSA_PRIV_H
13
14 #include <linux/phy.h>
15 #include <linux/netdevice.h>
16 #include <linux/netpoll.h>
17 #include <net/dsa.h>
18
19 enum {
20 DSA_NOTIFIER_AGEING_TIME,
21 DSA_NOTIFIER_BRIDGE_JOIN,
22 DSA_NOTIFIER_BRIDGE_LEAVE,
23 DSA_NOTIFIER_FDB_ADD,
24 DSA_NOTIFIER_FDB_DEL,
25 DSA_NOTIFIER_MDB_ADD,
26 DSA_NOTIFIER_MDB_DEL,
27 };
28
29 /* DSA_NOTIFIER_AGEING_TIME */
30 struct dsa_notifier_ageing_time_info {
31 struct switchdev_trans *trans;
32 unsigned int ageing_time;
33 int sw_index;
34 };
35
36 /* DSA_NOTIFIER_BRIDGE_* */
37 struct dsa_notifier_bridge_info {
38 struct net_device *br;
39 int sw_index;
40 int port;
41 };
42
43 /* DSA_NOTIFIER_FDB_* */
44 struct dsa_notifier_fdb_info {
45 const struct switchdev_obj_port_fdb *fdb;
46 struct switchdev_trans *trans;
47 int sw_index;
48 int port;
49 };
50
51 /* DSA_NOTIFIER_MDB_* */
52 struct dsa_notifier_mdb_info {
53 const struct switchdev_obj_port_mdb *mdb;
54 struct switchdev_trans *trans;
55 int sw_index;
56 int port;
57 };
58
59 struct dsa_device_ops {
60 struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev);
61 struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,
62 struct packet_type *pt,
63 struct net_device *orig_dev);
64 };
65
66 struct dsa_slave_priv {
67 struct sk_buff * (*xmit)(struct sk_buff *skb,
68 struct net_device *dev);
69
70 /* DSA port data, such as switch, port index, etc. */
71 struct dsa_port *dp;
72
73 /*
74 * The phylib phy_device pointer for the PHY connected
75 * to this port.
76 */
77 struct phy_device *phy;
78 phy_interface_t phy_interface;
79 int old_link;
80 int old_pause;
81 int old_duplex;
82
83 #ifdef CONFIG_NET_POLL_CONTROLLER
84 struct netpoll *netpoll;
85 #endif
86
87 /* TC context */
88 struct list_head mall_tc_list;
89 };
90
91 /* dsa.c */
92 int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev,
93 struct dsa_port *dport, int port);
94 void dsa_cpu_dsa_destroy(struct dsa_port *dport);
95 const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
96 int dsa_cpu_port_ethtool_setup(struct dsa_switch *ds);
97 void dsa_cpu_port_ethtool_restore(struct dsa_switch *ds);
98
99 /* legacy.c */
100 int dsa_legacy_register(void);
101 void dsa_legacy_unregister(void);
102
103 /* port.c */
104 int dsa_port_set_state(struct dsa_port *dp, u8 state,
105 struct switchdev_trans *trans);
106 void dsa_port_set_state_now(struct dsa_port *dp, u8 state);
107 int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br);
108 void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br);
109 int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
110 struct switchdev_trans *trans);
111 int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock,
112 struct switchdev_trans *trans);
113 int dsa_port_fdb_add(struct dsa_port *dp,
114 const struct switchdev_obj_port_fdb *fdb,
115 struct switchdev_trans *trans);
116 int dsa_port_fdb_del(struct dsa_port *dp,
117 const struct switchdev_obj_port_fdb *fdb);
118 int dsa_port_fdb_dump(struct dsa_port *dp, struct switchdev_obj_port_fdb *fdb,
119 switchdev_obj_dump_cb_t *cb);
120 int dsa_port_mdb_add(struct dsa_port *dp,
121 const struct switchdev_obj_port_mdb *mdb,
122 struct switchdev_trans *trans);
123 int dsa_port_mdb_del(struct dsa_port *dp,
124 const struct switchdev_obj_port_mdb *mdb);
125 int dsa_port_mdb_dump(struct dsa_port *dp, struct switchdev_obj_port_mdb *mdb,
126 switchdev_obj_dump_cb_t *cb);
127 int dsa_port_vlan_add(struct dsa_port *dp,
128 const struct switchdev_obj_port_vlan *vlan,
129 struct switchdev_trans *trans);
130 int dsa_port_vlan_del(struct dsa_port *dp,
131 const struct switchdev_obj_port_vlan *vlan);
132 int dsa_port_vlan_dump(struct dsa_port *dp,
133 struct switchdev_obj_port_vlan *vlan,
134 switchdev_obj_dump_cb_t *cb);
135
136 /* slave.c */
137 extern const struct dsa_device_ops notag_netdev_ops;
138 void dsa_slave_mii_bus_init(struct dsa_switch *ds);
139 void dsa_cpu_port_ethtool_init(struct ethtool_ops *ops);
140 int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
141 int port, const char *name);
142 void dsa_slave_destroy(struct net_device *slave_dev);
143 int dsa_slave_suspend(struct net_device *slave_dev);
144 int dsa_slave_resume(struct net_device *slave_dev);
145 int dsa_slave_register_notifier(void);
146 void dsa_slave_unregister_notifier(void);
147
148 /* switch.c */
149 int dsa_switch_register_notifier(struct dsa_switch *ds);
150 void dsa_switch_unregister_notifier(struct dsa_switch *ds);
151
152 /* tag_brcm.c */
153 extern const struct dsa_device_ops brcm_netdev_ops;
154
155 /* tag_dsa.c */
156 extern const struct dsa_device_ops dsa_netdev_ops;
157
158 /* tag_edsa.c */
159 extern const struct dsa_device_ops edsa_netdev_ops;
160
161 /* tag_lan9303.c */
162 extern const struct dsa_device_ops lan9303_netdev_ops;
163
164 /* tag_mtk.c */
165 extern const struct dsa_device_ops mtk_netdev_ops;
166
167 /* tag_qca.c */
168 extern const struct dsa_device_ops qca_netdev_ops;
169
170 /* tag_trailer.c */
171 extern const struct dsa_device_ops trailer_netdev_ops;
172
173 #endif