Skip to content

Commit 875f4d8

Browse files
committed
format
Signed-off-by: Hoooao <hao021014@163.com>
1 parent 7c7c84c commit 875f4d8

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

include/bm/bm_sim/action_profile.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ class ActionProfile : public NamedP4Object {
297297

298298
bool group_is_empty(grp_hdl_t grp) const;
299299

300+
bool is_selector_fanout_enabled() const {
301+
return selector_fanout_enabled;
302+
}
303+
300304
const ActionEntry &lookup(const Packet &pkt,
301305
const IndirectIndex &index) const;
302306

@@ -313,6 +317,7 @@ class ActionProfile : public NamedP4Object {
313317
std::shared_ptr<GroupSelectionIface> grp_selector_{nullptr};
314318
GroupSelectionIface *grp_selector{&grp_mgr};
315319
std::unique_ptr<Calculation> hash{nullptr};
320+
bool selector_fanout_enabled{false};
316321
};
317322

318323
} // namespace bm

include/bm/bm_sim/fanout_pkt_mgr.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-present Contributors to the P4 Project
1+
/* Copyright 2025-present Contributors to the P4 Project
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -15,8 +15,9 @@
1515
#ifndef BM_BM_SIM_FANOUT_PKT_MGR_H_
1616
#define BM_BM_SIM_FANOUT_PKT_MGR_H_
1717

18-
#include <vector>
18+
#include <memory>
1919
#include <unordered_map>
20+
#include <vector>
2021
#include "logger.h"
2122
#include "packet.h"
2223
#include "match_tables.h"
@@ -35,7 +36,8 @@ struct FanoutCtx {
3536
MatchTableIndirect *cur_table{nullptr};
3637
std::function<void(const bm::Packet *)> buffer_push_fn;
3738

38-
FanoutCtx(const std::function<void(const bm::Packet *)> &buffer_push_fn)
39+
explicit FanoutCtx(
40+
const std::function<void(const bm::Packet *)> &buffer_push_fn)
3941
: buffer_push_fn(buffer_push_fn) { }
4042
};
4143

@@ -97,12 +99,12 @@ class FanoutPktMgr {
9799
#endif
98100
std::mutex fanout_pkt_mutex;
99101
std::vector<ActionProfile*> act_profs;
100-
102+
101103
private:
102104
FanoutPktMgr() = default;
103105
std::unordered_map<std::thread::id, FanoutCtx> fanout_ctx_map;
104-
std::shared_ptr<SelectorIface>
105-
grp_selector{std::make_shared<FanoutPktSelection>()};
106+
std::shared_ptr<SelectorIface>
107+
grp_selector{std::make_shared<FanoutPktSelection>()};
106108
};
107109

108110
} // namespace bm

src/bm_sim/P4Objects.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2509,7 +2509,7 @@ P4Objects::check_hash(const std::string &name) const {
25092509
bool P4Objects::is_selector_fanout(const Json::Value &cfg_selector) const {
25102510
bool is_fanout = cfg_selector.isMember("algo") &&
25112511
cfg_selector["algo"].asString() == "selector_fanout";
2512-
if(is_fanout && !FanoutPktMgr::pkt_fanout_on){
2512+
if (is_fanout && !FanoutPktMgr::pkt_fanout_on) {
25132513
throw std::runtime_error("Selector fanout is not enabled, but"
25142514
" found selector_fanout mode used");
25152515
}

src/bm_sim/action_profile.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,4 +643,8 @@ ActionProfile::choose_from_group(grp_hdl_t grp, const Packet &pkt) const {
643643
return grp_selector->get_from_hash(grp, h);
644644
}
645645

646+
void ActionProfile::set_selector_fanout() {
647+
selector_fanout_enabled = true;
648+
}
649+
646650
} // namespace bm

src/bm_sim/match_tables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ MatchTableIndirect::lookup(const Packet &pkt,
722722
FanoutPktMgr::instance().set_ctx(this, pkt, action_profile, *hit);
723723
}
724724
}
725-
725+
726726
const auto &entry = action_profile->lookup(pkt, index);
727727
// Unfortunately this has to be done at this stage and cannot be done when
728728
// inserting a member because for 2 match tables sharing the same action

targets/simple_switch/simple_switch.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ SimpleSwitch::start_and_return_() {
289289
BMLOG_DEBUG_PKT(*pkt,
290290
"SELECTOR_FANOUT packet pushed to ingress_buffer");
291291
});
292-
292+
293293
threads_.push_back(std::move(ingress_thread));
294294
for (size_t i = 0; i < nb_egress_threads; i++) {
295295
auto egress_thread = std::thread(&SimpleSwitch::egress_thread, this, i);
@@ -298,7 +298,7 @@ SimpleSwitch::start_and_return_() {
298298
egress_thread.get_id(), [&](const bm::Packet *pkt) {
299299
this->egress_buffers.push_front(i, 0,
300300
std::unique_ptr<bm::Packet>(const_cast<bm::Packet *>(pkt)));
301-
BMLOG_DEBUG_PKT(*pkt,
301+
BMLOG_DEBUG_PKT(*pkt,
302302
"SELECTOR_FANOUT packet pushed to egress_buffer");
303303
});
304304

@@ -696,7 +696,7 @@ SimpleSwitch::egress_thread(size_t worker_id) {
696696

697697
phv = packet->get_phv();
698698
Field &f_egress_spec = phv->get_field("standard_metadata.egress_spec");
699-
699+
700700
if (packet->has_next_node()) {
701701
egress_mau->apply_from_next_node(packet.get());
702702
} else {

0 commit comments

Comments
 (0)