2 * adummy.c: a dummy ATM driver
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>
17 #include <linux/sched.h>
18 #include <linux/timer.h>
19 #include <linux/interrupt.h>
21 #include <asm/byteorder.h>
22 #include <asm/uaccess.h>
24 #include <linux/atmdev.h>
25 #include <linux/atm.h>
26 #include <linux/sonet.h>
28 /* version definition */
30 #define DRV_VERSION "1.0"
32 #define DEV_LABEL "adummy"
34 #define ADUMMY_DEV(dev) ((struct adummy_dev *) (dev)->dev_data)
37 struct atm_dev *atm_dev;
39 struct list_head entry;
44 static LIST_HEAD(adummy_devs);
47 adummy_start(struct atm_dev *dev)
49 dev->ci_range.vpi_bits = 4;
50 dev->ci_range.vci_bits = 12;
56 adummy_open(struct atm_vcc *vcc)
61 if (vci == ATM_VCI_UNSPEC || vpi == ATM_VPI_UNSPEC)
64 set_bit(ATM_VF_ADDR, &vcc->flags);
65 set_bit(ATM_VF_READY, &vcc->flags);
71 adummy_close(struct atm_vcc *vcc)
73 clear_bit(ATM_VF_READY, &vcc->flags);
74 clear_bit(ATM_VF_ADDR, &vcc->flags);
78 adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
83 dev_kfree_skb_any(skb);
84 atomic_inc(&vcc->stats->tx);
90 adummy_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
95 return sprintf(page, "version %s\n", DRV_VERSION);
100 static struct atmdev_ops adummy_ops =
103 .close = adummy_close,
105 .proc_read = adummy_proc_read,
109 static int __init adummy_init(void)
111 struct atm_dev *atm_dev;
112 struct adummy_dev *adummy_dev;
115 printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
117 adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
120 printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
124 memset(adummy_dev, 0, sizeof(struct adummy_dev));
126 atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
128 printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
133 adummy_dev->atm_dev = atm_dev;
134 atm_dev->dev_data = adummy_dev;
136 if (adummy_start(atm_dev)) {
137 printk(KERN_ERR DEV_LABEL ": adummy_start() failed\n");
142 list_add(&adummy_dev->entry, &adummy_devs);
147 atm_dev_deregister(atm_dev);
153 static void __exit adummy_cleanup(void)
155 struct adummy_dev *adummy_dev, *next;
157 list_for_each_entry_safe(adummy_dev, next, &adummy_devs, entry) {
158 atm_dev_deregister(adummy_dev->atm_dev);
163 module_init(adummy_init);
164 module_exit(adummy_cleanup);
166 MODULE_AUTHOR("chas williams <chas@cmf.nrl.navy.mil>");
167 MODULE_DESCRIPTION("dummy ATM driver");
168 MODULE_LICENSE("GPL");