Skip to contentSkip to conversation

: ir241_flow_sched_ttp-6.diff

PATCH New Jean Tourrilhes 1 participant 1 message Dec 2, 2002 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : ir241_flow_sched_ttp-6.diff

ir241_flow_sched_ttp-6.diff :
---------------------------
<Won't compile without ir241_flow_sched_lap_lmp-6.diff>
o [CORRECT] Fix race condition when starting todo timer
o [CORRECT] Fix race condition when stopping higher layer Higher layer would think it is stopped and us it is started
o [CORRECT] Give credit even if packets in Tx queue
If Tx queue was stopped, could starve peer and deadlock
o [CORRECT] Protect Rx credit update with spinlock
o [CORRECT] Calculate properly self->avail_credit Didn't take into account queued Rx fragments Incremented even if Rx frame not delivered to higher layer -> would never stop the peer (i.e. not flow control) -> could become infinite
o [CORRECT] Send credit when higher layer reenable receive Peer wouldn't restart Tx to us if flow stopped
o [FEATURE] Implement LAP queue not full notification Lower latency, ...
o [FEATURE] Reduce Tx queue to 8 packets (from 10)
But make sure we can always send a full LAP window (7)
o [FEATURE] Fix and optimise TTP flow control
Make sure peer can always send a full LAP window (7) Minimise explicit credit updates (give_credit)
o [FEATURE] Remove need for todo timer in Tx/Rx paths Less potential races, lower latency, lower context switches Could not use tasklet because broken API, better anyway ;-)

include/net/irda/irttp.h renamed from include/net/irda/irttp.d6.h +43 -5
diff -u -p -r linux/include/net/irda/irttp.d6.h linux/include/net/irda/irttp.h
@@ -42,11 +42,48 @@
 #define TTP_PARAMETERS         0x80
 #define TTP_MORE               0x80
 
-#define DEFAULT_INITIAL_CREDIT 14
+/* Transmission queue sizes */
+/* Worst case scenario, two window of data - Jean II */
+#define TTP_TX_MAX_QUEUE	14
+/* We need to keep at least 5 frames to make sure that we can refill
+ * appropriately the LAP layer. LAP keeps only two buffers, and we need
+ * to have 7 to make a full window - Jean II */
+#define TTP_TX_LOW_THRESHOLD	5
+/* Most clients are synchronous with respect to flow control, so we can
+ * keep a low number of Tx buffers in TTP - Jean II */
+#define TTP_TX_HIGH_THRESHOLD	7
+
+/* Receive queue sizes */
+/* Minimum of credit that the peer should hold.
+ * If the peer has less credits than 9 frames, we will explicitely send
+ * him some credits (through irttp_give_credit() and a specific frame).
+ * Note that when we give credits it's likely that it won't be sent in
+ * this LAP window, but in the next one. So, we make sure that the peer
+ * has something to send while waiting for credits (one LAP window == 7
+ * + 1 frames while he process the credits). - Jean II */
+#define TTP_RX_MIN_CREDIT	8
+/* This is the default maximum number of credits held by the peer, so the
+ * default maximum number of frames he can send us before needing flow
+ * control answer from us (this may be negociated differently at TSAP setup).
+ * We want to minimise the number of times we have to explicitely send some
+ * credit to the peer, hoping we can piggyback it on the return data. In
+ * particular, it doesn't make sense for us to send credit more than once
+ * per LAP window.
+ * Moreover, giving credits has some latency, so we need strictly more than
+ * a LAP window, otherwise we may already have credits in our Tx queue.
+ * But on the other hand, we don't want to keep too many Rx buffer here
+ * before starting to flow control the other end, so make it exactly one
+ * LAP window + 1 + MIN_CREDITS. - Jean II */
+#define TTP_RX_DEFAULT_CREDIT	16
+/* Maximum number of credits we can allow the peer to have, and therefore
+ * maximum Rx queue size.
+ * Note that we try to deliver packets to the higher layer every time we
+ * receive something, so in normal mode the Rx queue will never contains
+ * more than one or two packets. - Jean II */
+#define TTP_RX_MAX_CREDIT	21
 
-#define TTP_LOW_THRESHOLD       4
-#define TTP_HIGH_THRESHOLD     10
-#define TTP_MAX_QUEUE          14
+/* What clients should use when calling ttp_open_tsap() */
+#define DEFAULT_INITIAL_CREDIT	TTP_RX_DEFAULT_CREDIT
 
 /* Some priorities for disconnect requests */
 #define P_NORMAL    0
@@ -90,7 +127,7 @@ struct tsap_cb {
 
 	struct net_device_stats stats;
 	struct timer_list todo_timer; 
-	
+
 	__u32 max_seg_size;     /* Max data that fit into an IrLAP frame */
 	__u8  max_header_size;
 
@@ -131,6 +168,7 @@ int irttp_disconnect_request(struct tsap
 void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow);
 void irttp_status_indication(void *instance,
 			     LINK_STATUS link, LOCK_STATUS lock);
+void irttp_flow_indication(void *instance, void *sap, LOCAL_FLOW flow);
 struct tsap_cb *irttp_dup(struct tsap_cb *self, void *instance);
 
 static __inline __u32 irttp_get_saddr(struct tsap_cb *self)
net/irda/irttp.c renamed from net/irda/irttp.d6.c +423 -298

917 lines not on this page · raw message