Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /* atm.h - general ATM declarations */
0003  
0004 /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
0005  
0006 
0007 /*
0008  * WARNING: User-space programs should not #include <linux/atm.h> directly.
0009  *          Instead, #include <atm.h>
0010  */
0011 
0012 #ifndef _UAPI_LINUX_ATM_H
0013 #define _UAPI_LINUX_ATM_H
0014 
0015 /*
0016  * BEGIN_xx and END_xx markers are used for automatic generation of
0017  * documentation. Do not change them.
0018  */
0019 
0020 #include <linux/compiler.h>
0021 #include <linux/atmapi.h>
0022 #include <linux/atmsap.h>
0023 #include <linux/atmioc.h>
0024 #include <linux/types.h>
0025 
0026 
0027 /* general ATM constants */
0028 #define ATM_CELL_SIZE           53  /* ATM cell size incl. header */
0029 #define ATM_CELL_PAYLOAD        48  /* ATM payload size */
0030 #define ATM_AAL0_SDU            52  /* AAL0 SDU size */
0031 #define ATM_MAX_AAL34_PDU    65535  /* maximum AAL3/4 PDU payload */
0032 #define ATM_AAL5_TRAILER         8  /* AAL5 trailer size */
0033 #define ATM_MAX_AAL5_PDU     65535  /* maximum AAL5 PDU payload */
0034 #define ATM_MAX_CDV       9999  /* maximum (default) CDV */
0035 #define ATM_NOT_RSV_VCI         32  /* first non-reserved VCI value */
0036 
0037 #define ATM_MAX_VPI        255  /* maximum VPI at the UNI */
0038 #define ATM_MAX_VPI_NNI       4096  /* maximum VPI at the NNI */
0039 #define ATM_MAX_VCI      65535  /* maximum VCI */
0040 
0041 
0042 /* "protcol" values for the socket system call */
0043 #define ATM_NO_AAL  0       /* AAL not specified */
0044 #define ATM_AAL0    13      /* "raw" ATM cells */
0045 #define ATM_AAL1    1       /* AAL1 (CBR) */
0046 #define ATM_AAL2    2       /* AAL2 (VBR) */
0047 #define ATM_AAL34   3       /* AAL3/4 (data) */
0048 #define ATM_AAL5    5       /* AAL5 (data) */
0049 
0050 /*
0051  * socket option name coding functions
0052  *
0053  * Note that __SO_ENCODE and __SO_LEVEL are somewhat a hack since the
0054  * << 22 only reserves 9 bits for the level.  On some architectures
0055  * SOL_SOCKET is 0xFFFF, so that's a bit of a problem
0056  */
0057 
0058 #define __SO_ENCODE(l,n,t)  ((((l) & 0x1FF) << 22) | ((n) << 16) | \
0059                 sizeof(t))
0060 #define __SO_LEVEL_MATCH(c,m)   (((c) >> 22) == ((m) & 0x1FF))
0061 #define __SO_NUMBER(c)      (((c) >> 16) & 0x3f)
0062 #define __SO_SIZE(c)        ((c) & 0x3fff)
0063 
0064 /*
0065  * ATM layer
0066  */
0067 
0068 #define SO_SETCLP   __SO_ENCODE(SOL_ATM,0,int)
0069                 /* set CLP bit value - TODO */
0070 #define SO_CIRANGE  __SO_ENCODE(SOL_ATM,1,struct atm_cirange)
0071                 /* connection identifier range; socket must be
0072                    bound or connected */
0073 #define SO_ATMQOS   __SO_ENCODE(SOL_ATM,2,struct atm_qos)
0074                 /* Quality of Service setting */
0075 #define SO_ATMSAP   __SO_ENCODE(SOL_ATM,3,struct atm_sap)
0076                 /* Service Access Point */
0077 #define SO_ATMPVC   __SO_ENCODE(SOL_ATM,4,struct sockaddr_atmpvc)
0078                 /* "PVC" address (also for SVCs); get only */
0079 #define SO_MULTIPOINT   __SO_ENCODE(SOL_ATM, 5, int)
0080                 /* make this vc a p2mp */
0081 
0082 
0083 /*
0084  * Note @@@: since the socket layers don't really distinguish the control and
0085  * the data plane but generally seems to be data plane-centric, any layer is
0086  * about equally wrong for the SAP. If you have a better idea about this,
0087  * please speak up ...
0088  */
0089 
0090 
0091 /* ATM cell header (for AAL0) */
0092 
0093 /* BEGIN_CH */
0094 #define ATM_HDR_GFC_MASK    0xf0000000
0095 #define ATM_HDR_GFC_SHIFT   28
0096 #define ATM_HDR_VPI_MASK    0x0ff00000
0097 #define ATM_HDR_VPI_SHIFT   20
0098 #define ATM_HDR_VCI_MASK    0x000ffff0
0099 #define ATM_HDR_VCI_SHIFT   4
0100 #define ATM_HDR_PTI_MASK    0x0000000e
0101 #define ATM_HDR_PTI_SHIFT   1
0102 #define ATM_HDR_CLP     0x00000001
0103 /* END_CH */
0104 
0105 
0106 /* PTI codings */
0107 
0108 /* BEGIN_PTI */
0109 #define ATM_PTI_US0 0  /* user data cell, congestion not exp, SDU-type 0 */
0110 #define ATM_PTI_US1 1  /* user data cell, congestion not exp, SDU-type 1 */
0111 #define ATM_PTI_UCES0   2  /* user data cell, cong. experienced, SDU-type 0 */
0112 #define ATM_PTI_UCES1   3  /* user data cell, cong. experienced, SDU-type 1 */
0113 #define ATM_PTI_SEGF5   4  /* segment OAM F5 flow related cell */
0114 #define ATM_PTI_E2EF5   5  /* end-to-end OAM F5 flow related cell */
0115 #define ATM_PTI_RSV_RM  6  /* reserved for traffic control/resource mgmt */
0116 #define ATM_PTI_RSV 7  /* reserved */
0117 /* END_PTI */
0118 
0119 
0120 /*
0121  * The following items should stay in linux/atm.h, which should be linked to
0122  * netatm/atm.h
0123  */
0124 
0125 /* Traffic description */
0126 
0127 #define ATM_NONE    0       /* no traffic */
0128 #define ATM_UBR     1
0129 #define ATM_CBR     2
0130 #define ATM_VBR     3
0131 #define ATM_ABR     4
0132 #define ATM_ANYCLASS    5       /* compatible with everything */
0133 
0134 #define ATM_MAX_PCR -1      /* maximum available PCR */
0135 
0136 struct atm_trafprm {
0137     unsigned char   traffic_class;  /* traffic class (ATM_UBR, ...) */
0138     int     max_pcr;    /* maximum PCR in cells per second */
0139     int     pcr;        /* desired PCR in cells per second */
0140     int     min_pcr;    /* minimum PCR in cells per second */
0141     int     max_cdv;    /* maximum CDV in microseconds */
0142     int     max_sdu;    /* maximum SDU in bytes */
0143         /* extra params for ABR */
0144         unsigned int    icr;            /* Initial Cell Rate (24-bit) */
0145         unsigned int    tbe;        /* Transient Buffer Exposure (24-bit) */ 
0146         unsigned int    frtt : 24;  /* Fixed Round Trip Time (24-bit) */
0147         unsigned int    rif  : 4;       /* Rate Increment Factor (4-bit) */
0148         unsigned int    rdf  : 4;       /* Rate Decrease Factor (4-bit) */
0149         unsigned int nrm_pres  :1;      /* nrm present bit */
0150         unsigned int trm_pres  :1;      /* rm present bit */
0151         unsigned int adtf_pres :1;      /* adtf present bit */
0152         unsigned int cdf_pres  :1;      /* cdf present bit*/
0153         unsigned int nrm       :3;      /* Max # of Cells for each forward RM cell (3-bit) */
0154         unsigned int trm       :3;      /* Time between forward RM cells (3-bit) */    
0155     unsigned int adtf      :10;     /* ACR Decrease Time Factor (10-bit) */
0156     unsigned int cdf       :3;      /* Cutoff Decrease Factor (3-bit) */
0157         unsigned int spare     :9;      /* spare bits */ 
0158 };
0159 
0160 struct atm_qos {
0161     struct atm_trafprm txtp;    /* parameters in TX direction */
0162     struct atm_trafprm rxtp __ATM_API_ALIGN;
0163                     /* parameters in RX direction */
0164     unsigned char aal __ATM_API_ALIGN;
0165 };
0166 
0167 /* PVC addressing */
0168 
0169 #define ATM_ITF_ANY -1      /* "magic" PVC address values */
0170 #define ATM_VPI_ANY -1
0171 #define ATM_VCI_ANY -1
0172 #define ATM_VPI_UNSPEC  -2
0173 #define ATM_VCI_UNSPEC  -2
0174 
0175 
0176 struct sockaddr_atmpvc {
0177     unsigned short  sap_family; /* address family, AF_ATMPVC  */
0178     struct {            /* PVC address */
0179         short   itf;        /* ATM interface */
0180         short   vpi;        /* VPI (only 8 bits at UNI) */
0181         int vci;        /* VCI (only 16 bits at UNI) */
0182     } sap_addr __ATM_API_ALIGN; /* PVC address */
0183 };
0184 
0185 /* SVC addressing */
0186 
0187 #define ATM_ESA_LEN 20      /* ATM End System Address length */
0188 #define ATM_E164_LEN    12      /* maximum E.164 number length */
0189 
0190 #define ATM_AFI_DCC 0x39        /* DCC ATM Format */
0191 #define ATM_AFI_ICD 0x47        /* ICD ATM Format */
0192 #define ATM_AFI_E164    0x45        /* E.164 ATM Format */
0193 #define ATM_AFI_LOCAL   0x49        /* Local ATM Format */ 
0194 
0195 #define ATM_AFI_DCC_GROUP   0xBD    /* DCC ATM Group Format */
0196 #define ATM_AFI_ICD_GROUP   0xC5    /* ICD ATM Group Format */
0197 #define ATM_AFI_E164_GROUP  0xC3    /* E.164 ATM Group Format */
0198 #define ATM_AFI_LOCAL_GROUP 0xC7    /* Local ATM Group Format */
0199 
0200 #define ATM_LIJ_NONE    0       /* no leaf-initiated join */
0201 #define ATM_LIJ     1       /* request joining */
0202 #define ATM_LIJ_RPJ 2       /* set to root-prompted join */
0203 #define ATM_LIJ_NJ  3       /* set to network join */
0204 
0205 
0206 struct sockaddr_atmsvc {
0207     unsigned short  sas_family; /* address family, AF_ATMSVC */
0208     struct {                /* SVC address */
0209         unsigned char   prv[ATM_ESA_LEN];/* private ATM address */
0210         char        pub[ATM_E164_LEN+1]; /* public address (E.164) */
0211                         /* unused addresses must be bzero'ed */
0212     char        lij_type;   /* role in LIJ call; one of ATM_LIJ* */
0213     __u32   lij_id;     /* LIJ call identifier */
0214     } sas_addr __ATM_API_ALIGN;     /* SVC address */
0215 };
0216 
0217 
0218 static __inline__ int atmsvc_addr_in_use(struct sockaddr_atmsvc addr)
0219 {
0220     return *addr.sas_addr.prv || *addr.sas_addr.pub;
0221 }
0222 
0223 
0224 static __inline__ int atmpvc_addr_in_use(struct sockaddr_atmpvc addr)
0225 {
0226     return addr.sap_addr.itf || addr.sap_addr.vpi || addr.sap_addr.vci;
0227 }
0228 
0229 
0230 /*
0231  * Some stuff for linux/sockios.h
0232  */
0233 
0234 struct atmif_sioc {
0235     int number;
0236     int length;
0237     void __user *arg;
0238 };
0239 
0240 
0241 typedef unsigned short atm_backend_t;
0242 #endif /* _UAPI_LINUX_ATM_H */