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 * The full GNU General Public License is included in this distribution in the 15 * file called LICENSE. 16 * 17 * Contact Information: 18 * wlanfae <wlanfae@realtek.com> 19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, 20 * Hsinchu 300, Taiwan. 21 * 22 *****************************************************************************/ 23 24 #ifndef __RTL_USB_H__ 25 #define __RTL_USB_H__ 26 27 #include <linux/skbuff.h> 28 29 #define RTL_RX_DESC_SIZE 24 30 31 #define RTL_USB_DEVICE(vend, prod, cfg) \ 32 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ 33 .idVendor = (vend), \ 34 .idProduct = (prod), \ 35 .driver_info = (kernel_ulong_t)&(cfg) 36 37 #define USB_HIGH_SPEED_BULK_SIZE 512 38 #define USB_FULL_SPEED_BULK_SIZE 64 39 40 41 #define RTL_USB_MAX_TXQ_NUM 4 /* max tx queue */ 42 #define RTL_USB_MAX_EP_NUM 6 /* max ep number */ 43 #define RTL_USB_MAX_TX_URBS_NUM 8 44 45 enum rtl_txq { 46 /* These definitions shall be consistent with value 47 * returned by skb_get_queue_mapping 48 *------------------------------------*/ 49 RTL_TXQ_BK, 50 RTL_TXQ_BE, 51 RTL_TXQ_VI, 52 RTL_TXQ_VO, 53 /*------------------------------------*/ 54 RTL_TXQ_BCN, 55 RTL_TXQ_MGT, 56 RTL_TXQ_HI, 57 58 /* Must be last */ 59 __RTL_TXQ_NUM, 60 }; 61 62 struct rtl_ep_map { 63 u32 ep_mapping[__RTL_TXQ_NUM]; 64 }; 65 66 struct _trx_info { 67 struct rtl_usb *rtlusb; 68 u32 ep_num; 69 }; 70 71 static inline void _rtl_install_trx_info(struct rtl_usb *rtlusb, 72 struct sk_buff *skb, 73 u32 ep_num) 74 { 75 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 76 info->rate_driver_data[0] = rtlusb; 77 info->rate_driver_data[1] = (void *)(__kernel_size_t)ep_num; 78 } 79 80 81 /* Add suspend/resume later */ 82 enum rtl_usb_state { 83 USB_STATE_STOP = 0, 84 USB_STATE_START = 1, 85 }; 86 87 #define IS_USB_STOP(rtlusb_ptr) (USB_STATE_STOP == (rtlusb_ptr)->state) 88 #define IS_USB_START(rtlusb_ptr) (USB_STATE_START == (rtlusb_ptr)->state) 89 #define SET_USB_STOP(rtlusb_ptr) \ 90 do { \ 91 (rtlusb_ptr)->state = USB_STATE_STOP; \ 92 } while (0) 93 94 #define SET_USB_START(rtlusb_ptr) \ 95 do { \ 96 (rtlusb_ptr)->state = USB_STATE_START; \ 97 } while (0) 98 99 struct rtl_usb { 100 struct usb_device *udev; 101 struct usb_interface *intf; 102 enum rtl_usb_state state; 103 104 /* Bcn control register setting */ 105 u32 reg_bcn_ctrl_val; 106 /* for 88/92cu card disable */ 107 u8 disableHWSM; 108 /*QOS & EDCA */ 109 enum acm_method acm_method; 110 /* irq . HIMR,HIMR_EX */ 111 u32 irq_mask[2]; 112 bool irq_enabled; 113 114 u16 (*usb_mq_to_hwq)(__le16 fc, u16 mac80211_queue_index); 115 116 /* Tx */ 117 u8 out_ep_nums ; 118 u8 out_queue_sel; 119 struct rtl_ep_map ep_map; 120 121 u32 max_bulk_out_size; 122 u32 tx_submitted_urbs; 123 struct sk_buff_head tx_skb_queue[RTL_USB_MAX_EP_NUM]; 124 125 struct usb_anchor tx_pending[RTL_USB_MAX_EP_NUM]; 126 struct usb_anchor tx_submitted; 127 128 struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *, 129 struct sk_buff_head *); 130 int (*usb_tx_post_hdl)(struct ieee80211_hw *, 131 struct urb *, struct sk_buff *); 132 void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *); 133 134 /* Rx */ 135 u8 in_ep_nums; 136 u32 in_ep; /* Bulk IN endpoint number */ 137 u32 rx_max_size; /* Bulk IN max buffer size */ 138 u32 rx_urb_num; /* How many Bulk INs are submitted to host. */ 139 struct usb_anchor rx_submitted; 140 struct usb_anchor rx_cleanup_urbs; 141 struct tasklet_struct rx_work_tasklet; 142 struct sk_buff_head rx_queue; 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 rtl_usb_probe(struct usb_interface *intf, 159 const struct usb_device_id *id, 160 struct rtl_hal_cfg *rtl92cu_hal_cfg); 161 void rtl_usb_disconnect(struct usb_interface *intf); 162 int rtl_usb_suspend(struct usb_interface *pusb_intf, pm_message_t message); 163 int rtl_usb_resume(struct usb_interface *pusb_intf); 164 165 #endif 166