Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel: Make sure the E1000 network adapter keeps receiving packets #6669

Merged
merged 5 commits into from
Apr 27, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Kernel: Use macros instead of hard-coded magic values
  • Loading branch information
gunnarbeutner committed Apr 27, 2021
commit da1bb3563db81593ebcc54ad43a5d9568bdf824d
14 changes: 8 additions & 6 deletions Kernel/Net/E1000NetworkAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ namespace Kernel {
#define INTERRUPT_TXD_LOW (1 << 15)
#define INTERRUPT_SRPD (1 << 16)

#define PCI_VENDOR_INTEL 0x8086
gunnarbeutner marked this conversation as resolved.
Show resolved Hide resolved

// https://www.intel.com/content/dam/doc/manual/pci-pci-x-family-gbe-controllers-software-dev-manual.pdf Section 5.2
static bool is_valid_device_id(u16 device_id)
{
Expand Down Expand Up @@ -160,7 +162,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::detect()
PCI::enumerate([&](const PCI::Address& address, PCI::ID id) {
if (address.is_null())
return;
if (id.vendor_id != 0x8086)
if (id.vendor_id != PCI_VENDOR_INTEL)
return;
if (!is_valid_device_id(id.device_id))
return;
Expand Down Expand Up @@ -223,16 +225,16 @@ void E1000NetworkAdapter::handle_irq(const RegisterState&)

m_entropy_source.add_random_event(status);

if (status & 4) {
if (status & INTERRUPT_LSC) {
u32 flags = in32(REG_CTRL);
out32(REG_CTRL, flags | ECTRL_SLU);
}
if (status & 0x80) {
receive();
}
if (status & 0x10) {
if (status & INTERRUPT_RXDMT0) {
// Threshold OK?
}
if (status & INTERRUPT_RXT0) {
receive();
}

m_wait_queue.wake_all();

Expand Down