39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
#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
|