patch-2.2.10 linux/net/irda/irlap_event.c
Next file: linux/net/irda/irlap_frame.c
Previous file: linux/net/irda/irlap_comp.c
Back to the patch index
Back to the overall index
- Lines: 468
- Date:
Mon Jun 7 16:19:59 1999
- Orig file:
v2.2.9/linux/net/irda/irlap_event.c
- Orig date:
Wed Apr 28 11:37:32 1999
diff -u --recursive --new-file v2.2.9/linux/net/irda/irlap_event.c linux/net/irda/irlap_event.c
@@ -6,10 +6,10 @@
* Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Sat Aug 16 00:59:29 1997
- * Modified at: Fri Apr 23 11:55:12 1999
+ * Modified at: Mon May 31 21:55:42 1999
* Modified by: Dag Brattli <dagb@cs.uit.no>
*
- * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>,
+ * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
* Thomas Davis <ratbert@radiks.net>
* All Rights Reserved.
*
@@ -209,8 +209,8 @@
* Rushes through the state machine without any delay. If state == XMIT
* then send queued data frames.
*/
-void irlap_do_event( struct irlap_cb *self, IRLAP_EVENT event,
- struct sk_buff *skb, struct irlap_info *info)
+void irlap_do_event(struct irlap_cb *self, IRLAP_EVENT event,
+ struct sk_buff *skb, struct irlap_info *info)
{
int ret;
@@ -218,7 +218,7 @@
return;
DEBUG(4, __FUNCTION__ "(), event = %s, state = %s\n",
- irlap_event[ event], irlap_state[ self->state]);
+ irlap_event[event], irlap_state[self->state]);
ret = (*state[ self->state]) (self, event, skb, info);
@@ -236,13 +236,12 @@
if (skb_queue_len(&self->tx_list)) {
/* Try to send away all queued data frames */
while ((skb = skb_dequeue(&self->tx_list)) != NULL) {
- ret = (*state[ self->state])(self, SEND_I_CMD,
- skb, NULL);
+ ret = (*state[self->state])(self, SEND_I_CMD,
+ skb, NULL);
if ( ret == -EPROTO)
break; /* Try again later! */
}
} else if (self->disconnect_pending) {
- DEBUG(0, __FUNCTION__ "(), disconnecting!\n");
self->disconnect_pending = FALSE;
ret = (*state[self->state])(self, DISCONNECT_REQUEST,
@@ -274,22 +273,22 @@
* Switches state and provides debug information
*
*/
-void irlap_next_state( struct irlap_cb *self, IRLAP_STATE state)
+void irlap_next_state(struct irlap_cb *self, IRLAP_STATE state)
{
- if ( !self || self->magic != LAP_MAGIC)
+ if (!self || self->magic != LAP_MAGIC)
return;
- DEBUG( 4, "next LAP state = %s\n", irlap_state[ state]);
+ DEBUG(4, "next LAP state = %s\n", irlap_state[ state]);
self->state = state;
/*
* If we are swithing away from a XMIT state then we are allowed to
* transmit a maximum number of bytes again when we enter the XMIT
- * state again. Since its possible to "switch" from XMIT to XMIT and
+ * state again. Since its possible to "switch" from XMIT to XMIT,
* we cannot do this when swithing into the XMIT state :-)
*/
- if (( state != LAP_XMIT_P) && ( state != LAP_XMIT_S))
+ if ((state != LAP_XMIT_P) && (state != LAP_XMIT_S))
self->bytes_left = self->window_bytes;
}
@@ -310,7 +309,7 @@
ASSERT( self != NULL, return -1;);
ASSERT( self->magic == LAP_MAGIC, return -1;);
- switch( event) {
+ switch(event) {
case CONNECT_REQUEST:
ASSERT( self->irdev != NULL, return -1;);
@@ -393,7 +392,6 @@
irlap_start_query_timer( self, QUERY_TIMEOUT);
irlap_next_state( self, LAP_REPLY);
}
-
dev_kfree_skb(skb);
break;
@@ -530,7 +528,7 @@
irlap_send_discovery_xid_frame(self, info->S,
self->slot, FALSE,
discovery_rsp);
-
+
self->frame_sent = TRUE;
irlap_next_state(self, LAP_REPLY);
}
@@ -568,27 +566,28 @@
switch (event) {
case CONNECT_RESPONSE:
- skb_pull( skb, 11);
+ /* skb_pull(skb, 11); */
+ skb_pull(skb, sizeof(struct snrm_frame));
- ASSERT( self->irdev != NULL, return -1;);
- irda_qos_negotiate( &self->qos_rx, &self->qos_tx, skb);
+ ASSERT(self->irdev != NULL, return -1;);
+ irda_qos_negotiate(&self->qos_rx, &self->qos_tx, skb);
irlap_initiate_connection_state( self);
/*
* We are allowed to send two frames!
*/
- irlap_send_ua_response_frame( self, &self->qos_rx);
- irlap_send_ua_response_frame( self, &self->qos_rx);
+ irlap_send_ua_response_frame(self, &self->qos_rx);
+ irlap_send_ua_response_frame(self, &self->qos_rx);
- irlap_apply_connection_parameters( self, &self->qos_tx);
+ irlap_apply_connection_parameters(self, &self->qos_tx);
/*
* The WD-timer could be set to the duration of the P-timer
- * for this case, but it is recommomended to use twice the
+ * for this case, but it is recommended to use twice the
* value (note 3 IrLAP p. 60).
*/
- irlap_start_wd_timer( self, self->wd_timeout);
+ irlap_start_wd_timer(self, self->wd_timeout);
irlap_next_state( self, LAP_NRM_S);
break;
@@ -669,28 +668,30 @@
* The device with the largest device address wins the battle
* (both have sent a SNRM command!)
*/
- if ( info->daddr > self->saddr) {
- del_timer( &self->final_timer);
- irlap_initiate_connection_state( self);
+ if (info->daddr > self->saddr) {
+ del_timer(&self->final_timer);
+ irlap_initiate_connection_state(self);
- ASSERT( self->irdev != NULL, return -1;);
- irda_qos_negotiate( &self->qos_rx, &self->qos_tx, skb);
+ ASSERT(self->irdev != NULL, return -1;);
+ /* skb_pull(skb, 11); */
+ skb_pull(skb, sizeof(struct snrm_frame));
+ irda_qos_negotiate(&self->qos_rx, &self->qos_tx, skb);
irlap_send_ua_response_frame(self, &self->qos_rx);
- irlap_apply_connection_parameters( self, &self->qos_tx);
- irlap_connect_confirm( self, skb);
+ irlap_apply_connection_parameters(self, &self->qos_tx);
+ irlap_connect_confirm(self, skb);
/*
* The WD-timer could be set to the duration of the
- * P-timer for this case, but it is recommomended
+ * P-timer for this case, but it is recommended
* to use twice the value (note 3 IrLAP p. 60).
*/
- irlap_start_wd_timer( self, self->wd_timeout);
+ irlap_start_wd_timer(self, self->wd_timeout);
- irlap_next_state( self, LAP_NRM_S);
+ irlap_next_state(self, LAP_NRM_S);
} else {
/* We just ignore the other device! */
- irlap_next_state( self, LAP_SETUP);
+ irlap_next_state(self, LAP_SETUP);
}
break;
case RECV_UA_RSP:
@@ -702,9 +703,10 @@
/* Negotiate connection parameters */
ASSERT( skb->len > 10, return -1;);
- skb_pull( skb, 10);
+ /* skb_pull(skb, 10); */
+ skb_pull(skb, sizeof(struct ua_frame));
- ASSERT( self->irdev != NULL, return -1;);
+ ASSERT(self->irdev != NULL, return -1;);
irda_qos_negotiate( &self->qos_rx, &self->qos_tx, skb);
irlap_apply_connection_parameters( self, &self->qos_tx);
@@ -758,36 +760,30 @@
* stations.
*
*/
-static int irlap_state_xmit_p( struct irlap_cb *self, IRLAP_EVENT event,
- struct sk_buff *skb, struct irlap_info *info)
+static int irlap_state_xmit_p(struct irlap_cb *self, IRLAP_EVENT event,
+ struct sk_buff *skb, struct irlap_info *info)
{
int ret = 0;
- ASSERT( self != NULL, return -ENODEV;);
- ASSERT( self->magic == LAP_MAGIC, return -EBADR;);
-
- DEBUG( 4, __FUNCTION__ "(), event=%s, vs=%d, vr=%d",
- irlap_event[ event], self->vs, self->vr);
+ DEBUG(4, __FUNCTION__ "(), event=%s, vs=%d, vr=%d",
+ irlap_event[event], self->vs, self->vr);
switch (event) {
case SEND_I_CMD:
- ASSERT( skb != NULL, return -1;);
- DEBUG( 4, __FUNCTION__ "(), Window=%d\n", self->window);
-
/*
* Only send frame if send-window > 0.
*/
- if (( self->window > 0) && ( !self->remote_busy)) {
+ if ((self->window > 0) && (!self->remote_busy)) {
/*
* Test if we have transmitted more bytes over the
* link than its possible to do with the current
* speed and turn-around-time.
*/
- if (( skb->len+self->bofs_count) > self->bytes_left) {
- DEBUG( 4, __FUNCTION__ "(), Not allowed to "
- "transmit more bytes!\n");
- skb_queue_head( &self->tx_list, skb);
+ if ((skb->len+self->bofs_count) > self->bytes_left) {
+ DEBUG(4, __FUNCTION__ "(), Not allowed to "
+ "transmit more bytes!\n");
+ skb_queue_head(&self->tx_list, skb);
/*
* We should switch state to LAP_NRM_P, but
@@ -799,7 +795,7 @@
*/
return -EPROTO;
}
- self->bytes_left -= ( skb->len + self->bofs_count);
+ self->bytes_left -= (skb->len + self->bofs_count);
/*
* Send data with poll bit cleared only if window > 1
@@ -808,11 +804,9 @@
if (( self->window > 1) &&
skb_queue_len( &self->tx_list) > 0)
{
- DEBUG( 4, __FUNCTION__ "(), window > 1\n");
irlap_send_data_primary( self, skb);
irlap_next_state( self, LAP_XMIT_P);
} else {
- DEBUG( 4, __FUNCTION__ "(), window <= 1\n");
irlap_send_data_primary_poll( self, skb);
irlap_next_state( self, LAP_NRM_P);
@@ -930,9 +924,6 @@
int ns_status;
int nr_status;
- ASSERT(self != NULL, return -1;);
- ASSERT(self->magic == LAP_MAGIC, return -1;);
-
switch (event) {
case RECV_I_RSP: /* Optimize for the common case */
/* FIXME: must check for remote_busy below */
@@ -944,7 +935,6 @@
*/
self->fast_RR = FALSE;
#endif
-
ASSERT( info != NULL, return -1;);
ns_status = irlap_validate_ns_received(self, info->ns);
@@ -1138,13 +1128,6 @@
}
break;
case RECV_RR_RSP:
- DEBUG(4, __FUNCTION__ "(), RECV_RR_FRAME: "
- "Retrans:%d, nr=%d, va=%d, vs=%d, vr=%d\n",
- self->retry_count, info->nr, self->va, self->vs,
- self->vr);
-
- ASSERT(info != NULL, return -1;);
-
/*
* If you get a RR, the remote isn't busy anymore,
* no matter what the NR
@@ -1191,14 +1174,6 @@
/* Resend rejected frames */
irlap_resend_rejected_frames( self, CMD_FRAME);
- /*
- * Start only if not running, DB
- * TODO: Should this one be here?
- */
- /* if ( !self->final_timer.prev) */
-/* irda_start_timer( FINAL_TIMER, self->final_timeout); */
-
- /* Keep state */
irlap_next_state( self, LAP_NRM_P);
} else if (ret == NR_INVALID) {
DEBUG(1, "irlap_state_nrm_p: received RR with "
@@ -1207,8 +1182,7 @@
irlap_next_state( self, LAP_RESET_WAIT);
- irlap_disconnect_indication( self,
- LAP_RESET_INDICATION);
+ irlap_disconnect_indication(self, LAP_RESET_INDICATION);
self->xmitflag = TRUE;
}
if (skb)
@@ -1476,13 +1450,13 @@
/*
* Send frame only if send window > 1
*/
- if (( self->window > 0) && ( !self->remote_busy)) {
+ if ((self->window > 0) && ( !self->remote_busy)) {
/*
* Test if we have transmitted more bytes over the
* link than its possible to do with the current
* speed and turn-around-time.
*/
- if (( skb->len+self->bofs_count) > self->bytes_left) {
+ if ((skb->len+self->bofs_count) > self->bytes_left) {
DEBUG( 4, "IrDA: Not allowed to transmit more bytes!\n");
skb_queue_head( &self->tx_list, skb);
/*
@@ -1504,11 +1478,9 @@
if (( self->window > 1) &&
skb_queue_len( &self->tx_list) > 0)
{
- DEBUG( 4, __FUNCTION__ "(), window > 1\n");
irlap_send_data_secondary( self, skb);
irlap_next_state( self, LAP_XMIT_S);
} else {
- DEBUG( 4, "(), window <= 1\n");
irlap_send_data_secondary_final( self, skb);
irlap_next_state( self, LAP_NRM_S);
@@ -1570,7 +1542,7 @@
/*
* poll bit cleared?
*/
- if ( !info->pf) {
+ if (!info->pf) {
self->vr = (self->vr + 1) % 8;
/* Update Nr received */
@@ -1600,35 +1572,39 @@
* also before changing to XMIT_S
* state. (note 1, IrLAP p. 82)
*/
- irlap_wait_min_turn_around( self, &self->qos_tx);
- /*
- * Any pending data requests?
+ irlap_wait_min_turn_around(self, &self->qos_tx);
+
+ /*
+ * Give higher layers a chance to
+ * immediately reply with some data before
+ * we decide if we should send a RR frame
+ * or not
*/
- if (( skb_queue_len( &self->tx_list) > 0) &&
- ( self->window > 0))
+ irlap_data_indication(self, skb);
+
+ /* Any pending data requests? */
+ if ((skb_queue_len(&self->tx_list) > 0) &&
+ (self->window > 0))
{
self->ack_required = TRUE;
- del_timer( &self->wd_timer);
+ del_timer(&self->wd_timer);
- irlap_next_state( self, LAP_XMIT_S);
+ irlap_next_state(self, LAP_XMIT_S);
} else {
- irlap_send_rr_frame( self, RSP_FRAME);
- irlap_start_wd_timer( self, self->wd_timeout);
+ irlap_send_rr_frame(self, RSP_FRAME);
+ irlap_start_wd_timer(self, self->wd_timeout);
/* Keep the state */
- irlap_next_state( self, LAP_NRM_S);
+ irlap_next_state(self, LAP_NRM_S);
}
- irlap_data_indication( self, skb);
-
break;
}
}
/*
* Check for Unexpected next to send (Ns)
*/
- if (( ns_status == NS_UNEXPECTED) &&
- ( nr_status == NR_EXPECTED))
+ if ((ns_status == NS_UNEXPECTED) && (nr_status == NR_EXPECTED))
{
/* Unexpected next to send, with final bit cleared */
if ( !info->pf) {
@@ -1651,8 +1627,7 @@
/*
* Unexpected Next to Receive(NR) ?
*/
- if (( ns_status == NS_EXPECTED) &&
- ( nr_status == NR_UNEXPECTED))
+ if ((ns_status == NS_EXPECTED) && (nr_status == NR_UNEXPECTED))
{
if ( info->pf) {
DEBUG( 4, "RECV_I_RSP: frame(s) lost\n");
@@ -1748,20 +1723,20 @@
irlap_update_nr_received( self, info->nr);
del_timer( &self->wd_timer);
- irlap_wait_min_turn_around( self, &self->qos_tx);
+ irlap_wait_min_turn_around(self, &self->qos_tx);
irlap_next_state( self, LAP_XMIT_S);
} else {
self->remote_busy = FALSE;
/* Update Nr received */
- irlap_update_nr_received( self, info->nr);
- irlap_wait_min_turn_around( self, &self->qos_tx);
+ irlap_update_nr_received(self, info->nr);
+ irlap_wait_min_turn_around(self, &self->qos_tx);
- irlap_send_rr_frame( self, RSP_FRAME);
+ irlap_send_rr_frame(self, RSP_FRAME);
- irlap_start_wd_timer( self, self->wd_timeout);
- irlap_next_state( self, LAP_NRM_S);
+ irlap_start_wd_timer(self, self->wd_timeout);
+ irlap_next_state(self, LAP_NRM_S);
}
- } else if ( nr_status == NR_UNEXPECTED) {
+ } else if (nr_status == NR_UNEXPECTED) {
self->remote_busy = FALSE;
irlap_update_nr_received( self, info->nr);
irlap_resend_rejected_frames( self, RSP_FRAME);
@@ -1773,8 +1748,8 @@
} else {
DEBUG(1, __FUNCTION__ "(), invalid nr not implemented!\n");
}
- if ( skb)
- dev_kfree_skb( skb);
+ if (skb)
+ dev_kfree_skb(skb);
break;
case RECV_SNRM_CMD:
@@ -1886,7 +1861,7 @@
ASSERT( self != NULL, return -ENODEV;);
ASSERT( self->magic == LAP_MAGIC, return -EBADR;);
- switch( event) {
+ switch(event) {
case RESET_RESPONSE:
irlap_send_ua_response_frame( self, &self->qos_rx);
irlap_initiate_connection_state( self);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)