xref: /linux/include/uapi/linux/atm.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*6f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells /* atm.h - general ATM declarations */
3607ca46eSDavid Howells 
4607ca46eSDavid Howells /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
5607ca46eSDavid Howells 
6607ca46eSDavid Howells 
7607ca46eSDavid Howells /*
8607ca46eSDavid Howells  * WARNING: User-space programs should not #include <linux/atm.h> directly.
9607ca46eSDavid Howells  *          Instead, #include <atm.h>
10607ca46eSDavid Howells  */
11607ca46eSDavid Howells 
12607ca46eSDavid Howells #ifndef _UAPI_LINUX_ATM_H
13607ca46eSDavid Howells #define _UAPI_LINUX_ATM_H
14607ca46eSDavid Howells 
15607ca46eSDavid Howells /*
16607ca46eSDavid Howells  * BEGIN_xx and END_xx markers are used for automatic generation of
17607ca46eSDavid Howells  * documentation. Do not change them.
18607ca46eSDavid Howells  */
19607ca46eSDavid Howells 
20607ca46eSDavid Howells #include <linux/compiler.h>
21607ca46eSDavid Howells #include <linux/atmapi.h>
22607ca46eSDavid Howells #include <linux/atmsap.h>
23607ca46eSDavid Howells #include <linux/atmioc.h>
24607ca46eSDavid Howells #include <linux/types.h>
25607ca46eSDavid Howells 
26607ca46eSDavid Howells 
27607ca46eSDavid Howells /* general ATM constants */
28607ca46eSDavid Howells #define ATM_CELL_SIZE		    53	/* ATM cell size incl. header */
29607ca46eSDavid Howells #define ATM_CELL_PAYLOAD	    48	/* ATM payload size */
30607ca46eSDavid Howells #define ATM_AAL0_SDU		    52	/* AAL0 SDU size */
31607ca46eSDavid Howells #define ATM_MAX_AAL34_PDU	 65535	/* maximum AAL3/4 PDU payload */
32607ca46eSDavid Howells #define ATM_AAL5_TRAILER	     8	/* AAL5 trailer size */
33607ca46eSDavid Howells #define ATM_MAX_AAL5_PDU	 65535	/* maximum AAL5 PDU payload */
34607ca46eSDavid Howells #define ATM_MAX_CDV		  9999	/* maximum (default) CDV */
35607ca46eSDavid Howells #define ATM_NOT_RSV_VCI		    32	/* first non-reserved VCI value */
36607ca46eSDavid Howells 
37607ca46eSDavid Howells #define ATM_MAX_VPI		   255	/* maximum VPI at the UNI */
38607ca46eSDavid Howells #define ATM_MAX_VPI_NNI		  4096	/* maximum VPI at the NNI */
39607ca46eSDavid Howells #define ATM_MAX_VCI		 65535	/* maximum VCI */
40607ca46eSDavid Howells 
41607ca46eSDavid Howells 
42607ca46eSDavid Howells /* "protcol" values for the socket system call */
43607ca46eSDavid Howells #define ATM_NO_AAL	0		/* AAL not specified */
44607ca46eSDavid Howells #define ATM_AAL0	13		/* "raw" ATM cells */
45607ca46eSDavid Howells #define ATM_AAL1	1		/* AAL1 (CBR) */
46607ca46eSDavid Howells #define ATM_AAL2	2		/* AAL2 (VBR) */
47607ca46eSDavid Howells #define ATM_AAL34	3		/* AAL3/4 (data) */
48607ca46eSDavid Howells #define ATM_AAL5	5		/* AAL5 (data) */
49607ca46eSDavid Howells 
50607ca46eSDavid Howells /*
51607ca46eSDavid Howells  * socket option name coding functions
52607ca46eSDavid Howells  *
53607ca46eSDavid Howells  * Note that __SO_ENCODE and __SO_LEVEL are somewhat a hack since the
54607ca46eSDavid Howells  * << 22 only reserves 9 bits for the level.  On some architectures
55607ca46eSDavid Howells  * SOL_SOCKET is 0xFFFF, so that's a bit of a problem
56607ca46eSDavid Howells  */
57607ca46eSDavid Howells 
58607ca46eSDavid Howells #define __SO_ENCODE(l,n,t)	((((l) & 0x1FF) << 22) | ((n) << 16) | \
59607ca46eSDavid Howells 				sizeof(t))
60607ca46eSDavid Howells #define __SO_LEVEL_MATCH(c,m)	(((c) >> 22) == ((m) & 0x1FF))
61607ca46eSDavid Howells #define __SO_NUMBER(c)		(((c) >> 16) & 0x3f)
62607ca46eSDavid Howells #define __SO_SIZE(c)		((c) & 0x3fff)
63607ca46eSDavid Howells 
64607ca46eSDavid Howells /*
65607ca46eSDavid Howells  * ATM layer
66607ca46eSDavid Howells  */
67607ca46eSDavid Howells 
68607ca46eSDavid Howells #define SO_SETCLP	__SO_ENCODE(SOL_ATM,0,int)
69607ca46eSDavid Howells 			    /* set CLP bit value - TODO */
70607ca46eSDavid Howells #define SO_CIRANGE	__SO_ENCODE(SOL_ATM,1,struct atm_cirange)
71607ca46eSDavid Howells 			    /* connection identifier range; socket must be
72607ca46eSDavid Howells 			       bound or connected */
73607ca46eSDavid Howells #define SO_ATMQOS	__SO_ENCODE(SOL_ATM,2,struct atm_qos)
74607ca46eSDavid Howells 			    /* Quality of Service setting */
75607ca46eSDavid Howells #define SO_ATMSAP	__SO_ENCODE(SOL_ATM,3,struct atm_sap)
76607ca46eSDavid Howells 			    /* Service Access Point */
77607ca46eSDavid Howells #define SO_ATMPVC	__SO_ENCODE(SOL_ATM,4,struct sockaddr_atmpvc)
78607ca46eSDavid Howells 			    /* "PVC" address (also for SVCs); get only */
79607ca46eSDavid Howells #define SO_MULTIPOINT	__SO_ENCODE(SOL_ATM, 5, int)
80607ca46eSDavid Howells 			    /* make this vc a p2mp */
81607ca46eSDavid Howells 
82607ca46eSDavid Howells 
83607ca46eSDavid Howells /*
84607ca46eSDavid Howells  * Note @@@: since the socket layers don't really distinguish the control and
85607ca46eSDavid Howells  * the data plane but generally seems to be data plane-centric, any layer is
86607ca46eSDavid Howells  * about equally wrong for the SAP. If you have a better idea about this,
87607ca46eSDavid Howells  * please speak up ...
88607ca46eSDavid Howells  */
89607ca46eSDavid Howells 
90607ca46eSDavid Howells 
91607ca46eSDavid Howells /* ATM cell header (for AAL0) */
92607ca46eSDavid Howells 
93607ca46eSDavid Howells /* BEGIN_CH */
94607ca46eSDavid Howells #define ATM_HDR_GFC_MASK	0xf0000000
95607ca46eSDavid Howells #define ATM_HDR_GFC_SHIFT	28
96607ca46eSDavid Howells #define ATM_HDR_VPI_MASK	0x0ff00000
97607ca46eSDavid Howells #define ATM_HDR_VPI_SHIFT	20
98607ca46eSDavid Howells #define ATM_HDR_VCI_MASK	0x000ffff0
99607ca46eSDavid Howells #define ATM_HDR_VCI_SHIFT	4
100607ca46eSDavid Howells #define ATM_HDR_PTI_MASK	0x0000000e
101607ca46eSDavid Howells #define ATM_HDR_PTI_SHIFT	1
102607ca46eSDavid Howells #define ATM_HDR_CLP		0x00000001
103607ca46eSDavid Howells /* END_CH */
104607ca46eSDavid Howells 
105607ca46eSDavid Howells 
106607ca46eSDavid Howells /* PTI codings */
107607ca46eSDavid Howells 
108607ca46eSDavid Howells /* BEGIN_PTI */
109607ca46eSDavid Howells #define ATM_PTI_US0	0  /* user data cell, congestion not exp, SDU-type 0 */
110607ca46eSDavid Howells #define ATM_PTI_US1	1  /* user data cell, congestion not exp, SDU-type 1 */
111607ca46eSDavid Howells #define ATM_PTI_UCES0	2  /* user data cell, cong. experienced, SDU-type 0 */
112607ca46eSDavid Howells #define ATM_PTI_UCES1	3  /* user data cell, cong. experienced, SDU-type 1 */
113607ca46eSDavid Howells #define ATM_PTI_SEGF5	4  /* segment OAM F5 flow related cell */
114607ca46eSDavid Howells #define ATM_PTI_E2EF5	5  /* end-to-end OAM F5 flow related cell */
115607ca46eSDavid Howells #define ATM_PTI_RSV_RM	6  /* reserved for traffic control/resource mgmt */
116607ca46eSDavid Howells #define ATM_PTI_RSV	7  /* reserved */
117607ca46eSDavid Howells /* END_PTI */
118607ca46eSDavid Howells 
119607ca46eSDavid Howells 
120607ca46eSDavid Howells /*
121607ca46eSDavid Howells  * The following items should stay in linux/atm.h, which should be linked to
122607ca46eSDavid Howells  * netatm/atm.h
123607ca46eSDavid Howells  */
124607ca46eSDavid Howells 
125607ca46eSDavid Howells /* Traffic description */
126607ca46eSDavid Howells 
127607ca46eSDavid Howells #define ATM_NONE	0		/* no traffic */
128607ca46eSDavid Howells #define ATM_UBR		1
129607ca46eSDavid Howells #define ATM_CBR		2
130607ca46eSDavid Howells #define ATM_VBR		3
131607ca46eSDavid Howells #define ATM_ABR		4
132607ca46eSDavid Howells #define ATM_ANYCLASS	5		/* compatible with everything */
133607ca46eSDavid Howells 
134607ca46eSDavid Howells #define ATM_MAX_PCR	-1		/* maximum available PCR */
135607ca46eSDavid Howells 
136607ca46eSDavid Howells struct atm_trafprm {
137607ca46eSDavid Howells 	unsigned char	traffic_class;	/* traffic class (ATM_UBR, ...) */
138607ca46eSDavid Howells 	int		max_pcr;	/* maximum PCR in cells per second */
139607ca46eSDavid Howells 	int		pcr;		/* desired PCR in cells per second */
140607ca46eSDavid Howells 	int		min_pcr;	/* minimum PCR in cells per second */
141607ca46eSDavid Howells 	int		max_cdv;	/* maximum CDV in microseconds */
142607ca46eSDavid Howells 	int		max_sdu;	/* maximum SDU in bytes */
143607ca46eSDavid Howells         /* extra params for ABR */
144607ca46eSDavid Howells         unsigned int 	icr;         	/* Initial Cell Rate (24-bit) */
145607ca46eSDavid Howells         unsigned int	tbe;		/* Transient Buffer Exposure (24-bit) */
146607ca46eSDavid Howells         unsigned int 	frtt : 24;	/* Fixed Round Trip Time (24-bit) */
147607ca46eSDavid Howells         unsigned int 	rif  : 4;       /* Rate Increment Factor (4-bit) */
148607ca46eSDavid Howells         unsigned int 	rdf  : 4;       /* Rate Decrease Factor (4-bit) */
149607ca46eSDavid Howells         unsigned int nrm_pres  :1;      /* nrm present bit */
150607ca46eSDavid Howells         unsigned int trm_pres  :1;     	/* rm present bit */
151607ca46eSDavid Howells         unsigned int adtf_pres :1;     	/* adtf present bit */
152607ca46eSDavid Howells         unsigned int cdf_pres  :1;    	/* cdf present bit*/
153607ca46eSDavid Howells         unsigned int nrm       :3;     	/* Max # of Cells for each forward RM cell (3-bit) */
154607ca46eSDavid Howells         unsigned int trm       :3;    	/* Time between forward RM cells (3-bit) */
155607ca46eSDavid Howells 	unsigned int adtf      :10;     /* ACR Decrease Time Factor (10-bit) */
156607ca46eSDavid Howells 	unsigned int cdf       :3;      /* Cutoff Decrease Factor (3-bit) */
157607ca46eSDavid Howells         unsigned int spare     :9;      /* spare bits */
158607ca46eSDavid Howells };
159607ca46eSDavid Howells 
160607ca46eSDavid Howells struct atm_qos {
161607ca46eSDavid Howells 	struct atm_trafprm txtp;	/* parameters in TX direction */
162607ca46eSDavid Howells 	struct atm_trafprm rxtp __ATM_API_ALIGN;
163607ca46eSDavid Howells 					/* parameters in RX direction */
164607ca46eSDavid Howells 	unsigned char aal __ATM_API_ALIGN;
165607ca46eSDavid Howells };
166607ca46eSDavid Howells 
167607ca46eSDavid Howells /* PVC addressing */
168607ca46eSDavid Howells 
169607ca46eSDavid Howells #define ATM_ITF_ANY	-1		/* "magic" PVC address values */
170607ca46eSDavid Howells #define ATM_VPI_ANY	-1
171607ca46eSDavid Howells #define ATM_VCI_ANY	-1
172607ca46eSDavid Howells #define ATM_VPI_UNSPEC	-2
173607ca46eSDavid Howells #define ATM_VCI_UNSPEC	-2
174607ca46eSDavid Howells 
175607ca46eSDavid Howells 
176607ca46eSDavid Howells struct sockaddr_atmpvc {
177607ca46eSDavid Howells 	unsigned short 	sap_family;	/* address family, AF_ATMPVC  */
178607ca46eSDavid Howells 	struct {			/* PVC address */
179607ca46eSDavid Howells 		short	itf;		/* ATM interface */
180607ca46eSDavid Howells 		short	vpi;		/* VPI (only 8 bits at UNI) */
181607ca46eSDavid Howells 		int	vci;		/* VCI (only 16 bits at UNI) */
182607ca46eSDavid Howells 	} sap_addr __ATM_API_ALIGN;	/* PVC address */
183607ca46eSDavid Howells };
184607ca46eSDavid Howells 
185607ca46eSDavid Howells /* SVC addressing */
186607ca46eSDavid Howells 
187607ca46eSDavid Howells #define	ATM_ESA_LEN	20		/* ATM End System Address length */
188607ca46eSDavid Howells #define ATM_E164_LEN	12		/* maximum E.164 number length */
189607ca46eSDavid Howells 
190607ca46eSDavid Howells #define ATM_AFI_DCC	0x39		/* DCC ATM Format */
191607ca46eSDavid Howells #define ATM_AFI_ICD	0x47		/* ICD ATM Format */
192607ca46eSDavid Howells #define ATM_AFI_E164	0x45		/* E.164 ATM Format */
193607ca46eSDavid Howells #define ATM_AFI_LOCAL	0x49		/* Local ATM Format */
194607ca46eSDavid Howells 
195607ca46eSDavid Howells #define ATM_AFI_DCC_GROUP	0xBD	/* DCC ATM Group Format */
196607ca46eSDavid Howells #define ATM_AFI_ICD_GROUP	0xC5	/* ICD ATM Group Format */
197607ca46eSDavid Howells #define ATM_AFI_E164_GROUP	0xC3	/* E.164 ATM Group Format */
198607ca46eSDavid Howells #define ATM_AFI_LOCAL_GROUP	0xC7	/* Local ATM Group Format */
199607ca46eSDavid Howells 
200607ca46eSDavid Howells #define ATM_LIJ_NONE	0		/* no leaf-initiated join */
201607ca46eSDavid Howells #define ATM_LIJ		1		/* request joining */
202607ca46eSDavid Howells #define ATM_LIJ_RPJ	2		/* set to root-prompted join */
203607ca46eSDavid Howells #define ATM_LIJ_NJ	3		/* set to network join */
204607ca46eSDavid Howells 
205607ca46eSDavid Howells 
206607ca46eSDavid Howells struct sockaddr_atmsvc {
207607ca46eSDavid Howells     unsigned short 	sas_family;	/* address family, AF_ATMSVC */
208607ca46eSDavid Howells     struct {				/* SVC address */
209607ca46eSDavid Howells         unsigned char	prv[ATM_ESA_LEN];/* private ATM address */
210607ca46eSDavid Howells         char		pub[ATM_E164_LEN+1]; /* public address (E.164) */
211607ca46eSDavid Howells     					/* unused addresses must be bzero'ed */
212607ca46eSDavid Howells 	char		lij_type;	/* role in LIJ call; one of ATM_LIJ* */
213607ca46eSDavid Howells 	__u32	lij_id;		/* LIJ call identifier */
214607ca46eSDavid Howells     } sas_addr __ATM_API_ALIGN;		/* SVC address */
215607ca46eSDavid Howells };
216607ca46eSDavid Howells 
217607ca46eSDavid Howells 
atmsvc_addr_in_use(struct sockaddr_atmsvc addr)218607ca46eSDavid Howells static __inline__ int atmsvc_addr_in_use(struct sockaddr_atmsvc addr)
219607ca46eSDavid Howells {
220607ca46eSDavid Howells 	return *addr.sas_addr.prv || *addr.sas_addr.pub;
221607ca46eSDavid Howells }
222607ca46eSDavid Howells 
223607ca46eSDavid Howells 
atmpvc_addr_in_use(struct sockaddr_atmpvc addr)224607ca46eSDavid Howells static __inline__ int atmpvc_addr_in_use(struct sockaddr_atmpvc addr)
225607ca46eSDavid Howells {
226607ca46eSDavid Howells 	return addr.sap_addr.itf || addr.sap_addr.vpi || addr.sap_addr.vci;
227607ca46eSDavid Howells }
228607ca46eSDavid Howells 
229607ca46eSDavid Howells 
230607ca46eSDavid Howells /*
231607ca46eSDavid Howells  * Some stuff for linux/sockios.h
232607ca46eSDavid Howells  */
233607ca46eSDavid Howells 
234607ca46eSDavid Howells struct atmif_sioc {
235607ca46eSDavid Howells 	int number;
236607ca46eSDavid Howells 	int length;
237607ca46eSDavid Howells 	void __user *arg;
238607ca46eSDavid Howells };
239607ca46eSDavid Howells 
240607ca46eSDavid Howells 
241607ca46eSDavid Howells typedef unsigned short atm_backend_t;
242607ca46eSDavid Howells #endif /* _UAPI_LINUX_ATM_H */
243