]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - drivers/usb/atm/usbatm.h
USB: add SPDX identifiers to all remaining files in drivers/usb/
[mirror_ubuntu-jammy-kernel.git] / drivers / usb / atm / usbatm.h
CommitLineData
5fd54ace 1// SPDX-License-Identifier: GPL-2.0+
c59bba75
DS
2/******************************************************************************
3 * usbatm.h - Generic USB xDSL driver core
4 *
5 * Copyright (C) 2001, Alcatel
6 * Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
7 * Copyright (C) 2004, David Woodhouse
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program; if not, write to the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 ******************************************************************************/
24
25#ifndef _USBATM_H_
26#define _USBATM_H_
27
c59bba75
DS
28#include <linux/atm.h>
29#include <linux/atmdev.h>
30#include <linux/completion.h>
31#include <linux/device.h>
0ec3c7e8 32#include <linux/kernel.h>
c59bba75
DS
33#include <linux/kref.h>
34#include <linux/list.h>
35#include <linux/stringify.h>
36#include <linux/usb.h>
ab3c81ff 37#include <linux/mutex.h>
32e24930 38#include <linux/ratelimit.h>
c59bba75 39
0ec3c7e8
DS
40/*
41#define VERBOSE_DEBUG
42*/
43
c59bba75
DS
44#define usb_err(instance, format, arg...) \
45 dev_err(&(instance)->usb_intf->dev , format , ## arg)
46#define usb_info(instance, format, arg...) \
47 dev_info(&(instance)->usb_intf->dev , format , ## arg)
48#define usb_warn(instance, format, arg...) \
49 dev_warn(&(instance)->usb_intf->dev , format , ## arg)
50#define usb_dbg(instance, format, arg...) \
ca4d7013 51 dev_dbg(&(instance)->usb_intf->dev , format , ## arg)
c59bba75
DS
52
53/* FIXME: move to dev_* once ATM is driver model aware */
54#define atm_printk(level, instance, format, arg...) \
843c944f
AM
55 printk(level "ATM dev %d: " format , \
56 (instance)->atm_dev->number , ## arg)
c59bba75
DS
57
58#define atm_err(instance, format, arg...) \
59 atm_printk(KERN_ERR, instance , format , ## arg)
60#define atm_info(instance, format, arg...) \
61 atm_printk(KERN_INFO, instance , format , ## arg)
62#define atm_warn(instance, format, arg...) \
63 atm_printk(KERN_WARNING, instance , format , ## arg)
32e24930
JP
64#define atm_dbg(instance, format, ...) \
65 pr_debug("ATM dev %d: " format, \
66 (instance)->atm_dev->number, ##__VA_ARGS__)
67#define atm_rldbg(instance, format, ...) \
68 pr_debug_ratelimited("ATM dev %d: " format, \
69 (instance)->atm_dev->number, ##__VA_ARGS__)
c59bba75 70
35644b0c
DS
71/* flags, set by mini-driver in bind() */
72
73#define UDSL_SKIP_HEAVY_INIT (1<<0)
80aae7a1 74#define UDSL_USE_ISOC (1<<1)
a3673d3c 75#define UDSL_IGNORE_EILSEQ (1<<2)
35644b0c
DS
76
77
c59bba75
DS
78/* mini driver */
79
80struct usbatm_data;
81
82/*
83* Assuming all methods exist and succeed, they are called in this order:
84*
16f76a76 85* bind, heavy_init, atm_start, ..., atm_stop, unbind
c59bba75
DS
86*/
87
88struct usbatm_driver {
c59bba75
DS
89 const char *driver_name;
90
35644b0c 91 /* init device ... can sleep, or cause probe() failure */
16f76a76 92 int (*bind) (struct usbatm_data *, struct usb_interface *,
35644b0c 93 const struct usb_device_id *id);
c59bba75
DS
94
95 /* additional device initialization that is too slow to be done in probe() */
16f76a76 96 int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
c59bba75
DS
97
98 /* cleanup device ... can sleep, but can't fail */
16f76a76 99 void (*unbind) (struct usbatm_data *, struct usb_interface *);
c59bba75
DS
100
101 /* init ATM device ... can sleep, or cause ATM initialization failure */
102 int (*atm_start) (struct usbatm_data *, struct atm_dev *);
103
104 /* cleanup ATM device ... can sleep, but can't fail */
105 void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
106
16f76a76
NK
107 int bulk_in; /* bulk rx endpoint */
108 int isoc_in; /* isochronous rx endpoint */
109 int bulk_out; /* bulk tx endpoint */
c59bba75
DS
110
111 unsigned rx_padding;
112 unsigned tx_padding;
113};
114
115extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
116 struct usbatm_driver *driver);
117extern void usbatm_usb_disconnect(struct usb_interface *intf);
118
119
120struct usbatm_channel {
121 int endpoint; /* usb pipe */
122 unsigned int stride; /* ATM cell size + padding */
123 unsigned int buf_size; /* urb buffer size */
80aae7a1 124 unsigned int packet_size; /* endpoint maxpacket */
c59bba75
DS
125 spinlock_t lock;
126 struct list_head list;
127 struct tasklet_struct tasklet;
128 struct timer_list delay;
129 struct usbatm_data *usbatm;
130};
131
132/* main driver data */
133
134struct usbatm_data {
135 /******************
136 * public fields *
16f76a76 137 ******************/
c59bba75
DS
138
139 /* mini driver */
140 struct usbatm_driver *driver;
141 void *driver_data;
142 char driver_name[16];
35644b0c 143 unsigned int flags; /* set by mini-driver in bind() */
c59bba75
DS
144
145 /* USB device */
146 struct usb_device *usb_dev;
147 struct usb_interface *usb_intf;
148 char description[64];
149
150 /* ATM device */
151 struct atm_dev *atm_dev;
152
153 /********************************
154 * private fields - do not use *
16f76a76 155 ********************************/
c59bba75
DS
156
157 struct kref refcount;
ab3c81ff 158 struct mutex serialize;
0e42a627 159 int disconnected;
c59bba75
DS
160
161 /* heavy init */
c4504a7e 162 struct task_struct *thread;
c59bba75
DS
163 struct completion thread_started;
164 struct completion thread_exited;
165
166 /* ATM device */
167 struct list_head vcc_list;
168
169 struct usbatm_channel rx_channel;
170 struct usbatm_channel tx_channel;
171
172 struct sk_buff_head sndqueue;
0ec3c7e8 173 struct sk_buff *current_skb; /* being emptied */
c59bba75 174
e3fb2f64
DS
175 struct usbatm_vcc_data *cached_vcc;
176 int cached_vci;
177 short cached_vpi;
178
179 unsigned char *cell_buf; /* holds partial rx cell */
180 unsigned int buf_usage;
181
c59bba75
DS
182 struct urb *urbs[0];
183};
184
9fc950d3
SA
185static inline void *to_usbatm_driver_data(struct usb_interface *intf)
186{
187 struct usbatm_data *usbatm_instance;
188
189 if (intf == NULL)
190 return NULL;
191
192 usbatm_instance = usb_get_intfdata(intf);
193
194 if (usbatm_instance == NULL) /* set NULL before unbind() */
195 return NULL;
196
197 return usbatm_instance->driver_data; /* set NULL after unbind() */
198}
199
c59bba75 200#endif /* _USBATM_H_ */