1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include "decl.h"
21#include "ioctl.h"
22#include "util.h"
23#include "fw.h"
24#include "main.h"
25#include "wmm.h"
26#include "11n.h"
27
28
29
30
31
32
33
34int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter)
35{
36
37 adapter->init_wait_q_woken = true;
38 wake_up_interruptible(&adapter->init_wait_q);
39 return 0;
40}
41
42
43
44
45
46
47
48
49int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter)
50{
51 adapter->hw_status = MWIFIEX_HW_STATUS_NOT_READY;
52 adapter->init_wait_q_woken = true;
53 wake_up_interruptible(&adapter->init_wait_q);
54 return 0;
55}
56
57
58
59
60
61int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
62 u32 func_init_shutdown)
63{
64 u16 cmd;
65
66 if (func_init_shutdown == MWIFIEX_FUNC_INIT) {
67 cmd = HostCmd_CMD_FUNC_INIT;
68 } else if (func_init_shutdown == MWIFIEX_FUNC_SHUTDOWN) {
69 cmd = HostCmd_CMD_FUNC_SHUTDOWN;
70 } else {
71 dev_err(priv->adapter->dev, "unsupported parameter\n");
72 return -1;
73 }
74
75 return mwifiex_send_cmd_sync(priv, cmd, HostCmd_ACT_GEN_SET, 0, NULL);
76}
77EXPORT_SYMBOL_GPL(mwifiex_init_shutdown_fw);
78
79
80
81
82
83
84
85int mwifiex_get_debug_info(struct mwifiex_private *priv,
86 struct mwifiex_debug_info *info)
87{
88 struct mwifiex_adapter *adapter = priv->adapter;
89
90 if (info) {
91 memcpy(info->packets_out,
92 priv->wmm.packets_out,
93 sizeof(priv->wmm.packets_out));
94 info->curr_tx_buf_size = (u32) adapter->curr_tx_buf_size;
95 info->tx_buf_size = (u32) adapter->tx_buf_size;
96 info->rx_tbl_num = mwifiex_get_rx_reorder_tbl(priv,
97 info->rx_tbl);
98 info->tx_tbl_num = mwifiex_get_tx_ba_stream_tbl(priv,
99 info->tx_tbl);
100 info->ps_mode = adapter->ps_mode;
101 info->ps_state = adapter->ps_state;
102 info->is_deep_sleep = adapter->is_deep_sleep;
103 info->pm_wakeup_card_req = adapter->pm_wakeup_card_req;
104 info->pm_wakeup_fw_try = adapter->pm_wakeup_fw_try;
105 info->is_hs_configured = adapter->is_hs_configured;
106 info->hs_activated = adapter->hs_activated;
107 info->num_cmd_host_to_card_failure
108 = adapter->dbg.num_cmd_host_to_card_failure;
109 info->num_cmd_sleep_cfm_host_to_card_failure
110 = adapter->dbg.num_cmd_sleep_cfm_host_to_card_failure;
111 info->num_tx_host_to_card_failure
112 = adapter->dbg.num_tx_host_to_card_failure;
113 info->num_event_deauth = adapter->dbg.num_event_deauth;
114 info->num_event_disassoc = adapter->dbg.num_event_disassoc;
115 info->num_event_link_lost = adapter->dbg.num_event_link_lost;
116 info->num_cmd_deauth = adapter->dbg.num_cmd_deauth;
117 info->num_cmd_assoc_success =
118 adapter->dbg.num_cmd_assoc_success;
119 info->num_cmd_assoc_failure =
120 adapter->dbg.num_cmd_assoc_failure;
121 info->num_tx_timeout = adapter->dbg.num_tx_timeout;
122 info->num_cmd_timeout = adapter->dbg.num_cmd_timeout;
123 info->timeout_cmd_id = adapter->dbg.timeout_cmd_id;
124 info->timeout_cmd_act = adapter->dbg.timeout_cmd_act;
125 memcpy(info->last_cmd_id, adapter->dbg.last_cmd_id,
126 sizeof(adapter->dbg.last_cmd_id));
127 memcpy(info->last_cmd_act, adapter->dbg.last_cmd_act,
128 sizeof(adapter->dbg.last_cmd_act));
129 info->last_cmd_index = adapter->dbg.last_cmd_index;
130 memcpy(info->last_cmd_resp_id, adapter->dbg.last_cmd_resp_id,
131 sizeof(adapter->dbg.last_cmd_resp_id));
132 info->last_cmd_resp_index = adapter->dbg.last_cmd_resp_index;
133 memcpy(info->last_event, adapter->dbg.last_event,
134 sizeof(adapter->dbg.last_event));
135 info->last_event_index = adapter->dbg.last_event_index;
136 info->data_sent = adapter->data_sent;
137 info->cmd_sent = adapter->cmd_sent;
138 info->cmd_resp_received = adapter->cmd_resp_received;
139 }
140
141 return 0;
142}
143
144
145
146
147
148int
149mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
150 struct sk_buff *skb)
151{
152 struct rxpd *rx_pd;
153 u16 pkt_len;
154
155 if (!skb)
156 return -1;
157
158 rx_pd = (struct rxpd *)skb->data;
159
160 skb_pull(skb, le16_to_cpu(rx_pd->rx_pkt_offset));
161 skb_pull(skb, sizeof(pkt_len));
162
163 pkt_len = le16_to_cpu(rx_pd->rx_pkt_length);
164
165
166 memmove(skb->data + sizeof(struct ieee80211_hdr_3addr),
167 skb->data + sizeof(struct ieee80211_hdr),
168 pkt_len - sizeof(struct ieee80211_hdr));
169
170 pkt_len -= ETH_ALEN + sizeof(pkt_len);
171 rx_pd->rx_pkt_length = cpu_to_le16(pkt_len);
172
173 cfg80211_rx_mgmt(priv->wdev, priv->roc_cfg.chan.center_freq,
174 CAL_RSSI(rx_pd->snr, rx_pd->nf), skb->data, pkt_len,
175 0, GFP_ATOMIC);
176
177 return 0;
178}
179
180
181
182
183
184
185
186
187
188
189int mwifiex_recv_packet(struct mwifiex_private *priv, struct sk_buff *skb)
190{
191 if (!skb)
192 return -1;
193
194 skb->dev = priv->netdev;
195 skb->protocol = eth_type_trans(skb, priv->netdev);
196 skb->ip_summed = CHECKSUM_NONE;
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215 if ((priv->adapter->iface_type == MWIFIEX_USB ||
216 priv->adapter->iface_type == MWIFIEX_PCIE) &&
217 (skb->truesize > MWIFIEX_RX_DATA_BUF_SIZE))
218 skb->truesize += (skb->len - MWIFIEX_RX_DATA_BUF_SIZE);
219
220 priv->stats.rx_bytes += skb->len;
221 priv->stats.rx_packets++;
222 if (in_interrupt())
223 netif_rx(skb);
224 else
225 netif_rx_ni(skb);
226
227 return 0;
228}
229
230
231
232
233
234
235
236
237
238
239int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
240 struct cmd_ctrl_node *cmd_node)
241{
242 dev_dbg(adapter->dev, "cmd completed: status=%d\n",
243 adapter->cmd_wait_q.status);
244
245 *(cmd_node->condition) = true;
246
247 if (adapter->cmd_wait_q.status == -ETIMEDOUT)
248 dev_err(adapter->dev, "cmd timeout\n");
249 else
250 wake_up_interruptible(&adapter->cmd_wait_q.wait);
251
252 return 0;
253}
254