xref: /linux/drivers/net/usb/kalmia.c (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2d4026123SMarius B. Kotsbak /*
3d4026123SMarius B. Kotsbak  * USB network interface driver for Samsung Kalmia based LTE USB modem like the
4d4026123SMarius B. Kotsbak  * Samsung GT-B3730 and GT-B3710.
5d4026123SMarius B. Kotsbak  *
6d4026123SMarius B. Kotsbak  * Copyright (C) 2011 Marius Bjoernstad Kotsbak <marius@kotsbak.com>
7d4026123SMarius B. Kotsbak  *
8d4026123SMarius B. Kotsbak  * Sponsored by Quicklink Video Distribution Services Ltd.
9d4026123SMarius B. Kotsbak  *
10d4026123SMarius B. Kotsbak  * Based on the cdc_eem module.
11d4026123SMarius B. Kotsbak  */
12d4026123SMarius B. Kotsbak 
13d4026123SMarius B. Kotsbak #include <linux/module.h>
14d4026123SMarius B. Kotsbak #include <linux/netdevice.h>
15d4026123SMarius B. Kotsbak #include <linux/etherdevice.h>
16d4026123SMarius B. Kotsbak #include <linux/ctype.h>
17d4026123SMarius B. Kotsbak #include <linux/ethtool.h>
18d4026123SMarius B. Kotsbak #include <linux/workqueue.h>
19d4026123SMarius B. Kotsbak #include <linux/mii.h>
20d4026123SMarius B. Kotsbak #include <linux/usb.h>
21d4026123SMarius B. Kotsbak #include <linux/crc32.h>
22d4026123SMarius B. Kotsbak #include <linux/usb/cdc.h>
23d4026123SMarius B. Kotsbak #include <linux/usb/usbnet.h>
24d4026123SMarius B. Kotsbak #include <linux/gfp.h>
25d4026123SMarius B. Kotsbak 
26d4026123SMarius B. Kotsbak /*
27d4026123SMarius B. Kotsbak  * The Samsung Kalmia based LTE USB modems have a CDC ACM port for modem control
28d4026123SMarius B. Kotsbak  * handled by the "option" module and an ethernet data port handled by this
29d4026123SMarius B. Kotsbak  * module.
30d4026123SMarius B. Kotsbak  *
31d4026123SMarius B. Kotsbak  * The stick must first be switched into modem mode by usb_modeswitch
32d4026123SMarius B. Kotsbak  * or similar tool. Then the modem gets sent two initialization packets by
33d4026123SMarius B. Kotsbak  * this module, which gives the MAC address of the device. User space can then
34d4026123SMarius B. Kotsbak  * connect the modem using AT commands through the ACM port and then use
35d4026123SMarius B. Kotsbak  * DHCP on the network interface exposed by this module. Network packets are
36d4026123SMarius B. Kotsbak  * sent to and from the modem in a proprietary format discovered after watching
37d4026123SMarius B. Kotsbak  * the behavior of the windows driver for the modem.
38d4026123SMarius B. Kotsbak  *
39d4026123SMarius B. Kotsbak  * More information about the use of the modem is available in usb_modeswitch
40d4026123SMarius B. Kotsbak  * forum and the project page:
41d4026123SMarius B. Kotsbak  *
42d4026123SMarius B. Kotsbak  * http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?t=465
43d4026123SMarius B. Kotsbak  * https://github.com/mkotsbak/Samsung-GT-B3730-linux-driver
44d4026123SMarius B. Kotsbak  */
45d4026123SMarius B. Kotsbak 
46d4026123SMarius B. Kotsbak /* #define	DEBUG */
47d4026123SMarius B. Kotsbak /* #define	VERBOSE */
48d4026123SMarius B. Kotsbak 
49d4026123SMarius B. Kotsbak #define KALMIA_HEADER_LENGTH 6
50d4026123SMarius B. Kotsbak #define KALMIA_ALIGN_SIZE 4
51d4026123SMarius B. Kotsbak #define KALMIA_USB_TIMEOUT 10000
52d4026123SMarius B. Kotsbak 
53d4026123SMarius B. Kotsbak /*-------------------------------------------------------------------------*/
54d4026123SMarius B. Kotsbak 
55d4026123SMarius B. Kotsbak static int
kalmia_send_init_packet(struct usbnet * dev,u8 * init_msg,u8 init_msg_len,u8 * buffer,u8 expected_len)56d4026123SMarius B. Kotsbak kalmia_send_init_packet(struct usbnet *dev, u8 *init_msg, u8 init_msg_len,
57d4026123SMarius B. Kotsbak 	u8 *buffer, u8 expected_len)
58d4026123SMarius B. Kotsbak {
59d4026123SMarius B. Kotsbak 	int act_len;
60d4026123SMarius B. Kotsbak 	int status;
61d4026123SMarius B. Kotsbak 
62d4026123SMarius B. Kotsbak 	netdev_dbg(dev->net, "Sending init packet");
63d4026123SMarius B. Kotsbak 
64d4026123SMarius B. Kotsbak 	status = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 0x02),
65d4026123SMarius B. Kotsbak 		init_msg, init_msg_len, &act_len, KALMIA_USB_TIMEOUT);
66d4026123SMarius B. Kotsbak 	if (status != 0) {
67d4026123SMarius B. Kotsbak 		netdev_err(dev->net,
68*c68f345bSMiko Larsson 			"Error sending init packet. Status %i\n",
69*c68f345bSMiko Larsson 			status);
70d4026123SMarius B. Kotsbak 		return status;
71d4026123SMarius B. Kotsbak 	}
72d4026123SMarius B. Kotsbak 	else if (act_len != init_msg_len) {
73d4026123SMarius B. Kotsbak 		netdev_err(dev->net,
74d4026123SMarius B. Kotsbak 			"Did not send all of init packet. Bytes sent: %i",
75d4026123SMarius B. Kotsbak 			act_len);
76d4026123SMarius B. Kotsbak 	}
77d4026123SMarius B. Kotsbak 	else {
78d4026123SMarius B. Kotsbak 		netdev_dbg(dev->net, "Successfully sent init packet.");
79d4026123SMarius B. Kotsbak 	}
80d4026123SMarius B. Kotsbak 
81d4026123SMarius B. Kotsbak 	status = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, 0x81),
82d4026123SMarius B. Kotsbak 		buffer, expected_len, &act_len, KALMIA_USB_TIMEOUT);
83d4026123SMarius B. Kotsbak 
84d4026123SMarius B. Kotsbak 	if (status != 0)
85d4026123SMarius B. Kotsbak 		netdev_err(dev->net,
86*c68f345bSMiko Larsson 			"Error receiving init result. Status %i\n",
87*c68f345bSMiko Larsson 			status);
88d4026123SMarius B. Kotsbak 	else if (act_len != expected_len)
89d4026123SMarius B. Kotsbak 		netdev_err(dev->net, "Unexpected init result length: %i\n",
90d4026123SMarius B. Kotsbak 			act_len);
91d4026123SMarius B. Kotsbak 
92d4026123SMarius B. Kotsbak 	return status;
93d4026123SMarius B. Kotsbak }
94d4026123SMarius B. Kotsbak 
95d4026123SMarius B. Kotsbak static int
kalmia_init_and_get_ethernet_addr(struct usbnet * dev,u8 * ethernet_addr)96d4026123SMarius B. Kotsbak kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 *ethernet_addr)
97d4026123SMarius B. Kotsbak {
98bd0d7aa6SJesper Juhl 	static const char init_msg_1[] =
99d4026123SMarius B. Kotsbak 		{ 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
100d4026123SMarius B. Kotsbak 		0x00, 0x00 };
101bd0d7aa6SJesper Juhl 	static const char init_msg_2[] =
102d4026123SMarius B. Kotsbak 		{ 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xf4,
103d4026123SMarius B. Kotsbak 		0x00, 0x00 };
104bd0d7aa6SJesper Juhl 	static const int buflen = 28;
1057cdfa4a3SMarius B. Kotsbak 	char *usb_buf;
106d4026123SMarius B. Kotsbak 	int status;
107d4026123SMarius B. Kotsbak 
1087cdfa4a3SMarius B. Kotsbak 	usb_buf = kmalloc(buflen, GFP_DMA | GFP_KERNEL);
1097cdfa4a3SMarius B. Kotsbak 	if (!usb_buf)
1107cdfa4a3SMarius B. Kotsbak 		return -ENOMEM;
1117cdfa4a3SMarius B. Kotsbak 
1127cdfa4a3SMarius B. Kotsbak 	memcpy(usb_buf, init_msg_1, 12);
113b72c8a7eSColin Ian King 	status = kalmia_send_init_packet(dev, usb_buf, ARRAY_SIZE(init_msg_1),
114b72c8a7eSColin Ian King 					 usb_buf, 24);
115d4026123SMarius B. Kotsbak 	if (status != 0)
116f1472cb0SWenwen Wang 		goto out;
117d4026123SMarius B. Kotsbak 
1187cdfa4a3SMarius B. Kotsbak 	memcpy(usb_buf, init_msg_2, 12);
119b72c8a7eSColin Ian King 	status = kalmia_send_init_packet(dev, usb_buf, ARRAY_SIZE(init_msg_2),
120b72c8a7eSColin Ian King 					 usb_buf, 28);
121d4026123SMarius B. Kotsbak 	if (status != 0)
122f1472cb0SWenwen Wang 		goto out;
123d4026123SMarius B. Kotsbak 
1247cdfa4a3SMarius B. Kotsbak 	memcpy(ethernet_addr, usb_buf + 10, ETH_ALEN);
125f1472cb0SWenwen Wang out:
1267cdfa4a3SMarius B. Kotsbak 	kfree(usb_buf);
127d4026123SMarius B. Kotsbak 	return status;
128d4026123SMarius B. Kotsbak }
129d4026123SMarius B. Kotsbak 
130d4026123SMarius B. Kotsbak static int
kalmia_bind(struct usbnet * dev,struct usb_interface * intf)131d4026123SMarius B. Kotsbak kalmia_bind(struct usbnet *dev, struct usb_interface *intf)
132d4026123SMarius B. Kotsbak {
1335c18e80bSDan Carpenter 	int status;
134d4026123SMarius B. Kotsbak 	u8 ethernet_addr[ETH_ALEN];
135d4026123SMarius B. Kotsbak 
136d4026123SMarius B. Kotsbak 	/* Don't bind to AT command interface */
137d4026123SMarius B. Kotsbak 	if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
138d4026123SMarius B. Kotsbak 		return -EINVAL;
139d4026123SMarius B. Kotsbak 
140d4026123SMarius B. Kotsbak 	dev->in = usb_rcvbulkpipe(dev->udev, 0x81 & USB_ENDPOINT_NUMBER_MASK);
141d4026123SMarius B. Kotsbak 	dev->out = usb_sndbulkpipe(dev->udev, 0x02 & USB_ENDPOINT_NUMBER_MASK);
142d4026123SMarius B. Kotsbak 	dev->status = NULL;
143d4026123SMarius B. Kotsbak 
144d4026123SMarius B. Kotsbak 	dev->net->hard_header_len += KALMIA_HEADER_LENGTH;
145d4026123SMarius B. Kotsbak 	dev->hard_mtu = 1400;
146d4026123SMarius B. Kotsbak 	dev->rx_urb_size = dev->hard_mtu * 10; // Found as optimal after testing
147d4026123SMarius B. Kotsbak 
148d4026123SMarius B. Kotsbak 	status = kalmia_init_and_get_ethernet_addr(dev, ethernet_addr);
1494f06717fSJohan Hovold 	if (status)
150d4026123SMarius B. Kotsbak 		return status;
151d4026123SMarius B. Kotsbak 
15216813717SJakub Kicinski 	eth_hw_addr_set(dev->net, ethernet_addr);
153d4026123SMarius B. Kotsbak 
154d4026123SMarius B. Kotsbak 	return status;
155d4026123SMarius B. Kotsbak }
156d4026123SMarius B. Kotsbak 
157d4026123SMarius B. Kotsbak static struct sk_buff *
kalmia_tx_fixup(struct usbnet * dev,struct sk_buff * skb,gfp_t flags)158d4026123SMarius B. Kotsbak kalmia_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
159d4026123SMarius B. Kotsbak {
160d4026123SMarius B. Kotsbak 	struct sk_buff *skb2 = NULL;
161d4026123SMarius B. Kotsbak 	u16 content_len;
162d4026123SMarius B. Kotsbak 	unsigned char *header_start;
163d4026123SMarius B. Kotsbak 	unsigned char ether_type_1, ether_type_2;
164d4026123SMarius B. Kotsbak 	u8 remainder, padlen = 0;
165d4026123SMarius B. Kotsbak 
166d4026123SMarius B. Kotsbak 	if (!skb_cloned(skb)) {
167d4026123SMarius B. Kotsbak 		int headroom = skb_headroom(skb);
168d4026123SMarius B. Kotsbak 		int tailroom = skb_tailroom(skb);
169d4026123SMarius B. Kotsbak 
170d4026123SMarius B. Kotsbak 		if ((tailroom >= KALMIA_ALIGN_SIZE) && (headroom
171d4026123SMarius B. Kotsbak 			>= KALMIA_HEADER_LENGTH))
172d4026123SMarius B. Kotsbak 			goto done;
173d4026123SMarius B. Kotsbak 
174d4026123SMarius B. Kotsbak 		if ((headroom + tailroom) > (KALMIA_HEADER_LENGTH
175d4026123SMarius B. Kotsbak 			+ KALMIA_ALIGN_SIZE)) {
176d4026123SMarius B. Kotsbak 			skb->data = memmove(skb->head + KALMIA_HEADER_LENGTH,
177d4026123SMarius B. Kotsbak 				skb->data, skb->len);
178d4026123SMarius B. Kotsbak 			skb_set_tail_pointer(skb, skb->len);
179d4026123SMarius B. Kotsbak 			goto done;
180d4026123SMarius B. Kotsbak 		}
181d4026123SMarius B. Kotsbak 	}
182d4026123SMarius B. Kotsbak 
183d4026123SMarius B. Kotsbak 	skb2 = skb_copy_expand(skb, KALMIA_HEADER_LENGTH,
184d4026123SMarius B. Kotsbak 		KALMIA_ALIGN_SIZE, flags);
185d4026123SMarius B. Kotsbak 	if (!skb2)
186d4026123SMarius B. Kotsbak 		return NULL;
187d4026123SMarius B. Kotsbak 
188d4026123SMarius B. Kotsbak 	dev_kfree_skb_any(skb);
189d4026123SMarius B. Kotsbak 	skb = skb2;
190d4026123SMarius B. Kotsbak 
1917cdfa4a3SMarius B. Kotsbak done:
1927cdfa4a3SMarius B. Kotsbak 	header_start = skb_push(skb, KALMIA_HEADER_LENGTH);
193d4026123SMarius B. Kotsbak 	ether_type_1 = header_start[KALMIA_HEADER_LENGTH + 12];
194d4026123SMarius B. Kotsbak 	ether_type_2 = header_start[KALMIA_HEADER_LENGTH + 13];
195d4026123SMarius B. Kotsbak 
196d4026123SMarius B. Kotsbak 	netdev_dbg(dev->net, "Sending etherType: %02x%02x", ether_type_1,
197d4026123SMarius B. Kotsbak 		ether_type_2);
198d4026123SMarius B. Kotsbak 
199d4026123SMarius B. Kotsbak 	/* According to empiric data for data packages */
200d4026123SMarius B. Kotsbak 	header_start[0] = 0x57;
201d4026123SMarius B. Kotsbak 	header_start[1] = 0x44;
202d4026123SMarius B. Kotsbak 	content_len = skb->len - KALMIA_HEADER_LENGTH;
203d4026123SMarius B. Kotsbak 
2047cdfa4a3SMarius B. Kotsbak 	put_unaligned_le16(content_len, &header_start[2]);
205d4026123SMarius B. Kotsbak 	header_start[4] = ether_type_1;
206d4026123SMarius B. Kotsbak 	header_start[5] = ether_type_2;
207d4026123SMarius B. Kotsbak 
208d4026123SMarius B. Kotsbak 	/* Align to 4 bytes by padding with zeros */
209d4026123SMarius B. Kotsbak 	remainder = skb->len % KALMIA_ALIGN_SIZE;
210d4026123SMarius B. Kotsbak 	if (remainder > 0) {
211d4026123SMarius B. Kotsbak 		padlen = KALMIA_ALIGN_SIZE - remainder;
212b080db58SJohannes Berg 		skb_put_zero(skb, padlen);
213d4026123SMarius B. Kotsbak 	}
214d4026123SMarius B. Kotsbak 
215cbb963deSAndy Shevchenko 	netdev_dbg(dev->net,
216cbb963deSAndy Shevchenko 		"Sending package with length %i and padding %i. Header: %6phC.",
217cbb963deSAndy Shevchenko 		content_len, padlen, header_start);
218d4026123SMarius B. Kotsbak 
219d4026123SMarius B. Kotsbak 	return skb;
220d4026123SMarius B. Kotsbak }
221d4026123SMarius B. Kotsbak 
222d4026123SMarius B. Kotsbak static int
kalmia_rx_fixup(struct usbnet * dev,struct sk_buff * skb)223d4026123SMarius B. Kotsbak kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
224d4026123SMarius B. Kotsbak {
225d4026123SMarius B. Kotsbak 	/*
226d4026123SMarius B. Kotsbak 	 * Our task here is to strip off framing, leaving skb with one
227d4026123SMarius B. Kotsbak 	 * data frame for the usbnet framework code to process.
228d4026123SMarius B. Kotsbak 	 */
229bd0d7aa6SJesper Juhl 	static const u8 HEADER_END_OF_USB_PACKET[] =
230d4026123SMarius B. Kotsbak 		{ 0x57, 0x5a, 0x00, 0x00, 0x08, 0x00 };
231bd0d7aa6SJesper Juhl 	static const u8 EXPECTED_UNKNOWN_HEADER_1[] =
232d4026123SMarius B. Kotsbak 		{ 0x57, 0x43, 0x1e, 0x00, 0x15, 0x02 };
233bd0d7aa6SJesper Juhl 	static const u8 EXPECTED_UNKNOWN_HEADER_2[] =
234d4026123SMarius B. Kotsbak 		{ 0x57, 0x50, 0x0e, 0x00, 0x00, 0x00 };
2357cdfa4a3SMarius B. Kotsbak 	int i = 0;
236d4026123SMarius B. Kotsbak 
237d4026123SMarius B. Kotsbak 	/* incomplete header? */
238d4026123SMarius B. Kotsbak 	if (skb->len < KALMIA_HEADER_LENGTH)
239d4026123SMarius B. Kotsbak 		return 0;
240d4026123SMarius B. Kotsbak 
241d4026123SMarius B. Kotsbak 	do {
242d4026123SMarius B. Kotsbak 		struct sk_buff *skb2 = NULL;
243d4026123SMarius B. Kotsbak 		u8 *header_start;
244d4026123SMarius B. Kotsbak 		u16 usb_packet_length, ether_packet_length;
245d4026123SMarius B. Kotsbak 		int is_last;
246d4026123SMarius B. Kotsbak 
247d4026123SMarius B. Kotsbak 		header_start = skb->data;
248d4026123SMarius B. Kotsbak 
249d4026123SMarius B. Kotsbak 		if (unlikely(header_start[0] != 0x57 || header_start[1] != 0x44)) {
250d4026123SMarius B. Kotsbak 			if (!memcmp(header_start, EXPECTED_UNKNOWN_HEADER_1,
251d4026123SMarius B. Kotsbak 				sizeof(EXPECTED_UNKNOWN_HEADER_1)) || !memcmp(
252d4026123SMarius B. Kotsbak 				header_start, EXPECTED_UNKNOWN_HEADER_2,
253d4026123SMarius B. Kotsbak 				sizeof(EXPECTED_UNKNOWN_HEADER_2))) {
254cbb963deSAndy Shevchenko 				netdev_dbg(dev->net,
255cbb963deSAndy Shevchenko 					"Received expected unknown frame header: %6phC. Package length: %i\n",
256cbb963deSAndy Shevchenko 					header_start,
257d4026123SMarius B. Kotsbak 					skb->len - KALMIA_HEADER_LENGTH);
258d4026123SMarius B. Kotsbak 			}
259d4026123SMarius B. Kotsbak 			else {
260cbb963deSAndy Shevchenko 				netdev_err(dev->net,
261cbb963deSAndy Shevchenko 					"Received unknown frame header: %6phC. Package length: %i\n",
262cbb963deSAndy Shevchenko 					header_start,
263d4026123SMarius B. Kotsbak 					skb->len - KALMIA_HEADER_LENGTH);
264d4026123SMarius B. Kotsbak 				return 0;
265d4026123SMarius B. Kotsbak 			}
266d4026123SMarius B. Kotsbak 		}
267d4026123SMarius B. Kotsbak 		else
268cbb963deSAndy Shevchenko 			netdev_dbg(dev->net,
269cbb963deSAndy Shevchenko 				"Received header: %6phC. Package length: %i\n",
270cbb963deSAndy Shevchenko 				header_start, skb->len - KALMIA_HEADER_LENGTH);
271d4026123SMarius B. Kotsbak 
272d4026123SMarius B. Kotsbak 		/* subtract start header and end header */
273d4026123SMarius B. Kotsbak 		usb_packet_length = skb->len - (2 * KALMIA_HEADER_LENGTH);
2747cdfa4a3SMarius B. Kotsbak 		ether_packet_length = get_unaligned_le16(&header_start[2]);
275d4026123SMarius B. Kotsbak 		skb_pull(skb, KALMIA_HEADER_LENGTH);
276d4026123SMarius B. Kotsbak 
277d4026123SMarius B. Kotsbak 		/* Some small packets misses end marker */
278d4026123SMarius B. Kotsbak 		if (usb_packet_length < ether_packet_length) {
279d4026123SMarius B. Kotsbak 			ether_packet_length = usb_packet_length
280d4026123SMarius B. Kotsbak 				+ KALMIA_HEADER_LENGTH;
281d4026123SMarius B. Kotsbak 			is_last = true;
282d4026123SMarius B. Kotsbak 		}
283d4026123SMarius B. Kotsbak 		else {
284d4026123SMarius B. Kotsbak 			netdev_dbg(dev->net, "Correct package length #%i", i
285d4026123SMarius B. Kotsbak 				+ 1);
286d4026123SMarius B. Kotsbak 
287d4026123SMarius B. Kotsbak 			is_last = (memcmp(skb->data + ether_packet_length,
288d4026123SMarius B. Kotsbak 				HEADER_END_OF_USB_PACKET,
289d4026123SMarius B. Kotsbak 				sizeof(HEADER_END_OF_USB_PACKET)) == 0);
290d4026123SMarius B. Kotsbak 			if (!is_last) {
291d4026123SMarius B. Kotsbak 				header_start = skb->data + ether_packet_length;
292cbb963deSAndy Shevchenko 				netdev_dbg(dev->net,
293cbb963deSAndy Shevchenko 					"End header: %6phC. Package length: %i\n",
294cbb963deSAndy Shevchenko 					header_start,
295d4026123SMarius B. Kotsbak 					skb->len - KALMIA_HEADER_LENGTH);
296d4026123SMarius B. Kotsbak 			}
297d4026123SMarius B. Kotsbak 		}
298d4026123SMarius B. Kotsbak 
299d4026123SMarius B. Kotsbak 		if (is_last) {
300d4026123SMarius B. Kotsbak 			skb2 = skb;
301d4026123SMarius B. Kotsbak 		}
302d4026123SMarius B. Kotsbak 		else {
303d4026123SMarius B. Kotsbak 			skb2 = skb_clone(skb, GFP_ATOMIC);
304d4026123SMarius B. Kotsbak 			if (unlikely(!skb2))
305d4026123SMarius B. Kotsbak 				return 0;
306d4026123SMarius B. Kotsbak 		}
307d4026123SMarius B. Kotsbak 
308d4026123SMarius B. Kotsbak 		skb_trim(skb2, ether_packet_length);
309d4026123SMarius B. Kotsbak 
310d4026123SMarius B. Kotsbak 		if (is_last) {
311d4026123SMarius B. Kotsbak 			return 1;
312d4026123SMarius B. Kotsbak 		}
313d4026123SMarius B. Kotsbak 		else {
314d4026123SMarius B. Kotsbak 			usbnet_skb_return(dev, skb2);
315d4026123SMarius B. Kotsbak 			skb_pull(skb, ether_packet_length);
316d4026123SMarius B. Kotsbak 		}
317d4026123SMarius B. Kotsbak 
318d4026123SMarius B. Kotsbak 		i++;
319d4026123SMarius B. Kotsbak 	}
320d4026123SMarius B. Kotsbak 	while (skb->len);
321d4026123SMarius B. Kotsbak 
322d4026123SMarius B. Kotsbak 	return 1;
323d4026123SMarius B. Kotsbak }
324d4026123SMarius B. Kotsbak 
325d4026123SMarius B. Kotsbak static const struct driver_info kalmia_info = {
326d4026123SMarius B. Kotsbak 	.description = "Samsung Kalmia LTE USB dongle",
327d4026123SMarius B. Kotsbak 	.flags = FLAG_WWAN,
328d4026123SMarius B. Kotsbak 	.bind = kalmia_bind,
329d4026123SMarius B. Kotsbak 	.rx_fixup = kalmia_rx_fixup,
330d4026123SMarius B. Kotsbak 	.tx_fixup = kalmia_tx_fixup
331d4026123SMarius B. Kotsbak };
332d4026123SMarius B. Kotsbak 
333d4026123SMarius B. Kotsbak /*-------------------------------------------------------------------------*/
334d4026123SMarius B. Kotsbak 
335d4026123SMarius B. Kotsbak static const struct usb_device_id products[] = {
336d4026123SMarius B. Kotsbak 	/* The unswitched USB ID, to get the module auto loaded: */
337d4026123SMarius B. Kotsbak 	{ USB_DEVICE(0x04e8, 0x689a) },
33808a7e621SMasahiro Yamada 	/* The stick switched into modem (by e.g. usb_modeswitch): */
339d4026123SMarius B. Kotsbak 	{ USB_DEVICE(0x04e8, 0x6889),
340d4026123SMarius B. Kotsbak 		.driver_info = (unsigned long) &kalmia_info, },
341d4026123SMarius B. Kotsbak 	{ /* EMPTY == end of list */} };
342d4026123SMarius B. Kotsbak MODULE_DEVICE_TABLE( usb, products);
343d4026123SMarius B. Kotsbak 
344d4026123SMarius B. Kotsbak static struct usb_driver kalmia_driver = {
345d4026123SMarius B. Kotsbak 	.name = "kalmia",
346d4026123SMarius B. Kotsbak 	.id_table = products,
347d4026123SMarius B. Kotsbak 	.probe = usbnet_probe,
348d4026123SMarius B. Kotsbak 	.disconnect = usbnet_disconnect,
349d4026123SMarius B. Kotsbak 	.suspend = usbnet_suspend,
350e1f12eb6SSarah Sharp 	.resume = usbnet_resume,
351e1f12eb6SSarah Sharp 	.disable_hub_initiated_lpm = 1,
352d4026123SMarius B. Kotsbak };
353d4026123SMarius B. Kotsbak 
354d632eb1bSGreg Kroah-Hartman module_usb_driver(kalmia_driver);
355d4026123SMarius B. Kotsbak 
356d4026123SMarius B. Kotsbak MODULE_AUTHOR("Marius Bjoernstad Kotsbak <marius@kotsbak.com>");
357d4026123SMarius B. Kotsbak MODULE_DESCRIPTION("Samsung Kalmia USB network driver");
358d4026123SMarius B. Kotsbak MODULE_LICENSE("GPL");
359