ipheth.c (97eb3f24352ec6632c2127b35d8087d2a809a9b9) ipheth.c (9c412942a0bb19ba18f7bd939d42eff1e132a901)
1/*
2 * ipheth.c - Apple iPhone USB Ethernet driver
3 *
4 * Copyright (c) 2009 Diego Giagio <diego@giagio.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 51 unchanged lines hidden (view full) ---

60#define USB_PRODUCT_IPHONE_3GS 0x1294
61#define USB_PRODUCT_IPHONE_4 0x1297
62
63#define IPHETH_USBINTF_CLASS 255
64#define IPHETH_USBINTF_SUBCLASS 253
65#define IPHETH_USBINTF_PROTO 1
66
67#define IPHETH_BUF_SIZE 1516
1/*
2 * ipheth.c - Apple iPhone USB Ethernet driver
3 *
4 * Copyright (c) 2009 Diego Giagio <diego@giagio.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 51 unchanged lines hidden (view full) ---

60#define USB_PRODUCT_IPHONE_3GS 0x1294
61#define USB_PRODUCT_IPHONE_4 0x1297
62
63#define IPHETH_USBINTF_CLASS 255
64#define IPHETH_USBINTF_SUBCLASS 253
65#define IPHETH_USBINTF_PROTO 1
66
67#define IPHETH_BUF_SIZE 1516
68#define IPHETH_IP_ALIGN 2 /* padding at front of URB */
68#define IPHETH_TX_TIMEOUT (5 * HZ)
69
70#define IPHETH_INTFNUM 2
71#define IPHETH_ALT_INTFNUM 1
72
73#define IPHETH_CTRL_ENDP 0x00
74#define IPHETH_CTRL_BUF_SIZE 0x40
75#define IPHETH_CTRL_TIMEOUT (5 * HZ)

--- 121 unchanged lines hidden (view full) ---

197 return;
198 case 0:
199 break;
200 default:
201 err("%s: urb status: %d", __func__, status);
202 return;
203 }
204
69#define IPHETH_TX_TIMEOUT (5 * HZ)
70
71#define IPHETH_INTFNUM 2
72#define IPHETH_ALT_INTFNUM 1
73
74#define IPHETH_CTRL_ENDP 0x00
75#define IPHETH_CTRL_BUF_SIZE 0x40
76#define IPHETH_CTRL_TIMEOUT (5 * HZ)

--- 121 unchanged lines hidden (view full) ---

198 return;
199 case 0:
200 break;
201 default:
202 err("%s: urb status: %d", __func__, status);
203 return;
204 }
205
205 len = urb->actual_length;
206 buf = urb->transfer_buffer;
206 if (urb->actual_length <= IPHETH_IP_ALIGN) {
207 dev->net->stats.rx_length_errors++;
208 return;
209 }
210 len = urb->actual_length - IPHETH_IP_ALIGN;
211 buf = urb->transfer_buffer + IPHETH_IP_ALIGN;
207
212
208 skb = dev_alloc_skb(NET_IP_ALIGN + len);
213 skb = dev_alloc_skb(len);
209 if (!skb) {
210 err("%s: dev_alloc_skb: -ENOMEM", __func__);
211 dev->net->stats.rx_dropped++;
212 return;
213 }
214
214 if (!skb) {
215 err("%s: dev_alloc_skb: -ENOMEM", __func__);
216 dev->net->stats.rx_dropped++;
217 return;
218 }
219
215 skb_reserve(skb, NET_IP_ALIGN);
216 memcpy(skb_put(skb, len), buf + NET_IP_ALIGN, len - NET_IP_ALIGN);
220 memcpy(skb_put(skb, len), buf, len);
217 skb->dev = dev->net;
218 skb->protocol = eth_type_trans(skb, dev->net);
219
220 dev->net->stats.rx_packets++;
221 dev->net->stats.rx_bytes += len;
222
223 netif_rx(skb);
224 ipheth_rx_submit(dev, GFP_ATOMIC);

--- 342 unchanged lines hidden ---
221 skb->dev = dev->net;
222 skb->protocol = eth_type_trans(skb, dev->net);
223
224 dev->net->stats.rx_packets++;
225 dev->net->stats.rx_bytes += len;
226
227 netif_rx(skb);
228 ipheth_rx_submit(dev, GFP_ATOMIC);

--- 342 unchanged lines hidden ---