diff --git a/src/Home/Net/Drivers/PCNet.ZC b/src/Home/Net/Drivers/PCNet.ZC index 3cf9f465..861a269a 100755 --- a/src/Home/Net/Drivers/PCNet.ZC +++ b/src/Home/Net/Drivers/PCNet.ZC @@ -512,20 +512,28 @@ U0 PCNetTransmitPacketFinish(I64 de_index) CPCNetDescriptorEntry *entry = &pcnet.tx_de_buffer[de_index * sizeof(CPCNetDescriptorEntry)]; - // check the TX packet MAC against local MAC, if they match: software loopback the TX packet to RX NetQueue - if (!MemCompare(EthernetMACGet(), pcnet.tx_buffer_addr + de_index * ETHERNET_FRAME_SIZE, 6)) - NetQueuePush(pcnet.tx_buffer_addr + de_index * ETHERNET_FRAME_SIZE, U16_MAX - (entry->status1 & 0xFFFF) + 1); - Bts(&entry->status1, PCNET_DESCRIPTORf_OWN); NetLog("PCNET FINISH TX PACKET: TX DE index: %X, OWN bit of entry at entry: %b.", de_index, Bt(&entry->status1, PCNET_DESCRIPTORf_OWN)); } -U0 EthernetFrameFinish(I64 de_index) -{//Alias for driver Finish TX function. +U0 NetDriverTransmitPacketFinish(I64 de_index) +{//Alias for driver-specific Finish TX function. PCNetTransmitPacketFinish(de_index); } +I64 NetDriverPacketBufferGet(I64 de_index) +{ + return pcnet.tx_buffer_addr + de_index * ETHERNET_FRAME_SIZE; +} + +I64 NetDriverPacketLengthGet(I64 de_index) +{ + CPCNetDescriptorEntry *entry = &pcnet.tx_de_buffer[de_index * sizeof(CPCNetDescriptorEntry)]; + + return U16_MAX - (entry->status1 & 0xFFFF) + 1; +} + I64 PCNetPacketReceive(U8 **packet_buffer_out, U16 *packet_length_out) {/* Receives the packet at the current RX DE index. Parameters are both pointers, since we modify the value at the packet_buffer_out, diff --git a/src/Home/Net/Drivers/VirtIONet.ZC b/src/Home/Net/Drivers/VirtIONet.ZC index 31541648..a2010aa1 100755 --- a/src/Home/Net/Drivers/VirtIONet.ZC +++ b/src/Home/Net/Drivers/VirtIONet.ZC @@ -167,15 +167,15 @@ I64 EthernetFrameAllocate(U8 **buffer_out, U8 *src_addr, U8 *dst_addr, I64 index; - if (!MemCompare(dst_addr, &VirtioNet.mac, 6)) { - frame = loopback_frame; - loopback_length = length; - index = I64_MAX; - } else { +// if (!MemCompare(dst_addr, &VirtioNet.mac, 6)) { +// frame = loopback_frame; +// loopback_length = length; +// index = I64_MAX; +// } else { index = @virtio_net_alloc_tx_packet(&frame, 14 + length/*, flags*/); if (index < 0) return index; - } +// } MemCopy(frame + 0, dst_addr, 6); MemCopy(frame + 6, src_addr, 6); @@ -186,15 +186,26 @@ I64 EthernetFrameAllocate(U8 **buffer_out, U8 *src_addr, U8 *dst_addr, return index; } -I64 EthernetFrameFinish(I64 index) { - if (index == I64_MAX && loopback_frame && loopback_length) { - NetQueuePush(loopback_frame, loopback_length); - loopback_length = 0; - return 0; - } +//I64 EthernetFrameFinish(I64 index) { +I64 NetDriverTransmitPacketFinish(I64 index) { +// if (index == I64_MAX && loopback_frame && loopback_length) { +// NetQueuePush(loopback_frame, loopback_length); +// loopback_length = 0; +// return 0; +// } return @virtio_net_finish_tx_packet(index); } +I64 NetDriverPacketBufferGet(I64 de_index) +{ + return tx_buffers + de_index * ETHERNET_FRAME_SIZE; +} + +I64 NetDriverPacketLengthGet(I64 de_index) +{ // TODO: ... de_index in Alec's VirtIO-Net driver don't match up to any way to get packet length... + return 0; +} + U8 *EthernetMACGet() { return &VirtioNet.mac; } I64 @virtio_net_init() { diff --git a/src/Home/Net/Protocols/Ethernet.ZC b/src/Home/Net/Protocols/Ethernet.ZC index bcce3903..f2f75652 100755 --- a/src/Home/Net/Protocols/Ethernet.ZC +++ b/src/Home/Net/Protocols/Ethernet.ZC @@ -52,4 +52,14 @@ U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length) frame_out->length = length - ETHERNET_MAC_HEADER_LENGTH - 4; // He has a comment literally just saying "??". + or - 4? } +U0 EthernetFrameFinish(I64 de_index) +{//Alias for generic driver Finish TX function. + + // check the TX packet MAC against local MAC, if they match: software loopback the TX packet to RX NetQueue + if (!MemCompare(EthernetMACGet(), NetDriverPacketBufferGet(de_index), MAC_ADDRESS_LENGTH)) + NetQueuePush(NetDriverPacketBufferGet(de_index), NetDriverPacketLengthGet(de_index)); + + NetDriverTransmitPacketFinish(de_index); +} + EthernetGlobalsInit; \ No newline at end of file