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/errno.h>
19 #include <linux/types.h>
20 #include <linux/socket.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>
29 #include <linux/inet.h>
30 #include <linux/netdevice.h>
31 #include <linux/skbuff.h>
33 #include <asm/segment.h>
34 #include <asm/system.h>
35 #include <linux/fcntl.h>
37 #include <linux/interrupt.h>
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.
44 static void rose_send_iframe(struct sock *sk, struct sk_buff *skb)
49 skb->data[2] |= (sk->protinfo.rose->vr << 5) & 0xE0;
50 skb->data[2] |= (sk->protinfo.rose->vs << 1) & 0x0E;
52 rose_start_idletimer(sk);
54 rose_transmit_link(skb, sk->protinfo.rose->neighbour);
57 void rose_kick(struct sock *sk)
59 struct sk_buff *skb, *skbn;
60 unsigned short start, end;
62 if (sk->protinfo.rose->state != ROSE_STATE_3)
65 if (sk->protinfo.rose->condition & ROSE_COND_PEER_RX_BUSY)
68 if (skb_peek(&sk->write_queue) == NULL)
71 start = (skb_peek(&sk->protinfo.rose->ack_queue) == NULL) ? sk->protinfo.rose->va : sk->protinfo.rose->vs;
72 end = (sk->protinfo.rose->va + sysctl_rose_window_size) % ROSE_MODULUS;
77 sk->protinfo.rose->vs = start;
80 * Transmit data until either we're out of data to send or
84 skb = skb_dequeue(&sk->write_queue);
87 if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) {
88 skb_queue_head(&sk->write_queue, skb);
92 skb_set_owner_w(skbn, sk);
95 * Transmit the frame copy.
97 rose_send_iframe(sk, skbn);
99 sk->protinfo.rose->vs = (sk->protinfo.rose->vs + 1) % ROSE_MODULUS;
102 * Requeue the original data frame.
104 skb_queue_tail(&sk->protinfo.rose->ack_queue, skb);
106 } while (sk->protinfo.rose->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL);
108 sk->protinfo.rose->vl = sk->protinfo.rose->vr;
109 sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;
115 * The following routines are taken from page 170 of the 7th ARRL Computer
116 * Networking Conference paper, as is the whole state machine.
119 void rose_enquiry_response(struct sock *sk)
121 if (sk->protinfo.rose->condition & ROSE_COND_OWN_RX_BUSY)
122 rose_write_internal(sk, ROSE_RNR);
124 rose_write_internal(sk, ROSE_RR);
126 sk->protinfo.rose->vl = sk->protinfo.rose->vr;
127 sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;