📄 skgeasf.c
字号:
YlciEnablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_BDC); YlciEnablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_ICMPV6); return 0;}/******************************************************************************* SkAsfResume - Called when card resumes** Description:** Returns:* Always 0*/int SkAsfResume(SK_AC *pAC, /* Pointer to adapter context */SK_IOC IoC ) { /* IO context handle */ SK_U8 lRetCode; lRetCode = AsfHciSendCommand(pAC, IoC, YASF_HOSTCMD_DISCARD_ARP_QUERY, 0, 0, 0, ASF_HCI_WAIT, 1 ); if( lRetCode == HCI_EN_CMD_ERROR ) { printk("sk98lin: Could not discard LLC frame in FW\n"); } else { printk("sk98lin: LLC frame discarded in FW (%u)\n", lRetCode); } /* Disable ARP pattern, host system takes over the ARP handling */ YlciDisablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_MAC ); YlciDisablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_MUL); YlciDisablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_BDC); YlciDisablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_ICMPV6); return 0;}/******************************************************************************* SkAsfDeInit - DeInit function of ASF** Description:** Returns:* Always 0*/int SkAsfDeInit(SK_AC *pAC, /* Pointer to adapter context */SK_IOC IoC ) { /* IO context handle */#ifndef USE_ASF_DASH_FWSK_U32 TmpVal32;#endif#ifdef USE_ASF_DASH_FW /* Reset OS Present Flag in ASF Status and Command Register */ AsfResetOsPresentBit( pAC, IoC );#else /* Reset OS Present Flag in ASF Status and Command Register */ SK_IN32( IoC, REG_ASF_STATUS_CMD, &TmpVal32 ); TmpVal32 &= ~BIT_4; SK_OUT32( IoC, REG_ASF_STATUS_CMD, TmpVal32 );#endif if( pAC->AsfData.InitState == ASF_INIT_OK ) {#ifdef USE_ASF_DASH_FW switch(pAC->AsfData.OpMode) { case SK_GEASF_MODE_ASF: // Enable ARP pattern, ASF FW is now responsible for ARP handling YlciEnablePattern ( pAC, IoC, 0, ASF_PATTERN_ID_ARP ); break; case SK_GEASF_MODE_IPMI: // Enable ARP pattern, ASF FW is now responsible for ARP handling YlciEnablePattern ( pAC, IoC, 0, ASF_PATTERN_ID_ARP ); if (pAC->AsfData.DualMode == SK_GEASF_Y2_DUALPORT) { YlciEnablePattern ( pAC, IoC, 1, ASF_PATTERN_ID_ARP ); } break; case SK_GEASF_MODE_DASH: YlciEnablePattern( pAC, IoC, 0, ASF_DASH_PATTERN_NUM_MAC ); YlciEnablePattern( pAC, IoC, 0, ASF_DASH_PATTERN_NUM_MUL ); YlciEnablePattern( pAC, IoC, 0, ASF_DASH_PATTERN_NUM_BDC ); YlciEnablePattern( pAC, IoC, 0, ASF_DASH_PATTERN_NUM_ICMPV6); break; } // switch(pAC->AsfData.OpMode) // Inform the FW that the driver will be unloaded AsfHciSendCommand( pAC ,IoC , YASF_HOSTCMD_DRV_GOODBYE, 0, 0, 0, ASF_HCI_WAIT, 2 ); // will be done in FW now // if( pAC->AsfData.ChipMode == SK_GEASF_CHIP_EX ) // AsfEnableFlushFifo( pAC, IoC );#else if (pAC->AsfData.OpMode == SK_GEASF_MODE_ASF) { // Enable ARP pattern, ASF FW is now responsible for ARP handling YlciEnablePattern ( pAC, IoC, 0, 5 ); } if (pAC->AsfData.OpMode == SK_GEASF_MODE_IPMI) { // Enable ARP pattern, ASF FW is now responsible for ARP handling YlciEnablePattern ( pAC, IoC, 0, 5 ); if (pAC->AsfData.DualMode == SK_GEASF_Y2_DUALPORT) { YlciEnablePattern ( pAC, IoC, 1, 5 ); } } // Inform the FW that the driver will be unloaded AsfHciSendCommand( pAC, IoC, YASF_HOSTCMD_DRV_GOODBYE, 0, 0, 0, ASF_HCI_WAIT, 2 );#endif } return( 0 );}/******************************************************************************* SkAsfDeInitStandBy - StandBy -DeInit function of ASF** Description:** Returns:* Always 0*/int SkAsfDeInitStandBy(SK_AC *pAC, /* Pointer to adapter context */SK_IOC IoC ) { /* IO context handle */#ifdef USE_ASF_DASH_FW if( pAC->AsfData.InitState == ASF_INIT_OK ) { // will be done in FW now if( pAC->AsfData.ChipMode == SK_GEASF_CHIP_EX ) AsfEnableFlushFifo( pAC, IoC ); switch(pAC->AsfData.OpMode) { case SK_GEASF_MODE_ASF: case SK_GEASF_MODE_IPMI: // Enable ARP pattern, ASF FW is now responsible for ARP handling YlciEnablePattern ( pAC, IoC, pAC->AsfData.ActivePort, ASF_PATTERN_ID_ARP ); break; case SK_GEASF_MODE_DASH: YlciEnablePattern( pAC, IoC, 0, ASF_DASH_PATTERN_NUM_MAC ); YlciEnablePattern( pAC, IoC, 0, ASF_DASH_PATTERN_NUM_MUL ); YlciEnablePattern( pAC, IoC, 0, ASF_DASH_PATTERN_NUM_BDC ); YlciEnablePattern( pAC, IoC, 0, ASF_DASH_PATTERN_NUM_ICMPV6); break; } // switch(pAC->AsfData.OpMode) // Inform the FW that the driver will be unloaded AsfHciSendCommand( pAC ,IoC , YASF_HOSTCMD_DRV_STANDBY, 0, 0, 0, ASF_HCI_WAIT, 2 ); }#else if( pAC->AsfData.InitState == ASF_INIT_OK ) { // Enable ARP pattern, ASF FW is now responsible for ARP handling YlciEnablePattern ( pAC, IoC, pAC->AsfData.ActivePort, 5 ); // Inform the FW that the driver will be unloaded AsfHciSendCommand( pAC, IoC, YASF_HOSTCMD_DRV_STANDBY, 0, 0, 0, ASF_HCI_WAIT, 2 ); }#endif return( 0 );}/******************************************************************************* SkAsfInitStandBy - StandBy - Init function of ASF** Description:** Returns:* Always 0*/int SkAsfInitStandBy(SK_AC *pAC, /* Pointer to adapter context */SK_IOC IoC, /* IO context handle */int Level) { /* Initialization level */#ifndef USE_ASF_DASH_FW SK_U32 TmpVal32;#endif SK_EVPARA EventParam; /* Event struct for timer event */ #ifdef USE_ASF_DASH_FW if( pAC->AsfData.InitState == ASF_INIT_OK ) { switch(Level) { case SK_INIT_DATA: /* Set OS Present Flag in ASF Status and Command Register */ AsfSetOsPresentBit( pAC, IoC ); // Disable ARP pattern, host system takes over the ARP handling // YlciDisablePattern( pAC, IoC,pAC->AsfData.ActivePort, ASF_PATTERN_ID_ARP); // Inform the FW that the driver will be activated again AsfHciSendCommand( pAC ,IoC , YASF_HOSTCMD_DRV_HELLO, 0, 0, 0, ASF_HCI_WAIT, 2 ); break; case SK_INIT_IO: break; case SK_INIT_RUN: SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam)); SkTimerStart(pAC, IoC, &pAC->AsfData.AsfTimer, 5000000, SKGE_ASF, SK_ASF_EVT_TIMER_EXPIRED, EventParam); break; } // switch( Level ) } // if( pAC->AsfData.InitState == ASF_INIT_OK #else if( pAC->AsfData.InitState == ASF_INIT_OK ) { switch(Level) { case SK_INIT_DATA: /* Set OS Present Flag in ASF Status and Command Register */ SK_IN32( IoC, REG_ASF_STATUS_CMD, &TmpVal32 ); TmpVal32 |= BIT_4; // Disable ARP pattern, host system takes over the ARP handling YlciDisablePattern ( pAC, IoC, pAC->AsfData.ActivePort, 5 ); // Inform the FW that the driver will be activated again // Schlechte Idee, schaltet ASF beim laden des Treibers ab // AsfHciSendCommand( pAC, IoC, YASF_HOSTCMD_DRV_HELLO, 0, 0, 0, ASF_HCI_WAIT, 2 ); break; case SK_INIT_IO: break; case SK_INIT_RUN: SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam)); SkTimerStart(pAC, IoC, &pAC->AsfData.AsfTimer, 5000000, SKGE_ASF, SK_ASF_EVT_TIMER_EXPIRED, EventParam); break; } // switch( Level ) } // if( pAC->AsfData.InitState == ASF_INIT_OK )#endif return( 0 );}/******************************************************************************** SkAsfSeprom2Mib reads ASF MIB config data from SEPROM** Context:*** Returns: 0: successful* 1: error*/SK_I8 SkAsfSeprom2Mib(SK_AC *pAC, /* Pointer to adapter context */SK_IOC IoC ) { /* IO context handle */ SK_U8 ind; SK_U8 i; SK_U8 version; SK_I8 RetCode; SK_U32 our_reg2; SK_U32 Len; ind = 0; VPD_IN32(pAC, IoC, PCI_OUR_REG_2, &our_reg2); pAC->vpd.rom_size = 256 << ((our_reg2 & PCI_VPD_ROM_SZ) >> 14); Len = VpdReadBlock( pAC, IoC, &pAC->AsfData.VpdConfigBuf[0], ASF_VPD_CONFIG_BASE, ASF_VPD_CONFIG_SIZE ); if( Len == ASF_VPD_CONFIG_SIZE ) { RetCode = SK_ASF_PNMI_ERR_OK; /* check, whether the signature is valid */ if( pAC->AsfData.VpdConfigBuf[0] == 'A' && pAC->AsfData.VpdConfigBuf[1] == 'S' && pAC->AsfData.VpdConfigBuf[2] == 'F' && pAC->AsfData.VpdConfigBuf[3] == '!' ) { ind = 4; version = pAC->AsfData.VpdConfigBuf[ind++]; switch( version ) { case 1: pAC->AsfData.Mib.Ena = pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.RspEnable = pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.Retrans = (SK_U16) pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.Retrans |= (SK_U16) (pAC->AsfData.VpdConfigBuf[ind++] << 8); pAC->AsfData.Mib.RetransInt = (SK_U32) pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.RetransInt |= (SK_U32) (pAC->AsfData.VpdConfigBuf[ind++] << 8); pAC->AsfData.Mib.RetransInt |= (SK_U32) (pAC->AsfData.VpdConfigBuf[ind++] << 16); pAC->AsfData.Mib.RetransInt |= (SK_U32) (pAC->AsfData.VpdConfigBuf[ind++] << 24); pAC->AsfData.Mib.HbEna = pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.HbInt = (SK_U32) pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.HbInt |= (SK_U32) (pAC->AsfData.VpdConfigBuf[ind++] << 8); pAC->AsfData.Mib.HbInt |= (SK_U32) (pAC->AsfData.VpdConfigBuf[ind++] << 16); pAC->AsfData.Mib.HbInt |= (SK_U32) (pAC->AsfData.VpdConfigBuf[ind++] << 24); pAC->AsfData.Mib.WdEna = pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.WdTime = (SK_U32) pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.WdTime |= (SK_U32) (pAC->AsfData.VpdConfigBuf[ind++] << 8); pAC->AsfData.Mib.WdTime |= (SK_U32) (pAC->AsfData.VpdConfigBuf[ind++] << 16); pAC->AsfData.Mib.WdTime |= (SK_U32) (pAC->AsfData.VpdConfigBuf[ind++] << 24); for( i=0; i<4; i++ ) pAC->AsfData.Mib.IpDest[i] = pAC->AsfData.VpdConfigBuf[ind++]; for( i=0; i<4; i++ ) pAC->AsfData.Mib.IpSource[i] = pAC->AsfData.VpdConfigBuf[ind++]; for( i=0; i<6; i++ ) pAC->AsfData.Mib.MacDest[i] = pAC->AsfData.VpdConfigBuf[ind++]; for( i=0; i<64; i++ ) pAC->AsfData.Mib.CommunityName[i] = pAC->AsfData.VpdConfigBuf[ind++]; for( i=0; i<6; i++ ) pAC->AsfData.Mib.Reserved[i] = pAC->AsfData.VpdConfigBuf[ind++]; SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,(" O.K.\n")); break; case 2: pAC->AsfData.Mib.Ena = pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.RspEnable = pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.Retrans = (SK_U16) pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.RetransInt = (SK_U32) pAC->AsfData.VpdConfigBuf[ind++] * 10; pAC->AsfData.Mib.HbEna = pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.HbInt = (SK_U32) pAC->AsfData.VpdConfigBuf[ind++] * 10; pAC->AsfData.Mib.WdEna = pAC->AsfData.VpdConfigBuf[ind++]; pAC->AsfData.Mib.WdTime = (SK_U32) pAC->AsfData.VpdConfigBuf[ind++] * 10; for( i=0; i<4; i++ ) pAC->AsfData.Mib.IpDest[i] = pAC->AsfData.VpdConfigBuf[ind++]; for( i=0; i<4; i++ ) pAC->AsfData.Mib.IpSource[i] = pAC->AsfData.VpdConfigBuf[ind++]; for( i=0; i<6; i++ ) pAC->AsfData.Mib.MacDest[i] = pAC->AsfData.VpdConfigBuf[ind++]; for( i=0; i<10; i++ ) pAC->AsfData.Mib.CommunityName[i] = pAC->AsfData.VpdConfigBuf[ind++]; for( i=0; i<6; i++ ) pAC->AsfData.Mib.Reserved[i] = pAC->AsfData.VpdConfigBuf[ind++]; SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,(" O.K.\n")); break; default: // invalidate ASF signature, this causes a new formating of the SEEPROM pAC->AsfData.VpdConfigBuf[0] = 'x'; pAC->AsfData.VpdConfigBuf[1] = 'x'; pAC->AsfData.VpdConfigBuf[2] = 'x'; pAC->AsfData.VpdConfigBuf[3] = 'x'; SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,(" unknown version: 0x%x\n", version )); break; } // switch( version ) { } else { SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,(" *** Error: Signature not valid\n")); } } // if( Len == .. ) else { RetCode = SK_ASF_PNMI_ERR_GENERAL; SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,(" *** failed\n")); } return( RetCode );}/******************************************************************************** SkAsfMib2Seprom writes ASF MIB config data to SEPROM** Context:*** Returns: 0: successful* 1: error
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -