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

📄 xemac.h

📁 powerpc405开发板的linux网口驱动程序
💻 H
📖 第 1 页 / 共 3 页
字号:
#define XEM_MULTICAST_OPTION      0x00000040UL /**< Multicast address reception                                                    (defaults off) */#define XEM_FLOW_CONTROL_OPTION   0x00000080UL /**< Interpret pause frames in                                                    full duplex mode (defaults                                                    off) */#define XEM_INSERT_PAD_OPTION     0x00000100UL /**< Pad short frames on transmit                                                    (defaults on) */#define XEM_INSERT_FCS_OPTION     0x00000200UL /**< Insert FCS (CRC) on transmit                                                    (defaults on) */#define XEM_INSERT_ADDR_OPTION    0x00000400UL /**< Insert source address on                                                    transmit (defaults on) */#define XEM_OVWRT_ADDR_OPTION     0x00000800UL /**< Overwrite source address on                                                    transmit. This is only used                                                    only used if source address                                                    insertion is on (defaults on) */#define XEM_NO_SGEND_INT_OPTION   0x00001000UL /**< Disables the SGEND interrupt                                                    with SG DMA. Setting this                                                    option to ON may help bulk                                                    data transfer performance                                                    when utilizing higher packet                                                    threshold counts on slower                                                    systems (default is off) */#define XEM_STRIP_PAD_FCS_OPTION  0x00002000UL /**< Strip FCS and padding from                                                    received frames (defaults off) */#define XEM_JUMBO_OPTION          0x00004000UL /**< Allow reception of Jumbo frames,                                                    transmission of Jumbo frames is                                                    always enabled.                                                    (default is off) */#define XEM_MULTICAST_CAM_OPTION  0x00008000UL /**< Allow Rx address filtering                                                    for multicast CAM entries                                                    (default is off) *//*@}*//* * Some default values for interrupt coalescing within the scatter-gather * DMA engine. */#define XEM_SGDMA_DFT_THRESHOLD     1       /* Default pkt threshold */#define XEM_SGDMA_MAX_THRESHOLD     255     /* Maximum pkt theshold */#define XEM_SGDMA_DFT_WAITBOUND     5       /* Default pkt wait bound (msec) */#define XEM_SGDMA_MAX_WAITBOUND     1023    /* Maximum pkt wait bound (msec) *//* * Direction identifiers. These are used for setting values like packet * thresholds and wait bound for specific channels */#define XEM_SEND    1#define XEM_RECV    2/* * Arguments to SgSend function to indicate whether to hold off starting * the scatter-gather engine. */#define XEM_SGDMA_NODELAY     0     /* start SG DMA immediately */#define XEM_SGDMA_DELAY       1     /* do not start SG DMA *//* * Constants to determine the configuration of the hardware device. They are * used to allow the driver to verify it can operate with the hardware. */#define XEM_CFG_NO_IPIF             0       /* Not supported by the driver */#define XEM_CFG_NO_DMA              1       /* No DMA */#define XEM_CFG_SIMPLE_DMA          2       /* Simple DMA */#define XEM_CFG_DMA_SG              3       /* DMA scatter gather */#define XEM_MULTI_CAM_ENTRIES       64      /* Number of storable addresses in                                               the CAM *//* * The next few constants help upper layers determine the size of memory * pools used for Ethernet buffers and descriptor lists. */#define XEM_MAC_ADDR_SIZE   6       /* six-byte MAC address */#define XEM_MTU             1500    /* max size of Ethernet frame */#define XEM_JUMBO_MTU       8982    /* max payload size of jumbo frame */#define XEM_HDR_SIZE        14      /* size of Ethernet header */#define XEM_HDR_VLAN_SIZE   18      /* size of Ethernet header with VLAN */#define XEM_TRL_SIZE        4       /* size of Ethernet trailer (FCS) */#define XEM_MAX_FRAME_SIZE  (XEM_MTU + XEM_HDR_SIZE + XEM_TRL_SIZE)#define XEM_MAX_VLAN_FRAME_SIZE  (XEM_MTU + XEM_HDR_VLAN_SIZE + XEM_TRL_SIZE)#define XEM_MAX_JUMBO_FRAME_SIZE (XEM_JUMBO_MTU + XEM_HDR_SIZE + XEM_TRL_SIZE)/* * Define a default number of send and receive buffers */#define XEM_MIN_RECV_BUFS   32      /* minimum # of recv buffers */#define XEM_DFT_RECV_BUFS   64      /* default # of recv buffers */#define XEM_MIN_SEND_BUFS   16      /* minimum # of send buffers */#define XEM_DFT_SEND_BUFS   32      /* default # of send buffers */#define XEM_MIN_BUFFERS     (XEM_MIN_RECV_BUFS + XEM_MIN_SEND_BUFS)#define XEM_DFT_BUFFERS     (XEM_DFT_RECV_BUFS + XEM_DFT_SEND_BUFS)/* * Define the number of send and receive buffer descriptors, used for * scatter-gather DMA */#define XEM_MIN_RECV_DESC   16      /* minimum # of recv descriptors */#define XEM_DFT_RECV_DESC   32      /* default # of recv descriptors */#define XEM_MIN_SEND_DESC   8       /* minimum # of send descriptors */#define XEM_DFT_SEND_DESC   16      /* default # of send descriptors *//**************************** Type Definitions *******************************//** * Ethernet statistics (see XEmac_GetStats() and XEmac_ClearStats()) */typedef struct{    Xuint32 XmitFrames;              /**< Number of frames transmitted */    Xuint32 XmitBytes;               /**< Number of bytes transmitted */    Xuint32 XmitLateCollisionErrors; /**< Number of transmission failures                                          due to late collisions */    Xuint32 XmitExcessDeferral;      /**< Number of transmission failures                                          due o excess collision deferrals */    Xuint32 XmitOverrunErrors;       /**< Number of transmit overrun errors */    Xuint32 XmitUnderrunErrors;      /**< Number of transmit underrun errors */    Xuint32 RecvFrames;              /**< Number of frames received */    Xuint32 RecvBytes;               /**< Number of bytes received */    Xuint32 RecvFcsErrors;           /**< Number of frames discarded due                                          to FCS errors */    Xuint32 RecvAlignmentErrors;     /**< Number of frames received with                                          alignment errors */    Xuint32 RecvOverrunErrors;       /**< Number of frames discarded due                                          to overrun errors */    Xuint32 RecvUnderrunErrors;      /**< Number of recv underrun errors */    Xuint32 RecvMissedFrameErrors;   /**< Number of frames missed by MAC */    Xuint32 RecvCollisionErrors;     /**< Number of frames discarded due                                          to collisions */    Xuint32 RecvLengthFieldErrors;   /**< Number of frames discarded with                                          invalid length field */    Xuint32 RecvShortErrors;         /**< Number of short frames discarded */    Xuint32 RecvLongErrors;          /**< Number of long frames discarded */    Xuint32 DmaErrors;               /**< Number of DMA errors since init */    Xuint32 FifoErrors;              /**< Number of FIFO errors since init */    Xuint32 RecvInterrupts;          /**< Number of receive interrupts */    Xuint32 XmitInterrupts;          /**< Number of transmit interrupts */    Xuint32 EmacInterrupts;          /**< Number of MAC (device) interrupts */    Xuint32 TotalIntrs;              /**< Total interrupts */} XEmac_Stats;/** * This typedef contains configuration information for a device. */typedef struct{    Xuint16 DeviceId;           /**< Unique ID  of device */    Xuint32 BaseAddress;        /**< Register base address */    Xuint32 PhysAddress;        /**< Physical Base address */    Xboolean HasCounters;       /**< Does device have counters? */    Xuint8  IpIfDmaConfig;      /**< IPIF/DMA hardware configuration */    Xboolean HasMii;            /**< Does device support MII? */    Xboolean HasCam;            /**< Does device have multicast CAM */    Xboolean HasJumbo;          /**< Can device transfer jumbo frames */    Xboolean TxDre;             /**< Has data realignment engine on TX channel */    Xboolean RxDre;             /**< Has data realignment engine on RX channel */    Xboolean TxHwCsum;          /**< Has checksum offload on TX channel */    Xboolean RxHwCsum;          /**< Has checksum offload on RX channel */} XEmac_Config;/** @name Typedefs for callbacks * Callback functions. * @{ *//** * Callback when data is sent or received with scatter-gather DMA. * * @param CallBackRef is a callback reference passed in by the upper layer *        when setting the callback functions, and passed back to the upper *        layer when the callback is invoked. * @param BdPtr is a pointer to the first buffer descriptor in a list of *        buffer descriptors. * @param NumBds is the number of buffer descriptors in the list pointed *        to by BdPtr. */typedef void (*XEmac_SgHandler)(void *CallBackRef, XBufDescriptor *BdPtr,                                Xuint32 NumBds);/** * Callback when data is sent or received with direct FIFO communication or * simple DMA. The user typically defines two callacks, one for send and one * for receive. * * @param CallBackRef is a callback reference passed in by the upper layer *        when setting the callback functions, and passed back to the upper *        layer when the callback is invoked. */typedef void (*XEmac_FifoHandler)(void *CallBackRef);/** * Callback when an asynchronous error occurs. * * @param CallBackRef is a callback reference passed in by the upper layer *        when setting the callback functions, and passed back to the upper *        layer when the callback is invoked. * @param ErrorCode is a Xilinx error code defined in xstatus.h.  Also see *        XEmac_SetErrorHandler() for a description of possible errors. */typedef void (*XEmac_ErrorHandler)(void *CallBackRef, XStatus ErrorCode);/*@}*//** * The XEmac driver instance data. The user is required to allocate a * variable of this type for every EMAC device in the system. A pointer * to a variable of this type is then passed to the driver API functions. */typedef struct{    Xuint32 BaseAddress;         /* Base address (of IPIF) */    Xuint32 PhysAddress;         /* Physical Base address */    Xuint32 IsStarted;           /* Device is currently started */    Xuint32 IsReady;             /* Device is initialized and ready */    Xuint32 TxDmaControlWord;    /* TX SGDMA channel control word */    Xuint32 RxDmaControlWord;    /* RX SGDMA channel control word */    Xboolean IsPolled;           /* Device is in polled mode */    XEmac_Config *ConfigPtr;     /* Configuration table entry */    XEmac_Stats Stats;    XPacketFifoV200a RecvFifo;   /* FIFO used to receive frames */    XPacketFifoV200a SendFifo;   /* FIFO used to send frames */    /*     * Callbacks     */    XEmac_FifoHandler FifoRecvHandler;  /* for non-DMA/simple DMA interrupts */    void *FifoRecvRef;    XEmac_FifoHandler FifoSendHandler;  /* for non-DMA/simple DMA interrupts */    void *FifoSendRef;    XEmac_ErrorHandler ErrorHandler;    /* for asynchronous errors */    void *ErrorRef;    XDmaChannel RecvChannel;            /* DMA receive channel driver */    XDmaChannel SendChannel;            /* DMA send channel driver */    Xboolean    IsSgEndDisable;         /* Does SG DMA enable SGEND interrupt */    XEmac_SgHandler SgRecvHandler;      /* callback for scatter-gather DMA */    void *SgRecvRef;    XEmac_SgHandler SgSendHandler;      /* callback for scatter-gather DMA */    void *SgSendRef;} XEmac;/***************** Macros (Inline Functions) Definitions *********************//*****************************************************************************//**** This macro determines if the device is currently configured for* scatter-gather DMA.** @param InstancePtr is a pointer to the XEmac instance to be worked on.** @return** Boolean XTRUE if the device is configured for scatter-gather DMA, or XFALSE* if it is not.** @note** Signature: Xboolean XEmac_mIsSgDma(XEmac *InstancePtr)*******************************************************************************/#define XEmac_mIsSgDma(InstancePtr) \    (((InstancePtr)->ConfigPtr->IpIfDmaConfig == XEM_CFG_DMA_SG) ? \     XTRUE : XFALSE)/*****************************************************************************//**** This macro determines if the device is currently configured for simple DMA.** @param InstancePtr is a pointer to the XEmac instance to be worked on.** @return** Boolean XTRUE if the device is configured for simple DMA, or XFALSE otherwise** @note** Signature: Xboolean XEmac_mIsSimpleDma(XEmac *InstancePtr)*******************************************************************************/#define XEmac_mIsSimpleDma(InstancePtr) \    (((InstancePtr)->ConfigPtr->IpIfDmaConfig == XEM_CFG_SIMPLE_DMA) ? \     XTRUE : XFALSE)/*****************************************************************************//**** This macro determines if the device is currently configured with DMA (either* simple DMA or scatter-gather DMA)** @param InstancePtr is a pointer to the XEmac instance to be worked on.** @return** Boolean XTRUE if the device is configured with DMA, or XFALSE otherwise** @note** Signature: Xboolean XEmac_mIsDma(XEmac *InstancePtr)*******************************************************************************/#define XEmac_mIsDma(InstancePtr) \    ((XEmac_mIsSimpleDma(InstancePtr) || XEmac_mIsSgDma(InstancePtr)) ? \     XTRUE : XFALSE)/*****************************************************************************//**** This macro determines if the device has CAM option for storing additional* receive filters for multicast or unicast addresses.** @param InstancePtr is a pointer to the XEmac instance to be worked on.** @return** Boolean XTRUE if the device is configured with the CAM, or XFALSE otherwise** @note*

⌨️ 快捷键说明

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