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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [net/] [rose/] [rose_out.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_out.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
/*
41
 *      This procedure is passed a buffer descriptor for an iframe. It builds
42
 *      the rest of the control part of the frame and then writes it out.
43
 */
44
static void rose_send_iframe(struct sock *sk, struct sk_buff *skb)
45
{
46
        if (skb == NULL)
47
                return;
48
 
49
        skb->data[2] |= (sk->protinfo.rose->vr << 5) & 0xE0;
50
        skb->data[2] |= (sk->protinfo.rose->vs << 1) & 0x0E;
51
 
52
        rose_transmit_link(skb, sk->protinfo.rose->neighbour);
53
}
54
 
55
void rose_kick(struct sock *sk)
56
{
57
        struct sk_buff *skb, *skbn;
58
        unsigned short start, end;
59
 
60
        if (sk->protinfo.rose->state != ROSE_STATE_3)
61
                return;
62
 
63
        if (sk->protinfo.rose->condition & ROSE_COND_PEER_RX_BUSY)
64
                return;
65
 
66
        if (skb_peek(&sk->write_queue) == NULL)
67
                return;
68
 
69
        start = (skb_peek(&sk->protinfo.rose->ack_queue) == NULL) ? sk->protinfo.rose->va : sk->protinfo.rose->vs;
70
        end   = (sk->protinfo.rose->va + sysctl_rose_window_size) % ROSE_MODULUS;
71
 
72
        if (start == end)
73
                return;
74
 
75
        sk->protinfo.rose->vs = start;
76
 
77
        /*
78
         * Transmit data until either we're out of data to send or
79
         * the window is full.
80
         */
81
 
82
        skb  = skb_dequeue(&sk->write_queue);
83
 
84
        do {
85
                if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) {
86
                        skb_queue_head(&sk->write_queue, skb);
87
                        break;
88
                }
89
 
90
                /*
91
                 * Transmit the frame copy.
92
                 */
93
                rose_send_iframe(sk, skbn);
94
 
95
                sk->protinfo.rose->vs = (sk->protinfo.rose->vs + 1) % ROSE_MODULUS;
96
 
97
                /*
98
                 * Requeue the original data frame.
99
                 */
100
                skb_queue_tail(&sk->protinfo.rose->ack_queue, skb);
101
 
102
        } while (sk->protinfo.rose->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL);
103
 
104
        sk->protinfo.rose->vl         = sk->protinfo.rose->vr;
105
        sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;
106
        sk->protinfo.rose->timer      = 0;
107
}
108
 
109
/*
110
 * The following routines are taken from page 170 of the 7th ARRL Computer
111
 * Networking Conference paper, as is the whole state machine.
112
 */
113
 
114
void rose_enquiry_response(struct sock *sk)
115
{
116
        if (sk->protinfo.rose->condition & ROSE_COND_OWN_RX_BUSY)
117
                rose_write_internal(sk, ROSE_RNR);
118
        else
119
                rose_write_internal(sk, ROSE_RR);
120
 
121
        sk->protinfo.rose->vl         = sk->protinfo.rose->vr;
122
        sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;
123
        sk->protinfo.rose->timer      = 0;
124
}
125
 
126
#endif

powered by: WebSVN 2.1.0

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