⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wancomend.c

📁 WINDRIVER SBC7410 BSP
💻 C
📖 第 1 页 / 共 5 页
字号:
/* wancomEnd.c - END style Marvell/Galileo GT64260 Ethernet network interface driver *//* Copyright 1989-2002 Wind River Systems, Inc. *//* Copyright 2001 Marvell, Inc. *//********************************************************************************              (c), Copyright 2001, Marvell International Ltd.                 ** THIS CODE CONTAINS CONFIDENTIAL INFORMATION OF MARVELL SEMICONDUCTOR, INC.   ** NO RIGHTS ARE GRANTED HEREIN UNDER ANY PATENT, MASK WORK RIGHT OR COPYRIGHT  ** OF MARVELL OR ANY THIRD PARTY. MARVELL RESERVES THE RIGHT AT ITS SOLE        ** DISCRETION TO REQUEST THAT THIS CODE BE IMMEDIATELY RETURNED TO MARVELL.     ** THIS CODE IS PROVIDED "AS IS". MARVELL MAKES NO WARRANTIES, EXPRESS, IMPLIED ** OR OTHERWISE, REGARDING ITS ACCURACY, COMPLETENESS OR PERFORMANCE.           *********************************************************************************/#include "copyright_wrs.h"/*modification history--------------------01b,26aug02,dld  typecasts to eliminate Diab warnings01a,28may02,gtf  created from Marvel wancom end driver.*//*DESCRIPTIONThis module implements an Galileo Ethernet network interface driver.   This is a fast Ethernet IEEE 802.3 10Base-T and 100Base-T compatible.  The Galileo establishes a shared memory communication system with the  CPU, which is divided into two parts: the Transmit Frame Area (TFA)  and the Receive Frame Area (RFA).                                   The TFA consists of a linked list of frame descriptors through which packet are transmitted. The linked list is in a form of a ring.     The RFA is a linked list of receive frame descriptors through which packet receive is performed. The linked list is in a form of queue.    The RFA also contains two Receive Buffers Area. One area is used for   clusters (See netBufLib) and the other one is used for Galileo device  receive buffers. This is done as we must keep receive buffers at 64bit alignment ! 															BOARD LAYOUTThis device is on-board.  No jumpering diagram is necessary.EXTERNAL INTERFACEThe driver provides the standard external interface, wancomEndLoad(),  which takes a string of colon separated parameters. The parameters    should be specified in hexadecimal, optionally preceeded by "0x" or a minus sign "-".                                                       The parameter string is parsed using strtok_r() and each parameter isconverted from a string representation to binary by a call to       strtoul(parameter, NULL, 16).                                      The format of the parameter string is:                                 "<memBase>:<memSize>:<nCFDs>:<nRFDs>:<flags>"                         In addition, the two global variables 'wancomEndIntConnect' and         'wancomEndIntDisconnect' specify respectively the interrupt connect     routine and the interrupt disconnect routine to be used depending on the BSP. The former defaults to intConnect() and the user can override this to use any other interrupt connect routine (say pciIntConnect()) in sysHwInit() or any device specific initialization routine called in sysHwInit(). Likewise, the latter is set by default to NULL, but it   may be overridden in the BSP in the same way.                         TARGET-SPECIFIC PARAMETERS.IP <memBase>                                                              This parameter is passed to the driver via wancomEndLoad().           This parameter can be used to specify an explicit memory region for    use by the Galileo device.  This should be done on targets that        restrict the Galileo device memory to a particular memory region.      The constant `NONE' can be used to indicate that there are no memory   limitations, in which case the driver will allocate cache safe memory  for its use using cacheDmaAlloc().                                    .IP <memSize>                                                              The memory size parameter specifies the size of the pre-allocated      memory region. If memory base is specified as NONE (-1), the driver    ignores this parameter. Otherwise, the driver checks the size of the   provoded memory region is adequate with respect to the given number of Command Frame Descriptor and Receive Frame Descriptor.                 .IP <nTfds>                                                                This parameter specifies the number of transmit descriptor/buffers to  be allocated. If this parameter is less than two, a default of 32 is   used.                                                                  .IP <nRfds>                                                                This parameter specifies the number of receive descriptor/buffers to   be allocated. If this parameter is less than two, a default of 32 is   used.                                                                  .IP <flags>                                                                User flags may control the run-time characteristics of the Ethernet    chip. Not implemented.                                                 EXTERNAL SUPPORT REQUIREMENTSThis driver requires one external support function:.CSSTATUS sysWancomInit (int unit, WANCOM_PORT_INFO *pPort).CEThis routine performs any target-specific initializationrequired before the GT64260A ethernet ports are initialized by the driver.The driver calls this routine every time it wants to [re]initializethe device.  This routine returns OK, or ERROR if it fails..LPSYSTEM RESOURCE USAGEThe driver uses cacheDmaMalloc() to allocate memory to share with      the Galileo Ethernet port.                                             The size of this area is affected by the configuration parameters      specified in the wancomEndLoad() call.                                 Either the shared memory region must be non-cacheable, or else         the hardware must implement bus snooping.  The driver cannot maintain  cache coherency for the device because fields within the command       structures are asynchronously modified by both the driver and the      device, and these fields may share the same cache line.                TUNING HINTSThe only adjustable parameters are the number of TFDs and RFDs that    will be created at run-time.  These parameters are given to the        driver when wancomEndLoad() is called.  There is one TFD and one RFD   associated with each transmitted frame and each received frame         respectively. For memory-limited applications, decreasing the number   of TFDs and RFDs may be desirable. Increasing the number of TFDs will  provide no performance benefit after a certain point. Increasing the   number of RFDs will provide more buffering before packets are dropped.  This can be useful if there are tasks running at a higher priority    than the net task.                                                     ALIGNMENTSome architectures do not support unaligned access to 32-bit data items. Onthese architectures (eg PowerPC and ARM), it will be necessary to adjust theoffset parameter in the load string to realign the packet. Failure to do sowill result in received packets being absorbed by the network stack, althoughtransmit functions should work OK.SEE ALSO: ifLib,.I "Marvell GT64260A Data Sheet,"*/#include "vxWorks.h"#include "config.h"#include "wdLib.h"#include "iv.h"#include "vme.h"#include "net/mbuf.h"#include "net/unixLib.h"#include "net/protosw.h"#include "sys/socket.h"#include "sys/ioctl.h"#include "errno.h"#include "memLib.h"#include "intLib.h"#include "net/route.h"#include "iosLib.h"#include "errnoLib.h"#include "vxLib.h"   #include "private/funcBindP.h"#include "cacheLib.h"#include "logLib.h"#include "netLib.h"#include "stdio.h"#include "stdlib.h"#include "sysLib.h"#include "taskLib.h"#include "etherLib.h"#include "net/systm.h"#include "sys/times.h"#include "net/if_subr.h"#include "drv/pci/pciIntLib.h"#undef ETHER_MAP_IP_MULTICAST#include "etherMultiLib.h"#include "end.h"#include "semLib.h"#define    END_MACROS#include "endLib.h"#include "lstLib.h"#include "wancomEnd.h"/* defines *//* Driver debug control */#define WANCOM_DRV_DEBUG/* Driver debug control */#ifdef WANCOM_DRV_DEBUG#define DRV_DEBUG_OFF		0x0000#define DRV_DEBUG_RX		0x0001#define DRV_DEBUG_TX		0x0002#define DRV_DEBUG_POLL		(DRV_DEBUG_POLL_RX | DRV_DEBUG_POLL_TX)#define DRV_DEBUG_POLL_RX   0x0004#define DRV_DEBUG_POLL_TX   0x0008#define DRV_DEBUG_LOAD		0x0010#define DRV_DEBUG_IOCTL		0x0020#define DRV_DEBUG_INT		0x0040#define DRV_DEBUG_START    	0x0080#define DRV_DEBUG_DUMP    	0x0100#define DRV_DEBUG_MEM    	0x0200#define DRV_DEBUG_RX_ERR   	0x0400	#define DRV_DEBUG_ERR   	0x0800	#define DRV_DEBUG_ALL    	0xffffint wancomDebug = DRV_DEBUG_RX_ERR | DRV_DEBUG_ERR ;#define WANCOM_DRV_LOG(FLG, X0, X1, X2, X3, X4, X5, X6)				\    {															\    if (wancomDebug & FLG)										\		if (_func_logMsg != NULL)								\			_func_logMsg (X0, X1, X2, X3, X4, X5, X6);			\	}#define WANCOM_DRV_PRINT(FLG, X)										\    {															\    if (wancomDebug & FLG) printf X;							\    }#else /* DRV_DEBUG */#define WANCOM_DRV_LOG(FLG, X0, X1, X2, X3, X4, X5, X6)#define WANCOM_DRV_PRINT(FLG, X)#endif /* DRV_DEBUG *//* general macros for reading/writing from/to specified locations *//* Cache and PCI-bus related macros */#define WANCOM_CACHE_INVALIDATE(address, len)				    \        CACHE_DRV_INVALIDATE (&pDrvCtrl->cacheFuncs, (address), (len))/* driver flags */#define WANCOM_OWN_MEM	0x01		/* internally provided memory */#define WANCOM_INV_NCFD 0x02		/* invalid nCFDs provided */#define WANCOM_INV_NRFD 0x04		/* invalid nRFDs provided */#define WANCOM_POLLING	0x08		/* polling mode */#define WANCOM_PROMISC	0x20    	/* promiscuous mode */#define WANCOM_MCAST	0x40    	/* multicast addressing mode */#define WANCOM_MCASTALL	0x80    	/* all multicast addressing mode */#define WANCOM_MEMOWN	0x10    	/* device mem allocated by driver */#define WANCOM_FLAG_CLEAR(clearBits)			\    (pDrvCtrl->flags &= ~(clearBits)) #define WANCOM_FLAG_SET(setBits)				\    (pDrvCtrl->flags |= (setBits)) #define WANCOM_FLAG_GET()						\    (pDrvCtrl->flags) #define WANCOM_FLAG_ISSET(setBits)				\    (pDrvCtrl->flags & (setBits)) /* shortcuts */#define END_FLAGS_ISSET(setBits)				\    ((&pDrvCtrl->endObj)->flags & (setBits))	#define CL_OVERHEAD	4							/* prepended cluster header */#define CL_RFD_SIZE	(RFD_SIZE + CL_OVERHEAD)		#define WANCOM_HADDR(pEnd)                      	\        ((pEnd)->mib2Tbl.ifPhysAddress.phyAddress)#define WANCOM_HADDR_LEN(pEnd)                      \        ((pEnd)->mib2Tbl.ifPhysAddress.addrLength)/* Port Registers read write macros */#define PORT_REG_WRITE(offset, value)						\    GT64260_REG_WR (((pDrvCtrl->pCSR) + (offset)), (value))#define PORT_REG_READ(offset, pValue)						\    GT64260_REG_RD (((pDrvCtrl->pCSR) + (offset)), (pValue))/* get the pointer to the appropriate frame descriptor ring */#define WANCOM_FREE_CFD_GET(pCurrFD)				\    ((pCurrFD) = pDrvCtrl->currTxDescPtr)#define WANCOM_USED_CFD_GET(pCurrFD)				\    ((pCurrFD) = pDrvCtrl->usedTxDescPtr)#define USED_CFD_SET(pCurrFD)				\    (pDrvCtrl->usedTxDescPtr) = (pCurrFD) #define WANCOM_RFD_GET(pCurrFD)					\    ((pCurrFD) = pDrvCtrl->headRxDescPtr)#define WANCOM_RFD_SET(pCurrFD)					\    (pDrvCtrl->headRxDescPtr = (pCurrFD))#define WANCOM_INT_ENABLE(pDrvCtrl)					\    ((int)(pDrvCtrl)->port.intEnable)#define WANCOM_INT_DISABLE(pDrvCtrl)					\    ((int)(pDrvCtrl)->port.intDisable)#define WANCOM_INT_ACK(pDrvCtrl)						\    ((int)(pDrvCtrl)->port.intAck)#define GT64260_INT_ENABLE						\		PORT_REG_WRITE (INTERRUPT_MASK_REG, 							\					   RX_BUFFER_RETURN | TX_END_LOW_PRIO)#define GT64260_INT_DISABLE						\		PORT_REG_WRITE (INTERRUPT_MASK_REG, 0)#define GT64260_INT_ACK(cause32bit) \		PORT_REG_WRITE (INTERRUPT_CAUSE_REG, ~cause32bit)	/* globals */FUNCPTR wancomEndIntConnect    = (FUNCPTR) intConnect ;FUNCPTR wancomEndIntDisconnect = (FUNCPTR) NULL;/* locals */typedef unsigned int              RX_COMMAND;typedef struct SdmaRxDesc    {    unsigned int        bufsize :16;    unsigned int        bytecnt :16;    RX_COMMAND          cmd_sts;     unsigned int        next_desc_ptr;     unsigned int        buf_ptr;      unsigned int        indexToRxQueue:4; /*    unsigned char      indexToRxQueue;*//* index to rx queue to release the descriptor to the right queue */    } RX_DESC;typedef unsigned int              TX_COMMAND;typedef struct SdmaTxDesc    {    unsigned int          bytecnt   :16;    unsigned int          shadow    :16;    TX_COMMAND            cmd_sts;    unsigned int          next_desc_ptr;     unsigned int          buf_ptr;    unsigned int          pointerToRxQueue;/*    TaskFunction    funcCallBackPointer;*/    unsigned int          shadowOwner:1; /* if 1 -> belong to the GT */    } TX_DESC;/* The definition of the driver control structure */typedef struct wancom_drv_ctrl    {    END_OBJ     endObj;     /* base class */    int         unit;       /* unit number */    char *      pMemBase;   /* memory pool base */    ULONG       memSize;    /* memory pool size */    char *      pClsBase;   /* cluster pool base */    char *      pMemArea;   /* Mblk Clblk pool pointer */    int         nCFDs;      /* how many CFDs to create */    int         nRFDs;      /* how many RFDs to create */    UINT32      pCSR;       /* pointer to CSR base */    RX_DESC*    headRxDescPtr;   /* Pointer to head Rx desc queue 	*/    RX_DESC*    tailRxDescPtr;   /* Pointer to tail Rx desc queue 	*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -