Fixes and Enhancements We correct an omission in our 8139 device-driver’s ‘read()’ function and supply ‘flush()’ and ‘fsync()’ methods
Receiver Buffer ‘wraparound’ Our driver for the RealTek controller didn’t correctly handle the buffer’s wraparound Two disjoint memory-segments must be copied from this Buffer into user-space Packet-header Receive Buffer …data C R H D R data..… Received network-packet continues at the buffer beginning
‘wrapfix.c’ The code-changes needed for dealing with packet-wraparound are shown in this file You can replace the previous ‘my_read()’ driver-function with this revised version
Closing a device-file too soon Another problem that our previous drivers neglected to handle concerns cases when the ‘/dev/nic’ device-file is ‘closed’ before all packets that had been queued up for transmission have actually been sent out The driver’s ‘release()’ method performs a reset-operation, which disables the nic’s ability to finish any pending transmissions
Kernel calls ‘flush()’ Before closing a device-file, the kernel will call the driver’s ‘flush()’ function – unless the driver didn’t implement this method We can supply a ‘flush()’ method that will delay the kernel from attempting to ‘close’ the ‘/dev/nic’ device-file until after all of the packets that were previously written have in fact been successfully transmitted
Transmit Status of All Descriptors The TSAD register shows the descriptors which still have packets that are queued for transmission, and which descriptors have finished transmitting -- successfully or with transmission-errors T O K T O K T O K T O K T U N T U N T U N T U N T A B T A B T T A B T A B O W N O W N O W N O W N 0x60-0x61
Packet retransmission The RealTek Manual says packets which encounter TxErrors can be retransmitted by writing ‘1’ to bit #0 of TxConfig register int port = iobase + 0x30; // TxConfig outl( inl( port ) | 1, port ); // Retransmit