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,38 @@
#ifndef NETWORK_SWITCH_DEDICATED_BUFFER_H
#define NETWORK_SWITCH_DEDICATED_BUFFER_H
#include "network/switch/switch_buffer.h"
namespace dofs {
// DedicatedBuffer: buffer_size is split across ports (equal split by default).
// Each port has a hard cap; no borrowing.
class DedicatedBuffer : public SwitchBuffer {
public:
DedicatedBuffer(Simulator* const sim,
NetworkSwitch* const owner,
Bytes total_bytes,
uint16_t ports);
bool enqueue_packet(const Packet& pkt, PortId egress,
FlowPriority prio) override;
bool drain_one(PortId port) override;
protected:
std::array<std::deque<Queued>, PRI_COUNT> &queues_for(PortId p) override;
const std::array<std::deque<Queued>, PRI_COUNT> &queues_for(
PortId p) const override;
bool on_enqueue_cap_check(PortId port, Bytes sz) override;
void on_enqueue_commit(PortId port, Bytes sz) override;
void on_dequeue_commit(PortId port, Bytes sz) override;
private:
// Hard cap per port (equal share of total; final remainder goes to low ports).
Bytes _per_port_cap;
std::vector<std::array<std::deque<Queued>, PRI_COUNT >> _per_port_queues;
};
} // namespace dofs
#endif // NETWORK_SWITCH_DEDICATED_BUFFER_H