OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [LINUX_2_4_26_OR32/] [linux/] [linux-2.4/] [include/] [linux/] [atmdev.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.