c145223247c5b953bb3ee47c4551db187fde477d
[sfrench/cifs-2.6.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 struct dsa_device_ops {
20         struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev);
21         struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,
22                                struct packet_type *pt,
23                                struct net_device *orig_dev);
24 };
25
26 struct dsa_slave_priv {
27         struct sk_buff *        (*xmit)(struct sk_buff *skb,
28                                         struct net_device *dev);
29
30         /* DSA port data, such as switch, port index, etc. */
31         struct dsa_port         *dp;
32
33         /*
34          * The phylib phy_device pointer for the PHY connected
35          * to this port.
36          */
37         struct phy_device       *phy;
38         phy_interface_t         phy_interface;
39         int                     old_link;
40         int                     old_pause;
41         int                     old_duplex;
42
43 #ifdef CONFIG_NET_POLL_CONTROLLER
44         struct netpoll          *netpoll;
45 #endif
46
47         /* TC context */
48         struct list_head        mall_tc_list;
49 };
50
51 /* dsa.c */
52 int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev,
53                       struct dsa_port *dport, int port);
54 void dsa_cpu_dsa_destroy(struct dsa_port *dport);
55 const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
56 int dsa_cpu_port_ethtool_setup(struct dsa_switch *ds);
57 void dsa_cpu_port_ethtool_restore(struct dsa_switch *ds);
58
59 /* legacy.c */
60 int dsa_legacy_register(void);
61 void dsa_legacy_unregister(void);
62
63 /* port.c */
64 int dsa_port_set_state(struct dsa_port *dp, u8 state,
65                        struct switchdev_trans *trans);
66 void dsa_port_set_state_now(struct dsa_port *dp, u8 state);
67 int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br);
68 void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br);
69 int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
70                             struct switchdev_trans *trans);
71
72 /* slave.c */
73 extern const struct dsa_device_ops notag_netdev_ops;
74 void dsa_slave_mii_bus_init(struct dsa_switch *ds);
75 void dsa_cpu_port_ethtool_init(struct ethtool_ops *ops);
76 int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
77                      int port, const char *name);
78 void dsa_slave_destroy(struct net_device *slave_dev);
79 int dsa_slave_suspend(struct net_device *slave_dev);
80 int dsa_slave_resume(struct net_device *slave_dev);
81 int dsa_slave_register_notifier(void);
82 void dsa_slave_unregister_notifier(void);
83
84 /* switch.c */
85 int dsa_switch_register_notifier(struct dsa_switch *ds);
86 void dsa_switch_unregister_notifier(struct dsa_switch *ds);
87
88 /* tag_brcm.c */
89 extern const struct dsa_device_ops brcm_netdev_ops;
90
91 /* tag_dsa.c */
92 extern const struct dsa_device_ops dsa_netdev_ops;
93
94 /* tag_edsa.c */
95 extern const struct dsa_device_ops edsa_netdev_ops;
96
97 /* tag_lan9303.c */
98 extern const struct dsa_device_ops lan9303_netdev_ops;
99
100 /* tag_mtk.c */
101 extern const struct dsa_device_ops mtk_netdev_ops;
102
103 /* tag_qca.c */
104 extern const struct dsa_device_ops qca_netdev_ops;
105
106 /* tag_trailer.c */
107 extern const struct dsa_device_ops trailer_netdev_ops;
108
109 #endif