Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _NET_DN_NSP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _NET_DN_NSP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)     (c) 1995-1998 E.M. Serrat		emserrat@geocities.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)     
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) *******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) /* dn_nsp.c functions prototyping */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) void dn_nsp_send_data_ack(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) void dn_nsp_send_oth_ack(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) void dn_send_conn_ack(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) void dn_send_conn_conf(struct sock *sk, gfp_t gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) void dn_nsp_send_disc(struct sock *sk, unsigned char type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 		      unsigned short reason, gfp_t gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) void dn_nsp_return_disc(struct sk_buff *skb, unsigned char type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 			unsigned short reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) void dn_nsp_send_conninit(struct sock *sk, unsigned char flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) void dn_nsp_output(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 			    struct sk_buff_head *q, unsigned short acknum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, gfp_t gfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		       int oob);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) unsigned long dn_nsp_persist(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) int dn_nsp_xmit_timeout(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) int dn_nsp_rx(struct sk_buff *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 				  long timeo, int *err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define NSP_REASON_OK 0		/* No error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define NSP_REASON_NR 1		/* No resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define NSP_REASON_UN 2		/* Unrecognised node name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define NSP_REASON_SD 3		/* Node shutting down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define NSP_REASON_ID 4		/* Invalid destination end user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define NSP_REASON_ER 5		/* End user lacks resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define NSP_REASON_OB 6		/* Object too busy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define NSP_REASON_US 7		/* Unspecified error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define NSP_REASON_TP 8		/* Third-Party abort */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define NSP_REASON_EA 9		/* End user has aborted the link */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define NSP_REASON_IF 10	/* Invalid node name format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define NSP_REASON_LS 11	/* Local node shutdown */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define NSP_REASON_LL 32	/* Node lacks logical-link resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define NSP_REASON_LE 33	/* End user lacks logical-link resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define NSP_REASON_UR 34	/* Unacceptable RQSTRID or PASSWORD field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define NSP_REASON_UA 36	/* Unacceptable ACCOUNT field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define NSP_REASON_TM 38	/* End user timed out logical link */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define NSP_REASON_NU 39	/* Node unreachable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define NSP_REASON_NL 41	/* No-link message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define NSP_REASON_DC 42	/* Disconnect confirm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define NSP_REASON_IO 43	/* Image data field overflow */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define NSP_DISCINIT 0x38
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define NSP_DISCCONF 0x48
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) /*------------------------- NSP - messages ------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /* Data Messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) /*---------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) /* Data Messages    (data segment/interrupt/link service)               */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) struct nsp_data_seg_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	__u8   msgflg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	__le16 dstaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	__le16 srcaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) struct nsp_data_opt_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	__le16 acknum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	__le16 segnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	__le16 lsflgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) struct nsp_data_opt_msg1 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	__le16 acknum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	__le16 segnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) /* Acknowledgment Message (data/other data)                             */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) struct nsp_data_ack_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	__u8   msgflg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	__le16 dstaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	__le16 srcaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	__le16 acknum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) /* Connect Acknowledgment Message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) struct  nsp_conn_ack_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	__u8 msgflg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	__le16 dstaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /* Connect Initiate/Retransmit Initiate/Connect Confirm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct  nsp_conn_init_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	__u8   msgflg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define NSP_CI      0x18            /* Connect Initiate     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define NSP_RCI     0x68            /* Retrans. Conn Init   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	__le16 dstaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	__le16 srcaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	__u8   services;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define NSP_FC_NONE   0x00            /* Flow Control None    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define NSP_FC_SRC    0x04            /* Seg Req. Count       */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define NSP_FC_SCMC   0x08            /* Sess. Control Mess   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define NSP_FC_MASK   0x0c            /* FC type mask         */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	__u8   info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	__le16 segsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /* Disconnect Initiate/Disconnect Confirm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct  nsp_disconn_init_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	__u8   msgflg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	__le16 dstaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	__le16 srcaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	__le16 reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct  srcobj_fmt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	__u8   format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	__u8   task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	__le16 grpcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	__le16 usrcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	__u8   dlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  * A collection of functions for manipulating the sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  * numbers used in NSP. Similar in operation to the functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  * of the same name in TCP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static __inline__ int dn_before(__u16 seq1, __u16 seq2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)         seq1 &= 0x0fff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)         seq2 &= 0x0fff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)         return (int)((seq1 - seq2) & 0x0fff) > 2048;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static __inline__ int dn_after(__u16 seq1, __u16 seq2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)         seq1 &= 0x0fff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)         seq2 &= 0x0fff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)         return (int)((seq2 - seq1) & 0x0fff) > 2048;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) static __inline__ int dn_equal(__u16 seq1, __u16 seq2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)         return ((seq1 ^ seq2) & 0x0fff) == 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static __inline__ int dn_before_or_equal(__u16 seq1, __u16 seq2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	return (dn_before(seq1, seq2) || dn_equal(seq1, seq2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static __inline__ void seq_add(__u16 *seq, __u16 off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)         (*seq) += off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)         (*seq) &= 0x0fff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static __inline__ int seq_next(__u16 seq1, __u16 seq2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	return dn_equal(seq1 + 1, seq2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  * Can we delay the ack ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) static __inline__ int sendack(__u16 seq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)         return (int)((seq & 0x1000) ? 0 : 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * Is socket congested ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) static __inline__ int dn_congested(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)         return atomic_read(&sk->sk_rmem_alloc) > (sk->sk_rcvbuf >> 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) #define DN_MAX_NSP_DATA_HEADER (11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #endif /* _NET_DN_NSP_H */