atm.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /* atm.h - general ATM declarations */
  3. /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
  4. /*
  5. * WARNING: User-space programs should not #include <linux/atm.h> directly.
  6. * Instead, #include <atm.h>
  7. */
  8. #ifndef _UAPI_LINUX_ATM_H
  9. #define _UAPI_LINUX_ATM_H
  10. /*
  11. * BEGIN_xx and END_xx markers are used for automatic generation of
  12. * documentation. Do not change them.
  13. */
  14. #include <linux/compiler.h>
  15. #include <linux/atmapi.h>
  16. #include <linux/atmsap.h>
  17. #include <linux/atmioc.h>
  18. #include <linux/types.h>
  19. /* general ATM constants */
  20. #define ATM_CELL_SIZE 53 /* ATM cell size incl. header */
  21. #define ATM_CELL_PAYLOAD 48 /* ATM payload size */
  22. #define ATM_AAL0_SDU 52 /* AAL0 SDU size */
  23. #define ATM_MAX_AAL34_PDU 65535 /* maximum AAL3/4 PDU payload */
  24. #define ATM_AAL5_TRAILER 8 /* AAL5 trailer size */
  25. #define ATM_MAX_AAL5_PDU 65535 /* maximum AAL5 PDU payload */
  26. #define ATM_MAX_CDV 9999 /* maximum (default) CDV */
  27. #define ATM_NOT_RSV_VCI 32 /* first non-reserved VCI value */
  28. #define ATM_MAX_VPI 255 /* maximum VPI at the UNI */
  29. #define ATM_MAX_VPI_NNI 4096 /* maximum VPI at the NNI */
  30. #define ATM_MAX_VCI 65535 /* maximum VCI */
  31. /* "protcol" values for the socket system call */
  32. #define ATM_NO_AAL 0 /* AAL not specified */
  33. #define ATM_AAL0 13 /* "raw" ATM cells */
  34. #define ATM_AAL1 1 /* AAL1 (CBR) */
  35. #define ATM_AAL2 2 /* AAL2 (VBR) */
  36. #define ATM_AAL34 3 /* AAL3/4 (data) */
  37. #define ATM_AAL5 5 /* AAL5 (data) */
  38. /*
  39. * socket option name coding functions
  40. *
  41. * Note that __SO_ENCODE and __SO_LEVEL are somewhat a hack since the
  42. * << 22 only reserves 9 bits for the level. On some architectures
  43. * SOL_SOCKET is 0xFFFF, so that's a bit of a problem
  44. */
  45. #define __SO_ENCODE(l,n,t) ((((l) & 0x1FF) << 22) | ((n) << 16) | \
  46. sizeof(t))
  47. #define __SO_LEVEL_MATCH(c,m) (((c) >> 22) == ((m) & 0x1FF))
  48. #define __SO_NUMBER(c) (((c) >> 16) & 0x3f)
  49. #define __SO_SIZE(c) ((c) & 0x3fff)
  50. /*
  51. * ATM layer
  52. */
  53. #define SO_SETCLP __SO_ENCODE(SOL_ATM,0,int)
  54. /* set CLP bit value - TODO */
  55. #define SO_CIRANGE __SO_ENCODE(SOL_ATM,1,struct atm_cirange)
  56. /* connection identifier range; socket must be
  57. bound or connected */
  58. #define SO_ATMQOS __SO_ENCODE(SOL_ATM,2,struct atm_qos)
  59. /* Quality of Service setting */
  60. #define SO_ATMSAP __SO_ENCODE(SOL_ATM,3,struct atm_sap)
  61. /* Service Access Point */
  62. #define SO_ATMPVC __SO_ENCODE(SOL_ATM,4,struct sockaddr_atmpvc)
  63. /* "PVC" address (also for SVCs); get only */
  64. #define SO_MULTIPOINT __SO_ENCODE(SOL_ATM, 5, int)
  65. /* make this vc a p2mp */
  66. /*
  67. * Note @@@: since the socket layers don't really distinguish the control and
  68. * the data plane but generally seems to be data plane-centric, any layer is
  69. * about equally wrong for the SAP. If you have a better idea about this,
  70. * please speak up ...
  71. */
  72. /* ATM cell header (for AAL0) */
  73. /* BEGIN_CH */
  74. #define ATM_HDR_GFC_MASK 0xf0000000
  75. #define ATM_HDR_GFC_SHIFT 28
  76. #define ATM_HDR_VPI_MASK 0x0ff00000
  77. #define ATM_HDR_VPI_SHIFT 20
  78. #define ATM_HDR_VCI_MASK 0x000ffff0
  79. #define ATM_HDR_VCI_SHIFT 4
  80. #define ATM_HDR_PTI_MASK 0x0000000e
  81. #define ATM_HDR_PTI_SHIFT 1
  82. #define ATM_HDR_CLP 0x00000001
  83. /* END_CH */
  84. /* PTI codings */
  85. /* BEGIN_PTI */
  86. #define ATM_PTI_US0 0 /* user data cell, congestion not exp, SDU-type 0 */
  87. #define ATM_PTI_US1 1 /* user data cell, congestion not exp, SDU-type 1 */
  88. #define ATM_PTI_UCES0 2 /* user data cell, cong. experienced, SDU-type 0 */
  89. #define ATM_PTI_UCES1 3 /* user data cell, cong. experienced, SDU-type 1 */
  90. #define ATM_PTI_SEGF5 4 /* segment OAM F5 flow related cell */
  91. #define ATM_PTI_E2EF5 5 /* end-to-end OAM F5 flow related cell */
  92. #define ATM_PTI_RSV_RM 6 /* reserved for traffic control/resource mgmt */
  93. #define ATM_PTI_RSV 7 /* reserved */
  94. /* END_PTI */
  95. /*
  96. * The following items should stay in linux/atm.h, which should be linked to
  97. * netatm/atm.h
  98. */
  99. /* Traffic description */
  100. #define ATM_NONE 0 /* no traffic */
  101. #define ATM_UBR 1
  102. #define ATM_CBR 2
  103. #define ATM_VBR 3
  104. #define ATM_ABR 4
  105. #define ATM_ANYCLASS 5 /* compatible with everything */
  106. #define ATM_MAX_PCR -1 /* maximum available PCR */
  107. struct atm_trafprm {
  108. unsigned char traffic_class; /* traffic class (ATM_UBR, ...) */
  109. int max_pcr; /* maximum PCR in cells per second */
  110. int pcr; /* desired PCR in cells per second */
  111. int min_pcr; /* minimum PCR in cells per second */
  112. int max_cdv; /* maximum CDV in microseconds */
  113. int max_sdu; /* maximum SDU in bytes */
  114. /* extra params for ABR */
  115. unsigned int icr; /* Initial Cell Rate (24-bit) */
  116. unsigned int tbe; /* Transient Buffer Exposure (24-bit) */
  117. unsigned int frtt : 24; /* Fixed Round Trip Time (24-bit) */
  118. unsigned int rif : 4; /* Rate Increment Factor (4-bit) */
  119. unsigned int rdf : 4; /* Rate Decrease Factor (4-bit) */
  120. unsigned int nrm_pres :1; /* nrm present bit */
  121. unsigned int trm_pres :1; /* rm present bit */
  122. unsigned int adtf_pres :1; /* adtf present bit */
  123. unsigned int cdf_pres :1; /* cdf present bit*/
  124. unsigned int nrm :3; /* Max # of Cells for each forward RM cell (3-bit) */
  125. unsigned int trm :3; /* Time between forward RM cells (3-bit) */
  126. unsigned int adtf :10; /* ACR Decrease Time Factor (10-bit) */
  127. unsigned int cdf :3; /* Cutoff Decrease Factor (3-bit) */
  128. unsigned int spare :9; /* spare bits */
  129. };
  130. struct atm_qos {
  131. struct atm_trafprm txtp; /* parameters in TX direction */
  132. struct atm_trafprm rxtp __ATM_API_ALIGN;
  133. /* parameters in RX direction */
  134. unsigned char aal __ATM_API_ALIGN;
  135. };
  136. /* PVC addressing */
  137. #define ATM_ITF_ANY -1 /* "magic" PVC address values */
  138. #define ATM_VPI_ANY -1
  139. #define ATM_VCI_ANY -1
  140. #define ATM_VPI_UNSPEC -2
  141. #define ATM_VCI_UNSPEC -2
  142. struct sockaddr_atmpvc {
  143. unsigned short sap_family; /* address family, AF_ATMPVC */
  144. struct { /* PVC address */
  145. short itf; /* ATM interface */
  146. short vpi; /* VPI (only 8 bits at UNI) */
  147. int vci; /* VCI (only 16 bits at UNI) */
  148. } sap_addr __ATM_API_ALIGN; /* PVC address */
  149. };
  150. /* SVC addressing */
  151. #define ATM_ESA_LEN 20 /* ATM End System Address length */
  152. #define ATM_E164_LEN 12 /* maximum E.164 number length */
  153. #define ATM_AFI_DCC 0x39 /* DCC ATM Format */
  154. #define ATM_AFI_ICD 0x47 /* ICD ATM Format */
  155. #define ATM_AFI_E164 0x45 /* E.164 ATM Format */
  156. #define ATM_AFI_LOCAL 0x49 /* Local ATM Format */
  157. #define ATM_AFI_DCC_GROUP 0xBD /* DCC ATM Group Format */
  158. #define ATM_AFI_ICD_GROUP 0xC5 /* ICD ATM Group Format */
  159. #define ATM_AFI_E164_GROUP 0xC3 /* E.164 ATM Group Format */
  160. #define ATM_AFI_LOCAL_GROUP 0xC7 /* Local ATM Group Format */
  161. #define ATM_LIJ_NONE 0 /* no leaf-initiated join */
  162. #define ATM_LIJ 1 /* request joining */
  163. #define ATM_LIJ_RPJ 2 /* set to root-prompted join */
  164. #define ATM_LIJ_NJ 3 /* set to network join */
  165. struct sockaddr_atmsvc {
  166. unsigned short sas_family; /* address family, AF_ATMSVC */
  167. struct { /* SVC address */
  168. unsigned char prv[ATM_ESA_LEN];/* private ATM address */
  169. char pub[ATM_E164_LEN+1]; /* public address (E.164) */
  170. /* unused addresses must be bzero'ed */
  171. char lij_type; /* role in LIJ call; one of ATM_LIJ* */
  172. __u32 lij_id; /* LIJ call identifier */
  173. } sas_addr __ATM_API_ALIGN; /* SVC address */
  174. };
  175. static __inline__ int atmsvc_addr_in_use(struct sockaddr_atmsvc addr)
  176. {
  177. return *addr.sas_addr.prv || *addr.sas_addr.pub;
  178. }
  179. static __inline__ int atmpvc_addr_in_use(struct sockaddr_atmpvc addr)
  180. {
  181. return addr.sap_addr.itf || addr.sap_addr.vpi || addr.sap_addr.vci;
  182. }
  183. /*
  184. * Some stuff for linux/sockios.h
  185. */
  186. struct atmif_sioc {
  187. int number;
  188. int length;
  189. void __user *arg;
  190. };
  191. typedef unsigned short atm_backend_t;
  192. #endif /* _UAPI_LINUX_ATM_H */