usb.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /* Copyright(c) 2018-2019 Realtek Corporation
  3. */
  4. #ifndef __RTW_USB_H_
  5. #define __RTW_USB_H_
  6. #define FW_8192C_START_ADDRESS 0x1000
  7. #define FW_8192C_END_ADDRESS 0x5fff
  8. #define RTW_USB_MAX_RXTX_COUNT 128
  9. #define RTW_USB_VENQT_MAX_BUF_SIZE 254
  10. #define MAX_USBCTRL_VENDORREQ_TIMES 10
  11. #define RTW_USB_CMD_READ 0xc0
  12. #define RTW_USB_CMD_WRITE 0x40
  13. #define RTW_USB_CMD_REQ 0x05
  14. #define RTW_USB_VENQT_CMD_IDX 0x00
  15. #define RTW_USB_SUPER_SPEED_BULK_SIZE 1024
  16. #define RTW_USB_HIGH_SPEED_BULK_SIZE 512
  17. #define RTW_USB_FULL_SPEED_BULK_SIZE 64
  18. #define RTW_USB_TX_SEL_HQ BIT(0)
  19. #define RTW_USB_TX_SEL_LQ BIT(1)
  20. #define RTW_USB_TX_SEL_NQ BIT(2)
  21. #define RTW_USB_TX_SEL_EQ BIT(3)
  22. #define RTW_USB_BULK_IN_ADDR 0x80
  23. #define RTW_USB_INT_IN_ADDR 0x81
  24. #define RTW_USB_HW_QUEUE_ENTRY 8
  25. #define RTW_USB_PACKET_OFFSET_SZ 8
  26. #define RTW_USB_MAX_XMITBUF_SZ (1024 * 20)
  27. #define RTW_USB_MAX_RECVBUF_SZ 32768
  28. #define RTW_USB_RECVBUFF_ALIGN_SZ 8
  29. #define RTW_USB_RXAGG_SIZE 6
  30. #define RTW_USB_RXAGG_TIMEOUT 10
  31. #define RTW_USB_RXCB_NUM 4
  32. #define RTW_USB_EP_MAX 4
  33. #define TX_DESC_QSEL_MAX 20
  34. #define RTW_USB_VENDOR_ID_REALTEK 0x0bda
  35. static inline struct rtw89_usb *rtw_get_usb_priv(struct rtw89_dev *rtwdev)
  36. {
  37. return (struct rtw89_usb *)rtwdev->priv;
  38. }
  39. struct rx_usb_ctrl_block {
  40. struct rtw89_dev *rtwdev;
  41. struct urb *rx_urb;
  42. struct sk_buff *rx_skb;
  43. int n;
  44. };
  45. struct rtw89_usb_tx_data {
  46. u8 sn;
  47. };
  48. struct rtw89_usb {
  49. struct rtw89_dev *rtwdev;
  50. struct usb_device *udev;
  51. /* protects usb_data_index */
  52. spinlock_t usb_lock;
  53. __le32 *usb_data;
  54. unsigned int usb_data_index;
  55. u32 bulkout_size;
  56. u8 pipe_interrupt;
  57. u8 pipe_in;
  58. u8 out_ep[RTW_USB_EP_MAX];
  59. u8 qsel_to_ep[TX_DESC_QSEL_MAX];
  60. u8 usb_txagg_num;
  61. struct workqueue_struct *txwq, *rxwq;
  62. struct sk_buff_head tx_queue[RTW_USB_EP_MAX];
  63. struct work_struct tx_work;
  64. struct rx_usb_ctrl_block rx_cb[RTW_USB_RXCB_NUM];
  65. struct sk_buff_head rx_queue;
  66. struct work_struct rx_work;
  67. };
  68. static inline struct rtw89_usb_tx_data *rtw_usb_get_tx_data(struct sk_buff *skb)
  69. {
  70. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  71. BUILD_BUG_ON(sizeof(struct rtw89_usb_tx_data) >
  72. sizeof(info->status.status_driver_data));
  73. return (struct rtw89_usb_tx_data *)info->status.status_driver_data;
  74. }
  75. int rtw89_usb_probe(struct usb_interface *intf, const struct usb_device_id *id);
  76. void rtw89_usb_disconnect(struct usb_interface *intf);
  77. #endif