aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/net')
-rw-r--r--drivers/usb/net/Kconfig19
-rw-r--r--drivers/usb/net/Makefile1
-rw-r--r--drivers/usb/net/gl620a.c407
-rw-r--r--drivers/usb/net/usbnet.c350
4 files changed, 418 insertions, 359 deletions
diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
index 0aa8637e5ff3..0aafd599d7d4 100644
--- a/drivers/usb/net/Kconfig
+++ b/drivers/usb/net/Kconfig
@@ -128,16 +128,6 @@ config USB_USBNET
128comment "USB Host-to-Host Cables" 128comment "USB Host-to-Host Cables"
129 depends on USB_USBNET 129 depends on USB_USBNET
130 130
131config USB_GENESYS
132 boolean "GeneSys GL620USB-A based cables"
133 default y
134 depends on USB_USBNET
135 help
136 Choose this option if you're using a host-to-host cable,
137 or PC2PC motherboard, with this chip.
138
139 Note that the half-duplex "GL620USB" is not supported.
140
141config USB_PL2301 131config USB_PL2301
142 boolean "Prolific PL-2301/2302 based cables" 132 boolean "Prolific PL-2301/2302 based cables"
143 default y 133 default y
@@ -224,6 +214,15 @@ config USB_NET_AX8817X
224 what other networking devices you have in use. 214 what other networking devices you have in use.
225 215
226 216
217config USB_NET_GL620A
218 tristate "GeneSys GL620USB-A based cables"
219 depends on USB_USBNET
220 help
221 Choose this option if you're using a host-to-host cable,
222 or PC2PC motherboard, with this chip.
223
224 Note that the half-duplex "GL620USB" is not supported.
225
227config USB_NET_NET1080 226config USB_NET_NET1080
228 tristate "NetChip 1080 based cables (Laplink, ...)" 227 tristate "NetChip 1080 based cables (Laplink, ...)"
229 default y 228 default y
diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile
index 14d554080aa5..f9b181e91c1f 100644
--- a/drivers/usb/net/Makefile
+++ b/drivers/usb/net/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_USB_KAWETH) += kaweth.o
7obj-$(CONFIG_USB_PEGASUS) += pegasus.o 7obj-$(CONFIG_USB_PEGASUS) += pegasus.o
8obj-$(CONFIG_USB_RTL8150) += rtl8150.o 8obj-$(CONFIG_USB_RTL8150) += rtl8150.o
9obj-$(CONFIG_USB_NET_AX8817X) += asix.o 9obj-$(CONFIG_USB_NET_AX8817X) += asix.o
10obj-$(CONFIG_USB_NET_GL620A) += gl620a.o
10obj-$(CONFIG_USB_NET_NET1080) += net1080.o 11obj-$(CONFIG_USB_NET_NET1080) += net1080.o
11obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o 12obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o
12obj-$(CONFIG_USB_USBNET) += usbnet.o 13obj-$(CONFIG_USB_USBNET) += usbnet.o
diff --git a/drivers/usb/net/gl620a.c b/drivers/usb/net/gl620a.c
new file mode 100644
index 000000000000..c8763ae33c73
--- /dev/null
+++ b/drivers/usb/net/gl620a.c
@@ -0,0 +1,407 @@
1/*
2 * GeneSys GL620USB-A based links
3 * Copyright (C) 2001 by Jiun-Jie Huang <huangjj@genesyslogic.com.tw>
4 * Copyright (C) 2001 by Stanislav Brabec <utx@penguin.cz>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// #define DEBUG // error path messages, extra info
22// #define VERBOSE // more; success messages
23
24#include <linux/config.h>
25#ifdef CONFIG_USB_DEBUG
26# define DEBUG
27#endif
28#include <linux/module.h>
29#include <linux/sched.h>
30#include <linux/init.h>
31#include <linux/netdevice.h>
32#include <linux/etherdevice.h>
33#include <linux/ethtool.h>
34#include <linux/workqueue.h>
35#include <linux/mii.h>
36#include <linux/usb.h>
37
38#include "usbnet.h"
39
40
41/*
42 * GeneSys GL620USB-A (www.genesyslogic.com.tw)
43 *
44 * ... should partially interop with the Win32 driver for this hardware.
45 * The GeneSys docs imply there's some NDIS issue motivating this framing.
46 *
47 * Some info from GeneSys:
48 * - GL620USB-A is full duplex; GL620USB is only half duplex for bulk.
49 * (Some cables, like the BAFO-100c, use the half duplex version.)
50 * - For the full duplex model, the low bit of the version code says
51 * which side is which ("left/right").
52 * - For the half duplex type, a control/interrupt handshake settles
53 * the transfer direction. (That's disabled here, partially coded.)
54 * A control URB would block until other side writes an interrupt.
55 *
56 * Original code from Jiun-Jie Huang <huangjj@genesyslogic.com.tw>
57 * and merged into "usbnet" by Stanislav Brabec <utx@penguin.cz>.
58 */
59
60// control msg write command
61#define GENELINK_CONNECT_WRITE 0xF0
62// interrupt pipe index
63#define GENELINK_INTERRUPT_PIPE 0x03
64// interrupt read buffer size
65#define INTERRUPT_BUFSIZE 0x08
66// interrupt pipe interval value
67#define GENELINK_INTERRUPT_INTERVAL 0x10
68// max transmit packet number per transmit
69#define GL_MAX_TRANSMIT_PACKETS 32
70// max packet length
71#define GL_MAX_PACKET_LEN 1514
72// max receive buffer size
73#define GL_RCV_BUF_SIZE \
74 (((GL_MAX_PACKET_LEN + 4) * GL_MAX_TRANSMIT_PACKETS) + 4)
75
76struct gl_packet {
77 u32 packet_length;
78 char packet_data [1];
79};
80
81struct gl_header {
82 u32 packet_count;
83 struct gl_packet packets;
84};
85
86#ifdef GENELINK_ACK
87
88// FIXME: this code is incomplete, not debugged; it doesn't
89// handle interrupts correctly; it should use the generic
90// status IRQ code (which didn't exist back in 2001).
91
92struct gl_priv {
93 struct urb *irq_urb;
94 char irq_buf [INTERRUPT_BUFSIZE];
95};
96
97static inline int gl_control_write(struct usbnet *dev, u8 request, u16 value)
98{
99 int retval;
100
101 retval = usb_control_msg(dev->udev,
102 usb_sndctrlpipe(dev->udev, 0),
103 request,
104 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
105 value,
106 0, // index
107 0, // data buffer
108 0, // size
109 USB_CTRL_SET_TIMEOUT);
110 return retval;
111}
112
113static void gl_interrupt_complete(struct urb *urb, struct pt_regs *regs)
114{
115 int status = urb->status;
116
117 switch (status) {
118 case 0:
119 /* success */
120 break;
121 case -ECONNRESET:
122 case -ENOENT:
123 case -ESHUTDOWN:
124 /* this urb is terminated, clean up */
125 dbg("%s - urb shutting down with status: %d",
126 __FUNCTION__, status);
127 return;
128 default:
129 dbg("%s - nonzero urb status received: %d",
130 __FUNCTION__, urb->status);
131 }
132
133 status = usb_submit_urb(urb, GFP_ATOMIC);
134 if (status)
135 err("%s - usb_submit_urb failed with result %d",
136 __FUNCTION__, status);
137}
138
139static int gl_interrupt_read(struct usbnet *dev)
140{
141 struct gl_priv *priv = dev->priv_data;
142 int retval;
143
144 // issue usb interrupt read
145 if (priv && priv->irq_urb) {
146 // submit urb
147 if ((retval = usb_submit_urb(priv->irq_urb, GFP_KERNEL)) != 0)
148 dbg("gl_interrupt_read: submit fail - %X...", retval);
149 else
150 dbg("gl_interrupt_read: submit success...");
151 }
152
153 return 0;
154}
155
156// check whether another side is connected
157static int genelink_check_connect(struct usbnet *dev)
158{
159 int retval;
160
161 dbg("genelink_check_connect...");
162
163 // detect whether another side is connected
164 if ((retval = gl_control_write(dev, GENELINK_CONNECT_WRITE, 0)) != 0) {
165 dbg("%s: genelink_check_connect write fail - %X",
166 dev->net->name, retval);
167 return retval;
168 }
169
170 // usb interrupt read to ack another side
171 if ((retval = gl_interrupt_read(dev)) != 0) {
172 dbg("%s: genelink_check_connect read fail - %X",
173 dev->net->name, retval);
174 return retval;
175 }
176
177 dbg("%s: genelink_check_connect read success", dev->net->name);
178 return 0;
179}
180
181// allocate and initialize the private data for genelink
182static int genelink_init(struct usbnet *dev)
183{
184 struct gl_priv *priv;
185
186 // allocate the private data structure
187 if ((priv = kmalloc(sizeof *priv, GFP_KERNEL)) == 0) {
188 dbg("%s: cannot allocate private data per device",
189 dev->net->name);
190 return -ENOMEM;
191 }
192
193 // allocate irq urb
194 if ((priv->irq_urb = usb_alloc_urb(0, GFP_KERNEL)) == 0) {
195 dbg("%s: cannot allocate private irq urb per device",
196 dev->net->name);
197 kfree(priv);
198 return -ENOMEM;
199 }
200
201 // fill irq urb
202 usb_fill_int_urb(priv->irq_urb, dev->udev,
203 usb_rcvintpipe(dev->udev, GENELINK_INTERRUPT_PIPE),
204 priv->irq_buf, INTERRUPT_BUFSIZE,
205 gl_interrupt_complete, 0,
206 GENELINK_INTERRUPT_INTERVAL);
207
208 // set private data pointer
209 dev->priv_data = priv;
210
211 return 0;
212}
213
214// release the private data
215static int genelink_free(struct usbnet *dev)
216{
217 struct gl_priv *priv = dev->priv_data;
218
219 if (!priv)
220 return 0;
221
222// FIXME: can't cancel here; it's synchronous, and
223// should have happened earlier in any case (interrupt
224// handling needs to be generic)
225
226 // cancel irq urb first
227 usb_kill_urb(priv->irq_urb);
228
229 // free irq urb
230 usb_free_urb(priv->irq_urb);
231
232 // free the private data structure
233 kfree(priv);
234
235 return 0;
236}
237
238#endif
239
240static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
241{
242 struct gl_header *header;
243 struct gl_packet *packet;
244 struct sk_buff *gl_skb;
245 u32 size;
246
247 header = (struct gl_header *) skb->data;
248
249 // get the packet count of the received skb
250 le32_to_cpus(&header->packet_count);
251 if ((header->packet_count > GL_MAX_TRANSMIT_PACKETS)
252 || (header->packet_count < 0)) {
253 dbg("genelink: invalid received packet count %d",
254 header->packet_count);
255 return 0;
256 }
257
258 // set the current packet pointer to the first packet
259 packet = &header->packets;
260
261 // decrement the length for the packet count size 4 bytes
262 skb_pull(skb, 4);
263
264 while (header->packet_count > 1) {
265 // get the packet length
266 size = le32_to_cpu(packet->packet_length);
267
268 // this may be a broken packet
269 if (size > GL_MAX_PACKET_LEN) {
270 dbg("genelink: invalid rx length %d", size);
271 return 0;
272 }
273
274 // allocate the skb for the individual packet
275 gl_skb = alloc_skb(size, GFP_ATOMIC);
276 if (gl_skb) {
277
278 // copy the packet data to the new skb
279 memcpy(skb_put(gl_skb, size),
280 packet->packet_data, size);
281 usbnet_skb_return(dev, gl_skb);
282 }
283
284 // advance to the next packet
285 packet = (struct gl_packet *)
286 &packet->packet_data [size];
287 header->packet_count--;
288
289 // shift the data pointer to the next gl_packet
290 skb_pull(skb, size + 4);
291 }
292
293 // skip the packet length field 4 bytes
294 skb_pull(skb, 4);
295
296 if (skb->len > GL_MAX_PACKET_LEN) {
297 dbg("genelink: invalid rx length %d", skb->len);
298 return 0;
299 }
300 return 1;
301}
302
303static struct sk_buff *
304genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags)
305{
306 int padlen;
307 int length = skb->len;
308 int headroom = skb_headroom(skb);
309 int tailroom = skb_tailroom(skb);
310 u32 *packet_count;
311 u32 *packet_len;
312
313 // FIXME: magic numbers, bleech
314 padlen = ((skb->len + (4 + 4*1)) % 64) ? 0 : 1;
315
316 if ((!skb_cloned(skb))
317 && ((headroom + tailroom) >= (padlen + (4 + 4*1)))) {
318 if ((headroom < (4 + 4*1)) || (tailroom < padlen)) {
319 skb->data = memmove(skb->head + (4 + 4*1),
320 skb->data, skb->len);
321 skb->tail = skb->data + skb->len;
322 }
323 } else {
324 struct sk_buff *skb2;
325 skb2 = skb_copy_expand(skb, (4 + 4*1) , padlen, flags);
326 dev_kfree_skb_any(skb);
327 skb = skb2;
328 if (!skb)
329 return NULL;
330 }
331
332 // attach the packet count to the header
333 packet_count = (u32 *) skb_push(skb, (4 + 4*1));
334 packet_len = packet_count + 1;
335
336 *packet_count = cpu_to_le32(1);
337 *packet_len = cpu_to_le32(length);
338
339 // add padding byte
340 if ((skb->len % dev->maxpacket) == 0)
341 skb_put(skb, 1);
342
343 return skb;
344}
345
346static int genelink_bind(struct usbnet *dev, struct usb_interface *intf)
347{
348 dev->hard_mtu = GL_RCV_BUF_SIZE;
349 dev->net->hard_header_len += 4;
350 dev->in = usb_rcvbulkpipe(dev->udev, dev->driver_info->in);
351 dev->out = usb_sndbulkpipe(dev->udev, dev->driver_info->out);
352 return 0;
353}
354
355static const struct driver_info genelink_info = {
356 .description = "Genesys GeneLink",
357 .flags = FLAG_FRAMING_GL | FLAG_NO_SETINT,
358 .bind = genelink_bind,
359 .rx_fixup = genelink_rx_fixup,
360 .tx_fixup = genelink_tx_fixup,
361
362 .in = 1, .out = 2,
363
364#ifdef GENELINK_ACK
365 .check_connect =genelink_check_connect,
366#endif
367};
368
369static const struct usb_device_id products [] = {
370
371{
372 USB_DEVICE(0x05e3, 0x0502), // GL620USB-A
373 .driver_info = (unsigned long) &genelink_info,
374},
375 /* NOT: USB_DEVICE(0x05e3, 0x0501), // GL620USB
376 * that's half duplex, not currently supported
377 */
378 { }, // END
379};
380MODULE_DEVICE_TABLE(usb, products);
381
382static struct usb_driver gl620a_driver = {
383 .owner = THIS_MODULE,
384 .name = "gl620a",
385 .id_table = products,
386 .probe = usbnet_probe,
387 .disconnect = usbnet_disconnect,
388 .suspend = usbnet_suspend,
389 .resume = usbnet_resume,
390};
391
392static int __init usbnet_init(void)
393{
394 return usb_register(&gl620a_driver);
395}
396module_init(usbnet_init);
397
398static void __exit usbnet_exit(void)
399{
400 usb_deregister(&gl620a_driver);
401}
402module_exit(usbnet_exit);
403
404MODULE_AUTHOR("Jiun-Jie Huang");
405MODULE_DESCRIPTION("GL620-USB-A Host-to-Host Link cables");
406MODULE_LICENSE("GPL");
407
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 590bf31ae1f4..d52480aced80 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -156,9 +156,6 @@
156// us (it polls at HZ/4 usually) before we report too many false errors. 156// us (it polls at HZ/4 usually) before we report too many false errors.
157#define THROTTLE_JIFFIES (HZ/8) 157#define THROTTLE_JIFFIES (HZ/8)
158 158
159// for vendor-specific control operations
160#define CONTROL_TIMEOUT_MS USB_CTRL_GET_TIMEOUT
161
162// between wakeups 159// between wakeups
163#define UNLINK_TIMEOUT_MS 3 160#define UNLINK_TIMEOUT_MS 3
164 161
@@ -690,341 +687,6 @@ static const struct driver_info cdc_info = {
690 687
691 688
692 689
693#ifdef CONFIG_USB_GENESYS
694#define HAVE_HARDWARE
695
696/*-------------------------------------------------------------------------
697 *
698 * GeneSys GL620USB-A (www.genesyslogic.com.tw)
699 *
700 * ... should partially interop with the Win32 driver for this hardware
701 * The GeneSys docs imply there's some NDIS issue motivating this framing.
702 *
703 * Some info from GeneSys:
704 * - GL620USB-A is full duplex; GL620USB is only half duplex for bulk.
705 * (Some cables, like the BAFO-100c, use the half duplex version.)
706 * - For the full duplex model, the low bit of the version code says
707 * which side is which ("left/right").
708 * - For the half duplex type, a control/interrupt handshake settles
709 * the transfer direction. (That's disabled here, partially coded.)
710 * A control URB would block until other side writes an interrupt.
711 *
712 * Original code from Jiun-Jie Huang <huangjj@genesyslogic.com.tw>
713 * and merged into "usbnet" by Stanislav Brabec <utx@penguin.cz>.
714 *
715 *-------------------------------------------------------------------------*/
716
717// control msg write command
718#define GENELINK_CONNECT_WRITE 0xF0
719// interrupt pipe index
720#define GENELINK_INTERRUPT_PIPE 0x03
721// interrupt read buffer size
722#define INTERRUPT_BUFSIZE 0x08
723// interrupt pipe interval value
724#define GENELINK_INTERRUPT_INTERVAL 0x10
725// max transmit packet number per transmit
726#define GL_MAX_TRANSMIT_PACKETS 32
727// max packet length
728#define GL_MAX_PACKET_LEN 1514
729// max receive buffer size
730#define GL_RCV_BUF_SIZE \
731 (((GL_MAX_PACKET_LEN + 4) * GL_MAX_TRANSMIT_PACKETS) + 4)
732
733struct gl_packet {
734 u32 packet_length;
735 char packet_data [1];
736};
737
738struct gl_header {
739 u32 packet_count;
740 struct gl_packet packets;
741};
742
743#ifdef GENELINK_ACK
744
745// FIXME: this code is incomplete, not debugged; it doesn't
746// handle interrupts correctly. interrupts should be generic
747// code like all other device I/O, anyway.
748
749struct gl_priv {
750 struct urb *irq_urb;
751 char irq_buf [INTERRUPT_BUFSIZE];
752};
753
754static inline int gl_control_write (struct usbnet *dev, u8 request, u16 value)
755{
756 int retval;
757
758 retval = usb_control_msg (dev->udev,
759 usb_sndctrlpipe (dev->udev, 0),
760 request,
761 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
762 value,
763 0, // index
764 0, // data buffer
765 0, // size
766 CONTROL_TIMEOUT_MS);
767 return retval;
768}
769
770static void gl_interrupt_complete (struct urb *urb, struct pt_regs *regs)
771{
772 int status = urb->status;
773
774 switch (status) {
775 case 0:
776 /* success */
777 break;
778 case -ECONNRESET:
779 case -ENOENT:
780 case -ESHUTDOWN:
781 /* this urb is terminated, clean up */
782 dbg("%s - urb shutting down with status: %d",
783 __FUNCTION__, status);
784 return;
785 default:
786 dbg("%s - nonzero urb status received: %d",
787 __FUNCTION__, urb->status);
788 }
789
790 status = usb_submit_urb (urb, GFP_ATOMIC);
791 if (status)
792 err ("%s - usb_submit_urb failed with result %d",
793 __FUNCTION__, status);
794}
795
796static int gl_interrupt_read (struct usbnet *dev)
797{
798 struct gl_priv *priv = dev->priv_data;
799 int retval;
800
801 // issue usb interrupt read
802 if (priv && priv->irq_urb) {
803 // submit urb
804 if ((retval = usb_submit_urb (priv->irq_urb, GFP_KERNEL)) != 0)
805 dbg ("gl_interrupt_read: submit fail - %X...", retval);
806 else
807 dbg ("gl_interrupt_read: submit success...");
808 }
809
810 return 0;
811}
812
813// check whether another side is connected
814static int genelink_check_connect (struct usbnet *dev)
815{
816 int retval;
817
818 dbg ("genelink_check_connect...");
819
820 // detect whether another side is connected
821 if ((retval = gl_control_write (dev, GENELINK_CONNECT_WRITE, 0)) != 0) {
822 dbg ("%s: genelink_check_connect write fail - %X",
823 dev->net->name, retval);
824 return retval;
825 }
826
827 // usb interrupt read to ack another side
828 if ((retval = gl_interrupt_read (dev)) != 0) {
829 dbg ("%s: genelink_check_connect read fail - %X",
830 dev->net->name, retval);
831 return retval;
832 }
833
834 dbg ("%s: genelink_check_connect read success", dev->net->name);
835 return 0;
836}
837
838// allocate and initialize the private data for genelink
839static int genelink_init (struct usbnet *dev)
840{
841 struct gl_priv *priv;
842
843 // allocate the private data structure
844 if ((priv = kmalloc (sizeof *priv, GFP_KERNEL)) == 0) {
845 dbg ("%s: cannot allocate private data per device",
846 dev->net->name);
847 return -ENOMEM;
848 }
849
850 // allocate irq urb
851 if ((priv->irq_urb = usb_alloc_urb (0, GFP_KERNEL)) == 0) {
852 dbg ("%s: cannot allocate private irq urb per device",
853 dev->net->name);
854 kfree (priv);
855 return -ENOMEM;
856 }
857
858 // fill irq urb
859 usb_fill_int_urb (priv->irq_urb, dev->udev,
860 usb_rcvintpipe (dev->udev, GENELINK_INTERRUPT_PIPE),
861 priv->irq_buf, INTERRUPT_BUFSIZE,
862 gl_interrupt_complete, 0,
863 GENELINK_INTERRUPT_INTERVAL);
864
865 // set private data pointer
866 dev->priv_data = priv;
867
868 return 0;
869}
870
871// release the private data
872static int genelink_free (struct usbnet *dev)
873{
874 struct gl_priv *priv = dev->priv_data;
875
876 if (!priv)
877 return 0;
878
879// FIXME: can't cancel here; it's synchronous, and
880// should have happened earlier in any case (interrupt
881// handling needs to be generic)
882
883 // cancel irq urb first
884 usb_kill_urb (priv->irq_urb);
885
886 // free irq urb
887 usb_free_urb (priv->irq_urb);
888
889 // free the private data structure
890 kfree (priv);
891
892 return 0;
893}
894
895#endif
896
897static int genelink_rx_fixup (struct usbnet *dev, struct sk_buff *skb)
898{
899 struct gl_header *header;
900 struct gl_packet *packet;
901 struct sk_buff *gl_skb;
902 u32 size;
903
904 header = (struct gl_header *) skb->data;
905
906 // get the packet count of the received skb
907 le32_to_cpus (&header->packet_count);
908 if ((header->packet_count > GL_MAX_TRANSMIT_PACKETS)
909 || (header->packet_count < 0)) {
910 dbg ("genelink: invalid received packet count %d",
911 header->packet_count);
912 return 0;
913 }
914
915 // set the current packet pointer to the first packet
916 packet = &header->packets;
917
918 // decrement the length for the packet count size 4 bytes
919 skb_pull (skb, 4);
920
921 while (header->packet_count > 1) {
922 // get the packet length
923 size = packet->packet_length;
924
925 // this may be a broken packet
926 if (size > GL_MAX_PACKET_LEN) {
927 dbg ("genelink: invalid rx length %d", size);
928 return 0;
929 }
930
931 // allocate the skb for the individual packet
932 gl_skb = alloc_skb (size, GFP_ATOMIC);
933 if (gl_skb) {
934
935 // copy the packet data to the new skb
936 memcpy(skb_put(gl_skb, size), packet->packet_data, size);
937 usbnet_skb_return (dev, gl_skb);
938 }
939
940 // advance to the next packet
941 packet = (struct gl_packet *)
942 &packet->packet_data [size];
943 header->packet_count--;
944
945 // shift the data pointer to the next gl_packet
946 skb_pull (skb, size + 4);
947 }
948
949 // skip the packet length field 4 bytes
950 skb_pull (skb, 4);
951
952 if (skb->len > GL_MAX_PACKET_LEN) {
953 dbg ("genelink: invalid rx length %d", skb->len);
954 return 0;
955 }
956 return 1;
957}
958
959static struct sk_buff *
960genelink_tx_fixup (struct usbnet *dev, struct sk_buff *skb, unsigned flags)
961{
962 int padlen;
963 int length = skb->len;
964 int headroom = skb_headroom (skb);
965 int tailroom = skb_tailroom (skb);
966 u32 *packet_count;
967 u32 *packet_len;
968
969 // FIXME: magic numbers, bleech
970 padlen = ((skb->len + (4 + 4*1)) % 64) ? 0 : 1;
971
972 if ((!skb_cloned (skb))
973 && ((headroom + tailroom) >= (padlen + (4 + 4*1)))) {
974 if ((headroom < (4 + 4*1)) || (tailroom < padlen)) {
975 skb->data = memmove (skb->head + (4 + 4*1),
976 skb->data, skb->len);
977 skb->tail = skb->data + skb->len;
978 }
979 } else {
980 struct sk_buff *skb2;
981 skb2 = skb_copy_expand (skb, (4 + 4*1) , padlen, flags);
982 dev_kfree_skb_any (skb);
983 skb = skb2;
984 if (!skb)
985 return NULL;
986 }
987
988 // attach the packet count to the header
989 packet_count = (u32 *) skb_push (skb, (4 + 4*1));
990 packet_len = packet_count + 1;
991
992 // FIXME little endian?
993 *packet_count = 1;
994 *packet_len = length;
995
996 // add padding byte
997 if ((skb->len % dev->maxpacket) == 0)
998 skb_put (skb, 1);
999
1000 return skb;
1001}
1002
1003static int genelink_bind (struct usbnet *dev, struct usb_interface *intf)
1004{
1005 dev->hard_mtu = GL_RCV_BUF_SIZE;
1006 dev->net->hard_header_len += 4;
1007 return 0;
1008}
1009
1010static const struct driver_info genelink_info = {
1011 .description = "Genesys GeneLink",
1012 .flags = FLAG_FRAMING_GL | FLAG_NO_SETINT,
1013 .bind = genelink_bind,
1014 .rx_fixup = genelink_rx_fixup,
1015 .tx_fixup = genelink_tx_fixup,
1016
1017 .in = 1, .out = 2,
1018
1019#ifdef GENELINK_ACK
1020 .check_connect =genelink_check_connect,
1021#endif
1022};
1023
1024#endif /* CONFIG_USB_GENESYS */
1025
1026
1027
1028#ifdef CONFIG_USB_PL2301 690#ifdef CONFIG_USB_PL2301
1029#define HAVE_HARDWARE 691#define HAVE_HARDWARE
1030 692
@@ -1059,7 +721,7 @@ pl_vendor_req (struct usbnet *dev, u8 req, u8 val, u8 index)
1059 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 721 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1060 val, index, 722 val, index,
1061 NULL, 0, 723 NULL, 0,
1062 CONTROL_TIMEOUT_MS); 724 USB_CTRL_GET_TIMEOUT);
1063} 725}
1064 726
1065static inline int 727static inline int
@@ -2323,16 +1985,6 @@ EXPORT_SYMBOL_GPL(usbnet_resume);
2323 1985
2324static const struct usb_device_id products [] = { 1986static const struct usb_device_id products [] = {
2325 1987
2326#ifdef CONFIG_USB_GENESYS
2327{
2328 USB_DEVICE (0x05e3, 0x0502), // GL620USB-A
2329 .driver_info = (unsigned long) &genelink_info,
2330},
2331 /* NOT: USB_DEVICE (0x05e3, 0x0501), // GL620USB
2332 * that's half duplex, not currently supported
2333 */
2334#endif
2335
2336#ifdef CONFIG_USB_PL2301 1988#ifdef CONFIG_USB_PL2301
2337{ 1989{
2338 USB_DEVICE (0x067b, 0x0000), // PL-2301 1990 USB_DEVICE (0x067b, 0x0000), // PL-2301