]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blame - net/dsa/dsa_priv.h
UBUNTU: Ubuntu-5.4.0-117.132
[mirror_ubuntu-focal-kernel.git] / net / dsa / dsa_priv.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
91da11f8
LB
2/*
3 * net/dsa/dsa_priv.h - Hardware switch handling
e84665c9 4 * Copyright (c) 2008-2009 Marvell Semiconductor
91da11f8
LB
5 */
6
7#ifndef __DSA_PRIV_H
8#define __DSA_PRIV_H
9
91da11f8 10#include <linux/phy.h>
5075314e 11#include <linux/netdevice.h>
04ff53f9 12#include <linux/netpoll.h>
ea5dd34b 13#include <net/dsa.h>
82ed3610 14#include <net/gro_cells.h>
5075314e 15
52c96f9d 16enum {
1faabf74 17 DSA_NOTIFIER_AGEING_TIME,
52c96f9d
VD
18 DSA_NOTIFIER_BRIDGE_JOIN,
19 DSA_NOTIFIER_BRIDGE_LEAVE,
685fb6a4
VD
20 DSA_NOTIFIER_FDB_ADD,
21 DSA_NOTIFIER_FDB_DEL,
8ae5bcdc
VD
22 DSA_NOTIFIER_MDB_ADD,
23 DSA_NOTIFIER_MDB_DEL,
d0c627b8
VD
24 DSA_NOTIFIER_VLAN_ADD,
25 DSA_NOTIFIER_VLAN_DEL,
52c96f9d
VD
26};
27
1faabf74
VD
28/* DSA_NOTIFIER_AGEING_TIME */
29struct dsa_notifier_ageing_time_info {
30 struct switchdev_trans *trans;
31 unsigned int ageing_time;
1faabf74
VD
32};
33
52c96f9d
VD
34/* DSA_NOTIFIER_BRIDGE_* */
35struct dsa_notifier_bridge_info {
36 struct net_device *br;
37 int sw_index;
38 int port;
39};
40
685fb6a4
VD
41/* DSA_NOTIFIER_FDB_* */
42struct dsa_notifier_fdb_info {
685fb6a4
VD
43 int sw_index;
44 int port;
2acf4e6a
AS
45 const unsigned char *addr;
46 u16 vid;
685fb6a4
VD
47};
48
8ae5bcdc
VD
49/* DSA_NOTIFIER_MDB_* */
50struct dsa_notifier_mdb_info {
51 const struct switchdev_obj_port_mdb *mdb;
52 struct switchdev_trans *trans;
53 int sw_index;
54 int port;
55};
56
d0c627b8
VD
57/* DSA_NOTIFIER_VLAN_* */
58struct dsa_notifier_vlan_info {
59 const struct switchdev_obj_port_vlan *vlan;
60 struct switchdev_trans *trans;
61 int sw_index;
62 int port;
63};
64
91da11f8 65struct dsa_slave_priv {
15240248 66 /* Copy of CPU port xmit for faster access in slave transmit hot path */
4ed70ce9 67 struct sk_buff * (*xmit)(struct sk_buff *skb,
5075314e 68 struct net_device *dev);
e84665c9 69
5f6b4e14 70 struct pcpu_sw_netstats *stats64;
f613ed66 71
82ed3610
AL
72 struct gro_cells gcells;
73
afdcf151
VD
74 /* DSA port data, such as switch, port index, etc. */
75 struct dsa_port *dp;
e84665c9 76
04ff53f9
FF
77#ifdef CONFIG_NET_POLL_CONTROLLER
78 struct netpoll *netpoll;
79#endif
f50f2127
FF
80
81 /* TC context */
82 struct list_head mall_tc_list;
91da11f8
LB
83};
84
91da11f8 85/* dsa.c */
c39e2a1d 86const struct dsa_device_ops *dsa_tag_driver_get(int tag_protocol);
4dad81ee 87void dsa_tag_driver_put(const struct dsa_device_ops *ops);
c39e2a1d 88
c9eb3e0f 89bool dsa_schedule_work(struct work_struct *work);
98cdb480 90const char *dsa_tag_protocol_to_str(const struct dsa_device_ops *ops);
91da11f8 91
37b8da1a
AS
92int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
93 struct net_device *dev,
94 const unsigned char *addr, u16 vid,
87b0984e
PM
95 u16 flags,
96 struct netlink_ext_ack *extack);
37b8da1a
AS
97int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
98 struct net_device *dev,
99 const unsigned char *addr, u16 vid);
a6a71f19 100
f2f23566 101/* master.c */
17a22fcf
VD
102int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp);
103void dsa_master_teardown(struct net_device *dev);
f2f23566 104
2231c43b
VD
105static inline struct net_device *dsa_master_find_slave(struct net_device *dev,
106 int device, int port)
3775b1b7 107{
2f657a60
VD
108 struct dsa_port *cpu_dp = dev->dsa_ptr;
109 struct dsa_switch_tree *dst = cpu_dp->dst;
3775b1b7 110 struct dsa_switch *ds;
fc5f3376 111 struct dsa_port *slave_port;
3775b1b7
VD
112
113 if (device < 0 || device >= DSA_MAX_SWITCHES)
114 return NULL;
115
116 ds = dst->ds[device];
117 if (!ds)
118 return NULL;
119
120 if (port < 0 || port >= ds->num_ports)
121 return NULL;
122
fc5f3376
AL
123 slave_port = &ds->ports[port];
124
125 if (unlikely(slave_port->type != DSA_PORT_TYPE_USER))
126 return NULL;
127
128 return slave_port->slave;
3775b1b7
VD
129}
130
a40c175b
VD
131/* port.c */
132int dsa_port_set_state(struct dsa_port *dp, u8 state,
133 struct switchdev_trans *trans);
888ae539 134int dsa_port_enable_rt(struct dsa_port *dp, struct phy_device *phy);
fb8a6a2b 135int dsa_port_enable(struct dsa_port *dp, struct phy_device *phy);
888ae539 136void dsa_port_disable_rt(struct dsa_port *dp);
75104db0 137void dsa_port_disable(struct dsa_port *dp);
cfbed329
VD
138int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br);
139void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br);
4d61d304
VD
140int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
141 struct switchdev_trans *trans);
d87bd94e
VD
142int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock,
143 struct switchdev_trans *trans);
2acf4e6a
AS
144int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
145 u16 vid);
146int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
147 u16 vid);
de40fc5d 148int dsa_port_fdb_dump(struct dsa_port *dp, dsa_fdb_dump_cb_t *cb, void *data);
bb9f6031 149int dsa_port_mdb_add(const struct dsa_port *dp,
3a9afea3
VD
150 const struct switchdev_obj_port_mdb *mdb,
151 struct switchdev_trans *trans);
bb9f6031 152int dsa_port_mdb_del(const struct dsa_port *dp,
3a9afea3 153 const struct switchdev_obj_port_mdb *mdb);
ea87005a
FF
154int dsa_port_pre_bridge_flags(const struct dsa_port *dp, unsigned long flags,
155 struct switchdev_trans *trans);
57652796
RK
156int dsa_port_bridge_flags(const struct dsa_port *dp, unsigned long flags,
157 struct switchdev_trans *trans);
08cc83cc
VD
158int dsa_port_mrouter(struct dsa_port *dp, bool mrouter,
159 struct switchdev_trans *trans);
076e7133
VD
160int dsa_port_vlan_add(struct dsa_port *dp,
161 const struct switchdev_obj_port_vlan *vlan,
162 struct switchdev_trans *trans);
163int dsa_port_vlan_del(struct dsa_port *dp,
164 const struct switchdev_obj_port_vlan *vlan);
314f76d7
VO
165int dsa_port_vid_add(struct dsa_port *dp, u16 vid, u16 flags);
166int dsa_port_vid_del(struct dsa_port *dp, u16 vid);
33615367
SR
167int dsa_port_link_register_of(struct dsa_port *dp);
168void dsa_port_link_unregister_of(struct dsa_port *dp);
77373d49
IC
169void dsa_port_phylink_validate(struct phylink_config *config,
170 unsigned long *supported,
171 struct phylink_link_state *state);
172int dsa_port_phylink_mac_link_state(struct phylink_config *config,
173 struct phylink_link_state *state);
174void dsa_port_phylink_mac_config(struct phylink_config *config,
175 unsigned int mode,
176 const struct phylink_link_state *state);
177void dsa_port_phylink_mac_an_restart(struct phylink_config *config);
178void dsa_port_phylink_mac_link_down(struct phylink_config *config,
179 unsigned int mode,
180 phy_interface_t interface);
181void dsa_port_phylink_mac_link_up(struct phylink_config *config,
182 unsigned int mode,
183 phy_interface_t interface,
184 struct phy_device *phydev);
185extern const struct phylink_mac_ops dsa_port_phylink_mac_ops;
57ab1ca2 186
91da11f8 187/* slave.c */
5075314e 188extern const struct dsa_device_ops notag_netdev_ops;
91da11f8 189void dsa_slave_mii_bus_init(struct dsa_switch *ds);
951259aa 190int dsa_slave_create(struct dsa_port *dp);
cda5c15b 191void dsa_slave_destroy(struct net_device *slave_dev);
24462549
FF
192int dsa_slave_suspend(struct net_device *slave_dev);
193int dsa_slave_resume(struct net_device *slave_dev);
88e4f0ca
VD
194int dsa_slave_register_notifier(void);
195void dsa_slave_unregister_notifier(void);
91da11f8 196
97a69a0d
VO
197void *dsa_defer_xmit(struct sk_buff *skb, struct net_device *dev);
198
d945097b
VD
199static inline struct dsa_port *dsa_slave_to_port(const struct net_device *dev)
200{
201 struct dsa_slave_priv *p = netdev_priv(dev);
202
203 return p->dp;
204}
205
d0006b00
VD
206static inline struct net_device *
207dsa_slave_to_master(const struct net_device *dev)
208{
209 struct dsa_port *dp = dsa_slave_to_port(dev);
210
f8b8b1cd 211 return dp->cpu_dp->master;
d0006b00
VD
212}
213
f515f192
VD
214/* switch.c */
215int dsa_switch_register_notifier(struct dsa_switch *ds);
216void dsa_switch_unregister_notifier(struct dsa_switch *ds);
91da11f8 217#endif