X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Firda%2Firlap_event.c;h=99faff68c399aa92422453f79497889113de9094;hb=refs%2Fheads%2Fvserver;hp=a58bb70d57fd6d62ebcfb737f045ada68d23a778;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/net/irda/irlap_event.c b/net/irda/irlap_event.c index a58bb70d5..99faff68c 100644 --- a/net/irda/irlap_event.c +++ b/net/irda/irlap_event.c @@ -25,7 +25,6 @@ * ********************************************************************/ -#include #include #include #include @@ -169,8 +168,8 @@ static void irlap_poll_timer_expired(void *data) { struct irlap_cb *self = (struct irlap_cb *) data; - ASSERT(self != NULL, return;); - ASSERT(self->magic == LAP_MAGIC, return;); + IRDA_ASSERT(self != NULL, return;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return;); irlap_do_event(self, POLL_TIMER_EXPIRED, NULL, NULL); } @@ -181,17 +180,17 @@ static void irlap_poll_timer_expired(void *data) * Make sure that state is XMIT_P/XMIT_S when calling this function * (and that nobody messed up with the state). - Jean II */ -void irlap_start_poll_timer(struct irlap_cb *self, int timeout) +static void irlap_start_poll_timer(struct irlap_cb *self, int timeout) { - ASSERT(self != NULL, return;); - ASSERT(self->magic == LAP_MAGIC, return;); + IRDA_ASSERT(self != NULL, return;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return;); #ifdef CONFIG_IRDA_FAST_RR /* * Send out the RR frames faster if our own transmit queue is empty, or * if the peer is busy. The effect is a much faster conversation */ - if ((skb_queue_len(&self->txq) == 0) || (self->remote_busy)) { + if (skb_queue_empty(&self->txq) || self->remote_busy) { if (self->fast_RR == TRUE) { /* * Assert that the fast poll timer has not reached the @@ -263,7 +262,7 @@ void irlap_do_event(struct irlap_cb *self, IRLAP_EVENT event, IRDA_DEBUG(2, "%s() : queue len = %d\n", __FUNCTION__, skb_queue_len(&self->txq)); - if (skb_queue_len(&self->txq)) { + if (!skb_queue_empty(&self->txq)) { /* Prevent race conditions with irlap_data_request() */ self->local_busy = TRUE; @@ -346,12 +345,12 @@ static int irlap_state_ndm(struct irlap_cb *self, IRLAP_EVENT event, discovery_t *discovery_rsp; int ret = 0; - ASSERT(self != NULL, return -1;); - ASSERT(self->magic == LAP_MAGIC, return -1;); + IRDA_ASSERT(self != NULL, return -1;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); switch (event) { case CONNECT_REQUEST: - ASSERT(self->netdev != NULL, return -1;); + IRDA_ASSERT(self->netdev != NULL, return -1;); if (self->media_busy) { /* Note : this will never happen, because we test @@ -389,10 +388,11 @@ static int irlap_state_ndm(struct irlap_cb *self, IRLAP_EVENT event, } break; case DISCOVERY_REQUEST: - ASSERT(info != NULL, return -1;); + IRDA_ASSERT(info != NULL, return -1;); if (self->media_busy) { - IRDA_DEBUG(0, "%s(), media busy!\n", __FUNCTION__); + IRDA_DEBUG(1, "%s(), DISCOVERY_REQUEST: media busy!\n", + __FUNCTION__); /* irlap->log.condition = MEDIA_BUSY; */ /* This will make IrLMP try again */ @@ -414,7 +414,7 @@ static int irlap_state_ndm(struct irlap_cb *self, IRLAP_EVENT event, irlap_next_state(self, LAP_QUERY); break; case RECV_DISCOVERY_XID_CMD: - ASSERT(info != NULL, return -1;); + IRDA_ASSERT(info != NULL, return -1;); /* Assert that this is not the final slot */ if (info->s <= info->S) { @@ -433,10 +433,11 @@ static int irlap_state_ndm(struct irlap_cb *self, IRLAP_EVENT event, self->frame_sent = FALSE; /* - * Remember to multiply the query timeout value with - * the number of slots used + * Go to reply state until end of discovery to + * inhibit our own transmissions. Set the timer + * to not stay forever there... Jean II */ - irlap_start_query_timer(self, QUERY_TIMEOUT*info->S); + irlap_start_query_timer(self, info->S, info->s); irlap_next_state(self, LAP_REPLY); } else { /* This is the final slot. How is it possible ? @@ -452,6 +453,9 @@ static int irlap_state_ndm(struct irlap_cb *self, IRLAP_EVENT event, * Not much. It's too late to answer those discovery frames, * so we just pass the info to IrLMP who will put it in the * log (and post an event). + * Another cause would be devices that do discovery much + * slower than us, however the latest fixes should minimise + * those cases... * Jean II */ IRDA_DEBUG(1, "%s(), Receiving final discovery request, missed the discovery slots :-(\n", __FUNCTION__); @@ -572,21 +576,21 @@ static int irlap_state_query(struct irlap_cb *self, IRLAP_EVENT event, { int ret = 0; - ASSERT(self != NULL, return -1;); - ASSERT(self->magic == LAP_MAGIC, return -1;); + IRDA_ASSERT(self != NULL, return -1;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); switch (event) { case RECV_DISCOVERY_XID_RSP: - ASSERT(info != NULL, return -1;); - ASSERT(info->discovery != NULL, return -1;); + IRDA_ASSERT(info != NULL, return -1;); + IRDA_ASSERT(info->discovery != NULL, return -1;); IRDA_DEBUG(4, "%s(), daddr=%08x\n", __FUNCTION__, info->discovery->data.daddr); if (!self->discovery_log) { - WARNING("%s: discovery log is gone! " - "maybe the discovery timeout has been set to " - "short?\n", __FUNCTION__); + IRDA_WARNING("%s: discovery log is gone! " + "maybe the discovery timeout has been set" + " to short?\n", __FUNCTION__); break; } hashbin_insert(self->discovery_log, @@ -609,7 +613,7 @@ static int irlap_state_query(struct irlap_cb *self, IRLAP_EVENT event, * Jean II */ - ASSERT(info != NULL, return -1;); + IRDA_ASSERT(info != NULL, return -1;); IRDA_DEBUG(1, "%s(), Receiving discovery request (s = %d) while performing discovery :-(\n", __FUNCTION__, info->s); @@ -686,17 +690,17 @@ static int irlap_state_reply(struct irlap_cb *self, IRLAP_EVENT event, IRDA_DEBUG(4, "%s()\n", __FUNCTION__); - ASSERT(self != NULL, return -1;); - ASSERT(self->magic == LAP_MAGIC, return -1;); + IRDA_ASSERT(self != NULL, return -1;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); switch (event) { case QUERY_TIMER_EXPIRED: - IRDA_DEBUG(2, "%s(), QUERY_TIMER_EXPIRED <%ld>\n", + IRDA_DEBUG(0, "%s(), QUERY_TIMER_EXPIRED <%ld>\n", __FUNCTION__, jiffies); irlap_next_state(self, LAP_NDM); break; case RECV_DISCOVERY_XID_CMD: - ASSERT(info != NULL, return -1;); + IRDA_ASSERT(info != NULL, return -1;); /* Last frame? */ if (info->s == 0xff) { del_timer(&self->query_timer); @@ -707,16 +711,26 @@ static int irlap_state_reply(struct irlap_cb *self, IRLAP_EVENT event, irlap_next_state(self, LAP_NDM); irlap_discovery_indication(self, info->discovery); - } else if ((info->s >= self->slot) && (!self->frame_sent)) { - discovery_rsp = irlmp_get_discovery_response(); - discovery_rsp->data.daddr = info->daddr; + } else { + /* If it's our slot, send our reply */ + if ((info->s >= self->slot) && (!self->frame_sent)) { + discovery_rsp = irlmp_get_discovery_response(); + discovery_rsp->data.daddr = info->daddr; + + irlap_send_discovery_xid_frame(self, info->S, + self->slot, + FALSE, + discovery_rsp); - irlap_send_discovery_xid_frame(self, info->S, - self->slot, FALSE, - discovery_rsp); + self->frame_sent = TRUE; + } + /* Readjust our timer to accomodate devices + * doing faster or slower discovery than us... + * Jean II */ + irlap_start_query_timer(self, info->S, info->s); - self->frame_sent = TRUE; - irlap_next_state(self, LAP_REPLY); + /* Keep state */ + //irlap_next_state(self, LAP_REPLY); } break; default: @@ -743,14 +757,14 @@ static int irlap_state_conn(struct irlap_cb *self, IRLAP_EVENT event, IRDA_DEBUG(4, "%s(), event=%s\n", __FUNCTION__, irlap_event[ event]); - ASSERT(self != NULL, return -1;); - ASSERT(self->magic == LAP_MAGIC, return -1;); + IRDA_ASSERT(self != NULL, return -1;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); switch (event) { case CONNECT_RESPONSE: skb_pull(skb, sizeof(struct snrm_frame)); - ASSERT(self->netdev != NULL, return -1;); + IRDA_ASSERT(self->netdev != NULL, return -1;); irlap_qos_negotiate(self, skb); @@ -837,8 +851,8 @@ static int irlap_state_setup(struct irlap_cb *self, IRLAP_EVENT event, IRDA_DEBUG(4, "%s()\n", __FUNCTION__); - ASSERT(self != NULL, return -1;); - ASSERT(self->magic == LAP_MAGIC, return -1;); + IRDA_ASSERT(self != NULL, return -1;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); switch (event) { case FINAL_TIMER_EXPIRED: @@ -866,8 +880,8 @@ static int irlap_state_setup(struct irlap_cb *self, IRLAP_EVENT event, case RECV_SNRM_CMD: IRDA_DEBUG(4, "%s(), SNRM battle!\n", __FUNCTION__); - ASSERT(skb != NULL, return 0;); - ASSERT(info != NULL, return 0;); + IRDA_ASSERT(skb != NULL, return 0;); + IRDA_ASSERT(info != NULL, return 0;); /* * The device with the largest device address wins the battle @@ -877,7 +891,7 @@ static int irlap_state_setup(struct irlap_cb *self, IRLAP_EVENT event, del_timer(&self->final_timer); irlap_initiate_connection_state(self); - ASSERT(self->netdev != NULL, return -1;); + IRDA_ASSERT(self->netdev != NULL, return -1;); skb_pull(skb, sizeof(struct snrm_frame)); @@ -909,11 +923,11 @@ static int irlap_state_setup(struct irlap_cb *self, IRLAP_EVENT event, irlap_initiate_connection_state(self); /* Negotiate connection parameters */ - ASSERT(skb->len > 10, return -1;); + IRDA_ASSERT(skb->len > 10, return -1;); skb_pull(skb, sizeof(struct ua_frame)); - ASSERT(self->netdev != NULL, return -1;); + IRDA_ASSERT(self->netdev != NULL, return -1;); irlap_qos_negotiate(self, skb); @@ -1059,7 +1073,7 @@ static int irlap_state_xmit_p(struct irlap_cb *self, IRLAP_EVENT event, #else /* CONFIG_IRDA_DYNAMIC_WINDOW */ /* Window has been adjusted for the max packet * size, so much simpler... - Jean II */ - nextfit = (skb_queue_len(&self->txq) > 0); + nextfit = !skb_queue_empty(&self->txq); #endif /* CONFIG_IRDA_DYNAMIC_WINDOW */ /* * Send data with poll bit cleared only if window > 1 @@ -1144,8 +1158,8 @@ static int irlap_state_pclose(struct irlap_cb *self, IRLAP_EVENT event, IRDA_DEBUG(1, "%s()\n", __FUNCTION__); - ASSERT(self != NULL, return -1;); - ASSERT(self->magic == LAP_MAGIC, return -1;); + IRDA_ASSERT(self != NULL, return -1;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); switch (event) { case RECV_UA_RSP: /* FALLTHROUGH */ @@ -1212,7 +1226,7 @@ static int irlap_state_nrm_p(struct irlap_cb *self, IRLAP_EVENT event, */ self->fast_RR = FALSE; #endif /* CONFIG_IRDA_FAST_RR */ - ASSERT( info != NULL, return -1;); + IRDA_ASSERT( info != NULL, return -1;); ns_status = irlap_validate_ns_received(self, info->ns); nr_status = irlap_validate_nr_received(self, info->nr); @@ -1446,7 +1460,7 @@ static int irlap_state_nrm_p(struct irlap_cb *self, IRLAP_EVENT event, /* Start poll timer */ irlap_start_poll_timer(self, self->poll_timeout); } else if (ret == NR_UNEXPECTED) { - ASSERT(info != NULL, return -1;); + IRDA_ASSERT(info != NULL, return -1;); /* * Unexpected nr! */ @@ -1477,7 +1491,7 @@ static int irlap_state_nrm_p(struct irlap_cb *self, IRLAP_EVENT event, } break; case RECV_RNR_RSP: - ASSERT(info != NULL, return -1;); + IRDA_ASSERT(info != NULL, return -1;); /* Stop final timer */ del_timer(&self->final_timer); @@ -1598,8 +1612,8 @@ static int irlap_state_reset_wait(struct irlap_cb *self, IRLAP_EVENT event, IRDA_DEBUG(3, "%s(), event = %s\n", __FUNCTION__, irlap_event[event]); - ASSERT(self != NULL, return -1;); - ASSERT(self->magic == LAP_MAGIC, return -1;); + IRDA_ASSERT(self != NULL, return -1;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); switch (event) { case RESET_REQUEST: @@ -1645,8 +1659,8 @@ static int irlap_state_reset(struct irlap_cb *self, IRLAP_EVENT event, IRDA_DEBUG(3, "%s(), event = %s\n", __FUNCTION__, irlap_event[event]); - ASSERT(self != NULL, return -1;); - ASSERT(self->magic == LAP_MAGIC, return -1;); + IRDA_ASSERT(self != NULL, return -1;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); switch (event) { case RECV_DISC_CMD: @@ -1679,7 +1693,7 @@ static int irlap_state_reset(struct irlap_cb *self, IRLAP_EVENT event, if (self->retry_count < 3) { irlap_wait_min_turn_around(self, &self->qos_tx); - ASSERT(self->netdev != NULL, return -1;); + IRDA_ASSERT(self->netdev != NULL, return -1;); irlap_send_snrm_frame(self, self->qos_dev); self->retry_count++; /* Experimental!! */ @@ -1738,8 +1752,8 @@ static int irlap_state_xmit_s(struct irlap_cb *self, IRLAP_EVENT event, IRDA_DEBUG(4, "%s(), event=%s\n", __FUNCTION__, irlap_event[event]); - ASSERT(self != NULL, return -ENODEV;); - ASSERT(self->magic == LAP_MAGIC, return -EBADR;); + IRDA_ASSERT(self != NULL, return -ENODEV;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -EBADR;); switch (event) { case SEND_I_CMD: @@ -1799,7 +1813,7 @@ static int irlap_state_xmit_s(struct irlap_cb *self, IRLAP_EVENT event, #else /* CONFIG_IRDA_DYNAMIC_WINDOW */ /* Window has been adjusted for the max packet * size, so much simpler... - Jean II */ - nextfit = (skb_queue_len(&self->txq) > 0); + nextfit = !skb_queue_empty(&self->txq); #endif /* CONFIG_IRDA_DYNAMIC_WINDOW */ /* * Send data with final bit cleared only if window > 1 @@ -1860,8 +1874,8 @@ static int irlap_state_nrm_s(struct irlap_cb *self, IRLAP_EVENT event, IRDA_DEBUG(4, "%s(), event=%s\n", __FUNCTION__, irlap_event[ event]); - ASSERT(self != NULL, return -1;); - ASSERT(self->magic == LAP_MAGIC, return -1;); + IRDA_ASSERT(self != NULL, return -1;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); switch (event) { case RECV_I_CMD: /* Optimize for the common case */ @@ -1922,7 +1936,7 @@ static int irlap_state_nrm_s(struct irlap_cb *self, IRLAP_EVENT event, irlap_data_indication(self, skb, FALSE); /* Any pending data requests? */ - if ((skb_queue_len(&self->txq) > 0) && + if (!skb_queue_empty(&self->txq) && (self->window > 0)) { self->ack_required = TRUE; @@ -2023,7 +2037,7 @@ static int irlap_state_nrm_s(struct irlap_cb *self, IRLAP_EVENT event, /* * Any pending data requests? */ - if ((skb_queue_len(&self->txq) > 0) && + if (!skb_queue_empty(&self->txq) && (self->window > 0) && !self->remote_busy) { irlap_data_indication(self, skb, TRUE); @@ -2054,7 +2068,7 @@ static int irlap_state_nrm_s(struct irlap_cb *self, IRLAP_EVENT event, */ nr_status = irlap_validate_nr_received(self, info->nr); if (nr_status == NR_EXPECTED) { - if ((skb_queue_len( &self->txq) > 0) && + if (!skb_queue_empty(&self->txq) && (self->window > 0)) { self->remote_busy = FALSE; @@ -2217,8 +2231,8 @@ static int irlap_state_sclose(struct irlap_cb *self, IRLAP_EVENT event, IRDA_DEBUG(1, "%s()\n", __FUNCTION__); - ASSERT(self != NULL, return -ENODEV;); - ASSERT(self->magic == LAP_MAGIC, return -EBADR;); + IRDA_ASSERT(self != NULL, return -ENODEV;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -EBADR;); switch (event) { case RECV_DISC_CMD: @@ -2290,8 +2304,8 @@ static int irlap_state_reset_check( struct irlap_cb *self, IRLAP_EVENT event, IRDA_DEBUG(1, "%s(), event=%s\n", __FUNCTION__, irlap_event[event]); - ASSERT(self != NULL, return -ENODEV;); - ASSERT(self->magic == LAP_MAGIC, return -EBADR;); + IRDA_ASSERT(self != NULL, return -ENODEV;); + IRDA_ASSERT(self->magic == LAP_MAGIC, return -EBADR;); switch (event) { case RESET_RESPONSE: