11ccea77eSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2eb4fd8cdSElina Pasheva /*
3eb4fd8cdSElina Pasheva * USB-to-WWAN Driver for Sierra Wireless modems
4eb4fd8cdSElina Pasheva *
5eb4fd8cdSElina Pasheva * Copyright (C) 2008, 2009, 2010 Paxton Smith, Matthew Safar, Rory Filer
6eb4fd8cdSElina Pasheva * <linux@sierrawireless.com>
7eb4fd8cdSElina Pasheva *
8eb4fd8cdSElina Pasheva * Portions of this based on the cdc_ether driver by David Brownell (2003-2005)
9eb4fd8cdSElina Pasheva * and Ole Andre Vadla Ravnas (ActiveSync) (2006).
10eb4fd8cdSElina Pasheva *
11eb4fd8cdSElina Pasheva * IMPORTANT DISCLAIMER: This driver is not commercially supported by
12eb4fd8cdSElina Pasheva * Sierra Wireless. Use at your own risk.
13eb4fd8cdSElina Pasheva */
14eb4fd8cdSElina Pasheva
15eb4fd8cdSElina Pasheva #define DRIVER_VERSION "v.2.0"
16eb4fd8cdSElina Pasheva #define DRIVER_AUTHOR "Paxton Smith, Matthew Safar, Rory Filer"
17eb4fd8cdSElina Pasheva #define DRIVER_DESC "USB-to-WWAN Driver for Sierra Wireless modems"
18eb4fd8cdSElina Pasheva static const char driver_name[] = "sierra_net";
19eb4fd8cdSElina Pasheva
20eb4fd8cdSElina Pasheva /* if defined debug messages enabled */
21eb4fd8cdSElina Pasheva /*#define DEBUG*/
22eb4fd8cdSElina Pasheva
23eb4fd8cdSElina Pasheva #include <linux/module.h>
24eb4fd8cdSElina Pasheva #include <linux/etherdevice.h>
25eb4fd8cdSElina Pasheva #include <linux/ethtool.h>
26eb4fd8cdSElina Pasheva #include <linux/mii.h>
27eb4fd8cdSElina Pasheva #include <linux/sched.h>
28eb4fd8cdSElina Pasheva #include <linux/timer.h>
29eb4fd8cdSElina Pasheva #include <linux/usb.h>
30eb4fd8cdSElina Pasheva #include <linux/usb/cdc.h>
31eb4fd8cdSElina Pasheva #include <net/ip.h>
32eb4fd8cdSElina Pasheva #include <net/udp.h>
33eb4fd8cdSElina Pasheva #include <asm/unaligned.h>
34eb4fd8cdSElina Pasheva #include <linux/usb/usbnet.h>
35eb4fd8cdSElina Pasheva
36eb4fd8cdSElina Pasheva #define SWI_USB_REQUEST_GET_FW_ATTR 0x06
37eb4fd8cdSElina Pasheva #define SWI_GET_FW_ATTR_MASK 0x08
38eb4fd8cdSElina Pasheva
39eb4fd8cdSElina Pasheva /* atomic counter partially included in MAC address to make sure 2 devices
40eb4fd8cdSElina Pasheva * do not end up with the same MAC - concept breaks in case of > 255 ifaces
41eb4fd8cdSElina Pasheva */
42eb4fd8cdSElina Pasheva static atomic_t iface_counter = ATOMIC_INIT(0);
43eb4fd8cdSElina Pasheva
44eb4fd8cdSElina Pasheva /*
45eb4fd8cdSElina Pasheva * SYNC Timer Delay definition used to set the expiry time
46eb4fd8cdSElina Pasheva */
47eb4fd8cdSElina Pasheva #define SIERRA_NET_SYNCDELAY (2*HZ)
48eb4fd8cdSElina Pasheva
49eb4fd8cdSElina Pasheva /* Max. MTU supported. The modem buffers are limited to 1500 */
50eb4fd8cdSElina Pasheva #define SIERRA_NET_MAX_SUPPORTED_MTU 1500
51eb4fd8cdSElina Pasheva
52eb4fd8cdSElina Pasheva /* The SIERRA_NET_USBCTL_BUF_LEN defines a buffer size allocated for control
53eb4fd8cdSElina Pasheva * message reception ... and thus the max. received packet.
54eb4fd8cdSElina Pasheva * (May be the cause for parse_hip returning -EINVAL)
55eb4fd8cdSElina Pasheva */
56eb4fd8cdSElina Pasheva #define SIERRA_NET_USBCTL_BUF_LEN 1024
57eb4fd8cdSElina Pasheva
585aee0728SBjørn Mork /* Overriding the default usbnet rx_urb_size */
595aee0728SBjørn Mork #define SIERRA_NET_RX_URB_SIZE (8 * 1024)
60eb4fd8cdSElina Pasheva
61eb4fd8cdSElina Pasheva /* Private data structure */
62eb4fd8cdSElina Pasheva struct sierra_net_data {
63eb4fd8cdSElina Pasheva
64eb4fd8cdSElina Pasheva u16 link_up; /* air link up or down */
65eb4fd8cdSElina Pasheva u8 tx_hdr_template[4]; /* part of HIP hdr for tx'd packets */
66eb4fd8cdSElina Pasheva
67eb4fd8cdSElina Pasheva u8 sync_msg[4]; /* SYNC message */
68eb4fd8cdSElina Pasheva u8 shdwn_msg[4]; /* Shutdown message */
69eb4fd8cdSElina Pasheva
70eb4fd8cdSElina Pasheva /* Backpointer to the container */
71eb4fd8cdSElina Pasheva struct usbnet *usbnet;
72eb4fd8cdSElina Pasheva
73eb4fd8cdSElina Pasheva u8 ifnum; /* interface number */
74eb4fd8cdSElina Pasheva
75eb4fd8cdSElina Pasheva /* Bit masks, must be a power of 2 */
76eb4fd8cdSElina Pasheva #define SIERRA_NET_EVENT_RESP_AVAIL 0x01
77eb4fd8cdSElina Pasheva #define SIERRA_NET_TIMER_EXPIRY 0x02
78eb4fd8cdSElina Pasheva unsigned long kevent_flags;
79eb4fd8cdSElina Pasheva struct work_struct sierra_net_kevent;
80eb4fd8cdSElina Pasheva struct timer_list sync_timer; /* For retrying SYNC sequence */
81eb4fd8cdSElina Pasheva };
82eb4fd8cdSElina Pasheva
83eb4fd8cdSElina Pasheva struct param {
84eb4fd8cdSElina Pasheva int is_present;
85eb4fd8cdSElina Pasheva union {
86eb4fd8cdSElina Pasheva void *ptr;
87eb4fd8cdSElina Pasheva u32 dword;
88eb4fd8cdSElina Pasheva u16 word;
89eb4fd8cdSElina Pasheva u8 byte;
90eb4fd8cdSElina Pasheva };
91eb4fd8cdSElina Pasheva };
92eb4fd8cdSElina Pasheva
93eb4fd8cdSElina Pasheva /* HIP message type */
94eb4fd8cdSElina Pasheva #define SIERRA_NET_HIP_EXTENDEDID 0x7F
95eb4fd8cdSElina Pasheva #define SIERRA_NET_HIP_HSYNC_ID 0x60 /* Modem -> host */
96eb4fd8cdSElina Pasheva #define SIERRA_NET_HIP_RESTART_ID 0x62 /* Modem -> host */
97eb4fd8cdSElina Pasheva #define SIERRA_NET_HIP_MSYNC_ID 0x20 /* Host -> modem */
98eb4fd8cdSElina Pasheva #define SIERRA_NET_HIP_SHUTD_ID 0x26 /* Host -> modem */
99eb4fd8cdSElina Pasheva
100eb4fd8cdSElina Pasheva #define SIERRA_NET_HIP_EXT_IP_IN_ID 0x0202
101eb4fd8cdSElina Pasheva #define SIERRA_NET_HIP_EXT_IP_OUT_ID 0x0002
102eb4fd8cdSElina Pasheva
103eb4fd8cdSElina Pasheva /* 3G UMTS Link Sense Indication definitions */
104eb4fd8cdSElina Pasheva #define SIERRA_NET_HIP_LSI_UMTSID 0x78
105eb4fd8cdSElina Pasheva
106eb4fd8cdSElina Pasheva /* Reverse Channel Grant Indication HIP message */
107eb4fd8cdSElina Pasheva #define SIERRA_NET_HIP_RCGI 0x64
108eb4fd8cdSElina Pasheva
109eb4fd8cdSElina Pasheva /* LSI Protocol types */
110eb4fd8cdSElina Pasheva #define SIERRA_NET_PROTOCOL_UMTS 0x01
1115a70348eSStefan Brüns #define SIERRA_NET_PROTOCOL_UMTS_DS 0x04
112eb4fd8cdSElina Pasheva /* LSI Coverage */
113eb4fd8cdSElina Pasheva #define SIERRA_NET_COVERAGE_NONE 0x00
114eb4fd8cdSElina Pasheva #define SIERRA_NET_COVERAGE_NOPACKET 0x01
115eb4fd8cdSElina Pasheva
116eb4fd8cdSElina Pasheva /* LSI Session */
117eb4fd8cdSElina Pasheva #define SIERRA_NET_SESSION_IDLE 0x00
118eb4fd8cdSElina Pasheva /* LSI Link types */
1195a70348eSStefan Brüns #define SIERRA_NET_AS_LINK_TYPE_IPV4 0x00
1205a70348eSStefan Brüns #define SIERRA_NET_AS_LINK_TYPE_IPV6 0x02
121eb4fd8cdSElina Pasheva
122eb4fd8cdSElina Pasheva struct lsi_umts {
123eb4fd8cdSElina Pasheva u8 protocol;
124eb4fd8cdSElina Pasheva u8 unused1;
125eb4fd8cdSElina Pasheva __be16 length;
126eb4fd8cdSElina Pasheva /* eventually use a union for the rest - assume umts for now */
127eb4fd8cdSElina Pasheva u8 coverage;
1285a70348eSStefan Brüns u8 network_len; /* network name len */
1295a70348eSStefan Brüns u8 network[40]; /* network name (UCS2, bigendian) */
130eb4fd8cdSElina Pasheva u8 session_state;
131eb4fd8cdSElina Pasheva u8 unused3[33];
1325a70348eSStefan Brüns } __packed;
1335a70348eSStefan Brüns
1345a70348eSStefan Brüns struct lsi_umts_single {
1355a70348eSStefan Brüns struct lsi_umts lsi;
136eb4fd8cdSElina Pasheva u8 link_type;
137eb4fd8cdSElina Pasheva u8 pdp_addr_len; /* NW-supplied PDP address len */
138eb4fd8cdSElina Pasheva u8 pdp_addr[16]; /* NW-supplied PDP address (bigendian)) */
139eb4fd8cdSElina Pasheva u8 unused4[23];
140eb4fd8cdSElina Pasheva u8 dns1_addr_len; /* NW-supplied 1st DNS address len (bigendian) */
141eb4fd8cdSElina Pasheva u8 dns1_addr[16]; /* NW-supplied 1st DNS address */
142eb4fd8cdSElina Pasheva u8 dns2_addr_len; /* NW-supplied 2nd DNS address len */
143eb4fd8cdSElina Pasheva u8 dns2_addr[16]; /* NW-supplied 2nd DNS address (bigendian)*/
144eb4fd8cdSElina Pasheva u8 wins1_addr_len; /* NW-supplied 1st Wins address len */
145eb4fd8cdSElina Pasheva u8 wins1_addr[16]; /* NW-supplied 1st Wins address (bigendian)*/
146eb4fd8cdSElina Pasheva u8 wins2_addr_len; /* NW-supplied 2nd Wins address len */
147eb4fd8cdSElina Pasheva u8 wins2_addr[16]; /* NW-supplied 2nd Wins address (bigendian) */
148eb4fd8cdSElina Pasheva u8 unused5[4];
149eb4fd8cdSElina Pasheva u8 gw_addr_len; /* NW-supplied GW address len */
150eb4fd8cdSElina Pasheva u8 gw_addr[16]; /* NW-supplied GW address (bigendian) */
151eb4fd8cdSElina Pasheva u8 reserved[8];
152ba2d3587SEric Dumazet } __packed;
153eb4fd8cdSElina Pasheva
1545a70348eSStefan Brüns struct lsi_umts_dual {
1555a70348eSStefan Brüns struct lsi_umts lsi;
1565a70348eSStefan Brüns u8 pdp_addr4_len; /* NW-supplied PDP IPv4 address len */
1575a70348eSStefan Brüns u8 pdp_addr4[4]; /* NW-supplied PDP IPv4 address (bigendian)) */
1585a70348eSStefan Brüns u8 pdp_addr6_len; /* NW-supplied PDP IPv6 address len */
1595a70348eSStefan Brüns u8 pdp_addr6[16]; /* NW-supplied PDP IPv6 address (bigendian)) */
1605a70348eSStefan Brüns u8 unused4[23];
1615a70348eSStefan Brüns u8 dns1_addr4_len; /* NW-supplied 1st DNS v4 address len (bigendian) */
1625a70348eSStefan Brüns u8 dns1_addr4[4]; /* NW-supplied 1st DNS v4 address */
1635a70348eSStefan Brüns u8 dns1_addr6_len; /* NW-supplied 1st DNS v6 address len */
1645a70348eSStefan Brüns u8 dns1_addr6[16]; /* NW-supplied 1st DNS v6 address (bigendian)*/
1655a70348eSStefan Brüns u8 dns2_addr4_len; /* NW-supplied 2nd DNS v4 address len (bigendian) */
1665a70348eSStefan Brüns u8 dns2_addr4[4]; /* NW-supplied 2nd DNS v4 address */
1675a70348eSStefan Brüns u8 dns2_addr6_len; /* NW-supplied 2nd DNS v6 address len */
1685a70348eSStefan Brüns u8 dns2_addr6[16]; /* NW-supplied 2nd DNS v6 address (bigendian)*/
1695a70348eSStefan Brüns u8 unused5[68];
1705a70348eSStefan Brüns } __packed;
1715a70348eSStefan Brüns
172eb4fd8cdSElina Pasheva #define SIERRA_NET_LSI_COMMON_LEN 4
1735a70348eSStefan Brüns #define SIERRA_NET_LSI_UMTS_LEN (sizeof(struct lsi_umts_single))
174eb4fd8cdSElina Pasheva #define SIERRA_NET_LSI_UMTS_STATUS_LEN \
175eb4fd8cdSElina Pasheva (SIERRA_NET_LSI_UMTS_LEN - SIERRA_NET_LSI_COMMON_LEN)
1765a70348eSStefan Brüns #define SIERRA_NET_LSI_UMTS_DS_LEN (sizeof(struct lsi_umts_dual))
1775a70348eSStefan Brüns #define SIERRA_NET_LSI_UMTS_DS_STATUS_LEN \
1785a70348eSStefan Brüns (SIERRA_NET_LSI_UMTS_DS_LEN - SIERRA_NET_LSI_COMMON_LEN)
179eb4fd8cdSElina Pasheva
180eb4fd8cdSElina Pasheva /* Our own net device operations structure */
181eb4fd8cdSElina Pasheva static const struct net_device_ops sierra_net_device_ops = {
182eb4fd8cdSElina Pasheva .ndo_open = usbnet_open,
183eb4fd8cdSElina Pasheva .ndo_stop = usbnet_stop,
184eb4fd8cdSElina Pasheva .ndo_start_xmit = usbnet_start_xmit,
185eb4fd8cdSElina Pasheva .ndo_tx_timeout = usbnet_tx_timeout,
186f77f0aeeSJarod Wilson .ndo_change_mtu = usbnet_change_mtu,
187323955a0SHeiner Kallweit .ndo_get_stats64 = dev_get_tstats64,
188eb4fd8cdSElina Pasheva .ndo_set_mac_address = eth_mac_addr,
189eb4fd8cdSElina Pasheva .ndo_validate_addr = eth_validate_addr,
190eb4fd8cdSElina Pasheva };
191eb4fd8cdSElina Pasheva
192eb4fd8cdSElina Pasheva /* get private data associated with passed in usbnet device */
sierra_net_get_private(struct usbnet * dev)193eb4fd8cdSElina Pasheva static inline struct sierra_net_data *sierra_net_get_private(struct usbnet *dev)
194eb4fd8cdSElina Pasheva {
195eb4fd8cdSElina Pasheva return (struct sierra_net_data *)dev->data[0];
196eb4fd8cdSElina Pasheva }
197eb4fd8cdSElina Pasheva
198eb4fd8cdSElina Pasheva /* set private data associated with passed in usbnet device */
sierra_net_set_private(struct usbnet * dev,struct sierra_net_data * priv)199eb4fd8cdSElina Pasheva static inline void sierra_net_set_private(struct usbnet *dev,
200eb4fd8cdSElina Pasheva struct sierra_net_data *priv)
201eb4fd8cdSElina Pasheva {
202eb4fd8cdSElina Pasheva dev->data[0] = (unsigned long)priv;
203eb4fd8cdSElina Pasheva }
204eb4fd8cdSElina Pasheva
2055a70348eSStefan Brüns /* is packet IPv4/IPv6 */
is_ip(struct sk_buff * skb)206eb4fd8cdSElina Pasheva static inline int is_ip(struct sk_buff *skb)
207eb4fd8cdSElina Pasheva {
2085a70348eSStefan Brüns return skb->protocol == cpu_to_be16(ETH_P_IP) ||
2095a70348eSStefan Brüns skb->protocol == cpu_to_be16(ETH_P_IPV6);
210eb4fd8cdSElina Pasheva }
211eb4fd8cdSElina Pasheva
212eb4fd8cdSElina Pasheva /*
213eb4fd8cdSElina Pasheva * check passed in packet and make sure that:
214eb4fd8cdSElina Pasheva * - it is linear (no scatter/gather)
215eb4fd8cdSElina Pasheva * - it is ethernet (mac_header properly set)
216eb4fd8cdSElina Pasheva */
check_ethip_packet(struct sk_buff * skb,struct usbnet * dev)217eb4fd8cdSElina Pasheva static int check_ethip_packet(struct sk_buff *skb, struct usbnet *dev)
218eb4fd8cdSElina Pasheva {
219eb4fd8cdSElina Pasheva skb_reset_mac_header(skb); /* ethernet header */
220eb4fd8cdSElina Pasheva
221eb4fd8cdSElina Pasheva if (skb_is_nonlinear(skb)) {
222eb4fd8cdSElina Pasheva netdev_err(dev->net, "Non linear buffer-dropping\n");
223eb4fd8cdSElina Pasheva return 0;
224eb4fd8cdSElina Pasheva }
225eb4fd8cdSElina Pasheva
226eb4fd8cdSElina Pasheva if (!pskb_may_pull(skb, ETH_HLEN))
227eb4fd8cdSElina Pasheva return 0;
228eb4fd8cdSElina Pasheva skb->protocol = eth_hdr(skb)->h_proto;
229eb4fd8cdSElina Pasheva
230eb4fd8cdSElina Pasheva return 1;
231eb4fd8cdSElina Pasheva }
232eb4fd8cdSElina Pasheva
save16bit(struct param * p,const u8 * datap)233eb4fd8cdSElina Pasheva static const u8 *save16bit(struct param *p, const u8 *datap)
234eb4fd8cdSElina Pasheva {
235eb4fd8cdSElina Pasheva p->is_present = 1;
236eb4fd8cdSElina Pasheva p->word = get_unaligned_be16(datap);
237eb4fd8cdSElina Pasheva return datap + sizeof(p->word);
238eb4fd8cdSElina Pasheva }
239eb4fd8cdSElina Pasheva
save8bit(struct param * p,const u8 * datap)240eb4fd8cdSElina Pasheva static const u8 *save8bit(struct param *p, const u8 *datap)
241eb4fd8cdSElina Pasheva {
242eb4fd8cdSElina Pasheva p->is_present = 1;
243eb4fd8cdSElina Pasheva p->byte = *datap;
244eb4fd8cdSElina Pasheva return datap + sizeof(p->byte);
245eb4fd8cdSElina Pasheva }
246eb4fd8cdSElina Pasheva
247eb4fd8cdSElina Pasheva /*----------------------------------------------------------------------------*
248eb4fd8cdSElina Pasheva * BEGIN HIP *
249eb4fd8cdSElina Pasheva *----------------------------------------------------------------------------*/
250eb4fd8cdSElina Pasheva /* HIP header */
251eb4fd8cdSElina Pasheva #define SIERRA_NET_HIP_HDR_LEN 4
252eb4fd8cdSElina Pasheva /* Extended HIP header */
253eb4fd8cdSElina Pasheva #define SIERRA_NET_HIP_EXT_HDR_LEN 6
254eb4fd8cdSElina Pasheva
255eb4fd8cdSElina Pasheva struct hip_hdr {
256eb4fd8cdSElina Pasheva int hdrlen;
257eb4fd8cdSElina Pasheva struct param payload_len;
258eb4fd8cdSElina Pasheva struct param msgid;
259eb4fd8cdSElina Pasheva struct param msgspecific;
260eb4fd8cdSElina Pasheva struct param extmsgid;
261eb4fd8cdSElina Pasheva };
262eb4fd8cdSElina Pasheva
parse_hip(const u8 * buf,const u32 buflen,struct hip_hdr * hh)263eb4fd8cdSElina Pasheva static int parse_hip(const u8 *buf, const u32 buflen, struct hip_hdr *hh)
264eb4fd8cdSElina Pasheva {
265eb4fd8cdSElina Pasheva const u8 *curp = buf;
266eb4fd8cdSElina Pasheva int padded;
267eb4fd8cdSElina Pasheva
268eb4fd8cdSElina Pasheva if (buflen < SIERRA_NET_HIP_HDR_LEN)
269eb4fd8cdSElina Pasheva return -EPROTO;
270eb4fd8cdSElina Pasheva
271eb4fd8cdSElina Pasheva curp = save16bit(&hh->payload_len, curp);
272eb4fd8cdSElina Pasheva curp = save8bit(&hh->msgid, curp);
273eb4fd8cdSElina Pasheva curp = save8bit(&hh->msgspecific, curp);
274eb4fd8cdSElina Pasheva
275eb4fd8cdSElina Pasheva padded = hh->msgid.byte & 0x80;
276eb4fd8cdSElina Pasheva hh->msgid.byte &= 0x7F; /* 7 bits */
277eb4fd8cdSElina Pasheva
278eb4fd8cdSElina Pasheva hh->extmsgid.is_present = (hh->msgid.byte == SIERRA_NET_HIP_EXTENDEDID);
279eb4fd8cdSElina Pasheva if (hh->extmsgid.is_present) {
280eb4fd8cdSElina Pasheva if (buflen < SIERRA_NET_HIP_EXT_HDR_LEN)
281eb4fd8cdSElina Pasheva return -EPROTO;
282eb4fd8cdSElina Pasheva
283eb4fd8cdSElina Pasheva hh->payload_len.word &= 0x3FFF; /* 14 bits */
284eb4fd8cdSElina Pasheva
285eb4fd8cdSElina Pasheva curp = save16bit(&hh->extmsgid, curp);
286eb4fd8cdSElina Pasheva hh->extmsgid.word &= 0x03FF; /* 10 bits */
287eb4fd8cdSElina Pasheva
288eb4fd8cdSElina Pasheva hh->hdrlen = SIERRA_NET_HIP_EXT_HDR_LEN;
289eb4fd8cdSElina Pasheva } else {
290eb4fd8cdSElina Pasheva hh->payload_len.word &= 0x07FF; /* 11 bits */
291eb4fd8cdSElina Pasheva hh->hdrlen = SIERRA_NET_HIP_HDR_LEN;
292eb4fd8cdSElina Pasheva }
293eb4fd8cdSElina Pasheva
294eb4fd8cdSElina Pasheva if (padded) {
295eb4fd8cdSElina Pasheva hh->hdrlen++;
296eb4fd8cdSElina Pasheva hh->payload_len.word--;
297eb4fd8cdSElina Pasheva }
298eb4fd8cdSElina Pasheva
299eb4fd8cdSElina Pasheva /* if real packet shorter than the claimed length */
300eb4fd8cdSElina Pasheva if (buflen < (hh->hdrlen + hh->payload_len.word))
301eb4fd8cdSElina Pasheva return -EINVAL;
302eb4fd8cdSElina Pasheva
303eb4fd8cdSElina Pasheva return 0;
304eb4fd8cdSElina Pasheva }
305eb4fd8cdSElina Pasheva
build_hip(u8 * buf,const u16 payloadlen,struct sierra_net_data * priv)306eb4fd8cdSElina Pasheva static void build_hip(u8 *buf, const u16 payloadlen,
307eb4fd8cdSElina Pasheva struct sierra_net_data *priv)
308eb4fd8cdSElina Pasheva {
309eb4fd8cdSElina Pasheva /* the following doesn't have the full functionality. We
310eb4fd8cdSElina Pasheva * currently build only one kind of header, so it is faster this way
311eb4fd8cdSElina Pasheva */
312eb4fd8cdSElina Pasheva put_unaligned_be16(payloadlen, buf);
313eb4fd8cdSElina Pasheva memcpy(buf+2, priv->tx_hdr_template, sizeof(priv->tx_hdr_template));
314eb4fd8cdSElina Pasheva }
315eb4fd8cdSElina Pasheva /*----------------------------------------------------------------------------*
316eb4fd8cdSElina Pasheva * END HIP *
317eb4fd8cdSElina Pasheva *----------------------------------------------------------------------------*/
318eb4fd8cdSElina Pasheva
sierra_net_send_cmd(struct usbnet * dev,u8 * cmd,int cmdlen,const char * cmd_name)319eb4fd8cdSElina Pasheva static int sierra_net_send_cmd(struct usbnet *dev,
320eb4fd8cdSElina Pasheva u8 *cmd, int cmdlen, const char * cmd_name)
321eb4fd8cdSElina Pasheva {
322eb4fd8cdSElina Pasheva struct sierra_net_data *priv = sierra_net_get_private(dev);
323eb4fd8cdSElina Pasheva int status;
324eb4fd8cdSElina Pasheva
325f7385ec9SMing Lei status = usbnet_write_cmd(dev, USB_CDC_SEND_ENCAPSULATED_COMMAND,
326f7385ec9SMing Lei USB_DIR_OUT|USB_TYPE_CLASS|USB_RECIP_INTERFACE,
327f7385ec9SMing Lei 0, priv->ifnum, cmd, cmdlen);
328eb4fd8cdSElina Pasheva
329eb4fd8cdSElina Pasheva if (status != cmdlen && status != -ENODEV)
330eb4fd8cdSElina Pasheva netdev_err(dev->net, "Submit %s failed %d\n", cmd_name, status);
331eb4fd8cdSElina Pasheva
332eb4fd8cdSElina Pasheva return status;
333eb4fd8cdSElina Pasheva }
334eb4fd8cdSElina Pasheva
sierra_net_send_sync(struct usbnet * dev)335eb4fd8cdSElina Pasheva static int sierra_net_send_sync(struct usbnet *dev)
336eb4fd8cdSElina Pasheva {
337eb4fd8cdSElina Pasheva int status;
338eb4fd8cdSElina Pasheva struct sierra_net_data *priv = sierra_net_get_private(dev);
339eb4fd8cdSElina Pasheva
340eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "%s", __func__);
341eb4fd8cdSElina Pasheva
342eb4fd8cdSElina Pasheva status = sierra_net_send_cmd(dev, priv->sync_msg,
343eb4fd8cdSElina Pasheva sizeof(priv->sync_msg), "SYNC");
344eb4fd8cdSElina Pasheva
345eb4fd8cdSElina Pasheva return status;
346eb4fd8cdSElina Pasheva }
347eb4fd8cdSElina Pasheva
sierra_net_set_ctx_index(struct sierra_net_data * priv,u8 ctx_ix)348eb4fd8cdSElina Pasheva static void sierra_net_set_ctx_index(struct sierra_net_data *priv, u8 ctx_ix)
349eb4fd8cdSElina Pasheva {
350eb4fd8cdSElina Pasheva dev_dbg(&(priv->usbnet->udev->dev), "%s %d", __func__, ctx_ix);
351eb4fd8cdSElina Pasheva priv->tx_hdr_template[0] = 0x3F;
352eb4fd8cdSElina Pasheva priv->tx_hdr_template[1] = ctx_ix;
353a932657fSBjørn Mork *((__be16 *)&priv->tx_hdr_template[2]) =
354eb4fd8cdSElina Pasheva cpu_to_be16(SIERRA_NET_HIP_EXT_IP_OUT_ID);
355eb4fd8cdSElina Pasheva }
356eb4fd8cdSElina Pasheva
sierra_net_parse_lsi(struct usbnet * dev,char * data,int datalen)357eb4fd8cdSElina Pasheva static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen)
358eb4fd8cdSElina Pasheva {
359eb4fd8cdSElina Pasheva struct lsi_umts *lsi = (struct lsi_umts *)data;
3605a70348eSStefan Brüns u32 expected_length;
361eb4fd8cdSElina Pasheva
3625a70348eSStefan Brüns if (datalen < sizeof(struct lsi_umts_single)) {
3635b5e0928SAlexey Dobriyan netdev_err(dev->net, "%s: Data length %d, exp >= %zu\n",
3645a70348eSStefan Brüns __func__, datalen, sizeof(struct lsi_umts_single));
365eb4fd8cdSElina Pasheva return -1;
366eb4fd8cdSElina Pasheva }
367eb4fd8cdSElina Pasheva
368764895d3SStefan Brüns /* Validate the session state */
369764895d3SStefan Brüns if (lsi->session_state == SIERRA_NET_SESSION_IDLE) {
370764895d3SStefan Brüns netdev_err(dev->net, "Session idle, 0x%02x\n",
371764895d3SStefan Brüns lsi->session_state);
372764895d3SStefan Brüns return 0;
373764895d3SStefan Brüns }
374764895d3SStefan Brüns
375eb4fd8cdSElina Pasheva /* Validate the protocol - only support UMTS for now */
3765a70348eSStefan Brüns if (lsi->protocol == SIERRA_NET_PROTOCOL_UMTS) {
3775a70348eSStefan Brüns struct lsi_umts_single *single = (struct lsi_umts_single *)lsi;
3785a70348eSStefan Brüns
3795a70348eSStefan Brüns /* Validate the link type */
3805a70348eSStefan Brüns if (single->link_type != SIERRA_NET_AS_LINK_TYPE_IPV4 &&
3815a70348eSStefan Brüns single->link_type != SIERRA_NET_AS_LINK_TYPE_IPV6) {
3825a70348eSStefan Brüns netdev_err(dev->net, "Link type unsupported: 0x%02x\n",
3835a70348eSStefan Brüns single->link_type);
3845a70348eSStefan Brüns return -1;
3855a70348eSStefan Brüns }
3865a70348eSStefan Brüns expected_length = SIERRA_NET_LSI_UMTS_STATUS_LEN;
3875a70348eSStefan Brüns } else if (lsi->protocol == SIERRA_NET_PROTOCOL_UMTS_DS) {
3885a70348eSStefan Brüns expected_length = SIERRA_NET_LSI_UMTS_DS_STATUS_LEN;
3895a70348eSStefan Brüns } else {
390eb4fd8cdSElina Pasheva netdev_err(dev->net, "Protocol unsupported, 0x%02x\n",
391eb4fd8cdSElina Pasheva lsi->protocol);
392eb4fd8cdSElina Pasheva return -1;
393eb4fd8cdSElina Pasheva }
394eb4fd8cdSElina Pasheva
3955a70348eSStefan Brüns if (be16_to_cpu(lsi->length) != expected_length) {
3965a70348eSStefan Brüns netdev_err(dev->net, "%s: LSI_UMTS_STATUS_LEN %d, exp %u\n",
3975a70348eSStefan Brüns __func__, be16_to_cpu(lsi->length), expected_length);
398eb4fd8cdSElina Pasheva return -1;
399eb4fd8cdSElina Pasheva }
400eb4fd8cdSElina Pasheva
401eb4fd8cdSElina Pasheva /* Validate the coverage */
4025a70348eSStefan Brüns if (lsi->coverage == SIERRA_NET_COVERAGE_NONE ||
4035a70348eSStefan Brüns lsi->coverage == SIERRA_NET_COVERAGE_NOPACKET) {
404eb4fd8cdSElina Pasheva netdev_err(dev->net, "No coverage, 0x%02x\n", lsi->coverage);
405eb4fd8cdSElina Pasheva return 0;
406eb4fd8cdSElina Pasheva }
407eb4fd8cdSElina Pasheva
408eb4fd8cdSElina Pasheva /* Set link_sense true */
409eb4fd8cdSElina Pasheva return 1;
410eb4fd8cdSElina Pasheva }
411eb4fd8cdSElina Pasheva
sierra_net_handle_lsi(struct usbnet * dev,char * data,struct hip_hdr * hh)412eb4fd8cdSElina Pasheva static void sierra_net_handle_lsi(struct usbnet *dev, char *data,
413eb4fd8cdSElina Pasheva struct hip_hdr *hh)
414eb4fd8cdSElina Pasheva {
415eb4fd8cdSElina Pasheva struct sierra_net_data *priv = sierra_net_get_private(dev);
416eb4fd8cdSElina Pasheva int link_up;
417eb4fd8cdSElina Pasheva
418eb4fd8cdSElina Pasheva link_up = sierra_net_parse_lsi(dev, data + hh->hdrlen,
419eb4fd8cdSElina Pasheva hh->payload_len.word);
420eb4fd8cdSElina Pasheva if (link_up < 0) {
421eb4fd8cdSElina Pasheva netdev_err(dev->net, "Invalid LSI\n");
422eb4fd8cdSElina Pasheva return;
423eb4fd8cdSElina Pasheva }
424eb4fd8cdSElina Pasheva if (link_up) {
425eb4fd8cdSElina Pasheva sierra_net_set_ctx_index(priv, hh->msgspecific.byte);
426eb4fd8cdSElina Pasheva priv->link_up = 1;
427eb4fd8cdSElina Pasheva } else {
428eb4fd8cdSElina Pasheva priv->link_up = 0;
429eb4fd8cdSElina Pasheva }
4309ef2c441SMing Lei usbnet_link_change(dev, link_up, 0);
431eb4fd8cdSElina Pasheva }
432eb4fd8cdSElina Pasheva
sierra_net_dosync(struct usbnet * dev)433eb4fd8cdSElina Pasheva static void sierra_net_dosync(struct usbnet *dev)
434eb4fd8cdSElina Pasheva {
435eb4fd8cdSElina Pasheva int status;
436eb4fd8cdSElina Pasheva struct sierra_net_data *priv = sierra_net_get_private(dev);
437eb4fd8cdSElina Pasheva
438eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "%s", __func__);
439eb4fd8cdSElina Pasheva
4407b0c5f21SDan Williams /* The SIERRA_NET_HIP_MSYNC_ID command appears to request that the
4417b0c5f21SDan Williams * firmware restart itself. After restarting, the modem will respond
4427b0c5f21SDan Williams * with the SIERRA_NET_HIP_RESTART_ID indication. The driver continues
4437b0c5f21SDan Williams * sending MSYNC commands every few seconds until it receives the
4447b0c5f21SDan Williams * RESTART event from the firmware
4457b0c5f21SDan Williams */
4467b0c5f21SDan Williams
447eb4fd8cdSElina Pasheva /* tell modem we are ready */
448eb4fd8cdSElina Pasheva status = sierra_net_send_sync(dev);
449eb4fd8cdSElina Pasheva if (status < 0)
450eb4fd8cdSElina Pasheva netdev_err(dev->net,
451eb4fd8cdSElina Pasheva "Send SYNC failed, status %d\n", status);
452eb4fd8cdSElina Pasheva status = sierra_net_send_sync(dev);
453eb4fd8cdSElina Pasheva if (status < 0)
454eb4fd8cdSElina Pasheva netdev_err(dev->net,
455eb4fd8cdSElina Pasheva "Send SYNC failed, status %d\n", status);
456eb4fd8cdSElina Pasheva
457eb4fd8cdSElina Pasheva /* Now, start a timer and make sure we get the Restart Indication */
458eb4fd8cdSElina Pasheva priv->sync_timer.expires = jiffies + SIERRA_NET_SYNCDELAY;
459eb4fd8cdSElina Pasheva add_timer(&priv->sync_timer);
460eb4fd8cdSElina Pasheva }
461eb4fd8cdSElina Pasheva
sierra_net_kevent(struct work_struct * work)462eb4fd8cdSElina Pasheva static void sierra_net_kevent(struct work_struct *work)
463eb4fd8cdSElina Pasheva {
464eb4fd8cdSElina Pasheva struct sierra_net_data *priv =
465eb4fd8cdSElina Pasheva container_of(work, struct sierra_net_data, sierra_net_kevent);
466eb4fd8cdSElina Pasheva struct usbnet *dev = priv->usbnet;
467eb4fd8cdSElina Pasheva int len;
468eb4fd8cdSElina Pasheva int err;
469eb4fd8cdSElina Pasheva u8 *buf;
470eb4fd8cdSElina Pasheva u8 ifnum;
471eb4fd8cdSElina Pasheva
472eb4fd8cdSElina Pasheva if (test_bit(SIERRA_NET_EVENT_RESP_AVAIL, &priv->kevent_flags)) {
473eb4fd8cdSElina Pasheva clear_bit(SIERRA_NET_EVENT_RESP_AVAIL, &priv->kevent_flags);
474eb4fd8cdSElina Pasheva
475eb4fd8cdSElina Pasheva /* Query the modem for the LSI message */
476eb4fd8cdSElina Pasheva buf = kzalloc(SIERRA_NET_USBCTL_BUF_LEN, GFP_KERNEL);
47738673c82SJoe Perches if (!buf)
478eb4fd8cdSElina Pasheva return;
47938673c82SJoe Perches
480eb4fd8cdSElina Pasheva ifnum = priv->ifnum;
481eb4fd8cdSElina Pasheva len = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
482eb4fd8cdSElina Pasheva USB_CDC_GET_ENCAPSULATED_RESPONSE,
483eb4fd8cdSElina Pasheva USB_DIR_IN|USB_TYPE_CLASS|USB_RECIP_INTERFACE,
484eb4fd8cdSElina Pasheva 0, ifnum, buf, SIERRA_NET_USBCTL_BUF_LEN,
485eb4fd8cdSElina Pasheva USB_CTRL_SET_TIMEOUT);
486eb4fd8cdSElina Pasheva
487eb4fd8cdSElina Pasheva if (len < 0) {
488eb4fd8cdSElina Pasheva netdev_err(dev->net,
489eb4fd8cdSElina Pasheva "usb_control_msg failed, status %d\n", len);
490eb4fd8cdSElina Pasheva } else {
491eb4fd8cdSElina Pasheva struct hip_hdr hh;
492eb4fd8cdSElina Pasheva
493eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "%s: Received status message,"
494eb4fd8cdSElina Pasheva " %04x bytes", __func__, len);
495eb4fd8cdSElina Pasheva
496eb4fd8cdSElina Pasheva err = parse_hip(buf, len, &hh);
497eb4fd8cdSElina Pasheva if (err) {
498eb4fd8cdSElina Pasheva netdev_err(dev->net, "%s: Bad packet,"
499eb4fd8cdSElina Pasheva " parse result %d\n", __func__, err);
500eb4fd8cdSElina Pasheva kfree(buf);
501eb4fd8cdSElina Pasheva return;
502eb4fd8cdSElina Pasheva }
503eb4fd8cdSElina Pasheva
504eb4fd8cdSElina Pasheva /* Validate packet length */
505eb4fd8cdSElina Pasheva if (len != hh.hdrlen + hh.payload_len.word) {
506eb4fd8cdSElina Pasheva netdev_err(dev->net, "%s: Bad packet, received"
507eb4fd8cdSElina Pasheva " %d, expected %d\n", __func__, len,
508eb4fd8cdSElina Pasheva hh.hdrlen + hh.payload_len.word);
509eb4fd8cdSElina Pasheva kfree(buf);
510eb4fd8cdSElina Pasheva return;
511eb4fd8cdSElina Pasheva }
512eb4fd8cdSElina Pasheva
513eb4fd8cdSElina Pasheva /* Switch on received message types */
514eb4fd8cdSElina Pasheva switch (hh.msgid.byte) {
515eb4fd8cdSElina Pasheva case SIERRA_NET_HIP_LSI_UMTSID:
516eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "LSI for ctx:%d",
517eb4fd8cdSElina Pasheva hh.msgspecific.byte);
518eb4fd8cdSElina Pasheva sierra_net_handle_lsi(dev, buf, &hh);
519eb4fd8cdSElina Pasheva break;
520eb4fd8cdSElina Pasheva case SIERRA_NET_HIP_RESTART_ID:
521eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "Restart reported: %d,"
522eb4fd8cdSElina Pasheva " stopping sync timer",
523eb4fd8cdSElina Pasheva hh.msgspecific.byte);
524eb4fd8cdSElina Pasheva /* Got sync resp - stop timer & clear mask */
525eb4fd8cdSElina Pasheva del_timer_sync(&priv->sync_timer);
526eb4fd8cdSElina Pasheva clear_bit(SIERRA_NET_TIMER_EXPIRY,
527eb4fd8cdSElina Pasheva &priv->kevent_flags);
528eb4fd8cdSElina Pasheva break;
529eb4fd8cdSElina Pasheva case SIERRA_NET_HIP_HSYNC_ID:
530eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "SYNC received");
531eb4fd8cdSElina Pasheva err = sierra_net_send_sync(dev);
532eb4fd8cdSElina Pasheva if (err < 0)
533eb4fd8cdSElina Pasheva netdev_err(dev->net,
534eb4fd8cdSElina Pasheva "Send SYNC failed %d\n", err);
535eb4fd8cdSElina Pasheva break;
536eb4fd8cdSElina Pasheva case SIERRA_NET_HIP_EXTENDEDID:
537eb4fd8cdSElina Pasheva netdev_err(dev->net, "Unrecognized HIP msg, "
538eb4fd8cdSElina Pasheva "extmsgid 0x%04x\n", hh.extmsgid.word);
539eb4fd8cdSElina Pasheva break;
540eb4fd8cdSElina Pasheva case SIERRA_NET_HIP_RCGI:
541eb4fd8cdSElina Pasheva /* Ignored */
542eb4fd8cdSElina Pasheva break;
543eb4fd8cdSElina Pasheva default:
544eb4fd8cdSElina Pasheva netdev_err(dev->net, "Unrecognized HIP msg, "
545eb4fd8cdSElina Pasheva "msgid 0x%02x\n", hh.msgid.byte);
546eb4fd8cdSElina Pasheva break;
547eb4fd8cdSElina Pasheva }
548eb4fd8cdSElina Pasheva }
549eb4fd8cdSElina Pasheva kfree(buf);
550eb4fd8cdSElina Pasheva }
551eb4fd8cdSElina Pasheva /* The sync timer bit might be set */
552eb4fd8cdSElina Pasheva if (test_bit(SIERRA_NET_TIMER_EXPIRY, &priv->kevent_flags)) {
553eb4fd8cdSElina Pasheva clear_bit(SIERRA_NET_TIMER_EXPIRY, &priv->kevent_flags);
554eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "Deferred sync timer expiry");
555eb4fd8cdSElina Pasheva sierra_net_dosync(priv->usbnet);
556eb4fd8cdSElina Pasheva }
557eb4fd8cdSElina Pasheva
558eb4fd8cdSElina Pasheva if (priv->kevent_flags)
559eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "sierra_net_kevent done, "
560eb4fd8cdSElina Pasheva "kevent_flags = 0x%lx", priv->kevent_flags);
561eb4fd8cdSElina Pasheva }
562eb4fd8cdSElina Pasheva
sierra_net_defer_kevent(struct usbnet * dev,int work)563eb4fd8cdSElina Pasheva static void sierra_net_defer_kevent(struct usbnet *dev, int work)
564eb4fd8cdSElina Pasheva {
565eb4fd8cdSElina Pasheva struct sierra_net_data *priv = sierra_net_get_private(dev);
566eb4fd8cdSElina Pasheva
567eb4fd8cdSElina Pasheva set_bit(work, &priv->kevent_flags);
568eb4fd8cdSElina Pasheva schedule_work(&priv->sierra_net_kevent);
569eb4fd8cdSElina Pasheva }
570eb4fd8cdSElina Pasheva
571eb4fd8cdSElina Pasheva /*
572eb4fd8cdSElina Pasheva * Sync Retransmit Timer Handler. On expiry, kick the work queue
573eb4fd8cdSElina Pasheva */
sierra_sync_timer(struct timer_list * t)574d28bb967SKees Cook static void sierra_sync_timer(struct timer_list *t)
575eb4fd8cdSElina Pasheva {
576d28bb967SKees Cook struct sierra_net_data *priv = from_timer(priv, t, sync_timer);
577d28bb967SKees Cook struct usbnet *dev = priv->usbnet;
578eb4fd8cdSElina Pasheva
579eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "%s", __func__);
580eb4fd8cdSElina Pasheva /* Kick the tasklet */
581eb4fd8cdSElina Pasheva sierra_net_defer_kevent(dev, SIERRA_NET_TIMER_EXPIRY);
582eb4fd8cdSElina Pasheva }
583eb4fd8cdSElina Pasheva
sierra_net_status(struct usbnet * dev,struct urb * urb)584eb4fd8cdSElina Pasheva static void sierra_net_status(struct usbnet *dev, struct urb *urb)
585eb4fd8cdSElina Pasheva {
586eb4fd8cdSElina Pasheva struct usb_cdc_notification *event;
587eb4fd8cdSElina Pasheva
588eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "%s", __func__);
589eb4fd8cdSElina Pasheva
590eb4fd8cdSElina Pasheva if (urb->actual_length < sizeof *event)
591eb4fd8cdSElina Pasheva return;
592eb4fd8cdSElina Pasheva
593eb4fd8cdSElina Pasheva /* Add cases to handle other standard notifications. */
594eb4fd8cdSElina Pasheva event = urb->transfer_buffer;
595eb4fd8cdSElina Pasheva switch (event->bNotificationType) {
596eb4fd8cdSElina Pasheva case USB_CDC_NOTIFY_NETWORK_CONNECTION:
597eb4fd8cdSElina Pasheva case USB_CDC_NOTIFY_SPEED_CHANGE:
598eb4fd8cdSElina Pasheva /* USB 305 sends those */
599eb4fd8cdSElina Pasheva break;
600eb4fd8cdSElina Pasheva case USB_CDC_NOTIFY_RESPONSE_AVAILABLE:
601eb4fd8cdSElina Pasheva sierra_net_defer_kevent(dev, SIERRA_NET_EVENT_RESP_AVAIL);
602eb4fd8cdSElina Pasheva break;
603eb4fd8cdSElina Pasheva default:
604eb4fd8cdSElina Pasheva netdev_err(dev->net, ": unexpected notification %02x!\n",
605eb4fd8cdSElina Pasheva event->bNotificationType);
606eb4fd8cdSElina Pasheva break;
607eb4fd8cdSElina Pasheva }
608eb4fd8cdSElina Pasheva }
609eb4fd8cdSElina Pasheva
sierra_net_get_drvinfo(struct net_device * net,struct ethtool_drvinfo * info)610eb4fd8cdSElina Pasheva static void sierra_net_get_drvinfo(struct net_device *net,
611eb4fd8cdSElina Pasheva struct ethtool_drvinfo *info)
612eb4fd8cdSElina Pasheva {
613eb4fd8cdSElina Pasheva /* Inherit standard device info */
614eb4fd8cdSElina Pasheva usbnet_get_drvinfo(net, info);
615fb3ceec1SWolfram Sang strscpy(info->driver, driver_name, sizeof(info->driver));
616fb3ceec1SWolfram Sang strscpy(info->version, DRIVER_VERSION, sizeof(info->version));
617eb4fd8cdSElina Pasheva }
618eb4fd8cdSElina Pasheva
sierra_net_get_link(struct net_device * net)619eb4fd8cdSElina Pasheva static u32 sierra_net_get_link(struct net_device *net)
620eb4fd8cdSElina Pasheva {
621eb4fd8cdSElina Pasheva struct usbnet *dev = netdev_priv(net);
622eb4fd8cdSElina Pasheva /* Report link is down whenever the interface is down */
623eb4fd8cdSElina Pasheva return sierra_net_get_private(dev)->link_up && netif_running(net);
624eb4fd8cdSElina Pasheva }
625eb4fd8cdSElina Pasheva
626bc689c97Sstephen hemminger static const struct ethtool_ops sierra_net_ethtool_ops = {
627eb4fd8cdSElina Pasheva .get_drvinfo = sierra_net_get_drvinfo,
628eb4fd8cdSElina Pasheva .get_link = sierra_net_get_link,
629eb4fd8cdSElina Pasheva .get_msglevel = usbnet_get_msglevel,
630eb4fd8cdSElina Pasheva .set_msglevel = usbnet_set_msglevel,
631eb4fd8cdSElina Pasheva .nway_reset = usbnet_nway_reset,
63277651900SOliver Neukum .get_link_ksettings = usbnet_get_link_ksettings_mii,
63377651900SOliver Neukum .set_link_ksettings = usbnet_set_link_ksettings_mii,
634eb4fd8cdSElina Pasheva };
635eb4fd8cdSElina Pasheva
sierra_net_get_fw_attr(struct usbnet * dev,u16 * datap)636eb4fd8cdSElina Pasheva static int sierra_net_get_fw_attr(struct usbnet *dev, u16 *datap)
637eb4fd8cdSElina Pasheva {
638eb4fd8cdSElina Pasheva int result = 0;
639a932657fSBjørn Mork __le16 attrdata;
640eb4fd8cdSElina Pasheva
641f7385ec9SMing Lei result = usbnet_read_cmd(dev,
642eb4fd8cdSElina Pasheva /* _u8 vendor specific request */
643eb4fd8cdSElina Pasheva SWI_USB_REQUEST_GET_FW_ATTR,
644eb4fd8cdSElina Pasheva USB_DIR_IN | USB_TYPE_VENDOR, /* __u8 request type */
645eb4fd8cdSElina Pasheva 0x0000, /* __u16 value not used */
646eb4fd8cdSElina Pasheva 0x0000, /* __u16 index not used */
647f7385ec9SMing Lei &attrdata, /* char *data */
648f7385ec9SMing Lei sizeof(attrdata) /* __u16 size */
649f7385ec9SMing Lei );
650eb4fd8cdSElina Pasheva
651f7385ec9SMing Lei if (result < 0)
652eb4fd8cdSElina Pasheva return -EIO;
653eb4fd8cdSElina Pasheva
654f7385ec9SMing Lei *datap = le16_to_cpu(attrdata);
655eb4fd8cdSElina Pasheva return result;
656eb4fd8cdSElina Pasheva }
657eb4fd8cdSElina Pasheva
658eb4fd8cdSElina Pasheva /*
659eb4fd8cdSElina Pasheva * collects the bulk endpoints, the status endpoint.
660eb4fd8cdSElina Pasheva */
sierra_net_bind(struct usbnet * dev,struct usb_interface * intf)661eb4fd8cdSElina Pasheva static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
662eb4fd8cdSElina Pasheva {
663eb4fd8cdSElina Pasheva u8 ifacenum;
664eb4fd8cdSElina Pasheva u8 numendpoints;
665eb4fd8cdSElina Pasheva u16 fwattr = 0;
666eb4fd8cdSElina Pasheva int status;
667eb4fd8cdSElina Pasheva struct sierra_net_data *priv;
668eb4fd8cdSElina Pasheva static const u8 sync_tmplate[sizeof(priv->sync_msg)] = {
669eb4fd8cdSElina Pasheva 0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00};
670eb4fd8cdSElina Pasheva static const u8 shdwn_tmplate[sizeof(priv->shdwn_msg)] = {
671eb4fd8cdSElina Pasheva 0x00, 0x00, SIERRA_NET_HIP_SHUTD_ID, 0x00};
6722674e7eaSJakub Kicinski u8 mod[2];
673eb4fd8cdSElina Pasheva
674eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "%s", __func__);
675eb4fd8cdSElina Pasheva
676eb4fd8cdSElina Pasheva ifacenum = intf->cur_altsetting->desc.bInterfaceNumber;
677eb4fd8cdSElina Pasheva numendpoints = intf->cur_altsetting->desc.bNumEndpoints;
678eb4fd8cdSElina Pasheva /* We have three endpoints, bulk in and out, and a status */
679eb4fd8cdSElina Pasheva if (numendpoints != 3) {
680eb4fd8cdSElina Pasheva dev_err(&dev->udev->dev, "Expected 3 endpoints, found: %d",
681eb4fd8cdSElina Pasheva numendpoints);
682eb4fd8cdSElina Pasheva return -ENODEV;
683eb4fd8cdSElina Pasheva }
684eb4fd8cdSElina Pasheva /* Status endpoint set in usbnet_get_endpoints() */
685eb4fd8cdSElina Pasheva dev->status = NULL;
686eb4fd8cdSElina Pasheva status = usbnet_get_endpoints(dev, intf);
687eb4fd8cdSElina Pasheva if (status < 0) {
688eb4fd8cdSElina Pasheva dev_err(&dev->udev->dev, "Error in usbnet_get_endpoints (%d)",
689eb4fd8cdSElina Pasheva status);
690eb4fd8cdSElina Pasheva return -ENODEV;
691eb4fd8cdSElina Pasheva }
692eb4fd8cdSElina Pasheva /* Initialize sierra private data */
693eb4fd8cdSElina Pasheva priv = kzalloc(sizeof *priv, GFP_KERNEL);
69438673c82SJoe Perches if (!priv)
695eb4fd8cdSElina Pasheva return -ENOMEM;
696eb4fd8cdSElina Pasheva
697eb4fd8cdSElina Pasheva priv->usbnet = dev;
698eb4fd8cdSElina Pasheva priv->ifnum = ifacenum;
699eb4fd8cdSElina Pasheva dev->net->netdev_ops = &sierra_net_device_ops;
700eb4fd8cdSElina Pasheva
701eb4fd8cdSElina Pasheva /* change MAC addr to include, ifacenum, and to be unique */
7022674e7eaSJakub Kicinski mod[0] = atomic_inc_return(&iface_counter);
7032674e7eaSJakub Kicinski mod[1] = ifacenum;
7042674e7eaSJakub Kicinski dev_addr_mod(dev->net, ETH_ALEN - 2, mod, 2);
705eb4fd8cdSElina Pasheva
706eb4fd8cdSElina Pasheva /* prepare shutdown message template */
707eb4fd8cdSElina Pasheva memcpy(priv->shdwn_msg, shdwn_tmplate, sizeof(priv->shdwn_msg));
708eb4fd8cdSElina Pasheva /* set context index initially to 0 - prepares tx hdr template */
709eb4fd8cdSElina Pasheva sierra_net_set_ctx_index(priv, 0);
710eb4fd8cdSElina Pasheva
7117b0c5f21SDan Williams /* prepare sync message template */
7127b0c5f21SDan Williams memcpy(priv->sync_msg, sync_tmplate, sizeof(priv->sync_msg));
7137b0c5f21SDan Williams
714eb4fd8cdSElina Pasheva /* decrease the rx_urb_size and max_tx_size to 4k on USB 1.1 */
7155aee0728SBjørn Mork dev->rx_urb_size = SIERRA_NET_RX_URB_SIZE;
716eb4fd8cdSElina Pasheva if (dev->udev->speed != USB_SPEED_HIGH)
7175aee0728SBjørn Mork dev->rx_urb_size = min_t(size_t, 4096, SIERRA_NET_RX_URB_SIZE);
718eb4fd8cdSElina Pasheva
719eb4fd8cdSElina Pasheva dev->net->hard_header_len += SIERRA_NET_HIP_EXT_HDR_LEN;
720eb4fd8cdSElina Pasheva dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
721f77f0aeeSJarod Wilson dev->net->max_mtu = SIERRA_NET_MAX_SUPPORTED_MTU;
722eb4fd8cdSElina Pasheva
723eb4fd8cdSElina Pasheva /* Set up the netdev */
724eb4fd8cdSElina Pasheva dev->net->flags |= IFF_NOARP;
725eb4fd8cdSElina Pasheva dev->net->ethtool_ops = &sierra_net_ethtool_ops;
726eb4fd8cdSElina Pasheva netif_carrier_off(dev->net);
727eb4fd8cdSElina Pasheva
728eb4fd8cdSElina Pasheva sierra_net_set_private(dev, priv);
729eb4fd8cdSElina Pasheva
730eb4fd8cdSElina Pasheva priv->kevent_flags = 0;
731eb4fd8cdSElina Pasheva
732eb4fd8cdSElina Pasheva /* Use the shared workqueue */
733eb4fd8cdSElina Pasheva INIT_WORK(&priv->sierra_net_kevent, sierra_net_kevent);
734eb4fd8cdSElina Pasheva
735eb4fd8cdSElina Pasheva /* Only need to do this once */
736d28bb967SKees Cook timer_setup(&priv->sync_timer, sierra_sync_timer, 0);
737eb4fd8cdSElina Pasheva
738eb4fd8cdSElina Pasheva /* verify fw attributes */
739eb4fd8cdSElina Pasheva status = sierra_net_get_fw_attr(dev, &fwattr);
740eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "Fw attr: %x\n", fwattr);
741eb4fd8cdSElina Pasheva
742eb4fd8cdSElina Pasheva /* test whether firmware supports DHCP */
743eb4fd8cdSElina Pasheva if (!(status == sizeof(fwattr) && (fwattr & SWI_GET_FW_ATTR_MASK))) {
744eb4fd8cdSElina Pasheva /* found incompatible firmware version */
745eb4fd8cdSElina Pasheva dev_err(&dev->udev->dev, "Incompatible driver and firmware"
746eb4fd8cdSElina Pasheva " versions\n");
747eb4fd8cdSElina Pasheva kfree(priv);
748eb4fd8cdSElina Pasheva return -ENODEV;
749eb4fd8cdSElina Pasheva }
7506f1464bfSElina Pasheva
751eb4fd8cdSElina Pasheva return 0;
752eb4fd8cdSElina Pasheva }
753eb4fd8cdSElina Pasheva
sierra_net_unbind(struct usbnet * dev,struct usb_interface * intf)754eb4fd8cdSElina Pasheva static void sierra_net_unbind(struct usbnet *dev, struct usb_interface *intf)
755eb4fd8cdSElina Pasheva {
756eb4fd8cdSElina Pasheva int status;
757eb4fd8cdSElina Pasheva struct sierra_net_data *priv = sierra_net_get_private(dev);
758eb4fd8cdSElina Pasheva
759eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "%s", __func__);
760eb4fd8cdSElina Pasheva
76123f333a2STejun Heo /* kill the timer and work */
762*292a089dSSteven Rostedt (Google) timer_shutdown_sync(&priv->sync_timer);
76323f333a2STejun Heo cancel_work_sync(&priv->sierra_net_kevent);
764eb4fd8cdSElina Pasheva
765eb4fd8cdSElina Pasheva /* tell modem we are going away */
766eb4fd8cdSElina Pasheva status = sierra_net_send_cmd(dev, priv->shdwn_msg,
767eb4fd8cdSElina Pasheva sizeof(priv->shdwn_msg), "Shutdown");
768eb4fd8cdSElina Pasheva if (status < 0)
769eb4fd8cdSElina Pasheva netdev_err(dev->net,
770eb4fd8cdSElina Pasheva "usb_control_msg failed, status %d\n", status);
771eb4fd8cdSElina Pasheva
7727b0c5f21SDan Williams usbnet_status_stop(dev);
773eb4fd8cdSElina Pasheva
7747b0c5f21SDan Williams sierra_net_set_private(dev, NULL);
775eb4fd8cdSElina Pasheva kfree(priv);
776eb4fd8cdSElina Pasheva }
777eb4fd8cdSElina Pasheva
sierra_net_skb_clone(struct usbnet * dev,struct sk_buff * skb,int len)778eb4fd8cdSElina Pasheva static struct sk_buff *sierra_net_skb_clone(struct usbnet *dev,
779eb4fd8cdSElina Pasheva struct sk_buff *skb, int len)
780eb4fd8cdSElina Pasheva {
781eb4fd8cdSElina Pasheva struct sk_buff *new_skb;
782eb4fd8cdSElina Pasheva
783eb4fd8cdSElina Pasheva /* clone skb */
784eb4fd8cdSElina Pasheva new_skb = skb_clone(skb, GFP_ATOMIC);
785eb4fd8cdSElina Pasheva
786eb4fd8cdSElina Pasheva /* remove len bytes from original */
787eb4fd8cdSElina Pasheva skb_pull(skb, len);
788eb4fd8cdSElina Pasheva
789eb4fd8cdSElina Pasheva /* trim next packet to it's length */
790eb4fd8cdSElina Pasheva if (new_skb) {
791eb4fd8cdSElina Pasheva skb_trim(new_skb, len);
792eb4fd8cdSElina Pasheva } else {
793eb4fd8cdSElina Pasheva if (netif_msg_rx_err(dev))
794eb4fd8cdSElina Pasheva netdev_err(dev->net, "failed to get skb\n");
795eb4fd8cdSElina Pasheva dev->net->stats.rx_dropped++;
796eb4fd8cdSElina Pasheva }
797eb4fd8cdSElina Pasheva
798eb4fd8cdSElina Pasheva return new_skb;
799eb4fd8cdSElina Pasheva }
800eb4fd8cdSElina Pasheva
801eb4fd8cdSElina Pasheva /* ---------------------------- Receive data path ----------------------*/
sierra_net_rx_fixup(struct usbnet * dev,struct sk_buff * skb)802eb4fd8cdSElina Pasheva static int sierra_net_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
803eb4fd8cdSElina Pasheva {
804eb4fd8cdSElina Pasheva int err;
805eb4fd8cdSElina Pasheva struct hip_hdr hh;
806eb4fd8cdSElina Pasheva struct sk_buff *new_skb;
807eb4fd8cdSElina Pasheva
808eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "%s", __func__);
809eb4fd8cdSElina Pasheva
810eb4fd8cdSElina Pasheva /* could contain multiple packets */
811eb4fd8cdSElina Pasheva while (likely(skb->len)) {
812eb4fd8cdSElina Pasheva err = parse_hip(skb->data, skb->len, &hh);
813eb4fd8cdSElina Pasheva if (err) {
814eb4fd8cdSElina Pasheva if (netif_msg_rx_err(dev))
815eb4fd8cdSElina Pasheva netdev_err(dev->net, "Invalid HIP header %d\n",
816eb4fd8cdSElina Pasheva err);
817eb4fd8cdSElina Pasheva /* dev->net->stats.rx_errors incremented by caller */
818eb4fd8cdSElina Pasheva dev->net->stats.rx_length_errors++;
819eb4fd8cdSElina Pasheva return 0;
820eb4fd8cdSElina Pasheva }
821eb4fd8cdSElina Pasheva
822eb4fd8cdSElina Pasheva /* Validate Extended HIP header */
823eb4fd8cdSElina Pasheva if (!hh.extmsgid.is_present
824eb4fd8cdSElina Pasheva || hh.extmsgid.word != SIERRA_NET_HIP_EXT_IP_IN_ID) {
825eb4fd8cdSElina Pasheva if (netif_msg_rx_err(dev))
826eb4fd8cdSElina Pasheva netdev_err(dev->net, "HIP/ETH: Invalid pkt\n");
827eb4fd8cdSElina Pasheva
828eb4fd8cdSElina Pasheva dev->net->stats.rx_frame_errors++;
829e966c8ecSPeter Senna Tschudin /* dev->net->stats.rx_errors incremented by caller */
830eb4fd8cdSElina Pasheva return 0;
831eb4fd8cdSElina Pasheva }
832eb4fd8cdSElina Pasheva
833eb4fd8cdSElina Pasheva skb_pull(skb, hh.hdrlen);
834eb4fd8cdSElina Pasheva
8355a70348eSStefan Brüns /* We are going to accept this packet, prepare it.
8365a70348eSStefan Brüns * In case protocol is IPv6, keep it, otherwise force IPv4.
8375a70348eSStefan Brüns */
8385a70348eSStefan Brüns skb_reset_mac_header(skb);
8395a70348eSStefan Brüns if (eth_hdr(skb)->h_proto != cpu_to_be16(ETH_P_IPV6))
8405a70348eSStefan Brüns eth_hdr(skb)->h_proto = cpu_to_be16(ETH_P_IP);
8415a70348eSStefan Brüns eth_zero_addr(eth_hdr(skb)->h_source);
8425a70348eSStefan Brüns memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
843eb4fd8cdSElina Pasheva
844eb4fd8cdSElina Pasheva /* Last packet in batch handled by usbnet */
845eb4fd8cdSElina Pasheva if (hh.payload_len.word == skb->len)
846eb4fd8cdSElina Pasheva return 1;
847eb4fd8cdSElina Pasheva
848eb4fd8cdSElina Pasheva new_skb = sierra_net_skb_clone(dev, skb, hh.payload_len.word);
849eb4fd8cdSElina Pasheva if (new_skb)
850eb4fd8cdSElina Pasheva usbnet_skb_return(dev, new_skb);
851eb4fd8cdSElina Pasheva
852eb4fd8cdSElina Pasheva } /* while */
853eb4fd8cdSElina Pasheva
854eb4fd8cdSElina Pasheva return 0;
855eb4fd8cdSElina Pasheva }
856eb4fd8cdSElina Pasheva
857eb4fd8cdSElina Pasheva /* ---------------------------- Transmit data path ----------------------*/
sierra_net_tx_fixup(struct usbnet * dev,struct sk_buff * skb,gfp_t flags)8589625e5faSBjørn Mork static struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev,
8599625e5faSBjørn Mork struct sk_buff *skb, gfp_t flags)
860eb4fd8cdSElina Pasheva {
861eb4fd8cdSElina Pasheva struct sierra_net_data *priv = sierra_net_get_private(dev);
862eb4fd8cdSElina Pasheva u16 len;
863eb4fd8cdSElina Pasheva bool need_tail;
864eb4fd8cdSElina Pasheva
865c593642cSPankaj Bharadiya BUILD_BUG_ON(sizeof_field(struct usbnet, data)
866d632eb1bSGreg Kroah-Hartman < sizeof(struct cdc_state));
867d632eb1bSGreg Kroah-Hartman
868eb4fd8cdSElina Pasheva dev_dbg(&dev->udev->dev, "%s", __func__);
869eb4fd8cdSElina Pasheva if (priv->link_up && check_ethip_packet(skb, dev) && is_ip(skb)) {
870eb4fd8cdSElina Pasheva /* enough head room as is? */
871eb4fd8cdSElina Pasheva if (SIERRA_NET_HIP_EXT_HDR_LEN <= skb_headroom(skb)) {
872eb4fd8cdSElina Pasheva /* Save the Eth/IP length and set up HIP hdr */
873eb4fd8cdSElina Pasheva len = skb->len;
874eb4fd8cdSElina Pasheva skb_push(skb, SIERRA_NET_HIP_EXT_HDR_LEN);
875eb4fd8cdSElina Pasheva /* Handle ZLP issue */
876eb4fd8cdSElina Pasheva need_tail = ((len + SIERRA_NET_HIP_EXT_HDR_LEN)
877eb4fd8cdSElina Pasheva % dev->maxpacket == 0);
878eb4fd8cdSElina Pasheva if (need_tail) {
879eb4fd8cdSElina Pasheva if (unlikely(skb_tailroom(skb) == 0)) {
880eb4fd8cdSElina Pasheva netdev_err(dev->net, "tx_fixup:"
881eb4fd8cdSElina Pasheva "no room for packet\n");
882eb4fd8cdSElina Pasheva dev_kfree_skb_any(skb);
883eb4fd8cdSElina Pasheva return NULL;
884eb4fd8cdSElina Pasheva } else {
885eb4fd8cdSElina Pasheva skb->data[skb->len] = 0;
886eb4fd8cdSElina Pasheva __skb_put(skb, 1);
887eb4fd8cdSElina Pasheva len = len + 1;
888eb4fd8cdSElina Pasheva }
889eb4fd8cdSElina Pasheva }
890eb4fd8cdSElina Pasheva build_hip(skb->data, len, priv);
891eb4fd8cdSElina Pasheva return skb;
892eb4fd8cdSElina Pasheva } else {
893eb4fd8cdSElina Pasheva /*
894eb4fd8cdSElina Pasheva * compensate in the future if necessary
895eb4fd8cdSElina Pasheva */
896eb4fd8cdSElina Pasheva netdev_err(dev->net, "tx_fixup: no room for HIP\n");
897eb4fd8cdSElina Pasheva } /* headroom */
898eb4fd8cdSElina Pasheva }
899eb4fd8cdSElina Pasheva
900eb4fd8cdSElina Pasheva if (!priv->link_up)
901eb4fd8cdSElina Pasheva dev->net->stats.tx_carrier_errors++;
902eb4fd8cdSElina Pasheva
903eb4fd8cdSElina Pasheva /* tx_dropped incremented by usbnet */
904eb4fd8cdSElina Pasheva
905eb4fd8cdSElina Pasheva /* filter the packet out, release it */
906eb4fd8cdSElina Pasheva dev_kfree_skb_any(skb);
907eb4fd8cdSElina Pasheva return NULL;
908eb4fd8cdSElina Pasheva }
909eb4fd8cdSElina Pasheva
910dd03cff2SBjørn Mork static const struct driver_info sierra_net_info_direct_ip = {
911eb4fd8cdSElina Pasheva .description = "Sierra Wireless USB-to-WWAN Modem",
912eb4fd8cdSElina Pasheva .flags = FLAG_WWAN | FLAG_SEND_ZLP,
913eb4fd8cdSElina Pasheva .bind = sierra_net_bind,
914eb4fd8cdSElina Pasheva .unbind = sierra_net_unbind,
915eb4fd8cdSElina Pasheva .status = sierra_net_status,
916eb4fd8cdSElina Pasheva .rx_fixup = sierra_net_rx_fixup,
917eb4fd8cdSElina Pasheva .tx_fixup = sierra_net_tx_fixup,
918eb4fd8cdSElina Pasheva };
919eb4fd8cdSElina Pasheva
9207b0c5f21SDan Williams static int
sierra_net_probe(struct usb_interface * udev,const struct usb_device_id * prod)9217b0c5f21SDan Williams sierra_net_probe(struct usb_interface *udev, const struct usb_device_id *prod)
9227b0c5f21SDan Williams {
9237b0c5f21SDan Williams int ret;
9247b0c5f21SDan Williams
9257b0c5f21SDan Williams ret = usbnet_probe(udev, prod);
9267b0c5f21SDan Williams if (ret == 0) {
9277b0c5f21SDan Williams struct usbnet *dev = usb_get_intfdata(udev);
9287b0c5f21SDan Williams
9297b0c5f21SDan Williams ret = usbnet_status_start(dev, GFP_KERNEL);
9307b0c5f21SDan Williams if (ret == 0) {
9317b0c5f21SDan Williams /* Interrupt URB now set up; initiate sync sequence */
9327b0c5f21SDan Williams sierra_net_dosync(dev);
9337b0c5f21SDan Williams }
9347b0c5f21SDan Williams }
9357b0c5f21SDan Williams return ret;
9367b0c5f21SDan Williams }
9377b0c5f21SDan Williams
938aefe5c00SBjørn Mork #define DIRECT_IP_DEVICE(vend, prod) \
939aefe5c00SBjørn Mork {USB_DEVICE_INTERFACE_NUMBER(vend, prod, 7), \
940aefe5c00SBjørn Mork .driver_info = (unsigned long)&sierra_net_info_direct_ip}, \
941aefe5c00SBjørn Mork {USB_DEVICE_INTERFACE_NUMBER(vend, prod, 10), \
942aefe5c00SBjørn Mork .driver_info = (unsigned long)&sierra_net_info_direct_ip}, \
943aefe5c00SBjørn Mork {USB_DEVICE_INTERFACE_NUMBER(vend, prod, 11), \
944aefe5c00SBjørn Mork .driver_info = (unsigned long)&sierra_net_info_direct_ip}
945aefe5c00SBjørn Mork
946eb4fd8cdSElina Pasheva static const struct usb_device_id products[] = {
947aefe5c00SBjørn Mork DIRECT_IP_DEVICE(0x1199, 0x68A3), /* Sierra Wireless USB-to-WWAN modem */
948aefe5c00SBjørn Mork DIRECT_IP_DEVICE(0x0F3D, 0x68A3), /* AT&T Direct IP modem */
949aefe5c00SBjørn Mork DIRECT_IP_DEVICE(0x1199, 0x68AA), /* Sierra Wireless Direct IP LTE modem */
950aefe5c00SBjørn Mork DIRECT_IP_DEVICE(0x0F3D, 0x68AA), /* AT&T Direct IP LTE modem */
951eb4fd8cdSElina Pasheva
952eb4fd8cdSElina Pasheva {}, /* last item */
953eb4fd8cdSElina Pasheva };
954eb4fd8cdSElina Pasheva MODULE_DEVICE_TABLE(usb, products);
955eb4fd8cdSElina Pasheva
956eb4fd8cdSElina Pasheva /* We are based on usbnet, so let it handle the USB driver specifics */
957eb4fd8cdSElina Pasheva static struct usb_driver sierra_net_driver = {
958eb4fd8cdSElina Pasheva .name = "sierra_net",
959eb4fd8cdSElina Pasheva .id_table = products,
9607b0c5f21SDan Williams .probe = sierra_net_probe,
961eb4fd8cdSElina Pasheva .disconnect = usbnet_disconnect,
962eb4fd8cdSElina Pasheva .suspend = usbnet_suspend,
963eb4fd8cdSElina Pasheva .resume = usbnet_resume,
964eb4fd8cdSElina Pasheva .no_dynamic_id = 1,
965e1f12eb6SSarah Sharp .disable_hub_initiated_lpm = 1,
966eb4fd8cdSElina Pasheva };
967eb4fd8cdSElina Pasheva
968d632eb1bSGreg Kroah-Hartman module_usb_driver(sierra_net_driver);
969eb4fd8cdSElina Pasheva
970eb4fd8cdSElina Pasheva MODULE_AUTHOR(DRIVER_AUTHOR);
971eb4fd8cdSElina Pasheva MODULE_DESCRIPTION(DRIVER_DESC);
972eb4fd8cdSElina Pasheva MODULE_VERSION(DRIVER_VERSION);
973eb4fd8cdSElina Pasheva MODULE_LICENSE("GPL");
974