xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852be/phl/hal_g6/hal_c2h.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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_C2H_C_
16 #include "hal_headers.h"
17 
18 
19 struct hal_c2h_hdl c2h_list[] =
20 {
21 	{C2H_CAT_OUTSRC, C2H_CLS_PHYDM_MIN, C2H_CLS_PHYDM_MAX,
22 		rtw_hal_bb_process_c2h},
23 	{C2H_CAT_OUTSRC, C2H_CLS_BTC_MIN, C2H_CLS_BTC_MAX,
24 		rtw_hal_btc_process_c2h},
25 	{C2H_CAT_MAC, C2H_CLS_MAC_MIN, C2H_CLS_MAC_MAX,
26 		rtw_hal_mac_process_c2h},
27 	{C2H_CAT_MAX, C2H_CLS_MAX, C2H_CLS_MAX, NULL}
28 };
29 
hal_c2h_post_process(void * phl,void * hal,void * c2h)30 void hal_c2h_post_process(void *phl, void *hal, void *c2h)
31 {
32 	struct rtw_phl_com_t *phl_com = (struct rtw_phl_com_t *)phl;
33 	struct rtw_c2h_info *c = (struct rtw_c2h_info *)c2h;
34 	u8 i = 0;
35 	u32 ret = 0;
36 
37 	for (i = 0; C2H_CAT_MAX != c2h_list[i].cat; i++) {
38 		if (c->c2h_cat == c2h_list[i].cat) {
39 			if (c->c2h_class >= c2h_list[i].cls_min &&
40 				c->c2h_class <= c2h_list[i].cls_max) {
41 				ret = c2h_list[i].c2h_hdl(hal, c2h);
42 				break;
43 			}
44 		}
45 	}
46 
47 	if (ret > 0) {
48 		/* submit phl msg hub */
49 		struct phl_msg msg = {0};
50 		struct phl_msg_attribute attr = {0};
51 
52 		SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_MDL_RX);
53 		SET_MSG_EVT_ID_FIELD(msg.msg_id, (u16)ret);
54 		if (rtw_phl_msg_hub_hal_send(phl_com, &attr, &msg) !=
55 			RTW_PHL_STATUS_SUCCESS) {
56 			PHL_ERR("%s rtw_phl_msg_hub_hal_send failed\n", __func__);
57 		}
58 	}
59 }
60 
61