summaryrefslogtreecommitdiff
path: root/kernel/drivers/rtl8139.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-10-06 11:12:16 +0200
committerAnton Kling <anton@kling.gg>2024-10-06 11:12:16 +0200
commitf18beba3cb3d85ed6e0f44fdff9256c50adcc5e1 (patch)
tree42e15026c9a0154269e5c7de71cd829866d6d564 /kernel/drivers/rtl8139.c
parent6dc2637972f93dea8cc831d7ee225daefb74b8ab (diff)
Kernel/Networking: Modify outgoing packet in place
This avoids creation of new buffers and unnecessary memcpys. The old interface still exists for UDP but will be removed when I am less lazy. From testing it does not appear to have any performance improvement but this is most likely due to other bottlenecks as extra copies should always be worse.
Diffstat (limited to 'kernel/drivers/rtl8139.c')
-rw-r--r--kernel/drivers/rtl8139.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/kernel/drivers/rtl8139.c b/kernel/drivers/rtl8139.c
index 669cb6c..946c405 100644
--- a/kernel/drivers/rtl8139.c
+++ b/kernel/drivers/rtl8139.c
@@ -111,6 +111,24 @@ void rtl8139_handler(void *regs) {
EOI(0xB);
}
+u8 *nic_get_buffer(void) {
+ if (send_buffers_loop > 3) {
+ send_buffers_loop = 0;
+ }
+ return send_buffers[send_buffers_loop];
+}
+
+void nic_send_buffer(u16 data_size) {
+ const struct PCI_DEVICE *device = &rtl8139;
+ outl(device->gen.base_mem_io + 0x20 + send_buffers_loop * 4,
+ (u32)virtual_to_physical(send_buffers[send_buffers_loop], NULL));
+ outl(device->gen.base_mem_io + 0x10 + send_buffers_loop * 4, data_size);
+ send_buffers_loop += 1;
+ if (send_buffers_loop > 3) {
+ send_buffers_loop = 0;
+ }
+}
+
void rtl8139_send_data(u8 *data, u16 data_size) {
if (data_size > 0x1000) {
rtl8139_send_data(data, 0x1000);