📄 mottsecend.c
字号:
#define END_INC_IN_ERRS() (pDrvCtrl->endObj.mib2Tbl.ifInErrors++)#define END_INC_IN_UCAST(mData, mLen) (pDrvCtrl->endObj.mib2Tbl.ifInUcastPkts++)#define END_INC_IN_NUCAST(mData, mLen) (pDrvCtrl->endObj.mib2Tbl.ifInNUcastPkts++)#define END_INC_IN_OCTETS(mLen) (pDrvCtrl->endObj.mib2Tbl.ifInOctets += mLen)#define END_INC_OUT_DISCARDS() (pDrvCtrl->endObj.mib2Tbl.ifOutDiscards++)#define END_INC_OUT_ERRS() (pDrvCtrl->endObj.mib2Tbl.ifOutErrors++)#define END_INC_OUT_UCAST(mData, mLen) (pDrvCtrl->endObj.mib2Tbl.ifOutUcastPkts++)#define END_INC_OUT_NUCAST(mData, mLen) (pDrvCtrl->endObj.mib2Tbl.ifOutNUcastPkts++)#define END_INC_OUT_OCTETS(mLen) (pDrvCtrl->endObj.mib2Tbl.ifOutOctets += mLen)#endif#endif /* INCLUDE_RFC_2233 *//* locals *//* Function declarations not in any header files *//* forward function declarations */LOCAL STATUS motTsecInitParse (TSEC_DRV_CTRL * pDrvCtrl, char *initString);LOCAL STATUS motTsecFuncInit (TSEC_DRV_CTRL *);LOCAL STATUS motTsecParmInit (TSEC_DRV_CTRL *);LOCAL STATUS motTsecPhyParmInit (TSEC_DRV_CTRL * pDrvCtrl);LOCAL STATUS motTsecInitMem (TSEC_DRV_CTRL *pDrvCtrl);LOCAL STATUS motTsecRbdInit (TSEC_DRV_CTRL * pDrvCtrl);LOCAL STATUS motTsecTbdInit (TSEC_DRV_CTRL * pDrvCtrl);LOCAL STATUS motTsecPhyPreInit (TSEC_DRV_CTRL * pDrvCtrl);LOCAL STATUS motTsecSend (TSEC_DRV_CTRL *pDrvCtrl, M_BLK *pMblk);LOCAL void motTsecRestart (TSEC_DRV_CTRL *pDrvCtrl);LOCAL void motTsecGracefulStop (TSEC_DRV_CTRL *pDrvCtrl);LOCAL STATUS motTsecHashTblPopulate (TSEC_DRV_CTRL * pDrvCtrl);LOCAL int motTsecTbdClean (TSEC_DRV_CTRL * pDrvCtrl);LOCAL void motTsecHandleRXFrames(TSEC_DRV_CTRL *pDrvCtrl);LOCAL STATUS motTsecMiiPhyRead (TSEC_DRV_CTRL * pDrvCtrl, UINT8 phyAddr, UINT8 regAddr, UINT16 *retVal);LOCAL STATUS motTsecMiiPhyWrite (TSEC_DRV_CTRL * pDrvCtrl, UINT8 phyAddr, UINT8 regAddr, UINT16 writeData);LOCAL STATUS motTsecAddrSet (TSEC_DRV_CTRL * pDrvCtrl, char * pAddr);LOCAL void motTsecPhyLSCInt (TSEC_DRV_CTRL *pDrvCtrl );LOCAL STATUS motTsecPktTransmit (TSEC_DRV_CTRL *, M_BLK *, int );LOCAL void motTsecHandleLSCJob (TSEC_DRV_CTRL *, UINT32);LOCAL void motTsecTxInt (TSEC_DRV_CTRL * pDrvCtrl);LOCAL void motTsecRxInt (TSEC_DRV_CTRL * pDrvCtrl);/* END Specific interfaces. */END_OBJ * motTsecEndLoad (char *initString);STATUS motTsecStart (TSEC_DRV_CTRL * pDrvCtrl);LOCAL STATUS motTsecUnload (TSEC_DRV_CTRL * pDrvCtrl);LOCAL STATUS motTsecStop (TSEC_DRV_CTRL * pDrvCtrl);LOCAL STATUS motTsecIoctl (void * pCookie, int cmd, caddr_t data);LOCAL STATUS motTsecMCastAddrAdd (TSEC_DRV_CTRL * pDrvCtrl, UCHAR * pAddress);LOCAL STATUS motTsecMCastAddrDel (TSEC_DRV_CTRL * pDrvCtrl, UCHAR * pAddress);LOCAL STATUS motTsecMCastAddrGet (TSEC_DRV_CTRL * pDrvCtrl, MULTI_TABLE *pTable);LOCAL STATUS motTsecPollSend (TSEC_DRV_CTRL * pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS motTsecPollReceive (TSEC_DRV_CTRL * pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS motTsecPollStart (TSEC_DRV_CTRL * pDrvCtrl);LOCAL STATUS motTsecPollStop (TSEC_DRV_CTRL * pDrvCtrl);/* globals */IMPORT POOL_FUNC * _pEndNetPoolFuncTbl;IMPORT FUNCPTR ffsMsb; #ifdef MOT_TSEC_DBGvoid motTsecMiiShow (int, int, int);void motTsecMibShow (int);void motTsecRegsShow (int);#define MOT_TSEC_DBG_OFF 0x0000#define MOT_TSEC_DBG_RX 0x0001#define MOT_TSEC_DBG_TX 0x0002#define MOT_TSEC_DBG_POLL 0x0004#define MOT_TSEC_DBG_MII 0x0008#define MOT_TSEC_DBG_LOAD 0x0010#define MOT_TSEC_DBG_IOCTL 0x0020#define MOT_TSEC_DBG_INT 0x0040#define MOT_TSEC_DBG_START 0x0080#define MOT_TSEC_DBG_INT_RX_ERR 0x0100#define MOT_TSEC_DBG_INT_TX_ERR 0x0200#define MOT_TSEC_DBG_RX_ERR 0x0400#define MOT_TSEC_DBG_TX_ERR 0x0800#define MOT_TSEC_DBG_TRACE 0x1000#define MOT_TSEC_DBG_TRACE_RX 0x2000#define MOT_TSEC_DBG_TRACE_TX 0x4000#define MOT_TSEC_DBG_MONITOR 0x8000#define MOT_TSEC_DBG_ANY 0xffff#define MOT_TSEC_DBG_REG 0x10000#define MOT_TSEC_LOG(FLG, X0, X1, X2, X3, X4, X5, X6) \ { \ if (motTsecEndDbg & FLG) \ logMsg (X0, X1, X2, X3, X4, X5, X6); \ }#define MOT_TSEC_STAT_INCR(i) (i++)FUNCPTR _func_netJobAdd;FUNCPTR _func_txRestart;FUNCPTR _func_error;/* global debug level flag */UINT32 motTsecEndDbg = (MOT_TSEC_DBG_REG); TSEC_DRV_CTRL * pTsecDrvCtrlDbg[MOT_TSEC_MAX_DEVS];#else /* MOT_TSEC_DBG */#define MOT_TSEC_LOG(FLG, X0, X1, X2, X3, X4, X5, X6)#define MOT_TSEC_STAT_INCR(i)#endif#ifdef MOT_TSEC_DBGLOCAL const char *speedStr[4] = {"NA","10","100","1GIG"};LOCAL const char *duplexStr[3] = {"NA","Half","Full"};LOCAL const char *linkStr[2] = {"Down","Up"};#endif/* LOCAL const char *pErrorStr = "No Clusters"; */LOCAL const char *pIfDescrStr = "Motorola TSEC";/* * Define the device function table. This is static across all driver * instances. */LOCAL NET_FUNCS netTsecFuncs = { (FUNCPTR) motTsecStart, /* start func. */ (FUNCPTR) motTsecStop, /* stop func. */ (FUNCPTR) motTsecUnload, /* unload func. */ (FUNCPTR) motTsecIoctl, /* ioctl func. */ (FUNCPTR) motTsecSend, /* send func. */ (FUNCPTR) motTsecMCastAddrAdd, /* multicast add func. */ (FUNCPTR) motTsecMCastAddrDel, /* multicast delete func. */ (FUNCPTR) motTsecMCastAddrGet, /* multicast get fun. */ (FUNCPTR) motTsecPollSend, /* polling send func. */ (FUNCPTR) motTsecPollReceive, /* polling receive func. */ endEtherAddressForm, /* put address info into a NET_BUFFER */ (FUNCPTR) endEtherPacketDataGet, /* get pointer to data in NET_BUFFER */ (FUNCPTR) endEtherPacketAddrGet /* Get packet addresses */ };/********************************************************************************* motTsecEndLoad - initialize the driver and device** This routine initializes both driver and device to an operational state* using device specific parameters specified by <initString>.** The parameter string, <initString>, is an ordered list of parameters each* separated by a colon. The format of <initString> is:** "<CCSVal>:<ivec>:<bufBase>:<bufSize>:<fifoTxBase>:<fifoRxBase>* :<tbdNum>:<rbdNum>:<phyAddr>:<phyDefMode>:<pAnOrderTbl>:<userFlags>* ** The TSEC shares a region of memory with the driver. The caller of this* routine can specify the address of this memory region, or can specify that* the driver must obtain this memory region from the system resources.** A default number of transmit/receive buffer descriptors of 32 can be* selected by passing zero in the parameters <tbdNum> and <rbdNum>.* In other cases, the number of buffers selected should be greater than two.** The <bufBase> parameter is used to inform the driver about the shared* memory region. If this parameter is set to the constant "NONE," then this* routine will attempt to allocate the shared memory from the system. Any* other value for this parameter is interpreted by this routine as the address* of the shared memory region to be used. The <bufSize> parameter is used* to check that this region is large enough with respect to the provided* values of both transmit/receive buffer descriptors.** If the caller provides the shared memory region, then the driver assumes* that this region does not require cache coherency operations, nor does it* require conversions between virtual and physical addresses.** If the caller indicates that this routine must allocate the shared memory* region, then this routine will use cacheDmaMalloc() to obtain* some cache-safe memory. The attributes of this memory will be checked,* and if the memory is not write coherent, this routine will abort and* return NULL.** RETURNS: an END object pointer, or NULL on error.** ERRNO** SEE ALSO: ifLib,* \tb MPC8260 Power QUICC II User's Manual */END_OBJ* motTsecEndLoad ( char *initString ) { TSEC_DRV_CTRL * pDrvCtrl = NULL; /* pointer to TSEC_DRV_CTRL structure */ if (initString == NULL) return NULL; if (initString[0] == 0) { bcopy ((char *)MOT_TSEC_DEV_NAME, (void *)initString, MOT_TSEC_DEV_NAME_LEN); return NULL; } /* allocate the device structure */ pDrvCtrl = (TSEC_DRV_CTRL *) calloc (sizeof (TSEC_DRV_CTRL), 1); if (pDrvCtrl == NULL) return NULL; /* get memory for the phyInfo structure */ pDrvCtrl->phyInfo = calloc (sizeof (PHY_INFO), 1); if (pDrvCtrl->phyInfo == NULL) return NULL; /* set up function pointers */ pDrvCtrl->netJobAdd = (FUNCPTR) netJobAdd; pDrvCtrl->muxTxRestart = (FUNCPTR) muxTxRestart; pDrvCtrl->muxError = (FUNCPTR) muxError; /* Parse InitString */ if (motTsecInitParse (pDrvCtrl, initString) == ERROR) goto errorExit; /* sanity check the unit number */ if (pDrvCtrl->unit >= MOT_TSEC_MAX_DEVS ) goto errorExit; pDrvCtrl->tsecMiiPtr = (TSEC_REG_T *)((UINT32) pDrvCtrl->tsecRegsPtr + (UINT32) MOT_TSEC_ADRS_OFFSET_1); /* adjust the CCSBAR */ if (pDrvCtrl->tsecNum == MOT_TSEC_DEV_1) pDrvCtrl->tsecRegsPtr = (TSEC_REG_T *)((UINT32) pDrvCtrl->tsecRegsPtr + (UINT32) MOT_TSEC_ADRS_OFFSET_1); else if (pDrvCtrl->tsecNum == MOT_TSEC_DEV_2) pDrvCtrl->tsecRegsPtr = (TSEC_REG_T *)((UINT32) pDrvCtrl->tsecRegsPtr + (UINT32) MOT_TSEC_ADRS_OFFSET_2); else return (NULL);#ifdef MOT_TSEC_DBG pTsecDrvCtrlDbg[pDrvCtrl->tsecNum] = pDrvCtrl; /* support unit test */ _func_netJobAdd = (FUNCPTR) netJobAdd; _func_txRestart = (FUNCPTR) muxTxRestart; _func_error = (FUNCPTR) muxError;#endif /* MOT_TSEC_DBG */ /* Init BSP function and driver callbacks */ if (motTsecFuncInit (pDrvCtrl) == ERROR) goto errorExit; /* Init PHY parameters */ if (motTsecPhyParmInit (pDrvCtrl) == ERROR) goto errorExit; /* set the MAC address in the mib interface */ bcopy ((char *) pDrvCtrl->enetAddr.ether_addr_octet, (char *) END_HADDR(pDrvCtrl->endObj), END_HADDR_LEN (pDrvCtrl->endObj) ); /* memory initialization */ if (motTsecInitMem (pDrvCtrl) == ERROR) goto errorExit; /* Init TSEC hardware parameters */ if (motTsecParmInit (pDrvCtrl) == ERROR) goto errorExit; /* endObj initializations */ if (END_OBJ_INIT (&pDrvCtrl->endObj, (DEV_OBJ*) pDrvCtrl, MOT_TSEC_DEV_NAME, pDrvCtrl->unit, &netTsecFuncs, (char *) pIfDescrStr) == ERROR) goto errorExit;#ifdef INCLUDE_RFC_2233 /* Initialize MIB-II entries (for RFC 2233 ifXTable) */ pDrvCtrl->endObj.pMib2Tbl = m2IfAlloc(M2_ifType_ethernet_csmacd, (UINT8*) pDrvCtrl->enetAddr.ether_addr_octet, 6, ETHERMTU, pDrvCtrl->phyInfo->phySpeed, MOT_TSEC_DEV_NAME, pDrvCtrl->unit); if (pDrvCtrl->endObj.pMib2Tbl == NULL) { logMsg ("%s%d - MIB-II initializations failed\n", (int)MOT_TSEC_DEV_NAME, pDrvCtrl->unit,0,0,0,0); goto errorExit; } /* * Set the RFC2233 flag bit in the END object flags field and * install the counter update routines. */ m2IfPktCountRtnInstall(pDrvCtrl->endObj.pMib2Tbl, m2If8023PacketCount); /* * Make a copy of the data in mib2Tbl struct as well. We do this * mainly for backward compatibility issues. There might be some * code that might be referencing the END pointer and might * possibly do lookups on the mib2Tbl, which will cause all sorts * of problems. */ bcopy ((char *)&pDrvCtrl->endObj.pMib2Tbl->m2Data.mibIfTbl, (char *)&pDrvCtrl->endObj.mib2Tbl, sizeof (M2_INTERFACETBL)); /* Mark the device ready */ END_OBJ_READY (&pDrvCtrl->endObj, IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST | END_MIB_2233);#else /* Old RFC 1213 mib2 interface */ if (END_MIB_INIT (&pDrvCtrl->endObj, M2_ifType_ethernet_csmacd, (u_char *) &pDrvCtrl->enetAddr.ether_addr_octet[0], 6, ETHERMTU, pDrvCtrl->phyInfo->phySpeed) == ERROR) goto errorExit; /* Mark the device ready */ END_OBJ_READY (&pDrvCtrl->endObj, IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -