1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
7 #include <linux/skbuff.h>
9 #define RTL_RX_DESC_SIZE 24
11 #define RTL_USB_DEVICE(vend, prod, cfg) \
12 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
14 .idProduct = (prod), \
15 .driver_info = (kernel_ulong_t)&(cfg)
17 #define USB_HIGH_SPEED_BULK_SIZE 512
18 #define USB_FULL_SPEED_BULK_SIZE 64
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_BULKOUT_NUM 4
23 #define RTL_USB_MAX_TX_URBS_NUM 8
26 /* These definitions shall be consistent with value
27 * returned by skb_get_queue_mapping
28 *------------------------------------*/
33 /*------------------------------------*/
43 u32 ep_mapping[__RTL_TXQ_NUM];
47 struct rtl_usb *rtlusb;
51 static inline void _rtl_install_trx_info(struct rtl_usb *rtlusb,
55 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
57 info->rate_driver_data[0] = rtlusb;
58 info->rate_driver_data[1] = (void *)(__kernel_size_t)ep_num;
61 /* Add suspend/resume later */
67 #define IS_USB_STOP(rtlusb_ptr) (USB_STATE_STOP == (rtlusb_ptr)->state)
68 #define IS_USB_START(rtlusb_ptr) (USB_STATE_START == (rtlusb_ptr)->state)
69 #define SET_USB_STOP(rtlusb_ptr) \
71 (rtlusb_ptr)->state = USB_STATE_STOP; \
74 #define SET_USB_START(rtlusb_ptr) \
76 (rtlusb_ptr)->state = USB_STATE_START; \
80 struct usb_device *udev;
81 struct usb_interface *intf;
82 enum rtl_usb_state state;
84 /* Bcn control register setting */
86 /* for 88/92cu card disable */
89 enum acm_method acm_method;
90 /* irq . HIMR,HIMR_EX */
94 u16 (*usb_mq_to_hwq)(__le16 fc, u16 mac80211_queue_index);
98 u8 out_eps[RTL_USB_MAX_BULKOUT_NUM];
100 struct rtl_ep_map ep_map;
102 u32 max_bulk_out_size;
103 u32 tx_submitted_urbs;
104 struct sk_buff_head tx_skb_queue[RTL_USB_MAX_EP_NUM];
106 struct usb_anchor tx_pending[RTL_USB_MAX_EP_NUM];
107 struct usb_anchor tx_submitted;
109 struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *,
110 struct sk_buff_head *);
111 int (*usb_tx_post_hdl)(struct ieee80211_hw *,
112 struct urb *, struct sk_buff *);
113 void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *);
117 u32 in_ep; /* Bulk IN endpoint number */
118 u32 rx_max_size; /* Bulk IN max buffer size */
119 u32 rx_urb_num; /* How many Bulk INs are submitted to host. */
120 struct usb_anchor rx_submitted;
121 struct usb_anchor rx_cleanup_urbs;
122 struct tasklet_struct rx_work_tasklet;
123 struct sk_buff_head rx_queue;
124 void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *,
125 struct sk_buff_head *);
126 void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *);
129 struct rtl_usb_priv {
130 struct bt_coexist_info bt_coexist;
134 #define rtl_usbpriv(hw) (((struct rtl_usb_priv *)(rtl_priv(hw))->priv))
135 #define rtl_usbdev(usbpriv) (&((usbpriv)->dev))
137 int rtl_usb_probe(struct usb_interface *intf,
138 const struct usb_device_id *id,
139 const struct rtl_hal_cfg *rtl92cu_hal_cfg);
140 void rtl_usb_disconnect(struct usb_interface *intf);
141 int rtl_usb_suspend(struct usb_interface *pusb_intf, pm_message_t message);
142 int rtl_usb_resume(struct usb_interface *pusb_intf);