fixed some style issues, added tooling for docs

This commit is contained in:
2025-09-13 21:15:26 -04:00
parent 3872beaba3
commit 9ab64e18a4
62 changed files with 769 additions and 137 deletions

View File

@@ -18,14 +18,14 @@ void log_error(std::string_view type,
std::mutex &error_mutex() noexcept;
template <class T>
inline T&& show(std::string_view name, T&& value) noexcept {
inline T&&show(std::string_view name, T&&value) noexcept {
std::lock_guard<std::mutex> lock(error_mutex());
std::cerr << name << '=' << value << '\n';
return std::forward<T>(value);
}
template <class T>
inline T&& eval_and_show(std::string_view expr, T&& value) noexcept {
inline T&&eval_and_show(std::string_view expr, T&&value) noexcept {
std::lock_guard<std::mutex> lock(error_mutex());
std::cerr << expr << '=' << value << '\n';
return std::forward<T>(value);

View File

@@ -10,7 +10,7 @@ Host::Host(Simulator *const sim, NodeId id) noexcept
Node::set_status(NodeStatus::OK);
}
void Host::attach_nic(NetworkNic* nic) noexcept {
void Host::attach_nic(NetworkNic *nic) noexcept {
if (_nic && _nic != nic) {
log_error("ERROR", "Host::attach_nic called while NIC already attached");
}
@@ -18,7 +18,7 @@ void Host::attach_nic(NetworkNic* nic) noexcept {
_nic = nic;
}
void Host::detach_nic(NetworkNic* nic) noexcept {
void Host::detach_nic(NetworkNic *nic) noexcept {
if (_nic && _nic != nic) {
log_error("ERROR", "Host::detach_nic called with non-matching NIC pointer");
return;

View File

@@ -22,8 +22,8 @@ public:
}
// NIC lifecycle hooks (called by the NIC)
void attach_nic(NetworkNic* nic) noexcept;
void detach_nic(NetworkNic* nic) noexcept;
void attach_nic(NetworkNic *nic) noexcept;
void detach_nic(NetworkNic *nic) noexcept;
// Data-plane completion: a whole flow has arrived.
virtual void recv_flow(NodeId src,
@@ -32,7 +32,7 @@ public:
Bytes flow_size) = 0;
// Control/telemetry interrupt: ACK/NACK/TRIM_BACK, etc.
virtual void recv_frame(const Packet& frame) = 0;
virtual void recv_frame(const Packet &frame) = 0;
virtual void recv_mgmt_msg(std::unique_ptr<struct MgmtMsg> msg) = 0;

View File

@@ -26,7 +26,7 @@ void Node::set_status(NodeStatus s) noexcept {
}
static inline bool schedule_status_ok_after(Simulator *const sim, Time delay_ns,
Node* self) {
Node *self) {
if (!sim) {
log_error("ERROR", "Node: simulator instance not found for boot/reboot");
return false;

View File

@@ -53,7 +53,7 @@ public:
}
template <typename T>
T choose_weighted(const std::vector<std::pair<double, T>>& items) {
T choose_weighted(const std::vector<std::pair<double, T>> &items) {
return choose_weighted_impl(items.begin(), items.end());
}

View File

@@ -7,7 +7,7 @@
namespace dofs {
bool Simulator::Cmp::operator()(const Item& a, const Item& b) const noexcept {
bool Simulator::Cmp::operator()(const Item &a, const Item &b) const noexcept {
if (a.when != b.when)
return a.when > b.when;
@@ -40,7 +40,7 @@ bool Simulator::run_next() {
void Simulator::run_until(Time end_time) {
while (!_event_pq.empty()) {
const Item& top = _event_pq.top();
const Item &top = _event_pq.top();
if (end_time < top.when)
break;
@@ -67,7 +67,7 @@ void Simulator::flush_after(Time grace) noexcept {
}
std::vector<std::unique_ptr<Simulator>>& Simulator::_registry() {
std::vector<std::unique_ptr<Simulator>> &Simulator::_registry() {
static std::vector<std::unique_ptr<Simulator>> reg;
return reg;
}
@@ -77,7 +77,7 @@ std::pair<InstanceId, Simulator *> Simulator::create_simulator(InstanceId id) {
return {INVALID_INSTANCE_ID, nullptr};
}
auto& reg = _registry();
auto &reg = _registry();
if (static_cast<size_t>(id) >= reg.size()) {
reg.resize(static_cast<size_t>(id) + 1);
@@ -85,7 +85,7 @@ std::pair<InstanceId, Simulator *> Simulator::create_simulator(InstanceId id) {
if (!reg[static_cast<size_t>(id)]) {
auto sim = std::make_unique<Simulator>();
Simulator* ptr = sim.get();
Simulator *ptr = sim.get();
reg[static_cast<size_t>(id)] = std::move(sim);
return {id, ptr};
}
@@ -97,7 +97,7 @@ Simulator * Simulator::get_simulator(InstanceId id) noexcept {
if (id == INVALID_INSTANCE_ID)
return nullptr;
auto& reg = _registry();
auto &reg = _registry();
const size_t idx = static_cast<size_t>(id);
if (idx >= reg.size())
@@ -122,8 +122,8 @@ Rng const * Simulator::get_rng() const noexcept {
}
std::pair<LinkId, Link *> Simulator::create_link(
NetworkNode* a, PortId a_port,
NetworkNode* b, PortId b_port,
NetworkNode *a, PortId a_port,
NetworkNode *b, PortId b_port,
Time latency,
double bandwidth_gbps) {
@@ -143,7 +143,7 @@ std::pair<LinkId, Link *> Simulator::create_link(
latency,
bandwidth_gbps));
Link* raw = up.get();
Link *raw = up.get();
_links.push_back(std::move(up));
return {id, raw};
}

View File

@@ -40,7 +40,7 @@ private:
};
struct Cmp {
bool operator()(const Item& a, const Item& b) const noexcept;
bool operator()(const Item &a, const Item &b) const noexcept;
};
std::priority_queue<Item, std::vector<Item>, Cmp> _event_pq;
@@ -63,7 +63,7 @@ public:
Time now() const noexcept;
template <class F, class... Args>
EventId schedule_at(Time abs_time, F&& f, Args&&... args) {
EventId schedule_at(Time abs_time, F&&f, Args&&... args) {
if (_locked)
return NULL_EVENT;
@@ -81,7 +81,7 @@ public:
}
template <class F, class... Args>
EventId schedule_after(Time delay, F&& f, Args&&... args) {
EventId schedule_after(Time delay, F&&f, Args&&... args) {
return schedule_at(_now + delay, std::forward<F>(f),
std::forward<Args>(args)...);
}
@@ -91,7 +91,7 @@ public:
void run_until(Time end_time);
// ----- Termination helpers -----
// Prevent any future schedule_* calls from enqueuing events.
// Prevent any future schedule_ *calls from enqueuing events.
void lock() noexcept;
bool is_locked() const noexcept {
return _locked;
@@ -100,21 +100,21 @@ public:
void flush_after(Time grace) noexcept;
// ---------- Object management ----------
Rng* create_rng(std::uint64_t seed);
Rng* get_rng() noexcept;
Rng const* get_rng() const noexcept;
Rng *create_rng(std::uint64_t seed);
Rng *get_rng() noexcept;
Rng const *get_rng() const noexcept;
std::pair<LinkId, Link *> create_link(NetworkNode* a, PortId a_port,
NetworkNode* b, PortId b_port,
std::pair<LinkId, Link *> create_link(NetworkNode *a, PortId a_port,
NetworkNode *b, PortId b_port,
Time latency,
double bandwidth_gbps);
Link* get_link(LinkId id) noexcept;
Link const* get_link(LinkId id) const noexcept;
Link *get_link(LinkId id) noexcept;
Link const *get_link(LinkId id) const noexcept;
private:
template <class F, class... Args>
static auto make_callable(F&& f, Args&&... args) {
static auto make_callable(F&&f, Args&&... args) {
using Fn = std::decay_t<F>;
using Tup = std::tuple<std::decay_t<Args>...>;
return [fn = Fn(std::forward<F>(f)),
@@ -123,7 +123,7 @@ private:
};
}
static std::vector<std::unique_ptr<Simulator>>& _registry();
static std::vector<std::unique_ptr<Simulator>> &_registry();
};
} // namespace dofs

View File

@@ -33,7 +33,7 @@ public:
PacketGroups select_multicast_groups(PacketGroups update_groups_mask) override {
PacketGroups result = 0;
for (auto const& r : _ranges) {
for (auto const &r : _ranges) {
if (!group_present(update_groups_mask, r.update_group))
continue;
@@ -60,7 +60,7 @@ private:
}
void validate_and_build() {
for (auto const& r : _ranges) {
for (auto const &r : _ranges) {
assert(r.low_bit <= r.high_bit);
assert(r.high_bit < 128 && r.low_bit < 128);
(void)r;
@@ -68,7 +68,7 @@ private:
}
// init all cursors to 0 for determinism.
for (auto const& r : _ranges)
for (auto const &r : _ranges)
_rr_cursor[r.update_group] = 0;
}
};

View File

@@ -88,7 +88,7 @@ void Publisher::on_staging_timer() noexcept {
if (mcast_mask == 0) {
DOFS_ERROR("publisher", "policy produced empty multicast mask");
} else {
auto* n = this->nic();
auto *n = this->nic();
if (!n) {
DOFS_ERROR("publisher", "no NIC attached; dropping update");

View File

@@ -16,7 +16,7 @@ namespace dofs {
class Publisher final : public Host {
public:
Publisher(Simulator* sim,
Publisher(Simulator *sim,
NodeId id,
Time update_latency_base,
std::unique_ptr<PubBasePolicy> policy,
@@ -34,7 +34,7 @@ public:
// Host overrides (data-plane callbacks)
virtual void recv_flow(NodeId src, FlowId flow, FlowPriority prio,
Bytes flow_size) override;
virtual void recv_frame(const Packet& frame) override;
virtual void recv_frame(const Packet &frame) override;
// Telemetry
uint64_t updates_in() const noexcept {

View File

@@ -4,9 +4,9 @@
namespace dofs {
Subscriber::Subscriber(Simulator* sim,
Subscriber::Subscriber(Simulator *sim,
NodeId id,
Publisher* publisher,
Publisher *publisher,
std::unique_ptr<SubBasePolicy> policy,
Time mgmt_latency,
Time heartbeat_period) noexcept
@@ -54,7 +54,7 @@ void Subscriber::on_heartbeat_timer() noexcept {
const NodeId sid = this->id();
const NodeStatus st = NodeStatus::OK;
const Time gen = _sim->now();
Publisher* const pub = _publisher;
Publisher *const pub = _publisher;
_sim->schedule_after(_mgmt_latency, [pub, sid, st, gen]() {
pub->recv_mgmt_msg(std::make_unique<HeartbeatMsg>(sid, st, gen));
});

View File

@@ -14,9 +14,9 @@ class Publisher;
class Subscriber final : public Host {
public:
Subscriber(Simulator* sim,
Subscriber(Simulator *sim,
NodeId id,
Publisher* publisher,
Publisher *publisher,
std::unique_ptr<SubBasePolicy> policy,
Time mgmt_latency,
Time heartbeat_period) noexcept;
@@ -27,12 +27,12 @@ public:
// Host overrides (data-plane callbacks)
void recv_flow(NodeId src, FlowId flow, FlowPriority prio,
Bytes flow_size) override;
void recv_frame(const Packet& frame) override;
void recv_frame(const Packet &frame) override;
void set_status(NodeStatus s) noexcept;
// For future: swap publisher pointer
void set_publisher(Publisher* p) noexcept {
void set_publisher(Publisher *p) noexcept {
_publisher = p;
}

View File

@@ -77,7 +77,7 @@ std::optional<Link::Reservation> Link::reserve(Bytes bytes,
return std::nullopt;
}
Time& cursor = (d.value() == Dir::AtoB) ? _next_available_ab :
Time &cursor = (d.value() == Dir::AtoB) ? _next_available_ab :
_next_available_ba;
const Time now = _sim->now();
@@ -122,7 +122,7 @@ void Link::send_pkt(Packet &pkt, NodeId caller) {
rsv->finish.unsafe_sub(now) : Time(0);
const Time total_delay = to_finish + _latency_cur;
NetworkNode* target_node = (d.value() == Dir::AtoB) ? _b : _a;
NetworkNode *target_node = (d.value() == Dir::AtoB) ? _b : _a;
PortId target_ingress = (d.value() == Dir::AtoB) ? _b_port : _a_port;
_sim->schedule_after(total_delay,
@@ -142,7 +142,7 @@ void Link::schedule_delivery_after(Packet &pkt, NodeId caller, Time after) {
return;
}
NetworkNode* target_node = (d.value() == Dir::AtoB) ? _b : _a;
NetworkNode *target_node = (d.value() == Dir::AtoB) ? _b : _a;
PortId target_ingress = (d.value() == Dir::AtoB) ? _b_port : _a_port;
_sim->schedule_after(after,

View File

@@ -18,7 +18,7 @@ NetworkNic::NetworkNic(Simulator *const sim,
LBType lb_type,
Bytes cc_init_cwnd,
Bytes cc_max_cwnd,
const NicSchedulingWeights& schedw) noexcept
const NicSchedulingWeights &schedw) noexcept
: NetworkNode(sim, id, NodeType::NIC),
_buf(buf),
_port_cnt(total_ports),
@@ -63,7 +63,7 @@ NetworkNic::NetworkNic(Simulator *const sim,
break;
}
for (auto& pq : _ports) {
for (auto &pq : _ports) {
pq.b_control = _schedw.control;
pq.b_retrans = _schedw.retrans;
pq.b_mice = _schedw.mice;
@@ -71,14 +71,14 @@ NetworkNic::NetworkNic(Simulator *const sim,
}
}
void NetworkNic::attach_host(Host* host) noexcept {
void NetworkNic::attach_host(Host *host) noexcept {
_host = host;
if (_host)
_host->attach_nic(this);
}
void NetworkNic::detach_host(Host* host) noexcept {
void NetworkNic::detach_host(Host *host) noexcept {
if (_host && _host != host) {
log_error("ERROR", "NetworkNic::detach_host pointer mismatch");
return;
@@ -123,7 +123,7 @@ std::uint64_t NetworkNic::txkey(FlowId f, PacketSeq s) noexcept {
static_cast<std::uint64_t>(static_cast<std::uint16_t>(s));
}
void NetworkNic::record_tx_timestamp(const Packet& pkt) noexcept {
void NetworkNic::record_tx_timestamp(const Packet &pkt) noexcept {
if (!_sim)
return;
@@ -131,8 +131,8 @@ void NetworkNic::record_tx_timestamp(const Packet& pkt) noexcept {
_tx_sent_at[key] = _sim->now();
}
bool NetworkNic::lookup_rtt_and_erase(const Packet& ack_like, Time now,
Time& out_rtt) noexcept {
bool NetworkNic::lookup_rtt_and_erase(const Packet &ack_like, Time now,
Time &out_rtt) noexcept {
const auto key = txkey(ack_like.flow_id(), ack_like.seq());
auto it = _tx_sent_at.find(key);
@@ -350,7 +350,7 @@ Packet NetworkNic::make_data_packet(NodeId dst, PortId out_port,
return p;
}
Packet NetworkNic::make_ack_packet(const Packet& rx_data,
Packet NetworkNic::make_ack_packet(const Packet &rx_data,
PortId ingress) noexcept {
Packet ack(rx_data.dst_node(), rx_data.dst_port(),
rx_data.src_node(), rx_data.src_port(),
@@ -372,7 +372,7 @@ Packet NetworkNic::make_nack_packet(NodeId peer, FlowId flow, PacketSeq miss,
return nack;
}
Packet NetworkNic::make_trim_back_response(const Packet& trim,
Packet NetworkNic::make_trim_back_response(const Packet &trim,
PortId ingress) noexcept {
Packet tb(trim.dst_node(), trim.dst_port(),
trim.src_node(), trim.src_port(),
@@ -384,7 +384,7 @@ Packet NetworkNic::make_trim_back_response(const Packet& trim,
return tb;
}
void NetworkNic::schedule_ack(const Packet& rx_data, PortId ingress) noexcept {
void NetworkNic::schedule_ack(const Packet &rx_data, PortId ingress) noexcept {
if (!_sim)
return;
@@ -414,7 +414,7 @@ void NetworkNic::schedule_nack(NodeId peer, FlowId flow, PacketSeq missing_seq,
_telemetry.tx_nacks++;
}
void NetworkNic::schedule_trim_back_response(const Packet& trim,
void NetworkNic::schedule_trim_back_response(const Packet &trim,
PortId ingress) noexcept {
if (!_sim)
return;
@@ -497,7 +497,7 @@ void NetworkNic::enqueue_packet(PortId port, QClass cls, Packet pkt) noexcept {
return;
}
auto& pq = _ports[port];
auto &pq = _ports[port];
switch (cls) {
case QClass::CONTROL:
@@ -521,7 +521,7 @@ void NetworkNic::enqueue_packet(PortId port, QClass cls, Packet pkt) noexcept {
}
void NetworkNic::schedule_port_if_needed(PortId port) noexcept {
auto& pq = _ports[port];
auto &pq = _ports[port];
if (pq.scheduled || !_sim)
return;
@@ -532,8 +532,8 @@ void NetworkNic::schedule_port_if_needed(PortId port) noexcept {
this, port);
}
bool NetworkNic::pick_next_qclass(const PortQueues& pq,
QClass& out_cls) const noexcept {
bool NetworkNic::pick_next_qclass(const PortQueues &pq,
QClass &out_cls) const noexcept {
if (!pq.control.empty() && pq.b_control > Bytes(0)) {
out_cls = QClass::CONTROL;
return true;
@@ -558,9 +558,9 @@ bool NetworkNic::pick_next_qclass(const PortQueues& pq,
}
bool NetworkNic::try_send_one(PortId port, QClass cls) noexcept {
auto& pq = _ports[port];
auto &pq = _ports[port];
std::deque<Packet> *q = nullptr;
Bytes* budget = nullptr;
Bytes *budget = nullptr;
switch (cls) {
case QClass::CONTROL:
@@ -594,7 +594,7 @@ bool NetworkNic::try_send_one(PortId port, QClass cls) noexcept {
if (!is_ctrl && _cc) {
const Bytes next_bytes = pkt.total_size();
Bytes& out = _tx_outstanding[pkt.flow_id()];
Bytes &out = _tx_outstanding[pkt.flow_id()];
if (!_cc->is_allowed_to_send(out, next_bytes)) {
q->push_front(std::move(pkt));
@@ -625,7 +625,7 @@ bool NetworkNic::try_send_one(PortId port, QClass cls) noexcept {
}
void NetworkNic::port_drain_task(PortId port) noexcept {
auto& pq = _ports[port];
auto &pq = _ports[port];
// Attempt to send while there is any budget and any queue has packets.
// Refill budgets when all depleted or all queues empty.

View File

@@ -41,12 +41,12 @@ public:
LBType lb_type,
Bytes cc_init_cwnd,
Bytes cc_max_cwnd,
const NicSchedulingWeights& schedw) noexcept;
const NicSchedulingWeights &schedw) noexcept;
virtual void recv_pkt(Packet &pkt, PortId ingress) override;
void attach_host(Host* host) noexcept;
void detach_host(Host* host) noexcept;
void attach_host(Host *host) noexcept;
void detach_host(Host *host) noexcept;
// Host API (TX):
void send_flow(NodeId dst, Bytes size,
@@ -83,24 +83,24 @@ private:
void schedule_port_if_needed(PortId port) noexcept;
void port_drain_task(PortId port) noexcept;
bool pick_next_qclass(const PortQueues& pq, QClass& out_cls) const noexcept;
bool pick_next_qclass(const PortQueues &pq, QClass &out_cls) const noexcept;
bool try_send_one(PortId port, QClass cls) noexcept;
void enqueue_packet(PortId port, QClass cls, Packet pkt) noexcept;
void schedule_ack(const Packet& rx_data, PortId ingress) noexcept;
void schedule_ack(const Packet &rx_data, PortId ingress) noexcept;
void schedule_nack(NodeId peer, FlowId flow, PacketSeq missing_seq,
FlowPriority prio, PortId ingress) noexcept;
void schedule_trim_back_response(const Packet& trim, PortId ingress) noexcept;
void schedule_trim_back_response(const Packet &trim, PortId ingress) noexcept;
bool is_elephant(Bytes sz) const noexcept;
static inline std::uint64_t txkey(FlowId f, PacketSeq s) noexcept;
void record_tx_timestamp(const Packet& pkt) noexcept;
bool lookup_rtt_and_erase(const Packet& ack_like, Time now,
Time& out_rtt) noexcept;
void record_tx_timestamp(const Packet &pkt) noexcept;
bool lookup_rtt_and_erase(const Packet &ack_like, Time now,
Time &out_rtt) noexcept;
PortId pick_src_port_for_flow(NodeId dst) noexcept;
@@ -109,11 +109,11 @@ private:
Packet make_data_packet(NodeId dst, PortId out_port, FlowPriority prio,
FlowId fid, PacketSeq seq, Bytes payload) noexcept;
Packet make_ack_packet(const Packet& rx_data, PortId ingress) noexcept;
Packet make_ack_packet(const Packet &rx_data, PortId ingress) noexcept;
Packet make_nack_packet(NodeId peer, FlowId flow, PacketSeq miss,
FlowPriority prio,
PortId ingress) noexcept;
Packet make_trim_back_response(const Packet& trim, PortId ingress) noexcept;
Packet make_trim_back_response(const Packet &trim, PortId ingress) noexcept;
private:
Host *_host {nullptr};

View File

@@ -133,7 +133,7 @@ void NetworkSwitch::enqueue_one(Packet pkt, PortId egress,
(void)_buf->enqueue_packet(pkt, egress, prio);
}
void NetworkSwitch::build_uc_egress(const Packet& pkt,
void NetworkSwitch::build_uc_egress(const Packet &pkt,
std::vector<PortId> &out) const {
// Unicast: consult table; if multiple candidates, ECMP-pick one by entropy
std::vector<PortId> candidates =
@@ -168,7 +168,7 @@ void NetworkSwitch::build_uc_egress(const Packet& pkt,
out.push_back(candidates[idx % candidates.size()]);
}
void NetworkSwitch::build_mc_fanout(const Packet& pkt, PortId ingress,
void NetworkSwitch::build_mc_fanout(const Packet &pkt, PortId ingress,
std::vector<PortId> &fanout) const {
if (!_rt)
return;
@@ -180,7 +180,7 @@ void NetworkSwitch::build_mc_fanout(const Packet& pkt, PortId ingress,
if (!group_bit_set(mask, gid))
continue;
const auto* trees = _rt->multicast.trees_of(gid);
const auto *trees = _rt->multicast.trees_of(gid);
if (!trees || trees->empty())
continue;
@@ -201,7 +201,7 @@ void NetworkSwitch::build_mc_fanout(const Packet& pkt, PortId ingress,
chosen_idx %= k;
}
const McTree& t = (*trees)[chosen_idx];
const McTree &t = (*trees)[chosen_idx];
if (t.parent_port.has_value() && ingress != t.parent_port.value()) {
// Skip this group's replication from the wrong direction

View File

@@ -51,11 +51,11 @@ private:
// Build multicast fanout: pick exactly one tree per active group bit,
// optionally enforcing RPF via parent_port, and union child ports.
void build_mc_fanout(const Packet& pkt, PortId ingress,
void build_mc_fanout(const Packet &pkt, PortId ingress,
std::vector<PortId> &fanout) const;
// Build unicast egress list: if multiple candidates, ECMP-pick one via hash_ecmp.
void build_uc_egress(const Packet& pkt, std::vector<PortId> &out) const;
void build_uc_egress(const Packet &pkt, std::vector<PortId> &out) const;
static void merge_sorted_unique(std::vector<PortId> &base,
const std::vector<PortId> &add);

View File

@@ -4,7 +4,7 @@ add_library(dofs_nic STATIC)
target_include_directories(dofs_nic
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src> # "network/...", "core/..."
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/network> # ** enables "nic/..." **
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/network> # **enables "nic/..." **
$<INSTALL_INTERFACE:include>
)
@@ -44,7 +44,7 @@ add_library(dofs_nic_headers_tooling STATIC ${NIC_STUBS})
target_include_directories(dofs_nic_headers_tooling
PRIVATE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/network> # ** not src/network/nic **
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/network> # **not src/network/nic **
)
target_link_libraries(dofs_nic_headers_tooling PRIVATE dofs_nic dofs_network dofs_core)

View File

@@ -21,7 +21,7 @@ bool CongestionControl::is_allowed_to_send(Bytes bytes_outstanding,
DCQCN::DCQCN(Bytes init_cwnd, Bytes max_cwnd) noexcept
: CongestionControl(init_cwnd, max_cwnd) {}
void DCQCN::update(const Packet& pkt, Time rtt) noexcept {
void DCQCN::update(const Packet &pkt, Time rtt) noexcept {
// Extremely simple placeholder logic:
// - If ECN marked or TRIM_BACK/NACK, cut cwnd multiplicatively.
// - If ACK of data (no ECN), increase cwnd additively (slowly).
@@ -67,7 +67,7 @@ void DCQCN::update(const Packet& pkt, Time rtt) noexcept {
NSCC::NSCC(Bytes init_cwnd, Bytes max_cwnd) noexcept
: CongestionControl(init_cwnd, max_cwnd) {}
void NSCC::update(const Packet& pkt, Time rtt) noexcept {
void NSCC::update(const Packet &pkt, Time rtt) noexcept {
if (pkt.protocol() == PacketProtocol::HEADER_TRIM_BACK ||
pkt.protocol() == PacketProtocol::NACK ||
pkt.is_ecn()) {

View File

@@ -13,7 +13,7 @@ public:
explicit CongestionControl(Bytes init_cwnd, Bytes max_cwnd) noexcept;
virtual ~CongestionControl() = default;
virtual void update(const Packet& pkt, Time rtt) noexcept = 0;
virtual void update(const Packet &pkt, Time rtt) noexcept = 0;
virtual bool is_allowed_to_send(Bytes bytes_outstanding,
Bytes next_bytes) const noexcept;
@@ -33,13 +33,13 @@ protected:
class DCQCN final : public CongestionControl {
public:
explicit DCQCN(Bytes init_cwnd, Bytes max_cwnd) noexcept;
virtual void update(const Packet& pkt, Time rtt) noexcept override;
virtual void update(const Packet &pkt, Time rtt) noexcept override;
};
class NSCC final : public CongestionControl {
public:
explicit NSCC(Bytes init_cwnd, Bytes max_cwnd) noexcept;
virtual void update(const Packet& pkt, Time rtt) noexcept override;
virtual void update(const Packet &pkt, Time rtt) noexcept override;
};
} // namespace dofs

View File

@@ -2,11 +2,11 @@
namespace dofs {
void LBRandomPacketSpraying::update(const Packet& pkt) noexcept {
void LBRandomPacketSpraying::update(const Packet &pkt) noexcept {
(void)pkt;
}
uint16_t LBRandomPacketSpraying::get_entropy(const Packet& context) noexcept {
uint16_t LBRandomPacketSpraying::get_entropy(const Packet &context) noexcept {
(void)context;
if (!_rng)

View File

@@ -14,10 +14,10 @@ public:
explicit LoadBalance(Rng *const rng) noexcept : _rng(rng) {}
virtual ~LoadBalance() = default;
virtual void update(const Packet& pkt) noexcept = 0;
virtual void update(const Packet &pkt) noexcept = 0;
// Produce a 16-bit entropy value for the next packet.
virtual uint16_t get_entropy(const Packet& context) noexcept = 0;
virtual uint16_t get_entropy(const Packet &context) noexcept = 0;
protected:
Rng *const _rng;
@@ -27,8 +27,8 @@ protected:
class LBRandomPacketSpraying final : public LoadBalance {
public:
explicit LBRandomPacketSpraying(Rng *const rng) noexcept : LoadBalance(rng) {}
virtual void update(const Packet& pkt) noexcept override;
virtual uint16_t get_entropy(const Packet& context) noexcept override;
virtual void update(const Packet &pkt) noexcept override;
virtual uint16_t get_entropy(const Packet &context) noexcept override;
};
} // namespace dofs

View File

@@ -4,7 +4,7 @@ add_library(dofs_switch STATIC)
target_include_directories(dofs_switch
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src> # "network/...", "core/..."
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/network> # ** enables "switch/..." **
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/network> # **enables "switch/..." **
$<INSTALL_INTERFACE:include>
)
@@ -57,7 +57,7 @@ add_library(dofs_switch_headers_tooling STATIC ${SWITCH_STUBS})
target_include_directories(dofs_switch_headers_tooling
PRIVATE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/network> # ** not src/network/switch **
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/network> # **not src/network/switch **
)
target_link_libraries(dofs_switch_headers_tooling PRIVATE dofs_switch dofs_network dofs_core)

View File

@@ -2,8 +2,8 @@
namespace dofs {
DedicatedBuffer::DedicatedBuffer(Simulator* const sim,
NetworkSwitch* const owner,
DedicatedBuffer::DedicatedBuffer(Simulator *const sim,
NetworkSwitch *const owner,
Bytes total_bytes,
uint16_t ports)
: SwitchBuffer(sim, owner, SwitchBufferType::DEDICATED, total_bytes, ports),
@@ -38,7 +38,7 @@ void DedicatedBuffer::on_dequeue_commit(PortId port, Bytes sz) {
_per_port_bytes[port] -= sz;
}
bool DedicatedBuffer::enqueue_packet(const Packet& pkt, PortId egress,
bool DedicatedBuffer::enqueue_packet(const Packet &pkt, PortId egress,
FlowPriority prio) {
if (egress >= _port_cnt)
return false;
@@ -49,7 +49,7 @@ bool DedicatedBuffer::enqueue_packet(const Packet& pkt, PortId egress,
return false;
Queued q{pkt, egress, prio, _sim->now(), sz};
auto& qset = queues_for(egress);
auto &qset = queues_for(egress);
qset[to_idx(prio)].push_back(std::move(q));
on_enqueue_commit(egress, sz);

View File

@@ -9,12 +9,12 @@ namespace dofs {
// Each port has a hard cap; no borrowing.
class DedicatedBuffer : public SwitchBuffer {
public:
DedicatedBuffer(Simulator* const sim,
NetworkSwitch* const owner,
DedicatedBuffer(Simulator *const sim,
NetworkSwitch *const owner,
Bytes total_bytes,
uint16_t ports);
bool enqueue_packet(const Packet& pkt, PortId egress,
bool enqueue_packet(const Packet &pkt, PortId egress,
FlowPriority prio) override;
bool drain_one(PortId port) override;

View File

@@ -6,7 +6,7 @@
namespace dofs {
Packet &DedicatedREDEngine::process_packet(Packet &pkt,
SwitchBuffer* buf) noexcept {
SwitchBuffer *buf) noexcept {
if (!buf)
return pkt;

View File

@@ -15,7 +15,7 @@ public:
// Decide ECN mark / header-trim for a packet about to enter 'buf'.
// Returns the same packet reference, possibly modified in-place.
virtual Packet &process_packet(Packet &pkt, SwitchBuffer* buf) noexcept = 0;
virtual Packet &process_packet(Packet &pkt, SwitchBuffer *buf) noexcept = 0;
protected:
// Helpers for derived engines

View File

@@ -16,7 +16,7 @@ bool MulticastTable::add_tree(std::size_t group_id, uint16_t tree_id) {
if (group_id >= _groups.size())
return false;
auto& trees = _groups[group_id];
auto &trees = _groups[group_id];
auto it = std::find_if(trees.begin(), trees.end(),
[&](const McTree & t) {
return t.tree_id == tree_id;
@@ -39,7 +39,7 @@ bool MulticastTable::delete_tree(std::size_t group_id, uint16_t tree_id) {
if (group_id >= _groups.size())
return false;
auto& trees = _groups[group_id];
auto &trees = _groups[group_id];
auto it = std::find_if(trees.begin(), trees.end(),
[&](const McTree & t) {
return t.tree_id == tree_id;
@@ -57,7 +57,7 @@ bool MulticastTable::add_child_port(std::size_t group_id, uint16_t tree_id,
if (group_id >= _groups.size())
return false;
auto& trees = _groups[group_id];
auto &trees = _groups[group_id];
auto it = std::find_if(trees.begin(), trees.end(),
[&](const McTree & t) {
return t.tree_id == tree_id;
@@ -74,7 +74,7 @@ bool MulticastTable::delete_child_port(std::size_t group_id, uint16_t tree_id,
if (group_id >= _groups.size())
return false;
auto& trees = _groups[group_id];
auto &trees = _groups[group_id];
auto it = std::find_if(trees.begin(), trees.end(),
[&](const McTree & t) {
return t.tree_id == tree_id;
@@ -91,7 +91,7 @@ bool MulticastTable::set_parent(std::size_t group_id, uint16_t tree_id,
if (group_id >= _groups.size())
return false;
auto& trees = _groups[group_id];
auto &trees = _groups[group_id];
auto it = std::find_if(trees.begin(), trees.end(),
[&](const McTree & t) {
return t.tree_id == tree_id;
@@ -109,7 +109,7 @@ bool MulticastTable::set_weight(std::size_t group_id, uint16_t tree_id,
if (group_id >= _groups.size())
return false;
auto& trees = _groups[group_id];
auto &trees = _groups[group_id];
auto it = std::find_if(trees.begin(), trees.end(),
[&](const McTree & t) {
return t.tree_id == tree_id;
@@ -127,7 +127,7 @@ bool MulticastTable::set_epoch(std::size_t group_id, uint16_t tree_id,
if (group_id >= _groups.size())
return false;
auto& trees = _groups[group_id];
auto &trees = _groups[group_id];
auto it = std::find_if(trees.begin(), trees.end(),
[&](const McTree & t) {
return t.tree_id == tree_id;
@@ -158,7 +158,7 @@ std::vector<PortId> MulticastTable::get_port_list(PacketGroups groups) const {
if (!bit_set)
continue;
const auto& trees = _groups[gid];
const auto &trees = _groups[gid];
auto it = std::find_if(trees.begin(), trees.end(),
[](const McTree & t) {
return t.tree_id == 0;

View File

@@ -2,8 +2,8 @@
namespace dofs {
SharedBuffer::SharedBuffer(Simulator* const sim,
NetworkSwitch* const owner,
SharedBuffer::SharedBuffer(Simulator *const sim,
NetworkSwitch *const owner,
Bytes total_bytes,
uint16_t ports)
: SwitchBuffer(sim, owner, SwitchBufferType::SHARED, total_bytes, ports),
@@ -36,7 +36,7 @@ void SharedBuffer::on_dequeue_commit(PortId port, Bytes sz) {
_per_port_bytes[port] -= sz;
}
bool SharedBuffer::enqueue_packet(const Packet& pkt, PortId egress,
bool SharedBuffer::enqueue_packet(const Packet &pkt, PortId egress,
FlowPriority prio) {
if (egress >= _port_cnt)
return false;
@@ -47,7 +47,7 @@ bool SharedBuffer::enqueue_packet(const Packet& pkt, PortId egress,
return false;
Queued q{pkt, egress, prio, _sim->now(), sz};
auto& qset = queues_for(egress);
auto &qset = queues_for(egress);
qset[to_idx(prio)].push_back(std::move(q));
on_enqueue_commit(egress, sz);

View File

@@ -9,12 +9,12 @@ namespace dofs {
// 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,
SharedBuffer(Simulator *const sim,
NetworkSwitch *const owner,
Bytes total_bytes,
uint16_t ports);
virtual bool enqueue_packet(const Packet& pkt, PortId egress,
virtual bool enqueue_packet(const Packet &pkt, PortId egress,
FlowPriority prio) override;
virtual bool drain_one(PortId port) override;

View File

@@ -9,8 +9,8 @@
namespace dofs {
SwitchBuffer::SwitchBuffer(Simulator* const sim,
NetworkSwitch* const owner,
SwitchBuffer::SwitchBuffer(Simulator *const sim,
NetworkSwitch *const owner,
SwitchBufferType t,
Bytes total_bytes,
uint16_t ports)
@@ -122,13 +122,13 @@ Bytes SwitchBuffer::queued_bytes_port(PortId p) const noexcept {
return port_buffered(p);
}
std::optional<Time> SwitchBuffer::try_reserve_and_send(PortId port, Queued& q) {
std::optional<Time> SwitchBuffer::try_reserve_and_send(PortId port, Queued &q) {
if (port >= _egress_links.size() || _egress_links[port] == nullptr) {
log_error("ERROR", "SwitchBuffer: egress link missing on port");
return std::nullopt;
}
Link* link = _egress_links[port];
Link *link = _egress_links[port];
auto r = link->reserve(q.size_bytes, _owner->id());
@@ -155,7 +155,7 @@ void SwitchBuffer::schedule_drain_if_needed(PortId port) {
if (queued_bytes_port(port) == Bytes(0))
return;
Link* link = _egress_links[port];
Link *link = _egress_links[port];
if (!link)
return;
@@ -180,7 +180,7 @@ void SwitchBuffer::drain_once(PortId port) {
// No progress: either queues empty or link not reservable now.
// If queues are still non-empty, retry later at next-available.
auto& qs = queues_for(port);
auto &qs = queues_for(port);
bool any = !qs[PRI_CTRL].empty() || !qs[PRI_MICE].empty() ||
!qs[PRI_ELE].empty();
@@ -193,8 +193,8 @@ bool SwitchBuffer::drain_one_common(PortId port) {
if (port >= _port_cnt)
return false;
auto& queues = queues_for(port);
auto& sched = _sched[port];
auto &queues = queues_for(port);
auto &sched = _sched[port];
auto head_size = [&](int pri) -> Bytes {
if (queues[pri].empty())
@@ -212,7 +212,7 @@ bool SwitchBuffer::drain_one_common(PortId port) {
Bytes sz = head_size(pri);
if (sz > Bytes(0) && sched.deficit_bytes[pri] >= int64_t(sz)) {
auto& q = queues[pri].front();
auto &q = queues[pri].front();
auto finish_opt = try_reserve_and_send(port, q);
if (finish_opt.has_value()) {
@@ -221,7 +221,7 @@ bool SwitchBuffer::drain_one_common(PortId port) {
on_dequeue_commit(port, sz);
sched.next_pick = (pri + 1) % PRI_COUNT;
Link* link = _egress_links[port];
Link *link = _egress_links[port];
const Time na = link->next_available(_owner->id());
const Time now = _sim->now();
const Time delay = (na > now) ? na.unsafe_sub(now) : Time(0);

View File

@@ -32,9 +32,9 @@ public:
virtual ~SwitchBuffer() = default;
// --- API: enqueue & drain ---
// NOTE: ECN/drop decisions are expected to be done *before* enqueue;
// NOTE: ECN/drop decisions are expected to be done *before *enqueue;
// we still guard and return false on capacity violations.
virtual bool enqueue_packet(const Packet& pkt,
virtual bool enqueue_packet(const Packet &pkt,
PortId egress,
FlowPriority prio) = 0;
@@ -68,8 +68,8 @@ public:
void set_egress_links(const std::vector<Link*> &links);
protected:
SwitchBuffer(Simulator* const sim,
NetworkSwitch* const owner,
SwitchBuffer(Simulator *const sim,
NetworkSwitch *const owner,
SwitchBufferType t,
Bytes total_bytes,
uint16_t ports);

View File

@@ -16,7 +16,7 @@ std::vector<PortId> UnicastTable::get_port_list(NodeId dst_node,
bool UnicastTable::add_entry(NodeId dst_node, PortId dst_port,
PortId out_port) {
const IPv4Addr k = ipv4(dst_node, dst_port);
auto& vec = _table[k];
auto &vec = _table[k];
return insert_sorted_unique(vec, out_port);
}