1 // SPDX-License-Identifier: GPL-2.0-or-later << 2 /* 1 /* >> 2 * ROSE release 003 3 * 3 * 4 * Copyright (C) Jonathan Naylor G4KLX (g4klx@ !! 4 * This code REQUIRES 2.1.15 or higher/ NET3.038 >> 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 * ROSE 003 Jonathan(G4KLX) New timer architecture. >> 15 * Removed M bit processing. 5 */ 16 */ >> 17 6 #include <linux/errno.h> 18 #include <linux/errno.h> 7 #include <linux/types.h> 19 #include <linux/types.h> 8 #include <linux/socket.h> 20 #include <linux/socket.h> 9 #include <linux/in.h> 21 #include <linux/in.h> 10 #include <linux/kernel.h> 22 #include <linux/kernel.h> >> 23 #include <linux/sched.h> 11 #include <linux/timer.h> 24 #include <linux/timer.h> 12 #include <linux/string.h> 25 #include <linux/string.h> 13 #include <linux/sockios.h> 26 #include <linux/sockios.h> 14 #include <linux/net.h> 27 #include <linux/net.h> 15 #include <linux/gfp.h> << 16 #include <net/ax25.h> 28 #include <net/ax25.h> 17 #include <linux/inet.h> 29 #include <linux/inet.h> 18 #include <linux/netdevice.h> 30 #include <linux/netdevice.h> 19 #include <linux/skbuff.h> 31 #include <linux/skbuff.h> 20 #include <net/sock.h> 32 #include <net/sock.h> >> 33 #include <asm/segment.h> >> 34 #include <asm/system.h> 21 #include <linux/fcntl.h> 35 #include <linux/fcntl.h> 22 #include <linux/mm.h> 36 #include <linux/mm.h> 23 #include <linux/interrupt.h> 37 #include <linux/interrupt.h> 24 #include <net/rose.h> 38 #include <net/rose.h> 25 39 26 /* !! 40 /* 27 * This procedure is passed a buffer desc 41 * This procedure is passed a buffer descriptor for an iframe. It builds 28 * the rest of the control part of the fr 42 * the rest of the control part of the frame and then writes it out. 29 */ 43 */ 30 static void rose_send_iframe(struct sock *sk, 44 static void rose_send_iframe(struct sock *sk, struct sk_buff *skb) 31 { 45 { 32 struct rose_sock *rose = rose_sk(sk); << 33 << 34 if (skb == NULL) 46 if (skb == NULL) 35 return; 47 return; 36 48 37 skb->data[2] |= (rose->vr << 5) & 0xE0 !! 49 skb->data[2] |= (sk->protinfo.rose->vr << 5) & 0xE0; 38 skb->data[2] |= (rose->vs << 1) & 0x0E !! 50 skb->data[2] |= (sk->protinfo.rose->vs << 1) & 0x0E; 39 51 40 rose_start_idletimer(sk); 52 rose_start_idletimer(sk); 41 53 42 rose_transmit_link(skb, rose->neighbou !! 54 rose_transmit_link(skb, sk->protinfo.rose->neighbour); 43 } 55 } 44 56 45 void rose_kick(struct sock *sk) 57 void rose_kick(struct sock *sk) 46 { 58 { 47 struct rose_sock *rose = rose_sk(sk); << 48 struct sk_buff *skb, *skbn; 59 struct sk_buff *skb, *skbn; 49 unsigned short start, end; 60 unsigned short start, end; 50 61 51 if (rose->state != ROSE_STATE_3) !! 62 if (sk->protinfo.rose->state != ROSE_STATE_3) 52 return; 63 return; 53 64 54 if (rose->condition & ROSE_COND_PEER_R !! 65 if (sk->protinfo.rose->condition & ROSE_COND_PEER_RX_BUSY) 55 return; 66 return; 56 67 57 if (!skb_peek(&sk->sk_write_queue)) !! 68 if (skb_peek(&sk->write_queue) == NULL) 58 return; 69 return; 59 70 60 start = (skb_peek(&rose->ack_queue) == !! 71 start = (skb_peek(&sk->protinfo.rose->ack_queue) == NULL) ? sk->protinfo.rose->va : sk->protinfo.rose->vs; 61 end = (rose->va + sysctl_rose_window !! 72 end = (sk->protinfo.rose->va + sysctl_rose_window_size) % ROSE_MODULUS; 62 73 63 if (start == end) 74 if (start == end) 64 return; 75 return; 65 76 66 rose->vs = start; !! 77 sk->protinfo.rose->vs = start; 67 78 68 /* 79 /* 69 * Transmit data until either we're ou 80 * Transmit data until either we're out of data to send or 70 * the window is full. 81 * the window is full. 71 */ 82 */ 72 83 73 skb = skb_dequeue(&sk->sk_write_queue !! 84 skb = skb_dequeue(&sk->write_queue); 74 85 75 do { 86 do { 76 if ((skbn = skb_clone(skb, GFP 87 if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) { 77 skb_queue_head(&sk->sk !! 88 skb_queue_head(&sk->write_queue, skb); 78 break; 89 break; 79 } 90 } 80 91 81 skb_set_owner_w(skbn, sk); 92 skb_set_owner_w(skbn, sk); 82 93 83 /* 94 /* 84 * Transmit the frame copy. 95 * Transmit the frame copy. 85 */ 96 */ 86 rose_send_iframe(sk, skbn); 97 rose_send_iframe(sk, skbn); 87 98 88 rose->vs = (rose->vs + 1) % RO !! 99 sk->protinfo.rose->vs = (sk->protinfo.rose->vs + 1) % ROSE_MODULUS; 89 100 90 /* 101 /* 91 * Requeue the original data f 102 * Requeue the original data frame. 92 */ 103 */ 93 skb_queue_tail(&rose->ack_queu !! 104 skb_queue_tail(&sk->protinfo.rose->ack_queue, skb); 94 105 95 } while (rose->vs != end && !! 106 } while (sk->protinfo.rose->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL); 96 (skb = skb_dequeue(&sk->sk_wr << 97 107 98 rose->vl = rose->vr; !! 108 sk->protinfo.rose->vl = sk->protinfo.rose->vr; 99 rose->condition &= ~ROSE_COND_ACK_PEND !! 109 sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING; 100 110 101 rose_stop_timer(sk); 111 rose_stop_timer(sk); 102 } 112 } 103 113 104 /* 114 /* 105 * The following routines are taken from page 115 * The following routines are taken from page 170 of the 7th ARRL Computer 106 * Networking Conference paper, as is the whol 116 * Networking Conference paper, as is the whole state machine. 107 */ 117 */ 108 118 109 void rose_enquiry_response(struct sock *sk) 119 void rose_enquiry_response(struct sock *sk) 110 { 120 { 111 struct rose_sock *rose = rose_sk(sk); !! 121 if (sk->protinfo.rose->condition & ROSE_COND_OWN_RX_BUSY) 112 << 113 if (rose->condition & ROSE_COND_OWN_RX << 114 rose_write_internal(sk, ROSE_R 122 rose_write_internal(sk, ROSE_RNR); 115 else 123 else 116 rose_write_internal(sk, ROSE_R 124 rose_write_internal(sk, ROSE_RR); 117 125 118 rose->vl = rose->vr; !! 126 sk->protinfo.rose->vl = sk->protinfo.rose->vr; 119 rose->condition &= ~ROSE_COND_ACK_PEND !! 127 sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING; 120 128 121 rose_stop_timer(sk); 129 rose_stop_timer(sk); 122 } 130 } 123 131
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.