2 * adummy.c: a dummy ATM driver
5 #include <linux/module.h>
6 #include <linux/version.h>
7 #include <linux/kernel.h>
8 #include <linux/skbuff.h>
10 #include <linux/errno.h>
11 #include <linux/types.h>
12 #include <linux/string.h>
13 #include <linux/delay.h>
14 #include <linux/init.h>
16 #include <linux/sched.h>
17 #include <linux/timer.h>
18 #include <linux/interrupt.h>
20 #include <asm/byteorder.h>
21 #include <asm/uaccess.h>
23 #include <linux/atmdev.h>
24 #include <linux/atm.h>
25 #include <linux/sonet.h>
27 /* version definition */
29 #define DRV_VERSION "1.0"
31 #define DEV_LABEL "adummy"
33 #define ADUMMY_DEV(dev) ((struct adummy_dev *) (dev)->dev_data)
36 struct atm_dev
*atm_dev
;
38 struct list_head entry
;
43 static LIST_HEAD(adummy_devs
);
46 adummy_start(struct atm_dev
*dev
)
48 dev
->ci_range
.vpi_bits
= 4;
49 dev
->ci_range
.vci_bits
= 12;
55 adummy_open(struct atm_vcc
*vcc
)
60 if (vci
== ATM_VCI_UNSPEC
|| vpi
== ATM_VPI_UNSPEC
)
63 set_bit(ATM_VF_ADDR
, &vcc
->flags
);
64 set_bit(ATM_VF_READY
, &vcc
->flags
);
70 adummy_close(struct atm_vcc
*vcc
)
72 clear_bit(ATM_VF_READY
, &vcc
->flags
);
73 clear_bit(ATM_VF_ADDR
, &vcc
->flags
);
77 adummy_send(struct atm_vcc
*vcc
, struct sk_buff
*skb
)
82 dev_kfree_skb_any(skb
);
83 atomic_inc(&vcc
->stats
->tx
);
89 adummy_proc_read(struct atm_dev
*dev
, loff_t
*pos
, char *page
)
94 return sprintf(page
, "version %s\n", DRV_VERSION
);
99 static struct atmdev_ops adummy_ops
=
102 .close
= adummy_close
,
104 .proc_read
= adummy_proc_read
,
108 static int __init
adummy_init(void)
110 struct atm_dev
*atm_dev
;
111 struct adummy_dev
*adummy_dev
;
114 printk(KERN_ERR
"adummy: version %s\n", DRV_VERSION
);
116 adummy_dev
= (struct adummy_dev
*) kmalloc(sizeof(struct adummy_dev
),
119 printk(KERN_ERR DEV_LABEL
": kmalloc() failed\n");
123 memset(adummy_dev
, 0, sizeof(struct adummy_dev
));
125 atm_dev
= atm_dev_register(DEV_LABEL
, &adummy_ops
, -1, NULL
);
127 printk(KERN_ERR DEV_LABEL
": atm_dev_register() failed\n");
132 adummy_dev
->atm_dev
= atm_dev
;
133 atm_dev
->dev_data
= adummy_dev
;
135 if (adummy_start(atm_dev
)) {
136 printk(KERN_ERR DEV_LABEL
": adummy_start() failed\n");
141 list_add(&adummy_dev
->entry
, &adummy_devs
);
146 atm_dev_deregister(atm_dev
);
152 static void __exit
adummy_cleanup(void)
154 struct adummy_dev
*adummy_dev
, *next
;
156 list_for_each_entry_safe(adummy_dev
, next
, &adummy_devs
, entry
) {
157 atm_dev_deregister(adummy_dev
->atm_dev
);
162 module_init(adummy_init
);
163 module_exit(adummy_cleanup
);
165 MODULE_AUTHOR("chas williams <chas@cmf.nrl.navy.mil>");
166 MODULE_DESCRIPTION("dummy ATM driver");
167 MODULE_LICENSE("GPL");