diff --git a/scheduler/inc/scheduler_api.h b/scheduler/inc/scheduler_api.h index e16979badc..934c9e42fe 100644 --- a/scheduler/inc/scheduler_api.h +++ b/scheduler/inc/scheduler_api.h @@ -41,6 +41,10 @@ */ #define SYS_MSG_COOKIE 0xFACE +#define scheduler_get_src_id(qid) ((qid) >> 16) +#define scheduler_get_dest_id(qid) ((qid) & 0xFFFF) +#define scheduler_get_qid(src, dest) ((dest) | ((src) << 16)) + typedef enum { SYS_MSG_ID_MC_TIMER, SYS_MSG_ID_FTM_RSP, @@ -140,28 +144,46 @@ QDF_STATUS scheduler_deregister_module(QDF_MODULE_ID qid); /** * scheduler_post_msg_by_priority() - post messages by priority - * @qid: queue id to to post message + * @qid: queue id to which the message has to be posted. * @msg: message pointer * @is_high_priority: set to true for high priority message else false * * Return: QDF status */ -QDF_STATUS scheduler_post_msg_by_priority(QDF_MODULE_ID qid, - struct scheduler_msg *msg, bool is_high_priority); +QDF_STATUS scheduler_post_msg_by_priority(uint32_t qid, + struct scheduler_msg *msg, + bool is_high_priority); /** * scheduler_post_msg() - post normal messages(no priority) - * @qid: queue id to to post message + * @qid: queue id to which the message has to be posted. * @msg: message pointer * * Return: QDF status */ -static inline QDF_STATUS scheduler_post_msg(QDF_MODULE_ID qid, - struct scheduler_msg *msg) +static inline QDF_STATUS scheduler_post_msg(uint32_t qid, + struct scheduler_msg *msg) { return scheduler_post_msg_by_priority(qid, msg, false); } +/** + * scheduler_post_message() - post normal messages(no priority) + * @src_id: Source module of the message + * @dest_id: Destination module of the message + * @msg: message pointer + * + * This function will mask the src_id, and destination id to qid of + * scheduler_post_msg + * Return: QDF status + */ +static inline QDF_STATUS scheduler_post_message(QDF_MODULE_ID src_id, + QDF_MODULE_ID dest_id, + struct scheduler_msg *msg) +{ + return scheduler_post_msg(scheduler_get_qid(src_id, dest_id), msg); +} + /** * scheduler_resume() - resume scheduler thread * diff --git a/scheduler/src/scheduler_api.c b/scheduler/src/scheduler_api.c index ed93dfc997..fe003c81d8 100644 --- a/scheduler/src/scheduler_api.c +++ b/scheduler/src/scheduler_api.c @@ -216,7 +216,7 @@ QDF_STATUS scheduler_deinit(void) return QDF_STATUS_SUCCESS; } -QDF_STATUS scheduler_post_msg_by_priority(QDF_MODULE_ID qid, +QDF_STATUS scheduler_post_msg_by_priority(uint32_t qid, struct scheduler_msg *msg, bool is_high_priority) { @@ -224,6 +224,8 @@ QDF_STATUS scheduler_post_msg_by_priority(QDF_MODULE_ID qid, struct scheduler_mq_type *target_mq; struct scheduler_msg *queue_msg; struct scheduler_ctx *sched_ctx; + uint16_t src_id; + uint16_t dest_id; QDF_BUG(msg); if (!msg) @@ -244,6 +246,13 @@ QDF_STATUS scheduler_post_msg_by_priority(QDF_MODULE_ID qid, return QDF_STATUS_E_FAILURE; } + dest_id = scheduler_get_dest_id(qid); + src_id = scheduler_get_src_id(qid); + + if (dest_id >= QDF_MODULE_ID_MAX || src_id >= QDF_MODULE_ID_MAX) { + sched_err("Src_id/Dest_id invalid, cannot post message"); + return QDF_STATUS_E_FAILURE; + } /* Target_If is a special message queue in phase 3 convergence beacause * its used by both legacy WMA and as well as new UMAC components which * directly populate callback handlers in message body. @@ -255,20 +264,20 @@ QDF_STATUS scheduler_post_msg_by_priority(QDF_MODULE_ID qid, * legacy WMA message queue id to target_if queue such that its always * handled in right order. */ - if (QDF_MODULE_ID_WMA == qid) { + if (QDF_MODULE_ID_WMA == dest_id) { msg->callback = NULL; /* change legacy WMA message id to new target_if mq id */ - qid = QDF_MODULE_ID_TARGET_IF; + dest_id = QDF_MODULE_ID_TARGET_IF; } - qidx = sched_ctx->queue_ctx.scheduler_msg_qid_to_qidx[qid]; + qidx = sched_ctx->queue_ctx.scheduler_msg_qid_to_qidx[dest_id]; if (qidx >= SCHEDULER_NUMBER_OF_MSG_QUEUE) { sched_err("Scheduler is deinitialized ignore msg"); return QDF_STATUS_E_FAILURE; } if (!sched_ctx->queue_ctx.scheduler_msg_process_fn[qidx]) { - QDF_DEBUG_PANIC("callback not registered for qid[%d]", qid); + QDF_DEBUG_PANIC("callback not registered for qid[%d]", dest_id); return QDF_STATUS_E_FAILURE; }