usb_ops.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 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. *
  19. ******************************************************************************/
  20. #ifndef __USB_OPS_H_
  21. #define __USB_OPS_H_
  22. #define REALTEK_USB_VENQT_READ 0xC0
  23. #define REALTEK_USB_VENQT_WRITE 0x40
  24. #define REALTEK_USB_VENQT_CMD_REQ 0x05
  25. #define REALTEK_USB_VENQT_CMD_IDX 0x00
  26. enum{
  27. VENDOR_WRITE = 0x00,
  28. VENDOR_READ = 0x01,
  29. };
  30. #define ALIGNMENT_UNIT 16
  31. #define MAX_VENDOR_REQ_CMD_SIZE 254 //8188cu SIE Support
  32. #define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE +ALIGNMENT_UNIT)
  33. #ifdef PLATFORM_LINUX
  34. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12))
  35. #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size, timeout_ms) \
  36. usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), (timeout_ms))
  37. #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \
  38. usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), (timeout_ms))
  39. #else
  40. #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size,timeout_ms) \
  41. usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), \
  42. ((timeout_ms) == 0) ||((timeout_ms)*HZ/1000>0)?((timeout_ms)*HZ/1000):1)
  43. #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \
  44. usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \
  45. ((timeout_ms) == 0) ||((timeout_ms)*HZ/1000>0)?((timeout_ms)*HZ/1000):1)
  46. #endif
  47. #include <usb_ops_linux.h>
  48. #endif //PLATFORM_LINUX
  49. #ifdef CONFIG_RTL8192C
  50. void rtl8192cu_set_hw_type(_adapter *padapter);
  51. void rtl8192cu_set_intf_ops(struct _io_ops *pops);
  52. void rtl8192cu_recv_tasklet(void *priv);
  53. void rtl8192cu_xmit_tasklet(void *priv);
  54. #endif
  55. #ifdef CONFIG_RTL8723A
  56. void rtl8723au_set_hw_type(_adapter *padapter);
  57. void rtl8723au_set_intf_ops(struct _io_ops *pops);
  58. void rtl8192cu_recv_tasklet(void *priv);
  59. void rtl8192cu_xmit_tasklet(void *priv);
  60. #endif
  61. #ifdef CONFIG_RTL8192D
  62. void rtl8192du_set_hw_type(_adapter *padapter);
  63. void rtl8192du_set_intf_ops(struct _io_ops *pops);
  64. #ifndef PLATFORM_FREEBSD
  65. void rtl8192du_recv_tasklet(void *priv);
  66. #else // PLATFORM_FREEBSD
  67. void rtl8192du_recv_tasklet(void *priv, int npending);
  68. #ifdef CONFIG_RX_INDICATE_QUEUE
  69. void rtw_rx_indicate_tasklet(void *priv, int npending);
  70. #endif // CONFIG_RX_INDICATE_QUEUE
  71. #endif // PLATFORM_FREEBSD
  72. void rtl8192du_xmit_tasklet(void *priv);
  73. #endif
  74. #ifdef CONFIG_RTL8188E
  75. void rtl8188eu_set_hw_type(_adapter *padapter);
  76. void rtl8188eu_set_intf_ops(struct _io_ops *pops);
  77. #endif
  78. #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A)
  79. void rtl8812au_set_hw_type(_adapter *padapter);
  80. void rtl8812au_set_intf_ops(struct _io_ops *pops);
  81. #endif
  82. #ifdef CONFIG_RTL8192E
  83. void rtl8192eu_set_hw_type(_adapter *padapter);
  84. void rtl8192eu_set_intf_ops(struct _io_ops *pops);
  85. #endif
  86. /*
  87. * Increase and check if the continual_urb_error of this @param dvobjprive is larger than MAX_CONTINUAL_URB_ERR
  88. * @return _TRUE:
  89. * @return _FALSE:
  90. */
  91. static inline int rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj)
  92. {
  93. int ret = _FALSE;
  94. int value;
  95. if( (value=ATOMIC_INC_RETURN(&dvobj->continual_urb_error)) > MAX_CONTINUAL_URB_ERR) {
  96. DBG_871X("[dvobj:%p][ERROR] continual_urb_error:%d > %d\n", dvobj, value, MAX_CONTINUAL_URB_ERR);
  97. ret = _TRUE;
  98. } else {
  99. //DBG_871X("[dvobj:%p] continual_urb_error:%d\n", dvobj, value);
  100. }
  101. return ret;
  102. }
  103. /*
  104. * Set the continual_urb_error of this @param dvobjprive to 0
  105. */
  106. static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj)
  107. {
  108. ATOMIC_SET(&dvobj->continual_urb_error, 0);
  109. }
  110. enum RTW_USB_SPEED {
  111. RTW_USB_SPEED_UNKNOWN = 0,
  112. RTW_USB_SPEED_1_1 = 1,
  113. RTW_USB_SPEED_2 = 2,
  114. RTW_USB_SPEED_3 = 3,
  115. };
  116. #define IS_FULL_SPEED_USB(Adapter) (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_1_1)
  117. #define IS_HIGH_SPEED_USB(Adapter) (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_2)
  118. #define IS_SUPER_SPEED_USB(Adapter) (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_3)
  119. #define USB_SUPER_SPEED_BULK_SIZE 1024 // usb 3.0
  120. #define USB_HIGH_SPEED_BULK_SIZE 512 // usb 2.0
  121. #define USB_FULL_SPEED_BULK_SIZE 64 // usb 1.1
  122. static inline u8 rtw_usb_bulk_size_boundary(_adapter * padapter,int buf_len)
  123. {
  124. u8 rst = _TRUE;
  125. if (IS_SUPER_SPEED_USB(padapter))
  126. rst = (0 == (buf_len) % USB_SUPER_SPEED_BULK_SIZE)?_TRUE:_FALSE;
  127. if (IS_HIGH_SPEED_USB(padapter))
  128. rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE)?_TRUE:_FALSE;
  129. else
  130. rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE)?_TRUE:_FALSE;
  131. return rst;
  132. }
  133. #endif //__USB_OPS_H_