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

📄 zl5011xcpq.c

📁 Zalink50114----TDMoIP芯片驱动源码
💻 C
📖 第 1 页 / 共 2 页
字号:

 Outputs:
   None

 Returns:
   zlStatusE

 Remarks:
   None

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

zlStatusE zl5011xCpqSetGranuleUsage(zl5011xParamsS *zl5011xParams,
                                   Uint32T maxNumberOfGranules)
{
   zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_CPQ_FN_ID, "zl5011xCpqSetGranuleUsage: max granules %d",
         maxNumberOfGranules, 0, 0, 0, 0, 0);

   /* Check for valid parameter value */
   if((maxNumberOfGranules & ~ZL5011X_CPQ_MAX_NUM_GRANULES_CHECK) != 0)
   {
      status = ZL5011X_PARAMETER_INVALID;
   }

   if(status == ZL5011X_OK)
   {
      /* Set maximum queue size in granules */
      status = zl5011xWrite(zl5011xParams, ZL5011X_CPQ_MAX_QUEUE_SIZE,
            maxNumberOfGranules);

      /* Record paramter value in device structure */
      zl5011xParams -> cpuIf.maxNumberOfGranules = maxNumberOfGranules;
   }

   return status;

}

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

 Function:
   zl5011xCpqGetStatus

 Description:
   Reads CPQ status register

 Inputs:
   zl5011xParams  Pointer to the structure for this device instance

 Outputs:
   queueStatus   Return parameter, holds the queue status

 Returns:
   zlStatusE

 Remarks:
   None

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

zlStatusE zl5011xCpqGetStatus(zl5011xParamsS *zl5011xParams,
                             Uint32T *queueStatus)
{

   zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_CPQ_FN_ID, "zl5011xCpqGetStatus:", 0, 0, 0, 0, 0, 0);

   /* Get CPQ status */
   status = zl5011xRead(zl5011xParams, ZL5011X_CPQ_STATUS, queueStatus);

   *queueStatus &= ZL5011X_CPQ_STATUS_MASK_CHECK;

   if(status == ZL5011X_OK)
   {
      ZL5011X_TRACE(ZL5011X_CPQ_FN_ID, "zl5011xCpqGetStatus: Queue status %d",
            *queueStatus, 0, 0, 0, 0, 0);
   }

   return status;
}

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

 Function:
   zl5011xCpqGetQueueDepth

 Description:
   Gets the number of packets in a queue

 Inputs:
   zl5011xParams   Pointer to the structure for this device instance
   queue

 Outputs:
   packetCount    Return parameter which holds the number of packets in the
                  queue

 Returns:
   zlStatusE

 Remarks:
   None

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

zlStatusE zl5011xCpqGetQueueDepth(zl5011xParamsS *zl5011xParams,
                                 zl5011xQueueE queue, Uint32T *packetCount)
{
   zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_CPQ_FN_ID, "zl5011xCpqGetQueueDepth: Queue %d",
         queue, 0, 0, 0, 0, 0);

   /* Check queue number is within range */
   status = ZL5011X_CHECK_QUEUE_NUMBER(queue);

   if(status == ZL5011X_OK)
   {
      /* Get number of packets in queue */
      status = zl5011xRead(zl5011xParams,
            ZL5011X_CPQ_PACKET_COUNT + (queue * sizeof(Uint32T)), packetCount);

      *packetCount &= ZL5011X_CPQ_MAX_PACKET_COUNT_CHECK;
   }

   if(status == ZL5011X_OK)
   {
      ZL5011X_TRACE(ZL5011X_CPQ_FN_ID, "zl5011xCpqGetQueueDepth: Queue %d, Packet Count %d",
            queue, *packetCount, 0, 0, 0, 0);
   }

   return status;
}

/*******************************************************************************
 Function:
    zl5011xCpqEnableInterrupts

 Description:
   This function is used to enable the interrupt sources associated with the CPQ
   queues. There is a queue present (or ready) interrupt which occurs when the
   queue is started, and there is a queue overflow intr enable.

   There is another interrupt when the total number of granules for all the queues
   exceeds the "Max_Queue_Size" total number of granules but this is enabled
   in the ADM block and not in the CPQ block.

 Inputs:
    zl5011xParams        Pointer to the structure for this device instance
   interruptBits        bits = 1 to enable the interrupt

 Outputs:

 Returns:
    zlStatusE

 Remarks:
   Clear interrupt before enabling (except queue-present interrupts).

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

zlStatusE zl5011xCpqEnableInterrupts(zl5011xParamsS *zl5011xParams,
                                       Uint32T interruptBits)
{
   zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_CPQ_FN_ID, "zl5011xCpqEnableInterrupts: bits 0x%.08lx ",
         interruptBits, 0, 0, 0, 0, 0);

   if ((interruptBits & ~(ZL5011X_CPQ_ENABLE_ALL_INTRS )) > 0)
   {
      status = ZL5011X_PARAMETER_INVALID;
   }

   if (status == ZL5011X_OK)
   {
      /* read the intr status to clear it */
      status = zl5011xReadModWrite( zl5011xParams, ZL5011X_CPQ_STATUS, interruptBits, interruptBits);
   }

   if (status == ZL5011X_OK)
   {
      status = zl5011xReadModWrite( zl5011xParams, ZL5011X_CPQ_CONTROL, 0, interruptBits);
   }

   /* update structure */
   if (status == ZL5011X_OK)
   {
      zl5011xParams->interruptMasks.cpqMasks &= ~interruptBits;
   }

   return status;
}

/*******************************************************************************
 Function:
    zl5011xCpqDisableInterrupts

 Description:
   This function is used to disable the interrupt sources associated with the CPQ
   queues. For each queue there is a queue present (or ready) interrupt which
   occurs when the  queue is started, and there is a queue overflow intr enable.

   There is another interrupt when the total number of granules for all the queues
   exceeds the "Max_Queue_Size" total number of granules but this is enabled
   in the ADM block and not in the CPQ block.

 Inputs:
    zl5011xParams        Pointer to the structure for this device instance
   interruptBits        bits = 1 to disable the interrupt

 Outputs:

 Returns:
    zlStatusE

 Remarks:
   see also zl5011xCpqEnableInterrupts

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

zlStatusE zl5011xCpqDisableInterrupts(zl5011xParamsS *zl5011xParams,
                                       Uint32T interruptBits)
{
   zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_CPQ_FN_ID, "zl5011xCpqDisableInterrupts: bits 0x%.08lx ",
                            interruptBits, 0, 0, 0, 0, 0);

   if ((interruptBits & ~(ZL5011X_CPQ_ENABLE_ALL_INTRS )) != 0)
   {
      status = ZL5011X_PARAMETER_INVALID;
   }

   if (status == ZL5011X_OK)
   {
      status = zl5011xReadModWrite( zl5011xParams, ZL5011X_CPQ_CONTROL, interruptBits, interruptBits);
   }

   /* update structure */
   if (status == ZL5011X_OK)
   {
      zl5011xParams->interruptMasks.cpqMasks |= interruptBits;
   }

   return status;
}

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

 Function:
   zl5011xCpqReceiveQueueStatus

 Description:
   This function checks the CPQ status register to determine if the
   specified queue has packets ready for transfering

 Inputs:
   zl5011xParams      Device Handle
   queue             the queue to check for waiting packets

 Outputs:
   packetsWaiting    ZL5011X_FALSE if there are no packets, or
                     ZL5011X_TRUE if there are packets

 Returns:
   zlStatusE

 Remarks:

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

zlStatusE zl5011xCpqReceiveQueueStatus(zl5011xParamsS *zl5011xParams,
    zl5011xQueueE queue,zl5011xBooleanE *packetsWaiting)
{
  Uint32T cpqStatusRegister = 0;
  zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_CPQ_FN_ID,"zl5011xCpqReceiveQueueStatus : ", 0, 0, 0, 0, 0, 0);

   *packetsWaiting = ZL5011X_FALSE;

  if (status == ZL5011X_OK)
  {
    status = zl5011xCpqGetStatus(zl5011xParams,&cpqStatusRegister);

      if (status == ZL5011X_OK)
      {
         /* Test the appropriate bit in the CPQ status register */
         if ((cpqStatusRegister & (1 << (ZL5011X_QUEUE_NOT_EMPTY_SHIFT + queue))) != 0)
         {
            *packetsWaiting = ZL5011X_TRUE;
         }
      }
   }

   return(status);
}

/*****************   END   ****************************************************/

⌨️ 快捷键说明

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