usb.h 4.6 KB

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