OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [net/] [rose/] [rose_timer.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 *      ROSE release 003
3
 *
4
 *      This code REQUIRES 2.1.0 or higher/ NET3.029
5
 *
6
 *      This module:
7
 *              This module is free software; you can redistribute it and/or
8
 *              modify it under the terms of the GNU General Public License
9
 *              as published by the Free Software Foundation; either version
10
 *              2 of the License, or (at your option) any later version.
11
 *
12
 *      History
13
 *      ROSE 001        Jonathan(G4KLX) Cloned from nr_timer.c
14
 */
15
 
16
#include <linux/config.h>
17
#if defined(CONFIG_ROSE) || defined(CONFIG_ROSE_MODULE)
18
#include <linux/errno.h>
19
#include <linux/types.h>
20
#include <linux/socket.h>
21
#include <linux/in.h>
22
#include <linux/kernel.h>
23
#include <linux/sched.h>
24
#include <linux/timer.h>
25
#include <linux/string.h>
26
#include <linux/sockios.h>
27
#include <linux/net.h>
28
#include <net/ax25.h>
29
#include <linux/inet.h>
30
#include <linux/netdevice.h>
31
#include <linux/skbuff.h>
32
#include <net/sock.h>
33
#include <asm/segment.h>
34
#include <asm/system.h>
35
#include <linux/fcntl.h>
36
#include <linux/mm.h>
37
#include <linux/interrupt.h>
38
#include <net/rose.h>
39
 
40
static void rose_timer(unsigned long);
41
 
42
/*
43
 *      Linux set timer
44
 */
45
void rose_set_timer(struct sock *sk)
46
{
47
        unsigned long flags;
48
 
49
        save_flags(flags); cli();
50
        del_timer(&sk->timer);
51
        restore_flags(flags);
52
 
53
        sk->timer.data     = (unsigned long)sk;
54
        sk->timer.function = &rose_timer;
55
        sk->timer.expires  = jiffies + 10;
56
 
57
        add_timer(&sk->timer);
58
}
59
 
60
/*
61
 *      ROSE Timer
62
 *
63
 *      This routine is called every 100ms. Decrement timer by this
64
 *      amount - if expired then process the event.
65
 */
66
static void rose_timer(unsigned long param)
67
{
68
        struct sock *sk = (struct sock *)param;
69
        struct device *first;
70
 
71
        switch (sk->protinfo.rose->state) {
72
                case ROSE_STATE_0:
73
                        /* Magic here: If we listen() and a new link dies before it
74
                           is accepted() it isn't 'dead' so doesn't get removed. */
75
                        if (sk->destroy || (sk->state == TCP_LISTEN && sk->dead)) {
76
                                del_timer(&sk->timer);
77
                                rose_destroy_socket(sk);
78
                                return;
79
                        }
80
                        break;
81
 
82
                case ROSE_STATE_3:
83
                        /*
84
                         * Check for the state of the receive buffer.
85
                         */
86
                        if (sk->rmem_alloc < ((sk->rcvbuf - ROSE_MAX_WINDOW_LEN) / 2) && (sk->protinfo.rose->condition & ROSE_COND_OWN_RX_BUSY)) {
87
                                sk->protinfo.rose->condition &= ~ROSE_COND_OWN_RX_BUSY;
88
                                sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;
89
                                sk->protinfo.rose->vl         = sk->protinfo.rose->vr;
90
                                sk->protinfo.rose->timer      = 0;
91
                                rose_write_internal(sk, ROSE_RR);
92
                                break;
93
                        }
94
                        /*
95
                         * Check for frames to transmit.
96
                         */
97
                        rose_kick(sk);
98
                        break;
99
 
100
                default:
101
                        break;
102
        }
103
 
104
        if (sk->protinfo.rose->timer == 0 || --sk->protinfo.rose->timer > 0) {
105
                rose_set_timer(sk);
106
                return;
107
        }
108
 
109
        /*
110
         * Timer has expired, it may have been T1, T2, T3 or HB. We can tell
111
         * by the socket state.
112
         */
113
        switch (sk->protinfo.rose->state) {
114
                case ROSE_STATE_3:      /* HB */
115
                        if (sk->protinfo.rose->condition & ROSE_COND_ACK_PENDING) {
116
                                sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;
117
                                rose_enquiry_response(sk);
118
                        }
119
                        break;
120
 
121
                case ROSE_STATE_1:      /* T1 */
122
                case ROSE_STATE_4:      /* T2 */
123
                        rose_write_internal(sk, ROSE_CLEAR_REQUEST);
124
                        /* F6FBB - Disconnect the calling station
125
                        sk->protinfo.rose->state = ROSE_STATE_2;
126
                        sk->protinfo.rose->timer = sk->protinfo.rose->t3;
127
                        break; */
128
 
129
                        /* Falls to next case */
130
 
131
                case ROSE_STATE_2:      /* T3 */
132
                        /* F6FBB - Added Cause and diagnostic */
133
                        sk->protinfo.rose->cause = ROSE_DTE_ORIGINATED;
134
                        sk->protinfo.rose->diagnostic = 0x30;
135
 
136
                        /* F6FBB - Added Facilities */
137
                        first = rose_dev_first();
138
                        if (first) {
139
                                sk->protinfo.rose->facilities.fail_call = rose_callsign;
140
                                memcpy(&sk->protinfo.rose->facilities.fail_addr, first->dev_addr, ROSE_ADDR_LEN);
141
                        }
142
 
143
                        rose_clear_queues(sk);
144
                        sk->protinfo.rose->neighbour->use--;
145
                        sk->protinfo.rose->state = ROSE_STATE_0;
146
                        sk->state                = TCP_CLOSE;
147
                        sk->err                  = ETIMEDOUT;
148
                        sk->shutdown            |= SEND_SHUTDOWN;
149
                        if (!sk->dead)
150
                                sk->state_change(sk);
151
                        sk->dead                 = 1;
152
                        break;
153
        }
154
 
155
        rose_set_timer(sk);
156
}
157
 
158
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.