0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __LINUX_USB_USBNET_H
0010 #define __LINUX_USB_USBNET_H
0011
0012 #include <linux/mii.h>
0013 #include <linux/netdevice.h>
0014 #include <linux/skbuff.h>
0015 #include <linux/types.h>
0016 #include <linux/usb.h>
0017
0018
0019 struct usbnet {
0020
0021 struct usb_device *udev;
0022 struct usb_interface *intf;
0023 const struct driver_info *driver_info;
0024 const char *driver_name;
0025 void *driver_priv;
0026 wait_queue_head_t wait;
0027 struct mutex phy_mutex;
0028 unsigned char suspend_count;
0029 unsigned char pkt_cnt, pkt_err;
0030 unsigned short rx_qlen, tx_qlen;
0031 unsigned can_dma_sg:1;
0032
0033
0034 unsigned in, out;
0035 struct usb_host_endpoint *status;
0036 unsigned maxpacket;
0037 struct timer_list delay;
0038 const char *padding_pkt;
0039
0040
0041 struct net_device *net;
0042 int msg_enable;
0043 unsigned long data[5];
0044 u32 xid;
0045 u32 hard_mtu;
0046 size_t rx_urb_size;
0047 struct mii_if_info mii;
0048 long rx_speed;
0049 long tx_speed;
0050 # define SPEED_UNSET -1
0051
0052
0053 struct sk_buff_head rxq;
0054 struct sk_buff_head txq;
0055 struct sk_buff_head done;
0056 struct sk_buff_head rxq_pause;
0057 struct urb *interrupt;
0058 unsigned interrupt_count;
0059 struct mutex interrupt_mutex;
0060 struct usb_anchor deferred;
0061 struct tasklet_struct bh;
0062
0063 struct work_struct kevent;
0064 unsigned long flags;
0065 # define EVENT_TX_HALT 0
0066 # define EVENT_RX_HALT 1
0067 # define EVENT_RX_MEMORY 2
0068 # define EVENT_STS_SPLIT 3
0069 # define EVENT_LINK_RESET 4
0070 # define EVENT_RX_PAUSED 5
0071 # define EVENT_DEV_ASLEEP 6
0072 # define EVENT_DEV_OPEN 7
0073 # define EVENT_DEVICE_REPORT_IDLE 8
0074 # define EVENT_NO_RUNTIME_PM 9
0075 # define EVENT_RX_KILL 10
0076 # define EVENT_LINK_CHANGE 11
0077 # define EVENT_SET_RX_MODE 12
0078 # define EVENT_NO_IP_ALIGN 13
0079 };
0080
0081 static inline struct usb_driver *driver_of(struct usb_interface *intf)
0082 {
0083 return to_usb_driver(intf->dev.driver);
0084 }
0085
0086
0087 struct driver_info {
0088 char *description;
0089
0090 int flags;
0091
0092 #define FLAG_FRAMING_NC 0x0001
0093 #define FLAG_FRAMING_GL 0x0002
0094 #define FLAG_FRAMING_Z 0x0004
0095 #define FLAG_FRAMING_RN 0x0008
0096
0097 #define FLAG_NO_SETINT 0x0010
0098 #define FLAG_ETHER 0x0020
0099
0100 #define FLAG_FRAMING_AX 0x0040
0101 #define FLAG_WLAN 0x0080
0102 #define FLAG_AVOID_UNLINK_URBS 0x0100
0103 #define FLAG_SEND_ZLP 0x0200
0104 #define FLAG_WWAN 0x0400
0105
0106 #define FLAG_LINK_INTR 0x0800
0107
0108 #define FLAG_POINTTOPOINT 0x1000
0109
0110
0111
0112
0113
0114 #define FLAG_MULTI_PACKET 0x2000
0115 #define FLAG_RX_ASSEMBLE 0x4000
0116 #define FLAG_NOARP 0x8000
0117
0118
0119 int (*bind)(struct usbnet *, struct usb_interface *);
0120
0121
0122 void (*unbind)(struct usbnet *, struct usb_interface *);
0123
0124
0125 int (*reset)(struct usbnet *);
0126
0127
0128 int (*stop)(struct usbnet *);
0129
0130
0131 int (*check_connect)(struct usbnet *);
0132
0133
0134 int (*manage_power)(struct usbnet *, int);
0135
0136
0137 void (*status)(struct usbnet *, struct urb *);
0138
0139
0140 int (*link_reset)(struct usbnet *);
0141
0142
0143 int (*rx_fixup)(struct usbnet *dev, struct sk_buff *skb);
0144
0145
0146 struct sk_buff *(*tx_fixup)(struct usbnet *dev,
0147 struct sk_buff *skb, gfp_t flags);
0148
0149
0150 void (*recover)(struct usbnet *dev);
0151
0152
0153
0154
0155 int (*early_init)(struct usbnet *dev);
0156
0157
0158 void (*indication)(struct usbnet *dev, void *ind, int indlen);
0159
0160
0161 void (*set_rx_mode)(struct usbnet *dev);
0162
0163
0164 int in;
0165 int out;
0166
0167 unsigned long data;
0168 };
0169
0170
0171
0172
0173
0174 extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *);
0175 extern int usbnet_suspend(struct usb_interface *, pm_message_t);
0176 extern int usbnet_resume(struct usb_interface *);
0177 extern void usbnet_disconnect(struct usb_interface *);
0178 extern void usbnet_device_suggests_idle(struct usbnet *dev);
0179
0180 extern int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
0181 u16 value, u16 index, void *data, u16 size);
0182 extern int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
0183 u16 value, u16 index, const void *data, u16 size);
0184 extern int usbnet_read_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype,
0185 u16 value, u16 index, void *data, u16 size);
0186 extern int usbnet_write_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype,
0187 u16 value, u16 index, const void *data, u16 size);
0188 extern int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype,
0189 u16 value, u16 index, const void *data, u16 size);
0190
0191
0192
0193
0194
0195 struct cdc_state {
0196 struct usb_cdc_header_desc *header;
0197 struct usb_cdc_union_desc *u;
0198 struct usb_cdc_ether_desc *ether;
0199 struct usb_interface *control;
0200 struct usb_interface *data;
0201 };
0202
0203 extern void usbnet_cdc_update_filter(struct usbnet *dev);
0204 extern int usbnet_generic_cdc_bind(struct usbnet *, struct usb_interface *);
0205 extern int usbnet_ether_cdc_bind(struct usbnet *dev, struct usb_interface *intf);
0206 extern int usbnet_cdc_bind(struct usbnet *, struct usb_interface *);
0207 extern void usbnet_cdc_unbind(struct usbnet *, struct usb_interface *);
0208 extern void usbnet_cdc_status(struct usbnet *, struct urb *);
0209 extern int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb);
0210
0211
0212 #define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \
0213 |USB_CDC_PACKET_TYPE_ALL_MULTICAST \
0214 |USB_CDC_PACKET_TYPE_PROMISCUOUS \
0215 |USB_CDC_PACKET_TYPE_DIRECTED)
0216
0217
0218
0219 enum skb_state {
0220 illegal = 0,
0221 tx_start, tx_done,
0222 rx_start, rx_done, rx_cleanup,
0223 unlink_start
0224 };
0225
0226 struct skb_data {
0227 struct urb *urb;
0228 struct usbnet *dev;
0229 enum skb_state state;
0230 long length;
0231 unsigned long packets;
0232 };
0233
0234
0235
0236
0237 static inline void
0238 usbnet_set_skb_tx_stats(struct sk_buff *skb,
0239 unsigned long packets, long bytes_delta)
0240 {
0241 struct skb_data *entry = (struct skb_data *) skb->cb;
0242
0243 entry->packets = packets;
0244 entry->length = bytes_delta;
0245 }
0246
0247 extern int usbnet_open(struct net_device *net);
0248 extern int usbnet_stop(struct net_device *net);
0249 extern netdev_tx_t usbnet_start_xmit(struct sk_buff *skb,
0250 struct net_device *net);
0251 extern void usbnet_tx_timeout(struct net_device *net, unsigned int txqueue);
0252 extern int usbnet_change_mtu(struct net_device *net, int new_mtu);
0253
0254 extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *);
0255 extern int usbnet_get_ethernet_addr(struct usbnet *, int);
0256 extern void usbnet_defer_kevent(struct usbnet *, int);
0257 extern void usbnet_skb_return(struct usbnet *, struct sk_buff *);
0258 extern void usbnet_unlink_rx_urbs(struct usbnet *);
0259
0260 extern void usbnet_pause_rx(struct usbnet *);
0261 extern void usbnet_resume_rx(struct usbnet *);
0262 extern void usbnet_purge_paused_rxq(struct usbnet *);
0263
0264 extern int usbnet_get_link_ksettings_mii(struct net_device *net,
0265 struct ethtool_link_ksettings *cmd);
0266 extern int usbnet_set_link_ksettings_mii(struct net_device *net,
0267 const struct ethtool_link_ksettings *cmd);
0268 extern int usbnet_get_link_ksettings_internal(struct net_device *net,
0269 struct ethtool_link_ksettings *cmd);
0270 extern u32 usbnet_get_link(struct net_device *net);
0271 extern u32 usbnet_get_msglevel(struct net_device *);
0272 extern void usbnet_set_msglevel(struct net_device *, u32);
0273 extern void usbnet_set_rx_mode(struct net_device *net);
0274 extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
0275 extern int usbnet_nway_reset(struct net_device *net);
0276
0277 extern int usbnet_manage_power(struct usbnet *, int);
0278 extern void usbnet_link_change(struct usbnet *, bool, bool);
0279
0280 extern int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags);
0281 extern void usbnet_status_stop(struct usbnet *dev);
0282
0283 extern void usbnet_update_max_qlen(struct usbnet *dev);
0284
0285 #endif