Skip to contentSkip to conversation

patch-2.4.0-test10-irda18 (was: Re: The IrDA patches)

PATCH New Dag Brattli 1 participant 1 message Nov 11, 2000 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 patch-2.4.0-test10-irda18 (was: Re: The IrDA patches)

Linus,

Here are the new IrDA patches for Linux-2.4.0-test10. Please apply them to your latest 2.4 code. If you decide to apply them, then I suggest you start with the first one (irda1.diff) and work your way to the last one (irda24.diff) since most of them are not commutative.

The name of this patch is irda18.diff.

(Many thanks to Jean Tourrilhes for splitting up the big patch)

[FEATURE] : Add a new feature to the IrDA stack [CORRECT] : Fix to have the correct/expected behaviour [CRITICA] : Fix potential kernel crash
[OUPS ] : Error that will be fixed in a later patch

irda18.diff :
-----------------
o [CRITICA] Prevent out of bound access in QoS arrays
o [CORRECT] Properly disable link broken warning when disc time = 3s
o [FEATURE] Propagate link status indication to higher layers
o [FEATURE] Allow to set max IrDA speed in sysctl
o [FEATURE] Allow to set max IrDA inactive time in sysctl

include/net/irda/irda.h +2 -0
diff -urpN old-linux/include/net/irda/irda.h linux/include/net/irda/irda.h
@@ -242,6 +242,8 @@ typedef struct {
 	void (*disconnect_indication)(void *instance, void *sap, 
 				      LM_REASON reason, struct sk_buff *);
 	void (*flow_indication)(void *instance, void *sap, LOCAL_FLOW flow);
+	void (*status_indication)(void *instance,
+				  LINK_STATUS link, LOCK_STATUS lock);
 	void *instance; /* Layer instance pointer */
 	char name[16];  /* Name of layer */
 } notify_t;
include/net/irda/irlap.h +1 -1
diff -urpN old-linux/include/net/irda/irlap.h linux/include/net/irda/irlap.h
@@ -214,7 +214,7 @@ void irlap_unitdata_indication(struct ir
 void irlap_disconnect_request(struct irlap_cb *);
 void irlap_disconnect_indication(struct irlap_cb *, LAP_REASON reason);
 
-void irlap_status_indication(int quality_of_link);
+void irlap_status_indication(struct irlap_cb *, int quality_of_link);
 
 void irlap_test_request(__u8 *info, int len);
 
include/net/irda/irlmp.h +1 -1
diff -urpN old-linux/include/net/irda/irlmp.h linux/include/net/irda/irlmp.h
@@ -233,7 +233,7 @@ void irlmp_connless_data_indication(stru
 #endif /* CONFIG_IRDA_ULTRA */
 
 void irlmp_status_request(void);
-void irlmp_status_indication(LINK_STATUS link, LOCK_STATUS lock);
+void irlmp_status_indication(struct lap_cb *, LINK_STATUS link, LOCK_STATUS lock);
 
 int  irlmp_slsap_inuse(__u8 slsap);
 __u8 irlmp_find_free_slsap(void);
include/net/irda/irttp.h +2 -0
diff -urpN old-linux/include/net/irda/irttp.h linux/include/net/irda/irttp.h
@@ -129,6 +129,8 @@ int irttp_connect_response(struct tsap_c
 int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *skb,
 			     int priority);
 void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow);
+void irttp_status_indication(void *instance,
+			     LINK_STATUS link, LOCK_STATUS lock);
 struct tsap_cb *irttp_dup(struct tsap_cb *self, void *instance);
 
 static __inline __u32 irttp_get_saddr(struct tsap_cb *self)
include/net/irda/qos.h +3 -4
diff -urpN old-linux/include/net/irda/qos.h linux/include/net/irda/qos.h
@@ -86,6 +86,9 @@ struct qos_info {
 #endif
 };
 
+extern int sysctl_max_baud_rate;
+extern int sysctl_max_inactive_time;
+
 extern __u32 baud_rates[];
 extern __u32 data_sizes[];
 extern __u32 min_turn_times[];
@@ -100,10 +103,6 @@ __u32 irlap_requested_line_capacity(stru
 __u32 irlap_min_turn_time_in_bytes(__u32 speed, __u32 min_turn_time);
 
 int msb_index(__u16 byte);
-int value_index(__u32 value, __u32 *array);
-__u32 byte_value(__u8 byte, __u32 *array);
-__u32 index_value(int index, __u32 *array);
-
 void irda_qos_bits_to_value(struct qos_info *qos);
 
 #endif
net/irda/irlap.c +10 -5
diff -urpN old-linux/net/irda/irlap.c linux/net/irda/irlap.c
@@ -617,7 +617,7 @@ void irlap_discovery_indication(struct i
  *    
  *
  */
-void irlap_status_indication(int quality_of_link) 
+void irlap_status_indication(struct irlap_cb *self, int quality_of_link) 
 {
 	switch (quality_of_link) {
 	case STATUS_NO_ACTIVITY:
@@ -629,7 +629,8 @@ void irlap_status_indication(int quality
 	default:
 		break;
 	}
-	irlmp_status_indication(quality_of_link, LOCK_NO_CHANGE);
+	irlmp_status_indication(self->notify.instance,
+				quality_of_link, LOCK_NO_CHANGE);
 }
 
 /*
@@ -985,8 +986,8 @@ void irlap_init_qos_capabilities(struct 
 	/* Set data size */
 	/*self->qos_rx.data_size.bits &= 0x03;*/
 
-	/* Set disconnect time */
-	self->qos_rx.link_disc_time.bits &= 0x07;
+	/* Set disconnect time -> done properly in qos.c */
+	/*self->qos_rx.link_disc_time.bits &= 0x07;*/
 
 	irda_qos_bits_to_value(&self->qos_rx);
 }
@@ -1083,7 +1084,11 @@ void irlap_apply_connection_parameters(s
 	 */
 	ASSERT(self->qos_tx.max_turn_time.value != 0, return;);
 	if (self->qos_tx.link_disc_time.value == 3)
-		self->N1 = 0;
+		/*self->N1 = 0;*/
+		/* If we set N1 to 0, it will trigger immediately, which is
+		 * *not* what we want. What we really want is to disable it,
+		 * so we set it to -10 ;-) Jean II */
+		self->N1 = -10;
 	else
 		self->N1 = 3000 / self->qos_tx.max_turn_time.value;
 	
net/irda/irlap_event.c +2 -2
diff -urpN old-linux/net/irda/irlap_event.c linux/net/irda/irlap_event.c
@@ -1326,7 +1326,7 @@ static int irlap_state_nrm_p(struct irla
 				   " retry_count=%d\n", self->retry_count);
 			/* Keep state */
 		} else if (self->retry_count == self->N1) {
-			irlap_status_indication(STATUS_NO_ACTIVITY);
+			irlap_status_indication(self, STATUS_NO_ACTIVITY);
 			irlap_wait_min_turn_around(self, &self->qos_tx);
 			irlap_send_rr_frame(self, CMD_FRAME);
 			
@@ -1896,7 +1896,7 @@ static int irlap_state_nrm_s(struct irla
 			irlap_start_wd_timer(self, self->wd_timeout);
 			self->retry_count++;		
 		} else if (self->retry_count == (self->N1/2)) {
-			irlap_status_indication(STATUS_NO_ACTIVITY);
+			irlap_status_indication(self, STATUS_NO_ACTIVITY);
 			irlap_start_wd_timer(self, self->wd_timeout);
 			self->retry_count++;
 		} else if (self->retry_count >= self->N2/2) {
net/irda/irlmp.c +28 -2
diff -urpN old-linux/net/irda/irlmp.c linux/net/irda/irlmp.c
@@ -1111,9 +1111,35 @@ void irlmp_status_request(void) 
 	IRDA_DEBUG(0, __FUNCTION__ "(), Not implemented\n");
 }
 
-void irlmp_status_indication(LINK_STATUS link, LOCK_STATUS lock) 
+/*
+ * Propagate status indication from LAP to LSAPs (via LMP)
+ * This don't trigger any change of state in lap_cb, lmp_cb or lsap_cb,
+ * and the event is stateless, therefore we can bypass both state machines
+ * and send the event direct to the LSAP user.
+ * Jean II
+ */
+void irlmp_status_indication(struct lap_cb *self,
+			     LINK_STATUS link, LOCK_STATUS lock) 
 {
-	IRDA_DEBUG(1, __FUNCTION__ "(), Not implemented\n");
+	struct lsap_cb *next;
+	struct lsap_cb *curr;
+
+	/* Send status_indication to all LSAPs using this link */
+	next = (struct lsap_cb *) hashbin_get_first( self->lsaps);
+	while (next != NULL ) {
+		curr = next;
+		next = (struct lsap_cb *) hashbin_get_next(self->lsaps);
+
+		ASSERT(curr->magic == LMP_LSAP_MAGIC, return;);
+		/*
+		 *  Inform service user if he has requested it
+		 */
+		if (curr->notify.status_indication != NULL)
+			curr->notify.status_indication(curr->notify.instance, 
+						       link, lock);
+		else
+			IRDA_DEBUG(2, __FUNCTION__ "(), no handler\n");
+	}
 }
 
 /*
net/irda/irmod.c +1 -0
diff -urpN old-linux/net/irda/irmod.c linux/net/irda/irmod.c
@@ -314,6 +314,7 @@ void irda_notify_init(notify_t *notify)
 	notify->connect_indication = NULL;
 	notify->disconnect_indication = NULL;
 	notify->flow_indication = NULL;
+	notify->status_indication = NULL;
 	notify->instance = NULL;
 	strncpy(notify->name, "Unknown", NOTIFY_MAX_NAME);
 }
net/irda/irsysctl.c +7 -1
diff -urpN old-linux/net/irda/irsysctl.c linux/net/irda/irsysctl.c
@@ -33,7 +33,7 @@
 
 #define NET_IRDA 412 /* Random number */
 enum { DISCOVERY=1, DEVNAME, COMPRESSION, DEBUG, SLOTS, DISCOVERY_TIMEOUT, 
-       SLOT_TIMEOUT };
+       SLOT_TIMEOUT, MAX_BAUD_RATE, MAX_INACTIVE_TIME };
 
 extern int  sysctl_discovery;
 extern int  sysctl_discovery_slots;
@@ -42,6 +42,8 @@ extern int  sysctl_slot_timeout;
 extern int  sysctl_fast_poll_increase;
 int         sysctl_compression = 0;
 extern char sysctl_devname[];
+extern int  sysctl_max_baud_rate;
+extern int  sysctl_max_inactive_time;
 
 #ifdef CONFIG_IRDA_DEBUG
 extern unsigned int irda_debug;
@@ -84,6 +86,10 @@ static ctl_table irda_table[] = {
 	{ DISCOVERY_TIMEOUT, "discovery_timeout", &sysctl_discovery_timeout,
 	  sizeof(int), 0644, NULL, &proc_dointvec },
 	{ SLOT_TIMEOUT, "slot_timeout", &sysctl_slot_timeout,
+	  sizeof(int), 0644, NULL, &proc_dointvec },
+	{ MAX_BAUD_RATE, "max_baud_rate", &sysctl_max_baud_rate,
+	  sizeof(int), 0644, NULL, &proc_dointvec },
+	{ MAX_INACTIVE_TIME, "max_inactive_time", &sysctl_max_inactive_time,
 	  sizeof(int), 0644, NULL, &proc_dointvec },
 	{ 0 }
 };
net/irda/irttp.c +30 -0
diff -urpN old-linux/net/irda/irttp.c linux/net/irda/irttp.c
@@ -156,6 +156,8 @@ struct tsap_cb *irttp_open_tsap(__u8 sts
 	ttp_notify.disconnect_indication = irttp_disconnect_indication;
 	ttp_notify.data_indication = irttp_data_indication;
 	ttp_notify.udata_indication = irttp_udata_indication;
+	if(notify->status_indication != NULL)
+		ttp_notify.status_indication = irttp_status_indication;
 	ttp_notify.instance = self;
 	strncpy(ttp_notify.name, notify->name, NOTIFY_MAX_NAME);
 
@@ -605,6 +607,34 @@ static int irttp_data_indication(void *i
 		irttp_start_todo_timer(self, 0);
 	}
 	return 0;
+}
+
+/*
+ * Function irttp_status_indication (self, reason)
+ *
+ *    Status_indication, just pass to the higher layer...
+ *
+ */
+void irttp_status_indication(void *instance,
+			     LINK_STATUS link, LOCK_STATUS lock)
+{
+	struct tsap_cb *self;
+
+	IRDA_DEBUG(4, __FUNCTION__ "()\n");
+
+	self = (struct tsap_cb *) instance;
+	
+	ASSERT(self != NULL, return;);
+	ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
+	
+	/*
+	 *  Inform service user if he has requested it
+	 */
+	if (self->notify.status_indication != NULL)
+		self->notify.status_indication(self->notify.instance, 
+					       link, lock);
+	else
+		IRDA_DEBUG(2, __FUNCTION__ "(), no handler\n");
 }
 
 /*
net/irda/qos.c +68 -17

157 lines not on this page · raw message

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/