mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
Offload FCS to driver specific code
This commit is contained in:
parent
8662e5ca5e
commit
6c976d8b56
2 changed files with 10 additions and 5 deletions
|
@ -635,7 +635,13 @@ I64 PCNetPacketReceive(U8 **packet_buffer_out, U16 *packet_length_out)
|
||||||
NetDebug("PCNET RECEIVE PACKET: de_index incremented = 0x%0X", pcnet.current_rx_de_index);
|
NetDebug("PCNET RECEIVE PACKET: de_index incremented = 0x%0X", pcnet.current_rx_de_index);
|
||||||
|
|
||||||
*packet_buffer_out = pcnet.rx_buffer_addr_phys + de_index * ETHERNET_FRAME_SIZE;
|
*packet_buffer_out = pcnet.rx_buffer_addr_phys + de_index * ETHERNET_FRAME_SIZE;
|
||||||
*packet_length_out = packet_length;
|
|
||||||
|
// ASTRPRCV causes 802.3 packets to be stripped and FCS to be checked
|
||||||
|
U16 ethertype = (*packet_buffer_out)[ETHERNET_ETHERTYPE_OFFSET + 1] | (*packet_buffer_out)[ETHERNET_ETHERTYPE_OFFSET] << 8;
|
||||||
|
if (ethertype < ETHERNET_v2_MTU)
|
||||||
|
*packet_length_out = ethertype;
|
||||||
|
else
|
||||||
|
*packet_length_out = packet_length - FCS_LENGTH; // ethertype ii TODO: Validate FCS
|
||||||
|
|
||||||
return de_index;
|
return de_index;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ U0 EthernetGlobalsInit()
|
||||||
|
|
||||||
U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)
|
U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)
|
||||||
{
|
{
|
||||||
|
// length is assumed to NOT include the FCS.
|
||||||
|
|
||||||
// Shrine says MemCopy has a high overhead.
|
// Shrine says MemCopy has a high overhead.
|
||||||
// Almost tempted to say that means that a lot
|
// Almost tempted to say that means that a lot
|
||||||
// of the current system should be done with
|
// of the current system should be done with
|
||||||
|
@ -45,10 +47,7 @@ U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)
|
||||||
|
|
||||||
frame_out->data = frame + ETHERNET_DATA_OFFSET;
|
frame_out->data = frame + ETHERNET_DATA_OFFSET;
|
||||||
|
|
||||||
if (frame_out->ethertype <= ETHERNET_v2_MTU) // check if the field is a length or an ethertype
|
frame_out->length = length - ETHERNET_MAC_HEADER_LENGTH;
|
||||||
frame_out->length = frame_out->ethertype;
|
|
||||||
else
|
|
||||||
frame_out->length = length - ETHERNET_MAC_HEADER_LENGTH - FCS_LENGTH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 EthernetFrameFinish(I64 de_index)
|
U0 EthernetFrameFinish(I64 de_index)
|
||||||
|
|
Loading…
Reference in a new issue