DSL_DRV_STATIC DSL_int_t DSL_DRV_Write(DSL_DRV_DevHeader_t *pDrvHdr, IFX_uint8_t *pBuf, IFX_int_t nSize) { DSL_Error_t nErrCode = DSL_ERROR; DSL_uint32_t nOffset=0; DSL_OpenContext_t *pOpenContext = pDrvHdr->pOpenCtx; DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "Device will be written..."DSL_DRV_CRLF)); if (pOpenContext == DSL_NULL) { DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "pOpenContext is NULL"DSL_DRV_CRLF)); return -1; } if (pOpenContext->pDevCtx == DSL_NULL) { DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "Device context pointer is NULL"DSL_DRV_CRLF)); return -1; } pOpenContext->pDevCtx->bFirmwareReady = DSL_FALSE; nErrCode = DSL_DRV_DEV_FwDownload(pOpenContext->pDevCtx->pContext, pBuf, nSize, DSL_NULL, 0, 0, 0, DSL_TRUE); if (nErrCode != DSL_SUCCESS) return -1; pOpenContext->pDevCtx->bFirmwareReady = DSL_TRUE; DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "Firmware was downloaded successfully " "%d bytes has written..."DSL_DRV_CRLF, nOffset)); return (DSL_int_t)nOffset; }
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; }
DSL_DRV_STATIC int DSL_DRV_Close(DSL_DRV_DevHeader_t *pDrvHdr) { DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "Device will be closed..."DSL_DRV_CRLF)); if (pDrvHdr->deviceNum >= DSL_DRV_MAX_DEVICE_NUMBER) { return -1; } DSL_DRV_HandleDelete(pDrvHdr->pOpenCtx); DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "Close successfull..."DSL_DRV_CRLF)); return 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_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; }
//old name: int DSL_ModuleInit(void) int DSL_DRV_DeviceCreate(void) { DSL_int_t i; printf(DSL_DRV_CRLF DSL_DRV_CRLF "Infineon CPE API Driver version: %s" DSL_DRV_CRLF, &(dsl_cpe_api_version[4])); DSL_DRV_MemSet( &ifxDevices, 0, sizeof(DSL_devCtx_t) * DSL_DRV_MAX_DEVICE_NUMBER ); /* Apply initial debug levels. The lines below should be updated in case of new modules insert */ #ifndef DSL_DEBUG_DISABLE DSL_DRV_DebugInit(); #endif #if defined(INCLUDE_DSL_CPE_API_VINAX) && defined(INCLUDE_DSL_BONDING) if ( DSL_DRV_Phy2VirtMap( DSL_FPGA_BND_BASE_ADDR, DSL_FPGA_BND_REGS_SZ_BYTE, "BND_FPGA", (DSL_uint8_t**)&g_BndFpgaBase) < 0) { DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "Bonding FPGA memory mapping failed!"DSL_DRV_CRLF)); } #endif /* defined(INCLUDE_DSL_CPE_API_VINAX) && defined(INCLUDE_DSL_BONDING)*/ /* Get handles for lower level driver */ for (i = 0; i < DSL_DRV_MAX_DEVICE_NUMBER; i++) { ifxDevices[i].lowHandle = DSL_DRV_DEV_DriverHandleGet(0,i); if (ifxDevices[i].lowHandle == DSL_NULL) { printf("Get BSP Driver Handle Fail!"DSL_DRV_CRLF); } #ifdef INCLUDE_DSL_CPE_API_VINAX ifxDevices[i].nfc_lowHandle = DSL_DRV_DEV_DriverHandleGet(0,i); if (ifxDevices[i].lowHandle == DSL_NULL) { printf("Get BSP Driver NFC Handle Fail!"DSL_DRV_CRLF); } #endif /* #ifdef INCLUDE_DSL_CPE_API_VINAX*/ ifxDevices[i].nUsageCount = 0; ifxDevices[i].bFirstPowerOn = DSL_TRUE; DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "ifxDevices[%d].lowHandle=0x%0X"DSL_DRV_CRLF, i, ifxDevices[i].lowHandle)); } return 0; }
static DSL_int_t DSL_DRV_LED_Sim( DSL_DRV_ThreadParams_t *param) { DSL_int_t nOsRet = 0; DSL_Error_t nErrCode = DSL_SUCCESS; DSL_Context_t *pContext = (DSL_Context_t *)param->nArg1; DSL_uint16_t nPollTimeout = 0; /* begin polling ... */ stop_led_module = 0; nPollTimeout = pContext->nDataLedSimControlData.nBlinkTimeout; while (!stop_led_module) { DSL_DRV_WAIT_EVENT_TIMEOUT(pContext->dataLedSimEvent, nPollTimeout); if (pContext->nDataLedSimControlData.nLedBehavior == DAL_DATA_LED_BLINK) { /* Trigger Data LED to blink*/ DSL_DRV_LED_Flash(); } nPollTimeout = pContext->nDataLedSimControlData.nBlinkTimeout; } 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; }
DSL_DRV_STATIC DSL_uint_t DSL_DRV_Poll(DSL_DRV_DevHeader_t *pDrvHdr) { DSL_int_t nRet = 0; DSL_OpenContext_t *pOpenCtx = pDrvHdr->pOpenCtx; DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "IN - DSL_DRV_Poll" DSL_DRV_CRLF)); if (pOpenCtx == DSL_NULL) { /* This should never happen */ DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "!!! Ioctl call for file which " "was not opened" DSL_DRV_CRLF)); return -EFAULT; } #if 0 poll_wait(pFile, &pOpenCtx->eventWaitQueue, wait); if(DSL_DRV_MUTEX_LOCK(pOpenCtx->eventMutex)) { DSL_DEBUG( DSL_DBG_ERR, (DSL_NULL, "Couldn't lock event mutex"DSL_DRV_CRLF)); return DSL_ERROR; } if (pOpenCtx->eventFifo == DSL_NULL || pOpenCtx->eventFifoBuf == DSL_NULL || pOpenCtx->bEventActivation == DSL_FALSE) { DSL_DEBUG(DSL_DBG_WRN, (DSL_NULL, "!!! Ioctl call for file which was not configured" " for event handling!!!" DSL_DRV_CRLF)); } else { if ( DSL_Fifo_isEmpty( pOpenCtx->eventFifo ) == DSL_FALSE ) { nRet |= POLLIN | POLLRDNORM; /* an event available */ } } DSL_DRV_MUTEX_UNLOCK(pOpenCtx->eventMutex); DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "OUT - DSL_DRV_Poll" DSL_DRV_CRLF)); #endif return nRet; }
/* 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; }
int DSL_DRV_Open(void) { DSL_OpenContext_t *pOpenCtx; DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "Device will be opened..."DSL_DRV_CRLF)); if ( DSL_DRV_HandleInit(0, &pOpenCtx) != DSL_SUCCESS ) { DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "Cannot initialize device..."DSL_DRV_CRLF)); return -1; } // Store the context. Used by DSL_DRV_Ioctls gv_drv_dsl_pOpenCtx = pOpenCtx; DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "Open successfull..."DSL_DRV_CRLF)); return 0; }
DSL_DRV_STATIC int DSL_DRV_Open(DSL_DRV_DevHeader_t *pDrvHdr, IFX_uint8_t *pAnnex, IFX_int_t flags) { DSL_OpenContext_t *pOpenCtx=DSL_NULL; DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, SYS_DBG_MSG"Device will be opened..."DSL_DRV_CRLF)); if ( DSL_DRV_HandleInit(pDrvHdr->deviceNum, &pOpenCtx) != DSL_SUCCESS ) { DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, SYS_DBG_ERR"Cannot initialize device..."DSL_DRV_CRLF)); return ERROR; } pDrvHdr->pOpenCtx = pOpenCtx; DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, SYS_DBG_MSG"Open successfull..."DSL_DRV_CRLF)); return (int)pDrvHdr; }
/* Entry point of driver */ int DSL_DRV_DeviceCreate(void) { DSL_int_t i; DSL_char_t name[32]; printf(DSL_DRV_CRLF DSL_DRV_CRLF "Lantiq CPE API Driver version: %s" DSL_DRV_CRLF, &(dsl_cpe_api_version[4])); DSL_DRV_MemSet( &ifxDevices, 0, sizeof(DSL_devCtx_t) * DSL_DRV_MAX_ENTITIES ); /* Apply initial debug levels. The lines below should be updated in case of new modules insert */ #ifndef DSL_DEBUG_DISABLE DSL_DRV_DebugInit(); #endif DSL_DRV_DrvNum = iosDrvInstall(IFX_NULL, IFX_NULL, (FUNCPTR)DSL_DRV_Open, (FUNCPTR)DSL_DRV_Close, IFX_NULL, (FUNCPTR)DSL_DRV_Write, (FUNCPTR)DSL_DRV_Ioctls); /* Get handles for lower level driver */ for (i = 0; i < DSL_DRV_MAX_ENTITIES; i++) { ifxDevices[i].lowHandle = DSL_DRV_DEV_DriverHandleGet(0,i); if (ifxDevices[i].lowHandle == DSL_NULL) { printf("Get BSP Driver Handle Fail!"DSL_DRV_CRLF); } #ifdef INCLUDE_DSL_NFC_HANDLE ifxDevices[i].nfc_lowHandle = DSL_DRV_DEV_DriverHandleGet(0,i); if (ifxDevices[i].lowHandle == DSL_NULL) { printf("Get BSP Driver NFC Handle Fail!"DSL_DRV_CRLF); } #endif /* INCLUDE_DSL_NFC_HANDLE*/ ifxDevices[i].nUsageCount = 0; ifxDevices[i].bFirstPowerOn = DSL_TRUE; DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, SYS_DBG_MSG"ifxDevices[%d].lowHandle=0x%0X" DSL_DRV_CRLF, i, ifxDevices[i].lowHandle)); /* Set device number*/ DSL_DevHeader[i].deviceNum = i; sprintf(name, "/dev/%s/%d", DRV_DSL_CPE_API_DEV_NAME, i); DSL_DRV_DevNodeInit(&DSL_DevHeader[i], name, DSL_DRV_DrvNum); } return 0; }
/* 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_DRV_STATIC int DSL_DRV_DevNodeInit(DSL_DRV_DevHeader_t *pDrvHdr, char *name, DSL_uint32_t drvNum) { /* Add device to the device list */ if (iosDevAdd(&pDrvHdr->DevHdr, name, drvNum) == ERROR) { DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, SYS_DBG_ERR""DSL_DRV_CRLF DSL_DRV_CRLF"unable to register " "major for %s!!!", DRV_DSL_CPE_API_DEV_NAME)); return -1; } return 0; }
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; }
/* 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_FirmwareInit( DSL_Context_t *pContext) { DSL_Error_t nErrCode = DSL_SUCCESS; DSL_DEBUG(DSL_DBG_MSG, (pContext, "DSL[%02d]: IN - DSL_DRV_LED_FirmwareInit" DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); /* This function is currently not used. LED configuration is done within device specific function DSL_DRV_DEV_AutobootHandleStart() */ /* DSL_CHECK_CTX_POINTER(pContext); nErrCode = DSL_DRV_DEV_LED_FirmwareInit(pContext); */ DSL_DEBUG(DSL_DBG_MSG, (pContext, "DSL[%02d]: OUT - DSL_DRV_LED_FirmwareInit, retCode=%d" DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode)); return nErrCode; }
/** \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; }
DSL_Error_t DSL_DRV_BND_RemotePafAvailableCheck( DSL_IN DSL_Context_t *pContext, DSL_OUT DSL_uint16_t *pRemotePafAvailable) { DSL_Error_t nErrCode = DSL_SUCCESS; DSL_BND_HsStatusGet_t status; DSL_DRV_MemSet(&status, 0x0, sizeof(DSL_BND_HsStatusGet_t)); nErrCode = DSL_DRV_BND_HsStatusGet(pContext, &status); if (nErrCode != DSL_SUCCESS) { DSL_DEBUG(DSL_DBG_ERR, (pContext, SYS_DBG_ERR "DSL[%02d]: ERROR - PAF status get failed!" DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); return nErrCode; } /* Set RemotePafAvailable */ *pRemotePafAvailable = (DSL_uint16_t)status.data.nRemotePafSupported; return DSL_SUCCESS; }
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; }
/* IO controls for user space accessing \param ino Pointer to the stucture of inode. \param fil Pointer to the stucture of file. \param command The ioctl command. \param lon The address of data. \return Success or failure. \ingroup Internal */ DSL_int_t DSL_DRV_Ioctls(DSL_DRV_DevHeader_t *pDrvHdr, DSL_uint_t nCommand, DSL_uint32_t nArg) { DSL_int_t nErr=0; DSL_boolean_t bIsInKernel; DSL_uint32_t nRetCode = 0; DSL_Context_t *pContext; DSL_devCtx_t *pDevCtx; DSL_OpenContext_t *pOpenCtx = pDrvHdr->pOpenCtx; DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "Device will be controled..."DSL_DRV_CRLF)); DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "IN - DSL_DRV_Ioctls: The ioctl " "command(0x%X) is called" DSL_DRV_CRLF, nCommand)); if ((pOpenCtx = gv_drv_dsl_pOpenCtx) == DSL_NULL) // SchS: orig: if (pOpenCtx == DSL_NULL) { /* This should never happen */ DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "!!! Ioctl call for file which " "was not opened" DSL_DRV_CRLF)); return -1; } else { if ((pDevCtx = pOpenCtx->pDevCtx) == DSL_NULL) { /* This should never happen */ DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "DSL_DRV_Poll: !!! Ioctl call " "for file which was not opened correctly" DSL_DRV_CRLF)); return -1; } else { if ((pContext = pDevCtx->pContext) == DSL_NULL) { /* This should never happen */ DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "!!! Ioctl call to device " "which was not ready" DSL_DRV_CRLF)); return -1; } } } bIsInKernel = DSL_TRUE; switch(nCommand) { #if 0 //SchS case FIOSELECT: if ( DSL_Fifo_isEmpty( pOpenCtx->eventFifo ) == DSL_FALSE ) { selWakeup((SEL_WAKEUP_NODE*) nArg); } return 0; case FIOUNSELECT: selNodeDelete(&pOpenCtx->eventWaitQueue, (SEL_WAKEUP_NODE*) nArg); return 0; #endif } if ( (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API) || (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_G997) || (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_PM) || (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_SAR) || (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_DEP) ) { nRetCode = DSL_DRV_IoctlHandle(pOpenCtx, pContext, bIsInKernel, nCommand, nArg); if (nRetCode < DSL_SUCCESS) { nErr = DSL_DRV_ErrorToOS(nRetCode); } } #if defined(INCLUDE_DSL_ADSL_MIB) else if (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_MIB) { nRetCode = DSL_DRV_MIB_IoctlHandle(pContext, bIsInKernel, nCommand, nArg); nErr = nRetCode; } #endif else { DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "The ioctl command(0x%X) is not " "supported!" DSL_DRV_CRLF, nCommand)); nErr = -1; return nErr; } DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "OUT - DSL_DRV_Ioctls(), retCode=%d" DSL_DRV_CRLF, nErr)); return nErr; }
/* 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; }
/* 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_Start(DSL_Context_t *pContext) { DSL_Error_t nErrCode = DSL_SUCCESS; DSL_CEOC_Context_t *pCeocContext = DSL_NULL; DSL_CHECK_CTX_POINTER(pContext); DSL_CHECK_ERR_CODE(); DSL_DEBUG(DSL_DBG_MSG, (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC module starting..." DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); if(pContext->CEOC != DSL_NULL) { DSL_DEBUG(DSL_DBG_WRN, (pContext, SYS_DBG_WRN"DSL[%02d]: WARNING - CEOC already started" DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); return DSL_SUCCESS; } /* Create CEOC context */ pCeocContext = (DSL_CEOC_Context_t*)DSL_DRV_Malloc(sizeof(DSL_CEOC_Context_t)); if(!pCeocContext) { DSL_DEBUG(DSL_DBG_ERR, (pContext, SYS_DBG_ERR"DSL[%02d]: DSL_CEOC_Start: no memory for internal context" DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); return DSL_ERROR; } memset(pCeocContext, 0, sizeof(DSL_CEOC_Context_t)); /* Initialize pointer to the CEOC context in the DSL CPE context*/ pContext->CEOC = (DSL_void_t*)pCeocContext; /* init CEOC module common mutex */ DSL_DRV_MUTEX_INIT(DSL_CEOC_CONTEXT(pContext)->ceocMutex); #ifdef INCLUDE_DSL_CEOC_INTERNAL_API /* init CEOC module internal API mutex */ DSL_DRV_MUTEX_INIT(DSL_CEOC_CONTEXT(pContext)->ceocInternMutex); #endif /* #ifdef INCLUDE_DSL_CEOC_INTERNAL_API*/ /* Initialize CEOC module device specific parameters*/ if( DSL_CEOC_DEV_Start(pContext) != DSL_SUCCESS ) { DSL_DEBUG(DSL_DBG_ERR, (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC module device specific init failed!" DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); return DSL_ERROR; } DSL_CEOC_CONTEXT(pContext)->bInit = DSL_TRUE; /* Init CEOC module threads */ DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun = DSL_FALSE; DSL_CEOC_CONTEXT(pContext)->ceocThread.nThreadPollTime = DSL_CEOC_THREAD_POLLING_CYCLE; 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_ERR, (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC module thread start failed, retCode(%d)!" DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode)); } else { DSL_DEBUG(DSL_DBG_MSG, (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC module started..." DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); } return nErrCode; }
/* 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; }
/* 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_Stop(DSL_Context_t *pContext) { DSL_Error_t nErrCode = DSL_SUCCESS; DSL_CHECK_CTX_POINTER(pContext); DSL_CHECK_ERR_CODE(); if( !DSL_CEOC_CONTEXT(pContext) ) { return DSL_SUCCESS; } DSL_DEBUG(DSL_DBG_MSG, (pContext, SYS_DBG_MSG"DSL[%02d]: Stopping CEOC module..."DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); if( DSL_CEOC_CONTEXT(pContext)->bInit == DSL_FALSE ) { DSL_DEBUG(DSL_DBG_MSG, (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC module not initialized yet!" DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); return DSL_SUCCESS; } if( DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun == DSL_FALSE ) { DSL_DEBUG(DSL_DBG_WRN, (pContext, SYS_DBG_WRN"DSL[%02d]: WARNING - CEOC module thread already stopped" DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); } else { /* Signal CEOC thread to stop*/ DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun = DSL_FALSE; DSL_DRV_WAKEUP_EVENT(DSL_CEOC_CONTEXT(pContext)->ceocThread.waitEvent); DSL_DRV_WAIT_COMPLETION(&DSL_CEOC_CONTEXT(pContext)->ceocThread.Control); DSL_DEBUG(DSL_DBG_MSG, (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC thread has stopped... (%lu)" DSL_DRV_CRLF, DSL_DEV_NUM(pContext), DSL_DRV_TimeMSecGet())); } /* Call device specific CEOC de-initialization stuff*/ nErrCode = DSL_CEOC_DEV_Stop(pContext); if( nErrCode != DSL_SUCCESS ) { DSL_DEBUG(DSL_DBG_ERR, (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC module device deinitialization failed!" DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); } /* Free CEOC Module resources*/ if( DSL_CEOC_CONTEXT(pContext) != DSL_NULL ) { DSL_DRV_MemFree( DSL_CEOC_CONTEXT(pContext) ); } DSL_DEBUG(DSL_DBG_MSG, (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC module has stopped... (%lu)" DSL_DRV_CRLF, DSL_DEV_NUM(pContext), DSL_DRV_TimeMSecGet())); 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; }
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; }
/* 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; }
/* 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); }