1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 12:27:35 +00:00

Kernel: Add interface to read link speed and duplex for NetworkAdapter

Read the appropriate registers for RTL8139, RTL8168 and E1000.
For NE2000 just assume 10mbit full duplex as there is no indicator
for it in the pure NE2000 spec. Mock values for loopback.
This commit is contained in:
Thomas Wagenveld 2021-07-25 20:16:42 +02:00 committed by Gunnar Beutner
parent 238ac8ac25
commit 59fdeec7f5
9 changed files with 98 additions and 0 deletions

View file

@ -466,4 +466,29 @@ void E1000NetworkAdapter::receive()
}
}
i32 E1000NetworkAdapter::link_speed()
{
if (!link_up())
return NetworkAdapter::LINKSPEED_INVALID;
u32 speed = in32(REG_STATUS) & STATUS_SPEED;
switch (speed) {
case STATUS_SPEED_10MB:
return 10;
case STATUS_SPEED_100MB:
return 100;
case STATUS_SPEED_1000MB1:
case STATUS_SPEED_1000MB2:
return 1000;
default:
return NetworkAdapter::LINKSPEED_INVALID;
}
}
bool E1000NetworkAdapter::link_full_duplex()
{
u32 status = in32(REG_STATUS);
return !!(status & STATUS_FD);
}
}