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