1 /******************************************************************************
2 *
3 * Copyright(c) 2019 Realtek Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 *****************************************************************************/
15 #define _RTW_TRX_C_
16 #include <drv_types.h> /* struct dvobj_priv and etc. */
17
18
19 #ifdef RTW_PHL_TX
rtw_core_tx_mgmt(_adapter * padapter,struct xmit_frame * pxframe)20 s32 rtw_core_tx_mgmt(_adapter *padapter, struct xmit_frame *pxframe)
21 {
22
23 pxframe->xftype = RTW_TX_DRV_MGMT;
24
25 #ifdef RTW_PHL_DBG_CMD
26 core_add_record(padapter, REC_TX_MGMT, pxframe);
27 #endif
28
29 if(core_tx_prepare_phl(padapter, pxframe) == FAIL)
30 return _FAIL;
31
32 if (core_tx_call_phl(padapter, pxframe, NULL) == FAIL)
33 return _FAIL;
34
35 return _SUCCESS;
36 }
37 #endif
38
39 #ifdef CONFIG_DRV_FAKE_AP
40 int rtw_fakeap_tx(struct _ADAPTER*, struct xmit_frame*);
41 #endif /* CONFIG_DRV_FAKE_AP */
42 /*rtw_hal_mgnt_xmit*/
rtw_mgnt_xmit(_adapter * adapter,struct xmit_frame * pmgntframe)43 s32 rtw_mgnt_xmit(_adapter *adapter, struct xmit_frame *pmgntframe)
44 {
45 s32 ret = _FAIL;
46
47 update_mgntframe_attrib_addr(adapter, pmgntframe);
48
49 #if defined(CONFIG_IEEE80211W) || defined(CONFIG_RTW_MESH)
50 if ((!MLME_IS_MESH(adapter) && SEC_IS_BIP_KEY_INSTALLED(&adapter->securitypriv) == _TRUE)
51 #ifdef CONFIG_RTW_MESH
52 || (MLME_IS_MESH(adapter) && adapter->mesh_info.mesh_auth_id)
53 #endif
54 )
55 rtw_mgmt_xmitframe_coalesce(adapter, pmgntframe->pkt, pmgntframe);
56 #endif
57
58 #ifdef CONFIG_DRV_FAKE_AP
59 #ifndef RTW_PHL_TEST_FPGA
60 if (rtw_fakeap_tx(adapter, pmgntframe) == _SUCCESS)
61 return _SUCCESS;
62 #endif
63 #endif /* CONFIG_DRV_FAKE_AP */
64
65 ret = rtw_core_tx_mgmt(adapter, pmgntframe);
66 return ret;
67 }
68
69
rtw_alloc_litedatabuf(struct trx_data_buf_q * data_buf_q)70 struct lite_data_buf *rtw_alloc_litedatabuf(struct trx_data_buf_q *data_buf_q)
71 {
72 struct lite_data_buf *litedatabuf = NULL;
73 _list *list, *head;
74 _queue *free_litedatabuf_q = &data_buf_q->free_data_buf_queue;
75 unsigned long sp_flags;
76
77 /* RTW_INFO("+rtw_alloc_litexmitbuf\n"); */
78
79 _rtw_spinlock_irq(&free_litedatabuf_q->lock, &sp_flags);
80
81 if (_rtw_queue_empty(free_litedatabuf_q) == _TRUE)
82 litedatabuf = NULL;
83 else {
84
85 head = get_list_head(free_litedatabuf_q);
86
87 list = get_next(head);
88
89 litedatabuf = LIST_CONTAINOR(list,
90 struct lite_data_buf, list);
91
92 rtw_list_delete(&(litedatabuf->list));
93 }
94
95 if (litedatabuf != NULL) {
96 data_buf_q->free_data_buf_cnt--;
97
98
99 if (litedatabuf->sctx) {
100 RTW_INFO("%s plitexmitbuf->sctx is not NULL\n",
101 __func__);
102 rtw_sctx_done_err(&litedatabuf->sctx,
103 RTW_SCTX_DONE_BUF_ALLOC);
104 }
105 }
106
107 _rtw_spinunlock_irq(&free_litedatabuf_q->lock, &sp_flags);
108
109
110 return litedatabuf;
111 }
112
rtw_free_litedatabuf(struct trx_data_buf_q * data_buf_q,struct lite_data_buf * lite_data_buf)113 s32 rtw_free_litedatabuf(struct trx_data_buf_q *data_buf_q,
114 struct lite_data_buf *lite_data_buf)
115 {
116 _queue *free_litedatabuf_q = &data_buf_q->free_data_buf_queue;
117 unsigned long sp_flags;
118
119 /* RTW_INFO("+rtw_free_litexmitbuf\n"); */
120
121 if (data_buf_q == NULL)
122 return _FAIL;
123
124 if (lite_data_buf == NULL)
125 return _FAIL;
126
127 lite_data_buf->pbuf = NULL;
128 lite_data_buf->phl_buf_ptr = NULL;
129 #ifdef CONFIG_USB_HCI
130 lite_data_buf->dataurb = NULL;
131 #endif
132
133 if (lite_data_buf->sctx) {
134 RTW_INFO("%s lite_data_buf->sctx is not NULL\n", __func__);
135 rtw_sctx_done_err(&lite_data_buf->sctx, RTW_SCTX_DONE_BUF_FREE);
136 return _FAIL;
137 }
138
139 _rtw_spinlock_irq(&free_litedatabuf_q->lock, &sp_flags);
140
141 rtw_list_delete(&lite_data_buf->list);
142
143 rtw_list_insert_tail(&(lite_data_buf->list),
144 get_list_head(free_litedatabuf_q));
145
146 data_buf_q->free_data_buf_cnt++;
147
148 _rtw_spinunlock_irq(&free_litedatabuf_q->lock, &sp_flags);
149
150
151 return _SUCCESS;
152 }
153
154