mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Kernel: Implement link status in /proc/net/adapters
This commit is contained in:
parent
af840af1ce
commit
286bafbb19
4 changed files with 19 additions and 0 deletions
|
@ -318,6 +318,7 @@ Optional<KBuffer> procfs$net_adapters(InodeIdentifier)
|
|||
obj.set("bytes_in", adapter.bytes_in());
|
||||
obj.set("packets_out", adapter.packets_out());
|
||||
obj.set("bytes_out", adapter.bytes_out());
|
||||
obj.set("link_up", adapter.link_up());
|
||||
json.append(obj);
|
||||
});
|
||||
return json.serialized<KBufferBuilder>();
|
||||
|
|
|
@ -80,6 +80,17 @@
|
|||
#define TSTA_LC (1 << 2) // Late Collision
|
||||
#define LSTA_TU (1 << 3) // Transmit Underrun
|
||||
|
||||
// STATUS Register
|
||||
|
||||
#define STATUS_FD 0x01
|
||||
#define STATUS_LU 0x02
|
||||
#define STATUS_TXOFF 0x08
|
||||
#define STATUS_SPEED 0xC0
|
||||
#define STATUS_SPEED_10MB 0x00
|
||||
#define STATUS_SPEED_100MB 0x40
|
||||
#define STATUS_SPEED_1000MB1 0x80
|
||||
#define STATUS_SPEED_1000MB2 0xC0
|
||||
|
||||
OwnPtr<E1000NetworkAdapter> E1000NetworkAdapter::autodetect()
|
||||
{
|
||||
static const PCI::ID qemu_bochs_vbox_id = { 0x8086, 0x100e };
|
||||
|
@ -215,6 +226,11 @@ void E1000NetworkAdapter::read_mac_address()
|
|||
}
|
||||
}
|
||||
|
||||
bool E1000NetworkAdapter::link_up()
|
||||
{
|
||||
return (in32(REG_STATUS) & STATUS_LU);
|
||||
}
|
||||
|
||||
void E1000NetworkAdapter::initialize_rx_descriptors()
|
||||
{
|
||||
auto ptr = (u32)kmalloc_eternal(sizeof(e1000_rx_desc) * number_of_rx_descriptors + 16);
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
virtual ~E1000NetworkAdapter() override;
|
||||
|
||||
virtual void send_raw(const u8*, int) override;
|
||||
virtual bool link_up() override;
|
||||
|
||||
private:
|
||||
virtual void handle_irq() override;
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
const String& name() const { return m_name; }
|
||||
MACAddress mac_address() { return m_mac_address; }
|
||||
IPv4Address ipv4_address() const { return m_ipv4_address; }
|
||||
virtual bool link_up() { return false; }
|
||||
|
||||
void set_ipv4_address(const IPv4Address&);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue