2 * adummy.c: a dummy ATM driver
5 #include <linux/module.h>
6 #include <linux/kernel.h>
7 #include <linux/skbuff.h>
8 #include <linux/errno.h>
9 #include <linux/types.h>
10 #include <linux/string.h>
11 #include <linux/delay.h>
12 #include <linux/init.h>
14 #include <linux/timer.h>
15 #include <linux/interrupt.h>
16 #include <linux/slab.h>
18 #include <asm/byteorder.h>
19 #include <asm/uaccess.h>
21 #include <linux/atmdev.h>
22 #include <linux/atm.h>
23 #include <linux/sonet.h>
25 /* version definition */
27 #define DRV_VERSION "1.0"
29 #define DEV_LABEL "adummy"
31 #define ADUMMY_DEV(dev) ((struct adummy_dev *) (dev)->dev_data)
34 struct atm_dev
*atm_dev
;
36 struct list_head entry
;
41 static LIST_HEAD(adummy_devs
);
44 adummy_start(struct atm_dev
*dev
)
46 dev
->ci_range
.vpi_bits
= 4;
47 dev
->ci_range
.vci_bits
= 12;
53 adummy_open(struct atm_vcc
*vcc
)
58 if (vci
== ATM_VCI_UNSPEC
|| vpi
== ATM_VPI_UNSPEC
)
61 set_bit(ATM_VF_ADDR
, &vcc
->flags
);
62 set_bit(ATM_VF_READY
, &vcc
->flags
);
68 adummy_close(struct atm_vcc
*vcc
)
70 clear_bit(ATM_VF_READY
, &vcc
->flags
);
71 clear_bit(ATM_VF_ADDR
, &vcc
->flags
);
75 adummy_send(struct atm_vcc
*vcc
, struct sk_buff
*skb
)
80 dev_kfree_skb_any(skb
);
81 atomic_inc(&vcc
->stats
->tx
);
87 adummy_proc_read(struct atm_dev
*dev
, loff_t
*pos
, char *page
)
92 return sprintf(page
, "version %s\n", DRV_VERSION
);
97 static struct atmdev_ops adummy_ops
=
100 .close
= adummy_close
,
102 .proc_read
= adummy_proc_read
,
106 static int __init
adummy_init(void)
108 struct atm_dev
*atm_dev
;
109 struct adummy_dev
*adummy_dev
;
112 printk(KERN_ERR
"adummy: version %s\n", DRV_VERSION
);
114 adummy_dev
= kzalloc(sizeof(struct adummy_dev
),
117 printk(KERN_ERR DEV_LABEL
": kzalloc() failed\n");
121 atm_dev
= atm_dev_register(DEV_LABEL
, &adummy_ops
, -1, NULL
);
123 printk(KERN_ERR DEV_LABEL
": atm_dev_register() failed\n");
128 adummy_dev
->atm_dev
= atm_dev
;
129 atm_dev
->dev_data
= adummy_dev
;
131 if (adummy_start(atm_dev
)) {
132 printk(KERN_ERR DEV_LABEL
": adummy_start() failed\n");
137 list_add(&adummy_dev
->entry
, &adummy_devs
);
142 atm_dev_deregister(atm_dev
);
148 static void __exit
adummy_cleanup(void)
150 struct adummy_dev
*adummy_dev
, *next
;
152 list_for_each_entry_safe(adummy_dev
, next
, &adummy_devs
, entry
) {
153 atm_dev_deregister(adummy_dev
->atm_dev
);
158 module_init(adummy_init
);
159 module_exit(adummy_cleanup
);
161 MODULE_AUTHOR("chas williams <chas@cmf.nrl.navy.mil>");
162 MODULE_DESCRIPTION("dummy ATM driver");
163 MODULE_LICENSE("GPL");