| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* atmdev.h - ATM device driver declarations and various related items */ | 
|  | 2 |  | 
|  | 3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ | 
|  | 4 |  | 
|  | 5 |  | 
|  | 6 | #ifndef LINUX_ATMDEV_H | 
|  | 7 | #define LINUX_ATMDEV_H | 
|  | 8 |  | 
|  | 9 |  | 
|  | 10 | #include <linux/config.h> | 
|  | 11 | #include <linux/atmapi.h> | 
|  | 12 | #include <linux/atm.h> | 
|  | 13 | #include <linux/atmioc.h> | 
|  | 14 |  | 
|  | 15 |  | 
|  | 16 | #define ESI_LEN		6 | 
|  | 17 |  | 
|  | 18 | #define ATM_OC3_PCR	(155520000/270*260/8/53) | 
|  | 19 | /* OC3 link rate:  155520000 bps | 
|  | 20 | SONET overhead: /270*260 (9 section, 1 path) | 
|  | 21 | bits per cell:  /8/53 | 
|  | 22 | max cell rate:  353207.547 cells/sec */ | 
|  | 23 | #define ATM_25_PCR	((25600000/8-8000)/54) | 
|  | 24 | /* 25 Mbps ATM cell rate (59111) */ | 
|  | 25 | #define ATM_OC12_PCR	(622080000/1080*1040/8/53) | 
|  | 26 | /* OC12 link rate: 622080000 bps | 
|  | 27 | SONET overhead: /1080*1040 | 
|  | 28 | bits per cell:  /8/53 | 
|  | 29 | max cell rate:  1412830.188 cells/sec */ | 
|  | 30 | #define ATM_DS3_PCR	(8000*12) | 
|  | 31 | /* DS3: 12 cells in a 125 usec time slot */ | 
|  | 32 |  | 
|  | 33 |  | 
|  | 34 | #define __AAL_STAT_ITEMS \ | 
|  | 35 | __HANDLE_ITEM(tx);			/* TX okay */ \ | 
|  | 36 | __HANDLE_ITEM(tx_err);		/* TX errors */ \ | 
|  | 37 | __HANDLE_ITEM(rx);			/* RX okay */ \ | 
|  | 38 | __HANDLE_ITEM(rx_err);		/* RX errors */ \ | 
|  | 39 | __HANDLE_ITEM(rx_drop);		/* RX out of memory */ | 
|  | 40 |  | 
|  | 41 | struct atm_aal_stats { | 
|  | 42 | #define __HANDLE_ITEM(i) int i | 
|  | 43 | __AAL_STAT_ITEMS | 
|  | 44 | #undef __HANDLE_ITEM | 
|  | 45 | }; | 
|  | 46 |  | 
|  | 47 |  | 
|  | 48 | struct atm_dev_stats { | 
|  | 49 | struct atm_aal_stats aal0; | 
|  | 50 | struct atm_aal_stats aal34; | 
|  | 51 | struct atm_aal_stats aal5; | 
|  | 52 | } __ATM_API_ALIGN; | 
|  | 53 |  | 
|  | 54 |  | 
|  | 55 | #define ATM_GETLINKRATE	_IOW('a',ATMIOC_ITF+1,struct atmif_sioc) | 
|  | 56 | /* get link rate */ | 
|  | 57 | #define ATM_GETNAMES	_IOW('a',ATMIOC_ITF+3,struct atm_iobuf) | 
|  | 58 | /* get interface names (numbers) */ | 
|  | 59 | #define ATM_GETTYPE	_IOW('a',ATMIOC_ITF+4,struct atmif_sioc) | 
|  | 60 | /* get interface type name */ | 
|  | 61 | #define ATM_GETESI	_IOW('a',ATMIOC_ITF+5,struct atmif_sioc) | 
|  | 62 | /* get interface ESI */ | 
|  | 63 | #define ATM_GETADDR	_IOW('a',ATMIOC_ITF+6,struct atmif_sioc) | 
|  | 64 | /* get itf's local ATM addr. list */ | 
|  | 65 | #define ATM_RSTADDR	_IOW('a',ATMIOC_ITF+7,struct atmif_sioc) | 
|  | 66 | /* reset itf's ATM address list */ | 
|  | 67 | #define ATM_ADDADDR	_IOW('a',ATMIOC_ITF+8,struct atmif_sioc) | 
|  | 68 | /* add a local ATM address */ | 
|  | 69 | #define ATM_DELADDR	_IOW('a',ATMIOC_ITF+9,struct atmif_sioc) | 
|  | 70 | /* remove a local ATM address */ | 
|  | 71 | #define ATM_GETCIRANGE	_IOW('a',ATMIOC_ITF+10,struct atmif_sioc) | 
|  | 72 | /* get connection identifier range */ | 
|  | 73 | #define ATM_SETCIRANGE	_IOW('a',ATMIOC_ITF+11,struct atmif_sioc) | 
|  | 74 | /* set connection identifier range */ | 
|  | 75 | #define ATM_SETESI	_IOW('a',ATMIOC_ITF+12,struct atmif_sioc) | 
|  | 76 | /* set interface ESI */ | 
|  | 77 | #define ATM_SETESIF	_IOW('a',ATMIOC_ITF+13,struct atmif_sioc) | 
|  | 78 | /* force interface ESI */ | 
|  | 79 | #define ATM_GETSTAT	_IOW('a',ATMIOC_SARCOM+0,struct atmif_sioc) | 
|  | 80 | /* get AAL layer statistics */ | 
|  | 81 | #define ATM_GETSTATZ	_IOW('a',ATMIOC_SARCOM+1,struct atmif_sioc) | 
|  | 82 | /* get AAL layer statistics and zero */ | 
|  | 83 | #define ATM_GETLOOP	_IOW('a',ATMIOC_SARCOM+2,struct atmif_sioc) | 
|  | 84 | /* get loopback mode */ | 
|  | 85 | #define ATM_SETLOOP	_IOW('a',ATMIOC_SARCOM+3,struct atmif_sioc) | 
|  | 86 | /* set loopback mode */ | 
|  | 87 | #define ATM_QUERYLOOP	_IOW('a',ATMIOC_SARCOM+4,struct atmif_sioc) | 
|  | 88 | /* query supported loopback modes */ | 
|  | 89 | #define ATM_SETSC	_IOW('a',ATMIOC_SPECIAL+1,int) | 
|  | 90 | /* enable or disable single-copy */ | 
|  | 91 | #define ATM_SETBACKEND	_IOW('a',ATMIOC_SPECIAL+2,atm_backend_t) | 
|  | 92 | /* set backend handler */ | 
|  | 93 | #define ATM_NEWBACKENDIF _IOW('a',ATMIOC_SPECIAL+3,atm_backend_t) | 
|  | 94 | /* use backend to make new if */ | 
|  | 95 | #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf) | 
|  | 96 | /* add party to p2mp call */ | 
|  | 97 | #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int) | 
|  | 98 | /* drop party from p2mp call */ | 
|  | 99 |  | 
|  | 100 | /* | 
|  | 101 | * These are backend handkers that can be set via the ATM_SETBACKEND call | 
|  | 102 | * above.  In the future we may support dynamic loading of these - for now, | 
|  | 103 | * they're just being used to share the ATMIOC_BACKEND ioctls | 
|  | 104 | */ | 
|  | 105 | #define ATM_BACKEND_RAW		0 | 
|  | 106 | #define ATM_BACKEND_PPP		1	/* PPPoATM - RFC2364 */ | 
|  | 107 | #define ATM_BACKEND_BR2684	2	/* Bridged RFC1483/2684 */ | 
|  | 108 |  | 
|  | 109 | /* for ATM_GETTYPE */ | 
|  | 110 | #define ATM_ITFTYP_LEN	8	/* maximum length of interface type name */ | 
|  | 111 |  | 
|  | 112 | /* | 
|  | 113 | * Loopback modes for ATM_{PHY,SAR}_{GET,SET}LOOP | 
|  | 114 | */ | 
|  | 115 |  | 
|  | 116 | /* Point of loopback				CPU-->SAR-->PHY-->line--> ... */ | 
|  | 117 | #define __ATM_LM_NONE	0	/* no loop back     ^     ^     ^      ^      */ | 
|  | 118 | #define __ATM_LM_AAL	1	/* loop back PDUs --'     |     |      |      */ | 
|  | 119 | #define __ATM_LM_ATM	2	/* loop back ATM cells ---'     |      |      */ | 
|  | 120 | /* RESERVED		4	loop back on PHY side  ---'		      */ | 
|  | 121 | #define __ATM_LM_PHY	8	/* loop back bits (digital) ----'      |      */ | 
|  | 122 | #define __ATM_LM_ANALOG 16	/* loop back the analog signal --------'      */ | 
|  | 123 |  | 
|  | 124 | /* Direction of loopback */ | 
|  | 125 | #define __ATM_LM_MKLOC(n)	((n))	    /* Local (i.e. loop TX to RX) */ | 
|  | 126 | #define __ATM_LM_MKRMT(n)	((n) << 8)  /* Remote (i.e. loop RX to TX) */ | 
|  | 127 |  | 
|  | 128 | #define __ATM_LM_XTLOC(n)	((n) & 0xff) | 
|  | 129 | #define __ATM_LM_XTRMT(n)	(((n) >> 8) & 0xff) | 
|  | 130 |  | 
|  | 131 | #define ATM_LM_NONE	0	/* no loopback */ | 
|  | 132 |  | 
|  | 133 | #define ATM_LM_LOC_AAL	__ATM_LM_MKLOC(__ATM_LM_AAL) | 
|  | 134 | #define ATM_LM_LOC_ATM	__ATM_LM_MKLOC(__ATM_LM_ATM) | 
|  | 135 | #define ATM_LM_LOC_PHY	__ATM_LM_MKLOC(__ATM_LM_PHY) | 
|  | 136 | #define ATM_LM_LOC_ANALOG __ATM_LM_MKLOC(__ATM_LM_ANALOG) | 
|  | 137 |  | 
|  | 138 | #define ATM_LM_RMT_AAL	__ATM_LM_MKRMT(__ATM_LM_AAL) | 
|  | 139 | #define ATM_LM_RMT_ATM	__ATM_LM_MKRMT(__ATM_LM_ATM) | 
|  | 140 | #define ATM_LM_RMT_PHY	__ATM_LM_MKRMT(__ATM_LM_PHY) | 
|  | 141 | #define ATM_LM_RMT_ANALOG __ATM_LM_MKRMT(__ATM_LM_ANALOG) | 
|  | 142 |  | 
|  | 143 | /* | 
|  | 144 | * Note: ATM_LM_LOC_* and ATM_LM_RMT_* can be combined, provided that | 
|  | 145 | * __ATM_LM_XTLOC(x) <= __ATM_LM_XTRMT(x) | 
|  | 146 | */ | 
|  | 147 |  | 
|  | 148 |  | 
|  | 149 | struct atm_iobuf { | 
|  | 150 | int length; | 
|  | 151 | void __user *buffer; | 
|  | 152 | }; | 
|  | 153 |  | 
|  | 154 | /* for ATM_GETCIRANGE / ATM_SETCIRANGE */ | 
|  | 155 |  | 
|  | 156 | #define ATM_CI_MAX      -1              /* use maximum range of VPI/VCI */ | 
|  | 157 |  | 
|  | 158 | struct atm_cirange { | 
|  | 159 | signed char	vpi_bits;	/* 1..8, ATM_CI_MAX (-1) for maximum */ | 
|  | 160 | signed char	vci_bits;	/* 1..16, ATM_CI_MAX (-1) for maximum */ | 
|  | 161 | }; | 
|  | 162 |  | 
|  | 163 | /* for ATM_SETSC; actually taken from the ATM_VF number space */ | 
|  | 164 |  | 
|  | 165 | #define ATM_SC_RX	1024		/* enable RX single-copy */ | 
|  | 166 | #define ATM_SC_TX	2048		/* enable TX single-copy */ | 
|  | 167 |  | 
|  | 168 | #define ATM_BACKLOG_DEFAULT 32 /* if we get more, we're likely to time out | 
|  | 169 | anyway */ | 
|  | 170 |  | 
|  | 171 | /* MF: change_qos (Modify) flags */ | 
|  | 172 |  | 
|  | 173 | #define ATM_MF_IMMED	 1	/* Block until change is effective */ | 
|  | 174 | #define ATM_MF_INC_RSV	 2	/* Change reservation on increase */ | 
|  | 175 | #define ATM_MF_INC_SHP	 4	/* Change shaping on increase */ | 
|  | 176 | #define ATM_MF_DEC_RSV	 8	/* Change reservation on decrease */ | 
|  | 177 | #define ATM_MF_DEC_SHP	16	/* Change shaping on decrease */ | 
|  | 178 | #define ATM_MF_BWD	32	/* Set the backward direction parameters */ | 
|  | 179 |  | 
|  | 180 | #define ATM_MF_SET	(ATM_MF_INC_RSV | ATM_MF_INC_SHP | ATM_MF_DEC_RSV | \ | 
|  | 181 | ATM_MF_DEC_SHP | ATM_MF_BWD) | 
|  | 182 |  | 
|  | 183 | /* | 
|  | 184 | * ATM_VS_* are used to express VC state in a human-friendly way. | 
|  | 185 | */ | 
|  | 186 |  | 
|  | 187 | #define ATM_VS_IDLE	0	/* VC is not used */ | 
|  | 188 | #define ATM_VS_CONNECTED 1	/* VC is connected */ | 
|  | 189 | #define ATM_VS_CLOSING	2	/* VC is closing */ | 
|  | 190 | #define ATM_VS_LISTEN	3	/* VC is listening for incoming setups */ | 
|  | 191 | #define ATM_VS_INUSE	4	/* VC is in use (registered with atmsigd) */ | 
|  | 192 | #define ATM_VS_BOUND	5	/* VC is bound */ | 
|  | 193 |  | 
|  | 194 | #define ATM_VS2TXT_MAP \ | 
|  | 195 | "IDLE", "CONNECTED", "CLOSING", "LISTEN", "INUSE", "BOUND" | 
|  | 196 |  | 
|  | 197 | #define ATM_VF2TXT_MAP \ | 
|  | 198 | "ADDR",	"READY",	"PARTIAL",	"REGIS", \ | 
|  | 199 | "RELEASED", "HASQOS",	"LISTEN",	"META", \ | 
|  | 200 | "256",	"512",		"1024",		"2048", \ | 
|  | 201 | "SESSION",	"HASSAP",	"BOUND",	"CLOSE" | 
|  | 202 |  | 
|  | 203 |  | 
|  | 204 | #ifdef __KERNEL__ | 
|  | 205 |  | 
|  | 206 | #include <linux/wait.h> /* wait_queue_head_t */ | 
|  | 207 | #include <linux/time.h> /* struct timeval */ | 
|  | 208 | #include <linux/net.h> | 
|  | 209 | #include <linux/skbuff.h> /* struct sk_buff */ | 
|  | 210 | #include <linux/uio.h> | 
|  | 211 | #include <net/sock.h> | 
|  | 212 | #include <asm/atomic.h> | 
|  | 213 |  | 
|  | 214 | #ifdef CONFIG_PROC_FS | 
|  | 215 | #include <linux/proc_fs.h> | 
|  | 216 |  | 
|  | 217 | extern struct proc_dir_entry *atm_proc_root; | 
|  | 218 | #endif | 
|  | 219 |  | 
|  | 220 |  | 
|  | 221 | struct k_atm_aal_stats { | 
|  | 222 | #define __HANDLE_ITEM(i) atomic_t i | 
|  | 223 | __AAL_STAT_ITEMS | 
|  | 224 | #undef __HANDLE_ITEM | 
|  | 225 | }; | 
|  | 226 |  | 
|  | 227 |  | 
|  | 228 | struct k_atm_dev_stats { | 
|  | 229 | struct k_atm_aal_stats aal0; | 
|  | 230 | struct k_atm_aal_stats aal34; | 
|  | 231 | struct k_atm_aal_stats aal5; | 
|  | 232 | }; | 
|  | 233 |  | 
|  | 234 |  | 
|  | 235 | enum { | 
|  | 236 | ATM_VF_ADDR,		/* Address is in use. Set by anybody, cleared | 
|  | 237 | by device driver. */ | 
|  | 238 | ATM_VF_READY,		/* VC is ready to transfer data. Set by device | 
|  | 239 | driver, cleared by anybody. */ | 
|  | 240 | ATM_VF_PARTIAL,		/* resources are bound to PVC (partial PVC | 
|  | 241 | setup), controlled by socket layer */ | 
|  | 242 | ATM_VF_REGIS,		/* registered with demon, controlled by SVC | 
|  | 243 | socket layer */ | 
|  | 244 | ATM_VF_BOUND,		/* local SAP is set, controlled by SVC socket | 
|  | 245 | layer */ | 
|  | 246 | ATM_VF_RELEASED,	/* demon has indicated/requested release, | 
|  | 247 | controlled by SVC socket layer */ | 
|  | 248 | ATM_VF_HASQOS,		/* QOS parameters have been set */ | 
|  | 249 | ATM_VF_LISTEN,		/* socket is used for listening */ | 
|  | 250 | ATM_VF_META,		/* SVC socket isn't used for normal data | 
|  | 251 | traffic and doesn't depend on signaling | 
|  | 252 | to be available */ | 
|  | 253 | ATM_VF_SESSION,		/* VCC is p2mp session control descriptor */ | 
|  | 254 | ATM_VF_HASSAP,		/* SAP has been set */ | 
|  | 255 | ATM_VF_CLOSE,		/* asynchronous close - treat like VF_RELEASED*/ | 
|  | 256 | ATM_VF_WAITING,		/* waiting for reply from sigd */ | 
|  | 257 | ATM_VF_IS_CLIP,		/* in use by CLIP protocol */ | 
|  | 258 | }; | 
|  | 259 |  | 
|  | 260 |  | 
|  | 261 | #define ATM_VF2VS(flags) \ | 
|  | 262 | (test_bit(ATM_VF_READY,&(flags)) ? ATM_VS_CONNECTED : \ | 
|  | 263 | test_bit(ATM_VF_RELEASED,&(flags)) ? ATM_VS_CLOSING : \ | 
|  | 264 | test_bit(ATM_VF_LISTEN,&(flags)) ? ATM_VS_LISTEN : \ | 
|  | 265 | test_bit(ATM_VF_REGIS,&(flags)) ? ATM_VS_INUSE : \ | 
|  | 266 | test_bit(ATM_VF_BOUND,&(flags)) ? ATM_VS_BOUND : ATM_VS_IDLE) | 
|  | 267 |  | 
|  | 268 |  | 
|  | 269 | enum { | 
|  | 270 | ATM_DF_CLOSE,		/* close device when last VCC is closed */ | 
|  | 271 | }; | 
|  | 272 |  | 
|  | 273 |  | 
|  | 274 | #define ATM_PHY_SIG_LOST    0	/* no carrier/light */ | 
|  | 275 | #define ATM_PHY_SIG_UNKNOWN 1	/* carrier/light status is unknown */ | 
|  | 276 | #define ATM_PHY_SIG_FOUND   2	/* carrier/light okay */ | 
|  | 277 |  | 
|  | 278 | #define ATM_ATMOPT_CLP	1	/* set CLP bit */ | 
|  | 279 |  | 
|  | 280 | struct atm_vcc { | 
|  | 281 | /* struct sock has to be the first member of atm_vcc */ | 
|  | 282 | struct sock	sk; | 
|  | 283 | unsigned long	flags;		/* VCC flags (ATM_VF_*) */ | 
|  | 284 | short		vpi;		/* VPI and VCI (types must be equal */ | 
|  | 285 | /* with sockaddr) */ | 
|  | 286 | int 		vci; | 
|  | 287 | unsigned long	aal_options;	/* AAL layer options */ | 
|  | 288 | unsigned long	atm_options;	/* ATM layer options */ | 
|  | 289 | struct atm_dev	*dev;		/* device back pointer */ | 
|  | 290 | struct atm_qos	qos;		/* QOS */ | 
|  | 291 | struct atm_sap	sap;		/* SAP */ | 
|  | 292 | void (*push)(struct atm_vcc *vcc,struct sk_buff *skb); | 
|  | 293 | void (*pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* optional */ | 
|  | 294 | int (*push_oam)(struct atm_vcc *vcc,void *cell); | 
|  | 295 | int (*send)(struct atm_vcc *vcc,struct sk_buff *skb); | 
|  | 296 | void		*dev_data;	/* per-device data */ | 
|  | 297 | void		*proto_data;	/* per-protocol data */ | 
|  | 298 | struct k_atm_aal_stats *stats;	/* pointer to AAL stats group */ | 
|  | 299 | /* SVC part --- may move later ------------------------------------- */ | 
|  | 300 | short		itf;		/* interface number */ | 
|  | 301 | struct sockaddr_atmsvc local; | 
|  | 302 | struct sockaddr_atmsvc remote; | 
|  | 303 | /* Multipoint part ------------------------------------------------- */ | 
|  | 304 | struct atm_vcc	*session;	/* session VCC descriptor */ | 
|  | 305 | /* Other stuff ----------------------------------------------------- */ | 
|  | 306 | void		*user_back;	/* user backlink - not touched by */ | 
|  | 307 | /* native ATM stack. Currently used */ | 
|  | 308 | /* by CLIP and sch_atm. */ | 
|  | 309 | }; | 
|  | 310 |  | 
|  | 311 | static inline struct atm_vcc *atm_sk(struct sock *sk) | 
|  | 312 | { | 
|  | 313 | return (struct atm_vcc *)sk; | 
|  | 314 | } | 
|  | 315 |  | 
|  | 316 | static inline struct atm_vcc *ATM_SD(struct socket *sock) | 
|  | 317 | { | 
|  | 318 | return atm_sk(sock->sk); | 
|  | 319 | } | 
|  | 320 |  | 
|  | 321 | static inline struct sock *sk_atm(struct atm_vcc *vcc) | 
|  | 322 | { | 
|  | 323 | return (struct sock *)vcc; | 
|  | 324 | } | 
|  | 325 |  | 
|  | 326 | struct atm_dev_addr { | 
|  | 327 | struct sockaddr_atmsvc addr;	/* ATM address */ | 
|  | 328 | struct list_head entry;		/* next address */ | 
|  | 329 | }; | 
|  | 330 |  | 
|  | 331 | struct atm_dev { | 
|  | 332 | const struct atmdev_ops *ops;	/* device operations; NULL if unused */ | 
|  | 333 | const struct atmphy_ops *phy;	/* PHY operations, may be undefined */ | 
|  | 334 | /* (NULL) */ | 
|  | 335 | const char	*type;		/* device type name */ | 
|  | 336 | int		number;		/* device index */ | 
|  | 337 | void		*dev_data;	/* per-device data */ | 
|  | 338 | void		*phy_data;	/* private PHY date */ | 
|  | 339 | unsigned long	flags;		/* device flags (ATM_DF_*) */ | 
|  | 340 | struct list_head local;		/* local ATM addresses */ | 
|  | 341 | unsigned char	esi[ESI_LEN];	/* ESI ("MAC" addr) */ | 
|  | 342 | struct atm_cirange ci_range;	/* VPI/VCI range */ | 
|  | 343 | struct k_atm_dev_stats stats;	/* statistics */ | 
|  | 344 | char		signal;		/* signal status (ATM_PHY_SIG_*) */ | 
|  | 345 | int		link_rate;	/* link rate (default: OC3) */ | 
|  | 346 | atomic_t	refcnt;		/* reference count */ | 
|  | 347 | spinlock_t	lock;		/* protect internal members */ | 
|  | 348 | #ifdef CONFIG_PROC_FS | 
|  | 349 | struct proc_dir_entry *proc_entry; /* proc entry */ | 
|  | 350 | char *proc_name;		/* proc entry name */ | 
|  | 351 | #endif | 
|  | 352 | struct list_head dev_list;	/* linkage */ | 
|  | 353 | }; | 
|  | 354 |  | 
|  | 355 |  | 
|  | 356 | /* OF: send_Oam Flags */ | 
|  | 357 |  | 
|  | 358 | #define ATM_OF_IMMED  1		/* Attempt immediate delivery */ | 
|  | 359 | #define ATM_OF_INRATE 2		/* Attempt in-rate delivery */ | 
|  | 360 |  | 
|  | 361 |  | 
|  | 362 | /* | 
|  | 363 | * ioctl, getsockopt, and setsockopt are optional and can be set to NULL. | 
|  | 364 | */ | 
|  | 365 |  | 
|  | 366 | struct atmdev_ops { /* only send is required */ | 
|  | 367 | void (*dev_close)(struct atm_dev *dev); | 
|  | 368 | int (*open)(struct atm_vcc *vcc); | 
|  | 369 | void (*close)(struct atm_vcc *vcc); | 
|  | 370 | int (*ioctl)(struct atm_dev *dev,unsigned int cmd,void __user *arg); | 
|  | 371 | int (*getsockopt)(struct atm_vcc *vcc,int level,int optname, | 
|  | 372 | void __user *optval,int optlen); | 
|  | 373 | int (*setsockopt)(struct atm_vcc *vcc,int level,int optname, | 
|  | 374 | void __user *optval,int optlen); | 
|  | 375 | int (*send)(struct atm_vcc *vcc,struct sk_buff *skb); | 
|  | 376 | int (*send_oam)(struct atm_vcc *vcc,void *cell,int flags); | 
|  | 377 | void (*phy_put)(struct atm_dev *dev,unsigned char value, | 
|  | 378 | unsigned long addr); | 
|  | 379 | unsigned char (*phy_get)(struct atm_dev *dev,unsigned long addr); | 
|  | 380 | int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags); | 
|  | 381 | int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page); | 
|  | 382 | struct module *owner; | 
|  | 383 | }; | 
|  | 384 |  | 
|  | 385 | struct atmphy_ops { | 
|  | 386 | int (*start)(struct atm_dev *dev); | 
|  | 387 | int (*ioctl)(struct atm_dev *dev,unsigned int cmd,void __user *arg); | 
|  | 388 | void (*interrupt)(struct atm_dev *dev); | 
|  | 389 | int (*stop)(struct atm_dev *dev); | 
|  | 390 | }; | 
|  | 391 |  | 
|  | 392 | struct atm_skb_data { | 
|  | 393 | struct atm_vcc	*vcc;		/* ATM VCC */ | 
|  | 394 | unsigned long	atm_options;	/* ATM layer options */ | 
|  | 395 | }; | 
|  | 396 |  | 
|  | 397 | #define VCC_HTABLE_SIZE 32 | 
|  | 398 |  | 
|  | 399 | extern struct hlist_head vcc_hash[VCC_HTABLE_SIZE]; | 
|  | 400 | extern rwlock_t vcc_sklist_lock; | 
|  | 401 |  | 
|  | 402 | #define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb)) | 
|  | 403 |  | 
|  | 404 | struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops, | 
|  | 405 | int number,unsigned long *flags); /* number == -1: pick first available */ | 
|  | 406 | struct atm_dev *atm_dev_lookup(int number); | 
|  | 407 | void atm_dev_deregister(struct atm_dev *dev); | 
|  | 408 | void shutdown_atm_dev(struct atm_dev *dev); | 
|  | 409 | void vcc_insert_socket(struct sock *sk); | 
|  | 410 |  | 
|  | 411 |  | 
|  | 412 | /* | 
|  | 413 | * This is approximately the algorithm used by alloc_skb. | 
|  | 414 | * | 
|  | 415 | */ | 
|  | 416 |  | 
|  | 417 | static inline int atm_guess_pdu2truesize(int size) | 
|  | 418 | { | 
|  | 419 | return (SKB_DATA_ALIGN(size) + sizeof(struct skb_shared_info)); | 
|  | 420 | } | 
|  | 421 |  | 
|  | 422 |  | 
|  | 423 | static inline void atm_force_charge(struct atm_vcc *vcc,int truesize) | 
|  | 424 | { | 
|  | 425 | atomic_add(truesize, &sk_atm(vcc)->sk_rmem_alloc); | 
|  | 426 | } | 
|  | 427 |  | 
|  | 428 |  | 
|  | 429 | static inline void atm_return(struct atm_vcc *vcc,int truesize) | 
|  | 430 | { | 
|  | 431 | atomic_sub(truesize, &sk_atm(vcc)->sk_rmem_alloc); | 
|  | 432 | } | 
|  | 433 |  | 
|  | 434 |  | 
|  | 435 | static inline int atm_may_send(struct atm_vcc *vcc,unsigned int size) | 
|  | 436 | { | 
|  | 437 | return (size + atomic_read(&sk_atm(vcc)->sk_wmem_alloc)) < | 
|  | 438 | sk_atm(vcc)->sk_sndbuf; | 
|  | 439 | } | 
|  | 440 |  | 
|  | 441 |  | 
|  | 442 | static inline void atm_dev_hold(struct atm_dev *dev) | 
|  | 443 | { | 
|  | 444 | atomic_inc(&dev->refcnt); | 
|  | 445 | } | 
|  | 446 |  | 
|  | 447 |  | 
|  | 448 | static inline void atm_dev_put(struct atm_dev *dev) | 
|  | 449 | { | 
|  | 450 | atomic_dec(&dev->refcnt); | 
|  | 451 |  | 
|  | 452 | if ((atomic_read(&dev->refcnt) == 1) && | 
|  | 453 | test_bit(ATM_DF_CLOSE,&dev->flags)) | 
|  | 454 | shutdown_atm_dev(dev); | 
|  | 455 | } | 
|  | 456 |  | 
|  | 457 |  | 
|  | 458 | int atm_charge(struct atm_vcc *vcc,int truesize); | 
|  | 459 | struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size, | 
|  | 460 | int gfp_flags); | 
|  | 461 | int atm_pcr_goal(struct atm_trafprm *tp); | 
|  | 462 |  | 
|  | 463 | void vcc_release_async(struct atm_vcc *vcc, int reply); | 
|  | 464 |  | 
|  | 465 | struct atm_ioctl { | 
|  | 466 | struct module *owner; | 
|  | 467 | /* A module reference is kept if appropriate over this call. | 
|  | 468 | * Return -ENOIOCTLCMD if you don't handle it. */ | 
|  | 469 | int (*ioctl)(struct socket *, unsigned int cmd, unsigned long arg); | 
|  | 470 | struct list_head list; | 
|  | 471 | }; | 
|  | 472 |  | 
|  | 473 | /** | 
|  | 474 | * register_atm_ioctl - register handler for ioctl operations | 
|  | 475 | * | 
|  | 476 | * Special (non-device) handlers of ioctl's should | 
|  | 477 | * register here. If you're a normal device, you should | 
|  | 478 | * set .ioctl in your atmdev_ops instead. | 
|  | 479 | */ | 
|  | 480 | void register_atm_ioctl(struct atm_ioctl *); | 
|  | 481 |  | 
|  | 482 | /** | 
|  | 483 | * deregister_atm_ioctl - remove the ioctl handler | 
|  | 484 | */ | 
|  | 485 | void deregister_atm_ioctl(struct atm_ioctl *); | 
|  | 486 |  | 
|  | 487 | #endif /* __KERNEL__ */ | 
|  | 488 |  | 
|  | 489 | #endif |