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

📄 gei82543end.c

📁 intel 82543 千兆网卡 vxworks驱动源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* gei82543End.c - Intel 82540/82541/82543/82544/82545/82546/ MAC driver */

/*
 * Copyright (c) 2001-2005 Wind River Systems, Inc.
 *
 * The right to copy, distribute, modify or otherwise make use
 * of this software may be licensed only pursuant to the terms
 * of an applicable Wind River license agreement.
 */

/*
modification history
--------------------
02h,03oct05,dlk  Set packet checksum offset for packet-level checksum
                 for all boards, not just PRO1000_546_BOARD (SPR #113209).
02g,13sep05,wap  Workaround for SPR #112130
02f,30aug05,dlk  Changes from code review:
                 - Add missing ntohs() in IPv6 offload excess padding check
         - Update documentation on checksum offload support.
         Also, add section tags, and decrease the default phyMaxDelay
         parameter to 8 seconds (rather than 25).
02e,22aug05,dlk  Reinstate checksum offload support, but IFCAP_RXCSUM,
                 IFCAP_TXCSUM now control both IPv4 and IPv6 checksum offload.
02d,11aug05,dlk  Back out IPv6 checksum offload support changes checked in for
                 archival purposes in previous mod. Keep compiler warning fixes
         and minor clean-up.
02c,10aug05,dlk  Add IPv6 checksum offload support.
02b,05oct04,jln  fix compiling warnings (spr#102310)
02a,27sep04,jln  SPR#101312
01z,31aug04,mdo  Documentation fixes for apigen
01y,24may04,rcs  added compatability with Generic MIB interface
01x,21may04,jln  support Base6 netPoolCreate; update gei82543Unload;
                 optionally explicitly flush/invalidate data cache;
                 fix SPR#96602; Used 10 byte offset.
01w,27may04,dlk  Modify gei82543Recv() not to examine receive descriptor
                 for checksum status after returning receive descriptor to
         the MAC. In gei82543RxSetup(), adjust M_BLK data pointer
         by pDrvCtrl->offset.
01v,08may04,dlk  Modified to use linkBufPool() or netTupleGet().
01u,23apr04,dlk  SPR 96741: Skip over zero-length M_BLK segments in
                 gei82543LoanTransmit(). Apparently the hardware can't handle
         too many of these. Minor optimizations.
01t,19feb04,dlk  Use CSUM_IP_HDRLEN et. al. in gei82543EndSend() and
         gei82543ExtTxContextNew() to enable source-code compatibility
         between Base 6 and Router Stack 1.3.
         Changes from code review.
01s,09feb04,wap  Remove reference to ipHdrLen
01r,02feb04,wap  Add checksum offload support
01q,03dec03,rcs  added include for taskLib.h
01q,10oct03,mcm  Fixed syntax for string spanning multiple lines
01p,15feb03,jln  remove an unnessary cacheInvalidate for RX buffers (spr 86318)
01o,19dec02,jln  fix polling mode misalignment (spr 85241)
                 add PHY's BSP hookup for 82543-copper-based adapter(spr 84779)
01n,05nov02,jln  used cacheable memory for RX data buffer (spr 83679)
                 merge wpaul's RFC2233 poll mode support (spr 84019)
01m,23may02,jln  support 82545/82546 fiber-based adapter(spr 78084)
                 clean interrupts only when packets can be processed
01l,02may02,jln  support 82540/82545/82546 based adapters spr # 76739;
                 stop device only after device has been started spr # 76511
                 change input argument from vector to unit in SYS_INT_ENABLE
                 and SYS_INT_DISABLE macros
01k,22apr02,rcs  changed gei82543MemAllFree() to use free for
                 pDrvCtrl->pTxDesCtlBase SPR# 76130
01j,22apr02,rcs  removed taskDelay() from gei82543EndPollSend() SPR# 76102
01i,14jan02,dat  Removing warnings from Diab compiler
01h,08nov01,jln  coding workaround for TBI compatibility HW bug (spr# 71363),
                 but disable it by default for testing issues.
01g,01sep01,jln  clean up documentation
01f,10aug01,jln  add support for 82544-based adapters spr# 69774; remove
                 copying method for transmitting; add support for jumbo
                 frames spr# 67477
01e,03may01,jln  fix memory leak in gei82543EndStop (spr# 67116);
                 added read operation before exit ISR to flush write buffer
                 for PCI bridge; polish TX/RX handling
01d,01may01,jln  change MACRO(s) GEI_READ_REG, GEI_READ_DESC_WORD, and
                 GEI_READ_DESC_LONG for coding convention
01c,19apr01,jln  clean up for spr#65326
01b,01apr01,jln  clean up after code review (partial spr#65326).
01a,08jan01,jln  created based on templateEnd.c and fei82557End.c END scheme
*/

/*
DESCRIPTION
The gei82543End driver supports Intel PRO1000 T/F/XF/XT/MT/MF adaptors
These adaptors use Intel 82543GC/82544GC/EI/82540/82541/82545/82546EB/ Gigabit
Ethernet controllers.The 8254x are highly integrated, high-performance LAN
controllers for 1000/100/10Mb/s transfer rates. They provide 32/64 bit 33/66Mhz
interfaces to the PCI bus with 32/64 bit addressing and are fully compliant
with PCI bus specification version 2.2. The 82544, 82545 and 82546 also
provide PCI-X interface.

The 8254x controllers implement all IEEE 802.3 receive and transmit
MAC functions. They provide a Ten-Bit Interface (TBI) as specified in the IEEE
802.3z standard for 1000Mb/s full-duplex operation with 1.25 GHz Ethernet
transceivers (SERDES), as well as a GMII interface as specified in
IEEE 802.3ab for 10/100/1000 BASE-T transceivers, and also an MII interface as
specified in IEEE 802.3u for 10/100 BASE-T transceivers.

The 8254x controllers offer auto-negotiation capability for TBI and GMII/MII
modes and also support IEEE 802.3x compliant flow control. This driver
supports the checksum offload features of the 8254x family as follows:

\ts
--- Chip --- | ---- TX offload capabilities ---- | ---- RX offload capabilities
-------------|-----------------------------------|--------------------------
82543        | TCP/IPv4, UDP/IPv4, IPv4          | TCP/IPv4, UDP/IPv4
-------------|-----------------------------------|--------------------------
82544        | TCP/IPv4, UDP/IPv4, IPv4          | TCP/IPv4, UDP/IPv4, IPv4
-------------|-----------------------------------|--------------------------
8254[5601]   | TCP/IPv4, UDP/IPv4, IPv4          | TCP/IPv4, UDP/IPv4, IPv4
             | TCP/IPv6, UDP/IPv6                | TCP/IPv6, UDP/IPv6
\te

For the 82540/82541/82545/82546, the driver supports the transport
checksum over IPv6 on receive via the packet checksum feature. (The RX IPv6
checksum offload apparently does not function on these chips as documented.)
To avoid doing additional work massaging the packet checksum value when the
received packets might not be destined for this target, receive
checksum offload of TCP or UDP over IPv6 is attempted only when the
IPv6 header follows immediately after a 14-byte ethernet header, there
are no IPv6 extension headers, and there is no excess padding after the
end of the IPv6 payload.

Although these devices also support other features such as jumbo
frames, and provide flash support up to 512KB and EEPROM support, this
driver does NOT support these features.

The 8254x establishes a shared memory communication system with the
CPU, which is divided into two parts: the control/status registers and the
receive/transmit descriptors/buffers. The control/status registers
are on the 8254x chips and are only accessible with PCI or PCI-X
memory cycles, whereas the other structures reside on the host. The buffer
size can be programmed between 256 bytes to 16k bytes. This driver uses the
receive buffer size of 2048 bytes for an MTU of 1500.

The Intel PRO/1000 F/XF/MF adapters only implement the TBI mode of the
8254x controller with built-in SERDESs in the adaptors.

The Intel PRO/1000 T adapters based on 82543GC implement the GMII mode with
a Gigabit Ethernet Transceiver (PHY) of MARVELL's Alaska 88E1000/88E1000S.
However, the PRO/1000 XT/MT adapters based on 82540/82544/82545/82546 use
the built-in PHY in controllers.

The driver on the current release supports both GMII mode for Intel
PRO1000T/XT/MT adapters and TBI mode for Intel PRO1000 F/XF/MF adapters.
However, it requires the target-specific initialization code --
sys543BoardInit () -- to distinguish these kinds of adapters by PCI device
IDs.

EXTERNAL INTERFACE
The driver provides the standard external interface, gei82543EndLoad(), which
takes a string of colon separated parameters. The parameter string is parsed
using strtok_r() and each parameter in converted from a string representation
to a binary.

The format of the parameter string is:

 "<memBase>:<memSize>:<nRxDes>:<nTxDes>:<flags>:<offset>:<mtu>"

TARGET-SPECIFIC PARAMETERS

\is
\i <memBase>
This parameter is passed to the driver via gei82543EndLoad().

The 8254x is a DMA-type device and typically shares access to some region of
memory with the CPU. This driver is designed for systems that directly share
memory between the CPU and the 8254x.

This parameter can be used to specify an explicit memory region for use
by the 8254x chip.  This should be done on targets that restrict the 8254x
to a particular memory region.  The constant `NONE' can be used to indicate
that there are such memory, in which case the driver will allocate cache safe
memory for its use using cacheDmaAlloc().

\i <memSize>
The memory size parameter specifies the size of the pre-allocated memory
region. The driver checks the size of the provided memory region is adequate
with respect to the given number of transmit Descriptor and Receive
Descriptor.

\i <nRxDes>
This parameter specifies the number of transmit descriptors to be
allocated. If this number is 0, a default value of 24 will be used.

\i <nTxDes>
This parameter specifies the number of receive descriptors to be
allocated. If this parameter is 0, a default of 24 is used.

\i <flags>
This parameter is provided for user to customize this device driver for their
application.

GEI_END_SET_TIMER (0x01): a timer will be started to constantly free back the
loaned transmit mBlks.

GEI_END_SET_RX_PRIORITY (0x02): packet transfer (receive) from device to host
memory will have higher priority than the packet transfer (transmit) from host
memory to device in the PCI bus. For end-station application, it is suggested
to set this priority in favor of receive operation to avoid receive overrun.
However, for routing applications, it is not necessary to use this priority.
This option is only for 82543-based adapters.

GEI_END_FREE_RESOURCE_DELAY (0x04): when transmitting larger packets, the
driver will hold mblks(s) from the network stack and return them after the
driver has completed transmitting the packet, and either the timer has expired
or there are no more available descriptors. If this option is not used, the
driver will free mblk(s) when ever the packet transmission is done. This option
will place greater demands on the network pool and should only be used in
systems which have sufficient memory to allocate a large network pool. It is
not advised for the memory-limited target systems.

GEI_END_TBI_COMPATIBILITY (0x200): if this driver enables the workaround for
TBI compatibility HW bugs (#define INCLUDE_TBI_COMPATIBLE), user can set
this bit to enable a software workaround for the well-known TBI compatibility
HW bug in the Intel PRO1000 T adapter. This bug is only occurred in the
copper-and-82543-based adapter, and the link partner has advertised only
1000Base-T capability.

GEI_END_USER_MEM_FOR_DESC_ONLY (0x400): User can provide memory for this driver
through the shMemBase and shMemSize in the load string. By default, this memory
is used for TX/RX descriptors and RX buffer. However, if this flag is set, that
memory will be only used for TX/RX descriptors, and the driver will malloc
other memory for RX buffers and maintain cache coherency for RX buffers. It is
user's responsibility to maintain the cache coherence for memory they provided.

GEI_END_FORCE_FLUSH_CACHE: Set this flag to force flushing the data cache for
transmit data buffers even when bus snooping is enabled on the target.

GEI_END_FORCE_INVALIDATE_CACHE: Set this flag to force invalidating the data
cache for receive data buffers even when bus snooping is enabled on the target.

\i <offset>
This parameter is provided for the architectures which need DWORD (4 byte)
alignment of the IP header. In that case, the value of OFFSET should be two,
otherwise, the default value is zero.

\ie


EXTERNAL SUPPORT REQUIREMENTS

This driver requires one external support function:
\cs
STATUS sys82543BoardInit (int unit, ADAPTOR_INFO *pBoard)
\ce
This routine performs some target-specific initialization such as EEPROM
validation and obtaining ETHERNET address and initialization control words
 (ICWs) from EEPROM. The routine also initializes the adaptor-specific data
structure. Some target-specific functions used later in driver operation
are hooked up to that structure. It's strongly recommended that users provide
a delay function with higher timing resolution. This delay function will be
used in the PHY's read/write operations if GMII is used. The driver will use
taskDelay() by default if user can NOT provide any delay function, and
this will probably result in very slow PHY initialization process. The user
should also specify the PHY's type of MII or GMII. This routine returns OK,
or ERROR if it fails.




SYSTEM RESOURCE USAGE
The driver uses cacheDmaMalloc() to allocate memory to share with the 8254xGC.
The size of this area is affected by the configuration parameters specified
in the gei82543EndLoad() 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.

SYSTEM TUNING HINTS

Significant performance gains may be had by tuning the system and network stack.
This may be especially necessary for achieving gigabit transfer rates.

Increasing the network stack's pools are strongly recommended. This driver
borrows mblks from the network stack to accelerate packet transmitting.
Theoretically, the number borrowed clusters could be the same as the number of
the device's transmit descriptors. However, if the network stack has fewer
available clusters than available transmit descriptors then this will result
in reduced throughput. Therefore, increasing the network stack's number of
clusters relative to the number of transmit descriptors will increase bandwidth.
Of course this technique will eventually reach a point of diminishing return.
There are actually several sizes of clusters available in the network pool.
Increasing any or all of these cluster sizes will result in some increase in
performance. However, increasing the 2048-byte cluster size will likely have
the greatest impact since this size will hold an entire MTU and header.

Increasing the number of receive descriptors and clusters may also have
positive impact.

Increasing the buffer size of sockets can also be beneficial. This can
significantly improve performance for a target system under higher transfer
rates. However, it should be noted that large amounts of unread buffers idling
in sockets reduces the resources available to the rest of the stack. This can,
in fact, have a negative impact on bandwidth.  One method to reduce this effect
is to carefully adjust application tasks' priorities and possibly increase
number of receive clusters.

Callback functions defined in the sysGei82543End.c can be used to dynamically
and/or statically change the internal timer registers such as ITR, RADV, and
RDTR to reduce RX interrupt rate.

\INTERNAL
This library contains two conditional compilation switches: DRV_DEBUG and
INCLUDE_GEI82543_DEBUG_ROUTINE. If defined, debug routines will be included.
And output message can be selected by gei82543GCDebug variable.

SEE ALSO: muxLib, endLib
\tb RS-82543GC GIGABIT ETHERNET CONTROLLER NETWORKING DEVELOPER'S MANUAL
*/

/* includes */

#include "gei82543Lib.h"

 END_DEVICE * geiEndDevice[MAX_IF_CARD_NUM+1] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
 int     gei82543GCDebug = 0x0;

#define IF_FIBERCTRL_REG      0x7c30  /*fiber control register*/
#define IF_FIBERDIS_BIT         0x1    /*fiber module enable/disable bit*/
/*extern functions*/
extern void * sysVirtToPhys(void *virtAddr);
extern STATUS b_cintDisable(UINT8 cintnum);
extern STATUS b_cintDisconnect(UINT8 cintNo);
/* forward functions */
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    gei82543TBIlinkForce        (END_DEVICE *,BOOL, BOOL);
LOCAL STATUS    gei82543TBIHwAutoNegotiate  (END_DEVICE *,BOOL, BOOL);
LOCAL void      gei82543McastAdrClean       (END_DEVICE *);
LOCAL UINT32    gei82543DisableChipInt      (END_DEVICE *);
LOCAL void      gei82543EnableChipInt       (END_DEVICE *);
LOCAL void      gei82543Reset               (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      gei82543FiberLinkInt        (END_DEVICE *);*/
LOCAL void      gei82543RxIntHandle       (END_DEVICE *  pDrvCtrl );
LOCAL void      gei82543GMIIphyConfig       (END_DEVICE *);
LOCAL void      gei8254xNowUnload           (END_DEVICE *);

/* END specific interfaces. */
/* This is the only externally visible interface. */
STATUS         gei82543EndStart            (UINT8 slot);
LOCAL STATUS    gei82543EndStop             (END_DEVICE* pDrvCtrl);
LOCAL STATUS    gei82543EndUnload           (END_DEVICE* pDrvCtrl);
LOCAL void  gei82543LinkIntHandle ( END_DEVICE * pDrvCtrl );
LOCAL void gei82543LinkStatusGet(END_DEVICE * pDrvCtrl);
LOCAL void      gei82543AddrFilterSet       (END_DEVICE* pDrvCtrl);
/*LOCAL void gei82543CpldAllIntEnable(int slot);
LOCAL void gei82543CpldAllIntDisable(int slot);*/
LOCAL STATUS gei82543TBIModeSet(UINT8 slot);
LOCAL STATUS    gei82543EndMemInit          (END_DEVICE*);
STATUS gei82543LoopBackMode(UINT32 gPort,int arg);
STATUS gei82543MultiMacSet(UINT32 gPort,char *data);
/*
 * Declare our function table.  This is LOCAL across all driver
 * instances.
 */
/*lint -save -e{64}*/
LOCAL IF_FUNCS gei82543EndFuncTable =
    {
    (FUNCPTR) gei82543EndStart,     /* Function to start the device. */
    (FUNCPTR) gei82543EndStop,      /* Function to stop the device. */
    (FUNCPTR) gei82543EndUnload,    /* Unloading function for the driver. */
    (FUNCPTR) gei82545EndIoctl,     /* Ioctl function for the driver. */

⌨️ 快捷键说明

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