⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zl5011xcetqueue.c

📁 Zalink50114----TDMoIP芯片驱动源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*******************************************************************************
*
*  File name:              zl5011xCetQueue.c
*
*  Version:                21
*
*  Author:                 MRC
*
*  Date created:           03/02/2003
*
*  Copyright 2002, 2003, 2004, 2005, Zarlink Semiconductor Limited.
*  All rights reserved.
*
*  Module Description:
*  This module contains functionality required for managing the WAN Tx queues,
*  and is provided as part of the CET function.
*
*  The CET queue task must be run at a higher priority than the application task
*
*  Revision History:
*
*  Rev:  Date:       Author:  Comments:
*  1     07/02/2003  MRC      Creation
*  2     07/03/2003  MRC      Review actions
*  3     11/06/2003  MRC      Modified criteria for resetting the queue
*  4     09/07/2003  MRC      Now handles queue overrun more effectively
*  5     21/07/2003  MRC      No longer uses queue length to decide on reset
*  6     29/07/2003  MRC      Split the CET internal params etc into a seperate
*                             header file.
*  7     04/09/2003  MRC      Added check that the parameter handle is valid
*                             before calling queue handler
*  8     29/07/2004  MRC      Fixed some compiler warnings
*  9     20/10/2004  MRC      Added queue depth adjust functionality following a
*                             reset of the TDM queue.
*  10    22/10/2004  MRC      Added variables to preserve task priority settings
*  11    03/11/2004  MRC      Added task priority variable
*  12    21/01/2005  MRC      Moved variable definition
*  13    28/01/2005  MRC      Renamed CetQueueTable to CetExtensionTable and
*                             added non CES clocking options
*  14    31/01/2005  MRC      Modified clocking function
*  15    03/03/2005  MRC      Added async notification mechanism
*  16    11/03/2005  APL      Added ZL5011X_ERR_FN_ID to trace on error
*  17    23/03/2005  MRC      Amended status check in clock mod function
*  18    01/04/2005  MRC      Added task priority variable for clock mod task
*  19    18/04/2005  MRC      Changed queue management context state checks
*  20    05/05/2005  APL      Fixed compiler warning
*  21    20/05/2005  MRC      Issues a reset if too many adjusts are taking place
*
*******************************************************************************/

/*****************   INCLUDE FILES                *****************************/

#include "zl5011xApi.h"
#include "zl5011xCet.h"
#include "zl5011xMisc.h"

/******************************************************************************/

/*****************   STATIC GLOBAL VARIABLES   ********************************/

zl5011xBooleanE zl5011xCetRunning = ZL5011X_FALSE;
zl5011xCetExtensionTableS *zl5011xCetExtensionTable = NULL;

/* instantiate some of the #defines from zl5011xCet.h into variables, to
   support customisation for object only releases */

Uint32T Zl5011xCetTaskPriority = ZL5011X_CET_TASK_PRIORITY;
Uint32T Zl5011xCetDiffTaskPriority = ZL5011X_CET_DIFF_TASK_PRIORITY;
Uint32T Zl5011xCetAdTaskPriority = ZL5011X_CET_AD_TASK_PRIORITY;
Uint32T Zl5011xCetAdEnhTaskPriority = ZL5011X_CET_AD_ENH_TASK_PRIORITY;
Uint32T Zl5011xCetDiffRxTaskPriority = ZL5011X_CET_DIFF_RX_TASK_PRIORITY;
Uint32T Zl5011xCetQueueTaskPriority = ZL5011X_CET_QUEUE_TASK_PRIORITY;
Uint32T Zl5011xCetModTaskPriority = ZL5011X_CET_MOD_TASK_PRIORITY;
Uint32T Zl5011xCetQueueSize = ZL5011X_CET_QUEUE_SIZE;
Uint32T Zl5011xCetStatusQueueSize = ZL5011X_CET_QUEUE_SIZE;

/*****************   STATIC FUNCTION DECLARATIONS   ***************************/

void zl5011xCetQueueHandler(Uint32T index);

Uint32T zl5011xCetQueueExtraDebug = (Uint32T)-1;

/*****************   EXPORTED FUNCTION DEFINTIONS   ***************************/

/*******************************************************************************

 Function:
   zl5011xCetReceiveStatusMsgStructInit

 Description:
   Initialise the structure used in function zl5011xCetReceiveStatusMsg

 Inputs:
   par            Pointer to the structure for configuration items.

 Outputs:
   None

 Returns:
   zlStatusE

 Remarks:
   None

*******************************************************************************/

zlStatusE zl5011xCetReceiveStatusMsgStructInit(zl5011xCetReceiveStatusMsgS *par)
{
   zlStatusE status = ZL5011X_OK;

   status = ZL5011X_CHECK_POINTERS((void *)1, par);

   if (status == ZL5011X_OK)
   {
      ZL5011X_TRACE( ZL5011X_CET_FN_ID,
            "zl5011xCetReceiveStatusMsgStructInit:",
            0, 0, 0, 0, 0, 0);

      par->timeout = 0;
   }

   return status;
}

/*******************************************************************************

 Function:
   zl5011xCetReceiveStatusMsg

 Description:
   This function will receive the packet at the top of the message queue

 Inputs:
   par            Pointer to the structure for configuration items.

 Structure inputs:
   timeout        The time (in processor ticks) to wait for a packet to be
                  received. Set to 0 to return immediately if there are no
                  status messages waiting, and -1 to wait indefinitely for a
                  status message to become available.

 Structure outputs:
   zl5011xParams   Pointer to the structure for this device instance.
   stream         stream that this flag change is for
   statusType     set to indicate the type of change that occurred
   remoteFlags    new state of the flags from the master
   cetStatus      new state of the clock recovery

 Outputs:
   None

 Returns:
   zlStatusE

 Remarks:
   None

*******************************************************************************/

zlStatusE zl5011xCetReceiveStatusMsg(zl5011xCetReceiveStatusMsgS *par)
{
   zlStatusE status = ZL5011X_OK;

   status = ZL5011X_CHECK_POINTERS((void *)1, par);

   if (status == ZL5011X_OK)
   {
      if (zl5011xCetRunning != ZL5011X_TRUE)
      {
         status = ZL5011X_NOT_RUNNING;
      }
   }

   if (status == ZL5011X_OK)
   {
      if (zl5011xCetExtensionTable->clockStatusMode == ZL5011X_CET_STATUS_DISABLE)
      {  /* Status event notification was not enabled during zl5011xCetInit */
         status = ZL5011X_NOT_RUNNING;

         ZL5011X_TRACE((ZL5011X_ERR_FN_ID | ZL5011X_CET_FN_ID),
               "zl5011xCetReceiveStatusMsg: status logging not enabled",
               0,0,0,0,0,0);
      }
   }

   if (status == ZL5011X_OK)
   {
      if (OS_MSG_Q_RECEIVE(zl5011xCetExtensionTable->clockStatusQueueId, (char *)&(par->msg),
            sizeof(zl5011xCetStatusMsgS), par->timeout) == OS_ERROR)
      {
         /* no message received so indicate this using the status type field in the msg structure */
         par->msg.statusType = ZL5011X_CET_STATUS_DISABLE;
      }
      else
      {
         ZL5011X_TRACE(ZL5011X_CET_FN_ID,
               "zl5011xCetReceiveStatusMsg: dev = %08lX, stream = %02d, type = %d, state = %d, flags = %02X",
               (Uint32T)par->msg.zl5011xParams,
               par->msg.stream,
               par->msg.statusType,
               par->msg.cetStatus,
               par->msg.remoteFlags,
               0);
      }
   }

   return status;
}

/*******************************************************************************

 Function:
    zl5011xCetQueueSetModeStructInit

 Description:
    Set up default parameters for the zl5011xCetQueueSetMode function

 Inputs:
   zl5011xParams   Pointer to the structure for this device instance
   par            Pointer to the structure for configuration items.
                  See main function

 Outputs:
   None

 Returns:
   zlStatusE

 Remarks:

*******************************************************************************/

zlStatusE zl5011xCetQueueSetModeStructInit(zl5011xParamsS *zl5011xParams,
      zl5011xCetQueueSetModeS *par)
{
   zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_CET_FN_ID,
         "zl5011xCetQueueSetModeStructInit:", 0, 0, 0, 0, 0, 0);

   status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);

   if (status == ZL5011X_OK)
   {
      par->context = (Uint32T)ZL5011X_INVALID_CONTEXT;
      par->mode = ZL5011X_CET_QUEUE_ENABLE;

      par->resetPktDepth = (Uint32T)ZL5011X_INVALID;
   }

   return(status);
}

/*******************************************************************************

 Function:
      zl5011xCetQueueSetMode

 Description:
   This function is used to control the queue management for a given context.
   For example, if a queue uses the sequence number, then the queue depth will
   be constrained by this, and any over/under runs will NOT adjust the queue
   depth.
   This function is used with a resequencing queue, to adjust the queue depth
   in this situation.

 Inputs:
   zl5011xParams   Pointer to the structure for this device instance
   par            Pointer to the structure for configuration items. See below:

 Structure inputs:
   context        which context to setup
   mode           control operation of the queue management for the context
   resetPktDepth  the target queue depth in packets to be actioned
                  whenever the TDM queue is reset. This mechanism is similar
                  to the jitter buffer level specified at context creation, and
                  will have an uncertainty on the actual queue depth equivalent
                  to the packet delay variation.
                  If this parameter is not specified or an invalid value then
                  the default operation is for the queue to be set to 1/2 depth
                  following a reset.

 Structure outputs:
   None

 Returns:
   zlStatusE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -