Commit | Line | Data |
---|---|---|
904813cd DB |
1 | /* |
2 | * Net1080 based USB host-to-host cables | |
3 | * Copyright (C) 2000-2005 by David Brownell | |
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 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | */ | |
19 | ||
20 | // #define DEBUG // error path messages, extra info | |
21 | // #define VERBOSE // more; success messages | |
22 | ||
904813cd | 23 | #include <linux/module.h> |
904813cd DB |
24 | #include <linux/init.h> |
25 | #include <linux/netdevice.h> | |
26 | #include <linux/etherdevice.h> | |
27 | #include <linux/ethtool.h> | |
28 | #include <linux/workqueue.h> | |
29 | #include <linux/mii.h> | |
30 | #include <linux/usb.h> | |
3692e94f | 31 | #include <linux/usb/usbnet.h> |
5a0e3ad6 | 32 | #include <linux/slab.h> |
904813cd DB |
33 | |
34 | #include <asm/unaligned.h> | |
35 | ||
904813cd DB |
36 | |
37 | /* | |
38 | * Netchip 1080 driver ... http://www.netchip.com | |
39 | * (Sept 2004: End-of-life announcement has been sent.) | |
40 | * Used in (some) LapLink cables | |
41 | */ | |
42 | ||
43 | #define frame_errors data[1] | |
44 | ||
45 | /* | |
46 | * NetChip framing of ethernet packets, supporting additional error | |
47 | * checks for links that may drop bulk packets from inside messages. | |
48 | * Odd USB length == always short read for last usb packet. | |
49 | * - nc_header | |
50 | * - Ethernet header (14 bytes) | |
51 | * - payload | |
52 | * - (optional padding byte, if needed so length becomes odd) | |
53 | * - nc_trailer | |
54 | * | |
55 | * This framing is to be avoided for non-NetChip devices. | |
56 | */ | |
57 | ||
58 | struct nc_header { // packed: | |
59 | __le16 hdr_len; // sizeof nc_header (LE, all) | |
60 | __le16 packet_len; // payload size (including ethhdr) | |
61 | __le16 packet_id; // detects dropped packets | |
62 | #define MIN_HEADER 6 | |
63 | ||
64 | // all else is optional, and must start with: | |
65 | // __le16 vendorId; // from usb-if | |
66 | // __le16 productId; | |
ba2d3587 | 67 | } __packed; |
904813cd DB |
68 | |
69 | #define PAD_BYTE ((unsigned char)0xAC) | |
70 | ||
71 | struct nc_trailer { | |
72 | __le16 packet_id; | |
ba2d3587 | 73 | } __packed; |
904813cd DB |
74 | |
75 | // packets may use FLAG_FRAMING_NC and optional pad | |
76 | #define FRAMED_SIZE(mtu) (sizeof (struct nc_header) \ | |
77 | + sizeof (struct ethhdr) \ | |
78 | + (mtu) \ | |
79 | + 1 \ | |
80 | + sizeof (struct nc_trailer)) | |
81 | ||
82 | #define MIN_FRAMED FRAMED_SIZE(0) | |
83 | ||
84 | /* packets _could_ be up to 64KB... */ | |
85 | #define NC_MAX_PACKET 32767 | |
86 | ||
87 | ||
88 | /* | |
89 | * Zero means no timeout; else, how long a 64 byte bulk packet may be queued | |
90 | * before the hardware drops it. If that's done, the driver will need to | |
91 | * frame network packets to guard against the dropped USB packets. The win32 | |
92 | * driver sets this for both sides of the link. | |
93 | */ | |
94 | #define NC_READ_TTL_MS ((u8)255) // ms | |
95 | ||
96 | /* | |
97 | * We ignore most registers and EEPROM contents. | |
98 | */ | |
99 | #define REG_USBCTL ((u8)0x04) | |
100 | #define REG_TTL ((u8)0x10) | |
101 | #define REG_STATUS ((u8)0x11) | |
102 | ||
103 | /* | |
104 | * Vendor specific requests to read/write data | |
105 | */ | |
106 | #define REQUEST_REGISTER ((u8)0x10) | |
107 | #define REQUEST_EEPROM ((u8)0x11) | |
108 | ||
109 | static int | |
110 | nc_vendor_read(struct usbnet *dev, u8 req, u8 regnum, u16 *retval_ptr) | |
111 | { | |
5ffbe4da ML |
112 | int status = usbnet_read_cmd(dev, req, |
113 | USB_DIR_IN | USB_TYPE_VENDOR | | |
114 | USB_RECIP_DEVICE, | |
115 | 0, regnum, retval_ptr, | |
116 | sizeof *retval_ptr); | |
904813cd DB |
117 | if (status > 0) |
118 | status = 0; | |
119 | if (!status) | |
120 | le16_to_cpus(retval_ptr); | |
121 | return status; | |
122 | } | |
123 | ||
124 | static inline int | |
125 | nc_register_read(struct usbnet *dev, u8 regnum, u16 *retval_ptr) | |
126 | { | |
127 | return nc_vendor_read(dev, REQUEST_REGISTER, regnum, retval_ptr); | |
128 | } | |
129 | ||
130 | // no retval ... can become async, usable in_interrupt() | |
131 | static void | |
132 | nc_vendor_write(struct usbnet *dev, u8 req, u8 regnum, u16 value) | |
133 | { | |
5ffbe4da ML |
134 | usbnet_write_cmd(dev, req, |
135 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | |
136 | value, regnum, NULL, 0); | |
904813cd DB |
137 | } |
138 | ||
139 | static inline void | |
140 | nc_register_write(struct usbnet *dev, u8 regnum, u16 value) | |
141 | { | |
142 | nc_vendor_write(dev, REQUEST_REGISTER, regnum, value); | |
143 | } | |
144 | ||
145 | ||
146 | #if 0 | |
147 | static void nc_dump_registers(struct usbnet *dev) | |
148 | { | |
149 | u8 reg; | |
150 | u16 *vp = kmalloc(sizeof (u16)); | |
151 | ||
49ae25b0 | 152 | if (!vp) |
904813cd | 153 | return; |
904813cd | 154 | |
49ae25b0 | 155 | netdev_dbg(dev->net, "registers:\n"); |
904813cd DB |
156 | for (reg = 0; reg < 0x20; reg++) { |
157 | int retval; | |
158 | ||
159 | // reading some registers is trouble | |
160 | if (reg >= 0x08 && reg <= 0xf) | |
161 | continue; | |
162 | if (reg >= 0x12 && reg <= 0x1e) | |
163 | continue; | |
164 | ||
165 | retval = nc_register_read(dev, reg, vp); | |
166 | if (retval < 0) | |
49ae25b0 GKH |
167 | netdev_dbg(dev->net, "reg [0x%x] ==> error %d\n", |
168 | reg, retval); | |
904813cd | 169 | else |
49ae25b0 | 170 | netdev_dbg(dev->net, "reg [0x%x] = 0x%x\n", reg, *vp); |
904813cd DB |
171 | } |
172 | kfree(vp); | |
173 | } | |
174 | #endif | |
175 | ||
176 | ||
177 | /*-------------------------------------------------------------------------*/ | |
178 | ||
179 | /* | |
180 | * Control register | |
181 | */ | |
182 | ||
183 | #define USBCTL_WRITABLE_MASK 0x1f0f | |
184 | // bits 15-13 reserved, r/o | |
185 | #define USBCTL_ENABLE_LANG (1 << 12) | |
186 | #define USBCTL_ENABLE_MFGR (1 << 11) | |
187 | #define USBCTL_ENABLE_PROD (1 << 10) | |
188 | #define USBCTL_ENABLE_SERIAL (1 << 9) | |
189 | #define USBCTL_ENABLE_DEFAULTS (1 << 8) | |
190 | // bits 7-4 reserved, r/o | |
191 | #define USBCTL_FLUSH_OTHER (1 << 3) | |
192 | #define USBCTL_FLUSH_THIS (1 << 2) | |
193 | #define USBCTL_DISCONN_OTHER (1 << 1) | |
194 | #define USBCTL_DISCONN_THIS (1 << 0) | |
195 | ||
196 | static inline void nc_dump_usbctl(struct usbnet *dev, u16 usbctl) | |
197 | { | |
a475f603 JP |
198 | netif_dbg(dev, link, dev->net, |
199 | "net1080 %s-%s usbctl 0x%x:%s%s%s%s%s; this%s%s; other%s%s; r/o 0x%x\n", | |
200 | dev->udev->bus->bus_name, dev->udev->devpath, | |
201 | usbctl, | |
202 | (usbctl & USBCTL_ENABLE_LANG) ? " lang" : "", | |
203 | (usbctl & USBCTL_ENABLE_MFGR) ? " mfgr" : "", | |
204 | (usbctl & USBCTL_ENABLE_PROD) ? " prod" : "", | |
205 | (usbctl & USBCTL_ENABLE_SERIAL) ? " serial" : "", | |
206 | (usbctl & USBCTL_ENABLE_DEFAULTS) ? " defaults" : "", | |
207 | ||
208 | (usbctl & USBCTL_FLUSH_THIS) ? " FLUSH" : "", | |
209 | (usbctl & USBCTL_DISCONN_THIS) ? " DIS" : "", | |
210 | ||
211 | (usbctl & USBCTL_FLUSH_OTHER) ? " FLUSH" : "", | |
212 | (usbctl & USBCTL_DISCONN_OTHER) ? " DIS" : "", | |
213 | ||
214 | usbctl & ~USBCTL_WRITABLE_MASK); | |
904813cd DB |
215 | } |
216 | ||
217 | /*-------------------------------------------------------------------------*/ | |
218 | ||
219 | /* | |
220 | * Status register | |
221 | */ | |
222 | ||
223 | #define STATUS_PORT_A (1 << 15) | |
224 | ||
225 | #define STATUS_CONN_OTHER (1 << 14) | |
226 | #define STATUS_SUSPEND_OTHER (1 << 13) | |
227 | #define STATUS_MAILBOX_OTHER (1 << 12) | |
b4ee4a23 | 228 | #define STATUS_PACKETS_OTHER(n) (((n) >> 8) & 0x03) |
904813cd DB |
229 | |
230 | #define STATUS_CONN_THIS (1 << 6) | |
231 | #define STATUS_SUSPEND_THIS (1 << 5) | |
232 | #define STATUS_MAILBOX_THIS (1 << 4) | |
b4ee4a23 | 233 | #define STATUS_PACKETS_THIS(n) (((n) >> 0) & 0x03) |
904813cd DB |
234 | |
235 | #define STATUS_UNSPEC_MASK 0x0c8c | |
236 | #define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK)) | |
237 | ||
238 | ||
239 | static inline void nc_dump_status(struct usbnet *dev, u16 status) | |
240 | { | |
a475f603 JP |
241 | netif_dbg(dev, link, dev->net, |
242 | "net1080 %s-%s status 0x%x: this (%c) PKT=%d%s%s%s; other PKT=%d%s%s%s; unspec 0x%x\n", | |
243 | dev->udev->bus->bus_name, dev->udev->devpath, | |
244 | status, | |
245 | ||
246 | // XXX the packet counts don't seem right | |
247 | // (1 at reset, not 0); maybe UNSPEC too | |
248 | ||
249 | (status & STATUS_PORT_A) ? 'A' : 'B', | |
250 | STATUS_PACKETS_THIS(status), | |
251 | (status & STATUS_CONN_THIS) ? " CON" : "", | |
252 | (status & STATUS_SUSPEND_THIS) ? " SUS" : "", | |
253 | (status & STATUS_MAILBOX_THIS) ? " MBOX" : "", | |
254 | ||
255 | STATUS_PACKETS_OTHER(status), | |
256 | (status & STATUS_CONN_OTHER) ? " CON" : "", | |
257 | (status & STATUS_SUSPEND_OTHER) ? " SUS" : "", | |
258 | (status & STATUS_MAILBOX_OTHER) ? " MBOX" : "", | |
259 | ||
260 | status & STATUS_UNSPEC_MASK); | |
904813cd DB |
261 | } |
262 | ||
263 | /*-------------------------------------------------------------------------*/ | |
264 | ||
265 | /* | |
266 | * TTL register | |
267 | */ | |
268 | ||
269 | #define TTL_THIS(ttl) (0x00ff & ttl) | |
270 | #define TTL_OTHER(ttl) (0x00ff & (ttl >> 8)) | |
271 | #define MK_TTL(this,other) ((u16)(((other)<<8)|(0x00ff&(this)))) | |
272 | ||
273 | static inline void nc_dump_ttl(struct usbnet *dev, u16 ttl) | |
274 | { | |
a475f603 JP |
275 | netif_dbg(dev, link, dev->net, "net1080 %s-%s ttl 0x%x this = %d, other = %d\n", |
276 | dev->udev->bus->bus_name, dev->udev->devpath, | |
277 | ttl, TTL_THIS(ttl), TTL_OTHER(ttl)); | |
904813cd DB |
278 | } |
279 | ||
280 | /*-------------------------------------------------------------------------*/ | |
281 | ||
282 | static int net1080_reset(struct usbnet *dev) | |
283 | { | |
284 | u16 usbctl, status, ttl; | |
5ffbe4da | 285 | u16 vp; |
904813cd DB |
286 | int retval; |
287 | ||
904813cd DB |
288 | // nc_dump_registers(dev); |
289 | ||
5ffbe4da | 290 | if ((retval = nc_register_read(dev, REG_STATUS, &vp)) < 0) { |
49ae25b0 GKH |
291 | netdev_dbg(dev->net, "can't read %s-%s status: %d\n", |
292 | dev->udev->bus->bus_name, dev->udev->devpath, retval); | |
904813cd DB |
293 | goto done; |
294 | } | |
5ffbe4da | 295 | status = vp; |
904813cd DB |
296 | nc_dump_status(dev, status); |
297 | ||
5ffbe4da | 298 | if ((retval = nc_register_read(dev, REG_USBCTL, &vp)) < 0) { |
49ae25b0 | 299 | netdev_dbg(dev->net, "can't read USBCTL, %d\n", retval); |
904813cd DB |
300 | goto done; |
301 | } | |
5ffbe4da | 302 | usbctl = vp; |
904813cd DB |
303 | nc_dump_usbctl(dev, usbctl); |
304 | ||
305 | nc_register_write(dev, REG_USBCTL, | |
306 | USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER); | |
307 | ||
5ffbe4da | 308 | if ((retval = nc_register_read(dev, REG_TTL, &vp)) < 0) { |
49ae25b0 | 309 | netdev_dbg(dev->net, "can't read TTL, %d\n", retval); |
904813cd DB |
310 | goto done; |
311 | } | |
5ffbe4da | 312 | ttl = vp; |
904813cd DB |
313 | // nc_dump_ttl(dev, ttl); |
314 | ||
315 | nc_register_write(dev, REG_TTL, | |
316 | MK_TTL(NC_READ_TTL_MS, TTL_OTHER(ttl)) ); | |
49ae25b0 | 317 | netdev_dbg(dev->net, "assigned TTL, %d ms\n", NC_READ_TTL_MS); |
904813cd | 318 | |
a475f603 JP |
319 | netif_info(dev, link, dev->net, "port %c, peer %sconnected\n", |
320 | (status & STATUS_PORT_A) ? 'A' : 'B', | |
321 | (status & STATUS_CONN_OTHER) ? "" : "dis"); | |
904813cd DB |
322 | retval = 0; |
323 | ||
324 | done: | |
904813cd DB |
325 | return retval; |
326 | } | |
327 | ||
328 | static int net1080_check_connect(struct usbnet *dev) | |
329 | { | |
330 | int retval; | |
331 | u16 status; | |
5ffbe4da | 332 | u16 vp; |
904813cd | 333 | |
5ffbe4da ML |
334 | retval = nc_register_read(dev, REG_STATUS, &vp); |
335 | status = vp; | |
904813cd | 336 | if (retval != 0) { |
49ae25b0 | 337 | netdev_dbg(dev->net, "net1080_check_conn read - %d\n", retval); |
904813cd DB |
338 | return retval; |
339 | } | |
340 | if ((status & STATUS_CONN_OTHER) != STATUS_CONN_OTHER) | |
341 | return -ENOLINK; | |
342 | return 0; | |
343 | } | |
344 | ||
904813cd DB |
345 | static void nc_ensure_sync(struct usbnet *dev) |
346 | { | |
5ffbe4da ML |
347 | if (++dev->frame_errors <= 5) |
348 | return; | |
349 | ||
350 | if (usbnet_write_cmd_async(dev, REQUEST_REGISTER, | |
351 | USB_DIR_OUT | USB_TYPE_VENDOR | | |
352 | USB_RECIP_DEVICE, | |
353 | USBCTL_FLUSH_THIS | | |
354 | USBCTL_FLUSH_OTHER, | |
355 | REG_USBCTL, NULL, 0)) | |
356 | return; | |
357 | ||
358 | netif_dbg(dev, rx_err, dev->net, | |
359 | "flush net1080; too many framing errors\n"); | |
360 | dev->frame_errors = 0; | |
904813cd DB |
361 | } |
362 | ||
363 | static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |
364 | { | |
365 | struct nc_header *header; | |
366 | struct nc_trailer *trailer; | |
367 | u16 hdr_len, packet_len; | |
368 | ||
07ea875e EG |
369 | /* This check is no longer done by usbnet */ |
370 | if (skb->len < dev->net->hard_header_len) | |
371 | return 0; | |
372 | ||
904813cd | 373 | if (!(skb->len & 0x01)) { |
49ae25b0 | 374 | netdev_dbg(dev->net, "rx framesize %d range %d..%d mtu %d\n", |
127a4794 JP |
375 | skb->len, dev->net->hard_header_len, dev->hard_mtu, |
376 | dev->net->mtu); | |
a22d2b36 | 377 | dev->net->stats.rx_frame_errors++; |
904813cd DB |
378 | nc_ensure_sync(dev); |
379 | return 0; | |
380 | } | |
381 | ||
382 | header = (struct nc_header *) skb->data; | |
383 | hdr_len = le16_to_cpup(&header->hdr_len); | |
384 | packet_len = le16_to_cpup(&header->packet_len); | |
385 | if (FRAMED_SIZE(packet_len) > NC_MAX_PACKET) { | |
a22d2b36 | 386 | dev->net->stats.rx_frame_errors++; |
49ae25b0 | 387 | netdev_dbg(dev->net, "packet too big, %d\n", packet_len); |
904813cd DB |
388 | nc_ensure_sync(dev); |
389 | return 0; | |
390 | } else if (hdr_len < MIN_HEADER) { | |
a22d2b36 | 391 | dev->net->stats.rx_frame_errors++; |
49ae25b0 | 392 | netdev_dbg(dev->net, "header too short, %d\n", hdr_len); |
904813cd DB |
393 | nc_ensure_sync(dev); |
394 | return 0; | |
395 | } else if (hdr_len > MIN_HEADER) { | |
396 | // out of band data for us? | |
49ae25b0 | 397 | netdev_dbg(dev->net, "header OOB, %d bytes\n", hdr_len - MIN_HEADER); |
904813cd DB |
398 | nc_ensure_sync(dev); |
399 | // switch (vendor/product ids) { ... } | |
400 | } | |
401 | skb_pull(skb, hdr_len); | |
402 | ||
403 | trailer = (struct nc_trailer *) | |
404 | (skb->data + skb->len - sizeof *trailer); | |
405 | skb_trim(skb, skb->len - sizeof *trailer); | |
406 | ||
407 | if ((packet_len & 0x01) == 0) { | |
408 | if (skb->data [packet_len] != PAD_BYTE) { | |
a22d2b36 | 409 | dev->net->stats.rx_frame_errors++; |
49ae25b0 | 410 | netdev_dbg(dev->net, "bad pad\n"); |
904813cd DB |
411 | return 0; |
412 | } | |
413 | skb_trim(skb, skb->len - 1); | |
414 | } | |
415 | if (skb->len != packet_len) { | |
a22d2b36 | 416 | dev->net->stats.rx_frame_errors++; |
49ae25b0 GKH |
417 | netdev_dbg(dev->net, "bad packet len %d (expected %d)\n", |
418 | skb->len, packet_len); | |
904813cd DB |
419 | nc_ensure_sync(dev); |
420 | return 0; | |
421 | } | |
422 | if (header->packet_id != get_unaligned(&trailer->packet_id)) { | |
a22d2b36 | 423 | dev->net->stats.rx_fifo_errors++; |
49ae25b0 GKH |
424 | netdev_dbg(dev->net, "(2+ dropped) rx packet_id mismatch 0x%x 0x%x\n", |
425 | le16_to_cpu(header->packet_id), | |
426 | le16_to_cpu(trailer->packet_id)); | |
904813cd DB |
427 | return 0; |
428 | } | |
429 | #if 0 | |
60b86755 JP |
430 | netdev_dbg(dev->net, "frame <rx h %d p %d id %d\n", header->hdr_len, |
431 | header->packet_len, header->packet_id); | |
904813cd DB |
432 | #endif |
433 | dev->frame_errors = 0; | |
434 | return 1; | |
435 | } | |
436 | ||
437 | static struct sk_buff * | |
55016f10 | 438 | net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) |
904813cd | 439 | { |
904813cd DB |
440 | struct sk_buff *skb2; |
441 | struct nc_header *header = NULL; | |
442 | struct nc_trailer *trailer = NULL; | |
9bcbcf4d | 443 | int padlen = sizeof (struct nc_trailer); |
904813cd DB |
444 | int len = skb->len; |
445 | ||
9bcbcf4d | 446 | if (!((len + padlen + sizeof (struct nc_header)) & 0x01)) |
447 | padlen++; | |
904813cd DB |
448 | if (!skb_cloned(skb)) { |
449 | int headroom = skb_headroom(skb); | |
450 | int tailroom = skb_tailroom(skb); | |
451 | ||
9bcbcf4d | 452 | if (padlen <= tailroom && |
453 | sizeof(struct nc_header) <= headroom) | |
904813cd DB |
454 | /* There's enough head and tail room */ |
455 | goto encapsulate; | |
456 | ||
9bcbcf4d | 457 | if ((sizeof (struct nc_header) + padlen) < |
904813cd DB |
458 | (headroom + tailroom)) { |
459 | /* There's enough total room, so just readjust */ | |
460 | skb->data = memmove(skb->head | |
461 | + sizeof (struct nc_header), | |
462 | skb->data, skb->len); | |
27a884dc | 463 | skb_set_tail_pointer(skb, len); |
904813cd DB |
464 | goto encapsulate; |
465 | } | |
466 | } | |
467 | ||
468 | /* Create a new skb to use with the correct size */ | |
469 | skb2 = skb_copy_expand(skb, | |
470 | sizeof (struct nc_header), | |
9bcbcf4d | 471 | padlen, |
904813cd DB |
472 | flags); |
473 | dev_kfree_skb_any(skb); | |
474 | if (!skb2) | |
475 | return skb2; | |
476 | skb = skb2; | |
477 | ||
478 | encapsulate: | |
479 | /* header first */ | |
480 | header = (struct nc_header *) skb_push(skb, sizeof *header); | |
481 | header->hdr_len = cpu_to_le16(sizeof (*header)); | |
482 | header->packet_len = cpu_to_le16(len); | |
483 | header->packet_id = cpu_to_le16((u16)dev->xid++); | |
484 | ||
485 | /* maybe pad; then trailer */ | |
486 | if (!((skb->len + sizeof *trailer) & 0x01)) | |
487 | *skb_put(skb, 1) = PAD_BYTE; | |
488 | trailer = (struct nc_trailer *) skb_put(skb, sizeof *trailer); | |
489 | put_unaligned(header->packet_id, &trailer->packet_id); | |
490 | #if 0 | |
60b86755 JP |
491 | netdev_dbg(dev->net, "frame >tx h %d p %d id %d\n", |
492 | header->hdr_len, header->packet_len, | |
493 | header->packet_id); | |
904813cd DB |
494 | #endif |
495 | return skb; | |
496 | } | |
497 | ||
498 | static int net1080_bind(struct usbnet *dev, struct usb_interface *intf) | |
499 | { | |
500 | unsigned extra = sizeof (struct nc_header) | |
501 | + 1 | |
502 | + sizeof (struct nc_trailer); | |
503 | ||
504 | dev->net->hard_header_len += extra; | |
505 | dev->rx_urb_size = dev->net->hard_header_len + dev->net->mtu; | |
506 | dev->hard_mtu = NC_MAX_PACKET; | |
507 | return usbnet_get_endpoints (dev, intf); | |
508 | } | |
509 | ||
510 | static const struct driver_info net1080_info = { | |
511 | .description = "NetChip TurboCONNECT", | |
c261344d | 512 | .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_NC, |
904813cd DB |
513 | .bind = net1080_bind, |
514 | .reset = net1080_reset, | |
515 | .check_connect = net1080_check_connect, | |
516 | .rx_fixup = net1080_rx_fixup, | |
517 | .tx_fixup = net1080_tx_fixup, | |
518 | }; | |
519 | ||
520 | static const struct usb_device_id products [] = { | |
521 | { | |
522 | USB_DEVICE(0x0525, 0x1080), // NetChip ref design | |
523 | .driver_info = (unsigned long) &net1080_info, | |
524 | }, { | |
525 | USB_DEVICE(0x06D0, 0x0622), // Laplink Gold | |
526 | .driver_info = (unsigned long) &net1080_info, | |
527 | }, | |
528 | { }, // END | |
529 | }; | |
530 | MODULE_DEVICE_TABLE(usb, products); | |
531 | ||
532 | static struct usb_driver net1080_driver = { | |
904813cd DB |
533 | .name = "net1080", |
534 | .id_table = products, | |
535 | .probe = usbnet_probe, | |
536 | .disconnect = usbnet_disconnect, | |
537 | .suspend = usbnet_suspend, | |
538 | .resume = usbnet_resume, | |
e1f12eb6 | 539 | .disable_hub_initiated_lpm = 1, |
904813cd DB |
540 | }; |
541 | ||
d632eb1b | 542 | module_usb_driver(net1080_driver); |
904813cd DB |
543 | |
544 | MODULE_AUTHOR("David Brownell"); | |
545 | MODULE_DESCRIPTION("NetChip 1080 based USB Host-to-Host Links"); | |
546 | MODULE_LICENSE("GPL"); |