xref: /openbmc/linux/drivers/net/usb/lg-vl600.c (revision d58ff35122847a83ba55394e2ae3a1527b6febf5)
17a635ea9SAndrzej Zaborowski /*
27a635ea9SAndrzej Zaborowski  * Ethernet interface part of the LG VL600 LTE modem (4G dongle)
37a635ea9SAndrzej Zaborowski  *
47a635ea9SAndrzej Zaborowski  * Copyright (C) 2011 Intel Corporation
57a635ea9SAndrzej Zaborowski  * Author: Andrzej Zaborowski <balrogg@gmail.com>
67a635ea9SAndrzej Zaborowski  *
77a635ea9SAndrzej Zaborowski  * This program is free software; you can redistribute it and/or modify
87a635ea9SAndrzej Zaborowski  * it under the terms of the GNU General Public License as published by
97a635ea9SAndrzej Zaborowski  * the Free Software Foundation; either version 2 of the License, or
107a635ea9SAndrzej Zaborowski  * (at your option) any later version.
117a635ea9SAndrzej Zaborowski  *
127a635ea9SAndrzej Zaborowski  * This program is distributed in the hope that it will be useful,
137a635ea9SAndrzej Zaborowski  * but WITHOUT ANY WARRANTY; without even the implied warranty of
147a635ea9SAndrzej Zaborowski  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
157a635ea9SAndrzej Zaborowski  * GNU General Public License for more details.
167a635ea9SAndrzej Zaborowski  *
177a635ea9SAndrzej Zaborowski  * You should have received a copy of the GNU General Public License
189cb00073SJeff Kirsher  * along with this program; if not, see <http://www.gnu.org/licenses/>.
197a635ea9SAndrzej Zaborowski  */
207a635ea9SAndrzej Zaborowski #include <linux/etherdevice.h>
217a635ea9SAndrzej Zaborowski #include <linux/ethtool.h>
227a635ea9SAndrzej Zaborowski #include <linux/mii.h>
237a635ea9SAndrzej Zaborowski #include <linux/usb.h>
247a635ea9SAndrzej Zaborowski #include <linux/usb/cdc.h>
257a635ea9SAndrzej Zaborowski #include <linux/usb/usbnet.h>
267a635ea9SAndrzej Zaborowski #include <linux/if_ether.h>
277a635ea9SAndrzej Zaborowski #include <linux/if_arp.h>
287a635ea9SAndrzej Zaborowski #include <linux/inetdevice.h>
299d9779e7SPaul Gortmaker #include <linux/module.h>
307a635ea9SAndrzej Zaborowski 
317a635ea9SAndrzej Zaborowski /*
327a635ea9SAndrzej Zaborowski  * The device has a CDC ACM port for modem control (it claims to be
337a635ea9SAndrzej Zaborowski  * CDC ACM anyway) and a CDC Ethernet port for actual network data.
347a635ea9SAndrzej Zaborowski  * It will however ignore data on both ports that is not encapsulated
357a635ea9SAndrzej Zaborowski  * in a specific way, any data returned is also encapsulated the same
367a635ea9SAndrzej Zaborowski  * way.  The headers don't seem to follow any popular standard.
377a635ea9SAndrzej Zaborowski  *
387a635ea9SAndrzej Zaborowski  * This driver adds and strips these headers from the ethernet frames
397a635ea9SAndrzej Zaborowski  * sent/received from the CDC Ethernet port.  The proprietary header
407a635ea9SAndrzej Zaborowski  * replaces the standard ethernet header in a packet so only actual
417a635ea9SAndrzej Zaborowski  * ethernet frames are allowed.  The headers allow some form of
427a635ea9SAndrzej Zaborowski  * multiplexing by using non standard values of the .h_proto field.
437a635ea9SAndrzej Zaborowski  * Windows/Mac drivers do send a couple of such frames to the device
447a635ea9SAndrzej Zaborowski  * during initialisation, with protocol set to 0x0906 or 0x0b06 and (what
457a635ea9SAndrzej Zaborowski  * seems to be) a flag in the .dummy_flags.  This doesn't seem necessary
467a635ea9SAndrzej Zaborowski  * for modem operation but can possibly be used for GPS or other funcitons.
477a635ea9SAndrzej Zaborowski  */
487a635ea9SAndrzej Zaborowski 
497a635ea9SAndrzej Zaborowski struct vl600_frame_hdr {
507a635ea9SAndrzej Zaborowski 	__le32 len;
517a635ea9SAndrzej Zaborowski 	__le32 serial;
527a635ea9SAndrzej Zaborowski 	__le32 pkt_cnt;
537a635ea9SAndrzej Zaborowski 	__le32 dummy_flags;
547a635ea9SAndrzej Zaborowski 	__le32 dummy;
557a635ea9SAndrzej Zaborowski 	__le32 magic;
567a635ea9SAndrzej Zaborowski } __attribute__((packed));
577a635ea9SAndrzej Zaborowski 
587a635ea9SAndrzej Zaborowski struct vl600_pkt_hdr {
597a635ea9SAndrzej Zaborowski 	__le32 dummy[2];
607a635ea9SAndrzej Zaborowski 	__le32 len;
617a635ea9SAndrzej Zaborowski 	__be16 h_proto;
627a635ea9SAndrzej Zaborowski } __attribute__((packed));
637a635ea9SAndrzej Zaborowski 
647a635ea9SAndrzej Zaborowski struct vl600_state {
657a635ea9SAndrzej Zaborowski 	struct sk_buff *current_rx_buf;
667a635ea9SAndrzej Zaborowski };
677a635ea9SAndrzej Zaborowski 
687a635ea9SAndrzej Zaborowski static int vl600_bind(struct usbnet *dev, struct usb_interface *intf)
697a635ea9SAndrzej Zaborowski {
707a635ea9SAndrzej Zaborowski 	int ret;
717a635ea9SAndrzej Zaborowski 	struct vl600_state *s = kzalloc(sizeof(struct vl600_state), GFP_KERNEL);
727a635ea9SAndrzej Zaborowski 
737a635ea9SAndrzej Zaborowski 	if (!s)
747a635ea9SAndrzej Zaborowski 		return -ENOMEM;
757a635ea9SAndrzej Zaborowski 
767a635ea9SAndrzej Zaborowski 	ret = usbnet_cdc_bind(dev, intf);
777a635ea9SAndrzej Zaborowski 	if (ret) {
787a635ea9SAndrzej Zaborowski 		kfree(s);
797a635ea9SAndrzej Zaborowski 		return ret;
807a635ea9SAndrzej Zaborowski 	}
817a635ea9SAndrzej Zaborowski 
827a635ea9SAndrzej Zaborowski 	dev->driver_priv = s;
837a635ea9SAndrzej Zaborowski 
847a635ea9SAndrzej Zaborowski 	/* ARP packets don't go through, but they're also of no use.  The
857a635ea9SAndrzej Zaborowski 	 * subnet has only two hosts anyway: us and the gateway / DHCP
867a635ea9SAndrzej Zaborowski 	 * server (probably simulated by modem firmware or network operator)
877a635ea9SAndrzej Zaborowski 	 * whose address changes everytime we connect to the intarwebz and
887a635ea9SAndrzej Zaborowski 	 * who doesn't bother answering ARP requests either.  So hardware
897a635ea9SAndrzej Zaborowski 	 * addresses have no meaning, the destination and the source of every
907a635ea9SAndrzej Zaborowski 	 * packet depend only on whether it is on the IN or OUT endpoint.  */
917a635ea9SAndrzej Zaborowski 	dev->net->flags |= IFF_NOARP;
922ae40ee9SMark Kamichoff 	/* IPv6 NDP relies on multicast.  Enable it by default. */
932ae40ee9SMark Kamichoff 	dev->net->flags |= IFF_MULTICAST;
947a635ea9SAndrzej Zaborowski 
957a635ea9SAndrzej Zaborowski 	return ret;
967a635ea9SAndrzej Zaborowski }
977a635ea9SAndrzej Zaborowski 
987a635ea9SAndrzej Zaborowski static void vl600_unbind(struct usbnet *dev, struct usb_interface *intf)
997a635ea9SAndrzej Zaborowski {
1007a635ea9SAndrzej Zaborowski 	struct vl600_state *s = dev->driver_priv;
1017a635ea9SAndrzej Zaborowski 
1027a635ea9SAndrzej Zaborowski 	if (s->current_rx_buf)
1037a635ea9SAndrzej Zaborowski 		dev_kfree_skb(s->current_rx_buf);
1047a635ea9SAndrzej Zaborowski 
1057a635ea9SAndrzej Zaborowski 	kfree(s);
1067a635ea9SAndrzej Zaborowski 
1077a635ea9SAndrzej Zaborowski 	return usbnet_cdc_unbind(dev, intf);
1087a635ea9SAndrzej Zaborowski }
1097a635ea9SAndrzej Zaborowski 
1107a635ea9SAndrzej Zaborowski static int vl600_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
1117a635ea9SAndrzej Zaborowski {
1127a635ea9SAndrzej Zaborowski 	struct vl600_frame_hdr *frame;
1137a635ea9SAndrzej Zaborowski 	struct vl600_pkt_hdr *packet;
1147a635ea9SAndrzej Zaborowski 	struct ethhdr *ethhdr;
1157a635ea9SAndrzej Zaborowski 	int packet_len, count;
1167a635ea9SAndrzej Zaborowski 	struct sk_buff *buf = skb;
1177a635ea9SAndrzej Zaborowski 	struct sk_buff *clone;
1187a635ea9SAndrzej Zaborowski 	struct vl600_state *s = dev->driver_priv;
1197a635ea9SAndrzej Zaborowski 
1207a635ea9SAndrzej Zaborowski 	/* Frame lengths are generally 4B multiplies but every couple of
1217a635ea9SAndrzej Zaborowski 	 * hours there's an odd number of bytes sized yet correct frame,
1227a635ea9SAndrzej Zaborowski 	 * so don't require this.  */
1237a635ea9SAndrzej Zaborowski 
1247a635ea9SAndrzej Zaborowski 	/* Allow a packet (or multiple packets batched together) to be
1257a635ea9SAndrzej Zaborowski 	 * split across many frames.  We don't allow a new batch to
1267a635ea9SAndrzej Zaborowski 	 * begin in the same frame another one is ending however, and no
1277a635ea9SAndrzej Zaborowski 	 * leading or trailing pad bytes.  */
1287a635ea9SAndrzej Zaborowski 	if (s->current_rx_buf) {
1297a635ea9SAndrzej Zaborowski 		frame = (struct vl600_frame_hdr *) s->current_rx_buf->data;
1307a635ea9SAndrzej Zaborowski 		if (skb->len + s->current_rx_buf->len >
1317a635ea9SAndrzej Zaborowski 				le32_to_cpup(&frame->len)) {
1327a635ea9SAndrzej Zaborowski 			netif_err(dev, ifup, dev->net, "Fragment too long\n");
1337a635ea9SAndrzej Zaborowski 			dev->net->stats.rx_length_errors++;
1347a635ea9SAndrzej Zaborowski 			goto error;
1357a635ea9SAndrzej Zaborowski 		}
1367a635ea9SAndrzej Zaborowski 
1377a635ea9SAndrzej Zaborowski 		buf = s->current_rx_buf;
13859ae1d12SJohannes Berg 		skb_put_data(buf, skb->data, skb->len);
1397a635ea9SAndrzej Zaborowski 	} else if (skb->len < 4) {
1407a635ea9SAndrzej Zaborowski 		netif_err(dev, ifup, dev->net, "Frame too short\n");
1417a635ea9SAndrzej Zaborowski 		dev->net->stats.rx_length_errors++;
1427a635ea9SAndrzej Zaborowski 		goto error;
1437a635ea9SAndrzej Zaborowski 	}
1447a635ea9SAndrzej Zaborowski 
1457a635ea9SAndrzej Zaborowski 	frame = (struct vl600_frame_hdr *) buf->data;
1466d74eb94SMark Kamichoff 	/* Yes, check that frame->magic == 0x53544448 (or 0x44544d48),
1476d74eb94SMark Kamichoff 	 * otherwise we may run out of memory w/a bad packet */
1486d74eb94SMark Kamichoff 	if (ntohl(frame->magic) != 0x53544448 &&
1496d74eb94SMark Kamichoff 			ntohl(frame->magic) != 0x44544d48)
1506d74eb94SMark Kamichoff 		goto error;
1517a635ea9SAndrzej Zaborowski 
1527a635ea9SAndrzej Zaborowski 	if (buf->len < sizeof(*frame) ||
1537a635ea9SAndrzej Zaborowski 			buf->len != le32_to_cpup(&frame->len)) {
1547a635ea9SAndrzej Zaborowski 		/* Save this fragment for later assembly */
1557a635ea9SAndrzej Zaborowski 		if (s->current_rx_buf)
1567a635ea9SAndrzej Zaborowski 			return 0;
1577a635ea9SAndrzej Zaborowski 
1587a635ea9SAndrzej Zaborowski 		s->current_rx_buf = skb_copy_expand(skb, 0,
1597a635ea9SAndrzej Zaborowski 				le32_to_cpup(&frame->len), GFP_ATOMIC);
1607a635ea9SAndrzej Zaborowski 		if (!s->current_rx_buf) {
1617a635ea9SAndrzej Zaborowski 			netif_err(dev, ifup, dev->net, "Reserving %i bytes "
1627a635ea9SAndrzej Zaborowski 					"for packet assembly failed.\n",
1637a635ea9SAndrzej Zaborowski 					le32_to_cpup(&frame->len));
1647a635ea9SAndrzej Zaborowski 			dev->net->stats.rx_errors++;
1657a635ea9SAndrzej Zaborowski 		}
1667a635ea9SAndrzej Zaborowski 
1677a635ea9SAndrzej Zaborowski 		return 0;
1687a635ea9SAndrzej Zaborowski 	}
1697a635ea9SAndrzej Zaborowski 
1707a635ea9SAndrzej Zaborowski 	count = le32_to_cpup(&frame->pkt_cnt);
1717a635ea9SAndrzej Zaborowski 
1727a635ea9SAndrzej Zaborowski 	skb_pull(buf, sizeof(*frame));
1737a635ea9SAndrzej Zaborowski 
1747a635ea9SAndrzej Zaborowski 	while (count--) {
1757a635ea9SAndrzej Zaborowski 		if (buf->len < sizeof(*packet)) {
1767a635ea9SAndrzej Zaborowski 			netif_err(dev, ifup, dev->net, "Packet too short\n");
1777a635ea9SAndrzej Zaborowski 			goto error;
1787a635ea9SAndrzej Zaborowski 		}
1797a635ea9SAndrzej Zaborowski 
1807a635ea9SAndrzej Zaborowski 		packet = (struct vl600_pkt_hdr *) buf->data;
1817a635ea9SAndrzej Zaborowski 		packet_len = sizeof(*packet) + le32_to_cpup(&packet->len);
1827a635ea9SAndrzej Zaborowski 		if (packet_len > buf->len) {
1837a635ea9SAndrzej Zaborowski 			netif_err(dev, ifup, dev->net,
1847a635ea9SAndrzej Zaborowski 					"Bad packet length stored in header\n");
1857a635ea9SAndrzej Zaborowski 			goto error;
1867a635ea9SAndrzej Zaborowski 		}
1877a635ea9SAndrzej Zaborowski 
1887a635ea9SAndrzej Zaborowski 		/* Packet header is same size as the ethernet header
1897a635ea9SAndrzej Zaborowski 		 * (sizeof(*packet) == sizeof(*ethhdr)), additionally
1907a635ea9SAndrzej Zaborowski 		 * the h_proto field is in the same place so we just leave it
1917a635ea9SAndrzej Zaborowski 		 * alone and fill in the remaining fields.
1927a635ea9SAndrzej Zaborowski 		 */
1937a635ea9SAndrzej Zaborowski 		ethhdr = (struct ethhdr *) skb->data;
1947a635ea9SAndrzej Zaborowski 		if (be16_to_cpup(&ethhdr->h_proto) == ETH_P_ARP &&
1957a635ea9SAndrzej Zaborowski 				buf->len > 0x26) {
1967a635ea9SAndrzej Zaborowski 			/* Copy the addresses from packet contents */
1977a635ea9SAndrzej Zaborowski 			memcpy(ethhdr->h_source,
1987a635ea9SAndrzej Zaborowski 					&buf->data[sizeof(*ethhdr) + 0x8],
1997a635ea9SAndrzej Zaborowski 					ETH_ALEN);
2007a635ea9SAndrzej Zaborowski 			memcpy(ethhdr->h_dest,
2017a635ea9SAndrzej Zaborowski 					&buf->data[sizeof(*ethhdr) + 0x12],
2027a635ea9SAndrzej Zaborowski 					ETH_ALEN);
2037a635ea9SAndrzej Zaborowski 		} else {
204519983b1SJoe Perches 			eth_zero_addr(ethhdr->h_source);
2057a635ea9SAndrzej Zaborowski 			memcpy(ethhdr->h_dest, dev->net->dev_addr, ETH_ALEN);
2062ae40ee9SMark Kamichoff 
2072ae40ee9SMark Kamichoff 			/* Inbound IPv6 packets have an IPv4 ethertype (0x800)
2082ae40ee9SMark Kamichoff 			 * for some reason.  Peek at the L3 header to check
2092ae40ee9SMark Kamichoff 			 * for IPv6 packets, and set the ethertype to IPv6
2102ae40ee9SMark Kamichoff 			 * (0x86dd) so Linux can understand it.
2112ae40ee9SMark Kamichoff 			 */
2122ae40ee9SMark Kamichoff 			if ((buf->data[sizeof(*ethhdr)] & 0xf0) == 0x60)
2131f36fc74SJoe Perches 				ethhdr->h_proto = htons(ETH_P_IPV6);
2147a635ea9SAndrzej Zaborowski 		}
2157a635ea9SAndrzej Zaborowski 
2167a635ea9SAndrzej Zaborowski 		if (count) {
2177a635ea9SAndrzej Zaborowski 			/* Not the last packet in this batch */
2187a635ea9SAndrzej Zaborowski 			clone = skb_clone(buf, GFP_ATOMIC);
2197a635ea9SAndrzej Zaborowski 			if (!clone)
2207a635ea9SAndrzej Zaborowski 				goto error;
2217a635ea9SAndrzej Zaborowski 
2227a635ea9SAndrzej Zaborowski 			skb_trim(clone, packet_len);
2237a635ea9SAndrzej Zaborowski 			usbnet_skb_return(dev, clone);
2247a635ea9SAndrzej Zaborowski 
2257a635ea9SAndrzej Zaborowski 			skb_pull(buf, (packet_len + 3) & ~3);
2267a635ea9SAndrzej Zaborowski 		} else {
2277a635ea9SAndrzej Zaborowski 			skb_trim(buf, packet_len);
2287a635ea9SAndrzej Zaborowski 
2297a635ea9SAndrzej Zaborowski 			if (s->current_rx_buf) {
2307a635ea9SAndrzej Zaborowski 				usbnet_skb_return(dev, buf);
2317a635ea9SAndrzej Zaborowski 				s->current_rx_buf = NULL;
2327a635ea9SAndrzej Zaborowski 				return 0;
2337a635ea9SAndrzej Zaborowski 			}
2347a635ea9SAndrzej Zaborowski 
2357a635ea9SAndrzej Zaborowski 			return 1;
2367a635ea9SAndrzej Zaborowski 		}
2377a635ea9SAndrzej Zaborowski 	}
2387a635ea9SAndrzej Zaborowski 
2397a635ea9SAndrzej Zaborowski error:
2407a635ea9SAndrzej Zaborowski 	if (s->current_rx_buf) {
2417a635ea9SAndrzej Zaborowski 		dev_kfree_skb_any(s->current_rx_buf);
2427a635ea9SAndrzej Zaborowski 		s->current_rx_buf = NULL;
2437a635ea9SAndrzej Zaborowski 	}
2447a635ea9SAndrzej Zaborowski 	dev->net->stats.rx_errors++;
2457a635ea9SAndrzej Zaborowski 	return 0;
2467a635ea9SAndrzej Zaborowski }
2477a635ea9SAndrzej Zaborowski 
2487a635ea9SAndrzej Zaborowski static struct sk_buff *vl600_tx_fixup(struct usbnet *dev,
2497a635ea9SAndrzej Zaborowski 		struct sk_buff *skb, gfp_t flags)
2507a635ea9SAndrzej Zaborowski {
2517a635ea9SAndrzej Zaborowski 	struct sk_buff *ret;
2527a635ea9SAndrzej Zaborowski 	struct vl600_frame_hdr *frame;
2537a635ea9SAndrzej Zaborowski 	struct vl600_pkt_hdr *packet;
2547a635ea9SAndrzej Zaborowski 	static uint32_t serial = 1;
2557a635ea9SAndrzej Zaborowski 	int orig_len = skb->len - sizeof(struct ethhdr);
2567a635ea9SAndrzej Zaborowski 	int full_len = (skb->len + sizeof(struct vl600_frame_hdr) + 3) & ~3;
2577a635ea9SAndrzej Zaborowski 
2587a635ea9SAndrzej Zaborowski 	frame = (struct vl600_frame_hdr *) skb->data;
2597a635ea9SAndrzej Zaborowski 	if (skb->len > sizeof(*frame) && skb->len == le32_to_cpup(&frame->len))
2607a635ea9SAndrzej Zaborowski 		return skb; /* Already encapsulated? */
2617a635ea9SAndrzej Zaborowski 
2627a635ea9SAndrzej Zaborowski 	if (skb->len < sizeof(struct ethhdr))
2637a635ea9SAndrzej Zaborowski 		/* Drop, device can only deal with ethernet packets */
2647a635ea9SAndrzej Zaborowski 		return NULL;
2657a635ea9SAndrzej Zaborowski 
2667a635ea9SAndrzej Zaborowski 	if (!skb_cloned(skb)) {
2677a635ea9SAndrzej Zaborowski 		int headroom = skb_headroom(skb);
2687a635ea9SAndrzej Zaborowski 		int tailroom = skb_tailroom(skb);
2697a635ea9SAndrzej Zaborowski 
2707a635ea9SAndrzej Zaborowski 		if (tailroom >= full_len - skb->len - sizeof(*frame) &&
2717a635ea9SAndrzej Zaborowski 				headroom >= sizeof(*frame))
2727a635ea9SAndrzej Zaborowski 			/* There's enough head and tail room */
2737a635ea9SAndrzej Zaborowski 			goto encapsulate;
2747a635ea9SAndrzej Zaborowski 
2757a635ea9SAndrzej Zaborowski 		if (headroom + tailroom + skb->len >= full_len) {
2767a635ea9SAndrzej Zaborowski 			/* There's enough total room, just readjust */
2777a635ea9SAndrzej Zaborowski 			skb->data = memmove(skb->head + sizeof(*frame),
2787a635ea9SAndrzej Zaborowski 					skb->data, skb->len);
2797a635ea9SAndrzej Zaborowski 			skb_set_tail_pointer(skb, skb->len);
2807a635ea9SAndrzej Zaborowski 			goto encapsulate;
2817a635ea9SAndrzej Zaborowski 		}
2827a635ea9SAndrzej Zaborowski 	}
2837a635ea9SAndrzej Zaborowski 
2847a635ea9SAndrzej Zaborowski 	/* Alloc a new skb with the required size */
2857a635ea9SAndrzej Zaborowski 	ret = skb_copy_expand(skb, sizeof(struct vl600_frame_hdr), full_len -
2867a635ea9SAndrzej Zaborowski 			skb->len - sizeof(struct vl600_frame_hdr), flags);
2877a635ea9SAndrzej Zaborowski 	dev_kfree_skb_any(skb);
2887a635ea9SAndrzej Zaborowski 	if (!ret)
2897a635ea9SAndrzej Zaborowski 		return ret;
2907a635ea9SAndrzej Zaborowski 	skb = ret;
2917a635ea9SAndrzej Zaborowski 
2927a635ea9SAndrzej Zaborowski encapsulate:
2937a635ea9SAndrzej Zaborowski 	/* Packet header is same size as ethernet packet header
2947a635ea9SAndrzej Zaborowski 	 * (sizeof(*packet) == sizeof(struct ethhdr)), additionally the
2957a635ea9SAndrzej Zaborowski 	 * h_proto field is in the same place so we just leave it alone and
2967a635ea9SAndrzej Zaborowski 	 * overwrite the remaining fields.
2977a635ea9SAndrzej Zaborowski 	 */
2987a635ea9SAndrzej Zaborowski 	packet = (struct vl600_pkt_hdr *) skb->data;
2996d74eb94SMark Kamichoff 	/* The VL600 wants IPv6 packets to have an IPv4 ethertype
3006d74eb94SMark Kamichoff 	 * Since this modem only supports IPv4 and IPv6, just set all
3016d74eb94SMark Kamichoff 	 * frames to 0x0800 (ETH_P_IP)
3026d74eb94SMark Kamichoff 	 */
3036d74eb94SMark Kamichoff 	packet->h_proto = htons(ETH_P_IP);
3047a635ea9SAndrzej Zaborowski 	memset(&packet->dummy, 0, sizeof(packet->dummy));
3057a635ea9SAndrzej Zaborowski 	packet->len = cpu_to_le32(orig_len);
3067a635ea9SAndrzej Zaborowski 
307*d58ff351SJohannes Berg 	frame = skb_push(skb, sizeof(*frame));
3087a635ea9SAndrzej Zaborowski 	memset(frame, 0, sizeof(*frame));
3097a635ea9SAndrzej Zaborowski 	frame->len = cpu_to_le32(full_len);
3107a635ea9SAndrzej Zaborowski 	frame->serial = cpu_to_le32(serial++);
3117a635ea9SAndrzej Zaborowski 	frame->pkt_cnt = cpu_to_le32(1);
3127a635ea9SAndrzej Zaborowski 
3137a635ea9SAndrzej Zaborowski 	if (skb->len < full_len) /* Pad */
3147a635ea9SAndrzej Zaborowski 		skb_put(skb, full_len - skb->len);
3157a635ea9SAndrzej Zaborowski 
3167a635ea9SAndrzej Zaborowski 	return skb;
3177a635ea9SAndrzej Zaborowski }
3187a635ea9SAndrzej Zaborowski 
3197a635ea9SAndrzej Zaborowski static const struct driver_info	vl600_info = {
3207a635ea9SAndrzej Zaborowski 	.description	= "LG VL600 modem",
3216d74eb94SMark Kamichoff 	.flags		= FLAG_RX_ASSEMBLE | FLAG_WWAN,
3227a635ea9SAndrzej Zaborowski 	.bind		= vl600_bind,
3237a635ea9SAndrzej Zaborowski 	.unbind		= vl600_unbind,
3247a635ea9SAndrzej Zaborowski 	.status		= usbnet_cdc_status,
3257a635ea9SAndrzej Zaborowski 	.rx_fixup	= vl600_rx_fixup,
3267a635ea9SAndrzej Zaborowski 	.tx_fixup	= vl600_tx_fixup,
3277a635ea9SAndrzej Zaborowski };
3287a635ea9SAndrzej Zaborowski 
3297a635ea9SAndrzej Zaborowski static const struct usb_device_id products[] = {
3307a635ea9SAndrzej Zaborowski 	{
3317a635ea9SAndrzej Zaborowski 		USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM,
3327a635ea9SAndrzej Zaborowski 				USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
3337a635ea9SAndrzej Zaborowski 		.driver_info	= (unsigned long) &vl600_info,
3347a635ea9SAndrzej Zaborowski 	},
3357a635ea9SAndrzej Zaborowski 	{},	/* End */
3367a635ea9SAndrzej Zaborowski };
3377a635ea9SAndrzej Zaborowski MODULE_DEVICE_TABLE(usb, products);
3387a635ea9SAndrzej Zaborowski 
3397a635ea9SAndrzej Zaborowski static struct usb_driver lg_vl600_driver = {
3407a635ea9SAndrzej Zaborowski 	.name		= "lg-vl600",
3417a635ea9SAndrzej Zaborowski 	.id_table	= products,
3427a635ea9SAndrzej Zaborowski 	.probe		= usbnet_probe,
3437a635ea9SAndrzej Zaborowski 	.disconnect	= usbnet_disconnect,
3447a635ea9SAndrzej Zaborowski 	.suspend	= usbnet_suspend,
3457a635ea9SAndrzej Zaborowski 	.resume		= usbnet_resume,
346e1f12eb6SSarah Sharp 	.disable_hub_initiated_lpm = 1,
3477a635ea9SAndrzej Zaborowski };
3487a635ea9SAndrzej Zaborowski 
349d632eb1bSGreg Kroah-Hartman module_usb_driver(lg_vl600_driver);
3507a635ea9SAndrzej Zaborowski 
3517a635ea9SAndrzej Zaborowski MODULE_AUTHOR("Anrzej Zaborowski");
3527a635ea9SAndrzej Zaborowski MODULE_DESCRIPTION("LG-VL600 modem's ethernet link");
3537a635ea9SAndrzej Zaborowski MODULE_LICENSE("GPL");
354