コード例 #1
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;
}
コード例 #2
0
static DSL_int_t DSL_CEOC_Thread(DSL_DRV_ThreadParams_t *param)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_int_t nOsRet = 0;
   DSL_Context_t *pContext = (DSL_Context_t*)param->nArg1;
   DSL_LineStateValue_t nCurrentState = DSL_LINESTATE_UNKNOWN;
   DSL_CEOC_Message_t ceocMsg;
   DSL_uint16_t protIdent = 0x0;

   /* Check DSL CPE context pointer*/
   if( pContext == DSL_NULL || DSL_CEOC_CONTEXT(pContext) == DSL_NULL )
      return -1;

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

      return -1;
   }

   DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun = DSL_TRUE;

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC thread started"DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   /* main CEOC module Task*/
   while( DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun )
   {
      DSL_DRV_WAIT_EVENT_TIMEOUT( DSL_CEOC_CONTEXT(pContext)->ceocThread.waitEvent,
                              DSL_CEOC_CONTEXT(pContext)->ceocThread.nThreadPollTime);

      if (DSL_DRV_SIGNAL_PENDING)
         break;

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

      /* Only proceed if the specified line is in SHOWTIME state*/
      if ((nCurrentState != DSL_LINESTATE_SHOWTIME_TC_SYNC) &&
          (nCurrentState != DSL_LINESTATE_SHOWTIME_NO_SYNC))
      {
         continue;
      }

      /* Clear message length*/
      ceocMsg.length = 0x0;
      if( DSL_CEOC_DEV_MessageReceive(pContext, &protIdent, &ceocMsg) < DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_ERR,
            (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC message receive failed!"
            DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

         nErrCode = DSL_ERROR;

         break;
      }

      if( !ceocMsg.length )
      {
         /* No data available, continue polling*/
         continue;
      }

       /* EOC message available. Write the received message to the internal FIFO*/
      if( DSL_CEOC_FifoMessageWrite(pContext, protIdent, &ceocMsg) < DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_ERR, (pContext,
            SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC message write failed!"DSL_DRV_CRLF,
            DSL_DEV_NUM(pContext)));

         nErrCode = DSL_ERROR;

         break;
      }

      /* Proceed message for the Internal CEOC API*/
      #ifdef INCLUDE_DSL_CEOC_INTERNAL_API
      if( DSL_CEOC_CallbackHandle(pContext,protIdent,&ceocMsg) < DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_ERR,
            (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CallBack Handle failed!!"
            DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

         nErrCode = DSL_ERROR;

         break;
      }
      #endif
   }

   /* Clear CEOC module bRun flag*/
   DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun = DSL_FALSE;

   nOsRet = DSL_DRV_ErrorToOS(nErrCode);

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC thread stoped"DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   return nOsRet;
}
コード例 #3
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_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;
}
コード例 #4
0
ファイル: drv_dsl_cpe_led.c プロジェクト: janfj/dd-wrt
/*
   Led Thread Main function
*/
static DSL_int_t DSL_DRV_LED_Poll(
   DSL_DRV_ThreadParams_t *param)
{
   DSL_uint32_t flags = 0;
   DSL_int_t nOsRet = 0;
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_Context_t *pContext = (DSL_Context_t *)param->nArg1;
   DSL_LineStateValue_t nCurrentState = DSL_LINESTATE_UNKNOWN;

   /* begin polling ... */
   stop_led_module = 0;

   while (!stop_led_module)
   {
      /* Wake up every 10s */
      while (!(stop_led_module || pContext->bLedNeedToFlash) &&
         !(DSL_DRV_WAIT_EVENT_TIMEOUT(pContext->ledPollingEvent, 10000)));
      /* -ERESTARTSYS or condition evaluates to true */

      /* Only proceed if the specified line is in SHOWTIME state*/
      DSL_CTX_READ_SCALAR(pContext, nErrCode, nLineState, nCurrentState);
      if( nErrCode != DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_ERR, (pContext, "DSL[%02d]: ERROR - [%s %d]: Failed to get "
            "current line state!"DSL_DRV_CRLF, DSL_DEV_NUM(pContext), __func__, __LINE__));

         spin_lock_irqsave(&dsl_led_lock, flags);
         stop_led_module = 1;
         pContext->bLedNeedToFlash = DSL_FALSE;
         spin_unlock_irqrestore(&dsl_led_lock, flags);
         break;
      }

      /* Only proceed if the specified line is in SHOWTIME state*/
      if ((nCurrentState != DSL_LINESTATE_SHOWTIME_TC_SYNC) &&
         (nCurrentState != DSL_LINESTATE_SHOWTIME_NO_SYNC))
      {
         spin_lock_irqsave(&dsl_led_lock, flags);
         pContext->bLedNeedToFlash = DSL_FALSE;
         spin_unlock_irqrestore(&dsl_led_lock, flags);
         continue;
      }
      
      if (pContext->bLedNeedToFlash && (pContext->bLedStatusOn == DSL_FALSE))
      {
         /* FLASH */
         /* use GPIO9 for TR68 data led off. */
         if (DSL_DRV_DANUBE_CmvWrite(pContext, DSL_CMV_GROUP_INFO,
         DSL_CMV_ADDRESS_INFO_GPIO_CONTROL, 5, 1, &flash) != DSL_SUCCESS)
         {
            DSL_DEBUG(DSL_DBG_ERR, (pContext, "[%s %d]: CMV Write fail!" DSL_DRV_CRLF, __func__, __LINE__));
         }
         /* Let it flash for 1 second */
         if (!stop_led_module)
         {
            nErrCode = (DSL_Error_t)DSL_DRV_WAIT_EVENT_TIMEOUT(pContext->ledPollingEvent, 1000);
            if (nErrCode >= DSL_SUCCESS)
            {
               spin_lock_irqsave(&dsl_led_lock, flags);
               pContext->bLedStatusOn    = DSL_TRUE;
               pContext->bLedNeedToFlash = DSL_FALSE;
               spin_unlock_irqrestore(&dsl_led_lock, flags);
            }
         }
      }
      if ((pContext->bLedNeedToFlash == DSL_FALSE) && pContext->bLedStatusOn)
      {
         /* ON */
         /* use GPIO9 for TR68 data led off. */
         if (DSL_DRV_DANUBE_CmvWrite(pContext, DSL_CMV_GROUP_INFO,
            DSL_CMV_ADDRESS_INFO_GPIO_CONTROL, 5, 1, &on) != DSL_SUCCESS)
         {
            DSL_DEBUG(DSL_DBG_ERR, (pContext, "[%s %d]: CMV Write fail!" DSL_DRV_CRLF, __func__, __LINE__));
         }
         spin_lock_irqsave(&dsl_led_lock, flags);
         pContext->bLedStatusOn    = DSL_FALSE;
         spin_unlock_irqrestore(&dsl_led_lock, flags);
      }
   }

   nOsRet = DSL_DRV_ErrorToOS(nErrCode);

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

   return nOsRet;
}