Commit | Line | Data |
---|---|---|
2ca20f79 G |
1 | /****************************************************************************** |
2 | * | |
3 | * Copyright(c) 2009-2011 Realtek Corporation. All rights reserved. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms of version 2 of the GNU General Public License as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along with | |
15 | * this program; if not, write to the Free Software Foundation, Inc., | |
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA | |
17 | * | |
18 | * The full GNU General Public License is included in this distribution in the | |
19 | * file called LICENSE. | |
20 | * | |
21 | * Contact Information: | |
22 | * wlanfae <wlanfae@realtek.com> | |
23 | * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | |
24 | * Hsinchu 300, Taiwan. | |
25 | * | |
26 | *****************************************************************************/ | |
27 | ||
28 | #ifndef __RTL_USB_H__ | |
29 | #define __RTL_USB_H__ | |
30 | ||
31 | #include <linux/usb.h> | |
32 | #include <linux/skbuff.h> | |
33 | ||
34 | #define RTL_USB_DEVICE(vend, prod, cfg) \ | |
35 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ | |
36 | .idVendor = (vend), \ | |
37 | .idProduct = (prod), \ | |
38 | .driver_info = (kernel_ulong_t)&(cfg) | |
39 | ||
40 | #define USB_HIGH_SPEED_BULK_SIZE 512 | |
41 | #define USB_FULL_SPEED_BULK_SIZE 64 | |
42 | ||
43 | ||
44 | #define RTL_USB_MAX_TXQ_NUM 4 /* max tx queue */ | |
45 | #define RTL_USB_MAX_EP_NUM 6 /* max ep number */ | |
46 | #define RTL_USB_MAX_TX_URBS_NUM 8 | |
47 | ||
48 | enum rtl_txq { | |
49 | /* These definitions shall be consistent with value | |
50 | * returned by skb_get_queue_mapping | |
51 | *------------------------------------*/ | |
52 | RTL_TXQ_BK, | |
53 | RTL_TXQ_BE, | |
54 | RTL_TXQ_VI, | |
55 | RTL_TXQ_VO, | |
56 | /*------------------------------------*/ | |
57 | RTL_TXQ_BCN, | |
58 | RTL_TXQ_MGT, | |
59 | RTL_TXQ_HI, | |
60 | ||
61 | /* Must be last */ | |
62 | __RTL_TXQ_NUM, | |
63 | }; | |
64 | ||
65 | struct rtl_ep_map { | |
66 | u32 ep_mapping[__RTL_TXQ_NUM]; | |
67 | }; | |
68 | ||
69 | struct _trx_info { | |
70 | struct rtl_usb *rtlusb; | |
71 | u32 ep_num; | |
72 | }; | |
73 | ||
74 | static inline void _rtl_install_trx_info(struct rtl_usb *rtlusb, | |
75 | struct sk_buff *skb, | |
76 | u32 ep_num) | |
77 | { | |
78 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | |
79 | info->rate_driver_data[0] = rtlusb; | |
80 | info->rate_driver_data[1] = (void *)(__kernel_size_t)ep_num; | |
81 | } | |
82 | ||
83 | ||
84 | /* Add suspend/resume later */ | |
85 | enum rtl_usb_state { | |
86 | USB_STATE_STOP = 0, | |
87 | USB_STATE_START = 1, | |
88 | }; | |
89 | ||
90 | #define IS_USB_STOP(rtlusb_ptr) (USB_STATE_STOP == (rtlusb_ptr)->state) | |
91 | #define IS_USB_START(rtlusb_ptr) (USB_STATE_START == (rtlusb_ptr)->state) | |
92 | #define SET_USB_STOP(rtlusb_ptr) \ | |
93 | do { \ | |
94 | (rtlusb_ptr)->state = USB_STATE_STOP; \ | |
95 | } while (0) | |
96 | ||
97 | #define SET_USB_START(rtlusb_ptr) \ | |
98 | do { \ | |
99 | (rtlusb_ptr)->state = USB_STATE_START; \ | |
100 | } while (0) | |
101 | ||
102 | struct rtl_usb { | |
103 | struct usb_device *udev; | |
104 | struct usb_interface *intf; | |
105 | enum rtl_usb_state state; | |
106 | ||
107 | /* Bcn control register setting */ | |
108 | u32 reg_bcn_ctrl_val; | |
109 | /* for 88/92cu card disable */ | |
110 | u8 disableHWSM; | |
111 | /*QOS & EDCA */ | |
112 | enum acm_method acm_method; | |
113 | /* irq . HIMR,HIMR_EX */ | |
114 | u32 irq_mask[2]; | |
115 | bool irq_enabled; | |
116 | ||
117 | u16 (*usb_mq_to_hwq)(u16 fc, u16 mac80211_queue_index); | |
118 | ||
119 | /* Tx */ | |
120 | u8 out_ep_nums ; | |
121 | u8 out_queue_sel; | |
122 | struct rtl_ep_map ep_map; | |
123 | ||
124 | u32 max_bulk_out_size; | |
125 | u32 tx_submitted_urbs; | |
126 | struct sk_buff_head tx_skb_queue[RTL_USB_MAX_EP_NUM]; | |
127 | ||
128 | struct usb_anchor tx_pending[RTL_USB_MAX_EP_NUM]; | |
129 | struct usb_anchor tx_submitted; | |
130 | ||
131 | struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *, | |
132 | struct sk_buff_head *); | |
133 | int (*usb_tx_post_hdl)(struct ieee80211_hw *, | |
134 | struct urb *, struct sk_buff *); | |
135 | void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *); | |
136 | ||
137 | /* Rx */ | |
138 | u8 in_ep_nums ; | |
139 | u32 in_ep; /* Bulk IN endpoint number */ | |
140 | u32 rx_max_size; /* Bulk IN max buffer size */ | |
141 | u32 rx_urb_num; /* How many Bulk INs are submitted to host. */ | |
142 | struct usb_anchor rx_submitted; | |
143 | void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *, | |
144 | struct sk_buff_head *); | |
145 | void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *); | |
146 | }; | |
147 | ||
148 | struct rtl_usb_priv { | |
149 | struct rtl_usb dev; | |
150 | struct rtl_led_ctl ledctl; | |
151 | }; | |
152 | ||
153 | #define rtl_usbpriv(hw) (((struct rtl_usb_priv *)(rtl_priv(hw))->priv)) | |
154 | #define rtl_usbdev(usbpriv) (&((usbpriv)->dev)) | |
155 | ||
156 | ||
157 | ||
158 | int __devinit rtl_usb_probe(struct usb_interface *intf, | |
159 | const struct usb_device_id *id); | |
160 | void rtl_usb_disconnect(struct usb_interface *intf); | |
161 | int rtl_usb_suspend(struct usb_interface *pusb_intf, pm_message_t message); | |
162 | int rtl_usb_resume(struct usb_interface *pusb_intf); | |
163 | ||
164 | #endif |