Skip to contentSkip to conversation

ir249_irda-usb_reorg.diff

PATCH New Jean Tourrilhes 1 participant 1 message Sep 13, 2001

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ir249_irda-usb_reorg.diff

ir249_irda-usb_reorg.diff :
-------------------------
<Big patch, but not so many changes>
<Both mailing list will drop this patch because of its size> <Apply to kernel-2.4.10-pre8 or later, include fixes from that kernel>
o [FEATURE] Reorganise the code logically, make it more maintainable
- At HP, we say that it has been "re-invented"
o [FEATURE] Lot's of comments, make it easier to read the code
- And also remove some misleading comments
o [CORRECT] Don't push same URB twice to USB stack (speed in KICK_TX)
o [FEATURE] Defered timeout handling. It's just safer.
o [FEATURE] Use the USB_ZERO_PACKET flag to avoid ugly KICK_TX code
- Safer, leaner and correct : it's a standard USB feature.
- Can revert back to old ugly way with a #define
- Please fix uhci.c and usb-ohci.c to handle USB_ZERO_PACKET
o [FEATURE] Reduce latency by not doing LAP turnaround in software
- May be re-enabled with a dongle option
o [FEATURE] Parse USB endpoint properly, get irq endpoint
o [FEATURE] Set USB transfer flags safely

include/net/irda/irda-usb.h renamed from include/net/irda/irda-usb.d8.h +65 -24
diff -u -p linux/include/net/irda/irda-usb.d8.h linux/include/net/irda/irda-usb.h
@@ -1,13 +1,14 @@
 /*****************************************************************************
  *
  * Filename:      irda-usb.h
- * Version:       0.8
+ * Version:       0.9a
  * Description:   IrDA-USB Driver
  * Status:        Experimental 
  * Author:        Dag Brattli <[email protected]>
  *
- *      Copyright (C) 2001, Dag Brattli <[email protected]>
- *	Copyright (C) 2000, Roman Weissgaerber <[email protected]>
+ *	Copyright (C) 2001, Roman Weissgaerber <[email protected]>
+ *      Copyright (C) 2000, Dag Brattli <[email protected]>
+ *      Copyright (C) 2001, Jean Tourrilhes <[email protected]>
  *          
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -35,13 +36,44 @@
 #define IRDA_USB_MAX_MTU 2051
 #define IRDA_USB_SPEED_MTU 64		/* Weird, but work like this */
 
-/*
- * Maximum number of URB on the Rx and Tx path, a number larger than 1
- * is required for handling back-to-back (brickwalled) frames 
- */
-#define IU_MAX_ACTIVE_RX_URBS 1
-#define IU_MAX_RX_URBS	(IU_MAX_ACTIVE_RX_URBS + 1) 
-#define IU_MAX_TX_URBS  1
+/* Maximum number of active URB on the Rx path
+ * This is the amount of buffers the we keep between the USB harware and the
+ * IrDA stack.
+ *
+ * Note : the network layer does also queue the packets between us and the
+ * IrDA stack, and is actually pretty fast and efficient in doing that.
+ * Therefore, we don't need to have a large number of URBs, and we can
+ * perfectly live happy with only one. We certainly don't need to keep the
+ * full IrTTP window around here...
+ * I repeat for those who have trouble to understand : 1 URB is plenty
+ * good enough to handle back-to-back (brickwalled) frames. I tried it,
+ * it works (it's the hardware that has trouble doing it).
+ *
+ * Having 2 URBs would allow the USB stack to process one URB while we take
+ * care of the other and then swap the URBs...
+ * On the other hand, increasing the number of URB will have penalities
+ * in term of latency and will interact with the link management in IrLAP...
+ * Jean II */
+#define IU_MAX_ACTIVE_RX_URBS	1	/* Don't touch !!! */
+
+/* When a Rx URB is passed back to us, we can't reuse it immediately,
+ * because it may still be referenced by the USB layer. Therefore we
+ * need to keep one extra URB in the Rx path.
+ * Jean II */
+#define IU_MAX_RX_URBS	(IU_MAX_ACTIVE_RX_URBS + 1)
+
+/* Various ugly stuff to try to workaround generic problems */
+/* The USB layer should send empty frames at the end of packets multiple
+ * of the frame size. As it doesn't do it by default, we need to do it
+ * ourselves... See also following option. */
+#undef IU_BUG_KICK_TX
+/* Use the USB_ZERO_PACKET flag instead of sending empty frame (above)
+ * Work only with usb-uhci.o so far. Please fix uhic.c and usb-ohci.c */
+#define IU_USE_USB_ZERO_FLAG
+/* Send speed command in case of timeout, just for trying to get things sane */
+#define IU_BUG_KICK_TIMEOUT
+/* Show the USB class descriptor */
+#undef IU_DUMP_CLASS_DESC 
 
 /* Inbound header */
 #define MEDIA_BUSY    0x80
@@ -56,15 +88,19 @@
 #define SPEED_1152000 0x08
 #define SPEED_4000000 0x09
 
-/* device_info flags in struct usb_device_id */
+/* Basic capabilities */
 #define IUC_DEFAULT	0x00	/* Basic device compliant with 1.0 spec */
+/* Main bugs */
 #define IUC_SPEED_BUG	0x01	/* Device doesn't set speed after the frame */
-#define IUC_SIR_ONLY	0x02	/* Device doesn't behave at FIR speeds */
-#define IUC_SMALL_PKT	0x04	/* Device doesn't behave with big Rx packets */
-#define IUC_NO_WINDOW	0x08	/* Device doesn't behave with big Rx window */
-#define IUC_MAX_WINDOW	0x10	/* Device underestimate the Rx window */
-#define IUC_MAX_XBOFS	0x20	/* Device need more xbofs than advertised */
+#define IUC_NO_WINDOW	0x02	/* Device doesn't behave with big Rx window */
+#define IUC_NO_TURN	0x04	/* Device doesn't do turnaround by itself */
+/* Not currently used */
+#define IUC_SIR_ONLY	0x08	/* Device doesn't behave at FIR speeds */
+#define IUC_SMALL_PKT	0x10	/* Device doesn't behave with big Rx packets */
+#define IUC_MAX_WINDOW	0x20	/* Device underestimate the Rx window */
+#define IUC_MAX_XBOFS	0x40	/* Device need more xbofs than advertised */
 
+/* USB class definitions */
 #define USB_IRDA_HEADER   0x01
 #define USB_CLASS_IRDA    0x02 /* USB_CLASS_APP_SPEC subclass */ 
 #define USB_DT_IRDA       0x21
@@ -89,23 +125,29 @@ struct irda_usb_cb {
 	int netopen;			/* Device is active for network */
 	int present;			/* Device is present on the bus */
 	__u32 capability;		/* Capability of the hardware */
-	__u8  bulk_in_ep, bulk_out_ep;	/* Endpoint assignments */
-	__u16 bulk_out_mtu;
-	
+	__u8  bulk_in_ep;		/* Rx Endpoint assignments */
+	__u8  bulk_out_ep;		/* Tx Endpoint assignments */
+	__u16 bulk_out_mtu;		/* Max Tx packet size in bytes */
+	__u8  bulk_int_ep;		/* Interrupt Endpoint assignments */
+
 	wait_queue_head_t wait_q;	/* for timeouts */
 
-	struct urb rx_urb[IU_MAX_RX_URBS];  /* URBs used to receive data frames */
-	struct urb *rx_idle_urb;         /* Pointer to idle URB in Rx path */
+	struct urb rx_urb[IU_MAX_RX_URBS];	/* URBs used to receive data frames */
+	struct urb *idle_rx_urb;	/* Pointer to idle URB in Rx path */
 	struct urb tx_urb;		/* URB used to send data frames */
 	struct urb speed_urb;		/* URB used to send speed commands */
+#ifdef IU_BUG_KICK_TX
+	struct urb empty_urb;		/* URB used to send empty commands */
+#endif IU_BUG_KICK_TX
 	
 	struct net_device *netdev;	/* Yes! we are some kind of netdev. */
 	struct net_device_stats stats;
 	struct irlap_cb   *irlap;	/* The link layer we are binded to */
-	struct qos_info qos;		 
+	struct qos_info qos;
 	hashbin_t *tx_list;		/* Queued transmit skb's */
+	char *speed_buff;		/* Buffer for speed changes */
 
-        struct timeval stamp;
+	struct timeval stamp;
 	struct timeval now;
 
 	spinlock_t lock;		/* For serializing operations */
@@ -116,5 +158,4 @@ struct irda_usb_cb {
 	__s32 new_speed;		/* speed we need to set */
 	__u32 flags;			/* Interface flags */
 };
-
 
drivers/net/irda/irda-usb.c renamed from drivers/net/irda/irda-usb.d8.c +1167 -750

2,182 lines not on this page · raw message