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