2 * net/dsa/dsa_priv.h - Hardware switch handling
3 * Copyright (c) 2008-2009 Marvell Semiconductor
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.
14 #include <linux/phy.h>
15 #include <linux/netdevice.h>
16 #include <linux/netpoll.h>
20 DSA_NOTIFIER_AGEING_TIME
,
21 DSA_NOTIFIER_BRIDGE_JOIN
,
22 DSA_NOTIFIER_BRIDGE_LEAVE
,
29 /* DSA_NOTIFIER_AGEING_TIME */
30 struct dsa_notifier_ageing_time_info
{
31 struct switchdev_trans
*trans
;
32 unsigned int ageing_time
;
36 /* DSA_NOTIFIER_BRIDGE_* */
37 struct dsa_notifier_bridge_info
{
38 struct net_device
*br
;
43 /* DSA_NOTIFIER_FDB_* */
44 struct dsa_notifier_fdb_info
{
45 const struct switchdev_obj_port_fdb
*fdb
;
46 struct switchdev_trans
*trans
;
51 /* DSA_NOTIFIER_MDB_* */
52 struct dsa_notifier_mdb_info
{
53 const struct switchdev_obj_port_mdb
*mdb
;
54 struct switchdev_trans
*trans
;
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
);
66 struct dsa_slave_priv
{
67 struct sk_buff
* (*xmit
)(struct sk_buff
*skb
,
68 struct net_device
*dev
);
70 /* DSA port data, such as switch, port index, etc. */
74 * The phylib phy_device pointer for the PHY connected
77 struct phy_device
*phy
;
78 phy_interface_t phy_interface
;
83 #ifdef CONFIG_NET_POLL_CONTROLLER
84 struct netpoll
*netpoll
;
88 struct list_head mall_tc_list
;
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
);
100 int dsa_legacy_register(void);
101 void dsa_legacy_unregister(void);
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
);
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);
149 int dsa_switch_register_notifier(struct dsa_switch
*ds
);
150 void dsa_switch_unregister_notifier(struct dsa_switch
*ds
);
153 extern const struct dsa_device_ops brcm_netdev_ops
;
156 extern const struct dsa_device_ops dsa_netdev_ops
;
159 extern const struct dsa_device_ops edsa_netdev_ops
;
162 extern const struct dsa_device_ops lan9303_netdev_ops
;
165 extern const struct dsa_device_ops mtk_netdev_ops
;
168 extern const struct dsa_device_ops qca_netdev_ops
;
171 extern const struct dsa_device_ops trailer_netdev_ops
;