blob: 30dd10eb655867786379a02e2d3ebff5c2b9012f [file] [log] [blame]
Nicholas Flintham1e3d3112013-04-10 10:48:38 +01001/*
2 * USB Networking Link Interface
3 *
4 * Copyright (C) 2000-2005 by David Brownell <dbrownell@users.sourceforge.net>
5 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef __LINUX_USB_USBNET_H
23#define __LINUX_USB_USBNET_H
24
25struct usbnet {
26
27 struct usb_device *udev;
28 struct usb_interface *intf;
29 struct driver_info *driver_info;
30 const char *driver_name;
31 void *driver_priv;
32 wait_queue_head_t *wait;
33 struct mutex phy_mutex;
34 unsigned char suspend_count;
35
36
37 unsigned in, out;
38 struct usb_host_endpoint *status;
39 unsigned maxpacket;
40 struct timer_list delay;
41
42
43 struct net_device *net;
44 int msg_enable;
45 unsigned long data[5];
46 u32 xid;
47 u32 hard_mtu;
48 size_t rx_urb_size;
49 struct mii_if_info mii;
50
51
52 struct sk_buff_head rxq;
53 struct sk_buff_head txq;
54 struct sk_buff_head done;
55 struct sk_buff_head rxq_pause;
56 struct urb *interrupt;
57 struct usb_anchor deferred;
58 struct work_struct bh_w;
59
60 struct work_struct kevent;
61 unsigned long flags;
62# define EVENT_TX_HALT 0
63# define EVENT_RX_HALT 1
64# define EVENT_RX_MEMORY 2
65# define EVENT_STS_SPLIT 3
66# define EVENT_LINK_RESET 4
67# define EVENT_RX_PAUSED 5
68# define EVENT_DEV_WAKING 6
69# define EVENT_DEV_ASLEEP 7
70# define EVENT_DEV_OPEN 8
71};
72
73static inline struct usb_driver *driver_of(struct usb_interface *intf)
74{
75 return to_usb_driver(intf->dev.driver);
76}
77
78struct driver_info {
79 char *description;
80
81 int flags;
82#define FLAG_FRAMING_NC 0x0001
83#define FLAG_FRAMING_GL 0x0002
84#define FLAG_FRAMING_Z 0x0004
85#define FLAG_FRAMING_RN 0x0008
86
87#define FLAG_NO_SETINT 0x0010
88#define FLAG_ETHER 0x0020
89
90#define FLAG_FRAMING_AX 0x0040
91#define FLAG_WLAN 0x0080
92#define FLAG_AVOID_UNLINK_URBS 0x0100
93#define FLAG_SEND_ZLP 0x0200
94#define FLAG_WWAN 0x0400
95
96#define FLAG_LINK_INTR 0x0800
97
98#define FLAG_POINTTOPOINT 0x1000
99
100#define FLAG_MULTI_PACKET 0x2000
101#define FLAG_RX_ASSEMBLE 0x4000
102
103
104 int (*bind)(struct usbnet *, struct usb_interface *);
105
106
107 void (*unbind)(struct usbnet *, struct usb_interface *);
108
109
110 int (*reset)(struct usbnet *);
111
112
113 int (*stop)(struct usbnet *);
114
115
116 int (*check_connect)(struct usbnet *);
117
118
119 int (*manage_power)(struct usbnet *, int);
120
121
122 void (*status)(struct usbnet *, struct urb *);
123
124
125 int (*link_reset)(struct usbnet *);
126
127
128 int (*rx_fixup)(struct usbnet *dev, struct sk_buff *skb);
129
130
131 struct sk_buff *(*tx_fixup)(struct usbnet *dev,
132 struct sk_buff *skb, gfp_t flags);
133
134 int (*early_init)(struct usbnet *dev);
135
136
137 void (*indication)(struct usbnet *dev, void *ind, int indlen);
138
139
140 int in;
141 int out;
142
143 unsigned long data;
144};
145
146extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *);
147extern int usbnet_suspend(struct usb_interface *, pm_message_t);
148extern int usbnet_resume(struct usb_interface *);
149extern void usbnet_disconnect(struct usb_interface *);
150
151
152struct cdc_state {
153 struct usb_cdc_header_desc *header;
154 struct usb_cdc_union_desc *u;
155 struct usb_cdc_ether_desc *ether;
156 struct usb_interface *control;
157 struct usb_interface *data;
158};
159
160extern int usbnet_generic_cdc_bind(struct usbnet *, struct usb_interface *);
161extern int usbnet_cdc_bind(struct usbnet *, struct usb_interface *);
162extern void usbnet_cdc_unbind(struct usbnet *, struct usb_interface *);
163extern void usbnet_cdc_status(struct usbnet *, struct urb *);
164
165#define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \
166 |USB_CDC_PACKET_TYPE_ALL_MULTICAST \
167 |USB_CDC_PACKET_TYPE_PROMISCUOUS \
168 |USB_CDC_PACKET_TYPE_DIRECTED)
169
170
171enum skb_state {
172 illegal = 0,
173 tx_start, tx_done,
174 rx_start, rx_done, rx_cleanup,
175 unlink_start
176};
177
178struct skb_data {
179 struct urb *urb;
180 struct usbnet *dev;
181 enum skb_state state;
182 size_t length;
183};
184
185extern int usbnet_open(struct net_device *net);
186extern int usbnet_stop(struct net_device *net);
187extern netdev_tx_t usbnet_start_xmit(struct sk_buff *skb,
188 struct net_device *net);
189extern void usbnet_tx_timeout(struct net_device *net);
190extern int usbnet_change_mtu(struct net_device *net, int new_mtu);
191
192extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *);
193extern int usbnet_get_ethernet_addr(struct usbnet *, int);
194extern void usbnet_defer_kevent(struct usbnet *, int);
195extern void usbnet_skb_return(struct usbnet *, struct sk_buff *);
196extern void usbnet_unlink_rx_urbs(struct usbnet *);
197
198extern void usbnet_pause_rx(struct usbnet *);
199extern void usbnet_resume_rx(struct usbnet *);
200extern void usbnet_purge_paused_rxq(struct usbnet *);
201
202extern int usbnet_get_settings(struct net_device *net,
203 struct ethtool_cmd *cmd);
204extern int usbnet_set_settings(struct net_device *net,
205 struct ethtool_cmd *cmd);
206extern u32 usbnet_get_link(struct net_device *net);
207extern u32 usbnet_get_msglevel(struct net_device *);
208extern void usbnet_set_msglevel(struct net_device *, u32);
209extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
210extern int usbnet_nway_reset(struct net_device *net);
211
212#endif