In theory the driver should now work. though I'm not really buying it yet, I

think that it shouldn't drop any packets anymore (only delay them)
- I implemented a packet wrap, so after 64k the driver will start over again
- I fixed a bug where packets with the largest ethernet frame size (1514)
  weren't accepted.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3561 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Niels Sascha Reedijk 2003-06-18 10:45:52 +00:00
parent 274e6fefaa
commit 6ad250bc87
2 changed files with 22 additions and 4 deletions

View File

@ -2,3 +2,5 @@
- Confirm to the Opentracker coding guidelines
- Implement the free_hook
- Support other card types
- Implement support for more than one card
- Fix strange slowness

View File

@ -35,6 +35,13 @@
#include "ether_driver.h"
#include "util.h"
//#define RTL_NODEBUG
#ifdef RTL_NODEBUG
#define dprintf no_printf
void no_printf( const char *useless , ... ) {};
#endif
/* ----------
global data
----- */
@ -525,10 +532,10 @@ read_hook (void* cookie, off_t position, void *buf, size_t* num_bytes)
return B_IO_ERROR;
}
//Check for an error: if needed: resetrx
if ( !( packet_header->bits & 0x1 ) || packet_header->length > 1500 )
//Check for an error: if needed: resetrx, length may not be bigger than 1514 + 4 CRC
if ( !( packet_header->bits & 0x1 ) || packet_header->length > 1518 )
{
dprintf( "rtl8139_nielx read_hook: Error in package reception!!!\n" );
dprintf( "rtl8139_nielx read_hook: Error in package reception: bits: %u length %u!!!\n" , packet_header->bits , packet_header->length);
return B_IO_ERROR;
}
@ -546,7 +553,16 @@ read_hook (void* cookie, off_t position, void *buf, size_t* num_bytes)
//Copy the packet
*num_bytes = packet_header->length - 4;
memcpy( buf , data->receivebufferlog + data->receivebufferoffset + 4 , packet_header->length - 4); //length-4 because we don't want to copy the 4 bytes CRC
if ( data->receivebufferoffset + *num_bytes > 65536 )
{
//Packet wraps around , copy last bits except header ( = +4 )
memcpy( buf , data->receivebufferlog + data->receivebufferoffset + 4 , 0x10000 - ( data->receivebufferoffset + 4 ) );
//copy remaining bytes from the beginning
memcpy( buf + 0x10000 - ( data->receivebufferoffset + 4 ) , data->receivebufferlog , *num_bytes - (0x10000 - ( data->receivebufferoffset + 4 ) ) );
dprintf( "rtl8139_nielx read_hook: Wrapping around end of buffer\n" );
}
else
memcpy( buf , data->receivebufferlog + data->receivebufferoffset + 4 , packet_header->length - 4); //length-4 because we don't want to copy the 4 bytes CRC
//Update the buffer -- 4 for the header length, plus 3 for the dword allignment
data->receivebufferoffset = ( data->receivebufferoffset + packet_header->length + 4 + 3 ) & ~3;