1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef __LINUX_USB_USBNET_H
23#define __LINUX_USB_USBNET_H
24
25
26struct usbnet {
27
28 struct usb_device *udev;
29 struct usb_interface *intf;
30 struct driver_info *driver_info;
31 const char *driver_name;
32 void *driver_priv;
33 wait_queue_head_t wait;
34 struct mutex phy_mutex;
35 unsigned char suspend_count;
36 unsigned char pkt_cnt, pkt_err;
37 unsigned short rx_qlen, tx_qlen;
38 unsigned can_dma_sg:1;
39
40
41 unsigned in, out;
42 struct usb_host_endpoint *status;
43 unsigned maxpacket;
44 struct timer_list delay;
45 const char *padding_pkt;
46
47
48 struct net_device *net;
49 int msg_enable;
50 unsigned long data[5];
51 u32 xid;
52 u32 hard_mtu;
53 size_t rx_urb_size;
54 struct mii_if_info mii;
55
56
57 struct sk_buff_head rxq;
58 struct sk_buff_head txq;
59 struct sk_buff_head done;
60 struct sk_buff_head rxq_pause;
61 struct urb *interrupt;
62 unsigned interrupt_count;
63 struct mutex interrupt_mutex;
64 struct usb_anchor deferred;
65 struct tasklet_struct bh;
66
67 struct work_struct kevent;
68 unsigned long flags;
69# define EVENT_TX_HALT 0
70# define EVENT_RX_HALT 1
71# define EVENT_RX_MEMORY 2
72# define EVENT_STS_SPLIT 3
73# define EVENT_LINK_RESET 4
74# define EVENT_RX_PAUSED 5
75# define EVENT_DEV_ASLEEP 6
76# define EVENT_DEV_OPEN 7
77# define EVENT_DEVICE_REPORT_IDLE 8
78# define EVENT_NO_RUNTIME_PM 9
79# define EVENT_RX_KILL 10
80# define EVENT_LINK_CHANGE 11
81# define EVENT_SET_RX_MODE 12
82};
83
84static inline struct usb_driver *driver_of(struct usb_interface *intf)
85{
86 return to_usb_driver(intf->dev.driver);
87}
88
89
90struct driver_info {
91 char *description;
92
93 int flags;
94
95#define FLAG_FRAMING_NC 0x0001
96#define FLAG_FRAMING_GL 0x0002
97#define FLAG_FRAMING_Z 0x0004
98#define FLAG_FRAMING_RN 0x0008
99
100#define FLAG_NO_SETINT 0x0010
101#define FLAG_ETHER 0x0020
102
103#define FLAG_FRAMING_AX 0x0040
104#define FLAG_WLAN 0x0080
105#define FLAG_AVOID_UNLINK_URBS 0x0100
106#define FLAG_SEND_ZLP 0x0200
107#define FLAG_WWAN 0x0400
108
109#define FLAG_LINK_INTR 0x0800
110
111#define FLAG_POINTTOPOINT 0x1000
112
113
114
115
116
117#define FLAG_MULTI_PACKET 0x2000
118#define FLAG_RX_ASSEMBLE 0x4000
119#define FLAG_NOARP 0x8000
120
121
122 int (*bind)(struct usbnet *, struct usb_interface *);
123
124
125 void (*unbind)(struct usbnet *, struct usb_interface *);
126
127
128 int (*reset)(struct usbnet *);
129
130
131 int (*stop)(struct usbnet *);
132
133
134 int (*check_connect)(struct usbnet *);
135
136
137 int (*manage_power)(struct usbnet *, int);
138
139
140 void (*status)(struct usbnet *, struct urb *);
141
142
143 int (*link_reset)(struct usbnet *);
144
145
146 int (*rx_fixup)(struct usbnet *dev, struct sk_buff *skb);
147
148
149 struct sk_buff *(*tx_fixup)(struct usbnet *dev,
150 struct sk_buff *skb, gfp_t flags);
151
152
153 void (*recover)(struct usbnet *dev);
154
155
156
157
158 int (*early_init)(struct usbnet *dev);
159
160
161 void (*indication)(struct usbnet *dev, void *ind, int indlen);
162
163
164 void (*set_rx_mode)(struct usbnet *dev);
165
166
167 int in;
168 int out;
169
170 unsigned long data;
171};
172
173
174
175
176
177extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *);
178extern int usbnet_suspend(struct usb_interface *, pm_message_t);
179extern int usbnet_resume(struct usb_interface *);
180extern void usbnet_disconnect(struct usb_interface *);
181extern void usbnet_device_suggests_idle(struct usbnet *dev);
182
183extern int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
184 u16 value, u16 index, void *data, u16 size);
185extern int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
186 u16 value, u16 index, const void *data, u16 size);
187extern int usbnet_read_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype,
188 u16 value, u16 index, void *data, u16 size);
189extern int usbnet_write_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype,
190 u16 value, u16 index, const void *data, u16 size);
191extern int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype,
192 u16 value, u16 index, const void *data, u16 size);
193
194
195
196
197
198struct cdc_state {
199 struct usb_cdc_header_desc *header;
200 struct usb_cdc_union_desc *u;
201 struct usb_cdc_ether_desc *ether;
202 struct usb_interface *control;
203 struct usb_interface *data;
204};
205
206extern int usbnet_generic_cdc_bind(struct usbnet *, struct usb_interface *);
207extern int usbnet_cdc_bind(struct usbnet *, struct usb_interface *);
208extern void usbnet_cdc_unbind(struct usbnet *, struct usb_interface *);
209extern void usbnet_cdc_status(struct usbnet *, struct urb *);
210
211
212#define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \
213 |USB_CDC_PACKET_TYPE_ALL_MULTICAST \
214 |USB_CDC_PACKET_TYPE_PROMISCUOUS \
215 |USB_CDC_PACKET_TYPE_DIRECTED)
216
217
218
219enum skb_state {
220 illegal = 0,
221 tx_start, tx_done,
222 rx_start, rx_done, rx_cleanup,
223 unlink_start
224};
225
226struct skb_data {
227 struct urb *urb;
228 struct usbnet *dev;
229 enum skb_state state;
230 long length;
231 unsigned long packets;
232};
233
234
235
236
237static inline void
238usbnet_set_skb_tx_stats(struct sk_buff *skb,
239 unsigned long packets, long bytes_delta)
240{
241 struct skb_data *entry = (struct skb_data *) skb->cb;
242
243 entry->packets = packets;
244 entry->length = bytes_delta;
245}
246
247extern int usbnet_open(struct net_device *net);
248extern int usbnet_stop(struct net_device *net);
249extern netdev_tx_t usbnet_start_xmit(struct sk_buff *skb,
250 struct net_device *net);
251extern void usbnet_tx_timeout(struct net_device *net);
252extern int usbnet_change_mtu(struct net_device *net, int new_mtu);
253
254extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *);
255extern int usbnet_get_ethernet_addr(struct usbnet *, int);
256extern void usbnet_defer_kevent(struct usbnet *, int);
257extern void usbnet_skb_return(struct usbnet *, struct sk_buff *);
258extern void usbnet_unlink_rx_urbs(struct usbnet *);
259
260extern void usbnet_pause_rx(struct usbnet *);
261extern void usbnet_resume_rx(struct usbnet *);
262extern void usbnet_purge_paused_rxq(struct usbnet *);
263
264extern int usbnet_get_settings(struct net_device *net,
265 struct ethtool_cmd *cmd);
266extern int usbnet_set_settings(struct net_device *net,
267 struct ethtool_cmd *cmd);
268extern u32 usbnet_get_link(struct net_device *net);
269extern u32 usbnet_get_msglevel(struct net_device *);
270extern void usbnet_set_msglevel(struct net_device *, u32);
271extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
272extern int usbnet_nway_reset(struct net_device *net);
273
274extern int usbnet_manage_power(struct usbnet *, int);
275extern void usbnet_link_change(struct usbnet *, bool, bool);
276
277extern int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags);
278extern void usbnet_status_stop(struct usbnet *dev);
279
280extern void usbnet_update_max_qlen(struct usbnet *dev);
281
282#endif
283