• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5  *
6  ******************************************************************************/
7 
8 #include <drv_types.h>
9 #include <rtw_debug.h>
10 #include <hal_data.h>
11 
rtw_hal_sdio_max_txoqt_free_space(struct adapter * padapter)12 u8 rtw_hal_sdio_max_txoqt_free_space(struct adapter *padapter)
13 {
14 	struct hal_com_data	*pHalData = GET_HAL_DATA(padapter);
15 
16 	if (pHalData->SdioTxOQTMaxFreeSpace < 8)
17 		pHalData->SdioTxOQTMaxFreeSpace = 8;
18 
19 	return pHalData->SdioTxOQTMaxFreeSpace;
20 }
21 
rtw_hal_sdio_query_tx_freepage(struct adapter * padapter,u8 PageIdx,u8 RequiredPageNum)22 u8 rtw_hal_sdio_query_tx_freepage(
23 	struct adapter *padapter, u8 PageIdx, u8 RequiredPageNum
24 )
25 {
26 	struct hal_com_data	*pHalData = GET_HAL_DATA(padapter);
27 
28 	if ((pHalData->SdioTxFIFOFreePage[PageIdx]+pHalData->SdioTxFIFOFreePage[PUBLIC_QUEUE_IDX]) >= (RequiredPageNum))
29 		return true;
30 	else
31 		return false;
32 }
33 
rtw_hal_sdio_update_tx_freepage(struct adapter * padapter,u8 PageIdx,u8 RequiredPageNum)34 void rtw_hal_sdio_update_tx_freepage(
35 	struct adapter *padapter, u8 PageIdx, u8 RequiredPageNum
36 )
37 {
38 	struct hal_com_data	*pHalData = GET_HAL_DATA(padapter);
39 	u8 DedicatedPgNum = 0;
40 	u8 RequiredPublicFreePgNum = 0;
41 	/* _irqL irql; */
42 
43 	/* spin_lock_bh(&pHalData->SdioTxFIFOFreePageLock); */
44 
45 	DedicatedPgNum = pHalData->SdioTxFIFOFreePage[PageIdx];
46 	if (RequiredPageNum <= DedicatedPgNum) {
47 		pHalData->SdioTxFIFOFreePage[PageIdx] -= RequiredPageNum;
48 	} else {
49 		pHalData->SdioTxFIFOFreePage[PageIdx] = 0;
50 		RequiredPublicFreePgNum = RequiredPageNum - DedicatedPgNum;
51 		pHalData->SdioTxFIFOFreePage[PUBLIC_QUEUE_IDX] -= RequiredPublicFreePgNum;
52 	}
53 
54 	/* spin_unlock_bh(&pHalData->SdioTxFIFOFreePageLock); */
55 }
56 
rtw_hal_set_sdio_tx_max_length(struct adapter * padapter,u8 numHQ,u8 numNQ,u8 numLQ,u8 numPubQ)57 void rtw_hal_set_sdio_tx_max_length(
58 	struct adapter *padapter, u8 numHQ, u8 numNQ, u8 numLQ, u8 numPubQ
59 )
60 {
61 	struct hal_com_data	*pHalData = GET_HAL_DATA(padapter);
62 	u32 page_size;
63 	u32 lenHQ, lenNQ, lenLQ;
64 
65 	rtw_hal_get_def_var(padapter, HAL_DEF_TX_PAGE_SIZE, &page_size);
66 
67 	lenHQ = ((numHQ + numPubQ) >> 1) * page_size;
68 	lenNQ = ((numNQ + numPubQ) >> 1) * page_size;
69 	lenLQ = ((numLQ + numPubQ) >> 1) * page_size;
70 
71 	pHalData->sdio_tx_max_len[HI_QUEUE_IDX] =
72 		(lenHQ > MAX_XMITBUF_SZ) ? MAX_XMITBUF_SZ : lenHQ;
73 	pHalData->sdio_tx_max_len[MID_QUEUE_IDX] =
74 		(lenNQ > MAX_XMITBUF_SZ) ? MAX_XMITBUF_SZ : lenNQ;
75 	pHalData->sdio_tx_max_len[LOW_QUEUE_IDX] =
76 		(lenLQ > MAX_XMITBUF_SZ) ? MAX_XMITBUF_SZ : lenLQ;
77 }
78 
rtw_hal_get_sdio_tx_max_length(struct adapter * padapter,u8 queue_idx)79 u32 rtw_hal_get_sdio_tx_max_length(struct adapter *padapter, u8 queue_idx)
80 {
81 	struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
82 	struct hal_com_data	*pHalData = GET_HAL_DATA(padapter);
83 	u32 deviceId, max_len;
84 
85 
86 	deviceId = ffaddr2deviceId(pdvobjpriv, queue_idx);
87 	switch (deviceId) {
88 	case WLAN_TX_HIQ_DEVICE_ID:
89 		max_len = pHalData->sdio_tx_max_len[HI_QUEUE_IDX];
90 		break;
91 
92 	case WLAN_TX_MIQ_DEVICE_ID:
93 		max_len = pHalData->sdio_tx_max_len[MID_QUEUE_IDX];
94 		break;
95 
96 	case WLAN_TX_LOQ_DEVICE_ID:
97 		max_len = pHalData->sdio_tx_max_len[LOW_QUEUE_IDX];
98 		break;
99 
100 	default:
101 		max_len = pHalData->sdio_tx_max_len[MID_QUEUE_IDX];
102 		break;
103 	}
104 
105 	return max_len;
106 }
107