]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c
arm: imx6: defconfig: update tx6 defconfigs
[karo-tx-linux.git] / drivers / staging / rtl8188eu / core / rtw_mp_ioctl.c
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #define _RTW_MP_IOCTL_C_
21
22 #include <osdep_service.h>
23 #include <drv_types.h>
24 #include <mlme_osdep.h>
25
26 /* include <rtw_mp.h> */
27 #include <rtw_mp_ioctl.h>
28
29
30 /*   rtl8188eu_oid_rtl_seg_81_85   section start **************** */
31 int rtl8188eu_oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv)
32 {
33         int status = NDIS_STATUS_SUCCESS;
34         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
35
36 _func_enter_;
37
38         if (poid_par_priv->information_buf_len < sizeof(u8))
39                 return NDIS_STATUS_INVALID_LENGTH;
40
41         if (poid_par_priv->type_of_oid == SET_OID) {
42                 Adapter->registrypriv.wireless_mode = *(u8 *)poid_par_priv->information_buf;
43         } else if (poid_par_priv->type_of_oid == QUERY_OID) {
44                 *(u8 *)poid_par_priv->information_buf = Adapter->registrypriv.wireless_mode;
45                 *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
46                  RT_TRACE(_module_mp_, _drv_info_, ("-query Wireless Mode=%d\n", Adapter->registrypriv.wireless_mode));
47         } else {
48                 status = NDIS_STATUS_NOT_ACCEPTED;
49         }
50
51 _func_exit_;
52
53         return status;
54 }
55 /*   rtl8188eu_oid_rtl_seg_81_87_80   section start **************** */
56 int rtl8188eu_oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
57 {
58         struct bb_reg_param *pbbreg;
59         u16 offset;
60         u32 value;
61         int status = NDIS_STATUS_SUCCESS;
62         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
63
64 _func_enter_;
65
66         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_bb_reg_hdl\n"));
67
68         if (poid_par_priv->type_of_oid != SET_OID)
69                 return NDIS_STATUS_NOT_ACCEPTED;
70
71         if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param))
72                 return NDIS_STATUS_INVALID_LENGTH;
73
74         pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf);
75
76         offset = (u16)(pbbreg->offset) & 0xFFF; /* 0ffset :0x800~0xfff */
77         if (offset < BB_REG_BASE_ADDR)
78                 offset |= BB_REG_BASE_ADDR;
79
80         value = pbbreg->value;
81
82         RT_TRACE(_module_mp_, _drv_notice_,
83                  ("rtl8188eu_oid_rt_pro_write_bb_reg_hdl: offset=0x%03X value=0x%08X\n",
84                   offset, value));
85
86         _irqlevel_changed_(&oldirql, LOWER);
87         write_bbreg(Adapter, offset, 0xFFFFFFFF, value);
88         _irqlevel_changed_(&oldirql, RAISE);
89
90 _func_exit_;
91
92         return status;
93 }
94 /*  */
95 int rtl8188eu_oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
96 {
97         struct bb_reg_param *pbbreg;
98         u16 offset;
99         u32 value;
100         int status = NDIS_STATUS_SUCCESS;
101         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
102
103 _func_enter_;
104
105         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_bb_reg_hdl\n"));
106
107         if (poid_par_priv->type_of_oid != QUERY_OID)
108                 return NDIS_STATUS_NOT_ACCEPTED;
109
110         if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param))
111                 return NDIS_STATUS_INVALID_LENGTH;
112
113         pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf);
114
115         offset = (u16)(pbbreg->offset) & 0xFFF; /* 0ffset :0x800~0xfff */
116         if (offset < BB_REG_BASE_ADDR)
117                 offset |= BB_REG_BASE_ADDR;
118
119         _irqlevel_changed_(&oldirql, LOWER);
120         value = read_bbreg(Adapter, offset, 0xFFFFFFFF);
121         _irqlevel_changed_(&oldirql, RAISE);
122
123         pbbreg->value = value;
124         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
125
126         RT_TRACE(_module_mp_, _drv_notice_,
127                  ("-rtl8188eu_oid_rt_pro_read_bb_reg_hdl: offset=0x%03X value:0x%08X\n",
128                   offset, value));
129 _func_exit_;
130
131         return status;
132 }
133 /*  */
134 int rtl8188eu_oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv)
135 {
136         struct rf_reg_param *pbbreg;
137         u8 path;
138         u8 offset;
139         u32 value;
140         int status = NDIS_STATUS_SUCCESS;
141         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
142
143 _func_enter_;
144
145         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_rf_reg_hdl\n"));
146
147         if (poid_par_priv->type_of_oid != SET_OID)
148                 return NDIS_STATUS_NOT_ACCEPTED;
149
150         if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param))
151                 return NDIS_STATUS_INVALID_LENGTH;
152
153         pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf);
154
155         if (pbbreg->path >= MAX_RF_PATH_NUMS)
156                 return NDIS_STATUS_NOT_ACCEPTED;
157         if (pbbreg->offset > 0xFF)
158                 return NDIS_STATUS_NOT_ACCEPTED;
159         if (pbbreg->value > 0xFFFFF)
160                 return NDIS_STATUS_NOT_ACCEPTED;
161
162         path = (u8)pbbreg->path;
163         offset = (u8)pbbreg->offset;
164         value = pbbreg->value;
165
166         RT_TRACE(_module_mp_, _drv_notice_,
167                  ("rtl8188eu_oid_rt_pro_write_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n",
168                   path, offset, value));
169
170         _irqlevel_changed_(&oldirql, LOWER);
171         write_rfreg(Adapter, path, offset, value);
172         _irqlevel_changed_(&oldirql, RAISE);
173
174 _func_exit_;
175
176         return status;
177 }
178 /*  */
179 int rtl8188eu_oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv)
180 {
181         struct rf_reg_param *pbbreg;
182         u8 path;
183         u8 offset;
184         u32 value;
185         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
186         int status = NDIS_STATUS_SUCCESS;
187
188 _func_enter_;
189
190         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_rf_reg_hdl\n"));
191
192         if (poid_par_priv->type_of_oid != QUERY_OID)
193                 return NDIS_STATUS_NOT_ACCEPTED;
194
195         if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param))
196                 return NDIS_STATUS_INVALID_LENGTH;
197
198         pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf);
199
200         if (pbbreg->path >= MAX_RF_PATH_NUMS)
201                 return NDIS_STATUS_NOT_ACCEPTED;
202         if (pbbreg->offset > 0xFF)
203                 return NDIS_STATUS_NOT_ACCEPTED;
204
205         path = (u8)pbbreg->path;
206         offset = (u8)pbbreg->offset;
207
208         _irqlevel_changed_(&oldirql, LOWER);
209         value = read_rfreg(Adapter, path, offset);
210         _irqlevel_changed_(&oldirql, RAISE);
211
212         pbbreg->value = value;
213
214         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
215
216         RT_TRACE(_module_mp_, _drv_notice_,
217                  ("-rtl8188eu_oid_rt_pro_read_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n",
218                   path, offset, value));
219
220 _func_exit_;
221
222         return status;
223 }
224 /*   rtl8188eu_oid_rtl_seg_81_87_00   section end**************** */
225 /*  */
226
227 /*   rtl8188eu_oid_rtl_seg_81_80_00   section start **************** */
228 /*  */
229 int rtl8188eu_oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv)
230 {
231         u32             ratevalue;/* 4 */
232         int status = NDIS_STATUS_SUCCESS;
233         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
234
235 _func_enter_;
236
237         RT_TRACE(_module_mp_, _drv_notice_,
238                  ("+rtl8188eu_oid_rt_pro_set_data_rate_hdl\n"));
239
240         if (poid_par_priv->type_of_oid != SET_OID)
241                 return NDIS_STATUS_NOT_ACCEPTED;
242
243         if (poid_par_priv->information_buf_len != sizeof(u32))
244                 return NDIS_STATUS_INVALID_LENGTH;
245
246         ratevalue = *((u32 *)poid_par_priv->information_buf);/* 4 */
247         RT_TRACE(_module_mp_, _drv_notice_,
248                  ("rtl8188eu_oid_rt_pro_set_data_rate_hdl: data rate idx=%d\n", ratevalue));
249         if (ratevalue >= MPT_RATE_LAST)
250                 return NDIS_STATUS_INVALID_DATA;
251
252         Adapter->mppriv.rateidx = ratevalue;
253
254         _irqlevel_changed_(&oldirql, LOWER);
255         SetDataRate(Adapter);
256         _irqlevel_changed_(&oldirql, RAISE);
257
258 _func_exit_;
259
260         return status;
261 }
262 /*  */
263 int rtl8188eu_oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv)
264 {
265         u32             mode;
266         int status = NDIS_STATUS_SUCCESS;
267         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
268
269 _func_enter_;
270
271         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_start_test_hdl\n"));
272
273         if (Adapter->registrypriv.mp_mode == 0)
274                 return NDIS_STATUS_NOT_ACCEPTED;
275
276         if (poid_par_priv->type_of_oid != SET_OID)
277                 return NDIS_STATUS_NOT_ACCEPTED;
278
279         _irqlevel_changed_(&oldirql, LOWER);
280
281         /* IQCalibrateBcut(Adapter); */
282
283         mode = *((u32 *)poid_par_priv->information_buf);
284         Adapter->mppriv.mode = mode;/*  1 for loopback */
285
286         if (mp_start_test(Adapter) == _FAIL) {
287                 status = NDIS_STATUS_NOT_ACCEPTED;
288                 goto exit;
289         }
290
291 exit:
292         _irqlevel_changed_(&oldirql, RAISE);
293
294         RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_pro_start_test_hdl: mp_mode=%d\n", Adapter->mppriv.mode));
295
296 _func_exit_;
297
298         return status;
299 }
300 /*  */
301 int rtl8188eu_oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv)
302 {
303         int status = NDIS_STATUS_SUCCESS;
304         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
305
306 _func_enter_;
307
308         RT_TRACE(_module_mp_, _drv_notice_, ("+Set OID_RT_PRO_STOP_TEST\n"));
309
310         if (poid_par_priv->type_of_oid != SET_OID)
311                 return NDIS_STATUS_NOT_ACCEPTED;
312
313         _irqlevel_changed_(&oldirql, LOWER);
314         mp_stop_test(Adapter);
315         _irqlevel_changed_(&oldirql, RAISE);
316
317         RT_TRACE(_module_mp_, _drv_notice_, ("-Set OID_RT_PRO_STOP_TEST\n"));
318
319 _func_exit_;
320
321         return status;
322 }
323 /*  */
324 int rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv)
325 {
326         u32             Channel;
327         int status = NDIS_STATUS_SUCCESS;
328         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
329
330 _func_enter_;
331
332         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl\n"));
333
334         if (poid_par_priv->information_buf_len != sizeof(u32))
335                 return NDIS_STATUS_INVALID_LENGTH;
336
337         if (poid_par_priv->type_of_oid == QUERY_OID) {
338                 *((u32 *)poid_par_priv->information_buf) = Adapter->mppriv.channel;
339                 return NDIS_STATUS_SUCCESS;
340         }
341
342         if (poid_par_priv->type_of_oid != SET_OID)
343                 return NDIS_STATUS_NOT_ACCEPTED;
344
345         Channel = *((u32 *)poid_par_priv->information_buf);
346         RT_TRACE(_module_mp_, _drv_notice_, ("rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl: Channel=%d\n", Channel));
347         if (Channel > 14)
348                 return NDIS_STATUS_NOT_ACCEPTED;
349         Adapter->mppriv.channel = Channel;
350
351         _irqlevel_changed_(&oldirql, LOWER);
352         SetChannel(Adapter);
353         _irqlevel_changed_(&oldirql, RAISE);
354
355 _func_exit_;
356
357         return status;
358 }
359 /*  */
360 int rtl8188eu_oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv)
361 {
362         u16             bandwidth;
363         u16             channel_offset;
364         int status = NDIS_STATUS_SUCCESS;
365         struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context);
366
367 _func_enter_;
368
369         RT_TRACE(_module_mp_, _drv_info_,
370                  ("+rtl8188eu_oid_rt_set_bandwidth_hdl\n"));
371
372         if (poid_par_priv->type_of_oid != SET_OID)
373                 return NDIS_STATUS_NOT_ACCEPTED;
374
375         if (poid_par_priv->information_buf_len < sizeof(u32))
376                 return NDIS_STATUS_INVALID_LENGTH;
377
378         bandwidth = *((u32 *)poid_par_priv->information_buf);/* 4 */
379         channel_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
380
381         if (bandwidth != HT_CHANNEL_WIDTH_40)
382                 bandwidth = HT_CHANNEL_WIDTH_20;
383         padapter->mppriv.bandwidth = (u8)bandwidth;
384         padapter->mppriv.prime_channel_offset = (u8)channel_offset;
385
386         _irqlevel_changed_(&oldirql, LOWER);
387         SetBandwidth(padapter);
388         _irqlevel_changed_(&oldirql, RAISE);
389
390         RT_TRACE(_module_mp_, _drv_notice_,
391                  ("-rtl8188eu_oid_rt_set_bandwidth_hdl: bandwidth=%d channel_offset=%d\n",
392                   bandwidth, channel_offset));
393
394 _func_exit_;
395
396         return status;
397 }
398 /*  */
399 int rtl8188eu_oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv)
400 {
401         u32             antenna;
402         int status = NDIS_STATUS_SUCCESS;
403         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
404
405 _func_enter_;
406
407         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_antenna_bb_hdl\n"));
408
409         if (poid_par_priv->information_buf_len != sizeof(u32))
410                 return NDIS_STATUS_INVALID_LENGTH;
411
412         if (poid_par_priv->type_of_oid == SET_OID) {
413                 antenna = *(u32 *)poid_par_priv->information_buf;
414
415                 Adapter->mppriv.antenna_tx = (u16)((antenna & 0xFFFF0000) >> 16);
416                 Adapter->mppriv.antenna_rx = (u16)(antenna & 0x0000FFFF);
417                 RT_TRACE(_module_mp_, _drv_notice_,
418                          ("rtl8188eu_oid_rt_pro_set_antenna_bb_hdl: tx_ant=0x%04x rx_ant=0x%04x\n",
419                           Adapter->mppriv.antenna_tx, Adapter->mppriv.antenna_rx));
420
421                 _irqlevel_changed_(&oldirql, LOWER);
422                 SetAntenna(Adapter);
423                 _irqlevel_changed_(&oldirql, RAISE);
424         } else {
425                 antenna = (Adapter->mppriv.antenna_tx << 16)|Adapter->mppriv.antenna_rx;
426                 *(u32 *)poid_par_priv->information_buf = antenna;
427         }
428
429 _func_exit_;
430
431         return status;
432 }
433
434 int rtl8188eu_oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv)
435 {
436         u32             tx_pwr_idx;
437         int status = NDIS_STATUS_SUCCESS;
438         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
439
440 _func_enter_;
441
442         RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_set_tx_power_control_hdl\n"));
443
444         if (poid_par_priv->type_of_oid != SET_OID)
445                 return NDIS_STATUS_NOT_ACCEPTED;
446
447         if (poid_par_priv->information_buf_len != sizeof(u32))
448                 return NDIS_STATUS_INVALID_LENGTH;
449
450         tx_pwr_idx = *((u32 *)poid_par_priv->information_buf);
451         if (tx_pwr_idx > MAX_TX_PWR_INDEX_N_MODE)
452                 return NDIS_STATUS_NOT_ACCEPTED;
453
454         Adapter->mppriv.txpoweridx = (u8)tx_pwr_idx;
455
456         RT_TRACE(_module_mp_, _drv_notice_,
457                  ("rtl8188eu_oid_rt_pro_set_tx_power_control_hdl: idx=0x%2x\n",
458                   Adapter->mppriv.txpoweridx));
459
460         _irqlevel_changed_(&oldirql, LOWER);
461         SetTxPower(Adapter);
462         _irqlevel_changed_(&oldirql, RAISE);
463
464 _func_exit_;
465
466         return status;
467 }
468
469 /*  */
470 /*   rtl8188eu_oid_rtl_seg_81_80_20   section start **************** */
471 /*  */
472 int rtl8188eu_oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv)
473 {
474         int status = NDIS_STATUS_SUCCESS;
475         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
476
477 _func_enter_;
478
479         if (poid_par_priv->type_of_oid != QUERY_OID) {
480                 status = NDIS_STATUS_NOT_ACCEPTED;
481                 return status;
482         }
483
484         if (poid_par_priv->information_buf_len == sizeof(u32)) {
485                 *(u32 *)poid_par_priv->information_buf =  Adapter->mppriv.tx_pktcount;
486                 *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
487         } else {
488                 status = NDIS_STATUS_INVALID_LENGTH;
489         }
490
491 _func_exit_;
492
493         return status;
494 }
495 /*  */
496 int rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv)
497 {
498         int status = NDIS_STATUS_SUCCESS;
499         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
500
501 _func_enter_;
502
503         if (poid_par_priv->type_of_oid != QUERY_OID) {
504                 status = NDIS_STATUS_NOT_ACCEPTED;
505                 return status;
506         }
507         RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl.\n"));
508         if (poid_par_priv->information_buf_len == sizeof(u32)) {
509                 *(u32 *)poid_par_priv->information_buf =  Adapter->mppriv.rx_pktcount;
510                 *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
511                 RT_TRACE(_module_mp_, _drv_alert_, ("recv_ok:%d\n", Adapter->mppriv.rx_pktcount));
512         } else {
513                 status = NDIS_STATUS_INVALID_LENGTH;
514         }
515
516 _func_exit_;
517
518         return status;
519 }
520 /*  */
521 int rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv)
522 {
523         int status = NDIS_STATUS_SUCCESS;
524         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
525
526 _func_enter_;
527
528         if (poid_par_priv->type_of_oid != QUERY_OID) {
529                 status = NDIS_STATUS_NOT_ACCEPTED;
530                 return status;
531         }
532         RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl.\n"));
533         if (poid_par_priv->information_buf_len == sizeof(u32)) {
534                 *(u32 *)poid_par_priv->information_buf =  Adapter->mppriv.rx_crcerrpktcount;
535                 *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
536                 RT_TRACE(_module_mp_, _drv_alert_, ("recv_err:%d\n", Adapter->mppriv.rx_crcerrpktcount));
537         } else {
538                 status = NDIS_STATUS_INVALID_LENGTH;
539         }
540
541 _func_exit_;
542
543         return status;
544 }
545 /*  */
546
547 int rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv)
548 {
549         int status = NDIS_STATUS_SUCCESS;
550         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
551
552 _func_enter_;
553
554         if (poid_par_priv->type_of_oid != SET_OID) {
555                 status = NDIS_STATUS_NOT_ACCEPTED;
556                 return status;
557         }
558
559         RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl.\n"));
560         Adapter->mppriv.tx_pktcount = 0;
561
562 _func_exit_;
563
564         return status;
565 }
566 /*  */
567 int rtl8188eu_oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv)
568 {
569         int status = NDIS_STATUS_SUCCESS;
570         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
571
572 _func_enter_;
573
574         if (poid_par_priv->type_of_oid != SET_OID) {
575                 status = NDIS_STATUS_NOT_ACCEPTED;
576                 return status;
577         }
578
579         if (poid_par_priv->information_buf_len == sizeof(u32)) {
580                 Adapter->mppriv.rx_pktcount = 0;
581                 Adapter->mppriv.rx_crcerrpktcount = 0;
582         } else {
583                 status = NDIS_STATUS_INVALID_LENGTH;
584         }
585
586 _func_exit_;
587
588         return status;
589 }
590 /*  */
591 int rtl8188eu_oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par_priv)
592 {
593         int status = NDIS_STATUS_SUCCESS;
594         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
595
596 _func_enter_;
597
598         if (poid_par_priv->type_of_oid != SET_OID) {
599                 status = NDIS_STATUS_NOT_ACCEPTED;
600                 return status;
601         }
602
603         _irqlevel_changed_(&oldirql, LOWER);
604         ResetPhyRxPktCount(Adapter);
605         _irqlevel_changed_(&oldirql, RAISE);
606
607 _func_exit_;
608
609         return status;
610 }
611 /*  */
612 int rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv)
613 {
614         int status = NDIS_STATUS_SUCCESS;
615         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
616
617 _func_enter_;
618
619         RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl\n"));
620
621         if (poid_par_priv->type_of_oid != QUERY_OID)
622                 return NDIS_STATUS_NOT_ACCEPTED;
623
624         if (poid_par_priv->information_buf_len != sizeof(u32))
625                 return NDIS_STATUS_INVALID_LENGTH;
626
627         _irqlevel_changed_(&oldirql, LOWER);
628         *(u32 *)poid_par_priv->information_buf = GetPhyRxPktReceived(Adapter);
629         _irqlevel_changed_(&oldirql, RAISE);
630
631         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
632
633         RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl: recv_ok=%d\n", *(u32 *)poid_par_priv->information_buf));
634
635 _func_exit_;
636
637         return status;
638 }
639 /*  */
640 int rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv)
641 {
642         int status = NDIS_STATUS_SUCCESS;
643         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
644
645 _func_enter_;
646
647         RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl\n"));
648
649         if (poid_par_priv->type_of_oid != QUERY_OID)
650                 return NDIS_STATUS_NOT_ACCEPTED;
651
652
653         if (poid_par_priv->information_buf_len != sizeof(u32))
654                 return NDIS_STATUS_INVALID_LENGTH;
655
656         _irqlevel_changed_(&oldirql, LOWER);
657         *(u32 *)poid_par_priv->information_buf = GetPhyRxPktCRC32Error(Adapter);
658         _irqlevel_changed_(&oldirql, RAISE);
659
660         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
661
662         RT_TRACE(_module_mp_, _drv_info_,
663                  ("-rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl: recv_err =%d\n",
664                  *(u32 *)poid_par_priv->information_buf));
665
666 _func_exit_;
667
668         return status;
669 }
670 /*   rtl8188eu_oid_rtl_seg_81_80_20   section end **************** */
671 int rtl8188eu_oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv)
672 {
673         u32             bStartTest;
674         int status = NDIS_STATUS_SUCCESS;
675         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
676
677 _func_enter_;
678
679         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_continuous_tx_hdl\n"));
680
681         if (poid_par_priv->type_of_oid != SET_OID)
682                 return NDIS_STATUS_NOT_ACCEPTED;
683
684         bStartTest = *((u32 *)poid_par_priv->information_buf);
685
686         _irqlevel_changed_(&oldirql, LOWER);
687         SetContinuousTx(Adapter, (u8)bStartTest);
688         if (bStartTest) {
689                 struct mp_priv *pmp_priv = &Adapter->mppriv;
690                 if (pmp_priv->tx.stop == 0) {
691                         pmp_priv->tx.stop = 1;
692                         DBG_88E("%s: pkt tx is running...\n", __func__);
693                         rtw_msleep_os(5);
694                 }
695                 pmp_priv->tx.stop = 0;
696                 pmp_priv->tx.count = 1;
697                 SetPacketTx(Adapter);
698         }
699         _irqlevel_changed_(&oldirql, RAISE);
700
701 _func_exit_;
702
703         return status;
704 }
705
706 int rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv)
707 {
708         u32             bStartTest;
709         int status = NDIS_STATUS_SUCCESS;
710         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
711
712 _func_enter_;
713
714         RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl\n"));
715
716         if (poid_par_priv->type_of_oid != SET_OID)
717                 return NDIS_STATUS_NOT_ACCEPTED;
718
719         bStartTest = *((u32 *)poid_par_priv->information_buf);
720
721         _irqlevel_changed_(&oldirql, LOWER);
722         SetSingleCarrierTx(Adapter, (u8)bStartTest);
723         if (bStartTest) {
724                 struct mp_priv *pmp_priv = &Adapter->mppriv;
725                 if (pmp_priv->tx.stop == 0) {
726                         pmp_priv->tx.stop = 1;
727                         DBG_88E("%s: pkt tx is running...\n", __func__);
728                         rtw_msleep_os(5);
729                 }
730                 pmp_priv->tx.stop = 0;
731                 pmp_priv->tx.count = 1;
732                 SetPacketTx(Adapter);
733         }
734         _irqlevel_changed_(&oldirql, RAISE);
735
736 _func_exit_;
737
738         return status;
739 }
740
741 int rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *poid_par_priv)
742 {
743         u32             bStartTest;
744         int status = NDIS_STATUS_SUCCESS;
745         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
746
747 _func_enter_;
748
749         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl\n"));
750
751         if (poid_par_priv->type_of_oid != SET_OID)
752                 return NDIS_STATUS_NOT_ACCEPTED;
753
754         bStartTest = *((u32 *)poid_par_priv->information_buf);
755
756         _irqlevel_changed_(&oldirql, LOWER);
757         SetCarrierSuppressionTx(Adapter, (u8)bStartTest);
758         if (bStartTest) {
759                 struct mp_priv *pmp_priv = &Adapter->mppriv;
760                 if (pmp_priv->tx.stop == 0) {
761                         pmp_priv->tx.stop = 1;
762                         DBG_88E("%s: pkt tx is running...\n", __func__);
763                         rtw_msleep_os(5);
764                 }
765                 pmp_priv->tx.stop = 0;
766                 pmp_priv->tx.count = 1;
767                 SetPacketTx(Adapter);
768         }
769         _irqlevel_changed_(&oldirql, RAISE);
770
771 _func_exit_;
772
773         return status;
774 }
775
776 int rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv)
777 {
778         u32             bStartTest;
779         int status = NDIS_STATUS_SUCCESS;
780         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
781
782 _func_enter_;
783
784         RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl\n"));
785
786         if (poid_par_priv->type_of_oid != SET_OID)
787                 return NDIS_STATUS_NOT_ACCEPTED;
788
789         bStartTest = *((u32 *)poid_par_priv->information_buf);
790
791         _irqlevel_changed_(&oldirql, LOWER);
792         SetSingleToneTx(Adapter, (u8)bStartTest);
793         _irqlevel_changed_(&oldirql, RAISE);
794
795 _func_exit_;
796
797         return status;
798 }
799
800 int rtl8188eu_oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv)
801 {
802         return 0;
803 }
804
805 int rtl8188eu_oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv)
806 {
807         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
808         int status = NDIS_STATUS_SUCCESS;
809 _func_enter_;
810
811         if (poid_par_priv->type_of_oid != SET_OID)
812                 return NDIS_STATUS_NOT_ACCEPTED;
813
814         _irqlevel_changed_(&oldirql, LOWER);
815         rtw_hal_set_hwreg(Adapter, HW_VAR_TRIGGER_GPIO_0, NULL);
816         _irqlevel_changed_(&oldirql, RAISE);
817
818 _func_exit_;
819
820         return status;
821 }
822 /*   rtl8188eu_oid_rtl_seg_81_80_00   section end **************** */
823 /*  */
824 int rtl8188eu_oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv)
825 {
826         return 0;
827 }
828 /*  */
829 int rtl8188eu_oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv)
830 {
831         struct mp_rw_reg *RegRWStruct;
832         u32             offset, width;
833         int status = NDIS_STATUS_SUCCESS;
834         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
835
836 _func_enter_;
837
838         RT_TRACE(_module_mp_, _drv_info_,
839                  ("+rtl8188eu_oid_rt_pro_read_register_hdl\n"));
840
841         if (poid_par_priv->type_of_oid != QUERY_OID)
842                 return NDIS_STATUS_NOT_ACCEPTED;
843
844         RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf;
845         offset = RegRWStruct->offset;
846         width = RegRWStruct->width;
847
848         if (offset > 0xFFF)
849                 return NDIS_STATUS_NOT_ACCEPTED;
850
851         _irqlevel_changed_(&oldirql, LOWER);
852
853         switch (width) {
854         case 1:
855                 RegRWStruct->value = rtw_read8(Adapter, offset);
856                 break;
857         case 2:
858                 RegRWStruct->value = rtw_read16(Adapter, offset);
859                 break;
860         default:
861                 width = 4;
862                 RegRWStruct->value = rtw_read32(Adapter, offset);
863                 break;
864         }
865         RT_TRACE(_module_mp_, _drv_notice_,
866                  ("rtl8188eu_oid_rt_pro_read_register_hdl: offset:0x%04X value:0x%X\n",
867                   offset, RegRWStruct->value));
868
869         _irqlevel_changed_(&oldirql, RAISE);
870
871         *poid_par_priv->bytes_rw = width;
872
873 _func_exit_;
874
875         return status;
876 }
877 /*  */
878 int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv)
879 {
880         struct mp_rw_reg *RegRWStruct;
881         u32             offset, width, value;
882         int status = NDIS_STATUS_SUCCESS;
883         struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context);
884
885 _func_enter_;
886
887         RT_TRACE(_module_mp_, _drv_info_,
888                  ("+rtl8188eu_oid_rt_pro_write_register_hdl\n"));
889
890         if (poid_par_priv->type_of_oid != SET_OID)
891                 return NDIS_STATUS_NOT_ACCEPTED;
892
893         RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf;
894         offset = RegRWStruct->offset;
895         width = RegRWStruct->width;
896         value = RegRWStruct->value;
897
898         if (offset > 0xFFF)
899                 return NDIS_STATUS_NOT_ACCEPTED;
900
901         _irqlevel_changed_(&oldirql, LOWER);
902
903         switch (RegRWStruct->width) {
904         case 1:
905                 if (value > 0xFF) {
906                         status = NDIS_STATUS_NOT_ACCEPTED;
907                         break;
908                 }
909                 rtw_write8(padapter, offset, (u8)value);
910                 break;
911         case 2:
912                 if (value > 0xFFFF) {
913                         status = NDIS_STATUS_NOT_ACCEPTED;
914                         break;
915                 }
916                 rtw_write16(padapter, offset, (u16)value);
917                 break;
918         case 4:
919                 rtw_write32(padapter, offset, value);
920                 break;
921         default:
922                 status = NDIS_STATUS_NOT_ACCEPTED;
923                 break;
924         }
925
926         _irqlevel_changed_(&oldirql, RAISE);
927
928         RT_TRACE(_module_mp_, _drv_info_,
929                  ("-rtl8188eu_oid_rt_pro_write_register_hdl: offset=0x%08X width=%d value=0x%X\n",
930                   offset, width, value));
931
932 _func_exit_;
933
934         return status;
935 }
936 /*  */
937 int rtl8188eu_oid_rt_pro_burst_read_register_hdl(struct oid_par_priv *poid_par_priv)
938 {
939         return 0;
940 }
941 /*  */
942 int rtl8188eu_oid_rt_pro_burst_write_register_hdl(struct oid_par_priv *poid_par_priv)
943 {
944         return 0;
945 }
946 /*  */
947 int rtl8188eu_oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv)
948 {
949         return 0;
950 }
951
952 /*  */
953 int rtl8188eu_oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv)
954 {
955         return 0;
956 }
957
958 /*  */
959 int rtl8188eu_oid_rt_pro_write16_eeprom_hdl (struct oid_par_priv *poid_par_priv)
960 {
961         return 0;
962 }
963 /*  */
964 int rtl8188eu_oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv)
965 {
966         return 0;
967 }
968 /*  */
969 int rtl8188eu_oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv)
970 {
971         return 0;
972 }
973 /*  */
974 int rtl8188eu_oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv)
975 {
976         return 0;
977 }
978 /*  */
979 int rtl8188eu_oid_rt_wr_attrib_mem_hdl (struct oid_par_priv *poid_par_priv)
980 {
981         return 0;
982 }
983 /*  */
984 int  rtl8188eu_oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv)
985 {
986         return 0;
987 }
988 /*  */
989 int rtl8188eu_oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv)
990 {
991         return 0;
992 }
993 /*  */
994 int rtl8188eu_oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv *poid_par_priv)
995 {
996         return 0;
997 }
998 /*  */
999 int rtl8188eu_oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv)
1000 {
1001         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
1002
1003         int status = NDIS_STATUS_SUCCESS;
1004
1005 _func_enter_;
1006
1007         RT_TRACE(_module_mp_, _drv_notice_, ("+OID_RT_PRO_SET_DATA_RATE_EX\n"));
1008
1009         if (poid_par_priv->type_of_oid != SET_OID)
1010                 return NDIS_STATUS_NOT_ACCEPTED;
1011
1012         _irqlevel_changed_(&oldirql, LOWER);
1013
1014         if (rtw_setdatarate_cmd(Adapter, poid_par_priv->information_buf) != _SUCCESS)
1015                 status = NDIS_STATUS_NOT_ACCEPTED;
1016
1017         _irqlevel_changed_(&oldirql, RAISE);
1018
1019 _func_exit_;
1020
1021         return status;
1022 }
1023 /*  */
1024 int rtl8188eu_oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv)
1025 {
1026         int status = NDIS_STATUS_SUCCESS;
1027         u8 thermal = 0;
1028         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
1029
1030 _func_enter_;
1031
1032         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_get_thermal_meter_hdl\n"));
1033
1034         if (poid_par_priv->type_of_oid != QUERY_OID)
1035                 return NDIS_STATUS_NOT_ACCEPTED;
1036
1037         if (poid_par_priv->information_buf_len < sizeof(u32))
1038                 return NDIS_STATUS_INVALID_LENGTH;
1039
1040         _irqlevel_changed_(&oldirql, LOWER);
1041         GetThermalMeter(Adapter, &thermal);
1042         _irqlevel_changed_(&oldirql, RAISE);
1043
1044         *(u32 *)poid_par_priv->information_buf = (u32)thermal;
1045         *poid_par_priv->bytes_rw = sizeof(u32);
1046
1047 _func_exit_;
1048
1049         return status;
1050 }
1051 /*  */
1052 int rtl8188eu_oid_rt_pro_read_tssi_hdl(struct oid_par_priv *poid_par_priv)
1053 {
1054         return 0;
1055 }
1056 /*  */
1057 int rtl8188eu_oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_priv)
1058 {
1059         int status = NDIS_STATUS_SUCCESS;
1060         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
1061
1062
1063 _func_enter_;
1064
1065         if (poid_par_priv->information_buf_len < sizeof(u8))
1066                 return NDIS_STATUS_INVALID_LENGTH;
1067
1068         _irqlevel_changed_(&oldirql, LOWER);
1069         if (poid_par_priv->type_of_oid == SET_OID) {
1070                 u8 enable;
1071
1072                 enable = *(u8 *)poid_par_priv->information_buf;
1073                 RT_TRACE(_module_mp_, _drv_notice_,
1074                          ("+rtl8188eu_oid_rt_pro_set_power_tracking_hdl: enable =%d\n", enable));
1075
1076                 SetPowerTracking(Adapter, enable);
1077         } else {
1078                 GetPowerTracking(Adapter, (u8 *)poid_par_priv->information_buf);
1079         }
1080         _irqlevel_changed_(&oldirql, RAISE);
1081
1082 _func_exit_;
1083
1084         return status;
1085 }
1086 /*  */
1087 int rtl8188eu_oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv)
1088 {
1089         return 0;
1090 }
1091 /*  */
1092 int rtl8188eu_oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv)
1093 {
1094         return 0;
1095 }
1096 /*  */
1097 int rtl8188eu_oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv)
1098 {
1099         return 0;
1100 }
1101 /*  */
1102 int rtl8188eu_oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv *poid_par_priv)
1103 {
1104         return 0;
1105 }
1106 /*  */
1107 int rtl8188eu_oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv *poid_par_priv)
1108 {
1109         return 0;
1110 }
1111
1112 /*   rtl8188eu_oid_rtl_seg_87_12_00   section start **************** */
1113 int rtl8188eu_oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv)
1114 {
1115         return 0;
1116 }
1117
1118 int rtl8188eu_oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv)
1119 {
1120         return 0;
1121 }
1122
1123 int rtl8188eu_oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv)
1124 {
1125         return 0;
1126 }
1127
1128 int rtl8188eu_oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv)
1129 {
1130         return 0;
1131 }
1132
1133 int rtl8188eu_oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv)
1134 {
1135         return NDIS_STATUS_SUCCESS;
1136 }
1137 /*  */
1138 int rtl8188eu_oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv)
1139 {
1140         struct efuse_access_struct *pefuse;
1141         u8 *data;
1142         u16 addr = 0, cnts = 0, max_available_size = 0;
1143         int status = NDIS_STATUS_SUCCESS;
1144         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
1145
1146 _func_enter_;
1147
1148         if (poid_par_priv->type_of_oid != QUERY_OID)
1149                 return NDIS_STATUS_NOT_ACCEPTED;
1150
1151         if (poid_par_priv->information_buf_len < sizeof(struct efuse_access_struct))
1152                 return NDIS_STATUS_INVALID_LENGTH;
1153
1154         pefuse = (struct efuse_access_struct *)poid_par_priv->information_buf;
1155         addr = pefuse->start_addr;
1156         cnts = pefuse->cnts;
1157         data = pefuse->data;
1158
1159         RT_TRACE(_module_mp_, _drv_notice_,
1160                  ("+rtl8188eu_oid_rt_pro_read_efuse_hd: buf_len=%d addr=%d cnts=%d\n",
1161                   poid_par_priv->information_buf_len, addr, cnts));
1162
1163         EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false);
1164
1165         if ((addr + cnts) > max_available_size) {
1166                 RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_read_efuse_hdl: parameter error!\n"));
1167                 return NDIS_STATUS_NOT_ACCEPTED;
1168         }
1169
1170         _irqlevel_changed_(&oldirql, LOWER);
1171         if (rtw_efuse_access(Adapter, false, addr, cnts, data) == _FAIL) {
1172                 RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_read_efuse_hdl: rtw_efuse_access FAIL!\n"));
1173                 status = NDIS_STATUS_FAILURE;
1174         } else {
1175                 *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
1176         }
1177         _irqlevel_changed_(&oldirql, RAISE);
1178
1179 _func_exit_;
1180
1181         return status;
1182 }
1183 /*  */
1184 int rtl8188eu_oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv)
1185 {
1186         struct efuse_access_struct *pefuse;
1187         u8 *data;
1188         u16 addr = 0, cnts = 0, max_available_size = 0;
1189         int status = NDIS_STATUS_SUCCESS;
1190         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
1191
1192
1193 _func_enter_;
1194
1195         if (poid_par_priv->type_of_oid != SET_OID)
1196                 return NDIS_STATUS_NOT_ACCEPTED;
1197
1198         pefuse = (struct efuse_access_struct *)poid_par_priv->information_buf;
1199         addr = pefuse->start_addr;
1200         cnts = pefuse->cnts;
1201         data = pefuse->data;
1202
1203         RT_TRACE(_module_mp_, _drv_notice_,
1204                  ("+rtl8188eu_oid_rt_pro_write_efuse_hdl: buf_len=%d addr=0x%04x cnts=%d\n",
1205                   poid_par_priv->information_buf_len, addr, cnts));
1206
1207         EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false);
1208
1209         if ((addr + cnts) > max_available_size) {
1210                 RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_write_efuse_hdl: parameter error"));
1211                 return NDIS_STATUS_NOT_ACCEPTED;
1212         }
1213
1214         _irqlevel_changed_(&oldirql, LOWER);
1215         if (rtw_efuse_access(Adapter, true, addr, cnts, data) == _FAIL)
1216                 status = NDIS_STATUS_FAILURE;
1217         _irqlevel_changed_(&oldirql, RAISE);
1218
1219 _func_exit_;
1220
1221         return status;
1222 }
1223 /*  */
1224 int rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv)
1225 {
1226         struct pgpkt *ppgpkt;
1227         int status = NDIS_STATUS_SUCCESS;
1228         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
1229
1230 _func_enter_;
1231
1232         *poid_par_priv->bytes_rw = 0;
1233
1234         if (poid_par_priv->information_buf_len < sizeof(struct pgpkt *))
1235                 return NDIS_STATUS_INVALID_LENGTH;
1236
1237         ppgpkt = (struct pgpkt *)poid_par_priv->information_buf;
1238
1239         _irqlevel_changed_(&oldirql, LOWER);
1240
1241         if (poid_par_priv->type_of_oid == QUERY_OID) {
1242                 RT_TRACE(_module_mp_, _drv_notice_,
1243                          ("rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: Read offset=0x%x\n",\
1244                          ppgpkt->offset));
1245
1246                 Efuse_PowerSwitch(Adapter, false, true);
1247                 if (Efuse_PgPacketRead(Adapter, ppgpkt->offset, ppgpkt->data, false) == true)
1248                         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
1249                 else
1250                         status = NDIS_STATUS_FAILURE;
1251                 Efuse_PowerSwitch(Adapter, false, false);
1252         } else {
1253                 RT_TRACE(_module_mp_, _drv_notice_,
1254                          ("rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: Write offset=0x%x word_en=0x%x\n",\
1255                          ppgpkt->offset, ppgpkt->word_en));
1256
1257                 Efuse_PowerSwitch(Adapter, true, true);
1258                 if (Efuse_PgPacketWrite(Adapter, ppgpkt->offset, ppgpkt->word_en, ppgpkt->data, false) == true)
1259                         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
1260                 else
1261                         status = NDIS_STATUS_FAILURE;
1262                 Efuse_PowerSwitch(Adapter, true, false);
1263         }
1264
1265         _irqlevel_changed_(&oldirql, RAISE);
1266
1267         RT_TRACE(_module_mp_, _drv_info_,
1268                  ("-rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: status=0x%08X\n", status));
1269
1270 _func_exit_;
1271
1272         return status;
1273 }
1274 /*  */
1275 int rtl8188eu_oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv)
1276 {
1277         u16 size;
1278         u8 ret;
1279         int status = NDIS_STATUS_SUCCESS;
1280         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
1281
1282 _func_enter_;
1283
1284         if (poid_par_priv->type_of_oid != QUERY_OID)
1285                 return NDIS_STATUS_NOT_ACCEPTED;
1286
1287         if (poid_par_priv->information_buf_len < sizeof(u32))
1288                 return NDIS_STATUS_INVALID_LENGTH;
1289
1290         _irqlevel_changed_(&oldirql, LOWER);
1291         ret = efuse_GetCurrentSize(Adapter, &size);
1292         _irqlevel_changed_(&oldirql, RAISE);
1293         if (ret == _SUCCESS) {
1294                 *(u32 *)poid_par_priv->information_buf = size;
1295                 *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
1296         } else {
1297                 status = NDIS_STATUS_FAILURE;
1298         }
1299 _func_exit_;
1300
1301         return status;
1302 }
1303 /*  */
1304 int rtl8188eu_oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv)
1305 {
1306         int status = NDIS_STATUS_SUCCESS;
1307         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
1308
1309 _func_enter_;
1310
1311         if (poid_par_priv->type_of_oid != QUERY_OID)
1312                 return NDIS_STATUS_NOT_ACCEPTED;
1313
1314         if (poid_par_priv->information_buf_len < sizeof(u32))
1315                 return NDIS_STATUS_INVALID_LENGTH;
1316
1317         *(u32 *)poid_par_priv->information_buf = efuse_GetMaxSize(Adapter);
1318         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
1319
1320         RT_TRACE(_module_mp_, _drv_info_,
1321                  ("-rtl8188eu_oid_rt_get_efuse_max_size_hdl: size=%d status=0x%08X\n",
1322                   *(int *)poid_par_priv->information_buf, status));
1323
1324 _func_exit_;
1325
1326         return status;
1327 }
1328 /*  */
1329 int rtl8188eu_oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv)
1330 {
1331         int status;
1332
1333 _func_enter_;
1334
1335         RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_efuse_hdl\n"));
1336
1337         if (poid_par_priv->type_of_oid == QUERY_OID)
1338                 status = rtl8188eu_oid_rt_pro_read_efuse_hdl(poid_par_priv);
1339         else
1340                 status = rtl8188eu_oid_rt_pro_write_efuse_hdl(poid_par_priv);
1341
1342         RT_TRACE(_module_mp_, _drv_info_, ("-rtl8188eu_oid_rt_pro_efuse_hdl: status=0x%08X\n", status));
1343
1344 _func_exit_;
1345
1346         return status;
1347 }
1348 /*  */
1349 int rtl8188eu_oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv)
1350 {
1351         u8              *data;
1352         int status = NDIS_STATUS_SUCCESS;
1353         struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);
1354         u16     maplen = 0;
1355
1356 _func_enter_;
1357
1358         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_efuse_map_hdl\n"));
1359
1360         EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&maplen, false);
1361
1362         *poid_par_priv->bytes_rw = 0;
1363
1364         if (poid_par_priv->information_buf_len < maplen)
1365                 return NDIS_STATUS_INVALID_LENGTH;
1366
1367         data = (u8 *)poid_par_priv->information_buf;
1368
1369         _irqlevel_changed_(&oldirql, LOWER);
1370
1371         if (poid_par_priv->type_of_oid == QUERY_OID) {
1372                 RT_TRACE(_module_mp_, _drv_info_,
1373                          ("rtl8188eu_oid_rt_pro_efuse_map_hdl: READ\n"));
1374
1375                 if (rtw_efuse_map_read(Adapter, 0, maplen, data) == _SUCCESS) {
1376                         *poid_par_priv->bytes_rw = maplen;
1377                 } else {
1378                         RT_TRACE(_module_mp_, _drv_err_,
1379                                  ("rtl8188eu_oid_rt_pro_efuse_map_hdl: READ fail\n"));
1380                         status = NDIS_STATUS_FAILURE;
1381                 }
1382         } else {
1383                 /*  SET_OID */
1384                 RT_TRACE(_module_mp_, _drv_info_,
1385                          ("rtl8188eu_oid_rt_pro_efuse_map_hdl: WRITE\n"));
1386
1387                 if (rtw_efuse_map_write(Adapter, 0, maplen, data) == _SUCCESS) {
1388                         *poid_par_priv->bytes_rw = maplen;
1389                 } else {
1390                         RT_TRACE(_module_mp_, _drv_err_,
1391                                  ("rtl8188eu_oid_rt_pro_efuse_map_hdl: WRITE fail\n"));
1392                         status = NDIS_STATUS_FAILURE;
1393                 }
1394         }
1395
1396         _irqlevel_changed_(&oldirql, RAISE);
1397
1398         RT_TRACE(_module_mp_, _drv_info_,
1399                  ("-rtl8188eu_oid_rt_pro_efuse_map_hdl: status=0x%08X\n", status));
1400
1401 _func_exit_;
1402
1403         return status;
1404 }
1405
1406 int rtl8188eu_oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv)
1407 {
1408         int status = NDIS_STATUS_SUCCESS;
1409         return status;
1410 }
1411
1412 int rtl8188eu_oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv)
1413 {
1414         u8              rx_pkt_type;
1415         int status = NDIS_STATUS_SUCCESS;
1416
1417 _func_enter_;
1418
1419         RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_set_rx_packet_type_hdl\n"));
1420
1421         if (poid_par_priv->type_of_oid != SET_OID)
1422                 return NDIS_STATUS_NOT_ACCEPTED;
1423
1424         if (poid_par_priv->information_buf_len < sizeof(u8))
1425                 return NDIS_STATUS_INVALID_LENGTH;
1426
1427         rx_pkt_type = *((u8 *)poid_par_priv->information_buf);/* 4 */
1428
1429         RT_TRACE(_module_mp_, _drv_info_, ("rx_pkt_type: %x\n", rx_pkt_type));
1430 _func_exit_;
1431
1432         return status;
1433 }
1434
1435 int rtl8188eu_oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv *poid_par_priv)
1436 {
1437         return 0;
1438 }
1439
1440 int rtl8188eu_oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv *poid_par_priv)
1441 {
1442         return 0;
1443 }
1444
1445 int rtl8188eu_mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv)
1446 {
1447         struct mp_xmit_parm *pparm;
1448         struct adapter *padapter;
1449         struct mp_priv *pmp_priv;
1450         struct pkt_attrib *pattrib;
1451
1452         RT_TRACE(_module_mp_, _drv_notice_, ("+%s\n", __func__));
1453
1454         pparm = (struct mp_xmit_parm *)poid_par_priv->information_buf;
1455         padapter = (struct adapter *)poid_par_priv->adapter_context;
1456         pmp_priv = &padapter->mppriv;
1457
1458         if (poid_par_priv->type_of_oid == QUERY_OID) {
1459                 pparm->enable = !pmp_priv->tx.stop;
1460                 pparm->count = pmp_priv->tx.sended;
1461         } else {
1462                 if (pparm->enable == 0) {
1463                         pmp_priv->tx.stop = 1;
1464                 } else if (pmp_priv->tx.stop == 1) {
1465                         pmp_priv->tx.stop = 0;
1466                         pmp_priv->tx.count = pparm->count;
1467                         pmp_priv->tx.payload = pparm->payload_type;
1468                         pattrib = &pmp_priv->tx.attrib;
1469                         pattrib->pktlen = pparm->length;
1470                         memcpy(pattrib->dst, pparm->da, ETH_ALEN);
1471                         SetPacketTx(padapter);
1472                 } else {
1473                         return NDIS_STATUS_FAILURE;
1474                 }
1475         }
1476
1477         return NDIS_STATUS_SUCCESS;
1478 }
1479
1480 /*  */
1481 int rtl8188eu_oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv)
1482 {
1483         int status = NDIS_STATUS_SUCCESS;
1484
1485 _func_enter_;
1486
1487         if (poid_par_priv->type_of_oid != SET_OID) {
1488                 status = NDIS_STATUS_NOT_ACCEPTED;
1489                 return status;
1490         }
1491
1492         RT_TRACE(_module_mp_, _drv_info_,
1493                  ("\n ===> Setrtl8188eu_oid_rt_set_power_down_hdl.\n"));
1494
1495         _irqlevel_changed_(&oldirql, LOWER);
1496
1497         /* CALL  the power_down function */
1498         _irqlevel_changed_(&oldirql, RAISE);
1499
1500 _func_exit_;
1501
1502         return status;
1503 }
1504 /*  */
1505 int rtl8188eu_oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv)
1506 {
1507         return 0;
1508 }