• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */
3 
4 #include "../include/osdep_service.h"
5 #include "../include/drv_types.h"
6 #include "../include/osdep_intf.h"
7 #include "../include/usb_ops.h"
8 #include "../include/recv_osdep.h"
9 #include "../include/rtl8188e_hal.h"
10 
usbctrl_vendorreq(struct intf_hdl * pintfhdl,u16 value,void * pdata,u16 len,u8 requesttype)11 static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, void *pdata, u16 len, u8 requesttype)
12 {
13 	struct adapter	*adapt = pintfhdl->padapter;
14 	struct dvobj_priv  *dvobjpriv = adapter_to_dvobj(adapt);
15 	struct usb_device *udev = dvobjpriv->pusbdev;
16 	unsigned int pipe;
17 	int status = 0;
18 	u8 *pIo_buf;
19 	int vendorreq_times = 0;
20 
21 	if ((adapt->bSurpriseRemoved) || (adapt->pwrctrlpriv.pnp_bstop_trx)) {
22 		status = -EPERM;
23 		goto exit;
24 	}
25 
26 	if (len > MAX_VENDOR_REQ_CMD_SIZE) {
27 		DBG_88E("[%s] Buffer len error ,vendor request failed\n", __func__);
28 		status = -EINVAL;
29 		goto exit;
30 	}
31 
32 	_enter_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL);
33 
34 	/*  Acquire IO memory for vendorreq */
35 	pIo_buf = dvobjpriv->usb_vendor_req_buf;
36 
37 	if (!pIo_buf) {
38 		DBG_88E("[%s] pIo_buf == NULL\n", __func__);
39 		status = -ENOMEM;
40 		goto release_mutex;
41 	}
42 
43 	if (requesttype == REALTEK_USB_VENQT_READ)
44 		pipe = usb_rcvctrlpipe(udev, 0);/* read_in */
45 	else
46 		pipe = usb_sndctrlpipe(udev, 0);/* write_out */
47 
48 	while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) {
49 		if (requesttype == REALTEK_USB_VENQT_READ)
50 			memset(pIo_buf, 0, len);
51 		else
52 			memcpy(pIo_buf, pdata, len);
53 
54 		status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ,
55 					 requesttype, value, REALTEK_USB_VENQT_CMD_IDX,
56 					 pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT);
57 
58 		if (status == len) {   /*  Success this control transfer. */
59 			rtw_reset_continual_urb_error(dvobjpriv);
60 			if (requesttype == REALTEK_USB_VENQT_READ)
61 				memcpy(pdata, pIo_buf,  len);
62 		} else { /*  error cases */
63 			DBG_88E("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n",
64 				value, (requesttype == REALTEK_USB_VENQT_READ) ? "read" : "write",
65 				len, status, *(u32 *)pdata, vendorreq_times);
66 
67 			if (status < 0) {
68 				if (status == (-ESHUTDOWN) || status == -ENODEV) {
69 					adapt->bSurpriseRemoved = true;
70 				} else {
71 					struct hal_data_8188e	*haldata = GET_HAL_DATA(adapt);
72 					haldata->srestpriv.wifi_error_status = USB_VEN_REQ_CMD_FAIL;
73 				}
74 			} else { /*  status != len && status >= 0 */
75 				if (status > 0) {
76 					if (requesttype == REALTEK_USB_VENQT_READ) {
77 						/*  For Control read transfer, we have to copy the read data from pIo_buf to pdata. */
78 						memcpy(pdata, pIo_buf,  len);
79 					}
80 				}
81 			}
82 
83 			if (rtw_inc_and_chk_continual_urb_error(dvobjpriv)) {
84 				adapt->bSurpriseRemoved = true;
85 				break;
86 			}
87 
88 		}
89 
90 		/*  firmware download is checksumed, don't retry */
91 		if ((value >= FW_8188E_START_ADDRESS && value <= FW_8188E_END_ADDRESS) || status == len)
92 			break;
93 	}
94 release_mutex:
95 	_exit_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL);
96 exit:
97 	return status;
98 }
99 
usb_read8(struct intf_hdl * pintfhdl,u32 addr)100 static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
101 {
102 	u16 wvalue = (u16)(addr & 0x0000ffff);
103 	u8 data;
104 
105 	usbctrl_vendorreq(pintfhdl, wvalue, &data, 1, REALTEK_USB_VENQT_READ);
106 
107 	return data;
108 }
109 
usb_read16(struct intf_hdl * pintfhdl,u32 addr)110 static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
111 {
112 	u16 wvalue = (u16)(addr & 0x0000ffff);
113 	__le32 data;
114 
115 	usbctrl_vendorreq(pintfhdl, wvalue, &data, 2, REALTEK_USB_VENQT_READ);
116 
117 	return (u16)(le32_to_cpu(data) & 0xffff);
118 }
119 
usb_read32(struct intf_hdl * pintfhdl,u32 addr)120 static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
121 {
122 	u16 wvalue = (u16)(addr & 0x0000ffff);
123 	__le32 data;
124 
125 	usbctrl_vendorreq(pintfhdl, wvalue, &data, 4, REALTEK_USB_VENQT_READ);
126 
127 	return le32_to_cpu(data);
128 }
129 
usb_write8(struct intf_hdl * pintfhdl,u32 addr,u8 val)130 static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
131 {
132 	u16 wvalue = (u16)(addr & 0x0000ffff);
133 
134 	return usbctrl_vendorreq(pintfhdl, wvalue, &val, 1, REALTEK_USB_VENQT_WRITE);
135 }
136 
usb_write16(struct intf_hdl * pintfhdl,u32 addr,u16 val)137 static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
138 {
139 	u16 wvalue = (u16)(addr & 0x0000ffff);
140 	__le32 data = cpu_to_le32(val & 0x0000ffff);
141 
142 	return usbctrl_vendorreq(pintfhdl, wvalue, &data, 2, REALTEK_USB_VENQT_WRITE);
143 }
144 
usb_write32(struct intf_hdl * pintfhdl,u32 addr,u32 val)145 static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
146 {
147 	u16 wvalue = (u16)(addr & 0x0000ffff);
148 	__le32 data = cpu_to_le32(val);
149 
150 	return usbctrl_vendorreq(pintfhdl, wvalue, &data, 4, REALTEK_USB_VENQT_WRITE);
151 }
152 
usb_writeN(struct intf_hdl * pintfhdl,u32 addr,u32 length,u8 * pdata)153 static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata)
154 {
155 	u16 wvalue = (u16)(addr & 0x0000ffff);
156 	u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0};
157 
158 	if (length > VENDOR_CMD_MAX_DATA_LEN)
159 		return -EINVAL;
160 
161 	memcpy(buf, pdata, length);
162 
163 	return usbctrl_vendorreq(pintfhdl, wvalue, buf, (length & 0xffff), REALTEK_USB_VENQT_WRITE);
164 }
165 
interrupt_handler_8188eu(struct adapter * adapt,u16 pkt_len,u8 * pbuf)166 static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbuf)
167 {
168 	struct hal_data_8188e	*haldata = GET_HAL_DATA(adapt);
169 
170 	if (pkt_len != INTERRUPT_MSG_FORMAT_LEN) {
171 		DBG_88E("%s Invalid interrupt content length (%d)!\n", __func__, pkt_len);
172 		return;
173 	}
174 
175 	/*  HISR */
176 	memcpy(&haldata->IntArray[0], &pbuf[USB_INTR_CONTENT_HISR_OFFSET], 4);
177 	memcpy(&haldata->IntArray[1], &pbuf[USB_INTR_CONTENT_HISRE_OFFSET], 4);
178 
179 	/*  C2H Event */
180 	if (pbuf[0] != 0)
181 		memcpy(&haldata->C2hArray[0], &pbuf[USB_INTR_CONTENT_C2H_OFFSET], 16);
182 }
183 
recvbuf2recvframe(struct adapter * adapt,struct sk_buff * pskb)184 static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb)
185 {
186 	u8	*pbuf;
187 	u8	shift_sz = 0;
188 	u16	pkt_cnt;
189 	u32	pkt_offset, skb_len, alloc_sz;
190 	s32	transfer_len;
191 	struct recv_stat	*prxstat;
192 	struct phy_stat	*pphy_status = NULL;
193 	struct sk_buff *pkt_copy = NULL;
194 	struct recv_frame	*precvframe = NULL;
195 	struct rx_pkt_attrib	*pattrib = NULL;
196 	struct hal_data_8188e	*haldata = GET_HAL_DATA(adapt);
197 	struct recv_priv	*precvpriv = &adapt->recvpriv;
198 	struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue;
199 
200 	transfer_len = (s32)pskb->len;
201 	pbuf = pskb->data;
202 
203 	prxstat = (struct recv_stat *)pbuf;
204 	pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff;
205 
206 	do {
207 		prxstat = (struct recv_stat *)pbuf;
208 
209 		precvframe = rtw_alloc_recvframe(pfree_recv_queue);
210 		if (!precvframe) {
211 			DBG_88E("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __func__, __LINE__);
212 			goto _exit_recvbuf2recvframe;
213 		}
214 
215 		INIT_LIST_HEAD(&precvframe->list);
216 		precvframe->precvbuf = NULL;	/* can't access the precvbuf for new arch. */
217 		precvframe->len = 0;
218 
219 		update_recvframe_attrib_88e(precvframe, prxstat);
220 
221 		pattrib = &precvframe->attrib;
222 
223 		if ((pattrib->crc_err) || (pattrib->icv_err)) {
224 			DBG_88E("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __func__, pattrib->crc_err, pattrib->icv_err);
225 
226 			rtw_free_recvframe(precvframe, pfree_recv_queue);
227 			goto _exit_recvbuf2recvframe;
228 		}
229 
230 		if ((pattrib->physt) && (pattrib->pkt_rpt_type == NORMAL_RX))
231 			pphy_status = (struct phy_stat *)(pbuf + RXDESC_OFFSET);
232 
233 		pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len;
234 
235 		if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) {
236 			DBG_88E("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfoer_len\n", __func__, __LINE__);
237 			rtw_free_recvframe(precvframe, pfree_recv_queue);
238 			goto _exit_recvbuf2recvframe;
239 		}
240 
241 		/*	Modified by Albert 20101213 */
242 		/*	For 8 bytes IP header alignment. */
243 		if (pattrib->qos)	/*	Qos data, wireless lan header length is 26 */
244 			shift_sz = 6;
245 		else
246 			shift_sz = 0;
247 
248 		skb_len = pattrib->pkt_len;
249 
250 		/*  for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet. */
251 		/*  modify alloc_sz for recvive crc error packet by thomas 2011-06-02 */
252 		if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) {
253 			if (skb_len <= 1650)
254 				alloc_sz = 1664;
255 			else
256 				alloc_sz = skb_len + 14;
257 		} else {
258 			alloc_sz = skb_len;
259 			/*	6 is for IP header 8 bytes alignment in QoS packet case. */
260 			/*	8 is for skb->data 4 bytes alignment. */
261 			alloc_sz += 14;
262 		}
263 
264 		pkt_copy = netdev_alloc_skb(adapt->pnetdev, alloc_sz);
265 		if (pkt_copy) {
266 			pkt_copy->dev = adapt->pnetdev;
267 			precvframe->pkt = pkt_copy;
268 			precvframe->rx_head = pkt_copy->data;
269 			precvframe->rx_end = pkt_copy->data + alloc_sz;
270 			skb_reserve(pkt_copy, 8 - ((size_t)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */
271 			skb_reserve(pkt_copy, shift_sz);/* force ip_hdr at 8-byte alignment address according to shift_sz. */
272 			memcpy(pkt_copy->data, (pbuf + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len);
273 			precvframe->rx_tail = pkt_copy->data;
274 			precvframe->rx_data = pkt_copy->data;
275 		} else {
276 			if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) {
277 				DBG_88E("recvbuf2recvframe: alloc_skb fail , drop frag frame\n");
278 				rtw_free_recvframe(precvframe, pfree_recv_queue);
279 				goto _exit_recvbuf2recvframe;
280 			}
281 			precvframe->pkt = skb_clone(pskb, GFP_ATOMIC);
282 			if (precvframe->pkt) {
283 				precvframe->rx_tail = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE;
284 				precvframe->rx_head = precvframe->rx_tail;
285 				precvframe->rx_data = precvframe->rx_tail;
286 				precvframe->rx_end =  pbuf + pattrib->drvinfo_sz + RXDESC_SIZE + alloc_sz;
287 			} else {
288 				DBG_88E("recvbuf2recvframe: skb_clone fail\n");
289 				rtw_free_recvframe(precvframe, pfree_recv_queue);
290 				goto _exit_recvbuf2recvframe;
291 			}
292 		}
293 
294 		recvframe_put(precvframe, skb_len);
295 
296 		switch (haldata->UsbRxAggMode) {
297 		case USB_RX_AGG_DMA:
298 		case USB_RX_AGG_MIX:
299 			pkt_offset = (u16)_RND128(pkt_offset);
300 			break;
301 		case USB_RX_AGG_USB:
302 			pkt_offset = (u16)_RND4(pkt_offset);
303 			break;
304 		case USB_RX_AGG_DISABLE:
305 		default:
306 			break;
307 		}
308 		if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */
309 			if (pattrib->physt)
310 				update_recvframe_phyinfo_88e(precvframe, (struct phy_stat *)pphy_status);
311 			rtw_recv_entry(precvframe);
312 		} else {
313 			/* enqueue recvframe to txrtp queue */
314 			if (pattrib->pkt_rpt_type == TX_REPORT1) {
315 				/* CCX-TXRPT ack for xmit mgmt frames. */
316 				handle_txrpt_ccx_88e(adapt, precvframe->rx_data);
317 			} else if (pattrib->pkt_rpt_type == TX_REPORT2) {
318 				ODM_RA_TxRPT2Handle_8188E(
319 							&haldata->odmpriv,
320 							precvframe->rx_data,
321 							pattrib->pkt_len,
322 							pattrib->MacIDValidEntry[0],
323 							pattrib->MacIDValidEntry[1]
324 							);
325 			} else if (pattrib->pkt_rpt_type == HIS_REPORT) {
326 				interrupt_handler_8188eu(adapt, pattrib->pkt_len, precvframe->rx_data);
327 			}
328 			rtw_free_recvframe(precvframe, pfree_recv_queue);
329 		}
330 		pkt_cnt--;
331 		transfer_len -= pkt_offset;
332 		pbuf += pkt_offset;
333 		precvframe = NULL;
334 		pkt_copy = NULL;
335 
336 		if (transfer_len > 0 && pkt_cnt == 0)
337 			pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff;
338 
339 	} while ((transfer_len > 0) && (pkt_cnt > 0));
340 
341 _exit_recvbuf2recvframe:
342 
343 	return _SUCCESS;
344 }
345 
rtl8188eu_recv_tasklet(unsigned long priv)346 void rtl8188eu_recv_tasklet(unsigned long priv)
347 {
348 	struct sk_buff *pskb;
349 	struct adapter *adapt = (struct adapter *)priv;
350 	struct recv_priv *precvpriv = &adapt->recvpriv;
351 
352 	while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) {
353 		if ((adapt->bDriverStopped) || (adapt->bSurpriseRemoved)) {
354 			DBG_88E("recv_tasklet => bDriverStopped or bSurpriseRemoved\n");
355 			dev_kfree_skb_any(pskb);
356 			break;
357 		}
358 		recvbuf2recvframe(adapt, pskb);
359 		skb_reset_tail_pointer(pskb);
360 		pskb->len = 0;
361 		skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb);
362 	}
363 }
364 
usb_read_port_complete(struct urb * purb,struct pt_regs * regs)365 static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs)
366 {
367 	struct recv_buf	*precvbuf = (struct recv_buf *)purb->context;
368 	struct adapter	*adapt = (struct adapter *)precvbuf->adapter;
369 	struct recv_priv *precvpriv = &adapt->recvpriv;
370 
371 	precvpriv->rx_pending_cnt--;
372 
373 	if (adapt->bSurpriseRemoved || adapt->bDriverStopped || adapt->bReadPortCancel) {
374 		precvbuf->reuse = true;
375 		DBG_88E("%s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d)\n",
376 			__func__, adapt->bDriverStopped,
377 			adapt->bSurpriseRemoved, adapt->bReadPortCancel);
378 		return;
379 	}
380 
381 	if (purb->status == 0) { /* SUCCESS */
382 		if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)) {
383 			precvbuf->reuse = true;
384 			rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf);
385 			DBG_88E("%s()-%d: RX Warning!\n", __func__, __LINE__);
386 		} else {
387 			rtw_reset_continual_urb_error(adapter_to_dvobj(adapt));
388 
389 			precvbuf->transfer_len = purb->actual_length;
390 			skb_put(precvbuf->pskb, purb->actual_length);
391 			skb_queue_tail(&precvpriv->rx_skb_queue, precvbuf->pskb);
392 
393 			if (skb_queue_len(&precvpriv->rx_skb_queue) <= 1)
394 				tasklet_schedule(&precvpriv->recv_tasklet);
395 
396 			precvbuf->pskb = NULL;
397 			precvbuf->reuse = false;
398 			rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf);
399 		}
400 	} else {
401 		DBG_88E("###=> usb_read_port_complete => urb status(%d)\n", purb->status);
402 		skb_put(precvbuf->pskb, purb->actual_length);
403 		precvbuf->pskb = NULL;
404 
405 		if (rtw_inc_and_chk_continual_urb_error(adapter_to_dvobj(adapt)))
406 			adapt->bSurpriseRemoved = true;
407 
408 		switch (purb->status) {
409 		case -EINVAL:
410 		case -EPIPE:
411 		case -ENODEV:
412 		case -ESHUTDOWN:
413 		case -ENOENT:
414 			adapt->bDriverStopped = true;
415 			break;
416 		case -EPROTO:
417 		case -EOVERFLOW:
418 			{
419 				struct hal_data_8188e	*haldata = GET_HAL_DATA(adapt);
420 				haldata->srestpriv.wifi_error_status = USB_READ_PORT_FAIL;
421 			}
422 			precvbuf->reuse = true;
423 			rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf);
424 			break;
425 		case -EINPROGRESS:
426 			DBG_88E("ERROR: URB IS IN PROGRESS!/n");
427 			break;
428 		default:
429 			break;
430 		}
431 	}
432 }
433 
usb_read_port(struct intf_hdl * pintfhdl,u32 addr,u32 cnt,u8 * rmem)434 static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem)
435 {
436 	struct urb *purb = NULL;
437 	struct recv_buf	*precvbuf = (struct recv_buf *)rmem;
438 	struct adapter		*adapter = pintfhdl->padapter;
439 	struct dvobj_priv	*pdvobj = adapter_to_dvobj(adapter);
440 	struct recv_priv	*precvpriv = &adapter->recvpriv;
441 	struct usb_device	*pusbd = pdvobj->pusbdev;
442 	int err;
443 	unsigned int pipe;
444 	size_t tmpaddr = 0;
445 	size_t alignment = 0;
446 	u32 ret = _SUCCESS;
447 
448 	if (adapter->bDriverStopped || adapter->bSurpriseRemoved ||
449 	    adapter->pwrctrlpriv.pnp_bstop_trx)
450 		return _FAIL;
451 
452 	if (!precvbuf)
453 		return _FAIL;
454 
455 	if (!precvbuf->reuse || !precvbuf->pskb) {
456 		precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue);
457 		if (precvbuf->pskb)
458 			precvbuf->reuse = true;
459 	}
460 
461 	rtl8188eu_init_recvbuf(adapter, precvbuf);
462 
463 	/* re-assign for linux based on skb */
464 	if (!precvbuf->reuse || !precvbuf->pskb) {
465 		precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
466 		if (!precvbuf->pskb) {
467 			DBG_88E("#### usb_read_port() alloc_skb fail!#####\n");
468 			return _FAIL;
469 		}
470 
471 		tmpaddr = (size_t)precvbuf->pskb->data;
472 		alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1);
473 		skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment));
474 
475 		precvbuf->phead = precvbuf->pskb->head;
476 		precvbuf->pdata = precvbuf->pskb->data;
477 		precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
478 		precvbuf->pend = skb_end_pointer(precvbuf->pskb);
479 		precvbuf->pbuf = precvbuf->pskb->data;
480 	} else { /* reuse skb */
481 		precvbuf->phead = precvbuf->pskb->head;
482 		precvbuf->pdata = precvbuf->pskb->data;
483 		precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
484 		precvbuf->pend = skb_end_pointer(precvbuf->pskb);
485 		precvbuf->pbuf = precvbuf->pskb->data;
486 
487 		precvbuf->reuse = false;
488 	}
489 
490 	precvpriv->rx_pending_cnt++;
491 
492 	purb = precvbuf->purb;
493 
494 	/* translate DMA FIFO addr to pipehandle */
495 	pipe = ffaddr2pipehdl(pdvobj, addr);
496 
497 	usb_fill_bulk_urb(purb, pusbd, pipe,
498 			  precvbuf->pbuf,
499 			  MAX_RECVBUF_SZ,
500 			  usb_read_port_complete,
501 			  precvbuf);/* context is precvbuf */
502 
503 	err = usb_submit_urb(purb, GFP_ATOMIC);
504 	if ((err) && (err != (-EPERM))) {
505 		DBG_88E("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n",
506 			err, purb->status);
507 		ret = _FAIL;
508 	}
509 
510 	return ret;
511 }
512 
rtl8188eu_xmit_tasklet(unsigned long priv)513 void rtl8188eu_xmit_tasklet(unsigned long priv)
514 {
515 	int ret = false;
516 	struct adapter *adapt = (struct adapter *)priv;
517 	struct xmit_priv *pxmitpriv = &adapt->xmitpriv;
518 
519 	if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY))
520 		return;
521 
522 	while (1) {
523 		if ((adapt->bDriverStopped) ||
524 		    (adapt->bSurpriseRemoved) ||
525 		    (adapt->bWritePortCancel)) {
526 			DBG_88E("xmit_tasklet => bDriverStopped or bSurpriseRemoved or bWritePortCancel\n");
527 			break;
528 		}
529 
530 		ret = rtl8188eu_xmitframe_complete(adapt, pxmitpriv, NULL);
531 
532 		if (!ret)
533 			break;
534 	}
535 }
536 
rtl8188eu_set_intf_ops(struct _io_ops * pops)537 void rtl8188eu_set_intf_ops(struct _io_ops	*pops)
538 {
539 
540 	memset((u8 *)pops, 0, sizeof(struct _io_ops));
541 	pops->_read8 = &usb_read8;
542 	pops->_read16 = &usb_read16;
543 	pops->_read32 = &usb_read32;
544 	pops->_read_mem = &usb_read_mem;
545 	pops->_read_port = &usb_read_port;
546 	pops->_write8 = &usb_write8;
547 	pops->_write16 = &usb_write16;
548 	pops->_write32 = &usb_write32;
549 	pops->_writeN = &usb_writeN;
550 	pops->_write_mem = &usb_write_mem;
551 	pops->_write_port = &usb_write_port;
552 	pops->_read_port_cancel = &usb_read_port_cancel;
553 	pops->_write_port_cancel = &usb_write_port_cancel;
554 
555 }
556 
rtl8188eu_set_hw_type(struct adapter * adapt)557 void rtl8188eu_set_hw_type(struct adapter *adapt)
558 {
559 	adapt->chip_type = RTL8188E;
560 	adapt->HardwareType = HARDWARE_TYPE_RTL8188EU;
561 	DBG_88E("CHIP TYPE: RTL8188E\n");
562 }
563