Skip to content

Conversation

assembler-0
Copy link
Owner

@assembler-0 assembler-0 commented Sep 13, 2025

Summary by CodeRabbit

  • New Features

    • Introduces a basic networking stack with IPv4, ARP, and ICMP support.
    • Adds a “ping” command to the shell for ICMP echo requests.
    • Enables inbound packet handling for supported NICs and periodic network polling.
  • Refactor

    • Consolidates per-NIC initialization into a unified network stack initialization during boot.
  • Documentation

    • Updates README with a Network Interface subsection.
    • Revises architecture docs to reflect updated process control structures and configuration flags.
  • Chores

    • Integrates new networking modules into the build system.

Copy link

coderabbitai bot commented Sep 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces a basic Ethernet networking stack: a generic NIC registry and poller, IPv4/ARP/ICMP layers, and RX paths in E1000/RTL8139. Integrates stack initialization into kernel boot (replacing per-driver init) and polls NICs from the timer IRQ. Adds a shell “ping” command. Updates docs and string utilities.

Changes

Cohort / File(s) Summary
Docs updates
README.md, docs/ARCHITECTURE.md
README: adds Network Interface subsection (IP/ARP/ICMP). ARCHITECTURE: renames ProcessControlBlock to MLFQProcessControlBlock, updates public fields and config flags.
Network core interface
drivers/ethernet/Network.h, drivers/ethernet/Network.c
New NIC registry and API: device struct with callbacks, init routine registering E1000/RTL8139, device lookup, and poll-all function.
Protocol layers (IPv4/ARP/ICMP)
drivers/ethernet/interface/Ip.h, drivers/ethernet/interface/Ip.c, drivers/ethernet/interface/Arp.h, drivers/ethernet/interface/Arp.c, drivers/ethernet/interface/Icmp.h, drivers/ethernet/interface/Icmp.c
Adds minimal IPv4 send/receive, ARP cache with request/reply handling, and ICMP echo request/reply handlers with checksum logic.
NIC RX handling
drivers/ethernet/intel/E1000.h, drivers/ethernet/intel/E1000.c, drivers/ethernet/realtek/RTL8139.h, drivers/ethernet/realtek/RTL8139.c
Exposes RX handlers and integrates protocol dispatch: parse Ethernet frames; route IPv4 to IpHandlePacket and ARP to ArpHandlePacket. Adds RTL8139 RX offset field.
Kernel integration
kernel/core/Kernel.c, arch/x86_64/interrupts/Interrupts.c
Replaces per-driver init with Net_Initialize during boot. Timer IRQ path now calls Net_Poll after PIT tick increment.
Shell command
kernel/etc/Shell.c
Adds “ping” command: parses dotted-quad IP and triggers IcmpSendEchoRequest.
String utilities
kernel/etc/StringOps.h, kernel/etc/StringOps.c
Adds extern qualifiers to declarations and introduces strtok(char* s, char d) with kernel-heap allocations.
Build system
meson.build
Includes ethernet/interface headers and compiles Ip.c, Arp.c, Icmp.c, Network.c.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant Shell
    participant ICMP as Icmp.c
    participant IP as Ip.c
    participant ARP as Arp.c
    participant NIC as Network.c/Device
    Note over Shell,NIC: Outbound ping flow
    User->>Shell: ping 10.0.2.2
    Shell->>ICMP: IcmpSendEchoRequest(dest_ip)
    ICMP->>IP: IpSend(dest_ip, ICMP, icmp_payload)
    IP->>ARP: ArpResolve(dest_ip, out_mac)
    alt MAC known
        IP->>NIC: send_packet(ETH[IPv4+ICMP])
    else MAC unknown
        ARP->>NIC: send_packet(ETH[ARP Request])
        Note right of ARP: Caller drops packet
    end
Loading
sequenceDiagram
    autonumber
    participant IRQ as Timer IRQ (case 32)
    participant Net as Net_Poll
    participant E1000 as E1000_HandleReceive
    participant RTL as Rtl8139_HandleReceive
    participant IP as IpHandlePacket
    participant ARP as ArpHandlePacket
    Note over IRQ,RTL: Inbound polling path
    IRQ->>Net: Poll all devices
    Net->>E1000: poll_receive()
    E1000->>IP: IPv4 frames
    E1000->>ARP: ARP frames
    Net->>RTL: poll_receive()
    RTL->>IP: IPv4 frames
    RTL->>ARP: ARP frames
Loading
sequenceDiagram
    autonumber
    participant NIC as NIC RX
    participant IP as Ip.c
    participant ICMP as Icmp.c
    participant NIC2 as NIC TX
    Note over NIC,ICMP: ICMP echo reply
    NIC->>IP: IPv4 packet (protocol=ICMP)
    IP->>ICMP: IcmpHandlePacket(ip_hdr, icmp_hdr)
    alt Echo Request
        ICMP->>NIC2: send_packet(ETH[IPv4+ICMP Echo Reply])
    else Echo Reply
        ICMP-->>IP: log reception
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • A lot of fixes #48 — Also modifies the timer interrupt path in arch/x86_64/interrupts/Interrupts.c, intersecting with this PR’s Net_Poll addition.
  • Development #69 — Touches Ethernet driver/stack components, overlapping with newly added network interface and NIC handlers.
  • Development #52 — Changes StringOps implementation/headers, related to this PR’s new strtok and header adjustments.

Poem

A packet hops across the wire, so fleet,
ARP sniffs a MAC with quiet beat.
IP packs a snack for ICMP’s ring,
“pong!” replies—what joy to ping! 🐇
Timer ticks, the NICs all roll—
little ears up, I’m on patrol.

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Development

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3f43c8 and be9f52c.

⛔ Files ignored due to path filters (2)
  • kernel/etc/objects/panic.o is excluded by !**/*.o
  • kernel/etc/objects/splash1.o is excluded by !**/*.o
📒 Files selected for processing (20)
  • README.md (1 hunks)
  • arch/x86_64/interrupts/Interrupts.c (2 hunks)
  • docs/ARCHITECTURE.md (2 hunks)
  • drivers/ethernet/Network.c (1 hunks)
  • drivers/ethernet/Network.h (1 hunks)
  • drivers/ethernet/intel/E1000.c (2 hunks)
  • drivers/ethernet/intel/E1000.h (1 hunks)
  • drivers/ethernet/interface/Arp.c (1 hunks)
  • drivers/ethernet/interface/Arp.h (1 hunks)
  • drivers/ethernet/interface/Icmp.c (1 hunks)
  • drivers/ethernet/interface/Icmp.h (1 hunks)
  • drivers/ethernet/interface/Ip.c (1 hunks)
  • drivers/ethernet/interface/Ip.h (1 hunks)
  • drivers/ethernet/realtek/RTL8139.c (2 hunks)
  • drivers/ethernet/realtek/RTL8139.h (1 hunks)
  • kernel/core/Kernel.c (3 hunks)
  • kernel/etc/Shell.c (5 hunks)
  • kernel/etc/StringOps.c (2 hunks)
  • kernel/etc/StringOps.h (1 hunks)
  • meson.build (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@assembler-0 assembler-0 merged commit 5f48598 into main Sep 13, 2025
1 of 2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Sep 16, 2025
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.

1 participant