added networking components, hosts are next

This commit is contained in:
2025-09-07 11:47:15 -04:00
commit 3411089908
59 changed files with 4777 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
#ifndef NETWORK_SWITCH_SHARED_BUFFER_H
#define NETWORK_SWITCH_SHARED_BUFFER_H
#include "network/switch/switch_buffer.h"
namespace dofs {
// SharedBuffer: a single global memory pool shared by all ports.
// Only guard is the total pool (_buffer_bytes). Per-port usage tracked for stats.
class SharedBuffer : public SwitchBuffer {
public:
SharedBuffer(Simulator* const sim,
NetworkSwitch* const owner,
Bytes total_bytes,
uint16_t ports);
virtual bool enqueue_packet(const Packet& pkt, PortId egress,
FlowPriority prio) override;
virtual bool drain_one(PortId port) override;
protected:
virtual std::array<std::deque<Queued>, PRI_COUNT> &queues_for(
PortId p) override;
virtual const std::array<std::deque<Queued>, PRI_COUNT> &queues_for(
PortId p) const override;
virtual bool on_enqueue_cap_check(PortId port, Bytes sz) override;
virtual void on_enqueue_commit(PortId port, Bytes sz) override;
virtual void on_dequeue_commit(PortId port, Bytes sz) override;
private:
// Per-port, per-priority queues
std::vector<std::array<std::deque<Queued>, PRI_COUNT >> _per_port_queues;
Bytes _used_total;
};
} // namespace dofs
#endif // NETWORK_SWITCH_SHARED_BUFFER_H