mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
Kernel: Add dmesgln_pci logging for Kernel::PCI
A virtual method named device_name() was added to Kernel::PCI to support logging the PCI::Device name and address using dmesgln_pci. Previously, PCI::Device did not store the device name. All devices inheriting from PCI::Device now use dmesgln_pci where they previously used dmesgln.
This commit is contained in:
parent
6a5be5f1c5
commit
288a73ea0e
24 changed files with 90 additions and 52 deletions
|
@ -133,12 +133,12 @@ UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address addre
|
|||
{
|
||||
m_tx_buffers.ensure_capacity(RTL8139_TX_BUFFER_COUNT);
|
||||
|
||||
dmesgln("RTL8139: Found @ {}", pci_address());
|
||||
dmesgln_pci(*this, "Found @ {}", pci_address());
|
||||
|
||||
enable_bus_mastering(pci_address());
|
||||
|
||||
dmesgln("RTL8139: I/O port base: {}", m_registers_io_window);
|
||||
dmesgln("RTL8139: Interrupt line: {}", interrupt_number());
|
||||
dmesgln_pci(*this, "I/O port base: {}", m_registers_io_window);
|
||||
dmesgln_pci(*this, "Interrupt line: {}", interrupt_number());
|
||||
|
||||
// we add space to account for overhang from the last packet - the rtl8139
|
||||
// can optionally guarantee that packets will be contiguous by
|
||||
|
@ -154,7 +154,7 @@ UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address addre
|
|||
|
||||
read_mac_address();
|
||||
auto const& mac = mac_address();
|
||||
dmesgln("RTL8139: MAC address: {}", mac.to_string());
|
||||
dmesgln_pci(*this, "MAC address: {}", mac.to_string());
|
||||
|
||||
enable_irq();
|
||||
}
|
||||
|
@ -181,31 +181,31 @@ bool RTL8139NetworkAdapter::handle_irq(RegisterState const&)
|
|||
receive();
|
||||
}
|
||||
if (status & INT_RXERR) {
|
||||
dmesgln("RTL8139: RX error - resetting device");
|
||||
dmesgln_pci(*this, "RX error - resetting device");
|
||||
reset();
|
||||
}
|
||||
if (status & INT_TXOK) {
|
||||
dbgln_if(RTL8139_DEBUG, "RTL8139: TX complete");
|
||||
}
|
||||
if (status & INT_TXERR) {
|
||||
dmesgln("RTL8139: TX error - resetting device");
|
||||
dmesgln_pci(*this, "TX error - resetting device");
|
||||
reset();
|
||||
}
|
||||
if (status & INT_RX_BUFFER_OVERFLOW) {
|
||||
dmesgln("RTL8139: RX buffer overflow");
|
||||
dmesgln_pci(*this, "RX buffer overflow");
|
||||
}
|
||||
if (status & INT_LINK_CHANGE) {
|
||||
m_link_up = (in8(REG_MSR) & MSR_LINKB) == 0;
|
||||
dmesgln("RTL8139: Link status changed up={}", m_link_up);
|
||||
dmesgln_pci(*this, "Link status changed up={}", m_link_up);
|
||||
}
|
||||
if (status & INT_RX_FIFO_OVERFLOW) {
|
||||
dmesgln("RTL8139: RX FIFO overflow");
|
||||
dmesgln_pci(*this, "RX FIFO overflow");
|
||||
}
|
||||
if (status & INT_LENGTH_CHANGE) {
|
||||
dmesgln("RTL8139: Cable length change");
|
||||
dmesgln_pci(*this, "Cable length change");
|
||||
}
|
||||
if (status & INT_SYSTEM_ERROR) {
|
||||
dmesgln("RTL8139: System error - resetting device");
|
||||
dmesgln_pci(*this, "System error - resetting device");
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ void RTL8139NetworkAdapter::send_raw(ReadonlyBytes payload)
|
|||
dbgln_if(RTL8139_DEBUG, "RTL8139: send_raw length={}", payload.size());
|
||||
|
||||
if (payload.size() > PACKET_SIZE_MAX) {
|
||||
dmesgln("RTL8139: Packet was too big; discarding");
|
||||
dmesgln_pci(*this, "Packet was too big; discarding");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ void RTL8139NetworkAdapter::send_raw(ReadonlyBytes payload)
|
|||
}
|
||||
|
||||
if (hw_buffer == -1) {
|
||||
dmesgln("RTL8139: Hardware buffers full; discarding packet");
|
||||
dmesgln_pci(*this, "Hardware buffers full; discarding packet");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ void RTL8139NetworkAdapter::receive()
|
|||
dbgln_if(RTL8139_DEBUG, "RTL8139: receive, status={:#04x}, length={}, offset={}", status, length, m_rx_buffer_offset);
|
||||
|
||||
if (!(status & RX_OK) || (status & (RX_INVALID_SYMBOL_ERROR | RX_CRC_ERROR | RX_FRAME_ALIGNMENT_ERROR)) || (length >= PACKET_SIZE_MAX) || (length < PACKET_SIZE_MIN)) {
|
||||
dmesgln("RTL8139: receive got bad packet, status={:#04x}, length={}", status, length);
|
||||
dmesgln_pci(*this, "receive got bad packet, status={:#04x}, length={}", status, length);
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
virtual bool link_full_duplex() override;
|
||||
|
||||
virtual StringView purpose() const override { return class_name(); }
|
||||
virtual StringView device_name() const override { return "RTL8139"sv; }
|
||||
|
||||
private:
|
||||
RTL8139NetworkAdapter(PCI::Address, u8 irq, NonnullOwnPtr<IOWindow> registers_io_window, NonnullOwnPtr<KString>);
|
||||
|
|
|
@ -247,14 +247,14 @@ UNMAP_AFTER_INIT RTL8168NetworkAdapter::RTL8168NetworkAdapter(PCI::Address addre
|
|||
, m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(TXDescriptor) * (number_of_rx_descriptors + 1)).release_value_but_fixme_should_propagate_errors(), "RTL8168 RX"sv, Memory::Region::Access::ReadWrite).release_value())
|
||||
, m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(RXDescriptor) * (number_of_tx_descriptors + 1)).release_value_but_fixme_should_propagate_errors(), "RTL8168 TX"sv, Memory::Region::Access::ReadWrite).release_value())
|
||||
{
|
||||
dmesgln("RTL8168: Found @ {}", pci_address());
|
||||
dmesgln("RTL8168: I/O port base: {}", m_registers_io_window);
|
||||
dmesgln_pci(*this, "Found @ {}", pci_address());
|
||||
dmesgln_pci(*this, "I/O port base: {}", m_registers_io_window);
|
||||
|
||||
identify_chip_version();
|
||||
dmesgln("RTL8168: Version detected - {} ({}{})", possible_device_name(), (u8)m_version, m_version_uncertain ? "?" : "");
|
||||
dmesgln_pci(*this, "Version detected - {} ({}{})", possible_device_name(), (u8)m_version, m_version_uncertain ? "?" : "");
|
||||
|
||||
if (!determine_supported_version()) {
|
||||
dmesgln("RTL8168: Aborting initialization! Support for your chip version ({}) is not implemented yet, please open a GH issue and include this message.", (u8)m_version);
|
||||
dmesgln_pci(*this, "Aborting initialization! Support for your chip version ({}) is not implemented yet, please open a GH issue and include this message.", (u8)m_version);
|
||||
return; // Each ChipVersion requires a specific implementation of configure_phy and hardware_quirks
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,7 @@ void RTL8168NetworkAdapter::initialize()
|
|||
enable_bus_mastering(pci_address());
|
||||
|
||||
read_mac_address();
|
||||
dmesgln("RTL8168: MAC address: {}", mac_address().to_string());
|
||||
dmesgln_pci(*this, "MAC address: {}", mac_address().to_string());
|
||||
|
||||
// notify about driver start
|
||||
if (m_version >= ChipVersion::Version11 && m_version <= ChipVersion::Version13) {
|
||||
|
@ -1155,19 +1155,19 @@ bool RTL8168NetworkAdapter::handle_irq(RegisterState const&)
|
|||
dbgln_if(RTL8168_DEBUG, "RTL8168: TX error - invalid packet");
|
||||
}
|
||||
if (status & INT_RX_OVERFLOW) {
|
||||
dmesgln("RTL8168: RX descriptor unavailable (packet lost)");
|
||||
dmesgln_pci(*this, "RX descriptor unavailable (packet lost)");
|
||||
receive();
|
||||
}
|
||||
if (status & INT_LINK_CHANGE) {
|
||||
m_link_up = (in8(REG_PHYSTATUS) & PHY_LINK_STATUS) != 0;
|
||||
dmesgln("RTL8168: Link status changed up={}", m_link_up);
|
||||
dmesgln_pci(*this, "Link status changed up={}", m_link_up);
|
||||
}
|
||||
if (status & INT_RX_FIFO_OVERFLOW) {
|
||||
dmesgln("RTL8168: RX FIFO overflow");
|
||||
dmesgln_pci(*this, "RX FIFO overflow");
|
||||
receive();
|
||||
}
|
||||
if (status & INT_SYS_ERR) {
|
||||
dmesgln("RTL8168: Fatal system error");
|
||||
dmesgln_pci(*this, "Fatal system error");
|
||||
}
|
||||
}
|
||||
return was_handled;
|
||||
|
@ -1193,7 +1193,7 @@ void RTL8168NetworkAdapter::send_raw(ReadonlyBytes payload)
|
|||
dbgln_if(RTL8168_DEBUG, "RTL8168: send_raw length={}", payload.size());
|
||||
|
||||
if (payload.size() > TX_BUFFER_SIZE) {
|
||||
dmesgln("RTL8168: Packet was too big; discarding");
|
||||
dmesgln_pci(*this, "Packet was too big; discarding");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1237,7 +1237,7 @@ void RTL8168NetworkAdapter::receive()
|
|||
dbgln_if(RTL8168_DEBUG, "RTL8168: receive, flags={:#04x}, length={}, descriptor={}", flags, length, descriptor_index);
|
||||
|
||||
if (length > RX_BUFFER_SIZE || (flags & RXDescriptor::ErrorSummary) != 0) {
|
||||
dmesgln("RTL8168: receive got bad packet, flags={:#04x}, length={}", flags, length);
|
||||
dmesgln_pci(*this, "receive got bad packet, flags={:#04x}, length={}", flags, length);
|
||||
} else if ((flags & RXDescriptor::FirstSegment) != 0 && (flags & RXDescriptor::LastSegment) == 0) {
|
||||
VERIFY_NOT_REACHED();
|
||||
// Our maximum received packet size is smaller than the descriptor buffer size, so packets should never be segmented
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
virtual i32 link_speed() override;
|
||||
|
||||
virtual StringView purpose() const override { return class_name(); }
|
||||
virtual StringView device_name() const override { return class_name(); }
|
||||
|
||||
private:
|
||||
// FIXME: should this be increased? (maximum allowed here is 1024) - memory usage vs packet loss chance tradeoff
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue