Skip to content

e1000 driver#241

Open
cozis wants to merge 18 commits intovvaltchev:masterfrom
cozis:e1000_driver
Open

e1000 driver#241
cozis wants to merge 18 commits intovvaltchev:masterfrom
cozis:e1000_driver

Conversation

@cozis
Copy link
Copy Markdown
Contributor

@cozis cozis commented Mar 26, 2026

Hello @vvaltchev!

This is the e1000 I've been working on. I just wanted to get your first thoughts on the general structure. If everything looks good, I will go through the code again and make sure it follows the contributing guidelines (including squashing the branch and restored and modified files that didn't need to be, such as syscalls.h).

@cozis
Copy link
Copy Markdown
Contributor Author

cozis commented Mar 26, 2026

Hmm looks like there are some issues with RISC-V

Copy link
Copy Markdown
Owner

@vvaltchev vvaltchev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change, @cozis! There are few things to address, mostly cosmetic. Plus all the CI/CD failures need to be addressed. Finally, the commits should be squashed into one.

#define MOD_serial_prio 400
#define MOD_sb16_prio 410
#define MOD_null_prio 420
#define MOD_e1000_prio 430 // TODO: check that this is right
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This priority is OK.

@@ -0,0 +1,23 @@

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing:

/* SPDX-License-Identifier: BSD-2-Clause */


void kcond_init(struct kcond *c);
void kcond_destory(struct kcond *c);
void kcond_destroy(struct kcond *c);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing this typo! I don't know how it survived so long unnoticed!

#include <sys/utsname.h> // system header
#include <sys/stat.h> // system header
#include <fcntl.h> // system header
#include <arpa/inet.h>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing // system header comment

outb(PIC2_IMR, ICW4_8086);
pic_io_wait();

outb(PIC1_IMR, 0xff);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify why do we need that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in pic.c are redundant. I was having troubles getting the IRQ handler to fire, so I added these lines to ensure the PIC was letting IRQs through. I'll restore it as it was before

printk("e1000: Sending frame len=%d\n", len);

/* Number of descriptors that would be required to send this message. */
u32 num_desc = CEIL((u32) len, TX_BUF_SIZE);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If len was unsigned we wouldn't need those casts.

/*
* Slow path. Packet spans multiple entries. Not implemented yet.
*/
ASSERT(0);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: NOT_REACHED().

Copy link
Copy Markdown
Contributor Author

@cozis cozis Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is NOT_IMPLEMENTED() more appropriate here?


void *src = PA_TO_KERNEL_VA(rx_ring[rx_tail].addr);
size_t len = rx_ring[rx_tail].length;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: extra empty line.

*/

void *src = PA_TO_KERNEL_VA(rx_ring[rx_tail].addr);
size_t len = rx_ring[rx_tail].length;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're using size_t while length is u16. Why not using everywhere u32 (except in the struct, of course).

-gdb tcp::$GDB_PORT \
@QEMU_RAM_OPT@ \
-drive id=img1,format=raw,if=none,file=@IMG_FILE@ \
-netdev user,id=net0,hostfwd=udp::2222-:22 \
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add this to the QEMU scripts, you should make the e1000 module disabled by default as it's in-development at the moment. You can do this by adding it to this list:

list(
   APPEND disabled_modules_list

   # No modules in this list, at the moment
)

In the main CMakeLists.txt file. If something is not mature enough, shouldn't be enabled by default.

Copy link
Copy Markdown
Contributor Author

@cozis cozis Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why is adding the netdev to qemu related to disabling the module by default?

Also, what is the normal way to enable it without modifying the CMakeLists.txt?

@cozis
Copy link
Copy Markdown
Contributor Author

cozis commented Mar 29, 2026

Thanks for the review! I'll go through it in the next couple days

@vvaltchev
Copy link
Copy Markdown
Owner

vvaltchev commented Mar 30, 2026 via email

@vvaltchev
Copy link
Copy Markdown
Owner

vvaltchev commented Mar 30, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants