Intel Ethernet i217: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
m Bot: Replace deprecated source tag with syntaxhighlight
m Bot: Replace deprecated source tag with syntaxhighlight
Line 9: Line 9:


To start with, lets state some macro definitions that we are going to use in the code.
To start with, lets state some macro definitions that we are going to use in the code.
<source lang="c">
<syntaxhighlight lang="c">


#define INTEL_VEND 0x8086 // Vendor ID for Intel
#define INTEL_VEND 0x8086 // Vendor ID for Intel
Line 106: Line 106:
#define TSTA_LC (1 << 2) // Late Collision
#define TSTA_LC (1 << 2) // Late Collision
#define LSTA_TU (1 << 3) // Transmit Underrun
#define LSTA_TU (1 << 3) // Transmit Underrun
</syntaxhighlight>
</source>


Now lets define the data structures for the transmit and receive buffers
Now lets define the data structures for the transmit and receive buffers
Line 406: Line 406:
Now we need to detect if the card has an EEPROM or not. The Qemu and Bochs emulate EEPROM, but the I217 and 82577LM do not. The following first method tries to read the status field of the EEPROM, the status field should contain the value 0x10, and based on the result the internal data member eerprom_exists. The second method performs a 2-bytes read operation from the EEPROM
Now we need to detect if the card has an EEPROM or not. The Qemu and Bochs emulate EEPROM, but the I217 and 82577LM do not. The following first method tries to read the status field of the EEPROM, the status field should contain the value 0x10, and based on the result the internal data member eerprom_exists. The second method performs a 2-bytes read operation from the EEPROM


<source lang="c">
<syntaxhighlight lang="c">
bool E1000::detectEEProm()
bool E1000::detectEEProm()
{
{
Line 441: Line 441:
}
}


</syntaxhighlight>
</source>




Line 447: Line 447:
The first thing you will need to do after detecting the BAR0 type and the existence of the EEPROM is to read the hardware MAC address of the NIC. The following method reads the hardware mac address based. If an EEPROM exists it will read it from the EEPROM else it will read it from address 0x5400 where it should be located in that case. It is very important to detect if an EEPROM exists or not prior to reading the MAC address.
The first thing you will need to do after detecting the BAR0 type and the existence of the EEPROM is to read the hardware MAC address of the NIC. The following method reads the hardware mac address based. If an EEPROM exists it will read it from the EEPROM else it will read it from address 0x5400 where it should be located in that case. It is very important to detect if an EEPROM exists or not prior to reading the MAC address.


<source lang="c">
<syntaxhighlight lang="c">


bool E1000::readMACAddress()
bool E1000::readMACAddress()
Line 479: Line 479:
return true;
return true;
}
}
</syntaxhighlight>
</source>




Now, we need to configure the transmit and receive descriptor buffers, here are the implementation of the corresponding methods. The rxinit method is identical to the one I use for my e1000 driver. The difference is in txinit
Now, we need to configure the transmit and receive descriptor buffers, here are the implementation of the corresponding methods. The rxinit method is identical to the one I use for my e1000 driver. The difference is in txinit


<source lang="c">
<syntaxhighlight lang="c">


void E1000::rxinit()
void E1000::rxinit()
Line 564: Line 564:




</syntaxhighlight>
</source>




Line 602: Line 602:




<source lang="c">
<syntaxhighlight lang="c">


bool E1000::start ()
bool E1000::start ()
Line 625: Line 625:




</syntaxhighlight>
</source>