diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/net/irda/irda-usb.h |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/net/irda/irda-usb.h')
-rw-r--r-- | drivers/net/irda/irda-usb.h | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/drivers/net/irda/irda-usb.h b/drivers/net/irda/irda-usb.h new file mode 100644 index 000000000000..bd8f66542322 --- /dev/null +++ b/drivers/net/irda/irda-usb.h | |||
@@ -0,0 +1,163 @@ | |||
1 | /***************************************************************************** | ||
2 | * | ||
3 | * Filename: irda-usb.h | ||
4 | * Version: 0.9b | ||
5 | * Description: IrDA-USB Driver | ||
6 | * Status: Experimental | ||
7 | * Author: Dag Brattli <dag@brattli.net> | ||
8 | * | ||
9 | * Copyright (C) 2001, Roman Weissgaerber <weissg@vienna.at> | ||
10 | * Copyright (C) 2000, Dag Brattli <dag@brattli.net> | ||
11 | * Copyright (C) 2001, Jean Tourrilhes <jt@hpl.hp.com> | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or | ||
16 | * (at your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, | ||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | * GNU General Public License for more details. | ||
22 | * | ||
23 | * You should have received a copy of the GNU General Public License | ||
24 | * along with this program; if not, write to the Free Software | ||
25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
26 | * | ||
27 | *****************************************************************************/ | ||
28 | |||
29 | #include <linux/time.h> | ||
30 | |||
31 | #include <net/irda/irda.h> | ||
32 | #include <net/irda/irda_device.h> /* struct irlap_cb */ | ||
33 | |||
34 | #define RX_COPY_THRESHOLD 200 | ||
35 | #define IRDA_USB_MAX_MTU 2051 | ||
36 | #define IRDA_USB_SPEED_MTU 64 /* Weird, but work like this */ | ||
37 | |||
38 | /* Maximum number of active URB on the Rx path | ||
39 | * This is the amount of buffers the we keep between the USB harware and the | ||
40 | * IrDA stack. | ||
41 | * | ||
42 | * Note : the network layer does also queue the packets between us and the | ||
43 | * IrDA stack, and is actually pretty fast and efficient in doing that. | ||
44 | * Therefore, we don't need to have a large number of URBs, and we can | ||
45 | * perfectly live happy with only one. We certainly don't need to keep the | ||
46 | * full IrTTP window around here... | ||
47 | * I repeat for those who have trouble to understand : 1 URB is plenty | ||
48 | * good enough to handle back-to-back (brickwalled) frames. I tried it, | ||
49 | * it works (it's the hardware that has trouble doing it). | ||
50 | * | ||
51 | * Having 2 URBs would allow the USB stack to process one URB while we take | ||
52 | * care of the other and then swap the URBs... | ||
53 | * On the other hand, increasing the number of URB will have penalities | ||
54 | * in term of latency and will interact with the link management in IrLAP... | ||
55 | * Jean II */ | ||
56 | #define IU_MAX_ACTIVE_RX_URBS 1 /* Don't touch !!! */ | ||
57 | |||
58 | /* When a Rx URB is passed back to us, we can't reuse it immediately, | ||
59 | * because it may still be referenced by the USB layer. Therefore we | ||
60 | * need to keep one extra URB in the Rx path. | ||
61 | * Jean II */ | ||
62 | #define IU_MAX_RX_URBS (IU_MAX_ACTIVE_RX_URBS + 1) | ||
63 | |||
64 | /* Various ugly stuff to try to workaround generic problems */ | ||
65 | /* Send speed command in case of timeout, just for trying to get things sane */ | ||
66 | #define IU_BUG_KICK_TIMEOUT | ||
67 | /* Show the USB class descriptor */ | ||
68 | #undef IU_DUMP_CLASS_DESC | ||
69 | /* Assume a minimum round trip latency for USB transfer (in us)... | ||
70 | * USB transfer are done in the next USB slot if there is no traffic | ||
71 | * (1/19 msec) and is done at 12 Mb/s : | ||
72 | * Waiting for slot + tx = (53us + 16us) * 2 = 137us minimum. | ||
73 | * Rx notification will only be done at the end of the USB frame period : | ||
74 | * OHCI : frame period = 1ms | ||
75 | * UHCI : frame period = 1ms, but notification can take 2 or 3 ms :-( | ||
76 | * EHCI : frame period = 125us */ | ||
77 | #define IU_USB_MIN_RTT 500 /* This should be safe in most cases */ | ||
78 | |||
79 | /* Inbound header */ | ||
80 | #define MEDIA_BUSY 0x80 | ||
81 | |||
82 | #define SPEED_2400 0x01 | ||
83 | #define SPEED_9600 0x02 | ||
84 | #define SPEED_19200 0x03 | ||
85 | #define SPEED_38400 0x04 | ||
86 | #define SPEED_57600 0x05 | ||
87 | #define SPEED_115200 0x06 | ||
88 | #define SPEED_576000 0x07 | ||
89 | #define SPEED_1152000 0x08 | ||
90 | #define SPEED_4000000 0x09 | ||
91 | |||
92 | /* Basic capabilities */ | ||
93 | #define IUC_DEFAULT 0x00 /* Basic device compliant with 1.0 spec */ | ||
94 | /* Main bugs */ | ||
95 | #define IUC_SPEED_BUG 0x01 /* Device doesn't set speed after the frame */ | ||
96 | #define IUC_NO_WINDOW 0x02 /* Device doesn't behave with big Rx window */ | ||
97 | #define IUC_NO_TURN 0x04 /* Device doesn't do turnaround by itself */ | ||
98 | /* Not currently used */ | ||
99 | #define IUC_SIR_ONLY 0x08 /* Device doesn't behave at FIR speeds */ | ||
100 | #define IUC_SMALL_PKT 0x10 /* Device doesn't behave with big Rx packets */ | ||
101 | #define IUC_MAX_WINDOW 0x20 /* Device underestimate the Rx window */ | ||
102 | #define IUC_MAX_XBOFS 0x40 /* Device need more xbofs than advertised */ | ||
103 | |||
104 | /* USB class definitions */ | ||
105 | #define USB_IRDA_HEADER 0x01 | ||
106 | #define USB_CLASS_IRDA 0x02 /* USB_CLASS_APP_SPEC subclass */ | ||
107 | #define USB_DT_IRDA 0x21 | ||
108 | |||
109 | struct irda_class_desc { | ||
110 | __u8 bLength; | ||
111 | __u8 bDescriptorType; | ||
112 | __u16 bcdSpecRevision; | ||
113 | __u8 bmDataSize; | ||
114 | __u8 bmWindowSize; | ||
115 | __u8 bmMinTurnaroundTime; | ||
116 | __u16 wBaudRate; | ||
117 | __u8 bmAdditionalBOFs; | ||
118 | __u8 bIrdaRateSniff; | ||
119 | __u8 bMaxUnicastList; | ||
120 | } __attribute__ ((packed)); | ||
121 | |||
122 | /* class specific interface request to get the IrDA-USB class descriptor | ||
123 | * (6.2.5, USB-IrDA class spec 1.0) */ | ||
124 | |||
125 | #define IU_REQ_GET_CLASS_DESC 0x06 | ||
126 | |||
127 | struct irda_usb_cb { | ||
128 | struct irda_class_desc *irda_desc; | ||
129 | struct usb_device *usbdev; /* init: probe_irda */ | ||
130 | struct usb_interface *usbintf; /* init: probe_irda */ | ||
131 | int netopen; /* Device is active for network */ | ||
132 | int present; /* Device is present on the bus */ | ||
133 | __u32 capability; /* Capability of the hardware */ | ||
134 | __u8 bulk_in_ep; /* Rx Endpoint assignments */ | ||
135 | __u8 bulk_out_ep; /* Tx Endpoint assignments */ | ||
136 | __u16 bulk_out_mtu; /* Max Tx packet size in bytes */ | ||
137 | __u8 bulk_int_ep; /* Interrupt Endpoint assignments */ | ||
138 | |||
139 | wait_queue_head_t wait_q; /* for timeouts */ | ||
140 | |||
141 | struct urb *rx_urb[IU_MAX_RX_URBS]; /* URBs used to receive data frames */ | ||
142 | struct urb *idle_rx_urb; /* Pointer to idle URB in Rx path */ | ||
143 | struct urb *tx_urb; /* URB used to send data frames */ | ||
144 | struct urb *speed_urb; /* URB used to send speed commands */ | ||
145 | |||
146 | struct net_device *netdev; /* Yes! we are some kind of netdev. */ | ||
147 | struct net_device_stats stats; | ||
148 | struct irlap_cb *irlap; /* The link layer we are binded to */ | ||
149 | struct qos_info qos; | ||
150 | hashbin_t *tx_list; /* Queued transmit skb's */ | ||
151 | char *speed_buff; /* Buffer for speed changes */ | ||
152 | |||
153 | struct timeval stamp; | ||
154 | struct timeval now; | ||
155 | |||
156 | spinlock_t lock; /* For serializing operations */ | ||
157 | |||
158 | __u16 xbofs; /* Current xbofs setting */ | ||
159 | __s16 new_xbofs; /* xbofs we need to set */ | ||
160 | __u32 speed; /* Current speed */ | ||
161 | __s32 new_speed; /* speed we need to set */ | ||
162 | }; | ||
163 | |||