4 * This code REQUIRES 2.1.15 or higher/ NET3.038
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.
13 * ROSE 001 Jonathan(G4KLX) Cloned from nr_out.c
14 * ROSE 003 Jonathan(G4KLX) New timer architecture.
15 * Removed M bit processing.
18 #include <linux/config.h>
19 #if defined(CONFIG_ROSE) || defined(CONFIG_ROSE_MODULE)
20 #include <linux/errno.h>
21 #include <linux/types.h>
22 #include <linux/socket.h>
24 #include <linux/kernel.h>
25 #include <linux/sched.h>
26 #include <linux/timer.h>
27 #include <linux/string.h>
28 #include <linux/sockios.h>
29 #include <linux/net.h>
31 #include <linux/inet.h>
32 #include <linux/netdevice.h>
33 #include <linux/skbuff.h>
35 #include <asm/segment.h>
36 #include <asm/system.h>
37 #include <linux/fcntl.h>
39 #include <linux/interrupt.h>
43 * This procedure is passed a buffer descriptor for an iframe. It builds
44 * the rest of the control part of the frame and then writes it out.
46 static void rose_send_iframe(struct sock
*sk
, struct sk_buff
*skb
)
51 skb
->data
[2] |= (sk
->protinfo
.rose
->vr
<< 5) & 0xE0;
52 skb
->data
[2] |= (sk
->protinfo
.rose
->vs
<< 1) & 0x0E;
54 rose_start_idletimer(sk
);
56 rose_transmit_link(skb
, sk
->protinfo
.rose
->neighbour
);
59 void rose_kick(struct sock
*sk
)
61 struct sk_buff
*skb
, *skbn
;
62 unsigned short start
, end
;
64 if (sk
->protinfo
.rose
->state
!= ROSE_STATE_3
)
67 if (sk
->protinfo
.rose
->condition
& ROSE_COND_PEER_RX_BUSY
)
70 if (skb_peek(&sk
->write_queue
) == NULL
)
73 start
= (skb_peek(&sk
->protinfo
.rose
->ack_queue
) == NULL
) ? sk
->protinfo
.rose
->va
: sk
->protinfo
.rose
->vs
;
74 end
= (sk
->protinfo
.rose
->va
+ sysctl_rose_window_size
) % ROSE_MODULUS
;
79 sk
->protinfo
.rose
->vs
= start
;
82 * Transmit data until either we're out of data to send or
86 skb
= skb_dequeue(&sk
->write_queue
);
89 if ((skbn
= skb_clone(skb
, GFP_ATOMIC
)) == NULL
) {
90 skb_queue_head(&sk
->write_queue
, skb
);
94 skb_set_owner_w(skbn
, sk
);
97 * Transmit the frame copy.
99 rose_send_iframe(sk
, skbn
);
101 sk
->protinfo
.rose
->vs
= (sk
->protinfo
.rose
->vs
+ 1) % ROSE_MODULUS
;
104 * Requeue the original data frame.
106 skb_queue_tail(&sk
->protinfo
.rose
->ack_queue
, skb
);
108 } while (sk
->protinfo
.rose
->vs
!= end
&& (skb
= skb_dequeue(&sk
->write_queue
)) != NULL
);
110 sk
->protinfo
.rose
->vl
= sk
->protinfo
.rose
->vr
;
111 sk
->protinfo
.rose
->condition
&= ~ROSE_COND_ACK_PENDING
;
117 * The following routines are taken from page 170 of the 7th ARRL Computer
118 * Networking Conference paper, as is the whole state machine.
121 void rose_enquiry_response(struct sock
*sk
)
123 if (sk
->protinfo
.rose
->condition
& ROSE_COND_OWN_RX_BUSY
)
124 rose_write_internal(sk
, ROSE_RNR
);
126 rose_write_internal(sk
, ROSE_RR
);
128 sk
->protinfo
.rose
->vl
= sk
->protinfo
.rose
->vr
;
129 sk
->protinfo
.rose
->condition
&= ~ROSE_COND_ACK_PENDING
;