1 /******************************************************************************
2 * usb_atm.h - Generic USB xDSL driver core
4 * Copyright (C) 2001, Alcatel
5 * Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
6 * Copyright (C) 2004, David Woodhouse
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 59
20 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 ******************************************************************************/
24 #include <linux/list.h>
25 #include <linux/usb.h>
26 #include <linux/kref.h>
27 #include <linux/atm.h>
28 #include <linux/atmdev.h>
29 #include <asm/semaphore.h>
31 #define UDSL_MAX_RCV_URBS 4
32 #define UDSL_MAX_SND_URBS 4
33 #define UDSL_MAX_RCV_BUFS 8
34 #define UDSL_MAX_SND_BUFS 8
35 #define UDSL_MAX_RCV_BUF_SIZE 1024 /* ATM cells */
36 #define UDSL_MAX_SND_BUF_SIZE 1024 /* ATM cells */
37 #define UDSL_DEFAULT_RCV_URBS 2
38 #define UDSL_DEFAULT_SND_URBS 2
39 #define UDSL_DEFAULT_RCV_BUFS 4
40 #define UDSL_DEFAULT_SND_BUFS 4
41 #define UDSL_DEFAULT_RCV_BUF_SIZE 64 /* ATM cells */
42 #define UDSL_DEFAULT_SND_BUF_SIZE 64 /* ATM cells */
44 #define ATM_CELL_HEADER (ATM_CELL_SIZE - ATM_CELL_PAYLOAD)
45 #define UDSL_NUM_CELLS(x) (((x) + ATM_AAL5_TRAILER + ATM_CELL_PAYLOAD - 1) / ATM_CELL_PAYLOAD)
49 struct udsl_receive_buffer {
50 struct list_head list;
52 unsigned int filled_cells;
55 struct udsl_receiver {
56 struct list_head list;
57 struct udsl_receive_buffer *buffer;
59 struct udsl_instance_data *instance;
62 struct udsl_vcc_data {
64 struct list_head list;
69 /* raw cell reassembly */
75 struct udsl_send_buffer {
76 struct list_head list;
78 unsigned char *free_start;
79 unsigned int free_cells;
83 struct list_head list;
84 struct udsl_send_buffer *buffer;
86 struct udsl_instance_data *instance;
90 struct atm_skb_data atm_data;
91 unsigned int num_cells;
92 unsigned int num_entire;
93 unsigned int pdu_padding;
94 unsigned char cell_header[ATM_CELL_HEADER];
95 unsigned char aal5_trailer[ATM_AAL5_TRAILER];
98 #define UDSL_SKB(x) ((struct udsl_control *)(x)->cb)
100 /* main driver data */
104 UDSL_LOADING_FIRMWARE,
108 struct udsl_instance_data {
109 struct kref refcount;
110 struct semaphore serialize;
112 /* USB device part */
113 struct usb_device *usb_dev;
114 char description[64];
118 const char *driver_name;
120 /* ATM device part */
121 struct atm_dev *atm_dev;
122 struct list_head vcc_list;
125 int (*firmware_wait) (struct udsl_instance_data *);
126 enum udsl_status status;
127 wait_queue_head_t firmware_waiters;
130 struct udsl_receiver receivers[UDSL_MAX_RCV_URBS];
131 struct udsl_receive_buffer receive_buffers[UDSL_MAX_RCV_BUFS];
133 spinlock_t receive_lock;
134 struct list_head spare_receivers;
135 struct list_head filled_receive_buffers;
137 struct tasklet_struct receive_tasklet;
138 struct list_head spare_receive_buffers;
141 struct udsl_sender senders[UDSL_MAX_SND_URBS];
142 struct udsl_send_buffer send_buffers[UDSL_MAX_SND_BUFS];
144 struct sk_buff_head sndqueue;
146 spinlock_t send_lock;
147 struct list_head spare_senders;
148 struct list_head spare_send_buffers;
150 struct tasklet_struct send_tasklet;
151 struct sk_buff *current_skb; /* being emptied */
152 struct udsl_send_buffer *current_buffer; /* being filled */
153 struct list_head filled_send_buffers;
156 extern int udsl_instance_setup(struct usb_device *dev,
157 struct udsl_instance_data *instance);
158 extern void udsl_instance_disconnect(struct udsl_instance_data *instance);
159 extern void udsl_get_instance(struct udsl_instance_data *instance);
160 extern void udsl_put_instance(struct udsl_instance_data *instance);