DMM API Reference  3.10.00.15
dmm_scheduler.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  @file dmm_scheduler.h
4 
5  @brief Dual Mode Manager Scheduler
6 
7  Group: WCS LPC
8  $Target Device: DEVICES $
9 
10  ******************************************************************************
11  $License: TISD 2019 $
12  ******************************************************************************
13  $Release Name: PACKAGE NAME $
14  $Release Date: PACKAGE RELEASE DATE $
15  *****************************************************************************/
16 /*!****************************************************************************
17  * @file dmm_scheduler.h
18  *
19  * @brief Dual Mode Manager Scheduler
20  *
21  * DMM enables devices to run multiple wireless protocol stacks concurrently.
22  * The DMMSch is to enable concurrent operation of multiple stacks with minimized conflicts
23  * so that it does not cause significant performance degradation.
24  * The DMMSch uses Application Level, Stack Level information, and Global Priority Table (GPT) when scheduling a command.
25  * Stack Level information (provided by stack) is embedded in each RF command and it includes:
26  * - Start Type, Start Time, AllowDelay, Priority, Activity, etc.
27  * Application Level information (provided by User via the Policy Table) includes:
28  * - Application State Name, Weight, AppliedActivity, Pause, etc.
29  * Global Priority Table (GPT)
30  * - GPT defines relative priorities of the two stacks
31  * The DMMSch uses Start Type, Start Time, and AllowDelay (Stack Level Information) when scheduling a RF command
32  * and tries to avoid a conflict by delaying the command if allowed.
33  * When a command conflicts with another (during scheduling or execution),
34  * The DMMSch selects one command over the other based on the final priority of two commands as below:
35  * Final Priority = GPT (Stack level priority) + weight (Application Level)
36  *
37  * # DMMSch API #
38  *
39  * To use the DMMSch module to schedule a tacks RF commands, the application
40  * calls the following APIs:
41  * - DMMSch_init(): Initialize the DMMSch module/task.
42  * - DMMSch_Params_init(): Initialize a DMMSch_Params structure
43  * with default values. Then change the parameters from non-default
44  * values as needed.
45  * - DMMSch_open(): Open an instance of the DMMSch module,
46  * passing the initialized parameters.
47  * - Stack A application - DMMSch_registerClient: Passes Task_Handle and StackRole so
48  * DMMSch can map the Task_Handle to the stack role
49  * - Stack A application - Rf_open -> DMMSch_rfOpen: DMMSch overwrites the RF_Mode and
50  * rf patches for multi-mode operation, maps RF Handle to the stack ID,
51  * assigns phySwitchingTime for DMM operation.
52  * From this point, Task_Handle, StackRole, and Stack ID are all related.
53  * - Stack B application - DMMSch_registerClient: Passes Task_Handle and StackRole so
54  * DMMSch can map the Task_Handle to the stack role
55  * - Stack B application - Rf_open -> DMMSch_rfOpen: Rf_open -> DMMSch_rfOpen: DMMSch overwrites the RF_Mode and
56  * rf patches for multi-mode operation, maps RF Handle to the stack ID,
57  * assigns phySwitchingTime for DMM operation.
58  * From this point, Task_Handle, StackRole, and Stack ID are all related.
59  * - Stack A application - RF_scheduleCmd -> DMMSch_rfScheduleCmd: DMMSch adjusted timing based on policy
60  * - Stack B application - RF_scheduleCmd -> DMMSch_rfScheduleCmd: DMMSch adjusted timing based on policy
61  *
62  *
63  ********************************************************************************/
64 
65 #ifndef DMMSch_H_
66 #define DMMSch_H_
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
72 #include "stdint.h"
73 
74 #include <ti/drivers/rf/RF.h>
75 #include <ti/sysbios/knl/Task.h>
76 
77 #include "dmm_policy.h"
78 
79 
87 #define xDMM_DEBUG_LOGGING
88 
89 #ifdef DMM_DEBUG_LOGGING
90 #include <xdc/runtime/Log.h>
91 #define DMM_dbgLog0(str) Log_info0(str)
92 #define DMM_dbgLog1(str, a0) Log_info1(str, a0)
93 #define DMM_dbgLog2(str, a0, a1) Log_info2(str, a0, a1)
94 #define DMM_dbgLog3(str, a0, a1, a2) Log_info3(str, a0, a1, a2)
95 #define DMM_dbgLog4(str, a0, a1, a2, a3) Log_info4(str, a0, a1, a2, a3)
96 #define DMM_dbgLog5(str, a0, a1, a2, a3, a4) Log_info5(str, a0, a1, a2, a3, a4)
97 #else
98 #define DMM_dbgLog0(str)
99 #define DMM_dbgLog1(str, a0)
100 #define DMM_dbgLog2(str, a0, a1)
101 #define DMM_dbgLog3(str, a0, a1, a2)
102 #define DMM_dbgLog4(str, a0, a1, a2, a3)
103 #define DMM_dbgLog5(str, a0, a1, a2, a3, a4)
104 #endif
105 
110 typedef struct {
113 } DMMSch_Params;
114 
118 typedef enum
119 {
125 
131 #define CONFLICT_FLUSH_ALL 1
132 
141 typedef void (*DMMSch_PreemptionCb)(DMMPolicy_StackRole stackRolePreempted);
142 
150 extern void DMMSch_Params_init(DMMSch_Params *params);
151 
155 extern void DMMSch_init(void);
156 
161 extern void DMMSch_registerPreemptionCb(DMMSch_PreemptionCb dmmSchPreemptionCb);
162 
167 extern void DMMSch_open(DMMSch_Params *params);
168 
176 extern void DMMSch_registerClient(Task_Handle* pTaskHndl, DMMPolicy_StackRole StackRole);
177 
188 extern RF_Handle DMMSch_rfOpen(RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pOpSetup, RF_Params *params);
189 
204 extern RF_CmdHandle DMMSch_rfPostCmd(RF_Handle h, RF_Op* pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
205 
218 extern RF_CmdHandle DMMSch_rfScheduleCmd(RF_Handle h, RF_Op* pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent);
219 
231 extern RF_EventMask DMMSch_rfRunCmd(RF_Handle h, RF_Op* pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
232 
245 extern RF_EventMask DMMSch_rfRunScheduleCmd(RF_Handle h, RF_Op* pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent);
246 
266 extern RF_Stat DMMSch_rfCancelCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
267 
286 extern RF_Stat DMMSch_rfFlushCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
287 
301 extern RF_Stat DMMSch_rfRunImmediateCmd(RF_Handle h, uint32_t* pCmdStruct);
302 
316 extern RF_Stat DMMSch_rfRunDirectCmd(RF_Handle h, uint32_t cmd);
317 
318 
324 extern bool DMMSch_setBlockModeOn(DMMPolicy_StackRole stackRole);
325 
331 extern bool DMMSch_setBlockModeOff(DMMPolicy_StackRole stackRole);
332 
338 extern bool DMMSch_getBlockModeStatus(DMMPolicy_StackRole stackRole);
339 
343 extern RF_Stat DMMSch_rfRequestAccess(RF_Handle h, RF_AccessParams *pParams);
344 
345 #ifdef __cplusplus
346 }
347 #endif
348 
349 #endif /* DMMSch_H_ */
Dual Mode Policy Manager.
RF_CmdHandle DMMSch_rfPostCmd(RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent)
Handles calls from a stack to RF_postCmd (re-mapped to DMMSch_postCmd), adjusts timing as necessary a...
used to define where there is no conflict in commands.
Definition: dmm_scheduler.h:120
void DMMSch_init(void)
Function that initializes the DMMSch module.
void DMMSch_open(DMMSch_Params *params)
Function to open the DMMSch module.
bool DMMSch_getBlockModeStatus(DMMPolicy_StackRole stackRole)
Get Block mode status.
void DMMSch_Params_init(DMMSch_Params *params)
Function to initialize the DMMSch_Params struct to its defaults.
RF_Stat DMMSch_rfCancelCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode)
Abort/stop/cancel single command in command queue.
RF parameter struct DMM Scheduler parameters are used with the DMMSch_open() and DMMSch_Params_init()...
Definition: dmm_scheduler.h:110
Structure used to define a stack command index table. Reserved for future usage.
Definition: dmm_policy.h:251
void DMMSch_registerPreemptionCb(DMMSch_PreemptionCb dmmSchPreemptionCb)
allows policy manager to register a callback on command preemption
DMMPolicy_StackCmdIndexTable * indexTable
Define the index table for the scheduler.
Definition: dmm_scheduler.h:112
used to define where there is a conflict with both previous and next command.
Definition: dmm_scheduler.h:123
bool DMMSch_setBlockModeOn(DMMPolicy_StackRole stackRole)
Turn on Block mode.
RF_Stat DMMSch_rfRunDirectCmd(RF_Handle h, uint32_t cmd)
Send any Direct command.
DMMPolicy_StackRole
the stack roles supported
Definition: dmm_policy.h:218
#define DMMPOLICY_NUM_STACKS
Number of RF driver clients supported.
Definition: dmm_policy.h:156
used to define where there is a conflict with the next command.
Definition: dmm_scheduler.h:122
DMM_ConflictStatus
DMM Conflict struct DMM Conflict Status.
Definition: dmm_scheduler.h:118
RF_CmdHandle DMMSch_rfScheduleCmd(RF_Handle h, RF_Op *pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent)
Handles calls from a stack to RF_scheduleCmd (re-mapped to DMMSch_scheduleCmd), adjusts timing as nec...
RF_Stat DMMSch_rfRequestAccess(RF_Handle h, RF_AccessParams *pParams)
Request access RF API that should not be used in DMM
void DMMSch_registerClient(Task_Handle *pTaskHndl, DMMPolicy_StackRole StackRole)
Register an DMM Scheduler client.
void(* DMMSch_PreemptionCb)(DMMPolicy_StackRole stackRolePreempted)
Defines the preemption callback.
Definition: dmm_scheduler.h:141
RF_Stat DMMSch_rfRunImmediateCmd(RF_Handle h, uint32_t *pCmdStruct)
Send any Immediate command.
RF_Handle DMMSch_rfOpen(RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pOpSetup, RF_Params *params)
Intercepts calls from a stack to RF_postCmd (re-mapped to DMMSch_rfOpen), The DMMSch module uses this...
RF_Stat DMMSch_rfFlushCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode)
Abort/stop/cancel command and any subsequent commands in command queue.
bool DMMSch_setBlockModeOff(DMMPolicy_StackRole stackRole)
Turn off Block mode.
RF_EventMask DMMSch_rfRunScheduleCmd(RF_Handle h, RF_Op *pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent)
Handles calls from a stack to RF_runScheduleCmd (re-mapped to DMMSch_runScheduleCmd), adjusts timing as necessary and schedules then accordingly with RF_scheduleCmd.
used to define where there is a conflict with the previous command.
Definition: dmm_scheduler.h:121
RF_EventMask DMMSch_rfRunCmd(RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent)
Handles calls from a stack to RF_runCmd (re-mapped to DMMSch_runCmd), adjusts timing as necessary and...