blob: 3bf85b23eec1a313aac77ab9587653a13631e707 [file] [log] [blame]
Larry Fingerd27a76f2019-02-14 13:59:08 -06001/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright(c) 2009-2012 Realtek Corporation.*/
George2ca20f72011-02-11 14:27:49 -06003
4#ifndef __RTL_USB_H__
5#define __RTL_USB_H__
6
George2ca20f72011-02-11 14:27:49 -06007#include <linux/skbuff.h>
8
Chaoming_Liacd48572011-04-25 12:52:54 -05009#define RTL_RX_DESC_SIZE 24
10
George2ca20f72011-02-11 14:27:49 -060011#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
George2ca20f72011-02-11 14:27:49 -060020#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
24enum 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
41struct rtl_ep_map {
42 u32 ep_mapping[__RTL_TXQ_NUM];
43};
44
45struct _trx_info {
46 struct rtl_usb *rtlusb;
47 u32 ep_num;
48};
49
50static 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 Finger93665092019-02-21 13:31:11 -060055
George2ca20f72011-02-11 14:27:49 -060056 info->rate_driver_data[0] = rtlusb;
57 info->rate_driver_data[1] = (void *)(__kernel_size_t)ep_num;
58}
59
George2ca20f72011-02-11 14:27:49 -060060/* Add suspend/resume later */
61enum 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
78struct 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 Fingere703c5d2019-02-14 16:36:37 -060086 u8 disablehwsm;
George2ca20f72011-02-11 14:27:49 -060087 /*QOS & EDCA */
88 enum acm_method acm_method;
89 /* irq . HIMR,HIMR_EX */
90 u32 irq_mask[2];
91 bool irq_enabled;
92
Larry Finger17c9ac62011-02-19 16:29:57 -060093 u16 (*usb_mq_to_hwq)(__le16 fc, u16 mac80211_queue_index);
George2ca20f72011-02-11 14:27:49 -060094
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 Kivilinna29bb7012013-03-17 11:59:24 +0200114 u8 in_ep_nums;
George2ca20f72011-02-11 14:27:49 -0600115 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 Kivilinna872de8f2013-03-17 11:59:13 +0200119 struct usb_anchor rx_cleanup_urbs;
Jussi Kivilinna29bb7012013-03-17 11:59:24 +0200120 struct tasklet_struct rx_work_tasklet;
121 struct sk_buff_head rx_queue;
George2ca20f72011-02-11 14:27:49 -0600122 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
127struct rtl_usb_priv {
Larry Finger67733862017-02-05 10:24:22 -0600128 struct bt_coexist_info bt_coexist;
Larry Finger67733862017-02-05 10:24:22 -0600129 struct rtl_usb dev;
George2ca20f72011-02-11 14:27:49 -0600130};
131
132#define rtl_usbpriv(hw) (((struct rtl_usb_priv *)(rtl_priv(hw))->priv))
133#define rtl_usbdev(usbpriv) (&((usbpriv)->dev))
134
Bill Pemberton9e2ff362012-12-03 09:56:43 -0500135int rtl_usb_probe(struct usb_interface *intf,
Larry Finger957f4ac2013-02-06 12:54:17 -0600136 const struct usb_device_id *id,
137 struct rtl_hal_cfg *rtl92cu_hal_cfg);
George2ca20f72011-02-11 14:27:49 -0600138void rtl_usb_disconnect(struct usb_interface *intf);
139int rtl_usb_suspend(struct usb_interface *pusb_intf, pm_message_t message);
140int rtl_usb_resume(struct usb_interface *pusb_intf);
141
142#endif