aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/atm
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/atm')
-rw-r--r--drivers/atm/Kconfig7
-rw-r--r--drivers/atm/Makefile1
-rw-r--r--drivers/atm/adummy.c168
3 files changed, 176 insertions, 0 deletions
diff --git a/drivers/atm/Kconfig b/drivers/atm/Kconfig
index 489de81ea609..01a9f1cb7743 100644
--- a/drivers/atm/Kconfig
+++ b/drivers/atm/Kconfig
@@ -5,6 +5,13 @@
5menu "ATM drivers" 5menu "ATM drivers"
6 depends on NETDEVICES && ATM 6 depends on NETDEVICES && ATM
7 7
8config ATM_DUMMY
9 tristate "Dummy ATM driver"
10 depends on ATM
11 help
12 Dummy ATM driver. Useful for proxy signalling, testing,
13 and development. If unsure, say N.
14
8config ATM_TCP 15config ATM_TCP
9 tristate "ATM over TCP" 16 tristate "ATM over TCP"
10 depends on INET && ATM 17 depends on INET && ATM
diff --git a/drivers/atm/Makefile b/drivers/atm/Makefile
index 5b77188527a9..b5077ce8cb40 100644
--- a/drivers/atm/Makefile
+++ b/drivers/atm/Makefile
@@ -31,6 +31,7 @@ ifeq ($(CONFIG_ATM_IDT77252_USE_SUNI),y)
31 obj-$(CONFIG_ATM_IDT77252) += suni.o 31 obj-$(CONFIG_ATM_IDT77252) += suni.o
32endif 32endif
33 33
34obj-$(CONFIG_ATM_DUMMY) += adummy.o
34obj-$(CONFIG_ATM_TCP) += atmtcp.o 35obj-$(CONFIG_ATM_TCP) += atmtcp.o
35obj-$(CONFIG_ATM_FIRESTREAM) += firestream.o 36obj-$(CONFIG_ATM_FIRESTREAM) += firestream.o
36obj-$(CONFIG_ATM_LANAI) += lanai.o 37obj-$(CONFIG_ATM_LANAI) += lanai.o
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
new file mode 100644
index 000000000000..d15c194be44a
--- /dev/null
+++ b/drivers/atm/adummy.c
@@ -0,0 +1,168 @@
1/*
2 * adummy.c: a dummy ATM driver
3 */
4
5#include <linux/config.h>
6#include <linux/module.h>
7#include <linux/version.h>
8#include <linux/kernel.h>
9#include <linux/skbuff.h>
10#include <linux/pci.h>
11#include <linux/errno.h>
12#include <linux/types.h>
13#include <linux/string.h>
14#include <linux/delay.h>
15#include <linux/init.h>
16#include <linux/mm.h>
17#include <linux/sched.h>
18#include <linux/timer.h>
19#include <linux/interrupt.h>
20#include <asm/io.h>
21#include <asm/byteorder.h>
22#include <asm/uaccess.h>
23
24#include <linux/atmdev.h>
25#include <linux/atm.h>
26#include <linux/sonet.h>
27
28/* version definition */
29
30#define DRV_VERSION "1.0"
31
32#define DEV_LABEL "adummy"
33
34#define ADUMMY_DEV(dev) ((struct adummy_dev *) (dev)->dev_data)
35
36struct adummy_dev {
37 struct atm_dev *atm_dev;
38
39 struct list_head entry;
40};
41
42/* globals */
43
44static LIST_HEAD(adummy_devs);
45
46static int __init
47adummy_start(struct atm_dev *dev)
48{
49 dev->ci_range.vpi_bits = 4;
50 dev->ci_range.vci_bits = 12;
51
52 return 0;
53}
54
55static int
56adummy_open(struct atm_vcc *vcc)
57{
58 short vpi = vcc->vpi;
59 int vci = vcc->vci;
60
61 if (vci == ATM_VCI_UNSPEC || vpi == ATM_VPI_UNSPEC)
62 return 0;
63
64 set_bit(ATM_VF_ADDR, &vcc->flags);
65 set_bit(ATM_VF_READY, &vcc->flags);
66
67 return 0;
68}
69
70static void
71adummy_close(struct atm_vcc *vcc)
72{
73 clear_bit(ATM_VF_READY, &vcc->flags);
74 clear_bit(ATM_VF_ADDR, &vcc->flags);
75}
76
77static int
78adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
79{
80 if (vcc->pop)
81 vcc->pop(vcc, skb);
82 else
83 dev_kfree_skb_any(skb);
84 atomic_inc(&vcc->stats->tx);
85
86 return 0;
87}
88
89static int
90adummy_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
91{
92 int left = *pos;
93
94 if (!left--)
95 return sprintf(page, "version %s\n", DRV_VERSION);
96
97 return 0;
98}
99
100static struct atmdev_ops adummy_ops =
101{
102 .open = adummy_open,
103 .close = adummy_close,
104 .send = adummy_send,
105 .proc_read = adummy_proc_read,
106 .owner = THIS_MODULE
107};
108
109static int __init adummy_init(void)
110{
111 struct atm_dev *atm_dev;
112 struct adummy_dev *adummy_dev;
113 int err = 0;
114
115 printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
116
117 adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
118 GFP_KERNEL);
119 if (!adummy_dev) {
120 printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
121 err = -ENOMEM;
122 goto out;
123 }
124 memset(adummy_dev, 0, sizeof(struct adummy_dev));
125
126 atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, 0);
127 if (!atm_dev) {
128 printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
129 err = -ENODEV;
130 goto out_kfree;
131 }
132
133 adummy_dev->atm_dev = atm_dev;
134 atm_dev->dev_data = adummy_dev;
135
136 if (adummy_start(atm_dev)) {
137 printk(KERN_ERR DEV_LABEL ": adummy_start() failed\n");
138 err = -ENODEV;
139 goto out_unregister;
140 }
141
142 list_add(&adummy_dev->entry, &adummy_devs);
143out:
144 return err;
145
146out_unregister:
147 atm_dev_deregister(atm_dev);
148out_kfree:
149 kfree(adummy_dev);
150 goto out;
151}
152
153static void __exit adummy_cleanup(void)
154{
155 struct adummy_dev *adummy_dev, *next;
156
157 list_for_each_entry_safe(adummy_dev, next, &adummy_devs, entry) {
158 atm_dev_deregister(adummy_dev->atm_dev);
159 kfree(adummy_dev);
160 }
161}
162
163module_init(adummy_init);
164module_exit(adummy_cleanup);
165
166MODULE_AUTHOR("chas williams <chas@cmf.nrl.navy.mil>");
167MODULE_DESCRIPTION("dummy ATM driver");
168MODULE_LICENSE("GPL");