Larry Finger | d27a76f | 2019-02-14 13:59:08 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* Copyright(c) 2009-2012 Realtek Corporation.*/ |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 3 | |
| 4 | #ifndef __RTL_USB_H__ |
| 5 | #define __RTL_USB_H__ |
| 6 | |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 7 | #include <linux/skbuff.h> |
| 8 | |
Chaoming_Li | acd4857 | 2011-04-25 12:52:54 -0500 | [diff] [blame] | 9 | #define RTL_RX_DESC_SIZE 24 |
| 10 | |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 11 | #define RTL_USB_DEVICE(vend, prod, cfg) \ |
| 12 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ |
| 13 | .idVendor = (vend), \ |
| 14 | .idProduct = (prod), \ |
| 15 | .driver_info = (kernel_ulong_t)&(cfg) |
| 16 | |
| 17 | #define USB_HIGH_SPEED_BULK_SIZE 512 |
| 18 | #define USB_FULL_SPEED_BULK_SIZE 64 |
| 19 | |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 20 | #define RTL_USB_MAX_TXQ_NUM 4 /* max tx queue */ |
| 21 | #define RTL_USB_MAX_EP_NUM 6 /* max ep number */ |
| 22 | #define RTL_USB_MAX_TX_URBS_NUM 8 |
| 23 | |
| 24 | enum rtl_txq { |
| 25 | /* These definitions shall be consistent with value |
| 26 | * returned by skb_get_queue_mapping |
| 27 | *------------------------------------*/ |
| 28 | RTL_TXQ_BK, |
| 29 | RTL_TXQ_BE, |
| 30 | RTL_TXQ_VI, |
| 31 | RTL_TXQ_VO, |
| 32 | /*------------------------------------*/ |
| 33 | RTL_TXQ_BCN, |
| 34 | RTL_TXQ_MGT, |
| 35 | RTL_TXQ_HI, |
| 36 | |
| 37 | /* Must be last */ |
| 38 | __RTL_TXQ_NUM, |
| 39 | }; |
| 40 | |
| 41 | struct rtl_ep_map { |
| 42 | u32 ep_mapping[__RTL_TXQ_NUM]; |
| 43 | }; |
| 44 | |
| 45 | struct _trx_info { |
| 46 | struct rtl_usb *rtlusb; |
| 47 | u32 ep_num; |
| 48 | }; |
| 49 | |
| 50 | static inline void _rtl_install_trx_info(struct rtl_usb *rtlusb, |
| 51 | struct sk_buff *skb, |
| 52 | u32 ep_num) |
| 53 | { |
| 54 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
Larry Finger | 9366509 | 2019-02-21 13:31:11 -0600 | [diff] [blame] | 55 | |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 56 | info->rate_driver_data[0] = rtlusb; |
| 57 | info->rate_driver_data[1] = (void *)(__kernel_size_t)ep_num; |
| 58 | } |
| 59 | |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 60 | /* Add suspend/resume later */ |
| 61 | enum rtl_usb_state { |
| 62 | USB_STATE_STOP = 0, |
| 63 | USB_STATE_START = 1, |
| 64 | }; |
| 65 | |
| 66 | #define IS_USB_STOP(rtlusb_ptr) (USB_STATE_STOP == (rtlusb_ptr)->state) |
| 67 | #define IS_USB_START(rtlusb_ptr) (USB_STATE_START == (rtlusb_ptr)->state) |
| 68 | #define SET_USB_STOP(rtlusb_ptr) \ |
| 69 | do { \ |
| 70 | (rtlusb_ptr)->state = USB_STATE_STOP; \ |
| 71 | } while (0) |
| 72 | |
| 73 | #define SET_USB_START(rtlusb_ptr) \ |
| 74 | do { \ |
| 75 | (rtlusb_ptr)->state = USB_STATE_START; \ |
| 76 | } while (0) |
| 77 | |
| 78 | struct rtl_usb { |
| 79 | struct usb_device *udev; |
| 80 | struct usb_interface *intf; |
| 81 | enum rtl_usb_state state; |
| 82 | |
| 83 | /* Bcn control register setting */ |
| 84 | u32 reg_bcn_ctrl_val; |
| 85 | /* for 88/92cu card disable */ |
Larry Finger | e703c5d | 2019-02-14 16:36:37 -0600 | [diff] [blame] | 86 | u8 disablehwsm; |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 87 | /*QOS & EDCA */ |
| 88 | enum acm_method acm_method; |
| 89 | /* irq . HIMR,HIMR_EX */ |
| 90 | u32 irq_mask[2]; |
| 91 | bool irq_enabled; |
| 92 | |
Larry Finger | 17c9ac6 | 2011-02-19 16:29:57 -0600 | [diff] [blame] | 93 | u16 (*usb_mq_to_hwq)(__le16 fc, u16 mac80211_queue_index); |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 94 | |
| 95 | /* Tx */ |
| 96 | u8 out_ep_nums ; |
| 97 | u8 out_queue_sel; |
| 98 | struct rtl_ep_map ep_map; |
| 99 | |
| 100 | u32 max_bulk_out_size; |
| 101 | u32 tx_submitted_urbs; |
| 102 | struct sk_buff_head tx_skb_queue[RTL_USB_MAX_EP_NUM]; |
| 103 | |
| 104 | struct usb_anchor tx_pending[RTL_USB_MAX_EP_NUM]; |
| 105 | struct usb_anchor tx_submitted; |
| 106 | |
| 107 | struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *, |
| 108 | struct sk_buff_head *); |
| 109 | int (*usb_tx_post_hdl)(struct ieee80211_hw *, |
| 110 | struct urb *, struct sk_buff *); |
| 111 | void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *); |
| 112 | |
| 113 | /* Rx */ |
Jussi Kivilinna | 29bb701 | 2013-03-17 11:59:24 +0200 | [diff] [blame] | 114 | u8 in_ep_nums; |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 115 | u32 in_ep; /* Bulk IN endpoint number */ |
| 116 | u32 rx_max_size; /* Bulk IN max buffer size */ |
| 117 | u32 rx_urb_num; /* How many Bulk INs are submitted to host. */ |
| 118 | struct usb_anchor rx_submitted; |
Jussi Kivilinna | 872de8f | 2013-03-17 11:59:13 +0200 | [diff] [blame] | 119 | struct usb_anchor rx_cleanup_urbs; |
Jussi Kivilinna | 29bb701 | 2013-03-17 11:59:24 +0200 | [diff] [blame] | 120 | struct tasklet_struct rx_work_tasklet; |
| 121 | struct sk_buff_head rx_queue; |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 122 | void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *, |
| 123 | struct sk_buff_head *); |
| 124 | void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *); |
| 125 | }; |
| 126 | |
| 127 | struct rtl_usb_priv { |
Larry Finger | 6773386 | 2017-02-05 10:24:22 -0600 | [diff] [blame] | 128 | struct bt_coexist_info bt_coexist; |
Larry Finger | 6773386 | 2017-02-05 10:24:22 -0600 | [diff] [blame] | 129 | struct rtl_usb dev; |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | #define rtl_usbpriv(hw) (((struct rtl_usb_priv *)(rtl_priv(hw))->priv)) |
| 133 | #define rtl_usbdev(usbpriv) (&((usbpriv)->dev)) |
| 134 | |
Bill Pemberton | 9e2ff36 | 2012-12-03 09:56:43 -0500 | [diff] [blame] | 135 | int rtl_usb_probe(struct usb_interface *intf, |
Larry Finger | 957f4ac | 2013-02-06 12:54:17 -0600 | [diff] [blame] | 136 | const struct usb_device_id *id, |
| 137 | struct rtl_hal_cfg *rtl92cu_hal_cfg); |
George | 2ca20f7 | 2011-02-11 14:27:49 -0600 | [diff] [blame] | 138 | void rtl_usb_disconnect(struct usb_interface *intf); |
| 139 | int rtl_usb_suspend(struct usb_interface *pusb_intf, pm_message_t message); |
| 140 | int rtl_usb_resume(struct usb_interface *pusb_intf); |
| 141 | |
| 142 | #endif |