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

📄 mottsecend.c

📁 vxworks MPC8541 BSP
💻 C
📖 第 1 页 / 共 5 页
字号:
    This function pointer is initialized by the BSP and call by the driver.    The driver calls this function to obtain the status of the speed    setting in the phy. This interface is hardware specific.\ce\cs    FUNCPTR hbFail; Heart Beat Fail Indicator    This function pointer is initialized by the BSP and call by the driver.    The driver calls this function to indicate an TSEC heart beat error.\ce\cs    FUNCPTR intDisc; Disconnect Function    This function pointer is initialized by the BSP and call by the driver.    The driver calls this function to indicate an TSEC disconnect error.\ce\ieEXTERNAL SUPPORT REQUIREMENTSThis driver requires several external support functions.Note: Function pointers _func_xxxxxxxx were removed and replaced withthe TSEC_END_FUNCS structure located in the load string. This is a majordifference between the old motTsecEnd driver and this one.\is\i sysTsecEnetEnable()\cs    STATUS sysTsecEnetEnable (UINT32 immrVal, UINT8 tsecNum);\ceThis routine is expected to handle any target-specific functions neededto enable the TSEC. These functions typically include setting the Port B and Con the MPC8260 so that the MII interface may be used. This routine isexpected to return OK on success, or ERROR. The driver calls this routine,once per device, from the motTsecStart () routine.\i sysTsecEnetDisable()\cs    STATUS sysTsecEnetDisable (UINT32 immrVal, UINT8 tsecNum);\ceThis routine is expected to perform any target specific functions requiredto disable the MII interface to the TSEC.  This involves restoring thedefault values for all the Port B and C signals. This routine is expected toreturn OK on success, or ERROR. The driver calls this routine from themotTsecStop() routine each time a device is disabled.\i sysTsecEnetAddrGet()\cs    STATUS sysTsecEnetAddrGet (int unit,UCHAR *address);\ceThe driver expects this routine to provide the six-byte Ethernet hardwareaddress that is used by this device.  This routine must copy the six-byteaddress to the space provided by <enetAddr>.  This routine is expected toreturn OK on success, or ERROR.  The driver calls this routine, once perdevice, from the motTsecEndLoad() routine.\cs    STATUS sysTsecMiiBitWr (UINT32 immrVal, UINT8 tsecNum, INT32 bitVal);\ceThis routine is expected to perform any target specific functions requiredto write a single bit value to the MII management interface of a MII-compliantPHY device. The MII management interface is made up of two lines: managementdata clock (MDC) and management data input/output (MDIO). The former providesthe timing reference for transfer of information on the MDIO signal.The latter is used to transfer control and status information between thePHY and the TSEC. For this transfer to be successful, the information itselfhas to be encoded into a frame format, and both the MDIO and MDC signals haveto comply with certain requirements as described in the 802.3u IEEE Standard.There is not built-in support in the TSEC for the MII management interface.This means that the clocking on the MDC line and the framing of the informationon the MDIO signal have to be done in software. Hence, this routine isexpected to write the value in <bitVal> to the MDIO line while properlysourcing the MDC clock to a PHY, for one bit time.\cs    STATUS sysTsecMiiBitRd (UINT32 immrVal, UINT8 tsecNum, INT8 * bitVal);\ceThis routine is expected to perform any target specific functions requiredto read a single bit value from the MII management interface of a MII-compliantPHY device. The MII management interface is made up of two lines: managementdata clock (MDC) and management data input/output (MDIO). The former providesthe timing reference for transfer of information on the MDIO signal.The latter is used to transfer control and status information between thePHY and the TSEC. For this transfer to be successful, the information itselfhas to be encoded into a frame format, and both the MDIO and MDC signals haveto comply with certain requirements as described in the 802.3u IEEE Standard.There is not built-in support in the TSEC for the MII management interface.This means that the clocking on the MDC line and the framing of the informationon the MDIO signal have to be done in software. Hence, this routine isexpected to read the value from the MDIO line in <bitVal>, while properlysourcing the MDC clock to a PHY, for one bit time.\ieSYSTEM RESOURCE USAGEIf the driver allocates the memory for the BDs to share with the TSEC,it does so by calling the cacheDmaMalloc() routine.  For the default caseof 64 transmit buffers and 32 receive buffers, the total size requestedis 776 bytes, and this includes the 8-byte alignment requirement of thedevice.  If a non-cacheable memory region is provided by the user, thesize of this region should be this amount, unless the user has specifieda different number of transmit or receive BDs.This driver can operate only if this memory region is non-cacheableor if the hardware implements bus snooping.  The driver cannot maintaincache coherency for the device because the BDs are asynchronouslymodified by both the driver and the device, and these fields sharethe same cache line.If the driver allocates the memory for the data buffers to share with the TSEC,it does so by calling the memalign () routine.  The driver does not need touse cache-safe memory for data buffers, since the host CPU and the device arenot allowed to modify buffers asynchronously. The related cache linesare flushed or invalidated as appropriate. For the default caseof 7 transmit clusters and 32 receive clusters, the total size requestedfor this memory region is 112751 bytes, and this includes the 32-bytealignment and the 32-byte pad-out area per buffer of the device.  If anon-cacheable memory region is provided by the user, the size of this regionshould be this amount, unless the user has specified a different numberof transmit or receive BDs.TUNING HINTSThe only adjustable parameters are the number of TBDs and RBDs that will becreated at run-time.  These parameters are given to the driver whenmotTsecEndLoad() is called.  There is one RBD associated with each receivedframe whereas a single transmit packet normally uses more than one TBD.  Formemory-limited applications, decreasing the number of RBDs may bedesirable.  Decreasing the number of TBDs below a certain point willprovide substantial performance degradation, and is not recommended. Anadequate number of loaning buffers are also pre-allocated to provide morebuffering before packets are dropped, but this is not configurable.The relative priority of the netTask and of the other tasks in the systemmay heavily affect performance of this driver. Usually the best performanceis achieved when the netTask priority equals that of the otherapplications using the driver.SPECIAL CONSIDERATIONSSEE ALSO: ifLib,\tb MPC8260 Fast Ethernet Controller (Supplement to the MPC860 User's Manual) \tb Motorola MPC860 User's Manual ,INCLUDE FILES:\INTERNALThis driver contains conditional compilation switch MOT_TSEC_DBG.If defined, adds debug output routines.  Output is furtherselectable at run-time via the motTsecEndDbg global variable.*/#include "vxWorks.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 "cacheLib.h"#include "logLib.h"#include "netLib.h"#include "stdio.h"#include "stdlib.h"#include "sysLib.h"#include "taskLib.h"#include "net/systm.h"#include "net/if_subr.h"#undef ETHER_MAP_IP_MULTICAST#include "etherMultiLib.h"#include "end.h"#define    END_MACROS#include "endLib.h"#include "miiLib.h"#include "lstLib.h"#include "semLib.h"#include "sys/times.h"#include "stdarg.h"#include "net/unixLib.h"#include "net/if_subr.h"#include "sysEpic.h"#ifdef WR_IPV6#include "adv_net.h"#endif /* WR_IPV6 */#include "drv/sio/m8260Cp.h"#include "motTsecEnd.h"#include "bspDefs.h"/* defines *//* general macros for reading/writing from/to specified locations *//* Cache and virtual/physical memory related macros */#define MOT_TSEC_CACHE_INVAL(address, len)                              \    CACHE_DRV_INVALIDATE (&pDrvCtrl->bufCacheFuncs, (address), (len));    #define MOT_TSEC_CACHE_FLUSH(address, len)                               \    CACHE_DRV_FLUSH (&pDrvCtrl->bufCacheFuncs, (address), (len)); #ifndef MOT_TSEC_MS_DELAY#define MOT_TSEC_MS_DELAY(x)   \    {                          \    int loop;                  \    loop = (x);                \    while (loop--)             \        sysDelay();            \    }#endif /* MOT_TSEC_MS_DELAY *//* Flag Macros */#define MOT_TSEC_FLAG_CLEAR(clearBits)       \    (pDrvCtrl->flags &= ~(clearBits))#define MOT_TSEC_FLAG_SET(setBits)           \    (pDrvCtrl->flags |= (setBits))#define MOT_TSEC_FLAG_GET()                  \    (pDrvCtrl->flags)#define MOT_TSEC_FLAG_ISSET(setBits)         \    (pDrvCtrl->flags & (setBits))#define MOT_TSEC_USR_FLAG_ISSET(setBits)     \    (pDrvCtrl->userFlags & (setBits))#define END_FLAGS_ISSET(setBits)             \    ((&pDrvCtrl->endObj)->flags & (setBits))#ifdef INCLUDE_RFC_2233#define END_HADDR(pEnd)                                                  \        ((pEnd).pMib2Tbl->m2Data.mibIfTbl.ifPhysAddress.phyAddress)#define END_HADDR_LEN(pEnd)                                              \        ((pEnd).pMib2Tbl->m2Data.mibIfTbl.ifPhysAddress.addrLength)#define END_INC_IN_UCAST(mData, mLen)  \        if (pDrvCtrl->endObj.pMib2Tbl != NULL)      \            {                                       \            pDrvCtrl->endObj.pMib2Tbl->m2PktCountRtn (pDrvCtrl->endObj.pMib2Tbl, \                                    M2_PACKET_IN,           \                                    mData,   \                                    mLen );  \            }#define END_INC_IN_NUCAST(mData, mLen)  \        if (pDrvCtrl->endObj.pMib2Tbl != NULL)      \            {                                       \            pDrvCtrl->endObj.pMib2Tbl->m2PktCountRtn (pDrvCtrl->endObj.pMib2Tbl, \                                    M2_PACKET_IN,           \                                    mData,   \                                    mLen );  \            }#define END_INC_IN_ERRS()  \        if (pDrvCtrl->endObj.pMib2Tbl != NULL)  \            {                                    \            pDrvCtrl->endObj.pMib2Tbl->m2CtrUpdateRtn (pDrvCtrl->endObj.pMib2Tbl, \                                     M2_ctrId_ifInErrors, 1);  \            }#define END_INC_IN_DISCARDS() \         if (pDrvCtrl->endObj.pMib2Tbl != NULL)  \             {                                    \             pDrvCtrl->endObj.pMib2Tbl->m2CtrUpdateRtn (pDrvCtrl->endObj.pMib2Tbl, \                                             M2_ctrId_ifInDiscards, 1);  \             }#define END_INC_IN_OCTETS(mLen)#define END_INC_OUT_UCAST(mData, mLen) \        if (pDrvCtrl->endObj.pMib2Tbl != NULL)  \            {                                    \            pDrvCtrl->endObj.pMib2Tbl->m2PktCountRtn (pDrvCtrl->endObj.pMib2Tbl, \                                    M2_PACKET_OUT,           \                                    mData,   \                                    mLen );  \            }#define END_INC_OUT_NUCAST(mData, mLen) \        if (pDrvCtrl->endObj.pMib2Tbl != NULL)  \            {                                    \            pDrvCtrl->endObj.pMib2Tbl->m2PktCountRtn (pDrvCtrl->endObj.pMib2Tbl, \                                    M2_PACKET_OUT,           \                                    mData,   \                                    mLen );  \            }#define END_INC_OUT_ERRS()                         \        if (pDrvCtrl->endObj.pMib2Tbl != NULL)      \            {                                       \            pDrvCtrl->endObj.pMib2Tbl->m2CtrUpdateRtn (pDrvCtrl->endObj.pMib2Tbl, \                                     M2_ctrId_ifOutErrors, 1);  \            }#define END_INC_OUT_DISCARDS()                      \        if (pDrvCtrl->endObj.pMib2Tbl != NULL)      \            {                                       \            pDrvCtrl->endObj.pMib2Tbl->m2CtrUpdateRtn (pDrvCtrl->endObj.pMib2Tbl, \	    M2_ctrId_ifOutDiscards, 1);  \            }#define END_INC_OUT_OCTETS(mLen)#else#define END_HADDR(pEnd)                                             \        ((pEnd).mib2Tbl.ifPhysAddress.phyAddress)#define END_HADDR_LEN(pEnd)                                         \        ((pEnd).mib2Tbl.ifPhysAddress.addrLength)#ifdef  INCLUDE_RFC_1213_OLD#define END_INC_IN_ERRS()                                              \            END_ERR_ADD(&pDrvCtrl->endObj, MIB2_IN_ERRS, +1)#define END_INC_IN_DISCARDS()                                          \            END_ERR_ADD(&pDrvCtrl->endObj, MIB2_IN_ERRS, +1)#define END_INC_IN_UCAST(mData, mLen)                                  \            END_ERR_ADD(&pDrvCtrl->endObj, MIB2_IN_UCAST, +1)#define END_INC_IN_NUCAST(mData, mLen)                                 \            END_ERR_ADD(&pDrvCtrl->endObj, MIB2_IN_UCAST, +1)#define END_INC_IN_OCTETS(mLen)#define END_INC_OUT_ERRS()                                             \            END_ERR_ADD(&pDrvCtrl->endObj, MIB2_OUT_ERRS, +1)#define END_INC_OUT_DISCARDS()                                         \            END_ERR_ADD(&pDrvCtrl->endObj, MIB2_OUT_ERRS, +1)#define END_INC_OUT_UCAST(mData, mLen)                                 \            END_ERR_ADD(&pDrvCtrl->endObj, MIB2_OUT_UCAST, +1)#define END_INC_OUT_NUCAST(mData, mLen)                                \            END_ERR_ADD(&pDrvCtrl->endObj, MIB2_OUT_UCAST, +1)#define END_INC_OUT_OCTETS(mLen)#else#define END_INC_IN_DISCARDS()           (pDrvCtrl->endObj.mib2Tbl.ifInDiscards++)

⌨️ 快捷键说明

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