1 /****************************************************************************** 2 * 3 * Copyright(c) 2019 - 2020 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 * Author: vincent_fann@realtek.com 15 * 16 *****************************************************************************/ 17 #ifndef __PHL_CMD_JOB_H__ 18 #define __PHL_CMD_JOB_H__ 19 20 #define RTW_PHL_JOB_NAME_LEN 32 21 #ifndef MIN 22 #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) 23 #endif 24 struct fsm_msg; 25 struct _cmd_obj; 26 27 /* command job */ 28 enum JOB_ID { 29 JOB_RUN_FUNC, 30 JOB_ADD_STA_ENTRY, 31 JOB_ADD_MACID, 32 JOB_MAX, 33 }; 34 35 struct job_hdl_ent { 36 u16 job_id; 37 char name[RTW_PHL_JOB_NAME_LEN]; 38 int (*job_func)(struct _cmd_obj *pcmd, void *param); 39 }; 40 41 enum JOB_RESULT { 42 JOB_SUCCESS, 43 /* caller thread will be schedule out until job is completed */ 44 JOB_TIMEOUT, 45 JOB_FAILURE 46 }; 47 48 struct wait_completion { 49 50 u8 sync; 51 u32 submit_time; 52 53 /* <0: not synchronous, 54 * 0: wait forever, 55 * >0: max waitting time (ms) 56 */ 57 int max_wait_time; 58 59 _os_event done; 60 61 /* JOB_WAIT_COMPLETION use */ 62 int rtn; /* handle return value */ 63 enum JOB_RESULT result; /* operation result */ 64 }; 65 66 struct phl_cmd_job { 67 _os_list list; 68 u16 id; 69 struct wait_completion wait; 70 u8 pwr_level; 71 union { 72 struct { /* JOB_RUN_FUNC */ 73 int (*func)(void *priv, void *param); /* TODO remove */ 74 int (*fptr)(void *priv, void *param, bool discard); 75 void *priv; 76 void *parm; 77 int parm_sz; 78 char name[RTW_PHL_JOB_NAME_LEN]; 79 } cmd; 80 81 struct { /* JOB_ADD_STA_ENTRY */ 82 struct rtw_phl_stainfo_t *sta; 83 } sta; 84 } u; 85 }; 86 87 enum PWR_LEVEL { 88 PWR_DONT_CARE, /* able to run in any kind of power mode */ 89 PWR_NO_IO, /* without register read write */ 90 PWR_BASIC_IO /* leave 32K and PG */ 91 }; 92 93 enum JOB_SYNC { 94 JOB_ASYNC, 95 /* caller thread will be schedule out until job is completed */ 96 JOB_WAIT_COMPLETION 97 }; 98 99 char *job_name(struct _cmd_obj *pcmd, u8 id); 100 void cmd_set_job_tbl(struct _cmd_obj *pcmd); 101 void cmd_discard_msg_job(struct _cmd_obj *pcmd, struct fsm_msg *msg); 102 int phl_cmd_do_job(struct _cmd_obj *pcmd, void *param); 103 104 /* command thread jobs */ 105 /* TODO remove below when no reference */ 106 enum rtw_phl_status rtw_phl_job_add_fptr(void *phl, void *func, 107 void *priv, void *parm, char *name, enum PWR_LEVEL pwr); 108 109 enum rtw_phl_status rtw_phl_job_fill_fptr(void *phl, struct phl_cmd_job *job, 110 void *func, void *priv, void *parm, char *name, enum PWR_LEVEL pwr); 111 112 enum rtw_phl_status phl_cmd_enqueue_and_wait_job(struct _cmd_obj *pcmd, 113 struct fsm_msg *msg); 114 115 enum rtw_phl_status phl_cmd_complete_job(void *phl, struct phl_cmd_job *job); 116 117 enum rtw_phl_status rtw_phl_job_reg_wdog(void *phl, 118 int (*func)(void *priv, void *param, bool discard), 119 void *priv, void *parm, int parm_sz, char *name, enum PWR_LEVEL pwr); 120 enum rtw_phl_status rtw_phl_cmd_pause_wdog(void *phl, char *reason); 121 enum rtw_phl_status rtw_phl_cmd_resume_wdog(void *phl, char *reason); 122 123 enum rtw_phl_status rtw_hal_add_sta_entry_job(void *phl, 124 struct rtw_phl_stainfo_t *sta, enum JOB_SYNC sync); 125 126 #endif /* __PHL_CMD_JOB_H__ */ 127