blob: 56ab0726c641a01e31db29c71b6f4b14e6ce20db [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _NET_DN_H
3#define _NET_DN_H
4
5#include <linux/dn.h>
6#include <net/sock.h>
David S. Miller4c5e40362012-02-15 16:37:44 -05007#include <net/flow.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <asm/byteorder.h>
Harvey Harrison475ad8e2008-11-27 23:04:13 -08009#include <asm/unaligned.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11struct dn_scp /* Session Control Port */
12{
13 unsigned char state;
14#define DN_O 1 /* Open */
15#define DN_CR 2 /* Connect Receive */
16#define DN_DR 3 /* Disconnect Reject */
17#define DN_DRC 4 /* Discon. Rej. Complete*/
18#define DN_CC 5 /* Connect Confirm */
19#define DN_CI 6 /* Connect Initiate */
20#define DN_NR 7 /* No resources */
21#define DN_NC 8 /* No communication */
22#define DN_CD 9 /* Connect Delivery */
23#define DN_RJ 10 /* Rejected */
24#define DN_RUN 11 /* Running */
25#define DN_DI 12 /* Disconnect Initiate */
26#define DN_DIC 13 /* Disconnect Complete */
27#define DN_DN 14 /* Disconnect Notificat */
28#define DN_CL 15 /* Closed */
29#define DN_CN 16 /* Closed Notification */
30
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080031 __le16 addrloc;
32 __le16 addrrem;
33 __u16 numdat;
34 __u16 numoth;
35 __u16 numoth_rcv;
36 __u16 numdat_rcv;
37 __u16 ackxmt_dat;
38 __u16 ackxmt_oth;
39 __u16 ackrcv_dat;
40 __u16 ackrcv_oth;
41 __u8 flowrem_sw;
42 __u8 flowloc_sw;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#define DN_SEND 2
44#define DN_DONTSEND 1
45#define DN_NOCHANGE 0
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080046 __u16 flowrem_dat;
47 __u16 flowrem_oth;
48 __u16 flowloc_dat;
49 __u16 flowloc_oth;
50 __u8 services_rem;
51 __u8 services_loc;
52 __u8 info_rem;
53 __u8 info_loc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080055 __u16 segsize_rem;
56 __u16 segsize_loc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080058 __u8 nonagle;
59 __u8 multi_ireq;
60 __u8 accept_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 unsigned long seg_total; /* Running total of current segment */
62
63 struct optdata_dn conndata_in;
64 struct optdata_dn conndata_out;
65 struct optdata_dn discdata_in;
66 struct optdata_dn discdata_out;
67 struct accessdata_dn accessdata;
68
69 struct sockaddr_dn addr; /* Local address */
70 struct sockaddr_dn peer; /* Remote address */
71
72 /*
73 * In this case the RTT estimation is not specified in the
74 * docs, nor is any back off algorithm. Here we follow well
75 * known tcp algorithms with a few small variations.
76 *
77 * snd_window: Max number of packets we send before we wait for
78 * an ack to come back. This will become part of a
79 * more complicated scheme when we support flow
80 * control.
81 *
82 * nsp_srtt: Round-Trip-Time (x8) in jiffies. This is a rolling
83 * average.
84 * nsp_rttvar: Round-Trip-Time-Varience (x4) in jiffies. This is the
85 * varience of the smoothed average (but calculated in
86 * a simpler way than for normal statistical varience
87 * calculations).
88 *
89 * nsp_rxtshift: Backoff counter. Value is zero normally, each time
90 * a packet is lost is increases by one until an ack
91 * is received. Its used to index an array of backoff
92 * multipliers.
93 */
94#define NSP_MIN_WINDOW 1
95#define NSP_MAX_WINDOW (0x07fe)
96 unsigned long max_window;
97 unsigned long snd_window;
98#define NSP_INITIAL_SRTT (HZ)
99 unsigned long nsp_srtt;
100#define NSP_INITIAL_RTTVAR (HZ*3)
101 unsigned long nsp_rttvar;
102#define NSP_MAXRXTSHIFT 12
103 unsigned long nsp_rxtshift;
104
105 /*
106 * Output queues, one for data, one for otherdata/linkservice
107 */
108 struct sk_buff_head data_xmit_queue;
109 struct sk_buff_head other_xmit_queue;
110
111 /*
112 * Input queue for other data
113 */
114 struct sk_buff_head other_receive_queue;
115 int other_report;
116
117 /*
118 * Stuff to do with the slow timer
119 */
120 unsigned long stamp; /* time of last transmit */
121 unsigned long persist;
122 int (*persist_fxn)(struct sock *sk);
123 unsigned long keepalive;
124 void (*keepalive_fxn)(struct sock *sk);
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126};
127
128static inline struct dn_scp *DN_SK(struct sock *sk)
129{
130 return (struct dn_scp *)(sk + 1);
131}
132
133/*
134 * src,dst : Source and Destination DECnet addresses
135 * hops : Number of hops through the network
136 * dst_port, src_port : NSP port numbers
137 * services, info : Useful data extracted from conninit messages
138 * rt_flags : Routing flags byte
139 * nsp_flags : NSP layer flags byte
140 * segsize : Size of segment
141 * segnum : Number, for data, otherdata and linkservice
142 * xmit_count : Number of times we've transmitted this skb
143 * stamp : Time stamp of most recent transmission, used in RTT calculations
144 * iif: Input interface number
145 *
146 * As a general policy, this structure keeps all addresses in network
147 * byte order, and all else in host byte order. Thus dst, src, dst_port
148 * and src_port are in network order. All else is in host order.
149 *
150 */
151#define DN_SKB_CB(skb) ((struct dn_skb_cb *)(skb)->cb)
152struct dn_skb_cb {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800153 __le16 dst;
154 __le16 src;
155 __u16 hops;
156 __le16 dst_port;
157 __le16 src_port;
158 __u8 services;
159 __u8 info;
160 __u8 rt_flags;
161 __u8 nsp_flags;
162 __u16 segsize;
163 __u16 segnum;
164 __u16 xmit_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 unsigned long stamp;
166 int iif;
167};
168
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800169static inline __le16 dn_eth2dn(unsigned char *ethaddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170{
Harvey Harrisonc4106aa2008-11-27 00:12:47 -0800171 return get_unaligned((__le16 *)(ethaddr + 4));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172}
173
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800174static inline __le16 dn_saddr2dn(struct sockaddr_dn *saddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175{
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800176 return *(__le16 *)saddr->sdn_nodeaddr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177}
178
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800179static inline void dn_dn2eth(unsigned char *ethaddr, __le16 addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180{
Harvey Harrisonc4106aa2008-11-27 00:12:47 -0800181 __u16 a = le16_to_cpu(addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 ethaddr[0] = 0xAA;
183 ethaddr[1] = 0x00;
184 ethaddr[2] = 0x04;
185 ethaddr[3] = 0x00;
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800186 ethaddr[4] = (__u8)(a & 0xff);
187 ethaddr[5] = (__u8)(a >> 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188}
189
David S. Millerbef55ae2011-03-12 17:17:10 -0500190static inline void dn_sk_ports_copy(struct flowidn *fld, struct dn_scp *scp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191{
David S. Millerbef55ae2011-03-12 17:17:10 -0500192 fld->fld_sport = scp->addrloc;
193 fld->fld_dport = scp->addrrem;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194}
195
Joe Perches59ddd962013-09-20 11:23:20 -0700196unsigned int dn_mss_from_pmtu(struct net_device *dev, int mtu);
Rashika Kheriaab3301bd2014-02-09 22:22:53 +0530197void dn_register_sysctl(void);
198void dn_unregister_sysctl(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
200#define DN_MENUVER_ACC 0x01
201#define DN_MENUVER_USR 0x02
202#define DN_MENUVER_PRX 0x04
203#define DN_MENUVER_UIC 0x08
204
Joe Perches59ddd962013-09-20 11:23:20 -0700205struct sock *dn_sklist_find_listener(struct sockaddr_dn *addr);
206struct sock *dn_find_by_skb(struct sk_buff *skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207#define DN_ASCBUF_LEN 9
Joe Perches59ddd962013-09-20 11:23:20 -0700208char *dn_addr2asc(__u16, char *);
209int dn_destroy_timer(struct sock *sk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
Joe Perches59ddd962013-09-20 11:23:20 -0700211int dn_sockaddr2username(struct sockaddr_dn *addr, unsigned char *buf,
212 unsigned char type);
213int dn_username2sockaddr(unsigned char *data, int len, struct sockaddr_dn *addr,
214 unsigned char *type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
Joe Perches59ddd962013-09-20 11:23:20 -0700216void dn_start_slow_timer(struct sock *sk);
217void dn_stop_slow_timer(struct sock *sk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800219extern __le16 decnet_address;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220extern int decnet_debug_level;
221extern int decnet_time_wait;
222extern int decnet_dn_count;
223extern int decnet_di_count;
224extern int decnet_dr_count;
225extern int decnet_no_fc_max_cwnd;
226
Eric Dumazet8d987e52010-11-09 23:24:26 +0000227extern long sysctl_decnet_mem[3];
Steven Whitehouse1f12bcc2005-12-05 13:42:06 -0800228extern int sysctl_decnet_wmem[3];
229extern int sysctl_decnet_rmem[3];
230
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231#endif /* _NET_DN_H */