Tweaked the driver a bit

This commit is contained in:
MHeinrichs
2018-02-09 00:41:02 +01:00
parent c37eaf21ed
commit 16f86601d9
8 changed files with 146 additions and 141 deletions
+101 -114
View File
@@ -353,109 +353,103 @@ PRIVATE REGARGS BOOL read_frame(struct IOSana2Req *req, struct HWFrame *frame)
LONG datasize;
struct IOSana2Req *got;
ULONG pkttyp = 0; /* just to avoid warning with opt build, irrelevant otherwise */
BOOL rv;
BOOL rv,ok;
struct HWFrame *frame = pb->pb_Frame;
while(hw_recv_pending(pb)){
d8(("+hw_recv\n"));
rv = hw_recv_frame(pb, frame);
d8(("-hw_recv\n"));
if (rv)
{
pb->pb_DevStats.PacketsReceived++;
pkttyp = frame->hwf_Type;
#if 0
/* perform internal loop back of magic packets of type 0xfffd */
if(pkttyp == HW_MAGIC_LOOPBACK) {
d(("loop back packet (size %ld)\n",frame->hwf_Size));
hw_send_frame(pb, frame);
return;
}
/* plipbox requests online magic (again) */
if(pkttyp == HW_MAGIC_ONLINE) {
d(("request online magic"));
hw_send_magic_pkt(pb, HW_MAGIC_ONLINE);
return;
}
#endif
datasize = frame->hwf_Size - HW_ETH_HDR_SIZE;
dotracktype(pb, pkttyp, 0, 1, 0, datasize, 0);
d(("packet %08lx, size %ld received\n",pkttyp,datasize));
ok = FALSE;
ObtainSemaphore(&pb->pb_ReadListSem);
/* traverse the list of read-requests */
for(got = (struct IOSana2Req *)pb->pb_ReadList.lh_Head;
got->ios2_Req.io_Message.mn_Node.ln_Succ;
got = (struct IOSana2Req *)got->ios2_Req.io_Message.mn_Node.ln_Succ )
{
/* check if this one requests for the new packet we got */
if (got->ios2_PacketType == pkttyp )
{
Remove((struct Node*)got);
ok =TRUE;
break;
}
}
ReleaseSemaphore(&pb->pb_ReadListSem);
if(!ok){
/* If no one wanted this packet explicitely, there is one chance
** left: somebody waiting for orphaned packets. If this fails, too,
** we will drop it.
*/
d(("unknown packet\n"));
pb->pb_DevStats.UnknownTypesReceived++;
ObtainSemaphore(&pb->pb_ReadOrphanListSem);
got = (struct IOSana2Req *)RemHead((struct List*)&pb->pb_ReadOrphanList);
ReleaseSemaphore(&pb->pb_ReadOrphanListSem);
if (got)
{
d(("orphan read\n"));
ok=TRUE;
}
}
d8(("+hw_recv\n"));
rv = hw_recv_frame(pb, frame);
d8(("-hw_recv\n"));
if (rv)
{
pb->pb_DevStats.PacketsReceived++;
pkttyp = frame->hwf_Type;
#if 0
/* perform internal loop back of magic packets of type 0xfffd */
if(pkttyp == HW_MAGIC_LOOPBACK) {
d(("loop back packet (size %ld)\n",frame->hwf_Size));
hw_send_frame(pb, frame);
return;
}
/* plipbox requests online magic (again) */
if(pkttyp == HW_MAGIC_ONLINE) {
d(("request online magic"));
hw_send_magic_pkt(pb, HW_MAGIC_ONLINE);
return;
}
#endif
datasize = frame->hwf_Size - HW_ETH_HDR_SIZE;
dotracktype(pb, pkttyp, 0, 1, 0, datasize, 0);
d(("packet %08lx, size %ld received\n",pkttyp,datasize));
ObtainSemaphore(&pb->pb_ReadListSem);
/* traverse the list of read-requests */
for(got = (struct IOSana2Req *)pb->pb_ReadList.lh_Head;
got->ios2_Req.io_Message.mn_Node.ln_Succ;
got = (struct IOSana2Req *)got->ios2_Req.io_Message.mn_Node.ln_Succ )
{
/* check if this one requests for the new packet we got */
if (got->ios2_PacketType == pkttyp )
{
BOOL ok;
Remove((struct Node*)got);
/* deliver packet */
ok = read_frame(got, frame);
if(!ok) {
DoEvent(pb, S2EVENT_ERROR | S2EVENT_BUFF | S2EVENT_SOFTWARE);
}
d(("packet received, satisfying S2Request\n"));
DevTermIO(pb, got);
got = NULL;
break;
}
}
ReleaseSemaphore(&pb->pb_ReadListSem);
}
else
{
d(("Error receiving (%ld. len=%ld)\n", rv, frame->hwf_Size));
/* something went wrong during receipt */
DoEvent(pb, S2EVENT_HARDWARE | S2EVENT_ERROR | S2EVENT_RX);
got = NULL;
pb->pb_DevStats.BadData++;
}
/* If no one wanted this packet explicitely, there is one chance
** left: somebody waiting for orphaned packets. If this fails, too,
** we will drop it.
*/
if (got)
{
d(("unknown packet\n"));
pb->pb_DevStats.UnknownTypesReceived++;
ObtainSemaphore(&pb->pb_ReadOrphanListSem);
got = (struct IOSana2Req *)RemHead((struct List*)&pb->pb_ReadOrphanList);
ReleaseSemaphore(&pb->pb_ReadOrphanListSem);
if (got)
{
BOOL ok = read_frame(got, frame);
if(!ok) {
DoEvent(pb, S2EVENT_ERROR | S2EVENT_BUFF | S2EVENT_SOFTWARE);
}
d(("orphan read\n"));
DevTermIO(pb, got);
}
else
{
dotracktype(pb, pkttyp, 0, 0, 0, 0, 1);
d(("packet thrown away...\n"));
}
}
if(ok){
/* deliver packet */
ok = read_frame(got, frame);
if(!ok) {
DoEvent(pb, S2EVENT_ERROR | S2EVENT_BUFF | S2EVENT_SOFTWARE);
}
d(("packet received, satisfying S2Request\n"));
DevTermIO(pb, got);
}
else{
/* throw it away*/
dotracktype(pb, pkttyp, 0, 0, 0, 0, 1);
d(("packet thrown away...\n"));
}
got = NULL;
}
else
{
d(("Error receiving (%ld. len=%ld)\n", rv, frame->hwf_Size));
/* something went wrong during receipt */
DoEvent(pb, S2EVENT_HARDWARE | S2EVENT_ERROR | S2EVENT_RX);
got = NULL;
pb->pb_DevStats.BadData++;
}
}
}
/*E*/
@@ -725,21 +719,14 @@ PRIVATE REGARGS BOOL read_frame(struct IOSana2Req *req, struct HWFrame *frame)
hw_enable_global_int(pb);
recv = Wait(wmask);
d2(("**> wait: got 0x%08lx\n", recv));
haverec = hw_recv_pending(pb);
}
hw_disable_global_int(pb);
/*allow only a certain number of packets to be serverd per interrupt*/
if(haverec>MAX_READ_PACKAGE)
haverec = MAX_READ_PACKAGE;
/*hw_disable_global_int(pb);*/
/* accept pending receive and start reading */
while( haverec-- )
{
d2(("*+ do_read\n"));
doreadreqs(pb);
d2(("*- do_read\n"));
}
d2(("*+ do_read\n"));
doreadreqs(pb);
d2(("*- do_read\n"));
if( recv & specialmask )
{