📄 rtlcpp.c
字号:
if ( ((tempcmd_leng) & 0x80000000)!=0)
{
DRV_LOG (DRV_DEBUG_TX, "TX int exit %x\n",pDrvCtrl->tmdIndexC , 0, 0, 0, 0, 0);
break;
}
oldLevel = intLock();
netClFree (pDrvCtrl->end.pNetPool,pDrvCtrl->freeData[pDrvCtrl->tmdIndexC]);
intUnlock(oldLevel);
#ifdef DRV_TEST_8139
g_FreeClusterNum++; /* add by zoutl for test 2003-3-25 16:47 */
#endif
/* add by zoutl 2003-3-19 14:44 */
/* soon notify upper protocols BDs are available */
/*
if (pDrvCtrl->txBlocked)
{
DRV_LOG (DRV_DEBUG_zou, "muxTxRestart\n" ,0,0, 0, 0, 0, 0);
(void) netJobAdd ((FUNCPTR) muxTxRestart,
(int) &pDrvCtrl->end,
0, 0, 0, 0);
pDrvCtrl->txBlocked = FALSE ;
}
*/
/* added by ft to solve tx suspend prolem */
if (first)
{
if (pDrvCtrl->txBlocked)
{
DRV_LOG (DRV_DEBUG_ALL, ("rtl8139 %d Restart mux \n"), pDrvCtrl->unit, 0, 0, 0, 0, 0);
(void) netJobAdd ((FUNCPTR) muxTxRestart, (int) &pDrvCtrl->end, 0, 0, 0, 0);
pDrvCtrl->txBlocked = FALSE;
}
first = FALSE;
}
/******************* end ***********************************/
/* add by zoutl 2003-3-19 14:44 */
/* now bump the tmd disposal index pointer around the ring */
pDrvCtrl->tmdIndexC = (pDrvCtrl->tmdIndexC + 1) & (pDrvCtrl->tringSize - 1);
DRV_LOG (DRV_DEBUG_TX, "TX int free one %x ,pDrvCtrl->tringSize = %d\n",pDrvCtrl->tmdIndexC , pDrvCtrl->tringSize, 0, 0, 0, 0);/* added by mashuyu */
}
}
#endif
/*******************************************************************************
*
* rtl81x9HandleRecvInt - task level interrupt service for input packets
*
* This routine is called by the interrupt service routine to do any
* message received processing.
*
* RETURNS: N/A.
*/
#ifdef DRV_TEST_8139
extern unsigned int g_DriverRecvPkt; /* add by zoutl for test 2003-4-10 8:58 */
unsigned int g_8139RecvPacketNum1; /* add by zoutl for test 2003-4-10 8:58 */
extern unsigned int g_MuxRecvPkt; /* add by zoutl for test 2003-4-10 8:58 */
#endif
LOCAL void rtl81x9HandleRecvInt
(
RTL81X9END_DEVICE *pDrvCtrl
)
{
int len;/*, wrapSize; */
M_BLK_ID pMblk;
CL_BLK_ID pClBlk;
/*RTL_RX_DATA *rxData;*/
char *pNewCluster;
char *pCluster;
char *pTemp;
RTL_RMD *pRmd = (RTL_RMD *)NULL;
UINT32 tempcmd_leng;
int ii;
#ifdef DRV_TEST_8139
int iii; /* add by zoutl for test 2003-3-15 9:24 */
#endif
/* Disable interrupts by clearing the interrupt mask. */
/*logMsg("Receive int \n", 0, 0, 0, 0, 0, 0); */ /************kongfq*********/
pDrvCtrl->proc_rx=0;
/*pRmd = pDrvCtrl->pRring + pDrvCtrl->rmdIndex;*/
pRmd = ( RTL_RMD *)(pDrvCtrl->ptrRxBufSpace + 16*pDrvCtrl->rmdIndex); /* modified by zoutl 2003/2/21 */
RTL_CACHE_INVALIDATE (pRmd, 16); /* add by zoutl 2003-3-17 16:02 */
DRV_LOG (DRV_DEBUG_RX, "pRmd->cmd_leng is 0x%x, rmdIndex:%d\n", pRmd->cmd_leng,pDrvCtrl->rmdIndex, 0, 0, 0, 0); /* added by mashuyu */
do{
tempcmd_leng=PCI_SWAP (pRmd->cmd_leng);/* added by mashuyu */
if( (tempcmd_leng & 0x80000000)!=0)
{
/* DRV_LOG (DRV_DEBUG_ERR, "Get Nothing \n",0, 0, 0, 0, 0, 0); */ /* delete by zoutl 2003-3-17 8:41 */
break;
}
/* add by zoutl for Net test 2003-6-7 10:13 */
#ifdef DRV_TEST_8139
if((pDrvCtrl->unit == g_ucTestNetUnit)
&& (strncmp(g_cTestNetName, "rtl", 3) == 0))
{
g_DriverRecvPkt++;
}
#endif
/* if( (tempcmd_leng & 0x00080000)!=0) */
if( (tempcmd_leng & 0x00100000)!=0)
{
DRV_LOG (DRV_DEBUG_ERR, "Rx Get Error,tempcmd_len:0x%8x \n",tempcmd_leng, 0, 0, 0, 0, 0);
/* break; */
goto cleanRXD1; /* modified by fengtao */
}
#ifdef DRV_TEST_8139
if(pDrvCtrl->unit == g_ucTestNetUnit)
{
g_8139RecvPacketNum1++; /* add by zoutl for test 2003-4-10 8:58 */
}
#endif
/* rtl81x9CsrWriteWord (pDrvCtrl, RTL_REGS_INTR_STATUS, RTL_IPT_RX_OK, NONE); */
pNewCluster = netClusterGet (pDrvCtrl->end.pNetPool,
pDrvCtrl->pClPoolId);
if (pNewCluster == NULL)
{
DRV_LOG (DRV_DEBUG_ERR, "Cannot loan!\n", 1, 2, 3, 4, 5, 6);
goto cleanRXD1;
}
if ((pClBlk = netClBlkGet (pDrvCtrl->end.pNetPool, M_DONTWAIT)) == NULL)
{
netClFree (pDrvCtrl->end.pNetPool, pNewCluster);
DRV_LOG (DRV_DEBUG_ERR, "Out of Cluster Blocks!\n", 1, 2, 3, 4, 5, 6);
END_ERR_ADD (&pDrvCtrl->end, MIB2_IN_ERRS, +1);
goto cleanRXD1;
}
/*
* OK we've got a spare, let's get an M_BLK_ID and marry it to the
* one in the ring.
*/
if ((pMblk = mBlkGet(pDrvCtrl->end.pNetPool, M_DONTWAIT, MT_DATA))== NULL)
{
netClBlkFree (pDrvCtrl->end.pNetPool, pClBlk);
netClFree (pDrvCtrl->end.pNetPool, pNewCluster);
DRV_LOG (DRV_DEBUG_ERR, "Out of M Blocks!\n", 1, 2, 3, 4, 5, 6);
END_ERR_ADD (&pDrvCtrl->end, MIB2_IN_ERRS, +1);
goto cleanRXD1;
}
END_ERR_ADD (&pDrvCtrl->end, MIB2_IN_UCAST, +1);
len = 0x1fff & tempcmd_leng/*pRmd->cmd_leng*/; /* get packet length */ /* modified by mashuyu */
len-=4; /*remove crc */
/*DRV_LOG (DRV_DEBUG_ALL, "len=%x\n", len, 0, 0, 0, 0, 0); *//* added by mashuyu */
RTL_RMD_TO_ADDR (pRmd, pCluster); /* Get pointer to packet */
pCluster -= pDrvCtrl->offset;
/* Join the cluster to the MBlock */
netClBlkJoin (pClBlk, pCluster, len, NULL, 0, 0, 0);
netMblkClJoin (pMblk, pClBlk);
/* make the packet data coherent */
RTL_CACHE_INVALIDATE (pMblk->mBlkHdr.mData, len);
pMblk->mBlkHdr.mData += pDrvCtrl->offset;
pMblk->mBlkHdr.mLen = len;
pMblk->mBlkHdr.mFlags |= M_PKTHDR;
pMblk->mBlkPktHdr.len = len;
/* add by zoutl for test 2003-3-15 9:24 */
#ifdef DRV_TEST_8139
if(pDrvCtrl->unit == g_ucTestNetUnit)
{
if(g_iPrintPackt)
{
printf("\nreceive-----------------------------\n");
printf("receive len is 0x%x\n",len);
for(iii=0;iii<14;iii++)
{
if(iii%16==0&&iii!=0)
printf("\n");
printf("%02x ",(int)*(pMblk->mBlkHdr.mData+iii));
}
}
}
#endif
/* add by zoutl for test 2003-3-15 9:24 */
DRV_LOG (DRV_DEBUG_RX, "Calling upper layer!\n", 1, 2, 3, 4, 5, 6);/* added by mashuyu */
/* Deal with memory alignment. */
pNewCluster += pDrvCtrl->offset;
/*****kongfq20005.8.31 for test 正常模式下需删去**************/
#if 0
logMsg("len= %d \n",len,0,0,0,0,0);
logMsg("%x %x %x %x %x %x \n ",pCluster[0],pCluster[1],pCluster[2],
pCluster[3],pCluster[4],pCluster[5]);
#endif
/*********************/
/* add by liuliping 2005-6-22 ,modified by kongfanqiang*/
if(FTreceivefunc != NULL)
{
if (1 == (*FTreceivefunc)(pCluster,(USHORT)len));/*pNewCluster,(USHORT)len))*/
len = len;
}
/* Give receiver a new buffer */
RTL_RMD_BUF_TO_ADDR (pRmd, pTemp, pNewCluster);
/* Call the upper layer's receive routine. */
END_RCV_RTN_CALL(&pDrvCtrl->end, pMblk);
/* add by zoutl for Net test 2003-6-7 10:13 */
#ifdef DRV_TEST_8139
if((pDrvCtrl->unit == g_ucTestNetUnit)
&& (strncmp(g_cTestNetName, "rtl", 3) == 0))
{
g_MuxRecvPkt++;
}
#endif
cleanRXD1:
/* LN_CLEAN_RXD (pRmd); */
if(pDrvCtrl->rmdIndex == (pDrvCtrl->rringSize-1) )
tempcmd_leng=RTLCP_RX_OWN| RTLCP_RX_EOR|RTLCP_RX_EMS|RTL81x9_BUFSIZE;
else
tempcmd_leng=RTLCP_RX_OWN|RTLCP_RX_EMS|RTL81x9_BUFSIZE;
pRmd->cmd_leng=PCI_SWAP (tempcmd_leng);/* added by mashuyu */
/* Flush the write pipe */
/* CACHE_PIPE_FLUSH (); */
/* Advance our management index */
pDrvCtrl->rmdIndex = (pDrvCtrl->rmdIndex + 1) & (pDrvCtrl->rringSize - 1);
/* DRV_LOG (DRV_DEBUG_RX, "Index=%x\n", pDrvCtrl->rmdIndex, 0, 0, 0, 0, 0); */
pRmd = ( RTL_RMD *)(pDrvCtrl->ptrRxBufSpace + 16*pDrvCtrl->rmdIndex); /* modified by zoutl 2003/2/21 */
/*DRV_LOG (DRV_DEBUG_ERR, "now %x ,%x ,%x\n", pRmd->cmd_leng, pRmd->bufptr0, (int)pRmd, 0, 0, 0); */ /* modified by zoutl 2003/2/21 */
RTL_CACHE_INVALIDATE (pRmd, 16); /* add by zoutl 2003-3-17 16:02 */
tempcmd_leng=PCI_SWAP (pRmd->cmd_leng);/* added by mashuyu */
/* if( (tempcmd_leng& 0x80000000)==0x00000000 )
PCI_SWAP (pRmd->cmd_leng); */
}while( (tempcmd_leng & 0x80000000)==0x00000000); /* modified by mashuyu */
/* DRV_LOG (DRV_DEBUG_RX, "Receive int end\n", 0, 0, 0, 0, 0, 0); */
}
/*******************************************************************************
*
* rtl81x9Ioctl - interface ioctl procedure
*
* Process an interface ioctl request.
*
* This routine implements the network interface control functions.
* It handles EIOCSADDR, EIOCGADDR, EIOCSFLAGS, EIOCGFLAGS, EIOCMULTIADD,
* EIOCMULTIDRTL, EIOCMULTIGET, EIOCPOLLSTART, EIOCPOLLSTOP, EIOCGMIB2 commands.
*
* RETURNS: OK if successful, otherwise EINVAL.
*/
LOCAL int rtl81x9Ioctl
(
RTL81X9END_DEVICE * pDrvCtrl,
int cmd,
caddr_t data
)
{
int error = 0;
long value;
char macaddress[8]={0};
long *macadd1;
long *macadd2;
switch (cmd)
{
case EIOCSADDR:
if (data == NULL)
return (EINVAL);
bcopy ((char *)data, (char *)END_HADDR(&pDrvCtrl->end),
END_HADDR_LEN(&pDrvCtrl->end));
/********************************added by mashuyu***************************************************************/
bcopy ((char *) END_HADDR (&pDrvCtrl->end),
(char *) (macaddress),
END_HADDR_LEN (&pDrvCtrl->end));
macaddress[6]=0;
macaddress[7]=0;
macadd1=(long *)(&macaddress[0]); /* modified by zoutl 2003/2/21 */
macadd2=(long *)(&macaddress[4]); /* modified by zoutl 2003/2/21 */
*macadd1=PCI_SWAP(*macadd1);
*macadd2=PCI_SWAP(*macadd2);
rtl81x9CsrWriteByte (pDrvCtrl, RTL_REGS_CFG_9346, RTL_EEMODE_WRITECFG, RTL_WIN_0);
rtl81x9CsrWriteLong(pDrvCtrl, RTL_REGS_IDR0, *macadd1, RTL_WIN_0);
rtl81x9CsrWriteLong(pDrvCtrl, RTL_REGS_IDR4, *macadd2, RTL_WIN_0);
rtl81x9CsrWriteByte (pDrvCtrl, RTL_REGS_CFG_9346, RTL_EEMODE_OFF, RTL_WIN_0);
/**************************************added by mashuyu***********************************************************/
break;
case EIOCGADDR:
if (data == NULL)
return (EINVAL);
bcopy ((char *)END_HADDR(&pDrvCtrl->end), (char *)data,
END_HADDR_LEN(&pDrvCtrl->end));
break;
case EIOCSFLAGS:
value = (long)data;
if (value < 0)
{
value = -value;
value--; /* HRTLP: WHY ??? */
END_FLAGS_CLR (&pDrvCtrl->end, value);
}
else
{
END_FLAGS_SET (&pDrvCtrl->end, value);
}
rtl81x9Config (pDrvCtrl);
break;
case EIOCGFLAGS:
*(int *)data = END_FLAGS_GET(&pDrvCtrl->end);
break;
case EIOCPOLLSTART:
error = rtl81x9PollStart (pDrvCtrl);
break;
case EIOCPOLLSTOP:
error = rtl81x9PollStop (pDrvCtrl);
break;
case EIOCGMIB2:
if (data == NULL)
return (EINVAL);
bcopy((char *)&pDrvCtrl->end.mib2Tbl, (char *)data,
sizeof(pDrvCtrl->end.mib2Tbl));
break;
case EIOCGFBUF:
if (data == NULL)
return (EINVAL);
*(int *)data = RTL_MIN_FBUF;
break;
case EIOCGMWIDTH:
if (data == NULL)
return (EINVAL);
*(int *)data = pDrvCtrl->memWidth;
break;
case EIOCGHDRLEN:
if (data == NULL)
return (EINVAL);
*(int *)data = 14;
break;
default:
error = EINVAL;
}
return (error);
}
/*******************************************************************************
*
* rtl81x9Wait - wait for the command complet
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -