📄 gei82543end.c
字号:
#define END_CACHE_INVALIDATE(address, len) \ CACHE_DRV_INVALIDATE (&pDrvCtrl->cacheFuncs, (address), (len))#define END_CACHE_PHYS_TO_VIRT(address) \ CACHE_DRV_PHYS_TO_VIRT (&pDrvCtrl->cacheFuncs, (address))#define END_CACHE_VIRT_TO_PHYS(address) \ CACHE_DRV_VIRT_TO_PHYS (&pDrvCtrl->cacheFuncs, (address))/* misc. */#define GEI_DESC_ALIGN_BYTE (128)/* * Default macro definitions for BSP interface. * These macros can be redefined in a wrapper file, to generate * a new module with an optimized interface. *//* macro to connect interrupt handler to vector */#ifndef SYS_INT_CONNECT#define SYS_INT_CONNECT(pDrvCtrl,rtn,arg,pResult) \ { \ *pResult = OK; \ if (pDrvCtrl->adaptor.intConnect) \ *pResult = (pDrvCtrl->adaptor.intConnect) ((VOIDFUNCPTR *) \ INUM_TO_IVEC (pDrvCtrl->adaptor.vector), \ rtn, (int)arg); \ }#endif/* macro to disconnect interrupt handler from vector */#ifndef SYS_INT_DISCONNECT#define SYS_INT_DISCONNECT(pDrvCtrl,rtn,arg,pResult) \ { \ *pResult = OK; \ if (pDrvCtrl->adaptor.intDisConnect) \ *pResult = (pDrvCtrl->adaptor.intDisConnect) ((VOIDFUNCPTR *) \ INUM_TO_IVEC (pDrvCtrl->adaptor.vector), \ rtn, (int)arg); \ }#endif/* macro to enable the appropriate interrupt level */#ifndef SYS_INT_ENABLE#define SYS_INT_ENABLE(pDrvCtrl) \ { \ pDrvCtrl->adaptor.intEnable(pDrvCtrl->unit); \ }#endif#ifndef SYS_INT_DISABLE#define SYS_INT_DISABLE(pDrvCtrl) \ { \ pDrvCtrl->adaptor.intDisable(pDrvCtrl->unit); \ }#endif/* * a shortcut for getting the hardware address * from the MIB II stuff. */#define END_HADDR(pEnd) \ ((pEnd)->mib2Tbl.ifPhysAddress.phyAddress)#define END_HADDR_LEN(pEnd) \ ((pEnd)->mib2Tbl.ifPhysAddress.addrLength)/* device structure */typedef struct end_device { END_OBJ end; /* the class we inherit from. */ int unit; /* unit number */ UINT32 flags; /* flags for device configuration */ UINT32 usrFlags; /* flags for user customization */ CACHE_FUNCS cacheFuncs; /* cache function pointers */ CL_POOL_ID pClPoolId; /* cluster pool ID */ ADAPTOR_INFO adaptor; /* adaptor information */ UINT32 devRegBase; /* virtual base address for registers */ P_TX_DESCTL pTxDesCtlBase; /* pointer to the TX management array base */ char *pTxDescBase; /* pointer to the TX descriptor base */ char *pRxDescBase; /* pointer to the RX descriptor base */ char * pRxBufBase; /* pointer to the RX buffer base */ volatile int txDescTail; /* index to the TX tail */ volatile int rxDescTail; /* index to the RX tail */ int txDescNum; /* num of TX descriptors */ int rxDescNum; /* num of RX descriptors */ UINT32 rxBufSize; /* RX buffer size */ UINT32 txReqDescNum; /* request number for TX descriptor */ int mtu; /* maximum transfer unit */ volatile int rxtxHandling; /* indicator for RX handling */ volatile BOOL txStall; /* indicator for transmit stall */ BOOL txActivity; /* TX activity flag */ int txIntDelay; /* delay time for TX interrupt */ int rxIntDelay; /* delay time for RX interrupt */ int maxRxNumPerInt; /* maximum RX packets processed per Int */ BOOL dmaPriority; /* indicator for TX/RX DMA prefer */ UINT32 timerInterval; /* interval for timer interrupt */ BOOL timerCheckTxStall; /* indicator for txStall checking */ UINT32 multiCastFilterType; /* indicator of multicast table type */ int flowCtrl; /* flow control setting */ STATUS linkInitStatus; /* the status of first link */ volatile UINT32 linkStatus; /* indicator for link status */ BOOL linkMethod; /* indicator for link approaches */ WDOG_ID timerId; /* timer ID */ UINT32 txConfigureWord; /* copy of TX configuration word register */ UINT32 devCtrlRegVal; /* control register value */ UINT32 speed; /* device speed */ UINT32 duplex; /* device duplex mode */ UINT32 offset; /* offset for IP header */ UINT32 cableType; /* cable type (Fiber or Copper) */ BOOL memAllocFlag; /* indicator that the shared memory */ /* allocated by driver */ char * pMemBase; /* memory base for TX/RX area */ int memSize; /* total memory size for RX/TX area */ char * pMclkArea; /* address of Mclk */ char * pTxPollBufAdr; /* address for TX buffer in polling mode */ PHY_INFO * pPhyInfo; /* pointer to phyInfo structure */ UINT32 phyInitFlags; /* Initial PHY flags for phyInfo */ volatile UINT32 txDescLastCheck; /* index of the last checked TX desc */ volatile UINT32 txDescFreeNum; /* available/usable TX desc number */ STA_REG staRegs; /* statistic register structure */ BOOL txResoFreeQuick; /* flag to free loaned mBlk quickly */ volatile BOOL attach; /* indicator for drive attach */ volatile BOOL devStartFlag; /* indicator for device start */ UINT32 rxtxHandlerNum; /* num of rxtx handler calling */ UINT32 rxIntCount; /* receive interrupt count */ UINT32 txIntCount; /* transmit interrupt count */ UINT32 rxORunIntCount; /* num of RX overrun interrupt count */ UINT32 rxPacketNum; /* statistic RX packet number */ UINT32 rxPacketDrvErr ; /* num of RX packet drop due to no resc */#ifdef INCLUDE_TBI_COMPATIBLE BOOL tbiCompatibility; /* TBI compatibility for HW bug */#endif } END_DEVICE;/* DEBUG MACROS */#undef DRV_DEBUG#undef INCLUDE_GEI82543_DEBUG_ROUTINE#undef GEI82543_NO_LOCAL#ifdef DEBUG #define LOGMSG(x,a,b,c,d,e,f) \ if (endDebug) \ { \ logMsg (x,a,b,c,d,e,f); \ }#else#define LOGMSG(x,a,b,c,d,e,f)#endif /* DEBUG */#ifdef GEI82543_NO_LOCAL#undef LOCAL#define LOCAL#endif#ifdef DRV_DEBUG#define DRV_DEBUG_OFF 0x0000#define DRV_DEBUG_RX 0x0001#define DRV_DEBUG_TX 0x0002#define DRV_DEBUG_INT 0x0004#define DRV_DEBUG_POLL (DRV_DEBUG_POLL_RX | DRV_DEBUG_POLL_TX)#define DRV_DEBUG_POLL_RX 0x0008#define DRV_DEBUG_POLL_TX 0x0010#define DRV_DEBUG_LOAD 0x0020#define DRV_DEBUG_IOCTL 0x0040#define DRV_DEBUG_TIMER 0x20000int gei82543GCDebug = 0x0;#define DRV_LOG(FLG, X0, X1, X2, X3, X4, X5, X6) \ if (gei82543GCDebug & FLG) \ logMsg(X0, X1, X2, X3, X4, X5, X6);#define DRV_PRINT(FLG,X) \ if (gei82543GCDebug & FLG) printf X;#else /* DRV_DEBUG */#define DRV_LOG(DBG_SW, X0, X1, X2, X3, X4, X5, X6)#define DRV_PRINT(DBG_SW,X)#endif /* DRV_DEBUG */ #ifdef INCLUDE_GEI82543_DEBUG_ROUTINELOCAL void gei82543LedOff (int);LOCAL void gei82543LedOn (int);LOCAL void gei82543StatusShow (int);LOCAL UINT32 gei82543RegGet (int,UINT32);LOCAL void gei82543RegSet (int,UINT32, UINT32); #ifdef INCLUDE_TBI_COMPATIBLELOCAL void gei82543TbiCompWr (int, int);#endif /* INCLUDE_TBI_COMPATIBLE */#endif /* INCLUDE_GEI82543_DEBUG_ROUTINE *//* forward functions */LOCAL void gei82543EndTimerHandler (END_DEVICE *);LOCAL void gei82543MemAllFree (END_DEVICE *);LOCAL STATUS gei82543linkStatusCheck (END_DEVICE *);LOCAL void gei82543TxRxEnable (END_DEVICE *);LOCAL void gei82543TxRxDisable (END_DEVICE *);LOCAL void gei82543Delay (END_DEVICE *, UINT32);LOCAL void gei82543RxSetup (END_DEVICE *);LOCAL void gei82543TxSetup (END_DEVICE *);LOCAL STATUS gei82543HwInit (END_DEVICE *);LOCAL void gei82543RxDesUpdate (END_DEVICE *,char *); LOCAL void gei82543DuplexGet (END_DEVICE *);LOCAL void gei82543SpeedGet (END_DEVICE *);LOCAL void gei82543HwStatusDump (END_DEVICE *);LOCAL STATUS gei82543linkInit (END_DEVICE *);LOCAL STATUS gei82543linkTBISetup (END_DEVICE *,BOOL);LOCAL STATUS gei82543TBIlinkForce (END_DEVICE *,BOOL, BOOL);LOCAL STATUS gei82543TBIHwAutoNegotiate (END_DEVICE *,BOOL, BOOL);LOCAL void gei82543EtherRxAdrSet (END_DEVICE *,UINT8 adr[],int);LOCAL void gei82543AllRxAdrClean (END_DEVICE *);LOCAL void gei82543McastAdrClean (END_DEVICE *);LOCAL void gei82543AllMtaAdrClean (END_DEVICE *);LOCAL void gei82543AllVlanClean (END_DEVICE *);LOCAL UINT32 gei82543DisableChipInt (END_DEVICE *);LOCAL void gei82543EnableChipInt (END_DEVICE *);LOCAL void gei82543Reset (END_DEVICE *);LOCAL void gei82543TxMblkFree (END_DEVICE *,int);LOCAL void gei82543TxMblkWaitClean (END_DEVICE *);LOCAL STATUS gei82543EndMCastAdd (END_DEVICE *,char*);LOCAL STATUS gei82543EndMCastDel (END_DEVICE *,char*);LOCAL STATUS gei82543EndMCastGet (END_DEVICE *,MULTI_TABLE*);LOCAL void gei82543EndInt (END_DEVICE *);LOCAL void gei82543RxTxIntHandle (END_DEVICE *);LOCAL STATUS gei82543Recv (END_DEVICE *,char *, UINT8);LOCAL void gei82543EndConfigure (END_DEVICE *);LOCAL void gei82543FlowCtrlRegsSet (END_DEVICE *);LOCAL STATUS gei82543PhyWrite (END_DEVICE *,UINT8,UINT8,UINT16);LOCAL STATUS gei82543PhyRead (END_DEVICE *,UINT8,UINT8, UINT16 *);LOCAL STATUS gei82544PhyWrite (END_DEVICE *,UINT8,UINT8,UINT16);LOCAL STATUS gei82544PhyRead (END_DEVICE *,UINT8,UINT8, UINT16 *);LOCAL void gei82543LoanTransmit (END_DEVICE *,M_BLK_ID);LOCAL void gei82543TxResoFree (END_DEVICE *);LOCAL int gei82543TxDesCleanGet (END_DEVICE *,int);LOCAL UINT32 gei82543TxStallCheck (END_DEVICE *);LOCAL void gei82543GMIIphyConfig (END_DEVICE *);LOCAL void gei82543GMIIphyReConfig (END_DEVICE *);LOCAL STATUS gei82543linkGMIISetup (END_DEVICE *);LOCAL STATUS gei82543linkGMIIPreInit (END_DEVICE *);/* END specific interfaces. *//* This is the only externally visible interface. */END_OBJ* gei82543EndLoad (char* initString);LOCAL STATUS gei82543EndStart (END_DEVICE* pDrvCtrl);LOCAL STATUS gei82543EndStop (END_DEVICE* pDrvCtrl);LOCAL int gei82543EndIoctl (END_DEVICE* pDrvCtrl, int cmd, caddr_t data);LOCAL STATUS gei82543EndUnload (END_DEVICE* pDrvCtrl);LOCAL STATUS gei82543EndSend (END_DEVICE* pDrvCtrl, M_BLK_ID pBuf);LOCAL STATUS gei82543EndMCastAdd (END_DEVICE* pDrvCtrl, char* pAddress);LOCAL STATUS gei82543EndMCastDel (END_DEVICE* pDrvCtrl, char* pAddress);LOCAL STATUS gei82543EndMCastGet (END_DEVICE* pDrvCtrl, MULTI_TABLE* pTable);LOCAL STATUS gei82543EndPollStart (END_DEVICE* pDrvCtrl);LOCAL STATUS gei82543EndPollStop (END_DEVICE* pDrvCtrl);LOCAL STATUS gei82543EndPollSend (END_DEVICE* pDrvCtrl, M_BLK_ID pBuf);LOCAL STATUS gei82543EndPollRcv (END_DEVICE* pDrvCtrl, M_BLK_ID pBuf);LOCAL void gei82543AddrFilterSet (END_DEVICE* pDrvCtrl);LOCAL STATUS gei82543EndParse (END_DEVICE*, char *);LOCAL STATUS gei82543EndMemInit (END_DEVICE*);/* * Declare our function table. This is LOCAL across all driver * instances. */LOCAL NET_FUNCS gei82543EndFuncTable = { (FUNCPTR) gei82543EndStart, /* Function to start the device. */ (FUNCPTR) gei82543EndStop, /* Function to stop the device. */ (FUNCPTR) gei82543EndUnload, /* Unloading function for the driver. */ (FUNCPTR) gei82543EndIoctl, /* Ioctl function for the driver. */ (FUNCPTR) gei82543EndSend, /* Send function for the driver. */ (FUNCPTR) gei82543EndMCastAdd, /* Multicast add function for the */ /* driver. */ (FUNCPTR) gei82543EndMCastDel, /* Multicast delete function for */ /* the driver. */ (FUNCPTR) gei82543EndMCastGet, /* Multicast retrieve function for */ /* the driver. */ (FUNCPTR) gei82543EndPollSend, /* Polling send function */ (FUNCPTR) gei82543EndPollRcv, /* Polling receive function */ endEtherAddressForm, /* put address info into a NET_BUFFER */ endEtherPacketDataGet, /* get pointer to data in NET_BUFFER */ endEtherPacketAddrGet /* Get packet addresses. */ };/*************************************************************************** gei82543EndLoad - initialize the driver and device** This routine initializes the driver and the device to the operational state.* All of the device specific parameters are passed in the initString.** The string contains the target specific parameters like this:* "unitnum:shmem_addr:shmem_size:rxDescNum:txDescNum:usrFlags:offset:mtu"** RETURNS: an END object pointer, NULL if error, or zero */END_OBJ* gei82543EndLoad ( char *initString /* String to be parsed by the driver. */ ) { END_DEVICE *pDrvCtrl = NULL; /* pointer to device structure */ DRV_LOG (DRV_DEBUG_LOAD, "Loading gei82543End Driver...\n", 1, 2, 3, 4, 5, 6); /* sanity check */ if (initString == NULL) return NULL; if (initString[0] == 0) { bcopy ((char *) DEVICE_NAME, (void *)initString, DEVICE_NAME_LENGTH); return 0; } /* allocate the device structure */ pDrvCtrl = (END_DEVICE *)calloc (sizeof (END_DEVICE), 1); if (pDrvCtrl == NULL) goto errorExit; /* clean up driver structure */ memset((void *)pDrvCtrl, 0, sizeof (END_DEVICE)); /* parse the init string, filling in the device structure */ if (gei82543EndParse (pDrvCtrl, initString) == ERROR) goto errorExit; /* zero adaptor structure */ memset ((void *)&pDrvCtrl->adaptor, 0, sizeof(ADAPTOR_INFO)); /* call BSP routine to get PCI information*/ if (sys82543BoardInit (pDrvCtrl->unit, &pDrvCtrl->adaptor) != OK) { DRV_LOG (DRV_DEBUG_LOAD, "Error in getting board info\n", 1, 2, 3, 4, 5, 6); goto errorExit; } /* set up the base register */ pDrvCtrl->devRegBase = (UINT32)(pDrvCtrl->adaptor.regBaseLow); /* set up device structure based on user's flags */ if (pDrvCtrl->usrFlags & GEI_END_JUMBO_FRAME_SUPPORT) { if (pDrvCtrl->mtu <= 0) pDrvCtrl->mtu = GEI_DEFAULT_JUMBO_MTU_SIZE; pDrvCtrl->mtu = (pDrvCtrl->mtu <= ETHERMTU)? ETHERMTU : ((pDrvCtrl->mtu > GEI_MAX_JUMBO_MTU_SIZE)?
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -