瀏覽代碼

qcacld-3.0: Add timer related messages at the top of PE queue

qcacld-2.0 to qcacld-3.0 propagation

Currently when PE queue is full, timer message gets queued at the
end of PE queue even when timer gets expired in time. This causes
delay in processing timer messages. This delay can be maximum if
timer message is the last message in PE queue. This can take substantial
amount of time to process timer message as timer message will be
processed only after processing of other messages. For instance,
if timer message processing takes substantial amount of time during
scan, it can delay sending max channel timeout and may result in
scan timeout. So, add timer related messages at
the top of PE queue to process those messages immediately.

Change-Id: Iccaf0075c97a7edd2c1de1d168f1a4e7d01381c2
CRs-Fixed: 936179
Padma, Santhosh Kumar 9 年之前
父節點
當前提交
9509135262

+ 28 - 38
core/cds/inc/cds_mq.h

@@ -105,44 +105,34 @@ typedef enum {
 
 } CDS_MQ_ID;
 
-/**---------------------------------------------------------------------------
-
-   \brief cds_mq_post_message() - post a message to a message queue
-
-   This API allows messages to be posted to a specific message queue.  Messages
-   can be posted to the following message queues:
-
-   <ul>
-    <li> SME
-    <li> PE
-    <li> HAL
-    <li> TL
-   </ul>
-
-   \param msgQueueId - identifies the message queue upon which the message
-   will be posted.
-
-   \param message - a pointer to a message buffer.  Memory for this message
-   buffer is allocated by the caller and free'd by the QDF after the
-   message is posted to the message queue.  If the consumer of the
-   message needs anything in this message, it needs to copy the contents
-   before returning from the message queue handler.
-
-   \return QDF_STATUS_SUCCESS - the message has been successfully posted
-   to the message queue.
-
-   QDF_STATUS_E_INVAL - The value specified by msgQueueId does not
-   refer to a valid Message Queue Id.
-
-   QDF_STATUS_E_FAULT  - message is an invalid pointer.
-
-   QDF_STATUS_E_FAILURE - the message queue handler has reported
-   an unknown failure.
-
-   \sa
-
-   --------------------------------------------------------------------------*/
-QDF_STATUS cds_mq_post_message(CDS_MQ_ID msgQueueId, cds_msg_t *message);
+#define HIGH_PRIORITY 1
+#define LOW_PRIORITY 0
+QDF_STATUS cds_mq_post_message_by_priority(CDS_MQ_ID msg_queue_id,
+					   cds_msg_t *message,
+					   int is_high_priority);
+
+/**
+ * cds_mq_post_message() - posts a message to a message queue
+ * @msg_queue_id: Identifies the message queue upon which the message
+ *    will be posted.
+ * @message: A pointer to a message buffer. Memory for this message
+ *    buffer is allocated by the caller and free'd by the QDF after the
+ *    message is posted to the message queue.  If the consumer of the
+ *    message needs anything in this message, it needs to copy the contents
+ *    before returning from the message queue handler.
+ *
+ * Return: QDF_STATUS_SUCCESS for successful posting
+ *             QDF_STATUS_E_INVAL for invalid message queue id
+ *             QDF_STATUS_E_FAULT for invalid message pointer
+ *             QDF_STATUS_E_FAILURE for unknown failure reported by
+ *             message queue handler
+ */
+static inline QDF_STATUS cds_mq_post_message(CDS_MQ_ID msg_queue_id,
+					     cds_msg_t *message)
+{
+	return cds_mq_post_message_by_priority(msg_queue_id, message,
+						LOW_PRIORITY);
+}
 
 /**---------------------------------------------------------------------------
 

+ 1 - 0
core/cds/inc/cds_sched.h

@@ -535,6 +535,7 @@ QDF_STATUS cds_sched_close(void *p_cds_context);
 QDF_STATUS cds_mq_init(p_cds_mq_type pMq);
 void cds_mq_deinit(p_cds_mq_type pMq);
 void cds_mq_put(p_cds_mq_type pMq, p_cds_msg_wrapper pMsgWrapper);
+void cds_mq_put_front(p_cds_mq_type mq, p_cds_msg_wrapper msg_wrapper);
 p_cds_msg_wrapper cds_mq_get(p_cds_mq_type pMq);
 bool cds_is_mq_empty(p_cds_mq_type pMq);
 p_cds_sched_context get_cds_sched_ctxt(void);

+ 17 - 11
core/cds/src/cds_api.c

@@ -1231,18 +1231,21 @@ QDF_STATUS cds_free_context(void *p_cds_context, QDF_MODULE_ID moduleID,
 } /* cds_free_context() */
 
 /**
- * cds_mq_post_message() - post a message to a message queue
- * @msgQueueId: identifies the message queue upon which the message
- *	will be posted.
- * @message: a pointer to a message buffer. Memory for this message
- *	buffer is allocated by the caller and free'd by the QDF after the
- *	message is posted to the message queue.  If the consumer of the
- *	message needs anything in this message, it needs to copy the contents
- *	before returning from the message queue handler.
+ * cds_mq_post_message_by_priority() - posts message using priority
+ * to message queue
+ * @msgQueueId: message queue id
+ * @pMsg: message to be posted
+ * @is_high_priority: wheather message is high priority
  *
- * Return: QDF status
+ * This function is used to post high priority message to message queue
+ *
+ * Return: QDF_STATUS_SUCCESS on success
+ *         QDF_STATUS_E_FAILURE on failure
+ *         QDF_STATUS_E_RESOURCES on resource allocation failure
  */
-QDF_STATUS cds_mq_post_message(CDS_MQ_ID msgQueueId, cds_msg_t *pMsg)
+QDF_STATUS cds_mq_post_message_by_priority(CDS_MQ_ID msgQueueId,
+					   cds_msg_t *pMsg,
+					   int is_high_priority)
 {
 	p_cds_mq_type pTargetMq = NULL;
 	p_cds_msg_wrapper pMsgWrapper = NULL;
@@ -1326,7 +1329,10 @@ QDF_STATUS cds_mq_post_message(CDS_MQ_ID msgQueueId, cds_msg_t *pMsg)
 	qdf_mem_copy((void *)pMsgWrapper->pVosMsg,
 		     (void *)pMsg, sizeof(cds_msg_t));
 
-	cds_mq_put(pTargetMq, pMsgWrapper);
+	if (is_high_priority)
+		cds_mq_put_front(pTargetMq, pMsgWrapper);
+	else
+		cds_mq_put(pTargetMq, pMsgWrapper);
 
 	set_bit(MC_POST_EVENT_MASK, &gp_cds_context->qdf_sched.mcEventFlag);
 	wake_up_interruptible(&gp_cds_context->qdf_sched.mcWaitQueue);

+ 24 - 0
core/cds/src/cds_mq.c

@@ -117,6 +117,30 @@ inline void cds_mq_put(p_cds_mq_type pMq, p_cds_msg_wrapper pMsgWrapper)
 
 } /* cds_mq_put() */
 
+/**
+ * cds_mq_put_front() - adds a message to the head of message queue
+ * @mq: message queue
+ * @msg_wrapper: message wrapper
+ *
+ * This function is used to add a message to the head of message queue
+ *
+ * Return: None
+ */
+void cds_mq_put_front(p_cds_mq_type mq, p_cds_msg_wrapper msg_wrapper)
+{
+	unsigned long flags;
+
+	if ((mq == NULL) || (msg_wrapper == NULL)) {
+		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
+			"%s: NULL pointer passed", __func__);
+		return;
+	}
+
+	spin_lock_irqsave(&mq->mqLock, flags);
+	list_add(&msg_wrapper->msgNode, &mq->mqList);
+	spin_unlock_irqrestore(&mq->mqLock, flags);
+}
+
 /**
  * cds_mq_get() - get a message with its wrapper from a message queue
  * @pMq: Pointer to the message queue

+ 2 - 0
core/mac/src/pe/include/lim_api.h

@@ -129,6 +129,8 @@ tSirRetStatus peProcessMsg(tpAniSirGlobal pMac, tSirMsgQ *limMsg);
 extern void lim_cleanup(tpAniSirGlobal);
 /* / Function to post messages to LIM thread */
 extern uint32_t lim_post_msg_api(tpAniSirGlobal, tSirMsgQ *);
+uint32_t lim_post_msg_high_priority(tpAniSirGlobal mac, tSirMsgQ *msg);
+
 /**
  * Function to process messages posted to LIM thread
  * and dispatch to various sub modules within LIM module.

+ 15 - 0
core/mac/src/pe/lim/lim_api.c

@@ -873,6 +873,21 @@ uint32_t lim_post_msg_api(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
 
 } /*** end lim_post_msg_api() ***/
 
+/**
+ * lim_post_msg_high_priority() - posts high priority pe message
+ * @mac: mac context
+ * @msg: message to be posted
+ *
+ * This function is used to post high priority pe message
+ *
+ * Return: returns value returned by vos_mq_post_message_by_priority
+ */
+uint32_t lim_post_msg_high_priority(tpAniSirGlobal mac, tSirMsgQ *msg)
+{
+	return cds_mq_post_message_by_priority(CDS_MQ_ID_PE, (cds_msg_t *)msg,
+					       HIGH_PRIORITY);
+}
+
 /*--------------------------------------------------------------------------
 
    \brief pe_post_msg_api() - A wrapper function to post message to Voss msg queues

+ 2 - 1
core/mac/src/pe/lim/lim_timer_utils.c

@@ -39,6 +39,7 @@
 #include "lim_utils.h"
 #include "lim_assoc_utils.h"
 #include "lim_security_utils.h"
+#include <lim_api.h>
 
 /* channel Switch Timer in ticks */
 #define LIM_CHANNEL_SWITCH_TIMER_TICKS           1
@@ -474,7 +475,7 @@ void lim_timer_handler(void *pMacGlobal, uint32_t param)
 	msg.bodyptr = NULL;
 	msg.bodyval = 0;
 
-	statusCode = lim_post_msg_api(pMac, &msg);
+	statusCode = lim_post_msg_high_priority(pMac, &msg);
 	if (statusCode != eSIR_SUCCESS)
 		lim_log(pMac, LOGE,
 			FL("posting message %X to LIM failed, reason=%d"),