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 _HAL_P2PPS_C_
16 #include "hal_headers.h"
17
18 #ifdef CONFIG_PHL_P2PPS
19 #define TSF32_TOG_EARLY_T 2000 /*2ms*/
20
rtw_hal_noa_enable(void * hal,struct rtw_phl_noa_info * noa_info,struct rtw_phl_noa_desc * in_desc,u16 macid)21 enum rtw_hal_status rtw_hal_noa_enable(void *hal,
22 struct rtw_phl_noa_info *noa_info,
23 struct rtw_phl_noa_desc *in_desc,
24 u16 macid)
25 {
26 enum rtw_hal_status ret = RTW_HAL_STATUS_FAILURE;
27 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
28 u8 cur_en_desc_num = noa_info->en_desc_num;
29
30 PHL_TRACE(COMP_PHL_P2PPS, _PHL_INFO_, "[NoA]%s: macid(0x%x), cur_en_desc_num(%d)\n",
31 __func__, macid, cur_en_desc_num);
32 if (cur_en_desc_num == 0) {
33 ret = rtw_hal_mac_noa_init(hal_info, noa_info, in_desc, macid);
34 } else {
35 ret = rtw_hal_mac_noa_update(hal_info, noa_info, in_desc, macid);
36 }
37 return ret;
38 }
39
rtw_hal_noa_disable(void * hal,struct rtw_phl_noa_info * noa_info,struct rtw_phl_noa_desc * in_desc,u16 macid)40 enum rtw_hal_status rtw_hal_noa_disable(void *hal,
41 struct rtw_phl_noa_info *noa_info,
42 struct rtw_phl_noa_desc *in_desc,
43 u16 macid)
44 {
45 enum rtw_hal_status ret = RTW_HAL_STATUS_FAILURE;
46 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
47 u8 cur_en_desc_num = noa_info->en_desc_num;
48
49 PHL_TRACE(COMP_PHL_P2PPS, _PHL_INFO_, "[NoA]%s(): cur_en_desc_num(%d)\n",
50 __func__, cur_en_desc_num);
51 if (cur_en_desc_num == 1) {
52 ret = rtw_hal_mac_noa_terminate(hal_info, noa_info, in_desc,
53 macid);
54 } else {
55 ret = rtw_hal_mac_noa_remove(hal_info, noa_info, in_desc, macid);
56 }
57 return ret;
58 }
59
rtw_hal_tsf32_tog_enable(void * hal,struct rtw_wifi_role_t * w_role)60 enum rtw_hal_status rtw_hal_tsf32_tog_enable(void *hal,
61 struct rtw_wifi_role_t *w_role)
62 {
63 enum rtw_hal_status h_stat = RTW_HAL_STATUS_FAILURE;
64 struct hal_info_t *hal_info = hal;
65 h_stat = rtw_hal_mac_tsf32_tog_enable(hal_info, w_role->hw_band,
66 w_role->hw_port,
67 TSF32_TOG_EARLY_T);
68 return h_stat;
69 }
70
rtw_hal_tsf32_tog_disable(void * hal,struct rtw_wifi_role_t * w_role)71 enum rtw_hal_status rtw_hal_tsf32_tog_disable(void *hal,
72 struct rtw_wifi_role_t *w_role)
73 {
74 enum rtw_hal_status h_stat = RTW_HAL_STATUS_FAILURE;
75 struct hal_info_t *hal_info = hal;
76 h_stat = rtw_hal_mac_tsf32_tog_disable(hal_info, w_role->hw_band,
77 w_role->hw_port);
78 return h_stat;
79 }
80
rtw_hal_get_tsf32_tog_rpt(void * hal,struct rtw_phl_tsf32_tog_rpt * rpt)81 enum rtw_hal_status rtw_hal_get_tsf32_tog_rpt(void *hal,
82 struct rtw_phl_tsf32_tog_rpt *rpt)
83 {
84 struct hal_info_t *hal_info = hal;
85
86 return rtw_hal_mac_get_tsf32_tog_rpt(hal_info, rpt);
87 }
88 #endif
89
90