📄 skgeasf.c
字号:
/****************************************************************************** * * Name: skgeasf.c * Project: Gigabit Ethernet Adapters, Common Modules * Version: $Revision: 1.1.2.31 $ * Date: $Date: 2008/03/26 15:37:51 $ * Purpose: ASF Handler. * ******************************************************************************//****************************************************************************** * * (C)Copyright 1998-2002 SysKonnect GmbH. * (C)Copyright 2002-2007 Marvell. * * Driver for Marvell Yukon/2 chipset and SysKonnect Gigabit Ethernet * Server Adapters. * * Address all question to: gr-msgg-linux@marvell.com * * LICENSE: * (C)Copyright Marvell. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The information in this file is provided "AS IS" without warranty. * /LICENSE * *****************************************************************************//****************************************************************************** * * Description: * * This module is intended to handle all the asf functions * * Include File Hierarchy: * * "h/skdrv1st.h" * "h/skdrv2nd.h" * ******************************************************************************//* Event queue and dispatcher*/#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))static const char SysKonnectFileId[] ="$Header: /data/cvs/sweprojects/yukon2/lindrv/asf_linux/Attic/skgeasf.c,v 1.1.2.31 2008/03/26 15:37:51 tschilli Exp $" ;#endif#define __SKASF_C#define TMPTIME_DIVIDER 650#ifdef __cplusplusextern "C" {#endif /* cplusplus */// #include <ntddk.h>// #include <wdm.h>#include "h/sktypes.h"#include "h/skdrv1st.h"#include "h/skdrv2nd.h"#include "h/skgeasf.h"#include "h/skgespi.h"#include "h/skfops.h"#include "linux/delay.h"//#include "h/yuk.h"//#include "h/skvpd.h"//#include <stdlib.h>static char *AsfFileName = "/etc/" SK_DRV_NAME "/AcpiAsf.bin";#ifndef USE_ASF_DASH_FWstatic char *IpmiFileNameS1 = "/etc/" SK_DRV_NAME "/ipmiyk2-s1.bin";static char *IpmiFileNameS2 = "/etc/" SK_DRV_NAME "/ipmiyk2-s2.bin";#endif#ifdef USE_ASF_DASH_FWstatic char *DashFileNameS1 = "/etc/" SK_DRV_NAME "/dashyex-s1.bin";static char *DashFileNameS2 = "/etc/" SK_DRV_NAME "/dashyex-s2.bin";#endif// static char *SimuAsfTab = "/etc/" SK_DRV_NAME "/AcpiAsf.bin";// ARP pattern 40 byte (5 bytes in mask)// this pattern length corresponds with YLCI_MACRXFIFOTHRES// Pattern mask for ARP Frames#ifdef ASF_ONLY_ARP_REQUESTstatic SK_U8 ARP_FRAME_PATTERN[] ={ /* MAC Header - 14 bytes */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Dest MAC Addr */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Src MAC Addr */ 0x08, 0x06, /*Frame Type */ /* ARP Header - 28 bytes */ 0x00, 0x01, /* hard type */ 0x08, 0x00, /* prot type */ 0x06, /* hard size */ 0x04, /* prot size */ 0x00, 0x01, /* op = request */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* senders mac */ 0x00, 0x00, 0x00, 0x00, /* senders ip */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* target mac */ 0x00, 0x00};static SK_U8 ARP_PATTERN_MASK[] = { 0x00, 0xF0, 0x3F, 0x00, 0x00 };#elsestatic SK_U8 ARP_FRAME_PATTERN[] ={ /* MAC Header - 14 bytes */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Dest MAC Addr */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Src MAC Addr */ 0x08, 0x06, /*Frame Type */ /* ARP Header - 28 bytes */ 0x00, 0x01, /* hard type */ 0x08, 0x00, /* prot type */ 0x06, /* hard size */ 0x04, /* prot size */ 0x00, 0x00, /* op = request */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* senders mac */ 0x00, 0x00, 0x00, 0x00, /* senders ip */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* target mac */ 0x00, 0x00};static SK_U8 ARP_PATTERN_MASK[] = { 0x00, 0xF0, 0x0F, 0x00, 0x00 };#endif// RSP pattern - 40 bytes (this makes 5 bytes in RSP_PATTERN_MASK)// this pattern length corresponds with YLCI_MACRXFIFOTHRESstatic SK_U8 RSP_FRAME_PATTERN[] ={ /* MAC Header (14 bytes) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Dest MAC Addr*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Src MAC Addr */ 0x08, 0x00, /*Frame Type */ /* IP Header (20 bytes) */ 0x45, 0x00, 0x00, 0x00, /* Version & Header Length */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, /* Protocol */ 0x00, 0x00, 0x00, 0x00, /*Src IP address*/ 0x00, 0x00, 0x00, 0x00, /*My IP address*/ /* part of UDP Header (6 bytes) */ 0x00, 0x00, /* src port */ 0x02, 0x98, /* dest. port */ 0x00, 0x00}; /* length */// Pattern mask for RSP Framesstatic SK_U8 RSP_PATTERN_MASK[] = { 0x00, 0x70, 0x80, 0x00, 0x30 };// RMCP pattern (unsecure port)// this pattern length corresponds with YLCI_MACRXFIFOTHRESstatic SK_U8 RMCP_FRAME_PATTERN[] ={ /* MAC Header */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Dest MAC Addr*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Src MAC Addr */ 0x08, 0x00, /*Frame Type */ /* IP Header */ 0x45, 0x00, 0x00, 0x00, /* Version & Header Length */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, /* Protocol */ 0x00, 0x00, 0x00, 0x00, /*Src IP address*/ 0x00, 0x00, 0x00, 0x00, /*My IP address*/ /* UDP Header */ 0x00, 0x00, /* src port */ 0x02, 0x6f, /* unsecure dest. port */ 0x00, 0x00};// Pattern mask for RMCP Framesstatic SK_U8 RMCP_PATTERN_MASK[] = { 0x00, 0x70, 0x80, 0x00, 0x30 };#if 0// TCP patternstatic SK_U8 TCP_FRAME_PATTERN[] ={ /* MAC Header */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Dest MAC Addr*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Src MAC Addr */ 0x08, 0x00, /*Frame Type */ /* IP Header */ 0x45, 0x00, 0x00, 0x00, /* Version & Header Length */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, /* Protocol */ 0x00, 0x00, 0x00, 0x00, /*Src IP address*/ 0x00, 0x00, 0x00, 0x00, /*My IP address*/ /* UDP Header */ 0x00, 0x00, /* src port */ 0x02, 0x6f, /* unsecure dest. port */ 0x00, 0x00};// Pattern mask for TCP Framesstatic SK_U8 TCP_PATTERN_MASK[] = { 0x00, 0x70, 0x80, 0x00, 0x30 };#endif#if 0// ICMP patternstatic SK_U8 ICMP_FRAME_PATTERN[] ={ /* MAC Header */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Dest MAC Addr*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*Src MAC Addr */ 0x08, 0x00, /*Frame Type */ /* IP Header */ 0x45, 0x00, 0x00, 0x00, /* Version & Header Length */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* Protocol */ 0x00, 0x00, 0x00, 0x00, /*Src IP address*/ 0x00, 0x00, 0x00, 0x00, /*My IP address*/ /* ICMP Header */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};// Pattern mask for ICMP Framesstatic SK_U8 ICMP_PATTERN_MASK[] = { 0x00, 0x70, 0x80, 0x00, 0x00 };#endif/* * USE_ALT_TIMING * This define enables an alternative way to measure the time period while sending * data or a cmd to the fw. Timecritical systems like RT system might expect a * serious improvement in the behaviour of the driver if this define is set. */#ifdef USE_ALT_TIMING#define RDTSCLL(val) __asm__ __volatile__("rdtsc": "=A" (val))#endif/******************************************************************************* SkAsfRestorePattern - interface function (global symbol)** Description:* restores pattern for ASF and IPMI** Returns:* Always 0*/int SkAsfRestorePattern ( SK_AC *pAC , /* Pointer to adapter context */ SK_IOC IoC) /* IO context handle */{ if (pAC->AsfData.OpMode == SK_GEASF_MODE_ASF) { // asf mode -> we are running on // yukon ec with only one port AsfSetUpPattern(pAC, IoC, 0); } else { if (pAC->AsfData.OpMode == SK_GEASF_MODE_IPMI) { // ipmi mode -> we are running on // yukon 2 with at least one port AsfSetUpPattern(pAC, IoC, 0); // port A if (pAC->AsfData.DualMode == SK_GEASF_Y2_DUALPORT) { AsfSetUpPattern(pAC, IoC, 1); // port B } } } return (SK_ASF_PNMI_ERR_OK);}/******************************************************************************* SkAsfInit - Init function of ASF** Description:* SK_INIT_DATA: Initialises the data structures* SK_INIT_IO: Resets the XMAC statistics, determines the device and* connector type.* SK_INIT_RUN: Starts a timer event for port switch per hour* calculation.** Returns:* Always 0*/int SkAsfInit( SK_AC *pAC, /* Pointer to adapter context */ SK_IOC IoC, /* IO context handle */ int Level) /* Initialization level */{ SK_U32 TmpVal32; SK_U8 TmpVal8; SK_U32 FlashOffset = 0; SK_U32 i; SK_U32 FileLengthS1; SK_U32 FileLengthS2; char *FwFileNameS1 = NULL; char *FwFileNameS2 = NULL; SK_U8 *pAsfFwS1 = NULL; SK_U8 *pAsfFwS2 = NULL; SK_U8 FlashOk; int RetCode; SK_BOOL DoUpdate = SK_FALSE; SK_U8 lRetCode; SK_U32 FwImageCsOk; SK_U32 FwFlashCsOk; SK_U32 FwImageCs = 0; SK_U32 FwFlashCs = 0; SK_U32 FwCs; SK_U32 *pTmp32; SK_U8 *pHciRecBuf; SK_EVPARA EventParam; /* Event struct for timer event */ unsigned long FlashSize; unsigned long EraseOff = 0; SK_U32 SpiRetVal; SK_U8 Tmp1Val8, Tmp2Val8; SK_BOOL YukonEcA1; SK_U8 OldGuid[16]; SK_U8 AsfFlag = 0, IpmiFlag = 0, AsfDashFlag = 0; SK_U8 AsfHintBit = 0, IpmiHintBit = 0, NoHintBit = 0; RetCode = SK_ASF_PNMI_ERR_OK; SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("ASF: SkAsfInit: Called, level=%d sizof ASF-MIB:0x%x Bytes\n", Level, sizeof(STR_ASF_MIB) ) ); /* YukonEcA1 introduced by rschmidt */ YukonEcA1 = (pAC->GIni.GIChipId == CHIP_ID_YUKON_EC && pAC->GIni.GIChipRev == CHIP_REV_YU_EC_A1); switch(Level) { case SK_INIT_DATA: /* Set structure to zero */ // This will be done in function "AsfReadConfiguration" // SK_MEMSET((char *)&pAC->AsfData, 0, sizeof(pAC->AsfData)); pAC->AsfData.ActivePort = 0; pAC->AsfData.OpMode = SK_GEASF_MODE_IPMI; pAC->AsfData.ChipMode = SK_GEASF_CHIP_UNKNOWN; pAC->AsfData.InitState = ASF_INIT_UNDEFINED;#ifdef USE_ASF_DASH_FW pAC->ReturningFromSuspend = 0; pAC->RamAddr = 0; pAC->RamSelect = 0;#endif pAC->ForceFWIPUpdate = 0; pAC->RecvNewPattern = 0;#ifdef USE_ASF_DASH_FW AsfResetOsPresentBit( pAC, IoC );#endif break; case SK_INIT_IO:#if (0) /* Set 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#ifdef USE_ASF_DASH_FW AsfResetOsPresentBit( pAC, IoC );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -