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_API_C_
16 #include "hal_headers.h"
17
rtw_hal_get_tsf(void * hal,u8 port,u32 * tsf_h,u32 * tsf_l)18 enum rtw_hal_status rtw_hal_get_tsf(void *hal, u8 port, u32 *tsf_h, u32 *tsf_l)
19 {
20 enum rtw_hal_status status = RTW_HAL_STATUS_FAILURE;
21 status = rtw_hal_mac_get_tsf(hal, &port, tsf_h, tsf_l);
22
23 if (status != RTW_HAL_STATUS_SUCCESS) {
24 PHL_TRACE(COMP_PHL_MCC, _PHL_ERR_, "rtw_hal_get_tsf(): get failed\n");
25 }
26 return status;
27 }
28
29 enum rtw_hal_status
rtw_hal_tsf_sync(void * hal,u8 port_sync_from,u8 port_sync_to,enum phl_band_idx band,s32 sync_offset_tu,enum hal_tsf_sync_act act)30 rtw_hal_tsf_sync(void *hal, u8 port_sync_from,
31 u8 port_sync_to, enum phl_band_idx band,
32 s32 sync_offset_tu, enum hal_tsf_sync_act act)
33 {
34 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
35
36 return rtw_hal_mac_tsf_sync(hal_info, port_sync_from,
37 port_sync_to, band, sync_offset_tu, act);
38 }
39
40 enum rtw_hal_status
rtw_hal_config_rts_th(void * hal,u8 band_idx,u16 rts_time_th,u16 rts_len_th)41 rtw_hal_config_rts_th(void *hal, u8 band_idx, u16 rts_time_th, u16 rts_len_th)
42 {
43 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
44
45 return rtw_hal_mac_set_hw_rts_th(hal_info, band_idx, rts_time_th, rts_len_th);
46 }
47
rtw_hal_get_btc_req_slot(void * hal)48 u32 rtw_hal_get_btc_req_slot(void *hal)
49 {
50 return rtw_hal_btc_req_bt_slot_t(hal);
51 }
52
53 /**
54 * This function is used to pause/unpause multiple macid
55 * @hal: see hal_info_t
56 * @macid_arr: macid array to be pause/unpause
57 * 1 means to be set (pause/unpause)
58 * 0 means don't care
59 * @macid_arr_sz: size of macid array
60 * @pause: all macid of this array to be paused/unpaused
61 * 1=paused,0=unpaused
62 */
63 enum rtw_hal_status
rtw_hal_set_macid_grp_pause(void * hal,u32 * macid_arr,u8 arr_size,bool pause)64 rtw_hal_set_macid_grp_pause(void *hal, u32 *macid_arr, u8 arr_size, bool pause)
65 {
66 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
67 struct rtw_hal_com_t *hal_com = hal_info->hal_com;
68
69 return rtw_hal_mac_set_macid_grp_pause(hal_com, macid_arr, arr_size, pause);
70 }
71
72 /**
73 * This function is used to pause/unpause single macid
74 * @hal: see hal_info_t
75 * @macid: macid be pause/unpause
76 * @pause: all macid of this array to be paused/unpaused
77 * 1=paused,0=unpaused
78 */
79 enum rtw_hal_status
rtw_hal_set_macid_pause(void * hal,u16 macid,bool pause)80 rtw_hal_set_macid_pause(void *hal, u16 macid, bool pause)
81 {
82 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
83 struct rtw_hal_com_t *hal_com = hal_info->hal_com;
84
85 return rtw_hal_mac_set_macid_pause(hal_com, macid, pause);
86 }
87
rtw_hal_set_dfs_tb_ctrl(void * hal,u8 set)88 enum rtw_hal_status rtw_hal_set_dfs_tb_ctrl(void *hal, u8 set)
89 {
90 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
91
92 return rtw_hal_mac_set_dfs_tb_ctrl(hal_info, set);
93 }
94
rtw_hal_get_phy_stat_info(void * hal,enum phl_band_idx hw_band,enum phl_stat_info_query phy_stat)95 u32 rtw_hal_get_phy_stat_info(void *hal, enum phl_band_idx hw_band,
96 enum phl_stat_info_query phy_stat)
97 {
98 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
99 struct rtw_hal_com_t *hal_com = hal_info->hal_com;
100 struct rtw_hal_stat_info *stat_info = &hal_com->band[hw_band].stat_info;
101
102 switch (phy_stat) {
103 case STAT_INFO_FA_ALL:
104 return stat_info->cnt_fail_all;
105 case STAT_INFO_CCA_ALL:
106 return stat_info->cnt_cca_all;
107 default:
108 return 0;
109 }
110 }