18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci/* atm.h - general ATM declarations */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/* 88c2ecf20Sopenharmony_ci * WARNING: User-space programs should not #include <linux/atm.h> directly. 98c2ecf20Sopenharmony_ci * Instead, #include <atm.h> 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef _UAPI_LINUX_ATM_H 138c2ecf20Sopenharmony_ci#define _UAPI_LINUX_ATM_H 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* 168c2ecf20Sopenharmony_ci * BEGIN_xx and END_xx markers are used for automatic generation of 178c2ecf20Sopenharmony_ci * documentation. Do not change them. 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include <linux/compiler.h> 218c2ecf20Sopenharmony_ci#include <linux/atmapi.h> 228c2ecf20Sopenharmony_ci#include <linux/atmsap.h> 238c2ecf20Sopenharmony_ci#include <linux/atmioc.h> 248c2ecf20Sopenharmony_ci#include <linux/types.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* general ATM constants */ 288c2ecf20Sopenharmony_ci#define ATM_CELL_SIZE 53 /* ATM cell size incl. header */ 298c2ecf20Sopenharmony_ci#define ATM_CELL_PAYLOAD 48 /* ATM payload size */ 308c2ecf20Sopenharmony_ci#define ATM_AAL0_SDU 52 /* AAL0 SDU size */ 318c2ecf20Sopenharmony_ci#define ATM_MAX_AAL34_PDU 65535 /* maximum AAL3/4 PDU payload */ 328c2ecf20Sopenharmony_ci#define ATM_AAL5_TRAILER 8 /* AAL5 trailer size */ 338c2ecf20Sopenharmony_ci#define ATM_MAX_AAL5_PDU 65535 /* maximum AAL5 PDU payload */ 348c2ecf20Sopenharmony_ci#define ATM_MAX_CDV 9999 /* maximum (default) CDV */ 358c2ecf20Sopenharmony_ci#define ATM_NOT_RSV_VCI 32 /* first non-reserved VCI value */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define ATM_MAX_VPI 255 /* maximum VPI at the UNI */ 388c2ecf20Sopenharmony_ci#define ATM_MAX_VPI_NNI 4096 /* maximum VPI at the NNI */ 398c2ecf20Sopenharmony_ci#define ATM_MAX_VCI 65535 /* maximum VCI */ 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* "protcol" values for the socket system call */ 438c2ecf20Sopenharmony_ci#define ATM_NO_AAL 0 /* AAL not specified */ 448c2ecf20Sopenharmony_ci#define ATM_AAL0 13 /* "raw" ATM cells */ 458c2ecf20Sopenharmony_ci#define ATM_AAL1 1 /* AAL1 (CBR) */ 468c2ecf20Sopenharmony_ci#define ATM_AAL2 2 /* AAL2 (VBR) */ 478c2ecf20Sopenharmony_ci#define ATM_AAL34 3 /* AAL3/4 (data) */ 488c2ecf20Sopenharmony_ci#define ATM_AAL5 5 /* AAL5 (data) */ 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* 518c2ecf20Sopenharmony_ci * socket option name coding functions 528c2ecf20Sopenharmony_ci * 538c2ecf20Sopenharmony_ci * Note that __SO_ENCODE and __SO_LEVEL are somewhat a hack since the 548c2ecf20Sopenharmony_ci * << 22 only reserves 9 bits for the level. On some architectures 558c2ecf20Sopenharmony_ci * SOL_SOCKET is 0xFFFF, so that's a bit of a problem 568c2ecf20Sopenharmony_ci */ 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define __SO_ENCODE(l,n,t) ((((l) & 0x1FF) << 22) | ((n) << 16) | \ 598c2ecf20Sopenharmony_ci sizeof(t)) 608c2ecf20Sopenharmony_ci#define __SO_LEVEL_MATCH(c,m) (((c) >> 22) == ((m) & 0x1FF)) 618c2ecf20Sopenharmony_ci#define __SO_NUMBER(c) (((c) >> 16) & 0x3f) 628c2ecf20Sopenharmony_ci#define __SO_SIZE(c) ((c) & 0x3fff) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* 658c2ecf20Sopenharmony_ci * ATM layer 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define SO_SETCLP __SO_ENCODE(SOL_ATM,0,int) 698c2ecf20Sopenharmony_ci /* set CLP bit value - TODO */ 708c2ecf20Sopenharmony_ci#define SO_CIRANGE __SO_ENCODE(SOL_ATM,1,struct atm_cirange) 718c2ecf20Sopenharmony_ci /* connection identifier range; socket must be 728c2ecf20Sopenharmony_ci bound or connected */ 738c2ecf20Sopenharmony_ci#define SO_ATMQOS __SO_ENCODE(SOL_ATM,2,struct atm_qos) 748c2ecf20Sopenharmony_ci /* Quality of Service setting */ 758c2ecf20Sopenharmony_ci#define SO_ATMSAP __SO_ENCODE(SOL_ATM,3,struct atm_sap) 768c2ecf20Sopenharmony_ci /* Service Access Point */ 778c2ecf20Sopenharmony_ci#define SO_ATMPVC __SO_ENCODE(SOL_ATM,4,struct sockaddr_atmpvc) 788c2ecf20Sopenharmony_ci /* "PVC" address (also for SVCs); get only */ 798c2ecf20Sopenharmony_ci#define SO_MULTIPOINT __SO_ENCODE(SOL_ATM, 5, int) 808c2ecf20Sopenharmony_ci /* make this vc a p2mp */ 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/* 848c2ecf20Sopenharmony_ci * Note @@@: since the socket layers don't really distinguish the control and 858c2ecf20Sopenharmony_ci * the data plane but generally seems to be data plane-centric, any layer is 868c2ecf20Sopenharmony_ci * about equally wrong for the SAP. If you have a better idea about this, 878c2ecf20Sopenharmony_ci * please speak up ... 888c2ecf20Sopenharmony_ci */ 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* ATM cell header (for AAL0) */ 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* BEGIN_CH */ 948c2ecf20Sopenharmony_ci#define ATM_HDR_GFC_MASK 0xf0000000 958c2ecf20Sopenharmony_ci#define ATM_HDR_GFC_SHIFT 28 968c2ecf20Sopenharmony_ci#define ATM_HDR_VPI_MASK 0x0ff00000 978c2ecf20Sopenharmony_ci#define ATM_HDR_VPI_SHIFT 20 988c2ecf20Sopenharmony_ci#define ATM_HDR_VCI_MASK 0x000ffff0 998c2ecf20Sopenharmony_ci#define ATM_HDR_VCI_SHIFT 4 1008c2ecf20Sopenharmony_ci#define ATM_HDR_PTI_MASK 0x0000000e 1018c2ecf20Sopenharmony_ci#define ATM_HDR_PTI_SHIFT 1 1028c2ecf20Sopenharmony_ci#define ATM_HDR_CLP 0x00000001 1038c2ecf20Sopenharmony_ci/* END_CH */ 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/* PTI codings */ 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci/* BEGIN_PTI */ 1098c2ecf20Sopenharmony_ci#define ATM_PTI_US0 0 /* user data cell, congestion not exp, SDU-type 0 */ 1108c2ecf20Sopenharmony_ci#define ATM_PTI_US1 1 /* user data cell, congestion not exp, SDU-type 1 */ 1118c2ecf20Sopenharmony_ci#define ATM_PTI_UCES0 2 /* user data cell, cong. experienced, SDU-type 0 */ 1128c2ecf20Sopenharmony_ci#define ATM_PTI_UCES1 3 /* user data cell, cong. experienced, SDU-type 1 */ 1138c2ecf20Sopenharmony_ci#define ATM_PTI_SEGF5 4 /* segment OAM F5 flow related cell */ 1148c2ecf20Sopenharmony_ci#define ATM_PTI_E2EF5 5 /* end-to-end OAM F5 flow related cell */ 1158c2ecf20Sopenharmony_ci#define ATM_PTI_RSV_RM 6 /* reserved for traffic control/resource mgmt */ 1168c2ecf20Sopenharmony_ci#define ATM_PTI_RSV 7 /* reserved */ 1178c2ecf20Sopenharmony_ci/* END_PTI */ 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci/* 1218c2ecf20Sopenharmony_ci * The following items should stay in linux/atm.h, which should be linked to 1228c2ecf20Sopenharmony_ci * netatm/atm.h 1238c2ecf20Sopenharmony_ci */ 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci/* Traffic description */ 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#define ATM_NONE 0 /* no traffic */ 1288c2ecf20Sopenharmony_ci#define ATM_UBR 1 1298c2ecf20Sopenharmony_ci#define ATM_CBR 2 1308c2ecf20Sopenharmony_ci#define ATM_VBR 3 1318c2ecf20Sopenharmony_ci#define ATM_ABR 4 1328c2ecf20Sopenharmony_ci#define ATM_ANYCLASS 5 /* compatible with everything */ 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define ATM_MAX_PCR -1 /* maximum available PCR */ 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_cistruct atm_trafprm { 1378c2ecf20Sopenharmony_ci unsigned char traffic_class; /* traffic class (ATM_UBR, ...) */ 1388c2ecf20Sopenharmony_ci int max_pcr; /* maximum PCR in cells per second */ 1398c2ecf20Sopenharmony_ci int pcr; /* desired PCR in cells per second */ 1408c2ecf20Sopenharmony_ci int min_pcr; /* minimum PCR in cells per second */ 1418c2ecf20Sopenharmony_ci int max_cdv; /* maximum CDV in microseconds */ 1428c2ecf20Sopenharmony_ci int max_sdu; /* maximum SDU in bytes */ 1438c2ecf20Sopenharmony_ci /* extra params for ABR */ 1448c2ecf20Sopenharmony_ci unsigned int icr; /* Initial Cell Rate (24-bit) */ 1458c2ecf20Sopenharmony_ci unsigned int tbe; /* Transient Buffer Exposure (24-bit) */ 1468c2ecf20Sopenharmony_ci unsigned int frtt : 24; /* Fixed Round Trip Time (24-bit) */ 1478c2ecf20Sopenharmony_ci unsigned int rif : 4; /* Rate Increment Factor (4-bit) */ 1488c2ecf20Sopenharmony_ci unsigned int rdf : 4; /* Rate Decrease Factor (4-bit) */ 1498c2ecf20Sopenharmony_ci unsigned int nrm_pres :1; /* nrm present bit */ 1508c2ecf20Sopenharmony_ci unsigned int trm_pres :1; /* rm present bit */ 1518c2ecf20Sopenharmony_ci unsigned int adtf_pres :1; /* adtf present bit */ 1528c2ecf20Sopenharmony_ci unsigned int cdf_pres :1; /* cdf present bit*/ 1538c2ecf20Sopenharmony_ci unsigned int nrm :3; /* Max # of Cells for each forward RM cell (3-bit) */ 1548c2ecf20Sopenharmony_ci unsigned int trm :3; /* Time between forward RM cells (3-bit) */ 1558c2ecf20Sopenharmony_ci unsigned int adtf :10; /* ACR Decrease Time Factor (10-bit) */ 1568c2ecf20Sopenharmony_ci unsigned int cdf :3; /* Cutoff Decrease Factor (3-bit) */ 1578c2ecf20Sopenharmony_ci unsigned int spare :9; /* spare bits */ 1588c2ecf20Sopenharmony_ci}; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_cistruct atm_qos { 1618c2ecf20Sopenharmony_ci struct atm_trafprm txtp; /* parameters in TX direction */ 1628c2ecf20Sopenharmony_ci struct atm_trafprm rxtp __ATM_API_ALIGN; 1638c2ecf20Sopenharmony_ci /* parameters in RX direction */ 1648c2ecf20Sopenharmony_ci unsigned char aal __ATM_API_ALIGN; 1658c2ecf20Sopenharmony_ci}; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci/* PVC addressing */ 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci#define ATM_ITF_ANY -1 /* "magic" PVC address values */ 1708c2ecf20Sopenharmony_ci#define ATM_VPI_ANY -1 1718c2ecf20Sopenharmony_ci#define ATM_VCI_ANY -1 1728c2ecf20Sopenharmony_ci#define ATM_VPI_UNSPEC -2 1738c2ecf20Sopenharmony_ci#define ATM_VCI_UNSPEC -2 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_cistruct sockaddr_atmpvc { 1778c2ecf20Sopenharmony_ci unsigned short sap_family; /* address family, AF_ATMPVC */ 1788c2ecf20Sopenharmony_ci struct { /* PVC address */ 1798c2ecf20Sopenharmony_ci short itf; /* ATM interface */ 1808c2ecf20Sopenharmony_ci short vpi; /* VPI (only 8 bits at UNI) */ 1818c2ecf20Sopenharmony_ci int vci; /* VCI (only 16 bits at UNI) */ 1828c2ecf20Sopenharmony_ci } sap_addr __ATM_API_ALIGN; /* PVC address */ 1838c2ecf20Sopenharmony_ci}; 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci/* SVC addressing */ 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci#define ATM_ESA_LEN 20 /* ATM End System Address length */ 1888c2ecf20Sopenharmony_ci#define ATM_E164_LEN 12 /* maximum E.164 number length */ 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci#define ATM_AFI_DCC 0x39 /* DCC ATM Format */ 1918c2ecf20Sopenharmony_ci#define ATM_AFI_ICD 0x47 /* ICD ATM Format */ 1928c2ecf20Sopenharmony_ci#define ATM_AFI_E164 0x45 /* E.164 ATM Format */ 1938c2ecf20Sopenharmony_ci#define ATM_AFI_LOCAL 0x49 /* Local ATM Format */ 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci#define ATM_AFI_DCC_GROUP 0xBD /* DCC ATM Group Format */ 1968c2ecf20Sopenharmony_ci#define ATM_AFI_ICD_GROUP 0xC5 /* ICD ATM Group Format */ 1978c2ecf20Sopenharmony_ci#define ATM_AFI_E164_GROUP 0xC3 /* E.164 ATM Group Format */ 1988c2ecf20Sopenharmony_ci#define ATM_AFI_LOCAL_GROUP 0xC7 /* Local ATM Group Format */ 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci#define ATM_LIJ_NONE 0 /* no leaf-initiated join */ 2018c2ecf20Sopenharmony_ci#define ATM_LIJ 1 /* request joining */ 2028c2ecf20Sopenharmony_ci#define ATM_LIJ_RPJ 2 /* set to root-prompted join */ 2038c2ecf20Sopenharmony_ci#define ATM_LIJ_NJ 3 /* set to network join */ 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_cistruct sockaddr_atmsvc { 2078c2ecf20Sopenharmony_ci unsigned short sas_family; /* address family, AF_ATMSVC */ 2088c2ecf20Sopenharmony_ci struct { /* SVC address */ 2098c2ecf20Sopenharmony_ci unsigned char prv[ATM_ESA_LEN];/* private ATM address */ 2108c2ecf20Sopenharmony_ci char pub[ATM_E164_LEN+1]; /* public address (E.164) */ 2118c2ecf20Sopenharmony_ci /* unused addresses must be bzero'ed */ 2128c2ecf20Sopenharmony_ci char lij_type; /* role in LIJ call; one of ATM_LIJ* */ 2138c2ecf20Sopenharmony_ci __u32 lij_id; /* LIJ call identifier */ 2148c2ecf20Sopenharmony_ci } sas_addr __ATM_API_ALIGN; /* SVC address */ 2158c2ecf20Sopenharmony_ci}; 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_cistatic __inline__ int atmsvc_addr_in_use(struct sockaddr_atmsvc addr) 2198c2ecf20Sopenharmony_ci{ 2208c2ecf20Sopenharmony_ci return *addr.sas_addr.prv || *addr.sas_addr.pub; 2218c2ecf20Sopenharmony_ci} 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_cistatic __inline__ int atmpvc_addr_in_use(struct sockaddr_atmpvc addr) 2258c2ecf20Sopenharmony_ci{ 2268c2ecf20Sopenharmony_ci return addr.sap_addr.itf || addr.sap_addr.vpi || addr.sap_addr.vci; 2278c2ecf20Sopenharmony_ci} 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci/* 2318c2ecf20Sopenharmony_ci * Some stuff for linux/sockios.h 2328c2ecf20Sopenharmony_ci */ 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_cistruct atmif_sioc { 2358c2ecf20Sopenharmony_ci int number; 2368c2ecf20Sopenharmony_ci int length; 2378c2ecf20Sopenharmony_ci void __user *arg; 2388c2ecf20Sopenharmony_ci}; 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_citypedef unsigned short atm_backend_t; 2428c2ecf20Sopenharmony_ci#endif /* _UAPI_LINUX_ATM_H */ 243