📄 motfcc2end.c
字号:
/* motFcc2End.c - Second Generation Motorola FCC Ethernet network interface.*//* * Copyright (c) 2003-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--------------------01s,18sep06,wap Do both pre and post invalidation of RX buffers (CQ63978)01r,11may06,dgp doc: fix list format in lib01q,28aug05,dlk Add section tags. Fix typo breaking polled mode (SPR#110883). Fix off-by-one error in transmit cleanup-before-coalesce code. Decrease phyMaxDelay from 20 to 5 seconds. Fix errors in disabled INCLUDE_DUMPS code.01p,29aug05,wap Add support for IFF_ALLMULTI (SPR #110201)01o,26jun05,dlk Replace netJobAdd() with jobQueuePost().01n,19mar05,dlk Optimizations. Clean-up. Enable SNOOP through load string.01m,28oct04,dtr SPR 103066.01l,31aug04,mdo Documentation fixes for apigen01k,19aug04,mdo SPR's 99632, 98962, removed windview windview from code - left event defines if needed. Removed Graceful TX/Stop. Added dump routines for debug. 01j,23aug04,rcs fixed SPR 10024501i,23jul04,mdo Base6 Enhancements01p,09jul04,rcs Fixed SPR 88900 motFcc2End driver does not handle netJobAdd() failure01o,09jul04,rcs Fixed SPR 98957 dereference of pDrvCtrl precedes check 01n,09jul04,rcs Added muxError call when netTupleGet fails SPR 8889801m,09jul04,rcs Implemented clean unload SPRs 98962, 98957, 98523, 89166, 78575, 01l,09jul04,rcs Implemented Generic MIB Interface SPRs 96969, 72266, 70728, 73830, 67057, 27788, 20618 01k,09jul04,rcs Implemented netPoolCreate SPR 6705701j,08jul04,rcs Fixed SPR 98818 removed motFccReplenish call from ISR01i,08jul04,rcs Added recommended enhancements SPR 9013501h,15jun04,mdo SPR 9680901g,09jun04,mdo SPR fix 9790901f,04jun04,mil Changed cacheArchXXX funcs to cacheXXX funcs.01e,30mar04,mdo SPR's 81336, 93209, 94561, 94562 and general cleanup.01d,02dec03,rcs fixed warnings for base601c,20aug03,gjc Fixed SPR #90352, fixed compiler warnings and removed logMsg01b,13aug03,gjc Fixed SPRs #89689, #89649, #87812, #87749, #90135, #86434 01a,14jan03,gjc SPR#85164 Second Generation Motorola FCC END Driver.*//*DESCRIPTIONThis module implements a Motorola Fast Communication Controller (FCC)Ethernet network interface driver. This is a second generation driver that isbased on the original motFccEnd.c. It differs from the original ininitialization, performance, features and SPR fixes.The driver "load string" interface differs from its predecessor. A parameterthat contains a pointer to a predefined array of function pointers was addedto the end of the load string. This array replaces multiple individual functionpointers for dual ported RAM allocation, MII access, duplex control, andheartbeat and disconnect functionality; it is described more fully below.The array simplifies updating the driver and BSP code independently.Performance of the driver has been greatly enhanced. A layer of unnecessaryqueuing was removed. Time-critical functions were re-written to be more fluidand efficient. The driver's work load is distributed between the interrupt andthe net job queue. Only one netJobAdd() call is made per interrupt.Multiple events pending are sent as a single net job.A new Generic MIB interface has been implemented.Several SPRs, written against the original motFccEnd driver and previous motFcc2Endversions, are fixed.The FCC supports several communication protocols. This driver supports the FCCoperating in Ethernet mode, which is fully compliant with the IEEE 802.3u10Base-T and 100Base-T specifications.The FCC establishes a shared memory communication system with the CPU,which may be divided into three parts: a set of Control/Status Registers (CSR)and FCC-specific parameters, the buffer descriptors (BD), and the data buffers.Both the CSRs and the internal parameters reside in the MPC8260's internalRAM. They are used for mode control, and to extract status informationof a global nature. For instance, by programming these registers, the drivercan specify which FCC events should generate an interrupt, whetherfeatures like the promiscuous mode or the heartbeat are enabled, and so on.Pointers to both the Transmit Buffer Descriptors ring (TBD) and theReceive Buffer Descriptors ring (RBD) are stored in the internal parameterRAM. The latter also includes protocol-specific parameters, such as theindividual physical address of the station and the maximum receive framelength.The BDs are used to pass data buffers and related buffer informationbetween the hardware and the software. They may reside either on the 60xbus, or on the CPM local bus. They include local status information, and apointer to the receive or transmit data buffers. These buffers are located inexternal memory, and may reside on the 60x bus, or the CPM local bus (seebelow).This driver is designed to be moderately generic. Without modification, it canoperate across all the FCCs in the MPC8260, regardless of where the internalmemory base address is located. To achieve this goal, this driver must begiven several target-specific parameters and some external support routines.These parameters, and the mechanisms used to communicate them to the driver, are detailed below.BOARD LAYOUTThis device is on-board. No jumper diagram is necessary.EXTERNAL INTERFACEThe driver provides the standard external interface, motFccEnd2Load(), whichtakes a string of parameters delineated by colons. The parameters should bespecified in hexadecimal, optionally preceded 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 tostrtoul(parameter, NULL, 16).The format of the parameter string is:"<unit>:<immrVal>:<fccNum>:<bdBase>:<bdSize>:<bufBase>:<bufSize>:<fifoTxBase>:<fifoRxBase> :<tbdNum>:<rbdNum>:<phyAddr>:<phyDefMode>:<phyAnOrderTbl>:<userFlags>:<function table>(:<maxRxFrames>)"TARGET-SPECIFIC PARAMETERS\is\i <unit>This driver is written to support multiple individual device units.This parameter is used to explicitly state which unit is being used.Default is unit 0. \i <immrVal>Indicates the address at which the host processor presents its internalmemory (also known as the internal RAM base address). With this address,and the <fccNum> value (see below), the driver is able to compute thelocation of the FCC parameter RAM, and, ultimately, to program the FCCfor proper operation.\i <fccNum>This driver is written to support multiple individual device units.This parameter is used to explicitly state which FCC is being used.\i <bdBase>The Motorola Fast Communication Controller is a DMA-type device and typicallyshares access to some region of memory with the CPU. This driver is designedfor systems that directly share memory between the CPU and the FCC.This parameter tells the driver that space for both the TBDs and theRBDs need not be allocated, but should be taken from a cache-coherentprivate memory space provided by the user at the given address. TBDs and RBDsare both 8 bytes each, and individual descriptors must be 8-bytealigned. The driver requires that an additional 8 bytes be provided foralignment, even if <bdBase> is aligned to begin with.If this parameter is "NONE", space for buffer descriptors is obtainedby calling cacheDmaMalloc() in motFccInitMem().\i <bdSize>The <bdSize> parameter specifies the size of the pre-allocated memoryregion for the BDs. If <bdBase> is specified as NONE (-1), the driver ignoresthis parameter. Otherwise, the driver checks that the size of the providedmemory region is adequate with respect to the given number of Transmit BufferDescriptors and Receive Buffer Descriptors (plus an additional 8 bytes foralignment).\i <bufBase>This parameter tells the driver that space for data buffersneed not be allocated but should be taken from a cache-coherentprivate memory space provided at the given address. The memory used for buffersmust be 32-byte aligned and non-cacheable. The FCC poses one more constraint, inthat DMA cycles may occur even when all the incoming data have already beentransferred to memory. This means at most 32 bytes of memory at the end ofeach receive data buffer may be overwritten during reception. The driverpads that area out, thus consuming some additional memory.If this parameter is "NONE", space for buffer descriptors is obtainedby calling memalign() in motFccInitMem().\i <bufSize>The <bufSize> parameter specifies the size of the pre-allocated memoryregion for data buffers. If <bufBase> is specified as NONE (-1), the driverignores this parameter. Otherwise, the driver checks that the size of the providedmemory region is adequate with respect to the given number of Receive BufferDescriptors and a non-configurable number of transmit buffers (MOT_FCC_TX_CL_NUM). All the above should fit in the given memory space.This area should also include room for buffer management structures.\i <fifoTxBase>Indicate the base location of the transmit FIFO, in internal memory.The user does not need to initialize this parameter. The defaultvalue (see MOT_FCC_FIFO_TX_BASE) is highly optimized for best performance.However, if the user wishes to reserve that very area in internal RAM forother purposes, this parameter may be set to a different value.If <fifoTxBase> is specified as NONE (-1), the driver uses the defaultvalue.\i <fifoRxBase>Indicate the base location of the receive FIFO, in internal memory.The user does not need to initialize this parameter. The defaultvalue (see MOT_FCC_FIFO_RX_BASE) is highly optimized for best performance.However, if the user wishes to reserve that very area in internal RAM forother purposes, this parameter may be set to a different value.If <fifoRxBase> is specified as NONE (-1), the driver uses the defaultvalue.\i <tbdNum>This parameter specifies the number of transmit buffer descriptors (TBDs).Each buffer descriptor resides in 8 bytes of the processor's externalRAM space. If this parameter is less than a minimum number specified inMOT_FCC_TBD_MIN, or if it is "NULL", a default value of MOT_FCC_TBD_DEF_NUMis used. This parameter should always be an even number since each packet the driver sends may consume more than a single TBD.\i <rbdNum>This parameter specifies the number of receive buffer descriptors (RBDs).Each buffer descriptor resides in 8 bytes of the processor's externalRAM space, and each one points to a buffer in external RAM. If this parameter is less than a minimum number specified in MOT_FCC_RBD_MIN, or if it is "NULL", a default value of MOT_FCC_RBD_DEF_NUM is used. This parameter should always be an even number. \i <phyAddr>This parameter specifies the logical address of a MII-compliant physicaldevice (PHY) that is to be used as a physical media on the network.Valid addresses are in the range 0-31. There may be more than one deviceunder the control of the same management interface. The default physicallayer initialization routine scans the whole range of PHY devicesstarting from the one in <phyAddr>. If this parameter is"MII_PHY_NULL", the default physical layer initialization routine findsout the PHY actual address by scanning the whole range. The one with the lowestaddress is chosen.\i <phyDefMode>This parameter specifies the operating mode that is set upby the default physical layer initialization routine in case allthe attempts made to establish a valid link failed. If that happens,the first PHY that matches the specified abilities is chosen towork in that mode, and the physical link is not tested.\i <phyAnOrderTbl>This parameter may be set to the address of a table that specifies theorder how different subsets of technology abilities, if enabled, should be advertised by the auto-negotiation process. Unless the flag <MOT_FCC_USR_PHY_TBL>is set in the userFlags field of the load string, the driver ignores thisparameter.The user does not normally need to specify this parameter, since the defaultbehaviour enables auto-negotiation process as described in IEEE 802.3u.\i <userFlags>This field enables the user to give some degree of customization to thedriver.MOT_FCC_USR_PHY_NO_AN: The default physical layer initializationroutine exploits the auto-negotiation mechanism as described inthe IEEE Std 802.3u, to bring a valid link up. According to it, allthe link partners on the media take part in the negotiationprocess, and the highest priority common denominator technology abilityis chosen. To prevent auto-negotiation from occurring, set this bit inthe user flags.MOT_FCC_USR_PHY_TBL: In the auto-negotiation process, PHYsadvertise all their technology abilities at the same time,and the result is that the maximum common denominator is used. However,this behaviour may be changed, and the user may affect the order howeach subset of PHY's abilities is negotiated. Hence, when theMOT_FCC_USR_PHY_TBL bit is set, the default physical layerinitialization routine looks at the motFccAnOrderTbl[] table andauto-negotiate a subset of abilities at a time, as suggested by thetable itself. It is worth noticing here, however, that if theMOT_FCC_USR_PHY_NO_AN bit is on, the above table is ignored.MOT_FCC_USR_PHY_NO_FD: The PHY may be set to operate in full duplex mode,provided it has this ability, as a result of the negotiation with otherlink partners. However, in this operating mode, the FCC ignores thecollision detect and carrier sense signals. To prevent negotiating fullduplex mode, set the MOT_FCC_USR_PHY_NO_FD bit in the user flags.MOT_FCC_USR_PHY_NO_HD: The PHY may be set to operate in half duplex mode,provided it has this ability, as a result of the negotiation with other linkpartners. To prevent negotiating half duplex mode, set theMOT_FCC_USR_PHY_NO_HD bit in the user flags.MOT_FCC_USR_PHY_NO_100: The PHY may be set to operate at 100Mbit/s speed,provided it has this ability, as a result of the negotiation withother link partners. To prevent negotiating 100Mbit/s speed,set the MOT_FCC_USR_PHY_NO_100 bit in the user flags.MOT_FCC_USR_PHY_NO_10: The PHY may be set to operate at 10Mbit/s speed,provided it has this ability, as a result of the negotiation withother link partners. To prevent negotiating 10Mbit/s speed,set the MOT_FCC_USR_PHY_NO_10 bit in the user flags.MOT_FCC_USR_PHY_ISO: Some boards may have different PHYs controlled by thesame management interface. In some cases, it may be necessary toelectrically isolate some of them from the interface itself, in orderto guarantee a proper behaviour on the medium layer. If the user wishes toelectrically isolate all PHYs from the MII interface, the MOT_FCC_USR_PHY_ISO bit should be set. The default behaviour is to not isolate any PHY on the board.MOT_FCC_USR_LOOP: When the MOT_FCC_USR_LOOP bit is set, the driverconfigures the FCC to work in internal loopback mode, with the TX signaldirectly connected to the RX. This mode should only be used for testing.MOT_FCC_USR_RMON: When the MOT_FCC_USR_RMON bit is set, the driver configures the FCC to work in RMON mode, thus collecting network statisticsrequired for RMON support without the need to receive all packets as inpromiscuous mode.MOT_FCC_USR_BUF_LBUS: When the MOT_FCC_USR_BUF_LBUS bit is set, the driverconfigures the FCC to work as though the data buffers were located in theCPM local bus.MOT_FCC_USR_BD_LBUS: When the MOT_FCC_USR_BD_LBUS bit is set, the driver configures the FCC to work as though the buffer descriptors were located in theCPM local bus.MOT_FCC_USR_HBC: If the MOT_FCC_USR_HBC bit is set, the driver configures the FCC to perform heartbeat check following end of transmissionand the HB bit in the status field of the TBD is set if the collisioninput does not assert within the heartbeat window. The user does not normallyneed to set this bit.\i <Function>This is a pointer to the structure FCC_END_FUNCS. The structure contains mostlyFUNCPTRs that are used as a communication mechanism between the driver and theBSP. If the pointer contains a NULL value, the driver uses system defaultfunctions for the m82xxDpram DPRAM allocation and, obviously, the driver does not support BSP function calls for heartbeat errors, disconnect errors, andPHY status changes that are hardware specific.\is\cs FUNCPTR miiPhyInit; \ce\i BSP Mii/Phy Init FunctionThis function pointer is initialized by the BSP and called by the driver toinitialize the MII driver. The driver sets up it's PHY settings and thencalls this routine. The BSP is responsible for setting BSP specific PHYparameters and then calling the miiPhyInit. The BSP is responsible to setup any call to an interrupt. See miiPhyInt below.\cs FUNCPTR miiPhyInt; \ce\i Driver Function for BSP to Call on a Phy Status ChangeThis function pointer is initialized by the driver and called by the BSP.The BSP calls this function when it handles a hardware MII specificinterrupt. The driver initializes this to the function motFccPhyLSCInt.The BSP may or may not choose to call this function. It will depend if theBSP supports an interrupt driven PHY. The BSP can also set up the miiLibdriver to poll. In this case the miiPhy driver calls this function. SeemiiLib for details.Note: Not calling this function when the PHY duplex mode changes
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -