DSL_Error_t DSL_DRV_BND_PortModeSyncSet(
    DSL_IN DSL_Context_t *pContext,
    DSL_OUT DSL_BND_PortModeSync_t *pData)
{
    DSL_Error_t nErrCode = DSL_SUCCESS;

    DSL_CHECK_POINTER(pContext, pData);
    DSL_CHECK_ERR_CODE();

    DSL_DEBUG(DSL_DBG_MSG,
              (pContext, SYS_DBG_MSG"DSL[%02d]: IN - DSL_DRV_BND_PortModeSyncSet"DSL_DRV_CRLF,
               DSL_DEV_NUM(pContext)));

    if (pData->data.nPortMode < DSL_PORT_MODE_NA ||
            pData->data.nPortMode >= DSL_PORT_MODE_LAST)
    {
        nErrCode = DSL_ERR_PARAM_RANGE;
    }
    else
    {
        DSL_CTX_WRITE(pContext, nErrCode, BndPortModeSync, pData->data.nPortMode);
    }

    DSL_DEBUG(DSL_DBG_MSG,
              (pContext, SYS_DBG_MSG"DSL[%02d]: OUT - DSL_DRV_BND_PortModeSyncSet, retCode=%d"
               DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));

    return nErrCode;

}
static DSL_Error_t DSL_CEOC_FifoMessageWrite(
   DSL_Context_t *pContext,
   DSL_uint16_t protIdent,
   DSL_CEOC_Message_t *pMsg)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;

   DSL_CHECK_POINTER(pContext, pMsg);
   DSL_CHECK_ERR_CODE();

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: IN - DSL_CEOC_FifoMessageWrite"
      DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

   switch( protIdent )
   {
   case DSL_CEOC_SNMP_PROTOCOL_ID:
      nErrCode = DSL_CEOC_FifoSnmpMessageWrite( pContext, pMsg );
      break;

   default:
      nErrCode = DSL_WRN_EOC_UNSUPPORTED_PROTOCOLL_ID;
      DSL_DEBUG(DSL_DBG_WRN, (pContext,
         SYS_DBG_WRN"DSL[%02d]: WARNING - Unsupported protocol identifier(0x%04X)!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext), protIdent));
      break;
   }

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: OUT - DSL_CEOC_FifoMessageWrite, rerCode=%d"
      DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));

   return nErrCode;
}
/*
   For a detailed description of the function, its arguments and return value
   please refer to the description in the header file 'drv_dsl_cpe_intern_ceoc.h'
*/
DSL_Error_t DSL_CEOC_Restart(DSL_Context_t *pContext)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;

   DSL_CHECK_POINTER(pContext, DSL_CEOC_CONTEXT(pContext));
   DSL_CHECK_ERR_CODE();

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: Restarting CEOC module..."DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   /* Check CEOC module bRun flag*/
   if( DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun == DSL_FALSE )
   {
      DSL_DRV_INIT_EVENT("ceocev_ne", DSL_CEOC_CONTEXT(pContext)->ceocThread.waitEvent);

      /* Start CEOC module thread*/
      nErrCode = (DSL_Error_t)DSL_DRV_THREAD(&DSL_CEOC_CONTEXT(pContext)->ceocThread.Control,
                                 "ceocex_ne", DSL_CEOC_Thread, (DSL_uint32_t)pContext);

      if( nErrCode != DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_MSG,
            (pContext, SYS_DBG_MSG"DSL[%02d]: ERROR - CEOC module thread start failed, retCode(%d)!"
            DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));
      }
   }
   else
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC thread should be stoped before restarting!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return nErrCode;
   }

   /* Call device specific CEOC restart stuff*/
   nErrCode = DSL_CEOC_DEV_Restart(pContext);
   if( nErrCode != DSL_SUCCESS )
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC device specific restart failed!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return nErrCode;
   }

   return nErrCode;
}
/*
   For a detailed description please refer to the equivalent ioctl
   \ref DSL_FIO_BND_HS_STATUS_GET
*/
DSL_Error_t DSL_DRV_BND_HsStatusGet(
    DSL_IN DSL_Context_t *pContext,
    DSL_OUT DSL_BND_HsStatusGet_t *pData)
{
    DSL_Error_t nErrCode = DSL_SUCCESS;

    DSL_CHECK_POINTER(pContext, pData);
    DSL_CHECK_ERR_CODE();

    DSL_DEBUG(DSL_DBG_MSG,
              (pContext, SYS_DBG_MSG"DSL[%02d]: IN - DSL_DRV_BND_HsStatusGet"DSL_DRV_CRLF,
               DSL_DEV_NUM(pContext)));

#if (DSL_DRV_LINES_PER_DEVICE == 2)
    if (DSL_DRV_DEV_FirmwareFeatureCheck(pContext,
                                         DSL_FW_XDSLFEATURE_DUALPORT) == DSL_FALSE)
    {
        /* on-chip bonding: ignore if feature is not supported */
        DSL_DEBUG(DSL_DBG_WRN, (pContext, SYS_DBG_WRN"DSL[%02d]: "
                                "WARNING - DSL_DRV_BND_HsStatusGet(): Firmware does not support bonding"
                                DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));
    }
    else
#endif /* (DSL_DRV_LINES_PER_DEVICE == 2) */
    {
        if (DSL_DRV_VRX_FirmwareXdslModeCheck(pContext, DSL_VRX_FW_VDSL2))
        {
            /* Call VRX device specific implementation*/
            nErrCode = DSL_DRV_BND_DEV_HsStatusGet(pContext, pData);
        }
        else
        {
            /* Adsl off-chip bonding case are not supported */
            DSL_DEBUG(DSL_DBG_WRN, (pContext, SYS_DBG_WRN"DSL[%02d]: "
                                    "WARNING - DSL_DRV_BND_HsStatusGet(): Firmware does not support bonding"
                                    DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));
        }
    }

    DSL_DEBUG(DSL_DBG_MSG,
              (pContext, SYS_DBG_MSG"DSL[%02d]: OUT - DSL_DRV_BND_HsStatusGet, retCode=%d"
               DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));

    return nErrCode;
}
static DSL_Error_t DSL_CEOC_CallbackHandle(
   DSL_Context_t *pContext,
   DSL_uint16_t protIdent,
   DSL_CEOC_Message_t *pMsg)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_uint8_t i = 0;

   DSL_CHECK_POINTER(pContext, pMsg);
   DSL_CHECK_ERR_CODE();

   if( DSL_CEOC_CONTEXT(pContext) == DSL_NULL )
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC module not started!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_ERROR;
   }

   /* Lock CEOC internal API mutex*/
   if( DSL_DRV_MUTEX_LOCK( DSL_CEOC_CONTEXT(pContext)->ceocInternMutex ) )
   {
      return DSL_ERROR;
   }

   for( i = 0; i < DSL_DRV_MAX_DEVICE_NUMBER; i++ )
   {
      if( !(DSL_CEOC_CONTEXT(pContext)->pCeocEventCallback[i]) )
         continue;

      if( DSL_CEOC_CONTEXT(pContext)->pCeocEventCallback[i](protIdent, pMsg) != DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_ERR,
            (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC CallBack(%d) handle failed!"
            DSL_DRV_CRLF, DSL_DEV_NUM(pContext), i));
      }
   }

   /* Unlock CEOC internal API mutex*/
   DSL_DRV_MUTEX_UNLOCK( DSL_CEOC_CONTEXT(pContext)->ceocInternMutex );

   return nErrCode;
}
/*
   For a detailed description please refer to the equivalent ioctl
   \ref DSL_FIO_BND_ETH_COUNTERS_GET
*/
DSL_Error_t DSL_DRV_BND_EthCountersGet(
    DSL_IN DSL_Context_t *pContext,
    DSL_OUT DSL_BND_EthCounters_t *pData)
{
    DSL_Error_t nErrCode = DSL_SUCCESS;

    DSL_CHECK_POINTER(pContext, pData);
    DSL_CHECK_ERR_CODE();

    DSL_DEBUG(DSL_DBG_MSG,
              (pContext, SYS_DBG_MSG"DSL[%02d]: IN - DSL_DRV_BND_EthCountersGet"DSL_DRV_CRLF,
               DSL_DEV_NUM(pContext)));

    /* Call device specific implementation*/
    nErrCode = DSL_DRV_BND_DEV_EthCountersGet(pContext, pData);

    DSL_DEBUG(DSL_DBG_MSG,
              (pContext, SYS_DBG_MSG"DSL[%02d]: OUT - DSL_DRV_BND_EthCountersGet, retCode=%d"
               DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));

    return nErrCode;
}
DSL_Error_t DSL_DRV_BND_ConfigGet(
    DSL_IN DSL_Context_t *pContext,
    DSL_OUT DSL_BND_ConfigGet_t *pData)
{
    DSL_Error_t nErrCode = DSL_SUCCESS;

    DSL_CHECK_POINTER(pContext, pData);
    DSL_CHECK_ERR_CODE();

    DSL_DEBUG(DSL_DBG_MSG,
              (pContext, SYS_DBG_MSG"DSL[%02d]: IN - DSL_DRV_BND_ConfigGet"DSL_DRV_CRLF,
               DSL_DEV_NUM(pContext)));

    /* Get Bonding configuration from the CPE API Context*/
    DSL_CTX_READ(pContext, nErrCode, BndConfig, pData->data);

    DSL_DEBUG(DSL_DBG_MSG,
              (pContext, SYS_DBG_MSG"DSL[%02d]: OUT - DSL_DRV_BND_ConfigGet, retCode=%d"
               DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));

    return nErrCode;
}
Exemple #8
0
/**
   \brief API for atm driver to notify led thread a data comming/sending
   This function provide a API used by ATM driver, the atm driver call this
   function once a atm packet sent/received.

   \return  0 success else failed

   \ingroup Internal
 */
static DSL_int_t DSL_DRV_LED_Flash ( DSL_void_t )
{
   DSL_uint32_t flags = 0;
   DSL_Error_t nErrCode = DSL_SUCCESS;

   DSL_Context_t *pContext = pGlobalContext;

   DSL_DEBUG(DSL_DBG_MSG, (pContext, "DSL[%02d]: IN - DSL_DRV_LED_Flash"DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   DSL_CHECK_POINTER(pContext, pContext->pDevCtx);
   DSL_CHECK_ERR_CODE();

   spin_lock_irqsave(&dsl_led_lock, flags);
   if (!stop_led_module)
   {
      /* asking to flash led */
      pContext->bLedNeedToFlash = DSL_TRUE;
      pContext->bLedStatusOn    = DSL_FALSE;
   }
   spin_unlock_irqrestore(&dsl_led_lock, flags);
#ifndef RTEMS
   if (!stop_led_module)
#else
   if (stop_led_module)
#endif /* RTEMS*/
   {
      DSL_DRV_WAKEUP_EVENT(pContext->ledPollingEvent);
   }

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, "DSL[%02d]: OUT - DSL_DRV_LED_Flash"DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   return 0;
}
/*
   For a detailed description please refer to the equivalent ioctl
   \ref DSL_FIO_BND_CONFIG_SET
*/
DSL_Error_t DSL_DRV_BND_ConfigSet(
    DSL_IN DSL_Context_t *pContext,
    DSL_IN DSL_BND_ConfigSet_t *pData)
{
    DSL_Error_t nErrCode = DSL_SUCCESS, nRetCode = DSL_SUCCESS;
    DSL_uint8_t nLine;
    DSL_Context_t *pCurrCtx;
#if defined(INCLUDE_DSL_CPE_API_VRX)
    DSL_LineFeatureData_t lineFeatureDataCfg;
    DSL_int_t nAutoTcCount = 0, nVdslAtmCount = 0;
    DSL_TcLayerSelection_t nTcMode = DSL_TC_UNKNOWN;
#endif

    DSL_CHECK_POINTER(pContext, pData);
    DSL_CHECK_ERR_CODE();

    DSL_DEBUG(DSL_DBG_MSG,
              (pContext, SYS_DBG_MSG"DSL[%02d]: IN - DSL_DRV_BND_ConfigSet"DSL_DRV_CRLF,
               DSL_DEV_NUM(pContext)));

#if defined(INCLUDE_DSL_CPE_API_VRX)
    if (pData->data.bPafEnable == DSL_TRUE)
    {
#if (DSL_DRV_LINES_PER_DEVICE == 2)
        if (DSL_DRV_DEV_FirmwareFeatureCheck(pContext,
                                             DSL_FW_XDSLFEATURE_DUALPORT) == DSL_FALSE)
        {
            DSL_DEBUG(DSL_DBG_WRN, (pContext, SYS_DBG_WRN
                                    "DSL[%02d]: Bonding could not be enabled because of firmware "
                                    "doesn't support it"DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

            return DSL_WRN_BND_NOT_SUPPORTED_BY_FIRMWARE;
        }
        else
#endif /* (DSL_DRV_LINES_PER_DEVICE == 2) */
        {
            /* Check if one of the following configurations are done for one of
               the available devices/lines. If yes, return appropriate warning.
               - ReTx is enabled
               - Auto TC-Layer is configured for VDSL
               - ATM TC-Layer is configured for VDSL */
            for (nLine = 0;
                    nLine < DSL_DRV_LINES_PER_DEVICE * DSL_DRV_MAX_DEVICE_NUMBER;
                    nLine++)
            {
                pCurrCtx = pContext->pXDev[nLine].pContext;

                DSL_CTX_READ_SCALAR(pCurrCtx, nRetCode,
                                    pDevCtx->data.deviceCfg.sysCIF[DSL_MODE_VDSL].nTcLayer,
                                    nTcMode);
                DSL_SET_ERROR_CODE(nRetCode, nErrCode);

                if (nTcMode == DSL_TC_AUTO)
                {
                    nAutoTcCount++;
                }
                if (nTcMode == DSL_TC_ATM)
                {
                    nVdslAtmCount++;
                }
            }

            /* Set error/warning return codes in order of priority */
            if (nVdslAtmCount > 0)
            {
                /* Reject bonding enable in this case */
                pData->data.bPafEnable = DSL_FALSE;
                DSL_SET_ERROR_CODE(DSL_ERR_CONFIG_BND_VS_TCLAYER, nErrCode);
            }
            else if (nAutoTcCount > 0)
            {
                /* Accept bonding enable in this case (do not reset user enable) */
                DSL_SET_ERROR_CODE(DSL_WRN_CONFIG_BND_VS_TCLAYER, nErrCode);
            }
        }
    }
#endif

#if defined(INCLUDE_DSL_BONDING) && (DSL_DRV_LINES_PER_DEVICE == 2)
    for (nLine = 0; nLine < DSL_DRV_LINES_PER_DEVICE; nLine++)
    {
        pCurrCtx = pContext->pXDev[nLine].pContext;

        /* Set Bonding configuration within CPE API Context*/
        DSL_CTX_WRITE(pCurrCtx, nRetCode, BndConfig, pData->data);
        DSL_SET_ERROR_CODE(nRetCode, nErrCode);
    }
#else
    /* Set Bonding configuration within CPE API Context*/
    DSL_CTX_WRITE(pContext, nRetCode, BndConfig, pData->data);
    DSL_SET_ERROR_CODE(nRetCode, nErrCode);
#endif

    DSL_DEBUG(DSL_DBG_MSG,
              (pContext, SYS_DBG_MSG"DSL[%02d]: OUT - DSL_DRV_BND_ConfigSet, retCode=%d"
               DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));

    return nErrCode;
}
static DSL_Error_t DSL_CEOC_FifoSnmpMessageWrite(
   DSL_Context_t *pContext,
   DSL_CEOC_Message_t *pMsg)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_uint8_t *pElmnt = DSL_NULL;
   DSL_OpenContext_t *pCurr;

   DSL_CHECK_POINTER(pContext, pContext->pDevCtx);
   DSL_CHECK_ERR_CODE();
   DSL_CHECK_POINTER(pContext, DSL_CEOC_CONTEXT(pContext));
   DSL_CHECK_ERR_CODE();

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: IN - DSL_CEOC_FifoSnmpMessageWrite"
      DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

   /* Lock Open Context list*/
   if (DSL_DRV_MUTEX_LOCK(pContext->pDevCtx->openContextListMutex))
   {
      DSL_DEBUG( DSL_DBG_ERR,
         (DSL_NULL, SYS_DBG_ERR"DSL[%02d]: ERROR - Couldn't lock Context List mutex!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_ERR_SEMAPHORE_GET;
   }

   for (pCurr = pOpenContextList; pCurr != DSL_NULL; pCurr = pCurr->pNext)
   {
      if (DSL_DRV_MUTEX_LOCK(pCurr->rxSnmpFifoMutex))
      {
         DSL_DEBUG( DSL_DBG_ERR,
            (DSL_NULL, SYS_DBG_ERR"DSL[%02d]: ERROR - Couldn't lock Rx SNMP FIFO mutex!"
            DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

         nErrCode = DSL_ERR_SEMAPHORE_GET;

         break;
      }

      if ((pCurr->rxSnmpFifo != DSL_NULL) &&
          (pCurr->rxSnmpFifoBuf != DSL_NULL) &&
          ((pCurr->nResourceActivationMask & DSL_RESOURCE_ACTIVATION_SNMP) == DSL_RESOURCE_ACTIVATION_CLEANED))
      {
         /* Check if there is a free space in the SNMP FIFO*/
         if ( DSL_Fifo_isFull(pCurr->rxSnmpFifo) )
         {
            DSL_DEBUG( DSL_DBG_WRN,
              (pContext, SYS_DBG_WRN"DSL[%02d]: WARNING - CEOC Rx SNMP fifo is full!"
              DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));
         }
         else
         {
            if ((pElmnt = DSL_Fifo_writeElement(pCurr->rxSnmpFifo)) == DSL_NULL)
            {
               DSL_DEBUG( DSL_DBG_ERR,
                  (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - received NULL pointer to the CEOC SNMP fifo!"
                  DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

               nErrCode = DSL_ERROR;
            }
            else
            {
               /* copy an element */
               /*  DSL_G997_SnmpData_t and DSL_CEOC_Message_t structures are identical,
                    we can use any*/
               memcpy(pElmnt, pMsg, sizeof(DSL_G997_SnmpData_t));
            }
          }
      }

      DSL_DRV_MUTEX_UNLOCK(pCurr->rxSnmpFifoMutex);
   }

   /* Unlock Open Context list*/
   DSL_DRV_MUTEX_UNLOCK(pContext->pDevCtx->openContextListMutex);

   if (nErrCode == DSL_SUCCESS)
   {
      /* Generate DSL_EVENT_S_SNMP_MESSAGE_AVAILABLE event*/
      nErrCode = DSL_DRV_EventGenerate(
                    pContext, 0, DSL_ACCESSDIR_NA, DSL_XTUDIR_NA,
                    DSL_EVENT_S_SNMP_MESSAGE_AVAILABLE, DSL_NULL, 0);

      if( nErrCode != DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_ERR,
            (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - DSL_EVENT_S_SNMP_MESSAGE_AVAILABLE "
            "event generation failed!"DSL_DRV_CRLF,
            DSL_DEV_NUM(pContext)));
      }
   }

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: OUT - DSL_CEOC_FifoSnmpMessageWrite, rerCode=%d"
      DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));

   return nErrCode;
}
static DSL_Error_t DSL_CEOC_FifoSnmpMessageRead(
   DSL_OpenContext_t *pOpenCtx,
   DSL_Context_t *pContext,
   DSL_CEOC_Message_t *pMsg)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_uint8_t *pElmnt = DSL_NULL;

   DSL_CHECK_POINTER(pContext, pMsg);
   DSL_CHECK_ERR_CODE();

   DSL_DEBUG(DSL_DBG_MSG, (pContext,
      SYS_DBG_MSG"DSL[%02d]: IN - DSL_CEOC_FifoSnmpMessageRead" DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   if (DSL_DRV_MUTEX_LOCK(pOpenCtx->rxSnmpFifoMutex))
   {
      DSL_DEBUG( DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC mutex lock failed!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_ERR_SEMAPHORE_GET;
   }

   if ((pOpenCtx->rxSnmpFifo != DSL_NULL) &&
       (pOpenCtx->rxSnmpFifoBuf != DSL_NULL) &&
       ((pOpenCtx->nResourceActivationMask & DSL_RESOURCE_ACTIVATION_SNMP) == DSL_RESOURCE_ACTIVATION_CLEANED))
   {
      if (DSL_Fifo_isEmpty(pOpenCtx->rxSnmpFifo))
      {
         DSL_DEBUG( DSL_DBG_WRN,
            (pContext, SYS_DBG_WRN"DSL[%02d]: WARNING - CEOC Rx SNMP fifo is empty!"
            DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

         nErrCode = DSL_WRN_SNMP_NO_DATA;
      }
      else
      {
         pElmnt = DSL_Fifo_readElement(pOpenCtx->rxSnmpFifo);

         if( pElmnt == DSL_NULL )
         {
            DSL_DEBUG( DSL_DBG_ERR,
               (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - received NULL pointer to the CEOC SNMP fifo!"
               DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

            nErrCode = DSL_ERROR;
         }
         else
         {
            /* copy an element */
            memcpy(pMsg, pElmnt, sizeof(DSL_G997_SnmpData_t));
         }
      }
   }
   else
   {
      nErrCode = DSL_WRN_SNMP_NO_DATA;
   }

   DSL_DRV_MUTEX_UNLOCK(pOpenCtx->rxSnmpFifoMutex);

   DSL_DEBUG(DSL_DBG_MSG, (pContext,
      SYS_DBG_MSG"DSL[%02d]: OUT - DSL_CEOC_FifoSnmpMessageRead, retCode=%d"
      DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));

   return nErrCode;
}
/*
   For a detailed description of the function, its arguments and return value
   please refer to the description in the header file 'drv_dsl_cpe_intern_ceoc.h'
*/
DSL_Error_t DSL_CEOC_MessageSend(
   DSL_Context_t *pContext,
   DSL_uint16_t protIdent,
   DSL_CEOC_Message_t *pMsg)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_LineStateValue_t nCurrentState = DSL_LINESTATE_UNKNOWN;

   DSL_CHECK_POINTER(pContext, pMsg);
   DSL_CHECK_ERR_CODE();

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: IN - DSL_CEOC_MessageSend"DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   if( DSL_CEOC_CONTEXT(pContext) == DSL_NULL )
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC module not started!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_ERROR;
   }

   if( !DSL_CEOC_CONTEXT(pContext)->bInit )
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC module not initialized!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_ERROR;
   }

   /* Check message length*/
   if( pMsg->length > DSL_G997_SNMP_MESSAGE_LENGTH || pMsg->length == 0 )
   {
      DSL_DEBUG(DSL_DBG_ERR, (pContext,
         SYS_DBG_ERR"DSL[%02d]: ERROR - EOC message length should "
         "be in range [1...%d]!" DSL_DRV_CRLF, DSL_DEV_NUM(pContext),
         DSL_G997_SNMP_MESSAGE_LENGTH));

      return DSL_ERR_INVALID_PARAMETER;
   }

   /* Only proceed if the specified line is in SHOWTIME state*/
   DSL_CTX_READ_SCALAR(pContext, nErrCode, nLineState, nCurrentState);

   /* Lock CEOC common mutex*/
   if( DSL_DRV_MUTEX_LOCK( DSL_CEOC_CONTEXT(pContext)->ceocMutex ) )
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - EOC common mutex lock failed!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_ERROR;
   }

   if ((nCurrentState == DSL_LINESTATE_SHOWTIME_TC_SYNC) ||
       (nCurrentState == DSL_LINESTATE_SHOWTIME_NO_SYNC))
   {
      /* Call device specific stuff*/
      nErrCode = DSL_CEOC_DEV_MessageSend(pContext, protIdent, pMsg);
      if( nErrCode != DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_ERR,
           (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - EOC message send failed!"
           DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));
      }
   }
   else
   {
      nErrCode = DSL_ERR_ONLY_AVAILABLE_IN_SHOWTIME;
      DSL_DEBUG(DSL_DBG_ERR,
        (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - function only available in the SHOWTIME!"
        DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));
   }

   /* Unlock CEOC common mutex*/
   DSL_DRV_MUTEX_UNLOCK( DSL_CEOC_CONTEXT(pContext)->ceocMutex );


   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: OUT - DSL_CEOC_MessageSend, rerCode=%d"
      DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));

   return nErrCode;
}
Exemple #13
0
/*
   For a detailed description of the function, its arguments and return value
   please refer to the description in the header file 'drv_dsl_cpe_intern_led.h'
*/
DSL_Error_t DSL_DRV_LED_ModuleInit(
   DSL_Context_t *pContext)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_FwVersion_t *pVer = DSL_NULL;
     
   DSL_CHECK_POINTER(pContext, pContext->pDevCtx);
   DSL_CHECK_ERR_CODE();

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, "DSL[%02d]: IN - DSL_DRV_LED_ModuleInit"DSL_DRV_CRLF,
       DSL_DEV_NUM(pContext)));

   if (pContext->bLedInit)
   {
      DSL_DEBUG(DSL_DBG_WRN,
         (pContext, "DSL[%02d]: WARNING - LED module already started" DSL_DRV_CRLF,
         DSL_DEV_NUM(pContext)));
         
      return DSL_SUCCESS;
   }

   if(DSL_DRV_MUTEX_LOCK(pContext->dataMutex))
   {
      DSL_DEBUG( DSL_DBG_ERR,
         (pContext, "DSL[%02d]: ERROR - Couldn't lock data mutex!"DSL_DRV_CRLF,
         DSL_DEV_NUM(pContext)));

      return DSL_ERROR;
   }

   pVer = &(pContext->pDevCtx->data.version.fwVersion);

   if (pVer->bValid == DSL_TRUE)
   {
      if (pVer->nMajorVersion != DSL_AMAZON_SE_FW_MAJOR_NUMBER &&
          pVer->nMajorVersion != DSL_AR9_FW_MAJOR_NUMBER && 
          pVer->nMajorVersion != DSL_DANUBE_FW_MAJOR_NUMBER)
      {
         DSL_DEBUG(DSL_DBG_ERR,
            (pContext, "DSL[%02d]: ADSL Data LED handling included but not implemented for Danube!"
            DSL_DRV_CRLF,
            DSL_DEV_NUM(pContext)));

         nErrCode = DSL_ERR_NOT_IMPLEMENTED;
      }
   }
   else
   {
      DSL_DEBUG(DSL_DBG_ERR, (pContext,
         "DSL[%02d]: ERROR - No firmware version available" DSL_DRV_CRLF,
         DSL_DEV_NUM(pContext)));
            
      nErrCode = DSL_WRN_DEVICE_NO_DATA;
   }

   DSL_DRV_MUTEX_UNLOCK(pContext->dataMutex);   

   if (nErrCode != DSL_SUCCESS)
   {
      return nErrCode;
   }

   spin_lock_init(&dsl_led_lock);
   pGlobalContext = pContext;
   pContext->bLedNeedToFlash = DSL_FALSE;
   pContext->bLedStatusOn = DSL_FALSE;
#if !((DSL_DATA_LED_FLASH_FREQUENCY >= 1) && (DSL_DATA_LED_FLASH_FREQUENCY <= 32))
#error Please use --with-adsl-data-led-flash-frequency=[1-32] to define ADSL Data Flash Frequency
#endif
   DSL_DEBUG(DSL_DBG_MSG, (pContext, "DSL[%02d]: ADSL data led flashing at %d Hz" DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext), DSL_DATA_LED_FLASH_FREQUENCY));
   flash_freq = DSL_DATA_LED_FLASH_FREQUENCY;
   if (flash_freq == 16)
   {
      flash = (pVer->nMajorVersion == DSL_DANUBE_FW_MAJOR_NUMBER) ? 0x901 : 0xA01;
   }
   else
   {
      flash_freq = ((flash_freq * 2) << 2) & 0xFC;
      flash = (pVer->nMajorVersion == DSL_DANUBE_FW_MAJOR_NUMBER) ? 0x902 : 0xA02;
      flash |= flash_freq;
   }
   
   off = (pVer->nMajorVersion == DSL_DANUBE_FW_MAJOR_NUMBER) ? 0x900 : 0xA00;

   on  = off | 0x3;
   
   /* adsl led for led function */
   DSL_DRV_INIT_EVENT ("atm_led", pContext->ledPollingEvent);

#ifdef INCLUDE_DSL_DATA_LED_SIMULATOR
   pContext->nDataLedSimControlData.nLedBehavior  = DSL_DATA_LED_OFF;
   pContext->nDataLedSimControlData.nBlinkTimeout = 1000;
   DSL_DRV_INIT_EVENT ("led_sim", pContext->dataLedSimEvent);   
   if ( DSL_DRV_THREAD (
           &LedSim, "atm_led_sim",
           DSL_DRV_LED_Sim, (DSL_uint32_t)pContext))
   {
      DSL_DEBUG(DSL_DBG_ERR, (pContext, "DSL[%02d]: ADSL DATA LED Simulator task start failed!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_ERROR;
   }
#else
   DSL_BSP_ATMLedCBRegister (DSL_DRV_LED_Flash);
#endif /* INCLUDE_DSL_DATA_LED_SIMULATOR*/

   pContext->bLedInit = DSL_TRUE;

   return (DSL_Error_t)DSL_DRV_THREAD (&LedControl, "atm_led_completion", DSL_DRV_LED_Poll, (DSL_uint32_t)pContext);
}