aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/asix.c3
-rw-r--r--drivers/net/usb/cdc_ether.c13
-rw-r--r--drivers/net/usb/cdc_subset.c3
-rw-r--r--drivers/net/usb/dm9601.c3
-rw-r--r--drivers/net/usb/gl620a.c3
-rw-r--r--drivers/net/usb/mcs7830.c3
-rw-r--r--drivers/net/usb/net1080.c3
-rw-r--r--drivers/net/usb/plusb.c3
-rw-r--r--drivers/net/usb/rndis_host.c303
-rw-r--r--drivers/net/usb/usbnet.c6
-rw-r--r--drivers/net/usb/usbnet.h202
-rw-r--r--drivers/net/usb/zaurus.c3
12 files changed, 101 insertions, 447 deletions
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 569028b2baf2..6f245cfb6624 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -33,8 +33,7 @@
33#include <linux/mii.h> 33#include <linux/mii.h>
34#include <linux/usb.h> 34#include <linux/usb.h>
35#include <linux/crc32.h> 35#include <linux/crc32.h>
36 36#include <linux/usb/usbnet.h>
37#include "usbnet.h"
38 37
39#define DRIVER_VERSION "14-Jun-2006" 38#define DRIVER_VERSION "14-Jun-2006"
40static const char driver_name [] = "asix"; 39static const char driver_name [] = "asix";
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index a42acc3cc609..a934428a5890 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -31,8 +31,7 @@
31#include <linux/mii.h> 31#include <linux/mii.h>
32#include <linux/usb.h> 32#include <linux/usb.h>
33#include <linux/usb/cdc.h> 33#include <linux/usb/cdc.h>
34 34#include <linux/usb/usbnet.h>
35#include "usbnet.h"
36 35
37 36
38#if defined(CONFIG_USB_NET_RNDIS_HOST) || defined(CONFIG_USB_NET_RNDIS_HOST_MODULE) 37#if defined(CONFIG_USB_NET_RNDIS_HOST) || defined(CONFIG_USB_NET_RNDIS_HOST_MODULE)
@@ -228,15 +227,16 @@ next_desc:
228 buf += buf [0]; 227 buf += buf [0];
229 } 228 }
230 229
231 /* Microsoft ActiveSync based RNDIS devices lack the CDC descriptors, 230 /* Microsoft ActiveSync based and some regular RNDIS devices lack the
232 * so we'll hard-wire the interfaces and not check for descriptors. 231 * CDC descriptors, so we'll hard-wire the interfaces and not check
232 * for descriptors.
233 */ 233 */
234 if (is_activesync(&intf->cur_altsetting->desc) && !info->u) { 234 if (rndis && !info->u) {
235 info->control = usb_ifnum_to_if(dev->udev, 0); 235 info->control = usb_ifnum_to_if(dev->udev, 0);
236 info->data = usb_ifnum_to_if(dev->udev, 1); 236 info->data = usb_ifnum_to_if(dev->udev, 1);
237 if (!info->control || !info->data) { 237 if (!info->control || !info->data) {
238 dev_dbg(&intf->dev, 238 dev_dbg(&intf->dev,
239 "activesync: master #0/%p slave #1/%p\n", 239 "rndis: master #0/%p slave #1/%p\n",
240 info->control, 240 info->control,
241 info->data); 241 info->data);
242 goto bad_desc; 242 goto bad_desc;
@@ -316,7 +316,6 @@ void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf)
316} 316}
317EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); 317EXPORT_SYMBOL_GPL(usbnet_cdc_unbind);
318 318
319
320/*------------------------------------------------------------------------- 319/*-------------------------------------------------------------------------
321 * 320 *
322 * Communications Device Class, Ethernet Control model 321 * Communications Device Class, Ethernet Control model
diff --git a/drivers/net/usb/cdc_subset.c b/drivers/net/usb/cdc_subset.c
index 943988ed01d8..0ec7936cbe21 100644
--- a/drivers/net/usb/cdc_subset.c
+++ b/drivers/net/usb/cdc_subset.c
@@ -26,8 +26,7 @@
26#include <linux/workqueue.h> 26#include <linux/workqueue.h>
27#include <linux/mii.h> 27#include <linux/mii.h>
28#include <linux/usb.h> 28#include <linux/usb.h>
29 29#include <linux/usb/usbnet.h>
30#include "usbnet.h"
31 30
32 31
33/* 32/*
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 633a511d6cb6..4b131a6c6b70 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -20,8 +20,7 @@
20#include <linux/mii.h> 20#include <linux/mii.h>
21#include <linux/usb.h> 21#include <linux/usb.h>
22#include <linux/crc32.h> 22#include <linux/crc32.h>
23 23#include <linux/usb/usbnet.h>
24#include "usbnet.h"
25 24
26/* datasheet: 25/* datasheet:
27 http://www.davicom.com.tw/big5/download/Data%20Sheet/DM9601-DS-P01-930914.pdf 26 http://www.davicom.com.tw/big5/download/Data%20Sheet/DM9601-DS-P01-930914.pdf
diff --git a/drivers/net/usb/gl620a.c b/drivers/net/usb/gl620a.c
index 031cf5ca4dbb..f7ccfad9384e 100644
--- a/drivers/net/usb/gl620a.c
+++ b/drivers/net/usb/gl620a.c
@@ -29,8 +29,7 @@
29#include <linux/workqueue.h> 29#include <linux/workqueue.h>
30#include <linux/mii.h> 30#include <linux/mii.h>
31#include <linux/usb.h> 31#include <linux/usb.h>
32 32#include <linux/usb/usbnet.h>
33#include "usbnet.h"
34 33
35 34
36/* 35/*
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 5ea7411e1337..c3d119f997f5 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -31,8 +31,7 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/netdevice.h> 32#include <linux/netdevice.h>
33#include <linux/usb.h> 33#include <linux/usb.h>
34 34#include <linux/usb/usbnet.h>
35#include "usbnet.h"
36 35
37/* requests */ 36/* requests */
38#define MCS7830_RD_BMREQ (USB_DIR_IN | USB_TYPE_VENDOR | \ 37#define MCS7830_RD_BMREQ (USB_DIR_IN | USB_TYPE_VENDOR | \
diff --git a/drivers/net/usb/net1080.c b/drivers/net/usb/net1080.c
index 19bf8dae70c9..034e8a73ca6b 100644
--- a/drivers/net/usb/net1080.c
+++ b/drivers/net/usb/net1080.c
@@ -28,11 +28,10 @@
28#include <linux/workqueue.h> 28#include <linux/workqueue.h>
29#include <linux/mii.h> 29#include <linux/mii.h>
30#include <linux/usb.h> 30#include <linux/usb.h>
31#include <linux/usb/usbnet.h>
31 32
32#include <asm/unaligned.h> 33#include <asm/unaligned.h>
33 34
34#include "usbnet.h"
35
36 35
37/* 36/*
38 * Netchip 1080 driver ... http://www.netchip.com 37 * Netchip 1080 driver ... http://www.netchip.com
diff --git a/drivers/net/usb/plusb.c b/drivers/net/usb/plusb.c
index 45300939d185..08555f8b15f4 100644
--- a/drivers/net/usb/plusb.c
+++ b/drivers/net/usb/plusb.c
@@ -28,8 +28,7 @@
28#include <linux/workqueue.h> 28#include <linux/workqueue.h>
29#include <linux/mii.h> 29#include <linux/mii.h>
30#include <linux/usb.h> 30#include <linux/usb.h>
31 31#include <linux/usb/usbnet.h>
32#include "usbnet.h"
33 32
34 33
35/* 34/*
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index 1ebe3259be0d..a61324757b17 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -29,8 +29,8 @@
29#include <linux/mii.h> 29#include <linux/mii.h>
30#include <linux/usb.h> 30#include <linux/usb.h>
31#include <linux/usb/cdc.h> 31#include <linux/usb/cdc.h>
32 32#include <linux/usb/usbnet.h>
33#include "usbnet.h" 33#include <linux/usb/rndis_host.h>
34 34
35 35
36/* 36/*
@@ -56,217 +56,17 @@
56 */ 56 */
57 57
58/* 58/*
59 * CONTROL uses CDC "encapsulated commands" with funky notifications.
60 * - control-out: SEND_ENCAPSULATED
61 * - interrupt-in: RESPONSE_AVAILABLE
62 * - control-in: GET_ENCAPSULATED
63 *
64 * We'll try to ignore the RESPONSE_AVAILABLE notifications.
65 *
66 * REVISIT some RNDIS implementations seem to have curious issues still
67 * to be resolved.
68 */
69struct rndis_msg_hdr {
70 __le32 msg_type; /* RNDIS_MSG_* */
71 __le32 msg_len;
72 // followed by data that varies between messages
73 __le32 request_id;
74 __le32 status;
75 // ... and more
76} __attribute__ ((packed));
77
78/* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */
79#define CONTROL_BUFFER_SIZE 1025
80
81/* RNDIS defines an (absurdly huge) 10 second control timeout,
82 * but ActiveSync seems to use a more usual 5 second timeout
83 * (which matches the USB 2.0 spec).
84 */
85#define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000)
86
87
88#define ccpu2 __constant_cpu_to_le32
89
90#define RNDIS_MSG_COMPLETION ccpu2(0x80000000)
91
92/* codes for "msg_type" field of rndis messages;
93 * only the data channel uses packet messages (maybe batched);
94 * everything else goes on the control channel.
95 */
96#define RNDIS_MSG_PACKET ccpu2(0x00000001) /* 1-N packets */
97#define RNDIS_MSG_INIT ccpu2(0x00000002)
98#define RNDIS_MSG_INIT_C (RNDIS_MSG_INIT|RNDIS_MSG_COMPLETION)
99#define RNDIS_MSG_HALT ccpu2(0x00000003)
100#define RNDIS_MSG_QUERY ccpu2(0x00000004)
101#define RNDIS_MSG_QUERY_C (RNDIS_MSG_QUERY|RNDIS_MSG_COMPLETION)
102#define RNDIS_MSG_SET ccpu2(0x00000005)
103#define RNDIS_MSG_SET_C (RNDIS_MSG_SET|RNDIS_MSG_COMPLETION)
104#define RNDIS_MSG_RESET ccpu2(0x00000006)
105#define RNDIS_MSG_RESET_C (RNDIS_MSG_RESET|RNDIS_MSG_COMPLETION)
106#define RNDIS_MSG_INDICATE ccpu2(0x00000007)
107#define RNDIS_MSG_KEEPALIVE ccpu2(0x00000008)
108#define RNDIS_MSG_KEEPALIVE_C (RNDIS_MSG_KEEPALIVE|RNDIS_MSG_COMPLETION)
109
110/* codes for "status" field of completion messages */
111#define RNDIS_STATUS_SUCCESS ccpu2(0x00000000)
112#define RNDIS_STATUS_FAILURE ccpu2(0xc0000001)
113#define RNDIS_STATUS_INVALID_DATA ccpu2(0xc0010015)
114#define RNDIS_STATUS_NOT_SUPPORTED ccpu2(0xc00000bb)
115#define RNDIS_STATUS_MEDIA_CONNECT ccpu2(0x4001000b)
116#define RNDIS_STATUS_MEDIA_DISCONNECT ccpu2(0x4001000c)
117
118
119struct rndis_data_hdr {
120 __le32 msg_type; /* RNDIS_MSG_PACKET */
121 __le32 msg_len; // rndis_data_hdr + data_len + pad
122 __le32 data_offset; // 36 -- right after header
123 __le32 data_len; // ... real packet size
124
125 __le32 oob_data_offset; // zero
126 __le32 oob_data_len; // zero
127 __le32 num_oob; // zero
128 __le32 packet_data_offset; // zero
129
130 __le32 packet_data_len; // zero
131 __le32 vc_handle; // zero
132 __le32 reserved; // zero
133} __attribute__ ((packed));
134
135struct rndis_init { /* OUT */
136 // header and:
137 __le32 msg_type; /* RNDIS_MSG_INIT */
138 __le32 msg_len; // 24
139 __le32 request_id;
140 __le32 major_version; // of rndis (1.0)
141 __le32 minor_version;
142 __le32 max_transfer_size;
143} __attribute__ ((packed));
144
145struct rndis_init_c { /* IN */
146 // header and:
147 __le32 msg_type; /* RNDIS_MSG_INIT_C */
148 __le32 msg_len;
149 __le32 request_id;
150 __le32 status;
151 __le32 major_version; // of rndis (1.0)
152 __le32 minor_version;
153 __le32 device_flags;
154 __le32 medium; // zero == 802.3
155 __le32 max_packets_per_message;
156 __le32 max_transfer_size;
157 __le32 packet_alignment; // max 7; (1<<n) bytes
158 __le32 af_list_offset; // zero
159 __le32 af_list_size; // zero
160} __attribute__ ((packed));
161
162struct rndis_halt { /* OUT (no reply) */
163 // header and:
164 __le32 msg_type; /* RNDIS_MSG_HALT */
165 __le32 msg_len;
166 __le32 request_id;
167} __attribute__ ((packed));
168
169struct rndis_query { /* OUT */
170 // header and:
171 __le32 msg_type; /* RNDIS_MSG_QUERY */
172 __le32 msg_len;
173 __le32 request_id;
174 __le32 oid;
175 __le32 len;
176 __le32 offset;
177/*?*/ __le32 handle; // zero
178} __attribute__ ((packed));
179
180struct rndis_query_c { /* IN */
181 // header and:
182 __le32 msg_type; /* RNDIS_MSG_QUERY_C */
183 __le32 msg_len;
184 __le32 request_id;
185 __le32 status;
186 __le32 len;
187 __le32 offset;
188} __attribute__ ((packed));
189
190struct rndis_set { /* OUT */
191 // header and:
192 __le32 msg_type; /* RNDIS_MSG_SET */
193 __le32 msg_len;
194 __le32 request_id;
195 __le32 oid;
196 __le32 len;
197 __le32 offset;
198/*?*/ __le32 handle; // zero
199} __attribute__ ((packed));
200
201struct rndis_set_c { /* IN */
202 // header and:
203 __le32 msg_type; /* RNDIS_MSG_SET_C */
204 __le32 msg_len;
205 __le32 request_id;
206 __le32 status;
207} __attribute__ ((packed));
208
209struct rndis_reset { /* IN */
210 // header and:
211 __le32 msg_type; /* RNDIS_MSG_RESET */
212 __le32 msg_len;
213 __le32 reserved;
214} __attribute__ ((packed));
215
216struct rndis_reset_c { /* OUT */
217 // header and:
218 __le32 msg_type; /* RNDIS_MSG_RESET_C */
219 __le32 msg_len;
220 __le32 status;
221 __le32 addressing_lost;
222} __attribute__ ((packed));
223
224struct rndis_indicate { /* IN (unrequested) */
225 // header and:
226 __le32 msg_type; /* RNDIS_MSG_INDICATE */
227 __le32 msg_len;
228 __le32 status;
229 __le32 length;
230 __le32 offset;
231/**/ __le32 diag_status;
232 __le32 error_offset;
233/**/ __le32 message;
234} __attribute__ ((packed));
235
236struct rndis_keepalive { /* OUT (optionally IN) */
237 // header and:
238 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */
239 __le32 msg_len;
240 __le32 request_id;
241} __attribute__ ((packed));
242
243struct rndis_keepalive_c { /* IN (optionally OUT) */
244 // header and:
245 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */
246 __le32 msg_len;
247 __le32 request_id;
248 __le32 status;
249} __attribute__ ((packed));
250
251/* NOTE: about 30 OIDs are "mandatory" for peripherals to support ... and
252 * there are gobs more that may optionally be supported. We'll avoid as much
253 * of that mess as possible.
254 */
255#define OID_802_3_PERMANENT_ADDRESS ccpu2(0x01010101)
256#define OID_GEN_MAXIMUM_FRAME_SIZE ccpu2(0x00010106)
257#define OID_GEN_CURRENT_PACKET_FILTER ccpu2(0x0001010e)
258
259/*
260 * RNDIS notifications from device: command completion; "reverse" 59 * RNDIS notifications from device: command completion; "reverse"
261 * keepalives; etc 60 * keepalives; etc
262 */ 61 */
263static void rndis_status(struct usbnet *dev, struct urb *urb) 62void rndis_status(struct usbnet *dev, struct urb *urb)
264{ 63{
265 devdbg(dev, "rndis status urb, len %d stat %d", 64 devdbg(dev, "rndis status urb, len %d stat %d",
266 urb->actual_length, urb->status); 65 urb->actual_length, urb->status);
267 // FIXME for keepalives, respond immediately (asynchronously) 66 // FIXME for keepalives, respond immediately (asynchronously)
268 // if not an RNDIS status, do like cdc_status(dev,urb) does 67 // if not an RNDIS status, do like cdc_status(dev,urb) does
269} 68}
69EXPORT_SYMBOL_GPL(rndis_status);
270 70
271/* 71/*
272 * RPC done RNDIS-style. Caller guarantees: 72 * RPC done RNDIS-style. Caller guarantees:
@@ -278,7 +78,7 @@ static void rndis_status(struct usbnet *dev, struct urb *urb)
278 * Call context is likely probe(), before interface name is known, 78 * Call context is likely probe(), before interface name is known,
279 * which is why we won't try to use it in the diagnostics. 79 * which is why we won't try to use it in the diagnostics.
280 */ 80 */
281static int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf) 81int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf)
282{ 82{
283 struct cdc_state *info = (void *) &dev->data; 83 struct cdc_state *info = (void *) &dev->data;
284 int master_ifnum; 84 int master_ifnum;
@@ -347,10 +147,26 @@ static int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf)
347 request_id, xid); 147 request_id, xid);
348 /* then likely retry */ 148 /* then likely retry */
349 } else switch (buf->msg_type) { 149 } else switch (buf->msg_type) {
350 case RNDIS_MSG_INDICATE: { /* fault */ 150 case RNDIS_MSG_INDICATE: { /* fault/event */
351 // struct rndis_indicate *msg = (void *)buf; 151 struct rndis_indicate *msg = (void *)buf;
352 dev_info(&info->control->dev, 152 int state = 0;
353 "rndis fault indication\n"); 153
154 switch (msg->status) {
155 case RNDIS_STATUS_MEDIA_CONNECT:
156 state = 1;
157 case RNDIS_STATUS_MEDIA_DISCONNECT:
158 dev_info(&info->control->dev,
159 "rndis media %sconnect\n",
160 !state?"dis":"");
161 if (dev->driver_info->link_change)
162 dev->driver_info->link_change(
163 dev, state);
164 break;
165 default:
166 dev_info(&info->control->dev,
167 "rndis indication: 0x%08x\n",
168 le32_to_cpu(msg->status));
169 }
354 } 170 }
355 break; 171 break;
356 case RNDIS_MSG_KEEPALIVE: { /* ping */ 172 case RNDIS_MSG_KEEPALIVE: { /* ping */
@@ -387,6 +203,7 @@ static int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf)
387 dev_dbg(&info->control->dev, "rndis response timeout\n"); 203 dev_dbg(&info->control->dev, "rndis response timeout\n");
388 return -ETIMEDOUT; 204 return -ETIMEDOUT;
389} 205}
206EXPORT_SYMBOL_GPL(rndis_command);
390 207
391/* 208/*
392 * rndis_query: 209 * rndis_query:
@@ -453,7 +270,8 @@ response_error:
453 return -EDOM; 270 return -EDOM;
454} 271}
455 272
456static int rndis_bind(struct usbnet *dev, struct usb_interface *intf) 273int
274generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
457{ 275{
458 int retval; 276 int retval;
459 struct net_device *net = dev->net; 277 struct net_device *net = dev->net;
@@ -467,8 +285,9 @@ static int rndis_bind(struct usbnet *dev, struct usb_interface *intf)
467 struct rndis_query_c *get_c; 285 struct rndis_query_c *get_c;
468 struct rndis_set *set; 286 struct rndis_set *set;
469 struct rndis_set_c *set_c; 287 struct rndis_set_c *set_c;
288 struct rndis_halt *halt;
470 } u; 289 } u;
471 u32 tmp; 290 u32 tmp, *phym;
472 int reply_len; 291 int reply_len;
473 unsigned char *bp; 292 unsigned char *bp;
474 293
@@ -517,7 +336,7 @@ static int rndis_bind(struct usbnet *dev, struct usb_interface *intf)
517 "dev can't take %u byte packets (max %u)\n", 336 "dev can't take %u byte packets (max %u)\n",
518 dev->hard_mtu, tmp); 337 dev->hard_mtu, tmp);
519 retval = -EINVAL; 338 retval = -EINVAL;
520 goto fail_and_release; 339 goto halt_fail_and_release;
521 } 340 }
522 dev->hard_mtu = tmp; 341 dev->hard_mtu = tmp;
523 net->mtu = dev->hard_mtu - net->hard_header_len; 342 net->mtu = dev->hard_mtu - net->hard_header_len;
@@ -533,13 +352,43 @@ static int rndis_bind(struct usbnet *dev, struct usb_interface *intf)
533 dev->hard_mtu, tmp, dev->rx_urb_size, 352 dev->hard_mtu, tmp, dev->rx_urb_size,
534 1 << le32_to_cpu(u.init_c->packet_alignment)); 353 1 << le32_to_cpu(u.init_c->packet_alignment));
535 354
355 /* module has some device initialization code needs to be done right
356 * after RNDIS_INIT */
357 if (dev->driver_info->early_init &&
358 dev->driver_info->early_init(dev) != 0)
359 goto halt_fail_and_release;
360
361 /* Check physical medium */
362 reply_len = sizeof *phym;
363 retval = rndis_query(dev, intf, u.buf, OID_GEN_PHYSICAL_MEDIUM,
364 0, (void **) &phym, &reply_len);
365 if (retval != 0)
366 /* OID is optional so don't fail here. */
367 *phym = RNDIS_PHYSICAL_MEDIUM_UNSPECIFIED;
368 if ((flags & FLAG_RNDIS_PHYM_WIRELESS) &&
369 *phym != RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN) {
370 if (netif_msg_probe(dev))
371 dev_dbg(&intf->dev, "driver requires wireless "
372 "physical medium, but device is not.\n");
373 retval = -ENODEV;
374 goto halt_fail_and_release;
375 }
376 if ((flags & FLAG_RNDIS_PHYM_NOT_WIRELESS) &&
377 *phym == RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN) {
378 if (netif_msg_probe(dev))
379 dev_dbg(&intf->dev, "driver requires non-wireless "
380 "physical medium, but device is wireless.\n");
381 retval = -ENODEV;
382 goto halt_fail_and_release;
383 }
384
536 /* Get designated host ethernet address */ 385 /* Get designated host ethernet address */
537 reply_len = ETH_ALEN; 386 reply_len = ETH_ALEN;
538 retval = rndis_query(dev, intf, u.buf, OID_802_3_PERMANENT_ADDRESS, 387 retval = rndis_query(dev, intf, u.buf, OID_802_3_PERMANENT_ADDRESS,
539 48, (void **) &bp, &reply_len); 388 48, (void **) &bp, &reply_len);
540 if (unlikely(retval< 0)) { 389 if (unlikely(retval< 0)) {
541 dev_err(&intf->dev, "rndis get ethaddr, %d\n", retval); 390 dev_err(&intf->dev, "rndis get ethaddr, %d\n", retval);
542 goto fail_and_release; 391 goto halt_fail_and_release;
543 } 392 }
544 memcpy(net->dev_addr, bp, ETH_ALEN); 393 memcpy(net->dev_addr, bp, ETH_ALEN);
545 394
@@ -550,12 +399,12 @@ static int rndis_bind(struct usbnet *dev, struct usb_interface *intf)
550 u.set->oid = OID_GEN_CURRENT_PACKET_FILTER; 399 u.set->oid = OID_GEN_CURRENT_PACKET_FILTER;
551 u.set->len = ccpu2(4); 400 u.set->len = ccpu2(4);
552 u.set->offset = ccpu2((sizeof *u.set) - 8); 401 u.set->offset = ccpu2((sizeof *u.set) - 8);
553 *(__le32 *)(u.buf + sizeof *u.set) = ccpu2(DEFAULT_FILTER); 402 *(__le32 *)(u.buf + sizeof *u.set) = RNDIS_DEFAULT_FILTER;
554 403
555 retval = rndis_command(dev, u.header); 404 retval = rndis_command(dev, u.header);
556 if (unlikely(retval < 0)) { 405 if (unlikely(retval < 0)) {
557 dev_err(&intf->dev, "rndis set packet filter, %d\n", retval); 406 dev_err(&intf->dev, "rndis set packet filter, %d\n", retval);
558 goto fail_and_release; 407 goto halt_fail_and_release;
559 } 408 }
560 409
561 retval = 0; 410 retval = 0;
@@ -563,6 +412,11 @@ static int rndis_bind(struct usbnet *dev, struct usb_interface *intf)
563 kfree(u.buf); 412 kfree(u.buf);
564 return retval; 413 return retval;
565 414
415halt_fail_and_release:
416 memset(u.halt, 0, sizeof *u.halt);
417 u.halt->msg_type = RNDIS_MSG_HALT;
418 u.halt->msg_len = ccpu2(sizeof *u.halt);
419 (void) rndis_command(dev, (void *)u.halt);
566fail_and_release: 420fail_and_release:
567 usb_set_intfdata(info->data, NULL); 421 usb_set_intfdata(info->data, NULL);
568 usb_driver_release_interface(driver_of(intf), info->data); 422 usb_driver_release_interface(driver_of(intf), info->data);
@@ -571,13 +425,19 @@ fail:
571 kfree(u.buf); 425 kfree(u.buf);
572 return retval; 426 return retval;
573} 427}
428EXPORT_SYMBOL_GPL(generic_rndis_bind);
429
430static int rndis_bind(struct usbnet *dev, struct usb_interface *intf)
431{
432 return generic_rndis_bind(dev, intf, FLAG_RNDIS_PHYM_NOT_WIRELESS);
433}
574 434
575static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf) 435void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
576{ 436{
577 struct rndis_halt *halt; 437 struct rndis_halt *halt;
578 438
579 /* try to clear any rndis state/activity (no i/o from stack!) */ 439 /* try to clear any rndis state/activity (no i/o from stack!) */
580 halt = kzalloc(sizeof *halt, GFP_KERNEL); 440 halt = kzalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL);
581 if (halt) { 441 if (halt) {
582 halt->msg_type = RNDIS_MSG_HALT; 442 halt->msg_type = RNDIS_MSG_HALT;
583 halt->msg_len = ccpu2(sizeof *halt); 443 halt->msg_len = ccpu2(sizeof *halt);
@@ -585,13 +445,14 @@ static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
585 kfree(halt); 445 kfree(halt);
586 } 446 }
587 447
588 return usbnet_cdc_unbind(dev, intf); 448 usbnet_cdc_unbind(dev, intf);
589} 449}
450EXPORT_SYMBOL_GPL(rndis_unbind);
590 451
591/* 452/*
592 * DATA -- host must not write zlps 453 * DATA -- host must not write zlps
593 */ 454 */
594static int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb) 455int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
595{ 456{
596 /* peripheral may have batched packets to us... */ 457 /* peripheral may have batched packets to us... */
597 while (likely(skb->len)) { 458 while (likely(skb->len)) {
@@ -633,8 +494,9 @@ static int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
633 /* caller will usbnet_skb_return the remaining packet */ 494 /* caller will usbnet_skb_return the remaining packet */
634 return 1; 495 return 1;
635} 496}
497EXPORT_SYMBOL_GPL(rndis_rx_fixup);
636 498
637static struct sk_buff * 499struct sk_buff *
638rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) 500rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
639{ 501{
640 struct rndis_data_hdr *hdr; 502 struct rndis_data_hdr *hdr;
@@ -679,6 +541,7 @@ fill:
679 /* FIXME make the last packet always be short ... */ 541 /* FIXME make the last packet always be short ... */
680 return skb; 542 return skb;
681} 543}
544EXPORT_SYMBOL_GPL(rndis_tx_fixup);
682 545
683 546
684static const struct driver_info rndis_info = { 547static const struct driver_info rndis_info = {
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 8ed1fc5cbc70..8463efb9e0b1 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -41,8 +41,7 @@
41#include <linux/workqueue.h> 41#include <linux/workqueue.h>
42#include <linux/mii.h> 42#include <linux/mii.h>
43#include <linux/usb.h> 43#include <linux/usb.h>
44 44#include <linux/usb/usbnet.h>
45#include "usbnet.h"
46 45
47#define DRIVER_VERSION "22-Aug-2005" 46#define DRIVER_VERSION "22-Aug-2005"
48 47
@@ -1204,6 +1203,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1204 if ((dev->driver_info->flags & FLAG_ETHER) != 0 1203 if ((dev->driver_info->flags & FLAG_ETHER) != 0
1205 && (net->dev_addr [0] & 0x02) == 0) 1204 && (net->dev_addr [0] & 0x02) == 0)
1206 strcpy (net->name, "eth%d"); 1205 strcpy (net->name, "eth%d");
1206 /* WLAN devices should always be named "wlan%d" */
1207 if ((dev->driver_info->flags & FLAG_WLAN) != 0)
1208 strcpy(net->name, "wlan%d");
1207 1209
1208 /* maybe the remote can't receive an Ethernet MTU */ 1210 /* maybe the remote can't receive an Ethernet MTU */
1209 if (net->mtu > (dev->hard_mtu - net->hard_header_len)) 1211 if (net->mtu > (dev->hard_mtu - net->hard_header_len))
diff --git a/drivers/net/usb/usbnet.h b/drivers/net/usb/usbnet.h
deleted file mode 100644
index 1fae4347e831..000000000000
--- a/drivers/net/usb/usbnet.h
+++ /dev/null
@@ -1,202 +0,0 @@
1/*
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
23#ifndef __USBNET_H
24#define __USBNET_H
25
26
27/* interface from usbnet core to each USB networking link we handle */
28struct usbnet {
29 /* housekeeping */
30 struct usb_device *udev;
31 struct usb_interface *intf;
32 struct driver_info *driver_info;
33 const char *driver_name;
34 wait_queue_head_t *wait;
35 struct mutex phy_mutex;
36 unsigned char suspend_count;
37
38 /* i/o info: pipes etc */
39 unsigned in, out;
40 struct usb_host_endpoint *status;
41 unsigned maxpacket;
42 struct timer_list delay;
43
44 /* protocol/interface state */
45 struct net_device *net;
46 struct net_device_stats stats;
47 int msg_enable;
48 unsigned long data [5];
49 u32 xid;
50 u32 hard_mtu; /* count any extra framing */
51 size_t rx_urb_size; /* size for rx urbs */
52 struct mii_if_info mii;
53
54 /* various kinds of pending driver work */
55 struct sk_buff_head rxq;
56 struct sk_buff_head txq;
57 struct sk_buff_head done;
58 struct urb *interrupt;
59 struct tasklet_struct bh;
60
61 struct work_struct kevent;
62 unsigned long flags;
63# define EVENT_TX_HALT 0
64# define EVENT_RX_HALT 1
65# define EVENT_RX_MEMORY 2
66# define EVENT_STS_SPLIT 3
67# define EVENT_LINK_RESET 4
68};
69
70static inline struct usb_driver *driver_of(struct usb_interface *intf)
71{
72 return to_usb_driver(intf->dev.driver);
73}
74
75/* interface from the device/framing level "minidriver" to core */
76struct driver_info {
77 char *description;
78
79 int flags;
80/* framing is CDC Ethernet, not writing ZLPs (hw issues), or optionally: */
81#define FLAG_FRAMING_NC 0x0001 /* guard against device dropouts */
82#define FLAG_FRAMING_GL 0x0002 /* genelink batches packets */
83#define FLAG_FRAMING_Z 0x0004 /* zaurus adds a trailer */
84#define FLAG_FRAMING_RN 0x0008 /* RNDIS batches, plus huge header */
85
86#define FLAG_NO_SETINT 0x0010 /* device can't set_interface() */
87#define FLAG_ETHER 0x0020 /* maybe use "eth%d" names */
88
89#define FLAG_FRAMING_AX 0x0040 /* AX88772/178 packets */
90
91 /* init device ... can sleep, or cause probe() failure */
92 int (*bind)(struct usbnet *, struct usb_interface *);
93
94 /* cleanup device ... can sleep, but can't fail */
95 void (*unbind)(struct usbnet *, struct usb_interface *);
96
97 /* reset device ... can sleep */
98 int (*reset)(struct usbnet *);
99
100 /* see if peer is connected ... can sleep */
101 int (*check_connect)(struct usbnet *);
102
103 /* for status polling */
104 void (*status)(struct usbnet *, struct urb *);
105
106 /* link reset handling, called from defer_kevent */
107 int (*link_reset)(struct usbnet *);
108
109 /* fixup rx packet (strip framing) */
110 int (*rx_fixup)(struct usbnet *dev, struct sk_buff *skb);
111
112 /* fixup tx packet (add framing) */
113 struct sk_buff *(*tx_fixup)(struct usbnet *dev,
114 struct sk_buff *skb, gfp_t flags);
115
116 /* for new devices, use the descriptor-reading code instead */
117 int in; /* rx endpoint */
118 int out; /* tx endpoint */
119
120 unsigned long data; /* Misc driver specific data */
121};
122
123/* Minidrivers are just drivers using the "usbnet" core as a powerful
124 * network-specific subroutine library ... that happens to do pretty
125 * much everything except custom framing and chip-specific stuff.
126 */
127extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *);
128extern int usbnet_suspend (struct usb_interface *, pm_message_t );
129extern int usbnet_resume (struct usb_interface *);
130extern void usbnet_disconnect(struct usb_interface *);
131
132
133/* Drivers that reuse some of the standard USB CDC infrastructure
134 * (notably, using multiple interfaces according to the CDC
135 * union descriptor) get some helper code.
136 */
137struct cdc_state {
138 struct usb_cdc_header_desc *header;
139 struct usb_cdc_union_desc *u;
140 struct usb_cdc_ether_desc *ether;
141 struct usb_interface *control;
142 struct usb_interface *data;
143};
144
145extern int usbnet_generic_cdc_bind (struct usbnet *, struct usb_interface *);
146extern void usbnet_cdc_unbind (struct usbnet *, struct usb_interface *);
147
148/* CDC and RNDIS support the same host-chosen packet filters for IN transfers */
149#define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \
150 |USB_CDC_PACKET_TYPE_ALL_MULTICAST \
151 |USB_CDC_PACKET_TYPE_PROMISCUOUS \
152 |USB_CDC_PACKET_TYPE_DIRECTED)
153
154
155/* we record the state for each of our queued skbs */
156enum skb_state {
157 illegal = 0,
158 tx_start, tx_done,
159 rx_start, rx_done, rx_cleanup
160};
161
162struct skb_data { /* skb->cb is one of these */
163 struct urb *urb;
164 struct usbnet *dev;
165 enum skb_state state;
166 size_t length;
167};
168
169
170extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *);
171extern void usbnet_defer_kevent (struct usbnet *, int);
172extern void usbnet_skb_return (struct usbnet *, struct sk_buff *);
173extern void usbnet_unlink_rx_urbs(struct usbnet *);
174
175extern int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd);
176extern int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd);
177extern u32 usbnet_get_link (struct net_device *net);
178extern u32 usbnet_get_msglevel (struct net_device *);
179extern void usbnet_set_msglevel (struct net_device *, u32);
180extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *);
181extern int usbnet_nway_reset(struct net_device *net);
182
183/* messaging support includes the interface name, so it must not be
184 * used before it has one ... notably, in minidriver bind() calls.
185 */
186#ifdef DEBUG
187#define devdbg(usbnet, fmt, arg...) \
188 printk(KERN_DEBUG "%s: " fmt "\n" , (usbnet)->net->name , ## arg)
189#else
190#define devdbg(usbnet, fmt, arg...) do {} while(0)
191#endif
192
193#define deverr(usbnet, fmt, arg...) \
194 printk(KERN_ERR "%s: " fmt "\n" , (usbnet)->net->name , ## arg)
195#define devwarn(usbnet, fmt, arg...) \
196 printk(KERN_WARNING "%s: " fmt "\n" , (usbnet)->net->name , ## arg)
197
198#define devinfo(usbnet, fmt, arg...) \
199 printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net->name , ## arg); \
200
201
202#endif /* __USBNET_H */
diff --git a/drivers/net/usb/zaurus.c b/drivers/net/usb/zaurus.c
index 9f98e8ce487a..e24f7b3ace4b 100644
--- a/drivers/net/usb/zaurus.c
+++ b/drivers/net/usb/zaurus.c
@@ -29,8 +29,7 @@
29#include <linux/crc32.h> 29#include <linux/crc32.h>
30#include <linux/usb.h> 30#include <linux/usb.h>
31#include <linux/usb/cdc.h> 31#include <linux/usb/cdc.h>
32 32#include <linux/usb/usbnet.h>
33#include "usbnet.h"
34 33
35 34
36/* 35/*