@@ -70,35 +70,39 @@ class FanoutPktMgr {
7070 return instance_;
7171 }
7272
73- inline void register_thread (std::thread::id thread_id,
74- const std::function<void (const bm::Packet *)> &buffer_push_fn) {
75- BMLOG_DEBUG (" Registering thread {}" , thread_id);
76- fanout_ctx_map.emplace (thread_id, FanoutCtx (buffer_push_fn));
77- }
78- inline SelectorIface* get_grp_selector () {
79- return grp_selector;
80- }
81-
8273 FanoutCtx& get_fanout_ctx ();
8374 void set_ctx (MatchTableIndirect *table, const Packet &pkt,
8475 ActionProfile *action_profile, bool hit);
8576 void reset_ctx ();
8677 void replicate_for_entries (const std::vector<const ActionEntry*> &entries);
8778
79+ // PI overwrite selector specified during P4Object init,
80+ // so we need to set the selector in switch start_and_return_
81+ void set_grp_selector () {
82+ for (const auto &ap : act_profs) {
83+ ap->set_group_selector (grp_selector);
84+ }
85+ }
86+ inline void register_thread (std::thread::id thread_id,
87+ const std::function<void (const bm::Packet *)> &buffer_push_fn) {
88+ BMLOG_DEBUG (" Registering thread {}" , thread_id);
89+ fanout_ctx_map.emplace (thread_id, FanoutCtx (buffer_push_fn));
90+ }
91+
92+ // TODO(Hao): deduplicate packets fanout, optional
8893#ifdef BM_PKT_FANOUT_ON
8994 static constexpr bool pkt_fanout_on = true ;
9095#else
9196 static constexpr bool pkt_fanout_on = false ;
9297#endif
9398 std::mutex fanout_pkt_mutex;
94- // TODO(Hao): deduplicate packets fanout, optional
95-
96-
99+ std::vector<ActionProfile*> act_profs;
100+
97101 private:
98102 FanoutPktMgr () = default ;
99103 std::unordered_map<std::thread::id, FanoutCtx> fanout_ctx_map;
100- FanoutPktSelection fanout_selection;
101- SelectorIface* grp_selector{&fanout_selection };
104+ std::shared_ptr<SelectorIface>
105+ grp_selector{std::make_shared<FanoutPktSelection>() };
102106};
103107
104108} // namespace bm
0 commit comments