• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2009-2012  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/skbuff.h>
32 
33 #define RTL_RX_DESC_SIZE		24
34 
35 #define RTL_USB_DEVICE(vend, prod, cfg) \
36 	.match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
37 	.idVendor = (vend), \
38 	.idProduct = (prod), \
39 	.driver_info = (kernel_ulong_t)&(cfg)
40 
41 #define USB_HIGH_SPEED_BULK_SIZE	512
42 #define USB_FULL_SPEED_BULK_SIZE	64
43 
44 
45 #define RTL_USB_MAX_TXQ_NUM		4		/* max tx queue */
46 #define RTL_USB_MAX_EP_NUM		6		/* max ep number */
47 #define RTL_USB_MAX_TX_URBS_NUM		8
48 
49 enum rtl_txq {
50 	/* These definitions shall be consistent with value
51 	 * returned by skb_get_queue_mapping
52 	 *------------------------------------*/
53 	RTL_TXQ_BK,
54 	RTL_TXQ_BE,
55 	RTL_TXQ_VI,
56 	RTL_TXQ_VO,
57 	/*------------------------------------*/
58 	RTL_TXQ_BCN,
59 	RTL_TXQ_MGT,
60 	RTL_TXQ_HI,
61 
62 	/* Must be last */
63 	__RTL_TXQ_NUM,
64 };
65 
66 struct rtl_ep_map {
67 	u32 ep_mapping[__RTL_TXQ_NUM];
68 };
69 
70 struct _trx_info {
71 	struct rtl_usb *rtlusb;
72 	u32 ep_num;
73 };
74 
_rtl_install_trx_info(struct rtl_usb * rtlusb,struct sk_buff * skb,u32 ep_num)75 static inline void _rtl_install_trx_info(struct rtl_usb *rtlusb,
76 					 struct sk_buff *skb,
77 					 u32 ep_num)
78 {
79 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
80 	info->rate_driver_data[0] = rtlusb;
81 	info->rate_driver_data[1] = (void *)(__kernel_size_t)ep_num;
82 }
83 
84 
85 /*  Add suspend/resume later */
86 enum rtl_usb_state {
87 	USB_STATE_STOP	= 0,
88 	USB_STATE_START	= 1,
89 };
90 
91 #define IS_USB_STOP(rtlusb_ptr) (USB_STATE_STOP == (rtlusb_ptr)->state)
92 #define IS_USB_START(rtlusb_ptr) (USB_STATE_START == (rtlusb_ptr)->state)
93 #define SET_USB_STOP(rtlusb_ptr) \
94 	do {							\
95 		(rtlusb_ptr)->state = USB_STATE_STOP;		\
96 	} while (0)
97 
98 #define SET_USB_START(rtlusb_ptr)				\
99 	do { \
100 		(rtlusb_ptr)->state = USB_STATE_START;		\
101 	} while (0)
102 
103 struct rtl_usb {
104 	struct usb_device *udev;
105 	struct usb_interface *intf;
106 	enum rtl_usb_state state;
107 
108 	/* Bcn control register setting */
109 	u32 reg_bcn_ctrl_val;
110 	/* for 88/92cu card disable */
111 	u8	disableHWSM;
112 	/*QOS & EDCA */
113 	enum acm_method acm_method;
114 	/* irq  . HIMR,HIMR_EX */
115 	u32 irq_mask[2];
116 	bool irq_enabled;
117 
118 	u16 (*usb_mq_to_hwq)(__le16 fc, u16 mac80211_queue_index);
119 
120 	/* Tx */
121 	u8 out_ep_nums ;
122 	u8 out_queue_sel;
123 	struct rtl_ep_map ep_map;
124 
125 	u32 max_bulk_out_size;
126 	u32 tx_submitted_urbs;
127 	struct sk_buff_head tx_skb_queue[RTL_USB_MAX_EP_NUM];
128 
129 	struct usb_anchor tx_pending[RTL_USB_MAX_EP_NUM];
130 	struct usb_anchor tx_submitted;
131 
132 	struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *,
133 						struct sk_buff_head *);
134 	int (*usb_tx_post_hdl)(struct ieee80211_hw *,
135 			       struct urb *, struct sk_buff *);
136 	void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *);
137 
138 	/* Rx */
139 	u8 in_ep_nums;
140 	u32 in_ep;		/* Bulk IN endpoint number */
141 	u32 rx_max_size;	/* Bulk IN max buffer size */
142 	u32 rx_urb_num;		/* How many Bulk INs are submitted to host. */
143 	struct usb_anchor	rx_submitted;
144 	struct usb_anchor	rx_cleanup_urbs;
145 	struct tasklet_struct   rx_work_tasklet;
146 	struct sk_buff_head	rx_queue;
147 	void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *,
148 				     struct sk_buff_head *);
149 	void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *);
150 };
151 
152 struct rtl_usb_priv {
153 	struct bt_coexist_info bt_coexist;
154 	struct rtl_led_ctl ledctl;
155 	struct rtl_usb dev;
156 };
157 
158 #define rtl_usbpriv(hw)	 (((struct rtl_usb_priv *)(rtl_priv(hw))->priv))
159 #define rtl_usbdev(usbpriv)	(&((usbpriv)->dev))
160 
161 
162 
163 int rtl_usb_probe(struct usb_interface *intf,
164 		  const struct usb_device_id *id,
165 		  struct rtl_hal_cfg *rtl92cu_hal_cfg);
166 void rtl_usb_disconnect(struct usb_interface *intf);
167 int rtl_usb_suspend(struct usb_interface *pusb_intf, pm_message_t message);
168 int rtl_usb_resume(struct usb_interface *pusb_intf);
169 
170 #endif
171