netcore.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* Shared kernel receive pump for the network stack.
  2. *
  3. * Packet-level commands still take an exclusive raw lease through
  4. * netdev_acquire(). TCP clients no longer take that lease: every socket
  5. * syscall drains the active NIC through net_pump(), which dispatches each
  6. * frame to the TCP client table, the TCP listener, a pending DNS query, the
  7. * ARP cache and the netkexec watcher, and answers ARP/ICMP.
  8. *
  9. * net_pump() may only be called with the BKL held: it serializes every stack
  10. * user against the same NIC rings, the shared receive scratch and the
  11. * protocol state. It temporarily enables interrupts (the driver TX timeout
  12. * paths spin on get_ticks_ms()) and restores the caller's IF at the end.
  13. */
  14. #ifndef NETCORE_H
  15. #define NETCORE_H
  16. /* Drain at most `budget` frames and dispatch them. Returns the number of
  17. * frames consumed. No-op while a packet-level command owns the NIC. */
  18. int net_pump(unsigned int budget);
  19. /* Save/disable interrupts, then enable them. Paired with net_irq_exit().
  20. * Used around driver calls in the cooperative stack paths so a stuck TX
  21. * descriptor can still time out on the PIT. */
  22. unsigned int net_irq_enter(void);
  23. void net_irq_exit(unsigned int flags);
  24. /* Long-running stack operations (DNS/ARP waits, TCP connects) keep the
  25. * background netkexec watcher from polling the active NIC and stealing their
  26. * frames. The counter is protected by the BKL. */
  27. void net_stack_enter(void);
  28. void net_stack_leave(void);
  29. int net_stack_busy(void);
  30. /* Reaper: forget a dead process's stack-operation counts. */
  31. void net_stack_reap(unsigned int pid);
  32. #endif